fix: cursor shape (DECSCUSR), Ctrl+V forwarding, and mouse scroll in alt screen#147
Open
jesse23 wants to merge 1 commit intocoder:mainfrom
Open
fix: cursor shape (DECSCUSR), Ctrl+V forwarding, and mouse scroll in alt screen#147jesse23 wants to merge 1 commit intocoder:mainfrom
jesse23 wants to merge 1 commit intocoder:mainfrom
Conversation
Bug 1 — DECSCUSR cursor shape silently dropped: Add ghostty_render_state_get_cursor_style and ghostty_render_state_get_cursor_blinking WASM exports to the patch. GhosttyTerminal.getCursor() now reads both from the terminal state instead of hardcoding style:'block' and blinking:false. Bug 2 — Ctrl+V not forwarded to PTY: InputHandler.handleKeyDown emits the encoded \x16 byte to onDataCallback before returning, so apps that read Ctrl+V natively (e.g. image paste flows) receive it. The browser paste event still fires afterwards so handlePaste continues to cover text paste unchanged. Bug 3 — Mouse wheel sends arrow keys when mouse tracking is active: Terminal.handleWheel checks hasMouseTracking() in the isAlternateScreen branch. When active, it emits an SGR scroll sequence (\x1b[<64/65;col;rowM) via dataEmitter instead of arrow keys, matching xterm.js behaviour. The arrow-key fallback is preserved for apps without mouse tracking (less, man, etc.). Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes all three issues reported in #145. Each fix is small and self-contained.
Bug 1 — DECSCUSR cursor shape silently dropped
GhosttyTerminal.getCursor()hardcodedstyle: 'block'andblinking: falsewith TODO comments. Added two new WASM exports to the patch:ghostty_render_state_get_cursor_style(term)→0=block,1=bar,2=underline (readsterminal.screens.active.cursor.cursor_style)ghostty_render_state_get_cursor_blinking(term)→ bool (readsterminal.modes.get(.cursor_blinking))getCursor()now returns the live values so the renderer reflects cursor shape changes from PTY output.Bug 2 — Ctrl+V not forwarded to PTY
handleKeyDownreturned early onCtrl+V/Cmd+Vwithout emitting\x16, so apps that read it natively (image paste flows, readlineyank) never received it. Now encodes and emits the keydown viaonDataCallbackbefore returning. The browserpasteevent still fires afterwards —handlePastecovers text paste unchanged.Bug 3 — Mouse wheel sends arrow keys when mouse tracking is active
handleWheelsent\x1B[A/\x1B[Bunconditionally on the alternate screen, ignoring whether the app had requested mouse events. Added ahasMouseTracking()guard: when active, emits an SGR scroll sequence (\x1b[<64/65;col;rowM) viadataEmitterinstead. The arrow-key fallback is preserved for apps without mouse tracking (less,man, etc.).Note: Bug 1 requires a WASM rebuild to take effect at runtime. The patch changes are ready; the resulting
.wasmand.jsbundle would need to be regenerated.Ref: #145
Downstream pR to prove the fix works:
jesse23/webtty#21