╭ changed ───────────╮ │src/ui/Home/Ansi.zig│ ╰────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │26 const button_index: usize = 0; │ │27 │ │28 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { │ │29 - // only logged-in users get a real HTML form to POST to the server │ │29 const logged_in = session.data.user_id != null; │ │30 │ │31 var box = wgt.Box(ui.Widget).init(.{ .border_style = null, .rounded_corners = true, .direction = .vert });│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │32 errdefer box.deinit(allocator); │ │34 - // marks this subtree as an HTML form scope for the web overlay │ │35 - if (logged_in) box.getFocus().kind = .{ .custom = "form:/ansi" }; │ │33 + box.getFocus().kind = .{ .custom = if (logged_in) "form:/ansi" else "form:" };│ │34 │ │35 var button_id: usize = undefined; │ │36 { │ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────╮ │39 button.getFocus().focusable = true; │ │40 // the renderer distinguishes plain clickables from buttons that│ │41 // should POST to a server route by this kind. │ │44 - if (logged_in) button.getFocus().kind = .{ .custom = "submit" };│ │42 + button.getFocus().kind = .{ .custom = "submit" }; │ │43 button_id = button.getFocus().id; │ │44 try box.children.put(allocator, button.getFocus().id, .{ │ │45 .widget = .{ .text_box = button }, │ ╰────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │74 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void {│ │75 _ = allocator; │ │76 switch (key) { │ │79 - .enter => self.toggle(), │ │77 + .enter => try self.toggle(), │ │78 .mouse => |mouse| { │ │79 if (mouse.action == .press and mouse.action.press == .left) { │ │80 if (root_focus.children.get(self.button_id)) |entry| { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │82 if (mouse.x >= r.x and mouse.y >= r.y and │ │83 mouse.x < r.x + r.size.width and mouse.y < r.y + r.size.height)│ │84 { │ │87 - self.toggle(); │ │85 + try self.toggle(); │ │86 } │ │87 } │ │88 } │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────╮ │91 } │ │92 } │ │93 │ │96 - fn toggle(self: *View) void { │ │97 - self.session.data.enable_ansi = !self.session.data.enable_ansi; │ │94 + // enqueue the toggle; the host drains it (applying + persisting) this frame.│ │95 + fn toggle(self: *View) !void { │ │96 + try self.session.push(.toggle_ansi); │ │97 } │ │98 │ │99 pub fn clearGrid(self: *View) void { │ ╰─────────────────────────────────────────────────────────────────────────────────────╯