How to use the xterm 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 vterm / vterm / src / components / terminalError.jsx View on Github external
createTerminal() {
    // Create the terminal and setup event hooks
    XTerminal.loadAddon('fit')

    // Take out values from config
    const { cursorBlink, cursorStyle } = Store.config

    this.Terminal = new XTerminal({ cursorBlink, cursorStyle })
    this.Terminal.on('open', this.onTerminalOpen)

    // Window Events listeners
    window.addEventListener('resize', this.onWindowResize)

    this.Terminal.open(this.Term, true)
    this.Terminal.fit()
  }
github vterm / vterm / src / components / terminal.jsx View on Github external
//   - onShellExit
    shell.on('data', this.onShellData)
    shell.on('exit', this.onShellExit)


    // SETTING UP THE TERMINAL:
    // - Taking values from the Store
    // - Taking ID, cols and rows from props
    // - Creating the Terminal object
    const { cursorBlink, cursorStyle } = Store.config
    const { id, cols, rows } = this.props

    // Creating the terminal with the default
    // options plus TODO: custom ones
    this.terminal = Store.tabs[id].terminal =
      new TERMINAL({
        cursorBlink,
        cursorStyle,
        cols,
        rows
      })

    const { terminal } = this
    // - SETTING UP EVENTS:
    //   - onTerminalOpen
    //   - onTerminalData
    //   - onTerminalTitle (linked to the shell)
    //   - onTerminalResize
    terminal.on('open',   this.onTerminalOpen  )
    terminal.on('data',   this.onTerminalData  )
    terminal.on('title',  this.onTerminalTitle )
    terminal.on('resize', this.onTerminalResize)
github faststackco / faststack / app / stores / Terminal.js View on Github external
constructor(id) {
    let io = this.ws(`/session/${id}/io`)
    let control = this.ws(`/session/${id}/control`)

    this.xterm = new Xterm()
    this.xterm.attach(io)

    this.elem = document.createElement('div')
    this.elem.style.flex = '1'
    this.xterm.open(this.elem)

    control.addEventListener('open', () => {
      window.addEventListener('resize', debounce(() => this.xterm.fit(), 100))
      this.xterm.on('resize', (size) => {
        control.send(JSON.stringify({
          command: 'window-resize',
          args: {width: size.cols.toString(), height: size.rows.toString()},
        }))
      })
    })
github manaflair / mylittledom / demo / Terminal.js View on Github external
constructor(props) {

        super(props);

        this.term = new XTerm();

        this.stdin = new PassThrough();
        this.stdout = new PassThrough();

        this.stdout.rows = 0;
        this.stdout.columns = 0;

        this.term.on(`resize`, ({ rows, cols: columns }) => {
            Object.assign(this.stdout, { rows, columns }).emit(`resize`);
        });

        this.term.on(`data`, data => {
            this.stdin.write(data.toString());
        });

        this.stdout.on(`data`, data => {
github willyelm / xatom-debug / lib / debug / DebugAreaView.js View on Github external
startProcess(command, args, options) {
        const projectPaths = atom.project.getPaths();
        const defaultOptions = {
            name: 'xterm-color',
            cwd: path.resolve(process.env.HOME),
            env: Object.assign({}, process.env, {
                TERM: 'xterm-256color',
                CLICOLOR: '1',
                LSCOLORS: 'ExFxCxDxBxegedabagacad'
            })
        };
        this.pty = spawnPty(command, args || [], Object.assign(defaultOptions, options));
        this.terminal = new Terminal();
        this.terminal.open(this.getElement(), true);
        this.terminal.on('data', (data) => {
            return this.pty.write(data);
        });
        this.showInitialMessage();
        this.element.addEventListener('focus', () => this.terminal.focus());
        this.resizeObserver = new ResizeObserver(this.elementDidResize.bind(this));
        this.resizeObserver.observe(this.element);
        this.pty.on('data', (data) => {
            return this.terminal.write(data);
        });
        this.pty.on('exit', () => {
            this.emitter.emit('didExitProccess');
            this.destroy();
        });
        return this.pty;
github maisk / atom-psql / lib / terminal-view.js View on Github external
_openTerminal() {
    this.pty = this._openPseudoterminal();
    this.terminal = new Terminal();
    this.terminal.open(this.element, true);
    this.applyThemeStyles();
  }
github matthew-matvei / freeman / src / renderer / objects / IntegratedTerminal.ts View on Github external
public constructor(
        @inject(TYPES.ISettingsManager) settingsManager: ISettingsManager,
        @inject(TYPES.IShell) shell: IShell,
        useFallbackShell = false
    ) {
        this.settingsManager = settingsManager;
        this.shell = shell;
        this.useFallbackShell = useFallbackShell;

        (Xterm as any).loadAddon("fit");
        this.xterm = new Xterm({
            cursorBlink: this.settingsManager.settings.terminal.cursorBlink
        });

        this.shell.spawn(this.shellName);
        this.shell.attach(this.xterm);
    }
github learn-co / learn-ide / lib / terminal-view.js View on Github external
initialize(terminal) {
    this.terminal = terminal;
    this.emulator = new TerminalEmulator({cursorBlink: true, rows: 16});

    this.attach();
    this.subscribe();
    this.resizeAfterDrag = this.resizeAfterDrag.bind(this)
  }