Skip to content

Commit

Permalink
only add editable default value for linux like systems
Browse files Browse the repository at this point in the history
  • Loading branch information
cstsunfu committed May 8, 2022
1 parent 8fccdf7 commit fe59101
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions bin/asynctask.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import sys
import os
import copy
import readline
import fnmatch
import pprint
import tempfile
Expand All @@ -35,6 +34,8 @@

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

if UNIX:
import readline

#----------------------------------------------------------------------
# macros
Expand Down Expand Up @@ -929,12 +930,17 @@ def _handle_input (self, varname):
return shadow[name]
if ',' not in tail:
prompt = 'Input argument (%s): '%name
text = ''
try:
readline.set_startup_hook(lambda: readline.insert_text(tail))
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)
finally:
readline.set_startup_hook()
if not text:
text = tail.strip()
else:
select = []
for part in tail.split(','):
Expand Down

0 comments on commit fe59101

Please sign in to comment.