From 03d5fa268902d609b2872178a1d5a4d9ff351ee7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 27 Jul 2026 07:11:33 -0700 Subject: [PATCH] lib-vt: move scrollback limits to terminal_set Terminal construction previously accepted GhosttyTerminalOptions with dimensions and one scrollback byte limit. Remove the options struct from the ABI and make ghostty_terminal_new accept columns and rows directly. Add byte and line limit options to ghostty_terminal_set and forward them to the runtime Terminal setters. NULL removes a limit, while zero bytes disables scrollback. Update type metadata, tests, and all API examples. --- example/c-vt-cmake-cross/src/main.c | 7 +- example/c-vt-cmake-static/src/main.c | 7 +- example/c-vt-cmake/src/main.c | 7 +- example/c-vt-colors/src/main.c | 7 +- example/c-vt-compression/src/main.c | 14 +- example/c-vt-effects/src/main.c | 7 +- example/c-vt-formatter/src/main.c | 7 +- example/c-vt-grid-ref-tracked/src/main.c | 7 +- example/c-vt-grid-traverse/src/main.c | 7 +- example/c-vt-kitty-graphics/src/main.c | 7 +- example/c-vt-render/src/main.c | 7 +- example/c-vt-selection-gesture/src/main.c | 7 +- example/c-vt-selection/src/main.c | 7 +- example/c-vt-stream/src/main.c | 7 +- example/cpp-vt-stream/src/main.cpp | 7 +- .../swift-vt-xcframework/Sources/main.swift | 7 +- example/wasm-vt/index.html | 15 +- include/ghostty/vt/key.h | 3 +- include/ghostty/vt/mouse.h | 3 +- include/ghostty/vt/terminal.h | 57 +- src/terminal/c/formatter.zig | 24 +- src/terminal/c/grid_ref.zig | 6 +- src/terminal/c/grid_ref_tracked.zig | 12 +- src/terminal/c/key_encode.zig | 6 +- src/terminal/c/kitty_graphics.zig | 81 ++- src/terminal/c/mouse_encode.zig | 6 +- src/terminal/c/render.zig | 141 ++-- src/terminal/c/selection.zig | 9 +- src/terminal/c/selection_gesture.zig | 42 +- src/terminal/c/terminal.zig | 684 +++++++----------- src/terminal/c/types.zig | 17 +- 31 files changed, 486 insertions(+), 739 deletions(-) diff --git a/example/c-vt-cmake-cross/src/main.c b/example/c-vt-cmake-cross/src/main.c index 992586451..3f4a8fb40 100644 --- a/example/c-vt-cmake-cross/src/main.c +++ b/example/c-vt-cmake-cross/src/main.c @@ -7,12 +7,7 @@ int main() { // Create a terminal with a small grid GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 24); assert(result == GHOSTTY_SUCCESS); // Write some VT-encoded content into the terminal diff --git a/example/c-vt-cmake-static/src/main.c b/example/c-vt-cmake-static/src/main.c index 233bd34d1..c9e566d5b 100644 --- a/example/c-vt-cmake-static/src/main.c +++ b/example/c-vt-cmake-static/src/main.c @@ -7,12 +7,7 @@ int main() { // Create a terminal with a small grid GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 24); assert(result == GHOSTTY_SUCCESS); // Write some VT-encoded content into the terminal diff --git a/example/c-vt-cmake/src/main.c b/example/c-vt-cmake/src/main.c index 992586451..3f4a8fb40 100644 --- a/example/c-vt-cmake/src/main.c +++ b/example/c-vt-cmake/src/main.c @@ -7,12 +7,7 @@ int main() { // Create a terminal with a small grid GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 24); assert(result == GHOSTTY_SUCCESS); // Write some VT-encoded content into the terminal diff --git a/example/c-vt-colors/src/main.c b/example/c-vt-colors/src/main.c index 6838527f2..19c1e7b46 100644 --- a/example/c-vt-colors/src/main.c +++ b/example/c-vt-colors/src/main.c @@ -87,12 +87,7 @@ void print_all_colors(GhosttyTerminal terminal, const char* label) { int main() { // Create a terminal GhosttyTerminal terminal = NULL; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - if (ghostty_terminal_new(NULL, &terminal, opts) != GHOSTTY_SUCCESS) { + if (ghostty_terminal_new(NULL, &terminal, 80, 24) != GHOSTTY_SUCCESS) { fprintf(stderr, "Failed to create terminal\n"); return 1; } diff --git a/example/c-vt-compression/src/main.c b/example/c-vt-compression/src/main.c index f3269b410..2eb3afc06 100644 --- a/example/c-vt-compression/src/main.c +++ b/example/c-vt-compression/src/main.c @@ -30,12 +30,14 @@ static bool compression_idle_step(GhosttyTerminal terminal) { int main(void) { GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 10 * 1024 * 1024, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 24); + assert(result == GHOSTTY_SUCCESS); + + size_t max_scrollback_bytes = 10 * 1024 * 1024; + result = ghostty_terminal_set( + terminal, + GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES, + &max_scrollback_bytes); assert(result == GHOSTTY_SUCCESS); //! [compression-activity] diff --git a/example/c-vt-effects/src/main.c b/example/c-vt-effects/src/main.c index cefee2ada..c40f8fa88 100644 --- a/example/c-vt-effects/src/main.c +++ b/example/c-vt-effects/src/main.c @@ -74,12 +74,7 @@ GhosttyClipboardWriteResult on_clipboard_write( int main() { // Create a terminal GhosttyTerminal terminal = NULL; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - if (ghostty_terminal_new(NULL, &terminal, opts) != GHOSTTY_SUCCESS) { + if (ghostty_terminal_new(NULL, &terminal, 80, 24) != GHOSTTY_SUCCESS) { fprintf(stderr, "Failed to create terminal\n"); return 1; } diff --git a/example/c-vt-formatter/src/main.c b/example/c-vt-formatter/src/main.c index 56f9d1220..9e7d250b9 100644 --- a/example/c-vt-formatter/src/main.c +++ b/example/c-vt-formatter/src/main.c @@ -7,12 +7,7 @@ int main() { // Create a terminal with a small grid GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 24); assert(result == GHOSTTY_SUCCESS); // Write VT-encoded content into the terminal to exercise various diff --git a/example/c-vt-grid-ref-tracked/src/main.c b/example/c-vt-grid-ref-tracked/src/main.c index a914a9727..104943d8d 100644 --- a/example/c-vt-grid-ref-tracked/src/main.c +++ b/example/c-vt-grid-ref-tracked/src/main.c @@ -25,12 +25,7 @@ static uint32_t codepoint_at_tracked_ref(GhosttyTrackedGridRef tracked) { int main() { GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 8, - .rows = 3, - .max_scrollback = 100, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 8, 3); assert(result == GHOSTTY_SUCCESS); const char *text = "alpha\r\n" diff --git a/example/c-vt-grid-traverse/src/main.c b/example/c-vt-grid-traverse/src/main.c index f07169eb6..fa9ce30ec 100644 --- a/example/c-vt-grid-traverse/src/main.c +++ b/example/c-vt-grid-traverse/src/main.c @@ -7,12 +7,7 @@ int main() { // Create a small terminal GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 10, - .rows = 3, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 10, 3); assert(result == GHOSTTY_SUCCESS); // Write some content so the grid has interesting data diff --git a/example/c-vt-kitty-graphics/src/main.c b/example/c-vt-kitty-graphics/src/main.c index d0d891928..049f7ab35 100644 --- a/example/c-vt-kitty-graphics/src/main.c +++ b/example/c-vt-kitty-graphics/src/main.c @@ -72,12 +72,7 @@ int main() { /* Create a terminal with Kitty graphics enabled. */ GhosttyTerminal terminal = NULL; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - if (ghostty_terminal_new(NULL, &terminal, opts) != GHOSTTY_SUCCESS) { + if (ghostty_terminal_new(NULL, &terminal, 80, 24) != GHOSTTY_SUCCESS) { fprintf(stderr, "Failed to create terminal\n"); return 1; } diff --git a/example/c-vt-render/src/main.c b/example/c-vt-render/src/main.c index feb3628d4..cb9e7e8c2 100644 --- a/example/c-vt-render/src/main.c +++ b/example/c-vt-render/src/main.c @@ -26,12 +26,7 @@ int main(void) { // from the terminal. The render state captures a snapshot of everything // needed to draw a frame. GhosttyTerminal terminal = NULL; - GhosttyTerminalOptions terminal_opts = { - .cols = 40, - .rows = 5, - .max_scrollback = 10000, - }; - result = ghostty_terminal_new(NULL, &terminal, terminal_opts); + result = ghostty_terminal_new(NULL, &terminal, 40, 5); assert(result == GHOSTTY_SUCCESS); GhosttyRenderState render_state = NULL; diff --git a/example/c-vt-selection-gesture/src/main.c b/example/c-vt-selection-gesture/src/main.c index 050e9a3b1..341c7547d 100644 --- a/example/c-vt-selection-gesture/src/main.c +++ b/example/c-vt-selection-gesture/src/main.c @@ -54,12 +54,7 @@ static GhosttySelectionGestureEvent new_event( int main() { GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 20, - .rows = 4, - .max_scrollback = 100, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 20, 4); assert(result == GHOSTTY_SUCCESS); vt_write(terminal, "hello world\r\nsecond line"); diff --git a/example/c-vt-selection/src/main.c b/example/c-vt-selection/src/main.c index 83384ec15..0b3ff28cc 100644 --- a/example/c-vt-selection/src/main.c +++ b/example/c-vt-selection/src/main.c @@ -49,12 +49,7 @@ static void print_selection( int main() { GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 8, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 8); assert(result == GHOSTTY_SUCCESS); // A realistic shell transcript with OSC 133 semantic prompt markers. diff --git a/example/c-vt-stream/src/main.c b/example/c-vt-stream/src/main.c index 7063e1f14..c2db6b14b 100644 --- a/example/c-vt-stream/src/main.c +++ b/example/c-vt-stream/src/main.c @@ -7,12 +7,7 @@ int main(void) { //! [vt-stream-init] // Create a terminal GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(NULL, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(NULL, &terminal, 80, 24); assert(result == GHOSTTY_SUCCESS); //! [vt-stream-init] diff --git a/example/cpp-vt-stream/src/main.cpp b/example/cpp-vt-stream/src/main.cpp index a77f98ad5..90331e363 100644 --- a/example/cpp-vt-stream/src/main.cpp +++ b/example/cpp-vt-stream/src/main.cpp @@ -6,12 +6,7 @@ int main() { // Create a terminal GhosttyTerminal terminal; - GhosttyTerminalOptions opts = { - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }; - GhosttyResult result = ghostty_terminal_new(nullptr, &terminal, opts); + GhosttyResult result = ghostty_terminal_new(nullptr, &terminal, 80, 24); assert(result == GHOSTTY_SUCCESS); // Feed VT data into the terminal diff --git a/example/swift-vt-xcframework/Sources/main.swift b/example/swift-vt-xcframework/Sources/main.swift index d374f539f..d6cf2bb17 100644 --- a/example/swift-vt-xcframework/Sources/main.swift +++ b/example/swift-vt-xcframework/Sources/main.swift @@ -3,12 +3,7 @@ import GhosttyVt // Create a terminal with a small grid var terminal: GhosttyTerminal? -var opts = GhosttyTerminalOptions( - cols: 80, - rows: 24, - max_scrollback: 0 -) -let result = ghostty_terminal_new(nil, &terminal, opts) +let result = ghostty_terminal_new(nil, &terminal, 80, 24) guard result == GHOSTTY_SUCCESS, let terminal else { fatalError("Failed to create terminal") } diff --git a/example/wasm-vt/index.html b/example/wasm-vt/index.html index d720e2375..81a033737 100644 --- a/example/wasm-vt/index.html +++ b/example/wasm-vt/index.html @@ -199,20 +199,15 @@ const rows = parseInt(document.getElementById('rows').value, 10); const vtText = parseEscapes(document.getElementById('vtInput').value); - const TERM_OPTS_SIZE = typeLayout['GhosttyTerminalOptions'].size; - const optsPtr = wasmInstance.exports.ghostty_wasm_alloc_u8_array(TERM_OPTS_SIZE); - new Uint8Array(getBuffer(), optsPtr, TERM_OPTS_SIZE).fill(0); - const optsView = new DataView(getBuffer(), optsPtr, TERM_OPTS_SIZE); - setField(optsView, 'GhosttyTerminalOptions', 'cols', cols); - setField(optsView, 'GhosttyTerminalOptions', 'rows', rows); - setField(optsView, 'GhosttyTerminalOptions', 'max_scrollback', 0); - // Allocate pointer to receive the terminal handle const termPtrPtr = wasmInstance.exports.ghostty_wasm_alloc_opaque(); // Create terminal - const newResult = wasmInstance.exports.ghostty_terminal_new(0, termPtrPtr, optsPtr); - wasmInstance.exports.ghostty_wasm_free_u8_array(optsPtr, TERM_OPTS_SIZE); + const newResult = wasmInstance.exports.ghostty_terminal_new( + 0, + termPtrPtr, + cols, + rows); if (newResult !== GHOSTTY_SUCCESS) { throw new Error(`ghostty_terminal_new failed with result ${newResult}`); diff --git a/include/ghostty/vt/key.h b/include/ghostty/vt/key.h index 61b954753..517d0c30d 100644 --- a/include/ghostty/vt/key.h +++ b/include/ghostty/vt/key.h @@ -42,8 +42,7 @@ * @code{.c} * // Create a terminal and feed it some VT data that changes modes * GhosttyTerminal terminal; - * ghostty_terminal_new(NULL, &terminal, - * (GhosttyTerminalOptions){.cols = 80, .rows = 24, .max_scrollback = 0}); + * ghostty_terminal_new(NULL, &terminal, 80, 24); * * // Application might write data that enables Kitty keyboard protocol, etc. * ghostty_terminal_vt_write(terminal, vt_data, vt_len); diff --git a/include/ghostty/vt/mouse.h b/include/ghostty/vt/mouse.h index 4ba5f52e3..4a582a23b 100644 --- a/include/ghostty/vt/mouse.h +++ b/include/ghostty/vt/mouse.h @@ -39,8 +39,7 @@ * @code{.c} * // Create a terminal and feed it some VT data that enables mouse tracking * GhosttyTerminal terminal; - * ghostty_terminal_new(NULL, &terminal, - * (GhosttyTerminalOptions){.cols = 80, .rows = 24, .max_scrollback = 0}); + * ghostty_terminal_new(NULL, &terminal, 80, 24); * * // Application might write data that enables mouse reporting, etc. * ghostty_terminal_vt_write(terminal, vt_data, vt_len); diff --git a/include/ghostty/vt/terminal.h b/include/ghostty/vt/terminal.h index 8470607b3..3bda9c9fd 100644 --- a/include/ghostty/vt/terminal.h +++ b/include/ghostty/vt/terminal.h @@ -172,26 +172,6 @@ extern "C" { * @{ */ -/** - * Terminal initialization options. - * - * @ingroup terminal - */ -typedef struct { - /** Terminal width in cells. Must be greater than zero. */ - uint16_t cols; - - /** Terminal height in cells. Must be greater than zero. */ - uint16_t rows; - - /** Maximum number of lines to keep in scrollback history. */ - size_t max_scrollback; - - // TODO: Consider ABI compatibility implications of this struct. - // We may want to artificially pad it significantly to support - // future options. -} GhosttyTerminalOptions; - /** * Amount of compression work to perform before returning. * @@ -888,6 +868,28 @@ typedef enum GHOSTTY_ENUM_TYPED { * Input type: GhosttyTerminalClipboardWriteFn */ GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE = 26, + + /** + * Set the maximum scrollback allocation in bytes. + * + * Lowering the limit immediately removes eligible complete historical + * pages. A value of zero disables scrollback and erases retained history. + * A NULL value pointer removes the byte limit. + * + * Input type: size_t* + */ + GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES = 27, + + /** + * Set the maximum number of physical lines retained in scrollback. + * + * Lowering the limit immediately removes eligible complete historical + * pages. The effective limit retains the active-area and page-granularity + * minimums. A NULL value pointer removes the line limit. + * + * Input type: size_t* + */ + GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_LINES = 28, GHOSTTY_TERMINAL_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE, } GhosttyTerminalOption; @@ -1221,16 +1223,22 @@ typedef enum GHOSTTY_ENUM_TYPED { /** * Create a new terminal instance. * + * The terminal starts with various reasonable defaults e.g. around + * scrollback limits. Use ghostty_terminal_set() to change any options + * prior to using the terminal. + * * @param allocator Pointer to allocator, or NULL to use the default allocator * @param terminal Pointer to store the created terminal handle - * @param options Terminal initialization options + * @param cols Terminal width in cells (must be greater than zero) + * @param rows Terminal height in cells (must be greater than zero) * @return GHOSTTY_SUCCESS on success, or an error code on failure * * @ingroup terminal */ GHOSTTY_API GhosttyResult ghostty_terminal_new(const GhosttyAllocator* allocator, - GhosttyTerminal* terminal, - GhosttyTerminalOptions options); + GhosttyTerminal* terminal, + uint16_t cols, + uint16_t rows); /** * Free a terminal instance. @@ -1291,7 +1299,8 @@ GHOSTTY_API GhosttyResult ghostty_terminal_resize(GhosttyTerminal terminal, * write_pty callback and userdata pointer. The value is passed * directly for pointer types (callbacks, userdata) or as a pointer * to the value for non-pointer types (e.g. GhosttyString*). - * NULL clears the option to its default. + * The behavior of a NULL value is specific to each option and is + * documented by the corresponding GhosttyTerminalOption value. * * Callbacks are invoked synchronously during ghostty_terminal_vt_write(). * Callbacks must not call ghostty_terminal_vt_write() on the same diff --git a/src/terminal/c/formatter.zig b/src/terminal/c/formatter.zig index 5b4504c8c..9b3c143a4 100644 --- a/src/terminal/c/formatter.zig +++ b/src/terminal/c/formatter.zig @@ -223,7 +223,8 @@ test "terminal_new/free" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -258,7 +259,8 @@ test "format plain" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -284,7 +286,8 @@ test "format reflects terminal changes" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -316,7 +319,8 @@ test "format null returns required size" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -348,7 +352,8 @@ test "format buffer too small" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -381,7 +386,8 @@ test "format vt" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -408,7 +414,8 @@ test "format plain with selection" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -452,7 +459,8 @@ test "format html" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); diff --git a/src/terminal/c/grid_ref.zig b/src/terminal/c/grid_ref.zig index 946ca8a1e..20f49be91 100644 --- a/src/terminal/c/grid_ref.zig +++ b/src/terminal/c/grid_ref.zig @@ -205,7 +205,8 @@ test "grid_ref_hyperlink_uri no hyperlink" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -228,7 +229,8 @@ test "grid_ref_hyperlink_uri with hyperlink" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(terminal); diff --git a/src/terminal/c/grid_ref_tracked.zig b/src/terminal/c/grid_ref_tracked.zig index 60091715f..475a8e430 100644 --- a/src/terminal/c/grid_ref_tracked.zig +++ b/src/terminal/c/grid_ref_tracked.zig @@ -96,7 +96,8 @@ test "tracked_grid_ref snapshots after terminal scroll" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -128,7 +129,8 @@ test "tracked_grid_ref reports no value after reset" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -154,7 +156,8 @@ test "tracked_grid_ref reports no value after alternate screen reset" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -194,7 +197,8 @@ test "tracked_grid_ref reports no value after terminal free" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); terminal_c.vt_write(terminal, "A", 1); diff --git a/src/terminal/c/key_encode.zig b/src/terminal/c/key_encode.zig index f270cb15a..f0aec36e7 100644 --- a/src/terminal/c/key_encode.zig +++ b/src/terminal/c/key_encode.zig @@ -257,7 +257,8 @@ test "setopt_from_terminal" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -283,7 +284,8 @@ test "setopt_from_terminal null" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); setopt_from_terminal(null, t); diff --git a/src/terminal/c/kitty_graphics.zig b/src/terminal/c/kitty_graphics.zig index 626cc7703..310b79cff 100644 --- a/src/terminal/c/kitty_graphics.zig +++ b/src/terminal/c/kitty_graphics.zig @@ -659,7 +659,8 @@ test "placement_iterator next on empty storage" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -688,7 +689,8 @@ test "placement_iterator get before next returns invalid" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -719,7 +721,8 @@ test "placement_iterator with transmit and display" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -772,7 +775,8 @@ test "placement_iterator with multiple placements" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -829,7 +833,8 @@ test "placement_iterator_set layer filter" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -919,7 +924,8 @@ test "image_get_handle returns null for missing id" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -940,7 +946,8 @@ test "image_get_handle and image_get with transmitted image" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -990,7 +997,8 @@ test "placement_rect with transmit and display" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1051,7 +1059,8 @@ test "placement_pixel_size with transmit and display" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1106,7 +1115,8 @@ test "placement_grid_size with transmit and display" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1160,7 +1170,8 @@ test "placement_viewport_pos with transmit and display" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1205,7 +1216,8 @@ test "placement_viewport_pos fully off-screen above" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 5, .max_scrollback = 100 }, + 80, + 5, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 5, 10, 20)); @@ -1244,7 +1256,8 @@ test "placement_viewport_pos top off-screen" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 5, .max_scrollback = 100 }, + 80, + 5, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 5, 10, 20)); @@ -1287,7 +1300,8 @@ test "placement_viewport_pos bottom off-screen" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 5, .max_scrollback = 0 }, + 80, + 5, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 5, 10, 20)); @@ -1327,7 +1341,8 @@ test "placement_viewport_pos top and bottom off-screen" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 5, .max_scrollback = 100 }, + 80, + 5, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 5, 10, 20)); @@ -1378,7 +1393,8 @@ test "placement_source_rect defaults to full image" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 24, 10, 20)); @@ -1417,7 +1433,8 @@ test "placement_source_rect with explicit source rect" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 24, 10, 20)); @@ -1461,7 +1478,8 @@ test "placement_source_rect clamps to image bounds" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 24, 10, 20)); @@ -1522,7 +1540,8 @@ test "placement_render_info returns all fields" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 24, 10, 20)); @@ -1561,7 +1580,8 @@ test "placement_render_info off-screen sets viewport_visible false" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 5, .max_scrollback = 100 }, + 80, + 5, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 5, 10, 20)); @@ -1610,7 +1630,8 @@ test "image_get_multi success" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 24, 10, 20)); @@ -1664,7 +1685,8 @@ test "placement_get_multi success" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); try testing.expectEqual(Result.success, terminal_c.resize(t, 80, 24, 10, 20)); @@ -1722,7 +1744,8 @@ test "storage generation via get" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1774,7 +1797,8 @@ test "image generation detects same-sized retransmission" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1835,7 +1859,8 @@ test "image generation via image_get_multi" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1871,7 +1896,8 @@ test "image compression and format always report decoded data" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -1917,7 +1943,8 @@ test "generation never recurs across resets and screen switches" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); diff --git a/src/terminal/c/mouse_encode.zig b/src/terminal/c/mouse_encode.zig index 951e80295..2586a57ad 100644 --- a/src/terminal/c/mouse_encode.zig +++ b/src/terminal/c/mouse_encode.zig @@ -324,7 +324,8 @@ test "setopt_from_terminal" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); @@ -346,7 +347,8 @@ test "setopt_from_terminal null" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer terminal_c.free(t); setopt_from_terminal(null, t); diff --git a/src/terminal/c/render.zig b/src/terminal/c/render.zig index 8ca58475f..e70e7a4b7 100644 --- a/src/terminal/c/render.zig +++ b/src/terminal/c/render.zig @@ -827,11 +827,8 @@ test "render: begin/end update" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 10, - .rows = 3, - .max_scrollback = 10_000, - }, + 10, + 3, )); defer terminal_c.free(terminal); @@ -952,11 +949,8 @@ test "render: row iterator new/free" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1008,11 +1002,8 @@ test "render: row get invalid data" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1047,11 +1038,8 @@ test "render: row set before iteration" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1081,11 +1069,8 @@ test "render: row get before iteration" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1115,11 +1100,8 @@ test "render: row get/set dirty" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1173,11 +1155,8 @@ test "render: row get selection" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 10, - .rows = 3, - .max_scrollback = 10_000, - }, + 10, + 3, )); defer terminal_c.free(terminal); @@ -1227,11 +1206,8 @@ test "render: row cells get selected" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 10, - .rows = 3, - .max_scrollback = 10_000, - }, + 10, + 3, )); defer terminal_c.free(terminal); @@ -1310,11 +1286,8 @@ test "render: row cells get has_styling" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 10, - .rows = 3, - .max_scrollback = 10_000, - }, + 10, + 3, )); defer terminal_c.free(terminal); @@ -1390,7 +1363,8 @@ test "render: row cells get graphemes utf8" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 10, .rows = 3, .max_scrollback = 10_000 }, + 10, + 3, )); defer terminal_c.free(terminal); @@ -1447,7 +1421,8 @@ test "render: row cells get graphemes utf8" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 10, .rows = 3, .max_scrollback = 10_000 }, + 10, + 3, )); defer terminal_c.free(terminal); @@ -1493,11 +1468,8 @@ test "render: row iterator next" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1543,11 +1515,8 @@ test "render: update" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1576,11 +1545,8 @@ test "render: colors get" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1618,11 +1584,8 @@ test "render: row cells bg_color no background" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1668,11 +1631,8 @@ test "render: row cells bg_color from style" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1720,11 +1680,8 @@ test "render: row cells bg_color from content tag" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1774,11 +1731,8 @@ test "render: row cells fg_color no foreground" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1824,11 +1778,8 @@ test "render: row cells fg_color from style" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1876,11 +1827,8 @@ test "render: colors get supports truncated sized struct" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1911,7 +1859,8 @@ test "render: get_multi success" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1947,7 +1896,8 @@ test "render: row_get_multi success" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(terminal); @@ -1990,7 +1940,8 @@ test "render: row_cells_get_multi success" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(terminal); diff --git a/src/terminal/c/selection.zig b/src/terminal/c/selection.zig index 7f0af205f..6dcfcc070 100644 --- a/src/terminal/c/selection.zig +++ b/src/terminal/c/selection.zig @@ -397,7 +397,8 @@ test "selection_format_alloc uses active selection" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -457,7 +458,8 @@ test "selection_format_buf uses provided selection" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); @@ -513,7 +515,8 @@ test "selection_format_alloc returns no_value without active selection" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer terminal_c.free(t); diff --git a/src/terminal/c/selection_gesture.zig b/src/terminal/c/selection_gesture.zig index 20d7386b6..46253057c 100644 --- a/src/terminal/c/selection_gesture.zig +++ b/src/terminal/c/selection_gesture.zig @@ -752,7 +752,8 @@ test "selection gesture lifecycle and get" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -788,7 +789,8 @@ test "selection gesture get_multi" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -832,7 +834,8 @@ test "selection gesture get_multi returns first failing index" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -944,7 +947,8 @@ test "selection gesture event applies press" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -991,7 +995,8 @@ test "selection gesture event press requires ref" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1019,7 +1024,8 @@ test "selection gesture event null output still reports no selection" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1053,7 +1059,8 @@ test "selection gesture event applies release" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1104,7 +1111,8 @@ test "selection gesture release without ref marks dragged" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1151,7 +1159,8 @@ test "selection gesture event applies drag" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1223,7 +1232,8 @@ test "selection gesture drag requires ref and geometry" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1267,7 +1277,8 @@ test "selection gesture event applies autoscroll tick" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1350,7 +1361,8 @@ test "selection gesture autoscroll tick requires viewport and geometry" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1389,7 +1401,8 @@ test "selection gesture event applies deep press" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); @@ -1444,7 +1457,8 @@ test "selection gesture deep press without active anchor returns no value" { try testing.expectEqual(Result.success, terminal_c.new( &lib.alloc.test_allocator, &terminal, - .{ .cols = 5, .rows = 2, .max_scrollback = 10_000 }, + 5, + 2, )); defer terminal_c.free(terminal); diff --git a/src/terminal/c/terminal.zig b/src/terminal/c/terminal.zig index 6a680c904..4d6d7fea6 100644 --- a/src/terminal/c/terminal.zig +++ b/src/terminal/c/terminal.zig @@ -307,13 +307,6 @@ pub fn zigTerminal(terminal_: Terminal) ?*ZigTerminal { return (terminal_ orelse return null).terminal; } -/// C: GhosttyTerminalOptions -pub const Options = extern struct { - cols: size.CellCountInt, - rows: size.CellCountInt, - max_scrollback: usize, -}; - const NewError = error{ InvalidValue, OutOfMemory, @@ -322,9 +315,10 @@ const NewError = error{ pub fn new( alloc_: ?*const CAllocator, result: *Terminal, - opts: Options, + cols: size.CellCountInt, + rows: size.CellCountInt, ) callconv(lib.calling_conv) Result { - result.* = new_(alloc_, opts) catch |err| { + result.* = new_(alloc_, cols, rows) catch |err| { result.* = null; return switch (err) { error.InvalidValue => .invalid_value, @@ -337,9 +331,10 @@ pub fn new( fn new_( alloc_: ?*const CAllocator, - opts: Options, + cols: size.CellCountInt, + rows: size.CellCountInt, ) NewError!*TerminalWrapper { - if (opts.cols == 0 or opts.rows == 0) return error.InvalidValue; + if (cols == 0 or rows == 0) return error.InvalidValue; const alloc = lib.alloc.default(alloc_); const t = alloc.create(ZigTerminal) catch @@ -363,9 +358,8 @@ fn new_( if (has_nonfailing_io) io_impl.io() else std.Io.failing, alloc, .{ - .cols = opts.cols, - .rows = opts.rows, - .max_scrollback_bytes = opts.max_scrollback, + .cols = cols, + .rows = rows, }, ); errdefer t.deinit(alloc); @@ -461,6 +455,8 @@ pub const Option = enum(c_int) { glyph_protocol = 24, pwd_changed = 25, clipboard_write = 26, + scrollback_max_bytes = 27, + scrollback_max_lines = 28, /// Input type expected for setting the option. pub fn InType(comptime self: Option) type { @@ -485,7 +481,11 @@ pub const Option = enum(c_int) { .glyph_protocol, => ?*const bool, .kitty_image_medium_temp_file => ?*const lib.String, - .apc_max_bytes, .apc_max_bytes_kitty => ?*const usize, + .apc_max_bytes, + .apc_max_bytes_kitty, + .scrollback_max_bytes, + .scrollback_max_lines, + => ?*const usize, .selection => ?*const selection_c.CSelection, .default_cursor_style => ?*const TerminalCursorStyle, .default_cursor_blink => ?*const bool, @@ -637,6 +637,12 @@ fn setTyped( const blink = if (value) |ptr| ptr.* else false; wrapper.terminal.setDefaultCursorBlink(blink); }, + .scrollback_max_bytes => wrapper.terminal.setScrollbackMaxBytes( + if (value) |ptr| ptr.* else null, + ), + .scrollback_max_lines => wrapper.terminal.setScrollbackMaxLines( + if (value) |ptr| ptr.* else null, + ), } return .success; } @@ -1027,11 +1033,8 @@ test "new/free" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); try testing.expect(t != null); @@ -1044,26 +1047,73 @@ test "new invalid value" { try testing.expectEqual(Result.invalid_value, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 0, - .rows = 24, - .max_scrollback = 10_000, - }, + 0, + 24, )); try testing.expect(t == null); try testing.expectEqual(Result.invalid_value, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 0, - .max_scrollback = 10_000, - }, + 80, + 0, )); try testing.expect(t == null); } +test "set scrollback limits" { + var t: Terminal = null; + try testing.expectEqual(Result.success, new( + &lib.alloc.test_allocator, + &t, + 80, + 3, + )); + defer free(t); + + const primary = t.?.terminal.screens.get(.primary).?; + + const max_bytes: usize = 0; + try testing.expectEqual( + Result.success, + set(t, .scrollback_max_bytes, &max_bytes), + ); + try testing.expectEqual( + @as(usize, 0), + primary.pages.limits.bytes.explicit, + ); + try testing.expect(primary.no_scrollback); + + try testing.expectEqual( + Result.success, + set(t, .scrollback_max_bytes, null), + ); + try testing.expectEqual( + std.math.maxInt(usize), + primary.pages.limits.bytes.explicit, + ); + try testing.expect(!primary.no_scrollback); + + const max_lines: usize = 12; + try testing.expectEqual( + Result.success, + set(t, .scrollback_max_lines, &max_lines), + ); + try testing.expectEqual( + max_lines, + primary.pages.limits.lines.explicit, + ); + + try testing.expectEqual( + Result.success, + set(t, .scrollback_max_lines, null), + ); + try testing.expectEqual( + std.math.maxInt(usize), + primary.pages.limits.lines.explicit, + ); +} + test "free null" { free(null); } @@ -1073,11 +1123,8 @@ test "scroll_viewport" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 5, - .rows = 2, - .max_scrollback = 10_000, - }, + 5, + 2, )); defer free(t); @@ -1135,11 +1182,8 @@ test "scroll_viewport row" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 5, - .rows = 2, - .max_scrollback = 10_000, - }, + 5, + 2, )); defer free(t); @@ -1195,11 +1239,8 @@ test "scroll_viewport row alt screen" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 5, - .rows = 2, - .max_scrollback = 10_000, - }, + 5, + 2, )); defer free(t); @@ -1248,11 +1289,8 @@ test "compression invalid arguments" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000_000, - }, + 80, + 24, )); defer free(t); @@ -1275,11 +1313,8 @@ test "compression activity and incremental scheduling" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000_000, - }, + 80, + 24, )); defer free(t); @@ -1342,11 +1377,8 @@ test "reset" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer free(t); @@ -1367,11 +1399,8 @@ test "resize" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer free(t); @@ -1389,11 +1418,8 @@ test "resize invalid value" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer free(t); @@ -1406,11 +1432,8 @@ test "resize shrinks both axes with cursor at bottom" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1430,11 +1453,8 @@ test "mode_get and mode_set" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1476,11 +1496,8 @@ test "mode_get unknown mode" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1494,11 +1511,8 @@ test "mode_set unknown mode" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1511,11 +1525,8 @@ test "vt_write" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer free(t); @@ -1531,11 +1542,8 @@ test "vt_write split escape sequence" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer free(t); @@ -1556,11 +1564,8 @@ test "vt_write split combining mark after base at right edge" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 2, - .rows = 2, - .max_scrollback = 0, - }, + 2, + 2, )); defer free(t); @@ -1579,11 +1584,8 @@ test "get cols and rows" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1600,11 +1602,8 @@ test "get cursor position" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1623,11 +1622,8 @@ test "get vt_processing_error" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1676,11 +1672,8 @@ test "get cursor_visible" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1700,11 +1693,8 @@ test "get active_screen" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1718,11 +1708,8 @@ test "get kitty_keyboard_flags" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1742,11 +1729,8 @@ test "get mouse_tracking" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1792,11 +1776,8 @@ test "get total_rows" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 10_000, - }, + 80, + 24, )); defer free(t); @@ -1810,11 +1791,8 @@ test "get scrollback_rows" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 3, - .max_scrollback = 10_000, - }, + 80, + 3, )); defer free(t); @@ -1834,11 +1812,8 @@ test "get invalid" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1850,11 +1825,8 @@ test "set default cursor style and blink" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1895,11 +1867,8 @@ test "set and get selection" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -1943,11 +1912,8 @@ test "selection derivation helpers" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2033,11 +1999,8 @@ test "selection_adjust mutates snapshot end" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2081,11 +2044,8 @@ test "selection_order and selection_ordered" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2134,11 +2094,8 @@ test "selection_contains" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2192,11 +2149,8 @@ test "selection_equal" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2204,11 +2158,8 @@ test "selection_equal" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &other_t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(other_t); @@ -2281,11 +2232,8 @@ test "selection_order invalid values" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2299,11 +2247,8 @@ test "grid_ref" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2337,7 +2282,8 @@ test "point_from_grid_ref roundtrip active" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer free(t); @@ -2362,7 +2308,8 @@ test "point_from_grid_ref roundtrip viewport" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 10_000 }, + 80, + 24, )); defer free(t); @@ -2385,7 +2332,8 @@ test "point_from_grid_ref history ref to active returns no_value" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 4, .max_scrollback = 10_000 }, + 80, + 4, )); defer free(t); @@ -2420,7 +2368,8 @@ test "point_from_grid_ref null node" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer free(t); @@ -2433,11 +2382,8 @@ test "set write_pty callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2476,11 +2422,8 @@ test "write_pty receives DECRQSS response" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2511,11 +2454,8 @@ test "write_pty receives OSC color query response" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2551,11 +2491,8 @@ test "set write_pty without callback ignores queries" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2568,11 +2505,8 @@ test "set write_pty null clears callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2597,11 +2531,8 @@ test "set bell callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2637,11 +2568,8 @@ test "bell without callback is silent" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2654,11 +2582,8 @@ test "set enquiry callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2696,11 +2621,8 @@ test "enquiry without callback is silent" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2713,11 +2635,8 @@ test "set xtversion callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2756,11 +2675,8 @@ test "xtversion without callback reports default" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2792,11 +2708,8 @@ test "set title_changed callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2831,11 +2744,8 @@ test "title_changed without callback is silent" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2848,11 +2758,8 @@ test "set pwd_changed callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -2891,11 +2798,8 @@ test "set clipboard_write callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3046,11 +2950,8 @@ test "clipboard_write without callback is unsupported and silent" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3071,11 +2972,8 @@ test "pwd_changed without callback is silent" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3090,11 +2988,8 @@ test "set size callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3137,11 +3032,8 @@ test "size without callback is silent" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3154,11 +3046,8 @@ test "set device_attributes callback primary" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3208,11 +3097,8 @@ test "set device_attributes callback secondary" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3262,11 +3148,8 @@ test "set device_attributes callback tertiary" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3316,11 +3199,8 @@ test "device_attributes without callback uses default" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3352,11 +3232,8 @@ test "device_attributes callback returns false uses default" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3393,11 +3270,8 @@ test "set and get title" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3432,11 +3306,8 @@ test "set and get pwd" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3464,11 +3335,8 @@ test "get title set via vt_write" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3485,11 +3353,8 @@ test "resize updates pixel dimensions" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3506,11 +3371,8 @@ test "resize pixel overflow saturates" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3526,11 +3388,8 @@ test "resize disables synchronized output" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3547,11 +3406,8 @@ test "resize sends in-band size report" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3588,11 +3444,8 @@ test "resize no size report without mode 2048" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3616,11 +3469,8 @@ test "resize in-band report without write_pty callback" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3638,11 +3488,8 @@ test "resize zero cols" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3654,11 +3501,8 @@ test "resize zero rows" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3670,11 +3514,8 @@ test "grid_ref out of bounds" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3690,11 +3531,8 @@ test "set and get color_foreground" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3718,11 +3556,8 @@ test "set and get color_background" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3743,11 +3578,8 @@ test "set and get color_cursor" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3768,11 +3600,8 @@ test "set and get color_palette" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3799,11 +3628,8 @@ test "get color default vs effective with override" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3846,11 +3672,8 @@ test "get color default returns no_value when unset" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3865,11 +3688,8 @@ test "get color_palette_default vs current" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3898,11 +3718,8 @@ test "set color sets dirty flag" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ - .cols = 80, - .rows = 24, - .max_scrollback = 0, - }, + 80, + 24, )); defer free(t); @@ -3919,7 +3736,8 @@ test "set glyph protocol disables APC handling and clears glossary" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer free(t); @@ -3946,7 +3764,8 @@ test "get_multi success" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer free(t); @@ -3967,7 +3786,8 @@ test "get_multi error sets out_written" { try testing.expectEqual(Result.success, new( &lib.alloc.test_allocator, &t, - .{ .cols = 80, .rows = 24, .max_scrollback = 0 }, + 80, + 24, )); defer free(t); diff --git a/src/terminal/c/types.zig b/src/terminal/c/types.zig index f160f3852..549dfff15 100644 --- a/src/terminal/c/types.zig +++ b/src/terminal/c/types.zig @@ -68,7 +68,6 @@ pub const structs: std.StaticStringMap(StructInfo) = structs: { .{ "GhosttySurfacePosition", StructInfo.init(SurfacePosition) }, .{ "GhosttyStyle", StructInfo.init(style_c.Style) }, .{ "GhosttyStyleColor", StructInfo.init(style_c.Color) }, - .{ "GhosttyTerminalOptions", StructInfo.init(terminal.Options) }, .{ "GhosttyTerminalScrollbar", StructInfo.init(terminal.TerminalScrollbar) }, .{ "GhosttyTerminalScrollViewport", StructInfo.init(terminal.ScrollViewport) }, }); @@ -216,7 +215,6 @@ test "json parses" { // Verify we have all expected structs try std.testing.expect(root.contains("GhosttyClipboardContent")); try std.testing.expect(root.contains("GhosttyClipboardWrite")); - try std.testing.expect(root.contains("GhosttyTerminalOptions")); try std.testing.expect(root.contains("GhosttyFormatterTerminalOptions")); const clipboard_content = root.get("GhosttyClipboardContent").?.object; @@ -231,20 +229,7 @@ test "json parses" { try std.testing.expect(clipboard_write_fields.contains("contents")); try std.testing.expect(clipboard_write_fields.contains("contents_len")); - // Verify GhosttyTerminalOptions fields - const term_opts = root.get("GhosttyTerminalOptions").?.object; - try std.testing.expect(term_opts.contains("size")); - try std.testing.expect(term_opts.contains("align")); - try std.testing.expect(term_opts.contains("fields")); - - const fields = term_opts.get("fields").?.object; - try std.testing.expect(fields.contains("cols")); - try std.testing.expect(fields.contains("rows")); - try std.testing.expect(fields.contains("max_scrollback")); - - // Verify field offsets make sense (cols should be at 0) - const cols = fields.get("cols").?.object; - try std.testing.expectEqual(0, cols.get("offset").?.integer); + try std.testing.expect(!root.contains("GhosttyTerminalOptions")); } test "struct sizes are non-zero" {