change: selects now use inputmanager

fix: bad exit logic
feat: field rename now supports renaming things with multiple widgets
This commit is contained in:
2025-05-27 12:44:45 -06:00
parent 7a394c642a
commit 0f9c377853
12 changed files with 543 additions and 161 deletions

View File

@@ -6,6 +6,7 @@ import { selectMenuInteractive } from "./selectMenu.ts";
import { TerminalBlock, TerminalLayout } from "./TerminalLayout.ts";
import { cliAlert, cliLog } from "./prompts.ts";
import type { ITool } from "../types.ts";
import { InputManager } from "./InputManager.ts";
// Register tools here (filename, no extension)
const toolRegistry: [string, Promise<{ default: ITool }>][] = [
@@ -55,6 +56,12 @@ export class PdfToolsCli {
}
public async run() {
const im = InputManager.getInstance();
im.activate();
im.addEventListener("exit", () => {
this.closeMessage = "Exiting...";
this.cleanup();
});
try {
await this.importTools();
const titleBlock = new TerminalBlock();
@@ -78,11 +85,13 @@ export class PdfToolsCli {
}
} finally {
this.cleanup();
Deno.exit(0);
}
}
private cleanup() {
this.terminalLayout.clearAll();
InputManager.getInstance().deactivate();
Deno.stdin.setRaw(false);
if (this.closeMessage) console.log(this.closeMessage);
}