fix(gui): map keys to vaxis Key constants
This commit is contained in:
parent
c353c92bc3
commit
875c42ad9e
1 changed files with 47 additions and 46 deletions
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
const std = @import("std");
|
||||
const wio = @import("wio");
|
||||
const vaxis = @import("vaxis");
|
||||
|
||||
// Modifiers bitmask (matches vaxis.Key.Modifiers packed struct layout used
|
||||
// by the rest of Flow's input handling).
|
||||
|
|
@ -95,11 +96,11 @@ pub fn codepointFromButton(b: wio.Button, mods: Mods) u21 {
|
|||
.@"7" => if (mods.shiftOnly()) '&' else '7',
|
||||
.@"8" => if (mods.shiftOnly()) '*' else '8',
|
||||
.@"9" => if (mods.shiftOnly()) '(' else '9',
|
||||
.space => ' ',
|
||||
.enter => '\r',
|
||||
.tab => '\t',
|
||||
.backspace => 0x7f,
|
||||
.escape => 0x1b,
|
||||
.space => vaxis.Key.space,
|
||||
.enter => vaxis.Key.enter,
|
||||
.tab => vaxis.Key.tab,
|
||||
.backspace => vaxis.Key.backspace,
|
||||
.escape => vaxis.Key.escape,
|
||||
.minus => if (mods.shiftOnly()) '_' else '-',
|
||||
.equals => if (mods.shiftOnly()) '+' else '=',
|
||||
.left_bracket => if (mods.shiftOnly()) '{' else '[',
|
||||
|
|
@ -111,47 +112,47 @@ pub fn codepointFromButton(b: wio.Button, mods: Mods) u21 {
|
|||
.comma => if (mods.shiftOnly()) '<' else ',',
|
||||
.dot => if (mods.shiftOnly()) '>' else '.',
|
||||
.slash => if (mods.shiftOnly()) '?' else '/',
|
||||
// Navigation keys map to special Unicode private-use codepoints
|
||||
// that Flow's input layer understands (matching kitty protocol).
|
||||
.up => 0xF700,
|
||||
.down => 0xF701,
|
||||
.left => 0xF702,
|
||||
.right => 0xF703,
|
||||
.home => 0xF704,
|
||||
.end => 0xF705,
|
||||
.page_up => 0xF706,
|
||||
.page_down => 0xF707,
|
||||
.insert => 0xF708,
|
||||
.delete => 0xF709,
|
||||
.f1 => 0xF710,
|
||||
.f2 => 0xF711,
|
||||
.f3 => 0xF712,
|
||||
.f4 => 0xF713,
|
||||
.f5 => 0xF714,
|
||||
.f6 => 0xF715,
|
||||
.f7 => 0xF716,
|
||||
.f8 => 0xF717,
|
||||
.f9 => 0xF718,
|
||||
.f10 => 0xF719,
|
||||
.f11 => 0xF71A,
|
||||
.f12 => 0xF71B,
|
||||
.kp_0 => '0',
|
||||
.kp_1 => '1',
|
||||
.kp_2 => '2',
|
||||
.kp_3 => '3',
|
||||
.kp_4 => '4',
|
||||
.kp_5 => '5',
|
||||
.kp_6 => '6',
|
||||
.kp_7 => '7',
|
||||
.kp_8 => '8',
|
||||
.kp_9 => '9',
|
||||
.kp_dot => '.',
|
||||
.kp_slash => '/',
|
||||
.kp_star => '*',
|
||||
.kp_minus => '-',
|
||||
.kp_plus => '+',
|
||||
.kp_enter => '\r',
|
||||
.kp_equals => '=',
|
||||
// Navigation and function keys: kitty protocol codepoints (vaxis.Key).
|
||||
.up => vaxis.Key.up,
|
||||
.down => vaxis.Key.down,
|
||||
.left => vaxis.Key.left,
|
||||
.right => vaxis.Key.right,
|
||||
.home => vaxis.Key.home,
|
||||
.end => vaxis.Key.end,
|
||||
.page_up => vaxis.Key.page_up,
|
||||
.page_down => vaxis.Key.page_down,
|
||||
.insert => vaxis.Key.insert,
|
||||
.delete => vaxis.Key.delete,
|
||||
.f1 => vaxis.Key.f1,
|
||||
.f2 => vaxis.Key.f2,
|
||||
.f3 => vaxis.Key.f3,
|
||||
.f4 => vaxis.Key.f4,
|
||||
.f5 => vaxis.Key.f5,
|
||||
.f6 => vaxis.Key.f6,
|
||||
.f7 => vaxis.Key.f7,
|
||||
.f8 => vaxis.Key.f8,
|
||||
.f9 => vaxis.Key.f9,
|
||||
.f10 => vaxis.Key.f10,
|
||||
.f11 => vaxis.Key.f11,
|
||||
.f12 => vaxis.Key.f12,
|
||||
// Keypad keys: kitty protocol codepoints (vaxis.Key).
|
||||
.kp_0 => vaxis.Key.kp_0,
|
||||
.kp_1 => vaxis.Key.kp_1,
|
||||
.kp_2 => vaxis.Key.kp_2,
|
||||
.kp_3 => vaxis.Key.kp_3,
|
||||
.kp_4 => vaxis.Key.kp_4,
|
||||
.kp_5 => vaxis.Key.kp_5,
|
||||
.kp_6 => vaxis.Key.kp_6,
|
||||
.kp_7 => vaxis.Key.kp_7,
|
||||
.kp_8 => vaxis.Key.kp_8,
|
||||
.kp_9 => vaxis.Key.kp_9,
|
||||
.kp_dot => vaxis.Key.kp_decimal,
|
||||
.kp_slash => vaxis.Key.kp_divide,
|
||||
.kp_star => vaxis.Key.kp_multiply,
|
||||
.kp_minus => vaxis.Key.kp_subtract,
|
||||
.kp_plus => vaxis.Key.kp_add,
|
||||
.kp_enter => vaxis.Key.kp_enter,
|
||||
.kp_equals => vaxis.Key.kp_equal,
|
||||
else => 0,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue