Fossil SCM
Add the "Reload" button to the --tk diff viewer.
Commit
37407fe616ce198acb9cbbb54c34649138919e5bfbbb8a606c14a437e0fc300c
Parent
d7cf18934408674…
1 file changed
+29
-5
+29
-5
| --- src/diff.tcl | ||
| +++ src/diff.tcl | ||
| @@ -90,11 +90,20 @@ | ||
| 90 | 90 | set x [lindex $difftxt $ii] |
| 91 | 91 | incr ii |
| 92 | 92 | return $x |
| 93 | 93 | } |
| 94 | 94 | |
| 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} { | |
| 96 | 105 | global difftxt debug |
| 97 | 106 | if {![info exists difftxt]} { |
| 98 | 107 | if {$debug} { |
| 99 | 108 | puts "# [list open $fossilcmd r]" |
| 100 | 109 | flush stdout |
| @@ -103,20 +112,34 @@ | ||
| 103 | 112 | set in [open $fossilcmd r] |
| 104 | 113 | fconfigure $in -encoding utf-8 |
| 105 | 114 | set difftxt [split [read $in] \n] |
| 106 | 115 | close $in |
| 107 | 116 | } 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 | + } | |
| 110 | 124 | } |
| 111 | 125 | } |
| 112 | 126 | set N [llength $difftxt] |
| 113 | 127 | set ii 0 |
| 114 | 128 | set nDiffs 0 |
| 115 | 129 | set n1 0 |
| 116 | 130 | set n2 0 |
| 117 | 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 | + } | |
| 118 | 141 | |
| 119 | 142 | |
| 120 | 143 | set fromIndex [lsearch -glob $fossilcmd *-from] |
| 121 | 144 | set toIndex [lsearch -glob $fossilcmd *-to] |
| 122 | 145 | set branchIndex [lsearch -glob $fossilcmd *-branch] |
| @@ -464,11 +487,11 @@ | ||
| 464 | 487 | ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical |
| 465 | 488 | ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal |
| 466 | 489 | ::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal |
| 467 | 490 | frame .spacer |
| 468 | 491 | |
| 469 | -if {[readDiffs $fossilcmd] == 0} { | |
| 492 | +if {[readDiffs $fossilcmd 0] == 0} { | |
| 470 | 493 | tk_messageBox -type ok -title $CFG(TITLE) -message "No changes" |
| 471 | 494 | exit |
| 472 | 495 | } |
| 473 | 496 | update idletasks |
| 474 | 497 | |
| @@ -579,14 +602,15 @@ | ||
| 579 | 602 | $w tag config search -background {#fcc000} |
| 580 | 603 | } |
| 581 | 604 | set ::search $w |
| 582 | 605 | } |
| 583 | 606 | ::ttk::button .bb.quit -text {Quit} -command exit |
| 607 | +::ttk::button .bb.reload -text {Reload} -command reloadDiff | |
| 584 | 608 | ::ttk::button .bb.invert -text {Invert} -command invertDiff |
| 585 | 609 | ::ttk::button .bb.save -text {Save As...} -command saveDiff |
| 586 | 610 | ::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 | |
| 588 | 612 | if {$fossilcmd!=""} {pack .bb.save -side left} |
| 589 | 613 | pack .bb.files .bb.search -side left |
| 590 | 614 | grid rowconfigure . 1 -weight 1 |
| 591 | 615 | grid columnconfigure . 1 -weight 1 |
| 592 | 616 | grid columnconfigure . 4 -weight 1 |
| 593 | 617 |
| --- 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 |