How to use the xterm/lib/addons/fit/fit.fit function in xterm

To help you get started, we’ve selected a few xterm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pterodactyl / panel / resources / scripts / components / server / Console.tsx View on Github external
useEffect(() => {
        if (connected && terminalElement && !terminal.element) {
            terminal.open(terminalElement);

            // @see https://github.com/xtermjs/xterm.js/issues/2265
            // @see https://github.com/xtermjs/xterm.js/issues/2230
            TerminalFit.fit(terminal);

            // Add support for copying terminal text.
            terminal.attachCustomKeyEventHandler((e: KeyboardEvent) => {
                // Ctrl + C
                if (e.ctrlKey && (e.key === 'c')) {
                    document.execCommand('copy');
                    return false;
                }

                return true;
            });
        }
    }, [ terminal, connected, terminalElement ]);
github jupyterlab / jupyterlab-data-explorer / packages / terminal / src / widget.ts View on Github external
private _resizeTerminal() {
    fit(this._term);
    if (this._offsetWidth === -1) {
      this._offsetWidth = this.node.offsetWidth;
    }
    if (this._offsetHeight === -1) {
      this._offsetHeight = this.node.offsetHeight;
    }
    this._setSessionSize();
    this._needsResize = false;
  }
github leonardochaia / timoneer / src / app / daemon-tools / container-exec / container-exec.component.ts View on Github external
private setupTerminal() {
    this.terminal = new Terminal({
      cursorBlink: false,
    });
    this.terminal.open(this.terminalContainer.nativeElement);
    this.terminal.focus();
    fit(this.terminal);
  }
}
github leonardochaia / timoneer / src / app / daemon-tools / container-attacher / container-attacher.component.ts View on Github external
public resizeTerminal(width: number = this.terminalContainer.nativeElement.offsetWidth) {
    const charHeight = 25;
    const charWidth = Math.floor((width - 20) / 8.39);
    if (width > 0) {
      this.terminal.resize(charWidth, charHeight);
      fit(this.terminal);
    }
    return {
      charHeight,
      charWidth
    };
  }
github manaflair / mylittledom / demo / Terminal.js View on Github external
@autobind handleResize(dimensions) {

        if (!this.term.element)
            return;

        fit(this.term);

    }