Compare commits

...

3 commits

3 changed files with 19 additions and 11 deletions

View file

@ -6,8 +6,8 @@
.dependencies = .{
.syntax = .{
.url = "git+https://github.com/neurocyte/flow-syntax?ref=master#7b1fd3a97f00aba3a95cc65b95f34162347ed1ea",
.hash = "flow_syntax-0.7.2-X8jOoQhWAQBPt1rBRmttAGI0Z2QC-hCSZuoBZoZgr6Vv",
.url = "git+https://github.com/neurocyte/flow-syntax?ref=zig-0.15#5bc4bcba1552a597d1a6a1f3bf8433ba710b6a90",
.hash = "flow_syntax-0.7.2-X8jOoaFbAQBEZWaLbtlj9C8N4zRkNSG2Nq_T40pXRypr",
},
.flags = .{
.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));
}
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 fn key_id_string(k: Key) []const u8 {
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 egc_: input.Key = undefined;
var mods: usize = undefined;
var text: []const u8 = undefined;
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) {
106 => if (mods == 4) try writer.writeAll("\n") else try writer.writeAll("j"),
input.key.enter => try writer.writeAll("\n"),
input.key.tab => try writer.writeAll("\t"),
else => if (!input.is_non_input_key(keypress)) {
else => {
if (keypress == vaxis.Key.multicodepoint) {
try writer.writeAll(text);
} else if (!input.is_non_input_key(keypress)) {
var buf: [6]u8 = undefined;
const bytes = try input.ucs32_to_utf8(&[_]u32{egc_}, &buf);
const bytes = try input.ucs32_to_utf8_scalar(egc_, &buf);
try writer.writeAll(buf[0..bytes]);
} else {
var buf: [6]u8 = undefined;
const bytes = try input.ucs32_to_utf8(&[_]u32{egc_}, &buf);
self.logger.print("unexpected codepoint in paste: {d} {s}", .{ keypress, buf[0..bytes] });
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;