mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
core: textCallback to send text directly to the terminal
This commit is contained in:
@ -1020,6 +1020,15 @@ pub fn keyCallback(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sends text as-is to the terminal without triggering any keyboard
|
||||||
|
/// protocol. This will treat the input text as if it was pasted
|
||||||
|
/// from the clipboard so the same logic will be applied. Namely,
|
||||||
|
/// if bracketed mode is on this will do a bracketed paste. Otherwise,
|
||||||
|
/// this will filter newlines to '\r'.
|
||||||
|
pub fn textCallback(self: *Surface, text: []const u8) !void {
|
||||||
|
try self.completeClipboardPaste(text);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn focusCallback(self: *Surface, focused: bool) !void {
|
pub fn focusCallback(self: *Surface, focused: bool) !void {
|
||||||
// Notify our render thread of the new state
|
// Notify our render thread of the new state
|
||||||
_ = self.renderer_thread.mailbox.push(.{
|
_ = self.renderer_thread.mailbox.push(.{
|
||||||
|
@ -686,19 +686,7 @@ pub const Surface = struct {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// For a char callback we just construct a key event with invalid
|
_ = self.core_surface.textCallback(buf[0..len]) catch |err| {
|
||||||
// keys but with text. This should result in the text being sent
|
|
||||||
// as-is.
|
|
||||||
_ = self.core_surface.keyCallback(.{
|
|
||||||
.action = .press,
|
|
||||||
.key = .invalid,
|
|
||||||
.physical_key = .invalid,
|
|
||||||
.mods = .{},
|
|
||||||
.consumed_mods = .{},
|
|
||||||
.composing = false,
|
|
||||||
.utf8 = buf[0..len],
|
|
||||||
.unshifted_codepoint = 0,
|
|
||||||
}) catch |err| {
|
|
||||||
log.err("error in key callback err={}", .{err});
|
log.err("error in key callback err={}", .{err});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user