add cut/copy/paste keys

The origin of these keys are old sun keyboards.
They are getting picked up by the custom (progammable) keyboard scene
(see https://github.com/manna-harbour/miryoku for a popular layout).
Support in ghosty is quite handy because it allows to bind copy/paste in
a way that doesn't overlap with ctrl-c/ctrl-v, which can have special
bindings in some terminal applications.
pull/7430/head
Jörg Thalheim 2025-05-24 00:29:53 +02:00
parent 26a42fac0e
commit a8651882a7
4 changed files with 20 additions and 0 deletions

View File

@ -292,6 +292,11 @@ typedef enum {
GHOSTTY_KEY_AUDIO_VOLUME_MUTE,
GHOSTTY_KEY_AUDIO_VOLUME_UP,
GHOSTTY_KEY_WAKE_UP,
// "Legacy, Non-standard, and Special Keys" § 3.7
GHOSTTY_KEY_COPY,
GHOSTTY_KEY_CUT,
GHOSTTY_KEY_PASTE,
} ghostty_input_key_e;
typedef struct {

View File

@ -388,6 +388,10 @@ const keymap: []const RawEntry = &.{
.{ gdk.KEY_KP_Delete, .numpad_delete },
.{ gdk.KEY_KP_Begin, .numpad_begin },
.{ gdk.KEY_Copy, .copy },
.{ gdk.KEY_Cut, .cut },
.{ gdk.KEY_Paste, .paste },
.{ gdk.KEY_Shift_L, .shift_left },
.{ gdk.KEY_Control_L, .control_left },
.{ gdk.KEY_Alt_L, .alt_left },

View File

@ -454,6 +454,11 @@ pub const Key = enum(c_int) {
audio_volume_up,
wake_up,
// "Legacy, Non-standard, and Special Keys" § 3.7
copy,
cut,
paste,
/// Converts an ASCII character to a key, if possible. This returns
/// null if the character is unknown.
///
@ -797,6 +802,9 @@ pub const Key = enum(c_int) {
.audio_volume_up,
.wake_up,
.help,
.copy,
.cut,
.paste,
=> null,
.unidentified,

View File

@ -130,6 +130,9 @@ const code_to_key = code_to_key: {
.{ "PageUp", .page_up },
.{ "Delete", .delete },
.{ "End", .end },
.{ "Copy", .copy },
.{ "Cut", .cut },
.{ "Paste", .paste },
.{ "PageDown", .page_down },
.{ "ArrowRight", .arrow_right },
.{ "ArrowLeft", .arrow_left },