Skip to content
This repository was archived by the owner on Jun 10, 2021. It is now read-only.

Commit 0d2afa3

Browse files
stefan-nickl-agcosnickl
authored andcommitted
1 parent a19b2e4 commit 0d2afa3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎codemod/base.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,20 @@ def _ask_about_patch(patch, editor, default_no):
686686
if p in 'eE':
687687
run_editor(patch.start_position, editor)
688688

689+
try:
690+
from msvcrt import getch
691+
except ImportError:
692+
import tty
693+
import termios
694+
def getch():
695+
fd = sys.stdin.fileno()
696+
old_settings = termios.tcgetattr(fd)
697+
698+
try:
699+
tty.setraw(fd)
700+
return sys.stdin.read(1)
701+
finally:
702+
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
689703

690704
def _prompt(letters='yn', default=None):
691705
"""
@@ -696,7 +710,7 @@ def _prompt(letters='yn', default=None):
696710
"""
697711
while True:
698712
try:
699-
input_text = sys.stdin.readline().strip()
713+
input_text = getch()
700714
except KeyboardInterrupt:
701715
sys.exit(0)
702716
if input_text and input_text in letters:

0 commit comments

Comments
 (0)