diff --git a/build.zig.zon b/build.zig.zon index 25ebca8..bb542c5 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -30,8 +30,8 @@ .hash = "fuzzig-0.1.1-Ji0xivxIAQBD0g8O_NV_0foqoPf3elsg9Sc3pNfdVH4D", }, .vaxis = .{ - .url = "git+https://github.com/neurocyte/libvaxis?ref=main#164dfadbad9a5df529ade8e3f0e5c52939d27e81", - .hash = "vaxis-0.5.1-BWNV_M4yCQBLJYI9ooJL-8dstYnId58coiBeHhF4m9wz", + .url = "git+https://github.com/neurocyte/libvaxis?ref=main#035457cdb54f4c12caae6638b837c447447ae70d", + .hash = "vaxis-0.5.1-BWNV_NAyCQBgEcQ3hBKEqyWOJh4uDSm4mPvffsI10J5i", }, .zeit = .{ .url = "git+https://github.com/rockorager/zeit?ref=zig-0.15#ed2ca60db118414bda2b12df2039e33bad3b0b88", diff --git a/src/renderer/vaxis/GraphemeCache.zig b/src/renderer/vaxis/GraphemeCache.zig deleted file mode 100644 index b47e9b6..0000000 --- a/src/renderer/vaxis/GraphemeCache.zig +++ /dev/null @@ -1,23 +0,0 @@ -storage: *Storage, - -pub const GraphemeCache = @This(); - -pub inline fn put(self: *@This(), bytes: []const u8) []u8 { - return self.storage.put(bytes); -} - -pub const Storage = struct { - buf: [1024 * 512]u8 = undefined, - idx: usize = 0, - - pub fn put(self: *@This(), bytes: []const u8) []u8 { - if (self.idx + bytes.len > self.buf.len) self.idx = 0; - defer self.idx += bytes.len; - @memcpy(self.buf[self.idx .. self.idx + bytes.len], bytes); - return self.buf[self.idx .. self.idx + bytes.len]; - } - - pub fn cache(self: *@This()) GraphemeCache { - return .{ .storage = self }; - } -}; diff --git a/src/renderer/vaxis/Layer.zig b/src/renderer/vaxis/Layer.zig index 7dd4e95..50831c8 100644 --- a/src/renderer/vaxis/Layer.zig +++ b/src/renderer/vaxis/Layer.zig @@ -2,7 +2,6 @@ const std = @import("std"); const vaxis = @import("vaxis"); pub const Plane = @import("Plane.zig"); -const GraphemeCache = @import("GraphemeCache.zig"); const Layer = @This(); @@ -14,7 +13,6 @@ plane_: Plane, const View = struct { allocator: std.mem.Allocator, screen: vaxis.Screen, - cache_storage: GraphemeCache.Storage = .{}, pub const Config = struct { h: u16, @@ -59,7 +57,6 @@ pub fn init(allocator: std.mem.Allocator, opts: Options) std.mem.Allocator.Error const name = "layer"; self.plane_ = .{ .window = self.window(), - .cache = self.view.cache_storage.cache(), .name_buf = undefined, .name_len = name.len, }; diff --git a/src/renderer/vaxis/Plane.zig b/src/renderer/vaxis/Plane.zig index 8ff6943..b59b1f6 100644 --- a/src/renderer/vaxis/Plane.zig +++ b/src/renderer/vaxis/Plane.zig @@ -8,7 +8,6 @@ const vaxis = @import("vaxis"); const Buffer = @import("Buffer"); const color = @import("color"); const RGB = @import("color").RGB; -const GraphemeCache = @import("GraphemeCache.zig"); const Plane = @This(); @@ -19,7 +18,7 @@ row: i32 = 0, col: i32 = 0, name_buf: [name_buf_len]u8, name_len: usize, -cache: GraphemeCache, +cache: GraphemeCache = .{}, style: vaxis.Cell.Style = .{}, style_base: vaxis.Cell.Style = .{}, scrolling: bool = false, @@ -50,7 +49,6 @@ pub fn init(nopts: *const Options, parent_: Plane) !Plane { const len = @min(nopts.name.len, name_buf_len); var plane: Plane = .{ .window = parent_.window.child(opts), - .cache = parent_.cache, .name_buf = undefined, .name_len = len, .scrolling = nopts.flags == .VSCROLL, @@ -502,6 +500,18 @@ pub fn metrics(self: *const Plane, tab_width: usize) Buffer.Metrics { }; } +const GraphemeCache = struct { + buf: [1024 * 16]u8 = undefined, + idx: usize = 0, + + pub fn put(self: *GraphemeCache, bytes: []const u8) []u8 { + if (self.idx + bytes.len > self.buf.len) self.idx = 0; + defer self.idx += bytes.len; + @memcpy(self.buf[self.idx .. self.idx + bytes.len], bytes); + return self.buf[self.idx .. self.idx + bytes.len]; + } +}; + fn to_cell_color(col: ThemeColor) vaxis.Cell.Color { return .{ .rgb = RGB.to_u8s(RGB.from_u24(col.color)) }; } diff --git a/src/renderer/vaxis/renderer.zig b/src/renderer/vaxis/renderer.zig index 78524c2..5f6376c 100644 --- a/src/renderer/vaxis/renderer.zig +++ b/src/renderer/vaxis/renderer.zig @@ -16,7 +16,6 @@ pub const CursorShape = vaxis.Cell.CursorShape; pub const style = @import("style.zig").StyleBits; pub const styles = @import("style.zig"); -const GraphemeCache = @import("GraphemeCache.zig"); const Self = @This(); pub const log_name = "vaxis"; @@ -26,7 +25,6 @@ allocator: std.mem.Allocator, tty: vaxis.Tty, vx: vaxis.Vaxis, tty_buffer: []u8, -cache_storage: GraphemeCache.Storage = .{}, no_alternate: bool, event_buffer: std.Io.Writer.Allocating, @@ -242,7 +240,6 @@ pub fn stdplane(self: *Self) Plane { const name = "root"; var plane: Plane = .{ .window = self.vx.window(), - .cache = self.cache_storage.cache(), .name_buf = undefined, .name_len = name.len, };