refactor(Buffer): remove Plane dependency in Buffer
This commit is contained in:
parent
a3a298f721
commit
128182a448
7 changed files with 242 additions and 216 deletions
|
@ -4,6 +4,7 @@ const FontStyle = @import("theme").FontStyle;
|
|||
const StyleBits = @import("style.zig").StyleBits;
|
||||
const Cell = @import("Cell.zig");
|
||||
const vaxis = @import("vaxis");
|
||||
const Buffer = @import("Buffer");
|
||||
|
||||
const Plane = @This();
|
||||
|
||||
|
@ -364,6 +365,24 @@ pub fn egc_chunk_width(self: *const Plane, chunk_: []const u8, abs_col_: usize)
|
|||
return colcount;
|
||||
}
|
||||
|
||||
pub fn metrix(self: *const Plane) Buffer.Metrix {
|
||||
return .{
|
||||
.ctx = self,
|
||||
.egc_length = struct {
|
||||
fn f(ctx: *const anyopaque, egcs: []const u8, colcount: *c_int, abs_col: usize) usize {
|
||||
const self_: *const Plane = @ptrCast(@alignCast(ctx));
|
||||
return self_.egc_length(egcs, colcount, abs_col);
|
||||
}
|
||||
}.f,
|
||||
.egc_chunk_width = struct {
|
||||
fn f(ctx: *const anyopaque, chunk_: []const u8, abs_col_: usize) usize {
|
||||
const self_: *const Plane = @ptrCast(@alignCast(ctx));
|
||||
return self_.egc_chunk_width(chunk_, abs_col_);
|
||||
}
|
||||
}.f,
|
||||
};
|
||||
}
|
||||
|
||||
const GraphemeCache = struct {
|
||||
buf: [1024 * 16]u8 = undefined,
|
||||
idx: usize = 0,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue