mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
apprt/embedded: ghostty_surface_text function, remove _char
This commit is contained in:
@ -388,7 +388,7 @@ void ghostty_surface_set_content_scale(ghostty_surface_t, double, double);
|
||||
void ghostty_surface_set_focus(ghostty_surface_t, bool);
|
||||
void ghostty_surface_set_size(ghostty_surface_t, uint32_t, uint32_t);
|
||||
void ghostty_surface_key(ghostty_surface_t, ghostty_input_action_e, uint32_t, ghostty_input_mods_e);
|
||||
void ghostty_surface_char(ghostty_surface_t, uint32_t);
|
||||
void ghostty_surface_text(ghostty_surface_t, const char *, uintptr_t);
|
||||
void ghostty_surface_mouse_button(ghostty_surface_t, ghostty_input_mouse_state_e, ghostty_input_mouse_button_e, ghostty_input_mods_e);
|
||||
void ghostty_surface_mouse_pos(ghostty_surface_t, double, double);
|
||||
void ghostty_surface_mouse_scroll(ghostty_surface_t, double, double, ghostty_input_scroll_mods_t);
|
||||
|
@ -836,8 +836,9 @@ extension Ghostty {
|
||||
return
|
||||
}
|
||||
|
||||
for codepoint in chars.unicodeScalars {
|
||||
ghostty_surface_char(surface, codepoint.value)
|
||||
let len = chars.utf8CString.count
|
||||
chars.withCString { ptr in
|
||||
ghostty_surface_text(surface, ptr, UInt(len))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -678,15 +678,8 @@ pub const Surface = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn charCallback(self: *Surface, cp_: u32) void {
|
||||
const cp = std.math.cast(u21, cp_) orelse return;
|
||||
var buf: [4]u8 = undefined;
|
||||
const len = std.unicode.utf8Encode(cp, &buf) catch |err| {
|
||||
log.err("error encoding codepoint={} err={}", .{ cp, err });
|
||||
return;
|
||||
};
|
||||
|
||||
_ = self.core_surface.textCallback(buf[0..len]) catch |err| {
|
||||
pub fn textCallback(self: *Surface, text: []const u8) void {
|
||||
_ = self.core_surface.textCallback(text) catch |err| {
|
||||
log.err("error in key callback err={}", .{err});
|
||||
return;
|
||||
};
|
||||
@ -946,11 +939,15 @@ pub const CAPI = struct {
|
||||
};
|
||||
}
|
||||
|
||||
/// Send for a unicode character. This is used for IME input. This
|
||||
/// should only be sent for characters that are not the result of
|
||||
/// key events.
|
||||
export fn ghostty_surface_char(surface: *Surface, codepoint: u32) void {
|
||||
surface.charCallback(codepoint);
|
||||
/// Send raw text to the terminal. This is treated like a paste
|
||||
/// so this isn't useful for sending escape sequences. For that,
|
||||
/// individual key input should be used.
|
||||
export fn ghostty_surface_text(
|
||||
surface: *Surface,
|
||||
ptr: [*]const u8,
|
||||
len: usize,
|
||||
) void {
|
||||
surface.textCallback(ptr[0..len]);
|
||||
}
|
||||
|
||||
/// Tell the surface that it needs to schedule a render
|
||||
|
Reference in New Issue
Block a user