╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Threads.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2125 _ = self.moveDetailVertical(index, root_focus, false); 2126 }, 2127 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2128 self.focusTag(index, tf, root_focus, i); 2129 } else { 2130 _ = self.moveDetailVertical(index, root_focus, true); 2131 }, 2132 .home => self.focusTag(index, tf, root_focus, 0), 2133 .end => self.focusTag(index, tf, root_focus, count - 1), 2134 else => {}, 2135 } 2136 } 2137 2138 const title_child_index: usize = 0; 2139 const tags_child_index: usize = 2; 2140 2141 // the tool row's first child after the spacer that pushes it right 2142 const first_in_row_index: usize = 1; 2143 2144 fn tagFlow(self: *This, index: usize) ?*ui.TagFlow { 2145 const inner = self.detailInner(index); 2146 if (inner.children.count() <= tags_child_index) return null; 2147 return switch (inner.children.values()[tags_child_index].widget) { 2148 .tag_flow => |*tf| tf, 2149 else => null, 2150 }; 2151 } 2152 2153 fn tagsFocused(self: *This, index: usize) bool { 2154 const inner = self.detailInner(index); 2155 const cid = inner.getFocus().child_id orelse return false; 2156 return inner.children.getIndex(cid) == tags_child_index and self.tagFlow(index) != null; 2157 } 2158 2159 fn toolRowFocused(self: *This, index: usize) bool { 2160 const outer = self.detailOuter(index); 2161 const cid = outer.getFocus().child_id orelse return false; 2162 return outer.children.getIndex(cid) == tool_row_index; 2163 } 2164 2165 fn focusTag(self: *This, index: usize, tf: *ui.TagFlow, root_focus: *Focus, item: usize) void { 2166 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2167 // keep the tag visible on the terminal: its rect offset by the flow's 2168 // position in the pane. 2169 if (self.session.is_terminal and item < tf.rects.items.len) { 2170 if (self.detailInner(index).children.values()[tags_child_index].rect) |flow_rect| { 2171 var rect = tf.rects.items[item]; 2172 rect.x += flow_rect.x; 2173 rect.y += flow_rect.y; 2174 self.detailScroll(index).scrollToRect(rect); 2175 } 2176 } 2177 } 2178 2179 fn titleFocused(self: *This, index: usize) bool { 2180 const inner = self.detailInner(index); 2181 const cid = inner.getFocus().child_id orelse return false; 2182 return inner.children.getIndex(cid) == title_child_index; 2183 } 2184 2185 fn authorFocused(self: *This, index: usize) bool { 2186 const inner = self.detailInner(index); 2187 const cid = inner.getFocus().child_id orelse return false; 2188 return cid == self.author_id[index]; 2189 } 2190 2191 fn descriptionFocused(self: *This, index: usize) bool { 2192 const cid = self.detailInner(index).getFocus().child_id orelse return false; 2193 return cid == self.description_id[index]; 2194 } 2195 2196 // return to the tool row's last-focused button (the header when the 2197 // description page shows no row). 2198 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2199 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2200 root_focus.setFocus(cid); 2201 } 2202 2203 // enter the detail pane. an empty pane (no issues) can't be entered. 2204 fn focusDetail(self: *This, index: usize, root_focus: *Focus) !void { 2205 if (self.detailInner(index).children.count() == 0) return; 2206 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2207 } 2208 2209 // return to the list. 2210 fn focusList(self: *This, index: usize, root_focus: *Focus) !void { 2211 root_focus.setFocus(self.listScroll(index).getFocus().id); 2212 } 2213 2214 // cross to the header tabs above the stack. 2215 fn focusHeader(self: *This, root_focus: *Focus) void { 2216 root_focus.setFocus(self.box.children.keys()[header_index]); 2217 } 2218 2219 pub fn clearGrid(self: *This) void { 2220 self.box.clearGrid(); 2221 } 2222 2223 pub fn getGrid(self: This) ?Grid { 2224 return self.box.getGrid(); 2225 } 2226 2227 pub fn getFocus(self: *This) *Focus { 2228 return self.box.getFocus(); 2229 } 2230 2231 // for the parent's "scroll up at the top jumps to the header" check: at the 2232 // top only while the header tabs hold focus, so up from the split 2233 // crosses into the tabs first. 2234 pub fn getSelectedIndex(self: *This) ?usize { 2235 return if (self.headerActive()) 0 else 1; 2236 } 2237 }; 2238 } 2239