Skip to content

Show a hint cursor at the live position in copy/Emacs modes#255

Merged
dakra merged 1 commit into
mainfrom
readonly-fake-cursor
May 10, 2026
Merged

Show a hint cursor at the live position in copy/Emacs modes#255
dakra merged 1 commit into
mainfrom
readonly-fake-cursor

Conversation

@dakra
Copy link
Copy Markdown
Owner

@dakra dakra commented May 10, 2026

Summary

  • Drops a thin overlay at the live terminal cursor position whenever point is somewhere else in copy or Emacs mode, so the next-output spot stays visible while the user reads scrollback.
  • Style follows cursor-in-non-selected-windows: nil hides; t derives from the saved cursor-type (box variants → hollow); hollow / box pass through to dedicated faces; bar / hbar fall back to hollow. Two new customisable faces (ghostel-fake-cursor, ghostel-fake-cursor-box); gated by ghostel-readonly-fake-cursor (default t).
  • Driven by pre-redisplay-functions installed buffer-locally on read-only entry — no post-command-hook overhead, fires only when redisplay is happening, and a single mechanism handles both point movement and the live cursor advancing under streaming Emacs-mode output.
  • Renames the internal helper ghostel--line-mode-cursor-buffer-posghostel--cursor-buffer-pos (no longer line-mode-specific). Single in-tree caller updated.

Test plan

  • make -j4 all (340 elisp+native tests, lint, build, Zig)
  • make test-evil (78/78)
  • Live: split a window with the ghostel buffer, type into the prompt, M-x ghostel-emacs-mode, navigate point up into scrollback — the hint should appear at the prompt position
  • Live: trigger background output (e.g. sleep 5 && ls &) — hint should track the new cursor row in Emacs mode
  • Live: M-x ghostel-copy-mode — hint stays put (terminal frozen)
  • Live: setq cursor-in-non-selected-windows nil while in copy mode — next redisplay clears the overlay
  • Live: try with 'box, 'hollow, 'bar to confirm style resolution

When the user navigates point off the live terminal cursor in copy
or Emacs mode the buffer no longer indicates where new output will
land — the only visible cursor follows point.  Drop a thin overlay
at the live cursor position that mimics
`cursor-in-non-selected-windows' so the next-output spot stays
visible while the user reads scrollback.

Style follows the variable's full range: nil hides the hint, t
derives from the saved `cursor-type' (box variants → hollow),
hollow and box pass through to dedicated faces, bar / hbar fall
back to hollow.  Faces `ghostel-fake-cursor' (hollow) and
`ghostel-fake-cursor-box' (solid) are user-customisable; the
hollow face uses `:line-width (-1 . -1)' so the box stays inside
the character cell and does not reflow the line.  Gated by the new
`ghostel-readonly-fake-cursor' defcustom (default t).

Updates are driven by `pre-redisplay-functions' installed
buffer-locally on read-only entry — fires only when the display
actually needs refreshing, no `post-command-hook' overhead, and
catches both point movement and the live cursor advancing under
streaming Emacs-mode output through one mechanism.  The existing
internal helper `ghostel--line-mode-cursor-buffer-pos' was renamed
to `ghostel--cursor-buffer-pos' to reflect that it is no longer
line-mode-specific.

Tests cover style resolution (incl. bar/hbar fallback), overlay
create/clear when point coincides with or moves away from the live
cursor, both defcustom and `cursor-in-non-selected-windows' kill
switches, the non-readonly modes never installing the overlay, the
box face path, the EOL after-string fallback, and the
`pre-redisplay-functions' lifecycle on leave-readonly.
@dakra dakra force-pushed the readonly-fake-cursor branch from 8899ab4 to 6bffc2b Compare May 10, 2026 14:30
@dakra dakra merged commit 6bffc2b into main May 10, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant