-
Notifications
You must be signed in to change notification settings - Fork 6
/
prefix.ahk
80 lines (60 loc) · 1.21 KB
/
prefix.ahk
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
;; This script provides: mark, prefix C-x, prefix argument
;; <variables>
;; - cx ... true if C-x is prefixed
;; - mark ... true if mark is active
;; - arg ... digit argument as an integer
;; <setters>
;; - set_cx()/reset_cx()
;; - set_mark()/reset_mark()
;; - set_digit_argument(n)
prefix_tt := alloc_tt()
mark_tt := alloc_tt()
;; --------------
;; set/reset mark
;; --------------
mark = 0
set_mark()
{ Global
mark := 1
ToolTip, mark, 45, 0, %mark_tt%
}
reset_mark()
{ Global
mark := 0
ToolTip, , , , %mark_tt%
}
add_hook("after_change_hook", "reset_mark")
add_hook("after_display_transition_hook", "reset_mark")
;; ----------
;; prefix C-x
;; ----------
cx = 0
set_cx()
{ Global
cx := 1
ToolTip, C-x -, 1, 0, %prefix_tt%
}
reset_cx()
{ Global
cx := 0
ToolTip, , , , %prefix_tt%
}
add_hook("pre_command_hook", "reset_cx")
;; --------------
;; digit argument
;; --------------
arg = 0
arg_internal = 0
set_digit_argument(n)
{ Global
arg_internal := n
ToolTip, %arg_internal%, 1, 0, %prefix_tt%
}
;; retrive arg from arg_internal
get_argument()
{ Global
arg := arg_internal
arg_internal = 0
ToolTip, , , , %prefix_tt%
}
add_hook("pre_command_hook", "get_argument")