mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
Fix cursor positioning in DOM terminal viewport scrolling
- Add proper cursor coordinate system translation between XTerm logical size and viewport size - Fix cursor positioning when viewport is scrolled up by adjusting cursor Y offset - Clean up unused variables and fix linting warnings - Ensure XTerm write callback timing for performance measurement 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
992cea9a91
commit
91d454f503
1 changed files with 14 additions and 8 deletions
|
|
@ -476,9 +476,13 @@ export class Terminal extends LitElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if cursor is on this line (relative to viewport)
|
// Check if cursor is on this line (relative to viewport)
|
||||||
// cursorY is absolute in buffer, need to check if it's in current viewport
|
// Cursor Y is relative to terminal size, but we're rendering with actualRows
|
||||||
|
// Need to offset cursor position by the difference
|
||||||
|
const adjustedCursorY = cursorY + (this.actualRows - this.rows);
|
||||||
const isCursorLine =
|
const isCursorLine =
|
||||||
row === cursorY && cursorY >= startRow && cursorY < startRow + this.actualRows;
|
row === adjustedCursorY &&
|
||||||
|
adjustedCursorY >= startRow &&
|
||||||
|
adjustedCursorY < startRow + this.actualRows;
|
||||||
const lineContent = this.renderLine(line, cell, isCursorLine ? cursorX : -1);
|
const lineContent = this.renderLine(line, cell, isCursorLine ? cursorX : -1);
|
||||||
html += `<div class="terminal-line">${lineContent || ''}</div>`;
|
html += `<div class="terminal-line">${lineContent || ''}</div>`;
|
||||||
}
|
}
|
||||||
|
|
@ -607,11 +611,13 @@ export class Terminal extends LitElement {
|
||||||
|
|
||||||
this.queueOperation(() => {
|
this.queueOperation(() => {
|
||||||
const writeStart = performance.now();
|
const writeStart = performance.now();
|
||||||
this.terminal!.write(data);
|
this.terminal!.write(data, () => {
|
||||||
const writeEnd = performance.now();
|
const writeEnd = performance.now();
|
||||||
console.log(
|
|
||||||
`XTerm write took: ${(writeEnd - writeStart).toFixed(2)}ms for ${data.length} chars`
|
console.log(
|
||||||
);
|
`XTerm write took: ${(writeEnd - writeStart).toFixed(2)}ms for ${data.length} chars`
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -664,7 +670,7 @@ export class Terminal extends LitElement {
|
||||||
* Scroll to a specific position in the buffer.
|
* Scroll to a specific position in the buffer.
|
||||||
* @param position - Line position (0 = top, max = bottom)
|
* @param position - Line position (0 = top, max = bottom)
|
||||||
*/
|
*/
|
||||||
public scrollTo(position: number) {
|
public scrollToPosition(position: number) {
|
||||||
if (!this.terminal) return;
|
if (!this.terminal) return;
|
||||||
|
|
||||||
this.queueOperation(() => {
|
this.queueOperation(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue