[Solved] Highlighter based animations?

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?

Here’s bit simpler example:

define-command scan %{ evaluate-commands %sh{(
    while true; do
        for i in $(seq 10 20); do
            echo "add-highlighter global/vaiv line $i default,rgb:ff0000" | kak -p $kak_session
            sleep 0.2
            echo "remove-highlighter global/vaiv" | kak -p $kak_session
        done
    done
) >/dev/null 2>&1 </dev/null & }}

sequentially adds line highlighting on 10, 11, 12 … 20 lines. But if I’m not holding <c-l> I can’t see the animation.

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.

I guess you meant “not”?

Should I report this behavior on issue tracker?

Yes please !

I guess I’ve figured out what’s the problem with the second example. If I wrap all commands to eval -client $kak_client then it redraws correctly.

Make it a plugin, I got it working from your config files and I think it’s very cool. :slight_smile:

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.

Thanks for the suggestion :slight_smile:

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 thinks there are more prioritized things to do. This is not that important as of today

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.

I meant showing something as part of the modeline

Oi! Got it.

Related issue about timers https://github.com/mawww/kakoune/issues/2337