Files
OliveTin/webui.dev/js/OutputTerminal.js
James Read 274d036f74 fmt: Cleanup terminal code (#381)
* fmt: Clean up OutputTerminal code

* fmt: Clean up OutputTerminal code
2024-08-09 19:04:57 +00:00

31 lines
509 B
JavaScript

import { Terminal } from '@xterm/xterm'
import { FitAddon } from '@xterm/addon-fit'
export class OutputTerminal {
constructor () {
this.terminal = new Terminal({
convertEol: true
})
const fitAddon = new FitAddon()
this.terminal.loadAddon(fitAddon)
this.terminal.fit = fitAddon
}
write (out, then) {
this.terminal.write(out, then)
}
fit () {
this.terminal.fit.fit()
}
open (el) {
this.terminal.open(el)
}
reset () {
this.terminal.reset()
}
}