╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issues.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2205 const title_input = &form.children.values()[title_field_index].widget.text_input; 2206 const tags_input = &form.children.values()[tags_field_index].widget.text_input; 2207 const description_input = &form.children.values()[description_field_index].widget.text_input; 2208 2209 const title = try title_input.text(allocator); 2210 defer allocator.free(title); 2211 const tags = try tags_input.text(allocator); 2212 defer allocator.free(tags); 2213 const description = try description_input.text(allocator); 2214 defer allocator.free(description); 2215 2216 if (!evt.Issue.fieldsValid(title, tags)) return; 2217 2218 var id_bytes: [evt.event_id_size]u8 = undefined; 2219 _ = try std.fmt.hexToBytes(&id_bytes, entry.id[0 .. evt.event_id_size * 2]); 2220 2221 switch (src.repo_kind) { 2222 inline else => |repo_kind| { 2223 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, .{ .path = src.path }); 2224 defer any_repo.deinit(io, allocator); 2225 switch (any_repo) { 2226 inline else => |*repo| try evt.Issue.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 2227 .title = title, 2228 .tags = tags, 2229 .description = description, 2230 } }, author_email), 2231 } 2232 }, 2233 } 2234 2235 const route = ui.RoutablePage.repoIssuesRoute(self.data.identity, entry.issue.event.status, "", entry.id) orelse return; 2236 try self.session.navigate(route); 2237 } 2238 2239 // flip the shown issue's status by re-emitting its event, then reload the 2240 // page rooted at the issue so the view reflects the change. this is the 2241 // terminal path; the web posts the button's form to the status route. 2242 fn toggleIssueStatus(self: *View, allocator: std.mem.Allocator, index: usize) !void { 2243 if (comptime wasm) return; 2244 const io = self.session.io orelse return; 2245 const src = self.data.repo_source orelse return; 2246 const sel = self.detailed_index[index] orelse return; 2247 const entry = self.window(index).issues[sel]; 2248 const author_email = (try self.session.eventAuthorEmail()) orelse return; 2249 2250 const status: evt.Issue.Status = switch (entry.issue.event.status) { 2251 .open => .closed, 2252 .closed => .open, 2253 }; 2254 2255 var id_bytes: [evt.event_id_size]u8 = undefined; 2256 _ = try std.fmt.hexToBytes(&id_bytes, entry.id[0 .. evt.event_id_size * 2]); 2257 2258 switch (src.repo_kind) { 2259 inline else => |repo_kind| { 2260 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, .{ .path = src.path }); 2261 defer any_repo.deinit(io, allocator); 2262 switch (any_repo) { 2263 inline else => |*repo| try evt.Issue.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author_email), 2264 } 2265 }, 2266 } 2267 2268 const route = ui.RoutablePage.repoIssuesRoute(self.data.identity, status, "", entry.id) orelse return; 2269 try self.session.navigate(route); 2270 } 2271 2272 // arrow keys move the tag selection; at the flow's edges focus crosses to 2273 // the neighboring widgets. 2274 fn tagsInput(self: *View, index: usize, key: Key, root_focus: *Focus) !void { 2275 const tf = self.tagFlow(index) orelse return; 2276 const cid = tf.focus.child_id orelse return; 2277 const cur = tf.indexOfFocusId(cid) orelse return; 2278 const count = tf.text_boxes.items.len; 2279 switch (key) { 2280 .arrow_left => if (cur > 0) self.focusTag(index, tf, root_focus, cur - 1) else try self.focusList(index, root_focus), 2281 .arrow_right => if (cur + 1 < count) self.focusTag(index, tf, root_focus, cur + 1), 2282 .arrow_up => if (tf.rowStep(cur, false)) |i| self.focusTag(index, tf, root_focus, i) else self.focusAuthor(index, root_focus), 2283 .arrow_down => if (tf.rowStep(cur, true)) |i| self.focusTag(index, tf, root_focus, i) else try self.focusDescription(index, root_focus), 2284 .home => self.focusTag(index, tf, root_focus, 0), 2285 .end => self.focusTag(index, tf, root_focus, count - 1), 2286 else => {}, 2287 } 2288 } 2289 2290 const button_in_row_index: usize = 1; 2291 const title_child_index: usize = 0; 2292 const tags_child_index: usize = 2; 2293 2294 fn tagFlow(self: *View, index: usize) ?*ui.TagFlow { 2295 const inner = self.detailInner(index); 2296 if (inner.children.count() <= tags_child_index) return null; 2297 return switch (inner.children.values()[tags_child_index].widget) { 2298 .tag_flow => |*tf| tf, 2299 else => null, 2300 }; 2301 } 2302 2303 fn tagsFocused(self: *View, index: usize) bool { 2304 const inner = self.detailInner(index); 2305 const cid = inner.getFocus().child_id orelse return false; 2306 return inner.children.getIndex(cid) == tags_child_index and self.tagFlow(index) != null; 2307 } 2308 2309 // the open/close button inside the detail frame's tool row, identified 2310 // by its posting kind; a logged-out session's or conflicted issue's row 2311 // has none. 2312 fn statusButton(self: *View, index: usize) ?*wgt.TextBox(ui.Widget) { 2313 const row = self.toolRow(index); 2314 if (row.children.count() <= button_in_row_index) return null; 2315 switch (row.children.values()[button_in_row_index].widget) { 2316 .text_box => |*tb| switch (tb.box.focus.kind) { 2317 .custom => |custom| if (std.mem.eql(u8, custom, "submit")) return tb, 2318 else => {}, 2319 }, 2320 else => {}, 2321 } 2322 return null; 2323 } 2324 2325 fn toolRowFocused(self: *View, index: usize) bool { 2326 const outer = self.detailOuter(index); 2327 const cid = outer.getFocus().child_id orelse return false; 2328 return outer.children.getIndex(cid) == tool_row_index; 2329 } 2330 2331 fn focusTag(self: *View, index: usize, tf: *ui.TagFlow, root_focus: *Focus, item: usize) void { 2332 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2333 // keep the tag visible on the terminal: its rect offset by the flow's 2334 // position in the pane. 2335 if (self.session.is_terminal and item < tf.rects.items.len) { 2336 if (self.detailInner(index).children.values()[tags_child_index].rect) |flow_rect| { 2337 var rect = tf.rects.items[item]; 2338 rect.x += flow_rect.x; 2339 rect.y += flow_rect.y; 2340 self.detailScroll(index).scrollToRect(rect); 2341 } 2342 } 2343 } 2344 2345 fn titleFocused(self: *View, index: usize) bool { 2346 const inner = self.detailInner(index); 2347 const cid = inner.getFocus().child_id orelse return false; 2348 return inner.children.getIndex(cid) == title_child_index; 2349 } 2350 2351 fn authorPresent(self: *View, index: usize) bool { 2352 return self.author_id[index] != null; 2353 } 2354 2355 fn authorFocused(self: *View, index: usize) bool { 2356 const inner = self.detailInner(index); 2357 const cid = inner.getFocus().child_id orelse return false; 2358 return cid == self.author_id[index]; 2359 } 2360 2361 fn descriptionFocused(self: *View, index: usize) bool { 2362 const cid = self.detailInner(index).getFocus().child_id orelse return false; 2363 return cid == self.description_id[index]; 2364 } 2365 2366 // the author sits right under the title at the top of the pane, so 2367 // focusing it scrolls there. 2368 fn focusAuthor(self: *View, index: usize, root_focus: *Focus) void { 2369 const id = self.author_id[index] orelse return; 2370 root_focus.setFocus(id); 2371 self.detailScroll(index).y = 0; 2372 } 2373 2374 // the title sits at the top of the pane, so focusing it scrolls there. 2375 fn focusTitle(self: *View, index: usize, root_focus: *Focus) void { 2376 const inner = self.detailInner(index); 2377 if (inner.children.count() == 0) return; 2378 root_focus.setFocus(inner.children.keys()[title_child_index]); 2379 self.detailScroll(index).y = 0; 2380 } 2381 2382 fn focusTags(self: *View, index: usize, root_focus: *Focus) !void { 2383 const tf = self.tagFlow(index) orelse return; 2384 if (tf.text_boxes.items.len == 0) return; 2385 const cid = tf.focus.child_id orelse tf.text_boxes.items[0].getFocus().id; 2386 const item = tf.indexOfFocusId(cid) orelse 0; 2387 self.focusTag(index, tf, root_focus, item); 2388 } 2389 2390 fn focusDescription(self: *View, index: usize, root_focus: *Focus) !void { 2391 if (self.description_id[index]) |id| root_focus.setFocus(id); 2392 } 2393 2394 // return to the tool row's last-focused button (the header when the 2395 // description page shows no row). 2396 fn focusToolRow(self: *View, index: usize, root_focus: *Focus) void { 2397 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2398 root_focus.setFocus(cid); 2399 } 2400 2401 // enter the detail pane. an empty pane (no issues) can't be entered. 2402 fn focusDetail(self: *View, index: usize, root_focus: *Focus) !void { 2403 if (self.detailInner(index).children.count() == 0) return; 2404 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2405 } 2406 2407 // return to the list. 2408 fn focusList(self: *View, index: usize, root_focus: *Focus) !void { 2409 root_focus.setFocus(self.listScroll(index).getFocus().id); 2410 } 2411 2412 // cross to the header tabs above the stack. 2413 fn focusHeader(self: *View, root_focus: *Focus) void { 2414 root_focus.setFocus(self.box.children.keys()[header_index]); 2415 } 2416 2417 pub fn clearGrid(self: *View) void { 2418 self.box.clearGrid(); 2419 } 2420 2421 pub fn getGrid(self: View) ?Grid { 2422 return self.box.getGrid(); 2423 } 2424 2425 pub fn getFocus(self: *View) *Focus { 2426 return self.box.getFocus(); 2427 } 2428 2429 // for the parent's "scroll up at the top jumps to the header" check: at the 2430 // top only while the header tabs hold focus, so up from the split 2431 // crosses into the tabs first. 2432 pub fn getSelectedIndex(self: *View) ?usize { 2433 return if (self.headerActive()) 0 else 1; 2434 } 2435 }; 2436 2437 // the "a:" navigation link for `status`'s issues page filtered to the 2438 // url-encoded `tag` and rooted at issue `id` within `identity` ("owner/name"). 2439 // a rooted url ignores `status` (it derives its view from the issue's own); 2440 // with an empty `id` this is the bare list link. 2441 fn issuesLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, status: evt.Issue.Status, tag: []const u8, id: []const u8) ![]const u8 { 2442 const route = ui.RoutablePage.repoIssuesRoute(identity, status, tag, id) orelse return error.RouteTooLong; 2443 const url = try route.toUrl(page_arena); 2444 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 2445 } 2446 2447 // the in-page "ai:" anchor for selecting issue `id` in `identity`'s list; the 2448 // href is only followed with js off. 2449 fn issueRowLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, id: []const u8) ![]const u8 { 2450 const route = ui.RoutablePage.repoIssuesRoute(identity, .open, "", id) orelse return error.RouteTooLong; 2451 const url = try route.toUrl(page_arena); 2452 return std.fmt.allocPrint(page_arena.allocator(), "ai:{s}", .{url}); 2453 } 2454 2455 // the "a:" link to the window `status_maybe` names, keeping the tag filter, 2456 // or the conflicts window when null, rooted at issue `id`. 2457 fn windowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, status_maybe: ?evt.Issue.Status, id: []const u8) ![]const u8 { 2458 if (status_maybe) |status| return issuesLink(page_arena, data.identity, status, data.tag, id); 2459 return conflictsLink(page_arena, data.identity, id); 2460 } 2461 2462 // the "a:" link to the conflicts list rooted at issue `start` ("" = the 2463 // first window). 2464 fn conflictsLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, start: []const u8) ![]const u8 { 2465 const route = ui.RoutablePage.repoIssuesConflictsRoute(identity, start) orelse return error.RouteTooLong; 2466 const url = try route.toUrl(page_arena); 2467 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 2468 } 2469 2470 // the "a:" link to the whole-description page of issue `id` within `identity`. 2471 fn descriptionLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, id: []const u8) ![]const u8 { 2472 const route = ui.RoutablePage.repoIssuesDescriptionRoute(identity, id) orelse return error.RouteTooLong; 2473 const url = try route.toUrl(page_arena); 2474 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 2475 } 2476 2477 // the "a:" link to `status`'s issues list filtered to `tag` (raw; encoded here). 2478 fn tagLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, status: evt.Issue.Status, tag: []const u8) ![]const u8 { 2479 const encoded = try ui.urlEncodeRef(page_arena.allocator(), tag); 2480 const route = ui.RoutablePage.repoIssuesRoute(identity, status, encoded, "") orelse return error.RouteTooLong; 2481 const url = try route.toUrl(page_arena); 2482 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{url}); 2483 } 2484 2485 // tabs switching between the issues page's views. 2486 pub const Header = struct { 2487 box: wgt.Box(ui.Widget), 2488 tab_ids: std.AutoArrayHashMapUnmanaged(usize, void), 2489 2490 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, data: *const Self) !Header { 2491 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); 2492 errdefer box.deinit(allocator); 2493 2494 var tab_ids: std.AutoArrayHashMapUnmanaged(usize, void) = .empty; 2495 errdefer tab_ids.deinit(allocator); 2496 2497 const aa = session.page_arena.allocator(); 2498 2499 // a list tab per status, labeled with its listing's issue count 2500 for ([_]evt.Issue.Status{ .open, .closed }) |status| { 2501 const route = ui.RoutablePage.repoIssuesRoute(data.identity, status, data.tag, "") orelse return error.RouteTooLong; 2502 const link = try std.fmt.allocPrint(aa, "ai:{s}", .{try route.toUrl(session.page_arena)}); 2503 const label = try std.fmt.allocPrint(aa, "{s} ({d})", .{ @tagName(status), data.window(status).count }); 2504 try addTab(allocator, &box, &tab_ids, label, link); 2505 } 2506 2507 // tags tab, labeled with the active tag filter 2508 { 2509 const tags_route = ui.RoutablePage.repoIssuesTagsRoute(data.identity, data.tag) orelse return error.RouteTooLong; 2510 const tags_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try tags_route.toUrl(session.page_arena)}); 2511 const label = if (data.tag.len == 0) "tags" else blk: { 2512 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, data.tag)); 2513 break :blk try std.fmt.allocPrint(aa, "tags ({s})", .{decoded}); 2514 }; 2515 try addTab(allocator, &box, &tab_ids, label, tags_link); 2516 } 2517 2518 // new-issue tab; an edit or resolve url shows its tab in this place 2519 { 2520 const route = switch (data.view) { 2521 .edit => ui.RoutablePage.repoIssuesEditRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 2522 .new_comment => ui.RoutablePage.repoCommentNewRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 2523 .edit_comment => ui.RoutablePage.repoCommentEditRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 2524 .resolve => ui.RoutablePage.repoIssuesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 2525 else => ui.RoutablePage.repoIssuesNewRoute(data.identity) orelse return error.RouteTooLong, 2526 }; 2527 const link = try std.fmt.allocPrint(aa, "ai:{s}", .{try route.toUrl(session.page_arena)}); 2528 const label: []const u8 = switch (data.view) { 2529 .edit => "edit", 2530 .new_comment => "reply", 2531 .edit_comment => "edit", 2532 .resolve => "resolve", 2533 else => "new", 2534 }; 2535 try addTab(allocator, &box, &tab_ids, label, link); 2536 } 2537 2538 // conflicts tab, labeled with the conflict count 2539 if (data.conflicts.count > 0) { 2540 const route = ui.RoutablePage.repoIssuesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 2541 const link = try std.fmt.allocPrint(aa, "ai:{s}", .{try route.toUrl(session.page_arena)}); 2542 const label = try std.fmt.allocPrint(aa, "conflicts ({d})", .{data.conflicts.count}); 2543 try addTab(allocator, &box, &tab_ids, label, link); 2544 } 2545 2546 var self = Header{ .box = box, .tab_ids = tab_ids }; 2547 // the tab matching the page's view is selected initially. 2548 self.getFocus().child_id = self.tab_ids.keys()[View.viewIndex(data.view)]; 2549 return self; 2550 } 2551 2552 fn addTab(allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), tab_ids: *std.AutoArrayHashMapUnmanaged(usize, void), label: []const u8, link: []const u8) !void { 2553 var text_box = try wgt.TextBox(ui.Widget).init(allocator, label, .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none }); 2554 errdefer text_box.deinit(allocator); 2555 text_box.getFocus().focusable = true; 2556 text_box.getFocus().kind = .{ .custom = link }; 2557 try tab_ids.put(allocator, text_box.getFocus().id, {}); 2558 try box.children.put(allocator, text_box.getFocus().id, .{ 2559 .widget = .{ .text_box = text_box }, 2560 .rect = null, 2561 .min_size = .{ .width = label.len + 2, .height = null }, 2562 }); 2563 } 2564 2565 pub fn deinit(self: *Header, allocator: std.mem.Allocator) void { 2566 self.box.deinit(allocator); 2567 self.tab_ids.deinit(allocator); 2568 } 2569 2570 pub fn build(self: *Header, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 2571 self.clearGrid(); 2572 // only the selected tab shows its border 2573 for (self.box.children.keys(), self.box.children.values()) |id, *child| { 2574 switch (child.widget) { 2575 .text_box => |*tb| tb.options.border_style = if (self.getFocus().child_id == id) .single else .hidden, 2576 else => {}, 2577 } 2578 } 2579 try self.box.build(allocator, constraint, root_focus); 2580 } 2581 2582 pub fn input(self: *Header, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 2583 _ = allocator; 2584 const current_tab = self.currentTabIndex() orelse return; 2585 if (inp.moveTab(key, current_tab, self.tab_ids.count())) |new_tab| { 2586 root_focus.setFocus(self.tab_ids.keys()[new_tab]); 2587 } 2588 } 2589 2590 pub fn clearGrid(self: *Header) void { 2591 self.box.clearGrid(); 2592 } 2593 2594 pub fn getGrid(self: Header) ?Grid { 2595 return self.box.getGrid(); 2596 } 2597 2598 pub fn getFocus(self: *Header) *Focus { 2599 return self.box.getFocus(); 2600 } 2601 2602 pub fn getSelectedIndex(self: Header) ?usize { 2603 return self.currentTabIndex(); 2604 } 2605 2606 fn currentTabIndex(self: Header) ?usize { 2607 const child_id = self.box.focus.child_id orelse return null; 2608 return self.tab_ids.getIndex(child_id); 2609 } 2610 }; 2611