Changeset a36c4cad9d3d…
Parent 9683dff013bb…
by
Changes to 9 files · Browse files at a36c4cad9d3d Showing diff from parent 9683dff013bb Diff from another changeset...
|
|
@@ -0,0 +1,210 @@ + // Copyright (C) 2011 Fog Creek Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "stdafx.h"
+
+#include "GlobalData.h"
+
+// According to http://msdn.microsoft.com/en-us/library/bb776094%28VS.85%29.aspx
+// the help texts for the commands should be reasonably short (under 40 characters)
+
+const CMenuDescription MenuDescList[] =
+{
+ { "commit", L"Commit...",
+ L"Commits changes in repository.",
+ "menucommit.ico", 0},
+ { "init", L"Create Repository Here",
+ L"Creates a new repository.",
+ "menucreaterepos.ico", 0},
+ { "clone", L"Clone...",
+ L"Creates a clone of a repository.",
+ "menuclone.ico", 0},
+ { "shelve", L"Shelve Changes",
+ L"Shelves or unshelves file changes.",
+ "shelve.ico", 0},
+ { "status", L"View File Status",
+ L"Shows repository status and changes.",
+ "menushowchanged.ico", 0},
+ { "add", L"Add Files...",
+ L"Adds files to version control.",
+ "menuadd.ico", 0},
+ { "revert", L"Revert Files...",
+ L"Reverts file changes.",
+ "menurevert.ico", 0},
+ { "remove", L"Remove Files...",
+ L"Removes files from version control.",
+ "menudelete.ico", 0},
+ { "rename", L"Rename File...",
+ L"Renames the file or directory.",
+ "general.ico", 0},
+ { "workbench", L"Workbench",
+ L"Shows the change history of the repository.",
+ "menulog.ico", 0},
+ { "log", L"Revision History",
+ L"Shows the change history of the selected files.",
+ "menulog.ico", 0},
+ { "synch", L"Synchronize",
+ L"Synchronizes with a remote repository.",
+ "menusynch.ico", 0},
+ { "serve", L"Web Server",
+ L"Starts the web server for this repository.",
+ "proxy.ico", 0},
+ { "update", L"Update...",
+ L"Updates the working directory.",
+ "menucheckout.ico", 0},
+ { "thgstatus", L"Update Icons",
+ L"Updates icons for this repository.",
+ "refresh_overlays.ico", 0},
+ { "userconf", L"Global Settings",
+ L"Configures user wide settings.",
+ "settings_user.ico", 0},
+ { "repoconf", L"Repository Settings",
+ L"Configures repository settings.",
+ "settings_repo.ico", 0},
+ { "about", L"About TortoiseHg",
+ L"Shows the about dialog.",
+ "menuabout.ico", 0},
+ { "annotate", L"Annotate Files",
+ L"Shows changeset information per file line.",
+ "menublame.ico", 0},
+ { "vdiff", L"Visual Diff",
+ L"Shows changes using the GUI diff tool.",
+ "TortoiseMerge.ico", 0},
+ { "hgignore", L"Edit Ignore Filter",
+ L"Edits the repository ignore filter.",
+ "ignore.ico", 0},
+ { "guess", L"Guess Renames",
+ L"Detects renames and copies.",
+ "detect_rename.ico", 0},
+ { "grep", L"Search History",
+ L"Searches file revisions for patterns.",
+ "menurepobrowse.ico", 0},
+ { "forget", L"Forget Files...",
+ L"Removes files from version control.",
+ "menudelete.ico", 0},
+ { "shellconf", L"Explorer Extension Settings",
+ L"Configures the Explorer extension.",
+ "settings_repo.ico", 0},
+ { "kiln", L"Kiln",
+ L"Opens the current repository in Kiln.",
+ "kiln.ico", 0 },
+ { "kilnfiles", L"Kiln",
+ L"Opens the selected files in Kiln.",
+ "kiln.ico", 0 },
+ { "keyboard", L"Keyboard Help",
+ L"Displays a list of keyboard shortcuts.",
+ "", 0 },
+
+ // Add new items here.
+ // Template:
+ // { "cmdname", L"Display Name",
+ // L"Status bar prompt.",
+ // "iconfile.ico", 0 },
+};
+const int MenuDescListCount = sizeof(MenuDescList) / sizeof(CMenuDescription);
+
+// Menu commands shown when the folder is in a repository but no files are selected
+const LPCTSTR RepoNoFilesMenu[] =
+{
+ "commit",
+ "status",
+ "shelve",
+ "vdiff",
+ NULL,
+ "add",
+ "revert",
+ "rename",
+ "forget",
+ "remove",
+ NULL,
+ "workbench",
+ "update",
+ "grep",
+ NULL,
+ "kiln",
+ NULL,
+ "synch",
+ "serve",
+ "clone",
+ "init"
+ "thgstatus",
+ NULL,
+ "hgignore",
+ "guess",
+ NULL,
+ "shellconf",
+ "repoconf",
+ "userconf",
+ NULL,
+ "keyboard",
+ "about",
+};
+const int RepoNoFilesMenuCount = sizeof(RepoNoFilesMenu) / sizeof(LPCTSTR);
+
+// Menu commands shown when the folder is in a repository and files are selected
+const LPCTSTR RepoFilesMenu[] =
+{
+ "commit",
+ "status",
+ "vdiff",
+ NULL,
+ "add",
+ "revert",
+ "rename",
+ "forget",
+ "remove",
+ NULL,
+ "log",
+ "annotate",
+ NULL,
+ "kilnfiles",
+ NULL,
+ "keyboard",
+ "about",
+};
+const int RepoFilesMenuCount = sizeof(RepoFilesMenu) / sizeof(LPCTSTR);
+
+// Menu commands shown when the folder is not in a repository
+const LPCTSTR NoRepoMenu[] =
+{
+ "clone",
+ "init",
+ "shellconf",
+ "userconf",
+ "thgstatus",
+ NULL,
+ "workbench",
+ NULL,
+ "keyboard",
+ "about",
+};
+const int NoRepoMenuCount = sizeof(NoRepoMenu) / sizeof(LPCTSTR);
+
+const LPCTSTR DefaultPromotedString = "commit,workbench,kiln,kilnfiles";
+
+// List of all keyboard shortcuts
+const CKeyShortcut KeyShortcutList[] =
+{
+ { "add", VK_INSERT, KSF_ALT },
+ { "remove", VK_DELETE, KSF_ALT },
+ { "commit", 'C', KSF_CONTROL | KSF_SHIFT },
+ { "forget", 'F', KSF_CONTROL | KSF_SHIFT },
+ { "rename", 'M', KSF_CONTROL | KSF_SHIFT },
+ { "synchronize", 'S', KSF_CONTROL | KSF_SHIFT },
+ { "update", 'U', KSF_CONTROL | KSF_SHIFT },
+ { "revert", 'V', KSF_CONTROL | KSF_SHIFT },
+ { "workbench", 'W', KSF_CONTROL | KSF_SHIFT },
+};
+const int KeyShortcutListCount = sizeof(KeyShortcutList) / sizeof(CKeyShortcut);
|
|
@@ -0,0 +1,52 @@ + // Copyright (C) 2011 Fog Creek Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+
+struct CMenuDescription
+{
+ CString strName;
+ CStringW strMenuText;
+ CStringW strHelpText;
+ CString strIconName;
+ UINT idCmd;
+};
+
+// Context menu data
+extern const CMenuDescription MenuDescList[];
+extern const int MenuDescListCount;
+extern const LPCTSTR RepoNoFilesMenu[];
+extern const int RepoNoFilesMenuCount;
+extern const LPCTSTR RepoFilesMenu[];
+extern const int RepoFilesMenuCount;
+extern const LPCTSTR NoRepoMenu[];
+extern const int NoRepoMenuCount;
+extern const LPCTSTR DefaultPromotedString;
+
+// Keyboard shortcut flags
+#define KSF_ALT 0x0001
+#define KSF_CONTROL 0x0002
+#define KSF_SHIFT 0x0004
+
+struct CKeyShortcut
+{
+ CString strName;
+ WORD wKey;
+ WORD wFlags;
+};
+
+// Keyboard shortcut data
+extern const CKeyShortcut KeyShortcutList[];
+extern const int KeyShortcutListCount;
|
|
@@ -0,0 +1,44 @@ + // Copyright (C) 2011 Fog Creek Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "stdafx.h"
+
+#include "KeyboardHelpDialog.h"
+#include "RegistryConfig.h"
+
+LRESULT CKeyboardHelpDialog::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&)
+{
+ CenterWindow();
+
+ // Attempt to load localized dialog strings if they exist.
+ CString strLang;
+ GetRegistryConfig("CMenuLang", strLang);
+ if (!strLang.IsEmpty())
+ {
+ CStringW strMenuText;
+ CStringW strHelpText;
+ GetCMenuTranslation(strLang, "keyboarddialog", strMenuText, strHelpText);
+ if (!strMenuText.IsEmpty()) ::SetWindowTextW(m_hWnd, strMenuText);
+ if (!strHelpText.IsEmpty()) ::SetDlgItemTextW(m_hWnd, IDC_TOPTEXT, strHelpText);
+ }
+
+ return 1L;
+}
+
+LRESULT CKeyboardHelpDialog::OnOK(WORD, WORD, HWND, BOOL&)
+{
+ EndDialog(IDOK);
+ return 1L;
+}
|
|
@@ -0,0 +1,30 @@ + // Copyright (C) 2011 Fog Creek Software
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#pragma once
+
+class CKeyboardHelpDialog : public CDialogImpl<CKeyboardHelpDialog>
+{
+public:
+ enum { IDD = IDD_KEYBOARDHELP };
+
+ BEGIN_MSG_MAP(CKeyboardHelpDialog)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_HANDLER(IDOK, BN_CLICKED, OnOK)
+ END_MSG_MAP()
+
+ LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+ LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+};
|
@@ -205,6 +205,7 @@ <ClCompile Include="Direntry.cpp" />
<ClCompile Include="Dirstate.cpp" />
<ClCompile Include="DirstateCache.cpp" />
+ <ClCompile Include="GlobalData.cpp" />
<ClCompile Include="IconBitmapUtils.cpp" />
<ClCompile Include="KeyboardHelpDialog.cpp" />
<ClCompile Include="Kiln.cpp" />
@@ -236,6 +237,7 @@ <ClInclude Include="Direntry.h" />
<ClInclude Include="Dirstate.h" />
<ClInclude Include="DirstateCache.h" />
+ <ClInclude Include="GlobalData.h" />
<ClInclude Include="IconBitmapUtils.h" />
<ClInclude Include="KeyboardHelpDialog.h" />
<ClInclude Include="Kiln.h" />
|
@@ -87,6 +87,9 @@ <ClCompile Include="KeyboardHelpDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="GlobalData.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Directory.h">
@@ -161,6 +164,9 @@ <ClInclude Include="KeyboardHelpDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="GlobalData.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="THgShell.def">
|
|
@@ -30,176 +30,6 @@
#include <msi.h>
-// According to http://msdn.microsoft.com/en-us/library/bb776094%28VS.85%29.aspx
-// the help texts for the commands should be reasonably short (under 40 characters)
-
-static const CMenuDescription MenuDescList[] =
-{
- { "commit", L"Commit...",
- L"Commits changes in repository.",
- "menucommit.ico", 0},
- { "init", L"Create Repository Here",
- L"Creates a new repository.",
- "menucreaterepos.ico", 0},
- { "clone", L"Clone...",
- L"Creates a clone of a repository.",
- "menuclone.ico", 0},
- { "shelve", L"Shelve Changes",
- L"Shelves or unshelves file changes.",
- "shelve.ico", 0},
- { "status", L"View File Status",
- L"Shows repository status and changes.",
- "menushowchanged.ico", 0},
- { "add", L"Add Files...",
- L"Adds files to version control.",
- "menuadd.ico", 0},
- { "revert", L"Revert Files...",
- L"Reverts file changes.",
- "menurevert.ico", 0},
- { "remove", L"Remove Files...",
- L"Removes files from version control.",
- "menudelete.ico", 0},
- { "rename", L"Rename File...",
- L"Renames the file or directory.",
- "general.ico", 0},
- { "workbench", L"Workbench",
- L"Shows the change history of the repository.",
- "menulog.ico", 0},
- { "log", L"Revision History",
- L"Shows the change history of the selected files.",
- "menulog.ico", 0},
- { "synch", L"Synchronize",
- L"Synchronizes with a remote repository.",
- "menusynch.ico", 0},
- { "serve", L"Web Server",
- L"Starts the web server for this repository.",
- "proxy.ico", 0},
- { "update", L"Update...",
- L"Updates the working directory.",
- "menucheckout.ico", 0},
- { "thgstatus", L"Update Icons",
- L"Updates icons for this repository.",
- "refresh_overlays.ico", 0},
- { "userconf", L"Global Settings",
- L"Configures user wide settings.",
- "settings_user.ico", 0},
- { "repoconf", L"Repository Settings",
- L"Configures repository settings.",
- "settings_repo.ico", 0},
- { "about", L"About TortoiseHg",
- L"Shows the about dialog.",
- "menuabout.ico", 0},
- { "annotate", L"Annotate Files",
- L"Shows changeset information per file line.",
- "menublame.ico", 0},
- { "vdiff", L"Visual Diff",
- L"Shows changes using the GUI diff tool.",
- "TortoiseMerge.ico", 0},
- { "hgignore", L"Edit Ignore Filter",
- L"Edits the repository ignore filter.",
- "ignore.ico", 0},
- { "guess", L"Guess Renames",
- L"Detects renames and copies.",
- "detect_rename.ico", 0},
- { "grep", L"Search History",
- L"Searches file revisions for patterns.",
- "menurepobrowse.ico", 0},
- { "forget", L"Forget Files...",
- L"Removes files from version control.",
- "menudelete.ico", 0},
- { "shellconf", L"Explorer Extension Settings",
- L"Configures the Explorer extension.",
- "settings_repo.ico", 0},
- { "kiln", L"Kiln",
- L"Opens the current repository in Kiln.",
- "kiln.ico", 0 },
- { "kilnfiles", L"Kiln",
- L"Opens the selected files in Kiln.",
- "kiln.ico", 0 },
- { "keyboard", L"Keyboard Help",
- L"Displays a list of keyboard shortcuts.",
- "", 0 },
-
- // Add new items here.
- // Template:
- // { "cmdname", L"Display Name",
- // L"Status bar prompt.",
- // "iconfile.ico", 0 },
-};
-
-static const LPCTSTR RepoNoFilesMenu[] =
-{
- "commit",
- "status",
- "shelve",
- "vdiff",
- NULL,
- "add",
- "revert",
- "rename",
- "forget",
- "remove",
- NULL,
- "workbench",
- "update",
- "grep",
- NULL,
- "kiln",
- NULL,
- "synch",
- "serve",
- "clone",
- "init"
- "thgstatus",
- NULL,
- "hgignore",
- "guess",
- NULL,
- "shellconf",
- "repoconf",
- "userconf",
- NULL,
- "keyboard",
- "about",
-};
-
-static const LPCTSTR RepoFilesMenu[] =
-{
- "commit",
- "status",
- "vdiff",
- NULL,
- "add",
- "revert",
- "rename",
- "forget",
- "remove",
- NULL,
- "log",
- "annotate",
- NULL,
- "kilnfiles",
- NULL,
- "keyboard",
- "about",
-};
-
-static const LPCTSTR NoRepoMenu[] =
-{
- "clone",
- "init",
- "shellconf",
- "userconf",
- "thgstatus",
- NULL,
- "workbench",
- NULL,
- "keyboard",
- "about",
-};
-
-static const LPCTSTR DefaultPromotedString = "commit,workbench,kiln,kilnfiles";
-
void CTortoiseHgCmenuBase::AddMenuList(UINT idCmd, const CString& strName)
{
ATLTRACE("AddMenuList: idCmd = %d, name = '%s'\n", idCmd, strName);
@@ -464,7 +294,7 @@ return S_OK;
}
- InitMenuMaps(MenuDescList, sizeof(MenuDescList) / sizeof(CMenuDescription));
+ InitMenuMaps(MenuDescList, MenuDescListCount);
CString promoted_string = DefaultPromotedString; // default value if key not found
GetRegistryConfig("PromotedItems", promoted_string);
@@ -524,18 +354,18 @@ if (bFileMenu)
{
ppszEntries = RepoFilesMenu;
- nCount = sizeof(RepoFilesMenu) / sizeof(LPCTSTR);
+ nCount = RepoFilesMenuCount;
}
else
{
ppszEntries = RepoNoFilesMenu;
- nCount = sizeof(RepoNoFilesMenu) / sizeof(LPCTSTR);
+ nCount = RepoNoFilesMenuCount;
}
}
else
{
ppszEntries = NoRepoMenu;
- nCount = sizeof(NoRepoMenu) / sizeof(LPCTSTR);
+ nCount = NoRepoMenuCount;
}
// start building TortoiseHg menus and submenus
|
@@ -14,15 +14,7 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
-
-struct CMenuDescription
-{
- CString strName;
- CStringW strMenuText;
- CStringW strHelpText;
- CString strIconName;
- UINT idCmd;
-};
+#include "GlobalData.h"
typedef CAtlMap<CString, CMenuDescription> CMenuDescriptionMap;
typedef CAtlMap<UINT, CMenuDescription> CMenuIdCmdMap;
|
@@ -19,36 +19,12 @@ #include "TortoiseHgKeyboard.h"
#include "TortoiseUtils.h"
#include "RunDialog.h"
+#include "GlobalData.h"
// Each Windows Explorer window is launched in a separate thread. Therefore, use thread
// local storage so that each thread can have its own hook.
__declspec(thread) CTortoiseHgKeyboard* CTortoiseHgKeyboard::g_pObject = NULL;
-// Keyboard shortcut flags
-#define KSF_ALT 0x0001
-#define KSF_CONTROL 0x0002
-#define KSF_SHIFT 0x0004
-
-struct CKeyShortcut
-{
- CString strName;
- WORD wKey;
- WORD wFlags;
-};
-
-static const CKeyShortcut KeyShortcutList[] =
-{
- { "add", VK_INSERT, KSF_ALT },
- { "remove", VK_DELETE, KSF_ALT },
- { "commit", 'C', KSF_CONTROL | KSF_SHIFT },
- { "forget", 'F', KSF_CONTROL | KSF_SHIFT },
- { "rename", 'M', KSF_CONTROL | KSF_SHIFT },
- { "synchronize", 'S', KSF_CONTROL | KSF_SHIFT },
- { "update", 'U', KSF_CONTROL | KSF_SHIFT },
- { "revert", 'V', KSF_CONTROL | KSF_SHIFT },
- { "workbench", 'W', KSF_CONTROL | KSF_SHIFT },
-};
-
STDMETHODIMP CTortoiseHgKeyboard::SetSite(IUnknown* pUnkSite)
{
if (g_pObject == NULL)
@@ -78,7 +54,7 @@ if (::GetKeyState(VK_SHIFT) & 0x8000) wFlags |= KSF_SHIFT;
// Look for a matching keyboard shortcut.
- for (int i = 0; i < sizeof(KeyShortcutList) / sizeof(CKeyShortcut); i++)
+ for (int i = 0; i < KeyShortcutListCount; i++)
{
if (KeyShortcutList[i].wKey == wParam && KeyShortcutList[i].wFlags == wFlags)
{
|
Loading...