this repo has no description
13
fork

Configure Feed

Select the types of activity you want to include in your feed.

TextView: add Error to buffer operations

Typed error sets are nice to have.

authored by

Jari Vetoniemi and committed by
Tim Culverhouse
54def846 71b8ecc7

+5 -3
+5 -3
src/widgets/TextView.zig
··· 43 43 style: vaxis.Style, 44 44 }; 45 45 46 + pub const Error = error{OutOfMemory}; 47 + 46 48 grapheme: std.MultiArrayList(grapheme.Grapheme) = .{}, 47 49 content: std.ArrayListUnmanaged(u8) = .{}, 48 50 style_list: StyleList = .{}, ··· 67 69 } 68 70 69 71 /// Replaces contents of the buffer, all previous buffer data is lost. 70 - pub fn update(self: *@This(), allocator: std.mem.Allocator, content: Content) !void { 72 + pub fn update(self: *@This(), allocator: std.mem.Allocator, content: Content) Error!void { 71 73 self.clear(allocator); 72 74 errdefer self.clear(allocator); 73 75 try self.append(allocator, content); 74 76 } 75 77 76 78 /// Appends content to the buffer. 77 - pub fn append(self: *@This(), allocator: std.mem.Allocator, content: Content) !void { 79 + pub fn append(self: *@This(), allocator: std.mem.Allocator, content: Content) Error!void { 78 80 var cols: usize = self.last_cols; 79 81 var iter = grapheme.Iterator.init(content.bytes, content.gd); 80 82 const dw: DisplayWidth = .{ .data = content.wd }; ··· 104 106 } 105 107 106 108 /// Update style for range of the buffer contents. 107 - pub fn updateStyle(self: *@This(), allocator: std.mem.Allocator, style: Style) !void { 109 + pub fn updateStyle(self: *@This(), allocator: std.mem.Allocator, style: Style) Error!void { 108 110 const style_index = blk: { 109 111 for (self.style_list.items, 0..) |s, i| { 110 112 if (std.meta.eql(s, style.style)) {