Fossil SCM
Automatically shrink the width of the merge-info --tk GUI so that it fits into the available console space.
Commit
e75753438a31225e4ed5e8a9536fdf0c02ef760a20137b8fecee7325b06e250d
Parent
bbf6c30747c6a45…
1 file changed
+14
-4
+14
-4
| --- src/merge.tcl | ||
| +++ src/merge.tcl | ||
| @@ -223,12 +223,11 @@ | ||
| 223 | 223 | set mx $lnA |
| 224 | 224 | if {$lnB>$mx} {set mx $lnB} |
| 225 | 225 | if {$lnC>$mx} {set mx $lnC} |
| 226 | 226 | if {$lnD>$mx} {set mx $lnD} |
| 227 | 227 | 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]] | |
| 230 | 229 | .lnA config -width $lnWidth |
| 231 | 230 | .lnB config -width $lnWidth |
| 232 | 231 | .lnC config -width $lnWidth |
| 233 | 232 | .lnD config -width $lnWidth |
| 234 | 233 | grid columnconfig . {0 2 4 6} -minsize $lnWidth |
| @@ -442,13 +441,13 @@ | ||
| 442 | 441 | %W selection clear 0 end |
| 443 | 442 | %W selection set @%x,%y |
| 444 | 443 | } |
| 445 | 444 | } |
| 446 | 445 | |
| 447 | -foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} { | |
| 446 | +foreach {side syncCol} {A .txtA B .txtB C .txtC D .txtD} { | |
| 448 | 447 | set ln .ln$side |
| 449 | - text $ln | |
| 448 | + text $ln -width 6 | |
| 450 | 449 | $ln tag config - -justify right |
| 451 | 450 | |
| 452 | 451 | set txt .txt$side |
| 453 | 452 | text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \ |
| 454 | 453 | -xscroll ".sbx$side set" |
| @@ -460,10 +459,21 @@ | ||
| 460 | 459 | $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \ |
| 461 | 460 | -justify center |
| 462 | 461 | $txt tag config err -foreground $CFG(ERR_FG) |
| 463 | 462 | } |
| 464 | 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 | +} | |
| 465 | 475 | |
| 466 | 476 | foreach c [cols] { |
| 467 | 477 | set keyPrefix [string toupper [colType $c]]_COL_ |
| 468 | 478 | if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}} |
| 469 | 479 | $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \ |
| 470 | 480 |
| --- 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 |