mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-19 01:00:42 +01: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
|
from . import logs
|
||||||
|
|
||||||
try:
|
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:
|
except ImportError:
|
||||||
def getch():
|
def getch():
|
||||||
import tty
|
import tty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user