feat: Emacs-style reverse-video cursor (solid, no blink)
Replaced the software blinking █ cursor with a reverse-video cursor that swaps foreground and background colors at the insertion point. Solid at all times — no blink logic, no state tracking, no flicker. - Removed duplicate cursor-visible-p functions - Removed software cursor draw from view-input - Removed terminal cursor style/show from initialize-backend - position-cursor draws character at cursor with :bg fg + :input-fg bg
This commit is contained in:
@@ -70,11 +70,6 @@ Returns a list of strings, one per line."
|
|||||||
;; No clock, no dot, no text. Everything clean.
|
;; No clock, no dot, no text. Everything clean.
|
||||||
)
|
)
|
||||||
|
|
||||||
(defun cursor-visible-p ()
|
|
||||||
"Returns T if the blinking cursor should be visible this frame (2Hz)."
|
|
||||||
(evenp (floor (get-internal-real-time)
|
|
||||||
(floor internal-time-units-per-second 2))))
|
|
||||||
|
|
||||||
(defun input-panel-top (chat-w h)
|
(defun input-panel-top (chat-w h)
|
||||||
"Compute the top row of the input panel based on current input buffer."
|
"Compute the top row of the input panel based on current input buffer."
|
||||||
(let* ((hpad 2)
|
(let* ((hpad 2)
|
||||||
@@ -248,13 +243,9 @@ Returns a list of strings, one per line."
|
|||||||
(setf cursor-line i
|
(setf cursor-line i
|
||||||
cursor-col (- pos accum)))
|
cursor-col (- pos accum)))
|
||||||
(incf accum (1+ len))))
|
(incf accum (1+ len))))
|
||||||
;; Draw software blinking cursor at insertion point
|
|
||||||
(when (cursor-visible-p)
|
|
||||||
(let ((cursor-row (+ panel-top 1 cursor-line)))
|
|
||||||
(cl-tty.backend:draw-text fb (+ hpad 2 cursor-col) cursor-row "█" input-fg nil))))
|
|
||||||
;; Hint — lowercase, right-aligned at h-2
|
;; Hint — lowercase, right-aligned at h-2
|
||||||
(let ((hint "ctrl+p | /help"))
|
(let ((hint "ctrl+p | /help"))
|
||||||
(cl-tty.backend:draw-text fb (- chat-w (length hint) 2) (- h 2) hint hint-fg (theme-color :bg)))))
|
(cl-tty.backend:draw-text fb (- chat-w (length hint) 2) (- h 2) hint hint-fg (theme-color :bg))))))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
** Sidebar
|
** Sidebar
|
||||||
@@ -328,13 +319,9 @@ Returns a list of strings, one per line."
|
|||||||
(position-cursor fb w h)
|
(position-cursor fb w h)
|
||||||
(setf (st :dirty) (list nil nil nil))))
|
(setf (st :dirty) (list nil nil nil))))
|
||||||
|
|
||||||
(defun cursor-visible-p ()
|
|
||||||
"Returns T if the software-cursor should be visible this frame (2Hz)."
|
|
||||||
(evenp (floor (get-internal-real-time)
|
|
||||||
(floor internal-time-units-per-second 2))))
|
|
||||||
|
|
||||||
(defun position-cursor (fb w h)
|
(defun position-cursor (fb w h)
|
||||||
"Position terminal cursor at input insertion point and draw █ software cursor."
|
"Reverse-video cursor (Emacs style): shows the character at cursor position
|
||||||
|
with foreground and background colors swapped."
|
||||||
(let* ((sw (if (sidebar-visible-p w) (or (st :sidebar-width) 42) 0))
|
(let* ((sw (if (sidebar-visible-p w) (or (st :sidebar-width) 42) 0))
|
||||||
(cw (- w sw))
|
(cw (- w sw))
|
||||||
(hpad 2)
|
(hpad 2)
|
||||||
@@ -343,11 +330,11 @@ Returns a list of strings, one per line."
|
|||||||
(prompt-w (- cw (* 2 hpad) 2))
|
(prompt-w (- cw (* 2 hpad) 2))
|
||||||
(display-start (max 0 (- pos (1- prompt-w))))
|
(display-start (max 0 (- pos (1- prompt-w))))
|
||||||
(cx (+ hpad 2 (- pos display-start)))
|
(cx (+ hpad 2 (- pos display-start)))
|
||||||
(cy (- h 6)))
|
(cy (- h 6))
|
||||||
(cl-tty.backend:cursor-move fb cx cy)
|
(ch (if (< pos (length text)) (char text pos) #\Space)))
|
||||||
(cl-tty.backend:cursor-style fb :block :blink t)
|
(cl-tty.backend:draw-text fb cx cy (string ch)
|
||||||
;; Software █ cursor — erase old position with space, draw new position
|
(theme-color :bg) ;; fg = global bg (black)
|
||||||
(cl-tty.backend:draw-text fb cx cy (if (cursor-visible-p) "█" " ") (theme-color :input-fg) nil)))
|
(theme-color :input-fg)))) ;; bg = text color (reverse)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Implementation — v0.7.0 additions
|
* Implementation — v0.7.0 additions
|
||||||
|
|||||||
Reference in New Issue
Block a user