On Fri, 2005-03-11 at 16:37 +0200, Tuomo Valkonen wrote:
> Now, besides these, what features (that don't need a major rewrite) would
> you want to see for Ion3?
'Menu from pipe' (or 'Dynamic' menu) would be a great feature to have in
ion3. I mean being able to use something like
defmenu(menu, {
pipemenu("Projects Submenu", "~/.ion3/scripts/projects.sh")
})
with 'projects.sh' producing something like
"SideStripes" "ioncore_exec_on(_, 'wing ~/work/SideStripes.wpr')"
"BlueSend" "ioncore_exec_on(_, 'wing ~/work/BlueSend.wpr')"
END
and "Projects Submenu" dynamically created on each menu invocation.
Right now I have to create each 'pipe menu' using ugly set of scripts.
This script goes for every 'pipe menu' I create:
function create_projectsmenu()
projects_menu = {}
if projectsmenu_running then
return
else
projectsmenu_running = true
end
ioncore.popen_bgread("~/.ion3/scripts/projects.sh",
function(s)
projects_menu = read_menu_item(s, projects_menu, "projectsmenu")
if not projects_menu then
projectsmenu_running = nil
end
end)
end
This script is (fortunately) defined only once:
function read_menu_item(s, menu, name)
while s do
local pe = string.find(s, string.char(10))
local ls
if pe then
ls = string.sub(s, 1, pe-1)
s = string.sub(s, pe+1)
else
ls = s
s = nil
end
if ls == "END" then
defmenu(name, menu)
return nil
else
if ls then
local p = string.find(ls, ":")
if p then
local n = string.sub(ls, 1, p-1)
local c = string.sub(ls, p+1)
menu[table.getn(menu)+1] = menuentry(n, c)
end
end
end
end
return menu
end
And instead of calling main menu directly I have to use
function main_menu(f, s)
create_projectsmenu()
mod_menu.bigmenu(f, s, 'mainmenu')
end
Having these three scripts to accomplish such a simple task means proposed
pipemenu() function would be a great simplification.
--
Alte