blob: 5a7d82fb8c97e41443b01b1d963662132f84c768 (
plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
TODO
namespace eval tile::Repeater {
variable State
set State(timer) {} ;
set State(interval) 100 ;
set State(delay) 300 ;
}
bind Repeater <Enter> { %W state active }
bind Repeater <Leave> { %W state !active }
bind Repeater <Key-space> { tile::Repeater::Activate %W }
bind Repeater <<Invoke>> { tile::Repeater::Activate %W }
bind Repeater <ButtonPress-1> { tile::Repeater::Press %W }
bind Repeater <ButtonRelease-1> { tile::Repeater::Release %W }
bind Repeater <B1-Leave> { tile::Repeater::Pause %W }
bind Repeater <B1-Enter> { tile::Repeater::Resume %W } ;
bind Repeater <B1-Enter> \
{ if {"%d" ne "NotifyUngrab"} { tile::Repeater::Resume %W } }
proc tile::Repeater::Activate {w} {
$w instate disabled { return }
set oldState [$w state pressed]
update idletasks; after 100
$w state $oldState
after idle [list $w invoke]
}
proc tile::Repeater::Press {w} {
variable State
$w instate disabled { return }
$w state pressed
$w invoke
after cancel $State(timer)
set State(timer) [after $State(delay) [list tile::Repeater::Repeat $w]]
}
proc tile::Repeater::Release {w} {
variable State
$w state !pressed
after cancel $State(timer)
}
proc tile::Repeater::Pause {w} {
variable State
$w state !pressed
after cancel $State(timer)
}
proc tile::Repeater::Resume {w} {
variable State
$w instate disabled { return }
$w state pressed
$w invoke
after cancel $State(timer)
set State(timer) [after $State(interval) [list tile::Repeater::Repeat $w]]
}
proc tile::Repeater::Repeat {w} {
variable State
$w instate disabled { return }
$w invoke
set State(timer) [after $State(interval) [list tile::Repeater::Repeat $w]]
}
|