private _setup()

in src/Terminal.ts [252:318]


  private _setup(): void {
    Object.keys(DEFAULT_OPTIONS).forEach((key) => {
      if (this.options[key] === null || this.options[key] === undefined) {
        this.options[key] = DEFAULT_OPTIONS[key];
      }
    });

    // this.context = options.context || window;
    // this.document = options.document || document;
    // TODO: WHy not document.body?
    this._parent = document ? document.body : null;

    this.cols = this.options.cols;
    this.rows = this.options.rows;

    if (this.options.handler) {
      this.on('data', this.options.handler);
    }

    this.cursorState = 0;
    this.cursorHidden = false;
    this._customKeyEventHandler = null;

    // modes
    this.applicationKeypad = false;
    this.applicationCursor = false;
    this.originMode = false;
    this.insertMode = false;
    this.wraparoundMode = true; // defaults: xterm - true, vt100 - false
    this.bracketedPasteMode = false;

    // charset
    this.charset = null;
    this.gcharset = null;
    this.glevel = 0;
    // TODO: Can this be just []?
    this.charsets = [null];

    this.curAttr = DEFAULT_ATTR;

    this.params = [];
    this.currentParam = 0;

    // user input states
    this.writeBuffer = [];
    this._writeInProgress = false;

    this._xoffSentToCatchUp = false;
    // this._writeStopped = false;
    this._userScrolling = false;

    this._inputHandler = new InputHandler(this);
    this.register(this._inputHandler);
    // Reuse renderer if the Terminal is being recreated via a reset call.
    this.renderer = this.renderer || null;
    this.selectionManager = this.selectionManager || null;
    this.linkifier = this.linkifier || new Linkifier(this);
    this._mouseZoneManager = this._mouseZoneManager || null;
    this.soundManager = this.soundManager || new SoundManager(this);

    // Create the terminal's buffers and set the current buffer
    this.buffers = new BufferSet(this);
    if (this.selectionManager) {
      this.selectionManager.clearSelection();
      this.selectionManager.initBuffersListeners();
    }
  }