╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Threads.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1787 // a multiline input keeps enter and any up/down that has a row to move to 1788 fn multilineKeepsKey(text_input: *wgt.TextInput(ui.Widget), allocator: std.mem.Allocator, key: Key) !bool { 1789 return switch (key) { 1790 .enter => true, 1791 .arrow_up => !try text_input.cursorOnFirstRow(allocator), 1792 .arrow_down => !try text_input.cursorOnLastRow(allocator), 1793 else => false, 1794 }; 1795 } 1796 1797 // the neighboring focusable resolve-form child, skipping the spacer and 1798 // the blank gap rows 1799 fn resolveStep(form: *wgt.Box(ui.Widget), cur: usize, down: bool) ?usize { 1800 var i = cur; 1801 while (true) { 1802 if (down) { 1803 i += 1; 1804 if (i >= form.children.count()) return null; 1805 } else { 1806 if (i == 0) return null; 1807 i -= 1; 1808 } 1809 switch (form.children.values()[i].widget) { 1810 .spacer, .text => continue, 1811 else => return i, 1812 } 1813 } 1814 } 1815 1816 // focus the resolve-form child at `i` (a version row focuses its selected 1817 // child) and keep it visible on the terminal 1818 fn focusResolveChild(self: *This, form: *wgt.Box(ui.Widget), i: usize, root_focus: *Focus) void { 1819 const child = &form.children.values()[i]; 1820 switch (child.widget) { 1821 .box => |*row| root_focus.setFocus(row.getFocus().child_id orelse form.children.keys()[i]), 1822 else => root_focus.setFocus(form.children.keys()[i]), 1823 } 1824 if (self.session.is_terminal) { 1825 if (self.resolveScroll()) |sc| { 1826 if (child.rect) |rect| sc.scrollToRect(rect); 1827 } 1828 } 1829 } 1830 1831 // re-emit the conflicted issue's event with the resolved content; any 1832 // event on the issue settles its conflict entry. this is the terminal 1833 // path; the web posts the form to the resolve route. 1834 fn submitResolution(self: *This, allocator: std.mem.Allocator) !void { 1835 if (comptime wasm) return; 1836 const io = self.session.io orelse return; 1837 const src = self.data.repo_source orelse return; 1838 const entry = self.data.selectedThread() orelse return; 1839 const author = (try self.session.eventAuthor()) orelse return; 1840 const form = self.threadForm() orelse return; 1841 1842 // gather the inputs by name; the d<n> hunk inputs appear in chunk order 1843 var title: ?[]u8 = null; 1844 var tags: ?[]u8 = null; 1845 var hunks: std.ArrayList([]const u8) = .empty; 1846 defer { 1847 if (title) |t| allocator.free(t); 1848 if (tags) |t| allocator.free(t); 1849 for (hunks.items) |h| allocator.free(h); 1850 hunks.deinit(allocator); 1851 } 1852 for (form.children.values()) |*child| switch (child.widget) { 1853 .text_input => |*ti| { 1854 const text = try ti.text(allocator); 1855 errdefer allocator.free(text); 1856 if (std.mem.eql(u8, ti.options.name, "title")) { 1857 title = text; 1858 } else if (std.mem.eql(u8, ti.options.name, "tags")) { 1859 tags = text; 1860 } else { 1861 try hunks.append(allocator, text); 1862 } 1863 }, 1864 else => {}, 1865 }; 1866 1867 var id_bytes: [evt.event_id_size]u8 = undefined; 1868 _ = try std.fmt.hexToBytes(&id_bytes, entry.id[0 .. evt.event_id_size * 2]); 1869 1870 switch (src.repo_kind) { 1871 inline else => |repo_kind| { 1872 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 1873 defer any_repo.deinit(io, allocator); 1874 switch (any_repo) { 1875 inline else => |*repo| Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .resolve = .{ 1876 .title = title, 1877 .tags = tags, 1878 .hunks = hunks.items, 1879 } }, author) catch |err| switch (err) { 1880 // leave the form up for correction 1881 error.InvalidFields => return, 1882 else => |e| return e, 1883 }, 1884 } 1885 }, 1886 } 1887 1888 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 1889 try self.session.navigate(route); 1890 } 1891 1892 // commit a new or edited comment and navigate to its permalink. this is the 1893 // terminal path; the web posts the form to its comment route. 1894 fn submitComment(self: *This, allocator: std.mem.Allocator) !void { 1895 if (comptime wasm) return; 1896 const io = self.session.io orelse return; 1897 const src = self.data.repo_source orelse return; 1898 const author = (try self.session.eventAuthor()) orelse return; 1899 const form = self.threadForm() orelse return; 1900 const body_input = &form.children.values()[comment_body_field_index].widget.text_input; 1901 const body = try body_input.text(allocator); 1902 defer allocator.free(body); 1903 if (!evt.Comment.fieldsValid(body)) return; 1904 1905 var thread_id: [evt.event_id_size * 2]u8 = undefined; 1906 @memcpy(&thread_id, self.data.selected_id); 1907 const parent_id = if (self.data.comment_id.len == 0) thread_id else blk: { 1908 var parent: [evt.event_id_size * 2]u8 = undefined; 1909 @memcpy(&parent, self.data.comment_id); 1910 break :blk parent; 1911 }; 1912 var event_id_hex: [evt.event_id_size * 2]u8 = undefined; 1913 const editing = self.data.view == .edit_comment; 1914 switch (src.repo_kind) { 1915 inline else => |repo_kind| { 1916 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 1917 defer any_repo.deinit(io, allocator); 1918 switch (any_repo) { 1919 inline else => |*repo| if (editing) { 1920 var comment_id: [evt.event_id_size]u8 = undefined; 1921 _ = std.fmt.hexToBytes(&comment_id, self.data.comment_id) catch return; 1922 try evt.Comment.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &comment_id, body, author); 1923 event_id_hex = std.fmt.bytesToHex(comment_id, .lower); 1924 } else { 1925 event_id_hex = try evt.Comment.create(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &parent_id, body, author); 1926 }, 1927 } 1928 }, 1929 } 1930 1931 body_input.clear(allocator); 1932 const route = commentRoute(self.data.identity, &thread_id, &event_id_hex, 0) orelse return; 1933 try self.session.navigate(route); 1934 } 1935 1936 // the terminal submit paths: the new form commits a new-issue event, the 1937 // edit form re-emits the selected issue's event with the form's content. 1938 // the web posts the forms to their routes instead. 1939 fn submitForm(self: *This, allocator: std.mem.Allocator) !void { 1940 if (self.data.view == .edit) { 1941 try self.submitEditedThread(allocator); 1942 } else { 1943 try self.submitNewThread(allocator); 1944 } 1945 } 1946 1947 // commit the new issue to the repo's events branch and navigate to it. 1948 // this is the terminal path; the web posts the form to the issue route, 1949 // so the wasm side never runs (or compiles) the repo access below. 1950 fn submitNewThread(self: *This, allocator: std.mem.Allocator) !void { 1951 if (comptime wasm) return; 1952 const io = self.session.io orelse return; 1953 const src = self.data.repo_source orelse return; 1954 const author = (try self.session.eventAuthor()) orelse return; 1955 1956 const form = self.threadForm() orelse return; 1957 const title_input = &form.children.values()[title_field_index].widget.text_input; 1958 const tags_input = &form.children.values()[tags_field_index].widget.text_input; 1959 const description_input = &form.children.values()[description_field_index].widget.text_input; 1960 1961 const title = try title_input.text(allocator); 1962 defer allocator.free(title); 1963 const tags = try tags_input.text(allocator); 1964 defer allocator.free(tags); 1965 const description = try description_input.text(allocator); 1966 defer allocator.free(description); 1967 1968 if (!Event.fieldsValid(title, tags)) return; 1969 1970 var id_bytes: [evt.event_id_size]u8 = undefined; 1971 io.random(&id_bytes); 1972 const event_id_hex = std.fmt.bytesToHex(id_bytes, .lower); 1973 1974 const event = evt.EventWithId{ 1975 .id = event_id_hex, 1976 .timestamp = @intCast(std.Io.Timestamp.now(io, .real).toSeconds()), 1977 .author = author, 1978 .event = @unionInit(evt.Event, @tagName(kind), Event{ 1979 .title = title, 1980 .description = description, 1981 .tags = tags, 1982 }), 1983 }; 1984 1985 switch (src.repo_kind) { 1986 inline else => |repo_kind| { 1987 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 1988 defer any_repo.deinit(io, allocator); 1989 switch (any_repo) { 1990 inline else => |*repo| try evt.consume(repo_kind, repo.self_repo_opts, io, allocator, repo, evt.events_ref, &.{event}), 1991 } 1992 }, 1993 } 1994 1995 // wipe the form so a return visit starts fresh 1996 title_input.clear(allocator); 1997 tags_input.clear(allocator); 1998 description_input.clear(allocator); 1999 2000 const route = listRoute(self.data.identity, @enumFromInt(0), "", &event_id_hex) orelse return; 2001 try self.session.navigate(route); 2002 } 2003 2004 // re-emit the selected issue's event with the form's content (status 2005 // preserved), then reload the issue's page. this is the terminal path; 2006 // the web posts the form to the edit route. 2007 fn submitEditedThread(self: *This, allocator: std.mem.Allocator) !void { 2008 if (comptime wasm) return; 2009 const io = self.session.io orelse return; 2010 const src = self.data.repo_source orelse return; 2011 const entry = self.data.selectedThread() orelse return; 2012 const author = (try self.session.eventAuthor()) orelse return; 2013 2014 const form = self.threadForm() orelse return; 2015 const title_input = &form.children.values()[title_field_index].widget.text_input; 2016 const tags_input = &form.children.values()[tags_field_index].widget.text_input; 2017 const description_input = &form.children.values()[description_field_index].widget.text_input; 2018 2019 const title = try title_input.text(allocator); 2020 defer allocator.free(title); 2021 const tags = try tags_input.text(allocator); 2022 defer allocator.free(tags); 2023 const description = try description_input.text(allocator); 2024 defer allocator.free(description); 2025 2026 if (!Event.fieldsValid(title, tags)) return; 2027 2028 var id_bytes: [evt.event_id_size]u8 = undefined; 2029 _ = try std.fmt.hexToBytes(&id_bytes, entry.id[0 .. evt.event_id_size * 2]); 2030 2031 switch (src.repo_kind) { 2032 inline else => |repo_kind| { 2033 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2034 defer any_repo.deinit(io, allocator); 2035 switch (any_repo) { 2036 inline else => |*repo| if (has_status) 2037 try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .fields = .{ 2038 .title = title, 2039 .tags = tags, 2040 .description = description, 2041 } }, author) 2042 else 2043 try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, title, tags, description, author), 2044 } 2045 }, 2046 } 2047 2048 const route = listRoute(self.data.identity, entryStatus(entry.*), "", entry.id) orelse return; 2049 try self.session.navigate(route); 2050 } 2051 2052 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 2053 const comment = self.data.comment_id.len != 0; 2054 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 2055 var id: [evt.event_id_size]u8 = undefined; 2056 _ = std.fmt.hexToBytes(&id, event_id) catch return; 2057 try self.removeEvent(allocator, if (comment) .comment else kind, id); 2058 } 2059 2060 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 2061 if (comptime wasm) return; 2062 const io = self.session.io orelse return; 2063 const src = self.data.repo_source orelse return; 2064 const author = (try self.session.eventAuthor()) orelse return; 2065 2066 switch (src.repo_kind) { 2067 inline else => |repo_kind| { 2068 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2069 defer any_repo.deinit(io, allocator); 2070 switch (any_repo) { 2071 inline else => |*repo| try evt.remove(repo_kind, repo.self_repo_opts, io, allocator, repo, &id, event_kind, author), 2072 } 2073 }, 2074 } 2075 2076 const id_hex = std.fmt.bytesToHex(id, .lower); 2077 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex) orelse return; 2078 try self.session.navigate(route); 2079 } 2080 2081 // flip the shown issue's status by re-emitting its event, then reload the 2082 // page rooted at the issue so the view reflects the change. this is the 2083 // terminal path; the web posts the button's form to the status route. 2084 fn toggleStatus(self: *This, allocator: std.mem.Allocator, index: usize) !void { 2085 if (comptime !has_status) return; 2086 if (comptime wasm) return; 2087 const io = self.session.io orelse return; 2088 const src = self.data.repo_source orelse return; 2089 const sel = self.detailed_index[index] orelse return; 2090 const entry = self.window(index).items[sel]; 2091 const author = (try self.session.eventAuthor()) orelse return; 2092 2093 const status: Status = switch (entryStatus(entry)) { 2094 .open => .closed, 2095 .closed => .open, 2096 }; 2097 2098 var id_bytes: [evt.event_id_size]u8 = undefined; 2099 _ = try std.fmt.hexToBytes(&id_bytes, entry.id[0 .. evt.event_id_size * 2]); 2100 2101 switch (src.repo_kind) { 2102 inline else => |repo_kind| { 2103 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2104 defer any_repo.deinit(io, allocator); 2105 switch (any_repo) { 2106 inline else => |*repo| try Event.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &id_bytes, .{ .status = status }, author), 2107 } 2108 }, 2109 } 2110 2111 const route = listRoute(self.data.identity, status, "", entry.id) orelse return; 2112 try self.session.navigate(route); 2113 } 2114 2115 // arrow keys move the tag selection; at the flow's edges focus crosses to 2116 // the neighboring widgets. 2117 fn tagsInput(self: *This, index: usize, key: Key, root_focus: *Focus) !void { 2118 const tf = self.tagFlow(index) orelse return; 2119 const cid = tf.focus.child_id orelse return; 2120 const cur = tf.indexOfFocusId(cid) orelse return; 2121 const count = tf.text_boxes.items.len; 2122 switch (key) { 2123 .arrow_left => if (cur > 0) self.focusTag(index, tf, root_focus, cur - 1) else try self.focusList(index, root_focus), 2124 .arrow_right => if (cur + 1 < count) self.focusTag(index, tf, root_focus, cur + 1), 2125 .arrow_up => if (tf.rowStep(cur, false)) |i| { 2126 self.focusTag(index, tf, root_focus, i); 2127 } else { 2128 _ = self.moveDetailVertical(index, root_focus, false); 2129 }, 2130 .arrow_down => if (tf.rowStep(cur, true)) |i| { 2131 self.focusTag(index, tf, root_focus, i); 2132 } else { 2133 _ = self.moveDetailVertical(index, root_focus, true); 2134 }, 2135 .home => self.focusTag(index, tf, root_focus, 0), 2136 .end => self.focusTag(index, tf, root_focus, count - 1), 2137 else => {}, 2138 } 2139 } 2140 2141 const title_child_index: usize = 0; 2142 const tags_child_index: usize = 2; 2143 2144 // the tool row's first child after the spacer that pushes it right 2145 const first_in_row_index: usize = 1; 2146 2147 fn tagFlow(self: *This, index: usize) ?*ui.TagFlow { 2148 const inner = self.detailInner(index); 2149 if (inner.children.count() <= tags_child_index) return null; 2150 return switch (inner.children.values()[tags_child_index].widget) { 2151 .tag_flow => |*tf| tf, 2152 else => null, 2153 }; 2154 } 2155 2156 fn tagsFocused(self: *This, index: usize) bool { 2157 const inner = self.detailInner(index); 2158 const cid = inner.getFocus().child_id orelse return false; 2159 return inner.children.getIndex(cid) == tags_child_index and self.tagFlow(index) != null; 2160 } 2161 2162 fn toolRowFocused(self: *This, index: usize) bool { 2163 const outer = self.detailOuter(index); 2164 const cid = outer.getFocus().child_id orelse return false; 2165 return outer.children.getIndex(cid) == tool_row_index; 2166 } 2167 2168 fn focusTag(self: *This, index: usize, tf: *ui.TagFlow, root_focus: *Focus, item: usize) void { 2169 root_focus.setFocus(tf.text_boxes.items[item].getFocus().id); 2170 // keep the tag visible on the terminal: its rect offset by the flow's 2171 // position in the pane. 2172 if (self.session.is_terminal and item < tf.rects.items.len) { 2173 if (self.detailInner(index).children.values()[tags_child_index].rect) |flow_rect| { 2174 var rect = tf.rects.items[item]; 2175 rect.x += flow_rect.x; 2176 rect.y += flow_rect.y; 2177 self.detailScroll(index).scrollToRect(rect); 2178 } 2179 } 2180 } 2181 2182 fn titleFocused(self: *This, index: usize) bool { 2183 const inner = self.detailInner(index); 2184 const cid = inner.getFocus().child_id orelse return false; 2185 return inner.children.getIndex(cid) == title_child_index; 2186 } 2187 2188 fn authorFocused(self: *This, index: usize) bool { 2189 const inner = self.detailInner(index); 2190 const cid = inner.getFocus().child_id orelse return false; 2191 return cid == self.author_id[index]; 2192 } 2193 2194 fn descriptionFocused(self: *This, index: usize) bool { 2195 const cid = self.detailInner(index).getFocus().child_id orelse return false; 2196 return cid == self.description_id[index]; 2197 } 2198 2199 // return to the tool row's last-focused button (the header when the 2200 // description page shows no row). 2201 fn focusToolRow(self: *This, index: usize, root_focus: *Focus) void { 2202 const cid = self.toolRow(index).getFocus().child_id orelse return self.focusHeader(root_focus); 2203 root_focus.setFocus(cid); 2204 } 2205 2206 // enter the detail pane. an empty pane (no issues) can't be entered. 2207 fn focusDetail(self: *This, index: usize, root_focus: *Focus) !void { 2208 if (self.detailInner(index).children.count() == 0) return; 2209 root_focus.setFocus(self.detailOuter(index).getFocus().id); 2210 } 2211 2212 // return to the list. 2213 fn focusList(self: *This, index: usize, root_focus: *Focus) !void { 2214 root_focus.setFocus(self.listScroll(index).getFocus().id); 2215 } 2216 2217 // cross to the header tabs above the stack. 2218 fn focusHeader(self: *This, root_focus: *Focus) void { 2219 root_focus.setFocus(self.box.children.keys()[header_index]); 2220 } 2221 2222 pub fn clearGrid(self: *This) void { 2223 self.box.clearGrid(); 2224 } 2225 2226 pub fn getGrid(self: This) ?Grid { 2227 return self.box.getGrid(); 2228 } 2229 2230 pub fn getFocus(self: *This) *Focus { 2231 return self.box.getFocus(); 2232 } 2233 2234 // for the parent's "scroll up at the top jumps to the header" check: at the 2235 // top only while the header tabs hold focus, so up from the split 2236 // crosses into the tabs first. 2237 pub fn getSelectedIndex(self: *This) ?usize { 2238 return if (self.headerActive()) 0 else 1; 2239 } 2240 }; 2241 } 2242