fix(tui): handle Kitty protocol lock key modifiers
Fixes keyboard input in Ghostty on Linux when Num Lock is enabled. The Kitty protocol includes Caps Lock (64) and Num Lock (128) bits in modifier values. Now masks out lock bits when matching shortcuts. Added helper functions: isArrowUp/Down/Left/Right, isEnter, isTab, isBackspace, isShiftEnter, isAltEnter, isAltLeft/Right, isCtrlLeft/Right fixes #243
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { isAltBackspace, isCtrlA, isCtrlE, isCtrlK, isCtrlU, isCtrlW } from "../keys.js";
|
||||
import { isAltBackspace, isArrowLeft, isArrowRight, isCtrlA, isCtrlE, isCtrlK, isCtrlU, isCtrlW } from "../keys.js";
|
||||
import type { Component } from "../tui.js";
|
||||
import { visibleWidth } from "../utils.js";
|
||||
|
||||
@@ -78,7 +78,7 @@ export class Input implements Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data === "\x1b[D") {
|
||||
if (isArrowLeft(data)) {
|
||||
// Left arrow
|
||||
if (this.cursor > 0) {
|
||||
this.cursor--;
|
||||
@@ -86,7 +86,7 @@ export class Input implements Component {
|
||||
return;
|
||||
}
|
||||
|
||||
if (data === "\x1b[C") {
|
||||
if (isArrowRight(data)) {
|
||||
// Right arrow
|
||||
if (this.cursor < this.value.length) {
|
||||
this.cursor++;
|
||||
|
||||
Reference in New Issue
Block a user