Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
create(id, container, options = {}) {
const opts = deepmerge(defaultOptions, options);
if (!this.terms[id]) {
this.terms[id] = new Terminal(opts);
this.terms[id].writeChunk = writeChunkFn(this.terms[id]);
this.terms[id].writeLog = writeLog(this.terms[id]);
} else {
this.terms[id]._core.options.theme = opts.theme;
}
// initialize the web links addon, registering the link matcher
webLinks.webLinksInit(this.terms[id], (event, uri) => {
window.open(uri, 'blank');
});
// opens the terminal within an element.
this.terms[id].open(container);
// Note: need to initialize the fit plugin when the component is re-rendered
// make the terminal's size and geometry fit the size of #terminal-container
this.terms[id].fit();
return this.terms[id];
}
initTerminal () {
let term = this.$_terminal = new Terminal({
cols: this.cols,
rows: this.rows,
theme: this.theme,
...this.options
})
webLinks.webLinksInit(term, this.handleLink)
term.open(this.$refs.render)
term.on('blur', () => this.$emit('blur'))
term.on('focus', () => this.$emit('focus'))
if (this.autoSize) {
this.$nextTick(this.fit)
}
},