docs: function Terminal(options) {
    var self = this;
  
    if (!(this instanceof Terminal)) {
      return new Terminal(arguments[0], arguments[1], arguments[2]);
    }
  
    Stream.call(this);
  
    if (typeof options === 'number') {
      options = {
        cols: arguments[0],
        rows: arguments[1],
        handler: arguments[2]
      };
    }
  
    options = options || {};
  
    each(keys(Terminal.defaults), function(key) {
      if (options[key] == null) {
        options[key] = Terminal.options[key];
        // Legacy:
        if (Terminal[key] !== Terminal.defaults[key]) {
          options[key] = Terminal[key];
        }
      }
      self[key] = options[key];
    });
  
    if (options.colors.length === 8) {
      options.colors = options.colors.concat(Terminal._colors.slice(8));
    } else if (options.colors.length === 16) {
      options.colors = options.colors.concat(Terminal._colors.slice(16));
    } else if (options.colors.length === 10) {
      options.colors = options.colors.slice(0, -2).concat(
        Terminal._colors.slice(8, -2), options.colors.slice(-2));
    } else if (options.colors.length === 18) {
      options.colors = options.colors.slice(0, -2).concat(
        Terminal._colors.slice(16, -2), options.colors.slice(-2));
    }
    this.colors = options.colors;
  
    this.options = options;
  
    // this.context = options.context || window;
    // this.document = options.document || document;
    this.parent = options.body || options.parent
      || (document ? document.getElementsByTagName('body')[0] : null);
  
    this.cols = options.cols || options.geometry[0];
    this.rows = options.rows || options.geometry[1];
  
    // Act as though we are a node TTY stream:
    this.setRawMode;
    this.isTTY = true;
    this.isRaw = true;
    this.columns = this.cols;
    this.rows = this.rows;
  
    if (options.handler) {
      this.on('data', options.handler);
    }
  
    this.ybase = 0;
    this.ydisp = 0;
    this.x = 0;
    this.y = 0;
    this.cursorHidden = false;
    this.convertEol;
    this.state = 0;
    this.queue = '';
    this.scrollTop = 0;
    this.scrollBottom = this.rows - 1;
  
    // modes
    this.applicationKeypad = false;
    this.applicationCursor = false;
    this.originMode = false;
    this.insertMode = false;
    this.wraparoundMode = false;
    this.normal = null;
  
    // select modes
    this.prefixMode = false;
    this.selectMode = false;
    this.visualMode = false;
    this.searchMode = false;
    this.searchDown;
    this.entry = '';
    this.entryPrefix = 'Search: ';
    this._real;
    this._selected;
    this._textarea;
  
    // charset
    this.charset = null;
    this.gcharset = null;
    this.glevel = 0;
    this.charsets = [null];
  
    // mouse properties
    this.decLocator;
    this.x10Mouse;
    this.vt200Mouse;
    this.vt300Mouse;
    this.normalMouse;
    this.mouseEvents;
    this.sendFocus;
    this.utfMouse;
    this.sgrMouse;
    this.urxvtMouse;
  
    // misc
    this.element;
    this.children;
    this.refreshStart;
    this.refreshEnd;
    this.savedX;
    this.savedY;
    this.savedCols;
  
    // stream
    this.readable = true;
    this.writable = true;
  
    this.defAttr = (0 << 18) | (257 << 9) | (256 << 0);
    this.curAttr = this.defAttr;
  
    this.params = [];
    this.currentParam = 0;
    this.prefix = '';
    this.postfix = '';
  
    this.lines = [];
    var i = this.rows;
    while (i--) {
      this.lines.push(this.blankLine());
    }
  
    this.tabs;
    this.setupStops();
  }