Fossil SCM
Tk diff: New "Files" menu implementation to better handle long file lists.
Commit
af9bda81e4877d1e3933888793cbcc8d1a2d0720
Parent
2e7b57fabda90ea…
1 file changed
+40
-3
+40
-3
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -622,10 +622,11 @@ | ||
| 622 | 622 | @ FONTS {{DejaVu Sans Mono} Consolas Monaco fixed} |
| 623 | 623 | @ FONT_SIZE 9 |
| 624 | 624 | @ PADX 5 |
| 625 | 625 | @ WIDTH 80 |
| 626 | 626 | @ HEIGHT 45 |
| 627 | +@ LB_HEIGHT 25 | |
| 627 | 628 | @ } |
| 628 | 629 | @ |
| 629 | 630 | @ if {![namespace exists ttk]} { |
| 630 | 631 | @ interp alias {} ::ttk::scrollbar {} ::scrollbar |
| 631 | 632 | @ interp alias {} ::ttk::menubutton {} ::menubutton |
| @@ -656,11 +657,11 @@ | ||
| 656 | 657 | @ if {[string compare -length 6 [gets $in] "<table"]} { |
| 657 | 658 | @ continue |
| 658 | 659 | @ } |
| 659 | 660 | @ incr nDiffs |
| 660 | 661 | @ 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 | |
| 662 | 663 | @ |
| 663 | 664 | @ foreach c [cols] { |
| 664 | 665 | @ while {[gets $in] ne "<pre>"} continue |
| 665 | 666 | @ |
| 666 | 667 | @ if {$nDiffs > 1} { |
| @@ -703,10 +704,15 @@ | ||
| 703 | 704 | @ if {$type ne "txt"} { |
| 704 | 705 | @ $c config -width $widths($type) |
| 705 | 706 | @ } |
| 706 | 707 | @ $c config -state disabled |
| 707 | 708 | @ } |
| 709 | +@ if {$nDiffs <= [.wfiles.lb cget -height]} { | |
| 710 | +@ .wfiles.lb config -height $nDiffs | |
| 711 | +@ grid remove .wfiles.sb | |
| 712 | +@ } | |
| 713 | +@ | |
| 708 | 714 | @ return $nDiffs |
| 709 | 715 | @ } |
| 710 | 716 | @ |
| 711 | 717 | @ proc viewDiff {idx} { |
| 712 | 718 | @ .txtA yview $idx |
| @@ -809,12 +815,43 @@ | ||
| 809 | 815 | @ } { |
| 810 | 816 | @ bind . <$key> "scroll-$axis $args; break" |
| 811 | 817 | @ bind . <Shift-$key> continue |
| 812 | 818 | @ } |
| 813 | 819 | @ |
| 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 | +@ } | |
| 816 | 853 | @ |
| 817 | 854 | @ foreach {side syncCol} {A .txtB B .txtA} { |
| 818 | 855 | @ set ln .ln$side |
| 819 | 856 | @ text $ln |
| 820 | 857 | @ $ln tag config - -justify right |
| 821 | 858 |
| --- 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 |