How to use the xterm.Terminal 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 tsl0922 / ttyd / html / js / app.js View on Github external
ws.onopen = function(event) {
        console.log('[ttyd] websocket opened');
        wsError = false;
        sendMessage(JSON.stringify({AuthToken: authToken}));

        if (typeof term !== 'undefined') {
            term.dispose();
        }

        // expose term handle for some programatic cases
        // which need to get the content of the terminal
        term = window.term = new Terminal({
            fontSize: 13,
            fontFamily: '"Menlo for Powerline", Menlo, Consolas, "Liberation Mono", Courier, monospace',
            theme: {
                foreground: '#d2d2d2',
                background: '#2b2b2b',
                cursor: '#adadad',
                black: '#000000',
                red: '#d81e00',
                green: '#5ea702',
                yellow: '#cfae00',
                blue: '#427ab3',
                magenta: '#89658e',
                cyan: '#00a7aa',
                white: '#dbded8',
                brightBlack: '#686a66',
                brightRed: '#f54235',
github Coding / WebIDE-Frontend / app / components / Terminal / Xterm.jsx View on Github external
componentDidMount () {
    const _this = this
    _this.props.tab.title = 'Shell'
    const terminalManager = new TerminalManager()
    TerminalState.terminalManager = terminalManager
    const uiTheme = SettingState.settings.appearance.ui_theme.value
    let theme = BRIGHT_THEME
    if (uiTheme === 'dark') {
      theme = DARK_THEME
    }

    const terminal = this.terminal = new Terminal({
      fontSize: 12,
      // theme: themeName,
      cols: 80,
      rows: 24,
      // fontFamily: 'Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Andale Mono", monospace;',
    })

    terminal.attachCustomKeyEventHandler((e) => {
      if (e.keyCode === 66 && e.altKey) {
        terminalManager.getSocket().emit('term.input', { id: terminal.id, input: '\u001bb' }) // x1bb
        return false
      } else if (e.keyCode === 70 && e.altKey) {
        terminalManager.getSocket().emit('term.input', { id: terminal.id, input: '\u001bf' }) // x1bf
        return false
      } else if (e.keyCode === 68 && e.altKey) {
        terminalManager.getSocket().emit('term.input', { id: terminal.id, input: '\u001bd' })
github wasmerio / wasmer-js / examples / wapm-shell / services / wapm-terminal / wapm-terminal.ts View on Github external
constructor() {
    // Create our xterm element
    this.xterm = new Terminal();
    this.xterm.on("paste", this.onPaste);
    this.xterm.on("resize", this.handleTermResize);

    // Create our Shell and tty
    this.wapmTty = new WapmTty(this.xterm);
    this.wapmShell = new WapmShell(this.wapmTty);
    this.xterm.on("data", this.wapmShell.handleTermData);
  }
github cloudcmd / gritty / client / gritty.js View on Github external
function createTerminal(terminalContainer, {env, cwd, command, autoRestart, socket, fontFamily}) {
    const fitAddon = new FitAddon();
    const webglAddon = new WebglAddon();
    const terminal = new Terminal({
        scrollback: 1000,
        tabStopWidth: 4,
        fontFamily,
    });
    
    terminal.open(terminalContainer);
    terminal.focus();
    
    terminal.loadAddon(webglAddon);
    terminal.loadAddon(fitAddon);
    fitAddon.fit();
    
    terminal.onResize(onTermResize(socket));
    terminal.onData(onTermData(socket));
    
    window.addEventListener('resize', onWindowResize(fitAddon));
github vuejs / vue-cli / packages / @vue / cli-ui / src / components / content / TerminalView.vue View on Github external
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)
      }
    },
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 codesandbox / codesandbox-client / standalone-packages / sse-loading-screen / src / index.js View on Github external
async function start() {
  const el = document.getElementById('term');

  Terminal.applyAddon(fit);
  Terminal.applyAddon(WebfontLoader);

  const term = new Terminal({
    fontFamily: 'Source Code Pro',
    rendererType: 'dom',
    allowTransparency: true,
    fontSize: 14,
    disableStdin: true,
    theme: {
      background: 'transparent',
      cursorStyle: 'underline',
    },
  });

  el.innerHTML = '';
  term.open(el);

  term.fit();
github tsl0922 / ttyd / preact / src / components / terminal / index.js View on Github external
onSocketOpen(event) {
        console.log('Websocket connection opened');
        const { socket, textEncoder } = this;
        socket.send(textEncoder.encode(JSON.stringify({AuthToken: ''})));

        if (this.terminal) {
            this.terminal.destroy();
        }

        this.terminal = new TERMINAL({
            fontSize: 13,
            fontFamily: '"Menlo for Powerline", Menlo, Consolas, "Liberation Mono", Courier, monospace',
            theme: {
                foreground: '#d2d2d2',
                background: '#2b2b2b',
                cursor: '#adadad',
                black: '#000000',
                red: '#d81e00',
                green: '#5ea702',
                yellow: '#cfae00',
                blue: '#427ab3',
                magenta: '#89658e',
                cyan: '#00a7aa',
                white: '#dbded8',
                brightBlack: '#686a66',
                brightRed: '#f54235',
github tsl0922 / ttyd / html / src / components / terminal / index.tsx View on Github external
private openTerminal() {
        if (this.terminal) {
            this.terminal.dispose();
        }

        this.socket = new WebSocket(this.props.url, ['tty']);
        this.terminal = new Terminal(this.props.options);
        const { socket, terminal, container, fitAddon, overlayAddon } = this;
        window.term = terminal as TerminalExtended;
        window.term.fit = () => {
            this.fitAddon.fit();
        };

        socket.binaryType = 'arraybuffer';
        socket.onopen = this.onSocketOpen;
        socket.onmessage = this.onSocketData;
        socket.onclose = this.onSocketClose;
        socket.onerror = this.onSocketError;

        terminal.loadAddon(fitAddon);
        terminal.loadAddon(overlayAddon);
        terminal.loadAddon(new WebLinksAddon());
        terminal.loadAddon(this.zmodemAddon);
github reactide / reactide / renderer / components / Terminal.js View on Github external
componentWillUnmount() {
    term.destroy();
    term = new Terminal({
      theme: { background: '#090c0f' }
    });
    term.write(this.state.cwd + '\r\n' + '$');
  }
  render() {