git-gui: only accept numbers in the goto-line input

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>

Bert Wesarg committed Oct 13, 2011 at 15:48 UTC 59252107ac24d5efb0d411ef4c2b279aa217cd7d
1 file changed +11 -2
lib/line.tcl
+11 -2
@@ -15,7 +15,11 @@ constructor new {i_w i_text args} {
15
16 ${NS}::frame $w
17 ${NS}::label $w.l -text [mc "Goto Line:"]
18 - entry $w.ent -textvariable ${__this}::linenum -background lightgreen
18 + entry $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]
24
25 pack $w.l -side left
@@ -26,7 +30,7 @@ constructor new {i_w i_text args} {
30 grid remove $w
31
32 bind $w.ent <Return> [cb _incrgoto]
29 - bind $w.ent <Escape> [list linebar::hide $this]
33 + bind $w.ent <Escape> [cb hide]
34
35 bind $w <Destroy> [list delete_this $this]
36 return $this
@@ -54,6 +58,11 @@ method editor {} {
58 return $w.ent
59 }
60
61 +method _validate {P} {
62 + # only accept numbers as input
63 + string is integer $P
64 +}
65 +
66 method _incrgoto {} {
67 if {$linenum ne {}} {
68 $ctext see $linenum.0