From 908e0c1f8c5e395bde75809310de493451e5319c Mon Sep 17 00:00:00 2001 From: Nicholas Ochiel Date: Fri, 17 Nov 2017 22:40:42 +0300 Subject: [PATCH] * Crude implementation of focus: use the current region to switch to the desired window. - The proper way to do this would be to switch focus to the target client's region but GNU Screen offers no obvious way to do that. - Remove screen region after client is closed. - Assumed: Kak server runs in screen. --- rc/base/screen.kak | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/rc/base/screen.kak b/rc/base/screen.kak index 157d38d0..f474fb8f 100644 --- a/rc/base/screen.kak +++ b/rc/base/screen.kak @@ -1,9 +1,9 @@ # http://gnu.org/software/screen/ # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ -hook global KakBegin .* %{ +hook -group GNUscreen global KakBegin .* %{ %sh{ - [ -z "${kak_client_env_STY}" ] && exit + [ -z "${STY}" ] && exit echo " alias global focus screen-focus alias global new screen-new-vertical @@ -15,14 +15,24 @@ hook global KakBegin .* %{ define-command screen-new-vertical -params .. -command-completion -docstring "Create a new vertical region" %{ %sh{ tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" - screen -X eval 'split -h' 'focus down' "screen kak -c \"${kak_session}\" -e \"$*\"" < "/dev/$tty" + screen -X eval \ + 'split -h' \ + 'focus down' \ + "screen sh -c 'kak -c \"${kak_session}\" -e \"$*\" ; + screen -X remove'" \ + < "/dev/$tty" } } define-command screen-new-horizontal -params .. -command-completion -docstring "Create a new horizontal region" %{ %sh{ tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" - screen -X eval 'split -v' 'focus right' "screen kak -c \"${kak_session}\" -e \"$*\"" < "/dev/$tty" + screen -X eval \ + 'split -v' \ + 'focus right' \ + "screen sh -c 'kak -c \"${kak_session}\" -e \"$*\" ; + screen -X remove'" \ + < "/dev/$tty" } } @@ -39,11 +49,10 @@ If no client is passed then the current one is used} \ screen-focus %{ %sh{ if [ $# -eq 1 ]; then printf %s\\n " - evaluate-commands -client '$1' %{ %sh{ - screen -X focus - }}" + evaluate-commands -client '$1' focus + " elif [ -n "${kak_client_env_STY}" ]; then tty="$(ps -o tty ${kak_client_pid} | tail -n 1)" - screen -X select "$kak_client_env_WINDOW" < "/dev/$tty" + screen -X select "${kak_client_env_WINDOW}" < "/dev/$tty" fi } }