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