Files
pipelines/app/third_party/xterm
alan 018d37f103 Terminal: grapheme-aware widths, drawn box/Powerline glyphs, line pictures
Emulator (vendored xterm):
- Widths follow glibc wcwidth on generated Unicode 16 tables
  (tool/gen_unicode_tables.py); combining marks, variation selectors,
  ZWJ sequences, skin tones, flags and Hangul jamo join the previous cell,
  stored as interned clusters (CellContent.clusterFlag) and drawn and
  copied whole. U+FE0F and flags take two columns, as modern terminals
  do; a wide character never starts in the last column.
- Box drawing, block elements and Powerline separators are drawn as
  geometry filling the cell; rows are whole pixels high.
- Backgrounds merge per colour; each line is a picture reused until the
  line changes (BufferLine.version); a line drawn unchanged settles into
  one laid out paragraph with a span per style. TerminalStyle and
  TerminalTheme compare by value.

App: bundled Symbols Nerd Font Mono subset (568 KiB, MIT) as the
terminal's first fallback, loaded on first use; line height 1.1;
?terminalUnicode=1 fixture showcase; bench gains a progress workload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 01:14:48 +00:00
..

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, not animated); 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)
  • 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