git-gui: Allow the user to manipulate the fonts from the options panel.
[gitweb.git] / git-gui
diff --git a/git-gui b/git-gui
index 8a42c97cb186283086b2455e6e199379ef6626b5..931a959307929de4b8a78c037ebdb6f3f5b78e04 100755 (executable)
--- a/git-gui
+++ b/git-gui
@@ -14,49 +14,103 @@ set gitdir {}
 ##
 ## config
 
-proc load_repo_config {} {
-       global repo_config
-       global cfg_trust_mtime
+proc is_many_config {name} {
+       switch -glob -- $name {
+       remote.*.fetch -
+       remote.*.push
+               {return 1}
+       *
+               {return 0}
+       }
+}
+
+proc load_config {} {
+       global repo_config global_config default_config
 
+       array unset global_config
        array unset repo_config
+       catch {
+               set fd_rc [open "| git repo-config --global --list" r]
+               while {[gets $fd_rc line] >= 0} {
+                       if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
+                               if {[is_many_config $name]} {
+                                       lappend global_config($name) $value
+                               } else {
+                                       set global_config($name) $value
+                               }
+                       }
+               }
+               close $fd_rc
+       }
        catch {
                set fd_rc [open "| git repo-config --list" r]
                while {[gets $fd_rc line] >= 0} {
                        if {[regexp {^([^=]+)=(.*)$} $line line name value]} {
-                               lappend repo_config($name) $value
+                               if {[is_many_config $name]} {
+                                       lappend repo_config($name) $value
+                               } else {
+                                       set repo_config($name) $value
+                               }
                        }
                }
                close $fd_rc
        }
 
-       if {[catch {set cfg_trust_mtime \
-                       [lindex $repo_config(gui.trustmtime) 0]
-               }]} {
-               set cfg_trust_mtime false
+       foreach name [array names default_config] {
+               if {[catch {set v $global_config($name)}]} {
+                       set global_config($name) $default_config($name)
+               }
+               if {[catch {set v $repo_config($name)}]} {
+                       set repo_config($name) $default_config($name)
+               }
        }
 }
 
-proc save_my_config {} {
-       global repo_config
-       global cfg_trust_mtime
+proc save_config {} {
+       global default_config font_descs
+       global repo_config global_config
+       global repo_config_new global_config_new
 
-       if {[catch {set rc_trustMTime $repo_config(gui.trustmtime)}]} {
-               set rc_trustMTime [list false]
-       }
-       if {$cfg_trust_mtime != [lindex $rc_trustMTime 0]} {
-               exec git repo-config gui.trustMTime $cfg_trust_mtime
-               set repo_config(gui.trustmtime) [list $cfg_trust_mtime]
+       foreach option $font_descs {
+               set name [lindex $option 0]
+               set font [lindex $option 1]
+               font configure $font \
+                       -family $global_config_new(gui.$font^^family) \
+                       -size $global_config_new(gui.$font^^size)
+               font configure ${font}bold \
+                       -family $global_config_new(gui.$font^^family) \
+                       -size $global_config_new(gui.$font^^size)
+               set global_config_new(gui.$name) [font configure $font]
+               unset global_config_new(gui.$font^^family)
+               unset global_config_new(gui.$font^^size)
        }
 
-       set cfg_geometry [wm geometry .]
-       append cfg_geometry " [lindex [.vpane sash coord 0] 1]"
-       append cfg_geometry " [lindex [.vpane.files sash coord 0] 0]"
-       if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
-               set rc_geometry [list [list]]
+       foreach name [array names default_config] {
+               set value $global_config_new($name)
+               if {$value != $global_config($name)} {
+                       if {$value == $default_config($name)} {
+                               catch {exec git repo-config --global --unset $name}
+                       } else {
+                               catch {exec git repo-config --global $name $value}
+                       }
+                       set global_config($name) $value
+                       if {$value == $repo_config($name)} {
+                               catch {exec git repo-config --unset $name}
+                               set repo_config($name) $value
+                       }
+               }
        }
-       if {$cfg_geometry != [lindex $rc_geometry 0]} {
-               exec git repo-config gui.geometry $cfg_geometry
-               set repo_config(gui.geometry) [list $cfg_geometry]
+
+       foreach name [array names default_config] {
+               set value $repo_config_new($name)
+               if {$value != $repo_config($name)} {
+                       if {$value == $global_config($name)} {
+                               catch {exec git repo-config --unset $name}
+                       } else {
+                               catch {exec git repo-config $name $value}
+                       }
+                       set repo_config($name) $value
+               }
        }
 }
 
@@ -79,6 +133,25 @@ proc error_popup {msg} {
                -message $msg
 }
 
+proc info_popup {msg} {
+       global gitdir appname
+
+       set title $appname
+       if {$gitdir != {}} {
+               append title { (}
+               append title [lindex \
+                       [file split [file normalize [file dirname $gitdir]]] \
+                       end]
+               append title {)}
+       }
+       tk_messageBox \
+               -parent . \
+               -icon error \
+               -type ok \
+               -title $title \
+               -message $msg
+}
+
 ######################################################################
 ##
 ## repository setup
@@ -98,8 +171,6 @@ if {$appname == {git-citool}} {
        set single_commit 1
 }
 
-load_repo_config
-
 ######################################################################
 ##
 ## task management
@@ -164,7 +235,7 @@ proc update_status {{final Ready.}} {
        global HEAD PARENT commit_type
        global ui_index ui_other ui_status_value ui_comm
        global status_active file_states
-       global cfg_trust_mtime
+       global repo_config
 
        if {$status_active || ![lock_index read]} return
 
@@ -190,12 +261,17 @@ proc update_status {{final Ready.}} {
                $ui_comm edit reset
        }
 
-       if {$cfg_trust_mtime == {true}} {
+       if {$repo_config(gui.trustmtime) == {true}} {
                update_status_stage2 {} $final
        } else {
                set status_active 1
                set ui_status_value {Refreshing file status...}
-               set fd_rf [open "| git update-index -q --unmerged --refresh" r]
+               set cmd [list git update-index]
+               lappend cmd -q
+               lappend cmd --unmerged
+               lappend cmd --ignore-missing
+               lappend cmd --refresh
+               set fd_rf [open "| $cmd" r]
                fconfigure $fd_rf -blocking 0 -translation binary
                fileevent $fd_rf readable \
                        [list update_status_stage2 $fd_rf $final]
@@ -372,6 +448,42 @@ proc reshow_diff {} {
        }
 }
 
+proc handle_empty_diff {} {
+       global ui_fname_value file_states file_lists
+
+       set path $ui_fname_value
+       set s $file_states($path)
+       if {[lindex $s 0] != {_M}} return
+
+       info_popup "No differences detected.
+
+[short_path $path] has no changes.
+
+The modification date of this file was updated by another
+application and you currently have the Trust File Modification
+Timestamps option enabled, so Git did not automatically detect
+that there are no content differences in this file.
+
+This file will now be removed from the modified files list, to
+prevent possible confusion.
+"
+       if {[catch {exec git update-index -- $path} err]} {
+               error_popup "Failed to refresh index:\n\n$err"
+       }
+
+       clear_diff
+       set old_w [mapcol [lindex $file_states($path) 0] $path]
+       set lno [lsearch -sorted $file_lists($old_w) $path]
+       if {$lno >= 0} {
+               set file_lists($old_w) \
+                       [lreplace $file_lists($old_w) $lno $lno]
+               incr lno
+               $old_w conf -state normal
+               $old_w delete $lno.0 [expr $lno + 1].0
+               $old_w conf -state disabled
+       }
+}
+
 proc show_diff {path {w {}} {lno {}}} {
        global file_states file_lists
        global PARENT diff_3way diff_active
@@ -442,6 +554,7 @@ proc show_diff {path {w {}} {lno {}}} {
 
 proc read_diff {fd} {
        global ui_diff ui_status_value diff_3way diff_active
+       global repo_config
 
        while {[gets $fd line] >= 0} {
                if {[string match {diff --git *} $line]} continue
@@ -488,6 +601,11 @@ proc read_diff {fd} {
                set diff_active 0
                unlock_index
                set ui_status_value {Ready.}
+
+               if {$repo_config(gui.trustmtime) == {true}
+                       && [$ui_diff index end] == {2.0}} {
+                       handle_empty_diff
+               }
        }
 }
 
@@ -579,7 +697,7 @@ before committing.
                U? {
                        error_popup "Unmerged files cannot be committed.
 
-File [escape_path $path] has merge conflicts.
+File [short_path $path] has merge conflicts.
 You must resolve them and include the file before committing.
 "
                        unlock_index
@@ -588,7 +706,7 @@ You must resolve them and include the file before committing.
                default {
                        error_popup "Unknown file state [lindex $s 0] detected.
 
-File [escape_path $path] cannot be committed by this program.
+File [short_path $path] cannot be committed by this program.
 "
                }
                }
@@ -879,6 +997,10 @@ proc escape_path {path} {
        return $path
 }
 
+proc short_path {path} {
+       return [escape_path [lindex [file split $path] end]]
+}
+
 set next_icon_id 0
 
 proc merge_state {path new_state} {
@@ -912,7 +1034,6 @@ proc merge_state {path new_state} {
 }
 
 proc display_file {path state} {
-       global ui_index ui_other
        global file_states file_lists status_active
 
        set old_m [merge_state $path $state]
@@ -1057,17 +1178,17 @@ proc load_all_remotes {} {
 }
 
 proc populate_remote_menu {m pfx op} {
-       global all_remotes font_ui
+       global all_remotes
 
        foreach remote $all_remotes {
                $m add command -label "$pfx $remote..." \
                        -command [list $op $remote] \
-                       -font $font_ui
+                       -font font_ui
        }
 }
 
 proc populate_pull_menu {m} {
-       global gitdir repo_config all_remotes font_ui disable_on_lock
+       global gitdir repo_config all_remotes disable_on_lock
 
        foreach remote $all_remotes {
                set rb {}
@@ -1095,7 +1216,7 @@ proc populate_pull_menu {m} {
                        $m add command \
                                -label "Branch $rb_short from $remote..." \
                                -command [list pull_remote $remote $rb] \
-                               -font $font_ui
+                               -font font_ui
                        lappend disable_on_lock \
                                [list $m entryconf [$m index last] -state]
                }
@@ -1217,29 +1338,52 @@ unset filemask i
 ##
 ## util
 
+proc is_MacOSX {} {
+       global tcl_platform tk_library
+       if {$tcl_platform(platform) == {unix}
+               && $tcl_platform(os) == {Darwin}
+               && [string match /Library/Frameworks/* $tk_library]} {
+               return 1
+       }
+       return 0
+}
+
+proc bind_button3 {w cmd} {
+       bind $w <Any-Button-3> $cmd
+       if {[is_MacOSX]} {
+               bind $w <Control-Button-1> $cmd
+       }
+}
+
+proc incr_font_size {font {amt 1}} {
+       set sz [font configure $font -size]
+       incr sz $amt
+       font configure $font -size $sz
+       font configure ${font}bold -size $sz
+}
+
 proc hook_failed_popup {hook msg} {
-       global gitdir font_ui font_diff appname
+       global gitdir appname
 
        set w .hookfail
        toplevel $w
-       wm transient $w .
 
        frame $w.m
        label $w.m.l1 -text "$hook hook failed:" \
                -anchor w \
                -justify left \
-               -font [concat $font_ui bold]
+               -font font_uibold
        text $w.m.t \
                -background white -borderwidth 1 \
                -relief sunken \
                -width 80 -height 10 \
-               -font $font_diff \
+               -font font_diff \
                -yscrollcommand [list $w.m.sby set]
        label $w.m.l2 \
                -text {You must correct the above errors before committing.} \
                -anchor w \
                -justify left \
-               -font [concat $font_ui bold]
+               -font font_uibold
        scrollbar $w.m.sby -command [list $w.m.t yview]
        pack $w.m.l1 -side top -fill x
        pack $w.m.l2 -side bottom -fill x
@@ -1252,7 +1396,7 @@ proc hook_failed_popup {hook msg} {
 
        button $w.ok -text OK \
                -width 15 \
-               -font $font_ui \
+               -font font_ui \
                -command "destroy $w"
        pack $w.ok -side bottom
 
@@ -1275,7 +1419,7 @@ proc new_console {short_title long_title} {
 
 proc console_init {w} {
        global console_cr console_data
-       global gitdir appname font_ui font_diff M1B
+       global gitdir appname M1B
 
        set console_cr($w) 1.0
        toplevel $w
@@ -1283,17 +1427,17 @@ proc console_init {w} {
        label $w.m.l1 -text "[lindex $console_data($w) 1]:" \
                -anchor w \
                -justify left \
-               -font [concat $font_ui bold]
+               -font font_uibold
        text $w.m.t \
                -background white -borderwidth 1 \
                -relief sunken \
                -width 80 -height 10 \
-               -font $font_diff \
+               -font font_diff \
                -state disabled \
                -yscrollcommand [list $w.m.sby set]
        label $w.m.s -anchor w \
                -justify left \
-               -font [concat $font_ui bold]
+               -font font_uibold
        scrollbar $w.m.sby -command [list $w.m.t yview]
        pack $w.m.l1 -side top -fill x
        pack $w.m.s -side bottom -fill x
@@ -1303,13 +1447,13 @@ proc console_init {w} {
 
        menu $w.ctxm -tearoff 0
        $w.ctxm add command -label "Copy" \
-               -font $font_ui \
+               -font font_ui \
                -command "tk_textCopy $w.m.t"
        $w.ctxm add command -label "Select All" \
-               -font $font_ui \
+               -font font_ui \
                -command "$w.m.t tag add sel 0.0 end"
        $w.ctxm add command -label "Copy All" \
-               -font $font_ui \
+               -font font_ui \
                -command "
                        $w.m.t tag add sel 0.0 end
                        tk_textCopy $w.m.t
@@ -1318,12 +1462,12 @@ proc console_init {w} {
 
        button $w.ok -text {Running...} \
                -width 15 \
-               -font $font_ui \
+               -font font_ui \
                -state disabled \
                -command "destroy $w"
        pack $w.ok -side bottom
 
-       bind $w.m.t <Any-Button-3> "tk_popup $w.ctxm %X %Y"
+       bind_button3 $w.m.t "tk_popup $w.ctxm %X %Y"
        bind $w.m.t <$M1B-Key-a> "$w.m.t tag add sel 0.0 end;break"
        bind $w.m.t <$M1B-Key-A> "$w.m.t tag add sel 0.0 end;break"
        bind $w <Visibility> "focus $w"
@@ -1440,14 +1584,16 @@ proc do_repack {} {
        console_exec $w $cmd
 }
 
-set quitting 0
+set is_quitting 0
 
 proc do_quit {} {
-       global gitdir ui_comm quitting
+       global gitdir ui_comm is_quitting repo_config
 
-       if {$quitting} return
-       set quitting 1
+       if {$is_quitting} return
+       set is_quitting 1
 
+       # -- Stash our current commit buffer.
+       #
        set save [file join $gitdir GITGUI_MSG]
        set msg [string trim [$ui_comm get 0.0 end]]
        if {[$ui_comm edit modified] && $msg != {}} {
@@ -1460,7 +1606,19 @@ proc do_quit {} {
                file delete $save
        }
 
-       save_my_config
+       # -- Stash our current window geometry into this repository.
+       #
+       set cfg_geometry [list]
+       lappend cfg_geometry [wm geometry .]
+       lappend cfg_geometry [lindex [.vpane sash coord 0] 1]
+       lappend cfg_geometry [lindex [.vpane.files sash coord 0] 0]
+       if {[catch {set rc_geometry $repo_config(gui.geometry)}]} {
+               set rc_geometry {}
+       }
+       if {$cfg_geometry != $rc_geometry} {
+               catch {exec git repo-config gui.geometry $cfg_geometry}
+       }
+
        destroy .
 }
 
@@ -1532,6 +1690,134 @@ proc do_commit {} {
        commit_tree
 }
 
+proc do_options {} {
+       global appname gitdir font_descs
+       global repo_config global_config
+       global repo_config_new global_config_new
+
+       load_config
+       array unset repo_config_new
+       array unset global_config_new
+       foreach name [array names repo_config] {
+               set repo_config_new($name) $repo_config($name)
+       }
+       foreach name [array names global_config] {
+               set global_config_new($name) $global_config($name)
+       }
+
+       set w .options_editor
+       toplevel $w
+
+       label $w.header -text "$appname Options" \
+               -font font_uibold
+       pack $w.header -side top -fill x
+
+       frame $w.buttons
+       button $w.buttons.restore -text {Restore Defaults} \
+               -font font_ui \
+               -command do_restore_defaults
+       pack $w.buttons.restore -side left
+       button $w.buttons.save -text Save \
+               -font font_ui \
+               -command [list do_save_config $w]
+       pack $w.buttons.save -side right
+       button $w.buttons.cancel -text {Cancel} \
+               -font font_ui \
+               -command [list destroy $w]
+       pack $w.buttons.cancel -side right
+       pack $w.buttons -side bottom -fill x -pady 10 -padx 10
+
+       labelframe $w.repo -text {This Repository} \
+               -font font_ui \
+               -relief raised -borderwidth 2
+       labelframe $w.global -text {Global (All Repositories)} \
+               -font font_ui \
+               -relief raised -borderwidth 2
+       pack $w.repo -side left -fill both -expand 1 -pady 5 -padx 5
+       pack $w.global -side right -fill both -expand 1 -pady 5 -padx 5
+
+       foreach option {
+               {trustmtime {Trust File Modification Timestamps}}
+               } {
+               set name [lindex $option 0]
+               set text [lindex $option 1]
+               foreach f {repo global} {
+                       checkbutton $w.$f.$name -text $text \
+                               -variable ${f}_config_new(gui.$name) \
+                               -onvalue true \
+                               -offvalue false \
+                               -font font_ui
+                       pack $w.$f.$name -side top -anchor w
+               }
+       }
+
+       set all_fonts [lsort [font families]]
+       foreach option $font_descs {
+               set name [lindex $option 0]
+               set font [lindex $option 1]
+               set text [lindex $option 2]
+
+               set global_config_new(gui.$font^^family) \
+                       [font configure $font -family]
+               set global_config_new(gui.$font^^size) \
+                       [font configure $font -size]
+
+               frame $w.global.$name
+               label $w.global.$name.l -text "$text:" -font font_ui
+               pack $w.global.$name.l -side left -anchor w -fill x
+               eval tk_optionMenu $w.global.$name.family \
+                       global_config_new(gui.$font^^family) \
+                       $all_fonts
+               spinbox $w.global.$name.size \
+                       -textvariable global_config_new(gui.$font^^size) \
+                       -from 2 -to 80 -increment 1 \
+                       -width 3 \
+                       -font font_ui
+               pack $w.global.$name.size -side right -anchor e
+               pack $w.global.$name.family -side right -anchor e
+               pack $w.global.$name -side top -anchor w -fill x
+       }
+
+       bind $w <Visibility> "grab $w; focus $w"
+       bind $w <Key-Escape> "destroy $w"
+       wm title $w "$appname ([lindex [file split \
+               [file normalize [file dirname $gitdir]]] \
+               end]): Options"
+       tkwait window $w
+}
+
+proc do_restore_defaults {} {
+       global font_descs default_config
+       global repo_config_new global_config_new
+
+       foreach name [array names default_config] {
+               set repo_config_new($name) $default_config($name)
+               set global_config_new($name) $default_config($name)
+       }
+
+       foreach option $font_descs {
+               set name [lindex $option 0]
+               set repo_config($name) $default_config(gui.$name)
+       }
+       apply_config
+
+       foreach option $font_descs {
+               set name [lindex $option 0]
+               set font [lindex $option 1]
+               set global_config_new(gui.$font^^family) \
+                       [font configure $font -family]
+               set global_config_new(gui.$font^^size) \
+                       [font configure $font -size]
+       }
+}
+
+proc do_save_config {w} {
+       if {[catch {save_config} err]} {
+               error_popup "Failed to completely save options:\n\n$err"
+       }
+       destroy $w
+}
+
 # shift == 1: left click
 #          3: right click  
 proc click {w x y shift wx wy} {
@@ -1564,18 +1850,64 @@ proc unclick {w x y} {
 
 ######################################################################
 ##
-## ui init
+## config defaults
+
+set cursor_ptr arrow
+font create font_diff -family Courier -size 10
+font create font_ui
+catch {
+       label .dummy
+       eval font configure font_ui [font actual [.dummy cget -font]]
+       destroy .dummy
+}
 
-set font_ui {Helvetica 10}
-set font_diff {Courier 10}
-set cursor_ptr left_ptr
+font create font_uibold
+font create font_diffbold
 
-switch -glob -- "$tcl_platform(platform),$tcl_platform(os)" {
-windows,*   {set M1B Control; set M1T Ctrl}
-unix,Darwin {set M1B M1; set M1T Cmd}
-*           {set M1B M1; set M1T M1}
+set M1B M1
+set M1T M1
+if {$tcl_platform(platform) == {windows}} {
+       set M1B Control
+       set M1T Ctrl
+} elseif {[is_MacOSX]} {
+       set M1B M1
+       set M1T Cmd
 }
 
+proc apply_config {} {
+       global repo_config font_descs
+
+       foreach option $font_descs {
+               set name [lindex $option 0]
+               set font [lindex $option 1]
+               if {[catch {
+                       foreach {cn cv} $repo_config(gui.$name) {
+                               font configure $font $cn $cv
+                       }
+                       } err]} {
+                       error_popup "Invalid font specified in gui.$name:\n\n$err"
+               }
+               foreach {cn cv} [font configure $font] {
+                       font configure ${font}bold $cn $cv
+               }
+               font configure ${font}bold -weight bold
+       }
+}
+
+set default_config(gui.trustmtime) false
+set default_config(gui.fontui) [font configure font_ui]
+set default_config(gui.fontdiff) [font configure font_diff]
+set font_descs {
+       {fontui   font_ui   {Main Font}}
+       {fontdiff font_diff {Diff/Console Font}}
+}
+load_config
+apply_config
+
+######################################################################
+##
+## ui construction
+
 # -- Menu Bar
 menu .mbar -tearoff 0
 .mbar add cascade -label Project -menu .mbar.project
@@ -1584,21 +1916,20 @@ menu .mbar -tearoff 0
 .mbar add cascade -label Fetch -menu .mbar.fetch
 .mbar add cascade -label Pull -menu .mbar.pull
 .mbar add cascade -label Push -menu .mbar.push
-.mbar add cascade -label Options -menu .mbar.options
 . configure -menu .mbar
 
 # -- Project Menu
 menu .mbar.project
 .mbar.project add command -label Visualize \
        -command do_gitk \
-       -font $font_ui
+       -font font_ui
 .mbar.project add command -label {Repack Database} \
        -command do_repack \
-       -font $font_ui
+       -font font_ui
 .mbar.project add command -label Quit \
        -command do_quit \
        -accelerator $M1T-Q \
-       -font $font_ui
+       -font font_ui
 
 # -- Edit Menu
 #
@@ -1606,61 +1937,65 @@ menu .mbar.edit
 .mbar.edit add command -label Undo \
        -command {catch {[focus] edit undo}} \
        -accelerator $M1T-Z \
-       -font $font_ui
+       -font font_ui
 .mbar.edit add command -label Redo \
        -command {catch {[focus] edit redo}} \
        -accelerator $M1T-Y \
-       -font $font_ui
+       -font font_ui
 .mbar.edit add separator
 .mbar.edit add command -label Cut \
        -command {catch {tk_textCut [focus]}} \
        -accelerator $M1T-X \
-       -font $font_ui
+       -font font_ui
 .mbar.edit add command -label Copy \
        -command {catch {tk_textCopy [focus]}} \
        -accelerator $M1T-C \
-       -font $font_ui
+       -font font_ui
 .mbar.edit add command -label Paste \
        -command {catch {tk_textPaste [focus]; [focus] see insert}} \
        -accelerator $M1T-V \
-       -font $font_ui
+       -font font_ui
 .mbar.edit add command -label Delete \
        -command {catch {[focus] delete sel.first sel.last}} \
        -accelerator Del \
-       -font $font_ui
+       -font font_ui
 .mbar.edit add separator
 .mbar.edit add command -label {Select All} \
        -command {catch {[focus] tag add sel 0.0 end}} \
        -accelerator $M1T-A \
-       -font $font_ui
+       -font font_ui
+.mbar.edit add separator
+.mbar.edit add command -label {Options...} \
+       -command do_options \
+       -font font_ui
 
 # -- Commit Menu
 menu .mbar.commit
 .mbar.commit add command -label Rescan \
        -command do_rescan \
        -accelerator F5 \
-       -font $font_ui
+       -font font_ui
 lappend disable_on_lock \
        [list .mbar.commit entryconf [.mbar.commit index last] -state]
 .mbar.commit add command -label {Amend Last Commit} \
        -command do_amend_last \
-       -font $font_ui
+       -font font_ui
 lappend disable_on_lock \
        [list .mbar.commit entryconf [.mbar.commit index last] -state]
 .mbar.commit add command -label {Include All Files} \
        -command do_include_all \
        -accelerator $M1T-I \
-       -font $font_ui
+       -font font_ui
 lappend disable_on_lock \
        [list .mbar.commit entryconf [.mbar.commit index last] -state]
 .mbar.commit add command -label {Sign Off} \
        -command do_signoff \
        -accelerator $M1T-S \
-       -font $font_ui
+       -font font_ui
 .mbar.commit add command -label Commit \
        -command do_commit \
        -accelerator $M1T-Return \
-       -font $font_ui
+       -font font_ui
 lappend disable_on_lock \
        [list .mbar.commit entryconf [.mbar.commit index last] -state]
 
@@ -1673,14 +2008,6 @@ menu .mbar.pull
 # -- Push Menu
 menu .mbar.push
 
-# -- Options Menu
-menu .mbar.options
-.mbar.options add checkbutton \
-       -label {Trust File Modification Timestamps} \
-       -offvalue false \
-       -onvalue true \
-       -variable cfg_trust_mtime
-
 # -- Main Window Layout
 panedwindow .vpane -orient vertical
 panedwindow .vpane.files -orient horizontal
@@ -1691,10 +2018,10 @@ pack .vpane -anchor n -side top -fill both -expand 1
 frame .vpane.files.index -height 100 -width 400
 label .vpane.files.index.title -text {Modified Files} \
        -background green \
-       -font $font_ui
+       -font font_ui
 text $ui_index -background white -borderwidth 0 \
        -width 40 -height 10 \
-       -font $font_ui \
+       -font font_ui \
        -cursor $cursor_ptr \
        -yscrollcommand {.vpane.files.index.sb set} \
        -state disabled
@@ -1708,10 +2035,10 @@ pack $ui_index -side left -fill both -expand 1
 frame .vpane.files.other -height 100 -width 100
 label .vpane.files.other.title -text {Untracked Files} \
        -background red \
-       -font $font_ui
+       -font font_ui
 text $ui_other -background white -borderwidth 0 \
        -width 40 -height 10 \
-       -font $font_ui \
+       -font font_ui \
        -cursor $cursor_ptr \
        -yscrollcommand {.vpane.files.other.sb set} \
        -state disabled
@@ -1721,8 +2048,8 @@ pack .vpane.files.other.sb -side right -fill y
 pack $ui_other -side left -fill both -expand 1
 .vpane.files add .vpane.files.other -sticky nsew
 
-$ui_index tag conf in_diff -font [concat $font_ui bold]
-$ui_other tag conf in_diff -font [concat $font_ui bold]
+$ui_index tag conf in_diff -font font_uibold
+$ui_other tag conf in_diff -font font_uibold
 
 # -- Diff and Commit Area
 frame .vpane.lower -height 400 -width 400
@@ -1737,39 +2064,39 @@ frame .vpane.lower.commarea.buttons
 label .vpane.lower.commarea.buttons.l -text {} \
        -anchor w \
        -justify left \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.commarea.buttons.l -side top -fill x
 pack .vpane.lower.commarea.buttons -side left -fill y
 
 button .vpane.lower.commarea.buttons.rescan -text {Rescan} \
        -command do_rescan \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.commarea.buttons.rescan -side top -fill x
 lappend disable_on_lock \
        {.vpane.lower.commarea.buttons.rescan conf -state}
 
 button .vpane.lower.commarea.buttons.amend -text {Amend Last} \
        -command do_amend_last \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.commarea.buttons.amend -side top -fill x
 lappend disable_on_lock \
        {.vpane.lower.commarea.buttons.amend conf -state}
 
 button .vpane.lower.commarea.buttons.incall -text {Include All} \
        -command do_include_all \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.commarea.buttons.incall -side top -fill x
 lappend disable_on_lock \
        {.vpane.lower.commarea.buttons.incall conf -state}
 
 button .vpane.lower.commarea.buttons.signoff -text {Sign Off} \
        -command do_signoff \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.commarea.buttons.signoff -side top -fill x
 
 button .vpane.lower.commarea.buttons.commit -text {Commit} \
        -command do_commit \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.commarea.buttons.commit -side top -fill x
 lappend disable_on_lock \
        {.vpane.lower.commarea.buttons.commit conf -state}
@@ -1781,7 +2108,7 @@ set ui_coml .vpane.lower.commarea.buffer.l
 label $ui_coml -text {Commit Message:} \
        -anchor w \
        -justify left \
-       -font $font_ui
+       -font font_ui
 trace add variable commit_type write {uplevel #0 {
        switch -glob $commit_type \
        initial {$ui_coml conf -text {Initial Commit Message:}} \
@@ -1795,7 +2122,7 @@ text $ui_comm -background white -borderwidth 1 \
        -autoseparators true \
        -relief sunken \
        -width 75 -height 9 -wrap none \
-       -font $font_diff \
+       -font font_diff \
        -yscrollcommand {.vpane.lower.commarea.buffer.sby set}
 scrollbar .vpane.lower.commarea.buffer.sby \
        -command [list $ui_comm yview]
@@ -1808,23 +2135,23 @@ pack .vpane.lower.commarea.buffer -side left -fill y
 #
 menu $ui_comm.ctxm -tearoff 0
 $ui_comm.ctxm add command -label "Cut" \
-       -font $font_ui \
+       -font font_ui \
        -command "tk_textCut $ui_comm"
 $ui_comm.ctxm add command -label "Copy" \
-       -font $font_ui \
+       -font font_ui \
        -command "tk_textCopy $ui_comm"
 $ui_comm.ctxm add command -label "Paste" \
-       -font $font_ui \
+       -font font_ui \
        -command "tk_textPaste $ui_comm"
 $ui_comm.ctxm add command -label "Delete" \
-       -font $font_ui \
+       -font font_ui \
        -command "$ui_comm delete sel.first sel.last"
 $ui_comm.ctxm add separator
 $ui_comm.ctxm add command -label "Select All" \
-       -font $font_ui \
+       -font font_ui \
        -command "$ui_comm tag add sel 0.0 end"
 $ui_comm.ctxm add command -label "Copy All" \
-       -font $font_ui \
+       -font font_ui \
        -command "
                $ui_comm tag add sel 0.0 end
                tk_textCopy $ui_comm
@@ -1832,9 +2159,9 @@ $ui_comm.ctxm add command -label "Copy All" \
        "
 $ui_comm.ctxm add separator
 $ui_comm.ctxm add command -label "Sign Off" \
-       -font $font_ui \
+       -font font_ui \
        -command do_signoff
-bind $ui_comm <Any-Button-3> "tk_popup $ui_comm.ctxm %X %Y"
+bind_button3 $ui_comm "tk_popup $ui_comm.ctxm %X %Y"
 
 # -- Diff Header
 set ui_fname_value {}
@@ -1842,21 +2169,21 @@ set ui_fstatus_value {}
 frame .vpane.lower.diff.header -background orange
 label .vpane.lower.diff.header.l1 -text {File:} \
        -background orange \
-       -font $font_ui
+       -font font_ui
 label .vpane.lower.diff.header.l2 -textvariable ui_fname_value \
        -background orange \
        -anchor w \
        -justify left \
-       -font $font_ui
+       -font font_ui
 label .vpane.lower.diff.header.l3 -text {Status:} \
        -background orange \
-       -font $font_ui
+       -font font_ui
 label .vpane.lower.diff.header.l4 -textvariable ui_fstatus_value \
        -background orange \
        -width $max_status_desc \
        -anchor w \
        -justify left \
-       -font $font_ui
+       -font font_ui
 pack .vpane.lower.diff.header.l1 -side left
 pack .vpane.lower.diff.header.l2 -side left -fill x
 pack .vpane.lower.diff.header.l4 -side right
@@ -1867,7 +2194,7 @@ frame .vpane.lower.diff.body
 set ui_diff .vpane.lower.diff.body.t
 text $ui_diff -background white -borderwidth 0 \
        -width 80 -height 15 -wrap none \
-       -font $font_diff \
+       -font font_diff \
        -xscrollcommand {.vpane.lower.diff.body.sbx set} \
        -yscrollcommand {.vpane.lower.diff.body.sby set} \
        -state disabled
@@ -1883,28 +2210,35 @@ 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 bold -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 font_diffbold
+$ui_diff tag conf bold -font font_diffbold
 
 # -- Diff Body Context Menu
 #
 menu $ui_diff.ctxm -tearoff 0
 $ui_diff.ctxm add command -label "Copy" \
-       -font $font_ui \
+       -font font_ui \
        -command "tk_textCopy $ui_diff"
 $ui_diff.ctxm add command -label "Select All" \
-       -font $font_ui \
+       -font font_ui \
        -command "$ui_diff tag add sel 0.0 end"
 $ui_diff.ctxm add command -label "Copy All" \
-       -font $font_ui \
+       -font font_ui \
        -command "
                $ui_diff tag add sel 0.0 end
                tk_textCopy $ui_diff
                $ui_diff tag remove sel 0.0 end
        "
-bind $ui_diff <Any-Button-3> "tk_popup $ui_diff.ctxm %X %Y"
+$ui_diff.ctxm add separator
+$ui_diff.ctxm add command -label "Decrease Font Size" \
+       -font font_ui \
+       -command {incr_font_size font_diff -1}
+$ui_diff.ctxm add command -label "Increase Font Size" \
+       -font font_ui \
+       -command {incr_font_size font_diff 1}
+bind_button3 $ui_diff "tk_popup $ui_diff.ctxm %X %Y"
 
 # -- Status Bar
 set ui_status_value {Initializing...}
@@ -1913,12 +2247,12 @@ label .status -textvariable ui_status_value \
        -justify left \
        -borderwidth 1 \
        -relief sunken \
-       -font $font_ui
+       -font font_ui
 pack .status -anchor w -side bottom -fill x
 
 # -- Load geometry
 catch {
-set gm [lindex $repo_config(gui.geometry) 0]
+set gm $repo_config(gui.geometry)
 wm geometry . [lindex $gm 0]
 .vpane sash place 0 \
        [lindex [.vpane sash coord 0] 0] \
@@ -1970,8 +2304,8 @@ bind all <$M1B-Key-w> {destroy [winfo toplevel %W]}
 bind all <$M1B-Key-W> {destroy [winfo toplevel %W]}
 foreach i [list $ui_index $ui_other] {
        bind $i <Button-1> {click %W %x %y 1 %X %Y; break}
-       bind $i <Button-3> {click %W %x %y 3 %X %Y; break}
        bind $i <ButtonRelease-1> {unclick %W %x %y; break}
+       bind_button3 $i {click %W %x %y 3 %X %Y; break}
 }
 unset i