Fossil SCM

Tk diff: New "Files" menu implementation to better handle long file lists.

joel 2013-07-15 03:05 UTC sbsreloaded
Commit af9bda81e4877d1e3933888793cbcc8d1a2d0720
1 file changed +40 -3
+40 -3
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -622,10 +622,11 @@
622622
@ FONTS {{DejaVu Sans Mono} Consolas Monaco fixed}
623623
@ FONT_SIZE 9
624624
@ PADX 5
625625
@ WIDTH 80
626626
@ HEIGHT 45
627
+@ LB_HEIGHT 25
627628
@ }
628629
@
629630
@ if {![namespace exists ttk]} {
630631
@ interp alias {} ::ttk::scrollbar {} ::scrollbar
631632
@ interp alias {} ::ttk::menubutton {} ::menubutton
@@ -656,11 +657,11 @@
656657
@ if {[string compare -length 6 [gets $in] "<table"]} {
657658
@ continue
658659
@ }
659660
@ incr nDiffs
660661
@ set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}]
661
-@ .files.menu add command -label $fn -command "viewDiff $idx"
662
+@ .wfiles.lb insert end $fn
662663
@
663664
@ foreach c [cols] {
664665
@ while {[gets $in] ne "<pre>"} continue
665666
@
666667
@ if {$nDiffs > 1} {
@@ -703,10 +704,15 @@
703704
@ if {$type ne "txt"} {
704705
@ $c config -width $widths($type)
705706
@ }
706707
@ $c config -state disabled
707708
@ }
709
+@ if {$nDiffs <= [.wfiles.lb cget -height]} {
710
+@ .wfiles.lb config -height $nDiffs
711
+@ grid remove .wfiles.sb
712
+@ }
713
+@
708714
@ return $nDiffs
709715
@ }
710716
@
711717
@ proc viewDiff {idx} {
712718
@ .txtA yview $idx
@@ -809,12 +815,43 @@
809815
@ } {
810816
@ bind . <$key> "scroll-$axis $args; break"
811817
@ bind . <Shift-$key> continue
812818
@ }
813819
@
814
-@ ::ttk::menubutton .files -menu .files.menu -text "Files"
815
-@ menu .files.menu -tearoff 0
820
+@ ::ttk::menubutton .files -text "Files"
821
+@ toplevel .wfiles
822
+@ wm withdraw .wfiles
823
+@ update idletasks
824
+@ wm transient .wfiles .
825
+@ wm overrideredirect .wfiles 1
826
+@ listbox .wfiles.lb -width 0 -height $CFG(LB_HEIGHT) -activestyle none \
827
+@ -yscroll {.wfiles.sb set}
828
+@ ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
829
+@ grid .wfiles.lb .wfiles.sb -sticky ns
830
+@ bind .files <1> {
831
+@ set x [winfo rootx %W]
832
+@ set y [expr {[winfo rooty %W]+[winfo height %W]}]
833
+@ wm geometry .wfiles +$x+$y
834
+@ wm deiconify .wfiles
835
+@ focus .wfiles.lb
836
+@ }
837
+@ bind .wfiles <FocusOut> {wm withdraw .wfiles}
838
+@ bind .wfiles <Escape> {focus .}
839
+@ foreach evt {1 Return} {
840
+@ bind .wfiles.lb <$evt> {
841
+@ catch {
842
+@ set idx [lindex [.txtA tag ranges fn] [expr {[%W curselection]*2}]]
843
+@ viewDiff $idx
844
+@ }
845
+@ focus .
846
+@ break
847
+@ }
848
+@ }
849
+@ bind .wfiles.lb <Motion> {
850
+@ %W selection clear 0 end
851
+@ %W selection set @%x,%y
852
+@ }
816853
@
817854
@ foreach {side syncCol} {A .txtB B .txtA} {
818855
@ set ln .ln$side
819856
@ text $ln
820857
@ $ln tag config - -justify right
821858
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -622,10 +622,11 @@
622 @ FONTS {{DejaVu Sans Mono} Consolas Monaco fixed}
623 @ FONT_SIZE 9
624 @ PADX 5
625 @ WIDTH 80
626 @ HEIGHT 45
 
627 @ }
628 @
629 @ if {![namespace exists ttk]} {
630 @ interp alias {} ::ttk::scrollbar {} ::scrollbar
631 @ interp alias {} ::ttk::menubutton {} ::menubutton
@@ -656,11 +657,11 @@
656 @ if {[string compare -length 6 [gets $in] "<table"]} {
657 @ continue
658 @ }
659 @ incr nDiffs
660 @ set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}]
661 @ .files.menu add command -label $fn -command "viewDiff $idx"
662 @
663 @ foreach c [cols] {
664 @ while {[gets $in] ne "<pre>"} continue
665 @
666 @ if {$nDiffs > 1} {
@@ -703,10 +704,15 @@
703 @ if {$type ne "txt"} {
704 @ $c config -width $widths($type)
705 @ }
706 @ $c config -state disabled
707 @ }
 
 
 
 
 
708 @ return $nDiffs
709 @ }
710 @
711 @ proc viewDiff {idx} {
712 @ .txtA yview $idx
@@ -809,12 +815,43 @@
809 @ } {
810 @ bind . <$key> "scroll-$axis $args; break"
811 @ bind . <Shift-$key> continue
812 @ }
813 @
814 @ ::ttk::menubutton .files -menu .files.menu -text "Files"
815 @ menu .files.menu -tearoff 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816 @
817 @ foreach {side syncCol} {A .txtB B .txtA} {
818 @ set ln .ln$side
819 @ text $ln
820 @ $ln tag config - -justify right
821
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -622,10 +622,11 @@
622 @ FONTS {{DejaVu Sans Mono} Consolas Monaco fixed}
623 @ FONT_SIZE 9
624 @ PADX 5
625 @ WIDTH 80
626 @ HEIGHT 45
627 @ LB_HEIGHT 25
628 @ }
629 @
630 @ if {![namespace exists ttk]} {
631 @ interp alias {} ::ttk::scrollbar {} ::scrollbar
632 @ interp alias {} ::ttk::menubutton {} ::menubutton
@@ -656,11 +657,11 @@
657 @ if {[string compare -length 6 [gets $in] "<table"]} {
658 @ continue
659 @ }
660 @ incr nDiffs
661 @ set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}]
662 @ .wfiles.lb insert end $fn
663 @
664 @ foreach c [cols] {
665 @ while {[gets $in] ne "<pre>"} continue
666 @
667 @ if {$nDiffs > 1} {
@@ -703,10 +704,15 @@
704 @ if {$type ne "txt"} {
705 @ $c config -width $widths($type)
706 @ }
707 @ $c config -state disabled
708 @ }
709 @ if {$nDiffs <= [.wfiles.lb cget -height]} {
710 @ .wfiles.lb config -height $nDiffs
711 @ grid remove .wfiles.sb
712 @ }
713 @
714 @ return $nDiffs
715 @ }
716 @
717 @ proc viewDiff {idx} {
718 @ .txtA yview $idx
@@ -809,12 +815,43 @@
815 @ } {
816 @ bind . <$key> "scroll-$axis $args; break"
817 @ bind . <Shift-$key> continue
818 @ }
819 @
820 @ ::ttk::menubutton .files -text "Files"
821 @ toplevel .wfiles
822 @ wm withdraw .wfiles
823 @ update idletasks
824 @ wm transient .wfiles .
825 @ wm overrideredirect .wfiles 1
826 @ listbox .wfiles.lb -width 0 -height $CFG(LB_HEIGHT) -activestyle none \
827 @ -yscroll {.wfiles.sb set}
828 @ ::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
829 @ grid .wfiles.lb .wfiles.sb -sticky ns
830 @ bind .files <1> {
831 @ set x [winfo rootx %W]
832 @ set y [expr {[winfo rooty %W]+[winfo height %W]}]
833 @ wm geometry .wfiles +$x+$y
834 @ wm deiconify .wfiles
835 @ focus .wfiles.lb
836 @ }
837 @ bind .wfiles <FocusOut> {wm withdraw .wfiles}
838 @ bind .wfiles <Escape> {focus .}
839 @ foreach evt {1 Return} {
840 @ bind .wfiles.lb <$evt> {
841 @ catch {
842 @ set idx [lindex [.txtA tag ranges fn] [expr {[%W curselection]*2}]]
843 @ viewDiff $idx
844 @ }
845 @ focus .
846 @ break
847 @ }
848 @ }
849 @ bind .wfiles.lb <Motion> {
850 @ %W selection clear 0 end
851 @ %W selection set @%x,%y
852 @ }
853 @
854 @ foreach {side syncCol} {A .txtB B .txtA} {
855 @ set ln .ln$side
856 @ text $ln
857 @ $ln tag config - -justify right
858

Keyboard Shortcuts

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