Skip to content

Commit

Permalink
controller: Call function interactive
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Oct 20, 2023
1 parent 89d4513 commit c28ebd9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/bindings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ return {
t['x'] = { function(_) ctrl:solve_interactive() end, 'Solve*' }
t['d'] = { function(_) ctrl:diff_interactive() end, 'Derivative*' }
t['i'] = { function(_) ctrl:integrate_interactive() end, 'Integrate*' }
t['f'] = { function(_) ctrl:call_n_interactive() end, 'Call*' }

t = edit.kbd
t['down'] = { function(_) ctrl.stack:swap() end, 'Swap' }
Expand Down
14 changes: 14 additions & 0 deletions rpn/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,20 @@ function meta:integrate_interactive()
end
end

cmd('Call n', 'call_n_interactive')
function meta:call_n_interactive()
if not self.stack:top() then return end

local dlg = ask_n(2, { title = string.format("Call ...", self.stack:top().infix or '?'), text = '' })
dlg.on_done = function(text)
local fn, n = table.unpack(text)
if fn:len() == 0 then return end
if tonumber(n) < 0 then return end

self:dispatch_function_n(fn, tonumber(n), true, false)
end
end

cmd('Explode', 'explode_interactive')
function meta:explode_interactive()
if not self.stack:top() then return end
Expand Down

0 comments on commit c28ebd9

Please sign in to comment.