Fossil

Check-in [2e7b57fa]
Login

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

Overview
Comment:Tk diff: Fix up scrolling code that previously assumed equal line lengths.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sbsreloaded
Files: files | file ages | folders
SHA1:2e7b57fabda90eab224e9b0d03b81e9ca0e6dcb2
User & Date: joel 2013-07-13 23:10:49
Context
2013-07-15
03:05
Tk diff: New "Files" menu implementation to better handle long file lists. check-in: af9bda81 user: joel tags: sbsreloaded
2013-07-13
23:10
Tk diff: Fix up scrolling code that previously assumed equal line lengths. check-in: 2e7b57fa user: joel tags: sbsreloaded
17:54
Improved header comment provides addition documentation for the "translate.c" compilation tool. No changes to code. check-in: 7e5f3062 user: drh tags: sbsreloaded
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/diffcmd.c.

618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
...
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
...
728
729
730
731
732
733
734





735





































736
737
738
739
740
741

742
743
744
745
746
747
748
749
750
751
752
753
...
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
...
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
834
835
836
837
@   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
@ }
@ 
@ if {![namespace exists ttk]} {
@   interp alias {} ::ttk::scrollbar {} ::scrollbar
@   interp alias {} ::ttk::menubutton {} ::menubutton
@ }
................................................................................
@         }
@       }
@     }
@   }
@   close $in
@   
@   foreach c [cols] {
@     if {[colType $c] eq "txt"} {
@       $c config -tabs [expr {[font measure mono 0]*($widths(txt)+1)}] 
@     } else {
@       $c config -width $widths([colType $c])
@     }
@     $c config -state disabled
@   }
@   return $nDiffs
@ }
@ 
@ proc viewDiff {idx} {
................................................................................
@       viewDiff fn.first
@     } else {
@       viewDiff [lindex $range 0]
@     }
@   }
@ }
@ 





@ proc scrollSync {axis sbs first last} {





































@   foreach c [cols] {
@     $c ${axis}view moveto $first
@   }
@   foreach sb $sbs {
@     if {$first <= 0 && $last >= 1} {
@       grid remove $sb

@     } else {
@       grid $sb
@       $sb set $first $last
@     }
@   }
@ }
@ 
@ wm withdraw .
@ wm title . $CFG(TITLE)
@ wm iconname . $CFG(TITLE)
@ bind . <q> exit
@ bind . <Tab> {cycleDiffs; break}
................................................................................
@   Left  x {scroll -5 units}
@   Right x {scroll 5 units}
@   Prior y {scroll -1 page}
@   Next  y {scroll 1 page}
@   Home  y {moveto 0}
@   End   y {moveto 1}
@ } {
@   bind . <$key> ".txtA ${axis}view $args; break"
@   bind . <Shift-$key> continue
@ }
@ 
@ ::ttk::menubutton .files -menu .files.menu -text "Files"
@ menu .files.menu -tearoff 0
@ 
@ 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
@ }
................................................................................
@      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
@ 
@ 
@ if {[readDiffs $cmd] == 0} {
@   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

@ grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew
@ 
@ wm deiconify .


;

/*
** Show diff output in a Tcl/Tk window, in response to the --tk option
** to the diff command.
** 
** Steps:







|







 







|
|
<
|







 







>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|

<
|
|
>
|
|
<
|
|







 







|






|






|







 







|









|
|












>



>
>







618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
...
695
696
697
698
699
700
701
702
703

704
705
706
707
708
709
710
711
...
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779

780
781
782
783
784

785
786
787
788
789
790
791
792
793
...
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
...
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
@   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      80
@   HEIGHT     45
@ }
@ 
@ if {![namespace exists ttk]} {
@   interp alias {} ::ttk::scrollbar {} ::scrollbar
@   interp alias {} ::ttk::menubutton {} ::menubutton
@ }
................................................................................
@         }
@       }
@     }
@   }
@   close $in
@   
@   foreach c [cols] {
@     set type [colType $c]
@     if {$type ne "txt"} {

@       $c config -width $widths($type)
@     }
@     $c config -state disabled
@   }
@   return $nDiffs
@ }
@ 
@ proc viewDiff {idx} {
................................................................................
@       viewDiff fn.first
@     } else {
@       viewDiff [lindex $range 0]
@     }
@   }
@ }
@ 
@ proc xvis {col} {
@   set view [$col xview]
@   return [expr {[lindex $view 1]-[lindex $view 0]}]
@ }
@ 
@ proc scroll-x {args} {
@   set c .txt[expr {[xvis .txtA] < [xvis .txtB] ? "A" : "B"}]
@   eval $c xview $args
@ }
@ 
@ interp alias {} scroll-y {} .txtA yview
@ 
@ proc noop {args} {}
@ 
@ proc enableSync {axis} {
@   update idletasks
@   interp alias {} sync-$axis {}
@   rename _sync-$axis sync-$axis
@ }
@ 
@ proc disableSync {axis} {
@   rename sync-$axis _sync-$axis
@   interp alias {} sync-$axis {} noop
@ }
@ 
@ proc sync-x {col first last} {
@   disableSync x
@   $col xview moveto [expr {$first*[xvis $col]/($last-$first)}]
@   foreach side {A B} {
@     set sb .sbx$side
@     set xview [.txt$side xview]
@     if {$xview ne "0.0 1.0"} {
@       grid $sb
@       eval $sb set $xview
@     } else {
@       grid remove $sb
@     }
@   }
@   enableSync x
@ }
@ 
@ proc sync-y {first last} {
@   disableSync y
@   foreach c [cols] {
@     $c yview moveto $first
@   }

@   if {$first > 0 || $last < 1} {
@     grid .sby
@     .sby set $first $last
@   } else {
@     grid remove .sby

@   }
@   enableSync y
@ }
@ 
@ wm withdraw .
@ wm title . $CFG(TITLE)
@ wm iconname . $CFG(TITLE)
@ bind . <q> exit
@ bind . <Tab> {cycleDiffs; break}
................................................................................
@   Left  x {scroll -5 units}
@   Right x {scroll 5 units}
@   Prior y {scroll -1 page}
@   Next  y {scroll 1 page}
@   Home  y {moveto 0}
@   End   y {moveto 1}
@ } {
@   bind . <$key> "scroll-$axis $args; break"
@   bind . <Shift-$key> continue
@ }
@ 
@ ::ttk::menubutton .files -menu .files.menu -text "Files"
@ menu .files.menu -tearoff 0
@ 
@ foreach {side syncCol} {A .txtB B .txtA} {
@   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 "sync-x $syncCol"
@   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
@ }
................................................................................
@      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) -yscroll sync-y
@   $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 {.txtB xview} -orient horizontal
@ frame .spacer
@ 
@ if {[readDiffs $cmd] == 0} {
@   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
@ grid .spacer -row 2 -column 2
@ grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew
@ 
@ wm deiconify .
@ update idletasks
@ .spacer config -height [winfo height .sbxA]
;

/*
** Show diff output in a Tcl/Tk window, in response to the --tk option
** to the diff command.
** 
** Steps: