When a command is performed with parameters, those are now passed to the predicate. The predicate can then return, after the validity boolean, any other value that will then be passed to the actual command. If the predicate only returns the validity boolean, the original parameters are passed through to the actual command. This allows predicates to manipulate the received parameters, and allows them to pass the result of an expensive computation to the actual command, which won't have to recalculate it. String and table predicates will now also return `core.active_view`.
25 lines
539 B
Lua
25 lines
539 B
Lua
local core = require "core"
|
|
local command = require "core.command"
|
|
|
|
command.add("core.commandview", {
|
|
["command:submit"] = function(active_view)
|
|
active_view:submit()
|
|
end,
|
|
|
|
["command:complete"] = function(active_view)
|
|
active_view:complete()
|
|
end,
|
|
|
|
["command:escape"] = function(active_view)
|
|
active_view:exit()
|
|
end,
|
|
|
|
["command:select-previous"] = function(active_view)
|
|
active_view:move_suggestion_idx(1)
|
|
end,
|
|
|
|
["command:select-next"] = function(active_view)
|
|
active_view:move_suggestion_idx(-1)
|
|
end,
|
|
})
|