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


TypeScript Terminal.open方法代码示例

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


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

示例1: Terminal

   t.off('keydown', (event: KeyboardEvent) => console.log(event));
   t.off('keypress', () => {});
   t.off('keypress', (event: KeyboardEvent) => console.log(event));
   t.off('refresh', () => {});
   t.off('refresh', (data: {element: HTMLElement, start: number, end: number}) => console.log(data));
   t.off('resize', () => {});
   t.off('resize', (data: {terminal: Terminal, cols: number, rows: number}) => console.log(data));
   t.off('scroll', () => {});
   t.off('scroll', (ydisp: number) => console.log(ydisp));
   t.off('title', () => {});
   t.off('title', (title: string) => console.log(title));
 }
 {
   const t: Terminal = new Terminal();
   const e: HTMLElement = null;
   t.open(e);
 }
 {
   const t: Terminal = new Terminal();
   t.attachCustomKeyEventHandler((e: KeyboardEvent) => true);
   t.attachCustomKeyEventHandler((e: KeyboardEvent) => false);
 }
 namespace options {
   {
     const t: Terminal = new Terminal();
     const r01: string = t.getOption('cursorStyle');
     const r02: string = t.getOption('termName');
     const r03: boolean = t.getOption('cancelEvents');
     const r04: boolean = t.getOption('convertEol');
     const r05: boolean = t.getOption('cursorBlink');
     const r06: boolean = t.getOption('debug');
开发者ID:blink1073,项目名称:xterm.js,代码行数:31,代码来源:typings-test.ts

示例2: 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


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