fill3: Add keyboard term_code constants.
This commit is contained in:
parent
a363004afe
commit
1ee92346b5
2 changed files with 31 additions and 20 deletions
|
|
@ -614,9 +614,9 @@ class Help:
|
||||||
self.widget = fill3.Border(self.view, title="Help")
|
self.widget = fill3.Border(self.view, title="Help")
|
||||||
portal = self.view.portal
|
portal = self.view.portal
|
||||||
self.key_map = {
|
self.key_map = {
|
||||||
"h": self._exit_help, terminal.UP_KEY: portal.scroll_up,
|
"h": self._exit_help, terminal.UP: portal.scroll_up,
|
||||||
terminal.DOWN_KEY: portal.scroll_down, terminal.LEFT_KEY: portal.scroll_left,
|
terminal.DOWN: portal.scroll_down, terminal.LEFT: portal.scroll_left,
|
||||||
terminal.RIGHT_KEY: portal.scroll_right, "q": self._exit_help,
|
terminal.RIGHT: portal.scroll_right, "q": self._exit_help,
|
||||||
terminal.ESC: self._exit_help}
|
terminal.ESC: self._exit_help}
|
||||||
|
|
||||||
def _exit_help(self):
|
def _exit_help(self):
|
||||||
|
|
@ -968,12 +968,11 @@ class Screen:
|
||||||
else fill3.appearance_resize(result, dimensions))
|
else fill3.appearance_resize(result, dimensions))
|
||||||
|
|
||||||
_KEY_MAP = {"t": toggle_window_orientation, "l": toggle_log, "h": toggle_help,
|
_KEY_MAP = {"t": toggle_window_orientation, "l": toggle_log, "h": toggle_help,
|
||||||
terminal.UP_KEY: cursor_up, terminal.DOWN_KEY: cursor_down,
|
terminal.UP: cursor_up, terminal.DOWN: cursor_down, terminal.LEFT: cursor_left,
|
||||||
terminal.LEFT_KEY: cursor_left, terminal.RIGHT_KEY: cursor_right,
|
terminal.RIGHT: cursor_right, terminal.PAGE_DOWN: cursor_page_down,
|
||||||
terminal.PAGE_DOWN_KEY: cursor_page_down, terminal.PAGE_UP_KEY: cursor_page_up,
|
terminal.PAGE_UP: cursor_page_up, "s": toggle_order, terminal.HOME: cursor_home,
|
||||||
"s": toggle_order, terminal.HOME_KEY: cursor_home, terminal.END_KEY: cursor_end,
|
terminal.END: cursor_end, "n": move_to_next_issue, "N": move_to_next_issue_of_tool,
|
||||||
"n": move_to_next_issue, "N": move_to_next_issue_of_tool, "e": edit_file,
|
"e": edit_file, "q": quit_, terminal.ESC: quit_, "r": refresh, "R": refresh_tool,
|
||||||
"q": quit_, terminal.ESC: quit_, "r": refresh, "R": refresh_tool,
|
|
||||||
"\t": toggle_focus, "f": toggle_fullscreen, "o": xdg_open}
|
"\t": toggle_focus, "f": toggle_fullscreen, "o": xdg_open}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,33 @@
|
||||||
|
|
||||||
|
|
||||||
import contextlib
|
import contextlib
|
||||||
|
import string
|
||||||
import sys
|
import sys
|
||||||
import termios
|
import termios
|
||||||
|
|
||||||
|
|
||||||
ESC = "\x1b"
|
ESC = "\x1b"
|
||||||
MOUSE = ESC + "[M"
|
UP = ESC + "[A"
|
||||||
|
DOWN = ESC + "[B"
|
||||||
UP_KEY = ESC + "[A"
|
RIGHT = ESC + "[C"
|
||||||
DOWN_KEY = ESC + "[B"
|
LEFT = ESC + "[D"
|
||||||
RIGHT_KEY = ESC + "[C"
|
PAGE_UP = ESC + "[5~"
|
||||||
LEFT_KEY = ESC + "[D"
|
PAGE_DOWN = ESC + "[6~"
|
||||||
PAGE_UP_KEY = ESC + "[5~"
|
HOME = ESC + "[H"
|
||||||
PAGE_DOWN_KEY = ESC + "[6~"
|
END = ESC + "[F"
|
||||||
HOME_KEY = ESC + "[H"
|
CTRL_UP = ESC + "[1;5A"
|
||||||
END_KEY = ESC + "[F"
|
CTRL_DOWN = ESC + "[1;5B"
|
||||||
|
CTRL_LEFT = ESC + "[1;5D"
|
||||||
|
CTRL_RIGHT = ESC + "[1;5C"
|
||||||
|
CTRL_SPACE = "\x00"
|
||||||
|
ENTER = "\n"
|
||||||
|
BACKSPACE = "\x7f"
|
||||||
|
ALT_BACKSPACE = ESC + BACKSPACE
|
||||||
|
ALT_CARROT = ESC + "^"
|
||||||
|
ALT_SEMICOLON = ESC + ";"
|
||||||
|
globals().update({f"ALT_{letter}": ESC + letter for letter in string.ascii_letters})
|
||||||
|
globals().update({f"CTRL_{letter}": chr(index + 1)
|
||||||
|
for index, letter in enumerate(string.ascii_uppercase)})
|
||||||
|
|
||||||
|
|
||||||
def move(x, y):
|
def move(x, y):
|
||||||
|
|
@ -64,11 +76,11 @@ def interactive():
|
||||||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_termios_settings)
|
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_termios_settings)
|
||||||
|
|
||||||
|
|
||||||
|
MOUSE = ESC + "[M"
|
||||||
RELEASE_MOUSE = 0
|
RELEASE_MOUSE = 0
|
||||||
DRAG_MOUSE = 1
|
DRAG_MOUSE = 1
|
||||||
CLICK_MOUSE = 2
|
CLICK_MOUSE = 2
|
||||||
PRESS_MOUSE = 3
|
PRESS_MOUSE = 3
|
||||||
|
|
||||||
WHEEL_UP_MOUSE = 4
|
WHEEL_UP_MOUSE = 4
|
||||||
WHEEL_DOWN_MOUSE = 5
|
WHEEL_DOWN_MOUSE = 5
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue