Skip to content

Commit cea07cf

Browse files
angavrilovpaulusmack
authored andcommitted
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 <[email protected]> Signed-off-by: Paul Mackerras <[email protected]>
1 parent dbc4941 commit cea07cf

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

gitk

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,11 @@ proc setoptions {} {
18011801
# command to invoke for command, or {variable value} for radiobutton
18021802
proc makemenu {m items} {
18031803
menu $m
1804+
if {[tk windowingsystem] eq {aqua}} {
1805+
set Meta1 Cmd
1806+
} else {
1807+
set Meta1 Ctrl
1808+
}
18041809
foreach i $items {
18051810
set name [mc [lindex $i 1]]
18061811
set type [lindex $i 2]
@@ -1826,7 +1831,9 @@ proc makemenu {m items} {
18261831
-value [lindex $thing 1]
18271832
}
18281833
}
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
18301837
if {$type eq "cascade"} {
18311838
makemenu $m.$submenu $thing
18321839
}
@@ -1860,17 +1867,17 @@ proc makewindow {} {
18601867
makemenu .bar {
18611868
{mc "File" cascade {
18621869
{mc "Update" command updatecommits -accelerator F5}
1863-
{mc "Reload" command reloadcommits}
1870+
{mc "Reload" command reloadcommits -accelerator Meta1-F5}
18641871
{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}
18671874
}}
18681875
{mc "Edit" cascade {
18691876
{mc "Preferences" command doprefs}
18701877
}}
18711878
{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}
18741881
{mc "Delete view" command delview -state disabled}
18751882
{xx "" separator}
18761883
{mc "All files" radiobutton {selectedview 0} -command {showview 0}}
@@ -2232,7 +2239,12 @@ proc makewindow {} {
22322239
bindkey <Key-Return> {dofind 1 1}
22332240
bindkey ? {dofind -1 1}
22342241
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
22362248
bind . <$M1B-q> doquit
22372249
bind . <$M1B-f> {dofind 1 1}
22382250
bind . <$M1B-g> {dofind 1 0}
@@ -3624,6 +3636,16 @@ proc decode_view_opts {n view_args} {
36243636
set newviewopts($n,args) [shellarglist $oargs]
36253637
}
36263638

3639+
proc edit_or_newview {} {
3640+
global curview
3641+
3642+
if {$curview > 0} {
3643+
editview
3644+
} else {
3645+
newview 0
3646+
}
3647+
}
3648+
36273649
proc editview {} {
36283650
global curview
36293651
global viewname viewperm newviewname newviewopts

0 commit comments

Comments
 (0)