当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript xterm.Terminal类代码示例

本文整理汇总了TypeScript中xterm.Terminal的典型用法代码示例。如果您正苦于以下问题:TypeScript Terminal类的具体用法?TypeScript Terminal怎么用?TypeScript Terminal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Terminal类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

	public constructor(
		private _rootProcessId: number,
		private _rootShellExecutable: string,
		private _terminalInstance: ITerminalInstance,
		private _xterm: XTermTerminal
	) {
		if (!platform.isWindows) {
			throw new Error(`WindowsShellHelper cannot be instantiated on ${platform.platform}`);
		}

		if (!windowsProcessTree) {
			windowsProcessTree = require.__$__nodeRequire('windows-process-tree');
		}

		this._childProcessIdStack = [this._rootProcessId];
		this._isDisposed = false;
		this._onCheckShell = new Emitter<TPromise<string>>();
		// The debounce is necessary to prevent multiple processes from spawning when
		// the enter key or output is spammed
		debounceEvent(this._onCheckShell.event, (l, e) => e, 150, true)(() => {
			setTimeout(() => {
				this.checkShell();
			}, 50);
		});

		this._xterm.on('lineFeed', () => this._onCheckShell.fire());
		this._xterm.on('keypress', () => this._onCheckShell.fire());
	}
开发者ID:armanio123,项目名称:vscode,代码行数:28,代码来源:windowsShellHelper.ts

示例2: constructor

	public constructor(
		private _rootProcessId: number,
		private _rootShellExecutable: string,
		private _terminalInstance: ITerminalInstance,
		private _xterm: XTermTerminal
	) {
		if (!platform.isWindows) {
			throw new Error(`WindowsShellHelper cannot be instantiated on ${platform.platform}`);
		}

		if (!windowsProcessTree) {
			windowsProcessTree = require.__$__nodeRequire('windows-process-tree');
		}

		this._childProcessIdStack = [this._rootProcessId];
		this._isDisposed = false;
		this._onCheckShell = new Emitter<TPromise<string>>();
		// The debounce is necessary to prevent multiple processes from spawning when
		// the enter key or output is spammed
		debounceEvent(this._onCheckShell.event, (l, e) => e, 150, true)(() => {
			setTimeout(() => {
				this.checkShell();
			}, 50);
		});

		// We want to fire a new check for the shell on a lineFeed, but only
		// when parsing has finished which is indicated by the cursormove event.
		// If this is done on every lineFeed, parsing ends up taking
		// significantly longer due to resetting timers. Note that this is
		// private API.
		this._xterm.on('lineFeed', () => this._newLineFeed = true);
		this._xterm.on('cursormove', () => {
			if (this._newLineFeed) {
				this._onCheckShell.fire();
			}
		});

		// Fire a new check for the shell when any key is pressed.
		this._xterm.on('keypress', () => this._onCheckShell.fire());
	}
开发者ID:elibarzilay,项目名称:vscode,代码行数:40,代码来源:windowsShellHelper.ts

示例3: setTheme

export function setTheme(terminal: Terminal, theme_name: string): void {
  let t = color_themes[theme_name];
  if (t == null) {
    t = color_themes["default"];
    if (t == null) {
      // can't happen
      return;
    }
  }
  const colors = t.colors;
  if (colors == null) {
    // satisfies typescript
    return;
  }
  const theme: ITheme = {
    background: colors[17],
    foreground: colors[16],
    cursor: colors[16],
    cursorAccent: colors[17],
    selection: "rgba(128, 128, 160, 0.25)",
    black: colors[0],
    red: colors[1],
    green: colors[2],
    yellow: colors[3],
    blue: colors[4],
    magenta: colors[5],
    cyan: colors[6],
    white: colors[7],
    brightBlack: colors[8],
    brightRed: colors[9],
    brightGreen: colors[10],
    brightYellow: colors[11],
    brightBlue: colors[12],
    brightMagenta: colors[13],
    brightCyan: colors[14],
    brightWhite: colors[15]
  };
  terminal.setOption("theme", theme);
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:39,代码来源:themes.ts

示例4: Terminal

      'tabStopWidth': 2,
    });
  }
}

namespace properties {
  {
    const t: Terminal = new Terminal();
    const element: HTMLElement = t.element;
    const textarea: HTMLTextAreaElement = t.textarea;
  }
}

namespace static_methods {
  {
    Terminal.applyAddon({});
    Terminal.applyAddon({});
    Terminal.applyAddon({});
    Terminal.applyAddon({});
    Terminal.applyAddon({});
    Terminal.applyAddon({});
  }
}

namespace methods_core {
  {
    const t: Terminal = new Terminal();
    t.blur();
    t.focus();
    t.destroy();
    t.clear();
开发者ID:blink1073,项目名称:xterm.js,代码行数:31,代码来源:typings-test.ts

示例5: Terminal

socket.on('connect', () => {
  const term = new Terminal();
  term.open(document.getElementById('terminal'));
  const defaultOptions = { fontSize: 14 };
  let options: any;
  try {
    if (localStorage.options === undefined) {
      options = defaultOptions;
    } else {
      options = JSON.parse(localStorage.options);
    }
  } catch {
    options = defaultOptions;
  }
  Object.keys(options).forEach(key => {
    const value = options[key];
    term.setOption(key, value);
  });
  const code = JSON.stringify(options, null, 2);
  const editor = document.querySelector('#options .editor');
  editor.value = code;
  editor.addEventListener('keyup', e => {
    try {
      const updated = JSON.parse(editor.value);
      const updatedCode = JSON.stringify(updated, null, 2);
      editor.value = updatedCode;
      editor.classList.remove('error');
      localStorage.options = updatedCode;
      Object.keys(updated).forEach(key => {
        const value = updated[key];
        term.setOption(key, value);
      });
      resize();
    } catch {
      // skip
      editor.classList.add('error');
    }
  });
  document.getElementById('overlay').style.display = 'none';
  document.querySelector('#options .toggler').addEventListener('click', e => {
    document.getElementById('options').classList.toggle('opened');
    e.preventDefault();
  });
  window.addEventListener('beforeunload', handler, false);
  /*
    term.scrollPort_.screen_.setAttribute('contenteditable', 'false');
  */

  term.attachCustomKeyEventHandler(e => {
    // Ctrl + Shift + C
    if (e.ctrlKey && e.shiftKey && e.keyCode === 67) {
      e.preventDefault();
      document.execCommand('copy');
      return false;
    }
    return true;
  });

  function resize(): void {
    fit(term);
    socket.emit('resize', { cols: term.cols, rows: term.rows });
  }
  window.onresize = resize;
  resize();
  term.focus();

  function kill(data: string): void {
    disconnect(data);
  }

  term.on('data', data => {
    socket.emit('input', data);
  });
  term.on('resize', size => {
    socket.emit('resize', size);
  });
  socket
    .on('data', (data: string) => {
      term.write(data);
    })
    .on('login', () => {
      term.writeln('');
      resize();
    })
    .on('logout', kill)
    .on('disconnect', kill)
    .on('error', (err: string | null) => {
      if (err) disconnect(err);
    });
});
开发者ID:krishnasrinivas,项目名称:wetty,代码行数:90,代码来源:index.ts

示例6:

		(import('windows-process-tree')).then(mod => {
			if (this._isDisposed) {
				return;
			}

			windowsProcessTree = mod;
			this._onCheckShell = new Emitter<Promise<string>>();
			// The debounce is necessary to prevent multiple processes from spawning when
			// the enter key or output is spammed
			Event.debounce(this._onCheckShell.event, (l, e) => e, 150, true)(() => {
				setTimeout(() => {
					this.checkShell();
				}, 50);
			});

			// We want to fire a new check for the shell on a linefeed, but only
			// when parsing has finished which is indicated by the cursormove event.
			// If this is done on every linefeed, parsing ends up taking
			// significantly longer due to resetting timers. Note that this is
			// private API.
			this._xterm.onLineFeed(() => this._newLineFeed = true);
			this._xterm.onCursorMove(() => {
				if (this._newLineFeed) {
					this._onCheckShell.fire(undefined);
				}
			});

			// Fire a new check for the shell when any key is pressed.
			this._xterm.onKey(() => this._onCheckShell.fire(undefined));
		});
开发者ID:PKRoma,项目名称:vscode,代码行数:30,代码来源:windowsShellHelper.ts

示例7: resize

 .on('login', () => {
   term.writeln('');
   resize();
 })
开发者ID:krishnasrinivas,项目名称:wetty,代码行数:4,代码来源:index.ts

示例8:

 .on('data', (data: string) => {
   term.write(data);
 })
开发者ID:krishnasrinivas,项目名称:wetty,代码行数:3,代码来源:index.ts


注:本文中的xterm.Terminal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。