╭ changed ────────╮ │src/main_wasm.zig│ ╰─────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────╮ │20 var page_arena: ?std.heap.ArenaAllocator = null; │ │21 var page: ?pg.Page = null; │ │22 │ │23 -fn start(json: []const u8) !void { │ │23 +fn start(json: []const u8, max_width: u32) !void { │ │24 if (page_arena) |*a| a.deinit(); │ │25 page_arena = std.heap.ArenaAllocator.init(allocator);│ │26 │ ╰─────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────╮ │36 if (root) |*old_root| old_root.deinit(); │ │37 root = next_root; │ │38 │ │39 - try updateHtml(); │ │39 + try tick(max_width); │ │40 } │ │41 │ │42 -fn tick() !void { │ │42 +fn tick(max_width: u32) !void { │ │43 const root_ptr = if (root) |*root_value| root_value else return error.NotStarted;│ │44 - // TODO: make this fit the current size of the browser window │ │44 try root_ptr.build(.{ │ │45 .min_size = .{ .width = null, .height = null }, │ │47 - .max_size = .{ .width = 80, .height = 24 }, │ │46 + // height is null so the TUI grows to fit all its content; the browser │ │47 + // page handles vertical scrolling. │ │48 + .max_size = .{ .width = max_width, .height = null }, │ │49 }, root_ptr.getFocus()); │ │50 try updateHtml(); │ │51 } │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │83 return slice.ptr; │ │84 } │ │85 │ │85 -export fn _start(json_ptr: [*]u8, json_len: u32) void { │ │86 +export fn _start(json_ptr: [*]u8, json_len: u32, max_width: u32) void { │ │87 const json = json_ptr[0..json_len]; │ │88 defer allocator.free(json); │ │88 - start(json) catch |err| { │ │89 + start(json, max_width) catch |err| { │ │90 var buf: [256]u8 = undefined; │ │91 const str = std.fmt.bufPrint(&buf, "start: {}", .{err}) catch unreachable;│ │92 consoleLog(str); │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │ 93 }; │ │ 94 } │ │ 95 │ │ 95 -export fn _tick() bool { │ │ 96 - tick() catch |err| { │ │ 96 +export fn _tick(max_width: u32) bool { │ │ 97 + tick(max_width) catch |err| { │ │ 98 var buf: [256]u8 = undefined; │ │ 99 const str = std.fmt.bufPrint(&buf, "tick: {}", .{err}) catch unreachable;│ │100 consoleLog(str); │ ╰──────────────────────────────────────────────────────────────────────────────────────╯