Implement output/clipboard interfaces, stub implementations, and implement execute()s for Copy and Paste

This commit is contained in:
2026-02-10 00:06:16 -06:00
parent f36621c646
commit 06ff1b396f
5 changed files with 80 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
import {StrRVal} from "./commands/command.js";
import {Awaitable} from "../util/types.js";
export const getSubjectDisplay = (sub: StrRVal): string => {
if ( sub.term === 'string' ) {
@@ -11,3 +12,39 @@ export const getSubjectDisplay = (sub: StrRVal): string => {
return JSON.stringify(sub.value, null, '\t') // fixme
}
export type Display = {
showSubject(sub: StrRVal): Awaitable<unknown>
}
export class ConsoleDisplay implements Display {
showSubject(sub: StrRVal) {
console.log(`\n---------------\n${getSubjectDisplay(sub)}\n---------------\n`)
}
}
export class NullDisplay implements Display {
showSubject() {}
}
export type Clipboard = {
read(): Awaitable<string>
overwrite(sub: string): Awaitable<unknown>
}
export class FakeClipboard {
private val = ''
read() {
return this.val
}
overwrite(sub: string) {
this.val = sub
}
}
export type OutputManager = {
display: Display,
clipboard: Clipboard,
}