╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Logout.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
66 .session = session, 67 .button_id = button_id, 68 .users_tab_id = users_tab_id, 69 }; 70 } 71 72 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 73 self.center.deinit(allocator); 74 } 75 76 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 77 try self.center.build(allocator, constraint, root_focus); 78 } 79 80 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void { 81 _ = allocator; 82 switch (key) { 83 .enter => { 84 try self.logout(root_focus); 85 return; 86 }, 87 .mouse => |mouse| { 88 if (mouse.action == .press and mouse.action.press == .left) { 89 if (root_focus.children.get(self.button_id)) |entry| { 90 const r = entry.rect; 91 if (mouse.x >= r.x and mouse.y >= r.y and 92 mouse.x < r.x + r.size.width and mouse.y < r.y + r.size.height) 93 { 94 try self.logout(root_focus); 95 return; 96 } 97 } 98 } 99 }, 100 else => {}, 101 } 102 } 103 104 fn logout(self: *View, root_focus: *Focus) !void { 105 self.session.data.user_id = null; 106 // jump focus back to the users tab — the logout button is about to 107 // be hidden by the tab-label swap. 108 try root_focus.setFocus(self.users_tab_id); 109 } 110 111 pub fn clearGrid(self: *View) void { 112 self.center.clearGrid(); 113 } 114 115 pub fn getGrid(self: View) ?Grid { 116 return self.center.getGrid(); 117 } 118 119 pub fn getFocus(self: *View) *Focus { 120 return self.center.getFocus(); 121 } 122 123 pub fn getSelectedIndex(self: View) ?usize { 124 _ = self; 125 return 0; 126 } 127 }; 128