-
Notifications
You must be signed in to change notification settings - Fork 1
fix: cursor shape (DECSCUSR), Ctrl+V forwarding, and mouse scroll in alt screen #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1597,9 +1597,21 @@ export class Terminal implements ITerminalCore { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isAltScreen = this.wasmTerm?.isAlternateScreen() ?? false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isAltScreen) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Alternate screen: send arrow keys to the application | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Applications like vim handle scrolling internally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Standard: ~3 arrow presses per wheel "click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (this.wasmTerm?.hasMouseTracking()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // App negotiated mouse tracking (e.g. vim `set mouse=a`): send SGR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // scroll sequence so the app scrolls its buffer, not the cursor. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const metrics = this.renderer?.getMetrics(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const canvas = this.canvas; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (metrics && canvas) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const rect = canvas.getBoundingClientRect(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const col = Math.max(1, Math.floor((e.clientX - rect.left) / metrics.width) + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const row = Math.max(1, Math.floor((e.clientY - rect.top) / metrics.height) + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const btn = e.deltaY < 0 ? 64 : 65; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.dataEmitter.fire(`\x1b[<${btn};${col};${row}M`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1600
to
+1613
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mouse coordinates (
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // No mouse tracking: arrow-key fallback for apps like `less`. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const direction = e.deltaY > 0 ? 'down' : 'up'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const count = Math.min(Math.abs(Math.round(e.deltaY / 33)), 5); // Cap at 5 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instantiating a
new TextDecoder()inside thehandleKeyDownevent handler is inefficient as it creates a new object on every Ctrl+V/Cmd+V press. Consider reusing a singleTextDecoderinstance (e.g., as a private member of the class) to improve performance and reduce garbage collection pressure, especially since this pattern is repeated elsewhere in the file.