mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 15:03:02 +00:00
fix(tui): use isEnter and isBackspace helpers in Input component
Fixes Kitty protocol handling for Enter and Backspace in the Input component, matching the Editor component fix.
This commit is contained in:
parent
b8e46130b0
commit
716516d61e
1 changed files with 14 additions and 3 deletions
|
|
@ -1,4 +1,15 @@
|
||||||
import { isAltBackspace, isArrowLeft, isArrowRight, isCtrlA, isCtrlE, isCtrlK, isCtrlU, isCtrlW } from "../keys.js";
|
import {
|
||||||
|
isAltBackspace,
|
||||||
|
isArrowLeft,
|
||||||
|
isArrowRight,
|
||||||
|
isBackspace,
|
||||||
|
isCtrlA,
|
||||||
|
isCtrlE,
|
||||||
|
isCtrlK,
|
||||||
|
isCtrlU,
|
||||||
|
isCtrlW,
|
||||||
|
isEnter,
|
||||||
|
} from "../keys.js";
|
||||||
import type { Component } from "../tui.js";
|
import type { Component } from "../tui.js";
|
||||||
import { visibleWidth } from "../utils.js";
|
import { visibleWidth } from "../utils.js";
|
||||||
|
|
||||||
|
|
@ -64,7 +75,7 @@ export class Input implements Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Handle special keys
|
// Handle special keys
|
||||||
if (data === "\r" || data === "\n") {
|
if (isEnter(data) || data === "\n") {
|
||||||
// Enter - submit
|
// Enter - submit
|
||||||
if (this.onSubmit) {
|
if (this.onSubmit) {
|
||||||
this.onSubmit(this.value);
|
this.onSubmit(this.value);
|
||||||
|
|
@ -72,7 +83,7 @@ export class Input implements Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data === "\x7f" || data === "\x08") {
|
if (isBackspace(data)) {
|
||||||
// Backspace - delete grapheme before cursor (handles emojis, etc.)
|
// Backspace - delete grapheme before cursor (handles emojis, etc.)
|
||||||
if (this.cursor > 0) {
|
if (this.cursor > 0) {
|
||||||
const beforeCursor = this.value.slice(0, this.cursor);
|
const beforeCursor = this.value.slice(0, this.cursor);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue