fmt: Cleanup terminal code (#381)

* fmt: Clean up OutputTerminal code

* fmt: Clean up OutputTerminal code
This commit is contained in:
James Read
2024-08-09 20:04:57 +01:00
committed by GitHub
parent 1fe0e49adb
commit 274d036f74
4 changed files with 37 additions and 14 deletions

View File

@@ -0,0 +1,30 @@
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()
}
}