Changeset 4f3600acf4ab…
Parent a36c4cad9d3d…
by
Changes to 3 files · Browse files at 4f3600acf4ab Showing diff from parent a36c4cad9d3d Diff from another changeset...
@@ -202,7 +202,7 @@ { "commit", 'C', KSF_CONTROL | KSF_SHIFT },
{ "forget", 'F', KSF_CONTROL | KSF_SHIFT },
{ "rename", 'M', KSF_CONTROL | KSF_SHIFT },
- { "synchronize", 'S', KSF_CONTROL | KSF_SHIFT },
+ { "synch", 'S', KSF_CONTROL | KSF_SHIFT },
{ "update", 'U', KSF_CONTROL | KSF_SHIFT },
{ "revert", 'V', KSF_CONTROL | KSF_SHIFT },
{ "workbench", 'W', KSF_CONTROL | KSF_SHIFT },
|
@@ -17,6 +17,53 @@
#include "KeyboardHelpDialog.h"
#include "RegistryConfig.h"
+#include "GlobalData.h"
+
+static CString GetKeyName(UINT uKey, bool bExtended = false)
+{
+ UINT uScanCode = ::MapVirtualKey(uKey, MAPVK_VK_TO_VSC);
+ LONG lParam = (LONG)uScanCode << 16;
+
+ // Adding this flag prevents a distinction from being made between the left and
+ // right Alt, Control, or Shift keys.
+ lParam |= (1 << 25);
+
+ // Adding this flag is necessary for certain keys (e.g. Insert, Delete) to be
+ // handled properly. However, it prevents other keys (e.g. Shift) from being
+ // handled properly. Therefore, only use it when necessary.
+ if (bExtended) lParam |= (1 << 24);
+
+ // Get the name of the key.
+ TCHAR szKeyName[20];
+ ::GetKeyNameText(lParam, szKeyName, 20);
+ return szKeyName;
+}
+
+static CStringW LookupMenuText(CString strName, CString strLang)
+{
+ // Search the context menu list to find the menu text for the specified command.
+ // Then, attempt to find a localized string in the registry.
+ for (int i = 0; i < MenuDescListCount; i++)
+ {
+ if (MenuDescList[i].strName == strName)
+ {
+ CStringW strMenuText = MenuDescList[i].strMenuText;
+ if (!strLang.IsEmpty())
+ {
+ CStringW strDummy;
+ GetCMenuTranslation(strLang, MenuDescList[i].strName, strMenuText,
+ strDummy);
+ }
+ if (strMenuText.Right(3) == "...")
+ {
+ // Strip off any trailing ellipsis from the name.
+ strMenuText.Truncate(strMenuText.GetLength() - 3);
+ }
+ return strMenuText;
+ }
+ }
+ return "";
+}
LRESULT CKeyboardHelpDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
{
@@ -34,6 +81,31 @@ if (!strHelpText.IsEmpty()) ::SetDlgItemTextW(m_hWnd, IDC_TOPTEXT, strHelpText);
}
+ // Set tab stops for the list box.
+ int nTabStop = 100;
+ SendDlgItemMessage(IDC_KEYLIST, LB_SETTABSTOPS, 1, (LPARAM)&nTabStop);
+
+ // Get the names of the Alt, Control, and Shift keys.
+ CString strAlt = GetKeyName(VK_MENU);
+ CString strControl = GetKeyName(VK_CONTROL);
+ CString strShift = GetKeyName(VK_SHIFT);
+ strAlt += '+';
+ strControl += '+';
+ strShift += '+';
+
+ // Add each keyboard shortcut to the list box.
+ for (int i = 0; i < KeyShortcutListCount; i++)
+ {
+ CString strKey;
+ WORD wFlags = KeyShortcutList[i].wFlags;
+ if (wFlags & KSF_CONTROL) strKey += strControl;
+ if (wFlags & KSF_ALT) strKey += strAlt;
+ if (wFlags & KSF_SHIFT) strKey += strShift;
+ strKey += GetKeyName(KeyShortcutList[i].wKey, true);
+ strKey += '\t';
+ strKey += LookupMenuText(KeyShortcutList[i].strName, strLang);
+ SendDlgItemMessage(IDC_KEYLIST, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)strKey);
+ }
return 1L;
}
|
@@ -70,7 +70,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,97,146,50,14
LTEXT "The following shortcut keys are available when using TortoiseHg from Windows Explorer.",IDC_TOPTEXT,7,7,229,16
- LISTBOX IDC_KEYLIST,7,34,229,101,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ LISTBOX IDC_KEYLIST,7,34,229,101,LBS_USETABSTOPS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
END
|
Loading...