╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Home.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
130 .home_users => self.session.data.current_page = .{ .home_users = self.data.users.start }, 131 .home_repos => self.session.data.current_page = .{ .home_repos = self.data.repos.start }, 132 .home_settings => self.session.data.current_page = .home_settings, 133 .home_auth => self.session.data.current_page = .home_auth, 134 // the quit tab is tty-only and not a route, so leave current_page 135 // alone (nothing to mirror into the url). 136 else => {}, 137 } 138 } 139 try self.box.build(allocator, constraint, root_focus); 140 } 141 142 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 143 if (self.getFocus().child_id) |child_id| { 144 if (self.box.children.getIndex(child_id)) |current_index| { 145 const child = &self.box.children.values()[current_index].widget; 146 var index = current_index; 147 148 const direction = inp.vertDirection(key); 149 150 switch (direction) { 151 .up => { 152 switch (child.*) { 153 .home_header => { 154 try child.input(allocator, key, root_focus); 155 }, 156 .stack => { 157 if (child.stack.getSelected()) |selected_widget| { 158 const at_top = switch (selected_widget.*) { 159 .home_users => |*v| v.getSelectedIndex() == 0, 160 .home_repos => |*v| v.getSelectedIndex() == 0, 161 .home_settings => |*v| v.getSelectedIndex() == 0, 162 .home_auth => |*v| v.getSelectedIndex() == 0, 163 .quit => |*v| v.getSelectedIndex() == 0, 164 else => false, 165 }; 166 if (at_top) { 167 index = header_index; 168 } else { 169 try child.input(allocator, key, root_focus); 170 } 171 } 172 }, 173 else => {}, 174 } 175 }, 176 .down => { 177 switch (child.*) { 178 .home_header => { 179 index = stack_index; 180 }, 181 .stack => { 182 try child.input(allocator, key, root_focus); 183 }, 184 else => {}, 185 } 186 }, 187 .none => { 188 try child.input(allocator, key, root_focus); 189 }, 190 } 191 192 if (index != current_index) { 193 root_focus.setFocus(self.box.children.keys()[index]); 194 } 195 } 196 } 197 } 198 199 pub fn clearGrid(self: *View) void { 200 self.box.clearGrid(); 201 } 202 203 pub fn getGrid(self: View) ?Grid { 204 return self.box.getGrid(); 205 } 206 207 pub fn getFocus(self: *View) *Focus { 208 return self.box.getFocus(); 209 } 210 }; 211