diff options
-rw-r--r-- | 102keyboard.subx | 12 | ||||
-rw-r--r-- | boot.subx | 33 | ||||
-rw-r--r-- | shell/gap-buffer.mu | 12 | ||||
-rw-r--r-- | shell/trace.mu | 14 |
4 files changed, 67 insertions, 4 deletions
diff --git a/102keyboard.subx b/102keyboard.subx index e8d23962..0c8826e1 100644 --- a/102keyboard.subx +++ b/102keyboard.subx @@ -6,6 +6,18 @@ == code +# Most keys correspond to their ASCII/Unicode values. +# TODO: Support for international keyboards and multi-byte Unicode. +# +# However there are some exceptions that have no assigned place in Unicode +# (and with good reason): +# 0x80 = left arrow ← +# 0x81 = down arrow ↓ +# 0x82 = up arrow ↑ +# 0x83 = right arrow → +# These code points are not used by Unicode and their semantics are agreed to +# be context-sensitive: https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C1_controls. +# Mu cannibalizes them in yet another non-standard way. read-key: # kbd: (addr keyboard) -> result/eax: byte # . prologue 55/push-ebp diff --git a/boot.subx b/boot.subx index 6982fccb..e8c86682 100644 --- a/boot.subx +++ b/boot.subx @@ -500,8 +500,14 @@ Keyboard-normal-map: 00 20 # 3a 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -# numeric keypad would start here, but isn't implemented +00 00 00 00 00 00 00 00 +# 48 +# ↑* ←* →* ↓* + 82 00 00 80 00 83 00 00 81 +# 51 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +# * - Not a valid ASCII/Unicode value. Keyboard-shift-map: 00 @@ -526,8 +532,14 @@ Keyboard-shift-map: 00 20 # 3a 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -# numeric keypad would start here, but isn't implemented +00 00 00 00 00 00 00 00 +# 48 +# ↑* ←* →* ↓* + 82 00 00 80 00 83 00 00 81 +# 51 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +# * - Not a valid ASCII/Unicode value. Keyboard-ctrl-map: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 @@ -543,6 +555,19 @@ Keyboard-ctrl-map: # 2c # ^z ^x ^c ^v ^b ^n ^m ^/ 1a 18 03 16 02 0e 0d 00 00 1f 00 00 +# 38 +# space + 00 20 +# 3a + 00 00 00 00 00 00 +00 00 00 00 00 00 00 00 +# 48 +# ↑* ←* →* ↓* + 82 00 00 80 00 83 00 00 81 +# 51 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + +# * - Not a valid ASCII/Unicode value. # }}} Video-mode-info: diff --git a/shell/gap-buffer.mu b/shell/gap-buffer.mu index b3c84532..616500b0 100644 --- a/shell/gap-buffer.mu +++ b/shell/gap-buffer.mu @@ -759,6 +759,18 @@ fn edit-gap-buffer self: (addr gap-buffer), key: grapheme { delete-before-gap self return } + { + compare g, 0x80/left-arrow + break-if-!= + var dummy/eax: grapheme <- gap-left self + return + } + { + compare g, 0x83/right-arrow + break-if-!= + var dummy/eax: grapheme <- gap-right self + return + } # default: insert character add-grapheme-at-gap self, g } diff --git a/shell/trace.mu b/shell/trace.mu index 0736f796..b0c43f74 100644 --- a/shell/trace.mu +++ b/shell/trace.mu @@ -690,6 +690,13 @@ fn edit-trace _self: (addr trace), key: grapheme { increment *cursor-y return } + { + compare key, 0x81/down-arrow + break-if-!= + var cursor-y/eax: (addr int) <- get self, cursor-y + increment *cursor-y + return + } # cursor up { compare key, 0x6b/k @@ -698,6 +705,13 @@ fn edit-trace _self: (addr trace), key: grapheme { decrement *cursor-y return } + { + compare key, 0x82/up-arrow + break-if-!= + var cursor-y/eax: (addr int) <- get self, cursor-y + decrement *cursor-y + return + } # enter = expand { compare key, 0xa/newline |