Re: example of query completion
Nicolas Chauvat <nicolas.chauvat-yG1kfhx/[email protected]>
| Newsgroups | gmane.comp.window-managers.ion.general |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Sep 09, 2008 at 09:43:27PM +0000, Tuomo Valkonen wrote: > On 2008-09-09, Nicolas Chauvat <nicolas.chauvat-yG1kfhx/[email protected]> wrote: > > I am trying to get completion to work when querying for user input in > > the ion command bar. > > Querying for what? How? At what level do you need help? As stated in my first email, I am trying to get a script like http://modeemi.fi/~tuomov/repos/ion-scripts-3/scripts/query_url.lua to work with the latest release of ion. You'll find attached my attempt at such a script. I started with query_url.lua and modified it. -- Nicolas Chauvat logilab.fr - services en informatique scientifique et gestion de connaissances
simpled_verbs.lua
(text/plain, 633 B)
local simpled_verb = "simpled-verbs"
function get_possible_verbs ()
local verbs = {}
local f = io.popen(simpled_verb .. " --list")
for line in f:lines() do
table.insert(verbs, line)
end
f:close()
return verbs
end
function query_verb(mplex)
local possible_verbs = get_possible_verbs()
print(possible_verbs,"\n")
local function handler(mplex, str)
ioncore.exec_on(mplex, simpled_verb .. ' ' .. str)
end
local function completor(wedln, what)
wedln:set_completions(mod_query.complete_from_list(possible_verbs, what))
end
mod_query.query(mplex, "verb: ", nil, handler, completor)
end