add basic support for repl interaction in x11

Define x11-repl command that optionally takes the name of an interpreter
to start it on a new window. Users then can select some text in the
editor and use [x11-]send-text command to send it to the interpreter.
Ideally the latter command should be bound to a key for easier
interaction. Requires xsel and xdotool to work.
This commit is contained in:
Gokcehan Kara 2016-01-24 15:18:14 +02:00
parent 830c9b237a
commit 0df6be4992

View File

@ -30,6 +30,28 @@ def -docstring 'create a new kak client for current session' \
setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 & setsid ${kak_opt_termcmd} "kak -c ${kak_session} ${kakoune_params}" < /dev/null > /dev/null 2>&1 &
}} }}
def -docstring 'create a new window for repl interaction' \
-params 0..1 \
-command-completion \
x11-repl %{ %sh{
if [ -z "${kak_opt_termcmd}" ]; then
echo "echo -color Error 'termcmd option is not set'"
exit
fi
if [ $# -eq 0 ]; then cmd="bash"; else cmd="$1"; fi
setsid ${kak_opt_termcmd} ${cmd} -t kak_repl_window < /dev/null > /dev/null 2>&1 &
}}
def x11-send-text -docstring "send selected text to the repl window" %{
%sh{
echo "${kak_selection}" | xsel -i
wid=$(xdotool getactivewindow)
xdotool search --name kak_repl_window windowactivate
xdotool key --clearmodifiers "Shift+Insert"
xdotool windowactivate $wid
}
}
def -docstring 'focus given client\'s window' \ def -docstring 'focus given client\'s window' \
-params 0..1 -client-completion \ -params 0..1 -client-completion \
x11-focus %{ %sh{ x11-focus %{ %sh{
@ -44,3 +66,5 @@ def -docstring 'focus given client\'s window' \
alias global focus x11-focus alias global focus x11-focus
alias global new x11-new alias global new x11-new
alias global repl x11-repl
alias global send-text x11-send-text