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
|
}
set leftLines {}
set rightLines {}
set state none
continue
}
# Detect the first line in a -c style diff
if {$state eq "none" && [regexp {^\*\*\*} $line]} {
set state newfile
set style c
set leftRE {^\*\*\*\s+(.*)$}
set rightRE {^---\s+(.*)$}
}
# Detect the first line in a -u style diff
if {$state eq "none" && [regexp {^---} $line]} {
set state newfile
set style u
set leftRE {^---\s+(.*)$}
set rightRE {^\+\+\+\s+(.*)$}
}
if {$state eq "newfile" && [regexp $leftRE $line -> sub]} {
emptyLine $top 1
insertLine $top 1 "" $divider patch
insertLine $top 1 "" $sub patch
insertLine $top 1 "" $divider patch
addChange $top 4 change 0 0 0 0
|
>
>
>
>
>
>
>
|
|
|
|
|
|
>
>
>
>
>
>
>
>
|
|
|
|
|
>
|
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
|
}
set leftLines {}
set rightLines {}
set state none
continue
}
# Detect the first line in a -c style diff
if {[regexp {^\*\*\* } $line]} {
if {$state eq "right"} {
displayOnePatch $top $leftLines $rightLines $leftLine $rightLine
set leftLines {}
set rightLines {}
set state none
}
if {$state eq "none"} {
set state newfile
set style c
set leftRE {^\*\*\*\s+(.*)$}
set rightRE {^---\s+(.*)$}
}
}
# Detect the first line in a -u style diff
if {[regexp {^--- } $line]} {
if {$state eq "right" || $state eq "both"} {
displayOnePatch $top $leftLines $rightLines $leftLine $rightLine
set leftLines {}
set rightLines {}
set state none
}
if {$state eq "none"} {
set state newfile
set style u
set leftRE {^---\s+(.*)$}
set rightRE {^\+\+\+\s+(.*)$}
}
}
if {$state eq "newfile" && [regexp $leftRE $line -> sub]} {
emptyLine $top 1
insertLine $top 1 "" $divider patch
insertLine $top 1 "" $sub patch
insertLine $top 1 "" $divider patch
addChange $top 4 change 0 0 0 0
|
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
|
set TmpPref(fontfamily) [$lb get $i]
font configure tmpfont -family $TmpPref(fontfamily)
if {[string is integer -strict $TmpPref(fontsize)]} {
font configure tmpfont -size $TmpPref(fontsize)
}
}
# Font dialog
proc makeFontWin {} {
global Pref TmpPref FontCache
destroy .fo
toplevel .fo -padx 3 -pady 3
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
|
set TmpPref(fontfamily) [$lb get $i]
font configure tmpfont -family $TmpPref(fontfamily)
if {[string is integer -strict $TmpPref(fontsize)]} {
font configure tmpfont -size $TmpPref(fontsize)
}
}
proc UpdateFontBox {lb} {
$lb delete 0 end
foreach {f fixed} $::FontCache {
if {$fixed || !$::diff(fixedfont)} {
$lb insert end $f
if {[string equal -nocase $f $::Pref(fontfamily)]} {
$lb selection set end
$lb see end
}
}
}
}
# Font dialog
proc makeFontWin {} {
global Pref TmpPref FontCache
destroy .fo
toplevel .fo -padx 3 -pady 3
|
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
|
pack .fo.lf.lb -fill both -expand 1
labelframe .fo.ls -text "Size" -padx 3 -pady 3
spinbox .fo.ls.sp -from 1 -to 30 -increment 1 -width 3 -state readonly \
-textvariable TmpPref(fontsize) -command [list exampleFont $lb]
pack .fo.ls.sp -fill both -expand 1
label .fo.le -text "Example" -anchor w -font tmpfont -width 1
button .fo.bo -text "Ok" -padx 10 -command "applyFont $lb ; destroy .fo"
button .fo.ba -text "Apply" -padx 10 -command "applyFont $lb"
button .fo.bc -text "Close" -padx 10 -command "destroy .fo"
if {![info exists FontCache]} {
set fam [lsort -dictionary [font families]]
font create testfont
foreach f $fam {
if {![string equal $f ""]} {
font configure testfont -family $f
if {[font metrics testfont -fixed]} {
lappend FontCache $f
}
}
}
font delete testfont
}
foreach f $FontCache {
$lb insert end $f
if {[string equal -nocase $f $Pref(fontfamily)]} {
$lb selection set end
$lb see end
}
}
destroy .fo.ltmp
grid .fo.lf .fo.ls -sticky news -padx 3 -pady 3
grid x .fo.le -sticky nwe -padx 3 -pady 3
grid x .fo.bo -sticky we -padx 3 -pady 3
grid x .fo.ba -sticky we -padx 3 -pady 3
grid x .fo.bc -sticky we -padx 3 -pady 3
grid .fo.lf -sticky news -rowspan 5
grid columnconfigure .fo 0 -weight 1
grid rowconfigure .fo 1 -weight 1
exampleFont $lb
}
|
|
>
>
>
>
<
|
<
<
<
<
<
|
<
<
|
>
|
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
|
pack .fo.lf.lb -fill both -expand 1
labelframe .fo.ls -text "Size" -padx 3 -pady 3
spinbox .fo.ls.sp -from 1 -to 30 -increment 1 -width 3 -state readonly \
-textvariable TmpPref(fontsize) -command [list exampleFont $lb]
pack .fo.ls.sp -fill both -expand 1
label .fo.le -text "Example\n0Ooi1Il" -anchor w -font tmpfont -width 1 \
-justify left
if {![info exists ::diff(fixedfont)]} {set ::diff(fixedfont) 1}
checkbutton .fo.cb -text "Fixed" -variable ::diff(fixedfont) \
-command [list UpdateFontBox $lb]
button .fo.bo -text "Ok" -padx 10 -command "applyFont $lb ; destroy .fo"
button .fo.ba -text "Apply" -padx 10 -command "applyFont $lb"
button .fo.bc -text "Close" -padx 10 -command "destroy .fo"
if {![info exists FontCache]} {
set fam [lsort -dictionary [font families]]
font create testfont
foreach f $fam {
if {![string equal $f ""]} {
font configure testfont -family $f
lappend FontCache $f [font metrics testfont -fixed]
}
}
font delete testfont
}
UpdateFontBox $lb
destroy .fo.ltmp
grid .fo.lf .fo.ls -sticky news -padx 3 -pady 3
grid x .fo.cb -sticky nwe -padx 3 -pady 3
grid x .fo.bo -sticky we -padx 3 -pady 3
grid x .fo.ba -sticky we -padx 3 -pady 3
grid x .fo.bc -sticky we -padx 3 -pady 3
grid .fo.le - -sticky nwe -padx 3 -pady 3
grid .fo.lf -sticky news -rowspan 5
grid columnconfigure .fo 0 -weight 1
grid rowconfigure .fo 1 -weight 1
exampleFont $lb
}
|