Files
pipelines/app/third_party/xterm

xterm (vendored)

This is our maintained copy of xterm.dart, vendored from the pub.dev release 4.0.0 (MIT, see LICENSE; the upstream README is kept as UPSTREAM_README.md). Upstream is unmaintained, so the app depends on this directory through a path dependency and we patch it here.

The commit that added this directory is the pristine upstream copy; every later change is a local patch. Review them with git log -p -- app/third_party/xterm.

Tests for the patches live in the app tree, app/test/third_party_xterm/, so they run under the memory watchdog with the rest of the app tests. The app's analysis_options.yaml excludes this directory from its strict lints; the code still compiles as part of every app build.

Local patches (keep this list current):

  • CSI parsing: colon subparameters (4:3, 38:2::r:g:b, 58/59), intermediates and private prefixes (CSI > 4;2 m is not SGR), empty parameters as defaults; SGR 21 is double underline, 53/55 overline
  • DCS/APC/PM/SOS strings consumed rather than printed; DECRQSS (m, r, q) answered
  • RIS (ESC c) full reset and DECSTR (CSI ! p)
  • DECSCUSR cursor shapes (blinking is stored; the host animates it); SCOSC/SCORC, CHT, CBT, HPA, HPR, VPR; HTS sets tab stops; DSR 6 one-based
  • OSC 10/11/12 colour queries from the view's theme; OSC 8 links on cells (Terminal.hyperlinkAt); OSC 52 set (onClipboardSet, no reads); OSC 7 (onWorkingDirectoryChange)
  • alternate screen 1049 restores the cursor; arrow keys follow DECCKM
  • mouse: wheel 64/65, screen-cell coordinates, drag (1002) and motion (1003) reporting, middle button, Shift+drag selects (ui/mouse_listener.dart)
  • rendering: block cursor shows the character inverted, underline/bar cursor position, strikethrough, conceal, overline, underline styles
  • focus reporting (?1004, Terminal.focusInput, called by TerminalView)
  • Terminal.maxLines is settable (Buffer.setMaxLines): a smaller value drops the oldest scrollback at once; IndexAwareCircularBuffer.trimStart detaches the dropped lines and keeps the others' indexes (it left them attached and off by the trimmed count, so clearScrollback broke anchors)
  • TerminalView.cursorBlinkVisible: the host animates a blinking cursor; while false the render object skips the cursor (the painter is unchanged)
  • RenderTerminal is exported from ui.dart (cell geometry for hosts)
  • Unicode: cell widths follow glibc wcwidth on Unicode 16 tables (utils/unicode_width.dart, generated utils/unicode_tables.dart by tool/gen_unicode_tables.py); grapheme clusters (combining marks, variation selectors, emoji ZWJ sequences, skin tones, flags, Hangul jamo) join the previous cell (core/buffer/grapheme_join.dart) and are stored interned (core/buffer/graphemes.dart, CellContent.clusterFlag), drawn whole and copied whole; U+FE0F and flags take two columns; a wide character never starts in the last column
  • rendering: box drawing, block elements and Powerline separators drawn as geometry filling the cell (ui/cell_glyphs.dart); whole-pixel row height; one paragraph per line for plain text with a span per style (ui/text_runs.dart), backgrounds merged per colour; a picture per line reused until the line changes (ui/row_pictures.dart, BufferLine.version); glyphs wider than their cells scaled to fit; TerminalStyle and TerminalTheme compare by value