╭ Repo.zig ─────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1 const std = @import("std"); 2 const evt = @import("../event.zig"); 3 const ui = @import("../ui.zig"); 4 const xit = @import("xit"); 5 const rp = xit.repo; 6 const xitui = xit.xitui; 7 const wgt = xitui.widget; 8 const layout = xitui.layout; 9 const Key = xitui.input.Key; 10 const Grid = xitui.grid.Grid; 11 const Focus = xitui.focus.Focus; 12 const inp = @import("./input.zig"); 13 14 pub const Header = @import("./Repo/Header.zig"); 15 pub const Files = @import("./Repo/Files.zig"); 16 pub const Commits = @import("./Repo/Commits.zig"); 17 pub const Refs = @import("./Repo/Refs.zig"); 18 pub const Issues = @import("./Repo/Issues.zig"); 19 pub const Comment = @import("./Repo/Comment.zig"); 20 pub const Events = @import("./Repo/Events.zig"); 21 pub const Settings = @import("./Settings.zig"); 22 pub const Auth = @import("./Auth.zig"); 23 pub const Quit = @import("./Quit.zig"); 24 25 const Array = ui.RoutablePage.Array(ui.RoutablePage.repo_identity_max_len); 26 27 header: Header, 28 repo: evt.Repo.Record, 29 files: Files, 30 commits: Commits, 31 refs: Refs, 32 issues: Issues, 33 events: Events, 34 settings: Settings, 35 auth: Auth, 36 quit: Quit, 37 // the full files route this page renders, mirrored into current_page when 38 // the files tab is selected. 39 route_name: ui.RoutablePage.RepoFilesRoute, 40 // the commits route this page renders ("owner/name/commits[/<oid>]"), mirrored 41 // when the commits tab is selected. 42 commits_route_name: ui.RoutablePage.RepoCommitsRoute, 43 // "owner/name" alone, mirrored when the settings/auth tab is selected. 44 identity: Array, 45 46 const Self = @This(); 47 48 pub fn init( 49 arena: *std.heap.ArenaAllocator, 50 session: *ui.Session, 51 route: ui.RoutablePage, 52 ) !Self { 53 const DB = evt.AdminDB; 54 const hash_kind = evt.admin_repo_opts.hash; 55 56 // every repo route stores its identity as "owner/name" (or elides it in 57 // local mode); files and commits carry their remaining fields directly. 58 const name_str = route.repoIdentity() orelse return error.UnexpectedRoute; 59 const repo_identity = ui.RoutablePage.RepoIdentity.parse(name_str) orelse return error.NotFound; 60 // the files and commits tabs share one ref/oid: whichever the incoming route 61 // names (it rides on the route's target tab), or the default branch when 62 // neither tab is targeted. building both views at it keeps switching tabs 63 // (even by key, without a reload) on the same ref. a null ref means the 64 // default branch (Files/Commits.init resolve it). the directory and the diff 65 // window only apply to their own tab. 66 const requested_ref_or_oid: ?ui.RoutablePage.RefOrOid = switch (route) { 67 .repo_files => |f| f.ref_kind, 68 .repo_commits => |c| c.ref_or_oid, 69 else => null, 70 }; 71 const requested_ref_value: []const u8 = switch (route) { 72 .repo_files => |*f| f.ref_value.slice(), 73 .repo_commits => |*c| c.value.slice(), 74 else => "", 75 }; 76 const files_dir = switch (route) { 77 .repo_files => |*f| f.path.slice(), 78 else => "", 79 }; 80 const files_line = switch (route) { 81 .repo_files => |f| f.line, 82 else => 0, 83 }; 84 // what the commits view's pane shows for the commit it walks from: a diff 85 // window (with the file it's filtered to) or that commit's message. 86 const commits_content: ui.RoutablePage.RepoCommitsRoute.Content = switch (route) { 87 .repo_commits => |c| c.content, 88 else => .{ .diff = .{} }, 89 }; 90 const commits_start = switch (commits_content) { 91 .diff => |d| d.start, 92 .message => 0, 93 }; 94 // the refs tab windows one column at a time: `refs_from` (a url-encoded 95 // ref name) roots `refs_kind`'s column, the other stays at its first window. 96 const refs_kind: ui.RoutablePage.RefKind = switch (route) { 97 .repo_refs => |r| r.kind, 98 else => .branch, 99 }; 100 const refs_from: []const u8 = switch (route) { 101 .repo_refs => |*r| r.from.slice(), 102 else => "", 103 }; 104 // the issues tab's tag filter, the issue its window is rooted at, and the 105 // view it shows. 106 const issues_tag: []const u8 = switch (route) { 107 .repo_issues => |*i| i.tag.slice(), 108 else => "", 109 }; 110 const issues_selected: []const u8 = switch (route) { 111 .repo_issues => |*i| i.selected.slice(), 112 else => "", 113 }; 114 const issues_comment: []const u8 = switch (route) { 115 .repo_issues => |*i| i.comment.slice(), 116 else => "", 117 }; 118 const issues_theirs: []const u8 = switch (route) { 119 .repo_issues => |*i| i.theirs.slice(), 120 else => "", 121 }; 122 const issues_view: ui.RoutablePage.IssuesView = switch (route) { 123 .repo_issues => |i| i.view, 124 else => .open, 125 }; 126 const issues_comments_start: usize = switch (route) { 127 .repo_issues => |i| i.comments_start, 128 else => 0, 129 }; 130 const events_kind: ?evt.EventKind = switch (route) { 131 .repo_events => |e| e.kind, 132 else => null, 133 }; 134 const events_view: ui.RoutablePage.EventsView = switch (route) { 135 .repo_events => |e| e.view, 136 else => .active, 137 }; 138 const events_selected: []const u8 = switch (route) { 139 .repo_events => |*e| e.selected.slice(), 140 else => "", 141 }; 142 143 // where the on-disk repo lives (null keeps the views' empty fallback), plus 144 // the repo and owner-name metadata the header shows. local mode already 145 // knows all three; the server paths resolve them from the admin db. 146 var source: ?ui.RepoSource = null; 147 var repo: evt.Repo.Record = undefined; 148 var owner_name: []const u8 = undefined; 149 if (session.local) |local| { 150 source = local; 151 // local routes elide the identity, so the display name comes from the 152 // repo's directory rather than the route. 153 repo = .{ .event = .{ 154 .user_id = "", 155 .name = try arena.allocator().dupe(u8, std.fs.path.basename(local.path)), 156 .description = "", 157 } }; 158 owner_name = ""; 159 } else { 160 const haxy_moment = session.haxy_moment orelse return error.NoMoment; 161 const found = (try evt.Repo.readByOwnerAndName(DB, hash_kind, haxy_moment, arena, repo_identity.owner, repo_identity.name)) orelse return error.NotFound; 162 repo = found.repo; 163 164 // resolve the creating user so the header can show their name to the left 165 // of the repo title. 166 const owner = (try evt.User.readById(DB, hash_kind, haxy_moment, arena, repo.event.user_id)) orelse return error.NotFound; 167 owner_name = owner.event.name; 168 169 // the repo's working copy lives at <repos_dir>/<hex event id>. 170 if (session.repos_dir) |repos_dir| { 171 const hex = std.fmt.bytesToHex(found.event_id, .lower); 172 source = .{ 173 .path = try std.fs.path.join(arena.allocator(), &.{ repos_dir, &hex }), 174 .repo_kind = .xit, 175 }; 176 } 177 } 178 179 // open the on-disk repo once and read every tab's data from it. files and 180 // commits resolve the same requested ref (the default branch when the 181 // route named none), so they end up viewing the same one and either's 182 // resolved ref can canonicalize the tab mirror urls below. no filesystem 183 // (wasm), nowhere to look, or a failed open: empty tabs. 184 const files, const commits, const refs, var issues, const events = blk: { 185 read: { 186 const io = session.io orelse break :read; 187 const src = source orelse break :read; 188 const gpa = arena.child_allocator; 189 switch (src.repo_kind) { 190 inline else => |repo_kind| { 191 var any_repo = rp.AnyRepo(repo_kind, .{}).open(io, gpa, src.localInitOpts()) catch break :read; 192 defer any_repo.deinit(io, gpa); 193 switch (any_repo) { 194 inline else => |*opened| { 195 // local mode: bring the event db up to date with the events branch 196 if (session.local != null) try evt.consume(repo_kind, opened.self_repo_opts, io, gpa, opened, evt.events_ref, &.{}); 197 break :blk .{ 198 try Files.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, repo_identity.identity, requested_ref_or_oid, requested_ref_value, files_dir, files_line), 199 try Commits.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, session.haxy_moment, repo_identity.identity, requested_ref_or_oid, requested_ref_value, commits_content), 200 try Refs.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, repo_identity.identity, refs_kind, refs_from), 201 try Issues.init(repo_kind, opened.self_repo_opts, arena, opened, io, session.haxy_moment, repo_identity.identity, issues_tag, issues_selected, issues_comment, issues_comments_start, issues_theirs, issues_view), 202 try Events.init(repo_kind, opened.self_repo_opts, arena, opened, io, session.haxy_moment, repo_identity.identity, events_view, events_kind, events_selected, session.local != null, session.data.sync_failure), 203 }; 204 }, 205 } 206 }, 207 } 208 } 209 const aa = arena.allocator(); 210 break :blk .{ 211 try Files.emptyResult(aa, repo_identity.identity, requested_ref_or_oid orelse .branch, requested_ref_value, files_dir), 212 try Commits.emptyResult(aa, repo_identity.identity, requested_ref_or_oid orelse .branch, requested_ref_value, commits_content), 213 try Refs.emptyResult(arena, repo_identity.identity, refs_kind, refs_from), 214 try Issues.emptyResult(aa, repo_identity.identity, issues_tag, issues_selected, issues_comment, issues_comments_start, issues_theirs, issues_view), 215 try Events.empty(aa, repo_identity.identity, events_view, session.local != null, session.data.sync_failure), 216 }; 217 }; 218 issues.repo_source = source; 219 220 // each tab mirror carries this page's route for that tab; tabs not targeted 221 // by the incoming route fall back to their root/first-page route. the files 222 // mirror carries the selected file (when the route named one) so the url 223 // keeps it before focus enters the view. 224 const files_path = if (files.selected_file) |f| try Files.childDir(arena.allocator(), files.dir, f) else files.dir; 225 // the content window only applies to a selected file, so the bare 226 // directory route drops it. 227 const files_route_line = if (files.selected_file != null) files_line else 0; 228 const route_name = (ui.RoutablePage.repoFilesRoute(repo_identity.identity, files.ref_or_oid, files.ref_or_oid_value, files_path, files_route_line) orelse return error.NotFound).repo_files; 229 // the message page mirrors its own url, not the log's 230 const commits_route = switch (commits.content) { 231 .message => ui.RoutablePage.repoCommitMessageRoute(repo_identity.identity, commits.ref_or_oid, commits.ref_or_oid_value), 232 .diff => |d| ui.RoutablePage.repoCommitsRoute(repo_identity.identity, commits.ref_or_oid, commits.ref_or_oid_value, commits_start, d.path), 233 }; 234 const commits_route_name = (commits_route orelse return error.NotFound).repo_commits; 235 236 return .{ 237 // files and commits resolve the same ref, so either's serves the header, 238 // which points both tabs at it. 239 .header = try Header.init(arena, repo.event.name, owner_name, files.ref_or_oid, files.ref_or_oid_value, issues_tag), 240 .repo = repo, 241 .files = files, 242 .commits = commits, 243 .refs = refs, 244 .issues = issues, 245 .events = events, 246 .settings = Settings.init(), 247 .auth = Auth.init(), 248 .quit = Quit.init(), 249 .route_name = route_name, 250 .commits_route_name = commits_route_name, 251 .identity = Array.from(repo_identity.identity) orelse return error.NotFound, 252 }; 253 } 254 255 pub const View = struct { 256 box: wgt.Box(ui.Widget), 257 data: *const Self, 258 session: *ui.Session, 259 260 const header_index: usize = 0; 261 const stack_index: usize = 1; 262 263 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { 264 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .rounded_corners = true, .direction = .vert }); 265 errdefer box.deinit(allocator); 266 267 // build the header first so we can grab the files-tab id for the auth 268 // view (it focuses there after login). 269 { 270 var header_view = try Header.View.init(allocator, &data.header, session); 271 errdefer header_view.deinit(allocator); 272 try box.children.put(allocator, header_view.getFocus().id, .{ .widget = .{ .repo_header = header_view }, .rect = null, .min_size = null }); 273 } 274 275 { 276 var stack = try wgt.Stack(ui.Widget).init(allocator); 277 errdefer stack.deinit(allocator); 278 279 // files — the default tab: the current directory's listing. 280 { 281 var files_view = try Files.View.init(allocator, &data.files, session); 282 errdefer files_view.deinit(allocator); 283 try stack.children.put(allocator, files_view.getFocus().id, .{ .repo_files = files_view }); 284 } 285 286 // commits — the current page of the commit log. 287 { 288 var commits_view = try Commits.View.init(allocator, &data.commits, session); 289 errdefer commits_view.deinit(allocator); 290 try stack.children.put(allocator, commits_view.getFocus().id, .{ .repo_commits = commits_view }); 291 } 292 293 // refs — the repo's branches and tags. 294 { 295 var refs_view = try Refs.View.init(allocator, &data.refs, session); 296 errdefer refs_view.deinit(allocator); 297 try stack.children.put(allocator, refs_view.getFocus().id, .{ .repo_refs = refs_view }); 298 } 299 300 // issues — the repo's issue tracker and comment permalinks. 301 { 302 var issues_view = try Issues.View.init(allocator, &data.issues, session); 303 errdefer issues_view.deinit(allocator); 304 try stack.children.put(allocator, issues_view.getFocus().id, .{ .repo_issues = issues_view }); 305 } 306 307 { 308 var events_view = try Events.View.init(allocator, &data.events, session); 309 errdefer events_view.deinit(allocator); 310 try stack.children.put(allocator, events_view.getFocus().id, .{ .repo_events = events_view }); 311 } 312 313 // the header only shows the settings tab with a login and the auth 314 // tab outside local mode, so keep the stack's children 1:1 with 315 // the tabs by skipping the same views. 316 if (session.data.user_id != null) { 317 var settings_view = try Settings.View.init(allocator, session); 318 errdefer settings_view.deinit(allocator); 319 try stack.children.put(allocator, settings_view.getFocus().id, .{ .home_settings = settings_view }); 320 } 321 322 if (!session.data.is_local) { 323 var auth_view = try Auth.View.init(allocator, &data.auth, session); 324 errdefer auth_view.deinit(allocator); 325 try stack.children.put(allocator, auth_view.getFocus().id, .{ .home_auth = auth_view }); 326 } 327 328 if (session.is_terminal) { 329 var quit_view = try Quit.View.init(allocator, session); 330 errdefer quit_view.deinit(allocator); 331 try stack.children.put(allocator, quit_view.getFocus().id, .{ .quit = quit_view }); 332 } 333 334 try box.children.put(allocator, stack.getFocus().id, .{ .widget = .{ .stack = stack }, .rect = null, .min_size = null }); 335 } 336 337 var self = View{ .box = box, .data = data, .session = session }; 338 self.getFocus().child_id = box.children.keys()[header_index]; 339 return self; 340 } 341 342 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 343 self.box.deinit(allocator); 344 } 345 346 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 347 self.clearGrid(); 348 const header = &self.box.children.values()[header_index].widget.repo_header; 349 const stack = &self.box.children.values()[stack_index].widget.stack; 350 351 // each header tab maps 1:1 to a stack child by position. mirror the 352 // selection into current_page so the host can push the matching url; 353 // all repo tabs share the .repo parent, so this stays on the page 354 // rather than navigating. 355 if (header.getSelectedIndex()) |index| { 356 stack.getFocus().child_id = stack.children.keys()[index]; 357 switch (std.meta.activeTag(stack.children.values()[index])) { 358 // files/commits carry this page's content route (directory / log 359 // page); settings/auth carry only "owner/name". 360 .repo_commits => self.session.data.current_page = .{ .repo_commits = self.data.commits_route_name }, 361 // the refs tab mirrors this page's windowed column. 362 .repo_refs => self.session.data.current_page = ui.RoutablePage.repoRefsRoute(self.data.identity.slice(), self.data.refs.kind, self.data.refs.from) orelse self.session.data.current_page, 363 // the issues tab mirrors this page's tag filter (issue urls 364 // themselves never carry the tag). 365 .repo_issues => self.session.data.current_page = ui.RoutablePage.repoIssuesRoute(self.data.identity.slice(), .open, self.data.issues.tag, "") orelse self.session.data.current_page, 366 .repo_events => self.session.data.current_page = ui.RoutablePage.repoEventsRoute(self.data.identity.slice(), self.data.events.view, null, "") orelse self.session.data.current_page, 367 .home_settings => { 368 if (ui.RoutablePage.Array(ui.RoutablePage.repo_route_max_len).from(self.data.identity.slice())) |identity| 369 self.session.data.current_page = .{ .repo_settings = identity }; 370 }, 371 .home_auth => { 372 if (ui.RoutablePage.Array(ui.RoutablePage.repo_route_max_len).from(self.data.identity.slice())) |identity| 373 self.session.data.current_page = .{ .repo_auth = identity }; 374 }, 375 // the quit tab is tty-only and not a route, so leave current_page 376 // alone (nothing to mirror into the url). 377 .quit => {}, 378 // the files tab (this page's directory route) 379 else => self.session.data.current_page = .{ .repo_files = self.data.route_name }, 380 } 381 } 382 try self.box.build(allocator, constraint, root_focus); 383 } 384 385 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 386 const stack = &self.box.children.values()[stack_index].widget.stack; 387 if (self.getFocus().child_id) |child_id| { 388 if (self.box.children.getIndex(child_id)) |current_index| { 389 const child = &self.box.children.values()[current_index].widget; 390 var index = current_index; 391 392 const direction = inp.vertDirection(key); 393 394 switch (direction) { 395 .up => { 396 switch (child.*) { 397 .repo_header => { 398 try child.input(allocator, key, root_focus); 399 }, 400 .stack => { 401 if (child.stack.getSelected()) |selected_widget| { 402 const at_top = switch (selected_widget.*) { 403 .repo_files => |*v| v.getSelectedIndex() == 0, 404 .repo_commits => |*v| v.getSelectedIndex() == 0, 405 .repo_refs => |*v| v.getSelectedIndex() == 0, 406 .repo_issues => |*v| v.getSelectedIndex() == 0, 407 .repo_events => |*v| v.getSelectedIndex() == 0, 408 .home_settings => |*v| v.getSelectedIndex() == 0, 409 .home_auth => |*v| v.getSelectedIndex() == 0, 410 .quit => |*v| v.getSelectedIndex() == 0, 411 else => false, 412 }; 413 if (at_top) { 414 index = header_index; 415 } else { 416 try child.input(allocator, key, root_focus); 417 } 418 } 419 }, 420 else => {}, 421 } 422 }, 423 .down => { 424 switch (child.*) { 425 .repo_header => { 426 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 427 .repo_files => |*v| if (v.focusCloneUrl(root_focus)) return, 428 .repo_commits => |*v| if (v.focusCloneUrl(root_focus)) return, 429 else => {}, 430 }; 431 index = stack_index; 432 }, 433 .stack => { 434 try child.input(allocator, key, root_focus); 435 }, 436 else => {}, 437 } 438 }, 439 .none => { 440 try child.input(allocator, key, root_focus); 441 }, 442 } 443 444 if (index != current_index) { 445 root_focus.setFocus(self.box.children.keys()[index]); 446 } 447 } 448 } 449 } 450 451 pub fn clearGrid(self: *View) void { 452 self.box.clearGrid(); 453 } 454 455 pub fn getGrid(self: View) ?Grid { 456 return self.box.getGrid(); 457 } 458 459 pub fn getFocus(self: *View) *Focus { 460 return self.box.getFocus(); 461 } 462 }; 463