Skip to content

Commit

Permalink
[input] allow percent of starting value #2082
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Oct 28, 2023
1 parent 727fd33 commit e9e2d69
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions visidata/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def find_nonword(s, a, b, incr):
first_action = False
complete_state.reset()

return type(value)(v)
return v


@VisiData.api
Expand All @@ -338,8 +338,15 @@ def editText(vd, y, x, w, record=True, display=True, **kwargs):
if record and vd.cmdlog:
vd.setLastArgs(v)

return v
if 'value' in kwargs:
starting_value = kwargs['value']
if isinstance(starting_value, (int, float)) and v[-1] == '%': #2082
pct = float(v[:-1])
v = pct*value/100

v = type(starting_value)(v)

return v

@VisiData.api
def inputsingle(vd, prompt, record=True):
Expand Down

0 comments on commit e9e2d69

Please sign in to comment.