╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2377 const src = self.data.repo_source orelse return; 2378 const sel = self.detailed_index[index] orelse return; 2379 const entry = self.window(index).items[sel]; 2380 const author = (try self.session.eventAuthor()) orelse return; 2381 2382 const status = (statusChange(entryStatus(entry)) orelse return).status; 2383 2384 const id_bytes = try evt.parseEventId(entry.id); 2385 2386 switch (src.repo_kind) { 2387 inline else => |repo_kind| { 2388 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2389 defer any_repo.deinit(io, allocator); 2390 switch (any_repo) { 2391 inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author), 2392 } 2393 }, 2394 } 2395 2396 const route = listRoute(self.data.identity, status, "", entry.id) orelse return; 2397 try self.session.navigate(route); 2398 } 2399 2400 // arrow keys move the tag selection; at the flow's edges focus crosses to 2401 // the neighboring widgets. 2402 fn tagsInput(self: *This, index: usize, child_index: usize, tf: *TagFlow, key: Key, root_focus: *Focus) void { 2403 const cid = tf.focus.child_id orelse return; 2404 const cur = tf.indexOfFocusId(cid) orelse return; 2405 const count = tf.text_boxes.items.len; 2406 switch (key) { 2407 .arrow_left => if (cur > 0) self.focusTag(index, child_index, tf, root_focus, cur - 1) else self.focusList(index, root_focus), 2408 .arrow_right => if (cur + 1 < count) self.focusTag(index, child_index, tf, root_focus, cur + 1), 2409 .arrow_up => if (tf.rowStep(cur, false)) |i| { 2410 self.focusTag(index, child_index, tf, root_focus, i); 2411 } else { 2412 _ = self.moveDetailVertical(index, root_focus, false); 2413 }, 2414 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2415 self.focusTag(index, child_index, tf, root_focus, i); 2416 } else { 2417 _ = self.moveDetailVertical(index, root_focus, true); 2418 }, 2419 .home => self.focusTag(index, child_index, tf, root_focus, 0), 2420 .end => self.focusTag(index, child_index, tf, root_focus, count - 1), 2421 else => {}, 2422 } 2423 } 2424 2425 // the tool row's first child after the spacer that pushes it right 2426 const first_in_row_index: usize = 1; 2427 2428 fn toolRowFocused(self: *This, index: usize) bool { 2429 const outer = self.detailOuter(index); 2430 const cid = outer.getFocus().child_id orelse return false; 2431 return outer.children.getIndex(cid) == tool_row_index; 2432 } 2433 2434 fn focusTag(self: *This, index: usize, child_index: usize, tf: *TagFlow, root_focus: *Focus, item: usize) void { 2435 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2436 // keep the tag visible on the terminal: its rect offset by the flow's 2437 // position in the pane. 2438 if (self.session.is_terminal and item < tf.rects.items.len) { 2439 if (self.detailInner(index).children.values()[child_index].rect) |flow_rect| { 2440 var rect = tf.rects.items[item]; 2441 rect.x += flow_rect.x; 2442 rect.y += flow_rect.y; 2443 self.detailScroll(index).scrollToRect(rect); 2444 } 2445 } 2446 } 2447 2448 // return to the tool row's last-focused button (the header when the 2449 // description page shows no row). 2450 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2451 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2452 root_focus.setFocus(cid); 2453 } 2454 2455 // enter the detail pane. an empty pane can't be entered. 2456 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 2457 if (self.detailInner(index).children.count() == 0) return; 2458 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2459 } 2460 2461 // return to the list. 2462 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2463 root_focus.setFocus(self.listScroll(index).getFocus().id); 2464 } 2465 2466 // cross to the header tabs above the stack. 2467 fn focusHeader(self: *This, root_focus: *Focus) void { 2468 root_focus.setFocus(self.box.children.keys()[header_index]); 2469 } 2470 2471 pub fn clearGrid(self: *This) void { 2472 self.box.clearGrid(); 2473 } 2474 2475 pub fn getGrid(self: This) ?Grid { 2476 return self.box.getGrid(); 2477 } 2478 2479 pub fn getFocus(self: *This) *Focus { 2480 return self.box.getFocus(); 2481 } 2482 2483 // for the parent's "scroll up at the top jumps to the header" check: at the 2484 // top only while the header tabs hold focus, so up from the split 2485 // crosses into the tabs first. 2486 pub fn getSelectedIndex(self: *This) ?usize { 2487 return if (self.headerActive()) 0 else 1; 2488 } 2489 }; 2490 } 2491