1
0
Fork 0

- fixed adjusting strategy functions when drawing gemini text.

This commit is contained in:
cage 2021-10-08 11:37:53 +02:00
parent c924e8f636
commit 9568b88e8d
4 changed files with 13 additions and 21 deletions

View File

@ -229,22 +229,18 @@
(when (rows window) (when (rows window)
(select-first-row window))) (select-first-row window)))
(defun adjust-rows-noop (window)
window)
(defun adjust-rows-select-last (window) (defun adjust-rows-select-last (window)
(with-accessors ((rows rows)) window (with-accessors ((rows rows)) window
(when rows (when rows
(let ((height (win-height-no-border window))) (let ((height (win-height-no-border window)))
(when (not (< (rows-length window) height)) (when (>= (rows-length window) height)
(select-row window (- (rows-length window) (select-row window (- (rows-length window)
height)))))) height))))))
window) window)
(defmethod adjust-selected-rows ((object row-oriented-widget) (strategy function))
(with-accessors ((row-selected-index row-selected-index)) object
(when (< row-selected-index
(rows-length object))
(funcall strategy object)))
object)
(defmethod selected-row ((object row-oriented-widget)) (defmethod selected-row ((object row-oriented-widget))
"Return the current selected row" "Return the current selected row"
(with-accessors ((rows rows) (with-accessors ((rows rows)

View File

@ -33,7 +33,7 @@
:initarg :metadata :initarg :metadata
:accessor metadata) :accessor metadata)
(adjust-rows-strategy (adjust-rows-strategy
:initform #'adjust-rows-select-first :initform #'adjust-rows-noop
:initarg :adjust-rows-strategy :initarg :adjust-rows-strategy
:accessor adjust-rows-strategy) :accessor adjust-rows-strategy)
(text-starting-column (text-starting-column

View File

@ -1935,6 +1935,7 @@
:unselect-all :unselect-all
:select-row :select-row
:select-first-row :select-first-row
:adjust-rows-noop
:adjust-rows-select-first :adjust-rows-select-first
:adjust-rows-select-last :adjust-rows-select-last
:adjust-selected-rows :adjust-selected-rows
@ -2074,7 +2075,6 @@
:row-get-original-object :row-get-original-object
:viewport-width :viewport-width
:draw-downloading-animation :draw-downloading-animation
:adjust-selected-rows
:visible-rows :visible-rows
:row-vertical-space-p :row-vertical-space-p
:row-preformatted-p :row-preformatted-p

View File

@ -1224,12 +1224,13 @@
(progn (progn
(line-oriented-window:append-new-rows win new-rows) (line-oriented-window:append-new-rows win new-rows)
(gemini-viewer:append-metadata-link window-metadata links) (gemini-viewer:append-metadata-link window-metadata links)
(gemini-viewer:append-metadata-source window-metadata source)) (gemini-viewer:append-metadata-source window-metadata source)
(funcall (message-window:adjust-rows-strategy win) win))
(progn (progn
(setf (gemini-viewer:gemini-metadata-source-file window-metadata) source) (setf (gemini-viewer:gemini-metadata-source-file window-metadata) source)
(setf (gemini-viewer:gemini-metadata-links window-metadata) links) (setf (gemini-viewer:gemini-metadata-links window-metadata) links)
(funcall (message-window:adjust-rows-strategy win) (funcall (message-window:adjust-rows-strategy win) win)
win)
(line-oriented-window:update-all-rows win new-rows))))))) (line-oriented-window:update-all-rows win new-rows)))))))
(defmethod process-event ((object gemini-got-line-event)) (defmethod process-event ((object gemini-got-line-event))
@ -1251,14 +1252,9 @@
(not (skip-rendering-p object)) (not (skip-rendering-p object))
(message-window:display-gemini-text-p win)) (message-window:display-gemini-text-p win))
(refresh-gemini-message-window links source ir-line append-text) (refresh-gemini-message-window links source ir-line append-text)
(multiple-value-bind (x start length)
(message-window:visible-rows win)
(declare (ignore x))
(if (or (not append-text)
(< (+ start length)
(windows:win-height-no-border win)))
(windows:draw win) (windows:draw win)
(message-window:draw-downloading-animation win)))))))) (when append-text
(message-window:draw-downloading-animation win)))))))
(defclass gemini-abort-downloading-event (program-event) ()) (defclass gemini-abort-downloading-event (program-event) ())