╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Quit.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
48 button_id = button.getFocus().id; 49 try box.children.put(allocator, button.getFocus().id, .{ 50 .widget = .{ .text_box = button }, 51 .rect = null, 52 .min_size = null, 53 }); 54 } 55 56 box.getFocus().child_id = button_id; 57 58 return .{ 59 .center = try ui.Center.init(allocator, .{ .box = box }, .both), 60 .data = data, 61 .session = session, 62 .button_id = button_id, 63 }; 64 } 65 66 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 67 self.center.deinit(allocator); 68 } 69 70 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 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 => { 78 self.session.quit_requested = true; 79 return; 80 }, 81 .mouse => |mouse| { 82 if (mouse.action == .press and mouse.action.press == .left) { 83 if (root_focus.children.get(self.button_id)) |entry| { 84 const r = entry.rect; 85 if (mouse.x >= r.x and mouse.y >= r.y and 86 mouse.x < r.x + r.size.width and mouse.y < r.y + r.size.height) 87 { 88 self.session.quit_requested = true; 89 return; 90 } 91 } 92 } 93 }, 94 else => {}, 95 } 96 } 97 98 pub fn clearGrid(self: *View) void { 99 self.center.clearGrid(); 100 } 101 102 pub fn getGrid(self: View) ?Grid { 103 return self.center.getGrid(); 104 } 105 106 pub fn getFocus(self: *View) *Focus { 107 return self.center.getFocus(); 108 } 109 110 pub fn getSelectedIndex(self: View) ?usize { 111 _ = self; 112 return 0; 113 } 114 }; 115