mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 04:02:21 +00:00
tui: fix shift+space/backspace/delete on kitty-protocol terminals
Kitty and other smart terminals send a specific CSI u control code for these shifted special keys, which are interpreted as a no-op by the editor component. These should send the underlying key instead, matching the behaviour of other TUI programs (e.g. readline, vim insert mode). On less smart terminals, these key combinations are the same as the non-shifted versions, and so already work with the existing code.
This commit is contained in:
parent
fd35d9188c
commit
c9b08d7643
2 changed files with 39 additions and 4 deletions
|
|
@ -22,7 +22,10 @@ import {
|
|||
isEnter,
|
||||
isEscape,
|
||||
isHome,
|
||||
isShiftBackspace,
|
||||
isShiftDelete,
|
||||
isShiftEnter,
|
||||
isShiftSpace,
|
||||
isTab,
|
||||
} from "../keys.js";
|
||||
import type { Component } from "../tui.js";
|
||||
|
|
@ -457,8 +460,8 @@ export class Editor implements Component {
|
|||
this.onSubmit(result);
|
||||
}
|
||||
}
|
||||
// Backspace
|
||||
else if (isBackspace(data)) {
|
||||
// Backspace (including Shift+Backspace)
|
||||
else if (isBackspace(data) || isShiftBackspace(data)) {
|
||||
this.handleBackspace();
|
||||
}
|
||||
// Line navigation shortcuts (Home/End keys)
|
||||
|
|
@ -467,8 +470,8 @@ export class Editor implements Component {
|
|||
} else if (isEnd(data)) {
|
||||
this.moveToLineEnd();
|
||||
}
|
||||
// Forward delete (Fn+Backspace or Delete key)
|
||||
else if (isDelete(data)) {
|
||||
// Forward delete (Fn+Backspace or Delete key, including Shift+Delete)
|
||||
else if (isDelete(data) || isShiftDelete(data)) {
|
||||
this.handleForwardDelete();
|
||||
}
|
||||
// Word navigation (Option/Alt + Arrow or Ctrl + Arrow)
|
||||
|
|
@ -503,6 +506,10 @@ export class Editor implements Component {
|
|||
// Left
|
||||
this.moveCursor(0, -1);
|
||||
}
|
||||
// Shift+Space - insert regular space (Kitty protocol sends escape sequence)
|
||||
else if (isShiftSpace(data)) {
|
||||
this.insertCharacter(" ");
|
||||
}
|
||||
// Regular characters (printable characters and unicode, but not control characters)
|
||||
else if (data.charCodeAt(0) >= 32) {
|
||||
this.insertCharacter(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue