Fossil SCM
Improvements to "3-way --tk"
Commit
4a70c64a51b284b6fabafe3431f2d3d5733ed292b645a510df3b6c4f7ba23241
Parent
c4b68636e2d895c…
1 file changed
+14
-26
+14
-26
| --- src/merge.tcl | ||
| +++ src/merge.tcl | ||
| @@ -5,15 +5,14 @@ | ||
| 5 | 5 | # |
| 6 | 6 | # set fossilcmd {| "./fossil" diff --tcl -i -v} |
| 7 | 7 | # |
| 8 | 8 | # This header comment is stripped off by the "mkbuiltin.c" program. |
| 9 | 9 | # |
| 10 | -set prog { | |
| 11 | 10 | package require Tk |
| 12 | 11 | |
| 13 | 12 | array set CFG_light { |
| 14 | - TITLE {Fossil Diff} | |
| 13 | + TITLE {Fossil Merge} | |
| 15 | 14 | LN_COL_BG #dddddd |
| 16 | 15 | LN_COL_FG #444444 |
| 17 | 16 | TXT_COL_BG #ffffff |
| 18 | 17 | TXT_COL_FG #000000 |
| 19 | 18 | MKR_COL_BG #444444 |
| @@ -33,11 +32,11 @@ | ||
| 33 | 32 | HEIGHT 45 |
| 34 | 33 | LB_HEIGHT 25 |
| 35 | 34 | } |
| 36 | 35 | |
| 37 | 36 | array set CFG_dark { |
| 38 | - TITLE {Fossil Diff} | |
| 37 | + TITLE {Fossil Merge} | |
| 39 | 38 | LN_COL_BG #dddddd |
| 40 | 39 | LN_COL_FG #444444 |
| 41 | 40 | TXT_COL_BG #3f3f3f |
| 42 | 41 | TXT_COL_FG #dcdccc |
| 43 | 42 | MKR_COL_BG #444444 |
| @@ -163,11 +162,11 @@ | ||
| 163 | 162 | .txtC insert end [string range $B 1 end]\n chng |
| 164 | 163 | } else { |
| 165 | 164 | .txtC insert end [string range $C 1 end]\n $tag |
| 166 | 165 | } |
| 167 | 166 | } |
| 168 | - if {$key4=="."} { | |
| 167 | + if {$key4=="." || $key4=="X"} { | |
| 169 | 168 | .lnD insert end \n - |
| 170 | 169 | .txtD insert end \n $dtag |
| 171 | 170 | } else { |
| 172 | 171 | .lnD insert end $lnD\n - |
| 173 | 172 | incr lnD |
| @@ -175,12 +174,10 @@ | ||
| 175 | 174 | .txtD insert end [string range $A 1 end]\n - |
| 176 | 175 | } elseif {$key4=="2"} { |
| 177 | 176 | .txtD insert end [string range $B 1 end]\n chng |
| 178 | 177 | } elseif {$key4=="3"} { |
| 179 | 178 | .txtD insert end [string range $C 1 end]\n add |
| 180 | - } elseif {$key4=="X"} { | |
| 181 | - .txtD insert end " \n" rm | |
| 182 | 179 | } else { |
| 183 | 180 | .txtD insert end [string range $D 1 end]\n - |
| 184 | 181 | } |
| 185 | 182 | } |
| 186 | 183 | } |
| @@ -350,10 +347,11 @@ | ||
| 350 | 347 | } |
| 351 | 348 | bind .wfiles.lb <Motion> { |
| 352 | 349 | %W selection clear 0 end |
| 353 | 350 | %W selection set @%x,%y |
| 354 | 351 | } |
| 352 | + | |
| 355 | 353 | |
| 356 | 354 | foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} { |
| 357 | 355 | set ln .ln$side |
| 358 | 356 | text $ln |
| 359 | 357 | $ln tag config - -justify right |
| @@ -394,29 +392,17 @@ | ||
| 394 | 392 | frame .spacer |
| 395 | 393 | |
| 396 | 394 | readMerge $fossilcmd |
| 397 | 395 | update idletasks |
| 398 | 396 | |
| 399 | -proc saveDiff {} { | |
| 400 | - set fn [tk_getSaveFile] | |
| 401 | - if {$fn==""} return | |
| 402 | - set out [open $fn wb] | |
| 403 | - puts $out "#!/usr/bin/tclsh\n#\n# Run this script using 'tclsh' or 'wish'" | |
| 404 | - puts $out "# to see the graphical diff.\n#" | |
| 405 | - puts $out "set fossilcmd {}" | |
| 406 | - puts $out "set prog [list $::prog]" | |
| 407 | - puts $out "set mergetxt \173" | |
| 408 | - foreach e $::mergetxt {puts $out [list $e]} | |
| 409 | - puts $out "\175" | |
| 410 | - puts $out "eval \$prog" | |
| 411 | - close $out | |
| 412 | -} | |
| 413 | 397 | proc searchOnOff {} { |
| 414 | 398 | if {[info exists ::search]} { |
| 415 | 399 | unset ::search |
| 416 | 400 | .txtA tag remove search 1.0 end |
| 417 | 401 | .txtB tag remove search 1.0 end |
| 402 | + .txtC tag remove search 1.0 end | |
| 403 | + .txtD tag remove search 1.0 end | |
| 418 | 404 | pack forget .bb.sframe |
| 419 | 405 | focus . |
| 420 | 406 | } else { |
| 421 | 407 | set ::search .txtA |
| 422 | 408 | if {![winfo exists .bb.sframe]} { |
| @@ -441,11 +427,16 @@ | ||
| 441 | 427 | proc searchStep {direction incr start stop} { |
| 442 | 428 | set pattern [.bb.sframe.e get] |
| 443 | 429 | if {$pattern==""} return |
| 444 | 430 | set count 0 |
| 445 | 431 | set w $::search |
| 446 | - if {"$w"==".txtA"} {set other .txtB} {set other .txtA} | |
| 432 | + switch $w { | |
| 433 | + .txtA {set other .txtB} | |
| 434 | + .txtB {set other .txtC} | |
| 435 | + .txtC {set other .txtD} | |
| 436 | + default {set other .txtA} | |
| 437 | + } | |
| 447 | 438 | if {[lsearch [$w mark names] search]<0} { |
| 448 | 439 | $w mark set search $start |
| 449 | 440 | } |
| 450 | 441 | switch $::search_type { |
| 451 | 442 | Exact {set st -exact} |
| @@ -476,15 +467,14 @@ | ||
| 476 | 467 | $w tag config search -background {#fcc000} |
| 477 | 468 | } |
| 478 | 469 | set ::search $w |
| 479 | 470 | } |
| 480 | 471 | ::ttk::button .bb.quit -text {Quit} -command exit |
| 481 | -::ttk::button .bb.save -text {Save As...} -command saveDiff | |
| 482 | 472 | ::ttk::button .bb.search -text {Search} -command searchOnOff |
| 483 | 473 | pack .bb.quit -side left |
| 484 | -if {$fossilcmd!=""} {pack .bb.save -side left} | |
| 485 | -pack .bb.files .bb.search -side left | |
| 474 | +# pack .bb.files -side left | |
| 475 | +pack .bb.search -side left | |
| 486 | 476 | grid rowconfigure . 1 -weight 1 |
| 487 | 477 | set rn 0 |
| 488 | 478 | foreach {lnwid txtwid} [cols] { |
| 489 | 479 | grid columnconfigure . $rn -weight 1 -uniform a |
| 490 | 480 | grid columnconfigure . [expr {$rn+1}] -weight 1 -uniform b |
| @@ -497,7 +487,5 @@ | ||
| 497 | 487 | grid .spacer -row 2 -column 2 |
| 498 | 488 | grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew |
| 499 | 489 | |
| 500 | 490 | .spacer config -height [winfo height .sbxA] |
| 501 | 491 | wm deiconify . |
| 502 | -} | |
| 503 | -eval $prog | |
| 504 | 492 |
| --- src/merge.tcl | |
| +++ src/merge.tcl | |
| @@ -5,15 +5,14 @@ | |
| 5 | # |
| 6 | # set fossilcmd {| "./fossil" diff --tcl -i -v} |
| 7 | # |
| 8 | # This header comment is stripped off by the "mkbuiltin.c" program. |
| 9 | # |
| 10 | set prog { |
| 11 | package require Tk |
| 12 | |
| 13 | array set CFG_light { |
| 14 | TITLE {Fossil Diff} |
| 15 | LN_COL_BG #dddddd |
| 16 | LN_COL_FG #444444 |
| 17 | TXT_COL_BG #ffffff |
| 18 | TXT_COL_FG #000000 |
| 19 | MKR_COL_BG #444444 |
| @@ -33,11 +32,11 @@ | |
| 33 | HEIGHT 45 |
| 34 | LB_HEIGHT 25 |
| 35 | } |
| 36 | |
| 37 | array set CFG_dark { |
| 38 | TITLE {Fossil Diff} |
| 39 | LN_COL_BG #dddddd |
| 40 | LN_COL_FG #444444 |
| 41 | TXT_COL_BG #3f3f3f |
| 42 | TXT_COL_FG #dcdccc |
| 43 | MKR_COL_BG #444444 |
| @@ -163,11 +162,11 @@ | |
| 163 | .txtC insert end [string range $B 1 end]\n chng |
| 164 | } else { |
| 165 | .txtC insert end [string range $C 1 end]\n $tag |
| 166 | } |
| 167 | } |
| 168 | if {$key4=="."} { |
| 169 | .lnD insert end \n - |
| 170 | .txtD insert end \n $dtag |
| 171 | } else { |
| 172 | .lnD insert end $lnD\n - |
| 173 | incr lnD |
| @@ -175,12 +174,10 @@ | |
| 175 | .txtD insert end [string range $A 1 end]\n - |
| 176 | } elseif {$key4=="2"} { |
| 177 | .txtD insert end [string range $B 1 end]\n chng |
| 178 | } elseif {$key4=="3"} { |
| 179 | .txtD insert end [string range $C 1 end]\n add |
| 180 | } elseif {$key4=="X"} { |
| 181 | .txtD insert end " \n" rm |
| 182 | } else { |
| 183 | .txtD insert end [string range $D 1 end]\n - |
| 184 | } |
| 185 | } |
| 186 | } |
| @@ -350,10 +347,11 @@ | |
| 350 | } |
| 351 | bind .wfiles.lb <Motion> { |
| 352 | %W selection clear 0 end |
| 353 | %W selection set @%x,%y |
| 354 | } |
| 355 | |
| 356 | foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} { |
| 357 | set ln .ln$side |
| 358 | text $ln |
| 359 | $ln tag config - -justify right |
| @@ -394,29 +392,17 @@ | |
| 394 | frame .spacer |
| 395 | |
| 396 | readMerge $fossilcmd |
| 397 | update idletasks |
| 398 | |
| 399 | proc saveDiff {} { |
| 400 | set fn [tk_getSaveFile] |
| 401 | if {$fn==""} return |
| 402 | set out [open $fn wb] |
| 403 | puts $out "#!/usr/bin/tclsh\n#\n# Run this script using 'tclsh' or 'wish'" |
| 404 | puts $out "# to see the graphical diff.\n#" |
| 405 | puts $out "set fossilcmd {}" |
| 406 | puts $out "set prog [list $::prog]" |
| 407 | puts $out "set mergetxt \173" |
| 408 | foreach e $::mergetxt {puts $out [list $e]} |
| 409 | puts $out "\175" |
| 410 | puts $out "eval \$prog" |
| 411 | close $out |
| 412 | } |
| 413 | proc searchOnOff {} { |
| 414 | if {[info exists ::search]} { |
| 415 | unset ::search |
| 416 | .txtA tag remove search 1.0 end |
| 417 | .txtB tag remove search 1.0 end |
| 418 | pack forget .bb.sframe |
| 419 | focus . |
| 420 | } else { |
| 421 | set ::search .txtA |
| 422 | if {![winfo exists .bb.sframe]} { |
| @@ -441,11 +427,16 @@ | |
| 441 | proc searchStep {direction incr start stop} { |
| 442 | set pattern [.bb.sframe.e get] |
| 443 | if {$pattern==""} return |
| 444 | set count 0 |
| 445 | set w $::search |
| 446 | if {"$w"==".txtA"} {set other .txtB} {set other .txtA} |
| 447 | if {[lsearch [$w mark names] search]<0} { |
| 448 | $w mark set search $start |
| 449 | } |
| 450 | switch $::search_type { |
| 451 | Exact {set st -exact} |
| @@ -476,15 +467,14 @@ | |
| 476 | $w tag config search -background {#fcc000} |
| 477 | } |
| 478 | set ::search $w |
| 479 | } |
| 480 | ::ttk::button .bb.quit -text {Quit} -command exit |
| 481 | ::ttk::button .bb.save -text {Save As...} -command saveDiff |
| 482 | ::ttk::button .bb.search -text {Search} -command searchOnOff |
| 483 | pack .bb.quit -side left |
| 484 | if {$fossilcmd!=""} {pack .bb.save -side left} |
| 485 | pack .bb.files .bb.search -side left |
| 486 | grid rowconfigure . 1 -weight 1 |
| 487 | set rn 0 |
| 488 | foreach {lnwid txtwid} [cols] { |
| 489 | grid columnconfigure . $rn -weight 1 -uniform a |
| 490 | grid columnconfigure . [expr {$rn+1}] -weight 1 -uniform b |
| @@ -497,7 +487,5 @@ | |
| 497 | grid .spacer -row 2 -column 2 |
| 498 | grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew |
| 499 | |
| 500 | .spacer config -height [winfo height .sbxA] |
| 501 | wm deiconify . |
| 502 | } |
| 503 | eval $prog |
| 504 |
| --- src/merge.tcl | |
| +++ src/merge.tcl | |
| @@ -5,15 +5,14 @@ | |
| 5 | # |
| 6 | # set fossilcmd {| "./fossil" diff --tcl -i -v} |
| 7 | # |
| 8 | # This header comment is stripped off by the "mkbuiltin.c" program. |
| 9 | # |
| 10 | package require Tk |
| 11 | |
| 12 | array set CFG_light { |
| 13 | TITLE {Fossil Merge} |
| 14 | LN_COL_BG #dddddd |
| 15 | LN_COL_FG #444444 |
| 16 | TXT_COL_BG #ffffff |
| 17 | TXT_COL_FG #000000 |
| 18 | MKR_COL_BG #444444 |
| @@ -33,11 +32,11 @@ | |
| 32 | HEIGHT 45 |
| 33 | LB_HEIGHT 25 |
| 34 | } |
| 35 | |
| 36 | array set CFG_dark { |
| 37 | TITLE {Fossil Merge} |
| 38 | LN_COL_BG #dddddd |
| 39 | LN_COL_FG #444444 |
| 40 | TXT_COL_BG #3f3f3f |
| 41 | TXT_COL_FG #dcdccc |
| 42 | MKR_COL_BG #444444 |
| @@ -163,11 +162,11 @@ | |
| 162 | .txtC insert end [string range $B 1 end]\n chng |
| 163 | } else { |
| 164 | .txtC insert end [string range $C 1 end]\n $tag |
| 165 | } |
| 166 | } |
| 167 | if {$key4=="." || $key4=="X"} { |
| 168 | .lnD insert end \n - |
| 169 | .txtD insert end \n $dtag |
| 170 | } else { |
| 171 | .lnD insert end $lnD\n - |
| 172 | incr lnD |
| @@ -175,12 +174,10 @@ | |
| 174 | .txtD insert end [string range $A 1 end]\n - |
| 175 | } elseif {$key4=="2"} { |
| 176 | .txtD insert end [string range $B 1 end]\n chng |
| 177 | } elseif {$key4=="3"} { |
| 178 | .txtD insert end [string range $C 1 end]\n add |
| 179 | } else { |
| 180 | .txtD insert end [string range $D 1 end]\n - |
| 181 | } |
| 182 | } |
| 183 | } |
| @@ -350,10 +347,11 @@ | |
| 347 | } |
| 348 | bind .wfiles.lb <Motion> { |
| 349 | %W selection clear 0 end |
| 350 | %W selection set @%x,%y |
| 351 | } |
| 352 | |
| 353 | |
| 354 | foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} { |
| 355 | set ln .ln$side |
| 356 | text $ln |
| 357 | $ln tag config - -justify right |
| @@ -394,29 +392,17 @@ | |
| 392 | frame .spacer |
| 393 | |
| 394 | readMerge $fossilcmd |
| 395 | update idletasks |
| 396 | |
| 397 | proc searchOnOff {} { |
| 398 | if {[info exists ::search]} { |
| 399 | unset ::search |
| 400 | .txtA tag remove search 1.0 end |
| 401 | .txtB tag remove search 1.0 end |
| 402 | .txtC tag remove search 1.0 end |
| 403 | .txtD tag remove search 1.0 end |
| 404 | pack forget .bb.sframe |
| 405 | focus . |
| 406 | } else { |
| 407 | set ::search .txtA |
| 408 | if {![winfo exists .bb.sframe]} { |
| @@ -441,11 +427,16 @@ | |
| 427 | proc searchStep {direction incr start stop} { |
| 428 | set pattern [.bb.sframe.e get] |
| 429 | if {$pattern==""} return |
| 430 | set count 0 |
| 431 | set w $::search |
| 432 | switch $w { |
| 433 | .txtA {set other .txtB} |
| 434 | .txtB {set other .txtC} |
| 435 | .txtC {set other .txtD} |
| 436 | default {set other .txtA} |
| 437 | } |
| 438 | if {[lsearch [$w mark names] search]<0} { |
| 439 | $w mark set search $start |
| 440 | } |
| 441 | switch $::search_type { |
| 442 | Exact {set st -exact} |
| @@ -476,15 +467,14 @@ | |
| 467 | $w tag config search -background {#fcc000} |
| 468 | } |
| 469 | set ::search $w |
| 470 | } |
| 471 | ::ttk::button .bb.quit -text {Quit} -command exit |
| 472 | ::ttk::button .bb.search -text {Search} -command searchOnOff |
| 473 | pack .bb.quit -side left |
| 474 | # pack .bb.files -side left |
| 475 | pack .bb.search -side left |
| 476 | grid rowconfigure . 1 -weight 1 |
| 477 | set rn 0 |
| 478 | foreach {lnwid txtwid} [cols] { |
| 479 | grid columnconfigure . $rn -weight 1 -uniform a |
| 480 | grid columnconfigure . [expr {$rn+1}] -weight 1 -uniform b |
| @@ -497,7 +487,5 @@ | |
| 487 | grid .spacer -row 2 -column 2 |
| 488 | grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew |
| 489 | |
| 490 | .spacer config -height [winfo height .sbxA] |
| 491 | wm deiconify . |
| 492 |