summaryrefslogtreecommitdiff
path: root/sphinx/cmd/quickstart.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2018-06-08 22:35:14 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2018-06-11 14:24:17 +0900
commitc15e2f3eff669f02540f66947b73639613965a08 (patch)
tree70996ddfc0a31d20b6bee37854a13bb141b07501 /sphinx/cmd/quickstart.py
parentac9f973c9be70c9f253a42939a73035be1e9e6aa (diff)
downloadsphinx-git-c15e2f3eff669f02540f66947b73639613965a08.tar.gz
Fix #5036: quickstart: Typing Ctrl-U clears the whole of line
Diffstat (limited to 'sphinx/cmd/quickstart.py')
-rw-r--r--sphinx/cmd/quickstart.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/sphinx/cmd/quickstart.py b/sphinx/cmd/quickstart.py
index 68718eeaf..8b928b478 100644
--- a/sphinx/cmd/quickstart.py
+++ b/sphinx/cmd/quickstart.py
@@ -38,7 +38,7 @@ from six.moves.urllib.parse import quote as urlquote
from sphinx import __display_version__, package_dir
from sphinx.util import texescape
from sphinx.util.console import ( # type: ignore
- purple, bold, red, turquoise, nocolor, color_terminal
+ colorize, bold, red, turquoise, nocolor, color_terminal
)
from sphinx.util.osutil import ensuredir, make_filename
from sphinx.util.template import SphinxRenderer
@@ -82,8 +82,14 @@ PROMPT_PREFIX = '> '
# function to get input from terminal -- overridden by the test suite
def term_input(prompt):
# type: (unicode) -> unicode
- print(prompt, end='')
- return input('')
+ if sys.platform == 'win32':
+ # Important: On windows, readline is not enabled by default. In these
+ # environment, escape sequences have been broken. To avoid the
+ # problem, quickstart uses ``print()`` to show prompt.
+ print(prompt, end='')
+ return input('')
+ else:
+ return input(prompt)
class ValidationError(Exception):
@@ -183,7 +189,7 @@ def do_prompt(text, default=None, validator=nonempty):
prompt = prompt.encode('utf-8')
except UnicodeEncodeError:
prompt = prompt.encode('latin1')
- prompt = purple(prompt)
+ prompt = colorize('purple', prompt, input_mode=True)
x = term_input(prompt).strip()
if default and not x:
x = default