╭ 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_selected: []const u8 = switch (route) { 135 .repo_events => |*e| e.selected.slice(), 136 else => "", 137 }; 138 139 // where the on-disk repo lives (null keeps the views' empty fallback), plus 140 // the repo and owner-name metadata the header shows. local mode already 141 // knows all three; the server paths resolve them from the admin db. 142 var source: ?ui.RepoSource = null; 143 var repo: evt.Repo.Record = undefined; 144 var owner_name: []const u8 = undefined; 145 if (session.local) |local| { 146 source = local; 147 // local routes elide the identity, so the display name comes from the 148 // repo's directory rather than the route. 149 repo = .{ .event = .{ 150 .user_id = "", 151 .name = try arena.allocator().dupe(u8, std.fs.path.basename(local.path)), 152 .description = "", 153 } }; 154 owner_name = ""; 155 } else { 156 const haxy_moment = session.haxy_moment orelse return error.NoMoment; 157 const found = (try evt.Repo.readByOwnerAndName(DB, hash_kind, haxy_moment, arena, repo_identity.owner, repo_identity.name)) orelse return error.NotFound; 158 repo = found.repo; 159 160 // resolve the creating user so the header can show their name to the left 161 // of the repo title. 162 const owner = (try evt.User.readById(DB, hash_kind, haxy_moment, arena, repo.event.user_id)) orelse return error.NotFound; 163 owner_name = owner.event.name; 164 165 // the repo's working copy lives at <repos_dir>/<hex event id>. 166 if (session.repos_dir) |repos_dir| { 167 const hex = std.fmt.bytesToHex(found.event_id, .lower); 168 source = .{ 169 .path = try std.fs.path.join(arena.allocator(), &.{ repos_dir, &hex }), 170 .repo_kind = .xit, 171 }; 172 } 173 } 174 175 // open the on-disk repo once and read every tab's data from it. files and 176 // commits resolve the same requested ref (the default branch when the 177 // route named none), so they end up viewing the same one and either's 178 // resolved ref can canonicalize the tab mirror urls below. no filesystem 179 // (wasm), nowhere to look, or a failed open: empty tabs. 180 const files, const commits, const refs, var issues, const events = blk: { 181 read: { 182 const io = session.io orelse break :read; 183 const src = source orelse break :read; 184 const gpa = arena.child_allocator; 185 switch (src.repo_kind) { 186 inline else => |repo_kind| { 187 var any_repo = rp.AnyRepo(repo_kind, .{}).open(io, gpa, .{ .path = src.path }) catch break :read; 188 defer any_repo.deinit(io, gpa); 189 switch (any_repo) { 190 inline else => |*opened| { 191 // local mode: bring the event db up to date with the events branch 192 if (session.local != null) try evt.consume(repo_kind, opened.self_repo_opts, io, gpa, opened, evt.events_ref, &.{}); 193 break :blk .{ 194 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), 195 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), 196 try Refs.init(repo_kind, opened.self_repo_opts, arena, opened, io, gpa, repo_identity.identity, refs_kind, refs_from), 197 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), 198 try Events.init(repo_kind, opened.self_repo_opts, arena, opened, io, session.haxy_moment, repo_identity.identity, events_kind, events_selected, session.local != null, session.data.sync_failure), 199 }; 200 }, 201 } 202 }, 203 } 204 } 205 const aa = arena.allocator(); 206 break :blk .{ 207 try Files.emptyResult(aa, repo_identity.identity, requested_ref_or_oid orelse .branch, requested_ref_value, files_dir), 208 try Commits.emptyResult(aa, repo_identity.identity, requested_ref_or_oid orelse .branch, requested_ref_value, commits_content), 209 try Refs.emptyResult(arena, repo_identity.identity, refs_kind, refs_from), 210 try Issues.emptyResult(aa, repo_identity.identity, issues_tag, issues_selected, issues_comment, issues_comments_start, issues_theirs, issues_view), 211 try Events.empty(aa, repo_identity.identity, session.local != null, session.data.sync_failure), 212 }; 213 }; 214 issues.repo_source = source; 215 216 // each tab mirror carries this page's route for that tab; tabs not targeted 217 // by the incoming route fall back to their root/first-page route. the files 218 // mirror carries the selected file (when the route named one) so the url 219 // keeps it before focus enters the view. 220 const files_path = if (files.selected_file) |f| try Files.childDir(arena.allocator(), files.dir, f) else files.dir; 221 // the content window only applies to a selected file, so the bare 222 // directory route drops it. 223 const files_route_line = if (files.selected_file != null) files_line else 0; 224 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; 225 // the message page mirrors its own url, not the log's 226 const commits_route = switch (commits.content) { 227 .message => ui.RoutablePage.repoCommitMessageRoute(repo_identity.identity, commits.ref_or_oid, commits.ref_or_oid_value), 228 .diff => |d| ui.RoutablePage.repoCommitsRoute(repo_identity.identity, commits.ref_or_oid, commits.ref_or_oid_value, commits_start, d.path), 229 }; 230 const commits_route_name = (commits_route orelse return error.NotFound).repo_commits; 231 232 return .{ 233 // files and commits resolve the same ref, so either's serves the header, 234 // which points both tabs at it. 235 .header = try Header.init(arena, repo.event.name, owner_name, files.ref_or_oid, files.ref_or_oid_value, issues_tag), 236 .repo = repo, 237 .files = files, 238 .commits = commits, 239 .refs = refs, 240 .issues = issues, 241 .events = events, 242 .settings = Settings.init(), 243 .auth = Auth.init(), 244 .quit = Quit.init(), 245 .route_name = route_name, 246 .commits_route_name = commits_route_name, 247 .identity = Array.from(repo_identity.identity) orelse return error.NotFound, 248 }; 249 } 250 251 pub const View = struct { 252 box: wgt.Box(ui.Widget), 253 data: *const Self, 254 session: *ui.Session, 255 256 const header_index: usize = 0; 257 const stack_index: usize = 1; 258 259 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { 260 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .rounded_corners = true, .direction = .vert }); 261 errdefer box.deinit(allocator); 262 263 // build the header first so we can grab the files-tab id for the auth 264 // view (it focuses there after login). 265 { 266 var header_view = try Header.View.init(allocator, &data.header, session); 267 errdefer header_view.deinit(allocator); 268 try box.children.put(allocator, header_view.getFocus().id, .{ .widget = .{ .repo_header = header_view }, .rect = null, .min_size = null }); 269 } 270 271 { 272 var stack = try wgt.Stack(ui.Widget).init(allocator); 273 errdefer stack.deinit(allocator); 274 275 // files — the default tab: the current directory's listing. 276 { 277 var files_view = try Files.View.init(allocator, &data.files, session); 278 errdefer files_view.deinit(allocator); 279 try stack.children.put(allocator, files_view.getFocus().id, .{ .repo_files = files_view }); 280 } 281 282 // commits — the current page of the commit log. 283 { 284 var commits_view = try Commits.View.init(allocator, &data.commits, session); 285 errdefer commits_view.deinit(allocator); 286 try stack.children.put(allocator, commits_view.getFocus().id, .{ .repo_commits = commits_view }); 287 } 288 289 // refs — the repo's branches and tags. 290 { 291 var refs_view = try Refs.View.init(allocator, &data.refs, session); 292 errdefer refs_view.deinit(allocator); 293 try stack.children.put(allocator, refs_view.getFocus().id, .{ .repo_refs = refs_view }); 294 } 295 296 // issues — the repo's issue tracker and comment permalinks. 297 { 298 var issues_view = try Issues.View.init(allocator, &data.issues, session); 299 errdefer issues_view.deinit(allocator); 300 try stack.children.put(allocator, issues_view.getFocus().id, .{ .repo_issues = issues_view }); 301 } 302 303 { 304 var events_view = try Events.View.init(allocator, &data.events, session); 305 errdefer events_view.deinit(allocator); 306 try stack.children.put(allocator, events_view.getFocus().id, .{ .repo_events = events_view }); 307 } 308 309 // the header only shows the settings tab with a login and the auth 310 // tab outside local mode, so keep the stack's children 1:1 with 311 // the tabs by skipping the same views. 312 if (session.data.user_id != null) { 313 var settings_view = try Settings.View.init(allocator, session); 314 errdefer settings_view.deinit(allocator); 315 try stack.children.put(allocator, settings_view.getFocus().id, .{ .home_settings = settings_view }); 316 } 317 318 if (!session.data.is_local) { 319 var auth_view = try Auth.View.init(allocator, &data.auth, session); 320 errdefer auth_view.deinit(allocator); 321 try stack.children.put(allocator, auth_view.getFocus().id, .{ .home_auth = auth_view }); 322 } 323 324 if (session.is_terminal) { 325 var quit_view = try Quit.View.init(allocator, session); 326 errdefer quit_view.deinit(allocator); 327 try stack.children.put(allocator, quit_view.getFocus().id, .{ .quit = quit_view }); 328 } 329 330 try box.children.put(allocator, stack.getFocus().id, .{ .widget = .{ .stack = stack }, .rect = null, .min_size = null }); 331 } 332 333 var self = View{ .box = box, .data = data, .session = session }; 334 self.getFocus().child_id = box.children.keys()[header_index]; 335 return self; 336 } 337 338 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 339 self.box.deinit(allocator); 340 } 341 342 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 343 self.clearGrid(); 344 const header = &self.box.children.values()[header_index].widget.repo_header; 345 const stack = &self.box.children.values()[stack_index].widget.stack; 346 347 // each header tab maps 1:1 to a stack child by position. mirror the 348 // selection into current_page so the host can push the matching url; 349 // all repo tabs share the .repo parent, so this stays on the page 350 // rather than navigating. 351 if (header.getSelectedIndex()) |index| { 352 stack.getFocus().child_id = stack.children.keys()[index]; 353 switch (std.meta.activeTag(stack.children.values()[index])) { 354 // files/commits carry this page's content route (directory / log 355 // page); settings/auth carry only "owner/name". 356 .repo_commits => self.session.data.current_page = .{ .repo_commits = self.data.commits_route_name }, 357 // the refs tab mirrors this page's windowed column. 358 .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, 359 // the issues tab mirrors this page's tag filter (issue urls 360 // themselves never carry the tag). 361 .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, 362 .repo_events => self.session.data.current_page = ui.RoutablePage.repoEventsRoute(self.data.identity.slice(), null, "") orelse self.session.data.current_page, 363 .home_settings => { 364 if (ui.RoutablePage.Array(ui.RoutablePage.repo_route_max_len).from(self.data.identity.slice())) |identity| 365 self.session.data.current_page = .{ .repo_settings = identity }; 366 }, 367 .home_auth => { 368 if (ui.RoutablePage.Array(ui.RoutablePage.repo_route_max_len).from(self.data.identity.slice())) |identity| 369 self.session.data.current_page = .{ .repo_auth = identity }; 370 }, 371 // the quit tab is tty-only and not a route, so leave current_page 372 // alone (nothing to mirror into the url). 373 .quit => {}, 374 // the files tab (this page's directory route) 375 else => self.session.data.current_page = .{ .repo_files = self.data.route_name }, 376 } 377 } 378 try self.box.build(allocator, constraint, root_focus); 379 } 380 381 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 382 const stack = &self.box.children.values()[stack_index].widget.stack; 383 if (self.getFocus().child_id) |child_id| { 384 if (self.box.children.getIndex(child_id)) |current_index| { 385 const child = &self.box.children.values()[current_index].widget; 386 var index = current_index; 387 388 const direction = inp.vertDirection(key); 389 390 switch (direction) { 391 .up => { 392 switch (child.*) { 393 .repo_header => { 394 try child.input(allocator, key, root_focus); 395 }, 396 .stack => { 397 if (child.stack.getSelected()) |selected_widget| { 398 const at_top = switch (selected_widget.*) { 399 .repo_files => |*v| v.getSelectedIndex() == 0, 400 .repo_commits => |*v| v.getSelectedIndex() == 0, 401 .repo_refs => |*v| v.getSelectedIndex() == 0, 402 .repo_issues => |*v| v.getSelectedIndex() == 0, 403 .repo_events => |*v| v.getSelectedIndex() == 0, 404 .home_settings => |*v| v.getSelectedIndex() == 0, 405 .home_auth => |*v| v.getSelectedIndex() == 0, 406 .quit => |*v| v.getSelectedIndex() == 0, 407 else => false, 408 }; 409 if (at_top) { 410 index = header_index; 411 } else { 412 try child.input(allocator, key, root_focus); 413 } 414 } 415 }, 416 else => {}, 417 } 418 }, 419 .down => { 420 switch (child.*) { 421 .repo_header => { 422 if (stack.getSelected()) |selected_widget| switch (selected_widget.*) { 423 .repo_files => |*v| if (v.focusCloneUrl(root_focus)) return, 424 .repo_commits => |*v| if (v.focusCloneUrl(root_focus)) return, 425 else => {}, 426 }; 427 index = stack_index; 428 }, 429 .stack => { 430 try child.input(allocator, key, root_focus); 431 }, 432 else => {}, 433 } 434 }, 435 .none => { 436 try child.input(allocator, key, root_focus); 437 }, 438 } 439 440 if (index != current_index) { 441 root_focus.setFocus(self.box.children.keys()[index]); 442 } 443 } 444 } 445 } 446 447 pub fn clearGrid(self: *View) void { 448 self.box.clearGrid(); 449 } 450 451 pub fn getGrid(self: View) ?Grid { 452 return self.box.getGrid(); 453 } 454 455 pub fn getFocus(self: *View) *Focus { 456 return self.box.getFocus(); 457 } 458 }; 459