diff --git a/docs/changelog.rst b/docs/changelog.rst index ca97b11fe..8f5f14e65 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -95,6 +95,9 @@ To update |kitty|, :doc:`follow the instructions `. - Update to using the Unicode 12 standard +- Unicode input kitten: Allow using the arrow keys in code mode to go to next + and previous unicode symbol. + - macOS: Fix specifying initial window size in cells not working correctly on Retina screens (:iss:`1444`) diff --git a/docs/kittens/unicode-input.rst b/docs/kittens/unicode-input.rst index 88c746d29..e29f8c604 100644 --- a/docs/kittens/unicode-input.rst +++ b/docs/kittens/unicode-input.rst @@ -15,6 +15,8 @@ In :guilabel:`Code` mode, you enter a unicode character by typing in the hex cod character and pressing enter, for example, type in ``2716`` and press enter to get ✖. You can also choose a character from the list of recently used characters by typing a leading period and then the two character index and pressing Enter. +The up and down arrow keys can be used to choose the previous and next unicode +symbol respectively. In :guilabel:`Name` mode you instead type words from the character name and use the arrow keys/tab to select the character from the displayed matches. You can also type diff --git a/kittens/unicode_input/main.py b/kittens/unicode_input/main.py index 5746a5e55..3250e409c 100644 --- a/kittens/unicode_input/main.py +++ b/kittens/unicode_input/main.py @@ -391,6 +391,23 @@ class UnicodeInput(Handler): self.refresh() def on_key(self, key_event): + if self.mode is HEX and key_event.type is not RELEASE and not key_event.mods: + try: + val = int(self.line_edit.current_input, 16) + except Exception: + return + if key_event.key is TAB: + self.line_edit.current_input = hex(val + 0x10)[2:] + self.refresh() + return + if key_event.key is UP: + self.line_edit.current_input = hex(val + 1)[2:] + self.refresh() + return + if key_event.key is DOWN: + self.line_edit.current_input = hex(val - 1)[2:] + self.refresh() + return if self.mode is NAME and key_event.type is not RELEASE and not key_event.mods: if key_event.key is TAB: if key_event.mods == SHIFT: