tkwait window $w
}
-proc makewindow {rargs} {
+proc makewindow {} {
- global canv canv2 canv3 linespc charspc ctext cflist textfont
+ global canv canv2 canv3 linespc charspc ctext cflist textfont mainfont uifont
global findtype findtypemenu findloc findstring fstring geometry
global entries sha1entry sha1string sha1but
global maincursor textcursor curtextcursor
menu .bar
.bar add cascade -label "File" -menu .bar.file
+ .bar configure -font $uifont
menu .bar.file
- .bar.file add command -label "Update" -command [list updatecommits $rargs]
+ .bar.file add command -label "Update" -command updatecommits
.bar.file add command -label "Reread references" -command rereadrefs
.bar.file add command -label "Quit" -command doquit
+ .bar.file configure -font $uifont
menu .bar.edit
.bar add cascade -label "Edit" -menu .bar.edit
.bar.edit add command -label "Preferences" -command doprefs
+ .bar.edit configure -font $uifont
+ menu .bar.view
+ .bar add cascade -label "View" -menu .bar.view
+ .bar.view add command -label "New view..." -command newview
+ .bar.view add command -label "Delete view" -command delview -state disabled
+ .bar.view add separator
+ .bar.view add command -label "All files" -command {showview 0}
menu .bar.help
.bar add cascade -label "Help" -menu .bar.help
.bar.help add command -label "About gitk" -command about
pack $w.ok -side bottom
}
+ proc keys {} {
+ set w .keys
+ if {[winfo exists $w]} {
+ raise $w
+ return
+ }
+ toplevel $w
+ wm title $w "Gitk key bindings"
+ message $w.m -text {
+ Gitk key bindings:
+
+ <Ctrl-Q> Quit
+ <Home> Move to first commit
+ <End> Move to last commit
+ <Up>, p, i Move up one commit
+ <Down>, n, k Move down one commit
+ <Left>, z, j Go back in history list
+ <Right>, x, l Go forward in history list
+ <PageUp> Move up one page in commit list
+ <PageDown> Move down one page in commit list
+ <Ctrl-Home> Scroll to top of commit list
+ <Ctrl-End> Scroll to bottom of commit list
+ <Ctrl-Up> Scroll commit list up one line
+ <Ctrl-Down> Scroll commit list down one line
+ <Ctrl-PageUp> Scroll commit list up one page
+ <Ctrl-PageDown> Scroll commit list down one page
+ <Delete>, b Scroll diff view up one page
+ <Backspace> Scroll diff view up one page
+ <Space> Scroll diff view down one page
+ u Scroll diff view up 18 lines
+ d Scroll diff view down 18 lines
+ <Ctrl-F> Find
+ <Ctrl-G> Move to next find hit
+ <Ctrl-R> Move to previous find hit
+ <Return> Move to next find hit
+ / Move to next find hit, or redo find
+ ? Move to previous find hit
+ f Scroll diff view to next file
+ <Ctrl-KP+> Increase font size
+ <Ctrl-plus> Increase font size
+ <Ctrl-KP-> Decrease font size
+ <Ctrl-minus> Decrease font size
+ } \
+ -justify left -bg white -border 2 -relief sunken
+ pack $w.m -side top -fill both
+ button $w.ok -text Close -command "destroy $w"
+ pack $w.ok -side bottom
+ }
+
+proc newview {} {
+ global newviewname nextviewnum newviewtop
+
+ set top .gitkview
+ if {[winfo exists $top]} {
+ raise $top
+ return
+ }
+ set newviewtop $top
+ toplevel $top
+ wm title $top "Gitk view definition"
+ label $top.nl -text "Name"
+ entry $top.name -width 20 -textvariable newviewname
+ set newviewname "View $nextviewnum"
+ grid $top.nl $top.name -sticky w
+ label $top.l -text "Files and directories to include:"
+ grid $top.l - -sticky w -pady 10
+ text $top.t -width 30 -height 10
+ grid $top.t - -sticky w
+ frame $top.buts
+ button $top.buts.ok -text "OK" -command newviewok
+ button $top.buts.can -text "Cancel" -command newviewcan
+ grid $top.buts.ok $top.buts.can
+ grid columnconfigure $top.buts 0 -weight 1 -uniform a
+ grid columnconfigure $top.buts 1 -weight 1 -uniform a
+ grid $top.buts - -pady 10 -sticky ew
+ focus $top.t
+}
+
+proc newviewok {} {
+ global newviewtop nextviewnum
+ global viewname viewfiles
+
+ set n $nextviewnum
+ incr nextviewnum
+ set viewname($n) [$newviewtop.name get]
+ set files {}
+ foreach f [split [$newviewtop.t get 0.0 end] "\n"] {
+ set ft [string trim $f]
+ if {$ft ne {}} {
+ lappend files $ft
+ }
+ }
+ set viewfiles($n) $files
+ catch {destroy $newviewtop}
+ unset newviewtop
+ .bar.view add command -label $viewname($n) -command [list showview $n]
+ after idle showview $n
+}
+
+proc newviewcan {} {
+ global newviewtop
+
+ catch {destroy $newviewtop}
+ unset newviewtop
+}
+
+proc delview {} {
+ global curview viewdata
+
+ if {$curview == 0} return
+ set nmenu [.bar.view index end]
+ set targetcmd [list showview $curview]
+ for {set i 5} {$i <= $nmenu} {incr i} {
+ if {[.bar.view entrycget $i -command] eq $targetcmd} {
+ .bar.view delete $i
+ break
+ }
+ }
+ set viewdata($curview) {}
+ showview 0
+}
+
+proc showview {n} {
+ global curview viewdata viewfiles
+ global displayorder parentlist childlist rowidlist rowoffsets
+ global colormap rowtextx commitrow
+ global numcommits rowrangelist commitlisted idrowranges
+ global selectedline currentid canv canvy0
+ global matchinglines treediffs
+ global parsed_args
+ global pending_select phase
+
+ if {$n == $curview} return
+ set selid {}
+ if {[info exists selectedline]} {
+ set selid $currentid
+ set y [yc $selectedline]
+ set ymax [lindex [$canv cget -scrollregion] 3]
+ set span [$canv yview]
+ set ytop [expr {[lindex $span 0] * $ymax}]
+ set ybot [expr {[lindex $span 1] * $ymax}]
+ if {$ytop < $y && $y < $ybot} {
+ set yscreen [expr {$y - $ytop}]
+ } else {
+ set yscreen [expr {($ybot - $ytop) / 2}]
+ }
+ }
+ unselectline
+ stopfindproc
+ if {$curview >= 0 && $phase eq {} && ![info exists viewdata($curview)]} {
+ set viewdata($curview) \
+ [list $displayorder $parentlist $childlist $rowidlist \
+ $rowoffsets $rowrangelist $commitlisted]
+ }
+ catch {unset matchinglines}
+ catch {unset treediffs}
+ clear_display
+ readrefs
+
+ set curview $n
+ .bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
+
+ if {![info exists viewdata($n)]} {
+ set args $parsed_args
+ if {$viewfiles($n) ne {}} {
+ set args [concat $args "--" $viewfiles($n)]
+ }
+ set pending_select $selid
+ getcommits $args
+ return
+ }
+
+ set displayorder [lindex $viewdata($n) 0]
+ set parentlist [lindex $viewdata($n) 1]
+ set childlist [lindex $viewdata($n) 2]
+ set rowidlist [lindex $viewdata($n) 3]
+ set rowoffsets [lindex $viewdata($n) 4]
+ set rowrangelist [lindex $viewdata($n) 5]
+ set commitlisted [lindex $viewdata($n) 6]
+ set numcommits [llength $displayorder]
+ catch {unset colormap}
+ catch {unset rowtextx}
+ catch {unset commitrow}
+ catch {unset idrowranges}
+ set curview $n
+ set row 0
+ foreach id $displayorder {
+ set commitrow($id) $row
+ incr row
+ }
+ setcanvscroll
+ set yf 0
+ set row 0
+ if {$selid ne {} && [info exists commitrow($selid)]} {
+ set row $commitrow($selid)
+ # try to get the selected row in the same position on the screen
+ set ymax [lindex [$canv cget -scrollregion] 3]
+ set ytop [expr {[yc $row] - $yscreen}]
+ if {$ytop < 0} {
+ set ytop 0
+ }
+ set yf [expr {$ytop * 1.0 / $ymax}]
+ }
+ allcanvs yview moveto $yf
+ drawvisible
+ selectline $row 0
+}
+
proc shortids {ids} {
set res {}
foreach id $ids {
selectline $l 1
}
+ proc selnextpage {dir} {
+ global canv linespc selectedline numcommits
+
+ set lpp [expr {([winfo height $canv] - 2) / $linespc}]
+ if {$lpp < 1} {
+ set lpp 1
+ }
+ allcanvs yview scroll [expr {$dir * $lpp}] units
+ if {![info exists selectedline]} return
+ set l [expr {$selectedline + $dir * $lpp}]
+ if {$l < 0} {
+ set l 0
+ } elseif {$l >= $numcommits} {
+ set l [expr $numcommits - 1]
+ }
+ unmarkmatches
+ selectline $l 1
+ }
+
proc unselectline {} {
- global selectedline
+ global selectedline currentid
catch {unset selectedline}
+ catch {unset currentid}
allcanvs delete secsel
}