diff --git a/config/bindings.lua b/config/bindings.lua index e7c747d..26ef04d 100644 --- a/config/bindings.lua +++ b/config/bindings.lua @@ -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' } diff --git a/rpn/controller.lua b/rpn/controller.lua index db5398a..cf184d4 100644 --- a/rpn/controller.lua +++ b/rpn/controller.lua @@ -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