mirror of https://codeberg.org/cage/tinmop/
- prevented crash when suggestion windows are shown
when the width of the terminal was too thin paginating the suggestions failed.
This commit is contained in:
parent
638f970ddf
commit
2c6497a6f0
|
@ -77,10 +77,23 @@
|
|||
(multiple-value-bind (candidates common-prefix underline-char-indices)
|
||||
(funcall complete:*complete-function* hint)
|
||||
(when candidates
|
||||
(let* ((batches (text-utils:box-fit-multiple-column candidates
|
||||
(- (win-width object) 2)
|
||||
(- (win-height object)
|
||||
+box-height-diff+)))
|
||||
(let* ((max-string-size (max 1 (floor (/ (win-width-no-border object) 2.5))))
|
||||
(truncate-fn (lambda (batch)
|
||||
(mapcar (lambda (a)
|
||||
(safe-subseq a
|
||||
0
|
||||
max-string-size))
|
||||
batch)))
|
||||
(batches (handler-bind ((conditions:out-of-bounds
|
||||
(lambda (e)
|
||||
(declare (ignore e))
|
||||
(invoke-restart 'truncate))))
|
||||
(text-utils:box-fit-multiple-column candidates
|
||||
(- (win-width object) 2)
|
||||
(- (win-height object)
|
||||
+box-height-diff+)
|
||||
:truncate-restart-fn
|
||||
truncate-fn)))
|
||||
(padding-size (- (length candidates)
|
||||
(length underline-char-indices)))
|
||||
(padding (when (> padding-size 0)
|
||||
|
@ -119,18 +132,18 @@
|
|||
for row in column
|
||||
for indices-row-underlined in column-indices
|
||||
with row-count = 1 do
|
||||
(let ((text (if (and (= row-count (1+ selected-item-row-index))
|
||||
(= column-count selected-item-column-index))
|
||||
(make-tui-string row
|
||||
:fgcolor foreground-selected-item
|
||||
:bgcolor background-selected-item)
|
||||
(make-tui-string row))))
|
||||
(print-text object
|
||||
(apply-attributes text
|
||||
indices-row-underlined
|
||||
matched-attributes)
|
||||
column-offset
|
||||
row-count))
|
||||
(let* ((text (if (and (= row-count (1+ selected-item-row-index))
|
||||
(= column-count selected-item-column-index))
|
||||
(make-tui-string row
|
||||
:fgcolor foreground-selected-item
|
||||
:bgcolor background-selected-item)
|
||||
(make-tui-string row)))
|
||||
(tui-text (handler-case
|
||||
(apply-attributes text
|
||||
indices-row-underlined
|
||||
matched-attributes)
|
||||
(error () text))))
|
||||
(print-text object tui-text column-offset row-count))
|
||||
(incf row-count))
|
||||
(incf column-offset column-size)))
|
||||
(draw-pagination-info object)))
|
||||
|
|
|
@ -101,10 +101,14 @@
|
|||
:line-char render-vertical-line-value
|
||||
:last-child-char render-leaf-value
|
||||
:print-data t))
|
||||
(batches (text-utils:box-fit-multiple-column-annotated tree-lines
|
||||
(- (win-width window) 2)
|
||||
(- (win-height window)
|
||||
+box-height-diff+))))
|
||||
(batches (handler-bind ((conditions:out-of-bounds
|
||||
(lambda (e)
|
||||
(declare (ignore e))
|
||||
(invoke-restart 'truncate))))
|
||||
(text-utils:box-fit-multiple-column-annotated tree-lines
|
||||
(- (win-width window) 2)
|
||||
(- (win-height window)
|
||||
+box-height-diff+)))))
|
||||
(with-accessors ((tree-color-map tree-color-map)) window
|
||||
(let ((colorized-batches (loop for batch in batches collect
|
||||
(loop for column in batch collect
|
||||
|
|
|
@ -523,7 +523,15 @@ lines fitted in the box (nil in this case).
|
|||
lines-length)
|
||||
rest-lines-index)))))
|
||||
|
||||
(defun box-fit-multiple-column (lines box-width box-height &key (spaces-between 1))
|
||||
(defun box-fit-multiple-column (lines box-width box-height
|
||||
&key
|
||||
(spaces-between 1)
|
||||
(truncate-restart-fn (lambda (batch)
|
||||
(mapcar (lambda (a)
|
||||
(subseq a
|
||||
0
|
||||
(- box-width spaces-between)))
|
||||
batch))))
|
||||
"Given 'lines' as list of strings this procedure will fits them in a
|
||||
box of width and height passed as parameters ('box-width' and 'box-height').
|
||||
|
||||
|
@ -556,6 +564,7 @@ printed in the box column by column; in the example above the results are:
|
|||
(multiple-value-bind (columns rest-index)
|
||||
(box-fit-as-much-lines-columns lines box-width
|
||||
box-height
|
||||
:truncate-restart-fn truncate-restart-fn
|
||||
:spaces-between spaces-between
|
||||
:pad-right-fn
|
||||
(lambda (a max-width)
|
||||
|
|
Loading…
Reference in New Issue