smarter breaks in toc columns closes #2

This commit is contained in:
tux 2023-08-09 16:39:17 +02:00
parent e2dc938c02
commit fbf273dae9

View File

@ -19,13 +19,21 @@
(map (lambda (foo) (map (lambda (foo)
(make-general-align-markup Y UP (make-override-markup '(baseline-skip . 1) (make-column-markup (make-general-align-markup Y UP (make-override-markup '(baseline-skip . 1) (make-column-markup
(let add-to-col ((lines restlines) (height-left height)) (let add-to-col ((lines restlines) (height-left height))
(let* ((finished (null? lines))
(linestencil (if (not finished) (interpret-markup layout (cons (list (cons 'line-width line-width) (cons 'baseline-skip 1)) props) (markup #:center-align (car lines)))))
(calc-height (- height-left (if finished 0 (interval-length (ly:stencil-extent linestencil Y))))))
(set! restlines lines) (set! restlines lines)
(if (or (< calc-height 0) (null? lines)) (if (null? lines)
(list) '()
(cons (markup #:stencil linestencil) (add-to-col (cdr lines) calc-height))))))))) (let* ((line-to-stencil (lambda (line) (interpret-markup layout (cons (list (cons 'line-width line-width) (cons 'baseline-skip 1)) props) (markup line))))
(stencil-height (lambda (stencil) (interval-length (ly:stencil-extent stencil Y))))
(linestencil (line-to-stencil (car lines)))
(calc-height (- height-left (stencil-height linestencil)))
(calc-width (interval-length (ly:stencil-extent linestencil X)))
(is-less-than-half-line-width (< calc-width (/ line-width 2.0)))
(next-line-height (if (null? (cdr lines)) 0 (stencil-height (line-to-stencil (cadr lines)))))
(no-space-for-next-line (and is-less-than-half-line-width (< (- calc-height next-line-height) 0)))
)
(if (or (< calc-height 0) no-space-for-next-line)
'()
(cons (markup #:stencil linestencil) (add-to-col (cdr lines) calc-height))))))))))
(make-list cols)))) (make-list cols))))
(if (null? restlines) (if (null? restlines)
(list) (list)
@ -182,8 +190,8 @@
indexItemMarkup = \markup \with-link-symbol-ref #'index:label { indexItemMarkup = \markup \with-link-symbol-ref #'index:label {
\index-item-with-pattern \index-item-with-pattern
} }
indexSectionMarkup = \markup \override #'(baseline-skip . 1.5) \column { indexSectionMarkup = \markup \override #'(baseline-skip . 1.5) \left-column {
\fill-line { \sans \bold \fontsize #3 \fromproperty #'index:text \null } \sans \bold \fontsize #3 \fromproperty #'index:text
\null \null
} }
indexCategoryMarkup = \markup \override #'(baseline-skip . 1.5) \column { indexCategoryMarkup = \markup \override #'(baseline-skip . 1.5) \column {