1750
option add *Entry.font uifont startupFile
1751
}
1752
1753
+proc makemenu {m items} {
1754
+ menu $m
1755
+ foreach i $items {
1756
+ set name [mc [lindex $i 0]]
1757
+ set type [lindex $i 1]
1758
+ set thing [lindex $i 2]
1759
+ set params [list $type]
1760
+ if {$name ne {}} {
1761
+ set u [string first "&" [string map {&& x} $name]]
1762
+ lappend params -label [string map {&& & & {}} $name]
1763
+ if {$u >= 0} {
1764
+ lappend params -underline $u
1765
+ }
1766
+ }
1767
+ switch -- $type {
1768
+ "cascade" {
1769
+ set submenu [string tolower [string map {& ""} [lindex $i 0]]]
1770
+ lappend params -menu $m.$submenu
1771
+ }
1772
+ "command" {
1773
+ lappend params -command $thing
1774
+ }
1775
+ "radiobutton" {
1776
+ lappend params -variable [lindex $thing 0] \
1777
+ -value [lindex $thing 1]
1778
+ }
1779
+ }
1780
+ eval $m add $params [lrange $i 3 end]
1781
+ if {$type eq "cascade"} {
1782
+ makemenu $m.$submenu $thing
1783
+ }
1784
+ }
1785
+}
1786
+
1787
+# translate string and remove ampersands
1788
+proc mca {str} {
1789
+ return [string map {&& & & {}} [mc $str]]
1790
+}
1791
+
1792
proc makewindow {} {
1793
global canv canv2 canv3 linespc charspc ctext cflist cscroll
1794
global tabstop
1806
global rprogitem rprogcoord rownumsel numcommits
1807
global have_tk85
1808
1770
- menu .bar
1771
- .bar add cascade -label [mc "File"] -menu .bar.file
1772
- menu .bar.file
1773
- .bar.file add command -label [mc "Update"] -command updatecommits
1774
- .bar.file add command -label [mc "Reload"] -command reloadcommits
1775
- .bar.file add command -label [mc "Reread references"] -command rereadrefs
1776
- .bar.file add command -label [mc "List references"] -command showrefs
1777
- .bar.file add command -label [mc "Quit"] -command doquit
1778
- menu .bar.edit
1779
- .bar add cascade -label [mc "Edit"] -menu .bar.edit
1780
- .bar.edit add command -label [mc "Preferences"] -command doprefs
1781
-
1782
- menu .bar.view
1783
- .bar add cascade -label [mc "View"] -menu .bar.view
1784
- .bar.view add command -label [mc "New view..."] -command {newview 0}
1785
- .bar.view add command -label [mc "Edit view..."] -command editview \
1786
- -state disabled
1787
- .bar.view add command -label [mc "Delete view"] -command delview -state disabled
1788
- .bar.view add separator
1789
- .bar.view add radiobutton -label [mc "All files"] -command {showview 0} \
1790
- -variable selectedview -value 0
1791
-
1792
- menu .bar.help
1793
- .bar add cascade -label [mc "Help"] -menu .bar.help
1794
- .bar.help add command -label [mc "About gitk"] -command about
1795
- .bar.help add command -label [mc "Key bindings"] -command keys
1796
- .bar.help configure
1809
+ makemenu .bar {
1810
+ {"File" cascade {
1811
+ {"Update" command updatecommits -accelerator F5}
1812
+ {"Reload" command reloadcommits}
1813
+ {"Reread references" command rereadrefs}
1814
+ {"List references" command showrefs}
1815
+ {"Quit" command doquit}
1816
+ }}
1817
+ {"Edit" cascade {
1818
+ {"Preferences" command doprefs}
1819
+ }}
1820
+ {"View" cascade {
1821
+ {"New view..." command {newview 0}}
1822
+ {"Edit view..." command editview -state disabled}
1823
+ {"Delete view" command delview -state disabled}
1824
+ {"" separator}
1825
+ {"All files" radiobutton {selectedview 0} -command {showview 0}}
1826
+ }}
1827
+ {"Help" cascade {
1828
+ {"About gitk" command about}
1829
+ {"Key bindings" command keys}
1830
+ }}
1831
+ }
1832
. configure -menu .bar
1833
1834
# the gui has upper and lower half, parts of a paned window.
2209
set curtextcursor $textcursor
2210
2211
set rowctxmenu .rowctxmenu
2177
- menu $rowctxmenu -tearoff 0
2178
- $rowctxmenu add command -label [mc "Diff this -> selected"] \
2179
- -command {diffvssel 0}
2180
- $rowctxmenu add command -label [mc "Diff selected -> this"] \
2181
- -command {diffvssel 1}
2182
- $rowctxmenu add command -label [mc "Make patch"] -command mkpatch
2183
- $rowctxmenu add command -label [mc "Create tag"] -command mktag
2184
- $rowctxmenu add command -label [mc "Write commit to file"] -command writecommit
2185
- $rowctxmenu add command -label [mc "Create new branch"] -command mkbranch
2186
- $rowctxmenu add command -label [mc "Cherry-pick this commit"] \
2187
- -command cherrypick
2188
- $rowctxmenu add command -label [mc "Reset HEAD branch to here"] \
2189
- -command resethead
2212
+ makemenu $rowctxmenu {
2213
+ {"Diff this -> selected" command {diffvssel 0}}
2214
+ {"Diff selected -> this" command {diffvssel 1}}
2215
+ {"Make patch" command mkpatch}
2216
+ {"Create tag" command mktag}
2217
+ {"Write commit to file" command writecommit}
2218
+ {"Create new branch" command mkbranch}
2219
+ {"Cherry-pick this commit" command cherrypick}
2220
+ {"Reset HEAD branch to here" command resethead}
2221
+ }
2222
+ $rowctxmenu configure -tearoff 0
2223
2224
set fakerowmenu .fakerowmenu
2192
- menu $fakerowmenu -tearoff 0
2193
- $fakerowmenu add command -label [mc "Diff this -> selected"] \
2194
- -command {diffvssel 0}
2195
- $fakerowmenu add command -label [mc "Diff selected -> this"] \
2196
- -command {diffvssel 1}
2197
- $fakerowmenu add command -label [mc "Make patch"] -command mkpatch
2198
-# $fakerowmenu add command -label [mc "Commit"] -command {mkcommit 0}
2199
-# $fakerowmenu add command -label [mc "Commit all"] -command {mkcommit 1}
2200
-# $fakerowmenu add command -label [mc "Revert local changes"] -command revertlocal
2225
+ makemenu $fakerowmenu {
2226
+ {"Diff this -> selected" command {diffvssel 0}}
2227
+ {"Diff selected -> this" command {diffvssel 1}}
2228
+ {"Make patch" command mkpatch}
2229
+ }
2230
+ $fakerowmenu configure -tearoff 0
2231
2232
set headctxmenu .headctxmenu
2203
- menu $headctxmenu -tearoff 0
2204
- $headctxmenu add command -label [mc "Check out this branch"] \
2205
- -command cobranch
2206
- $headctxmenu add command -label [mc "Remove this branch"] \
2207
- -command rmbranch
2233
+ makemenu $headctxmenu {
2234
+ {"Check out this branch" command cobranch}
2235
+ {"Remove this branch" command rmbranch}
2236
+ }
2237
+ $headctxmenu configure -tearoff 0
2238
2239
global flist_menu
2240
set flist_menu .flistctxmenu
2211
- menu $flist_menu -tearoff 0
2212
- $flist_menu add command -label [mc "Highlight this too"] \
2213
- -command {flist_hl 0}
2214
- $flist_menu add command -label [mc "Highlight this only"] \
2215
- -command {flist_hl 1}
2216
- $flist_menu add command -label [mc "External diff"] \
2217
- -command {external_diff}
2218
- $flist_menu add command -label [mc "Blame parent commit"] \
2219
- -command {external_blame 1}
2241
+ makemenu $flist_menu {
2242
+ {"Highlight this too" command {flist_hl 0}}
2243
+ {"Highlight this only" command {flist_hl 1}}
2244
+ {"External diff" command {external_diff}}
2245
+ {"Blame parent commit" command {external_blame 1}}
2246
+ }
2247
+ $flist_menu configure -tearoff 0
2248
}
2249
2250
# Windows sends all mouse wheel events to the current focused window, not
3404
3405
set curview $n
3406
set selectedview $n
3379
- .bar.view entryconf [mc "Edit view..."] -state [expr {$n == 0? "disabled": "normal"}]
3380
- .bar.view entryconf [mc "Delete view"] -state [expr {$n == 0? "disabled": "normal"}]
3407
+ .bar.view entryconf [mca "Edit view..."] -state [expr {$n == 0? "disabled": "normal"}]
3408
+ .bar.view entryconf [mca "Delete view"] -state [expr {$n == 0? "disabled": "normal"}]
3409
3410
run refill_reflist
3411
if {![info exists viewcomplete($n)]} {
7351
} else {
7352
set menu $fakerowmenu
7353
}
7326
- $menu entryconfigure [mc "Diff this -> selected"] -state $state
7327
- $menu entryconfigure [mc "Diff selected -> this"] -state $state
7328
- $menu entryconfigure [mc "Make patch"] -state $state
7354
+ $menu entryconfigure [mca "Diff this -> selected"] -state $state
7355
+ $menu entryconfigure [mca "Diff selected -> this"] -state $state
7356
+ $menu entryconfigure [mca "Make patch"] -state $state
7357
tk_popup $menu $x $y
7358
}
7359
10174
set viewperm(1) 0
10175
set vdatemode(1) 0
10176
addviewmenu 1
10149
- .bar.view entryconf [mc "Edit view..."] -state normal
10150
- .bar.view entryconf [mc "Delete view"] -state normal
10177
+ .bar.view entryconf [mca "Edit view..."] -state normal
10178
+ .bar.view entryconf [mca "Delete view"] -state normal
10179
}
10180
10181
if {[info exists permviews]} {