Optimize editor status line redisplay
This commit is contained in:
parent
c6b9e2980a
commit
2157589190
1 changed files with 28 additions and 14 deletions
|
@ -443,17 +443,30 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(line-number (cursor-line *editor*))
|
||||
(cursor-column *editor*)))
|
||||
|
||||
(defun redisplay-status-line ()
|
||||
(move-cursor 24 0)
|
||||
(write-byte #x1B *eio*)
|
||||
(write-char #\[ *eio*)
|
||||
(write-char #\7 *eio*)
|
||||
(write-char #\m *eio*)
|
||||
(write-string (status-line-string) *eio*)
|
||||
(write-byte #x1B *eio*)
|
||||
(write-char #\[ *eio*)
|
||||
(write-char #\m *eio*)
|
||||
(update-buffer-cursor (current-buffer *editor*)))
|
||||
(defparameter *status-line-position* 24
|
||||
"The line at which the status line should be drawn.")
|
||||
(defvar *old-status-line-string* nil)
|
||||
|
||||
(defun redisplay-status-line (&key completely-p)
|
||||
(when completely-p
|
||||
(setf *old-status-line-string* nil))
|
||||
(when (null *old-status-line-string*)
|
||||
(setf *old-status-line-string* (status-line-string)))
|
||||
(let* ((new-status (status-line-string))
|
||||
(old-status *old-status-line-string*)
|
||||
(difference-start (or (mismatch new-status old-status) 0))
|
||||
(difference-end (or (mismatch new-status old-status :from-end t) nil)))
|
||||
(hide-cursor)
|
||||
(move-cursor *status-line-position* difference-start)
|
||||
(invert-text)
|
||||
(write-string (subseq (status-line-string)
|
||||
difference-start
|
||||
difference-end)
|
||||
*eio*)
|
||||
(reset-text-attributes)
|
||||
(update-buffer-cursor (current-buffer *editor*))
|
||||
(setf *old-status-line-string* new-status)
|
||||
(show-cursor)))
|
||||
|
||||
|
||||
|
||||
|
@ -528,7 +541,7 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(bottom-line view) (next-line (bottom-line view)))
|
||||
(unless (null (bottom-line view))
|
||||
(redisplay-view-from-line view (bottom-line view)))
|
||||
(redisplay-status-line))
|
||||
(redisplay-status-line :completely-p t))
|
||||
|
||||
(defmethod scroll-view-up ((view buffer-view))
|
||||
(scroll-screen-down 1) ; view goes up, screen contents go down
|
||||
|
@ -538,7 +551,7 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(bottom-line view)
|
||||
(prev-line (bottom-line view)))
|
||||
(redisplay-line (top-line view))
|
||||
(redisplay-status-line))
|
||||
(redisplay-status-line :completely-p t))
|
||||
|
||||
(defmethod current-view ((obj editor))
|
||||
(buffer-view (current-buffer obj)))
|
||||
|
@ -653,7 +666,8 @@ Additionally ensures correct line numbers on the way, as a bonus."
|
|||
(redisplay-view (buffer-view (current-buffer *editor*))))
|
||||
|
||||
(defun com-refresh-screen ()
|
||||
(redisplay-view (buffer-view (current-buffer *editor*))))
|
||||
(redisplay-view (buffer-view (current-buffer *editor*)))
|
||||
(redisplay-status-line :completely-p t))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue