Skip to content

Commit

Permalink
Merge pull request #666 from vssdeo/662-In-the-Context-Menu-right-cli…
Browse files Browse the repository at this point in the history
…ck-show-keyboard-shortcuts

[bug 662] [Feature Request] - In the Context Menu(Right-Click) show k…
  • Loading branch information
mattrose authored Nov 19, 2022
2 parents 230e1e5 + ffd7ae5 commit a6b78bb
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion terminatorlib/terminal_popup_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def get_menu_item_mask(self, maskstr):
mask = mask | Gdk.ModifierType.SHIFT_MASK
dbg("adding mask <Shift> %s" % mask)

if maskstr.find('<Control>'.lower()) >= 0:
ctrl = (maskstr.find('<Control>'.lower()) >= 0 or
maskstr.find('<Primary>'.lower()) >= 0)
if ctrl:
mask = mask | Gdk.ModifierType.CONTROL_MASK
dbg("adding mask <Control> %s" % mask)

Expand All @@ -57,6 +59,18 @@ def menu_item(self, menutype, actstr, menustr):
if (pos >= 0 and pos+1 < len(menustr)):
accelchar = menustr.lower()[pos+1]

#this may require tweak. what about shortcut function keys ?
if maskstr:
mpos = maskstr.rfind(">")
#can't have a char at 0 position as <> is len 2
if mpos >= 0 and mpos+1 < len(maskstr):
configaccelchar = maskstr[mpos+1:]
#ensure to take only 1 char else ignore
if len(configaccelchar) == 1:
dbg("found accelchar in config:%s override:%s"
% (configaccelchar, accelchar))
accelchar = configaccelchar

dbg("action from config:%s for item:%s with shortcut accelchar:(%s)"
% (maskstr, menustr, accelchar))
item = menutype.new_with_mnemonic(_(menustr))
Expand Down

0 comments on commit a6b78bb

Please sign in to comment.