From a18ba77eb447e7c082f7d11504f21917871f4ac3 Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Sun, 4 May 2025 18:37:58 -0400 Subject: Make DisplayWidth.setup public Also adds setupWithGraphemes variant. --- src/DisplayWidth.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/DisplayWidth.zig') diff --git a/src/DisplayWidth.zig b/src/DisplayWidth.zig index 4c63be4..3da2d24 100644 --- a/src/DisplayWidth.zig +++ b/src/DisplayWidth.zig @@ -31,8 +31,14 @@ pub fn initWithGraphemes(allocator: Allocator, graphemes: Graphemes) Allocator.E return dw; } +pub fn setupWithGraphemes(dw: *DisplayWidth, allocator: Allocator, graphemes: Graphemes) Allocator.Error!void { + try dw.setup(allocator); + dw.graphemes = graphemes; + dw.owns_graphemes = false; +} + // Sets up the DisplayWidthData, leaving the GraphemeData undefined. -fn setup(dw: *DisplayWidth, allocator: Allocator) Allocator.Error!void { +pub fn setup(dw: *DisplayWidth, allocator: Allocator) Allocator.Error!void { const decompressor = compress.flate.inflate.decompressor; const in_bytes = @embedFile("dwp"); var in_fbs = std.io.fixedBufferStream(in_bytes); -- cgit v1.2.3