--
-- Copyright (c) Tuomo Valkonen 2004-2007.
--
--- Ion is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
+-- See the included file LICENSE for details.
--
--DOC
-- This function can be used to read completions from an external source.
-- The parameter \var{cp} is the completion proxy to be used,
--- and the string \var{cmd} the shell command to be executed. To its stdout,
--- the command should on the first line write the \var{common_beg}
+-- and the string \var{cmd} the shell command to be executed, in the directory
+-- \var{wd}.
+-- To its stdout, the command should on the first line write the \var{common_beg}
-- parameter of \fnref{WComplProxy.set_completions} (which \var{fn} maybe used
-- to override) and a single actual completion on each of the successive lines.
-- The function \var{reshnd} may be used to override a result table
-- building routine.
-function mod_query.popen_completions(cp, cmd, fn, reshnd)
+function mod_query.popen_completions(cp, cmd, fn, reshnd, wd)
local pst={cp=cp, maybe_stalled=0}
if not found_clean then
pipes[rcv]=pst
- ioncore.popen_bgread(cmd, coroutine.wrap(rcv))
+ ioncore.popen_bgread(cmd, coroutine.wrap(rcv), nil, wd)
end
end
local function mk_completion_test(str, sub_ok, casei_ok)
+ local settings=mod_query.get()
+
if not str then
return function(s) return true end
end
end
end
- local casei=(casei_ok and mod_query.get().caseicompl)
+ casei_ok=(casei_ok and settings.caseicompl)
+ sub_ok=(sub_ok and settings.substrcompl)
- if not casei then
+ if not casei_ok then
return mk(str, sub_ok)
else
local fn=mk(string.lower(str), sub_ok)
local scr=mplex:screen_of()
local function mkws()
- local tmpl={name=name, switchto=true}
+ local tmpl={
+ name=(name~="" and name),
+ switchto=true
+ }
if not ioncore.create_ws(scr, tmpl, layout) then
error(TR("Unknown error"))
end
--DOC
--- This query asks for the name of a client window and attaches
--- it to the frame the query was opened in. It uses the completion
--- function \fnref{ioncore.complete_clientwin}.
+-- This query asks for the name of a client window and switches
+-- focus to the one entered. It uses the completion function
+-- \fnref{ioncore.complete_clientwin}.
function mod_query.query_gotoclient(mplex)
mod_query.query(mplex, TR("Go to window:"), nil,
mod_query.gotoclient_handler,
end
--DOC
--- This query asks for the name of a client window and switches
--- focus to the one entered. It uses the completion function
--- \fnref{ioncore.complete_clientwin}.
+-- This query asks for the name of a client window and attaches
+-- it to the frame the query was opened in. It uses the completion
+-- function \fnref{ioncore.complete_clientwin}.
function mod_query.query_attachclient(mplex)
mod_query.query(mplex, TR("Attach window:"), nil,
mod_query.attachclient_handler,
end
-function mod_query.exec_completor(wedln, str, point)
+function mod_query.exec_completor_(wd, wedln, str, point)
local parts=break_cmdline(str)
local complidx=find_point(parts, point+1)
if ic then
mod_query.popen_completions(wedln,
ic..wp..string.shell_safe(s_compl),
- set_fn, filter_fn)
+ set_fn, filter_fn, wd)
end
end
+function mod_query.exec_completor(...)
+ mod_query.exec_completor_(nil, ...)
+end
+
+
local cmd_overrides={}
-- \file{ion-runinxterm}. Two colons ('::') will ask you to press
-- enter after the command has finished.
function mod_query.query_exec(mplex)
- mod_query.query(mplex, TR("Run:"), nil, mod_query.exec_handler,
- mod_query.exec_completor,
- "run")
+ local function compl(...)
+ local wd=ioncore.get_dir_for(mplex)
+ mod_query.exec_completor_(wd, ...)
+ end
+ mod_query.query(mplex, TR("Run:"), nil, mod_query.exec_handler,
+ compl, "run")
end
end
local res = {}
- local tst = mk_completion_test(host, true, false)
+ local tst = mk_completion_test(host, true, true)
for _, v in ipairs(mod_query.ssh_completions) do
if tst(v) then
local ntab=xform_menu({}, menu, "")
local function complete(str)
- -- casei_ok false, because everything is already in lower case
- return mod_query.complete_keys(ntab, str, true, false)
+ return mod_query.complete_keys(ntab, str, true, true)
end
local function handle(mplex, str)