-
Notifications
You must be signed in to change notification settings - Fork 0
vtf iodata keys
The module contains the types for the inputs of function keys.
- most common types:
- additional types (untested):
These types are created by the vtiinterpreter from the stdin stream.
The types are also used as reference objects for a comparison with __eq__()
( ==
)
and can be created defined in detail. The constants are containers for the key and modification values
-- the suitable for the respective type are available in the classes as class variables under
K
(key values) and M
(modification values).
The value of the key and the modification are assigned to the attributes KEY
and MOD
.
KEY_VALUES = _KeysValues()
Collection of keys values.
DelIns = _DelInsKEYS()
BACKSPACE = 0
DELETE = -1
HPClear = -11
INSERT = 1
KeyPad: _KeyPadKEYS = _KeyPadKEYS()
Keypad function keys.
PF1 = -1
PF2 = -2
PF3 = -3
PF4 = -4
NavKey: _NavKeyKEYS = _NavKeyKEYS()
A_*
: Arrow keysC_*
: Cursor NavigationP_*
: PageA_DOWN = 2
A_LEFT = -1
A_RIGHT = 1
A_UP = -2
C_BEGIN = -4
C_END = 3
C_HOME = -3
P_DOWN = 6
P_UP = -6
SHIFT_TAB = 9
MOD_VALUES = _MODI()
Key modifier values.
Supports the
&
operator to represent combined keystrokes.ALT = _MOD(3)
CTRL = _MOD(5)
META = _MOD(9)
SHIFT = _MOD(2)
NONE_KEY = _NoneKEYS()
No key values.
NONE_MOD = _NoneMODI()
Modifiers not supported.
keys.Eval(x) -> Key | Type[Key] ¶
Return a Key object or type from a representative sting.
raises:
- ValueError(exception) on errors with the original exception as argument.
class keys.Key ¶
The base class for keys.
K = NONE_KEY
KEY: int
M: MOD_VALUES
MOD: _MOD
__contains__(item) -> bool ¶
Return whether the modification matches. Multiple keystrokes are queried via a tuple. Values should be chosen from self.M.__eq__(other) -> bool ¶
Return whether other is the same kind of instance and the defined parameters of the reference object correlate with those of the other one.__hash__() -> int ¶
hash ofrepr(self)
__init__(key=None, mod=0) ¶
Create a reference object over the parent class.__int__() -> int ¶
KEY
__iter__() -> Iterable ¶
(KEY
,MOD
)__repr__() -> str ¶
specialCreate a Key object from a representative sting of a Key object.
raises:
- ValueError(exception) on errors with the original exception as argument.
ASCII Control Character
Values:
- KEY: str = character shifted by adding 64 (ASCII:
@A-Z\]^_`
)- MOD: int = decimal character value (0 - 32)
Basically, the alphabetic characters (
ctrl + [a-z_]
) -- except h, i, j, m -- are interpreted in combination with ctrl as Ctrl(<upper character>). ( [ ! ] To avoid the terminal processing in advance, this must be modified beforehand).Platform dependent specifics are listed below.
- @ UNIX :
Default characters processed by the terminal (representative, also applies to combinations that send the same, see below):
ctrl + c
: INTRctrl + q
: IXONctrl + s
: IXOFFctrl + z
: SUSPctrl + \
: QUITSpecifics (May vary significantly based on dynamic keymaps):
ctrl + h
= ctrl + backspace -> DelIns(KEY=0, MOD=5)ctrl + i
= \t -> Space("t") or Ctrl("I") (vtiinterpreter configuration)ctrl + j
= \n | \r -> Space("n") or Ctrl("J") (vtiinterpreter configuration)ctrl + m
= \n | \r -> Space("n") or Ctrl("M") (vtiinterpreter configuration)ctrl + space
-> Ctrl("@")ctrl + @
-> Ctrl("@")ctrl + | (Or)
-> Ctrl("\")ctrl + 2
-> Ctrl("@")ctrl + 3
= ESCctrl + 4
-> Ctrl("\")ctrl + 5
-> Ctrl("]")ctrl + 6
-> Ctrl("^")ctrl + 7
-> Ctrl("_")ctrl + 8
= backspace -> DelIns(KEY=0)ctrl + /
-> Ctrl("_")ctrl + {
= ESCctrl + [
= ESCctrl + ]
-> Ctrl("]")ctrl + }
-> Ctrl("]")ctrl + ?
= backspace -> DelIns(KEY=0)ctrl + \\
-> Ctrl("\")ctrl + ~
-> Ctrl("^")ctrl + -
-> Ctrl("_")ctrl + _
-> Ctrl("_")Depending on the vtiinterpreter configuration
Tab
,Enter/Return
andSpace
are interpreted as Ctrl.
Tab
-> Ctrl("I")Enter/Return
-> Ctrl("J")Space
-> Ctrl("`")
- @ Windows:
Default characters processed by the terminal (representative, also applies to combinations that send the same, see below):
ctrl + c
: INTRSpecifics:
ctrl + h
= ctrl + backspace -> DelIns(5)ctrl + i
= \t -> Space("\t") or Ctrl("I") (vtiinterpreter configuration)ctrl + j
= \n | \r -> Space("\n") or Ctrl("J") (vtiinterpreter configuration)ctrl + m
= \n | \r -> Space("\n") or Ctrl("M") (vtiinterpreter configuration)ctrl + &
-> Ctrl("^")ctrl + 7
-> Ctrl("_")ctrl + /
-> Ctrl("_")ctrl + +
-> Ctrl("]")ctrl + #
-> Ctrl("\")ctrl + _
-> Ctrl("_")break/pause
-> Ctrl("Z")Depending on the vtiinterpreter configuration
Tab
,Enter/Return
andSpace
are interpreted as Ctrl.
Tab
-> Ctrl("I")Enter/Return
-> Ctrl("M")Space
-> Ctrl("`")
- # Resources:
- ; xterm/PC-Style-Function-Keys ff. ; wikipedia/UTF-8/Codepage_layout
KEY: str
M: = NONE_MOD
__init__(key=None) ¶
Create a new reference object.
If key is
None
the comparison>>> Ctrl(None) == Ctrl(<Any>)always returns True, otherwise a value from
@A-Z\\]^_`
must be used; use "tab", "enter" or "space" as alias for the corresponding key, note the configuration of the vtiinterpreter.
Delete, Insert and Backspace Object
Values:
- KEY: int
- Values for comparison in K:
- INSERT = 1
- BACKSPACE = 0
- DELETE = -1
- HPClear = -11
- MOD: int
- Values for comparison in M:
- SHIFT = 2
- ALT = 3
- CTRL = 5
- META = 9
- Comparisons:
>>> DelIns.M.SHIFT in DelIns(key) >>> (DelIns.M.SHIFT, DelIns.M.CTRL) in DelIns(key) # Combined modifications >>> DelIns.M.SHIFT & DelIns.M.CTRL in DelIns(key) # Combined modifications
- # Resources:
- ; xterm/PC-Style-Function-Keys ff.
K = KEY_VALUES.DelIns
__init__(key=None, mod=0) ¶
Create a new reference object.
key should be selected from DelIns.K, if key is
None
the comparison>>> DelIns(None) == DelIns(<Any>)always returns True if the modification is matches.
mod should be selected from DelIns.M. The
&
operator can be used between the mods to represent combinations.>>> DelIns(1, DelIns.M.SHIFT & DelIns.M.CTRL)If mod is
0
, no modification is explicitly expected. If mod isNone
, the comparison is always True.
ESC double
Will be interpreted when esc is pressed twice. (Also send via
ctrl+alt/meta+3
,ctrl+alt/meta+[
andctrl+alt/meta+{
(UNIX) (see Meta and Ctrl)).Values:
- KEY: int = 2727
- MOD: int = 2727
KEY: int = 2727
M: _NoneMODI = NONE_MOD
MOD: int = 2727
__init__() ¶
Takes no parameters.
Function Key Object
Values:
KEY: int = Key number (1-20)
- MOD: int
- Values for comparison in M:
- SHIFT = 2
- ALT = 3
- CTRL = 5
- META = 9
- Comparisons:
>>> FKey.M.SHIFT in FKey(key) >>> (FKey.M.SHIFT, FKey.M.CTRL) in FKey(key) # Combined modifications >>> FKey.M.SHIFT & FKey.M.CTRL in FKey(key) # Combined modifications
- # Resources:
- ; xterm/PC-Style-Function-Keys ff.
__init__(key=None, mod=0) ¶
Create a new reference object.
key should be selected from FKey.K, if key is
None
the comparison>>> FKey(None) == FKey(<Any>)always returns True if the modification is matches.
mod should be selected from FKey.M. The
&
operator can be used between the mods to represent combinations.>>> FKey(1, FKey.M.SHIFT & FKey.M.CTRL)If mod is
0
, no modification is explicitly expected. If mod isNone
, the comparison is always True.
Keypad Object ## untested ##
Values:
- KEY: int | str (
'+' '-' '*' '/' '=' '.' ',' -1(PF1) -2(PF2) -3(PF3) -4(PF4) 0-9(N)
)- MOD: int = 0
- # Resources:
- ; xterm/PC-Style-Function-Keys ; xterm/VT220-Style-Function-Keys ; xterm/VT52-Style-Function-Keys
K = KEY_VALUES.KeyPad
KEY: int | str
M = NONE_MOD
__init__(key=None) ¶
key:'+' '-' '*' '/' '=' '.' ',' -1(PF1) -2(PF2) -3(PF3) -4(PF4) 0-9(N)
Meta/Alt Character
The largest range of alternative inputs. When an input is modified with Alt/Meta, Meta(<input>) is interpreted. Technically, the input is preceded by the escape character (
\x1b
), so a combination with Ctrl is also always interpreted as Meta. (Example:ctrl+alt/meta+a -> Meta("\x01")
). This also means that if the combination with Ctrl sends the escape character, EscEsc is automatically interpreted. Shifted characters are passed as such to Meta, thus the type is case sensitive (alt/meta+a -> Meta("a")
|alt/meta+shift+a -> Meta("A")
). Note: Control characters can NOT be shifted.Values:
- KEY: str = character (ASCII/UTF)
- MOD: int = decimal character value
- # Resources:
- ; xterm/PC-Style-Function-Keys ff. ; xterm/Alt-and-Meta-Keys
KEY: str
M = NONE_MOD
__init__(key=None) ¶
Create a new reference object.
key can be defined via
Ctrl(key)
for the range of ASCII control characters - combined with Alt/Meta;>>> Meta(Ctrl("A")) == Meta("\x01") # -> TrueOnly consistent with alphabetic characters, for the Ctrl special cases, combinations may be ignored or interpreted uncommonly.
If key is
None
the comparison>>> Meta(None) == Meta(<Any>)always returns True.
Modify Other Keys Object ## untested ##
Values:
- KEY: int
ASCII value
- MOD: int
- Values for comparison in M:
- SHIFT = 2
- ALT = 3
- CTRL = 5
- META = 9
- Comparisons:
>>> ModKey.M.SHIFT in ModKey(key) >>> (ModKey.M.SHIFT, ModKey.M.CTRL) in ModKey(key) # Combined modifications >>> ModKey.M.SHIFT & ModKey.M.CTRL in ModKey(key) # Combined modifications
- # Resources:
- ; xterm/Alt-and-Meta-Keys
__init__(key=None, mod=0) ¶
Create a new reference object.
key Must be a value from the ASCII range
0-127
, if key isNone
the comparison>>> ModKey(None) == ModKey(<Any>)always returns True if the modification is matches.
mod should be selected from ModKey.M. The
&
operator can be used between the mods to represent combinations.>>> ModKey(1, ModKey.M.SHIFT & ModKey.M.CTRL)If mod is
0
, no modification is explicitly expected. If mod isNone
, the comparison is always True.
Navigational Key Object
Arrow keys, pos1, end, page up/down, shift-tab.
Shift-tab is a special case, an
<NavKey(key=NavKey.K.SHIFT_TAB, mod=NavKey.M.SHIFT)>
is always created for this key combination. The keys pos1 and end are usually interpreted with the values from NavKey.K.C_HOME and NavKey.K.C_END.Values:
- KEY: int
- Values for comparison in K:
- A_RIGHT = 1
- A_LEFT = -1
- A_UP = -2
- A_DOWN = 2
- C_HOME = -3
- C_END = 3
- C_BEGIN = -4
- P_DOWN = 6
- P_UP = -6
- SHIFT_TAB = 9
- MOD: int
- Values for comparison in M:
- SHIFT = 2
- ALT = 3
- CTRL = 5
- META = 9
- Comparisons:
>>> NavKey.M.SHIFT in NavKey(key) >>> (NavKey.M.SHIFT, NavKey.M.CTRL) in NavKey(key) # Combined modifications >>> NavKey.M.SHIFT & NavKey.M.CTRL in NavKey(key) # Combined modifications
- # Resources:
- ; xterm/PC-Style-Function-Keys ff.
K = KEY_VALUES.NavKey
__init__(key=None, mod=0) ¶
Create a new reference object.
key should be selected from NavKey.K, if key is
None
the comparison>>> NavKey(None) == NavKey(<Any>)always returns True if the modification is matches.
mod should be selected from NavKey.M. The
&
operator can be used between the mods to represent combinations.>>> NavKey(1, NavKey.M.SHIFT & NavKey.M.CTRL)If mod is
0
, no modification is explicitly expected. If mod isNone
, the comparison is always True.
Date: | 07 Nov 2022 |
---|---|
Version: | 0.1 |
Author: | Adrian Hoefflin [srccircumflex] |
Doc-Generator: | "pyiStructure-RSTGenerator" <prototype> |