╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2922 errdefer background.deinit(allocator); 2923 const id = background.getFocus().id; 2924 try box.children.put(allocator, id, .{ .widget = .{ .background = background }, .rect = null, .min_size = null }); 2925 break :bg_blk id; 2926 }; 2927 if (session.web_port != null) { 2928 var footer = try widget.Footer.init(allocator, session); 2929 errdefer footer.deinit(allocator); 2930 try box.children.put(allocator, footer.getFocus().id, .{ .widget = .{ .footer = footer }, .rect = null, .min_size = .{ .width = null, .height = 1 } }); 2931 } 2932 box.getFocus().child_id = bg_id; 2933 break :blk Widget{ .box = box }; 2934 } else Widget{ .background = try widget.AnsiBackground.init(allocator, page_widget, session) }; 2935 errdefer root.deinit(allocator); 2936 2937 // input-owning views build their TextInputs in init, so reset their 2938 // registrations here 2939 session.text_inputs.clearRetainingCapacity(); 2940 2941 try root.build(allocator, .{ 2942 .min_size = .{ .width = null, .height = 40 }, 2943 .max_size = .{ .width = 100, .height = null }, 2944 }, root.getFocus()); 2945 2946 return root; 2947 } 2948 2949 // native and server-side sessions choose from the embedded collection. WASM 2950 // keeps the art serialized by the server instead. 2951 fn chooseAnsiArtForNavigation(session: *Session) void { 2952 if (comptime ansi_art.art.len == 0) return; 2953 if (session.data.current_page == .not_found) { 2954 session.data.ansi_art = ansi_art.not_found; 2955 return; 2956 } 2957 const io = session.io orelse return; 2958 var random: usize = undefined; 2959 io.random(std.mem.asBytes(&random)); 2960 session.data.ansi_art = ansi_art.art[random % ansi_art.art.len]; 2961 } 2962