git-gui: Allow the user to change the diff viewer font size.
authorShawn O. Pearce <spearce@spearce.org>
Sun, 12 Nov 2006 02:14:28 +0000 (21:14 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 12 Nov 2006 05:16:04 +0000 (00:16 -0500)
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 <spearce@spearce.org>
git-gui

diff --git a/git-gui b/git-gui
index 26df169c1877d7779343fcf467b84acca110cb46..fdb1dce88df22c63c74f0fcbd687fbfa639bbcef 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -39,6 +39,7 @@ proc load_repo_config {} {
 proc save_my_config {} {
        global repo_config
        global cfg_trust_mtime
+       global font_diff
 
        if {[catch {set rc_trustMTime $repo_config(gui.trustmtime)}]} {
                set rc_trustMTime [list false]
@@ -48,6 +49,14 @@ proc save_my_config {} {
                set repo_config(gui.trustmtime) [list $cfg_trust_mtime]
        }
 
+       if {[catch {set rc_fontdiff $repo_config(gui.fontdiff)}]} {
+               set rc_fontdiff [list {Courier 10}]
+       }
+       if {$font_diff != [lindex $rc_fontdiff 0]} {
+               exec git repo-config --global gui.fontDiff $font_diff
+               set repo_config(gui.fontdiff) [list $font_diff]
+       }
+
        set cfg_geometry [wm geometry .]
        append cfg_geometry " [lindex [.vpane sash coord 0] 1]"
        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
 
 $ui_diff tag conf dm -foreground red
 $ui_diff tag conf dp -foreground blue
-$ui_diff tag conf da -font [concat $font_diff bold]
 $ui_diff tag conf di -foreground "#00a000"
 $ui_diff tag conf dni -foreground "#a000a0"
+$ui_diff tag conf da -font [concat $font_diff bold]
 $ui_diff tag conf bold -font [concat $font_diff bold]
 
 # -- Diff Body Context Menu
@@ -1911,6 +1920,23 @@ $ui_diff.ctxm add command -label "Copy All" \
                tk_textCopy $ui_diff
                $ui_diff tag remove sel 0.0 end
        "
+$ui_diff.ctxm add separator
+$ui_diff.ctxm add command -label "Decrease Font Size" \
+       -font $font_ui \
+       -command {
+               lset font_diff 1 [expr [lindex $font_diff 1] - 1]
+               $ui_diff configure -font $font_diff
+               $ui_diff tag conf da -font [concat $font_diff bold]
+               $ui_diff tag conf bold -font [concat $font_diff bold]
+       }
+$ui_diff.ctxm add command -label "Increase Font Size" \
+       -font $font_ui \
+       -command {
+               lset font_diff 1 [expr [lindex $font_diff 1] + 1]
+               $ui_diff configure -font $font_diff
+               $ui_diff tag conf da -font [concat $font_diff bold]
+               $ui_diff tag conf bold -font [concat $font_diff bold]
+       }
 bind $ui_diff <Any-Button-3> "tk_popup $ui_diff.ctxm %X %Y"
 
 # -- Status Bar