mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 10:11:14 +00:00
Fix getch on windows
This commit is contained in:
parent
9192b555b5
commit
b18a049886
@ -6,7 +6,19 @@ from .exceptions import NoRuleMatched
|
||||
from . import logs
|
||||
|
||||
try:
|
||||
from msvcrt import getch
|
||||
import msvcrt
|
||||
def getch():
|
||||
ch = msvcrt.getch()
|
||||
if ch in (b'\x00', b'\xe0'): # arrow or function key prefix?
|
||||
ch = msvcrt.getch() # second call returns the actual key code
|
||||
|
||||
if ch == b'\x03':
|
||||
raise KeyboardInterrupt
|
||||
if ch == b'H':
|
||||
return 'k'
|
||||
if ch == b'P':
|
||||
return 'j'
|
||||
return ch.decode(sys.stdout.encoding)
|
||||
except ImportError:
|
||||
def getch():
|
||||
import tty
|
||||
|
Loading…
x
Reference in New Issue
Block a user