git-gui: Enable jumping to a specific line number in blame view.
This patch adds a goto control similar to the search control currently available. The goto control permits the user to specify a line number to jump to. When in blame, Control-G is bound to display this control. Signed-off-by: David Fries <David@Fries.net> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
David Fries committed
Jul 16, 2011 at 20:47 UTC
9a483e5c093bc5fa364e02b7a4aeb26dde99a5e9
2 files changed
+75
lib/blame.tcl
+11
@@ -22,6 +22,7 @@ field w_asim ; # text column: annotations (simple computation)
22
field w_file ; # text column: actual file data
23
field w_cviewer ; # pane showing commit message
24
field finder ; # find mini-dialog frame
25
+field gotoline ; # line goto mini-dialog frame
26
field status ; # status mega-widget instance
27
field old_height ; # last known height of $w.file_pane
28
@@ -231,6 +232,11 @@ constructor new {i_commit i_path i_jump} {
232
-column [expr {[llength $w_columns] - 1}] \
233
]
234
235
+ set gotoline [::linebar::new \
236
+ $w.file_pane.out.lf $w_file \
237
+ -column [expr {[llength $w_columns] - 1}] \
238
+ ]
239
+
240
set w_cviewer $w.file_pane.cm.t
241
text $w_cviewer \
242
-background white \
@@ -275,6 +281,10 @@ constructor new {i_commit i_path i_jump} {
281
-label [mc "Find Text..."] \
282
-accelerator F7 \
283
-command [list searchbar::show $finder]
284
+ $w.ctxm add command \
285
+ -label [mc "Goto Line..."] \
286
+ -accelerator "Ctrl-G" \
287
+ -command [list linebar::show $gotoline]
288
menu $w.ctxm.enc
289
build_encoding_menu $w.ctxm.enc [cb _setencoding]
290
$w.ctxm add cascade \
@@ -345,6 +355,7 @@ constructor new {i_commit i_path i_jump} {
355
bind $top <Escape> [list searchbar::hide $finder]
356
bind $top <F3> [list searchbar::find_next $finder]
357
bind $top <Shift-F3> [list searchbar::find_prev $finder]
358
+ bind $top <Control-Key-g> [list linebar::show $gotoline]
359
catch { bind $top <Shift-Key-XF86_Switch_VT_3> [list searchbar::find_prev $finder] }
360
361
grid configure $w.header -sticky ew
lib/line.tcl
new
+64
@@ -0,0 +1,64 @@
1
+# goto line number
2
+# based on code from gitk, Copyright (C) Paul Mackerras
3
+
4
+class linebar {
5
+
6
+field w
7
+field ctext
8
+
9
+field linenum {}
10
+
11
+constructor new {i_w i_text args} {
12
+ global use_ttk NS
13
+ set w $i_w
14
+ set ctext $i_text
15
+
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]
20
+
21
+ pack $w.l -side left
22
+ pack $w.bn -side right
23
+ pack $w.ent -side left -expand 1 -fill x
24
+
25
+ eval grid conf $w -sticky we $args
26
+ grid remove $w
27
+
28
+ bind $w.ent <Return> [cb _incrgoto]
29
+ bind $w.ent <Escape> [list linebar::hide $this]
30
+
31
+ bind $w <Destroy> [list delete_this $this]
32
+ return $this
33
+}
34
+
35
+method show {} {
36
+ if {![visible $this]} {
37
+ grid $w
38
+ }
39
+ focus -force $w.ent
40
+}
41
+
42
+method hide {} {
43
+ if {[visible $this]} {
44
+ focus $ctext
45
+ grid remove $w
46
+ }
47
+}
48
+
49
+method visible {} {
50
+ return [winfo ismapped $w]
51
+}
52
+
53
+method editor {} {
54
+ return $w.ent
55
+}
56
+
57
+method _incrgoto {} {
58
+ if {$linenum ne {}} {
59
+ $ctext see $linenum.0
60
+ hide $this
61
+ }
62
+}
63
+
64
+}