fix(tui): support pi-tui 0.36 key exports

This commit is contained in:
Peter Steinberger
2026-01-05 13:59:50 +00:00
parent 8e8d07cbf4
commit bb959684fe

View File

@@ -1,15 +1,4 @@
import { import { Editor, Key, matchesKey } from "@mariozechner/pi-tui";
Editor,
isAltEnter,
isCtrlC,
isCtrlD,
isCtrlL,
isCtrlO,
isCtrlP,
isCtrlT,
isEscape,
isShiftTab,
} from "@mariozechner/pi-tui";
export class CustomEditor extends Editor { export class CustomEditor extends Editor {
onEscape?: () => void; onEscape?: () => void;
@@ -23,39 +12,43 @@ export class CustomEditor extends Editor {
onAltEnter?: () => void; onAltEnter?: () => void;
handleInput(data: string): void { handleInput(data: string): void {
if (isAltEnter(data) && this.onAltEnter) { if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) {
this.onAltEnter(); this.onAltEnter();
return; return;
} }
if (isCtrlL(data) && this.onCtrlL) { if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) {
this.onCtrlL(); this.onCtrlL();
return; return;
} }
if (isCtrlO(data) && this.onCtrlO) { if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) {
this.onCtrlO(); this.onCtrlO();
return; return;
} }
if (isCtrlP(data) && this.onCtrlP) { if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) {
this.onCtrlP(); this.onCtrlP();
return; return;
} }
if (isCtrlT(data) && this.onCtrlT) { if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) {
this.onCtrlT(); this.onCtrlT();
return; return;
} }
if (isShiftTab(data) && this.onShiftTab) { if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) {
this.onShiftTab(); this.onShiftTab();
return; return;
} }
if (isEscape(data) && this.onEscape && !this.isShowingAutocomplete()) { if (
matchesKey(data, Key.escape) &&
this.onEscape &&
!this.isShowingAutocomplete()
) {
this.onEscape(); this.onEscape();
return; return;
} }
if (isCtrlC(data) && this.onCtrlC) { if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) {
this.onCtrlC(); this.onCtrlC();
return; return;
} }
if (isCtrlD(data)) { if (matchesKey(data, Key.ctrl("d"))) {
if (this.getText().length === 0 && this.onCtrlD) { if (this.getText().length === 0 && this.onCtrlD) {
this.onCtrlD(); this.onCtrlD();
} }