╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2410 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex) orelse return; 2411 try self.session.navigate(route); 2412 } 2413 2414 // flip the shown thread's status by re-emitting its event, then reload the 2415 // page rooted at the thread so the view reflects the change. this is the 2416 // terminal path; the web posts the button's form to the status route. 2417 fn toggleStatus(self: *This, allocator: std.mem.Allocator, index: usize) !void { 2418 if (comptime !has_status) return; 2419 if (comptime wasm) return; 2420 const io = self.session.io orelse return; 2421 const src = self.data.repo_source orelse return; 2422 const sel = self.detailed_index[index] orelse return; 2423 const entry = self.window(index).items[sel]; 2424 const author = (try self.session.eventAuthor()) orelse return; 2425 2426 const status = (statusChange(entryStatus(entry)) orelse return).status; 2427 2428 const id_bytes = try evt.parseEventId(entry.id); 2429 2430 switch (src.repo_kind) { 2431 inline else => |repo_kind| { 2432 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2433 defer any_repo.deinit(io, allocator); 2434 switch (any_repo) { 2435 inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author), 2436 } 2437 }, 2438 } 2439 2440 const route = listRoute(self.data.identity, status, "", entry.id) orelse return; 2441 try self.session.navigate(route); 2442 } 2443 2444 // arrow keys move the tag selection; at the flow's edges focus crosses to 2445 // the neighboring widgets. 2446 fn tagsInput(self: *This, index: usize, child_index: usize, tf: *TagFlow, key: Key, root_focus: *Focus) void { 2447 const cid = tf.focus.child_id orelse return; 2448 const cur = tf.indexOfFocusId(cid) orelse return; 2449 const count = tf.text_boxes.items.len; 2450 switch (key) { 2451 .arrow_left => if (cur > 0) self.focusTag(index, child_index, tf, root_focus, cur - 1) else self.focusList(index, root_focus), 2452 .arrow_right => if (cur + 1 < count) self.focusTag(index, child_index, tf, root_focus, cur + 1), 2453 .arrow_up => if (tf.rowStep(cur, false)) |i| { 2454 self.focusTag(index, child_index, tf, root_focus, i); 2455 } else { 2456 _ = self.moveDetailVertical(index, root_focus, false); 2457 }, 2458 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2459 self.focusTag(index, child_index, tf, root_focus, i); 2460 } else { 2461 _ = self.moveDetailVertical(index, root_focus, true); 2462 }, 2463 .home => self.focusTag(index, child_index, tf, root_focus, 0), 2464 .end => self.focusTag(index, child_index, tf, root_focus, count - 1), 2465 else => {}, 2466 } 2467 } 2468 2469 // the tool row's first child after the spacer that pushes it right 2470 const first_in_row_index: usize = 1; 2471 2472 fn toolRowFocused(self: *This, index: usize) bool { 2473 const outer = self.detailOuter(index); 2474 const cid = outer.getFocus().child_id orelse return false; 2475 return outer.children.getIndex(cid) == tool_row_index; 2476 } 2477 2478 fn focusTag(self: *This, index: usize, child_index: usize, tf: *TagFlow, root_focus: *Focus, item: usize) void { 2479 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2480 // keep the tag visible on the terminal: its rect offset by the flow's 2481 // position in the pane. 2482 if (self.session.is_terminal and item < tf.rects.items.len) { 2483 if (self.detailInner(index).children.values()[child_index].rect) |flow_rect| { 2484 var rect = tf.rects.items[item]; 2485 rect.x += flow_rect.x; 2486 rect.y += flow_rect.y; 2487 self.detailScroll(index).scrollToRect(rect); 2488 } 2489 } 2490 } 2491 2492 // return to the tool row's last-focused button (the header when the 2493 // description page shows no row). 2494 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2495 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2496 root_focus.setFocus(cid); 2497 } 2498 2499 // enter the detail pane. an empty pane can't be entered. 2500 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 2501 if (self.detailInner(index).children.count() == 0) return; 2502 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2503 } 2504 2505 // return to the list. 2506 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2507 root_focus.setFocus(self.listScroll(index).getFocus().id); 2508 } 2509 2510 // cross to the header tabs above the stack. 2511 fn focusHeader(self: *This, root_focus: *Focus) void { 2512 root_focus.setFocus(self.box.children.keys()[header_index]); 2513 } 2514 2515 pub fn clearGrid(self: *This) void { 2516 self.box.clearGrid(); 2517 } 2518 2519 pub fn getGrid(self: This) ?Grid { 2520 return self.box.getGrid(); 2521 } 2522 2523 pub fn getFocus(self: *This) *Focus { 2524 return self.box.getFocus(); 2525 } 2526 2527 // for the parent's "scroll up at the top jumps to the header" check: at the 2528 // top only while the header tabs hold focus, so up from the split 2529 // crosses into the tabs first. 2530 pub fn getSelectedIndex(self: *This) ?usize { 2531 return if (self.headerActive()) 0 else 1; 2532 } 2533 }; 2534 } 2535