fix: terminal cursor instead of software-drawn █

Replaced software cursor (draw-text █ every frame) with native terminal
cursor (position-cursor using cursor-move + cursor-style). Terminal handles
blinking natively at 500ms — no redraw needed for cursor updates.

- position-cursor: computed input insertion point from state, calls
  cursor-move + cursor-style (:block :blink t) + cursor-show.
- Called from main loop every frame after (sleep 0.1), outside
  redraw's begin-sync/end-sync. No flicker.
This commit is contained in:
2026-05-16 17:50:08 -04:00
parent 7eca785b0a
commit f8ae4ac817
3 changed files with 21 additions and 1 deletions

View File

@@ -326,6 +326,22 @@ Returns a list of strings, one per line."
(view-sidebar fb w h))
(cl-tty.backend:end-sync fb)
(setf (st :dirty) (list nil nil nil))))
(defun position-cursor (fb w h)
"Position terminal cursor at the input insertion point.
Terminal handles the blinking — we just set position and style once per frame."
(let* ((sw (if (sidebar-visible-p w) (or (st :sidebar-width) 42) 0))
(cw (- w sw))
(hpad 2)
(text (input-string))
(pos (or (st :cursor-pos) 0))
(prompt-w (- cw (* 2 hpad) 2))
(display-start (max 0 (- pos (1- prompt-w))))
(cx (+ hpad 2 (- pos display-start)))
(cy (- h 6)))
(cl-tty.backend:cursor-move fb cx cy)
(cl-tty.backend:cursor-style fb :block :blink t)
(cl-tty.backend:cursor-show fb)))
#+END_SRC
* Implementation — v0.7.0 additions