Skip to content

Commit 9ca72f4

Browse files
mark987paulusmack
authored andcommitted
Make gitk save and restore window pane position on Linux and Cygwin.
Subtle bugs remained on both Cygwin and Linux that caused the various window panes to be restored in positions different than where the user last placed them. Sergey Vlasov posed a pair of suggested fixes to this, what is done here is slightly different. The basic fix here involves a) explicitly remembering and restoring the sash positions for the upper window, and b) using paneconfigure to redundantly set height and width of other elements. This redundancy is needed as Cygwin Tcl has a nasty habit of setting pane sizes to zero if their slaves are not configured with a specific size, but Linux Tcl does not honor the specific size given. Signed-off-by: Mark Levedahl <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b6047c5 commit 9ca72f4

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

gitk

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,13 @@ proc makewindow {} {
439439
panedwindow .ctop -orient vertical
440440

441441
# possibly use assumed geometry
442-
if {![info exists geometry(topheight)]} {
442+
if {![info exists geometry(pwsash0)]} {
443443
set geometry(topheight) [expr {15 * $linespc}]
444444
set geometry(topwidth) [expr {80 * $charspc}]
445445
set geometry(botheight) [expr {15 * $linespc}]
446446
set geometry(botwidth) [expr {50 * $charspc}]
447-
set geometry(canv) [expr {40 * $charspc}]
448-
set geometry(canv2) [expr {20 * $charspc}]
449-
set geometry(canv3) [expr {20 * $charspc}]
447+
set geometry(pwsash0) "[expr {40 * $charspc}] 2"
448+
set geometry(pwsash1) "[expr {60 * $charspc}] 2"
450449
}
451450

452451
# the upper half will have a paned window, a scroll bar to the right, and some stuff below
@@ -457,18 +456,20 @@ proc makewindow {} {
457456
# create three canvases
458457
set cscroll .tf.histframe.csb
459458
set canv .tf.histframe.pwclist.canv
460-
canvas $canv -width $geometry(canv) \
459+
canvas $canv \
461460
-background $bgcolor -bd 0 \
462461
-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
463462
.tf.histframe.pwclist add $canv
464463
set canv2 .tf.histframe.pwclist.canv2
465-
canvas $canv2 -width $geometry(canv2) \
464+
canvas $canv2 \
466465
-background $bgcolor -bd 0 -yscrollincr $linespc
467466
.tf.histframe.pwclist add $canv2
468467
set canv3 .tf.histframe.pwclist.canv3
469-
canvas $canv3 -width $geometry(canv3) \
468+
canvas $canv3 \
470469
-background $bgcolor -bd 0 -yscrollincr $linespc
471470
.tf.histframe.pwclist add $canv3
471+
eval .tf.histframe.pwclist sash place 0 $geometry(pwsash0)
472+
eval .tf.histframe.pwclist sash place 1 $geometry(pwsash1)
472473

473474
# a scroll bar to rule them
474475
scrollbar $cscroll -command {allcanvs yview} -highlightthickness 0
@@ -577,6 +578,8 @@ proc makewindow {} {
577578
pack .tf.bar -in .tf -side bottom -fill x
578579
pack .tf.histframe -fill both -side top -expand 1
579580
.ctop add .tf
581+
.ctop paneconfigure .tf -height $geometry(topheight)
582+
.ctop paneconfigure .tf -width $geometry(topwidth)
580583

581584
# now build up the bottom
582585
panedwindow .pwbottom -orient horizontal
@@ -638,6 +641,7 @@ proc makewindow {} {
638641
$ctext tag conf found -back yellow
639642

640643
.pwbottom add .bleft
644+
.pwbottom paneconfigure .bleft -width $geometry(botwidth)
641645

642646
# lower right
643647
frame .bright
@@ -832,9 +836,8 @@ proc savestuff {w} {
832836
puts $f "set geometry(main) [wm geometry .]"
833837
puts $f "set geometry(topwidth) [winfo width .tf]"
834838
puts $f "set geometry(topheight) [winfo height .tf]"
835-
puts $f "set geometry(canv) [winfo width $canv]"
836-
puts $f "set geometry(canv2) [winfo width $canv2]"
837-
puts $f "set geometry(canv3) [winfo width $canv3]"
839+
puts $f "set geometry(pwsash0) \"[.tf.histframe.pwclist sash coord 0]\""
840+
puts $f "set geometry(pwsash1) \"[.tf.histframe.pwclist sash coord 1]\""
838841
puts $f "set geometry(botwidth) [winfo width .bleft]"
839842
puts $f "set geometry(botheight) [winfo height .bleft]"
840843

0 commit comments

Comments
 (0)