@@ -1026,13 +1026,24 @@ class ToolHelpBase(ToolBase):
1026
1026
default_keymap = rcParams ['keymap.help' ]
1027
1027
image = 'help.png'
1028
1028
1029
+
1030
+ @staticmethod
1031
+ def format_shortcut (keysequence ):
1032
+ """
1033
+ Converts a shortcut string from the notation used in rc config to the
1034
+ standard notation for displaying shortcuts, e.g. 'ctrl+a' -> 'Ctrl+A'.
1035
+ """
1036
+ def repl (match ):
1037
+ s = match .group (0 )
1038
+ return 'Shift+' + s if len (
1039
+ s ) == 1 and s .isupper () else s .capitalize ()
1040
+ if len (keysequence ) == 1 :
1041
+ return keysequence # do not modify single characters
1042
+ return re .sub (r"\w{2,}|(?<=\+)\w" , repl , keysequence )
1043
+
1029
1044
def _format_tool_keymap (self , name ):
1030
1045
keymaps = self .toolmanager .get_tool_keymap (name )
1031
- # Capitalize "ctrl+a" -> "Ctrl+A" but leave "a" as is.
1032
- return ", " .join (re .sub (r"\w{2,}|(?<=\+)\w" ,
1033
- lambda m : m .group (0 ).capitalize (),
1034
- keymap )
1035
- for keymap in keymaps )
1046
+ return ", " .join (self .format_shortcut (keymap ) for keymap in keymaps )
1036
1047
1037
1048
def _get_help_text (self ):
1038
1049
entries = []
@@ -1053,7 +1064,8 @@ def _get_help_html(self):
1053
1064
continue
1054
1065
rows .append (fmt .format (
1055
1066
name , self ._format_tool_keymap (name ), tool .description ))
1056
- return ("<table><thead>" + rows [0 ] + "</thead>"
1067
+ return ("<style>td {padding: 0px 4px}</style>"
1068
+ "<table><thead>" + rows [0 ] + "</thead>"
1057
1069
"<tbody>" .join (rows [1 :]) + "</tbody></table>" )
1058
1070
1059
1071
0 commit comments