gitk: Add a context menu for file list entries
At the moment this just has two entries, which allow you to add the file that you clicked on to the list of filenames to highlight, or replace the list with the file. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Jul 27, 2007 at 22:30 UTC
3244729aac7515ccda651d40f41cef94517ac089
1 file changed
+36
gitk
+36
@@ -879,6 +879,7 @@ proc makewindow {} {
879
bind $cflist <1> {sel_flist %W %x %y; break}
880
bind $cflist <B1-Motion> {sel_flist %W %x %y; break}
881
bind $cflist <ButtonRelease-1> {treeclick %W %x %y}
882
+ bind $cflist <Button-3> {pop_flist_menu %W %X %Y %x %y}
883
884
set maincursor [. cget -cursor]
885
set textcursor [$ctext cget -cursor]
@@ -916,6 +917,14 @@ proc makewindow {} {
917
-command cobranch
918
$headctxmenu add command -label "Remove this branch" \
919
-command rmbranch
920
+
921
+ global flist_menu
922
+ set flist_menu .flistctxmenu
923
+ menu $flist_menu -tearoff 0
924
+ $flist_menu add command -label "Highlight this too" \
925
+ -command {flist_hl 0}
926
+ $flist_menu add command -label "Highlight this only" \
927
+ -command {flist_hl 1}
928
}
929
930
# mouse-2 makes all windows scan vertically, but only the one
@@ -1499,6 +1508,33 @@ proc sel_flist {w x y} {
1508
}
1509
}
1510
1511
+proc pop_flist_menu {w X Y x y} {
1512
+ global ctext cflist cmitmode flist_menu flist_menu_file
1513
+ global treediffs diffids
1514
+
1515
+ set l [lindex [split [$w index "@$x,$y"] "."] 0]
1516
+ if {$l <= 1} return
1517
+ if {$cmitmode eq "tree"} {
1518
+ set e [linetoelt $l]
1519
+ if {[string index $e end] eq "/"} return
1520
+ } else {
1521
+ set e [lindex $treediffs($diffids) [expr {$l-2}]]
1522
+ }
1523
+ set flist_menu_file $e
1524
+ tk_popup $flist_menu $X $Y
1525
+}
1526
+
1527
+proc flist_hl {only} {
1528
+ global flist_menu_file highlight_files
1529
+
1530
+ set x [shellquote $flist_menu_file]
1531
+ if {$only || $highlight_files eq {}} {
1532
+ set highlight_files $x
1533
+ } else {
1534
+ append highlight_files " " $x
1535
+ }
1536
+}
1537
+
1538
# Functions for adding and removing shell-type quoting
1539
1540
proc shellquote {str} {