fix: unicode input in mini modes and palettes

closes: #81
This commit is contained in:
CJ van den Berg 2024-12-17 18:35:47 +01:00
parent e17345eff7
commit ff0987c108
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
8 changed files with 37 additions and 22 deletions

View file

@ -432,6 +432,13 @@ pub fn egc_chunk_width(self: *const Plane, chunk_: []const u8, abs_col_: usize,
return colcount;
}
pub fn egc_last(self: *const Plane, egcs: []const u8) []const u8 {
var iter = self.window.screen.unicode.graphemeIterator(egcs);
var last: []const u8 = egcs[0..0];
while (iter.next()) |grapheme| last = grapheme.bytes(egcs);
return last;
}
pub fn metrics(self: *const Plane, tab_width: usize) Buffer.Metrics {
return .{
.ctx = self,
@ -448,6 +455,12 @@ pub fn metrics(self: *const Plane, tab_width: usize) Buffer.Metrics {
}
}.f,
.tab_width = tab_width,
.egc_last = struct {
fn f(self_: Buffer.Metrics, egcs: []const u8) []const u8 {
const plane: *const Plane = @ptrCast(@alignCast(self_.ctx));
return plane.egc_last(egcs);
}
}.f,
};
}