╭ changed ─────────────╮ │src/ui/Repo/Issues.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────╮ │11 const Grid = xitui.grid.Grid; │ │12 const Focus = xitui.focus.Focus; │ │13 const inp = @import("../input.zig"); │ │14 - │ │15 -pub const SubHeader = @import("Issues/SubHeader.zig"); │ │14 │ │15 // how many issues one window shows before a "next" link appears.│ │16 pub const page_size = 20; │ ╰─────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────╮ │206 } │ │207 │ │208 pub const View = struct { │ │211 - // a vertical box: the sub header tabs on top, then a stack holding the │ │209 + // a vertical box: the header tabs on top, then a stack holding the │ │210 // results view — a horizontal split with the issue list on the left and a │ │211 // detail pane on the right showing the selected issue's description. │ │214 - box: wgt.Box(ui.Widget), // vert: [sub_header_index] = tabs, [stack_index] = stack│ │212 + box: wgt.Box(ui.Widget), // vert: [header_index] = tabs, [stack_index] = stack │ │213 data: *const Self, │ │214 session: *ui.Session, │ │215 // the issue whose description the pane currently shows (index into data.issues). │ ╰───────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │217 // the pane's description text box's focus id (null until a detail is shown).│ │218 description_id: ?usize, │ │219 │ │222 - const sub_header_index: usize = 0; │ │220 + const header_index: usize = 0; │ │221 const stack_index: usize = 1; │ │224 - // indices within the stack, 1:1 with the sub header tabs. │ │222 + // indices within the stack, 1:1 with the header tabs. │ │223 const results_view_index: usize = 0; │ │224 const tags_view_index: usize = 1; │ │225 // indices within the results box (the horizontal split inside the stack). │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │234 │ │235 // the tabs at the top. │ │236 { │ │239 - var sub_header = try SubHeader.View.init(allocator, session, data.identity, data.count, data.tag); │ │240 - errdefer sub_header.deinit(allocator); │ │241 - try outer.children.put(allocator, sub_header.getFocus().id, .{ .widget = .{ .repo_issues_sub_header = sub_header }, .rect = null, .min_size = null });│ │237 + var hdr = try Header.init(allocator, session, data.identity, data.count, data.tag); │ │238 + errdefer hdr.deinit(allocator); │ │239 + try outer.children.put(allocator, hdr.getFocus().id, .{ .widget = .{ .repo_issues_header = hdr }, .rect = null, .min_size = null }); │ │240 } │ │241 │ │242 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │320 } │ │321 │ │322 // focus entering the view lands on the tabs first. │ │325 - outer.getFocus().child_id = outer.children.keys()[sub_header_index];│ │323 + outer.getFocus().child_id = outer.children.keys()[header_index]; │ │324 │ │325 return .{ │ │326 .box = outer, │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │343 self.box.deinit(allocator); │ │344 } │ │345 │ │348 - fn subHeader(self: *View) *SubHeader.View { │ │349 - return &self.box.children.values()[sub_header_index].widget.repo_issues_sub_header;│ │346 + fn header(self: *View) *Header { │ │347 + return &self.box.children.values()[header_index].widget.repo_issues_header; │ │348 } │ │349 │ │350 fn viewStack(self: *View) *wgt.Stack(ui.Widget) { │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │387 return rb.children.getIndex(cid) == detail_index; │ │388 } │ │389 │ │392 - fn subHeaderActive(self: *View) bool { │ │390 + fn headerActive(self: *View) bool { │ │391 const cid = self.box.getFocus().child_id orelse return false;│ │394 - return self.box.children.getIndex(cid) == sub_header_index; │ │392 + return self.box.children.getIndex(cid) == header_index; │ │393 } │ │394 │ │395 fn tagsViewActive(self: *View) bool { │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────╮ │398 - if (self.subHeaderActive()) return false; │ │396 + if (self.headerActive()) return false; │ │397 const stack = self.viewStack(); │ │398 const cid = stack.getFocus().child_id orelse return false;│ │399 return stack.children.getIndex(cid) == tags_view_index; │ ╰───────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │413 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void {│ │414 self.clearGrid(); │ │415 │ │418 - // each sub header tab maps 1:1 to a stack child by position │ │419 - if (self.subHeader().getSelectedIndex()) |index| { │ │416 + // each header tab maps 1:1 to a stack child by position │ │417 + if (self.header().getSelectedIndex()) |index| { │ │418 const stack = self.viewStack(); │ │419 stack.getFocus().child_id = stack.children.keys()[index]; │ │420 self.session.data.current_page = (if (index == tags_view_index) │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │536 } │ │537 │ │538 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void {│ │541 - if (self.subHeaderActive()) { │ │539 + if (self.headerActive()) { │ │540 // down from the tabs re-enters the split; other keys move the tabs. │ │541 if (inp.vertDirection(key) == .down) { │ │542 root_focus.setFocus(self.box.children.keys()[stack_index]); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯