mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
modify keys state 2 depends on some scenarios
Trying to port xterms logic...
This commit is contained in:
@ -1037,7 +1037,30 @@ 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) {
|
||||||
|
// This copies xterm's `ModifyOtherKeys` function that returns
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// If we have anything other than shift pressed, encode.
|
||||||
|
var mods_no_shift = mods;
|
||||||
|
mods_no_shift.shift = false;
|
||||||
|
if (!mods_no_shift.empty()) break :should_modify true;
|
||||||
|
|
||||||
|
// We only have shift pressed. We only allow space.
|
||||||
|
if (codepoint == ' ') break :should_modify true;
|
||||||
|
|
||||||
|
// This logic isn't complete but I don't fully understand
|
||||||
|
// the rest so I'm going to wait until we can have a
|
||||||
|
// reasonable test scenario.
|
||||||
|
break :should_modify false;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (should_modify) {
|
||||||
for (input.function_keys.modifiers, 2..) |modset, code| {
|
for (input.function_keys.modifiers, 2..) |modset, code| {
|
||||||
if (!mods.equal(modset)) continue;
|
if (!mods.equal(modset)) continue;
|
||||||
|
|
||||||
@ -1056,6 +1079,7 @@ pub fn charCallback(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Prefix our data with ESC if we have alt pressed.
|
// Prefix our data with ESC if we have alt pressed.
|
||||||
var i: u8 = 0;
|
var i: u8 = 0;
|
||||||
|
Reference in New Issue
Block a user