-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mohitk0208/explorer
Explorer: add file mode explorer mode for better user experience
- Loading branch information
Showing
2 changed files
with
352 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
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 | ||
import sys | ||
|
||
def __call__(self): | ||
import sys | ||
import tty | ||
import 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters