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