Art, pipe codes and display codes
Reference for everything Carrier draws: art files, the codes inside them, and how colours reach the caller's terminal.

- Art files
- Finding art by name
- How art is drawn
- SAUCE
- Pipe codes
- Display codes
- Placing display codes in art
- Views
- Colour modes
- Showing art from code
- Console commands
- The stock art
Art files
| Extension | Read as | Wrap rule | Display codes |
|---|---|---|---|
.ans, .asc, .nfo, .diz |
CP437; control bytes other than BS, TAB, LF, CR, SUB and ESC become their IBM glyphs | immediate | filled in place on the drawn picture |
.utf8ans, .pipe, .txt |
UTF-8 (a file that is not valid UTF-8 is decoded as CP437) | deferred | substituted into the text before drawing |
Source: EXTENSIONS and CP437 in ArtRepository.php,
isCp437() in ArtFile.php.
Every file may contain ANSI escape sequences and pipe colour codes (|00–|31). Text after a
SUB byte (0x1A) is ignored.
Wrap rules
Terminals disagree about what happens after a character lands in the last column. The interpreter (AnsiInterpreter.php) plays each file with the rule it was written for:
| Rule | Behaviour | Used for |
|---|---|---|
| immediate | The cursor moves to the next row at once. A CRLF after a full row is a blank line. ANSI.SYS, CTerm/SyncTERM and ansilove work this way. | CP437 files |
| deferred | The cursor waits in the last column. A full row followed by CRLF is one row. xterm works this way. | UTF-8 files |
The result is a canvas: one character and one attribute per cell. The canvas is then sent with
autowrap turned off (ESC[?7l), one row per line ending in CRLF, then ESC[0m ESC[?7h, so a
full-width row never double-spaces on either kind of terminal. Rows are cropped to the
terminal's width. Source: CanvasRenderer::ansi() in
CanvasRenderer.php.
The interpreter understands SGR (m), cursor positioning (H, f, A, B, C, D, G,
d), ESC[2J, ESC[K, and save/restore cursor (s, u). Other escape sequences are skipped.
Art is limited to 2,000 rows.
iCE colours
When a file's SAUCE record has the iCE flag set (flags & 0x01), the blink attribute is read as
a bright background instead. How a bright background is sent to the caller depends on the
colour mode.
Finding art by name
Modules and menus ask for art by name (matrix, main, login). The search order is:
- the caller's theme's
art/directory, then each parent theme's; resources/art/in the board;resources/art/in the framework package.
The first directory with any match wins. A name with a known extension (matrix.ans) or a path
matches that file exactly. Within the directory, ArtRepository.php
picks a file in this order:
| Rule | Example | Effect |
|---|---|---|
| Width variants | main.c132.ans |
Used when the terminal is at least 132 columns wide. The widest variant that fits wins; plain files are used only when no width variant fits. name.c132x50.ans is also accepted; the row count is not checked. |
| Encoding | matrix.utf8ans |
Preferred on UTF-8 terminals; other files are preferred on CP437 terminals. |
| Extension order | utf8ans, ans, asc, pipe, txt, nfo, diz |
Within one variant, the earliest extension wins. |
| Random variants | matrix1.ans, matrix2.ans |
One variant number is picked at random on every display. |
See themes for theme directories and parents.
How art is drawn
ArtPresenter::show() (ArtPresenter.php):
- finds the file, reads it and its SAUCE record;
- renders it to a canvas and fills display codes (CP437 files), or substitutes display codes into the text first (UTF-8 files);
- drops trailing empty rows;
- extracts views and blanks their markers;
- clears the screen (or moves to a given row) and sends the canvas in the caller's colour mode, at the caller's emulated baud rate.
php carrier art:show follows the same rendering path without a session. See
Console commands.
SAUCE
Sauce.php reads and writes SAUCE 00 records:
[art][0x1A]["COMNT" + 64 bytes per comment][128-byte record].
| Field | Meaning in Carrier |
|---|---|
title, author, group, date |
Shown by art:info. toBytes() writes today's date (Ymd) when date is empty. |
dataType, fileType |
1/1 (character, ANSi) by default. |
tinfo1 |
Canvas width when the data type is character. 0 or no record means 80. |
tinfo2 |
Height; shown by art:info. |
flags |
Bit 0x01 is iCE colours. |
font |
Shown by art:info; default IBM VGA. |
comments |
Up to 255 lines of 64 characters. |
Write one with $sauce->toBytes() and append it to the art. The SUB byte and comment block are
included.
Pipe codes
Mystic/Renegade-style codes, valid in any string written with $terminal->write() /
writeln() and in menu labels. Source: PipeCodes.php.
Colours
| Code | Colour | Code | Colour |
|---|---|---|---|
|00 |
black | |08 |
dark gray |
|01 |
blue | |09 |
light blue |
|02 |
green | |10 |
light green |
|03 |
cyan | |11 |
light cyan |
|04 |
red | |12 |
light red |
|05 |
magenta | |13 |
light magenta |
|06 |
brown | |14 |
yellow |
|07 |
light gray | |15 |
white |
| Code | Sets |
|---|---|
|00–|15 |
foreground |
|16–|23 |
background 0–7 (|16 black … |23 light gray) |
|24–|31 |
bright (iCE) background 8–15 |
|32 and up |
nothing; printed as written |
Colour codes change only the part they name: |17 after |15 gives white on blue.
Screen and control codes
| Code | Effect |
|---|---|
|CL |
clear the screen and home the cursor |
|CR |
newline (CR LF) |
|BE |
bell |
|PA |
pause with the theme's pause prompt |
|PN |
wait for any key |
|PE |
wait for Enter |
|DE |
wait half a second |
|[X## |
move to column ## |
|[Y## |
move to row ## |
|[A##, |[B##, |[C##, |[D## |
move up, down, right, left ## cells |
|[K |
clear to end of line |
|[0, |[1 |
hide, show the cursor |
|SA, |RA |
save, restore the current colour |
|SS, |RS |
save, restore the cursor position |
|| or |PI |
a literal | |
|$R##, |$L##, |$C## |
pad the next display code to ## columns: left-aligned, right-aligned, centred (longer values are cut) |
|$D##c |
the character c repeated ## times |
## is always two digits. Unknown two-letter codes are printed unchanged.
Inside art files only the colour codes |00–|31 are interpreted while drawing. Display codes
are handled as described in Placing display codes in art.
Writing user text safely
$terminal->text() writes text literally. To embed user input in a pipe-coded string, escape it
with PipeCodes::escape(), which doubles | and removes ESC. PipeCodes::length() returns the
printable width of a pipe-coded string.
Display codes
Two-letter codes that print live values. Write them as |UN in strings, or as %UN or |UN in
art. Codes ending in a digit (%ET1) are views, not display codes.
Framework codes
Registered in Mci.php.
| Code | Value |
|---|---|
| Caller | |
UN |
handle (Guest before login) |
UR |
real name |
LO |
location |
UE |
|
UI |
user number |
UC |
number of calls |
PS |
number of posts |
SL |
security level |
SD |
name of the security level (Guest before login) |
UT |
theme title |
MS |
member since (Y-m-d) |
LD |
the caller's previous call (Y-m-d H:i); first call! when there is none |
TL, TR |
minutes left today (∞ when unlimited) |
ON |
minutes online this call |
| System | |
BN |
board name |
SN |
sysop name |
BL |
board location |
BT |
board tagline |
VN |
Carrier version |
VL |
Carrier v + version |
OS |
PHP's OS family |
PV |
PHP version |
DT |
date, in the configured date format |
CT |
time, in the configured time format |
DW |
weekday name |
ND |
this caller's node |
MN |
number of nodes |
AN |
callers online now |
UP |
uptime (3d 4h, 2h 10m, 5m) |
| Connection | |
IP |
caller's address, without the port |
PR |
protocol: TELNET, SSH, RLOGIN, WEB |
TE |
terminal type |
EN |
encoding label |
SW, SH |
screen width, height |
SZ |
screen size, 80x24 |
BD |
emulated baud rate, or max |
MD |
what the caller is doing (the activity shown in Who's Online) |
A code whose resolver throws prints nothing and logs a warning.
Board codes
This board adds its own in BoardCodes.php:
| Code | Value |
|---|---|
NM |
the caller's unread e-mail |
TC |
total calls |
TU |
total users |
TM |
total messages |
LC |
last caller's handle |
RR |
a random oneliner |
MA |
the current message area |
NM is also an access check: NM1 in an ACS string means "has at least one unread letter". See
acs.
Adding a code
Mark a method with #[DisplayCode]. Parameters are injected by name ($session) or from the
container:
use Carrier\Art\DisplayCode;
use Carrier\Session\Session;
final class BoardCodes
{
#[DisplayCode('NM')]
public function newMail(Session $session): int
{
return $session->user !== null ? Mail::unreadFor($session->user->key()) : 0;
}
}Mci::register('XX', fn (Session $s) => …) does the same at runtime. A code returning null
prints nothing.
Placing display codes in art
In CP437 art the value goes where the code is drawn, in the code's colour, and the shape of
the picture is kept. The width of the field depends on what follows the code
(Mci::place() in Mci.php):
| Drawn as | Field | Alignment | What moves |
|---|---|---|---|
%UN |
inline | — | the rest of that row shifts to fit the value; other rows stay put |
%UN........ |
the code plus its fill run | left | nothing; the value is padded or cut to the field |
....%BN.... |
the fill run on both sides plus the code | centred | nothing |
A fill run is two or more . or _ directly after the code; a single full stop after a code is
treated as prose. Fill characters are replaced by spaces or by the value.
In UTF-8 files (.pipe, .txt, .utf8ans) codes are substituted into the text before drawing,
so the row reflows. Pad with |$R20%UN there.
Views
A view is a placeholder for something the BBS draws: an input field, a lightbar, a list. Write
it in the art as % + two letters + a number, e.g. %ET1. Source:
ViewExtractor.php, View.php.
| Drawn as | Result |
|---|---|
%ET1 |
a view four cells wide at the marker's position, in the marker's colour |
%ET1__________ |
the width runs over the fill characters after it (_ . ░ ▒ ·) |
%ET1%ET1 |
the second copy, drawn in another colour, sets the focus colour |
Markers and _/. fill are blanked. ░, ▒ and · fill stays visible as part of the art.
The extractor accepts any two capital letters with a 1–3 digit number; what a view does is
decided by the code that reads it. In this repository:
| View | Read by | Used for |
|---|---|---|
VM1 |
MenuRunner.php | vertical lightbar: one option per row from the marker down |
HM1 |
MenuRunner.php | horizontal lightbar: options side by side from the marker |
ET1, ET2 |
Login.php | handle and password fields on login art |
TL1 |
Oneliners.php | where the oneliner list starts on oneliners art |
When the art has no matching view, these modules fall back to plain prompts. A module reads views
from the Screen returned by art() or header():
$screen = $this->art($session, 'login');
$field = $screen?->view('ET1'); // View: col, row, width, color(), color(focus: true)$screen->ofType('ET') returns all views of one type in number order. Run php carrier art:info <file> to list the views in a file with their positions.
Colour modes
Every colour goes out through one encoder (Attr::sgr() in
Attr.php). The mode decides how:
ColorMode.php.
| Mode | Setting value | Bright foreground | Bright background | Dark gray (|08) |
|---|---|---|---|---|
Bold |
— | bold + 30–37 | not sent (dark) | ESC[0;1;30m |
CTerm |
— | bold + 30–37 | blink + 40–47 under ESC[?33h |
ESC[0;1;30m |
Aixterm |
aixterm |
90–97 | 100–107 | ESC[0;90m |
Xterm256 |
256 |
38;5;n |
48;5;n |
ESC[0;38;5;240m |
TrueColor |
rgb |
38;2;r;g;b |
48;2;r;g;b |
ESC[0;38;2;85;85;85m |
Aixterm, Bold and CTerm use the terminal's own palette. Xterm256 uses the nearest entries
in the fixed 16–255 range, which colour themes usually leave alone. TrueColor sends the VGA
palette exactly. In every mode a black background is left to the terminal's default background.
Detection
Terminal::colors() picks the mode, first match wins:
| Condition | Mode |
|---|---|
| The caller chose a mode in Settings | that mode |
| The terminal answered the device-attributes probe as CTerm | CTerm (and ESC[?33h is sent) |
TerminalInfo::$iceColors is false |
Bold |
The caller is on the web terminal (xterm.js) |
Aixterm; its palette is already VGA |
SSH sent COLORTERM=truecolor or 24bit |
TrueColor |
The terminal type contains direct, truecolor, 24bit, ghostty, kitty, wezterm, alacritty, foot, iterm, contour or rio |
TrueColor |
The terminal type contains 256col |
Xterm256 |
| anything else | Aixterm |
The terminal type comes from telnet TTYPE, the SSH pty-req, or the rlogin handshake; see
transports.
The Colours setting
Callers change the mode under Settings → Colours. Each press cycles Auto → Terminal theme →
VGA 256-colour → VGA 24-bit. The choice is stored as the user setting colors (auto,
aixterm, 256, rgb) and applied on login by Session::applyPreferences(). The row shows a
dark gray sample so the caller can judge the result.
Showing art from code
Inside a module:
$this->art($session, 'rumors', ['pause' => 'end']);
$screen = $this->header($terminal, $session, 'Rumors', art: 'rumors');header() draws the named art when it exists; otherwise it clears the screen, writes the theme's header template and returns null. Options for
art() and ArtPresenter::show():
| Option | Default | Effect |
|---|---|---|
cls |
true |
clear the screen first |
pause |
false |
true or 'end': pause after drawing. 'page': pause every screenful (only for art without views) |
baud |
caller's setting | emulate this line speed while drawing |
mci |
[] |
extra one-off display codes, ['XX' => 'value'], which win over registered codes |
row |
— | draw from this screen row without clearing |
Both return null when no art with that name exists. Menus show art with ->art('name'); see
menus.
Console commands
| Command | Effect |
|---|---|
php carrier art:show <art> [--theme=default] [--html=<file>] [--baud=0] |
Render a file or a named art in this terminal. --html writes an HTML file instead; --baud emulates a line speed. Fills BN, SN, BT and BL; other codes stay as written. The colour mode is detected from $TERM and $COLORTERM. |
php carrier art:info <file> |
Print the SAUCE record, the rendered size and every view with its column, row and width. |
Source: ArtCommand.php. Output of art:info
on the stock matrix (colour codes removed, dot leaders shortened):
Title ......... Matrix
Author ........ Carrier
Group ......... Carrier BBS
Date .......... 20261128
Size .......... 80 x 23
Type .......... 1/1
iCE colours ... yes
Font .......... IBM VGA
Comments ...... Generated by tools/art/build.php. Edit freely
Rendered 23 rows at 80 columns.
VM1 col 29 row 12 width 4CanvasRenderer::html() exports a canvas as a <pre> of coloured <span>s in the VGA palette;
blinking cells get class="blink". The web page's /api/art/matrix route uses it.
The stock art
The default and amber themes ship connect, matrix, login, logon, main, doors and
logoff as CP437 .ans files with SAUCE records. They are generated in this repository by:
php tools/art/build.phpThe script draws with a small pixel font in half blocks and the same conventions a sysop uses in
PabloDraw or Moebius: %XX display codes and %VM1 / %ET1 views where the BBS should draw.
Running it overwrites those files. Edit the generated .ans files directly if you prefer; see
themes for adding a theme.