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