Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected resizeTerminal(): void {
const geo = proposeGeometry(this.term);
const cols = geo.cols;
const rows = geo.rows - 1; // subtract one row for margin
this.term.resize(cols, rows);
}
componentWillUpdate(nextProps, nextState) {
if (
nextState.cols !== this.state.cols ||
nextState.rows !== this.state.rows ||
nextState.autoFit !== this.state.autoFit
) {
if (nextState.autoFit) {
// If it is autoFit, get the computed size and set it
this.removeMinWidth();
const geometry = proposeGeometry(this.state.terminal);
this.state.terminal.resize(geometry.cols, geometry.rows);
this.props.onResize(geometry.rows, geometry.cols);
} else {
this.addMinWidth(nextState.cols);
this.state.terminal.resize(nextState.cols, nextState.rows);
this.props.onResize(nextState.rows, nextState.cols);
}
}
}
resize () {
if (this.term) {
let { cols, rows } = fit.proposeGeometry(this.term)
this.term.fit()
this.ptyProcess && this.ptyProcess.resize(cols, rows)
} else {
console.warn('no term!')
}
},
init () {
resize(cols = this.props.cols, rows = this.props.rows) {
if (!(this.term && this.term.element)) {
return;
}
const geometry = fit.proposeGeometry(this.term);
if (!geometry) {
return;
}
cols = (!cols || cols === 'auto') ? geometry.cols : cols;
rows = (!rows || rows === 'auto') ? geometry.rows : rows;
this.term.resize(cols, rows);
}
onWindowResize() {
if (this.state.autoFit) {
this.removeMinWidth();
const geometry = proposeGeometry(this.state.terminal);
if (geometry) {
this.setState({
rows: geometry.rows,
cols: geometry.cols
});
}
} else {
this.addMinWidth(this.state.cols);
}
}
resize(cols = this.props.cols, rows = this.props.rows) {
if (!(this.term && this.term.element)) {
return;
}
const geometry = fit.proposeGeometry(this.term);
if (!geometry) {
return;
}
cols = (!cols || cols === 'auto') ? geometry.cols : cols;
rows = (!rows || rows === 'auto') ? geometry.rows : rows;
this.term.resize(cols, rows);
}
clear() {