Fossil SCM

Improvements to "3-way --tk"

drh 2024-12-03 12:36 merge-enhancements
Commit 4a70c64a51b284b6fabafe3431f2d3d5733ed292b645a510df3b6c4f7ba23241
1 file changed +14 -26
+14 -26
--- src/merge.tcl
+++ src/merge.tcl
@@ -5,15 +5,14 @@
55
#
66
# set fossilcmd {| "./fossil" diff --tcl -i -v}
77
#
88
# This header comment is stripped off by the "mkbuiltin.c" program.
99
#
10
-set prog {
1110
package require Tk
1211
1312
array set CFG_light {
14
- TITLE {Fossil Diff}
13
+ TITLE {Fossil Merge}
1514
LN_COL_BG #dddddd
1615
LN_COL_FG #444444
1716
TXT_COL_BG #ffffff
1817
TXT_COL_FG #000000
1918
MKR_COL_BG #444444
@@ -33,11 +32,11 @@
3332
HEIGHT 45
3433
LB_HEIGHT 25
3534
}
3635
3736
array set CFG_dark {
38
- TITLE {Fossil Diff}
37
+ TITLE {Fossil Merge}
3938
LN_COL_BG #dddddd
4039
LN_COL_FG #444444
4140
TXT_COL_BG #3f3f3f
4241
TXT_COL_FG #dcdccc
4342
MKR_COL_BG #444444
@@ -163,11 +162,11 @@
163162
.txtC insert end [string range $B 1 end]\n chng
164163
} else {
165164
.txtC insert end [string range $C 1 end]\n $tag
166165
}
167166
}
168
- if {$key4=="."} {
167
+ if {$key4=="." || $key4=="X"} {
169168
.lnD insert end \n -
170169
.txtD insert end \n $dtag
171170
} else {
172171
.lnD insert end $lnD\n -
173172
incr lnD
@@ -175,12 +174,10 @@
175174
.txtD insert end [string range $A 1 end]\n -
176175
} elseif {$key4=="2"} {
177176
.txtD insert end [string range $B 1 end]\n chng
178177
} elseif {$key4=="3"} {
179178
.txtD insert end [string range $C 1 end]\n add
180
- } elseif {$key4=="X"} {
181
- .txtD insert end " \n" rm
182179
} else {
183180
.txtD insert end [string range $D 1 end]\n -
184181
}
185182
}
186183
}
@@ -350,10 +347,11 @@
350347
}
351348
bind .wfiles.lb <Motion> {
352349
%W selection clear 0 end
353350
%W selection set @%x,%y
354351
}
352
+
355353
356354
foreach {side syncCol} {A .txtB B .txtA C .txtC D .txtD} {
357355
set ln .ln$side
358356
text $ln
359357
$ln tag config - -justify right
@@ -394,29 +392,17 @@
394392
frame .spacer
395393
396394
readMerge $fossilcmd
397395
update idletasks
398396
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
-}
413397
proc searchOnOff {} {
414398
if {[info exists ::search]} {
415399
unset ::search
416400
.txtA tag remove search 1.0 end
417401
.txtB tag remove search 1.0 end
402
+ .txtC tag remove search 1.0 end
403
+ .txtD tag remove search 1.0 end
418404
pack forget .bb.sframe
419405
focus .
420406
} else {
421407
set ::search .txtA
422408
if {![winfo exists .bb.sframe]} {
@@ -441,11 +427,16 @@
441427
proc searchStep {direction incr start stop} {
442428
set pattern [.bb.sframe.e get]
443429
if {$pattern==""} return
444430
set count 0
445431
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
+ }
447438
if {[lsearch [$w mark names] search]<0} {
448439
$w mark set search $start
449440
}
450441
switch $::search_type {
451442
Exact {set st -exact}
@@ -476,15 +467,14 @@
476467
$w tag config search -background {#fcc000}
477468
}
478469
set ::search $w
479470
}
480471
::ttk::button .bb.quit -text {Quit} -command exit
481
-::ttk::button .bb.save -text {Save As...} -command saveDiff
482472
::ttk::button .bb.search -text {Search} -command searchOnOff
483473
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
486476
grid rowconfigure . 1 -weight 1
487477
set rn 0
488478
foreach {lnwid txtwid} [cols] {
489479
grid columnconfigure . $rn -weight 1 -uniform a
490480
grid columnconfigure . [expr {$rn+1}] -weight 1 -uniform b
@@ -497,7 +487,5 @@
497487
grid .spacer -row 2 -column 2
498488
grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew
499489
500490
.spacer config -height [winfo height .sbxA]
501491
wm deiconify .
502
-}
503
-eval $prog
504492
--- 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

Keyboard Shortcuts

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