OSDN Git Service

Use LPCSTR instead of CString in arguments of SaveKeyBind,
authorKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Fri, 8 Jul 2011 01:25:39 +0000 (10:25 +0900)
committerKazuhiro Fujieda <fujieda@users.sourceforge.jp>
Wed, 13 Jul 2011 05:28:17 +0000 (14:28 +0900)
SaveCommand and AddKeyBind2C_ of CProfile. Change the return type of
CCommands::GetCommandName to LPCSTR. Shorten variable names in these
functions.

xkeymacs/profile.cpp
xkeymacs/profile.h
xkeymacsdll/Commands.cpp
xkeymacsdll/Commands.h

index d003ae4..923ff43 100644 (file)
@@ -734,50 +734,39 @@ BOOL CProfile::IsCommandType(const int nType, LPCTSTR szKeyBind)
        return FALSE;\r
 }\r
 \r
-void CProfile::SaveKeyBind(const CString szApplicationName, const int nComID, const int nType, const int nKey)\r
+void CProfile::SaveKeyBind(const LPCSTR szAppName, const int nComID, const int nType, const int nKey)\r
 {\r
-       if (!nComID) {\r
+       if (!nComID)\r
                return;\r
-       }\r
-\r
-       CString szCommandName = CCommands::GetCommandName(nComID);\r
-       if (szCommandName.IsEmpty()) {\r
+       const LPCSTR szComName = CCommands::GetCommandName(nComID);\r
+       if (!szComName[0])\r
                return;\r
-       }\r
-\r
-       SaveKeyBind(szApplicationName, szCommandName, nType, nKey);\r
+       SaveKeyBind(szAppName, szComName, nType, nKey);\r
 }\r
 \r
-void CProfile::SaveKeyBind(const CString szApplicationName, const CString szCommandName, const int nType, const int nKey)\r
+void CProfile::SaveKeyBind(const LPCSTR szAppName, const LPCSTR szComName, const int nType, const int nKey)\r
 {\r
-       CString szKeyBind = WriteKeyBind(nType, nKey);\r
-       CString szSubKey(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA));\r
-       szSubKey += _T("\\") + szApplicationName + _T("\\") + szCommandName;\r
-       if (!szKeyBind.IsEmpty()) {\r
+       const CString szKeyBind = WriteKeyBind(nType, nKey);\r
+       CString szSubKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + szAppName + _T("\\") + szComName;\r
+       if (!szKeyBind.IsEmpty())\r
                szSubKey += _T("\\") + szKeyBind;\r
-       }\r
-\r
        HKEY hKey = NULL;\r
-       if (RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS) {\r
+       if (RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS)\r
                RegCloseKey(hKey);\r
-       }\r
 }\r
 \r
-void CProfile::SaveCommand(const CString szApplicationName, const int nComID)\r
+void CProfile::SaveCommand(const LPCSTR szAppName, const int nComID)\r
 {\r
-       SaveKeyBind(szApplicationName, nComID, 0, 0);\r
+       SaveKeyBind(szAppName, nComID, 0, 0);\r
 }\r
 \r
-void CProfile::AddKeyBind2C_(const CString szApplicationName, const BYTE bVk)\r
+void CProfile::AddKeyBind2C_(const LPCSTR szAppName, const BYTE bVk)\r
 {\r
        int nComID;\r
-       for (nComID = 0; nComID < MAX_COMMAND; ++nComID) {\r
-               if (Commands[nComID].fCommand == CCommands::C_) {\r
+       for (nComID = 0; nComID < MAX_COMMAND; ++nComID)\r
+               if (Commands[nComID].fCommand == CCommands::C_)\r
                        break;\r
-               }\r
-       }\r
-\r
-       SaveKeyBind(szApplicationName, nComID, NONE, bVk);\r
+       SaveKeyBind(szAppName, nComID, NONE, bVk);\r
 }\r
 \r
 void CProfile::LevelUp()\r
index 6b4b4dc..2adfc4d 100644 (file)
@@ -64,12 +64,12 @@ public:
        static void SaveData();\r
 \r
 private:\r
-       static void SaveKeyBind(CString szApplicationName, CString szCommandName, int nType, int nKey);\r
+       static void SaveKeyBind(const LPCSTR szAppName, const LPCSTR szComName, int nType, int nKey);\r
        static BOOL DiableTokenPrivileges();\r
        static BOOL AdjustTokenPrivileges(LPCTSTR lpName);\r
-       static void SaveCommand(CString szApplicationName, int nComID);\r
-       static void SaveKeyBind(CString szApplicationName, int nComID, int nType, int nKey);\r
-       static void AddKeyBind2C_(CString szApplicationName, BYTE bVk);\r
+       static void SaveCommand(const LPCSTR szAppName, int nComID);\r
+       static void SaveKeyBind(const LPCSTR szAppName, int nComID, int nType, int nKey);\r
+       static void AddKeyBind2C_(const LPCSTR szApplicationName, BYTE bVk);\r
        static void LevelUp();\r
        static void Item2AppName(CString *sz);\r
        static int IsNotSameString(CComboBox *pApplication, CString szListItem);\r
@@ -86,8 +86,8 @@ private:
        static DWORD m_dwTasks;\r
        static void GetTaskList();\r
        static BOOL IsCommandType(int nType, LPCTSTR szKeyBind);\r
-       static int KeyBind2Key(LPCTSTR szKey);\r
-       static int KeyBind2CommandType(LPCTSTR szKeyBind);\r
+       static int KeyBind2Key(const LPCTSTR szKey);\r
+       static int KeyBind2CommandType(const LPCTSTR szKeyBind);\r
        static CString WriteKeyBind(int nType, int nKey);\r
        static void LoadRegistry();\r
        static void SaveRegistry();\r
index d4342df..9c937c7 100644 (file)
@@ -4020,10 +4020,9 @@ int CCommands::ExecuteExtendedCommand()
        return Reset(GOTO_HOOKX);\r
 }\r
 \r
-CString CCommands::GetCommandName(int nComID)\r
+LPCSTR CCommands::GetCommandName(int nComID)\r
 {\r
-       CString szCommandName(Commands[nComID].szCommandName);\r
-       return szCommandName;\r
+       return Commands[nComID].szCommandName;\r
 }\r
 \r
 int CCommands::GetCategoryID(int nComID)\r
index 540296f..1e929c6 100644 (file)
@@ -169,7 +169,7 @@ public:
        static int BackwardChar();\r
        static int BeginningOfLine();\r
        static int ForwardChar();\r
-       static CString GetCommandName(int nComID);\r
+       static LPCSTR GetCommandName(int nComID);\r
        static int GetCategoryID(int nComID);\r
        static int GetDescriptionID(int nComID);\r
        static int GetToolTipID(int nComID);\r