Fossil

Check-in [695156c1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use tab stops instead of spaces to equalize line lengths in Tk diff.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sbsreloaded
Files: files | file ages | folders
SHA1:695156c1004d3acf18e9a0eeedab8e82b73d71fb
User & Date: joel 2013-07-10 05:27:01
Context
2013-07-10
18:06
Combine all diffs into a single display in Tk diff. check-in: 0a41e2b3 user: joel tags: sbsreloaded
05:27
Use tab stops instead of spaces to equalize line lengths in Tk diff. check-in: 695156c1 user: joel tags: sbsreloaded
2013-07-09
20:51
Add better comment explaining why .txtA/.txtB lines are padded with spaces. check-in: 2d8f2b4e user: joel tags: sbsreloaded
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diffcmd.c.

615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
...
659
660
661
662
663
664
665









666
667
668
669
670
671
672
673
674
675
676
677
678
679
...
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
735
736
737
...
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
@   RM_BG      #ffc0c0
@   HR_FG      #888888
@   HR_PAD_TOP 4
@   HR_PAD_BTM 8
@   FONTS      {{DejaVu Sans Mono} Consolas Monaco fixed}
@   FONT_SIZE  9
@   PADX       5
@   WIDTH      80
@   HEIGHT     45
@ }
@ 
@ if {![namespace exists ttk]} {
@   interp alias {} ::ttk::scrollbar {} ::scrollbar
@   interp alias {} ::ttk::menubutton {} ::menubutton
@ }
................................................................................
@     .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
@       set type [colType $c]









@       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\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).
................................................................................
@   
@   foreach c [cols] {
@     $c config -state normal
@     $c delete 1.0 end
@     foreach {content tag} $gDiffs($idx,$c) {
@       $c insert end $content $tag
@     }

@   }
@   
@   foreach c {.lnA .lnB .mkr} {
@     $c config -width $gDiffs($idx,[colType $c]-width)
@   }
@   
@   # Add whitespace to equalize line lengths.  This is done 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.
@   regexp {\d+} [.txtA index {end -1c}] numLines
@   set width $gDiffs($idx,txt-width)
@   foreach c {.txtA .txtB} {
@     for {set ln 1} {$ln <= $numLines} {incr ln} {
@       regexp {\d+$} [$c index $ln.end] len
@       $c insert $ln.end [string repeat " " [expr {$width-$len}]] ws
@     }
@   }
@   
@   foreach c [cols] {
@     $c config -state disabled
@   }
@ }
@ 
@ proc cycleDiffs {{inc 1}} {
@   global gIdx
@   .files.menu invoke [expr {($gIdx+$inc) % ([.files.menu index last]+1)}]
@ }
................................................................................
@       $sb set $first $last
@     }
@   }
@ }
@ 
@ proc copyText {c} {
@   set txt ""
@   # Copy selection without excess trailing whitespace
@   $c tag config ws -elide 1
@   catch {
@     $c tag add sel sel.first sel.last
@     set txt [selection get]
@   }
@   $c tag config ws -elide 0
@   clipboard clear
@   clipboard append $txt
@ }
@ 
@ wm withdraw .
@ wm title . $CFG(TITLE)
@ wm iconname . $CFG(TITLE)







|







 







>
>
>
>
>
>
>
>
>






|







 







>






<
<
<
<
<
<
<


<
<
<
<
<
<
<
|







 







|
<
<
<
<
<
<







615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
...
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
...
710
711
712
713
714
715
716
717
718
719
720
721
722
723







724
725







726
727
728
729
730
731
732
733
...
744
745
746
747
748
749
750
751






752
753
754
755
756
757
758
@   RM_BG      #ffc0c0
@   HR_FG      #888888
@   HR_PAD_TOP 4
@   HR_PAD_BTM 8
@   FONTS      {{DejaVu Sans Mono} Consolas Monaco fixed}
@   FONT_SIZE  9
@   PADX       5
@   WIDTH      81
@   HEIGHT     45
@ }
@ 
@ if {![namespace exists ttk]} {
@   interp alias {} ::ttk::scrollbar {} ::scrollbar
@   interp alias {} ::ttk::menubutton {} ::menubutton
@ }
................................................................................
@     .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
@       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).
................................................................................
@   
@   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
@   }
@   
@   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)}]
@ }
................................................................................
@       $sb set $first $last
@     }
@   }
@ }
@ 
@ proc copyText {c} {
@   set txt ""
@   catch {set txt [string map {\t\n \n} [selection get]]}






@   clipboard clear
@   clipboard append $txt
@ }
@ 
@ wm withdraw .
@ wm title . $CFG(TITLE)
@ wm iconname . $CFG(TITLE)