gitk: Use named fonts instead of the font specification
This replaces the use of $mainfont, $textfont and $uifont with named fonts called mainfont, textfont and uifont. We also have variants called mainfontbold and textfontbold. This makes it much easier to make sure font size changes are reflected everywhere they should be, since configuring a named font automatically changes all the widgets that are using that font. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Oct 4, 2007 at 22:27 UTC
9c311b3208f25ce70edf0fdbe0f440ecd8e0bda7
1 file changed
+142
-115
gitk
+142
-115
@@ -133,7 +133,7 @@ proc stop_rev_list {} {
133
}
134
135
proc getcommits {} {
136
- global phase canv mainfont curview
136
+ global phase canv curview
137
138
set phase getcommits
139
initlayout
@@ -615,7 +615,7 @@ proc confirm_popup msg {
615
616
proc makewindow {} {
617
global canv canv2 canv3 linespc charspc ctext cflist
618
- global textfont mainfont uifont tabstop
618
+ global tabstop
619
global findtype findtypemenu findloc findstring fstring geometry
620
global entries sha1entry sha1string sha1but
621
global diffcontextstring diffcontext
@@ -630,19 +630,19 @@ proc makewindow {} {
630
631
menu .bar
632
.bar add cascade -label "File" -menu .bar.file
633
- .bar configure -font $uifont
633
+ .bar configure -font uifont
634
menu .bar.file
635
.bar.file add command -label "Update" -command updatecommits
636
.bar.file add command -label "Reread references" -command rereadrefs
637
.bar.file add command -label "List references" -command showrefs
638
.bar.file add command -label "Quit" -command doquit
639
- .bar.file configure -font $uifont
639
+ .bar.file configure -font uifont
640
menu .bar.edit
641
.bar add cascade -label "Edit" -menu .bar.edit
642
.bar.edit add command -label "Preferences" -command doprefs
643
- .bar.edit configure -font $uifont
643
+ .bar.edit configure -font uifont
644
645
- menu .bar.view -font $uifont
645
+ menu .bar.view -font uifont
646
.bar add cascade -label "View" -menu .bar.view
647
.bar.view add command -label "New view..." -command {newview 0}
648
.bar.view add command -label "Edit view..." -command editview \
@@ -656,7 +656,7 @@ proc makewindow {} {
656
.bar add cascade -label "Help" -menu .bar.help
657
.bar.help add command -label "About gitk" -command about
658
.bar.help add command -label "Key bindings" -command keys
659
- .bar.help configure -font $uifont
659
+ .bar.help configure -font uifont
660
. configure -menu .bar
661
662
# the gui has upper and lower half, parts of a paned window.
@@ -713,10 +713,10 @@ proc makewindow {} {
713
set entries $sha1entry
714
set sha1but .tf.bar.sha1label
715
button $sha1but -text "SHA1 ID: " -state disabled -relief flat \
716
- -command gotocommit -width 8 -font $uifont
716
+ -command gotocommit -width 8 -font uifont
717
$sha1but conf -disabledforeground [$sha1but cget -foreground]
718
pack .tf.bar.sha1label -side left
719
- entry $sha1entry -width 40 -font $textfont -textvariable sha1string
719
+ entry $sha1entry -width 40 -font textfont -textvariable sha1string
720
trace add variable sha1string write sha1change
721
pack $sha1entry -side left -pady 2
722
@@ -745,9 +745,9 @@ proc makewindow {} {
745
746
# Status label and progress bar
747
set statusw .tf.bar.status
748
- label $statusw -width 15 -relief sunken -font $uifont
748
+ label $statusw -width 15 -relief sunken -font uifont
749
pack $statusw -side left -padx 5
750
- set h [expr {[font metrics $uifont -linespace] + 2}]
750
+ set h [expr {[font metrics uifont -linespace] + 2}]
751
set progresscanv .tf.bar.progress
752
canvas $progresscanv -relief sunken -height $h -borderwidth 2
753
set progressitem [$progresscanv create rect -1 0 0 $h -fill green]
@@ -760,10 +760,10 @@ proc makewindow {} {
760
set progupdatepending 0
761
762
# build up the bottom bar of upper window
763
- label .tf.lbar.flabel -text "Find " -font $uifont
764
- button .tf.lbar.fnext -text "next" -command dofind -font $uifont
765
- button .tf.lbar.fprev -text "prev" -command {dofind 1} -font $uifont
766
- label .tf.lbar.flab2 -text " commit " -font $uifont
763
+ label .tf.lbar.flabel -text "Find " -font uifont
764
+ button .tf.lbar.fnext -text "next" -command dofind -font uifont
765
+ button .tf.lbar.fprev -text "prev" -command {dofind 1} -font uifont
766
+ label .tf.lbar.flab2 -text " commit " -font uifont
767
pack .tf.lbar.flabel .tf.lbar.fnext .tf.lbar.fprev .tf.lbar.flab2 \
768
-side left -fill y
769
set gdttype "containing:"
@@ -772,27 +772,27 @@ proc makewindow {} {
772
"touching paths:" \
773
"adding/removing string:"]
774
trace add variable gdttype write gdttype_change
775
- $gm conf -font $uifont
776
- .tf.lbar.gdttype conf -font $uifont
775
+ $gm conf -font uifont
776
+ .tf.lbar.gdttype conf -font uifont
777
pack .tf.lbar.gdttype -side left -fill y
778
779
set findstring {}
780
set fstring .tf.lbar.findstring
781
lappend entries $fstring
782
- entry $fstring -width 30 -font $textfont -textvariable findstring
782
+ entry $fstring -width 30 -font textfont -textvariable findstring
783
trace add variable findstring write find_change
784
set findtype Exact
785
set findtypemenu [tk_optionMenu .tf.lbar.findtype \
786
findtype Exact IgnCase Regexp]
787
trace add variable findtype write findcom_change
788
- .tf.lbar.findtype configure -font $uifont
789
- .tf.lbar.findtype.menu configure -font $uifont
788
+ .tf.lbar.findtype configure -font uifont
789
+ .tf.lbar.findtype.menu configure -font uifont
790
set findloc "All fields"
791
tk_optionMenu .tf.lbar.findloc findloc "All fields" Headline \
792
Comments Author Committer
793
trace add variable findloc write find_change
794
- .tf.lbar.findloc configure -font $uifont
795
- .tf.lbar.findloc.menu configure -font $uifont
794
+ .tf.lbar.findloc configure -font uifont
795
+ .tf.lbar.findloc.menu configure -font uifont
796
pack .tf.lbar.findloc -side right
797
pack .tf.lbar.findtype -side right
798
pack $fstring -side left -expand 1 -fill x
@@ -820,10 +820,10 @@ proc makewindow {} {
820
frame .bleft.mid
821
822
button .bleft.top.search -text "Search" -command dosearch \
823
- -font $uifont
823
+ -font uifont
824
pack .bleft.top.search -side left -padx 5
825
set sstring .bleft.top.sstring
826
- entry $sstring -width 20 -font $textfont -textvariable searchstring
826
+ entry $sstring -width 20 -font textfont -textvariable searchstring
827
lappend entries $sstring
828
trace add variable searchstring write incrsearch
829
pack $sstring -side left -expand 1 -fill x
@@ -834,9 +834,9 @@ proc makewindow {} {
834
radiobutton .bleft.mid.new -text "New version" \
835
-command changediffdisp -variable diffelide -value {1 0}
836
label .bleft.mid.labeldiffcontext -text " Lines of context: " \
837
- -font $uifont
837
+ -font uifont
838
pack .bleft.mid.diff .bleft.mid.old .bleft.mid.new -side left
839
- spinbox .bleft.mid.diffcontext -width 5 -font $textfont \
839
+ spinbox .bleft.mid.diffcontext -width 5 -font textfont \
840
-from 1 -increment 1 -to 10000000 \
841
-validate all -validatecommand "diffcontextvalidate %P" \
842
-textvariable diffcontextstring
@@ -846,7 +846,7 @@ proc makewindow {} {
846
pack .bleft.mid.labeldiffcontext .bleft.mid.diffcontext -side left
847
set ctext .bleft.ctext
848
text $ctext -background $bgcolor -foreground $fgcolor \
849
- -state disabled -font $textfont \
849
+ -state disabled -font textfont \
850
-yscrollcommand scrolltext -wrap none
851
if {$have_tk85} {
852
$ctext conf -tabstyle wordprocessor
@@ -860,7 +860,7 @@ proc makewindow {} {
860
lappend fglist $ctext
861
862
$ctext tag conf comment -wrap $wrapcomment
863
- $ctext tag conf filesep -font [concat $textfont bold] -back "#aaaaaa"
863
+ $ctext tag conf filesep -font textfontbold -back "#aaaaaa"
864
$ctext tag conf hunksep -fore [lindex $diffcolors 2]
865
$ctext tag conf d0 -fore [lindex $diffcolors 0]
866
$ctext tag conf d1 -fore [lindex $diffcolors 1]
@@ -882,8 +882,8 @@ proc makewindow {} {
882
$ctext tag conf m15 -fore "#ff70b0"
883
$ctext tag conf mmax -fore darkgrey
884
set mergemax 16
885
- $ctext tag conf mresult -font [concat $textfont bold]
886
- $ctext tag conf msep -font [concat $textfont bold]
885
+ $ctext tag conf mresult -font textfontbold
886
+ $ctext tag conf msep -font textfontbold
887
$ctext tag conf found -back yellow
888
889
.pwbottom add .bleft
@@ -894,18 +894,18 @@ proc makewindow {} {
894
frame .bright.mode
895
radiobutton .bright.mode.patch -text "Patch" \
896
-command reselectline -variable cmitmode -value "patch"
897
- .bright.mode.patch configure -font $uifont
897
+ .bright.mode.patch configure -font uifont
898
radiobutton .bright.mode.tree -text "Tree" \
899
-command reselectline -variable cmitmode -value "tree"
900
- .bright.mode.tree configure -font $uifont
900
+ .bright.mode.tree configure -font uifont
901
grid .bright.mode.patch .bright.mode.tree -sticky ew
902
pack .bright.mode -side top -fill x
903
set cflist .bright.cfiles
904
- set indent [font measure $mainfont "nn"]
904
+ set indent [font measure mainfont "nn"]
905
text $cflist \
906
-selectbackground $selectbgcolor \
907
-background $bgcolor -foreground $fgcolor \
908
- -font $mainfont \
908
+ -font mainfont \
909
-tabs [list $indent [expr {2 * $indent}]] \
910
-yscrollcommand ".bright.sb set" \
911
-cursor [. cget -cursor] \
@@ -917,7 +917,7 @@ proc makewindow {} {
917
pack $cflist -side left -fill both -expand 1
918
$cflist tag configure highlight \
919
-background [$cflist cget -selectbackground]
920
- $cflist tag configure bold -font [concat $mainfont bold]
920
+ $cflist tag configure bold -font mainfontbold
921
922
.pwbottom add .bright
923
.ctop add .pwbottom
@@ -1272,10 +1272,10 @@ Copyright
1272
Use and redistribute under the terms of the GNU General Public License} \
1273
-justify center -aspect 400 -border 2 -bg white -relief groove
1274
pack $w.m -side top -fill x -padx 2 -pady 2
1275
- $w.m configure -font $uifont
1275
+ $w.m configure -font uifont
1276
button $w.ok -text Close -command "destroy $w" -default active
1277
pack $w.ok -side bottom
1278
- $w.ok configure -font $uifont
1278
+ $w.ok configure -font uifont
1279
bind $w <Visibility> "focus $w.ok"
1280
bind $w <Key-Escape> "destroy $w"
1281
bind $w <Key-Return> "destroy $w"
@@ -1336,10 +1336,10 @@ f Scroll diff view to next file
1336
" \
1337
-justify left -bg white -border 2 -relief groove
1338
pack $w.m -side top -fill both -padx 2 -pady 2
1339
- $w.m configure -font $uifont
1339
+ $w.m configure -font uifont
1340
button $w.ok -text Close -command "destroy $w" -default active
1341
pack $w.ok -side bottom
1342
- $w.ok configure -font $uifont
1342
+ $w.ok configure -font uifont
1343
bind $w <Visibility> "focus $w.ok"
1344
bind $w <Key-Escape> "destroy $w"
1345
bind $w <Key-Return> "destroy $w"
@@ -1871,22 +1871,22 @@ proc vieweditor {top n title} {
1871
1872
toplevel $top
1873
wm title $top $title
1874
- label $top.nl -text "Name" -font $uifont
1875
- entry $top.name -width 20 -textvariable newviewname($n) -font $uifont
1874
+ label $top.nl -text "Name" -font uifont
1875
+ entry $top.name -width 20 -textvariable newviewname($n) -font uifont
1876
grid $top.nl $top.name -sticky w -pady 5
1877
checkbutton $top.perm -text "Remember this view" -variable newviewperm($n) \
1878
- -font $uifont
1878
+ -font uifont
1879
grid $top.perm - -pady 5 -sticky w
1880
- message $top.al -aspect 1000 -font $uifont \
1880
+ message $top.al -aspect 1000 -font uifont \
1881
-text "Commits to include (arguments to git rev-list):"
1882
grid $top.al - -sticky w -pady 5
1883
entry $top.args -width 50 -textvariable newviewargs($n) \
1884
- -background white -font $uifont
1884
+ -background white -font uifont
1885
grid $top.args - -sticky ew -padx 5
1886
- message $top.l -aspect 1000 -font $uifont \
1886
+ message $top.l -aspect 1000 -font uifont \
1887
-text "Enter files and directories to include, one per line:"
1888
grid $top.l - -sticky w
1889
- text $top.t -width 40 -height 10 -background white -font $uifont
1889
+ text $top.t -width 40 -height 10 -background white -font uifont
1890
if {[info exists viewfiles($n)]} {
1891
foreach f $viewfiles($n) {
1892
$top.t insert end $f
@@ -1898,9 +1898,9 @@ proc vieweditor {top n title} {
1898
grid $top.t - -sticky ew -padx 5
1899
frame $top.buts
1900
button $top.buts.ok -text "OK" -command [list newviewok $top $n] \
1901
- -font $uifont
1901
+ -font uifont
1902
button $top.buts.can -text "Cancel" -command [list destroy $top] \
1903
- -font $uifont
1903
+ -font uifont
1904
grid $top.buts.ok $top.buts.can
1905
grid columnconfigure $top.buts 0 -weight 1 -uniform a
1906
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -2191,12 +2191,12 @@ proc bolden_name {row font} {
2191
}
2192
2193
proc unbolden {} {
2194
- global mainfont boldrows
2194
+ global boldrows
2195
2196
set stillbold {}
2197
foreach row $boldrows {
2198
if {![ishighlighted $row]} {
2199
- bolden $row $mainfont
2199
+ bolden $row mainfont
2200
} else {
2201
lappend stillbold $row
2202
}
@@ -2235,9 +2235,8 @@ proc delvhighlight {} {
2235
2236
proc vhighlightmore {} {
2237
global hlview vhl_done commitidx vhighlights
2238
- global displayorder vdisporder curview mainfont
2238
+ global displayorder vdisporder curview
2239
2240
- set font [concat $mainfont bold]
2240
set max $commitidx($hlview)
2241
if {$hlview == $curview} {
2242
set disp $displayorder
@@ -2253,7 +2252,7 @@ proc vhighlightmore {} {
2252
set row $commitrow($curview,$id)
2253
if {$r0 <= $row && $row <= $r1} {
2254
if {![highlighted $row]} {
2256
- bolden $row $font
2255
+ bolden $row mainfontbold
2256
}
2257
set vhighlights($row) 1
2258
}
@@ -2263,11 +2262,11 @@ proc vhighlightmore {} {
2262
}
2263
2264
proc askvhighlight {row id} {
2266
- global hlview vhighlights commitrow iddrawn mainfont
2265
+ global hlview vhighlights commitrow iddrawn
2266
2267
if {[info exists commitrow($hlview,$id)]} {
2268
if {[info exists iddrawn($id)] && ![ishighlighted $row]} {
2270
- bolden $row [concat $mainfont bold]
2269
+ bolden $row mainfontbold
2270
}
2271
set vhighlights($row) 1
2272
} else {
@@ -2277,7 +2276,7 @@ proc askvhighlight {row id} {
2276
2277
proc hfiles_change {} {
2278
global highlight_files filehighlight fhighlights fh_serial
2280
- global mainfont highlight_paths gdttype
2279
+ global highlight_paths gdttype
2280
2281
if {[info exists filehighlight]} {
2282
# delete previous highlights
@@ -2335,13 +2334,13 @@ proc find_change {name ix op} {
2334
}
2335
2336
proc findcom_change args {
2338
- global nhighlights mainfont boldnamerows
2337
+ global nhighlights boldnamerows
2338
global findpattern findtype findstring gdttype
2339
2340
stopfinding
2341
# delete previous highlights, if any
2342
foreach row $boldnamerows {
2344
- bolden_name $row $mainfont
2343
+ bolden_name $row mainfont
2344
}
2345
set boldnamerows {}
2346
catch {unset nhighlights}
@@ -2414,7 +2413,7 @@ proc askfilehighlight {row id} {
2413
}
2414
2415
proc readfhighlight {} {
2417
- global filehighlight fhighlights commitrow curview mainfont iddrawn
2416
+ global filehighlight fhighlights commitrow curview iddrawn
2417
global fhl_list find_dirn
2418
2419
if {![info exists filehighlight]} {
@@ -2436,7 +2435,7 @@ proc readfhighlight {} {
2435
if {![info exists commitrow($curview,$line)]} continue
2436
set row $commitrow($curview,$line)
2437
if {[info exists iddrawn($line)] && ![ishighlighted $row]} {
2439
- bolden $row [concat $mainfont bold]
2438
+ bolden $row mainfontbold
2439
}
2440
set fhighlights($row) 1
2441
}
@@ -2470,7 +2469,7 @@ proc doesmatch {f} {
2469
}
2470
2471
proc askfindhighlight {row id} {
2473
- global nhighlights commitinfo iddrawn mainfont
2472
+ global nhighlights commitinfo iddrawn
2473
global findloc
2474
global markingmatches
2475
@@ -2491,11 +2490,10 @@ proc askfindhighlight {row id} {
2490
}
2491
}
2492
if {$isbold && [info exists iddrawn($id)]} {
2494
- set f [concat $mainfont bold]
2493
if {![ishighlighted $row]} {
2496
- bolden $row $f
2494
+ bolden $row mainfontbold
2495
if {$isbold > 1} {
2498
- bolden_name $row $f
2496
+ bolden_name $row mainfontbold
2497
}
2498
}
2499
if {$markingmatches} {
@@ -2624,7 +2622,7 @@ proc is_ancestor {a} {
2622
}
2623
2624
proc askrelhighlight {row id} {
2627
- global descendent highlight_related iddrawn mainfont rhighlights
2625
+ global descendent highlight_related iddrawn rhighlights
2626
global selectedline ancestor
2627
2628
if {![info exists selectedline]} return
@@ -2648,7 +2646,7 @@ proc askrelhighlight {row id} {
2646
}
2647
if {[info exists iddrawn($id)]} {
2648
if {$isbold && ![ishighlighted $row]} {
2651
- bolden $row [concat $mainfont bold]
2649
+ bolden $row mainfontbold
2650
}
2651
}
2652
set rhighlights($row) $isbold
@@ -3624,7 +3622,7 @@ proc drawcmittext {id row col} {
3622
global commitlisted commitinfo rowidlist parentlist
3623
global rowtextx idpos idtags idheads idotherrefs
3624
global linehtag linentag linedtag selectedline
3627
- global mainfont canvxmax boldrows boldnamerows fgcolor nullid nullid2
3625
+ global canvxmax boldrows boldnamerows fgcolor nullid nullid2
3626
3627
# listed is 0 for boundary, 1 for normal, 2 for left, 3 for right
3628
set listed [lindex $commitlisted $row]
@@ -3681,15 +3679,15 @@ proc drawcmittext {id row col} {
3679
set name [lindex $commitinfo($id) 1]
3680
set date [lindex $commitinfo($id) 2]
3681
set date [formatdate $date]
3684
- set font $mainfont
3685
- set nfont $mainfont
3682
+ set font mainfont
3683
+ set nfont mainfont
3684
set isbold [ishighlighted $row]
3685
if {$isbold > 0} {
3686
lappend boldrows $row
3689
- lappend font bold
3687
+ set font mainfontbold
3688
if {$isbold > 1} {
3689
lappend boldnamerows $row
3692
- lappend nfont bold
3690
+ set nfont mainfontbold
3691
}
3692
}
3693
set linehtag($row) [$canv create text $xt $y -anchor w -fill $fgcolor \
@@ -3698,11 +3696,11 @@ proc drawcmittext {id row col} {
3696
set linentag($row) [$canv2 create text 3 $y -anchor w -fill $fgcolor \
3697
-text $name -font $nfont -tags text]
3698
set linedtag($row) [$canv3 create text 3 $y -anchor w -fill $fgcolor \
3701
- -text $date -font $mainfont -tags text]
3699
+ -text $date -font mainfont -tags text]
3700
if {[info exists selectedline] && $selectedline == $row} {
3701
make_secsel $row
3702
}
3705
- set xr [expr {$xt + [font measure $mainfont $headline]}]
3703
+ set xr [expr {$xt + [font measure $font $headline]}]
3704
if {$xr > $canvxmax} {
3705
set canvxmax $xr
3706
setcanvscroll
@@ -3985,7 +3983,7 @@ proc bindline {t id} {
3983
proc drawtags {id x xt y1} {
3984
global idtags idheads idotherrefs mainhead
3985
global linespc lthickness
3988
- global canv mainfont commitrow rowtextx curview fgcolor bgcolor
3986
+ global canv commitrow rowtextx curview fgcolor bgcolor
3987
3988
set marks {}
3989
set ntags 0
@@ -4014,9 +4012,9 @@ proc drawtags {id x xt y1} {
4012
foreach tag $marks {
4013
incr i
4014
if {$i >= $ntags && $i < $ntags + $nheads && $tag eq $mainhead} {
4017
- set wid [font measure [concat $mainfont bold] $tag]
4015
+ set wid [font measure mainfontbold $tag]
4016
} else {
4019
- set wid [font measure $mainfont $tag]
4017
+ set wid [font measure mainfont $tag]
4018
}
4019
lappend xvals $xt
4020
lappend wvals $wid
@@ -4028,7 +4026,7 @@ proc drawtags {id x xt y1} {
4026
foreach tag $marks x $xvals wid $wvals {
4027
set xl [expr {$x + $delta}]
4028
set xr [expr {$x + $delta + $wid + $lthickness}]
4031
- set font $mainfont
4029
+ set font mainfont
4030
if {[incr ntags -1] >= 0} {
4031
# draw a tag
4032
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
@@ -4041,7 +4039,7 @@ proc drawtags {id x xt y1} {
4039
if {[incr nheads -1] >= 0} {
4040
set col green
4041
if {$tag eq $mainhead} {
4044
- lappend font bold
4042
+ set font mainfontbold
4043
}
4044
} else {
4045
set col "#ddddff"
@@ -4050,7 +4048,7 @@ proc drawtags {id x xt y1} {
4048
$canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
4049
-width 1 -outline black -fill $col -tags tag.$id
4050
if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
4053
- set rwid [font measure $mainfont $remoteprefix]
4051
+ set rwid [font measure mainfont $remoteprefix]
4052
set xi [expr {$x + 1}]
4053
set yti [expr {$yt + 1}]
4054
set xri [expr {$x + $rwid}]
@@ -4082,10 +4080,10 @@ proc xcoord {i level ln} {
4080
}
4081
4082
proc show_status {msg} {
4085
- global canv mainfont fgcolor
4083
+ global canv fgcolor
4084
4085
clear_display
4088
- $canv create text 3 3 -anchor nw -text $msg -font $mainfont \
4086
+ $canv create text 3 3 -anchor nw -text $msg -font mainfont \
4087
-tags text -fill $fgcolor
4088
}
4089
@@ -5522,12 +5520,12 @@ proc clear_ctext {{first 1.0}} {
5520
}
5521
5522
proc settabs {{firstab {}}} {
5525
- global firsttabstop tabstop textfont ctext have_tk85
5523
+ global firsttabstop tabstop ctext have_tk85
5524
5525
if {$firstab ne {} && $have_tk85} {
5526
set firsttabstop $firstab
5527
}
5530
- set w [font measure $textfont "0"]
5528
+ set w [font measure textfont "0"]
5529
if {$firsttabstop != 0} {
5530
$ctext conf -tabs [list [expr {($firsttabstop + $tabstop) * $w}] \
5531
[expr {($firsttabstop + 2 * $tabstop) * $w}]]
@@ -5658,11 +5656,11 @@ proc scrolltext {f0 f1} {
5656
}
5657
5658
proc setcoords {} {
5661
- global linespc charspc canvx0 canvy0 mainfont
5659
+ global linespc charspc canvx0 canvy0
5660
global xspc1 xspc2 lthickness
5661
5664
- set linespc [font metrics $mainfont -linespace]
5665
- set charspc [font measure $mainfont "m"]
5662
+ set linespc [font metrics mainfont -linespace]
5663
+ set charspc [font measure mainfont "m"]
5664
set canvy0 [expr {int(3 + 0.5 * $linespc)}]
5665
set canvx0 [expr {int(3 + 0.5 * $linespc)}]
5666
set lthickness [expr {int($linespc / 9) + 1}]
@@ -5687,25 +5685,45 @@ proc redisplay {} {
5685
}
5686
}
5687
5688
+proc fontdescr {f} {
5689
+ set d [list [font actual $f -family] [font actual $f -size]]
5690
+ if {[font actual $f -weight] eq "bold"} {
5691
+ lappend d "bold"
5692
+ }
5693
+ if {[font actual $f -slant] eq "italic"} {
5694
+ lappend d "italic"
5695
+ }
5696
+ if {[font actual $f -underline]} {
5697
+ lappend d "underline"
5698
+ }
5699
+ if {[font actual $f -overstrike]} {
5700
+ lappend d "overstrike"
5701
+ }
5702
+ return $d
5703
+}
5704
+
5705
proc incrfont {inc} {
5706
global mainfont textfont ctext canv phase cflist showrefstop
5707
global stopped entries
5708
unmarkmatches
5694
- set mainfont [lreplace $mainfont 1 1 [expr {[lindex $mainfont 1] + $inc}]]
5695
- set textfont [lreplace $textfont 1 1 [expr {[lindex $textfont 1] + $inc}]]
5709
+ set s [font actual mainfont -size]
5710
+ incr s $inc
5711
+ if {$s < 1} {
5712
+ set s 1
5713
+ }
5714
+ font config mainfont -size $s
5715
+ font config mainfontbold -size $s
5716
+ set mainfont [fontdescr mainfont]
5717
+ set s [font actual textfont -size]
5718
+ incr s $inc
5719
+ if {$s < 1} {
5720
+ set s 1
5721
+ }
5722
+ font config textfont -size $s
5723
+ font config textfontbold -size $s
5724
+ set textfont [fontdescr textfont]
5725
setcoords
5726
settabs
5698
- $cflist conf -font $textfont
5699
- $ctext tag conf filesep -font [concat $textfont bold]
5700
- foreach e $entries {
5701
- $e conf -font $mainfont
5702
- }
5703
- if {$phase eq "getcommits"} {
5704
- $canv itemconf textitems -font $mainfont
5705
- }
5706
- if {[info exists showrefstop] && [winfo exists $showrefstop]} {
5707
- $showrefstop.list conf -font $mainfont
5708
- }
5727
redisplay
5728
}
5729
@@ -5816,7 +5834,7 @@ proc lineleave {id} {
5834
proc linehover {} {
5835
global hoverx hovery hoverid hovertimer
5836
global canv linespc lthickness
5819
- global commitinfo mainfont
5837
+ global commitinfo
5838
5839
set text [lindex $commitinfo($hoverid) 0]
5840
set ymax [lindex [$canv cget -scrollregion] 3]
@@ -5826,13 +5844,13 @@ proc linehover {} {
5844
set y [expr {$hovery + $yfrac * $ymax - $linespc / 2}]
5845
set x0 [expr {$x - 2 * $lthickness}]
5846
set y0 [expr {$y - 2 * $lthickness}]
5829
- set x1 [expr {$x + [font measure $mainfont $text] + 2 * $lthickness}]
5847
+ set x1 [expr {$x + [font measure mainfont $text] + 2 * $lthickness}]
5848
set y1 [expr {$y + $linespc + 2 * $lthickness}]
5849
set t [$canv create rectangle $x0 $y0 $x1 $y1 \
5850
-fill \#ffff80 -outline black -width 1 -tags hover]
5851
$canv raise $t
5852
set t [$canv create text $x $y -anchor nw -text $text -tags hover \
5835
- -font $mainfont]
5853
+ -font mainfont]
5854
$canv raise $t
5855
}
5856
@@ -6168,7 +6186,7 @@ proc domktag {} {
6186
6187
proc redrawtags {id} {
6188
global canv linehtag commitrow idpos selectedline curview
6171
- global mainfont canvxmax iddrawn
6189
+ global canvxmax iddrawn
6190
6191
if {![info exists commitrow($curview,$id)]} return
6192
if {![info exists iddrawn($id)]} return
@@ -6177,7 +6195,7 @@ proc redrawtags {id} {
6195
set xt [eval drawtags $id $idpos($id)]
6196
$canv coords $linehtag($commitrow($curview,$id)) $xt [lindex $idpos($id) 2]
6197
set text [$canv itemcget $linehtag($commitrow($curview,$id)) -text]
6180
- set xr [expr {$xt + [font measure $mainfont $text]}]
6198
+ set xr [expr {$xt + [font measure mainfont $text]}]
6199
if {$xr > $canvxmax} {
6200
set canvxmax $xr
6201
setcanvscroll
@@ -6509,8 +6527,8 @@ proc rmbranch {} {
6527
6528
# Display a list of tags and heads
6529
proc showrefs {} {
6512
- global showrefstop bgcolor fgcolor selectbgcolor mainfont
6513
- global bglist fglist uifont reflistfilter reflist maincursor
6530
+ global showrefstop bgcolor fgcolor selectbgcolor
6531
+ global bglist fglist reflistfilter reflist maincursor
6532
6533
set top .showrefs
6534
set showrefstop $top
@@ -6522,7 +6540,7 @@ proc showrefs {} {
6540
toplevel $top
6541
wm title $top "Tags and heads: [file tail [pwd]]"
6542
text $top.list -background $bgcolor -foreground $fgcolor \
6525
- -selectbackground $selectbgcolor -font $mainfont \
6543
+ -selectbackground $selectbgcolor -font mainfont \
6544
-xscrollcommand "$top.xsb set" -yscrollcommand "$top.ysb set" \
6545
-width 30 -height 20 -cursor $maincursor \
6546
-spacing1 1 -spacing3 1 -state disabled
@@ -6534,15 +6552,15 @@ proc showrefs {} {
6552
grid $top.list $top.ysb -sticky nsew
6553
grid $top.xsb x -sticky ew
6554
frame $top.f
6537
- label $top.f.l -text "Filter: " -font $uifont
6538
- entry $top.f.e -width 20 -textvariable reflistfilter -font $uifont
6555
+ label $top.f.l -text "Filter: " -font uifont
6556
+ entry $top.f.e -width 20 -textvariable reflistfilter -font uifont
6557
set reflistfilter "*"
6558
trace add variable reflistfilter write reflistfilter_change
6559
pack $top.f.e -side right -fill x -expand 1
6560
pack $top.f.l -side left
6561
grid $top.f - -sticky ew -pady 2
6562
button $top.close -command [list destroy $top] -text "Close" \
6545
- -font $uifont
6563
+ -font uifont
6564
grid $top.close -
6565
grid columnconfigure $top 0 -weight 1
6566
grid rowconfigure $top 0 -weight 1
@@ -7845,7 +7863,7 @@ proc doprefs {} {
7863
toplevel $top
7864
wm title $top "Gitk preferences"
7865
label $top.ldisp -text "Commit list display options"
7848
- $top.ldisp configure -font $uifont
7866
+ $top.ldisp configure -font uifont
7867
grid $top.ldisp - -sticky w -pady 10
7868
label $top.spacer -text " "
7869
label $top.maxwidthl -text "Maximum graph width (lines)" \
@@ -7863,7 +7881,7 @@ proc doprefs {} {
7881
grid x $top.showlocal -sticky w
7882
7883
label $top.ddisp -text "Diff display options"
7866
- $top.ddisp configure -font $uifont
7884
+ $top.ddisp configure -font uifont
7885
grid $top.ddisp - -sticky w -pady 10
7886
label $top.diffoptl -text "Options for diff program" \
7887
-font optionfont
@@ -7879,7 +7897,7 @@ proc doprefs {} {
7897
grid x $top.tabstopl $top.tabstop -sticky w
7898
7899
label $top.cdisp -text "Colors: press to choose"
7882
- $top.cdisp configure -font $uifont
7900
+ $top.cdisp configure -font uifont
7901
grid $top.cdisp - -sticky w -pady 10
7902
label $top.bg -padx 40 -relief sunk -background $bgcolor
7903
button $top.bgbut -text "Background" -font optionfont \
@@ -7912,9 +7930,9 @@ proc doprefs {} {
7930
7931
frame $top.buts
7932
button $top.buts.ok -text "OK" -command prefsok -default active
7915
- $top.buts.ok configure -font $uifont
7933
+ $top.buts.ok configure -font uifont
7934
button $top.buts.can -text "Cancel" -command prefscan -default normal
7917
- $top.buts.can configure -font $uifont
7935
+ $top.buts.can configure -font uifont
7936
grid $top.buts.ok $top.buts.can
7937
grid columnconfigure $top.buts 0 -weight 1 -uniform a
7938
grid columnconfigure $top.buts 1 -weight 1 -uniform a
@@ -8322,6 +8340,15 @@ set selectbgcolor gray85
8340
catch {source ~/.gitk}
8341
8342
font create optionfont -family sans-serif -size -12
8343
+font create mainfont
8344
+catch {eval font config mainfont [font actual $mainfont]}
8345
+eval font create mainfontbold [font actual mainfont] -weight bold
8346
+font create textfont
8347
+catch {eval font config textfont [font actual $textfont]}
8348
+eval font create textfontbold [font actual textfont]
8349
+font config textfontbold -weight bold
8350
+font create uifont
8351
+catch {eval font config uifont [font actual $uifont]}
8352
8353
# check that we can find a .git directory somewhere...
8354
if {[catch {set gitdir [gitdir]}]} {