╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Threads.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2513 2514 const id_bytes = try evt.parseEventId(entry.id); 2515 2516 switch (src.repo_kind) { 2517 inline else => |repo_kind| { 2518 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2519 defer any_repo.deinit(io, allocator); 2520 switch (any_repo) { 2521 inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author), 2522 } 2523 }, 2524 } 2525 2526 const route = listRoute(self.data.identity, status, "", entry.id) orelse return; 2527 try self.session.navigate(route); 2528 } 2529 2530 // arrow keys move the tag selection; at the flow's edges focus crosses to 2531 // the neighboring widgets. 2532 fn tagsInput(self: *This, index: usize, child_index: usize, tf: *ui.TagFlow, key: Key, root_focus: *Focus) void { 2533 const cid = tf.focus.child_id orelse return; 2534 const cur = tf.indexOfFocusId(cid) orelse return; 2535 const count = tf.text_boxes.items.len; 2536 switch (key) { 2537 .arrow_left => if (cur > 0) self.focusTag(index, child_index, tf, root_focus, cur - 1) else self.focusList(index, root_focus), 2538 .arrow_right => if (cur + 1 < count) self.focusTag(index, child_index, tf, root_focus, cur + 1), 2539 .arrow_up => if (tf.rowStep(cur, false)) |i| { 2540 self.focusTag(index, child_index, tf, root_focus, i); 2541 } else { 2542 _ = self.moveDetailVertical(index, root_focus, false); 2543 }, 2544 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2545 self.focusTag(index, child_index, tf, root_focus, i); 2546 } else { 2547 _ = self.moveDetailVertical(index, root_focus, true); 2548 }, 2549 .home => self.focusTag(index, child_index, tf, root_focus, 0), 2550 .end => self.focusTag(index, child_index, tf, root_focus, count - 1), 2551 else => {}, 2552 } 2553 } 2554 2555 // the tool row's first child after the spacer that pushes it right 2556 const first_in_row_index: usize = 1; 2557 2558 fn toolRowFocused(self: *This, index: usize) bool { 2559 const outer = self.detailOuter(index); 2560 const cid = outer.getFocus().child_id orelse return false; 2561 return outer.children.getIndex(cid) == tool_row_index; 2562 } 2563 2564 fn focusTag(self: *This, index: usize, child_index: usize, tf: *ui.TagFlow, root_focus: *Focus, item: usize) void { 2565 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2566 // keep the tag visible on the terminal: its rect offset by the flow's 2567 // position in the pane. 2568 if (self.session.is_terminal and item < tf.rects.items.len) { 2569 if (self.detailInner(index).children.values()[child_index].rect) |flow_rect| { 2570 var rect = tf.rects.items[item]; 2571 rect.x += flow_rect.x; 2572 rect.y += flow_rect.y; 2573 self.detailScroll(index).scrollToRect(rect); 2574 } 2575 } 2576 } 2577 2578 // return to the tool row's last-focused button (the header when the 2579 // description page shows no row). 2580 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2581 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2582 root_focus.setFocus(cid); 2583 } 2584 2585 // enter the detail pane. an empty pane can't be entered. 2586 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 2587 if (self.detailInner(index).children.count() == 0) return; 2588 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2589 } 2590 2591 // return to the list. 2592 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2593 root_focus.setFocus(self.listScroll(index).getFocus().id); 2594 } 2595 2596 // cross to the header tabs above the stack. 2597 fn focusHeader(self: *This, root_focus: *Focus) void { 2598 root_focus.setFocus(self.box.children.keys()[header_index]); 2599 } 2600 2601 pub fn clearGrid(self: *This) void { 2602 self.box.clearGrid(); 2603 } 2604 2605 pub fn getGrid(self: This) ?Grid { 2606 return self.box.getGrid(); 2607 } 2608 2609 pub fn getFocus(self: *This) *Focus { 2610 return self.box.getFocus(); 2611 } 2612 2613 // for the parent's "scroll up at the top jumps to the header" check: at the 2614 // top only while the header tabs hold focus, so up from the split 2615 // crosses into the tabs first. 2616 pub fn getSelectedIndex(self: *This) ?usize { 2617 return if (self.headerActive()) 0 else 1; 2618 } 2619 }; 2620 } 2621