╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Markdown.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
13 14 // a rendered markdown file: one child per block, word-wrapped to the width. 15 // without `data` (a file outside any repo), repo-relative links aren't clickable. 16 pub const View = struct { 17 box: wgt.Box(ui.Widget), 18 // where focus rests off the links, covering the whole document; it's 19 // registered after the links so they win hit-testing 20 body: *Focus, 21 22 pub fn init(allocator: std.mem.Allocator, doc: md.Document, data: ?*const Files, file_path: []const u8, page_arena: *std.heap.ArenaAllocator) !View { 23 const builder: Builder = .{ 24 .allocator = allocator, 25 .data = data, 26 .dir = if (std.mem.lastIndexOfScalar(u8, file_path, '/')) |slash| file_path[0..slash] else "", 27 .page_arena = page_arena, 28 .fonts = !hasNonAsciiHeading(doc.blocks), 29 }; 30 var box = try builder.blocksBox(doc.blocks, true); 31 errdefer box.deinit(allocator); 32 const body = try Focus.create(allocator, .container); 33 body.mode = .all; 34 box.getFocus().child_id = body.id; 35 return .{ .box = box, .body = body }; 36 } 37 38 pub fn deinit(self: *View, allocator: std.mem.Allocator) void { 39 self.box.deinit(allocator); 40 self.body.destroy(allocator); 41 } 42 43 pub fn build(self: *View, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 44 self.clearGrid(); 45 try self.box.build(allocator, constraint, root_focus); 46 const grid = self.box.getGrid() orelse return; 47 try self.box.getFocus().addChild(allocator, self.body, grid.size, 0, 0); 48 } 49 50 pub fn input(self: *View, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 51 _ = self; 52 _ = allocator; 53 _ = key; 54 _ = root_focus; 55 } 56 57 pub fn clearGrid(self: *View) void { 58 self.box.clearGrid(); 59 } 60 61 pub fn getGrid(self: View) ?Grid { 62 return self.box.getGrid(); 63 } 64 65 pub fn getFocus(self: *View) *Focus { 66 return self.box.getFocus(); 67 } 68 69 // whether `id` is the body or one of the links 70 pub fn owns(self: *View, id: usize) bool { 71 return self.box.getFocus().children.contains(id); 72 } 73 74 // focus the next or previous link in document order, scrolling it into 75 // view; from the body, start at the first link in view. stepping past 76 // either end returns to the body. 77 pub fn stepLink(self: *View, allocator: std.mem.Allocator, root_focus: *Focus, scroll: *wgt.Scroll(ui.Widget), forward: bool) !void { 78 var stops: std.ArrayList(usize) = .empty; 79 defer stops.deinit(allocator); 80 try collectStops(allocator, &self.box, self.box.getFocus(), &stops); 81 const children = self.box.getFocus().children; 82 83 const current = if (root_focus.grandchild_id) |id| std.mem.indexOfScalar(usize, stops.items, id) else null; 84 const target: ?usize = if (current) |c| 85 (if (forward) (if (c + 1 < stops.items.len) c + 1 else null) else (if (c > 0) c - 1 else null)) 86 else entry: { 87 const top: usize = @intCast(@max(scroll.y, 0)); 88 if (forward) { 89 for (stops.items, 0..) |id, i| { 90 if ((children.get(id) orelse unreachable).rect.y >= top) break :entry i; 91 } 92 break :entry null; 93 } 94 const bottom: usize = if (scroll.grid) |g| top + g.size.height - scroll.bar_h else std.math.maxInt(usize); 95 var i = stops.items.len; 96 while (i > 0) { 97 i -= 1; 98 if ((children.get(stops.items[i]) orelse unreachable).rect.y < bottom) break :entry i; 99 } 100 break :entry null; 101 }; 102 103 const id = stops.items[target orelse return root_focus.setFocus(self.body.id)]; 104 root_focus.setFocus(id); 105 const rect = (children.get(id) orelse unreachable).rect; 106 scroll.scrollToRect(.{ .x = @intCast(rect.x), .y = @intCast(rect.y), .size = rect.size }); 107 } 108 }; 109 110 // the focus ids of the laid-out links under `box`, in document order 111 fn collectStops(allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), view_focus: *Focus, stops: *std.ArrayList(usize)) !void { 112 for (box.children.values()) |*child| switch (child.widget) { 113 .rich_text => |*rich_text| try addStops(allocator, rich_text, view_focus, stops), 114 .markdown_heading => |*heading| try addStops(allocator, &heading.text, view_focus, stops), 115 .markdown_gutter => |*gutter| try collectStops(allocator, &gutter.child, view_focus, stops), 116 .box => |*inner| try collectStops(allocator, inner, view_focus, stops), 117 else => {}, 118 }; 119 } 120 121 // each link's first piece is its stop 122 fn addStops(allocator: std.mem.Allocator, rich_text: *RichText, view_focus: *Focus, stops: *std.ArrayList(usize)) !void { 123 for (rich_text.link_focuses) |focuses| { 124 if (focuses.items.len > 0 and view_focus.children.contains(focuses.items[0].id)) try stops.append(allocator, focuses.items[0].id); 125 } 126 } 127 128 // turns blocks into widgets, resolving links against the viewed file. 129 const Builder = struct { 130 allocator: std.mem.Allocator, 131 data: ?*const Files, 132 // the viewed file's directory, which relative links resolve against 133 dir: []const u8, 134 page_arena: *std.heap.ArenaAllocator, 135 // whether headings may use the title fonts 136 fonts: bool, 137 138 // a vertical box of `blocks`, with a blank row between them when `gap` 139 fn blocksBox(b: Builder, blocks: []const md.Block, gap: bool) anyerror!wgt.Box(ui.Widget) { 140 var box = try wgt.Box(ui.Widget).init(b.allocator, .{ .border_style = null, .direction = .vert, .gap = @intFromBool(gap) }); 141 errdefer box.deinit(b.allocator); 142 for (blocks) |block| try b.addBlock(&box, block); 143 return box; 144 } 145 146 fn addBlock(b: Builder, box: *wgt.Box(ui.Widget), block: md.Block) !void { 147 const allocator = b.allocator; 148 switch (block) { 149 .heading => |heading| { 150 const spans = try b.runSpans(heading.inlines, .{ .bold = true }); 151 try put(allocator, box, .{ .markdown_heading = try Heading.init(allocator, b.page_arena, heading.level, spans, b.fonts) }); 152 }, 153 .paragraph => |inlines| try put(allocator, box, .{ .rich_text = try RichText.init(allocator, try b.runSpans(inlines, .{})) }), 154 .code => |lines| { 155 const text = try std.mem.join(b.page_arena.allocator(), "\n", lines); 156 try put(allocator, box, .{ .text_box = try wgt.TextBox.init(allocator, text, .{ .border_style = .single, .round_corners = true, .wrap_kind = .char }) }); 157 }, 158 .quote => |blocks| { 159 const gutter = gutter: { 160 var inner = try b.blocksBox(blocks, true); 161 errdefer inner.deinit(allocator); 162 break :gutter try Gutter.init(allocator, "│ ", true, .{ .dim = true }, inner); 163 }; 164 try put(allocator, box, .{ .markdown_gutter = gutter }); 165 }, 166 .list => |list| { 167 var list_box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert }); 168 errdefer list_box.deinit(allocator); 169 // ordered markers are right-aligned to the widest number 170 const number_width = std.fmt.count("{d}", .{list.start + list.items.len -| 1}); 171 for (list.items, 0..) |item, i| { 172 const marker = if (item.task) |checked| 173 (if (checked) "☑ " else "☐ ") 174 else if (list.ordered) 175 try std.fmt.allocPrint(b.page_arena.allocator(), "{[n]d:>[w]}. ", .{ .n = list.start + i, .w = number_width }) 176 else 177 "• "; 178 const gutter = gutter: { 179 var inner = try b.blocksBox(item.blocks, false); 180 errdefer inner.deinit(allocator); 181 break :gutter try Gutter.init(allocator, marker, false, .{}, inner); 182 }; 183 try put(allocator, &list_box, .{ .markdown_gutter = gutter }); 184 } 185 try put(allocator, box, .{ .box = list_box }); 186 }, 187 // wider than any pane, and clipped to the width 188 .rule => try put(allocator, box, .{ .text_box = try wgt.TextBox.init(allocator, "─" ** 512, .{ .border_style = null, .wrap_kind = .none, .style = .{ .dim = true } }) }), 189 .raw => |lines| { 190 const text = try std.mem.join(b.page_arena.allocator(), "\n", lines); 191 try put(allocator, box, .{ .text_box = try wgt.TextBox.init(allocator, text, .{ .border_style = null, .wrap_kind = .none }) }); 192 }, 193 } 194 } 195 196 // styled spans for `inlines` over `base`, with each link resolved 197 fn runSpans(b: Builder, inlines: []const md.Inline, base: Grid.Style) ![]const RichText.Span { 198 const out = try b.page_arena.allocator().alloc(RichText.Span, inlines.len); 199 for (inlines, out) |run, *span| { 200 const link = if (run.link) |dest| try b.resolveLink(dest) else ""; 201 var style = base; 202 style.bold = style.bold or run.style.bold; 203 style.italic = run.style.italic; 204 style.strikethrough = run.style.strike; 205 if (run.style.code) style.fg = .{ .ansi = .yellow }; 206 if (link.len > 0) { 207 style.fg = .{ .ansi = .cyan }; 208 style.underline = true; 209 } 210 span.* = .{ .text = run.text, .style = style, .link = link }; 211 } 212 return out; 213 } 214 215 // the focus kind a link follows, or "" when it isn't clickable: web links 216 // are raw links, and a repo path is a files route relative to this file 217 fn resolveLink(b: Builder, dest: []const u8) ![]const u8 { 218 const aa = b.page_arena.allocator(); 219 for ([_][]const u8{ "http:", "https:", "mailto:" }) |scheme| { 220 if (std.ascii.startsWithIgnoreCase(dest, scheme)) return std.fmt.allocPrint(aa, "{s}{s}", .{ ui.raw_link_prefix, dest }); 221 } 222 if (hasScheme(dest) or std.mem.startsWith(u8, dest, "//")) return ""; 223 const data = b.data orelse return ""; 224 const end = std.mem.indexOfAny(u8, dest, "?#") orelse dest.len; 225 if (end == 0) return ""; 226 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, dest[0..end])); 227 228 var segments: std.ArrayList([]const u8) = .empty; 229 if (decoded[0] != '/') { 230 var base = std.mem.tokenizeScalar(u8, b.dir, '/'); 231 while (base.next()) |segment| try segments.append(aa, segment); 232 } 233 var parts = std.mem.tokenizeScalar(u8, decoded, '/'); 234 while (parts.next()) |part| { 235 if (std.mem.eql(u8, part, ".")) continue; 236 if (std.mem.eql(u8, part, "..")) { 237 // climbing above the root isn't a repo path 238 if (segments.pop() == null) return ""; 239 continue; 240 } 241 try segments.append(aa, part); 242 } 243 const path = try std.mem.join(aa, "/", segments.items); 244 const route = data.filesRoute(path, 0) orelse return ""; 245 return std.fmt.allocPrint(aa, "a:{s}", .{try route.toUrl(b.page_arena)}); 246 } 247 }; 248 249 // whether any heading, however nested, has non-ascii text, in which case 250 // none use the title fonts so they all look alike 251 fn hasNonAsciiHeading(blocks: []const md.Block) bool { 252 for (blocks) |block| switch (block) { 253 .heading => |heading| for (heading.inlines) |run| { 254 for (run.text) |c| if (!std.ascii.isAscii(c)) return true; 255 }, 256 .quote => |inner| if (hasNonAsciiHeading(inner)) return true, 257 .list => |list| for (list.items) |item| { 258 if (hasNonAsciiHeading(item.blocks)) return true; 259 }, 260 else => {}, 261 }; 262 return false; 263 } 264 265 // whether `dest` starts with a url scheme 266 fn hasScheme(dest: []const u8) bool { 267 const colon = std.mem.indexOfScalar(u8, dest, ':') orelse return false; 268 if (colon == 0 or !std.ascii.isAlphabetic(dest[0])) return false; 269 for (dest[0..colon]) |c| { 270 if (!std.ascii.isAlphanumeric(c) and c != '+' and c != '.' and c != '-') return false; 271 } 272 return true; 273 } 274 275 fn put(allocator: std.mem.Allocator, box: *wgt.Box(ui.Widget), widget: ui.Widget) !void { 276 var owned = widget; 277 errdefer owned.deinit(allocator); 278 try box.children.put(allocator, owned.getFocus().id, .{ .widget = owned, .rect = null, .min_size = null }); 279 } 280 281 // a heading in the title font when it fits, else the subtitle font, else 282 // bold text. the fonts only cover plain text of their own glyphs. 283 pub const Heading = struct { 284 focus: *Focus, 285 text: RichText, 286 title: ?ui.Title.View = null, 287 title_width: usize = 0, 288 sub_title: ?ui.SubTitle.View = null, 289 sub_title_width: usize = 0, 290 shown: enum { title, sub_title, text } = .text, 291 292 fn init(allocator: std.mem.Allocator, page_arena: *std.heap.ArenaAllocator, level: u3, spans: []const RichText.Span, fonts: bool) !Heading { 293 var self: Heading = .{ 294 .focus = try Focus.create(allocator, .container), 295 .text = undefined, 296 }; 297 errdefer self.focus.destroy(allocator); 298 self.text = try RichText.init(allocator, spans); 299 errdefer self.text.deinit(allocator); 300 301 var plain: std.ArrayList(u8) = .empty; 302 var has_links = false; 303 for (spans) |span| { 304 try plain.appendSlice(page_arena.allocator(), span.text); 305 has_links = has_links or span.link.len > 0; 306 } 307 const text = std.mem.trim(u8, plain.items, " "); 308 if (!fonts or level > 2 or has_links or text.len == 0 or !ui.Title.covers(text) or !ui.SubTitle.covers(text)) return self; 309 310 if (level == 1) { 311 const title = try ui.Title.init(page_arena, text, .solid); 312 self.title_width = try title.width(); 313 self.title = try ui.Title.View.init(allocator, &title); 314 } 315 errdefer if (self.title) |*title| title.deinit(allocator); 316 const sub_title = try ui.SubTitle.init(page_arena, text); 317 self.sub_title_width = try sub_title.width(); 318 self.sub_title = try ui.SubTitle.View.init(allocator, &sub_title); 319 return self; 320 } 321 322 pub fn deinit(self: *Heading, allocator: std.mem.Allocator) void { 323 self.focus.destroy(allocator); 324 self.text.deinit(allocator); 325 if (self.title) |*title| title.deinit(allocator); 326 if (self.sub_title) |*sub_title| sub_title.deinit(allocator); 327 } 328 329 pub fn build(self: *Heading, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 330 self.clearGrid(); 331 self.focus.clear(); 332 const max_width = constraint.max_size.width orelse std.math.maxInt(usize); 333 self.shown = if (self.title != null and self.title_width <= max_width) 334 .title 335 else if (self.sub_title != null and self.sub_title_width <= max_width) 336 .sub_title 337 else 338 .text; 339 switch (self.shown) { 340 .title => try self.buildShown(allocator, constraint, root_focus, if (self.title) |*title| title else unreachable), 341 .sub_title => try self.buildShown(allocator, constraint, root_focus, if (self.sub_title) |*sub_title| sub_title else unreachable), 342 .text => try self.buildShown(allocator, constraint, root_focus, &self.text), 343 } 344 } 345 346 fn buildShown(self: *Heading, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus, widget: anytype) !void { 347 try widget.build(allocator, constraint, root_focus); 348 const grid = widget.getGrid() orelse return; 349 try self.focus.addChild(allocator, widget.getFocus(), grid.size, 0, 0); 350 } 351 352 pub fn input(self: *Heading, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 353 _ = self; 354 _ = allocator; 355 _ = key; 356 _ = root_focus; 357 } 358 359 pub fn clearGrid(self: *Heading) void { 360 self.text.clearGrid(); 361 if (self.title) |*title| title.clearGrid(); 362 if (self.sub_title) |*sub_title| sub_title.clearGrid(); 363 } 364 365 pub fn getGrid(self: Heading) ?Grid { 366 return switch (self.shown) { 367 .title => if (self.title) |title| title.getGrid() else null, 368 .sub_title => if (self.sub_title) |sub_title| sub_title.getGrid() else null, 369 .text => self.text.getGrid(), 370 }; 371 } 372 373 pub fn getFocus(self: *Heading) *Focus { 374 return self.focus; 375 } 376 }; 377 378 // a marker column beside a child, so wrapped lines hang under the child's 379 // first line: a list item's bullet, or a quote's bar on every row. 380 pub const Gutter = struct { 381 focus: *Focus, 382 grid: ?Grid, 383 child: wgt.Box(ui.Widget), 384 marker: []const u8, 385 // draw the marker on every row rather than only the first 386 repeat: bool, 387 style: Grid.Style, 388 389 // takes ownership of `child` on success 390 fn init(allocator: std.mem.Allocator, marker: []const u8, repeat: bool, style: Grid.Style, child: wgt.Box(ui.Widget)) !Gutter { 391 return .{ .focus = try Focus.create(allocator, .container), .grid = null, .child = child, .marker = marker, .repeat = repeat, .style = style }; 392 } 393 394 pub fn deinit(self: *Gutter, allocator: std.mem.Allocator) void { 395 self.focus.destroy(allocator); 396 self.clearGrid(); 397 self.child.deinit(allocator); 398 } 399 400 pub fn build(self: *Gutter, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 401 self.clearGrid(); 402 self.focus.clear(); 403 const marker_width = try xitui.width.displayWidth(self.marker); 404 if (constraint.max_size.width) |w| if (w <= marker_width) return; 405 if (constraint.max_size.height == 0) return; 406 407 try self.child.build(allocator, .{ 408 .min_size = .{ .width = null, .height = null }, 409 .max_size = .{ .width = if (constraint.max_size.width) |w| w - marker_width else null, .height = constraint.max_size.height }, 410 }, root_focus); 411 const child_grid = self.child.getGrid(); 412 const child_size: layout.Size = if (child_grid) |g| g.size else .{ .width = 0, .height = 0 }; 413 414 var grid = try Grid.init(allocator, .{ .width = marker_width + child_size.width, .height = @max(1, child_size.height) }); 415 errdefer grid.deinit(); 416 for (0..if (self.repeat) grid.size.height else 1) |y| { 417 var x: usize = 0; 418 var utf8 = (try std.unicode.Utf8View.init(self.marker)).iterator(); 419 while (utf8.nextCodepoint()) |rune| { 420 (try grid.cell(x, y)).style = self.style; 421 try grid.setRune(x, y, rune); 422 x += xitui.width.cellWidth(rune); 423 } 424 } 425 if (child_grid) |g| { 426 try grid.drawGrid(g, marker_width, 0); 427 try self.focus.addChild(allocator, self.child.getFocus(), g.size, marker_width, 0); 428 } 429 self.grid = grid; 430 } 431 432 pub fn input(self: *Gutter, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 433 _ = self; 434 _ = allocator; 435 _ = key; 436 _ = root_focus; 437 } 438 439 pub fn clearGrid(self: *Gutter) void { 440 if (self.grid) |*grid| { 441 grid.deinit(); 442 self.grid = null; 443 } 444 self.child.clearGrid(); 445 } 446 447 pub fn getGrid(self: Gutter) ?Grid { 448 return self.grid; 449 } 450 451 pub fn getFocus(self: *Gutter) *Focus { 452 return self.focus; 453 } 454 }; 455