terminal/c: use lib.alloc instead of direct lib/allocator.zig import

Each C API file independently imported ../../lib/allocator.zig as
lib_alloc. Now that terminal/lib.zig re-exports the allocator module
as lib.alloc, use that instead. This removes the redundant import
and keeps all lib dependencies flowing through the single lib.zig
entry point.
This commit is contained in:
Mitchell Hashimoto
2026-03-25 07:29:23 -07:00
parent 2f2f003aa5
commit 3c9c3a4f54
12 changed files with 186 additions and 195 deletions

View File

@@ -1,8 +1,7 @@
const std = @import("std");
const testing = std.testing;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
/// Allocate a buffer of `len` bytes using the given allocator
/// (or the default allocator if NULL).
@@ -13,7 +12,7 @@ pub fn alloc(
alloc_: ?*const CAllocator,
len: usize,
) callconv(lib.calling_conv) ?[*]u8 {
const allocator = lib_alloc.default(alloc_);
const allocator = lib.alloc.default(alloc_);
const buf = allocator.alloc(u8, len) catch return null;
return buf.ptr;
}
@@ -29,14 +28,14 @@ pub fn free(
len: usize,
) callconv(lib.calling_conv) void {
const mem = ptr orelse return;
const allocator = lib_alloc.default(alloc_);
const allocator = lib.alloc.default(alloc_);
allocator.free(mem[0..len]);
}
test "alloc returns non-null" {
const ptr = alloc(&lib_alloc.test_allocator, 16);
const ptr = alloc(&lib.alloc.test_allocator, 16);
try testing.expect(ptr != null);
free(&lib_alloc.test_allocator, ptr, 16);
free(&lib.alloc.test_allocator, ptr, 16);
}
test "alloc with null allocator" {
@@ -46,23 +45,23 @@ test "alloc with null allocator" {
}
test "alloc zero length" {
const ptr = alloc(&lib_alloc.test_allocator, 0);
defer free(&lib_alloc.test_allocator, ptr, 0);
const ptr = alloc(&lib.alloc.test_allocator, 0);
defer free(&lib.alloc.test_allocator, ptr, 0);
}
test "free null pointer" {
free(&lib_alloc.test_allocator, null, 0);
free(&lib.alloc.test_allocator, null, 0);
}
test "free allocated memory" {
const allocator = lib_alloc.default(&lib_alloc.test_allocator);
const allocator = lib.alloc.default(&lib.alloc.test_allocator);
const mem = try allocator.alloc(u8, 16);
free(&lib_alloc.test_allocator, mem.ptr, mem.len);
free(&lib.alloc.test_allocator, mem.ptr, mem.len);
}
test "free with null allocator" {
// null allocator falls back to the default (test allocator in tests)
const allocator = lib_alloc.default(null);
const allocator = lib.alloc.default(null);
const mem = try allocator.alloc(u8, 8);
free(null, mem.ptr, mem.len);
}

View File

@@ -1,8 +1,7 @@
const std = @import("std");
const testing = std.testing;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const terminal_c = @import("terminal.zig");
const ZigTerminal = @import("../Terminal.zig");
const formatterpkg = @import("../formatter.zig");
@@ -127,7 +126,7 @@ fn terminal_new_(
}!*FormatterWrapper {
const t: *ZigTerminal = (terminal_ orelse return error.InvalidValue).terminal;
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(FormatterWrapper) catch
return error.OutOfMemory;
errdefer alloc.destroy(ptr);
@@ -184,7 +183,7 @@ pub fn format_alloc(
out_len: *usize,
) callconv(lib.calling_conv) Result {
const wrapper = formatter_ orelse return .invalid_value;
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
var aw: std.Io.Writer.Allocating = .init(alloc);
defer aw.deinit();
@@ -208,7 +207,7 @@ pub fn free(formatter_: Formatter) callconv(lib.calling_conv) void {
test "terminal_new/free" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -216,7 +215,7 @@ test "terminal_new/free" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .plain, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -228,7 +227,7 @@ test "terminal_new/free" {
test "terminal_new invalid_value on null terminal" {
var f: Formatter = null;
try testing.expectEqual(Result.invalid_value, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
null,
.{ .emit = .plain, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -243,7 +242,7 @@ test "free null" {
test "format plain" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -253,7 +252,7 @@ test "format plain" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .plain, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -269,7 +268,7 @@ test "format plain" {
test "format reflects terminal changes" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -279,7 +278,7 @@ test "format reflects terminal changes" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .plain, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -301,7 +300,7 @@ test "format reflects terminal changes" {
test "format null returns required size" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -311,7 +310,7 @@ test "format null returns required size" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .plain, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -333,7 +332,7 @@ test "format null returns required size" {
test "format buffer too small" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -343,7 +342,7 @@ test "format buffer too small" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .plain, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -366,7 +365,7 @@ test "format null formatter" {
test "format vt" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -376,7 +375,7 @@ test "format vt" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .vt, .unwrap = false, .trim = true, .extra = .{ .palette = true, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = true, .hyperlink = true, .protection = false, .kitty_keyboard = false, .charsets = false } } },
@@ -393,7 +392,7 @@ test "format vt" {
test "format html" {
var t: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 10_000 },
));
@@ -403,7 +402,7 @@ test "format html" {
var f: Formatter = null;
try testing.expectEqual(Result.success, terminal_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&f,
t,
.{ .emit = .html, .unwrap = false, .trim = true, .extra = .{ .palette = false, .modes = false, .scrolling_region = false, .tabstops = false, .pwd = false, .keyboard = false, .screen = .{ .cursor = false, .style = false, .hyperlink = false, .protection = false, .kitty_keyboard = false, .charsets = false } } },

View File

@@ -1,8 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const key_encode = @import("../../input/key_encode.zig");
const key_event = @import("key_event.zig");
const KittyFlags = @import("../../terminal/kitty/key.zig").Flags;
@@ -27,7 +26,7 @@ pub fn new(
alloc_: ?*const CAllocator,
result: *Encoder,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(KeyEncoderWrapper) catch
return .out_of_memory;
ptr.* = .{
@@ -166,7 +165,7 @@ test "alloc" {
const testing = std.testing;
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
free(e);
@@ -176,7 +175,7 @@ test "setopt bool" {
const testing = std.testing;
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -198,7 +197,7 @@ test "setopt kitty flags" {
const testing = std.testing;
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -219,7 +218,7 @@ test "setopt macos option as alt" {
const testing = std.testing;
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -241,7 +240,7 @@ test "setopt_from_terminal" {
// Create encoder
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -249,7 +248,7 @@ test "setopt_from_terminal" {
// Create terminal
var t: Terminal = undefined;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 0 },
));
@@ -275,7 +274,7 @@ test "setopt_from_terminal null" {
const terminal_c = @import("terminal.zig");
var t: Terminal = undefined;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 0 },
));
@@ -285,7 +284,7 @@ test "setopt_from_terminal null" {
// Valid encoder with null terminal
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -298,7 +297,7 @@ test "encode: kitty ctrl release with ctrl mod set" {
// Create encoder
var encoder: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&encoder,
));
defer free(encoder);
@@ -319,7 +318,7 @@ test "encode: kitty ctrl release with ctrl mod set" {
// Create key event
var event: key_event.Event = undefined;
try testing.expectEqual(Result.success, key_event.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&event,
));
defer key_event.free(event);

View File

@@ -1,8 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const key = @import("../../input/key.zig");
const Result = @import("result.zig").Result;
@@ -23,7 +22,7 @@ pub fn new(
alloc_: ?*const CAllocator,
result: *Event,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(KeyEventWrapper) catch
return .out_of_memory;
ptr.* = .{ .alloc = alloc };
@@ -126,7 +125,7 @@ test "alloc" {
const testing = std.testing;
var e: Event = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
free(e);
@@ -136,7 +135,7 @@ test "set" {
const testing = std.testing;
var e: Event = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -183,7 +182,7 @@ test "get" {
const testing = std.testing;
var e: Event = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -232,7 +231,7 @@ test "complete key event" {
const testing = std.testing;
var e: Event = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);

View File

@@ -1,5 +1,5 @@
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const lib = @import("../lib.zig");
const CAllocator = lib.alloc.Allocator;
const buildpkg = @import("build_info.zig");
pub const allocator = @import("allocator.zig");

View File

@@ -2,8 +2,7 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const testing = std.testing;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const input_mouse_encode = @import("../../input/mouse_encode.zig");
const renderer_size = @import("../../renderer/size.zig");
const point = @import("../point.zig");
@@ -91,7 +90,7 @@ pub fn new(
alloc_: ?*const CAllocator,
result: *Encoder,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(MouseEncoderWrapper) catch
return .out_of_memory;
ptr.* = .{
@@ -275,7 +274,7 @@ fn testSize() Size {
test "alloc" {
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
free(e);
@@ -284,7 +283,7 @@ test "alloc" {
test "setopt" {
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -316,14 +315,14 @@ test "setopt_from_terminal" {
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
var t: Terminal = undefined;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 0 },
));
@@ -345,7 +344,7 @@ test "setopt_from_terminal null" {
const terminal_c = @import("terminal.zig");
var t: Terminal = undefined;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{ .cols = 80, .rows = 24, .max_scrollback = 0 },
));
@@ -354,7 +353,7 @@ test "setopt_from_terminal null" {
var e: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);
@@ -364,7 +363,7 @@ test "setopt_from_terminal null" {
test "encode: sgr press left" {
var encoder: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&encoder,
));
defer free(encoder);
@@ -378,7 +377,7 @@ test "encode: sgr press left" {
var event: Event = undefined;
try testing.expectEqual(Result.success, mouse_event.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&event,
));
defer mouse_event.free(event);
@@ -413,7 +412,7 @@ test "encode: sgr press left" {
test "encode: motion dedupe and reset" {
var encoder: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&encoder,
));
defer free(encoder);
@@ -429,7 +428,7 @@ test "encode: motion dedupe and reset" {
var event: Event = undefined;
try testing.expectEqual(Result.success, mouse_event.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&event,
));
defer mouse_event.free(event);
@@ -483,7 +482,7 @@ test "encode: motion dedupe and reset" {
test "encode: querying required size doesn't update dedupe state" {
var encoder: Encoder = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&encoder,
));
defer free(encoder);
@@ -499,7 +498,7 @@ test "encode: querying required size doesn't update dedupe state" {
var event: Event = undefined;
try testing.expectEqual(Result.success, mouse_event.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&event,
));
defer mouse_event.free(event);

View File

@@ -2,8 +2,7 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const testing = std.testing;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const key = @import("../../input/key.zig");
const mouse = @import("../../input/mouse.zig");
const mouse_encode = @import("../../input/mouse_encode.zig");
@@ -36,7 +35,7 @@ pub fn new(
alloc_: ?*const CAllocator,
result: *Event,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(MouseEventWrapper) catch
return .out_of_memory;
ptr.* = .{ .alloc = alloc };
@@ -108,7 +107,7 @@ pub fn get_position(event_: Event) callconv(lib.calling_conv) Position {
test "alloc" {
var e: Event = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
free(e);
@@ -121,7 +120,7 @@ test "free null" {
test "set/get" {
var e: Event = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&e,
));
defer free(e);

View File

@@ -1,7 +1,6 @@
const std = @import("std");
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const osc = @import("../osc.zig");
const Result = @import("result.zig").Result;
@@ -17,7 +16,7 @@ pub fn new(
alloc_: ?*const CAllocator,
result: *Parser,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(osc.Parser) catch
return .out_of_memory;
ptr.* = .init(alloc);
@@ -107,7 +106,7 @@ test "alloc" {
const testing = std.testing;
var p: Parser = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&p,
));
free(p);
@@ -122,7 +121,7 @@ test "change window title" {
const testing = std.testing;
var p: Parser = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&p,
));
defer free(p);

View File

@@ -2,8 +2,7 @@ const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const colorpkg = @import("../color.zig");
const cursorpkg = @import("../cursor.zig");
const page = @import("../page.zig");
@@ -155,7 +154,7 @@ pub fn new(
}
fn new_(alloc_: ?*const CAllocator) error{OutOfMemory}!*RenderStateWrapper {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(RenderStateWrapper) catch
return error.OutOfMemory;
ptr.* = .{ .alloc = alloc };
@@ -355,7 +354,7 @@ pub fn row_iterator_new(
alloc_: ?*const CAllocator,
result: *RowIterator,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(RowIteratorWrapper) catch {
result.* = null;
return .out_of_memory;
@@ -390,7 +389,7 @@ pub fn row_cells_new(
alloc_: ?*const CAllocator,
result: *RowCells,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(RowCellsWrapper) catch {
result.* = null;
return .out_of_memory;
@@ -639,7 +638,7 @@ fn rowSetTyped(
test "render: new/free" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
try testing.expect(state != null);
@@ -653,7 +652,7 @@ test "render: free null" {
test "render: update invalid value" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -670,7 +669,7 @@ test "render: get invalid value" {
test "render: get invalid data" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -681,7 +680,7 @@ test "render: get invalid data" {
test "render: colors get invalid value" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -706,7 +705,7 @@ test "render: get/set dirty invalid value" {
test "render: get/set dirty" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -729,7 +728,7 @@ test "render: get/set dirty" {
test "render: set null value" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -740,7 +739,7 @@ test "render: set null value" {
test "render: row iterator get invalid value" {
var iterator: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&iterator,
));
defer row_iterator_free(iterator);
@@ -751,7 +750,7 @@ test "render: row iterator get invalid value" {
test "render: row iterator new/free" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -763,7 +762,7 @@ test "render: row iterator new/free" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -772,7 +771,7 @@ test "render: row iterator new/free" {
var iterator: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&iterator,
));
defer row_iterator_free(iterator);
@@ -806,7 +805,7 @@ test "render: row get null" {
test "render: row get invalid data" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -818,7 +817,7 @@ test "render: row get invalid data" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -827,7 +826,7 @@ test "render: row get invalid data" {
var iterator: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&iterator,
));
defer row_iterator_free(iterator);
@@ -845,7 +844,7 @@ test "render: row set null" {
test "render: row set before iteration" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -857,7 +856,7 @@ test "render: row set before iteration" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -866,7 +865,7 @@ test "render: row set before iteration" {
var iterator: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&iterator,
));
defer row_iterator_free(iterator);
@@ -879,7 +878,7 @@ test "render: row set before iteration" {
test "render: row get before iteration" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -891,7 +890,7 @@ test "render: row get before iteration" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -900,7 +899,7 @@ test "render: row get before iteration" {
var iterator: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&iterator,
));
defer row_iterator_free(iterator);
@@ -913,7 +912,7 @@ test "render: row get before iteration" {
test "render: row get/set dirty" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -925,7 +924,7 @@ test "render: row get/set dirty" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -939,7 +938,7 @@ test "render: row get/set dirty" {
// Create an iterator and verify it is dirty.
var it: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it,
));
defer row_iterator_free(it);
@@ -957,7 +956,7 @@ test "render: row get/set dirty" {
// It should not be dirty anymore.
var it2: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it2,
));
defer row_iterator_free(it2);
@@ -971,7 +970,7 @@ test "render: row get/set dirty" {
test "render: row iterator next" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -983,7 +982,7 @@ test "render: row iterator next" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -992,7 +991,7 @@ test "render: row iterator next" {
var iterator: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&iterator,
));
defer row_iterator_free(iterator);
@@ -1021,7 +1020,7 @@ test "render: row iterator next" {
test "render: update" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1033,7 +1032,7 @@ test "render: update" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1054,7 +1053,7 @@ test "render: update" {
test "render: colors get" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1066,7 +1065,7 @@ test "render: colors get" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1096,7 +1095,7 @@ test "render: colors get" {
test "render: row cells bg_color no background" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1111,7 +1110,7 @@ test "render: row cells bg_color no background" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1120,7 +1119,7 @@ test "render: row cells bg_color no background" {
var it: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it,
));
defer row_iterator_free(it);
@@ -1130,7 +1129,7 @@ test "render: row cells bg_color no background" {
var cells: RowCells = null;
try testing.expectEqual(Result.success, row_cells_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&cells,
));
defer row_cells_free(cells);
@@ -1146,7 +1145,7 @@ test "render: row cells bg_color no background" {
test "render: row cells bg_color from style" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1161,7 +1160,7 @@ test "render: row cells bg_color from style" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1170,7 +1169,7 @@ test "render: row cells bg_color from style" {
var it: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it,
));
defer row_iterator_free(it);
@@ -1180,7 +1179,7 @@ test "render: row cells bg_color from style" {
var cells: RowCells = null;
try testing.expectEqual(Result.success, row_cells_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&cells,
));
defer row_cells_free(cells);
@@ -1198,7 +1197,7 @@ test "render: row cells bg_color from style" {
test "render: row cells bg_color from content tag" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1215,7 +1214,7 @@ test "render: row cells bg_color from content tag" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1224,7 +1223,7 @@ test "render: row cells bg_color from content tag" {
var it: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it,
));
defer row_iterator_free(it);
@@ -1234,7 +1233,7 @@ test "render: row cells bg_color from content tag" {
var cells: RowCells = null;
try testing.expectEqual(Result.success, row_cells_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&cells,
));
defer row_cells_free(cells);
@@ -1252,7 +1251,7 @@ test "render: row cells bg_color from content tag" {
test "render: row cells fg_color no foreground" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1267,7 +1266,7 @@ test "render: row cells fg_color no foreground" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1276,7 +1275,7 @@ test "render: row cells fg_color no foreground" {
var it: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it,
));
defer row_iterator_free(it);
@@ -1286,7 +1285,7 @@ test "render: row cells fg_color no foreground" {
var cells: RowCells = null;
try testing.expectEqual(Result.success, row_cells_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&cells,
));
defer row_cells_free(cells);
@@ -1302,7 +1301,7 @@ test "render: row cells fg_color no foreground" {
test "render: row cells fg_color from style" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1317,7 +1316,7 @@ test "render: row cells fg_color from style" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);
@@ -1326,7 +1325,7 @@ test "render: row cells fg_color from style" {
var it: RowIterator = null;
try testing.expectEqual(Result.success, row_iterator_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&it,
));
defer row_iterator_free(it);
@@ -1336,7 +1335,7 @@ test "render: row cells fg_color from style" {
var cells: RowCells = null;
try testing.expectEqual(Result.success, row_cells_new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&cells,
));
defer row_cells_free(cells);
@@ -1354,7 +1353,7 @@ test "render: row cells fg_color from style" {
test "render: colors get supports truncated sized struct" {
var terminal: terminal_c.Terminal = null;
try testing.expectEqual(Result.success, terminal_c.new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&terminal,
.{
.cols = 80,
@@ -1366,7 +1365,7 @@ test "render: colors get supports truncated sized struct" {
var state: RenderState = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&state,
));
defer free(state);

View File

@@ -2,8 +2,7 @@ const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const sgr = @import("../sgr.zig");
const Result = @import("result.zig").Result;
@@ -22,7 +21,7 @@ pub fn new(
alloc_: ?*const CAllocator,
result: *Parser,
) callconv(lib.calling_conv) Result {
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const ptr = alloc.create(ParserWrapper) catch
return .out_of_memory;
ptr.* = .{
@@ -141,7 +140,7 @@ pub fn wasm_free_attribute(attr: *sgr.Attribute.C) callconv(lib.calling_conv) vo
test "alloc" {
var p: Parser = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&p,
));
free(p);
@@ -150,7 +149,7 @@ test "alloc" {
test "simple params, no seps" {
var p: Parser = undefined;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&p,
));
defer free(p);

View File

@@ -1,8 +1,7 @@
const std = @import("std");
const testing = std.testing;
const lib = @import("../lib.zig");
const lib_alloc = @import("../../lib/allocator.zig");
const CAllocator = lib_alloc.Allocator;
const CAllocator = lib.alloc.Allocator;
const ZigTerminal = @import("../Terminal.zig");
const Stream = @import("../stream_terminal.zig").Stream;
const ScreenSet = @import("../ScreenSet.zig");
@@ -239,7 +238,7 @@ fn new_(
) NewError!*TerminalWrapper {
if (opts.cols == 0 or opts.rows == 0) return error.InvalidValue;
const alloc = lib_alloc.default(alloc_);
const alloc = lib.alloc.default(alloc_);
const t = alloc.create(ZigTerminal) catch
return error.OutOfMemory;
errdefer alloc.destroy(t);
@@ -589,7 +588,7 @@ pub fn free(terminal_: Terminal) callconv(lib.calling_conv) void {
test "new/free" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -606,7 +605,7 @@ test "new invalid value" {
var t: Terminal = null;
try testing.expectEqual(Result.invalid_value, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 0,
@@ -617,7 +616,7 @@ test "new invalid value" {
try testing.expect(t == null);
try testing.expectEqual(Result.invalid_value, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -635,7 +634,7 @@ test "free null" {
test "scroll_viewport" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 5,
@@ -691,7 +690,7 @@ test "scroll_viewport null" {
test "reset" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -716,7 +715,7 @@ test "reset null" {
test "resize" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -738,7 +737,7 @@ test "resize null" {
test "resize invalid value" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -755,7 +754,7 @@ test "resize invalid value" {
test "mode_get and mode_set" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -801,7 +800,7 @@ test "mode_set null" {
test "mode_get unknown mode" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -819,7 +818,7 @@ test "mode_get unknown mode" {
test "mode_set unknown mode" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -836,7 +835,7 @@ test "mode_set unknown mode" {
test "vt_write" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -856,7 +855,7 @@ test "vt_write" {
test "vt_write split escape sequence" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -881,7 +880,7 @@ test "vt_write split escape sequence" {
test "get cols and rows" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -902,7 +901,7 @@ test "get cols and rows" {
test "get cursor position" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -930,7 +929,7 @@ test "get null" {
test "get cursor_visible" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -954,7 +953,7 @@ test "get cursor_visible" {
test "get active_screen" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -972,7 +971,7 @@ test "get active_screen" {
test "get kitty_keyboard_flags" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -996,7 +995,7 @@ test "get kitty_keyboard_flags" {
test "get mouse_tracking" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1046,7 +1045,7 @@ test "get mouse_tracking" {
test "get total_rows" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1064,7 +1063,7 @@ test "get total_rows" {
test "get scrollback_rows" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1088,7 +1087,7 @@ test "get scrollback_rows" {
test "get invalid" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1104,7 +1103,7 @@ test "get invalid" {
test "grid_ref" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1142,7 +1141,7 @@ test "grid_ref null terminal" {
test "set write_pty callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1185,7 +1184,7 @@ test "set write_pty callback" {
test "set write_pty without callback ignores queries" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1202,7 +1201,7 @@ test "set write_pty without callback ignores queries" {
test "set write_pty null clears callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1231,7 +1230,7 @@ test "set write_pty null clears callback" {
test "set bell callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1271,7 +1270,7 @@ test "set bell callback" {
test "bell without callback is silent" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1288,7 +1287,7 @@ test "bell without callback is silent" {
test "set enquiry callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1330,7 +1329,7 @@ test "set enquiry callback" {
test "enquiry without callback is silent" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1347,7 +1346,7 @@ test "enquiry without callback is silent" {
test "set xtversion callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1390,7 +1389,7 @@ test "set xtversion callback" {
test "xtversion without callback reports default" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1426,7 +1425,7 @@ test "xtversion without callback reports default" {
test "set title_changed callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1465,7 +1464,7 @@ test "set title_changed callback" {
test "title_changed without callback is silent" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1482,7 +1481,7 @@ test "title_changed without callback is silent" {
test "set size callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1529,7 +1528,7 @@ test "set size callback" {
test "size without callback is silent" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1546,7 +1545,7 @@ test "size without callback is silent" {
test "set device_attributes callback primary" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1600,7 +1599,7 @@ test "set device_attributes callback primary" {
test "set device_attributes callback secondary" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1654,7 +1653,7 @@ test "set device_attributes callback secondary" {
test "set device_attributes callback tertiary" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1708,7 +1707,7 @@ test "set device_attributes callback tertiary" {
test "device_attributes without callback uses default" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1744,7 +1743,7 @@ test "device_attributes without callback uses default" {
test "device_attributes callback returns false uses default" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1785,7 +1784,7 @@ test "device_attributes callback returns false uses default" {
test "set and get title" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1824,7 +1823,7 @@ test "set and get title" {
test "set and get pwd" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1856,7 +1855,7 @@ test "set and get pwd" {
test "get title set via vt_write" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1877,7 +1876,7 @@ test "get title set via vt_write" {
test "resize updates pixel dimensions" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1897,7 +1896,7 @@ test "resize updates pixel dimensions" {
test "resize pixel overflow saturates" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1917,7 +1916,7 @@ test "resize pixel overflow saturates" {
test "resize disables synchronized output" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1937,7 +1936,7 @@ test "resize disables synchronized output" {
test "resize sends in-band size report" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -1978,7 +1977,7 @@ test "resize sends in-band size report" {
test "resize no size report without mode 2048" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -2006,7 +2005,7 @@ test "resize no size report without mode 2048" {
test "resize in-band report without write_pty callback" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -2028,7 +2027,7 @@ test "resize null terminal" {
test "resize zero cols" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -2044,7 +2043,7 @@ test "resize zero cols" {
test "resize zero rows" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,
@@ -2060,7 +2059,7 @@ test "resize zero rows" {
test "grid_ref out of bounds" {
var t: Terminal = null;
try testing.expectEqual(Result.success, new(
&lib_alloc.test_allocator,
&lib.alloc.test_allocator,
&t,
.{
.cols = 80,

View File

@@ -15,6 +15,7 @@ else
.auto;
/// Forwarded decls from lib that are used.
pub const alloc = lib.allocator;
pub const Enum = lib.Enum;
pub const TaggedUnion = lib.TaggedUnion;
pub const Struct = lib.Struct;