File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from ._config import config
55
66
7+ class ReadChar :
8+ """A ContextManager allowing for keypress collection without requiering the user to
9+ confirm presses with ENTER. Can be used non-blocking while inside the context."""
10+
11+ def __init__ (self , cfg : config = None ) -> None :
12+ self .config = cfg if cfg is not None else config
13+
14+ def __enter__ (self ) -> "ReadChar" :
15+ raise NotImplementedError ("ToDo" )
16+ return self
17+
18+ def __exit__ (self , type , value , traceback ) -> None :
19+ raise NotImplementedError ("ToDo" )
20+
21+ @property
22+ def key_waiting (self ) -> bool :
23+ """True if a key has been pressed and is waiting to be read. False if not."""
24+ raise NotImplementedError ("ToDo" )
25+
26+ def char (self ) -> str :
27+ """Reads a singel char from the input stream and returns it as a string of
28+ length one. Does not require the user to press ENTER."""
29+ raise NotImplementedError ("ToDo" )
30+
31+ def key (self ) -> str :
32+ """Reads a keypress from the input stream and returns it as a string. Keypressed
33+ consisting of multiple characterrs will be read completly and be returned as a
34+ string matching the definitions in `key.py`.
35+ Does not require the user to press ENTER."""
36+ raise NotImplementedError ("ToDo" )
37+
38+
739# Initially taken from:
840# http://code.activestate.com/recipes/134892/
941# Thanks to Danny Yoo
Original file line number Diff line number Diff line change 33from ._config import config
44
55
6+ class ReadChar :
7+ """A ContextManager allowing for keypress collection without requiering the user to
8+ confirm presses with ENTER. Can be used non-blocking while inside the context."""
9+
10+ def __init__ (self , cfg : config = None ) -> None :
11+ self .config = cfg if cfg is not None else config
12+
13+ def __enter__ (self ) -> "ReadChar" :
14+ raise NotImplementedError ("ToDo" )
15+ return self
16+
17+ def __exit__ (self , type , value , traceback ) -> None :
18+ raise NotImplementedError ("ToDo" )
19+
20+ @property
21+ def key_waiting (self ) -> bool :
22+ """True if a key has been pressed and is waiting to be read. False if not."""
23+ raise NotImplementedError ("ToDo" )
24+
25+ def char (self ) -> str :
26+ """Reads a singel char from the input stream and returns it as a string of
27+ length one. Does not require the user to press ENTER."""
28+ raise NotImplementedError ("ToDo" )
29+
30+ def key (self ) -> str :
31+ """Reads a keypress from the input stream and returns it as a string. Keypressed
32+ consisting of multiple characterrs will be read completly and be returned as a
33+ string matching the definitions in `key.py`.
34+ Does not require the user to press ENTER."""
35+ raise NotImplementedError ("ToDo" )
36+
37+
638def readchar () -> str :
739 """Reads a single character from the input stream.
840 Blocks until a character is available."""
You can’t perform that action at this time.
0 commit comments