Skip to content

Rich text

A program can place a block of styled text into a rectangle of cells: a heading in one family and size, a paragraph in another, colour, bold, italic, underline and strikethrough. The body is a documented subset of the Rich Text Format, which the text systems of every desktop platform already produce.

A rich text block inside the terminal grid: a bold sans-serif heading 'Field notes', an italic serif line, and three walking directions in sans-serif with green ticks, a red cross and one struck-through route, between two lines of ordinary monospaced terminal text.
An OSC 7404 block: several families, sizes and colours in one rectangle of cells.
OSC 7404 ; a=p : w=<cells> : h=<rows> [: i=<id>] [: o=w|c|e] [: j=l|c|r] ; {\rtf1 …} ST
  • a=p places a block at the cursor, w cells wide and h rows tall.
  • a=q measures first: how many characters and lines a style gets in a rectangle, or whether a given body fits.
  • a=d deletes blocks.
  • o chooses wrap, clip, or wrap with an ellipsis; j sets the default alignment.

A refused sequence changes nothing and answers nothing, exactly as a terminal without the feature would behave, and an empty query doubles as feature detection. Selection inside a block works per character, and copying yields the text. The full contract is the rich text specification.

A block’s RTF body is capped at 16,384 bytes, with 4,096 characters and 512 style runs per block and 64 blocks per screen. Rendering limits:

  • The Linux, web and software renderers do not draw blocks.
  • Ligatures and kerning are off inside a block, and justified paragraphs are set flush left.
  • Background colour, tables, lists, links and pictures in the RTF are ignored.
  • A row with double width or double height refuses a block.

Layouts and rasters are retained until the source, typography or placement changes, and rows are found by binary search for pointer hits and selections. Applications should cache fit-query results by source, width and typography revision, since a query may take one round trip to the client that owns the fonts. See Performance for measuring a workload.