╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────────╮ │src/ui/Repo/Header.zig│ ╰──────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │130 // helper so the /repo/.../files url format lives in one place. │ │131 // both tabs link to the ref/oid this page is viewing, so switching tabs │ │132 // keeps the same ref (the files tab opens at its root directory). │ │133 + const current_page = session.data.current_page; │ │134 + const current_tag = std.meta.activeTag(current_page); │ │135 const files_route = ui.RoutablePage.repoFilesRoute(identity, data.ref_or_oid, data.ref_or_oid_value, "", 0) orelse return error.RouteTooLong; │ │134 - const files_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try files_route.toUrl(session.page_arena)}); │ │136 + const files_link = try ui.inPageTabLink(session, files_route, current_tag == .repo_files); │ │137 const commits_route = ui.RoutablePage.repoCommitsRoute(identity, data.ref_or_oid, data.ref_or_oid_value, 0, "") orelse return error.RouteTooLong;│ │136 - const commits_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try commits_route.toUrl(session.page_arena)}); │ │138 + const commits_link = try ui.inPageTabLink(session, commits_route, current_tag == .repo_commits); │ │139 const refs_route = ui.RoutablePage.repoRefsRoute(identity, .branch, "") orelse return error.RouteTooLong; │ │138 - const refs_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try refs_route.toUrl(session.page_arena)}); │ │140 + const refs_link = try ui.inPageTabLink(session, refs_route, current_tag == .repo_refs); │ │141 const issues_route = ui.RoutablePage.repoIssuesRoute(identity, .open, data.issues_tag, "") orelse return error.RouteTooLong; │ │140 - const issues_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try issues_route.toUrl(session.page_arena)}); │ │142 + const issues_link = try ui.inPageTabLink(session, issues_route, current_tag == .repo_issues); │ │143 const patches_route = ui.RoutablePage.repoPatchesRoute(identity, .open, data.patches_tag, "") orelse return error.RouteTooLong; │ │142 - const patches_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try patches_route.toUrl(session.page_arena)}); │ │144 + const patches_link = try ui.inPageTabLink(session, patches_route, current_tag == .repo_patches); │ │145 const discussions_route = ui.RoutablePage.repoDiscussionsRoute(identity, data.discussions_tag, "") orelse return error.RouteTooLong; │ │144 - const discussions_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try discussions_route.toUrl(session.page_arena)}); │ │146 + const discussions_link = try ui.inPageTabLink(session, discussions_route, current_tag == .repo_discussions); │ │147 const events_route = ui.RoutablePage.repoEventsRoute(identity, .active, null, "") orelse return error.RouteTooLong; │ │146 - const events_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try events_route.toUrl(session.page_arena)}); │ │148 + const events_link = try ui.inPageTabLink(session, events_route, current_tag == .repo_events); │ │149 const settings_route = ui.RoutablePage{ .repo_settings = Array.from(identity) orelse return error.RouteTooLong }; │ │148 - const settings_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try settings_route.toUrl(session.page_arena)}); │ │150 + const settings_link = try ui.inPageTabLink(session, settings_route, current_tag == .repo_settings); │ │151 const auth_route = ui.RoutablePage{ .repo_auth = Array.from(identity) orelse return error.RouteTooLong }; │ │150 - const auth_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try auth_route.toUrl(session.page_arena)}); │ │152 + const auth_link = try ui.inPageTabLink(session, auth_route, current_tag == .repo_auth); │ │153 │ │154 // the tab matching the current page is focused initially; matching by │ │155 // link (rather than position) keeps this robust to tab changes. │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │154 - const current_link: []const u8 = switch (session.data.current_page) {│ │155 - .repo_commits => commits_link, │ │156 - .repo_refs => refs_link, │ │157 - .repo_issues => issues_link, │ │158 - .repo_patches => patches_link, │ │159 - .repo_discussions => discussions_link, │ │160 - .repo_events => events_link, │ │161 - .repo_settings => settings_link, │ │162 - .repo_auth => auth_link, │ │163 - else => files_link, │ │164 - }; │ │156 var selected_tab: ?usize = null; │ │157 │ │158 // files tab │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │162 text_box.getFocus().focusable = true; │ │163 text_box.getFocus().kind = .{ .custom = files_link }; │ │164 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │174 - if (std.mem.eql(u8, files_link, current_link)) selected_tab = text_box.getFocus().id;│ │165 + if (current_tag == .repo_files) selected_tab = text_box.getFocus().id; │ │166 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │167 .widget = .{ .text_box = text_box }, │ │168 .rect = null, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │177 text_box.getFocus().focusable = true; │ │178 text_box.getFocus().kind = .{ .custom = commits_link }; │ │179 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │189 - if (std.mem.eql(u8, commits_link, current_link)) selected_tab = text_box.getFocus().id;│ │180 + if (current_tag == .repo_commits) selected_tab = text_box.getFocus().id; │ │181 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │182 .widget = .{ .text_box = text_box }, │ │183 .rect = null, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │192 text_box.getFocus().focusable = true; │ │193 text_box.getFocus().kind = .{ .custom = refs_link }; │ │194 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │204 - if (std.mem.eql(u8, refs_link, current_link)) selected_tab = text_box.getFocus().id;│ │195 + if (current_tag == .repo_refs) selected_tab = text_box.getFocus().id; │ │196 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │197 .widget = .{ .text_box = text_box }, │ │198 .rect = null, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │207 text_box.getFocus().focusable = true; │ │208 text_box.getFocus().kind = .{ .custom = issues_link }; │ │209 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │219 - if (std.mem.eql(u8, issues_link, current_link)) selected_tab = text_box.getFocus().id;│ │210 + if (current_tag == .repo_issues) selected_tab = text_box.getFocus().id; │ │211 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │212 .widget = .{ .text_box = text_box }, │ │213 .rect = null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │222 text_box.getFocus().focusable = true; │ │223 text_box.getFocus().kind = .{ .custom = patches_link }; │ │224 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │234 - if (std.mem.eql(u8, patches_link, current_link)) selected_tab = text_box.getFocus().id;│ │225 + if (current_tag == .repo_patches) selected_tab = text_box.getFocus().id; │ │226 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │227 .widget = .{ .text_box = text_box }, │ │228 .rect = null, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │237 text_box.getFocus().focusable = true; │ │238 text_box.getFocus().kind = .{ .custom = discussions_link }; │ │239 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │249 - if (std.mem.eql(u8, discussions_link, current_link)) selected_tab = text_box.getFocus().id;│ │240 + if (current_tag == .repo_discussions) selected_tab = text_box.getFocus().id; │ │241 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │242 .widget = .{ .text_box = text_box }, │ │243 .rect = null, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │252 text_box.getFocus().focusable = true; │ │253 text_box.getFocus().kind = .{ .custom = events_link }; │ │254 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │264 - if (std.mem.eql(u8, events_link, current_link)) selected_tab = text_box.getFocus().id;│ │255 + if (current_tag == .repo_events) selected_tab = text_box.getFocus().id; │ │256 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │257 .widget = .{ .text_box = text_box }, │ │258 .rect = null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │280 text_box.getFocus().focusable = true; │ │281 text_box.getFocus().kind = .{ .custom = settings_link }; │ │282 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │292 - if (std.mem.eql(u8, settings_link, current_link)) selected_tab = text_box.getFocus().id;│ │283 + if (current_tag == .repo_settings) selected_tab = text_box.getFocus().id; │ │284 try tabs_box.children.put(allocator, text_box.getFocus().id, .{ │ │285 .widget = .{ .text_box = text_box }, │ │286 .rect = null, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯