gitk: Fix various bugs in the view support
authorPaul Mackerras <paulus@samba.org>
Thu, 6 Apr 2006 11:22:52 +0000 (21:22 +1000)
committerPaul Mackerras <paulus@samba.org>
Thu, 6 Apr 2006 11:22:52 +0000 (21:22 +1000)
- don't re-read refs when switching views, it's too slow; just do
it if the user did File->Update
- make the view menu use the uifont
- if we have a graph line selected, unselect it before changing the view
- if a row is selected and appears in the new view, but we have to
read in the new view, select that row when we come across it
- if no row was previously selected, or if we don't find the previously
selected row in the new view, select the first row

Signed-off-by: Paul Mackerras <paulus@samba.org>
gitk
diff --git a/gitk b/gitk
index cfd0a3a698ed912bc9a6acfebe7e4ecdffdcbcc8..093213f24dfe57bc9f9259581d541829fcaf3184 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -223,6 +223,7 @@ proc updatecommits {} {
     set curview -1
     catch {unset viewdata($n)}
     parse_args $revtreeargs
     set curview -1
     catch {unset viewdata($n)}
     parse_args $revtreeargs
+    readrefs
     showview $n
 }
 
     showview $n
 }
 
@@ -351,7 +352,8 @@ proc error_popup msg {
 }
 
 proc makewindow {} {
 }
 
 proc makewindow {} {
-    global canv canv2 canv3 linespc charspc ctext cflist textfont mainfont uifont
+    global canv canv2 canv3 linespc charspc ctext cflist
+    global textfont mainfont uifont
     global findtype findtypemenu findloc findstring fstring geometry
     global entries sha1entry sha1string sha1but
     global maincursor textcursor curtextcursor
     global findtype findtypemenu findloc findstring fstring geometry
     global entries sha1entry sha1string sha1but
     global maincursor textcursor curtextcursor
@@ -369,7 +371,7 @@ proc makewindow {} {
     .bar add cascade -label "Edit" -menu .bar.edit
     .bar.edit add command -label "Preferences" -command doprefs
     .bar.edit configure -font $uifont
     .bar add cascade -label "Edit" -menu .bar.edit
     .bar.edit add command -label "Preferences" -command doprefs
     .bar.edit configure -font $uifont
-    menu .bar.view
+    menu .bar.view -font $uifont
     .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 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
@@ -907,6 +909,7 @@ proc showview {n} {
        }
     }
     unselectline
        }
     }
     unselectline
+    normalline
     stopfindproc
     if {$curview >= 0 && $phase eq {} && ![info exists viewdata($curview)]} {
        set viewdata($curview) \
     stopfindproc
     if {$curview >= 0 && $phase eq {} && ![info exists viewdata($curview)]} {
        set viewdata($curview) \
@@ -916,7 +919,6 @@ proc showview {n} {
     catch {unset matchinglines}
     catch {unset treediffs}
     clear_display
     catch {unset matchinglines}
     catch {unset treediffs}
     clear_display
-    readrefs
 
     set curview $n
     .bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
 
     set curview $n
     .bar.view entryconf 2 -state [expr {$n == 0? "disabled": "normal"}]
@@ -1159,7 +1161,7 @@ proc layoutmore {} {
 }
 
 proc showstuff {canshow} {
 }
 
 proc showstuff {canshow} {
-    global numcommits commitrow pending_select
+    global numcommits commitrow pending_select selectedline
     global linesegends idrowranges idrangedrawn
 
     if {$numcommits == 0} {
     global linesegends idrowranges idrangedrawn
 
     if {$numcommits == 0} {
@@ -1201,6 +1203,9 @@ proc showstuff {canshow} {
        $commitrow($pending_select) < $numcommits} {
        selectline $commitrow($pending_select) 1
     }
        $commitrow($pending_select) < $numcommits} {
        selectline $commitrow($pending_select) 1
     }
+    if {![info exists selectedline] && ![info exists pending_select]} {
+       selectline 0 1
+    }
 }
 
 proc layoutrows {row endrow last} {
 }
 
 proc layoutrows {row endrow last} {
@@ -1989,7 +1994,7 @@ proc xcoord {i level ln} {
 proc finishcommits {} {
     global commitidx phase
     global canv mainfont ctext maincursor textcursor
 proc finishcommits {} {
     global commitidx phase
     global canv mainfont ctext maincursor textcursor
-    global findinprogress
+    global findinprogress pending_select
 
     if {$commitidx > 0} {
        drawrest
 
     if {$commitidx > 0} {
        drawrest
@@ -2003,6 +2008,7 @@ proc finishcommits {} {
        settextcursor $textcursor
     }
     set phase {}
        settextcursor $textcursor
     }
     set phase {}
+    catch {unset pending_select}
 }
 
 # Don't change the text pane cursor if it is currently the hand cursor,
 }
 
 # Don't change the text pane cursor if it is currently the hand cursor,
@@ -2021,12 +2027,16 @@ proc drawrest {} {
     global startmsecs
     global canvy0 numcommits linespc
     global rowlaidout commitidx
     global startmsecs
     global canvy0 numcommits linespc
     global rowlaidout commitidx
+    global pending_select
 
     set row $rowlaidout
     layoutrows $rowlaidout $commitidx 1
     layouttail
     optimize_rows $row 0 $commitidx
     showstuff $commitidx
 
     set row $rowlaidout
     layoutrows $rowlaidout $commitidx 1
     layouttail
     optimize_rows $row 0 $commitidx
     showstuff $commitidx
+    if {[info exists pending_select]} {
+       selectline 0 1
+    }
 
     set drawmsecs [expr {[clock clicks -milliseconds] - $startmsecs}]
     #puts "overall $drawmsecs ms for $numcommits commits"
 
     set drawmsecs [expr {[clock clicks -milliseconds] - $startmsecs}]
     #puts "overall $drawmsecs ms for $numcommits commits"