╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Quit.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
38 .rect = null, 39 .min_size = null, 40 }); 41 } 42 43 var button_id: usize = undefined; 44 { 45 var button = try wgt.TextBox.init(allocator, "quit", .{ .border = .single, .round_corners = true, .wrap_kind = .none }); 46 errdefer button.deinit(allocator); 47 button.getFocus().mode = .all; 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.widget.Center.init(allocator, .{ .box = box }), 60 .session = session, 61 .button_id = button_id, 62 }; 63 } 64 65 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 66 self.center.deinit(allocator); 67 } 68 69 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 70 try self.center.build(allocator, constraint, root_focus); 71 } 72 73 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 74 _ = allocator; 75 switch (key) { 76 .enter => { 77 self.session.quit_requested = true; 78 return; 79 }, 80 .mouse => |mouse| { 81 if (inp.leftClickOn(root_focus, self.button_id, mouse)) { 82 self.session.quit_requested = true; 83 return; 84 } 85 }, 86 else => {}, 87 } 88 } 89 90 pub fn clearGrid(self: *View) void { 91 self.center.clearGrid(); 92 } 93 94 pub fn getGrid(self: View) ?Grid { 95 return self.center.getGrid(); 96 } 97 98 pub fn getFocus(self: *View) *Focus { 99 return self.center.getFocus(); 100 } 101 102 pub fn atTop(self: View) bool { 103 _ = self; 104 return true; 105 } 106 }; 107