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