# A script for long-line coloring.

# We use almr's looping techniques, as described in:

# https://discuss.kakoune.com/t/kakscript-has-loop-catch-this-head-tail-shift-int-0-streq-etc/1885
# https://gitlab.com/kstr0k/sel-editor.kak/-/snippets/2178452

declare-option -docstring 'divider pane coloring' \
str divider_face 'default,rgb:dae3e6'

declare-option -hidden int divider_column

define-command -params 1 -docstring 'divider-on <column>: colorize right side starting from column' \
divider-on %{
    add-highlighter -override global/divider group
    set-option global divider_column %arg(1)
    divider-do-256 divider-colorize
} -override

define-command -docstring 'divider-off: remove right-side coloring' \
divider-off %{
    remove-highlighter global/divider
} -override

define-command -hidden -params .. divider-do-2 %{
    %arg(@)
    %arg(@)
} -override

define-command -hidden -params .. divider-do-4 %{
    divider-do-2 divider-do-2 %arg(@)
} -override

define-command -hidden -params .. divider-do-16 %{
    divider-do-4 divider-do-4 %arg(@)
} -override

define-command -hidden -params .. divider-do-256 %{
    divider-do-16 divider-do-16 %arg(@)
} -override

define-command -hidden divider-colorize %{
    add-highlighter "global/divider/%opt(divider_column)" column %opt(divider_column) %opt(divider_face)
    set-option -add global divider_column 1
} -override

