From 368f4f565a79d322c7cca749e4ceb37d6249268d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 14 Nov 2025 13:19:16 -0800 Subject: [PATCH] terminal: Screen opts is a structure --- src/Surface.zig | 4 +- src/font/shaper/coretext.zig | 58 ++-- src/font/shaper/harfbuzz.zig | 32 +-- src/renderer/cell.zig | 2 +- src/renderer/link.zig | 6 +- src/terminal/Screen.zig | 364 +++++++++++++------------ src/terminal/Selection.zig | 36 +-- src/terminal/StringMap.zig | 2 +- src/terminal/Terminal.zig | 6 +- src/terminal/search/sliding_window.zig | 36 +-- 10 files changed, 282 insertions(+), 264 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index a44563ad4..f41e2f409 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -5696,7 +5696,7 @@ fn testMouseSelection( .padding = .{ .left = 5, .top = 5, .right = 5, .bottom = 5 }, .screen = .{ .width = 110, .height = 110 }, }; - var screen = try terminal.Screen.init(std.testing.allocator, 10, 5, 0); + var screen = try terminal.Screen.init(std.testing.allocator, .{ .cols = 10, .rows = 5, .max_scrollback = 0 }); defer screen.deinit(); // We hold both ctrl and alt for rectangular @@ -5765,7 +5765,7 @@ fn testMouseSelectionIsNull( .padding = .{ .left = 5, .top = 5, .right = 5, .bottom = 5 }, .screen = .{ .width = 110, .height = 110 }, }; - var screen = try terminal.Screen.init(std.testing.allocator, 10, 5, 0); + var screen = try terminal.Screen.init(std.testing.allocator, .{ .cols = 10, .rows = 5, .max_scrollback = 0 }); defer screen.deinit(); // We hold both ctrl and alt for rectangular diff --git a/src/font/shaper/coretext.zig b/src/font/shaper/coretext.zig index f1368679d..d73b191b8 100644 --- a/src/font/shaper/coretext.zig +++ b/src/font/shaper/coretext.zig @@ -598,7 +598,7 @@ test "run iterator" { { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("ABCD"); @@ -616,7 +616,7 @@ test "run iterator" { // Spaces should be part of a run { - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("ABCD EFG"); @@ -633,7 +633,7 @@ test "run iterator" { { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("A😃D"); @@ -652,7 +652,7 @@ test "run iterator" { // Bad ligatures for (&[_][]const u8{ "fl", "fi", "st" }) |bad| { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(bad); @@ -678,7 +678,7 @@ test "run iterator: empty cells with background set" { { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.setAttribute(.{ .direct_color_bg = .{ .r = 0xFF, .g = 0, .b = 0 } }); try screen.testWriteString("A"); @@ -731,7 +731,7 @@ test "shape" { buf_idx += try std.unicode.utf8Encode(0x1F3FD, buf[buf_idx..]); // Medium skin tone // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -764,7 +764,7 @@ test "shape nerd fonts" { buf_idx += try std.unicode.utf8Encode(' ', buf[buf_idx..]); // space // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -791,7 +791,7 @@ test "shape inconsolata ligs" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(">="); @@ -814,7 +814,7 @@ test "shape inconsolata ligs" { } { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("==="); @@ -845,7 +845,7 @@ test "shape monaspace ligs" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("==="); @@ -877,7 +877,7 @@ test "shape left-replaced lig in last run" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("!=="); @@ -909,7 +909,7 @@ test "shape left-replaced lig in early run" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("!==X"); @@ -938,7 +938,7 @@ test "shape U+3C9 with JB Mono" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("\u{03C9} foo"); @@ -969,7 +969,7 @@ test "shape emoji width" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("👍"); @@ -998,7 +998,7 @@ test "shape emoji width long" { defer testdata.deinit(); // Make a screen and add a long emoji sequence to it. - var screen = try terminal.Screen.init(alloc, 30, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 30, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); var page = screen.pages.pages.first.?.data; @@ -1050,7 +1050,7 @@ test "shape variation selector VS15" { buf_idx += try std.unicode.utf8Encode(0xFE0E, buf[buf_idx..]); // ZWJ to force text // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -1083,7 +1083,7 @@ test "shape variation selector VS16" { buf_idx += try std.unicode.utf8Encode(0xFE0F, buf[buf_idx..]); // ZWJ to force color // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -1111,7 +1111,7 @@ test "shape with empty cells in between" { defer testdata.deinit(); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 30, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 30, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("A"); screen.cursorRight(5); @@ -1149,7 +1149,7 @@ test "shape Chinese characters" { buf_idx += try std.unicode.utf8Encode('a', buf[buf_idx..]); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 30, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 30, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -1187,7 +1187,7 @@ test "shape box glyphs" { buf_idx += try std.unicode.utf8Encode(0x2501, buf[buf_idx..]); // // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -1219,7 +1219,7 @@ test "shape selection boundary" { defer testdata.deinit(); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("a1b2c3d4e5"); @@ -1342,7 +1342,7 @@ test "shape cursor boundary" { defer testdata.deinit(); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("a1b2c3d4e5"); @@ -1479,7 +1479,7 @@ test "shape cursor boundary and colored emoji" { defer testdata.deinit(); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 3, 10, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 3, .rows = 10, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("👍🏼"); @@ -1574,7 +1574,7 @@ test "shape cell attribute change" { // Plain >= should shape into 1 run { - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(">="); @@ -1594,7 +1594,7 @@ test "shape cell attribute change" { // Bold vs regular should split { - var screen = try terminal.Screen.init(alloc, 3, 10, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 3, .rows = 10, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(">"); try screen.setAttribute(.{ .bold = {} }); @@ -1616,7 +1616,7 @@ test "shape cell attribute change" { // Changing fg color should split { - var screen = try terminal.Screen.init(alloc, 3, 10, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 3, .rows = 10, .max_scrollback = 0 }); defer screen.deinit(); try screen.setAttribute(.{ .direct_color_fg = .{ .r = 1, .g = 2, .b = 3 } }); try screen.testWriteString(">"); @@ -1639,7 +1639,7 @@ test "shape cell attribute change" { // Changing bg color should NOT split { - var screen = try terminal.Screen.init(alloc, 3, 10, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 3, .rows = 10, .max_scrollback = 0 }); defer screen.deinit(); try screen.setAttribute(.{ .direct_color_bg = .{ .r = 1, .g = 2, .b = 3 } }); try screen.testWriteString(">"); @@ -1662,7 +1662,7 @@ test "shape cell attribute change" { // Same bg color should not split { - var screen = try terminal.Screen.init(alloc, 3, 10, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 3, .rows = 10, .max_scrollback = 0 }); defer screen.deinit(); try screen.setAttribute(.{ .direct_color_bg = .{ .r = 1, .g = 2, .b = 3 } }); try screen.testWriteString(">"); @@ -1700,7 +1700,7 @@ test "shape high plane sprite font codepoint" { var testdata = try testShaper(alloc); defer testdata.deinit(); - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); // U+1FB70: Vertical One Eighth Block-2 diff --git a/src/font/shaper/harfbuzz.zig b/src/font/shaper/harfbuzz.zig index b5c96797f..634afd0de 100644 --- a/src/font/shaper/harfbuzz.zig +++ b/src/font/shaper/harfbuzz.zig @@ -207,7 +207,7 @@ test "run iterator" { { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("ABCD"); @@ -225,7 +225,7 @@ test "run iterator" { // Spaces should be part of a run { - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("ABCD EFG"); @@ -242,7 +242,7 @@ test "run iterator" { { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("A😃D"); @@ -273,7 +273,7 @@ test "run iterator: empty cells with background set" { { // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.setAttribute(.{ .direct_color_bg = .{ .r = 0xFF, .g = 0, .b = 0 } }); try screen.testWriteString("A"); @@ -327,7 +327,7 @@ test "shape" { buf_idx += try std.unicode.utf8Encode(0x1F3FD, buf[buf_idx..]); // Medium skin tone // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -355,7 +355,7 @@ test "shape inconsolata ligs" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(">="); @@ -378,7 +378,7 @@ test "shape inconsolata ligs" { } { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("==="); @@ -409,7 +409,7 @@ test "shape monaspace ligs" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("==="); @@ -443,7 +443,7 @@ test "shape arabic forced LTR" { var testdata = try testShaperWithFont(alloc, .arabic); defer testdata.deinit(); - var screen = try terminal.Screen.init(alloc, 120, 30, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 120, .rows = 30, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(@embedFile("testdata/arabic.txt")); @@ -478,7 +478,7 @@ test "shape emoji width" { defer testdata.deinit(); { - var screen = try terminal.Screen.init(alloc, 5, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("👍"); @@ -563,7 +563,7 @@ test "shape variation selector VS15" { buf_idx += try std.unicode.utf8Encode(0xFE0E, buf[buf_idx..]); // ZWJ to force text // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -598,7 +598,7 @@ test "shape variation selector VS16" { buf_idx += try std.unicode.utf8Encode(0xFE0F, buf[buf_idx..]); // ZWJ to force color // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -704,7 +704,7 @@ test "shape box glyphs" { buf_idx += try std.unicode.utf8Encode(0x2501, buf[buf_idx..]); // // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(buf[0..buf_idx]); @@ -737,7 +737,7 @@ test "shape selection boundary" { defer testdata.deinit(); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("a1b2c3d4e5"); @@ -860,7 +860,7 @@ test "shape cursor boundary" { defer testdata.deinit(); // Make a screen with some data - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString("a1b2c3d4e5"); @@ -1092,7 +1092,7 @@ test "shape cell attribute change" { // Plain >= should shape into 1 run { - var screen = try terminal.Screen.init(alloc, 10, 3, 0); + var screen = try terminal.Screen.init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer screen.deinit(); try screen.testWriteString(">="); diff --git a/src/renderer/cell.zig b/src/renderer/cell.zig index d8427689b..1e371b07e 100644 --- a/src/renderer/cell.zig +++ b/src/renderer/cell.zig @@ -524,7 +524,7 @@ test "Cell constraint widths" { const testing = std.testing; const alloc = testing.allocator; - var s = try terminal.Screen.init(alloc, 4, 1, 0); + var s = try terminal.Screen.init(alloc, .{ .cols = 4, .rows = 1, .max_scrollback = 0 }); defer s.deinit(); // for each case, the numbers in the comment denote expected diff --git a/src/renderer/link.zig b/src/renderer/link.zig index 9f489ed48..40a25ea19 100644 --- a/src/renderer/link.zig +++ b/src/renderer/link.zig @@ -398,7 +398,7 @@ test "matchset" { const alloc = testing.allocator; // Initialize our screen - var s = try Screen.init(alloc, 5, 5, 0); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); @@ -456,7 +456,7 @@ test "matchset hover links" { const alloc = testing.allocator; // Initialize our screen - var s = try Screen.init(alloc, 5, 5, 0); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); @@ -549,7 +549,7 @@ test "matchset mods no match" { const alloc = testing.allocator; // Initialize our screen - var s = try Screen.init(alloc, 5, 5, 0); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 5b90bf41b..c4c3bed57 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -175,6 +175,21 @@ pub const CharsetState = struct { const CharsetArray = std.EnumArray(charsets.Slots, charsets.Charset); }; +pub const Options = struct { + cols: size.CellCountInt, + rows: size.CellCountInt, + max_scrollback: usize = 0, + + /// A simple, default terminal. If you rely on specific dimensions or + /// scrollback (or lack of) then do not use this directly. This is just + /// for callers that need some defaults. + pub const default: Options = .{ + .cols = 80, + .rows = 24, + .max_scrollback = 0, + }; +}; + /// Initialize a new screen. /// /// max_scrollback is the amount of scrollback to keep in bytes. This @@ -184,12 +199,15 @@ pub const CharsetState = struct { /// If max scrollback is 0, then no scrollback is kept at all. pub fn init( alloc: Allocator, - cols: size.CellCountInt, - rows: size.CellCountInt, - max_scrollback: usize, + opts: Options, ) !Screen { // Initialize our backing pages. - var pages = try PageList.init(alloc, cols, rows, max_scrollback); + var pages = try PageList.init( + alloc, + opts.cols, + opts.rows, + opts.max_scrollback, + ); errdefer pages.deinit(); // Create our tracked pin for the cursor. @@ -200,7 +218,7 @@ pub fn init( return .{ .alloc = alloc, .pages = pages, - .no_scrollback = max_scrollback == 0, + .no_scrollback = opts.max_scrollback == 0, .cursor = .{ .x = 0, .y = 0, @@ -3028,7 +3046,7 @@ test "Screen read and write" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); try testing.expectEqual(@as(style.Id, 0), s.cursor.style_id); @@ -3042,7 +3060,7 @@ test "Screen read and write newline" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); try testing.expectEqual(@as(style.Id, 0), s.cursor.style_id); @@ -3056,7 +3074,7 @@ test "Screen read and write scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 2, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 2, .max_scrollback = 1000 }); defer s.deinit(); try s.testWriteString("hello\nworld\ntest"); @@ -3076,7 +3094,7 @@ test "Screen read and write no scrollback small" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 2, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 2, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("hello\nworld\ntest"); @@ -3096,7 +3114,7 @@ test "Screen read and write no scrollback large" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 2, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 2, .max_scrollback = 0 }); defer s.deinit(); for (0..1_000) |i| { @@ -3117,13 +3135,13 @@ test "Screen cursorCopy x/y" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 10, 10, 0); + var s = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); s.cursorAbsolute(2, 3); try testing.expect(s.cursor.x == 2); try testing.expect(s.cursor.y == 3); - var s2 = try Screen.init(alloc, 10, 10, 0); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s2.deinit(); try s2.cursorCopy(s.cursor, .{}); try testing.expect(s2.cursor.x == 2); @@ -3141,10 +3159,10 @@ test "Screen cursorCopy style deref" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 10, 10, 0); + var s = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); - var s2 = try Screen.init(alloc, 10, 10, 0); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s2.deinit(); const page = &s2.cursor.page_pin.node.data; @@ -3163,10 +3181,10 @@ test "Screen cursorCopy style deref new page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); - var s2 = try Screen.init(alloc, 10, 10, 2048); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 2048 }); defer s2.deinit(); // We need to get the cursor on a new page. @@ -3236,11 +3254,11 @@ test "Screen cursorCopy style copy" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 10, 10, 0); + var s = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.setAttribute(.{ .bold = {} }); - var s2 = try Screen.init(alloc, 10, 10, 0); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s2.deinit(); const page = &s2.cursor.page_pin.node.data; try s2.cursorCopy(s.cursor, .{}); @@ -3252,10 +3270,10 @@ test "Screen cursorCopy hyperlink deref" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 10, 10, 0); + var s = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); - var s2 = try Screen.init(alloc, 10, 10, 0); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s2.deinit(); const page = &s2.cursor.page_pin.node.data; @@ -3274,10 +3292,10 @@ test "Screen cursorCopy hyperlink deref new page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); - var s2 = try Screen.init(alloc, 10, 10, 2048); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 2048 }); defer s2.deinit(); // We need to get the cursor on a new page. @@ -3347,7 +3365,7 @@ test "Screen cursorCopy hyperlink copy" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 10, 10, 0); + var s = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); // Create a hyperlink for the cursor. @@ -3355,7 +3373,7 @@ test "Screen cursorCopy hyperlink copy" { try testing.expectEqual(@as(usize, 1), s.cursor.page_pin.node.data.hyperlink_set.count()); try testing.expect(s.cursor.hyperlink_id != 0); - var s2 = try Screen.init(alloc, 10, 10, 0); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s2.deinit(); const page = &s2.cursor.page_pin.node.data; @@ -3372,7 +3390,7 @@ test "Screen cursorCopy hyperlink copy disabled" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 10, 10, 0); + var s = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); // Create a hyperlink for the cursor. @@ -3380,7 +3398,7 @@ test "Screen cursorCopy hyperlink copy disabled" { try testing.expectEqual(@as(usize, 1), s.cursor.page_pin.node.data.hyperlink_set.count()); try testing.expect(s.cursor.hyperlink_id != 0); - var s2 = try Screen.init(alloc, 10, 10, 0); + var s2 = try Screen.init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s2.deinit(); const page = &s2.cursor.page_pin.node.data; @@ -3397,7 +3415,7 @@ test "Screen style basics" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); const page = &s.cursor.page_pin.node.data; try testing.expectEqual(@as(usize, 0), page.styles.count()); @@ -3419,7 +3437,7 @@ test "Screen style reset to default" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); const page = &s.cursor.page_pin.node.data; try testing.expectEqual(@as(usize, 0), page.styles.count()); @@ -3439,7 +3457,7 @@ test "Screen style reset with unset" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); const page = &s.cursor.page_pin.node.data; try testing.expectEqual(@as(usize, 0), page.styles.count()); @@ -3459,7 +3477,7 @@ test "Screen clearRows active one line" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); try s.testWriteString("hello, world"); @@ -3474,7 +3492,7 @@ test "Screen clearRows active multi line" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); try s.testWriteString("hello\nworld"); @@ -3490,7 +3508,7 @@ test "Screen clearRows active styled line" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); try s.setAttribute(.{ .bold = {} }); @@ -3515,7 +3533,7 @@ test "Screen clearRows protected" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); try s.testWriteString("UNPROTECTED"); @@ -3543,7 +3561,7 @@ test "Screen eraseRows history" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 5, 5, 1000); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 1000 }); defer s.deinit(); try s.testWriteString("1\n2\n3\n4\n5\n6"); @@ -3577,7 +3595,7 @@ test "Screen eraseRows history with more lines" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 5, 5, 1000); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 1000 }); defer s.deinit(); try s.testWriteString("A\nB\nC\n1\n2\n3\n4\n5\n6"); @@ -3611,7 +3629,7 @@ test "Screen eraseRows active partial" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 5, 5, 0); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1\n2\n3"); @@ -3640,7 +3658,7 @@ test "Screen: clearPrompt" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); // Set one of the rows to be a prompt @@ -3661,7 +3679,7 @@ test "Screen: clearPrompt continuation" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 4, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 4, .max_scrollback = 0 }); defer s.deinit(); // Set one of the rows to be a prompt followed by a continuation row @@ -3683,7 +3701,7 @@ test "Screen: clearPrompt consecutive inputs" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); // Set both rows to be inputs @@ -3704,7 +3722,7 @@ test "Screen: clearPrompt no prompt" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -3722,7 +3740,7 @@ test "Screen: cursorDown across pages preserves style" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); // Scroll down enough to go to another page @@ -3774,7 +3792,7 @@ test "Screen: cursorUp across pages preserves style" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); // Scroll down enough to go to another page @@ -3821,7 +3839,7 @@ test "Screen: cursorAbsolute across pages preserves style" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); // Scroll down enough to go to another page @@ -3876,7 +3894,7 @@ test "Screen: cursorAbsolute to page with insufficient capacity" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); // Scroll down enough to go to another page @@ -3943,7 +3961,7 @@ test "Screen: scrolling" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); try s.setAttribute(.{ .direct_color_bg = .{ .r = 155 } }); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -3985,7 +4003,7 @@ test "Screen: scrolling with a single-row screen no scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 1, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 1, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1ABCD"); @@ -4005,7 +4023,7 @@ test "Screen: scrolling with a single-row screen with scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 1, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 1, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD"); @@ -4035,7 +4053,7 @@ test "Screen: scrolling across pages preserves style" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.setAttribute(.{ .bold = {} }); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -4064,7 +4082,7 @@ test "Screen: scroll down from 0" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -4083,7 +4101,7 @@ test "Screen: scrollback various cases" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); try s.cursorDownScroll(); @@ -4164,7 +4182,7 @@ test "Screen: scrollback with multi-row delta" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 3); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH\n6IJKL"); @@ -4190,7 +4208,7 @@ test "Screen: scrollback empty" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 50); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 50 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); s.scroll(.{ .delta_row = 1 }); @@ -4205,7 +4223,7 @@ test "Screen: scrollback doesn't move viewport if not at bottom" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 3); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"); @@ -4240,7 +4258,7 @@ test "Screen: scrolling moves selection" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -4319,7 +4337,7 @@ test "Screen: scrolling moves viewport" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 1); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n"); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -4344,7 +4362,7 @@ test "Screen: scrolling when viewport is pruned" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 215, 3, 1); + var s = try init(alloc, .{ .cols = 215, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); // Write some to create scrollback and move back into our scrollback. @@ -4370,7 +4388,7 @@ test "Screen: scroll and clear full screen" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 5); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -4397,7 +4415,7 @@ test "Screen: scroll and clear partial screen" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 5); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH"); @@ -4424,7 +4442,7 @@ test "Screen: scroll and clear empty screen" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 5); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); try s.scrollClear(); { @@ -4443,7 +4461,7 @@ test "Screen: scroll and clear ignore blank lines" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH"); try s.scrollClear(); @@ -4486,7 +4504,7 @@ test "Screen: scroll above same page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); try s.setAttribute(.{ .direct_color_bg = .{ .r = 155 } }); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -4545,7 +4563,7 @@ test "Screen: scroll above same page but cursor on previous page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 5, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 5, .max_scrollback = 10 }); defer s.deinit(); // We need to get the cursor to a new page @@ -4626,7 +4644,7 @@ test "Screen: scroll above same page but cursor on previous page last row" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 5, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 5, .max_scrollback = 10 }); defer s.deinit(); // We need to get the cursor to a new page @@ -4716,7 +4734,7 @@ test "Screen: scroll above creates new page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); // We need to get the cursor to a new page @@ -4788,7 +4806,7 @@ test "Screen: scroll above with cursor on non-final row" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 4, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 4, .max_scrollback = 10 }); defer s.deinit(); // Get the cursor to be 2 rows above a new page @@ -4865,7 +4883,7 @@ test "Screen: scroll above no scrollback bottom of page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const first_page_size = s.pages.pages.first.?.data.capacity.rows; @@ -4930,7 +4948,7 @@ test "Screen: clone" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH"); { @@ -4972,7 +4990,7 @@ test "Screen: clone partial" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH"); { @@ -5001,7 +5019,7 @@ test "Screen: clone partial cursor out of bounds" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 10); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH"); { @@ -5034,7 +5052,7 @@ test "Screen: clone contains full selection" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -5071,7 +5089,7 @@ test "Screen: clone contains none of selection" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -5098,7 +5116,7 @@ test "Screen: clone contains selection start cutoff" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -5135,7 +5153,7 @@ test "Screen: clone contains selection end cutoff" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -5172,7 +5190,7 @@ test "Screen: clone contains selection end cutoff reversed" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -5209,7 +5227,7 @@ test "Screen: clone contains subset of selection" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 4, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 4, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n4ABCD"); @@ -5246,7 +5264,7 @@ test "Screen: clone contains subset of rectangle selection" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 4, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 4, .max_scrollback = 1 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n4ABCD"); @@ -5285,7 +5303,7 @@ test "Screen: clone basic" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL"); @@ -5322,7 +5340,7 @@ test "Screen: clone empty viewport" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); { @@ -5344,7 +5362,7 @@ test "Screen: clone one line viewport" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1ABC"); @@ -5367,7 +5385,7 @@ test "Screen: clone empty active" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); { @@ -5389,7 +5407,7 @@ test "Screen: clone one line active with extra space" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1ABC"); @@ -5412,7 +5430,7 @@ test "Screen: clear history with no history" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 3); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); try s.testWriteString("4ABCD\n5EFGH\n6IJKL"); try testing.expect(s.pages.viewport == .active); @@ -5436,7 +5454,7 @@ test "Screen: clear history" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 3); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH\n6IJKL"); try testing.expect(s.pages.viewport == .active); @@ -5470,7 +5488,7 @@ test "Screen: clear above cursor" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 3); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 3 }); defer s.deinit(); try s.testWriteString("4ABCD\n5EFGH\n6IJKL"); s.clearRows( @@ -5497,7 +5515,7 @@ test "Screen: clear above cursor with history" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 3); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n"); try s.testWriteString("4ABCD\n5EFGH\n6IJKL"); @@ -5525,7 +5543,7 @@ test "Screen: resize (no reflow) more rows" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5543,7 +5561,7 @@ test "Screen: resize (no reflow) less rows" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5566,7 +5584,7 @@ test "Screen: resize (no reflow) less rows trims blank lines" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD"; try s.testWriteString(str); @@ -5601,7 +5619,7 @@ test "Screen: resize (no reflow) more rows trims blank lines" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD"; try s.testWriteString(str); @@ -5636,7 +5654,7 @@ test "Screen: resize (no reflow) more cols" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5653,7 +5671,7 @@ test "Screen: resize (no reflow) less cols" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5671,7 +5689,7 @@ test "Screen: resize (no reflow) more rows with scrollback cursor end" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 7, 3, 2); + var s = try init(alloc, .{ .cols = 7, .rows = 3, .max_scrollback = 2 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -5688,7 +5706,7 @@ test "Screen: resize (no reflow) less rows with scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 7, 3, 2); + var s = try init(alloc, .{ .cols = 7, .rows = 3, .max_scrollback = 2 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -5707,7 +5725,7 @@ test "Screen: resize (no reflow) less rows with empty trailing" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1\n2\n3\n4\n5\n6\n7\n8"; try s.testWriteString(str); @@ -5731,7 +5749,7 @@ test "Screen: resize (no reflow) more rows with soft wrapping" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 3, 3); + var s = try init(alloc, .{ .cols = 2, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); const str = "1A2B\n3C4E\n5F6G"; try s.testWriteString(str); @@ -5772,7 +5790,7 @@ test "Screen: resize more rows no scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5799,7 +5817,7 @@ test "Screen: resize more rows with empty scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 10); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5826,7 +5844,7 @@ test "Screen: resize more rows with populated scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -5871,7 +5889,7 @@ test "Screen: resize more cols no reflow" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -5900,7 +5918,7 @@ test "Screen: resize more cols perfect split" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH3IJKL"; try s.testWriteString(str); @@ -5918,7 +5936,7 @@ test "Screen: resize (no reflow) more cols with scrollback scrolled up" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1\n2\n3\n4\n5\n6\n7\n8"; try s.testWriteString(str); @@ -5951,7 +5969,7 @@ test "Screen: resize (no reflow) less cols with scrollback scrolled up" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1\n2\n3\n4\n5\n6\n7\n8"; try s.testWriteString(str); @@ -5995,7 +6013,7 @@ test "Screen: resize more cols no reflow preserves semantic prompt" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); // Set one of the rows to be a prompt @@ -6036,7 +6054,7 @@ test "Screen: resize more cols with reflow that fits full width" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); @@ -6076,7 +6094,7 @@ test "Screen: resize more cols with reflow that ends in newline" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 6, 3, 0); + var s = try init(alloc, .{ .cols = 6, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); @@ -6121,7 +6139,7 @@ test "Screen: resize more cols with reflow that forces more wrapping" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); @@ -6162,7 +6180,7 @@ test "Screen: resize more cols with reflow that unwraps multiple times" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH3IJKL"; try s.testWriteString(str); @@ -6203,7 +6221,7 @@ test "Screen: resize more cols with populated scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD5EFGH"; try s.testWriteString(str); @@ -6247,7 +6265,7 @@ test "Screen: resize more cols with reflow" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 3, 5); + var s = try init(alloc, .{ .cols = 2, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1ABC\n2DEF\n3ABC\n4DEF"; try s.testWriteString(str); @@ -6288,7 +6306,7 @@ test "Screen: resize more rows and cols with wrapping" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 4, 0); + var s = try init(alloc, .{ .cols = 2, .rows = 4, .max_scrollback = 0 }); defer s.deinit(); const str = "1A2B\n3C4D"; try s.testWriteString(str); @@ -6321,7 +6339,7 @@ test "Screen: resize less rows no scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -6352,7 +6370,7 @@ test "Screen: resize less rows moving cursor" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -6392,7 +6410,7 @@ test "Screen: resize less rows with empty scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 10); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -6415,7 +6433,7 @@ test "Screen: resize less rows with populated scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -6446,7 +6464,7 @@ test "Screen: resize less rows with full scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 3); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); const str = "00000\n1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -6486,7 +6504,7 @@ test "Screen: resize less cols no reflow" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1AB\n2EF\n3IJ"; try s.testWriteString(str); @@ -6515,7 +6533,7 @@ test "Screen: resize less cols with reflow but row space" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); const str = "1ABCD"; try s.testWriteString(str); @@ -6553,7 +6571,7 @@ test "Screen: resize less cols with reflow with trimmed rows" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -6577,7 +6595,7 @@ test "Screen: resize less cols with reflow with trimmed rows and scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 1); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 1 }); defer s.deinit(); const str = "3IJKL\n4ABCD\n5EFGH"; try s.testWriteString(str); @@ -6601,7 +6619,7 @@ test "Screen: resize less cols with reflow previously wrapped" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "3IJKL4ABCD5EFGH"; try s.testWriteString(str); @@ -6634,7 +6652,7 @@ test "Screen: resize less cols with reflow and scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1A\n2B\n3C\n4D\n5E"; try s.testWriteString(str); @@ -6667,7 +6685,7 @@ test "Screen: resize less cols with reflow previously wrapped and scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 2); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 2 }); defer s.deinit(); const str = "1ABCD2EFGH3IJKL4ABCD5EFGH"; try s.testWriteString(str); @@ -6721,7 +6739,7 @@ test "Screen: resize less cols with scrollback keeps cursor row" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 5); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); const str = "1A\n2B\n3C\n4D\n5E"; try s.testWriteString(str); @@ -6750,7 +6768,7 @@ test "Screen: resize more rows, less cols with reflow with scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 3); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 3 }); defer s.deinit(); const str = "1ABCD\n2EFGH3IJKL\n4MNOP"; try s.testWriteString(str); @@ -6791,7 +6809,7 @@ test "Screen: resize more rows then shrink again" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 10); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 10 }); defer s.deinit(); const str = "1ABC"; try s.testWriteString(str); @@ -6840,7 +6858,7 @@ test "Screen: resize less cols to eliminate wide char" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 1, 0); + var s = try init(alloc, .{ .cols = 2, .rows = 1, .max_scrollback = 0 }); defer s.deinit(); const str = "😀"; try s.testWriteString(str); @@ -6875,7 +6893,7 @@ test "Screen: resize less cols to wrap wide char" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 3, 3, 0); + var s = try init(alloc, .{ .cols = 3, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "x😀"; try s.testWriteString(str); @@ -6914,7 +6932,7 @@ test "Screen: resize less cols to eliminate wide char with row space" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 2, 0); + var s = try init(alloc, .{ .cols = 2, .rows = 2, .max_scrollback = 0 }); defer s.deinit(); const str = "😀"; try s.testWriteString(str); @@ -6947,7 +6965,7 @@ test "Screen: resize more cols with wide spacer head" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 3, 2, 0); + var s = try init(alloc, .{ .cols = 3, .rows = 2, .max_scrollback = 0 }); defer s.deinit(); const str = " 😀"; try s.testWriteString(str); @@ -7000,7 +7018,7 @@ test "Screen: resize more cols with wide spacer head multiple lines" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 3, 3, 0); + var s = try init(alloc, .{ .cols = 3, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "xxxyy😀"; try s.testWriteString(str); @@ -7051,7 +7069,7 @@ test "Screen: resize more cols requiring a wide spacer head" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 2, 0); + var s = try init(alloc, .{ .cols = 2, .rows = 2, .max_scrollback = 0 }); defer s.deinit(); const str = "xx😀"; try s.testWriteString(str); @@ -7102,7 +7120,7 @@ test "Screen: select untracked" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("ABC DEF\n 123\n456"); @@ -7122,7 +7140,7 @@ test "Screen: selectAll" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); { @@ -7158,7 +7176,7 @@ test "Screen: selectLine" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("ABC DEF\n 123\n456"); @@ -7239,7 +7257,7 @@ test "Screen: selectLine across soft-wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString(" 12 34012 \n 123"); @@ -7265,7 +7283,7 @@ test "Screen: selectLine across full soft-wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1ABCD2EFGH\n3IJKL"); @@ -7290,7 +7308,7 @@ test "Screen: selectLine across soft-wrap ignores blank lines" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString(" 12 34012 \n 123"); @@ -7350,7 +7368,7 @@ test "Screen: selectLine disabled whitespace trimming" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString(" 12 34012 \n 123"); @@ -7399,7 +7417,7 @@ test "Screen: selectLine with scrollback" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 2, 3, 5); + var s = try init(alloc, .{ .cols = 2, .rows = 3, .max_scrollback = 5 }); defer s.deinit(); try s.testWriteString("1A\n2B\n3C\n4D\n5E"); @@ -7443,7 +7461,7 @@ test "Screen: selectLine semantic prompt boundary" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteSemanticString("ABCDE\n", .unknown); try s.testWriteSemanticString("A ", .prompt); @@ -7492,7 +7510,7 @@ test "Screen: selectWord" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 10, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("ABC DEF\n 123\n456"); @@ -7607,7 +7625,7 @@ test "Screen: selectWord across soft-wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString(" 1234012\n 123"); @@ -7673,7 +7691,7 @@ test "Screen: selectWord whitespace across soft-wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("1 1\n 123"); @@ -7754,7 +7772,7 @@ test "Screen: selectWord with character boundary" { }; for (cases) |case| { - var s = try init(alloc, 20, 10, 0); + var s = try init(alloc, .{ .cols = 20, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString(case); @@ -7834,7 +7852,7 @@ test "Screen: selectOutput" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 15, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 15, .max_scrollback = 0 }); defer s.deinit(); // zig fmt: off @@ -7908,7 +7926,7 @@ test "Screen: selectOutput" { // input / prompt at y = 0, pt.y = 0 { s.deinit(); - s = try init(alloc, 10, 5, 0); + s = try init(alloc, .{ .cols = 10, .rows = 5, .max_scrollback = 0 }); try s.testWriteSemanticString("$ ", .prompt); try s.testWriteSemanticString("input1\n", .input); try s.testWriteSemanticString("output1\n", .command); @@ -7924,7 +7942,7 @@ test "Screen: selectPrompt basics" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 15, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 15, .max_scrollback = 0 }); defer s.deinit(); // zig fmt: off @@ -7999,7 +8017,7 @@ test "Screen: selectPrompt prompt at start" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 15, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 15, .max_scrollback = 0 }); defer s.deinit(); // zig fmt: off @@ -8043,7 +8061,7 @@ test "Screen: selectPrompt prompt at end" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 15, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 15, .max_scrollback = 0 }); defer s.deinit(); // zig fmt: off @@ -8087,7 +8105,7 @@ test "Screen: promptPath" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 15, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 15, .max_scrollback = 0 }); defer s.deinit(); // zig fmt: off @@ -8162,7 +8180,7 @@ test "Screen: selectionString basic" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -8187,7 +8205,7 @@ test "Screen: selectionString start outside of written area" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -8212,7 +8230,7 @@ test "Screen: selectionString end outside of written area" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -8237,7 +8255,7 @@ test "Screen: selectionString trim space" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1AB \n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -8274,7 +8292,7 @@ test "Screen: selectionString trim empty line" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1AB \n\n2EFGH\n3IJKL"; try s.testWriteString(str); @@ -8311,7 +8329,7 @@ test "Screen: selectionString soft wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH3IJKL"; try s.testWriteString(str); @@ -8336,7 +8354,7 @@ test "Screen: selectionString wide char" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1A⚡"; try s.testWriteString(str); @@ -8391,7 +8409,7 @@ test "Screen: selectionString wide char with header" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 3, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 3, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABC⚡"; try s.testWriteString(str); @@ -8417,7 +8435,7 @@ test "Screen: selectionString empty with soft wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 2, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 2, .max_scrollback = 0 }); defer s.deinit(); // Let me describe the situation that caused this because this @@ -8450,7 +8468,7 @@ test "Screen: selectionString with zero width joiner" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 1, 0); + var s = try init(alloc, .{ .cols = 10, .rows = 1, .max_scrollback = 0 }); defer s.deinit(); const str = "👨‍"; // this has a ZWJ try s.testWriteString(str); @@ -8486,7 +8504,7 @@ test "Screen: selectionString, rectangle, basic" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 30, 5, 0); + var s = try init(alloc, .{ .cols = 30, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = \\Lorem ipsum dolor @@ -8519,7 +8537,7 @@ test "Screen: selectionString, rectangle, w/EOL" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 30, 5, 0); + var s = try init(alloc, .{ .cols = 30, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = \\Lorem ipsum dolor @@ -8554,7 +8572,7 @@ test "Screen: selectionString, rectangle, more complex w/breaks" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 30, 8, 0); + var s = try init(alloc, .{ .cols = 30, .rows = 8, .max_scrollback = 0 }); defer s.deinit(); const str = \\Lorem ipsum dolor @@ -8593,7 +8611,7 @@ test "Screen: selectionString multi-page" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 10, 3, 2048); + var s = try init(alloc, .{ .cols = 10, .rows = 3, .max_scrollback = 2048 }); defer s.deinit(); const first_page_size = s.pages.pages.first.?.data.capacity.rows; @@ -8627,7 +8645,7 @@ test "Screen: lineIterator" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD\n2EFGH"; try s.testWriteString(str); @@ -8658,7 +8676,7 @@ test "Screen: lineIterator soft wrap" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3ABCD"; try s.testWriteString(str); @@ -8690,7 +8708,7 @@ test "Screen: hyperlink start/end" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); try testing.expect(s.cursor.hyperlink_id == 0); { @@ -8717,7 +8735,7 @@ test "Screen: hyperlink reuse" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); try testing.expect(s.cursor.hyperlink_id == 0); @@ -8755,7 +8773,7 @@ test "Screen: hyperlink cursor state on resize" { // it may be invalid one day. It's here to document/verify the // current behavior. - var s = try init(alloc, 5, 10, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); // Start a hyperlink @@ -8786,7 +8804,7 @@ test "Screen: cursorSetHyperlink OOM + URI too large for string alloc" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 80, 24, 0); + var s = try init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); // Start a hyperlink with a URI that just barely fits in the string alloc. @@ -8820,7 +8838,7 @@ test "Screen: adjustCapacity cursor style ref count" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 5, 5, 0); + var s = try init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); try s.setAttribute(.{ .bold = {} }); @@ -8854,7 +8872,7 @@ test "Screen: adjustCapacity cursor hyperlink exceeds string alloc size" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 80, 24, 0); + var s = try init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); // Start a hyperlink with a URI that just barely fits in the string alloc. @@ -8896,7 +8914,7 @@ test "Screen: adjustCapacity cursor style exceeds style set capacity" { const testing = std.testing; const alloc = testing.allocator; - var s = try init(alloc, 80, 24, 1000); + var s = try init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); const page = &s.cursor.page_pin.node.data; diff --git a/src/terminal/Selection.zig b/src/terminal/Selection.zig index 267f223d5..59cb4ef50 100644 --- a/src/terminal/Selection.zig +++ b/src/terminal/Selection.zig @@ -451,7 +451,7 @@ pub fn adjust( test "Selection: adjust right" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A1234\nB5678\nC1234\nD5678"); @@ -518,7 +518,7 @@ test "Selection: adjust right" { test "Selection: adjust left" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A1234\nB5678\nC1234\nD5678"); @@ -567,7 +567,7 @@ test "Selection: adjust left" { test "Selection: adjust left skips blanks" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A1234\nB5678\nC12\nD56"); @@ -616,7 +616,7 @@ test "Selection: adjust left skips blanks" { test "Selection: adjust up" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A\nB\nC\nD\nE"); @@ -663,7 +663,7 @@ test "Selection: adjust up" { test "Selection: adjust down" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A\nB\nC\nD\nE"); @@ -710,7 +710,7 @@ test "Selection: adjust down" { test "Selection: adjust down with not full screen" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A\nB\nC"); @@ -738,7 +738,7 @@ test "Selection: adjust down with not full screen" { test "Selection: adjust home" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A\nB\nC"); @@ -766,7 +766,7 @@ test "Selection: adjust home" { test "Selection: adjust end with not full screen" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A\nB\nC"); @@ -794,7 +794,7 @@ test "Selection: adjust end with not full screen" { test "Selection: adjust beginning of line" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 8, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 8, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A12 B34\nC12 D34"); @@ -864,7 +864,7 @@ test "Selection: adjust beginning of line" { test "Selection: adjust end of line" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 8, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 8, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("A12 B34\nC12 D34"); @@ -934,7 +934,7 @@ test "Selection: order, standard" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 100, 100, 1); + var s = try Screen.init(alloc, .{ .cols = 100, .rows = 100, .max_scrollback = 1 }); defer s.deinit(); { @@ -998,7 +998,7 @@ test "Selection: order, rectangle" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 100, 100, 1); + var s = try Screen.init(alloc, .{ .cols = 100, .rows = 100, .max_scrollback = 1 }); defer s.deinit(); // Conventions: @@ -1110,7 +1110,7 @@ test "Selection: order, rectangle" { test "topLeft" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); { // forward @@ -1173,7 +1173,7 @@ test "topLeft" { test "bottomRight" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); { // forward @@ -1236,7 +1236,7 @@ test "bottomRight" { test "ordered" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); { // forward @@ -1317,7 +1317,7 @@ test "ordered" { test "Selection: contains" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 10, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 10, .max_scrollback = 0 }); defer s.deinit(); { const sel = Selection.init( @@ -1363,7 +1363,7 @@ test "Selection: contains" { test "Selection: contains, rectangle" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 15, 15, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 15, .rows = 15, .max_scrollback = 0 }); defer s.deinit(); { const sel = Selection.init( @@ -1425,7 +1425,7 @@ test "Selection: contains, rectangle" { test "Selection: containedRow" { const testing = std.testing; - var s = try Screen.init(testing.allocator, 10, 5, 0); + var s = try Screen.init(testing.allocator, .{ .cols = 10, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); { diff --git a/src/terminal/StringMap.zig b/src/terminal/StringMap.zig index ae34f5fc8..4ac47eeab 100644 --- a/src/terminal/StringMap.zig +++ b/src/terminal/StringMap.zig @@ -109,7 +109,7 @@ test "StringMap searchIterator" { defer re.deinit(); // Initialize our screen - var s = try Screen.init(alloc, 5, 5, 0); + var s = try Screen.init(alloc, .{ .cols = 5, .rows = 5, .max_scrollback = 0 }); defer s.deinit(); const str = "1ABCD2EFGH\n3IJKL"; try s.testWriteString(str); diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index 8013110b7..d9ad62ae1 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -39,7 +39,7 @@ const log = std.log.scoped(.terminal); const TABSTOP_INTERVAL = 8; /// Screen type is an enum that tracks whether a screen is primary or alternate. -pub const ScreenType = enum { +pub const ScreenType = enum(u1) { primary, alternate, }; @@ -225,8 +225,8 @@ pub fn init( .cols = cols, .rows = rows, .active_screen = .primary, - .screen = try .init(alloc, cols, rows, opts.max_scrollback), - .secondary_screen = try .init(alloc, cols, rows, 0), + .screen = try .init(alloc, .{ .cols = cols, .rows = rows, .max_scrollback = opts.max_scrollback }), + .secondary_screen = try .init(alloc, .{ .cols = cols, .rows = rows, .max_scrollback = 0 }), .tabstops = try .init(alloc, cols, TABSTOP_INTERVAL), .scrolling_region = .{ .top = 0, diff --git a/src/terminal/search/sliding_window.zig b/src/terminal/search/sliding_window.zig index 4a2c3eb7d..db60a6670 100644 --- a/src/terminal/search/sliding_window.zig +++ b/src/terminal/search/sliding_window.zig @@ -494,7 +494,7 @@ test "SlidingWindow single append" { var w: SlidingWindow = try .init(alloc, .forward, "boo!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("hello. boo! hello. boo!"); @@ -537,7 +537,7 @@ test "SlidingWindow single append no match" { var w: SlidingWindow = try .init(alloc, .forward, "nope!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("hello. boo! hello. boo!"); @@ -561,7 +561,7 @@ test "SlidingWindow two pages" { var w: SlidingWindow = try .init(alloc, .forward, "boo!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -614,7 +614,7 @@ test "SlidingWindow two pages match across boundary" { var w: SlidingWindow = try .init(alloc, .forward, "hello, world"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -658,7 +658,7 @@ test "SlidingWindow two pages no match across boundary with newline" { var w: SlidingWindow = try .init(alloc, .forward, "hello, world"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -691,7 +691,7 @@ test "SlidingWindow two pages no match across boundary with newline reverse" { var w: SlidingWindow = try .init(alloc, .reverse, "hello, world"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -721,7 +721,7 @@ test "SlidingWindow two pages no match prunes first page" { var w: SlidingWindow = try .init(alloc, .forward, "nope!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -753,7 +753,7 @@ test "SlidingWindow two pages no match keeps both pages" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -796,7 +796,7 @@ test "SlidingWindow single append across circular buffer boundary" { var w: SlidingWindow = try .init(alloc, .forward, "abc"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("XXXXXXXXXXXXXXXXXXXboo!XXXXX"); @@ -851,7 +851,7 @@ test "SlidingWindow single append match on boundary" { var w: SlidingWindow = try .init(alloc, .forward, "abcd"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("o!XXXXXXXXXXXXXXXXXXXbo"); @@ -909,7 +909,7 @@ test "SlidingWindow single append reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "boo!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("hello. boo! hello. boo!"); @@ -952,7 +952,7 @@ test "SlidingWindow single append no match reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "nope!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("hello. boo! hello. boo!"); @@ -976,7 +976,7 @@ test "SlidingWindow two pages reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "boo!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -1029,7 +1029,7 @@ test "SlidingWindow two pages match across boundary reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "hello, world"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -1074,7 +1074,7 @@ test "SlidingWindow two pages no match prunes first page reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "nope!"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -1106,7 +1106,7 @@ test "SlidingWindow two pages no match keeps both pages reversed" { const testing = std.testing; const alloc = testing.allocator; - var s = try Screen.init(alloc, 80, 24, 1000); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 }); defer s.deinit(); // Fill up the first page. The final bytes in the first page @@ -1149,7 +1149,7 @@ test "SlidingWindow single append across circular buffer boundary reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "abc"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("XXXXXXXXXXXXXXXXXXXboo!XXXXX"); @@ -1205,7 +1205,7 @@ test "SlidingWindow single append match on boundary reversed" { var w: SlidingWindow = try .init(alloc, .reverse, "abcd"); defer w.deinit(); - var s = try Screen.init(alloc, 80, 24, 0); + var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 }); defer s.deinit(); try s.testWriteString("o!XXXXXXXXXXXXXXXXXXXbo");