2019-06-25 17:48:24 +02:00
|
|
|
hook global ModuleLoaded x11 %{
|
2019-03-13 22:00:59 +01:00
|
|
|
require-module x11-repl
|
|
|
|
}
|
|
|
|
|
|
|
|
provide-module x11-repl %{
|
|
|
|
|
2020-10-27 11:12:09 +01:00
|
|
|
declare-option -docstring "window id of the REPL window" str x11_repl_id
|
|
|
|
|
2020-02-03 20:53:28 +01:00
|
|
|
define-command -docstring %{
|
|
|
|
x11-repl [<arguments>]: create a new window for repl interaction
|
|
|
|
All optional parameters are forwarded to the new window
|
|
|
|
} \
|
2016-10-11 09:03:41 +02:00
|
|
|
-params .. \
|
2018-09-26 23:42:01 +02:00
|
|
|
-shell-completion \
|
2020-10-27 22:57:04 +01:00
|
|
|
x11-repl %{ x11-terminal sh -c %{
|
2020-10-30 14:35:20 +01:00
|
|
|
winid="${WINDOWID:-$(xdotool search --pid ${PPID} | tail -1)}"
|
2020-10-27 22:57:04 +01:00
|
|
|
printf "evaluate-commands -try-client $1 \
|
2020-10-30 14:35:20 +01:00
|
|
|
'set-option current x11_repl_id ${winid}'" | kak -p "$2"
|
2020-10-27 22:57:04 +01:00
|
|
|
shift 2;
|
|
|
|
[ "$1" ] && "$@" || "$SHELL"
|
|
|
|
} -- %val{client} %val{session} %arg{@}
|
|
|
|
}
|
2016-01-26 14:05:35 +01:00
|
|
|
|
2017-11-03 08:34:41 +01:00
|
|
|
define-command x11-send-text -docstring "send the selected text to the repl window" %{
|
2020-07-11 18:23:27 +02:00
|
|
|
evaluate-commands %sh{
|
|
|
|
printf %s\\n "${kak_selection}" | xsel -i ||
|
|
|
|
echo 'fail x11-send-text: failed to run xsel, see *debug* buffer for details' &&
|
2020-10-27 11:12:09 +01:00
|
|
|
xdotool windowactivate "${kak_opt_x11_repl_id}" key --clearmodifiers Shift+Insert ||
|
2020-07-11 18:23:27 +02:00
|
|
|
echo 'fail x11-send-text: failed to run xdotool, see *debug* buffer for details'
|
2016-01-26 14:05:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-01 12:30:34 +02:00
|
|
|
alias global repl-new x11-repl
|
|
|
|
alias global repl-send-text x11-send-text
|
2019-03-13 22:00:59 +01:00
|
|
|
|
|
|
|
}
|