gitk: Add a goto next/previous highlighted commit function
This is invoked by shift-down/shift-up. It relies on a patch to git-diff-tree that has recently gone into the git repository, commit ID e0c97ca6 (without this it may just sit there doing waiting for git-diff-tree when looking for the next/previous highlight). Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
164ff275ad
commit
4e7d677949
186
gitk
186
gitk
@ -632,6 +632,8 @@ proc makewindow {} {
|
|||||||
bindkey <End> sellastline
|
bindkey <End> sellastline
|
||||||
bind . <Key-Up> "selnextline -1"
|
bind . <Key-Up> "selnextline -1"
|
||||||
bind . <Key-Down> "selnextline 1"
|
bind . <Key-Down> "selnextline 1"
|
||||||
|
bind . <Shift-Key-Up> "next_highlight -1"
|
||||||
|
bind . <Shift-Key-Down> "next_highlight 1"
|
||||||
bindkey <Key-Right> "goforw"
|
bindkey <Key-Right> "goforw"
|
||||||
bindkey <Key-Left> "goback"
|
bindkey <Key-Left> "goback"
|
||||||
bind . <Key-Prior> "selnextpage -1"
|
bind . <Key-Prior> "selnextpage -1"
|
||||||
@ -892,6 +894,8 @@ Gitk key bindings:
|
|||||||
<Ctrl-Down> Scroll commit list down one line
|
<Ctrl-Down> Scroll commit list down one line
|
||||||
<Ctrl-PageUp> Scroll commit list up one page
|
<Ctrl-PageUp> Scroll commit list up one page
|
||||||
<Ctrl-PageDown> Scroll commit list down one page
|
<Ctrl-PageDown> Scroll commit list down one page
|
||||||
|
<Shift-Up> Move to previous highlighted line
|
||||||
|
<Shift-Down> Move to next highlighted line
|
||||||
<Delete>, b Scroll diff view up one page
|
<Delete>, b Scroll diff view up one page
|
||||||
<Backspace> Scroll diff view up one page
|
<Backspace> Scroll diff view up one page
|
||||||
<Space> Scroll diff view down one page
|
<Space> Scroll diff view down one page
|
||||||
@ -899,11 +903,12 @@ u Scroll diff view up 18 lines
|
|||||||
d Scroll diff view down 18 lines
|
d Scroll diff view down 18 lines
|
||||||
<Ctrl-F> Find
|
<Ctrl-F> Find
|
||||||
<Ctrl-G> Move to next find hit
|
<Ctrl-G> Move to next find hit
|
||||||
<Ctrl-R> Move to previous find hit
|
|
||||||
<Return> Move to next find hit
|
<Return> Move to next find hit
|
||||||
/ Move to next find hit, or redo find
|
/ Move to next find hit, or redo find
|
||||||
? Move to previous find hit
|
? Move to previous find hit
|
||||||
f Scroll diff view to next file
|
f Scroll diff view to next file
|
||||||
|
<Ctrl-S> Search for next hit in diff view
|
||||||
|
<Ctrl-R> Search for previous hit in diff view
|
||||||
<Ctrl-KP+> Increase font size
|
<Ctrl-KP+> Increase font size
|
||||||
<Ctrl-plus> Increase font size
|
<Ctrl-plus> Increase font size
|
||||||
<Ctrl-KP-> Decrease font size
|
<Ctrl-KP-> Decrease font size
|
||||||
@ -1669,8 +1674,9 @@ proc ishighlighted {row} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc bolden {row font} {
|
proc bolden {row font} {
|
||||||
global canv linehtag selectedline
|
global canv linehtag selectedline boldrows
|
||||||
|
|
||||||
|
lappend boldrows $row
|
||||||
$canv itemconf $linehtag($row) -font $font
|
$canv itemconf $linehtag($row) -font $font
|
||||||
if {[info exists selectedline] && $row == $selectedline} {
|
if {[info exists selectedline] && $row == $selectedline} {
|
||||||
$canv delete secsel
|
$canv delete secsel
|
||||||
@ -1682,8 +1688,9 @@ proc bolden {row font} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc bolden_name {row font} {
|
proc bolden_name {row font} {
|
||||||
global canv2 linentag selectedline
|
global canv2 linentag selectedline boldnamerows
|
||||||
|
|
||||||
|
lappend boldnamerows $row
|
||||||
$canv2 itemconf $linentag($row) -font $font
|
$canv2 itemconf $linentag($row) -font $font
|
||||||
if {[info exists selectedline] && $row == $selectedline} {
|
if {[info exists selectedline] && $row == $selectedline} {
|
||||||
$canv2 delete secsel
|
$canv2 delete secsel
|
||||||
@ -1694,14 +1701,18 @@ proc bolden_name {row font} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc unbolden {rows} {
|
proc unbolden {} {
|
||||||
global mainfont
|
global mainfont boldrows
|
||||||
|
|
||||||
foreach row $rows {
|
set stillbold {}
|
||||||
|
foreach row $boldrows {
|
||||||
if {![ishighlighted $row]} {
|
if {![ishighlighted $row]} {
|
||||||
bolden $row $mainfont
|
bolden $row $mainfont
|
||||||
|
} else {
|
||||||
|
lappend stillbold $row
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
set boldrows $stillbold
|
||||||
}
|
}
|
||||||
|
|
||||||
proc addvhighlight {n} {
|
proc addvhighlight {n} {
|
||||||
@ -1730,11 +1741,8 @@ proc delvhighlight {} {
|
|||||||
|
|
||||||
if {![info exists hlview]} return
|
if {![info exists hlview]} return
|
||||||
unset hlview
|
unset hlview
|
||||||
set rows [array names vhighlights]
|
catch {unset vhighlights}
|
||||||
if {$rows ne {}} {
|
unbolden
|
||||||
unset vhighlights
|
|
||||||
unbolden $rows
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proc vhighlightmore {} {
|
proc vhighlightmore {} {
|
||||||
@ -1787,11 +1795,8 @@ proc hfiles_change {name ix op} {
|
|||||||
# delete previous highlights
|
# delete previous highlights
|
||||||
catch {close $filehighlight}
|
catch {close $filehighlight}
|
||||||
unset filehighlight
|
unset filehighlight
|
||||||
set rows [array names fhighlights]
|
catch {unset fhighlights}
|
||||||
if {$rows ne {}} {
|
unbolden
|
||||||
unset fhighlights
|
|
||||||
unbolden $rows
|
|
||||||
}
|
|
||||||
unhighlight_filelist
|
unhighlight_filelist
|
||||||
}
|
}
|
||||||
set highlight_paths {}
|
set highlight_paths {}
|
||||||
@ -1817,7 +1822,7 @@ proc makepatterns {l} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc do_file_hl {serial} {
|
proc do_file_hl {serial} {
|
||||||
global highlight_files filehighlight highlight_paths gdttype
|
global highlight_files filehighlight highlight_paths gdttype fhl_list
|
||||||
|
|
||||||
if {$gdttype eq "touching paths:"} {
|
if {$gdttype eq "touching paths:"} {
|
||||||
if {[catch {set paths [shellsplit $highlight_files]}]} return
|
if {[catch {set paths [shellsplit $highlight_files]}]} return
|
||||||
@ -1831,64 +1836,72 @@ proc do_file_hl {serial} {
|
|||||||
set filehighlight [open $cmd r+]
|
set filehighlight [open $cmd r+]
|
||||||
fconfigure $filehighlight -blocking 0
|
fconfigure $filehighlight -blocking 0
|
||||||
fileevent $filehighlight readable readfhighlight
|
fileevent $filehighlight readable readfhighlight
|
||||||
|
set fhl_list {}
|
||||||
drawvisible
|
drawvisible
|
||||||
flushhighlights
|
flushhighlights
|
||||||
}
|
}
|
||||||
|
|
||||||
proc flushhighlights {} {
|
proc flushhighlights {} {
|
||||||
global filehighlight
|
global filehighlight fhl_list
|
||||||
|
|
||||||
if {[info exists filehighlight]} {
|
if {[info exists filehighlight]} {
|
||||||
|
lappend fhl_list {}
|
||||||
puts $filehighlight ""
|
puts $filehighlight ""
|
||||||
flush $filehighlight
|
flush $filehighlight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proc askfilehighlight {row id} {
|
proc askfilehighlight {row id} {
|
||||||
global filehighlight fhighlights
|
global filehighlight fhighlights fhl_list
|
||||||
|
|
||||||
set fhighlights($row) 0
|
lappend fhl_list $id
|
||||||
|
set fhighlights($row) -1
|
||||||
puts $filehighlight $id
|
puts $filehighlight $id
|
||||||
}
|
}
|
||||||
|
|
||||||
proc readfhighlight {} {
|
proc readfhighlight {} {
|
||||||
global filehighlight fhighlights commitrow curview mainfont iddrawn
|
global filehighlight fhighlights commitrow curview mainfont iddrawn
|
||||||
|
global fhl_list
|
||||||
|
|
||||||
set n [gets $filehighlight line]
|
while {[gets $filehighlight line] >= 0} {
|
||||||
if {$n < 0} {
|
set line [string trim $line]
|
||||||
|
set i [lsearch -exact $fhl_list $line]
|
||||||
|
if {$i < 0} continue
|
||||||
|
for {set j 0} {$j < $i} {incr j} {
|
||||||
|
set id [lindex $fhl_list $j]
|
||||||
|
if {[info exists commitrow($curview,$id)]} {
|
||||||
|
set fhighlights($commitrow($curview,$id)) 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set fhl_list [lrange $fhl_list [expr {$i+1}] end]
|
||||||
|
if {$line eq {}} continue
|
||||||
|
if {![info exists commitrow($curview,$line)]} continue
|
||||||
|
set row $commitrow($curview,$line)
|
||||||
|
if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
|
||||||
|
bolden $row [concat $mainfont bold]
|
||||||
|
}
|
||||||
|
set fhighlights($row) 1
|
||||||
|
}
|
||||||
if {[eof $filehighlight]} {
|
if {[eof $filehighlight]} {
|
||||||
# strange...
|
# strange...
|
||||||
puts "oops, git-diff-tree died"
|
puts "oops, git-diff-tree died"
|
||||||
catch {close $filehighlight}
|
catch {close $filehighlight}
|
||||||
unset filehighlight
|
unset filehighlight
|
||||||
}
|
}
|
||||||
return
|
next_hlcont
|
||||||
}
|
|
||||||
set line [string trim $line]
|
|
||||||
if {$line eq {}} return
|
|
||||||
if {![info exists commitrow($curview,$line)]} return
|
|
||||||
set row $commitrow($curview,$line)
|
|
||||||
if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
|
|
||||||
bolden $row [concat $mainfont bold]
|
|
||||||
}
|
|
||||||
set fhighlights($row) 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proc find_change {name ix op} {
|
proc find_change {name ix op} {
|
||||||
global nhighlights mainfont
|
global nhighlights mainfont boldnamerows
|
||||||
global findstring findpattern findtype
|
global findstring findpattern findtype
|
||||||
|
|
||||||
# delete previous highlights, if any
|
# delete previous highlights, if any
|
||||||
set rows [array names nhighlights]
|
foreach row $boldnamerows {
|
||||||
if {$rows ne {}} {
|
|
||||||
foreach row $rows {
|
|
||||||
if {$nhighlights($row) >= 2} {
|
|
||||||
bolden_name $row $mainfont
|
bolden_name $row $mainfont
|
||||||
}
|
}
|
||||||
}
|
set boldnamerows {}
|
||||||
unset nhighlights
|
catch {unset nhighlights}
|
||||||
unbolden $rows
|
unbolden
|
||||||
}
|
|
||||||
if {$findtype ne "Regexp"} {
|
if {$findtype ne "Regexp"} {
|
||||||
set e [string map {"*" "\\*" "?" "\\?" "\[" "\\\[" "\\" "\\\\"} \
|
set e [string map {"*" "\\*" "?" "\\?" "\[" "\\\[" "\\" "\\\\"} \
|
||||||
$findstring]
|
$findstring]
|
||||||
@ -1964,11 +1977,8 @@ proc rhighlight_sel {a} {
|
|||||||
proc rhighlight_none {} {
|
proc rhighlight_none {} {
|
||||||
global rhighlights
|
global rhighlights
|
||||||
|
|
||||||
set rows [array names rhighlights]
|
catch {unset rhighlights}
|
||||||
if {$rows ne {}} {
|
unbolden
|
||||||
unset rhighlights
|
|
||||||
unbolden $rows
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
proc is_descendent {a} {
|
proc is_descendent {a} {
|
||||||
@ -2066,6 +2076,81 @@ proc askrelhighlight {row id} {
|
|||||||
set rhighlights($row) $isbold
|
set rhighlights($row) $isbold
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proc next_hlcont {} {
|
||||||
|
global fhl_row fhl_dirn displayorder numcommits
|
||||||
|
global vhighlights fhighlights nhighlights rhighlights
|
||||||
|
global hlview filehighlight findstring highlight_related
|
||||||
|
|
||||||
|
if {![info exists fhl_dirn] || $fhl_dirn == 0} return
|
||||||
|
set row $fhl_row
|
||||||
|
while {1} {
|
||||||
|
if {$row < 0 || $row >= $numcommits} {
|
||||||
|
bell
|
||||||
|
set fhl_dirn 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
set id [lindex $displayorder $row]
|
||||||
|
if {[info exists hlview]} {
|
||||||
|
if {![info exists vhighlights($row)]} {
|
||||||
|
askvhighlight $row $id
|
||||||
|
}
|
||||||
|
if {$vhighlights($row) > 0} break
|
||||||
|
}
|
||||||
|
if {$findstring ne {}} {
|
||||||
|
if {![info exists nhighlights($row)]} {
|
||||||
|
askfindhighlight $row $id
|
||||||
|
}
|
||||||
|
if {$nhighlights($row) > 0} break
|
||||||
|
}
|
||||||
|
if {$highlight_related ne "None"} {
|
||||||
|
if {![info exists rhighlights($row)]} {
|
||||||
|
askrelhighlight $row $id
|
||||||
|
}
|
||||||
|
if {$rhighlights($row) > 0} break
|
||||||
|
}
|
||||||
|
if {[info exists filehighlight]} {
|
||||||
|
if {![info exists fhighlights($row)]} {
|
||||||
|
# ask for a few more while we're at it...
|
||||||
|
set r $row
|
||||||
|
for {set n 0} {$n < 100} {incr n} {
|
||||||
|
if {![info exists fhighlights($r)]} {
|
||||||
|
askfilehighlight $r [lindex $displayorder $r]
|
||||||
|
}
|
||||||
|
incr r $fhl_dirn
|
||||||
|
if {$r < 0 || $r >= $numcommits} break
|
||||||
|
}
|
||||||
|
flushhighlights
|
||||||
|
}
|
||||||
|
if {$fhighlights($row) < 0} {
|
||||||
|
set fhl_row $row
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if {$fhighlights($row) > 0} break
|
||||||
|
}
|
||||||
|
incr row $fhl_dirn
|
||||||
|
}
|
||||||
|
set fhl_dirn 0
|
||||||
|
selectline $row 1
|
||||||
|
}
|
||||||
|
|
||||||
|
proc next_highlight {dirn} {
|
||||||
|
global selectedline fhl_row fhl_dirn
|
||||||
|
global hlview filehighlight findstring highlight_related
|
||||||
|
|
||||||
|
if {![info exists selectedline]} return
|
||||||
|
if {!([info exists hlview] || $findstring ne {} ||
|
||||||
|
$highlight_related ne "None" || [info exists filehighlight])} return
|
||||||
|
set fhl_row [expr {$selectedline + $dirn}]
|
||||||
|
set fhl_dirn $dirn
|
||||||
|
next_hlcont
|
||||||
|
}
|
||||||
|
|
||||||
|
proc cancel_next_highlight {} {
|
||||||
|
global fhl_dirn
|
||||||
|
|
||||||
|
set fhl_dirn 0
|
||||||
|
}
|
||||||
|
|
||||||
# Graph layout functions
|
# Graph layout functions
|
||||||
|
|
||||||
proc shortids {ids} {
|
proc shortids {ids} {
|
||||||
@ -2785,7 +2870,7 @@ proc drawcmittext {id row col rmx} {
|
|||||||
global commitlisted commitinfo rowidlist
|
global commitlisted commitinfo rowidlist
|
||||||
global rowtextx idpos idtags idheads idotherrefs
|
global rowtextx idpos idtags idheads idotherrefs
|
||||||
global linehtag linentag linedtag
|
global linehtag linentag linedtag
|
||||||
global mainfont canvxmax
|
global mainfont canvxmax boldrows boldnamerows
|
||||||
|
|
||||||
set ofill [expr {[lindex $commitlisted $row]? "blue": "white"}]
|
set ofill [expr {[lindex $commitlisted $row]? "blue": "white"}]
|
||||||
set x [xc $row $col]
|
set x [xc $row $col]
|
||||||
@ -2814,8 +2899,10 @@ proc drawcmittext {id row col rmx} {
|
|||||||
set nfont $mainfont
|
set nfont $mainfont
|
||||||
set isbold [ishighlighted $row]
|
set isbold [ishighlighted $row]
|
||||||
if {$isbold > 0} {
|
if {$isbold > 0} {
|
||||||
|
lappend boldrows $row
|
||||||
lappend font bold
|
lappend font bold
|
||||||
if {$isbold > 1} {
|
if {$isbold > 1} {
|
||||||
|
lappend boldnamerows $row
|
||||||
lappend nfont bold
|
lappend nfont bold
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3232,6 +3319,7 @@ proc dofind {} {
|
|||||||
|
|
||||||
stopfindproc
|
stopfindproc
|
||||||
unmarkmatches
|
unmarkmatches
|
||||||
|
cancel_next_highlight
|
||||||
focus .
|
focus .
|
||||||
set matchinglines {}
|
set matchinglines {}
|
||||||
if {$findtype == "IgnCase"} {
|
if {$findtype == "IgnCase"} {
|
||||||
@ -3490,6 +3578,7 @@ proc selectline {l isnew} {
|
|||||||
catch {unset pending_select}
|
catch {unset pending_select}
|
||||||
$canv delete hover
|
$canv delete hover
|
||||||
normalline
|
normalline
|
||||||
|
cancel_next_highlight
|
||||||
if {$l < 0 || $l >= $numcommits} return
|
if {$l < 0 || $l >= $numcommits} return
|
||||||
set y [expr {$canvy0 + $l * $linespc}]
|
set y [expr {$canvy0 + $l * $linespc}]
|
||||||
set ymax [lindex [$canv cget -scrollregion] 3]
|
set ymax [lindex [$canv cget -scrollregion] 3]
|
||||||
@ -3662,6 +3751,7 @@ proc unselectline {} {
|
|||||||
catch {unset currentid}
|
catch {unset currentid}
|
||||||
allcanvs delete secsel
|
allcanvs delete secsel
|
||||||
rhighlight_none
|
rhighlight_none
|
||||||
|
cancel_next_highlight
|
||||||
}
|
}
|
||||||
|
|
||||||
proc reselectline {} {
|
proc reselectline {} {
|
||||||
@ -5290,6 +5380,8 @@ set fh_serial 0
|
|||||||
set nhl_names {}
|
set nhl_names {}
|
||||||
set highlight_paths {}
|
set highlight_paths {}
|
||||||
set searchdirn -forwards
|
set searchdirn -forwards
|
||||||
|
set boldrows {}
|
||||||
|
set boldnamerows {}
|
||||||
|
|
||||||
set optim_delay 16
|
set optim_delay 16
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user