-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruler.kak
60 lines (53 loc) · 1.45 KB
/
ruler.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
define-command -hidden normal-line-numbers %{
add-highlighter -override window/ruler number-lines -hlcursor -separator ' '
}
define-command -hidden relative-line-numbers %{
add-highlighter -override window/ruler number-lines -relative -hlcursor -separator ' '
}
define-command -hidden no-line-numbers %{
remove-highlighter window/ruler
}
declare-option -hidden bool ruler_enabled true
define-command -params 1 disable-ruler %{
set-option %arg{1} ruler_enabled false
update-ruler
}
define-command -params 1 enable-ruler %{
set-option %arg{1} ruler_enabled true
update-ruler
}
define-command -hidden update-ruler %{
eval %sh{
if [ "$kak_opt_readonly" = 'true' -o "$kak_opt_ruler_enabled" = 'false' ]; then
echo no-line-numbers
elif [ "$kak_opt_normal_mode" = 'true' ] && [ "$kak_opt_focused" = 'true' ]; then
echo relative-line-numbers
else
echo normal-line-numbers
fi
}
}
declare-option -hidden bool normal_mode
declare-option -hidden bool focused
hook global WinCreate '.*' %{
set-option window normal_mode true
set-option window focused true
update-ruler
}
hook global ModeChange '.*:.*:normal' %{
set-option window normal_mode true
update-ruler
}
hook global ModeChange '.*:normal:.*' %{
set-option window normal_mode false
update-ruler
}
hook global FocusIn '.*' %{
set-option window focused true
update-ruler
}
hook global FocusOut '.*' %{
set-option window focused false
update-ruler
}
hook global WinSetOption 'readonly=.*' update-ruler