╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2020 const ti = &child.widget.text_input; 2021 if (ti.options.multiline and try multilineKeepsKey(ti, allocator, key)) 2022 return child.widget.input(allocator, key, root_focus); 2023 } 2024 2025 const on_submit = child.widget == .submit_button; 2026 2027 switch (key) { 2028 .arrow_up, .back_tab => if (resolveStep(form, cur, false)) |i| self.focusResolveChild(form, i, root_focus) else self.focusHeader(root_focus), 2029 .arrow_down, .tab => if (resolveStep(form, cur, true)) |i| self.focusResolveChild(form, i, root_focus), 2030 .arrow_left, .arrow_right => switch (child.widget) { 2031 .box => |*row| { 2032 const row_cid = row.getFocus().child_id orelse return; 2033 const row_index = row.children.getIndex(row_cid) orelse return; 2034 if (key == .arrow_left) { 2035 if (row_index > 0) root_focus.setFocus(row.children.keys()[row_index - 1]); 2036 } else if (row_index + 1 < row.children.count()) { 2037 root_focus.setFocus(row.children.keys()[row_index + 1]); 2038 } 2039 }, 2040 else => try child.widget.input(allocator, key, root_focus), 2041 }, 2042 .enter => if (on_submit) try self.submitResolution(allocator), 2043 .mouse => |mouse| if (on_submit) { 2044 if (inp.leftClickOn(root_focus, child.widget.submit_button.buttonId(), mouse)) try self.submitResolution(allocator); 2045 }, 2046 else => try child.widget.input(allocator, key, root_focus), 2047 } 2048 } 2049 2050 // a multiline input keeps enter and any up/down that has a row to move to 2051 fn multilineKeepsKey(text_input: *wgt.TextInput, allocator: std.mem.Allocator, key: Key) !bool { 2052 return switch (key) { 2053 .enter => true, 2054 .arrow_up => !try text_input.cursorOnFirstRow(allocator), 2055 .arrow_down => !try text_input.cursorOnLastRow(allocator), 2056 else => false, 2057 }; 2058 } 2059 2060 // the neighboring focusable resolve-form child, skipping the spacer and 2061 // the blank gap rows 2062 fn resolveStep(form: *wgt.Box(Widget), cur: usize, down: bool) ?usize { 2063 var i = cur; 2064 while (true) { 2065 if (down) { 2066 i += 1; 2067 if (i >= form.children.count()) return null; 2068 } else { 2069 if (i == 0) return null; 2070 i -= 1; 2071 } 2072 switch (form.children.values()[i].widget) { 2073 .spacer, .text => continue, 2074 else => return i, 2075 } 2076 } 2077 } 2078 2079 // focus the resolve-form child at `i` (a version row focuses its selected 2080 // child) and keep it visible on the terminal 2081 fn focusResolveChild(self: *This, form: *wgt.Box(Widget), i: usize, root_focus: *Focus) void { 2082 const child = &form.children.values()[i]; 2083 switch (child.widget) { 2084 .box => |*row| root_focus.setFocus(row.getFocus().child_id orelse form.children.keys()[i]), 2085 else => root_focus.setFocus(form.children.keys()[i]), 2086 } 2087 if (self.session.is_terminal) { 2088 if (self.resolveScroll()) |sc| { 2089 if (child.rect) |rect| sc.scrollToRect(rect); 2090 } 2091 } 2092 } 2093 2094 // re-emit the conflicted thread's event with the resolved content; any 2095 // event on the thread settles its conflict entry. this is the terminal 2096 // path; the web posts the form to the resolve route. 2097 fn submitResolution(self: *This, allocator: std.mem.Allocator) !void { 2098 if (comptime wasm) return; 2099 const io = self.session.io orelse return; 2100 const src = self.data.repo_source orelse return; 2101 const entry = self.data.selectedThread() orelse return; 2102 const author = (try self.session.eventAuthor()) orelse return; 2103 const form = self.threadForm() orelse return; 2104 2105 // gather the inputs by name; the d<n> hunk inputs appear in chunk order 2106 var title: ?[]u8 = null; 2107 var tags: ?[]u8 = null; 2108 var hunks: std.ArrayList([]const u8) = .empty; 2109 defer { 2110 if (title) |t| allocator.free(t); 2111 if (tags) |t| allocator.free(t); 2112 for (hunks.items) |h| allocator.free(h); 2113 hunks.deinit(allocator); 2114 } 2115 for (form.children.values()) |*child| switch (child.widget) { 2116 .text_input => |*ti| { 2117 const text = try ti.text(allocator); 2118 errdefer allocator.free(text); 2119 if (std.mem.eql(u8, ti.options.name, "title")) { 2120 title = text; 2121 } else if (std.mem.eql(u8, ti.options.name, "tags")) { 2122 tags = text; 2123 } else { 2124 try hunks.append(allocator, text); 2125 } 2126 }, 2127 else => {}, 2128 }; 2129 2130 const id_bytes = try evt.parseEventId(entry.id); 2131 2132 switch (src.repo_kind) { 2133 inline else => |repo_kind| { 2134 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2135 defer any_repo.deinit(io, allocator); 2136 switch (any_repo) { 2137 inline else => |*repo| { 2138 var resolution: Event.Resolve = .{ 2139 .title = title, 2140 .tags = tags, 2141 .hunks = hunks.items, 2142 }; 2143 if (comptime @hasField(Event.Resolve, "theirs")) resolution.theirs = self.data.theirs_picks; 2144 const change = Event.Update{ .resolve = resolution }; 2145 Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, change, author) catch |err| switch (err) { 2146 // leave the form up for correction 2147 error.InvalidFields => return, 2148 else => |e| return e, 2149 }; 2150 }, 2151 } 2152 }, 2153 } 2154 2155 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2156 try self.session.navigate(route); 2157 } 2158 2159 // commit a new or edited comment and navigate to its permalink. this is the 2160 // terminal path; the web posts the form to its comment route. 2161 fn submitComment(self: *This, allocator: std.mem.Allocator) !void { 2162 if (comptime wasm) return; 2163 const io = self.session.io orelse return; 2164 const src = self.data.repo_source orelse return; 2165 const author = (try self.session.eventAuthor()) orelse return; 2166 const form = self.threadForm() orelse return; 2167 const body_input = &form.children.values()[comment_body_field_index].widget.text_input; 2168 const body = try body_input.text(allocator); 2169 defer allocator.free(body); 2170 if (!evt.Comment.fieldsValid(body)) return; 2171 2172 var thread_id: [evt.event_id_size * 2]u8 = undefined; 2173 @memcpy(&thread_id, self.data.selected_id); 2174 const parent_id = if (self.data.comment_id.len == 0) thread_id else blk: { 2175 var parent: [evt.event_id_size * 2]u8 = undefined; 2176 @memcpy(&parent, self.data.comment_id); 2177 break :blk parent; 2178 }; 2179 var event_id_hex: [evt.event_id_size * 2]u8 = undefined; 2180 const editing = self.data.view == .edit_comment; 2181 switch (src.repo_kind) { 2182 inline else => |repo_kind| { 2183 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2184 defer any_repo.deinit(io, allocator); 2185 switch (any_repo) { 2186 inline else => |*repo| if (editing) { 2187 const comment_id = evt.parseEventId(self.data.comment_id) catch return; 2188 try evt.Comment.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &comment_id, body, author); 2189 event_id_hex = std.fmt.bytesToHex(comment_id, .lower); 2190 } else { 2191 event_id_hex = try evt.Comment.create(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &parent_id, body, author); 2192 }, 2193 } 2194 }, 2195 } 2196 2197 body_input.clear(allocator); 2198 const route = ui.RoutablePage.repoThreadCommentRoute(kind, self.data.identity, &thread_id, &event_id_hex, 0) orelse return; 2199 try self.session.navigate(route); 2200 } 2201 2202 // the terminal submit paths: the new form commits a new thread event, the 2203 // edit form re-emits the selected thread's event with the form's content. 2204 // the web posts the forms to their routes instead. 2205 fn submitForm(self: *This, allocator: std.mem.Allocator) !void { 2206 if (self.data.view == .edit) { 2207 try self.submitEditedThread(allocator); 2208 } else { 2209 try self.submitNewThread(allocator); 2210 } 2211 } 2212 2213 // commit the new thread to the repo's events branch and navigate to it. 2214 // this is the terminal path; the web posts the form to the thread route, 2215 // so the wasm side never runs (or compiles) the repo access below. 2216 fn submitNewThread(self: *This, allocator: std.mem.Allocator) !void { 2217 if (comptime wasm) return; 2218 const io = self.session.io orelse return; 2219 const src = self.data.repo_source orelse return; 2220 const author = (try self.session.eventAuthor()) orelse return; 2221 2222 const form = self.threadForm() orelse return; 2223 const title_input = &form.children.values()[title_field_index].widget.text_input; 2224 const tags_input = &form.children.values()[tags_field_index].widget.text_input; 2225 const description_input = &form.children.values()[description_field_index].widget.text_input; 2226 2227 const title = try title_input.text(allocator); 2228 defer allocator.free(title); 2229 const tags = try tags_input.text(allocator); 2230 defer allocator.free(tags); 2231 const description = try description_input.text(allocator); 2232 defer allocator.free(description); 2233 2234 if (!Event.fieldsValid(title, tags)) return; 2235 2236 if (comptime supports_drafts) { 2237 const event_id_hex = try Data.createDraft(self.data, self.session, allocator, title, tags, description); 2238 title_input.clear(allocator); 2239 tags_input.clear(allocator); 2240 description_input.clear(allocator); 2241 const route = ui.RoutablePage.repoThreadCommentsRoute(kind, self.data.identity, &event_id_hex, 0) orelse return; 2242 try self.session.navigate(route); 2243 return; 2244 } 2245 2246 var id_bytes: [evt.event_id_size]u8 = undefined; 2247 io.random(&id_bytes); 2248 const event_id_hex = std.fmt.bytesToHex(id_bytes, .lower); 2249 2250 const event = evt.EventWithId{ 2251 .id = event_id_hex, 2252 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), 2253 .author = author, 2254 .event = @unionInit(evt.Event, @tagName(kind), Event{ 2255 .title = title, 2256 .description = description, 2257 .tags = tags, 2258 }), 2259 }; 2260 2261 switch (src.repo_kind) { 2262 inline else => |repo_kind| { 2263 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2264 defer any_repo.deinit(io, allocator); 2265 switch (any_repo) { 2266 inline else => |*repo| try evt.consume(.repo, repo_kind, repo.self_repo_opts, io, allocator, repo, evt.events_ref, &.{event}), 2267 } 2268 }, 2269 } 2270 2271 // wipe the form so a return visit starts fresh 2272 title_input.clear(allocator); 2273 tags_input.clear(allocator); 2274 description_input.clear(allocator); 2275 2276 const route = listRoute(self.data.identity, @enumFromInt(0), "", &event_id_hex) orelse return; 2277 try self.session.navigate(route); 2278 } 2279 2280 // re-emit the selected thread's event with the form's content (status 2281 // preserved), then reload the thread's page. this is the terminal path; 2282 // the web posts the form to the edit route. 2283 fn submitEditedThread(self: *This, allocator: std.mem.Allocator) !void { 2284 if (comptime wasm) return; 2285 const io = self.session.io orelse return; 2286 const src = self.data.repo_source orelse return; 2287 const entry = self.data.selectedThread() orelse return; 2288 const author = (try self.session.eventAuthor()) orelse return; 2289 2290 const form = self.threadForm() orelse return; 2291 const title_input = &form.children.values()[title_field_index].widget.text_input; 2292 const tags_input = &form.children.values()[tags_field_index].widget.text_input; 2293 const description_input = &form.children.values()[description_field_index].widget.text_input; 2294 2295 const title = try title_input.text(allocator); 2296 defer allocator.free(title); 2297 const tags = try tags_input.text(allocator); 2298 defer allocator.free(tags); 2299 const description = try description_input.text(allocator); 2300 defer allocator.free(description); 2301 2302 if (!Event.fieldsValid(title, tags)) return; 2303 2304 const id_bytes = try evt.parseEventId(entry.id); 2305 2306 switch (src.repo_kind) { 2307 inline else => |repo_kind| { 2308 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2309 defer any_repo.deinit(io, allocator); 2310 switch (any_repo) { 2311 inline else => |*repo| if (has_status) 2312 try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 2313 .title = title, 2314 .tags = tags, 2315 .description = description, 2316 } }, author) 2317 else 2318 try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, title, tags, description, author), 2319 } 2320 }, 2321 } 2322 2323 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2324 try self.session.navigate(route); 2325 } 2326 2327 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 2328 const comment = self.data.comment_id.len != 0; 2329 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 2330 const id = evt.parseEventId(event_id) catch return; 2331 try self.removeEvent(allocator, if (comment) .comment else kind, id); 2332 } 2333 2334 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 2335 if (comptime wasm) return; 2336 const io = self.session.io orelse return; 2337 const src = self.data.repo_source orelse return; 2338 const author = (try self.session.eventAuthor()) orelse return; 2339 2340 switch (src.repo_kind) { 2341 inline else => |repo_kind| { 2342 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2343 defer any_repo.deinit(io, allocator); 2344 switch (any_repo) { 2345 inline else => |*repo| try evt.remove(.repo, repo_kind, repo.self_repo_opts, io, allocator, repo, &id, event_kind, author), 2346 } 2347 }, 2348 } 2349 2350 const id_hex = std.fmt.bytesToHex(id, .lower); 2351 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex) orelse return; 2352 try self.session.navigate(route); 2353 } 2354 2355 // flip the shown thread's status by re-emitting its event, then reload the 2356 // page rooted at the thread so the view reflects the change. this is the 2357 // terminal path; the web posts the button's form to the status route. 2358 fn toggleStatus(self: *This, allocator: std.mem.Allocator, index: usize) !void { 2359 if (comptime !has_status) return; 2360 if (comptime wasm) return; 2361 const io = self.session.io orelse return; 2362 const src = self.data.repo_source orelse return; 2363 const sel = self.detailed_index[index] orelse return; 2364 const entry = self.window(index).items[sel]; 2365 const author = (try self.session.eventAuthor()) orelse return; 2366 2367 const status = (statusChange(entryStatus(entry)) orelse return).status; 2368 2369 const id_bytes = try evt.parseEventId(entry.id); 2370 2371 switch (src.repo_kind) { 2372 inline else => |repo_kind| { 2373 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2374 defer any_repo.deinit(io, allocator); 2375 switch (any_repo) { 2376 inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author), 2377 } 2378 }, 2379 } 2380 2381 const route = listRoute(self.data.identity, status, "", entry.id) orelse return; 2382 try self.session.navigate(route); 2383 } 2384 2385 // arrow keys move the tag selection; at the flow's edges focus crosses to 2386 // the neighboring widgets. 2387 fn tagsInput(self: *This, index: usize, child_index: usize, tf: *TagFlow, key: Key, root_focus: *Focus) void { 2388 const cid = tf.focus.child_id orelse return; 2389 const cur = tf.indexOfFocusId(cid) orelse return; 2390 const count = tf.text_boxes.items.len; 2391 switch (key) { 2392 .arrow_left => if (cur > 0) self.focusTag(index, child_index, tf, root_focus, cur - 1) else self.focusList(index, root_focus), 2393 .arrow_right => if (cur + 1 < count) self.focusTag(index, child_index, tf, root_focus, cur + 1), 2394 .arrow_up => if (tf.rowStep(cur, false)) |i| { 2395 self.focusTag(index, child_index, tf, root_focus, i); 2396 } else { 2397 _ = self.moveDetailVertical(index, root_focus, false); 2398 }, 2399 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2400 self.focusTag(index, child_index, tf, root_focus, i); 2401 } else { 2402 _ = self.moveDetailVertical(index, root_focus, true); 2403 }, 2404 .home => self.focusTag(index, child_index, tf, root_focus, 0), 2405 .end => self.focusTag(index, child_index, tf, root_focus, count - 1), 2406 else => {}, 2407 } 2408 } 2409 2410 // the tool row's first child after the spacer that pushes it right 2411 const first_in_row_index: usize = 1; 2412 2413 fn toolRowFocused(self: *This, index: usize) bool { 2414 const outer = self.detailOuter(index); 2415 const cid = outer.getFocus().child_id orelse return false; 2416 return outer.children.getIndex(cid) == tool_row_index; 2417 } 2418 2419 fn focusTag(self: *This, index: usize, child_index: usize, tf: *TagFlow, root_focus: *Focus, item: usize) void { 2420 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2421 // keep the tag visible on the terminal: its rect offset by the flow's 2422 // position in the pane. 2423 if (self.session.is_terminal and item < tf.rects.items.len) { 2424 if (self.detailInner(index).children.values()[child_index].rect) |flow_rect| { 2425 var rect = tf.rects.items[item]; 2426 rect.x += flow_rect.x; 2427 rect.y += flow_rect.y; 2428 self.detailScroll(index).scrollToRect(rect); 2429 } 2430 } 2431 } 2432 2433 // return to the tool row's last-focused button (the header when the 2434 // description page shows no row). 2435 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2436 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2437 root_focus.setFocus(cid); 2438 } 2439 2440 // enter the detail pane. an empty pane can't be entered. 2441 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 2442 if (self.detailInner(index).children.count() == 0) return; 2443 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2444 } 2445 2446 // return to the list. 2447 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2448 root_focus.setFocus(self.listScroll(index).getFocus().id); 2449 } 2450 2451 // cross to the header tabs above the stack. 2452 fn focusHeader(self: *This, root_focus: *Focus) void { 2453 root_focus.setFocus(self.box.children.keys()[header_index]); 2454 } 2455 2456 pub fn clearGrid(self: *This) void { 2457 self.box.clearGrid(); 2458 } 2459 2460 pub fn getGrid(self: This) ?Grid { 2461 return self.box.getGrid(); 2462 } 2463 2464 pub fn getFocus(self: *This) *Focus { 2465 return self.box.getFocus(); 2466 } 2467 2468 // for the parent's "scroll up at the top jumps to the header" check: at the 2469 // top only while the header tabs hold focus, so up from the split 2470 // crosses into the tabs first. 2471 pub fn getSelectedIndex(self: *This) ?usize { 2472 return if (self.headerActive()) 0 else 1; 2473 } 2474 }; 2475 } 2476