╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Settings.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
70 } 71 try self.center.build(allocator, constraint, root_focus); 72 } 73 74 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void { 75 _ = allocator; 76 switch (key) { 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| { 81 const r = entry.rect; 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 { 85 try self.toggle(); 86 } 87 } 88 } 89 }, 90 else => {}, 91 } 92 } 93 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 { 100 self.center.clearGrid(); 101 } 102 103 pub fn getGrid(self: View) ?Grid { 104 return self.center.getGrid(); 105 } 106 107 pub fn getFocus(self: *View) *Focus { 108 return self.center.getFocus(); 109 } 110 111 pub fn getSelectedIndex(self: View) ?usize { 112 _ = self; 113 return 0; 114 } 115 }; 116 117 fn labelFor(session: *const ui.Session) []const u8 { 118 return if (session.data.enable_ansi) label_on else label_off; 119 } 120