Skip to content

Commit 2c26e6f

Browse files
committed
git-gui: Allow the user to change the diff viewer font size.
Because the diff area is one of the most important areas to be able to read users should be able to increase or decrease the size of the font used within that area. Currently we save that back to the global configuration, even if it may have originated from the local repository configuration. This is probably going to be considered to be a bug by at least one user who wants some sort of different font within a given repository, but I'm just going to ignore the problem for now. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent f019c96 commit 2c26e6f

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

git-gui

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ proc load_repo_config {} {
3939
proc save_my_config {} {
4040
global repo_config
4141
global cfg_trust_mtime
42+
global font_diff
4243

4344
if {[catch {set rc_trustMTime $repo_config(gui.trustmtime)}]} {
4445
set rc_trustMTime [list false]
@@ -48,6 +49,14 @@ proc save_my_config {} {
4849
set repo_config(gui.trustmtime) [list $cfg_trust_mtime]
4950
}
5051

52+
if {[catch {set rc_fontdiff $repo_config(gui.fontdiff)}]} {
53+
set rc_fontdiff [list {Courier 10}]
54+
}
55+
if {$font_diff != [lindex $rc_fontdiff 0]} {
56+
exec git repo-config --global gui.fontDiff $font_diff
57+
set repo_config(gui.fontdiff) [list $font_diff]
58+
}
59+
5160
set cfg_geometry [wm geometry .]
5261
append cfg_geometry " [lindex [.vpane sash coord 0] 1]"
5362
append cfg_geometry " [lindex [.vpane.files sash coord 0] 0]"
@@ -1890,9 +1899,9 @@ pack .vpane.lower.diff.body -side bottom -fill both -expand 1
18901899

18911900
$ui_diff tag conf dm -foreground red
18921901
$ui_diff tag conf dp -foreground blue
1893-
$ui_diff tag conf da -font [concat $font_diff bold]
18941902
$ui_diff tag conf di -foreground "#00a000"
18951903
$ui_diff tag conf dni -foreground "#a000a0"
1904+
$ui_diff tag conf da -font [concat $font_diff bold]
18961905
$ui_diff tag conf bold -font [concat $font_diff bold]
18971906

18981907
# -- Diff Body Context Menu
@@ -1911,6 +1920,23 @@ $ui_diff.ctxm add command -label "Copy All" \
19111920
tk_textCopy $ui_diff
19121921
$ui_diff tag remove sel 0.0 end
19131922
"
1923+
$ui_diff.ctxm add separator
1924+
$ui_diff.ctxm add command -label "Decrease Font Size" \
1925+
-font $font_ui \
1926+
-command {
1927+
lset font_diff 1 [expr [lindex $font_diff 1] - 1]
1928+
$ui_diff configure -font $font_diff
1929+
$ui_diff tag conf da -font [concat $font_diff bold]
1930+
$ui_diff tag conf bold -font [concat $font_diff bold]
1931+
}
1932+
$ui_diff.ctxm add command -label "Increase Font Size" \
1933+
-font $font_ui \
1934+
-command {
1935+
lset font_diff 1 [expr [lindex $font_diff 1] + 1]
1936+
$ui_diff configure -font $font_diff
1937+
$ui_diff tag conf da -font [concat $font_diff bold]
1938+
$ui_diff tag conf bold -font [concat $font_diff bold]
1939+
}
19141940
bind $ui_diff <Any-Button-3> "tk_popup $ui_diff.ctxm %X %Y"
19151941

19161942
# -- Status Bar

0 commit comments

Comments
 (0)