From ffd7ae518ee08d4f382f541484555df0a8eef78d Mon Sep 17 00:00:00 2001 From: Vishweshwar Saran Singh Deo Date: Tue, 1 Nov 2022 16:28:09 +0530 Subject: [PATCH] [bug 662] [Feature Request] - In the Context Menu(Right-Click) show keyboard shortcuts / accelarators #662 -fixed: The problem in displaying is happening as the the config the key for eg Control is being saved as and the short cut alphabetic character is being picked when creating the menu item and not being overwritten from config -Note: the short cut for function keys are not being displayed in context-menu --- terminatorlib/terminal_popup_menu.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminal_popup_menu.py b/terminatorlib/terminal_popup_menu.py index 1d71d56b..027ee6d3 100644 --- a/terminatorlib/terminal_popup_menu.py +++ b/terminatorlib/terminal_popup_menu.py @@ -35,7 +35,9 @@ class TerminalPopupMenu(object): mask = mask | Gdk.ModifierType.SHIFT_MASK dbg("adding mask %s" % mask) - if maskstr.find(''.lower()) >= 0: + ctrl = (maskstr.find(''.lower()) >= 0 or + maskstr.find(''.lower()) >= 0) + if ctrl: mask = mask | Gdk.ModifierType.CONTROL_MASK dbg("adding mask %s" % mask) @@ -57,6 +59,18 @@ class TerminalPopupMenu(object): 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))