Skip to content

Commit

Permalink
git-gui: only accept numbers in the goto-line input
Browse files Browse the repository at this point in the history
Signed-off-by: Bert Wesarg <[email protected]>
Signed-off-by: Pat Thoyts <[email protected]>
  • Loading branch information
bertwesarg authored and patthoyts committed Oct 15, 2011
1 parent e0e0a6c commit 5925210
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/line.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ constructor new {i_w i_text args} {

${NS}::frame $w
${NS}::label $w.l -text [mc "Goto Line:"]
entry $w.ent -textvariable ${__this}::linenum -background lightgreen
entry $w.ent \
-textvariable ${__this}::linenum \
-background lightgreen \
-validate key \
-validatecommand [cb _validate %P]
${NS}::button $w.bn -text [mc Go] -command [cb _incrgoto]

pack $w.l -side left
Expand All @@ -26,7 +30,7 @@ constructor new {i_w i_text args} {
grid remove $w

bind $w.ent <Return> [cb _incrgoto]
bind $w.ent <Escape> [list linebar::hide $this]
bind $w.ent <Escape> [cb hide]

bind $w <Destroy> [list delete_this $this]
return $this
Expand Down Expand Up @@ -54,6 +58,11 @@ method editor {} {
return $w.ent
}

method _validate {P} {
# only accept numbers as input
string is integer $P
}

method _incrgoto {} {
if {$linenum ne {}} {
$ctext see $linenum.0
Expand Down

0 comments on commit 5925210

Please sign in to comment.