mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
allow non-printables even if modifiers are pressed
This commit is contained in:
@ -669,18 +669,14 @@ fn keyCallback(
|
||||
}
|
||||
|
||||
// Handle non-printables
|
||||
const char: u8 = switch (@bitCast(u8, mods)) {
|
||||
// No modifiers pressed at all
|
||||
0 => @as(u8, switch (key) {
|
||||
.backspace => 0x7F,
|
||||
.enter => '\r',
|
||||
.tab => '\t',
|
||||
.escape => 0x1B,
|
||||
else => 0,
|
||||
}),
|
||||
const char: u8 = char: {
|
||||
const mods_int = @bitCast(u8, mods);
|
||||
const ctrl_only = @bitCast(u8, glfw.Mods{ .control = true });
|
||||
|
||||
// Control only
|
||||
@bitCast(u8, glfw.Mods{ .control = true }) => @as(u8, switch (key) {
|
||||
// If we're only pressing control, check if this is a character
|
||||
// we convert to a non-printable.
|
||||
if (mods_int == ctrl_only) {
|
||||
const val: u8 = switch (key) {
|
||||
.a => 0x01,
|
||||
.b => 0x02,
|
||||
.c => 0x03,
|
||||
@ -708,9 +704,19 @@ fn keyCallback(
|
||||
.y => 0x19,
|
||||
.z => 0x1A,
|
||||
else => 0,
|
||||
}),
|
||||
};
|
||||
|
||||
if (val > 0) break :char val;
|
||||
}
|
||||
|
||||
// Otherwise, we don't care what modifiers we press we do this.
|
||||
break :char @as(u8, switch (key) {
|
||||
.backspace => 0x7F,
|
||||
.enter => '\r',
|
||||
.tab => '\t',
|
||||
.escape => 0x1B,
|
||||
else => 0,
|
||||
});
|
||||
};
|
||||
if (char > 0) {
|
||||
win.queueWrite(&[1]u8{char}) catch |err|
|
||||
|
Reference in New Issue
Block a user