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