╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Markdown.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
474 self.clearGrid(); 475 self.child.deinit(allocator); 476 } 477 478 pub fn build(self: *Gutter, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 479 self.clearGrid(); 480 self.focus.clear(); 481 const marker_width = try xitui.width.displayWidth(self.marker); 482 if (constraint.max_size.width) |w| if (w <= marker_width) return; 483 if (constraint.max_size.height == 0) return; 484 485 try self.child.build(allocator, .{ 486 .min_size = .{ .width = null, .height = null }, 487 .max_size = .{ .width = if (constraint.max_size.width) |w| w - marker_width else null, .height = constraint.max_size.height }, 488 }, root_focus); 489 const child_grid = self.child.getGrid(); 490 const child_size: layout.Size = if (child_grid) |g| g.size else .{ .width = 0, .height = 0 }; 491 492 var grid = try Grid.init(allocator, .{ .width = marker_width + child_size.width, .height = @max(1, child_size.height) }); 493 errdefer grid.deinit(); 494 for (0..if (self.repeat) grid.size.height else 1) |y| { 495 var x: usize = 0; 496 var utf8 = (try std.unicode.Utf8View.init(self.marker)).iterator(); 497 while (utf8.nextCodepoint()) |rune| { 498 (try grid.cell(x, y)).style = self.style; 499 try grid.setRune(x, y, rune); 500 x += xitui.width.cellWidth(rune); 501 } 502 } 503 if (child_grid) |g| { 504 try grid.drawGrid(g, marker_width, 0); 505 try self.focus.addChild(allocator, self.child.getFocus(), g.size, marker_width, 0); 506 } 507 self.grid = grid; 508 } 509 510 pub fn input(self: *Gutter, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 511 _ = self; 512 _ = allocator; 513 _ = key; 514 _ = root_focus; 515 } 516 517 pub fn clearGrid(self: *Gutter) void { 518 if (self.grid) |*grid| { 519 grid.deinit(); 520 self.grid = null; 521 } 522 self.child.clearGrid(); 523 } 524 525 pub fn getGrid(self: Gutter) ?Grid { 526 return self.grid; 527 } 528 529 pub fn getFocus(self: *Gutter) *Focus { 530 return self.focus; 531 } 532 }; 533