Skip to content

[guitool] feature to specify keyboard shortcuts for custom tools #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: git-gui/master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions lib/tools.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ proc tools_create_item {parent args} {
}

proc tools_populate_one {fullname} {
global tools_menubar tools_menutbl tools_id
global tools_menubar tools_menutbl tools_id repo_config

if {![info exists tools_id]} {
set tools_id 0
Expand All @@ -61,9 +61,25 @@ proc tools_populate_one {fullname} {
}
}

tools_create_item $parent command \
-label [lindex $names end] \
-command [list tools_exec $fullname]
set accel_key_bound 0
if {[info exists repo_config(guitool.$fullname.gitgui-shortcut)]} {
set accel_key $repo_config(guitool.$fullname.gitgui-shortcut)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dscho : I fixed the variable naming you suggested.

if { [ catch { bind . <$accel_key> [list tools_exec $fullname] } msg ] } {
puts stderr "Failed to bind keyboard shortcut '$accel_key' for custom tool '$fullname'. Error: $msg"
} else {
tools_create_item $parent command \
-label [lindex $names end] \
-command [list tools_exec $fullname] \
-accelerator $accel_key
set accel_key_bound true
}
}

if { ! $accel_key_bound } {
tools_create_item $parent command \
-label [lindex $names end] \
-command [list tools_exec $fullname]
}
}

proc tools_exec {fullname} {
Expand Down