Speed up displaying lines when scrolling up

This commit is contained in:
John Lorentzson 2025-07-31 12:12:25 +02:00
parent 4415bb3d55
commit 502451af8b

View file

@ -406,11 +406,19 @@ serial connection the editor normally runs under.")
(cursor-column (cursor *editor*)) start) (cursor-column (cursor *editor*)) start)
(update-buffer-cursor (current-buffer *editor*)))))) (update-buffer-cursor (current-buffer *editor*))))))
(defmethod redisplay-line ((line line) &key (start 0) addingp) (defmethod redisplay-line ((line line) &key (start 0) addingp known-free-p)
;; TODO: save the cursor position ;; TODO: save the cursor position
(with-editor-accessors *editor* (:current-line current (with-editor-accessors *editor* (:current-buffer buffer)
:current-buffer buffer)
(cond (cond
(known-free-p
(let ((start (position-if-not (lambda (c) (char= c #\Space))
(line-content line))))
(when start
(hide-cursor)
(move-cursor (view-line-number (buffer-view buffer) line)
start)
(write-string (line-content line) *eio* :start start)
(show-cursor))))
((and addingp (= start (1- (line-length line)))) ((and addingp (= start (1- (line-length line))))
(let ((char-pos (1- (fill-pointer (line-content line))))) (let ((char-pos (1- (fill-pointer (line-content line)))))
(move-cursor (view-line-number (buffer-view buffer) line) char-pos) (move-cursor (view-line-number (buffer-view buffer) line) char-pos)
@ -601,7 +609,7 @@ Additionally ensures correct line numbers on the way, as a bonus."
(prev-line (top-line view)) (prev-line (top-line view))
(bottom-line view) (bottom-line view)
(prev-line (bottom-line view))) (prev-line (bottom-line view)))
(redisplay-line (top-line view)) (redisplay-line (top-line view) :known-free-p t)
(redisplay-status-line :completely-p nil)) (redisplay-status-line :completely-p nil))
(defmethod get-line-into-view ((line line) (view buffer-view)) (defmethod get-line-into-view ((line line) (view buffer-view))