Fossil SCM

Improvements to the file selection option-menu in the merge UI.

drh 2024-12-05 20:08 better-merge
Commit 4582d69e34f17878eb2ff1c047d0145732dc19fc786ccb6405f1cee331f20ac8
1 file changed +8 -7
+8 -7
--- src/merge.tcl
+++ src/merge.tcl
@@ -100,11 +100,12 @@
100100
set cmd "$fossilcmd -c -1"
101101
} else {
102102
set cmd "$fossilcmd -c $ncontext"
103103
}
104104
if {[info exists current_file]} {
105
- append cmd " -tcl [list $current_file]"
105
+ regsub {^[A-Z]+ } $current_file {} fn
106
+ append cmd " -tcl [list $fn]"
106107
}
107108
if {[catch {
108109
set in [open $cmd r]
109110
fconfigure $in -encoding utf-8
110111
set mergetxt [read $in]
@@ -227,10 +228,11 @@
227228
set lnWidth [string length [format %d $mx]]
228229
.lnA config -width $lnWidth
229230
.lnB config -width $lnWidth
230231
.lnC config -width $lnWidth
231232
.lnD config -width $lnWidth
233
+ grid columnconfig . {0 2 4 6} -minsize $lnWidth
232234
}
233235
234236
proc viewDiff {idx} {
235237
.txtA yview $idx
236238
.txtA xview moveto 0
@@ -337,18 +339,17 @@
337339
}
338340
339341
frame .bb
340342
set useOptionMenu 1
341343
if {[info exists filelist]} {
342
- set current_file [lindex $filelist 1]
344
+ set current_file "[lindex $filelist 0] [lindex $filelist 1]"
343345
if {[llength $filelist]>2} {
344
- label .bb.filetag -text "File:"
345346
trace add variable current_file write readMerge
346347
347348
if {$tcl_platform(os)=="Darwin" || [llength $filelist]<30} {
348349
set fnlist {}
349
- foreach {op fn} $filelist {lappend fnlist $fn}
350
+ foreach {op fn} $filelist {lappend fnlist "$op $fn"}
350351
tk_optionMenu .bb.files current_file {*}$fnlist
351352
} else {
352353
set useOptionMenu 0
353354
::ttk::menubutton .bb.files -text $current_file
354355
if {[tk windowingsystem] eq "win32"} {
@@ -366,11 +367,11 @@
366367
-yscroll {.wfiles.sb set}
367368
set mx 1
368369
foreach {op fn} $filelist {
369370
set n [string length $fn]
370371
if {$n>$mx} {set mx $n}
371
- .wfiles.lb insert end $fn
372
+ .wfiles.lb insert end "$op $fn"
372373
}
373374
.bb.files config -width $mx
374375
::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
375376
grid .wfiles.lb .wfiles.sb -sticky ns
376377
bind .bb.files <1> {
@@ -383,11 +384,11 @@
383384
bind .wfiles <FocusOut> {wm withdraw .wfiles}
384385
bind .wfiles <Escape> {focus .}
385386
foreach evt {1 Return} {
386387
bind .wfiles.lb <$evt> {
387388
set ii [%W curselection]
388
- set ::current_file [lindex $::filelist [expr {$ii*2+1}]]
389
+ set ::current_file [%W get $ii]
389390
.bb.files config -text $::current_file
390391
focus .
391392
break
392393
}
393394
}
@@ -564,11 +565,11 @@
564565
}
565566
::ttk::button .bb.quit -text {Quit} -command exit
566567
::ttk::button .bb.search -text {Search} -command searchOnOff
567568
pack .bb.quit -side left
568569
if {[winfo exists .bb.files]} {
569
- pack .bb.filetag .bb.files -side left
570
+ pack .bb.files -side left
570571
}
571572
pack .bb.ctxtag .bb.ctx -side left
572573
pack .bb.search -side left
573574
grid rowconfigure . 1 -weight 1 -minsize [winfo reqheight .nameA]
574575
grid rowconfigure . 2 -weight 100
575576
--- src/merge.tcl
+++ src/merge.tcl
@@ -100,11 +100,12 @@
100 set cmd "$fossilcmd -c -1"
101 } else {
102 set cmd "$fossilcmd -c $ncontext"
103 }
104 if {[info exists current_file]} {
105 append cmd " -tcl [list $current_file]"
 
106 }
107 if {[catch {
108 set in [open $cmd r]
109 fconfigure $in -encoding utf-8
110 set mergetxt [read $in]
@@ -227,10 +228,11 @@
227 set lnWidth [string length [format %d $mx]]
228 .lnA config -width $lnWidth
229 .lnB config -width $lnWidth
230 .lnC config -width $lnWidth
231 .lnD config -width $lnWidth
 
232 }
233
234 proc viewDiff {idx} {
235 .txtA yview $idx
236 .txtA xview moveto 0
@@ -337,18 +339,17 @@
337 }
338
339 frame .bb
340 set useOptionMenu 1
341 if {[info exists filelist]} {
342 set current_file [lindex $filelist 1]
343 if {[llength $filelist]>2} {
344 label .bb.filetag -text "File:"
345 trace add variable current_file write readMerge
346
347 if {$tcl_platform(os)=="Darwin" || [llength $filelist]<30} {
348 set fnlist {}
349 foreach {op fn} $filelist {lappend fnlist $fn}
350 tk_optionMenu .bb.files current_file {*}$fnlist
351 } else {
352 set useOptionMenu 0
353 ::ttk::menubutton .bb.files -text $current_file
354 if {[tk windowingsystem] eq "win32"} {
@@ -366,11 +367,11 @@
366 -yscroll {.wfiles.sb set}
367 set mx 1
368 foreach {op fn} $filelist {
369 set n [string length $fn]
370 if {$n>$mx} {set mx $n}
371 .wfiles.lb insert end $fn
372 }
373 .bb.files config -width $mx
374 ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
375 grid .wfiles.lb .wfiles.sb -sticky ns
376 bind .bb.files <1> {
@@ -383,11 +384,11 @@
383 bind .wfiles <FocusOut> {wm withdraw .wfiles}
384 bind .wfiles <Escape> {focus .}
385 foreach evt {1 Return} {
386 bind .wfiles.lb <$evt> {
387 set ii [%W curselection]
388 set ::current_file [lindex $::filelist [expr {$ii*2+1}]]
389 .bb.files config -text $::current_file
390 focus .
391 break
392 }
393 }
@@ -564,11 +565,11 @@
564 }
565 ::ttk::button .bb.quit -text {Quit} -command exit
566 ::ttk::button .bb.search -text {Search} -command searchOnOff
567 pack .bb.quit -side left
568 if {[winfo exists .bb.files]} {
569 pack .bb.filetag .bb.files -side left
570 }
571 pack .bb.ctxtag .bb.ctx -side left
572 pack .bb.search -side left
573 grid rowconfigure . 1 -weight 1 -minsize [winfo reqheight .nameA]
574 grid rowconfigure . 2 -weight 100
575
--- src/merge.tcl
+++ src/merge.tcl
@@ -100,11 +100,12 @@
100 set cmd "$fossilcmd -c -1"
101 } else {
102 set cmd "$fossilcmd -c $ncontext"
103 }
104 if {[info exists current_file]} {
105 regsub {^[A-Z]+ } $current_file {} fn
106 append cmd " -tcl [list $fn]"
107 }
108 if {[catch {
109 set in [open $cmd r]
110 fconfigure $in -encoding utf-8
111 set mergetxt [read $in]
@@ -227,10 +228,11 @@
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
234 }
235
236 proc viewDiff {idx} {
237 .txtA yview $idx
238 .txtA xview moveto 0
@@ -337,18 +339,17 @@
339 }
340
341 frame .bb
342 set useOptionMenu 1
343 if {[info exists filelist]} {
344 set current_file "[lindex $filelist 0] [lindex $filelist 1]"
345 if {[llength $filelist]>2} {
 
346 trace add variable current_file write readMerge
347
348 if {$tcl_platform(os)=="Darwin" || [llength $filelist]<30} {
349 set fnlist {}
350 foreach {op fn} $filelist {lappend fnlist "$op $fn"}
351 tk_optionMenu .bb.files current_file {*}$fnlist
352 } else {
353 set useOptionMenu 0
354 ::ttk::menubutton .bb.files -text $current_file
355 if {[tk windowingsystem] eq "win32"} {
@@ -366,11 +367,11 @@
367 -yscroll {.wfiles.sb set}
368 set mx 1
369 foreach {op fn} $filelist {
370 set n [string length $fn]
371 if {$n>$mx} {set mx $n}
372 .wfiles.lb insert end "$op $fn"
373 }
374 .bb.files config -width $mx
375 ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
376 grid .wfiles.lb .wfiles.sb -sticky ns
377 bind .bb.files <1> {
@@ -383,11 +384,11 @@
384 bind .wfiles <FocusOut> {wm withdraw .wfiles}
385 bind .wfiles <Escape> {focus .}
386 foreach evt {1 Return} {
387 bind .wfiles.lb <$evt> {
388 set ii [%W curselection]
389 set ::current_file [%W get $ii]
390 .bb.files config -text $::current_file
391 focus .
392 break
393 }
394 }
@@ -564,11 +565,11 @@
565 }
566 ::ttk::button .bb.quit -text {Quit} -command exit
567 ::ttk::button .bb.search -text {Search} -command searchOnOff
568 pack .bb.quit -side left
569 if {[winfo exists .bb.files]} {
570 pack .bb.files -side left
571 }
572 pack .bb.ctxtag .bb.ctx -side left
573 pack .bb.search -side left
574 grid rowconfigure . 1 -weight 1 -minsize [winfo reqheight .nameA]
575 grid rowconfigure . 2 -weight 100
576

Keyboard Shortcuts

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