Replies: 5 comments 6 replies
-
|
Looks like when I updated diff --git a/src/widgets/TextView.zig b/src/widgets/TextView.zig
index f2f37330c0a9..125982c15947 100644
--- a/src/widgets/TextView.zig
+++ b/src/widgets/TextView.zig
@@ -1,6 +1,6 @@
const std = @import("std");
const vaxis = @import("../main.zig");
-const grapheme = @import("grapheme");
+const Graphemes = @import("Graphemes");
const DisplayWidth = @import("DisplayWidth");
const ScrollView = vaxis.widgets.ScrollView;
@@ -10,7 +10,7 @@ pub const BufferWriter = struct {
allocator: std.mem.Allocator,
buffer: *Buffer,
- gd: *const grapheme.GraphemeData,
+ gd: *const Graphemes,
wd: *const DisplayWidth.DisplayWidthData,
pub fn write(self: @This(), bytes: []const u8) Error!usize {
@@ -33,7 +33,7 @@ pub const Buffer = struct {
pub const Content = struct {
bytes: []const u8,
- gd: *const grapheme.GraphemeData,
+ gd: *const Graphemes,
wd: *const DisplayWidth.DisplayWidthData,
};
@@ -45,7 +45,7 @@ pub const Buffer = struct {
pub const Error = error{OutOfMemory};
- grapheme: std.MultiArrayList(grapheme.Grapheme) = .{},
+ grapheme: std.MultiArrayList(Graphemes.Grapheme) = .{},
content: std.ArrayListUnmanaged(u8) = .{},
style_list: StyleList = .{},
style_map: StyleMap = .{},
@@ -78,7 +78,7 @@ pub const Buffer = struct {
/// Appends content to the buffer.
pub fn append(self: *@This(), allocator: std.mem.Allocator, content: Content) Error!void {
var cols: usize = self.last_cols;
- var iter = grapheme.Iterator.init(content.bytes, content.gd);
+ var iter = Graphemes.Iterator.init(content.bytes, content.gd);
const dw: DisplayWidth = .{ .data = content.wd };
while (iter.next()) |g| {
try self.grapheme.append(allocator, .{
@@ -124,7 +124,7 @@ pub const Buffer = struct {
pub fn writer(
self: *@This(),
allocator: std.mem.Allocator,
- gd: *const grapheme.GraphemeData,
+ gd: *const Graphemes,
wd: *const DisplayWidth.DisplayWidthData,
) BufferWriter.Writer {
return .{ |
Beta Was this translation helpful? Give feedback.
-
|
Yee, this is the right direction. No I get: It looks like zg no longer has DisplayWidthData definition. PS. Using this opportunity, I would like to thank you for this amazing project. It made my life so much easier. |
Beta Was this translation helpful? Give feedback.
-
Thanks! Glad it's working for you. I pushed a fix on |
Beta Was this translation helpful? Give feedback.
-
|
Following my original goal of creating such a log history. My current code works fine, but is there any simpler way eg. are g and w values initialized somewhere inside of libvaxis and I could reuse them. I'm not used to zg, so I still don't fully know what Graphemes and DisplayWidth truly are - this is why I might be misunderstanding something. |
Beta Was this translation helpful? Give feedback.
-
|
Thx for your help. Now I have a working thing. The code below is a mess, but I will put it in case I forget about it. ...
var logBuffer: vaxis.widgets.TextView.Buffer = .{};
var alloc: std.mem.Allocator = undefined;
pub const std_options: std.Options = .{
.logFn = myLogFn,
};
pub fn myLogFn(
comptime _: std.log.Level,
comptime _: @TypeOf(.EnumLiteral),
comptime format: []const u8,
args: anytype,
) void {
const g = vaxis.Graphemes.init(alloc) catch @panic("Log: Out of memory");
const w = vaxis.DisplayWidth.init(alloc) catch @panic("Log: Out of memory");
var list = std.ArrayList(u8).init(alloc);
std.fmt.format(list.writer(), format ++ "\n", args) catch @panic("Log: couldn't format");
const str: []const u8 = list.toOwnedSlice() catch @panic("Log: Out of memory");
logBuffer.append(alloc, .{
.bytes = str,
.gd = &g,
.wd = &w,
}) catch @panic("Log: Out of memory");
}
... |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to create a scrollable text list of past log messages.
Not counting the lack of example usage of this struct - my only issue is that when I try to use this struct I get an error while sompiling...
Is it an issue with my build.zig or is it something else?
Beta Was this translation helpful? Give feedback.
All reactions