Terminal constructor

Terminal({
  1. int maxLines = 1000,
  2. void onBell()?,
  3. void onTitleChange(
    1. String title
    )?,
  4. void onIconChange(
    1. String title
    )?,
  5. void onOutput(
    1. String title
    )?,
  6. void onResize(
    1. int width,
    2. int height,
    3. int pixelWidth,
    4. int pixelHeight,
    )?,
  7. TerminalTargetPlatform platform = TerminalTargetPlatform.unknown,
  8. TerminalInputHandler? inputHandler = defaultInputHandler,
  9. TerminalMouseHandler? mouseHandler = defaultMouseHandler,
  10. void onPrivateOSC(
    1. String code,
    2. List<String> args
    )?,
  11. bool reflowEnabled = true,
  12. Set<int>? wordSeparators,
  13. void onOutputBytes(
    1. Uint8List data
    )?,
})

Creates an 80 × 24 terminal.

Implementation

Terminal({
  this.maxLines = 1000,
  this.onBell,
  this.onTitleChange,
  this.onIconChange,
  this.onOutput,
  this.onResize,
  this.platform = TerminalTargetPlatform.unknown,
  this.inputHandler = defaultInputHandler,
  this.mouseHandler = defaultMouseHandler,
  this.onPrivateOSC,
  this.reflowEnabled = true,
  this.wordSeparators,
  this.onOutputBytes,
}) {
  final controller = VtTerminalController(
    cols: _initialCols,
    rows: _initialRows,
    // xterm limits lines, not bytes.
    scrollbackMaxBytes: null,
    scrollbackMaxLines: _scrollbackLines(_initialRows),
  );
  _controller = controller;
  _engine = TerminalEngine(controller)..writeSequence = _writeSequence;
  _internals = _TerminalInternals(controller);
  bindTerminalEngine(this, _engine);
  bindTerminalInternals(this, _internals);
  controller
    ..onOutput = _onEngineOutput
    ..onResize = _onEngineResize
    ..onBell = _onEngineBell
    ..onTitleChanged = _onEngineTitle
    ..addListener(_engine.invalidate);
  // The native callables are GC roots: capture the terminal weakly so a
  // forgotten terminal can still be collected and finalized.
  final self = WeakReference(this);
  controller.terminal
    ..setUnknownSequenceMaxBytes(_unknownSequenceMaxBytes)
    ..onUnknownSequence = (sequence) {
      self.target?._queueUnknownSequence(sequence);
    }
    ..onResizeWindow = (request) {
      self.target?._queueResizeWindow(request);
    };
}