mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
Merge pull request #1651 from aca/korean-esc
input: escape can be used to clear dead key state
This commit is contained in:
@ -254,10 +254,19 @@ fn legacy(
|
|||||||
self.ignore_keypad_with_numlock,
|
self.ignore_keypad_with_numlock,
|
||||||
self.modify_other_keys_state_2,
|
self.modify_other_keys_state_2,
|
||||||
)) |sequence| pc_style: {
|
)) |sequence| pc_style: {
|
||||||
// If we're pressing enter and have UTF-8 text, we probably are
|
// If we're pressing enter or escape and have UTF-8 text, we probably
|
||||||
// clearing a dead key state. This happens specifically on macOS.
|
// are clearing a dead key state. This happens specifically on macOS.
|
||||||
|
// "Clearing" a dead key state may or may not commit the dead key
|
||||||
|
// state; this differs by language:
|
||||||
|
//
|
||||||
|
// - Japanese clears and does not write the characters.
|
||||||
|
// - Korean clears and writes the characters.
|
||||||
|
//
|
||||||
// We have a unit test for this.
|
// We have a unit test for this.
|
||||||
if (self.event.key == .enter and self.event.utf8.len > 0) {
|
if ((self.event.key == .enter or
|
||||||
|
self.event.key == .escape) and
|
||||||
|
self.event.utf8.len > 0)
|
||||||
|
{
|
||||||
break :pc_style;
|
break :pc_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1649,6 +1658,20 @@ test "legacy: enter with utf8 (dead key state)" {
|
|||||||
try testing.expectEqualStrings("A", actual);
|
try testing.expectEqualStrings("A", actual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "legacy: esc with utf8 (dead key state)" {
|
||||||
|
var buf: [128]u8 = undefined;
|
||||||
|
var enc: KeyEncoder = .{
|
||||||
|
.event = .{
|
||||||
|
.key = .escape,
|
||||||
|
.utf8 = "A",
|
||||||
|
.unshifted_codepoint = 0x0D,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const actual = try enc.legacy(&buf);
|
||||||
|
try testing.expectEqualStrings("A", actual);
|
||||||
|
}
|
||||||
|
|
||||||
test "legacy: ctrl+shift+minus (underscore on US)" {
|
test "legacy: ctrl+shift+minus (underscore on US)" {
|
||||||
var buf: [128]u8 = undefined;
|
var buf: [128]u8 = undefined;
|
||||||
var enc: KeyEncoder = .{
|
var enc: KeyEncoder = .{
|
||||||
|
Reference in New Issue
Block a user