Merge pull request #666 from vssdeo/662-In-the-Context-Menu-right-click-show-keyboard-shortcuts

[bug 662] [Feature Request] - In the Context Menu(Right-Click) show k…
This commit is contained in:
Matt Rose 2022-11-18 21:29:46 -05:00 committed by GitHub
commit a6b78bbbf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -35,7 +35,9 @@ class TerminalPopupMenu(object):
mask = mask | Gdk.ModifierType.SHIFT_MASK mask = mask | Gdk.ModifierType.SHIFT_MASK
dbg("adding mask <Shift> %s" % 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 mask = mask | Gdk.ModifierType.CONTROL_MASK
dbg("adding mask <Control> %s" % mask) dbg("adding mask <Control> %s" % mask)
@ -57,6 +59,18 @@ class TerminalPopupMenu(object):
if (pos >= 0 and pos+1 < len(menustr)): if (pos >= 0 and pos+1 < len(menustr)):
accelchar = menustr.lower()[pos+1] 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)" dbg("action from config:%s for item:%s with shortcut accelchar:(%s)"
% (maskstr, menustr, accelchar)) % (maskstr, menustr, accelchar))
item = menutype.new_with_mnemonic(_(menustr)) item = menutype.new_with_mnemonic(_(menustr))