-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcrosshairs.kak
88 lines (78 loc) · 3.51 KB
/
crosshairs.kak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
set-face global crosshairs_line default,rgb:383838+bd
set-face global crosshairs_column default,rgb:383838+bd
declare-option -hidden bool highlight_current_line false
declare-option -hidden str highlight_current_line_hook_cmd "nop"
declare-option -hidden bool highlight_current_column false
declare-option -hidden str highlight_current_column_hook_cmd "nop"
define-command -hidden crosshairs-highlight-column -docstring "Highlight current column" %{
try %{ remove-highlighter window/crosshairs-column }
try %{ add-highlighter window/crosshairs-column column %val{cursor_display_column} crosshairs_column }
}
define-command -hidden crosshairs-highlight-line -docstring "Highlight current line" %{
try %{ remove-highlighter window/crosshairs-line }
try %{ add-highlighter window/crosshairs-line line %val{cursor_line} crosshairs_line }
}
define-command -hidden crosshairs-update %{
evaluate-commands %{
%opt(highlight_current_line_hook_cmd)
%opt(highlight_current_column_hook_cmd)
}}
define-command -hidden -docstring "update hooks for highlighters" \
crosshairs-change-hooks %{
evaluate-commands %sh{
# set actions
if [ "$kak_opt_highlight_current_line" = true ]; then
printf "%s\n" "set-option global highlight_current_line_hook_cmd crosshairs-highlight-line"
else
printf "%s\n" "try %(remove-highlighter window/crosshairs-line)"
printf "%s\n" "set-option global highlight_current_line_hook_cmd nop"
fi
if [ "$kak_opt_highlight_current_column" = true ]; then
printf "%s\n" "set-option global highlight_current_column_hook_cmd crosshairs-highlight-column"
else
printf "%s\n" "try %(remove-highlighter window/crosshairs-column)"
printf "%s\n" "set-option global highlight_current_column_hook_cmd nop"
fi
# set hook
if [ "$kak_opt_highlight_current_column" = true ] || [ "$kak_opt_highlight_current_line" = true ]; then
printf "%s\n" "hook global -group crosshairs RawKey .+ crosshairs-update"
else
printf "%s\n" "remove-hooks global crosshairs"
fi
}
}
define-command crosshairs -docstring "Toggle Crosshairs or line/col highlighting" %{
evaluate-commands %sh{
if [ "$kak_opt_highlight_current_column" = true ] && [ "$kak_opt_highlight_current_line" = true ]; then
printf "%s\n" "set-option global highlight_current_line false"
printf "%s\n" "set-option global highlight_current_column false"
else
printf "%s\n" "set-option global highlight_current_line true"
printf "%s\n" "set-option global highlight_current_column true"
fi
}
crosshairs-change-hooks
crosshairs-update
}
define-command cursorline -docstring "Toggle Highlighting for current line" %{
evaluate-commands %sh{
if [ "$kak_opt_highlight_current_line" = true ] ; then
printf "%s\n" "set-option global highlight_current_line false"
else
printf "%s\n" "set-option global highlight_current_line true"
fi
}
crosshairs-change-hooks
crosshairs-update
}
define-command cursorcolumn -docstring "Toggle highlighting for current column" %{
evaluate-commands %sh{
if [ "$kak_opt_highlight_current_column" = true ] ; then
printf "%s\n" "set-option global highlight_current_column false"
else
printf "%s\n" "set-option global highlight_current_column true"
fi
}
crosshairs-change-hooks
crosshairs-update
}