Implement output/clipboard interfaces, stub implementations, and implement execute()s for Copy and Paste
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user