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