2020-03-24 23:22:16 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import { FitAddon } from 'xterm-addon-fit';
|
|
|
|
import WindowResizable from '../mixins/window-resizable';
|
2020-06-10 13:49:16 +00:00
|
|
|
import { classNames } from '@ember-decorators/component';
|
|
|
|
import classic from 'ember-classic-decorator';
|
2020-03-24 23:22:16 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
@classNames('terminal-container')
|
|
|
|
export default class ExecTerminal extends Component.extend(WindowResizable) {
|
2020-03-24 23:22:16 +00:00
|
|
|
didInsertElement() {
|
2021-12-28 14:45:20 +00:00
|
|
|
super.didInsertElement(...arguments);
|
2020-03-24 23:22:16 +00:00
|
|
|
let fitAddon = new FitAddon();
|
|
|
|
this.fitAddon = fitAddon;
|
|
|
|
this.terminal.loadAddon(fitAddon);
|
|
|
|
|
|
|
|
this.terminal.open(this.element.querySelector('.terminal'));
|
|
|
|
|
|
|
|
fitAddon.fit();
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-03-24 23:22:16 +00:00
|
|
|
|
|
|
|
windowResizeHandler(e) {
|
|
|
|
this.fitAddon.fit();
|
|
|
|
if (this.terminal.resized) {
|
|
|
|
this.terminal.resized(e);
|
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|