1# goto line number
2# based on code from gitk, Copyright (C) Paul Mackerras
34
class linebar {
56
field w
7field ctext
89
field linenum {}
1011
constructor new {i_w i_text args} {
12global use_ttk NS
13set w $i_w
14set ctext $i_text
1516
${NS}::frame $w
17${NS}::label $w.l -text [mc "Goto Line:"]
18entry $w.ent \
19-textvariable ${__this}::linenum \
20-background lightgreen \
21-validate key \
22-validatecommand [cb _validate %P]
23${NS}::button $w.bn -text [mc Go] -command [cb _incrgoto]
2425
pack $w.l -side left
26pack $w.bn -side right
27pack $w.ent -side left -expand 1 -fill x
2829
eval grid conf $w -sticky we $args
30grid remove $w
3132
bind $w.ent <Return> [cb _incrgoto]
33bind $w.ent <Escape> [cb hide]
3435
bind $w <Destroy> [list delete_this $this]
36return $this
37}
3839
method show {} {
40if {![visible $this]} {
41grid $w
42}
43focus -force $w.ent
44}
4546
method hide {} {
47if {[visible $this]} {
48focus $ctext
49grid remove $w
50}
51}
5253
method visible {} {
54return [winfo ismapped $w]
55}
5657
method editor {} {
58return $w.ent
59}
6061
method _validate {P} {
62# only accept numbers as input
63string is integer $P
64}
6566
method _incrgoto {} {
67if {$linenum ne {}} {
68$ctext see $linenum.0
69hide $this
70}
71}
7273
}