macos: hook up text input

This commit is contained in:
Mitchell Hashimoto
2023-02-18 11:08:54 -08:00
parent 4b44b2bc95
commit 7a368da099
4 changed files with 230 additions and 9 deletions

View File

@@ -427,4 +427,9 @@ pub const CAPI = struct {
@bitCast(input.Mods, @truncate(u8, @bitCast(c_uint, mods))),
);
}
/// Tell the surface that it needs to schedule a render
export fn ghostty_surface_char(win: *Window, codepoint: u32) void {
win.window.charCallback(codepoint);
}
};

View File

@@ -151,9 +151,18 @@ pub const Window = struct {
key: input.Key,
mods: input.Mods,
) void {
// log.warn("key action={} key={} mods={}", .{ action, key, mods });
self.core_win.keyCallback(action, key, mods) catch |err| {
log.err("error in key callback err={}", .{err});
return;
};
}
pub fn charCallback(self: *const Window, cp_: u32) void {
const cp = std.math.cast(u21, cp_) orelse return;
self.core_win.charCallback(cp) catch |err| {
log.err("error in char callback err={}", .{err});
return;
};
}
};