╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
246 .home_settings => self.session.data.current_page = .{ .repo_settings = self.data.identity }, 247 .home_auth => self.session.data.current_page = .{ .repo_auth = self.data.identity }, 248 // the quit tab is tty-only and not a route, so leave current_page 249 // alone (nothing to mirror into the url). 250 .quit => {}, 251 // the files tab (this page's directory route) 252 else => self.session.data.current_page = .{ .repo_files = .{ .name = self.data.route_name, .after = self.data.files_after } }, 253 } 254 } 255 try self.box.build(allocator, constraint, root_focus); 256 } 257 258 pub fn input(self: *View, allocator: std.mem.Allocator, key: inp.Key, root_focus: *Focus) !void { 259 if (self.getFocus().child_id) |child_id| { 260 if (self.box.children.getIndex(child_id)) |current_index| { 261 const child = &self.box.children.values()[current_index].widget; 262 var index = current_index; 263 264 const Direction = enum { up, down, none }; 265 const direction: Direction = switch (key) { 266 .arrow_up => .up, 267 .arrow_down => .down, 268 .mouse => |mouse| if (mouse.action == .scroll) 269 (if (mouse.action.scroll == .up) .up else .down) 270 else 271 .none, 272 else => .none, 273 }; 274 275 switch (direction) { 276 .up => { 277 switch (child.*) { 278 .repo_header => { 279 try child.input(allocator, key, root_focus); 280 }, 281 .stack => { 282 if (child.stack.getSelected()) |selected_widget| { 283 const at_top = switch (selected_widget.*) { 284 .repo_files => |*v| v.getSelectedIndex() == 0, 285 .repo_commits => |*v| v.getSelectedIndex() == 0, 286 .repo_refs => |*v| v.getSelectedIndex() == 0, 287 .home_settings => |*v| v.getSelectedIndex() == 0, 288 .home_auth => |*v| v.getSelectedIndex() == 0, 289 .quit => |*v| v.getSelectedIndex() == 0, 290 else => false, 291 }; 292 if (at_top) { 293 index = header_index; 294 } else { 295 try child.input(allocator, key, root_focus); 296 } 297 } 298 }, 299 else => {}, 300 } 301 }, 302 .down => { 303 switch (child.*) { 304 .repo_header => { 305 index = stack_index; 306 }, 307 .stack => { 308 try child.input(allocator, key, root_focus); 309 }, 310 else => {}, 311 } 312 }, 313 .none => { 314 try child.input(allocator, key, root_focus); 315 }, 316 } 317 318 if (index != current_index) { 319 root_focus.setFocus(self.box.children.keys()[index]); 320 } 321 } 322 } 323 } 324 325 pub fn clearGrid(self: *View) void { 326 self.box.clearGrid(); 327 } 328 329 pub fn getGrid(self: View) ?Grid { 330 return self.box.getGrid(); 331 } 332 333 pub fn getFocus(self: *View) *Focus { 334 return self.box.getFocus(); 335 } 336 }; 337