fix(tui): add isHome, isEnd, isDelete helpers for Kitty protocol

Extended the Kitty protocol parser to handle functional keys with
~ terminator (Delete, Insert, PageUp, PageDown) and Home/End keys.
Updated editor.ts and input.ts to use the new helpers.
This commit is contained in:
Mario Zechner 2025-12-19 21:00:20 +01:00
parent 716516d61e
commit cbd20b58a6
4 changed files with 84 additions and 7 deletions

View file

@ -8,6 +8,7 @@ import {
isCtrlK,
isCtrlU,
isCtrlW,
isDelete,
isEnter,
} from "../keys.js";
import type { Component } from "../tui.js";
@ -118,7 +119,7 @@ export class Input implements Component {
return;
}
if (data === "\x1b[3~") {
if (isDelete(data)) {
// Delete - delete grapheme at cursor (handles emojis, etc.)
if (this.cursor < this.value.length) {
const afterCursor = this.value.slice(this.cursor);