╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ ui.zig ───────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1820 } 1821 }.f; 1822 return .{ .r = snap(c.r), .g = snap(c.g), .b = snap(c.b) }; 1823 } 1824 1825 // composites ANSI art behind a foreground grid 1826 fn artBehind(allocator: std.mem.Allocator, foreground: Grid, art: *AnsiArt, anchor: ArtAnchor, root_focus: *Focus) !Grid { 1827 art.clearGrid(); 1828 try art.build(allocator, .{ 1829 .min_size = .{ .width = null, .height = null }, 1830 .max_size = .{ .width = foreground.size.width, .height = foreground.size.height }, 1831 }, root_focus); 1832 1833 var out = try Grid.initFromGrid(allocator, foreground, foreground.size, 0, 0); 1834 errdefer out.deinit(); 1835 1836 if (art.getGrid()) |art_grid| { 1837 const anchor_x = switch (anchor) { 1838 .top_left => 0, 1839 .top_right => foreground.size.width -| art_grid.size.width, 1840 }; 1841 for (0..art_grid.size.height) |y| { 1842 for (0..art_grid.size.width) |x| { 1843 const src = art_grid.cells.items[try art_grid.cells.at(.{ y, x })]; 1844 if (src.rune == null) continue; 1845 const idx = out.cells.at(.{ y, anchor_x + x }) catch continue; 1846 const dst = &out.cells.items[idx]; 1847 // composite the dimmed art behind every cell so it shows 1848 // through the whole UI: a blank cell becomes the art, while a 1849 // cell with a glyph keeps the glyph but takes the dimmed art as 1850 // its background (replacing whatever background it had, which 1851 // would otherwise obscure the art). 1852 if (cellIsBlank(dst.*)) { 1853 dst.* = src; 1854 dst.style.fg = sgrSafe(dimColor(dst.style.fg)); 1855 dst.style.bg = sgrSafe(dimColor(dst.style.bg)); 1856 } else { 1857 dst.style.bg = sgrSafe(dimColor(src.style.bg orelse src.style.fg)); 1858 } 1859 } 1860 } 1861 } 1862 return out; 1863 } 1864 }; 1865