From bb959684fe95510ab060b46267d1ad5dd24c2ec6 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 5 Jan 2026 13:59:50 +0000 Subject: [PATCH] fix(tui): support pi-tui 0.36 key exports --- src/tui/components/custom-editor.ts | 35 ++++++++++++----------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/tui/components/custom-editor.ts b/src/tui/components/custom-editor.ts index f9036080a..526584498 100644 --- a/src/tui/components/custom-editor.ts +++ b/src/tui/components/custom-editor.ts @@ -1,15 +1,4 @@ -import { - Editor, - isAltEnter, - isCtrlC, - isCtrlD, - isCtrlL, - isCtrlO, - isCtrlP, - isCtrlT, - isEscape, - isShiftTab, -} from "@mariozechner/pi-tui"; +import { Editor, Key, matchesKey } from "@mariozechner/pi-tui"; export class CustomEditor extends Editor { onEscape?: () => void; @@ -23,39 +12,43 @@ export class CustomEditor extends Editor { onAltEnter?: () => void; handleInput(data: string): void { - if (isAltEnter(data) && this.onAltEnter) { + if (matchesKey(data, Key.alt("enter")) && this.onAltEnter) { this.onAltEnter(); return; } - if (isCtrlL(data) && this.onCtrlL) { + if (matchesKey(data, Key.ctrl("l")) && this.onCtrlL) { this.onCtrlL(); return; } - if (isCtrlO(data) && this.onCtrlO) { + if (matchesKey(data, Key.ctrl("o")) && this.onCtrlO) { this.onCtrlO(); return; } - if (isCtrlP(data) && this.onCtrlP) { + if (matchesKey(data, Key.ctrl("p")) && this.onCtrlP) { this.onCtrlP(); return; } - if (isCtrlT(data) && this.onCtrlT) { + if (matchesKey(data, Key.ctrl("t")) && this.onCtrlT) { this.onCtrlT(); return; } - if (isShiftTab(data) && this.onShiftTab) { + if (matchesKey(data, Key.shift("tab")) && this.onShiftTab) { this.onShiftTab(); return; } - if (isEscape(data) && this.onEscape && !this.isShowingAutocomplete()) { + if ( + matchesKey(data, Key.escape) && + this.onEscape && + !this.isShowingAutocomplete() + ) { this.onEscape(); return; } - if (isCtrlC(data) && this.onCtrlC) { + if (matchesKey(data, Key.ctrl("c")) && this.onCtrlC) { this.onCtrlC(); return; } - if (isCtrlD(data)) { + if (matchesKey(data, Key.ctrl("d"))) { if (this.getText().length === 0 && this.onCtrlD) { this.onCtrlD(); }