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