╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2803 var background = try widget.AnsiBackground.init(allocator, page_widget, session); 2804 errdefer background.deinit(allocator); 2805 const id = background.getFocus().id; 2806 try box.children.put(allocator, id, .{ .widget = .{ .background = background }, .rect = null, .min_size = null }); 2807 break :bg_blk id; 2808 }; 2809 { 2810 var footer = try widget.Footer.init(allocator, session); 2811 errdefer footer.deinit(allocator); 2812 try box.children.put(allocator, footer.getFocus().id, .{ .widget = .{ .footer = footer }, .rect = null, .min_size = .{ .width = null, .height = 1 } }); 2813 } 2814 box.getFocus().child_id = bg_id; 2815 break :blk Widget{ .box = box }; 2816 } else Widget{ .background = try widget.AnsiBackground.init(allocator, page_widget, session) }; 2817 errdefer root.deinit(allocator); 2818 2819 // input-owning views build their TextInputs in init, so reset their 2820 // registrations here 2821 session.text_inputs.clearRetainingCapacity(); 2822 2823 try root.build(allocator, .{ 2824 .min_size = .{ .width = null, .height = 40 }, 2825 .max_size = .{ .width = 100, .height = null }, 2826 }, root.getFocus()); 2827 2828 return root; 2829 } 2830 2831 // native and server-side sessions choose from the embedded collection. WASM 2832 // keeps the art serialized by the server instead. 2833 fn chooseAnsiArtForNavigation(session: *Session) void { 2834 if (comptime ansi_arts.len == 0) return; 2835 const io = session.io orelse return; 2836 var random: usize = undefined; 2837 io.random(std.mem.asBytes(&random)); 2838 session.data.ansi_art = ansi_arts[random % ansi_arts.len]; 2839 } 2840