Merge branch 'master' into wio-sokol-gui

This commit is contained in:
CJ van den Berg 2026-04-12 20:07:40 +02:00
commit 02b62fa91c
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 19 additions and 11 deletions

View file

@ -6,8 +6,8 @@
.dependencies = .{ .dependencies = .{
.syntax = .{ .syntax = .{
.url = "git+https://github.com/neurocyte/flow-syntax?ref=master#7b1fd3a97f00aba3a95cc65b95f34162347ed1ea", .url = "git+https://github.com/neurocyte/flow-syntax?ref=zig-0.15#5bc4bcba1552a597d1a6a1f3bf8433ba710b6a90",
.hash = "flow_syntax-0.7.2-X8jOoQhWAQBPt1rBRmttAGI0Z2QC-hCSZuoBZoZgr6Vv", .hash = "flow_syntax-0.7.2-X8jOoaFbAQBEZWaLbtlj9C8N4zRkNSG2Nq_T40pXRypr",
}, },
.flags = .{ .flags = .{
.url = "git+https://github.com/neurocyte/flags?ref=main#984b27948da3e4e40a253f76c85b51ec1a9ada11", .url = "git+https://github.com/neurocyte/flags?ref=main#984b27948da3e4e40a253f76c85b51ec1a9ada11",

View file

@ -172,6 +172,10 @@ pub fn ucs32_to_utf8(ucs32: []const u32, utf8: []u8) error{ Utf8CannotEncodeSurr
return @intCast(try unicode.utf8Encode(@intCast(ucs32[0]), utf8)); return @intCast(try unicode.utf8Encode(@intCast(ucs32[0]), utf8));
} }
pub fn ucs32_to_utf8_scalar(ucs32: u32, utf8: []u8) error{ Utf8CannotEncodeSurrogateHalf, CodepointTooLarge }!usize {
return @intCast(try unicode.utf8Encode(@intCast(ucs32), utf8));
}
pub const utils = struct { pub const utils = struct {
pub fn key_id_string(k: Key) []const u8 { pub fn key_id_string(k: Key) []const u8 {
return switch (k) { return switch (k) {

View file

@ -429,20 +429,24 @@ fn handle_bracketed_paste_input(self: *Self, cbor_msg: []const u8) !bool {
var keypress: input.Key = undefined; var keypress: input.Key = undefined;
var egc_: input.Key = undefined; var egc_: input.Key = undefined;
var mods: usize = undefined; var mods: usize = undefined;
var text: []const u8 = undefined;
const writer = &self.bracketed_paste_buffer.writer; const writer = &self.bracketed_paste_buffer.writer;
if (try cbor.match(cbor_msg, .{ "I", cbor.number, cbor.extract(&keypress), cbor.extract(&egc_), cbor.string, cbor.extract(&mods) })) { if (try cbor.match(cbor_msg, .{ "I", cbor.number, cbor.extract(&keypress), cbor.extract(&egc_), cbor.extract(&text), cbor.extract(&mods) })) {
switch (keypress) { switch (keypress) {
106 => if (mods == 4) try writer.writeAll("\n") else try writer.writeAll("j"), 106 => if (mods == 4) try writer.writeAll("\n") else try writer.writeAll("j"),
input.key.enter => try writer.writeAll("\n"), input.key.enter => try writer.writeAll("\n"),
input.key.tab => try writer.writeAll("\t"), input.key.tab => try writer.writeAll("\t"),
else => if (!input.is_non_input_key(keypress)) { else => {
var buf: [6]u8 = undefined; if (keypress == vaxis.Key.multicodepoint) {
const bytes = try input.ucs32_to_utf8(&[_]u32{egc_}, &buf); try writer.writeAll(text);
try writer.writeAll(buf[0..bytes]); } else if (!input.is_non_input_key(keypress)) {
} else { var buf: [6]u8 = undefined;
var buf: [6]u8 = undefined; const bytes = try input.ucs32_to_utf8_scalar(egc_, &buf);
const bytes = try input.ucs32_to_utf8(&[_]u32{egc_}, &buf); try writer.writeAll(buf[0..bytes]);
self.logger.print("unexpected codepoint in paste: {d} {s}", .{ keypress, buf[0..bytes] }); } else {
var buf: [1024]u8 = undefined;
self.logger.print("unexpected codepoint in paste event: {s}", .{cbor.toJson(cbor_msg, &buf) catch "cbor.toJson failed"});
}
}, },
} }
return true; return true;