mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
modify keys state 2 depends on some scenarios
Trying to port xterms logic...
This commit is contained in:
@ -1037,23 +1037,47 @@ pub fn charCallback(
|
|||||||
// for any char with a modifier. Ctrl sequences like Ctrl+A
|
// for any char with a modifier. Ctrl sequences like Ctrl+A
|
||||||
// are handled in keyCallback and should never have reached this
|
// are handled in keyCallback and should never have reached this
|
||||||
// point.
|
// point.
|
||||||
if (critical.modify_other_keys and !mods.empty()) {
|
if (critical.modify_other_keys) {
|
||||||
for (input.function_keys.modifiers, 2..) |modset, code| {
|
// This copies xterm's `ModifyOtherKeys` function that returns
|
||||||
if (!mods.equal(modset)) continue;
|
// whether modify other keys should be encoded for the given
|
||||||
|
// input.
|
||||||
|
const should_modify = should_modify: {
|
||||||
|
// xterm IsControlInput
|
||||||
|
if (codepoint >= 0x40 and codepoint <= 0x7F)
|
||||||
|
break :should_modify true;
|
||||||
|
|
||||||
const resp = try std.fmt.bufPrint(
|
// If we have anything other than shift pressed, encode.
|
||||||
&data,
|
var mods_no_shift = mods;
|
||||||
"\x1B[27;{};{}~",
|
mods_no_shift.shift = false;
|
||||||
.{ code, codepoint },
|
if (!mods_no_shift.empty()) break :should_modify true;
|
||||||
);
|
|
||||||
_ = self.io_thread.mailbox.push(.{
|
// We only have shift pressed. We only allow space.
|
||||||
.write_small = .{
|
if (codepoint == ' ') break :should_modify true;
|
||||||
.data = data,
|
|
||||||
.len = @intCast(resp.len),
|
// This logic isn't complete but I don't fully understand
|
||||||
},
|
// the rest so I'm going to wait until we can have a
|
||||||
}, .{ .forever = {} });
|
// reasonable test scenario.
|
||||||
try self.io_thread.wakeup.notify();
|
break :should_modify false;
|
||||||
return;
|
};
|
||||||
|
|
||||||
|
if (should_modify) {
|
||||||
|
for (input.function_keys.modifiers, 2..) |modset, code| {
|
||||||
|
if (!mods.equal(modset)) continue;
|
||||||
|
|
||||||
|
const resp = try std.fmt.bufPrint(
|
||||||
|
&data,
|
||||||
|
"\x1B[27;{};{}~",
|
||||||
|
.{ code, codepoint },
|
||||||
|
);
|
||||||
|
_ = self.io_thread.mailbox.push(.{
|
||||||
|
.write_small = .{
|
||||||
|
.data = data,
|
||||||
|
.len = @intCast(resp.len),
|
||||||
|
},
|
||||||
|
}, .{ .forever = {} });
|
||||||
|
try self.io_thread.wakeup.notify();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user