╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Fork.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
238 self.clearGrid(); 239 const header = &self.box.children.values()[header_index].widget.fork_header; 240 const stack = &self.box.children.values()[stack_index].widget.stack; 241 if (header.getSelectedIndex()) |index| stack.getFocus().child_id = stack.children.keys()[index]; 242 try self.box.build(allocator, constraint, root_focus); 243 } 244 245 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 246 const stack = &self.box.children.values()[stack_index].widget.stack; 247 const current_id = self.box.getFocus().child_id orelse return; 248 const current_index = self.box.children.getIndex(current_id) orelse return; 249 const child = &self.box.children.values()[current_index].widget; 250 var next_index = current_index; 251 switch (inp.vertDirection(key)) { 252 .up => switch (child.*) { 253 .fork_header => try child.input(allocator, key, root_focus), 254 .stack => if (stack.getSelected()) |selected| { 255 if (selected.atTop(root_focus)) next_index = header_index else try child.input(allocator, key, root_focus); 256 }, 257 else => {}, 258 }, 259 .down => switch (child.*) { 260 .fork_header => { 261 if (stack.getSelected()) |selected| switch (selected.*) { 262 .repo_patch_detail => |*view| if (view.focusFirst(root_focus)) return, 263 .repo_files => |*view| if (view.focusHeader(root_focus)) return, 264 .repo_commits => |*view| if (view.focusHeader(root_focus)) return, 265 else => {}, 266 }; 267 next_index = stack_index; 268 }, 269 .stack => try child.input(allocator, key, root_focus), 270 else => {}, 271 }, 272 .none => try child.input(allocator, key, root_focus), 273 } 274 if (next_index != current_index) root_focus.setFocus(self.box.children.keys()[next_index]); 275 } 276 277 pub fn clearGrid(self: *View) void { 278 self.box.clearGrid(); 279 } 280 281 pub fn getGrid(self: View) ?Grid { 282 return self.box.getGrid(); 283 } 284 285 pub fn getFocus(self: *View) *Focus { 286 return self.box.getFocus(); 287 } 288 }; 289