Fossil SCM

Automatically shrink the width of the merge-info --tk GUI so that it fits into the available console space.

drh 2024-12-06 10:59 trunk
Commit e75753438a31225e4ed5e8a9536fdf0c02ef760a20137b8fecee7325b06e250d
1 file changed +14 -4
+14 -4
--- src/merge.tcl
+++ src/merge.tcl
@@ -223,12 +223,11 @@
223223
set mx $lnA
224224
if {$lnB>$mx} {set mx $lnB}
225225
if {$lnC>$mx} {set mx $lnC}
226226
if {$lnD>$mx} {set mx $lnD}
227227
global lnWidth
228
- set lnWidth [string length [format %d $mx]]
229
- if {$::tcl_platform(platform)=="windows"} {incr lnWidth}
228
+ set lnWidth [string length [format +%d $mx]]
230229
.lnA config -width $lnWidth
231230
.lnB config -width $lnWidth
232231
.lnC config -width $lnWidth
233232
.lnD config -width $lnWidth
234233
grid columnconfig . {0 2 4 6} -minsize $lnWidth
@@ -442,13 +441,13 @@
442441
%W selection clear 0 end
443442
%W selection set @%x,%y
444443
}
445444
}
446445
447
-foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} {
446
+foreach {side syncCol} {A .txtA B .txtB C .txtC D .txtD} {
448447
set ln .ln$side
449
- text $ln
448
+ text $ln -width 6
450449
$ln tag config - -justify right
451450
452451
set txt .txt$side
453452
text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \
454453
-xscroll ".sbx$side set"
@@ -460,10 +459,21 @@
460459
$txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
461460
-justify center
462461
$txt tag config err -foreground $CFG(ERR_FG)
463462
}
464463
text .mkr
464
+
465
+set mxwidth [lindex [wm maxsize .] 0]
466
+while {$CFG(WIDTH)>=40} {
467
+ set wanted [expr {([winfo reqwidth .lnA]+[winfo reqwidth .txtA])*4+30}]
468
+ if {$wanted<=$mxwidth} break
469
+ incr CFG(WIDTH) -10
470
+ .txtA config -width $CFG(WIDTH)
471
+ .txtB config -width $CFG(WIDTH)
472
+ .txtC config -width $CFG(WIDTH)
473
+ .txtD config -width $CFG(WIDTH)
474
+}
465475
466476
foreach c [cols] {
467477
set keyPrefix [string toupper [colType $c]]_COL_
468478
if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}}
469479
$c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
470480
--- src/merge.tcl
+++ src/merge.tcl
@@ -223,12 +223,11 @@
223 set mx $lnA
224 if {$lnB>$mx} {set mx $lnB}
225 if {$lnC>$mx} {set mx $lnC}
226 if {$lnD>$mx} {set mx $lnD}
227 global lnWidth
228 set lnWidth [string length [format %d $mx]]
229 if {$::tcl_platform(platform)=="windows"} {incr lnWidth}
230 .lnA config -width $lnWidth
231 .lnB config -width $lnWidth
232 .lnC config -width $lnWidth
233 .lnD config -width $lnWidth
234 grid columnconfig . {0 2 4 6} -minsize $lnWidth
@@ -442,13 +441,13 @@
442 %W selection clear 0 end
443 %W selection set @%x,%y
444 }
445 }
446
447 foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} {
448 set ln .ln$side
449 text $ln
450 $ln tag config - -justify right
451
452 set txt .txt$side
453 text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \
454 -xscroll ".sbx$side set"
@@ -460,10 +459,21 @@
460 $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
461 -justify center
462 $txt tag config err -foreground $CFG(ERR_FG)
463 }
464 text .mkr
 
 
 
 
 
 
 
 
 
 
 
465
466 foreach c [cols] {
467 set keyPrefix [string toupper [colType $c]]_COL_
468 if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}}
469 $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
470
--- src/merge.tcl
+++ src/merge.tcl
@@ -223,12 +223,11 @@
223 set mx $lnA
224 if {$lnB>$mx} {set mx $lnB}
225 if {$lnC>$mx} {set mx $lnC}
226 if {$lnD>$mx} {set mx $lnD}
227 global lnWidth
228 set lnWidth [string length [format +%d $mx]]
 
229 .lnA config -width $lnWidth
230 .lnB config -width $lnWidth
231 .lnC config -width $lnWidth
232 .lnD config -width $lnWidth
233 grid columnconfig . {0 2 4 6} -minsize $lnWidth
@@ -442,13 +441,13 @@
441 %W selection clear 0 end
442 %W selection set @%x,%y
443 }
444 }
445
446 foreach {side syncCol} {A .txtA B .txtB C .txtC D .txtD} {
447 set ln .ln$side
448 text $ln -width 6
449 $ln tag config - -justify right
450
451 set txt .txt$side
452 text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \
453 -xscroll ".sbx$side set"
@@ -460,10 +459,21 @@
459 $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
460 -justify center
461 $txt tag config err -foreground $CFG(ERR_FG)
462 }
463 text .mkr
464
465 set mxwidth [lindex [wm maxsize .] 0]
466 while {$CFG(WIDTH)>=40} {
467 set wanted [expr {([winfo reqwidth .lnA]+[winfo reqwidth .txtA])*4+30}]
468 if {$wanted<=$mxwidth} break
469 incr CFG(WIDTH) -10
470 .txtA config -width $CFG(WIDTH)
471 .txtB config -width $CFG(WIDTH)
472 .txtC config -width $CFG(WIDTH)
473 .txtD config -width $CFG(WIDTH)
474 }
475
476 foreach c [cols] {
477 set keyPrefix [string toupper [colType $c]]_COL_
478 if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}}
479 $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
480

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button