Skip to content

Commit

Permalink
Merge pull request #93 from cstsunfu/master
Browse files Browse the repository at this point in the history
editable default input value in the command line command
  • Loading branch information
skywind3000 authored Aug 4, 2023
2 parents 9d03ecc + fe59101 commit 4f98bf4
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions bin/asynctask.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@

UNIX = (sys.platform[:3] != 'win') and True or False

if UNIX:
import readline

#----------------------------------------------------------------------
# macros
Expand Down Expand Up @@ -928,9 +930,17 @@ def _handle_input (self, varname):
return shadow[name]
if ',' not in tail:
prompt = 'Input argument (%s): '%name
text = self.raw_input(prompt)
if not text:
text = tail.strip()
if UNIX: # for linux like system, using readline for editable default value
text = ''
try:
readline.set_startup_hook(lambda: readline.insert_text(tail))
text = self.raw_input(prompt)
finally:
readline.set_startup_hook()
else:
text = self.raw_input(prompt)
if not text:
text = tail.strip()
else:
select = []
for part in tail.split(','):
Expand Down

0 comments on commit 4f98bf4

Please sign in to comment.