41 lines
1.4 KiB
Text
41 lines
1.4 KiB
Text
provide-module expand %—
|
|
define-command -hidden -params 1 expand-impl %{
|
|
# param expand or shrink
|
|
evaluate-commands -itersel %sh{
|
|
sel="$kak_selection_desc"
|
|
left=${sel%%,*}
|
|
right=${sel##*,}
|
|
left_d=${left#*.}
|
|
right_d=${right#*.}
|
|
if [ "$left_d" -gt "$right_d" ]; then
|
|
# sel facing back
|
|
if [ "$1" = 'expand' ]; then
|
|
echo 'execute-keys "H<a-;>L<a-;>"'
|
|
else
|
|
echo 'execute-keys "L<a-;>H<a-;>"'
|
|
fi
|
|
elif [ "$left_d" -lt "$right_d" ]; then
|
|
# sel facing forward
|
|
if [ "$1" = 'expand' ]; then
|
|
echo 'execute-keys "L<a-;>H<a-;>"'
|
|
else
|
|
echo 'execute-keys "H<a-;>L<a-;>"'
|
|
fi
|
|
else
|
|
if [ "$1" = 'expand' ]; then
|
|
echo 'execute-keys "L<a-;>H<a-;>"'
|
|
else
|
|
echo 'nop'
|
|
fi
|
|
fi
|
|
}
|
|
}
|
|
define-command expand-selections %{
|
|
expand-impl expand
|
|
}
|
|
define-command shrink-selections %{
|
|
expand-impl shrink
|
|
}
|
|
map global object <a-e> '<esc>: expand-selections<ret>' -docstring 'expand selections'
|
|
map global object <a-s> '<esc>: shrink-selections<ret>' -docstring 'shrink selections'
|
|
—
|