aboutsummaryrefslogtreecommitdiffstats
path: root/getch.py
diff options
context:
space:
mode:
authorJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-03-17 21:29:48 +0200
committerJan Tuomi <jan-sebastian.tuomi@aalto.fi>2016-03-17 23:02:34 +0200
commit5bd3157eedb16d8f10339cc7b5659b07a1d0411e (patch)
tree27547b2a89bbbfc494b41d76f9e7f96236a45173 /getch.py
parentb6dc3ba88e5ef0a7e4509c88665372cb04a36f06 (diff)
Add help and restructure
Diffstat (limited to 'getch.py')
-rw-r--r--getch.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/getch.py b/getch.py
deleted file mode 100644
index be6203f..0000000
--- a/getch.py
+++ /dev/null
@@ -1,38 +0,0 @@
-class _Getch:
- """Gets a single character from standard input. Does not echo to the
-screen."""
- def __init__(self):
- try:
- self.impl = _GetchWindows()
- except ImportError:
- self.impl = _GetchUnix()
-
- def __call__(self): return self.impl()
-
-
-class _GetchUnix:
- def __init__(self):
- import tty, sys
-
- def __call__(self):
- import sys, tty, termios
- fd = sys.stdin.fileno()
- old_settings = termios.tcgetattr(fd)
- try:
- tty.setraw(sys.stdin.fileno())
- ch = sys.stdin.read(1)
- finally:
- termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
- return ch
-
-
-class _GetchWindows:
- def __init__(self):
- import msvcrt
-
- def __call__(self):
- import msvcrt
- return msvcrt.getch()
-
-
-getch = _Getch()