//! ANSI escape sequence builders. //! //! Mirrors the `github.com/charmbracelet/x/ansi` (v0.11.8) builders used by //! ultraviolet byte-for-byte where cost comparisons matter: parameters of 1 //! (or 0/negative) are omitted exactly as Go's `strconv.Itoa` gating does, and //! `CursorPosition(1,1)` collapses to `\x1b[H`. //! //! All builders write into a `std.Io.Writer` and return the number of bytes //! written. To compare sequence costs, render callers build each candidate //! into a fixed stack buffer and compare lengths — same semantics as Go's //! `len(seq)`. const std = @import("std"); const Writer = std.Io.Writer; const t = std.testing; /// Backspace pub const BS: u8 = 0x08; /// Horizontal Tab pub const HT: u8 = 0x09; /// Line Feed pub const LF: u8 = 0x0A; /// Carriage Return pub const CR: u8 = 0x0D; /// Unit Separator pub const US: u8 = 0x1F; /// Delete pub const DEL: u8 = 0x7F; /// NUL (^@). pub const NUL: u8 = 0x00; /// SOH (^A). pub const SOH: u8 = 0x01; /// STX (^B). pub const STX: u8 = 0x02; /// ETX (^C). pub const ETX: u8 = 0x03; /// EOT (^D). pub const EOT: u8 = 0x04; /// ENQ (^E). pub const ENQ: u8 = 0x05; /// ACK (^F). pub const ACK: u8 = 0x06; /// BEL (^G). pub const BEL: u8 = 0x07; /// VT (^K). pub const VT: u8 = 0x0B; /// FF (^L). pub const FF: u8 = 0x0C; /// SO (^N). pub const SO: u8 = 0x0E; /// SI (^O). pub const SI: u8 = 0x0F; /// DLE (^P). pub const DLE: u8 = 0x10; /// DC1 (^Q). pub const DC1: u8 = 0x11; /// DC2 (^R). pub const DC2: u8 = 0x12; /// DC3 (^S). pub const DC3: u8 = 0x13; /// DC4 (^T). pub const DC4: u8 = 0x14; /// NAK (^U). pub const NAK: u8 = 0x15; /// SYN (^V). pub const SYN: u8 = 0x16; /// ETB (^W). pub const ETB: u8 = 0x17; /// CAN (^X). pub const CAN: u8 = 0x18; /// EM (^Y). pub const EM: u8 = 0x19; /// SUB (^Z). pub const SUB: u8 = 0x1A; /// ESC (^[). pub const ESC: u8 = 0x1B; /// FS (^\). pub const FS: u8 = 0x1C; /// GS (^]). pub const GS: u8 = 0x1D; /// RS (^^). pub const RS: u8 = 0x1E; /// SP (space). pub const SP: u8 = 0x20; /// PAD. pub const PAD: u8 = 0x80; /// SOS. pub const SOS: u8 = 0x98; /// SS3. pub const SS3: u8 = 0x8F; /// DCS. pub const DCS: u8 = 0x90; /// CSI. pub const CSI: u8 = 0x9B; /// ST. pub const ST: u8 = 0x9C; /// OSC. pub const OSC: u8 = 0x9D; /// PM. pub const PM: u8 = 0x9E; /// APC. pub const APC: u8 = 0x9F; /// Returns the number of bytes `writeNumber` would emit for `n`. pub fn decimalLength(n: usize) usize { if (n < 10) return 1; if (n < 100) return 2; if (n < 1000) return 3; if (n < 10000) return 4; if (n < 100000) return 5; if (n < 10000000) return 7; return 9; } /// Writes the decimal ASCII representation of `n`. pub fn writeNumber(writer: *Writer, n: usize) Writer.Error!usize { if (n < 10) { try writer.writeByte(@intCast('0' + n)); return 1; } var buf: [20]u8 = undefined; const s = std.fmt.bufPrint(&buf, "{d}", .{n}) catch unreachable; try writer.writeAll(s); return s.len; } /// Writes a CSI sequence `ESC [ ` with the given parametrized /// count. The parameter is omitted entirely when `n <= 1`, matching the Go /// builders. Returns bytes written. fn writeCsiParam(writer: *Writer, n: usize, final: u8) Writer.Error!usize { var count: usize = 0; try writer.writeByte(0x1b); try writer.writeByte('['); count += 2; if (n > 1) { const c = try writeNumber(writer, n); count += c; } try writer.writeByte(final); return count + 1; } /// Writes a CSI sequence `ESC [ ` where the parameter is /// omitted when `n <= 0` (used by column/row absolute positioning). Returns /// bytes written. fn writeCsiPos(writer: *Writer, n: usize, final: u8) Writer.Error!usize { var count: usize = 0; try writer.writeByte(0x1b); try writer.writeByte('['); count += 2; if (n > 0) { const c = try writeNumber(writer, n); count += c; } try writer.writeByte(final); return count + 1; } /// CSI n A — move cursor up `n` cells. Parameter omitted for n <= 1. pub fn cursorUp(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'A'); } pub const cuu = cursorUp; /// CSI n B — move cursor down `n` cells. pub fn cursorDown(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'B'); } pub const cud = cursorDown; /// CSI n C — move cursor forward (right) `n` cells. pub fn cursorForward(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'C'); } pub const cuf = cursorForward; /// CSI n D — move cursor backward (left) `n` cells. pub fn cursorBackward(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'D'); } pub const cub = cursorBackward; /// CSI n G — move cursor to the given column (horizontal absolute). /// Parameter omitted for col <= 0 (defaults to 1). pub fn cursorHorizontalAbsolute(writer: *Writer, col: usize) Writer.Error!usize { return writeCsiPos(writer, col, 'G'); } pub const cha = cursorHorizontalAbsolute; /// CSI n G — alias for horizontal position absolute. pub fn horizontalPositionAbsolute(writer: *Writer, col: usize) Writer.Error!usize { return writeCsiPos(writer, col, 'G'); } pub const hpa = horizontalPositionAbsolute; pub const HorizontalPositionAbsolute = horizontalPositionAbsolute; /// CSI n d — move cursor to the given row (vertical absolute). pub fn verticalPositionAbsolute(writer: *Writer, row: usize) Writer.Error!usize { return writeCsiPos(writer, row, 'd'); } pub const vpa = verticalPositionAbsolute; /// CSI r ; c H — set cursor position. (1,1) collapses to `\x1b[H`. pub fn cursorPosition(writer: *Writer, col: usize, row: usize) Writer.Error!usize { if (row <= 1 and col <= 1) { try writer.writeAll("\x1b[H"); return 3; } var count: usize = 2; try writer.writeByte(0x1b); try writer.writeByte('['); if (row > 0) { const c = try writeNumber(writer, row); count += c; } try writer.writeByte(';'); if (col > 0) { const c = try writeNumber(writer, col); count += c; } try writer.writeByte('H'); return count + 2; } pub const cup = cursorPosition; /// ESC [ H — move cursor to upper-left corner of the scrolling region. pub const cursorHomePosition = "\x1b[H"; /// CSI n I — move cursor to the next tab stop `n` times. pub fn cursorHorizontalForwardTab(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'I'); } pub const cht = cursorHorizontalForwardTab; /// CSI n Z — move cursor to the previous tab stop `n` times. pub fn cursorBackwardTab(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'Z'); } pub const cbt = cursorBackwardTab; /// ESC M — reverse index (cursor up; scroll down at top margin). pub const reverseIndex = "\x1bM"; /// CSI n X — erase `n` characters (ECH). pub fn eraseCharacter(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'X'); } pub const ech = eraseCharacter; /// CSI n P — delete `n` characters (DCH). pub fn deleteCharacter(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'P'); } pub const dch = deleteCharacter; /// CSI n @ — insert `n` blank characters (ICH). pub fn insertCharacter(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, '@'); } pub const ich = insertCharacter; /// CSI n K — erase line (EL). pub fn eraseLine(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiPos(writer, n, 'K'); } pub const el = eraseLine; /// ESC [ K — clear from cursor to end of line. pub const eraseLineRight = "\x1b[K"; /// ESC [ 1K — clear from cursor to beginning of line. pub const eraseLineLeft = "\x1b[1K"; /// ESC [ 2K — clear entire line. pub const eraseEntireLine = "\x1b[2K"; /// CSI n J — erase display (ED). pub fn eraseDisplay(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiPos(writer, n, 'J'); } pub const ed = eraseDisplay; /// ESC [ J — clear from cursor to end of screen. pub const eraseScreenBelow = "\x1b[J"; /// ESC [ 1J — clear from cursor to beginning of screen. pub const eraseScreenAbove = "\x1b[1J"; /// ESC [ 2J — clear entire screen. pub const eraseEntireScreen = "\x1b[2J"; /// ESC [ 3J — clear entire display (including scrollback). pub const eraseEntireDisplay = "\x1b[3J"; /// CSI n L — insert `n` blank lines (IL). pub fn insertLine(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'L'); } pub const il = insertLine; /// CSI n M — delete `n` lines (DL). pub fn deleteLine(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'M'); } pub const dl = deleteLine; /// CSI n S — scroll screen up `n` lines (SU). pub fn scrollUp(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'S'); } pub const su = scrollUp; /// CSI n T — scroll screen down `n` lines (SD). pub fn scrollDown(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'T'); } pub const sd = scrollDown; /// CSI top ; bot r — set top and bottom scrolling margins (DECSTBM). pub fn setTopBottomMargins(writer: *Writer, top: usize, bot: usize) Writer.Error!usize { var count: usize = 2; try writer.writeByte(0x1b); try writer.writeByte('['); if (top > 0) { const c = try writeNumber(writer, top); count += c; } try writer.writeByte(';'); if (bot > 0) { const c = try writeNumber(writer, bot); count += c; } try writer.writeByte('r'); return count + 2; } pub const decstbm = setTopBottomMargins; /// CSI n b — repeat previous character `n` times (REP). pub fn repeatPreviousCharacter(writer: *Writer, n: usize) Writer.Error!usize { return writeCsiParam(writer, n, 'b'); } pub const rep = repeatPreviousCharacter; /// ESC [ ? 1049 h — enter alt screen, save cursor. pub const setModeAltScreenSaveCursor = "\x1b[?1049h"; /// ESC [ ? 1049 l — exit alt screen, restore cursor. pub const resetModeAltScreenSaveCursor = "\x1b[?1049l"; /// ESC [ ? 7 h — enable autowrap. pub const setModeAutoWrap = "\x1b[?7h"; /// ESC [ ? 7 l — disable autowrap. pub const resetModeAutoWrap = "\x1b[?7l"; /// ESC [ 4 h — enable insert/replace mode. pub const setModeInsertReplace = "\x1b[4h"; /// ESC [ 4 l — disable insert/replace mode. pub const resetModeInsertReplace = "\x1b[4l"; /// ESC [ ? 5 W — set tab stops every 8 columns. pub const setTabEvery8Columns = "\x1b[?5W"; /// ESC [ m — reset all styles. pub const resetStyle = "\x1b[m"; /// OSC 8 ; ; BEL — start a hyperlink. pub fn setHyperlink(writer: *Writer, uri: []const u8, params: []const u8) Writer.Error!usize { try writer.writeAll("\x1b]8;"); try writer.writeAll(params); try writer.writeByte(';'); try writer.writeAll(uri); try writer.writeByte(0x07); return 4 + params.len + 1 + uri.len + 1; } /// OSC 8 ; ; BEL — reset a hyperlink. pub fn resetHyperlink(writer: *Writer, params: []const u8) Writer.Error!usize { return setHyperlink(writer, "", params); } // --- window title / terminal colors / cursor style ------------------------- /// OSC 2 ; BEL — set the window title. Mirrors /// `ansi.SetWindowTitle` (`\x1b]2;{title}\x07`). pub fn setWindowTitle(writer: *Writer, title: []const u8) Writer.Error!usize { try writer.writeAll("\x1b]2;"); try writer.writeAll(title); try writer.writeByte(0x07); return 4 + title.len + 1; } /// OSC 10 ; <hex> BEL — set the terminal default foreground color. Mirrors /// `ansi.SetForegroundColor(hex)`. pub fn setForegroundColor(writer: *Writer, hex: []const u8) Writer.Error!usize { try writer.writeAll("\x1b]10;"); try writer.writeAll(hex); try writer.writeByte(0x07); return 5 + hex.len + 1; } /// OSC 110 BEL — reset the terminal default foreground color. pub const resetForegroundColor = "\x1b]110\x07"; /// OSC 11 ; <hex> BEL — set the terminal default background color. pub fn setBackgroundColor(writer: *Writer, hex: []const u8) Writer.Error!usize { try writer.writeAll("\x1b]11;"); try writer.writeAll(hex); try writer.writeByte(0x07); return 5 + hex.len + 1; } /// OSC 111 BEL — reset the terminal default background color. pub const resetBackgroundColor = "\x1b]111\x07"; /// OSC 12 ; <hex> BEL — set the terminal cursor color. pub fn setCursorColor(writer: *Writer, hex: []const u8) Writer.Error!usize { try writer.writeAll("\x1b]12;"); try writer.writeAll(hex); try writer.writeByte(0x07); return 5 + hex.len + 1; } /// OSC 112 BEL — reset the terminal cursor color. pub const resetCursorColor = "\x1b]112\x07"; /// CSI <style> q — set the cursor style (DECSCUSR). Mirrors /// `ansi.SetCursorStyle(style)` which never omits the parameter. pub fn setCursorStyle(writer: *Writer, style: usize) Writer.Error!usize { try writer.writeByte(0x1b); try writer.writeByte('['); const c = try writeNumber(writer, style); try writer.writeByte(' '); try writer.writeByte('q'); return c + 4; } // --- Windows Terminal progress bar (OSC 9;4) -------------------------------- /// Returns the bytes `ansi.SetProgressBar(pct)` emits (pct clamped to 0..100). pub fn progressBarSeq(pct: usize) [32]u8 { var seq: [32]u8 = undefined; const clamped = if (pct > 100) 100 else pct; var fw = Writer.fixed(&seq); _ = setProgressBar(&fw, clamped) catch unreachable; return seq; } /// OSC 9 ; 4 ; 1 ; <pct> BEL — set the progress bar to a percentage. pub fn setProgressBar(writer: *Writer, pct: usize) Writer.Error!usize { const clamped = if (pct > 100) 100 else pct; try writer.writeAll("\x1b]9;4;1;"); const c = try writeNumber(writer, clamped); try writer.writeByte(0x07); return 8 + c + 1; } /// OSC 9 ; 4 ; 2 ; <pct> BEL — set the progress bar to a percentage in the /// error state. pub fn setErrorProgressBar(writer: *Writer, pct: usize) Writer.Error!usize { const clamped = if (pct > 100) 100 else pct; try writer.writeAll("\x1b]9;4;2;"); const c = try writeNumber(writer, clamped); try writer.writeByte(0x07); return 8 + c + 1; } /// OSC 9 ; 4 ; 3 BEL — set the progress bar to the indeterminate state. pub const setIndeterminateProgressBar = "\x1b]9;4;3\x07"; /// OSC 9 ; 4 ; 4 ; <pct> BEL — set the progress bar to a percentage in the /// warning state. pub fn setWarningProgressBar(writer: *Writer, pct: usize) Writer.Error!usize { const clamped = if (pct > 100) 100 else pct; try writer.writeAll("\x1b]9;4;4;"); const c = try writeNumber(writer, clamped); try writer.writeByte(0x07); return 8 + c + 1; } /// OSC 9 ; 4 ; 0 BEL — hide/reset the progress bar. pub const resetProgressBar = "\x1b]9;4;0\x07"; // --- DEC/ANSI modes ---------------------------------------------------------- /// ESC [ ? 2026 h — enter synchronized output mode. pub const setModeSynchronizedOutput = "\x1b[?2026h"; /// ESC [ ? 2026 l — exit synchronized output mode. pub const resetModeSynchronizedOutput = "\x1b[?2026l"; /// ESC [ ? 25 h — show the text cursor. pub const setModeTextCursorEnable = "\x1b[?25h"; /// ESC [ ? 25 l — hide the text cursor. pub const resetModeTextCursorEnable = "\x1b[?25l"; /// ESC [ ? 2027 h — enable Unicode (grapheme) width mode (DEC 2027). pub const setModeUnicodeCore = "\x1b[?2027h"; /// ESC [ ? 2027 l — disable Unicode (grapheme) width mode (DEC 2027). pub const resetModeUnicodeCore = "\x1b[?2027l"; /// ESC [ ? 2004 h — enable bracketed paste mode. pub const setModeBracketedPaste = "\x1b[?2004h"; /// ESC [ ? 2004 l — disable bracketed paste mode. pub const resetModeBracketedPaste = "\x1b[?2004l"; /// ESC [ ? 1004 h — enable focus event reporting. pub const setModeFocusEvent = "\x1b[?1004h"; /// ESC [ ? 1004 l — disable focus event reporting. pub const resetModeFocusEvent = "\x1b[?1004l"; /// ESC [ ? 1002 h — enable mouse button + drag motion events. pub const setModeMouseButtonEvent = "\x1b[?1002h"; /// ESC [ ? 1002 l — disable mouse button + drag motion events. pub const resetModeMouseButtonEvent = "\x1b[?1002l"; /// ESC [ ? 1003 h — enable mouse any-motion events. pub const setModeMouseAnyEvent = "\x1b[?1003h"; /// ESC [ ? 1003 l — disable mouse any-motion events. pub const resetModeMouseAnyEvent = "\x1b[?1003l"; /// ESC [ ? 1006 h — enable SGR mouse encoding. pub const setModeMouseExtSgr = "\x1b[?1006h"; /// ESC [ ? 1006 l — disable SGR mouse encoding. pub const resetModeMouseExtSgr = "\x1b[?1006l"; // --- keyboard enhancements --------------------------------------------------- /// CSI > 4 ; 2 m — enable modifyOtherKeys level 2. pub const setModifyOtherKeys2 = "\x1b[>4;2m"; /// CSI > 4 m — reset modifyOtherKeys (level 0). pub const resetModifyOtherKeys = "\x1b[>4m"; /// ESC [ ? u — query the terminal's Kitty keyboard protocol flags. pub const requestKittyKeyboard = "\x1b[?u"; /// CSI = <flags> ; <mode> u — set the top-of-stack Kitty keyboard flags. /// Mirrors `ansi.KittyKeyboard(flags, mode)` (mode 1 sets, 2 sets-keeps, 3 /// unsets; bubbletea uses mode 1). pub fn kittyKeyboard(writer: *Writer, flags: usize, mode: usize) Writer.Error!usize { try writer.writeAll("\x1b[="); const a = try writeNumber(writer, flags); try writer.writeByte(';'); const b = try writeNumber(writer, mode); try writer.writeByte('u'); return 3 + a + 1 + b + 1; } /// CSI > <flags> u — push flags onto the Kitty keyboard stack. The parameter /// is omitted when flags is 0 (mirrors `ansi.PushKittyKeyboard`). pub fn pushKittyKeyboard(writer: *Writer, flags_in: usize) Writer.Error!usize { try writer.writeByte(0x1b); try writer.writeByte('['); try writer.writeByte('>'); if (flags_in > 0) _ = try writeNumber(writer, flags_in); try writer.writeByte('u'); return 4; } /// CSI < <n> u — pop n entries from the Kitty keyboard stack. The parameter /// is omitted when n is 0 (mirrors `ansi.PopKittyKeyboard`). pub fn popKittyKeyboard(writer: *Writer, n_in: usize) Writer.Error!usize { try writer.writeByte(0x1b); try writer.writeByte('['); try writer.writeByte('<'); if (n_in > 0) _ = try writeNumber(writer, n_in); try writer.writeByte('u'); return 4; } const testing = std.testing; /// this is the most pointless function on the face of the earth, just use w.buffered() fn fixedWriterOut(w: *Writer) []const u8 { return w.buffered(); } test "cursor movement byte parity with x/ansi" { var buf: [64]u8 = undefined; var w: Writer = .fixed(&buf); _ = try cursorUp(&w, 1); try t.expectEqualStrings("\x1b[A", fixedWriterOut(&w)); _ = try cursorUp(&w, 5); try t.expectEqualStrings("\x1b[A\x1b[5A", fixedWriterOut(&w)); _ = try cursorDown(&w, 2); try t.expectEqualStrings("\x1b[A\x1b[5A\x1b[2B", fixedWriterOut(&w)); _ = try cursorForward(&w, 10); try t.expectEqualStrings("\x1b[A\x1b[5A\x1b[2B\x1b[10C", fixedWriterOut(&w)); _ = try cursorBackward(&w, 1); try t.expectEqualStrings("\x1b[A\x1b[5A\x1b[2B\x1b[10C\x1b[D", fixedWriterOut(&w)); } test "absolute position byte parity with x/ansi" { var buf: [64]u8 = undefined; var w: Writer = .fixed(&buf); _ = try cursorHorizontalAbsolute(&w, 1); try t.expectEqualStrings("\x1b[1G", fixedWriterOut(&w)); // col 1 always written _ = try cursorHorizontalAbsolute(&w, 3); try t.expectEqualStrings("\x1b[1G\x1b[3G", fixedWriterOut(&w)); _ = try verticalPositionAbsolute(&w, 4); try t.expectEqualStrings("\x1b[1G\x1b[3G\x1b[4d", fixedWriterOut(&w)); } test "cursorPosition collapses (1,1) to home" { var buf: [64]u8 = undefined; var w: Writer = .fixed(&buf); _ = try cursorPosition(&w, 1, 1); try t.expectEqualStrings("\x1b[H", fixedWriterOut(&w)); _ = try cursorPosition(&w, 3, 2); try t.expectEqualStrings("\x1b[H\x1b[2;3H", fixedWriterOut(&w)); } test "erase and charset sequences" { var buf: [64]u8 = undefined; var w: Writer = .fixed(&buf); _ = try eraseCharacter(&w, 4); try t.expectEqualStrings("\x1b[4X", fixedWriterOut(&w)); _ = try deleteCharacter(&w, 1); try t.expectEqualStrings("\x1b[4X\x1b[P", fixedWriterOut(&w)); _ = try insertCharacter(&w, 2); try t.expectEqualStrings("\x1b[4X\x1b[P\x1b[2@", fixedWriterOut(&w)); _ = try repeatPreviousCharacter(&w, 3); try t.expectEqualStrings("\x1b[4X\x1b[P\x1b[2@\x1b[3b", fixedWriterOut(&w)); } test "line and screen ops" { var buf: [64]u8 = undefined; var w: Writer = .fixed(&buf); _ = try insertLine(&w, 1); try t.expectEqualStrings("\x1b[L", fixedWriterOut(&w)); _ = try deleteLine(&w, 2); try t.expectEqualStrings("\x1b[L\x1b[2M", fixedWriterOut(&w)); _ = try scrollUp(&w, 3); try t.expectEqualStrings("\x1b[L\x1b[2M\x1b[3S", fixedWriterOut(&w)); _ = try scrollDown(&w, 1); try t.expectEqualStrings("\x1b[L\x1b[2M\x1b[3S\x1b[T", fixedWriterOut(&w)); _ = try setTopBottomMargins(&w, 1, 24); try t.expectEqualStrings("\x1b[L\x1b[2M\x1b[3S\x1b[T\x1b[1;24r", fixedWriterOut(&w)); } test "hyperlink sequences" { var buf: [128]u8 = undefined; var w: Writer = .fixed(&buf); _ = try setHyperlink(&w, "https://example.com", ""); try t.expectEqualStrings("\x1b]8;;https://example.com\x07", fixedWriterOut(&w)); _ = try resetHyperlink(&w, ""); try t.expectEqualStrings("\x1b]8;;https://example.com\x07\x1b]8;;\x07", fixedWriterOut(&w)); }