Fossil

Diff
Login

Diff

Differences From Artifact [a0354ab40c]:

To Artifact [294cb0efc2]:


612
613
614
615
616
617
618



619
620
621
622
623
624
625
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628







+
+
+







@   MKR_COL_FG #dddddd
@   CHNG_BG    #d0d0ff
@   ADD_BG     #c0ffc0
@   RM_BG      #ffc0c0
@   HR_FG      #888888
@   HR_PAD_TOP 4
@   HR_PAD_BTM 8
@   FN_BG      #444444
@   FN_FG      #ffffff
@   FN_PAD     5
@   FONTS      {{DejaVu Sans Mono} Consolas Monaco fixed}
@   FONT_SIZE  9
@   PADX       5
@   WIDTH      81
@   HEIGHT     45
@ }
@ 
639
640
641
642
643
644
645
646
647
648

649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664













665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692

693
694

695
696
697
698
699
700
701
702
703
704







705
706
707
708
709
710
711
712
713
714
715
716
717
718

719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
642
643
644
645
646
647
648

649
650
651
652
653
654
655
656
657
658
659
660
661
662
663

664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698


699
700
701
702
703
704

705
706

707
708
709





710
711
712
713
714
715
716
717
718
719
720
721
722

723









724









725
726
727
728
729
730
731







-


+












-



+
+
+
+
+
+
+
+
+
+
+
+
+



















-
-






-
+

-
+


-
-
-
-
-



+
+
+
+
+
+
+



-

-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-







@ 
@ proc colType {c} {
@   regexp {[a-z]+} $c type
@   return $type
@ }
@ 
@ proc readDiffs {cmd} {
@   global gDiffs
@   set in [open $cmd r]
@   set idx -1
@   array set widths {txt 0 ln 0 mkr 0}
@   while {[gets $in line] != -1} {
@     if {![regexp {^=+\s+(.*?)\s+=+$} $line all fn]} {
@       continue
@     }
@     
@     if {[string compare -length 6 [gets $in] "<table"]} {
@       continue
@     }
@     
@     incr idx
@     .files.menu add radiobutton -variable gIdx -value $idx -label $fn \
@       -command "viewDiff $idx"
@     array set widths {txt 0 ln 0 mkr 0}
@     
@     foreach c [cols] {
@       while {[gets $in] ne "<pre>"} continue
@       
@       if {$idx > 0} {
@         $c insert end \n -
@       }
@       $c mark set diff$idx {end -1c}
@       $c mark gravity diff$idx left
@       if {[colType $c] eq "txt"} {
@         $c insert end $fn\n fn
@       } else {
@         $c insert end \n fn
@       }
@       $c insert end \n -
@        
@       set type [colType $c]
@       # A tab character is appended to each line in a txt column.  This,
@       # along with the -tabs text widget option, allows us to equalize line
@       # lengths in order to:
@       #  (a) scroll to the same horizontal position on both sides and
@       #  (b) keep the horizontal scrollbars from changing position/size as
@       #      you scroll vertically.
@       # To test, try "fossil diff --tk --from d7afa8f153 --to abe1030ca8"
@       # as well as its inverse.
@       set tab [expr {$type eq "txt" ? "\t" : ""}]
@       set str {}
@       while {[set line [gets $in]] ne "</pre>"} {
@         set len [string length [dehtml $line]]
@         if {$len > $widths($type)} {
@           set widths($type) $len
@         }
@         append str $line$tab\n
@       }
@       
@       set str [string range $str 0 end-1]
@       set colData {}
@       set re {<span class="diff([a-z]+)">([^<]*)</span>}
@       # Use \r as separator since it can't appear in the diff output (it gets
@       # converted to a space).
@       set str [regsub -all $re $str "\r\\1\r\\2\r"]
@       foreach {pre class mid} [split $str \r] {
@         if {$class ne ""} {
@           lappend colData [dehtml $pre] - [dehtml $mid] [list $class -]
@           $c insert end [dehtml $pre] - [dehtml $mid] [list $class -]
@         } else {
@           lappend colData [dehtml $pre] -
@           $c insert end [dehtml $pre] -
@         }
@       }
@       set gDiffs($idx,$c) $colData
@     }
@     
@     foreach {type width} [array get widths] {
@       set gDiffs($idx,$type-width) $width
@     }
@   }
@   close $in
@   
@   foreach c {.lnA .mkr .lnB} {
@     $c config -width $widths([colType $c])
@   }
@   foreach c {.txtA .txtB} {
@     $c config -tabs [expr {[font measure mono 0]*($widths(txt)+1)}]
@   }
@ }
@ 
@ proc viewDiff {idx} {
@   global gDiffs
@   .files config -text [.files.menu entrycget $idx -label]
@   
@   foreach c [cols] {
@     $c config -state normal
@     $c delete 1.0 end
@     foreach {content tag} $gDiffs($idx,$c) {
@       $c insert end $content $tag
@     }
@     $c config -state disabled
@   }
@   .txtA yview diff$idx
@   
@   foreach c {.lnA .lnB .mkr} {
@     $c config -width $gDiffs($idx,[colType $c]-width)
@   }
@   
@   set width $gDiffs($idx,txt-width)
@   foreach c {.txtA .txtB} {
@     $c config -tabs [expr {[font measure mono 0]*($width+1)}]
@   }
@ }
@ 
@ proc cycleDiffs {{inc 1}} {
@   global gIdx
@   .files.menu invoke [expr {($gIdx+$inc) % ([.files.menu index last]+1)}]
@ }
@ 
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800


801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818

819
820
821
822
823
824
825






826
827
828
829
830
831
832
773
774
775
776
777
778
779





780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833







-
-
-
-
-













+
+


















+







+
+
+
+
+
+







@ } {
@   bind . <$key> ".txtA ${axis}view $args; break"
@   bind . <Shift-$key> continue
@ }
@ 
@ ::ttk::menubutton .files -menu .files.menu
@ menu .files.menu -tearoff 0
@ readDiffs $cmd
@ if {[.files.menu index 0] eq "none"} {
@   tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
@   exit
@ }
@ 
@ foreach side {A B} {
@   set ln .ln$side
@   text $ln
@   $ln tag config - -justify right
@   
@   set txt .txt$side
@   text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \
@     -xscroll {scrollSync x {.sbxA .sbxB}}
@   foreach tag {add rm chng} {
@     $txt tag config $tag -background $CFG([string toupper $tag]_BG)
@     $txt tag lower $tag
@   }
@   $txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
@     -justify center
@   bind $txt <<Copy>> {copyText %W; break}
@   bind $txt <<Cut>> {copyText %W; break}
@ }
@ text .mkr
@ 
@ font create mono -family courier -size $CFG(FONT_SIZE)
@ foreach font $CFG(FONTS) {
@   if {[lsearch -exact [font families] $font] != -1} {
@      font config mono -family $font
@      break
@   }
@ }
@ foreach c [cols] {
@   set keyPrefix [string toupper [colType $c]]_COL_
@   $c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
@     -font mono -padx $CFG(PADX) -insertontime 0 -yscroll {scrollSync y .sby}
@   $c tag config hr -spacing1 $CFG(HR_PAD_TOP) -spacing3 $CFG(HR_PAD_BTM) \
@      -foreground $CFG(HR_FG)
@   $c tag config fn -spacing1 $CFG(FN_PAD) -spacing3 $CFG(FN_PAD)
@   bindtags $c ". $c Text all"
@   bind $c <1> {focus %W}
@ }
@ 
@ ::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
@ ::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
@ ::ttk::scrollbar .sbxB -command {.txtA xview} -orient horizontal
@ 
@ readDiffs $cmd
@ if {[.files.menu index 0] eq "none"} {
@   tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
@   exit
@ }
@ 
@ grid rowconfigure . 1 -weight 1
@ grid columnconfigure . 1 -weight 1
@ grid columnconfigure . 4 -weight 1
@ grid .files -columnspan 6
@ eval grid [cols] .sby -sticky nsew
@ grid .sbxA -row 2 -column 0 -columnspan 2 -sticky ew