╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
3351 errdefer box.deinit(allocator); 3352 const bg_id = bg_blk: { 3353 var background = try widget.AnsiBackground.init(allocator, page_widget, session); 3354 errdefer background.deinit(allocator); 3355 const id = background.getFocus().id; 3356 try box.children.put(allocator, id, .{ .widget = .{ .background = background }, .rect = null, .min_size = null }); 3357 break :bg_blk id; 3358 }; 3359 if (session.web_url != null) { 3360 var footer = try widget.Footer.init(allocator, session); 3361 errdefer footer.deinit(allocator); 3362 try box.children.put(allocator, footer.getFocus().id, .{ .widget = .{ .footer = footer }, .rect = null, .min_size = .{ .width = null, .height = 1 } }); 3363 } 3364 box.getFocus().child_id = bg_id; 3365 break :blk Widget{ .box = box }; 3366 } else Widget{ .background = try widget.AnsiBackground.init(allocator, page_widget, session) }; 3367 errdefer root.deinit(allocator); 3368 3369 // input-owning views build their TextInputs in init, so reset their 3370 // registrations here 3371 session.text_inputs.clearRetainingCapacity(); 3372 3373 try root.build(allocator, .{ 3374 .min_size = .{ .width = null, .height = 40 }, 3375 .max_size = .{ .width = 100, .height = null }, 3376 }, root.getFocus()); 3377 3378 return root; 3379 } 3380 3381 // native and server-side sessions choose from the embedded collection. WASM 3382 // keeps the art serialized by the server instead. 3383 fn chooseAnsiArtForNavigation(session: *Session) void { 3384 if (comptime ansi_art.art.len == 0) return; 3385 if (session.data.current_page == .not_found) { 3386 session.data.ansi_art = ansi_art.not_found; 3387 return; 3388 } 3389 const io = session.io orelse return; 3390 var random: usize = undefined; 3391 io.random(std.mem.asBytes(&random)); 3392 session.data.ansi_art = ansi_art.art[random % ansi_art.art.len]; 3393 } 3394