|
|
@ -5,19 +5,19 @@ import { FitAddon } from 'xterm-addon-fit'; |
|
|
|
import { Terminal } from 'xterm'; |
|
|
|
|
|
|
|
import type { Term } from './shared/type'; |
|
|
|
import { configureTerm } from './term/confiruragtion.js'; |
|
|
|
import { configureTerm, shouldFitTerm } from './term/confiruragtion.js'; |
|
|
|
import { terminal as termElement } from '../shared/elements.js'; |
|
|
|
|
|
|
|
export function terminal(socket: typeof Socket): Term | undefined { |
|
|
|
const term = new Terminal() as Term; |
|
|
|
if (_.isNull(termElement)) return; |
|
|
|
if (_.isNull(termElement)) return undefined; |
|
|
|
const webLinksAddon = new WebLinksAddon(); |
|
|
|
term.loadAddon(webLinksAddon); |
|
|
|
const fitAddon = new FitAddon(); |
|
|
|
term.loadAddon(fitAddon); |
|
|
|
term.open(termElement); |
|
|
|
term.resizeTerm = () => { |
|
|
|
fitAddon.fit(); |
|
|
|
if (shouldFitTerm()) fitAddon.fit(); |
|
|
|
socket.emit('resize', { cols: term.cols, rows: term.rows }); |
|
|
|
}; |
|
|
|
configureTerm(term); |
|
|
|