Terminal constructor
Terminal({
- int maxLines = 1000,
- void onBell()?,
- void onTitleChange(
- String title
- void onIconChange(
- String title
- void onOutput(
- String title
- void onResize()?,
- TerminalTargetPlatform platform = TerminalTargetPlatform.unknown,
- TerminalInputHandler? inputHandler = defaultInputHandler,
- TerminalMouseHandler? mouseHandler = defaultMouseHandler,
- void onPrivateOSC()?,
- bool reflowEnabled = true,
- Set<
int> ? wordSeparators, - void onOutputBytes(
- 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);
};
}