blob: 8a971c6e7d3294c4e91eca43bd4e144926ca575e (
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
|
#console show
package require tkdnd
namespace eval ::ix {
proc qo {p t e} {
set s [$p get $e]
if {$s ne ""} {
pd [concat $t.rp _cb symbol [pdtk_enquote $s] \;]
} else {pd [concat $t.rp _cb bang \;]}
}
proc qi {p t i} {
$p selection clear 0 end
$p selection set $i
qo $p $t $i
}
proc q_go {p t d} {
array set direction "next 1 prev -1"
array set edge "next end prev 0"
set cs [$p curselection]
if {$cs eq "" && [$p index end] != 0} {
set go 0 } else {
set go [expr $direction($d) + [lindex $cs $edge($d)]]}
if {$go >= [$p index end]} {set go 0}
if {$go < 0} {set go [expr [$p index end] - 1]}
qi $p $t $go
}
}
#> q listbox
#. -selectmode extended -font {{Bitstream Vera Sans} 8} -exportselection 0
#. -relief flat -borderwidth 0 -selectborderwidth 0 -bg "#ccffcc" -fg black
#. @list foreach x [list .#args] {.- insert end $x}
#. @add .- insert end [join [lrange [list .#args] 0 end] " "]
#. @scroll .- yview scroll .#1 units
#. @symbol .- insert end {.#1}
#. @float ::ix::qi .- .| .#1
#. @clear .- delete 0 end
#. @next ::ix::q_go .- .| next
#. @prev ::ix::q_go .- .| prev
#. @cmd eval ".- .#args"
bind .- <Enter> {focus .-}
bind .- <Leave> {focus .^.c}
bind .- <4> { pd [concat .|.rp _cb scroll -5 \;]}
bind .- <5> { pd [concat .|.rp _cb scroll 5 \;]}
bind .- <Shift-MouseWheel> {.- xview scroll [expr {- (%D / 120) * 4}] units}
bind .- <ButtonPress-3> {}
bind .- <Button3-Leave> {dnd drag %W}
dnd bindtarget .- text/plain <Drop> {
foreach l [split %D "\n"] {.- insert end [regsub -- {^file:[/]+} $l "/"]}
}
dnd bindtarget .- text/uri-list <Drop> {foreach d %D {.- insert end [regsub -- {^file:[/]+} $d "/"]}}
dnd bindsource .- text/uri-list {
set sel [.- curselection]
if {$sel ne ""} {
set dd {}
foreach el $sel {
lappend dd [.- get $el]
}
return $dd
}
}
bind .- <<ListboxSelect>> {
set sel [.- curselection]
if {$sel ne ""} {
::ix::qo .- .| [lindex $sel end]
# foreach el $sel {
# ::ix::qo .- .| $el
# }
}
}
bind .- <<delete>> {
set sel [.- curselection]
if {$sel ne ""} {
for {set i [expr [llength $sel] - 1]} {0 <= $i} {incr i -1} {
.- delete [lindex $sel $i]
}
}
}
bind .- <<selectAll>> {
.- selection set 0 end
}
event add <<selectAll>> <KeyPress-a>
event add <<delete>> <Delete>
event add <<delete>> <BackSpace>
event add <<delete>> <KeyPress-d>
puts "q .- .|"
|