flua_require("vr3framework.lua") establish_vr3_defaults() appl = {} appl.m = execute("uname -m") _X = readfrom("| uname -m") appl.m = read(_X,"*w") closefile(_X) appl.name = "Dictionary" appl.mask = ".dic" appl.more = "" appl.searched = "" appl.sd = 4 appl.maxf = 100 appl.founds = { } if appl.m == "mips" then print("Setup mips specific init values") -- for the path where the agenda dictionaries are placed appl.dicP = "/home/default/dics/" else print("Setup default init values") appl.dicP = "../" end -- appl.dicN = 8 appl.dicM = { "ger-eng", "ita-eng", "dut-eng", "fre-eng", "eng-spa", "ita-ger", "eng-lat", "eng-por" } appl.dicD = { } appl.dicD["ger-eng"] = appl.dicP .. "ger2eng.dic/" appl.dicD["ita-eng"] = appl.dicP .. "ita2eng.dic/" appl.dicD["dut-eng"] = appl.dicP .. "dut2eng.dic/" appl.dicD["fre-eng"] = appl.dicP .. "fre2eng.dic/" appl.dicD["eng-spa"] = appl.dicP .. "spa2eng.dic/" appl.dicD["ita-ger"] = appl.dicP .. "ita2ger.dic/" appl.dicD["eng-lat"] = appl.dicP .. "eng2lat.dic/" appl.dicD["eng-por"] = appl.dicP .. "eng2por.dic/" -- set default to first entry appl.dict = appl.dicD[appl.dicM[1]] set = build_main_window(appl.name) function loadF(filename) _F = openfile(filename, "r") local c = "" print(filename) if _F ~= nil then c = read(_F,"*a") setEdit(c) closefile(_F) end return c end function saveF(filename,c) _F = openfile(filename, 'w+') write(_F,c) closefile(_F) end -- On "done", checkpoint our state and bail function set:done_cb() -- saveF("." .. appl.name, getEdit()) exit(0) end ---------- toolbar buttons set.toolbar:begin_layout() about_entry = Menu_Entry{"About"} setd_entry = Menu_Entry{"Set Dict .."} clear_entry = Menu_Entry{"Clear"} search_entry = Menu_Entry{"Search"} more_entry = Menu_Entry{"More"} function about_entry:callback() run_about_window{appname=appl.name, version="0.1", copyright="Copyright (C) 2002", author="Andreas Holzer", note=appl.dict } end function clear_entry:callback() clearEdit() end function setd_entry:callback() filename = ag_file_chooser("Set Dic", appl.mask, appl.dict) if filename ~= nil then appl.dict = filename end end function clearEdit() set.out:clear() set.founds.value = "0" end function getEdit() return set.search.value end function setEdit(c) set.out.value = c end function addEdit(c,i) set.out:insert(i,c) -- set.out.value = c end menuP = Menu_Button{0,0,vr3_defaults.button_width,0; label="Edit"} menuF = Menu_Button{0,0,vr3_defaults.button_width,0; label="File"} menuS = Menu_Button{0,0,vr3_defaults.button_width,0; label="Search"} function search_entry:callback() searchInDic() end function more_entry:callback() local s s = strsub(appl.more,0,appl.sd-1) appl.more = strsub(appl.more,appl.sd) doSearch(s) appl.searched = appl.searched .. s end function strGenIndex(s,f) local ix,m; ix = strfind(s,f) if ix ~= nil then s = f .. strsub(s,0,ix-1) .. strsub(s,ix+1) else s = f .. s end appl.more = strsub(s,appl.sd) s = strsub(s,0,appl.sd-1) return s end function getSearchIndex(sv) local search, _X, si, s, r print("Dict-Path : ",appl.dict) execute("ls " .. appl.dict) search = format ("| dictHashN -s %s " .. appl.dict, sv) _X = readfrom(search) s = read(_X,"*l") si = strfind(s," ") s = strsub(s,si+1) r = strGenIndex(s,strlower(strsub(sv,0,1))) return (r) end function doSearch(sIndex) local i i = tonumber(set.founds.value) * 2+1 print(i) for j=1,strlen(sIndex) do letter = strsub(sIndex,j,j) set.action.value = format("%s.%s.%s:%s", appl.searched,sIndex,appl.more,letter) a = format("%s\"%s.dic.gz\"",appl.dict, letter) search = format ("| gzip -d -c %s | grep -i \"%s\"", a, set.search.value) print(search) _X = readfrom(search) s = "" Fl:flush() while ((_X ~= nil)and(i/2