╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ widget.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1663 } else if (byte == '\r') { 1664 // git may checkout the ansi art with crlf line endings on windows 1665 i += 1; 1666 } else if (byte == 0x1B and i + 1 < content.len and content[i + 1] == '[') { 1667 // CSI: scan to the final byte (0x40..0x7E); apply it if it's 'm' 1668 var j = i + 2; 1669 while (j < content.len and !(content[j] >= 0x40 and content[j] <= 0x7E)) j += 1; 1670 if (j >= content.len) { 1671 i = content.len; // malformed trailing escape; stop 1672 } else { 1673 if (content[j] == 'm') applySgr(&style, content[i + 2 .. j]); 1674 i = j + 1; 1675 } 1676 } else { 1677 const len = std.unicode.utf8ByteSequenceLength(byte) catch 1; 1678 const end = @min(content.len, i + len); 1679 const rune = content[i..end]; 1680 const codepoint = std.unicode.utf8Decode(rune) catch '�'; 1681 // a foreground color does not make a space visible. only an 1682 // effective background makes it opaque; foreground state often 1683 // remains active through the padding at the end of a row. 1684 const effective_background = if (style.inverted) style.fg else style.bg; 1685 const transparent = end - i == 1 and rune[0] == ' ' and effective_background == null; 1686 try row.append(allocator, .{ 1687 .rune = if (transparent) null else codepoint, 1688 .style = style, 1689 }); 1690 if (!transparent and xitui.width.cellWidth(codepoint) == 2) { 1691 try row.append(allocator, .{ .rune = null, .style = style, .continuation = true }); 1692 } 1693 i = end; 1694 } 1695 } 1696 // a trailing row with content but no closing newline 1697 if (row.items.len > 0) { 1698 width = @max(width, row.items.len); 1699 try rows.append(allocator, row); 1700 } else { 1701 row.deinit(allocator); 1702 } 1703 row = .empty; // ownership moved into rows (or freed); keep errdefer safe 1704 1705 const height = rows.items.len; 1706 if (width == 0 or height == 0) return; 1707 1708 const clamped_w = @min(width, constraint.max_size.width orelse width); 1709 const clamped_h = @min(height, constraint.max_size.height orelse height); 1710 1711 var grid = try Grid.init(allocator, .{ .width = clamped_w, .height = clamped_h }); 1712 errdefer grid.deinit(); 1713 for (rows.items[0..clamped_h], 0..) |r, y| { 1714 const n = @min(r.items.len, clamped_w); 1715 for (r.items[0..n], 0..) |cell, x| { 1716 if (cell.continuation) continue; 1717 (try grid.cell(x, y)).style = cell.style; 1718 try grid.setRune(x, y, cell.rune); 1719 } 1720 } 1721 self.grid = grid; 1722 } 1723 1724 pub fn clearGrid(self: *AnsiArt) void { 1725 if (self.grid) |*grid| { 1726 grid.deinit(); 1727 self.grid = null; 1728 } 1729 } 1730 1731 pub fn getGrid(self: AnsiArt) ?Grid { 1732 return self.grid; 1733 } 1734 1735 pub fn getFocus(self: *AnsiArt) *Focus { 1736 return self.focus; 1737 } 1738 1739 fn applySgr(style: *Grid.Style, params: []const u8) void { 1740 var nums: [16]u32 = undefined; 1741 var n: usize = 0; 1742 var it = std.mem.splitScalar(u8, params, ';'); 1743 while (it.next()) |tok| { 1744 if (n >= nums.len) break; 1745 // an empty parameter (e.g. bare "\x1b[m") means 0 1746 nums[n] = std.fmt.parseInt(u32, tok, 10) catch 0; 1747 n += 1; 1748 } 1749 if (n == 0) { 1750 style.* = .{}; 1751 return; 1752 } 1753 var i: usize = 0; 1754 while (i < n) : (i += 1) { 1755 switch (nums[i]) { 1756 0 => style.* = .{}, 1757 7 => style.inverted = true, 1758 27 => style.inverted = false, 1759 39 => style.fg = null, 1760 49 => style.bg = null, 1761 38, 48 => { 1762 // truecolor form: 38;2;r;g;b — anything else is ignored 1763 if (i + 4 < n and nums[i + 1] == 2) { 1764 const c = Grid.Color{ .rgb = .{ 1765 .r = @truncate(nums[i + 2]), 1766 .g = @truncate(nums[i + 3]), 1767 .b = @truncate(nums[i + 4]), 1768 } }; 1769 if (nums[i] == 38) style.fg = c else style.bg = c; 1770 i += 4; 1771 } 1772 }, 1773 else => {}, 1774 } 1775 } 1776 } 1777 }; 1778 1779 // a full-screen wrapper that renders ANSI art behind whatever page it wraps 1780 pub const AnsiBackground = struct { 1781 grid: ?Grid, 1782 child: *Widget, 1783 art: AnsiArt, 1784 session: *ui.Session, 1785 1786 pub fn init(allocator: std.mem.Allocator, child_widget: Widget, session: *ui.Session) !AnsiBackground { 1787 var cw = child_widget; 1788 const child = allocator.create(Widget) catch |e| { 1789 cw.deinit(allocator); 1790 return e; 1791 }; 1792 child.* = cw; 1793 errdefer { 1794 child.deinit(allocator); 1795 allocator.destroy(child); 1796 } 1797 return .{ .grid = null, .child = child, .art = try AnsiArt.init(allocator, session.data.ansi_art), .session = session }; 1798 } 1799 1800 pub fn deinit(self: *AnsiBackground, allocator: std.mem.Allocator) void { 1801 if (self.grid) |*grid| grid.deinit(); 1802 self.art.deinit(allocator); 1803 self.child.deinit(allocator); 1804 allocator.destroy(self.child); 1805 } 1806 1807 pub fn build(self: *AnsiBackground, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 1808 self.clearGrid(); 1809 1810 // make the wrapped page fill the whole available area 1811 try self.child.build(allocator, .{ 1812 .min_size = .{ 1813 .width = constraint.max_size.width orelse constraint.min_size.width, 1814 .height = constraint.max_size.height orelse constraint.min_size.height, 1815 }, 1816 .max_size = constraint.max_size, 1817 }, root_focus); 1818 1819 const foreground = self.child.getGrid() orelse return; 1820 if (!self.session.color) return; 1821 // terminals show the art only once they report a background to fade it toward 1822 const backdrop: ?Grid.Color.Rgb = if (self.session.is_terminal) self.session.terminal_background orelse return else null; 1823 self.art.content = self.session.data.ansi_art; 1824 try self.art.build(allocator, .{ 1825 .min_size = .{ .width = null, .height = null }, 1826 .max_size = .{ .width = foreground.size.width, .height = foreground.size.height }, 1827 }, root_focus); 1828 // the web fades the art with css opacity instead 1829 const art_backdrop = backdrop orelse return; 1830 if (self.art.grid) |*art_grid| { 1831 for (art_grid.cells) |*cell| { 1832 cell.style.fg = fadeColor(cell.style.fg, art_backdrop); 1833 cell.style.bg = fadeColor(cell.style.bg, art_backdrop); 1834 } 1835 self.grid = try artBehind(allocator, foreground, art_grid.*); 1836 } 1837 } 1838 1839 pub fn input(self: *AnsiBackground, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 1840 try self.child.input(allocator, key, root_focus); 1841 } 1842 1843 pub fn clearGrid(self: *AnsiBackground) void { 1844 if (self.grid) |*grid| { 1845 grid.deinit(); 1846 self.grid = null; 1847 } 1848 self.child.clearGrid(); 1849 self.art.clearGrid(); 1850 } 1851 1852 pub fn getGrid(self: AnsiBackground) ?Grid { 1853 return self.grid orelse self.child.getGrid(); 1854 } 1855 1856 pub fn getFocus(self: *AnsiBackground) *Focus { 1857 return self.child.getFocus(); 1858 } 1859 1860 // a foreground cell counts as blank if it's empty or a bare space without styling 1861 fn cellIsBlank(cell: Grid.Cell) bool { 1862 if (cell.continuation) return false; 1863 if (cell.rune) |rune| { 1864 return rune == ' ' and 1865 cell.style.fg == null and cell.style.bg == null and !cell.style.inverted; 1866 } 1867 return true; 1868 } 1869 1870 // the art is faded toward the background at this opacity so foreground 1871 // text stays legible over it 1872 pub const art_opacity = 25; // percent 1873 1874 // the art parser only emits truecolor, so a palette color never occurs 1875 fn artRgb(color: ?Grid.Color) ?Grid.Color.Rgb { 1876 const c = color orelse return null; 1877 return switch (c) { 1878 .rgb => |v| v, 1879 else => null, 1880 }; 1881 } 1882 1883 fn fadeColor(color: ?Grid.Color, backdrop: Grid.Color.Rgb) ?Grid.Color { 1884 const v = artRgb(color) orelse return color; 1885 const blend = struct { 1886 fn f(c: u8, b: u8) u8 { 1887 return @intCast((@as(u16, c) * art_opacity + @as(u16, b) * (100 - art_opacity)) / 100); 1888 } 1889 }.f; 1890 return .{ .rgb = .{ .r = blend(v.r, backdrop.r), .g = blend(v.g, backdrop.g), .b = blend(v.b, backdrop.b) } }; 1891 } 1892 1893 // terminals that don't support truecolor misparse a "38;2;r;g;b"/"48;2;…" 1894 // SGR as a list of plain SGR codes, so any channel value in 1..9 turns on 1895 // a text attribute (5/6 = blink, 7 = inverse, 8 = conceal, …). 1896 // snap such channels clear of that range so the backdrop doesn't blink or 1897 // hide text there; the ≤9/255 shift is imperceptible on terminals that 1898 // actually render truecolor. 1899 fn sgrSafe(color: ?Grid.Color) ?Grid.Color { 1900 const v = artRgb(color) orelse return color; 1901 const snap = struct { 1902 fn f(c: u8) u8 { 1903 return if (c >= 1 and c <= 9) 10 else c; 1904 } 1905 }.f; 1906 return .{ .rgb = .{ .r = snap(v.r), .g = snap(v.g), .b = snap(v.b) } }; 1907 } 1908 1909 // composites ANSI art behind a foreground grid 1910 fn artBehind(allocator: std.mem.Allocator, foreground: Grid, art_grid: Grid) !Grid { 1911 var out = try Grid.initFromGrid(allocator, foreground, foreground.size, 0, 0); 1912 errdefer out.deinit(); 1913 1914 const anchor_x = foreground.size.width -| art_grid.size.width; 1915 for (0..art_grid.size.height) |y| { 1916 for (0..art_grid.size.width) |x| { 1917 const src = (try art_grid.cell(x, y)).*; 1918 if (src.rune == null) continue; 1919 const dst = try out.cell(anchor_x + x, y); 1920 const wide = x + 1 < art_grid.size.width and (try art_grid.cell(x + 1, y)).continuation; 1921 const next_dst = if (wide) try out.cell(anchor_x + x + 1, y) else null; 1922 // blank cells take the art; occupied cells take its background 1923 if (cellIsBlank(dst.*) and (if (next_dst) |next| cellIsBlank(next.*) else true)) { 1924 dst.style = src.style; 1925 dst.style.fg = sgrSafe(dst.style.fg); 1926 dst.style.bg = sgrSafe(dst.style.bg); 1927 try out.setRune(anchor_x + x, y, src.rune); 1928 } else { 1929 const art_bg = sgrSafe(src.style.bg orelse src.style.fg); 1930 dst.style.bg = art_bg; 1931 if (next_dst) |next| next.style.bg = art_bg; 1932 } 1933 } 1934 } 1935 return out; 1936 } 1937 }; 1938 1939 pub const CopyableText = struct { 1940 pub const Choice = struct { 1941 selector: []const u8 = "", 1942 text: []const u8, 1943 copyable_text: ?[]const u8 = null, 1944 label: []const u8 = "", 1945 bottom_label: []const u8 = "", 1946 }; 1947 1948 box: wgt.Box(Widget), 1949 session: *ui.Session, 1950 choices: []Choice, 1951 selected: usize = 0, 1952 1953 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, choices: []const Choice, initial: usize) !CopyableText { 1954 if (choices.len == 0) return error.MissingCopyableText; 1955 1956 const owned_choices = try allocator.dupe(Choice, choices); 1957 errdefer allocator.free(owned_choices); 1958 1959 var box = try wgt.Box(Widget).init(allocator, .{ .border = null, .direction = .horiz }); 1960 errdefer box.deinit(allocator); 1961 1962 if (choices.len > 1) for (choices) |choice| { 1963 var selector_box = try wgt.TextBox.init(allocator, choice.selector, .{ .border = .hidden, .round_corners = true, .wrap_kind = .none }); 1964 errdefer selector_box.deinit(allocator); 1965 selector_box.getFocus().mode = .all; 1966 try box.children.put(allocator, selector_box.getFocus().id, .{ .widget = .{ .text_box = selector_box }, .rect = null, .min_size = .{ .width = choice.selector.len + 2, .height = 3 } }); 1967 }; 1968 1969 var text_input = try wgt.TextInput.init(allocator, .{ 1970 .border = .single, 1971 .round_corners = true, 1972 .top_label = .{ .text = choices[initial].label }, 1973 .bottom_label = .{ .text = choices[initial].bottom_label }, 1974 .read_only = true, 1975 .render_content = session.is_terminal, 1976 .visible_width = null, 1977 }); 1978 errdefer text_input.deinit(allocator); 1979 text_input.getFocus().mode = .all; 1980 try text_input.setContent(allocator, choices[initial].text); 1981 box.getFocus().child_id = text_input.getFocus().id; 1982 try box.children.put(allocator, text_input.getFocus().id, .{ .widget = .{ .text_input = text_input }, .rect = null, .min_size = null, .flex = .shrink }); 1983 1984 return .{ .box = box, .session = session, .choices = owned_choices, .selected = initial }; 1985 } 1986 1987 pub fn initClone(allocator: std.mem.Allocator, session: *ui.Session, handle: ui.RepoHandle) !?CopyableText { 1988 const aa = session.page_arena.allocator(); 1989 var choices: [2]Choice = undefined; 1990 var count: usize = 0; 1991 var ssh_index: ?usize = null; 1992 switch (handle.location) { 1993 .repo => |identity| { 1994 if (session.data.git_http_port) |port| { 1995 const url = try aa.print("http://localhost:{d}/{s}", .{ port, identity }); 1996 choices[count] = .{ 1997 .selector = "http", 1998 .text = url, 1999 .copyable_text = try aa.print("git clone {s}", .{url}), 2000 .label = " clone ", 2001 }; 2002 count += 1; 2003 } 2004 if (session.data.git_ssh_port) |port| { 2005 ssh_index = count; 2006 const url = try aa.print("ssh://localhost:{d}/{s}", .{ port, identity }); 2007 choices[count] = .{ 2008 .selector = "ssh", 2009 .text = url, 2010 .copyable_text = try aa.print("{s}git clone {s}", .{ session.data.git_ssh_prefix, url }), 2011 .label = " clone ", 2012 }; 2013 count += 1; 2014 } 2015 }, 2016 .fork => |f| if (session.data.git_ssh_port) |port| { 2017 const url = try aa.print("ssh://localhost:{d}/{s}+{s}", .{ port, f.identity, f.id }); 2018 choices[count] = .{ 2019 .text = url, 2020 .copyable_text = try aa.print("{s}git clone {s}", .{ session.data.git_ssh_prefix, url }), 2021 .label = " clone ", 2022 }; 2023 count += 1; 2024 }, 2025 } 2026 if (count == 0) return null; 2027 // a viewer who can push starts on the ssh url 2028 const initial = if (handle.canWrite()) ssh_index orelse 0 else 0; 2029 return @as(?CopyableText, try init(allocator, session, choices[0..count], initial)); 2030 } 2031 2032 pub fn minWidth(self: *const CopyableText) usize { 2033 var width = maxWidth(self.choices) + 2; 2034 if (self.choices.len > 1) { 2035 for (self.choices) |choice| width += choice.selector.len + 2; 2036 } 2037 return width; 2038 } 2039 2040 pub fn deinit(self: *CopyableText, allocator: std.mem.Allocator) void { 2041 self.box.deinit(allocator); 2042 allocator.free(self.choices); 2043 } 2044 2045 pub fn build(self: *CopyableText, allocator: std.mem.Allocator, constraint: layout.Constraint, root_focus: *Focus) !void { 2046 self.clearGrid(); 2047 2048 if (self.choices.len > 1) { 2049 if (root_focus.grandchild_id) |id| { 2050 for (0..self.choices.len) |i| { 2051 if (id != self.selector(i).getFocus().id) continue; 2052 if (i != self.selected) try self.select(allocator, i); 2053 root_focus.setFocus(self.textInput().getFocus().id); 2054 break; 2055 } 2056 } 2057 2058 const focused = root_focus.grandchild_id == self.textInput().getFocus().id; 2059 for (0..self.choices.len) |i| { 2060 self.selector(i).options.border = if (i == self.selected) 2061 (if (focused) .double else .single) 2062 else 2063 .hidden; 2064 } 2065 } 2066 self.textInput().options.border = .single; 2067 self.textInput().cursor = 0; 2068 self.textInput().scroll_offset = 0; 2069 try self.box.build(allocator, constraint, root_focus); 2070 2071 if (!self.session.is_terminal) { 2072 const aa = self.session.arena.allocator(); 2073 const id = self.textInput().getFocus().id; 2074 try self.session.text_inputs.put(aa, id, self.textInput()); 2075 } 2076 } 2077 2078 pub fn input(self: *CopyableText, allocator: std.mem.Allocator, key: Key, root_focus: *Focus) !void { 2079 switch (key) { 2080 .arrow_left => if (self.selected > 0) try self.select(allocator, self.selected - 1), 2081 .arrow_right => if (self.selected + 1 < self.choices.len) try self.select(allocator, self.selected + 1), 2082 .enter => if (self.session.is_terminal) self.show(), 2083 .mouse => |mouse| { 2084 if (self.choices.len > 1) for (0..self.choices.len) |i| { 2085 if (!inp.leftClickOn(root_focus, self.selector(i).getFocus().id, mouse)) continue; 2086 try self.select(allocator, i); 2087 root_focus.setFocus(self.textInput().getFocus().id); 2088 return; 2089 }; 2090 if (self.session.is_terminal and !mouse.ctrl and inp.leftClickOn(root_focus, self.textInput().getFocus().id, mouse)) self.show(); 2091 }, 2092 else => {}, 2093 } 2094 } 2095 2096 fn select(self: *CopyableText, allocator: std.mem.Allocator, selected: usize) !void { 2097 self.selected = selected; 2098 const choice = self.choices[selected]; 2099 const text_input = self.textInput(); 2100 text_input.options.top_label.text = choice.label; 2101 text_input.options.bottom_label.text = choice.bottom_label; 2102 try text_input.setContent(allocator, choice.text); 2103 } 2104 2105 fn show(self: *CopyableText) void { 2106 const choice = self.choices[self.selected]; 2107 self.session.host_request = .{ .show_copyable_text = choice.copyable_text orelse choice.text }; 2108 } 2109 2110 fn textInput(self: *CopyableText) *wgt.TextInput { 2111 return &self.box.children.values()[if (self.choices.len > 1) self.choices.len else 0].widget.text_input; 2112 } 2113 2114 fn selector(self: *CopyableText, index: usize) *wgt.TextBox { 2115 return &self.box.children.values()[index].widget.text_box; 2116 } 2117 2118 fn maxWidth(choices: []const Choice) usize { 2119 var width: usize = 0; 2120 for (choices) |choice| width = @max(width, choice.text.len, choice.label.len, choice.bottom_label.len); 2121 return width; 2122 } 2123 2124 pub fn clearGrid(self: *CopyableText) void { 2125 self.box.clearGrid(); 2126 } 2127 2128 pub fn getGrid(self: CopyableText) ?Grid { 2129 return self.box.getGrid(); 2130 } 2131 2132 pub fn getFocus(self: *CopyableText) *Focus { 2133 return self.box.getFocus(); 2134 } 2135 }; 2136