╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Threads.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2063 2064 var id_bytes: [evt.event_id_size]u8 = undefined; 2065 _ = try std.fmt.hexToBytes(&id_bytes, entry.id[0 .. evt.event_id_size * 2]); 2066 2067 switch (src.repo_kind) { 2068 inline else => |repo_kind| { 2069 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2070 defer any_repo.deinit(io, allocator); 2071 switch (any_repo) { 2072 inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author), 2073 } 2074 }, 2075 } 2076 2077 const route = listRoute(self.data.identity, status, "", entry.id) orelse return; 2078 try self.session.navigate(route); 2079 } 2080 2081 // arrow keys move the tag selection; at the flow's edges focus crosses to 2082 // the neighboring widgets. 2083 fn tagsInput(self: *This, index: usize, key: Key, root_focus: *Focus) !void { 2084 const tf = self.tagFlow(index) orelse return; 2085 const cid = tf.focus.child_id orelse return; 2086 const cur = tf.indexOfFocusId(cid) orelse return; 2087 const count = tf.text_boxes.items.len; 2088 switch (key) { 2089 .arrow_left => if (cur > 0) self.focusTag(index, tf, root_focus, cur - 1) else try self.focusList(index, root_focus), 2090 .arrow_right => if (cur + 1 < count) self.focusTag(index, tf, root_focus, cur + 1), 2091 .arrow_up => if (tf.rowStep(cur, false)) |i| { 2092 self.focusTag(index, tf, root_focus, i); 2093 } else { 2094 _ = self.moveDetailVertical(index, root_focus, false); 2095 }, 2096 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2097 self.focusTag(index, tf, root_focus, i); 2098 } else { 2099 _ = self.moveDetailVertical(index, root_focus, true); 2100 }, 2101 .home => self.focusTag(index, tf, root_focus, 0), 2102 .end => self.focusTag(index, tf, root_focus, count - 1), 2103 else => {}, 2104 } 2105 } 2106 2107 const title_child_index: usize = 0; 2108 const tags_child_index: usize = 2; 2109 2110 // the tool row's first child after the spacer that pushes it right 2111 const first_in_row_index: usize = 1; 2112 2113 fn tagFlow(self: *This, index: usize) ?*ui.TagFlow { 2114 const inner = self.detailInner(index); 2115 if (inner.children.count() <= tags_child_index) return null; 2116 return switch (inner.children.values()[tags_child_index].widget) { 2117 .tag_flow => |*tf| tf, 2118 else => null, 2119 }; 2120 } 2121 2122 fn tagsFocused(self: *This, index: usize) bool { 2123 const inner = self.detailInner(index); 2124 const cid = inner.getFocus().child_id orelse return false; 2125 return inner.children.getIndex(cid) == tags_child_index and self.tagFlow(index) != null; 2126 } 2127 2128 fn toolRowFocused(self: *This, index: usize) bool { 2129 const outer = self.detailOuter(index); 2130 const cid = outer.getFocus().child_id orelse return false; 2131 return outer.children.getIndex(cid) == tool_row_index; 2132 } 2133 2134 fn focusTag(self: *This, index: usize, tf: *ui.TagFlow, root_focus: *Focus, item: usize) void { 2135 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2136 // keep the tag visible on the terminal: its rect offset by the flow's 2137 // position in the pane. 2138 if (self.session.is_terminal and item < tf.rects.items.len) { 2139 if (self.detailInner(index).children.values()[tags_child_index].rect) |flow_rect| { 2140 var rect = tf.rects.items[item]; 2141 rect.x += flow_rect.x; 2142 rect.y += flow_rect.y; 2143 self.detailScroll(index).scrollToRect(rect); 2144 } 2145 } 2146 } 2147 2148 fn titleFocused(self: *This, index: usize) bool { 2149 const inner = self.detailInner(index); 2150 const cid = inner.getFocus().child_id orelse return false; 2151 return inner.children.getIndex(cid) == title_child_index; 2152 } 2153 2154 fn authorFocused(self: *This, index: usize) bool { 2155 const inner = self.detailInner(index); 2156 const cid = inner.getFocus().child_id orelse return false; 2157 return cid == self.author_id[index]; 2158 } 2159 2160 fn descriptionFocused(self: *This, index: usize) bool { 2161 const cid = self.detailInner(index).getFocus().child_id orelse return false; 2162 return cid == self.description_id[index]; 2163 } 2164 2165 // return to the tool row's last-focused button (the header when the 2166 // description page shows no row). 2167 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2168 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2169 root_focus.setFocus(cid); 2170 } 2171 2172 // enter the detail pane. an empty pane (no issues) can't be entered. 2173 fn focusDetail(self: *This, index: usize, root_focus: *Focus) !void { 2174 if (self.detailInner(index).children.count() == 0) return; 2175 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2176 } 2177 2178 // return to the list. 2179 fn focusList(self: *This, index: usize, root_focus: *Focus) !void { 2180 root_focus.setFocus(self.listScroll(index).getFocus().id); 2181 } 2182 2183 // cross to the header tabs above the stack. 2184 fn focusHeader(self: *This, root_focus: *Focus) void { 2185 root_focus.setFocus(self.box.children.keys()[header_index]); 2186 } 2187 2188 pub fn clearGrid(self: *This) void { 2189 self.box.clearGrid(); 2190 } 2191 2192 pub fn getGrid(self: This) ?Grid { 2193 return self.box.getGrid(); 2194 } 2195 2196 pub fn getFocus(self: *This) *Focus { 2197 return self.box.getFocus(); 2198 } 2199 2200 // for the parent's "scroll up at the top jumps to the header" check: at the 2201 // top only while the header tabs hold focus, so up from the split 2202 // crosses into the tabs first. 2203 pub fn getSelectedIndex(self: *This) ?usize { 2204 return if (self.headerActive()) 0 else 1; 2205 } 2206 }; 2207 } 2208