gitk: Add accelerators to frequently used menu commands
This commit documents keyboard accelerators used for menu commands in the menu, as it is usually done, and adds some more, e.g. F4 to invoke Edit View (or New View if the current view is the un-editable "All files" view). The changes include a workaround for handling Shift-F4 on systems where XKB binds special XF86_Switch_VT_* symbols to Ctrl-Alt-F* combinations. Tk often receives these codes when Shift-F* is pressed, so it is necessary to bind the relevant actions to them as well. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Alexander Gavrilov committed
Nov 9, 2008 at 13:00 UTC
cea07cf8dc9b3677e0c50433c0d72bce83adbdc7
1 file changed
+29
-7
gitk
+29
-7
@@ -1801,6 +1801,11 @@ proc setoptions {} {
1801
# command to invoke for command, or {variable value} for radiobutton
1802
proc makemenu {m items} {
1803
menu $m
1804
+ if {[tk windowingsystem] eq {aqua}} {
1805
+ set Meta1 Cmd
1806
+ } else {
1807
+ set Meta1 Ctrl
1808
+ }
1809
foreach i $items {
1810
set name [mc [lindex $i 1]]
1811
set type [lindex $i 2]
@@ -1826,7 +1831,9 @@ proc makemenu {m items} {
1831
-value [lindex $thing 1]
1832
}
1833
}
1829
- eval $m add $params [lrange $i 4 end]
1834
+ set tail [lrange $i 4 end]
1835
+ regsub -all {\yMeta1\y} $tail $Meta1 tail
1836
+ eval $m add $params $tail
1837
if {$type eq "cascade"} {
1838
makemenu $m.$submenu $thing
1839
}
@@ -1860,17 +1867,17 @@ proc makewindow {} {
1867
makemenu .bar {
1868
{mc "File" cascade {
1869
{mc "Update" command updatecommits -accelerator F5}
1863
- {mc "Reload" command reloadcommits}
1870
+ {mc "Reload" command reloadcommits -accelerator Meta1-F5}
1871
{mc "Reread references" command rereadrefs}
1865
- {mc "List references" command showrefs}
1866
- {mc "Quit" command doquit}
1872
+ {mc "List references" command showrefs -accelerator F2}
1873
+ {mc "Quit" command doquit -accelerator Meta1-Q}
1874
}}
1875
{mc "Edit" cascade {
1876
{mc "Preferences" command doprefs}
1877
}}
1878
{mc "View" cascade {
1872
- {mc "New view..." command {newview 0}}
1873
- {mc "Edit view..." command editview -state disabled}
1879
+ {mc "New view..." command {newview 0} -accelerator Shift-F4}
1880
+ {mc "Edit view..." command editview -state disabled -accelerator F4}
1881
{mc "Delete view" command delview -state disabled}
1882
{xx "" separator}
1883
{mc "All files" radiobutton {selectedview 0} -command {showview 0}}
@@ -2232,7 +2239,12 @@ proc makewindow {} {
2239
bindkey <Key-Return> {dofind 1 1}
2240
bindkey ? {dofind -1 1}
2241
bindkey f nextfile
2235
- bindkey <F5> updatecommits
2242
+ bind . <F5> updatecommits
2243
+ bind . <$M1B-F5> reloadcommits
2244
+ bind . <F2> showrefs
2245
+ bind . <Shift-F4> {newview 0}
2246
+ catch { bind . <Shift-Key-XF86_Switch_VT_4> {newview 0} }
2247
+ bind . <F4> edit_or_newview
2248
bind . <$M1B-q> doquit
2249
bind . <$M1B-f> {dofind 1 1}
2250
bind . <$M1B-g> {dofind 1 0}
@@ -3624,6 +3636,16 @@ proc decode_view_opts {n view_args} {
3636
set newviewopts($n,args) [shellarglist $oargs]
3637
}
3638
3639
+proc edit_or_newview {} {
3640
+ global curview
3641
+
3642
+ if {$curview > 0} {
3643
+ editview
3644
+ } else {
3645
+ newview 0
3646
+ }
3647
+}
3648
+
3649
proc editview {} {
3650
global curview
3651
global viewname viewperm newviewname newviewopts