Fossil SCM

Add the "Reload" button to the --tk diff viewer.

drh 2025-03-17 17:55 trunk
Commit 37407fe616ce198acb9cbbb54c34649138919e5bfbbb8a606c14a437e0fc300c
1 file changed +29 -5
+29 -5
--- src/diff.tcl
+++ src/diff.tcl
@@ -90,11 +90,20 @@
9090
set x [lindex $difftxt $ii]
9191
incr ii
9292
return $x
9393
}
9494
95
-proc readDiffs {fossilcmd} {
95
+proc reloadDiff {} {
96
+ global fossilcmd difftxt
97
+ unset -nocomplain difftxt
98
+ set idx [.txtA index @0,0]
99
+ readDiffs $fossilcmd 1
100
+ update
101
+ viewDiff $idx
102
+}
103
+
104
+proc readDiffs {fossilcmd redo} {
96105
global difftxt debug
97106
if {![info exists difftxt]} {
98107
if {$debug} {
99108
puts "# [list open $fossilcmd r]"
100109
flush stdout
@@ -103,20 +112,34 @@
103112
set in [open $fossilcmd r]
104113
fconfigure $in -encoding utf-8
105114
set difftxt [split [read $in] \n]
106115
close $in
107116
} msg]} {
108
- puts $msg
109
- exit 1
117
+ if {$redo} {
118
+ tk_messageBox -type ok -title Error -message "Unable to refresh:\n$msg"
119
+ return 0
120
+ } else {
121
+ puts $msg
122
+ exit 1
123
+ }
110124
}
111125
}
112126
set N [llength $difftxt]
113127
set ii 0
114128
set nDiffs 0
115129
set n1 0
116130
set n2 0
117131
array set widths {txt 3 ln 3 mkr 1}
132
+ if {$redo} {
133
+ foreach c [cols] {$c config -state normal}
134
+ .lnA delete 1.0 end
135
+ .txtA delete 1.0 end
136
+ .lnB delete 1.0 end
137
+ .txtB delete 1.0 end
138
+ .mkr delete 1.0 end
139
+ .wfiles.lb delete 0 end
140
+ }
118141
119142
120143
set fromIndex [lsearch -glob $fossilcmd *-from]
121144
set toIndex [lsearch -glob $fossilcmd *-to]
122145
set branchIndex [lsearch -glob $fossilcmd *-branch]
@@ -464,11 +487,11 @@
464487
::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
465488
::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
466489
::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
467490
frame .spacer
468491
469
-if {[readDiffs $fossilcmd] == 0} {
492
+if {[readDiffs $fossilcmd 0] == 0} {
470493
tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
471494
exit
472495
}
473496
update idletasks
474497
@@ -579,14 +602,15 @@
579602
$w tag config search -background {#fcc000}
580603
}
581604
set ::search $w
582605
}
583606
::ttk::button .bb.quit -text {Quit} -command exit
607
+::ttk::button .bb.reload -text {Reload} -command reloadDiff
584608
::ttk::button .bb.invert -text {Invert} -command invertDiff
585609
::ttk::button .bb.save -text {Save As...} -command saveDiff
586610
::ttk::button .bb.search -text {Search} -command searchOnOff
587
-pack .bb.quit .bb.invert -side left
611
+pack .bb.quit .bb.reload .bb.invert -side left
588612
if {$fossilcmd!=""} {pack .bb.save -side left}
589613
pack .bb.files .bb.search -side left
590614
grid rowconfigure . 1 -weight 1
591615
grid columnconfigure . 1 -weight 1
592616
grid columnconfigure . 4 -weight 1
593617
--- src/diff.tcl
+++ src/diff.tcl
@@ -90,11 +90,20 @@
90 set x [lindex $difftxt $ii]
91 incr ii
92 return $x
93 }
94
95 proc readDiffs {fossilcmd} {
 
 
 
 
 
 
 
 
 
96 global difftxt debug
97 if {![info exists difftxt]} {
98 if {$debug} {
99 puts "# [list open $fossilcmd r]"
100 flush stdout
@@ -103,20 +112,34 @@
103 set in [open $fossilcmd r]
104 fconfigure $in -encoding utf-8
105 set difftxt [split [read $in] \n]
106 close $in
107 } msg]} {
108 puts $msg
109 exit 1
 
 
 
 
 
110 }
111 }
112 set N [llength $difftxt]
113 set ii 0
114 set nDiffs 0
115 set n1 0
116 set n2 0
117 array set widths {txt 3 ln 3 mkr 1}
 
 
 
 
 
 
 
 
 
118
119
120 set fromIndex [lsearch -glob $fossilcmd *-from]
121 set toIndex [lsearch -glob $fossilcmd *-to]
122 set branchIndex [lsearch -glob $fossilcmd *-branch]
@@ -464,11 +487,11 @@
464 ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
465 ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
466 ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
467 frame .spacer
468
469 if {[readDiffs $fossilcmd] == 0} {
470 tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
471 exit
472 }
473 update idletasks
474
@@ -579,14 +602,15 @@
579 $w tag config search -background {#fcc000}
580 }
581 set ::search $w
582 }
583 ::ttk::button .bb.quit -text {Quit} -command exit
 
584 ::ttk::button .bb.invert -text {Invert} -command invertDiff
585 ::ttk::button .bb.save -text {Save As...} -command saveDiff
586 ::ttk::button .bb.search -text {Search} -command searchOnOff
587 pack .bb.quit .bb.invert -side left
588 if {$fossilcmd!=""} {pack .bb.save -side left}
589 pack .bb.files .bb.search -side left
590 grid rowconfigure . 1 -weight 1
591 grid columnconfigure . 1 -weight 1
592 grid columnconfigure . 4 -weight 1
593
--- src/diff.tcl
+++ src/diff.tcl
@@ -90,11 +90,20 @@
90 set x [lindex $difftxt $ii]
91 incr ii
92 return $x
93 }
94
95 proc reloadDiff {} {
96 global fossilcmd difftxt
97 unset -nocomplain difftxt
98 set idx [.txtA index @0,0]
99 readDiffs $fossilcmd 1
100 update
101 viewDiff $idx
102 }
103
104 proc readDiffs {fossilcmd redo} {
105 global difftxt debug
106 if {![info exists difftxt]} {
107 if {$debug} {
108 puts "# [list open $fossilcmd r]"
109 flush stdout
@@ -103,20 +112,34 @@
112 set in [open $fossilcmd r]
113 fconfigure $in -encoding utf-8
114 set difftxt [split [read $in] \n]
115 close $in
116 } msg]} {
117 if {$redo} {
118 tk_messageBox -type ok -title Error -message "Unable to refresh:\n$msg"
119 return 0
120 } else {
121 puts $msg
122 exit 1
123 }
124 }
125 }
126 set N [llength $difftxt]
127 set ii 0
128 set nDiffs 0
129 set n1 0
130 set n2 0
131 array set widths {txt 3 ln 3 mkr 1}
132 if {$redo} {
133 foreach c [cols] {$c config -state normal}
134 .lnA delete 1.0 end
135 .txtA delete 1.0 end
136 .lnB delete 1.0 end
137 .txtB delete 1.0 end
138 .mkr delete 1.0 end
139 .wfiles.lb delete 0 end
140 }
141
142
143 set fromIndex [lsearch -glob $fossilcmd *-from]
144 set toIndex [lsearch -glob $fossilcmd *-to]
145 set branchIndex [lsearch -glob $fossilcmd *-branch]
@@ -464,11 +487,11 @@
487 ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
488 ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
489 ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
490 frame .spacer
491
492 if {[readDiffs $fossilcmd 0] == 0} {
493 tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
494 exit
495 }
496 update idletasks
497
@@ -579,14 +602,15 @@
602 $w tag config search -background {#fcc000}
603 }
604 set ::search $w
605 }
606 ::ttk::button .bb.quit -text {Quit} -command exit
607 ::ttk::button .bb.reload -text {Reload} -command reloadDiff
608 ::ttk::button .bb.invert -text {Invert} -command invertDiff
609 ::ttk::button .bb.save -text {Save As...} -command saveDiff
610 ::ttk::button .bb.search -text {Search} -command searchOnOff
611 pack .bb.quit .bb.reload .bb.invert -side left
612 if {$fossilcmd!=""} {pack .bb.save -side left}
613 pack .bb.files .bb.search -side left
614 grid rowconfigure . 1 -weight 1
615 grid columnconfigure . 1 -weight 1
616 grid columnconfigure . 4 -weight 1
617

Keyboard Shortcuts

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