Skip to content

Commit b2ca7ab

Browse files
committed
gitk: fix history window panes position
When the history window panes in are resized by moving either of the two sashes and then the gitk window is vertically resized, the sashes fall back into their previous position without respecting the users wish for resizing. Save the sash position when the sashes are moved to make them keep their position when the window is resized afterwards. When the gitk window is opened and maximized on a screen, then closed and opened on a screen smaller than the previously used one, the author pane and time pane of the history window only are a few pixels wide and their contents are barely visible. Widen the two panes on start of gitk to a reasonable fixed size that shows a good amount of text of authors and time. Signed-off-by: Tobias Boesch <[email protected]>
1 parent f0ef5b6 commit b2ca7ab

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

gitk-git/gitk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,6 +2471,23 @@ proc makewindow {} {
24712471
-xscrollincr $linespc \
24722472
-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
24732473
.tf.histframe.pwclist add $canv
2474+
bind .tf.histframe.pwclist.canv <Configure> {
2475+
global oldsash
2476+
set parent [regsub {\.[A-Za-z]+$} %W ""]
2477+
puts "Canvas (pwclist) configuration changed saving sash \
2478+
position if parent panedwindow $parent is initialised \
2479+
(oldsash exist)"
2480+
if {[info exists oldsash($parent)]} {
2481+
set s0 [$parent sashpos 0]
2482+
set s1 [$parent sashpos 1]
2483+
puts " Sash0 is $s0"
2484+
puts " Sash1 is $s1"
2485+
set oldsash($parent) [list $s0 $s1]
2486+
puts " oldsash saved for $parent"
2487+
} else {
2488+
puts " oldsash not yet existing so oldsash is not saved for $parent"
2489+
}
2490+
}
24742491
set canv2 .tf.histframe.pwclist.canv2
24752492
canvas $canv2 \
24762493
-selectbackground $selectbgcolor \
@@ -3116,30 +3133,53 @@ proc savestuff {w} {
31163133
31173134
proc resizeclistpanes {win w} {
31183135
global oldwidth oldsash
3136+
puts "Starting resizeclistpanes..."
31193137
if {[info exists oldwidth($win)]} {
31203138
if {[info exists oldsash($win)]} {
3139+
puts " Using oldsash from window"
31213140
set s0 [lindex $oldsash($win) 0]
31223141
set s1 [lindex $oldsash($win) 1]
3142+
puts " Sash0 is $s0"
3143+
puts " Sash1 is $s1"
31233144
} else {
3145+
puts " New window creation detected"
3146+
puts " Width is $w"
3147+
puts " Using sash from window sashpos directly"
31243148
set s0 [$win sashpos 0]
31253149
set s1 [$win sashpos 1]
3150+
puts " Sash0 is $s0"
3151+
puts " Sash1 is $s1"
3152+
if {$s1 > $w - 140} {
3153+
puts " Sash1 greater than width - 140, setting max size"
3154+
set s1 [expr {$w - 140}]
3155+
if {$s0 > $s1 - 300} {
3156+
puts " Sash0 greater than sash1 - 300, setting max size"
3157+
set s0 [expr {$s1 - 300}]
3158+
}
3159+
}
31263160
}
31273161
if {$w < 60} {
3162+
puts " Narrow window ($w), scaling sash in dependency to window width"
31283163
set sash0 [expr {int($w/2 - 2)}]
31293164
set sash1 [expr {int($w*5/6 - 2)}]
31303165
} else {
3166+
puts " Wide window ($w), scaling sash in dependency to old width, oldsash and window width"
31313167
set factor [expr {1.0 * $w / $oldwidth($win)}]
31323168
set sash0 [expr {int($factor * [lindex $s0 0])}]
31333169
set sash1 [expr {int($factor * [lindex $s1 0])}]
31343170
if {$sash0 < 30} {
3171+
puts " Sash0 too small, setting min size"
31353172
set sash0 30
31363173
}
31373174
if {$sash1 < $sash0 + 20} {
3175+
puts " Sash1 smaller than sash0 + 20, setting min size"
31383176
set sash1 [expr {$sash0 + 20}]
31393177
}
31403178
if {$sash1 > $w - 10} {
3179+
puts " Sash1 greater than width - 140, setting max size"
31413180
set sash1 [expr {$w - 10}]
31423181
if {$sash0 > $sash1 - 20} {
3182+
puts " Sash0 greater than sash1 - 300, setting max size"
31433183
set sash0 [expr {$sash1 - 20}]
31443184
}
31453185
}
@@ -3149,6 +3189,7 @@ proc resizeclistpanes {win w} {
31493189
set oldsash($win) [list $sash0 $sash1]
31503190
}
31513191
set oldwidth($win) $w
3192+
puts "Finished resizeclistpanes..."
31523193
}
31533194
31543195
proc resizecdetpanes {win w} {

0 commit comments

Comments
 (0)