XtermTerminalView constructor

XtermTerminalView(
  1. HTMLElement parent, {
  2. XtermTheme theme = XtermTheme.omnyShell,
  3. int fontSize = 13,
  4. String fontFamily = defaultFontFamily,
  5. int scrollback = 5000,
})

Creates the terminal inside parent and fits it to the container.

The fit is deferred to later frames rather than run synchronously after open(): the fit addon reads the container's laid-out size, which isn't available in the same tick the element is attached — fitting too early leaves the terminal 0×0 and nothing renders. We fit on the next macrotask and again shortly after so it picks up the real geometry.

theme, fontSize and fontFamily let an embedding app match its own look; the defaults are OmnyShell's.

Implementation

XtermTerminalView(
  web.HTMLElement parent, {
  XtermTheme theme = XtermTheme.omnyShell,
  int fontSize = 13,
  String fontFamily = defaultFontFamily,
  int scrollback = 5000,
}) : _term = XTerminal(
       _options(
         theme: theme,
         fontSize: fontSize,
         fontFamily: fontFamily,
         scrollback: scrollback,
       ),
     ),
     _fit = XFitAddon() {
  _term.loadAddon(_fit);
  _term.open(parent);
  _autoFit0 = Timer(Duration.zero, fit);
  _autoFit80 = Timer(const Duration(milliseconds: 80), fit);
}