╭ 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 break :blk .{ 233 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), 234 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), 235 try Refs.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, repo_identity.identity, refs_kind, refs_from), 236 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), 237 try Patches.init(repo_kind, opened.self_repo_opts, arena, opened, io, session.haxy_moment, session, repo_id_maybe, repo_identity.identity, patches_tag, patches_selected, patches_comment, patches_comments_start, patches_theirs, patches_view), 238 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), 239 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), 240 }; 241 }, 242 } 243 }, 244 } 245 } 246 const aa = arena.allocator(); 247 break :blk .{ 248 try Files.emptyResult(aa, repo_identity.identity, requested_ref_or_oid orelse .branch, requested_ref_value, files_dir), 249 try Commits.emptyResult(aa, repo_identity.identity, requested_ref_or_oid orelse .branch, requested_ref_value, commits_content), 250 try Refs.emptyResult(arena, repo_identity.identity, refs_kind, refs_from), 251 try Issues.emptyResult(aa, repo_identity.identity, issues_tag, issues_selected, issues_comment, issues_comments_start, issues_theirs, issues_view), 252 try Patches.emptyResult(aa, repo_identity.identity, patches_tag, patches_selected, patches_comment, patches_comments_start, patches_theirs, patches_view), 253 try Discussions.emptyResult(aa, repo_identity.identity, discussions_tag, discussions_selected, discussions_comment, discussions_comments_start, discussions_view), 254 try Events.empty(aa, repo_identity.identity, events_view, session.local != null, session.data.sync_failure), 255 }; 256 }; 257 issues.repo_source = source; 258 patches.repo_source = source; 259 patches.repo_id = repo_id_maybe; 260 patches.target_branch = if (files.ref_or_oid == .branch) files.ref_or_oid_value else ""; 261 discussions.repo_source = source; 262 263 return .{ 264 // files and commits resolve the same ref, so either's serves the header, 265 // which points both tabs at it. 266 .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), 267 .repo = repo, 268 .files = files, 269 .commits = commits, 270 .refs = refs, 271 .issues = issues, 272 .patches = patches, 273 .discussions = discussions, 274 .events = events, 275 .settings = Settings.init(), 276 .auth = Auth.init(), 277 .quit = Quit.init(), 278 }; 279 } 280 281 pub const View = struct { 282 box: wgt.Box(ui.Widget), 283 284 const header_index: usize = 0; 285 const stack_index: usize = 1; 286 287 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { 288 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .rounded_corners = true, .direction = .vert }); 289 errdefer box.deinit(allocator); 290 291 // build the header first so we can grab the files-tab id for the auth 292 // view (it focuses there after login). 293 { 294 var header_view = try Header.View.init(allocator, &data.header, session); 295 errdefer header_view.deinit(allocator); 296 try box.children.put(allocator, header_view.getFocus().id, .{ .widget = .{ .repo_header = header_view }, .rect = null, .min_size = null }); 297 } 298 299 { 300 var stack = try wgt.Stack(ui.Widget).init(allocator); 301 errdefer stack.deinit(allocator); 302 303 // files — the default tab: the current directory's listing. 304 { 305 var files_view = try Files.View.init(allocator, &data.files, session); 306 errdefer files_view.deinit(allocator); 307 try stack.children.put(allocator, files_view.getFocus().id, .{ .repo_files = files_view }); 308 } 309 310 // commits — the current page of the commit log. 311 { 312 var commits_view = try Commits.View.init(allocator, &data.commits, session); 313 errdefer commits_view.deinit(allocator); 314 try stack.children.put(allocator, commits_view.getFocus().id, .{ .repo_commits = commits_view }); 315 } 316 317 // refs — the repo's branches and tags. 318 { 319 var refs_view = try Refs.View.init(allocator, &data.refs, session); 320 errdefer refs_view.deinit(allocator); 321 try stack.children.put(allocator, refs_view.getFocus().id, .{ .repo_refs = refs_view }); 322 } 323 324 // issues — the repo's issue tracker and comment permalinks. 325 { 326 var issues_view = try Issues.View.init(allocator, &data.issues, session); 327 errdefer issues_view.deinit(allocator); 328 try stack.children.put(allocator, issues_view.getFocus().id, .{ .repo_issues = issues_view }); 329 } 330 331 // patches and their comment permalinks. 332 { 333 var patches_view = try Patches.View.init(allocator, &data.patches, session); 334 errdefer patches_view.deinit(allocator); 335 try stack.children.put(allocator, patches_view.getFocus().id, .{ .repo_patches = patches_view }); 336 } 337 338 // discussions and their comment permalinks. 339 { 340 var discussions_view = try Discussions.View.init(allocator, &data.discussions, session); 341 errdefer discussions_view.deinit(allocator); 342 try stack.children.put(allocator, discussions_view.getFocus().id, .{ .repo_discussions = discussions_view }); 343 } 344 345 { 346 var events_view = try Events.View.init(allocator, &data.events, session); 347 errdefer events_view.deinit(allocator); 348 try stack.children.put(allocator, events_view.getFocus().id, .{ .repo_events = events_view }); 349 } 350 351 // the header only shows the settings tab with a login and the auth 352 // tab outside local mode, so keep the stack's children 1:1 with 353 // the tabs by skipping the same views. 354 if (session.data.user_id != null) { 355 var settings_view = try Settings.View.init(allocator, session); 356 errdefer settings_view.deinit(allocator); 357 try stack.children.put(allocator, settings_view.getFocus().id, .{ .home_settings = settings_view }); 358 } 359 360 if (!session.data.is_local) { 361 var auth_view = try Auth.View.init(allocator, &data.auth, session); 362 errdefer auth_view.deinit(allocator); 363 try stack.children.put(allocator, auth_view.getFocus().id, .{ .home_auth = auth_view }); 364 } 365 366 if (session.is_terminal) { 367 var quit_view = try Quit.View.init(allocator, session); 368 errdefer quit_view.deinit(allocator); 369 try stack.children.put(allocator, quit_view.getFocus().id, .{ .quit = quit_view }); 370 } 371 372 try box.children.put(allocator, stack.getFocus().id, .{ .widget = .{ .stack = stack }, .rect = null, .min_size = null }); 373 } 374 375 var self = View{ .box = box }; 376 self.getFocus().child_id = box.children.keys()[header_index]; 377 return self; 378 } 379 380 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 381 self.box.deinit(allocator); 382 } 383 384 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 385 self.clearGrid(); 386 const header = &self.box.children.values()[header_index].widget.repo_header; 387 const stack = &self.box.children.values()[stack_index].widget.stack; 388 389 // each header tab maps 1:1 to a stack child by position 390 if (header.getSelectedIndex()) |index| 391 stack.getFocus().child_id = stack.children.keys()[index]; 392 try self.box.build(allocator, constraint, root_focus); 393 } 394 395 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 396 const stack = &self.box.children.values()[stack_index].widget.stack; 397 if (self.getFocus().child_id) |child_id| { 398 if (self.box.children.getIndex(child_id)) |current_index| { 399 const child = &self.box.children.values()[current_index].widget; 400 var index = current_index; 401 402 const direction = inp.vertDirection(key); 403 404 switch (direction) { 405 .up => { 406 switch (child.*) { 407 .repo_header => { 408 try child.input(allocator, key, root_focus); 409 }, 410 .stack => { 411 if (child.stack.getSelected()) |selected_widget| { 412 const at_top = switch (selected_widget.*) { 413 .repo_files => |*v| v.getSelectedIndex() == 0, 414 .repo_commits => |*v| v.getSelectedIndex() == 0, 415 .repo_refs => |*v| v.getSelectedIndex() == 0, 416 .repo_issues => |*v| v.getSelectedIndex() == 0, 417 .repo_patches => |*v| v.getSelectedIndex() == 0, 418 .repo_discussions => |*v| v.getSelectedIndex() == 0, 419 .repo_events => |*v| v.getSelectedIndex() == 0, 420 .home_settings => |*v| v.getSelectedIndex() == 0, 421 .home_auth => |*v| v.getSelectedIndex() == 0, 422 .quit => |*v| v.getSelectedIndex() == 0, 423 else => false, 424 }; 425 if (at_top) { 426 index = header_index; 427 } else { 428 try child.input(allocator, key, root_focus); 429 } 430 } 431 }, 432 else => {}, 433 } 434 }, 435 .down => { 436 switch (child.*) { 437 .repo_header => { 438 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 439 .repo_files => |*v| if (v.focusCloneUrl(root_focus)) return, 440 .repo_commits => |*v| if (v.focusCloneUrl(root_focus)) return, 441 else => {}, 442 }; 443 index = stack_index; 444 }, 445 .stack => { 446 try child.input(allocator, key, root_focus); 447 }, 448 else => {}, 449 } 450 }, 451 .none => { 452 try child.input(allocator, key, root_focus); 453 }, 454 } 455 456 if (index != current_index) { 457 root_focus.setFocus(self.box.children.keys()[index]); 458 } 459 } 460 } 461 } 462 463 pub fn clearGrid(self: *View) void { 464 self.box.clearGrid(); 465 } 466 467 pub fn getGrid(self: View) ?Grid { 468 return self.box.getGrid(); 469 } 470 471 pub fn getFocus(self: *View) *Focus { 472 return self.box.getFocus(); 473 } 474 }; 475