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")
|
||||
portal = self.view.portal
|
||||
self.key_map = {
|
||||
"h": self._exit_help, terminal.UP_KEY: portal.scroll_up,
|
||||
terminal.DOWN_KEY: portal.scroll_down, terminal.LEFT_KEY: portal.scroll_left,
|
||||
terminal.RIGHT_KEY: portal.scroll_right, "q": self._exit_help,
|
||||
"h": self._exit_help, terminal.UP: portal.scroll_up,
|
||||
terminal.DOWN: portal.scroll_down, terminal.LEFT: portal.scroll_left,
|
||||
terminal.RIGHT: portal.scroll_right, "q": self._exit_help,
|
||||
terminal.ESC: self._exit_help}
|
||||
|
||||
def _exit_help(self):
|
||||
|
|
@ -968,12 +968,11 @@ class Screen:
|
|||
else fill3.appearance_resize(result, dimensions))
|
||||
|
||||
_KEY_MAP = {"t": toggle_window_orientation, "l": toggle_log, "h": toggle_help,
|
||||
terminal.UP_KEY: cursor_up, terminal.DOWN_KEY: cursor_down,
|
||||
terminal.LEFT_KEY: cursor_left, terminal.RIGHT_KEY: cursor_right,
|
||||
terminal.PAGE_DOWN_KEY: cursor_page_down, terminal.PAGE_UP_KEY: cursor_page_up,
|
||||
"s": toggle_order, terminal.HOME_KEY: cursor_home, terminal.END_KEY: cursor_end,
|
||||
"n": move_to_next_issue, "N": move_to_next_issue_of_tool, "e": edit_file,
|
||||
"q": quit_, terminal.ESC: quit_, "r": refresh, "R": refresh_tool,
|
||||
terminal.UP: cursor_up, terminal.DOWN: cursor_down, terminal.LEFT: cursor_left,
|
||||
terminal.RIGHT: cursor_right, terminal.PAGE_DOWN: cursor_page_down,
|
||||
terminal.PAGE_UP: cursor_page_up, "s": toggle_order, terminal.HOME: cursor_home,
|
||||
terminal.END: cursor_end, "n": move_to_next_issue, "N": move_to_next_issue_of_tool,
|
||||
"e": edit_file, "q": quit_, terminal.ESC: quit_, "r": refresh, "R": refresh_tool,
|
||||
"\t": toggle_focus, "f": toggle_fullscreen, "o": xdg_open}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,33 @@
|
|||
|
||||
|
||||
import contextlib
|
||||
import string
|
||||
import sys
|
||||
import termios
|
||||
|
||||
|
||||
ESC = "\x1b"
|
||||
MOUSE = ESC + "[M"
|
||||
|
||||
UP_KEY = ESC + "[A"
|
||||
DOWN_KEY = ESC + "[B"
|
||||
RIGHT_KEY = ESC + "[C"
|
||||
LEFT_KEY = ESC + "[D"
|
||||
PAGE_UP_KEY = ESC + "[5~"
|
||||
PAGE_DOWN_KEY = ESC + "[6~"
|
||||
HOME_KEY = ESC + "[H"
|
||||
END_KEY = ESC + "[F"
|
||||
UP = ESC + "[A"
|
||||
DOWN = ESC + "[B"
|
||||
RIGHT = ESC + "[C"
|
||||
LEFT = ESC + "[D"
|
||||
PAGE_UP = ESC + "[5~"
|
||||
PAGE_DOWN = ESC + "[6~"
|
||||
HOME = ESC + "[H"
|
||||
END = ESC + "[F"
|
||||
CTRL_UP = ESC + "[1;5A"
|
||||
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):
|
||||
|
|
@ -64,11 +76,11 @@ def interactive():
|
|||
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_termios_settings)
|
||||
|
||||
|
||||
MOUSE = ESC + "[M"
|
||||
RELEASE_MOUSE = 0
|
||||
DRAG_MOUSE = 1
|
||||
CLICK_MOUSE = 2
|
||||
PRESS_MOUSE = 3
|
||||
|
||||
WHEEL_UP_MOUSE = 4
|
||||
WHEEL_DOWN_MOUSE = 5
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue