fill3: Add keyboard term_code constants.
This commit is contained in:
parent
a363004afe
commit
1ee92346b5
2 changed files with 31 additions and 20 deletions
|
|
@ -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