Wanted to make something like Emacs beacon to find my cursor after jupms between windows, and buffers:
declare-option str beacon_final_bg "32302F"
declare-option str beacon_delay "0.1"
declare-option str beacon_transition %sh{
bg=$kak_opt_beacon_final_bg
while true; do
bg=$(echo "obase=16; ibase=16; $bg+222222" | bc)
if [ ${#bg} -eq 6 ] && [ "$bg" != "FFFFFF" ]; then
colors="rgb:$bg $colors"
else
break
fi
done
echo "$colors"
}
define-command -override beacon %{ nop %sh{ (
for color in $kak_opt_beacon_transition; do
printf "%s\n" "evaluate-commands -buffer $kak_buffile %{ add-highlighter buffer/beacon line $kak_cursor_line default,$color }" | kak -p $kak_session
sleep $kak_opt_beacon_delay
printf "%s\n" "evaluate-commands -buffer $kak_buffile %{ remove-highlighter buffer/beacon }" | kak -p $kak_session
done
) >/dev/null 2>&1 </dev/null & }}
Upon call, it should make current line almost white, then fade out. But the problem is that Kakoune doesn’t get redrawed until I manually move, so those highlighters only work if I’m holding some key that forces Kakoune to redraw. I wanted some kind of animation thought highlighters, but it doesn’t seem possible. Is there some command to force redraw like Vim’s redraw?
Arguably adding a highlighter should trigger a redraw, if that is now happening I think it can be considered a bug. An alternative would be to use ‘%opt{my_line}’ (quoted) instead of $i, and change that option value. option changing should trigger a redraw.
unfortunately it has terrible performance on low spec hardware and I do not use it anymore. I can make it into a plugin though, but since I’m not using it, I wont work actively on it.
Regarding performances, something pending on the todo list has been exposing timer support to users. Which would make things like that implementable without going through the shell. However I have been both lacking a strong enough motivating use case, not sure if such animations are a strong enough need.
I have one usecase for timers: I would like to show in the statusline the status of the latest :make command [building/failure/success], and leave it there for ~10s after it’s finished. I think it’d be possible kak -p and a detached shell scope, though.
If user press any key echo area usually clears. What’s the point of having a message for 10 seconds? I mean if user is AFK then it will disappear before it was noticed. If user is constantly working it will disappear as soon as key was pressed and 10 second duration still not gonna do much. If you want to show it constantly for 10 seconds it can override other messages.