git-gui: Enable jumping to a specific line number in blame view.
[git/jrn.git] / lib / line.tcl
blob4913bdd9a80714be10c1b99c75d7322cc29b3174
1 # goto line number
2 # based on code from gitk, Copyright (C) Paul Mackerras
4 class linebar {
6 field w
7 field ctext
9 field linenum {}
11 constructor new {i_w i_text args} {
12 global use_ttk NS
13 set w $i_w
14 set ctext $i_text
16 ${NS}::frame $w
17 ${NS}::label $w.l -text [mc "Goto Line:"]
18 entry $w.ent -textvariable ${__this}::linenum -background lightgreen
19 ${NS}::button $w.bn -text [mc Go] -command [cb _incrgoto]
21 pack $w.l -side left
22 pack $w.bn -side right
23 pack $w.ent -side left -expand 1 -fill x
25 eval grid conf $w -sticky we $args
26 grid remove $w
28 bind $w.ent <Return> [cb _incrgoto]
29 bind $w.ent <Escape> [list linebar::hide $this]
31 bind $w <Destroy> [list delete_this $this]
32 return $this
35 method show {} {
36 if {![visible $this]} {
37 grid $w
39 focus -force $w.ent
42 method hide {} {
43 if {[visible $this]} {
44 focus $ctext
45 grid remove $w
49 method visible {} {
50 return [winfo ismapped $w]
53 method editor {} {
54 return $w.ent
57 method _incrgoto {} {
58 if {$linenum ne {}} {
59 $ctext see $linenum.0
60 hide $this