From 147278ac61658295b692943b71c7e3af2aead6f2 Mon Sep 17 00:00:00 2001 From: donho Date: Sat, 6 Sep 2008 00:53:53 +0000 Subject: [PATCH] [NEW_FEATURE] UNICODE/ANSI release. Fix crash issue due to the incoherent modification/creation date. Fix tag match highlighting mismatched bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@307 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/installer/nppSetup.nsi | 5 + .../src/MISC/Exception/Win32Exception.h | 24 - PowerEditor/src/MISC/FileNameStringSplitter.h | 20 +- .../MISC/PluginsManager/Notepad_plus_msgs.h | 30 +- .../src/MISC/PluginsManager/PluginInterface.h | 13 +- .../MISC/PluginsManager/PluginsManager.cpp | 93 +- .../src/MISC/PluginsManager/PluginsManager.h | 30 +- PowerEditor/src/MISC/Process/Process.cpp | 57 +- PowerEditor/src/MISC/Process/Process.h | 30 +- PowerEditor/src/MISC/RegExt/regExtDlg.cpp | 87 +- PowerEditor/src/MISC/RegExt/regExtDlg.h | 4 +- PowerEditor/src/MISC/RegExt/regExtDlg.rc | 2 +- PowerEditor/src/MISC/SysMsg/SysMsg.cpp | 150 +- PowerEditor/src/MISC/SysMsg/SysMsg.h | 86 +- PowerEditor/src/Notepad_plus.cpp | 1770 +++++++------- PowerEditor/src/Notepad_plus.h | 208 +- PowerEditor/src/Notepad_plus.rc | 9 +- PowerEditor/src/Parameters.cpp | 2090 ++++++++--------- PowerEditor/src/Parameters.h | 350 +-- .../src/ScitillaComponent/AutoCompletion.cpp | 93 +- .../src/ScitillaComponent/AutoCompletion.h | 4 +- PowerEditor/src/ScitillaComponent/Buffer.cpp | 152 +- PowerEditor/src/ScitillaComponent/Buffer.h | 62 +- .../src/ScitillaComponent/DocTabView.cpp | 19 +- .../src/ScitillaComponent/DocTabView.h | 2 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 354 ++- .../src/ScitillaComponent/FindReplaceDlg.h | 116 +- .../src/ScitillaComponent/FindReplaceDlg.rc | 10 +- .../src/ScitillaComponent/FunctionCallTip.cpp | 98 +- .../src/ScitillaComponent/FunctionCallTip.h | 12 +- .../src/ScitillaComponent/GoToLineDlg.h | 2 +- PowerEditor/src/ScitillaComponent/Printer.cpp | 154 +- PowerEditor/src/ScitillaComponent/Printer.h | 4 +- .../ScitillaComponent/ScintillaEditView.cpp | 740 ++++-- .../src/ScitillaComponent/ScintillaEditView.h | 88 +- .../ScitillaComponent/SmartHighlighter.cpp | 14 +- .../ScitillaComponent/UserDefineDialog.cpp | 128 +- .../src/ScitillaComponent/UserDefineDialog.h | 26 +- .../src/ScitillaComponent/UserDefineDialog.rc | 12 +- .../UserDefineLangReference.h | 3 + .../src/ScitillaComponent/columnEditor.cpp | 37 +- .../src/ScitillaComponent/columnEditor.h | 4 +- .../src/ScitillaComponent/columnEditor.rc | 2 +- .../xmlMatchedTagsHighlighter.cpp | 109 +- .../xmlMatchedTagsHighlighter.h | 2 + PowerEditor/src/TinyXml/tinystr.cpp | 86 +- PowerEditor/src/TinyXml/tinystr.h | 57 +- PowerEditor/src/TinyXml/tinyxml.cpp | 208 +- PowerEditor/src/TinyXml/tinyxml.h | 266 ++- PowerEditor/src/TinyXml/tinyxmlerror.cpp | 31 +- PowerEditor/src/TinyXml/tinyxmlparser.cpp | 147 +- PowerEditor/src/UniConversion.cpp | 57 +- PowerEditor/src/UniConversion.h | 26 +- PowerEditor/src/Utf8_16.cpp | 14 +- PowerEditor/src/Utf8_16.h | 15 +- .../src/WinControls/AboutDlg/AboutDlg.cpp | 20 +- .../src/WinControls/AboutDlg/AboutDlg.h | 6 +- .../src/WinControls/AboutDlg/URLCtrl.cpp | 12 +- .../src/WinControls/AboutDlg/URLCtrl.h | 4 +- .../WinControls/ColourPicker/ColourPicker.cpp | 6 +- .../WinControls/ColourPicker/ColourPopup.cpp | 6 +- .../WinControls/ColourPicker/ColourPopup.rc | 2 +- .../WinControls/ColourPicker/WordStyleDlg.cpp | 54 +- .../WinControls/ColourPicker/WordStyleDlg.h | 12 +- .../WinControls/ColourPicker/WordStyleDlg.rc | 2 +- .../src/WinControls/ContextMenu/ContextMenu.h | 10 +- .../src/WinControls/DockingWnd/Docking.h | 6 +- .../WinControls/DockingWnd/DockingCont.cpp | 44 +- .../src/WinControls/DockingWnd/DockingCont.h | 6 +- .../DockingWnd/DockingDlgInterface.h | 18 +- .../DockingWnd/DockingGUIWidget.rc | 2 +- .../WinControls/DockingWnd/DockingManager.cpp | 8 +- .../WinControls/DockingWnd/DockingManager.h | 4 +- .../DockingWnd/DockingSplitter.cpp | 14 +- .../src/WinControls/DockingWnd/Gripper.cpp | 20 +- .../src/WinControls/DockingWnd/Gripper.h | 2 +- .../WinControls/DockingWnd/common_func.cpp | 21 +- PowerEditor/src/WinControls/Grid/BabyGrid.cpp | 210 +- PowerEditor/src/WinControls/Grid/BabyGrid.h | 7 +- .../src/WinControls/Grid/BabyGridWrapper.cpp | 4 +- .../src/WinControls/Grid/BabyGridWrapper.h | 2 +- .../src/WinControls/Grid/ShortcutMapper.cpp | 16 +- .../src/WinControls/Grid/ShortcutMapper.h | 21 +- .../src/WinControls/Grid/ShortcutMapper.rc | 2 +- .../src/WinControls/Grid/ShortcutMapper_rc.h | 4 - .../WinControls/ImageListSet/ImageListSet.cpp | 2 +- .../WinControls/ImageListSet/ImageListSet.h | 8 +- .../OpenSaveFileDialog/FileDialog.cpp | 177 +- .../OpenSaveFileDialog/FileDialog.h | 49 +- .../src/WinControls/Preference/preference.rc | 18 +- .../WinControls/Preference/preferenceDlg.cpp | 173 +- .../WinControls/Preference/preferenceDlg.h | 10 +- .../SplitterContainer/Splitter.cpp | 20 +- .../SplitterContainer/SplitterContainer.cpp | 10 +- .../SplitterContainer/SplitterContainer.h | 2 +- .../StaticDialog/RunDlg/RunDlg.cpp | 115 +- .../WinControls/StaticDialog/RunDlg/RunDlg.h | 36 +- .../WinControls/StaticDialog/RunDlg/RunDlg.rc | 2 +- .../WinControls/StaticDialog/StaticDialog.cpp | 2 +- .../src/WinControls/StatusBar/StatusBar.cpp | 4 +- .../src/WinControls/StatusBar/StatusBar.h | 3 +- .../src/WinControls/TabBar/ControlsTab.h | 18 +- PowerEditor/src/WinControls/TabBar/TabBar.cpp | 58 +- PowerEditor/src/WinControls/TabBar/TabBar.h | 14 +- .../src/WinControls/TaskList/TaskList.cpp | 10 +- .../src/WinControls/TaskList/TaskList.h | 2 +- .../src/WinControls/TaskList/TaskListDlg.h | 16 +- .../src/WinControls/TaskList/TaskListDlg.rc | 2 +- .../src/WinControls/ToolBar/ToolBar.cpp | 8 +- PowerEditor/src/WinControls/ToolBar/ToolBar.h | 2 +- .../src/WinControls/ToolTip/ToolTip.cpp | 6 +- PowerEditor/src/WinControls/ToolTip/ToolTip.h | 2 +- .../TrayIcon/trayIconControler.cpp | 6 +- .../WinControls/TrayIcon/trayIconControler.h | 2 +- PowerEditor/src/WinControls/Window.h | 4 +- .../src/WinControls/WindowsDlg/SizeableDlg.h | 5 +- .../src/WinControls/WindowsDlg/WinMgr.cpp | 2 +- .../src/WinControls/WindowsDlg/WindowsDlg.cpp | 168 +- .../src/WinControls/WindowsDlg/WindowsDlg.h | 6 +- .../src/WinControls/WindowsDlg/WindowsDlg.rc | 4 +- .../src/WinControls/WindowsDlg/WindowsDlgRc.h | 22 - .../src/WinControls/shortcut/RunMacroDlg.cpp | 4 +- .../src/WinControls/shortcut/RunMacroDlg.h | 2 +- .../src/WinControls/shortcut/RunMacroDlg.rc | 2 +- .../src/WinControls/shortcut/shortcut.cpp | 264 +-- .../src/WinControls/shortcut/shortcut.h | 56 +- .../src/WinControls/shortcut/shortcut.rc | 4 +- PowerEditor/src/lastRecentFileList.cpp | 34 +- PowerEditor/src/lastRecentFileList.h | 14 +- PowerEditor/src/lesDlgs.h | 6 +- PowerEditor/src/resource.h | 12 +- PowerEditor/src/winmain.cpp | 124 +- PowerEditor/src/xpm_icons.h | 7 +- PowerEditor/visual.net/notepadPlus.vcproj | 30 +- 134 files changed, 5423 insertions(+), 4881 deletions(-) diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index ebfedba1..928d2745 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -566,6 +566,11 @@ SubSection "Auto-completion Files" autoCompletionComponent File "..\bin\plugins\APIs\cs.xml" SectionEnd + Section HTML + SetOutPath "$INSTDIR\plugins\APIs" + File "..\bin\plugins\APIs\html.xml" + SectionEnd + Section PHP SetOutPath "$INSTDIR\plugins\APIs" File "..\bin\plugins\APIs\php.xml" diff --git a/PowerEditor/src/MISC/Exception/Win32Exception.h b/PowerEditor/src/MISC/Exception/Win32Exception.h index 51ea2b6a..651388f8 100644 --- a/PowerEditor/src/MISC/Exception/Win32Exception.h +++ b/PowerEditor/src/MISC/Exception/Win32Exception.h @@ -4,28 +4,6 @@ //By Bennett //Formatting Slightly modified for N++ -/* -this file is part of Notepad++ -Copyright (C)2003 Don HO - -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, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#ifndef WIN32EXCEPTION_H -#define WIN32EXCEPTION_H - #include "windows.h" #include @@ -63,5 +41,3 @@ private: friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info); }; - -#endif //WIN32EXCEPTION_H diff --git a/PowerEditor/src/MISC/FileNameStringSplitter.h b/PowerEditor/src/MISC/FileNameStringSplitter.h index d97bf08a..4368ac61 100644 --- a/PowerEditor/src/MISC/FileNameStringSplitter.h +++ b/PowerEditor/src/MISC/FileNameStringSplitter.h @@ -18,19 +18,19 @@ #ifndef FILENAME_STRING_SPLITTER_H #define FILENAME_STRING_SPLITTER_H -typedef std::vector stringVectorW; +typedef std::vector> stringVector; class FileNameStringSplitter { public : - FileNameStringSplitter(const wchar_t *fileNameStr) { + FileNameStringSplitter(const TCHAR *fileNameStr) { //if (!fileNameStr) return; - wchar_t *pStr = NULL; + TCHAR *pStr = NULL; bool isInsideQuotes = false; - wchar_t str[256]; + TCHAR str[256]; int i = 0; bool fini = false; - for (pStr = (wchar_t *)fileNameStr ; !fini ; ) + for (pStr = (TCHAR *)fileNameStr ; !fini ; ) { switch (*pStr) { @@ -39,7 +39,7 @@ public : { str[i] = '\0'; if (str[0]) - _fileNames.push_back(std::wstring(str)); + _fileNames.push_back(std::basic_string(str)); i = 0; } isInsideQuotes = !isInsideQuotes; @@ -56,7 +56,7 @@ public : { str[i] = '\0'; if (str[0]) - _fileNames.push_back(std::wstring(str)); + _fileNames.push_back(std::basic_string(str)); i = 0; } pStr++; @@ -65,7 +65,7 @@ public : case '\0' : str[i] = *pStr; if (str[0]) - _fileNames.push_back(std::wstring(str)); + _fileNames.push_back(std::basic_string(str)); fini = true; break; @@ -77,7 +77,7 @@ public : } }; - const wchar_t * getFileName(int index) const { + const TCHAR * getFileName(int index) const { return _fileNames[index].c_str(); }; @@ -86,7 +86,7 @@ public : }; private : - stringVectorW _fileNames; + stringVector _fileNames; }; #endif //FILENAME_STRING_SPLITTER_H diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index 8ee2f403..d10ef43f 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -59,9 +59,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV #define NPPM_SAVECURRENTSESSION (NPPMSG + 16) struct sessionInfo { - char* sessionFilePathName; + TCHAR* sessionFilePathName; int nbFile; - char** files; + TCHAR** files; }; #define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17) @@ -100,7 +100,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV //void NPPM_ACTIVATEDOC(int view, int index2Activate) #define NPPM_LAUNCHFINDINFILESDLG (NPPMSG + 29) - //void NPPM_LAUNCHFINDINFILESDLG(char * dir2Search, char * filtre) + //void NPPM_LAUNCHFINDINFILESDLG(TCHAR * dir2Search, TCHAR * filtre) #define NPPM_DMMSHOW (NPPMSG + 30) #define NPPM_DMMHIDE (NPPMSG + 31) @@ -111,16 +111,16 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV //void NPPM_DMMREGASDCKDLG(0, &tTbData) #define NPPM_LOADSESSION (NPPMSG + 34) - //void NPPM_LOADSESSION(0, const char* file name) + //void NPPM_LOADSESSION(0, const TCHAR* file name) #define NPPM_DMMVIEWOTHERTAB (NPPMSG + 35) //void WM_DMM_VIEWOTHERTAB(0, tTbData->pszName) #define NPPM_RELOADFILE (NPPMSG + 36) - //BOOL NPPM_RELOADFILE(BOOL withAlert, char *filePathName2Reload) + //BOOL NPPM_RELOADFILE(BOOL withAlert, TCHAR *filePathName2Reload) #define NPPM_SWITCHTOFILE (NPPMSG + 37) - //BOOL NPPM_SWITCHTOFILE(0, char *filePathName2switch) + //BOOL NPPM_SWITCHTOFILE(0, TCHAR *filePathName2switch) #define NPPM_SAVECURRENTFILE (NPPMSG + 38) //BOOL WM_SWITCHTOFILE(0, 0) @@ -142,7 +142,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV //winVer NPPM_GETWINDOWSVERSION(0, 0) #define NPPM_DMMGETPLUGINHWNDBYNAME (NPPMSG + 43) - //HWND WM_DMM_GETPLUGINHWNDBYNAME(const char *windowName, const char *moduleName) + //HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName) // if moduleName is NULL, then return value is NULL // if windowName is NULL, then the first found window handle which matches with the moduleName will be returned @@ -153,15 +153,15 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV //BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) #define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46) - //void NPPM_GETPLUGINSCONFIGDIR(int strLen, char *str) + //void NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str) #define NPPM_MSGTOPLUGIN (NPPMSG + 47) - //BOOL NPPM_MSGTOPLUGIN(char *destModuleName, CommunicationInfo *info) + //BOOL NPPM_MSGTOPLUGIN(TCHAR *destModuleName, CommunicationInfo *info) // return value is TRUE when the message arrive to the destination plugins. // if destModule or info is NULL, then return value is FALSE struct CommunicationInfo { long internalMsg; - const char * srcModuleName; + const TCHAR * srcModuleName; void * info; // defined by plugin }; @@ -218,8 +218,8 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV #define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58) // INT NPPM_GETFULLPATHFROMBUFFERID(INT bufferID, CHAR *fullFilePath) // Get full path file name from a bufferID. - // Return -1 if the bufferID non existing, otherwise the number of char copied/to copy - // User should call it with fullFilePath be NULL to get the number of char (not including the nul character), + // Return -1 if the bufferID non existing, otherwise the number of TCHAR copied/to copy + // User should call it with fullFilePath be NULL to get the number of TCHAR (not including the nul character), // allocate fullFilePath with the return values + 1, then call it again to get full path file name #define NPPM_GETBUFFERIDFROMPOS (NPPMSG + 59) @@ -252,10 +252,10 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV #define NPPM_GETEXTPART (RUNCOMMAND_USER + EXT_PART) #define NPPM_GETCURRENTWORD (RUNCOMMAND_USER + CURRENT_WORD) #define NPPM_GETNPPDIRECTORY (RUNCOMMAND_USER + NPP_DIRECTORY) - // BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, char *str) - // where str is the allocated char array, + // BOOL NPPM_GETXXXXXXXXXXXXXXXX(size_t strLen, TCHAR *str) + // where str is the allocated TCHAR array, // strLen is the allocated array size - // The return value is TRUE when get string operation success + // The return value is TRUE when get basic_string operation success // Otherwise (allocated array size is too small) FALSE #define NPPM_GETCURRENTLINE (RUNCOMMAND_USER + CURRENT_LINE) diff --git a/PowerEditor/src/MISC/PluginsManager/PluginInterface.h b/PowerEditor/src/MISC/PluginsManager/PluginInterface.h index f69b1414..ddc5bd08 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginInterface.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginInterface.h @@ -24,7 +24,7 @@ const int nbChar = 64; -typedef const char * (__cdecl * PFUNCGETNAME)(); +typedef const TCHAR * (__cdecl * PFUNCGETNAME)(); struct NppData { HWND _nppHandle; @@ -37,15 +37,16 @@ typedef void (__cdecl * PFUNCPLUGINCMD)(); typedef void (__cdecl * PBENOTIFIED)(SCNotification *); typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam); + struct ShortcutKey { bool _isCtrl; bool _isAlt; bool _isShift; - unsigned char _key; + UCHAR _key; }; struct FuncItem { - char _itemName[nbChar]; + TCHAR _itemName[nbChar]; PFUNCPLUGINCMD _pFunc; int _cmdID; bool _init2Check; @@ -56,9 +57,13 @@ typedef FuncItem * (__cdecl * PFUNCGETFUNCSARRAY)(int *); // You should implement (or define an empty function body) those functions which are called by Notepad++ plugin manager extern "C" __declspec(dllexport) void setInfo(NppData); -extern "C" __declspec(dllexport) const char * getName(); +extern "C" __declspec(dllexport) const TCHAR * getName(); extern "C" __declspec(dllexport) FuncItem * getFuncsArray(int *); extern "C" __declspec(dllexport) void beNotified(SCNotification *); extern "C" __declspec(dllexport) LRESULT messageProc(UINT Message, WPARAM wParam, LPARAM lParam); +#ifdef UNICODE +extern "C" __declspec(dllexport) BOOL isUnicode(); +#endif //UNICODE + #endif //PLUGININTERFACE_H diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 7939e92e..13c18561 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -18,34 +18,34 @@ #include #include "PluginsManager.h" -#define USERMSG "This plugin is not compatible with current version of Notepad++.\n\ -Remove this plugin from plugins directory if you don't want to see this message on the next launch time." +const TCHAR * USERMSG = TEXT("This plugin is not compatible with current version of Notepad++.\n\ +Remove this plugin from plugins directory if you don't want to see this message on the next launch time."); -bool PluginsManager::loadPlugins(const char *dir) +bool PluginsManager::loadPlugins(const TCHAR *dir) { if (_isDisabled) return false; - vector dllNames; - const char *pNppPath = (NppParameters::getInstance())->getNppPath(); + vector> dllNames; + const TCHAR *pNppPath = (NppParameters::getInstance())->getNppPath(); - string pluginsFullPathFilter = (dir && dir[0])?dir:pNppPath; + basic_string pluginsFullPathFilter = (dir && dir[0])?dir:pNppPath; - pluginsFullPathFilter += "\\plugins\\*.dll"; + pluginsFullPathFilter += TEXT("\\plugins\\*.dll"); WIN32_FIND_DATA foundData; HANDLE hFindFile = ::FindFirstFile(pluginsFullPathFilter.c_str(), &foundData); if (hFindFile != INVALID_HANDLE_VALUE) { - string plugins1stFullPath = (dir && dir[0])?dir:pNppPath; - plugins1stFullPath += "\\plugins\\"; + basic_string plugins1stFullPath = (dir && dir[0])?dir:pNppPath; + plugins1stFullPath += TEXT("\\plugins\\"); plugins1stFullPath += foundData.cFileName; dllNames.push_back(plugins1stFullPath); while (::FindNextFile(hFindFile, &foundData)) { - string fullPath = (dir && dir[0])?dir:pNppPath; - fullPath += "\\plugins\\"; + basic_string fullPath = (dir && dir[0])?dir:pNppPath; + fullPath += TEXT("\\plugins\\"); fullPath += foundData.cFileName; dllNames.push_back(fullPath); } @@ -57,41 +57,50 @@ bool PluginsManager::loadPlugins(const char *dir) { PluginInfo *pi = new PluginInfo; try { - char tmpStr[MAX_PATH]; - strcpy(tmpStr, dllNames[i].c_str()); - strcpy(pi->_moduleName, PathFindFileName(tmpStr)); + TCHAR tmpStr[MAX_PATH]; + lstrcpy(tmpStr, dllNames[i].c_str()); + lstrcpy(pi->_moduleName, PathFindFileName(tmpStr)); pi->_hLib = ::LoadLibrary(dllNames[i].c_str()); if (!pi->_hLib) - throw string("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem."); + throw basic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem.")); + + pi->_pFuncIsUnicode = (PFUNCISUNICODE)GetProcAddress(pi->_hLib, "isUnicode"); +#ifdef UNICODE + if (!pi->_pFuncIsUnicode || !pi->_pFuncIsUnicode()) + throw basic_string(TEXT("This ANSI plugin is not compatible with your Unicode Notepad++.")); +#else + if (pi->_pFuncIsUnicode) + throw basic_string(TEXT("This UNICODE plugin is not compatible with your ANSI mode Notepad++.")); +#endif pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo"); if (!pi->_pFuncSetInfo) - throw string("Missing \"setInfo\" function"); + throw basic_string(TEXT("Missing \"setInfo\" function")); pi->_pFuncGetName = (PFUNCGETNAME)GetProcAddress(pi->_hLib, "getName"); if (!pi->_pFuncGetName) - throw string("Missing \"getName\" function"); + throw basic_string(TEXT("Missing \"getName\" function")); pi->_pBeNotified = (PBENOTIFIED)GetProcAddress(pi->_hLib, "beNotified"); if (!pi->_pBeNotified) - throw string("Missing \"beNotified\" function"); + throw basic_string(TEXT("Missing \"beNotified\" function")); pi->_pMessageProc = (PMESSAGEPROC)GetProcAddress(pi->_hLib, "messageProc"); if (!pi->_pMessageProc) - throw string("Missing \"messageProc\" function"); + throw basic_string(TEXT("Missing \"messageProc\" function")); pi->_pFuncSetInfo(_nppData); pi->_pFuncGetFuncsArray = (PFUNCGETFUNCSARRAY)GetProcAddress(pi->_hLib, "getFuncsArray"); if (!pi->_pFuncGetFuncsArray) - throw string("Missing \"getFuncsArray\" function"); + throw basic_string(TEXT("Missing \"getFuncsArray\" function")); pi->_funcItems = pi->_pFuncGetFuncsArray(&pi->_nbFuncItem); if ((!pi->_funcItems) || (pi->_nbFuncItem <= 0)) - throw string("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly"); + throw basic_string(TEXT("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly")); pi->_pluginMenu = ::CreateMenu(); @@ -101,18 +110,18 @@ bool PluginsManager::loadPlugins(const char *dir) { GetLexerNameFn GetLexerName = (GetLexerNameFn)::GetProcAddress(pi->_hLib, "GetLexerName"); if (!GetLexerName) - throw string("Loading GetLexerName function failed."); + throw basic_string(TEXT("Loading GetLexerName function failed.")); GetLexerStatusTextFn GetLexerStatusText = (GetLexerStatusTextFn)::GetProcAddress(pi->_hLib, "GetLexerStatusText"); if (!GetLexerStatusText) - throw string("Loading GetLexerStatusText function failed."); + throw basic_string(TEXT("Loading GetLexerStatusText function failed.")); // Assign a buffer for the lexer name. - char lexName[MAX_EXTERNAL_LEXER_NAME_LEN]; - strcpy(lexName, ""); - char lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN]; - strcpy(lexDesc, ""); + TCHAR lexName[MAX_EXTERNAL_LEXER_NAME_LEN]; + lstrcpy(lexName, TEXT("")); + TCHAR lexDesc[MAX_EXTERNAL_LEXER_DESC_LEN]; + lstrcpy(lexDesc, TEXT("")); int numLexers = GetLexerCount(); @@ -130,16 +139,16 @@ bool PluginsManager::loadPlugins(const char *dir) containers[x] = NULL; } - char xmlPath[MAX_PATH]; - strcpy(xmlPath, nppParams->getNppPath()); - PathAppend(xmlPath, "plugins\\Config"); + TCHAR xmlPath[MAX_PATH]; + lstrcpy(xmlPath, nppParams->getNppPath()); + PathAppend(xmlPath, TEXT("plugins\\Config")); PathAppend(xmlPath, pi->_moduleName); PathRemoveExtension(xmlPath); - PathAddExtension(xmlPath, ".xml"); + PathAddExtension(xmlPath, TEXT(".xml")); if (!PathFileExists(xmlPath)) { - throw string(string(xmlPath) + " is missing."); + throw basic_string(basic_string(xmlPath) + TEXT(" is missing.")); } TiXmlDocument *_pXmlDoc = new TiXmlDocument(xmlPath); @@ -148,7 +157,7 @@ bool PluginsManager::loadPlugins(const char *dir) { delete _pXmlDoc; _pXmlDoc = NULL; - throw string(string(xmlPath) + " failed to load."); + throw basic_string(basic_string(xmlPath) + TEXT(" failed to load.")); } for (int x = 0; x < numLexers; x++) // postpone adding in case the xml is missing/corrupt @@ -162,17 +171,17 @@ bool PluginsManager::loadPlugins(const char *dir) } _pluginInfos.push_back(pi); } - catch(string s) + catch(basic_string s) { - s += "\n\n"; + s += TEXT("\n\n"); s += USERMSG; ::MessageBox(NULL, s.c_str(), dllNames[i].c_str(), MB_OK); delete pi; } catch(...) { - string msg = "Fail loaded"; - msg += "\n\n"; + basic_string msg = TEXT("Fail loaded"); + msg += TEXT("\n\n"); msg += USERMSG; ::MessageBox(NULL, msg.c_str(), dllNames[i].c_str(), MB_OK); delete pi; @@ -183,12 +192,12 @@ bool PluginsManager::loadPlugins(const char *dir) return true; } -void PluginsManager::setMenu(HMENU hMenu, const char *menuName) +void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName) { if (hasPlugins()) { vector & pluginCmdSCList = (NppParameters::getInstance())->getPluginCommandList(); - const char *nom_menu = (menuName && menuName[0])?menuName:"Plugins"; + const TCHAR *nom_menu = (menuName && menuName[0])?menuName:TEXT("Plugins"); _hPluginsMenu = ::CreateMenu(); ::InsertMenu(hMenu, 9, MF_BYPOSITION | MF_POPUP, (UINT_PTR)_hPluginsMenu, nom_menu); @@ -201,7 +210,7 @@ void PluginsManager::setMenu(HMENU hMenu, const char *menuName) { if (_pluginInfos[i]->_funcItems[j]._pFunc == NULL) { - ::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, ""); + ::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); continue; } @@ -209,14 +218,14 @@ void PluginsManager::setMenu(HMENU hMenu, const char *menuName) int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1); _pluginInfos[i]->_funcItems[j]._cmdID = cmdID; - string itemName = _pluginInfos[i]->_funcItems[j]._itemName; + basic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName; if (_pluginInfos[i]->_funcItems[j]._pShKey) { ShortcutKey & sKey = *(_pluginInfos[i]->_funcItems[j]._pShKey); PluginCmdShortcut pcs(Shortcut(itemName.c_str(), sKey._isCtrl, sKey._isAlt, sKey._isShift, sKey._key), cmdID, _pluginInfos[i]->_moduleName, j); pluginCmdSCList.push_back(pcs); - itemName += "\t"; + itemName += TEXT("\t"); itemName += pcs.toString(); } else diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 19a571cc..5c894e3b 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -22,12 +22,14 @@ #include "Parameters.h" #include "PluginInterface.h" +typedef BOOL (__cdecl * PFUNCISUNICODE)(); + struct PluginCommand { - char _pluginName[64]; + TCHAR _pluginName[64]; int _funcID; PFUNCPLUGINCMD _pFunc; - PluginCommand(const char *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc){ - strcpy(_pluginName, pluginName); + PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc){ + lstrcpy(_pluginName, pluginName); }; }; @@ -51,10 +53,11 @@ struct PluginInfo { PBENOTIFIED _pBeNotified; PFUNCGETFUNCSARRAY _pFuncGetFuncsArray; PMESSAGEPROC _pMessageProc; + PFUNCISUNICODE _pFuncIsUnicode; FuncItem *_funcItems; int _nbFuncItem; - char _moduleName[64]; + TCHAR _moduleName[64]; }; class PluginsManager { @@ -71,7 +74,7 @@ public: void init(const NppData & nppData) { _nppData = nppData; }; - bool loadPlugins(const char *dir = NULL); + bool loadPlugins(const TCHAR *dir = NULL); void runPluginCommand(size_t i) { if (i < _pluginsCommands.size()) @@ -79,10 +82,10 @@ public: _pluginsCommands[i]._pFunc(); }; - void runPluginCommand(const char *pluginName, int commandID) { + void runPluginCommand(const TCHAR *pluginName, int commandID) { for (size_t i = 0 ; i < _pluginsCommands.size() ; i++) { - if (!stricmp(_pluginsCommands[i]._pluginName, pluginName)) + if (!generic_stricmp(_pluginsCommands[i]._pluginName, pluginName)) { if (_pluginsCommands[i]._funcID == commandID) _pluginsCommands[i]._pFunc(); @@ -90,7 +93,7 @@ public: } }; - void setMenu(HMENU hMenu, const char *menuName); + void setMenu(HMENU hMenu, const TCHAR *menuName); void notify(SCNotification *notification) { for (size_t i = 0 ; i < _pluginInfos.size() ; i++) @@ -110,13 +113,13 @@ public: }; bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam) { - const char * moduleName = (const char *)wParam; + const TCHAR * moduleName = (const TCHAR *)wParam; if (!moduleName || !moduleName[0] || !lParam) return false; for (size_t i = 0 ; i < _pluginInfos.size() ; i++) { - if (stricmp(_pluginInfos[i]->_moduleName, moduleName) == 0) + if (generic_stricmp(_pluginInfos[i]->_moduleName, moduleName) == 0) { _pluginInfos[i]->_pMessageProc(Message, wParam, lParam); return true; @@ -130,6 +133,7 @@ public: }; void disable() {_isDisabled = true;}; + bool hasPlugins(){return (_pluginInfos.size()!= 0);}; private: NppData _nppData; @@ -138,15 +142,13 @@ private: vector _pluginInfos; vector _pluginsCommands; bool _isDisabled; - - bool hasPlugins(){return (_pluginInfos.size()!= 0);}; }; #define EXT_LEXER_DECL __stdcall // External Lexer function definitions... typedef int (EXT_LEXER_DECL *GetLexerCountFn)(); -typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, char *name, int buflength); -typedef void (EXT_LEXER_DECL *GetLexerStatusTextFn)(unsigned int Index, char *desc, int buflength); +typedef void (EXT_LEXER_DECL *GetLexerNameFn)(unsigned int Index, TCHAR *name, int buflength); +typedef void (EXT_LEXER_DECL *GetLexerStatusTextFn)(unsigned int Index, TCHAR *desc, int buflength); #endif //PLUGINSMANAGER_H diff --git a/PowerEditor/src/MISC/Process/Process.cpp b/PowerEditor/src/MISC/Process/Process.cpp index 2d04cc88..6fcda4bf 100644 --- a/PowerEditor/src/MISC/Process/Process.cpp +++ b/PowerEditor/src/MISC/Process/Process.cpp @@ -40,11 +40,11 @@ BOOL Process::run() try { // Create stdout pipe if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0)) - error("CreatePipe", result, 1000); + error(TEXT("CreatePipe"), result, 1000); // Create stderr pipe if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0)) - error("CreatePipe", result, 1001); + error(TEXT("CreatePipe"), result, 1001); STARTUPINFO startup; PROCESS_INFORMATION procinfo; @@ -56,17 +56,17 @@ BOOL Process::run() startup.hStdOutput = hPipeOutW; startup.hStdError = hPipeErrW; - string cmd = "\""; + basic_string cmd = TEXT("\""); cmd += _command; - cmd += "\""; + cmd += TEXT("\""); if (_args[0]) { - cmd += " "; + cmd += TEXT(" "); cmd += _args; } - BOOL started = ::CreateProcess(NULL, // command is part of input string - (LPSTR)cmd.c_str(), // (writeable) command string + BOOL started = ::CreateProcess(NULL, // command is part of input basic_string + (TCHAR *)cmd.c_str(), // (writeable) command basic_string NULL, // process security NULL, // thread security TRUE, // inherit handles flag @@ -80,17 +80,17 @@ BOOL Process::run() _hProcessThread = procinfo.hThread; if(!started) - error("CreateProcess", result, 1002); + error(TEXT("CreateProcess"), result, 1002); if (_type == CONSOLE_PROG) { - hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, "listenerEvent"); + hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent")); if(!hListenerEvent[0]) - error("CreateEvent", result, 1003); + error(TEXT("CreateEvent"), result, 1003); - hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, "listenerStdErrEvent"); + hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent")); if(!hListenerEvent[1]) - error("CreateEvent", result, 1004); + error(TEXT("CreateEvent"), result, 1004); // The process is running so we set this to FALSE @@ -98,15 +98,15 @@ BOOL Process::run() hWaitForProcessEndThread = ::CreateThread(NULL, 0, staticWaitForProcessEnd, this, 0, NULL); if (!hWaitForProcessEndThread) - error("CreateThread", result, 1005); + error(TEXT("CreateThread"), result, 1005); hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL); if (!hListenerStdOutThread) - error("CreateThread", result, 1006); + error(TEXT("CreateThread"), result, 1006); hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL); if (!hListenerStdErrThread) - error("CreateThread", result, 1007); + error(TEXT("CreateThread"), result, 1007); // We wait until the process is over // TO DO: This should be a bit secured in case something happen and the @@ -134,8 +134,9 @@ BOOL Process::run() } } } catch (int coderr){ - char str[10]; - ::MessageBox(NULL, itoa(coderr, str, 10), "Exception :", MB_OK); + TCHAR str[10]; + wsprintf(str, TEXT("%d"), coderr); + ::MessageBox(NULL, str, TEXT("Exception :"), MB_OK); } // on va fermer toutes les handles @@ -170,7 +171,7 @@ void Process::listenerStdOut() //DWORD size = 0; DWORD bytesAvail = 0; BOOL result = 0; - HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "listenerEvent"); + HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent")); //FILE *fp = NULL; int taille = 0; @@ -203,9 +204,9 @@ void Process::listenerStdOut() if ((!result) && (outbytesRead == 0)) break; } - //outbytesRead = strlen(bufferOut); + //outbytesRead = lstrlen(bufferOut); bufferOut[outbytesRead] = '\0'; - string s; + basic_string s; s.assign(bufferOut); _stdoutStr += s; @@ -221,7 +222,7 @@ void Process::listenerStdOut() if(!::SetEvent(hListenerEvent)) { - systemMessage("Thread listenerStdOut"); + systemMessage(TEXT("Thread listenerStdOut")); } } @@ -231,7 +232,7 @@ void Process::listenerStdErr() //DWORD size = 0; DWORD bytesAvail = 0; BOOL result = 0; - HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "listenerStdErrEvent"); + HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); int taille = 0; //TCHAR bufferOut[MAX_LINE_LENGTH + 1]; @@ -262,9 +263,9 @@ void Process::listenerStdErr() if ((!result) && (errbytesRead == 0)) break; } - //outbytesRead = strlen(bufferOut); + //outbytesRead = lstrlen(bufferOut); bufferErr[errbytesRead] = '\0'; - string s; + basic_string s; s.assign(bufferErr); _stderrStr += s; @@ -277,15 +278,15 @@ void Process::listenerStdErr() if(!::SetEvent(hListenerEvent)) { - systemMessage("Thread stdout listener"); + systemMessage(TEXT("Thread stdout listener")); } } void Process::waitForProcessEnd() { HANDLE hListenerEvent[2]; - hListenerEvent[0] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "listenerEvent"); - hListenerEvent[1] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "listenerStdErrEvent"); + hListenerEvent[0] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerEvent")); + hListenerEvent[1] = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); ::WaitForSingleObject(_hProcess, INFINITE); ::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE); @@ -293,7 +294,7 @@ void Process::waitForProcessEnd() _bProcessEnd = TRUE; } -void Process::error(const char *txt2display, BOOL & returnCode, int errCode) +void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode) { systemMessage(txt2display); returnCode = FALSE; diff --git a/PowerEditor/src/MISC/Process/Process.h b/PowerEditor/src/MISC/Process/Process.h index 2d35cf1c..8d5a520c 100644 --- a/PowerEditor/src/MISC/Process/Process.h +++ b/PowerEditor/src/MISC/Process/Process.h @@ -28,13 +28,13 @@ class Process { public: Process(progType pt = WIN32_PROG) : _type(pt) {}; - Process(const char *cmd, const char *args, const char *cDir, progType pt = WIN32_PROG) - : _type(pt), _stdoutStr(""), _stderrStr(""), _hPipeOutR(NULL), + Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir, progType pt = WIN32_PROG) + : _type(pt), _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL), _hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) { - strcpy(_command, cmd); - strcpy(_args, args); - strcpy(_curDir, cDir); + lstrcpy(_command, cmd); + lstrcpy(_args, args); + lstrcpy(_curDir, cDir); //_pid = id; _bProcessEnd = TRUE; @@ -42,11 +42,11 @@ public: BOOL run(); - const char * getStdout() const { + const TCHAR * getStdout() const { return _stdoutStr.c_str(); }; - const char * getStderr() const { + const TCHAR * getStderr() const { return _stderrStr.c_str(); }; @@ -55,24 +55,24 @@ public: }; bool hasStdout() { - return (_stdoutStr.compare("") != 0); + return (_stdoutStr.compare(TEXT("")) != 0); }; bool hasStderr() { - return (_stderrStr.compare("") != 0); + return (_stderrStr.compare(TEXT("")) != 0); }; protected: progType _type; // LES ENTREES - char _command[MAX_PATH]; - char _args[MAX_PATH]; - char _curDir[MAX_PATH]; + TCHAR _command[MAX_PATH]; + TCHAR _args[MAX_PATH]; + TCHAR _curDir[MAX_PATH]; // LES SORTIES - string _stdoutStr; - string _stderrStr; + basic_string _stdoutStr; + basic_string _stderrStr; int _exitCode; // LES HANDLES @@ -102,7 +102,7 @@ protected: void listenerStdErr(); void waitForProcessEnd(); - void error(const char *txt2display, BOOL & returnCode, int errCode); + void error(const TCHAR *txt2display, BOOL & returnCode, int errCode); }; #endif //PROCESSUS_H diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp index 8d8e6a80..60c7f148 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.cpp +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.cpp @@ -19,25 +19,26 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #include "regExtDlg.h" #include "resource.h" +#include "SysMsg.h" -const char *nppName = "Notepad++_file"; -const char *nppBackup = "Notepad++_backup"; -const char *nppDoc = "Notepad++ Document"; +const TCHAR *nppName = TEXT("Notepad++_file"); +const TCHAR *nppBackup = TEXT("Notepad++_backup"); +const TCHAR *nppDoc = TEXT("Notepad++ Document"); const int nbSupportedLang = 9; const int nbExtMax = 10; const int extNameMax = 18; -char defExtArray[nbSupportedLang][nbExtMax][extNameMax] = { - {"Notepad", ".txt", ".log", ".ini"}, - {"c, c++, objc", ".h", ".hpp", ".hxx", ".c", ".cpp", ".cxx", ".cc", ".m"}, - {"java, c#, pascal", ".java", ".cs", ".pas", ".inc"}, - {"web(html) script", ".html", ".htm", ".php", ".phtml", ".js", ".jsp", ".asp", ".css", ".xml"}, - {"public script", ".sh", ".bsh", ".nsi", ".nsh", ".lua", ".pl", ".pm", ".py"}, - {"property script", ".rc", ".as", ".mx", ".vb", ".vbs"}, - {"fortran, TeX, SQL", ".f", ".for", ".f90", ".f95", ".f2k", ".tex", ".sql"}, - {"misc", ".nfo", ".mak"}, - {"customize"} +TCHAR defExtArray[nbSupportedLang][nbExtMax][extNameMax] = { + {TEXT("Notepad"), TEXT(".txt"), TEXT(".log"), TEXT(".ini")}, + {TEXT("c, c++, objc"), TEXT(".h"), TEXT(".hpp"), TEXT(".hxx"), TEXT(".c"), TEXT(".cpp"), TEXT(".cxx"), TEXT(".cc"), TEXT(".m")}, + {TEXT("java, c#, pascal"), TEXT(".java"), TEXT(".cs"), TEXT(".pas"), TEXT(".inc")}, + {TEXT("web(html) script"), TEXT(".html"), TEXT(".htm"), TEXT(".php"), TEXT(".phtml"), TEXT(".js"), TEXT(".jsp"), TEXT(".asp"), TEXT(".css"), TEXT(".xml")}, + {TEXT("public script"), TEXT(".sh"), TEXT(".bsh"), TEXT(".nsi"), TEXT(".nsh"), TEXT(".lua"), TEXT(".pl"), TEXT(".pm"), TEXT(".py")}, + {TEXT("property script"), TEXT(".rc"), TEXT(".as"), TEXT(".mx"), TEXT(".vb"), TEXT(".vbs")}, + {TEXT("fortran, TeX, SQL"), TEXT(".f"), TEXT(".for"), TEXT(".f90"), TEXT(".f95"), TEXT(".f2k"), TEXT(".tex"), TEXT(".sql")}, + {TEXT("misc"), TEXT(".nfo"), TEXT(".mak")}, + {TEXT("customize")} }; void RegExtDlg::doDialog(bool isRTL) @@ -85,7 +86,7 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) case IDC_ADDFROMLANGEXT_BUTTON : { //int index2Add; - char ext2Add[extNameMax] = ""; + TCHAR ext2Add[extNameMax] = TEXT(""); if (!_isCustomize) { int index2Add = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCURSEL, 0, 0); @@ -100,7 +101,7 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) if (i != LB_ERR) return TRUE; addExt(ext2Add); - ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)""); + ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)TEXT("")); } ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)ext2Add); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false); @@ -109,7 +110,7 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) case IDC_REMOVEEXT_BUTTON : { - char ext2Sup[extNameMax] = ""; + TCHAR ext2Sup[extNameMax] = TEXT(""); int index2Sup = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETCURSEL, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_GETTEXT, index2Sup, (LPARAM)ext2Sup); if (deleteExts(ext2Sup)) @@ -122,7 +123,7 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { for (int i = 1 ; i < nbExtMax ; i++) { - if (!stricmp(ext2Sup, defExtArray[langIndex][i])) + if (!generic_stricmp(ext2Sup, defExtArray[langIndex][i])) { ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)ext2Sup); return TRUE; @@ -140,9 +141,9 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) if (HIWORD(wParam) == EN_CHANGE) { - char text[extNameMax] = ""; + TCHAR text[extNameMax] = TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text); - if ((strlen(text) == 1) && (text[0] != '.')) + if ((lstrlen(text) == 1) && (text[0] != '.')) { text[1] = text[0]; text[0] = '.'; @@ -150,7 +151,7 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)text); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETSEL, 2, 2); } - ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), (strlen(text) > 1)); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), (lstrlen(text) > 1)); return TRUE; } @@ -161,10 +162,10 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { if (i != LB_ERR) { - char itemName[32]; + TCHAR itemName[32]; ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETTEXT, i, (LPARAM)itemName); - if (!stricmp(defExtArray[nbSupportedLang-1][0], itemName)) + if (!generic_stricmp(defExtArray[nbSupportedLang-1][0], itemName)) { ::ShowWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANGEXT_LIST), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMEXT_EDIT), SW_SHOW); @@ -184,7 +185,7 @@ BOOL CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0); for (int j = 1 ; j < nbExtMax ; j++) - if (strcmp("", defExtArray[i][j])) + if (lstrcmp(TEXT(""), defExtArray[i][j])) { int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]); if (index == -1) @@ -221,22 +222,22 @@ void RegExtDlg::getRegisteredExts() int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT); for (int i = 0 ; i < nbRegisteredKey ; i++) { - char extName[extNameLen]; + TCHAR extName[extNameLen]; //FILETIME fileTime; int extNameActualLen = extNameLen; int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, NULL, NULL, NULL, NULL); if ((res == ERROR_SUCCESS) && (extName[0] == '.')) { - //char valName[extNameLen]; - char valData[extNameLen]; + //TCHAR valName[extNameLen]; + TCHAR valData[extNameLen]; int valDataLen = extNameLen; int valType; HKEY hKey2Check; extNameActualLen = extNameLen; ::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check); - ::RegQueryValueEx(hKey2Check, "", NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); + ::RegQueryValueEx(hKey2Check, TEXT(""), NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); //::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); - if ((valType == REG_SZ) && (!strcmp(valData, nppName))) + if ((valType == REG_SZ) && (!lstrcmp(valData, nppName))) ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName); ::RegCloseKey(hKey2Check); } @@ -250,7 +251,7 @@ void RegExtDlg::getDefSupportedExts() } -void RegExtDlg::addExt(char *ext) +void RegExtDlg::addExt(TCHAR *ext) { HKEY hKey; DWORD dwDisp; @@ -269,22 +270,22 @@ void RegExtDlg::addExt(char *ext) if (nRet == ERROR_SUCCESS) { int valDataLen = 256; - char valData[256]; + TCHAR valData[256]; if (dwDisp == REG_OPENED_EXISTING_KEY) { - int res = ::RegQueryValueEx(hKey, "", NULL, NULL, (LPBYTE)valData, (LPDWORD)&valDataLen); + int res = ::RegQueryValueEx(hKey, TEXT(""), NULL, NULL, (LPBYTE)valData, (LPDWORD)&valDataLen); if (res == ERROR_SUCCESS) ::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen+1); } - ::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppName, strlen(nppName)+1); + ::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppName, lstrlen(nppName)+1); ::RegCloseKey(hKey); } } -bool RegExtDlg::deleteExts(const char *ext2Delete) +bool RegExtDlg::deleteExts(const TCHAR *ext2Delete) { HKEY hKey; ::RegOpenKeyEx(HKEY_CLASSES_ROOT, ext2Delete, 0, KEY_ALL_ACCESS, &hKey); @@ -294,13 +295,13 @@ bool RegExtDlg::deleteExts(const char *ext2Delete) if ((nbValue <= 1) && (!nbSubkey)) { - char subKey[32] = "\\"; - strcat(subKey, ext2Delete); + TCHAR subKey[32] = TEXT("\\"); + lstrcat(subKey, ext2Delete); ::RegDeleteKey(HKEY_CLASSES_ROOT, subKey); } else { - char valData[extNameLen]; + TCHAR valData[extNameLen]; int valDataLen = extNameLen; int valType; int res = ::RegQueryValueEx(hKey, nppBackup, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); @@ -322,8 +323,8 @@ void RegExtDlg::writeNppPath() HKEY hKey, hRootKey; DWORD dwDisp; long nRet; - char regStr[MAX_PATH] = ""; - strcat(strcat(regStr, nppName), "\\shell\\open\\command"); + TCHAR regStr[MAX_PATH] = TEXT(""); + lstrcat(lstrcat(regStr, nppName), TEXT("\\shell\\open\\command")); nRet = ::RegCreateKeyEx( HKEY_CLASSES_ROOT, @@ -343,15 +344,15 @@ void RegExtDlg::writeNppPath() { // Write the value for new document ::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey); - ::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, strlen(nppDoc)+1); + ::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, lstrlen(nppDoc)+1); - char nppPath[MAX_PATH]; + TCHAR nppPath[MAX_PATH]; ::GetModuleFileName(_hInst, nppPath, MAX_PATH); - char nppPathParam[256] = "\""; - strcat(strcat(nppPathParam, nppPath), "\" \"%1\""); + TCHAR nppPathParam[256] = TEXT("\""); + lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\"")); - ::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, strlen(nppPathParam)+1); + ::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, lstrlen(nppPathParam)+1); } RegCloseKey(hKey); } diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.h b/PowerEditor/src/MISC/RegExt/regExtDlg.h index b2acbf32..11bc30db 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.h +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.h @@ -40,8 +40,8 @@ private : void getRegisteredExts(); void getDefSupportedExts(); - void addExt(char *ext); - bool deleteExts(const char *ext2Delete); + void addExt(TCHAR *ext); + bool deleteExts(const TCHAR *ext2Delete); void writeNppPath(); int getNbSubKey(HKEY hKey) const { diff --git a/PowerEditor/src/MISC/RegExt/regExtDlg.rc b/PowerEditor/src/MISC/RegExt/regExtDlg.rc index 92a7ee45..fc3b653e 100644 --- a/PowerEditor/src/MISC/RegExt/regExtDlg.rc +++ b/PowerEditor/src/MISC/RegExt/regExtDlg.rc @@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. IDD_REGEXT_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN LISTBOX IDC_REGEXT_LANGEXT_LIST,141,31,29,122,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP LISTBOX IDC_REGEXT_REGISTEREDEXTS_LIST,211,30,48,123,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP diff --git a/PowerEditor/src/MISC/SysMsg/SysMsg.cpp b/PowerEditor/src/MISC/SysMsg/SysMsg.cpp index d49188ed..47ecb6cd 100644 --- a/PowerEditor/src/MISC/SysMsg/SysMsg.cpp +++ b/PowerEditor/src/MISC/SysMsg/SysMsg.cpp @@ -19,7 +19,9 @@ #include #include -void systemMessage(const char *title) +WcharMbcsConvertor * WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor; + +void systemMessage(const TCHAR *title) { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -35,21 +37,21 @@ void systemMessage(const char *title) void printInt(int int2print) { - char str[32]; - sprintf(str, "%d", int2print); - ::MessageBox(NULL, str, "", MB_OK); + TCHAR str[32]; + wsprintf(str, TEXT("%d"), int2print); + ::MessageBox(NULL, str, TEXT(""), MB_OK); } -void printStr(const char *str2print) +void printStr(const TCHAR *str2print) { - ::MessageBox(NULL, str2print, "", MB_OK); + ::MessageBox(NULL, str2print, TEXT(""), MB_OK); } -void writeLog(const char *logFileName, const char *log2write) +void writeLog(const TCHAR *logFileName, const TCHAR *log2write) { - FILE *f = fopen(logFileName, "a+"); - const char * ptr = log2write; - fwrite(log2write, sizeof(log2write[0]), strlen(log2write), f); + FILE *f = generic_fopen(logFileName, TEXT("a+")); + const TCHAR * ptr = log2write; + fwrite(log2write, sizeof(log2write[0]), lstrlen(log2write), f); fputc('\n', f); fflush(f); fclose(f); @@ -63,11 +65,55 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep) return EXCEPTION_CONTINUE_SEARCH; } -std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand) +int getCpFromStringValue(const TCHAR * encodingStr) { - char cleanedName[64] = ""; + if (!encodingStr) + return CP_ACP; + + if (generic_stricmp(TEXT("windows-1250"), encodingStr) == 0) + return 1250; + if (generic_stricmp(TEXT("windows-1251"), encodingStr) == 0) + return 1251; + if (generic_stricmp(TEXT("windows-1252"), encodingStr) == 0) + return 1252; + if (generic_stricmp(TEXT("windows-1253"), encodingStr) == 0) + return 1253; + if (generic_stricmp(TEXT("windows-1254"), encodingStr) == 0) + return 1254; + if (generic_stricmp(TEXT("windows-1255"), encodingStr) == 0) + return 1255; + if (generic_stricmp(TEXT("windows-1256"), encodingStr) == 0) + return 1256; + if (generic_stricmp(TEXT("windows-1257"), encodingStr) == 0) + return 1257; + if (generic_stricmp(TEXT("windows-1258"), encodingStr) == 0) + return 1258; + + if (generic_stricmp(TEXT("big5"), encodingStr) == 0) + return 950; + if (generic_stricmp(TEXT("gb2312"), encodingStr) == 0) + return 936; + if (generic_stricmp(TEXT("shift_jis"), encodingStr) == 0) + return 936; + if (generic_stricmp(TEXT("euc-kr"), encodingStr) == 0) + return 936; + if (generic_stricmp(TEXT("tis-620"), encodingStr) == 0) + return 874; + + if (generic_stricmp(TEXT("iso-8859-8"), encodingStr) == 0) + return 28598; + + if (generic_stricmp(TEXT("utf-8"), encodingStr) == 0) + return 65001; + + return CP_ACP; +} + +std::basic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand) +{ + TCHAR cleanedName[64] = TEXT(""); size_t j = 0; - size_t menuNameLen = strlen(menuItemStr); + size_t menuNameLen = lstrlen(menuItemStr); for(size_t k = 0 ; k < menuNameLen ; k++) { if (menuItemStr[k] == '\t') @@ -88,4 +134,80 @@ std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand) } cleanedName[j] = 0; return cleanedName; -}; \ No newline at end of file +}; + +const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage) +{ + if (!_wideCharStr) + { + _wideCharStr = new wchar_t[initSize]; + _wideCharAllocLen = initSize; + } + + int len = MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, 0); + if (len > 0) + { + if (len > int(_wideCharAllocLen)) + { + delete [] _wideCharStr; + _wideCharAllocLen = len; + _wideCharStr = new wchar_t[_wideCharAllocLen]; + } + MultiByteToWideChar(codepage, 0, mbcs2Convert, -1, _wideCharStr, len); + } + else + _wideCharStr[0] = 0; + + return _wideCharStr; +} + +const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage) +{ + if (!_multiByteStr) + { + _multiByteStr = new char[initSize]; + _multiByteAllocLen = initSize; + } + + int len = WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, 0, NULL, NULL); + if (len > 0) + { + if (len > int(_multiByteAllocLen)) + { + delete [] _multiByteStr; + _multiByteAllocLen = len; + _multiByteStr = new char[_multiByteAllocLen]; + } + WideCharToMultiByte(codepage, 0, wcharStr2Convert, -1, _multiByteStr, len, NULL, NULL); + } + else + _multiByteStr[0] = 0; + + return _multiByteStr; +} + +std::wstring string2wstring(const std::string & rString, UINT codepage) +{ + int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0); + if(len > 0) + { + std::vector vw(len); + MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len); + return &vw[0]; + } + else + return L""; +} + +std::string wstring2string(const std::wstring & rwString, UINT codepage) +{ + int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL); + if(len > 0) + { + std::vector vw(len); + WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL); + return &vw[0]; + } + else + return ""; +} diff --git a/PowerEditor/src/MISC/SysMsg/SysMsg.h b/PowerEditor/src/MISC/SysMsg/SysMsg.h index 93538568..22b126d0 100644 --- a/PowerEditor/src/MISC/SysMsg/SysMsg.h +++ b/PowerEditor/src/MISC/SysMsg/SysMsg.h @@ -20,14 +20,92 @@ #include #include +#include +#include -void systemMessage(const char *title); +void systemMessage(const TCHAR *title); //DWORD ShortToLongPathName(LPCTSTR lpszShortPath, LPTSTR lpszLongPath, DWORD cchBuffer); void printInt(int int2print); -void printStr(const char *str2print); -void writeLog(const char *logFileName, const char *log2write); +void printStr(const TCHAR *str2print); +void writeLog(const TCHAR *logFileName, const TCHAR *log2write); int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep); +int getCpFromStringValue(const TCHAR * encodingStr); +std::basic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand = false); + +#define CP_ANSI_LATIN_1 1252 +#define CP_BIG5 950 + +#ifdef UNICODE + #define NppMainEntry wWinMain + #define generic_strtol wcstol + #define generic_strncpy wcsncpy + #define generic_stricmp wcsicmp + #define generic_strncmp wcsncmp + #define generic_strnicmp wcsnicmp + #define generic_strncat wcsncat + #define generic_strchr wcschr + #define generic_atoi _wtoi + #define generic_atof _wtof + #define generic_strtok wcstok + #define generic_strftime wcsftime + #define generic_fprintf fwprintf + #define generic_sscanf swscanf + #define generic_fopen _wfopen + #define generic_fgets fgetws + #define generic_stat _wstat + #define COPYDATA_FILENAMES COPYDATA_FILENAMESW +#else + #define NppMainEntry WinMain + #define generic_strtol strtol + #define generic_strncpy strncpy + #define generic_stricmp stricmp + #define generic_strncmp strncmp + #define generic_strnicmp strnicmp + #define generic_strncat strncat + #define generic_strchr strchr + #define generic_atoi atoi + #define generic_atof atof + #define generic_strtok strtok + #define generic_strftime strftime + #define generic_fprintf fprintf + #define generic_sscanf sscanf + #define generic_fopen fopen + #define generic_fgets fgets + #define generic_stat _stat + #define COPYDATA_FILENAMES COPYDATA_FILENAMESA +#endif + +//void char2wchar(const char* pszCHAR, wchar_t* pszWCHAR, UINT codepage); +//void wchar2char(const wchar_t* pszWCHAR, char* pszCHAR, UINT codepage); +std::wstring string2wstring(const std::string & rString, UINT codepage); +std::string wstring2string(const std::wstring & rwString, UINT codepage); + + +class WcharMbcsConvertor { +public: + static WcharMbcsConvertor * getInstance() {return _pSelf;}; + static void destroyInstance() {delete _pSelf;}; + + const wchar_t * char2wchar(const char* mbStr, UINT codepage); + const char * wchar2char(const wchar_t* wcStr, UINT codepage); + +protected: + WcharMbcsConvertor() : _multiByteStr(NULL), _wideCharStr(NULL), _multiByteAllocLen(0), _wideCharAllocLen(0), initSize(1024) {}; + ~WcharMbcsConvertor() { + if (_multiByteStr) + delete [] _multiByteStr; + if (_wideCharStr) + delete [] _wideCharStr; + }; + static WcharMbcsConvertor * _pSelf; + + const int initSize; + char *_multiByteStr; + size_t _multiByteAllocLen; + wchar_t *_wideCharStr; + size_t _wideCharAllocLen; + +}; -std::string purgeMenuItemString(const char * menuItemStr, bool keepAmpersand = false); #endif //M30_IDE_COMMUN_H diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index d58546ec..1a0b1fbe 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -37,14 +37,11 @@ #include "preferenceDlg.h" #include "TaskListDlg.h" #include "xpm_icons.h" -#include #include #include "xmlMatchedTagsHighlighter.h" -#include "UniConversion.h" -const char Notepad_plus::_className[32] = NOTEPAD_PP_CLASS_NAME; -const wchar_t Notepad_plus::_classNameW[32] = NOTEPAD_PP_CLASS_NAME_W; -const char *urlHttpRE = "http://[a-z0-9_\\-\\+.:?&@=/%#]*"; +const TCHAR Notepad_plus::_className[32] = TEXT("Notepad++"); +const char *urlHttpRegExpr = "http://[a-z0-9_\\-\\+.:?&@=/%#]*"; int docTabIconIDs[] = {IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON}; enum tb_stat {tb_saved, tb_unsaved, tb_ro}; @@ -75,7 +72,8 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p _pMainSplitter(NULL), _isfullScreen(false), _recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _isRTL(false), _linkTriggered(true), _isDocModifing(false), _isHotspotDblClicked(false), _sysMenuEntering(false), - _autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg) + _autoCompleteMain(&_mainEditView), _autoCompleteSub(&_subEditView), _smartHighlighter(&_findReplaceDlg), + _nativeLangEncoding(CP_ACP) { ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange)); @@ -85,16 +83,24 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p TiXmlDocument *nativeLangDocRoot = (NppParameters::getInstance())->getNativeLang(); if (nativeLangDocRoot) { - _nativeLang = nativeLangDocRoot->FirstChild("NotepadPlus"); + _nativeLang = nativeLangDocRoot->FirstChild(TEXT("NotepadPlus")); if (_nativeLang) { - _nativeLang = _nativeLang->FirstChild("Native-Langue"); + _nativeLang = _nativeLang->FirstChild(TEXT("Native-Langue")); if (_nativeLang) { TiXmlElement *element = _nativeLang->ToElement(); - const char *rtl = element->Attribute("RTL"); + const TCHAR *rtl = element->Attribute(TEXT("RTL")); if (rtl) - _isRTL = (strcmp(rtl, "yes") == 0); + _isRTL = (lstrcmp(rtl, TEXT("yes")) == 0); + + // get encoding + TiXmlDeclaration *declaration = _nativeLang->GetDocument()->FirstChild()->ToDeclaration(); + if (declaration) + { + const TCHAR * encodingStr = declaration->Encoding(); + _nativeLangEncoding = getCpFromStringValue(encodingStr); + } } } } @@ -104,59 +110,59 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p TiXmlDocument *toolIconsDocRoot = (NppParameters::getInstance())->getToolIcons(); if (toolIconsDocRoot) { - _toolIcons = toolIconsDocRoot->FirstChild("NotepadPlus"); + _toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus")); if (_toolIcons) { - if ((_toolIcons = _toolIcons->FirstChild("ToolBarIcons"))) + if ((_toolIcons = _toolIcons->FirstChild(TEXT("ToolBarIcons")))) { - if ((_toolIcons = _toolIcons->FirstChild("Theme"))) + if ((_toolIcons = _toolIcons->FirstChild(TEXT("Theme")))) { - const char *themeDir = (_toolIcons->ToElement())->Attribute("pathPrefix"); + const TCHAR *themeDir = (_toolIcons->ToElement())->Attribute(TEXT("pathPrefix")); - for (TiXmlNode *childNode = _toolIcons->FirstChildElement("Icon"); + for (TiXmlNode *childNode = _toolIcons->FirstChildElement(TEXT("Icon")); childNode ; - childNode = childNode->NextSibling("Icon") ) + childNode = childNode->NextSibling(TEXT("Icon"))) { int iIcon; - const char *res = (childNode->ToElement())->Attribute("id", &iIcon); + const TCHAR *res = (childNode->ToElement())->Attribute(TEXT("id"), &iIcon); if (res) { - TiXmlNode *grandChildNode = childNode->FirstChildElement("normal"); + TiXmlNode *grandChildNode = childNode->FirstChildElement(TEXT("normal")); if (grandChildNode) { TiXmlNode *valueNode = grandChildNode->FirstChild(); //putain, enfin!!! if (valueNode) { - string locator = themeDir?themeDir:""; + basic_string locator = themeDir?themeDir:TEXT(""); locator += valueNode->Value(); _customIconVect.push_back(iconLocator(0, iIcon, locator)); } } - grandChildNode = childNode->FirstChildElement("hover"); + grandChildNode = childNode->FirstChildElement(TEXT("hover")); if (grandChildNode) { TiXmlNode *valueNode = grandChildNode->FirstChild(); //putain, enfin!!! if (valueNode) { - string locator = themeDir?themeDir:""; + basic_string locator = themeDir?themeDir:TEXT(""); locator += valueNode->Value(); _customIconVect.push_back(iconLocator(1, iIcon, locator)); } } - grandChildNode = childNode->FirstChildElement("disabled"); + grandChildNode = childNode->FirstChildElement(TEXT("disabled")); if (grandChildNode) { TiXmlNode *valueNode = grandChildNode->FirstChild(); //putain, enfin!!! if (valueNode) { - string locator = themeDir?themeDir:""; + basic_string locator = themeDir?themeDir:TEXT(""); locator += valueNode->Value(); _customIconVect.push_back(iconLocator(2, iIcon, locator)); @@ -180,14 +186,15 @@ Notepad_plus::~Notepad_plus() { (NppParameters::getInstance())->destroyInstance(); MainFileManager->destroyInstance(); + (WcharMbcsConvertor::getInstance())->destroyInstance(); if (_pTrayIco) delete _pTrayIco; } -void Notepad_plus::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, CmdLineParams *cmdLineParams) +void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdLineParams *cmdLineParams) { Window::init(hInst, parent); - WNDCLASSW nppClass; + WNDCLASS nppClass; nppClass.style = CS_BYTEALIGNWINDOW | CS_DBLCLKS;//CS_HREDRAW | CS_VREDRAW; nppClass.lpfnWndProc = Notepad_plus_Proc; @@ -197,12 +204,12 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, Cm nppClass.hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)); nppClass.hCursor = ::LoadCursor(NULL, IDC_ARROW); nppClass.hbrBackground = ::CreateSolidBrush(::GetSysColor(COLOR_MENU)); - nppClass.lpszMenuName = MAKEINTRESOURCEW(IDR_M30_MENU); - nppClass.lpszClassName = _classNameW; + nppClass.lpszMenuName = MAKEINTRESOURCE(IDR_M30_MENU); + nppClass.lpszClassName = _className; - if (!::RegisterClassW(&nppClass)) + if (!::RegisterClass(&nppClass)) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(98); } @@ -214,10 +221,10 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, Cm if (cmdLineParams->_isNoPlugin) _pluginsManager.disable(); - _hSelf = ::CreateWindowExW( + _hSelf = ::CreateWindowEx( WS_EX_ACCEPTFILES | (_isRTL?WS_EX_LAYOUTRTL:0),\ - _classNameW,\ - L"Notepad++",\ + _className,\ + TEXT("Notepad++"),\ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,\ // CreateWindowEx bug : set all 0 to walk arround the pb 0, 0, 0, 0,\ @@ -230,7 +237,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdLine, Cm if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(777); } @@ -422,7 +429,7 @@ void Notepad_plus::saveDockingParams() } // add the missing information and store it in nppGUI - unsigned char floatContArray[50]; + UCHAR floatContArray[50]; memset(floatContArray, 0, 50); for (size_t i = 0 ; i < nppGUI._dockingData._pluginDockInfo.size() ; i++) @@ -474,17 +481,13 @@ bool Notepad_plus::loadSession(Session & session) switchEditViewTo(MAIN_VIEW); //open files in main for ( ; i < session.nbMainFiles() ; ) { - const char *pFn = session._mainViewFiles[i]._fileName.c_str(); + const TCHAR *pFn = session._mainViewFiles[i]._fileName.c_str(); if (isFileSession(pFn)) { vector::iterator posIt = session._mainViewFiles.begin() + i; session._mainViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions } - - wchar_t fnW[MAX_PATH]; - char2wchar(pFn, fnW); - - if (PathFileExistsW(fnW)) { + if (PathFileExists(pFn)) { lastOpened = doOpen(pFn); } else { lastOpened = BUFFER_INVALID; @@ -492,10 +495,10 @@ bool Notepad_plus::loadSession(Session & session) if (lastOpened != BUFFER_INVALID) { showView(MAIN_VIEW); - const char *pLn = session._mainViewFiles[i]._langName.c_str(); + const TCHAR *pLn = session._mainViewFiles[i]._langName.c_str(); int id = getLangFromMenuName(pLn); LangType typeToSet = L_TXT; - if (id != 0 && strcmp(pLn, "User Defined") != 0) + if (id != 0 && lstrcmp(pLn, TEXT("User Defined")) != 0) typeToSet = menuID2LangType(id); Buffer * buf = MainFileManager->getBufferByID(lastOpened); @@ -525,17 +528,13 @@ bool Notepad_plus::loadSession(Session & session) switchEditViewTo(SUB_VIEW); //open files in sub for ( ; k < session.nbSubFiles() ; ) { - const char *pFn = session._subViewFiles[k]._fileName.c_str(); + const TCHAR *pFn = session._subViewFiles[k]._fileName.c_str(); if (isFileSession(pFn)) { vector::iterator posIt = session._subViewFiles.begin() + k; session._subViewFiles.erase(posIt); continue; //skip session files, not supporting recursive sessions } - - wchar_t fnW[MAX_PATH]; - char2wchar(pFn, fnW); - - if (PathFileExistsW(fnW)) { + if (PathFileExists(pFn)) { lastOpened = doOpen(pFn); //check if already open in main. If so, clone if (_mainDocTab.getIndexByBuffer(lastOpened) != -1) { @@ -549,7 +548,7 @@ bool Notepad_plus::loadSession(Session & session) showView(SUB_VIEW); if (canHideView(MAIN_VIEW)) hideView(MAIN_VIEW); - const char *pLn = session._subViewFiles[k]._langName.c_str(); + const TCHAR *pLn = session._subViewFiles[k]._langName.c_str(); int id = getLangFromMenuName(pLn); LangType typeToSet = L_TXT; if (id != 0) @@ -558,8 +557,8 @@ bool Notepad_plus::loadSession(Session & session) Buffer * buf = MainFileManager->getBufferByID(lastOpened); buf->setPosition(session._subViewFiles[k], &_subEditView); if (typeToSet == L_USER) { - if (!strcmp(pLn, "User Defined")) { - pLn = ""; //default user defined + if (!lstrcmp(pLn, TEXT("User Defined"))) { + pLn = TEXT(""); //default user defined } } buf->setLangType(typeToSet, pLn); @@ -605,9 +604,9 @@ bool Notepad_plus::loadSession(Session & session) return allSessionFilesLoaded; } -BufferID Notepad_plus::doOpen(const char *fileName, bool isReadOnly) +BufferID Notepad_plus::doOpen(const TCHAR *fileName, bool isReadOnly) { - char longFileName[MAX_PATH]; + TCHAR longFileName[MAX_PATH]; ::GetFullPathName(fileName, MAX_PATH, longFileName, NULL); ::GetLongPathName(longFileName, longFileName, MAX_PATH); @@ -630,32 +629,29 @@ BufferID Notepad_plus::doOpen(const char *fileName, bool isReadOnly) return test; } - WCHAR longFileNameW[MAX_PATH]; - char2wchar(longFileName, longFileNameW); - - if (isFileSession(longFileName) && PathFileExistsW(longFileNameW)) { + if (isFileSession(longFileName) && PathFileExists(longFileName)) { fileLoadSession(longFileName); return BUFFER_INVALID; } - if (!PathFileExistsW(longFileNameW)) + if (!PathFileExists(longFileName)) { - wchar_t str2display[MAX_PATH*2]; - WCHAR longFileDir[MAX_PATH]; + TCHAR str2display[MAX_PATH*2]; + TCHAR longFileDir[MAX_PATH]; - wcscpy(longFileDir, longFileNameW); - PathRemoveFileSpecW(longFileDir); + lstrcpy(longFileDir, longFileName); + PathRemoveFileSpec(longFileDir); - if (PathFileExistsW(longFileDir)) + if (PathFileExists(longFileDir)) { - swprintf(str2display, L"%s doesn't exist. Create it?", longFileNameW); + wsprintf(str2display, TEXT("%s doesn't exist. Create it?"), longFileName); - if (::MessageBoxW(_hSelf, str2display, L"Create new file", MB_YESNO) == IDYES) + if (::MessageBox(_hSelf, str2display, TEXT("Create new file"), MB_YESNO) == IDYES) { bool res = MainFileManager->createEmptyFile(longFileName); if (!res) { - swprintf(str2display, L"Cannot create the file \"%s\"", longFileNameW); - ::MessageBoxW(_hSelf, str2display, L"Create new file", MB_OK); + wsprintf(str2display, TEXT("Cannot create the file \"%s\""), longFileName); + ::MessageBox(_hSelf, str2display, TEXT("Create new file"), MB_OK); return BUFFER_INVALID; } } @@ -709,17 +705,18 @@ BufferID Notepad_plus::doOpen(const char *fileName, bool isReadOnly) } else { - char msg[MAX_PATH + 100]; - strcpy(msg, "Can not open file \""); - //strcat(msg, fullPath); - strcat(msg, longFileName); - strcat(msg, "\"."); - ::MessageBox(_hSelf, msg, "ERR", MB_OK); + TCHAR msg[MAX_PATH + 100]; + lstrcpy(msg, TEXT("Can not open file \"")); + //lstrcat(msg, fullPath); + lstrcat(msg, longFileName); + lstrcat(msg, TEXT("\".")); + ::MessageBox(_hSelf, msg, TEXT("ERR"), MB_OK); return BUFFER_INVALID; } } bool Notepad_plus::doReload(BufferID id, bool alert) { + /* //No activation when reloading, defer untill document is actually visible if (alert) { @@ -728,7 +725,7 @@ bool Notepad_plus::doReload(BufferID id, bool alert) */ if (alert) { - if (::MessageBox(_hSelf, "Do you want to reload the current file?", "Reload", MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL) != IDYES) + if (::MessageBox(_hSelf, TEXT("Do you want to reload the current file?"), TEXT("Reload"), MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL) != IDYES) return false; } @@ -762,7 +759,7 @@ bool Notepad_plus::doReload(BufferID id, bool alert) return res; } -bool Notepad_plus::doSave(BufferID id, const char * filename, bool isCopy) +bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy) { SCNotification scnN; // Notify plugins that current file is about to be saved @@ -784,7 +781,7 @@ bool Notepad_plus::doSave(BufferID id, const char * filename, bool isCopy) } if (!res) - ::MessageBox(_hSelf, "Please check whether if this file is opened in another program", "Save failed", MB_OK); + ::MessageBox(_hSelf, TEXT("Please check whether if this file is opened in another program"), TEXT("Save failed"), MB_OK); return res; } @@ -799,7 +796,7 @@ void Notepad_plus::doClose(BufferID id, int whichOne) { _pluginsManager.notify(&scnN); //add to recent files if its an existing file - if (!buf->isUntitled() && PathFileExistsW(buf->getFilePathW())) + if (!buf->isUntitled() && PathFileExists(buf->getFilePath())) { _lastRecentFileList.add(buf->getFilePath()); } @@ -832,10 +829,10 @@ bool Notepad_plus::fileReload() return doReload(buf, true); } -string exts2Filters(string exts) { - const char *extStr = exts.c_str(); - char aExt[MAX_PATH]; - string filters(""); +basic_string exts2Filters(basic_string exts) { + const TCHAR *extStr = exts.c_str(); + TCHAR aExt[MAX_PATH]; + basic_string filters(TEXT("")); int j = 0; bool stop = false; @@ -850,9 +847,9 @@ string exts2Filters(string exts) { if (aExt[0]) { - filters += "*."; + filters += TEXT("*."); filters += aExt; - filters += ";"; + filters += TEXT(";"); } j = 0; } @@ -870,9 +867,9 @@ string exts2Filters(string exts) { aExt[j] = '\0'; if (aExt[0]) { - filters += "*."; + filters += TEXT("*."); filters += aExt; - filters += ";"; + filters += TEXT(";"); } } @@ -907,27 +904,27 @@ void Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg) if (!inExcludedList) { - const char *defList = l->getDefaultExtList(); - const char *userList = NULL; + const TCHAR *defList = l->getDefaultExtList(); + const TCHAR *userList = NULL; LexerStylerArray &lsa = (NppParameters::getInstance())->getLStylerArray(); - const char *lName = l->getLangName(); + const TCHAR *lName = l->getLangName(); LexerStyler *pLS = lsa.getLexerStylerByName(lName); if (pLS) userList = pLS->getLexerUserExt(); - std::string list(""); + std::basic_string list(TEXT("")); if (defList) list += defList; if (userList) { - list += " "; + list += TEXT(" "); list += userList; } - string stringFilters = exts2Filters(list); - const char *filters = stringFilters.c_str(); + basic_string stringFilters = exts2Filters(list); + const TCHAR *filters = stringFilters.c_str(); if (filters[0]) { int nbExt = fDlg.setExtsFilter(getLangDesc(lid, true).c_str(), filters); @@ -940,7 +937,7 @@ void Notepad_plus::setFileOpenSaveDlgFilters(FileDialog & fDlg) void Notepad_plus::fileOpen() { FileDialog fDlg(_hSelf, _hInst); - fDlg.setExtFilter("All types", ".*", NULL); + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); setFileOpenSaveDlgFilters(fDlg); @@ -959,22 +956,22 @@ void Notepad_plus::fileOpen() } } -bool Notepad_plus::isFileSession(const char * filename) { +bool Notepad_plus::isFileSession(const TCHAR * filename) { // if file2open matches the ext of user defined session file ext, then it'll be opened as a session - const char *definedSessionExt = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); + const TCHAR *definedSessionExt = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); if (*definedSessionExt != '\0') { - char fncp[MAX_PATH]; - strcpy(fncp, filename); - char *pExt = PathFindExtension(fncp); - string usrSessionExt = ""; + TCHAR fncp[MAX_PATH]; + lstrcpy(fncp, filename); + TCHAR *pExt = PathFindExtension(fncp); + basic_string usrSessionExt = TEXT(""); if (*definedSessionExt != '.') { - usrSessionExt += "."; + usrSessionExt += TEXT("."); } usrSessionExt += definedSessionExt; - if (!stricmp(pExt, usrSessionExt.c_str())) + if (!generic_stricmp(pExt, usrSessionExt.c_str())) { return true; } @@ -991,7 +988,7 @@ bool Notepad_plus::fileSave(BufferID id) if (!buf->getFileReadOnly() && buf->isDirty()) //cannot save if readonly { - const char *fn = buf->getFilePath(); + const TCHAR *fn = buf->getFilePath(); if (buf->isUntitled()) { return fileSaveAs(id); @@ -1003,32 +1000,32 @@ bool Notepad_plus::fileSave(BufferID id) if (backup == bak_simple) { //copy fn to fn.backup - string fn_bak(fn); + basic_string fn_bak(fn); if ((nppgui._useDir) && (nppgui._backupDir[0] != '\0')) { - char path[MAX_PATH]; - char *name; + TCHAR path[MAX_PATH]; + TCHAR *name; - strcpy(path, fn); + lstrcpy(path, fn); name = ::PathFindFileName(path); fn_bak = nppgui._backupDir; - fn_bak += "\\"; + fn_bak += TEXT("\\"); fn_bak += name; } else { fn_bak = fn; } - fn_bak += ".bak"; + fn_bak += TEXT(".bak"); ::CopyFile(fn, fn_bak.c_str(), FALSE); } else if (backup == bak_verbose) { - char path[MAX_PATH]; - char *name; - string fn_dateTime_bak; + TCHAR path[MAX_PATH]; + TCHAR *name; + basic_string fn_dateTime_bak; - strcpy(path, fn); + lstrcpy(path, fn); name = ::PathFindFileName(path); ::PathRemoveFileSpec(path); @@ -1036,15 +1033,15 @@ bool Notepad_plus::fileSave(BufferID id) if ((nppgui._useDir) && (nppgui._backupDir[0] != '\0')) {//printStr(nppgui._backupDir); fn_dateTime_bak = nppgui._backupDir; - fn_dateTime_bak += "\\"; + fn_dateTime_bak += TEXT("\\"); } else { - const char *bakDir = "nppBackup"; + const TCHAR *bakDir = TEXT("nppBackup"); fn_dateTime_bak = path; - fn_dateTime_bak += "\\"; + fn_dateTime_bak += TEXT("\\"); fn_dateTime_bak += bakDir; - fn_dateTime_bak += "\\"; + fn_dateTime_bak += TEXT("\\"); if (!::PathFileExists(fn_dateTime_bak.c_str())) { @@ -1055,16 +1052,16 @@ bool Notepad_plus::fileSave(BufferID id) fn_dateTime_bak += name; const int temBufLen = 32; - char tmpbuf[temBufLen]; + TCHAR tmpbuf[temBufLen]; time_t ltime = time(0); struct tm *today; today = localtime(<ime); - strftime(tmpbuf, temBufLen, "%Y-%m-%d_%H%M%S", today); + generic_strftime(tmpbuf, temBufLen, TEXT("%Y-%m-%d_%H%M%S"), today); - fn_dateTime_bak += "."; + fn_dateTime_bak += TEXT("."); fn_dateTime_bak += tmpbuf; - fn_dateTime_bak += ".bak"; + fn_dateTime_bak += TEXT(".bak"); ::CopyFile(fn, fn_dateTime_bak.c_str(), FALSE); } @@ -1100,11 +1097,11 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy) FileDialog fDlg(_hSelf, _hInst); - fDlg.setExtFilter("All types", ".*", NULL); + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); setFileOpenSaveDlgFilters(fDlg); fDlg.setDefFileName(buf->getFileName()); - char *pfn = fDlg.doSaveDlg(); + TCHAR *pfn = fDlg.doSaveDlg(); if (pfn) { @@ -1117,7 +1114,7 @@ bool Notepad_plus::fileSaveAs(BufferID id, bool isSaveCopy) } else //cannot save, other view has buffer already open, activate it { - ::MessageBox(_hSelf, "The file is already opened in the Notepad++.", "ERROR", MB_OK | MB_ICONSTOP); + ::MessageBox(_hSelf, TEXT("The file is already opened in the Notepad++."), TEXT("ERROR"), MB_OK | MB_ICONSTOP); switchToFile(other); return false; } @@ -1138,11 +1135,11 @@ bool Notepad_plus::fileRename(BufferID id, int curView) FileDialog fDlg(_hSelf, _hInst); - fDlg.setExtFilter("All types", ".*", NULL); + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); setFileOpenSaveDlgFilters(fDlg); fDlg.setDefFileName(buf->getFileName()); - char *pfn = fDlg.doSaveDlg(); + TCHAR *pfn = fDlg.doSaveDlg(); if (pfn) { @@ -1158,7 +1155,7 @@ bool Notepad_plus::fileDelete(BufferID id, int curView) bufferID = _pEditView->getCurrentBufferID(); Buffer * buf = MainFileManager->getBufferByID(bufferID); - const char *fileNamePath = buf->getFilePath(); + const TCHAR *fileNamePath = buf->getFilePath(); if (PathFileExists(fileNamePath)) return false; @@ -1180,13 +1177,13 @@ bool Notepad_plus::fileDelete(BufferID id, int curView) bufferID = _pEditView->getCurrentBufferID(); Buffer * buf = MainFileManager->getBufferByID(bufferID); - const char *fileNamePath = buf->getFilePath(); + const TCHAR *fileNamePath = buf->getFilePath(); if (doDeleteOrNot(fileNamePath) == IDYES) { if (!MainFileManager->deleteFile(bufferID)) { - ::MessageBox(_hSelf, "Delete File failed", "Delete File", MB_OK); + ::MessageBox(_hSelf, TEXT("Delete File failed"), TEXT("Delete File"), MB_OK); return false; } doClose(bufferID, MAIN_VIEW); @@ -1206,7 +1203,7 @@ bool Notepad_plus::fileClose(BufferID id, int curView) int res; //process the fileNamePath into LRF - const char *fileNamePath = buf->getFilePath(); + const TCHAR *fileNamePath = buf->getFilePath(); if (buf->isDirty()) { @@ -1398,21 +1395,21 @@ bool Notepad_plus::replaceAllFiles() { _invisibleEditView._currentBuffer = oldBuf; _pEditView = pOldView; - char result[64]; + TCHAR result[64]; if (nbTotal < 0) - strcpy(result, "The regular expression to search is formed badly"); + lstrcpy(result, TEXT("The regular expression to search is formed badly")); else { - itoa(nbTotal, result, 10); - strcat(result, " tokens are replaced."); + wsprintf(result, TEXT("%d"), nbTotal); + lstrcat(result, TEXT(" tokens are replaced.")); } - ::MessageBox(_hSelf, result, "", MB_OK); + ::MessageBox(_hSelf, result, TEXT(""), MB_OK); return true; } -bool Notepad_plus::matchInList(const char *fileName, const vector & patterns) +bool Notepad_plus::matchInList(const TCHAR *fileName, const vector> & patterns) { for (size_t i = 0 ; i < patterns.size() ; i++) { @@ -1453,11 +1450,7 @@ void Notepad_plus::doTrimTrailing() i--; if (i < (lineEnd - 1)) - { - _pEditView->execute(SCI_SETTARGETSTART, i + 1); - _pEditView->execute(SCI_SETTARGETEND, lineEnd); - _pEditView->execute(SCI_REPLACETARGET, 0, (LPARAM)""); - } + _pEditView->replaceTarget(TEXT(""), i + 1, lineEnd); } _pEditView->execute(SCI_ENDUNDOACTION); } @@ -1468,14 +1461,13 @@ void Notepad_plus::loadLastSession() loadSession(lastSession); } -void Notepad_plus::getMatchedFileNames(const char *dir, const vector & patterns, vector & fileNames, bool isRecursive, bool isInHiddenDir) +void Notepad_plus::getMatchedFileNames(const TCHAR *dir, const vector> & patterns, vector> & fileNames, bool isRecursive, bool isInHiddenDir) { - string dirFilter(dir); - dirFilter += "*.*"; - WIN32_FIND_DATAW foundData; + basic_string dirFilter(dir); + dirFilter += TEXT("*.*"); + WIN32_FIND_DATA foundData; - wstring dirFilterW = string2wstring(dirFilter); - HANDLE hFile = ::FindFirstFileW(dirFilterW.c_str(), &foundData); + HANDLE hFile = ::FindFirstFile(dirFilter.c_str(), &foundData); if (hFile != INVALID_HANDLE_VALUE) { @@ -1488,30 +1480,26 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector & p } else if (isRecursive) { - if ((wcscmp(foundData.cFileName, L".")) && (wcscmp(foundData.cFileName, L".."))) + if ((lstrcmp(foundData.cFileName, TEXT("."))) && (lstrcmp(foundData.cFileName, TEXT("..")))) { - string pathDir(dir); - wstring pathDirW = string2wstring(pathDir); - pathDirW += foundData.cFileName; - pathDirW += L"\\"; - pathDir = wstring2string(pathDirW); + basic_string pathDir(dir); + pathDir += foundData.cFileName; + pathDir += TEXT("\\"); getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive, isInHiddenDir); } } } else { - char filename[MAX_PATH]; - wchar2char(foundData.cFileName, filename); - if (matchInList(filename, patterns)) + if (matchInList(foundData.cFileName, patterns)) { - string pathFile(dir); - pathFile += filename; + basic_string pathFile(dir); + pathFile += foundData.cFileName; fileNames.push_back(pathFile.c_str()); } } } - while (::FindNextFileW(hFile, &foundData)) + while (::FindNextFile(hFile, &foundData)) { if (foundData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { @@ -1521,25 +1509,21 @@ void Notepad_plus::getMatchedFileNames(const char *dir, const vector & p } else if (isRecursive) { - if ((wcscmp(foundData.cFileName, L".")) && (wcscmp(foundData.cFileName, L".."))) + if ((lstrcmp(foundData.cFileName, TEXT("."))) && (lstrcmp(foundData.cFileName, TEXT("..")))) { - string pathDir(dir); - wstring pathDirW = string2wstring(pathDir); - pathDirW += foundData.cFileName; - pathDirW += L"\\"; - pathDir = wstring2string(pathDirW); + basic_string pathDir(dir); + pathDir += foundData.cFileName; + pathDir += TEXT("\\"); getMatchedFileNames(pathDir.c_str(), patterns, fileNames, isRecursive, isInHiddenDir); } } } else { - char filename[MAX_PATH]; - wchar2char(foundData.cFileName, filename); - if (matchInList(filename, patterns)) + if (matchInList(foundData.cFileName, patterns)) { - string pathFile(dir); - pathFile += filename; + basic_string pathFile(dir); + pathFile += foundData.cFileName; fileNames.push_back(pathFile.c_str()); } } @@ -1557,19 +1541,17 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir) if (!_findReplaceDlg.isFinderEmpty()) _findReplaceDlg.clearFinder(); - const char *dir2Search = _findReplaceDlg.getDir2Search(); - wchar_t dir2SearchW[MAX_PATH]; - char2wchar(dir2Search, dir2SearchW); + const TCHAR *dir2Search = _findReplaceDlg.getDir2Search(); - if (!dir2SearchW[0] || !::PathFileExistsW(dir2SearchW)) + if (!dir2Search[0] || !::PathFileExists(dir2Search)) { return false; } - vector patterns2Match; - if (_findReplaceDlg.getFilters() == "") - _findReplaceDlg.setFindInFilesDirFilter(NULL, "*.*"); + vector> patterns2Match; + if (_findReplaceDlg.getFilters() == TEXT("")) + _findReplaceDlg.setFindInFilesDirFilter(NULL, TEXT("*.*")); _findReplaceDlg.getPatterns(patterns2Match); - vector fileNames; + vector> fileNames; getMatchedFileNames(dir2Search, patterns2Match, fileNames, isRecursive, isInHiddenDir); bool dontClose = false; @@ -1599,7 +1581,6 @@ bool Notepad_plus::findInFiles(bool isRecursive, bool isInHiddenDir) } bool Notepad_plus::findInOpenedFiles() { - int nbTotal = 0; ScintillaEditView *pOldView = _pEditView; _pEditView = &_invisibleEditView; @@ -1766,13 +1747,13 @@ void Notepad_plus::checkLangsMenu(int id) const { if (curBuf->isUserDefineLangExt()) { - const char *userLangName = curBuf->getUserDefineLangName(); - char menuLangName[16]; + const TCHAR *userLangName = curBuf->getUserDefineLangName(); + TCHAR menuLangName[16]; for (int i = IDM_LANG_USER + 1 ; i <= IDM_LANG_USER_LIMIT ; i++) { if (::GetMenuString(_mainMenuHandle, i, menuLangName, sizeof(menuLangName), MF_BYCOMMAND)) - if (!strcmp(userLangName, menuLangName)) + if (!lstrcmp(userLangName, menuLangName)) { ::CheckMenuRadioItem(_mainMenuHandle, IDM_LANG_C, IDM_LANG_USER_LIMIT, i, MF_BYCOMMAND); return; @@ -1784,26 +1765,26 @@ void Notepad_plus::checkLangsMenu(int id) const ::CheckMenuRadioItem(_mainMenuHandle, IDM_LANG_C, IDM_LANG_USER_LIMIT, id, MF_BYCOMMAND); } -string Notepad_plus::getLangDesc(LangType langType, bool shortDesc) +basic_string Notepad_plus::getLangDesc(LangType langType, bool shortDesc) { if ((langType >= L_EXTERNAL) && (langType < NppParameters::getInstance()->L_END)) { ExternalLangContainer & elc = NppParameters::getInstance()->getELCFromIndex(langType - L_EXTERNAL); if (shortDesc) - return string(elc._name); + return basic_string(elc._name); else - return string(elc._desc); + return basic_string(elc._desc); } - string str2Show = ScintillaEditView::langNames[langType].longName; + basic_string str2Show = ScintillaEditView::langNames[langType].longName; if (langType == L_USER) { Buffer * currentBuf = _pEditView->getCurrentBuffer(); if (currentBuf->isUserDefineLangExt()) { - str2Show += " - "; + str2Show += TEXT(" - "); str2Show += currentBuf->getUserDefineLangName(); } } @@ -1897,31 +1878,45 @@ BOOL Notepad_plus::notify(SCNotification *notification) { if (!_tabPopupDropMenu.isCreated()) { - char goToView[64] = "Go to another View"; - char cloneToView[64] = "Clone to another View"; - const char *pGoToView = goToView; - const char *pCloneToView = cloneToView; - + TCHAR goToView[32] = TEXT("Go to another View"); + TCHAR cloneToView[32] = TEXT("Clone to another View"); + const TCHAR *pGoToView = goToView; + const TCHAR *pCloneToView = cloneToView; +#ifdef UNICODE + basic_string goToViewW = TEXT(""); + basic_string cloneToViewW = TEXT(""); +#endif if (_nativeLang) { - TiXmlNode *tabBarMenu = _nativeLang->FirstChild("Menu"); + TiXmlNode *tabBarMenu = _nativeLang->FirstChild(TEXT("Menu")); if (tabBarMenu) - tabBarMenu = tabBarMenu->FirstChild("TabBar"); + tabBarMenu = tabBarMenu->FirstChild(TEXT("TabBar")); if (tabBarMenu) { - for (TiXmlNode *childNode = tabBarMenu->FirstChildElement("Item"); + for (TiXmlNode *childNode = tabBarMenu->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int ordre; - element->Attribute("order", &ordre); + element->Attribute(TEXT("order"), &ordre); if (ordre == 5) - pGoToView = element->Attribute("name"); + pGoToView = element->Attribute(TEXT("name")); else if (ordre == 6) - pCloneToView = element->Attribute("name"); + pCloneToView = element->Attribute(TEXT("name")); } } +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + + const char *pGoToViewA = wmc->wchar2char(pGoToView, CP_ANSI_LATIN_1); + goToViewW = wmc->char2wchar(pGoToViewA, _nativeLangEncoding); + pGoToView = goToViewW.c_str(); + + const char *pCloneToViewA = wmc->wchar2char(pCloneToView, CP_ANSI_LATIN_1); + cloneToViewW = wmc->char2wchar(pCloneToViewA, _nativeLangEncoding); + pCloneToView = cloneToViewW.c_str(); +#endif if (!pGoToView || !pGoToView[0]) pGoToView = goToView; if (!pCloneToView || !pCloneToView[0]) @@ -2001,7 +1996,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) { bool isOverTypeMode = (_pEditView->execute(SCI_GETOVERTYPE) != 0); _pEditView->execute(SCI_SETOVERTYPE, !isOverTypeMode); - _statusBar.setText((_pEditView->execute(SCI_GETOVERTYPE))?"OVR":"INS", STATUSBAR_TYPING_MODE); + _statusBar.setText((_pEditView->execute(SCI_GETOVERTYPE))?TEXT("OVR"):TEXT("INS"), STATUSBAR_TYPING_MODE); } } else if (notification->nmhdr.hwndFrom == _mainDocTab.getHSelf()) @@ -2026,7 +2021,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) bool isFirstTime = !_goToLineDlg.isCreated(); _goToLineDlg.doDialog(_isRTL); if (isFirstTime) - changeDlgLang(_goToLineDlg.getHSelf(), "GoToLine"); + changeDlgLang(_goToLineDlg.getHSelf(), TEXT("GoToLine")); } } break; @@ -2051,81 +2046,147 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (!_tabPopupMenu.isCreated()) { - char close[32] = "Close me"; - char closeBut[32] = "Close all but me"; - char save[32] = "Save me"; - char saveAs[32] = "Save me As..."; - char print[32] = "Print me"; - char readOnly[32] = "Read only"; - char clearReadOnly[32] = "Clear read only flag"; - char goToView[32] = "Go to another View"; - char cloneToView[32] = "Clone to another View"; - char cilpFullPath[32] = "Full file path to Clipboard"; - char cilpFileName[32] = "File name to Clipboard"; - char cilpCurrentDir[32] = "Current dir path to Clipboard"; - char remove[32] = "Delete me"; - char rename[32] = "Rename me"; + TCHAR close[32] = TEXT("Close me"); + TCHAR closeBut[32] = TEXT("Close all but me"); + TCHAR save[32] = TEXT("Save me"); + TCHAR saveAs[32] = TEXT("Save me As..."); + TCHAR print[32] = TEXT("Print me"); + TCHAR readOnly[32] = TEXT("Read only"); + TCHAR clearReadOnly[32] = TEXT("Clear read only flag"); + TCHAR goToView[32] = TEXT("Go to another View"); + TCHAR cloneToView[32] = TEXT("Clone to another View"); + TCHAR cilpFullPath[32] = TEXT("Full file path to Clipboard"); + TCHAR cilpFileName[32] = TEXT("File name to Clipboard"); + TCHAR cilpCurrentDir[32] = TEXT("Current dir path to Clipboard"); + TCHAR remove[32] = TEXT("Delete me"); + TCHAR rename[32] = TEXT("Rename me"); - - const char *pClose = close; - const char *pCloseBut = closeBut; - const char *pSave = save; - const char *pSaveAs = saveAs; - const char *pPrint = print; - const char *pReadOnly = readOnly; - const char *pClearReadOnly = clearReadOnly; - const char *pGoToView = goToView; - const char *pCloneToView = cloneToView; - const char *pCilpFullPath = cilpFullPath; - const char *pCilpFileName = cilpFileName; - const char *pCilpCurrentDir = cilpCurrentDir; - const char *pRename = rename; - const char *pRemove = remove; + const TCHAR *pClose = close; + const TCHAR *pCloseBut = closeBut; + const TCHAR *pSave = save; + const TCHAR *pSaveAs = saveAs; + const TCHAR *pPrint = print; + const TCHAR *pReadOnly = readOnly; + const TCHAR *pClearReadOnly = clearReadOnly; + const TCHAR *pGoToView = goToView; + const TCHAR *pCloneToView = cloneToView; + const TCHAR *pCilpFullPath = cilpFullPath; + const TCHAR *pCilpFileName = cilpFileName; + const TCHAR *pCilpCurrentDir = cilpCurrentDir; + const TCHAR *pRename = rename; + const TCHAR *pRemove = remove; +#ifdef UNICODE + basic_string goToViewW, cloneToViewW, closeW, closeButW, saveW, saveAsW, printW,\ + readOnlyW, clearReadOnlyW, cilpFullPathW, cilpFileNameW, cilpCurrentDirW, removeW, renameW; +#endif if (_nativeLang) { - TiXmlNode *tabBarMenu = _nativeLang->FirstChild("Menu"); + TiXmlNode *tabBarMenu = _nativeLang->FirstChild(TEXT("Menu")); if (tabBarMenu) { - tabBarMenu = tabBarMenu->FirstChild("TabBar"); + tabBarMenu = tabBarMenu->FirstChild(TEXT("TabBar")); if (tabBarMenu) { - for (TiXmlNode *childNode = tabBarMenu->FirstChildElement("Item"); + for (TiXmlNode *childNode = tabBarMenu->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int ordre; - element->Attribute("order", &ordre); + element->Attribute(TEXT("order"), &ordre); switch (ordre) { case 0 : - pClose = element->Attribute("name"); break; + pClose = element->Attribute(TEXT("name")); break; case 1 : - pCloseBut = element->Attribute("name"); break; + pCloseBut = element->Attribute(TEXT("name")); break; case 2 : - pSave = element->Attribute("name"); break; + pSave = element->Attribute(TEXT("name")); break; case 3 : - pSaveAs = element->Attribute("name"); break; + pSaveAs = element->Attribute(TEXT("name")); break; case 4 : - pPrint = element->Attribute("name"); break; + pPrint = element->Attribute(TEXT("name")); break; case 5 : - pGoToView = element->Attribute("name"); break; + pGoToView = element->Attribute(TEXT("name")); break; case 6 : - pCloneToView = element->Attribute("name"); break; + pCloneToView = element->Attribute(TEXT("name")); break; case 7 : - pCilpFullPath = element->Attribute("name"); break; + pCilpFullPath = element->Attribute(TEXT("name")); break; case 8 : - pCilpFileName = element->Attribute("name"); break; + pCilpFileName = element->Attribute(TEXT("name")); break; case 9 : - pCilpCurrentDir = element->Attribute("name"); break; + pCilpCurrentDir = element->Attribute(TEXT("name")); break; case 10 : - pRename = element->Attribute("name"); break; + pRename = element->Attribute(TEXT("name")); break; case 11 : - pRemove = element->Attribute("name"); break; + pRemove = element->Attribute(TEXT("name")); break; + case 12 : + pReadOnly = element->Attribute(TEXT("name")); break; + case 13 : + pClearReadOnly = element->Attribute(TEXT("name")); break; } } } } +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + + const char *pCharStrA = wmc->wchar2char(pGoToView, CP_ANSI_LATIN_1); + goToViewW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pGoToView = goToViewW.c_str(); + + pCharStrA = wmc->wchar2char(pCloneToView, CP_ANSI_LATIN_1); + cloneToViewW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pCloneToView = cloneToViewW.c_str(); + + pCharStrA = wmc->wchar2char(pClose, CP_ANSI_LATIN_1); + closeW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pClose = closeW.c_str(); + + pCharStrA = wmc->wchar2char(pCloseBut, CP_ANSI_LATIN_1); + closeButW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pCloseBut = closeButW.c_str(); + + pCharStrA = wmc->wchar2char(pSave, CP_ANSI_LATIN_1); + saveW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pSave = saveW.c_str(); + + pCharStrA = wmc->wchar2char(pSaveAs, CP_ANSI_LATIN_1); + saveAsW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pSaveAs = saveAsW.c_str(); + + pCharStrA = wmc->wchar2char(pPrint, CP_ANSI_LATIN_1); + printW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pPrint = printW.c_str(); + + pCharStrA = wmc->wchar2char(pReadOnly, CP_ANSI_LATIN_1); + readOnlyW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pReadOnly = readOnlyW.c_str(); + + pCharStrA = wmc->wchar2char(pClearReadOnly, CP_ANSI_LATIN_1); + clearReadOnlyW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pClearReadOnly = clearReadOnlyW.c_str(); + + pCharStrA = wmc->wchar2char(pCilpFullPath, CP_ANSI_LATIN_1); + cilpFullPathW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pCilpFullPath = cilpFullPathW.c_str(); + + pCharStrA = wmc->wchar2char(pCilpFileName, CP_ANSI_LATIN_1); + cilpFileNameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pCilpFileName = cilpFileNameW.c_str(); + + pCharStrA = wmc->wchar2char(pCilpCurrentDir, CP_ANSI_LATIN_1); + cilpCurrentDirW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pCilpCurrentDir = cilpCurrentDirW.c_str(); + + pCharStrA = wmc->wchar2char(pRename, CP_ANSI_LATIN_1); + removeW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pRename = removeW.c_str(); + + pCharStrA = wmc->wchar2char(pRemove, CP_ANSI_LATIN_1); + renameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pRemove = renameW.c_str(); +#endif if (!pClose || !pClose[0]) pClose = close; if (!pCloseBut || !pCloseBut[0]) @@ -2150,6 +2211,10 @@ BOOL Notepad_plus::notify(SCNotification *notification) pRename = rename; if (!pRemove || !pRemove[0]) pRemove = remove; + if (!pReadOnly || !pReadOnly[0]) + pReadOnly = readOnly; + if (!pClearReadOnly || !pClearReadOnly[0]) + pClearReadOnly = clearReadOnly; } vector itemUnitArray; itemUnitArray.push_back(MenuItemUnit(IDM_FILE_CLOSE, pClose)); @@ -2185,12 +2250,11 @@ BOOL Notepad_plus::notify(SCNotification *notification) _tabPopupMenu.enableItem(IDM_EDIT_SETREADONLY, !isSysReadOnly); _tabPopupMenu.enableItem(IDM_EDIT_CLEARREADONLY, isSysReadOnly); - bool isFileExisting = PathFileExistsW(buf->getFilePathW()) != FALSE; + bool isFileExisting = PathFileExists(buf->getFilePath()) != FALSE; _tabPopupMenu.enableItem(IDM_FILE_DELETE, isFileExisting); _tabPopupMenu.enableItem(IDM_FILE_RENAME, isFileExisting); _tabPopupMenu.display(p); - return TRUE; } @@ -2220,7 +2284,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) case SCN_CHARADDED: { - charAdded(static_cast(notification->ch)); + charAdded(static_cast(notification->ch)); AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; @@ -2252,16 +2316,6 @@ BOOL Notepad_plus::notify(SCNotification *notification) xmlTagMatchHiliter.tagMatch(nppGUI._enableTagAttrsHilite); } _smartHighlighter.highlightView(notifyView); - - if (_linkTriggered) - { - int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; - if ((urlAction == 1) || (urlAction == 2)) - addHotSpot(_isDocModifing); - _linkTriggered = false; - _isDocModifing = false; - } - updateStatusBar(); AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; autoC->update(0); @@ -2271,15 +2325,14 @@ BOOL Notepad_plus::notify(SCNotification *notification) case SCN_SCROLLED: { _smartHighlighter.highlightView(notifyView); - ////_urlHighlighter.highlightView(notifyView); break; } - case TTN_GETDISPINFOW: + case TTN_GETDISPINFO: { - LPTOOLTIPTEXTW lpttt; + LPTOOLTIPTEXT lpttt; - lpttt = (LPTOOLTIPTEXTW)notification; + lpttt = (LPTOOLTIPTEXT)notification; lpttt->hinst = _hInst; POINT p; @@ -2287,7 +2340,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) ::ScreenToClient(_hSelf, &p); HWND hWin = ::RealChildWindowFromPoint(_hSelf, p); - static string tip; + static basic_string tip; int id = int(lpttt->hdr.idFrom); if (hWin == _rebarTop.getHSelf()) @@ -2309,9 +2362,7 @@ BOOL Notepad_plus::notify(SCNotification *notification) else break; - static wchar_t tipW[MAX_PATH]; - char2wchar(tip.c_str(), tipW); - lpttt->lpszText = tipW; + lpttt->lpszText = (TCHAR *)tip.c_str(); } break; @@ -2328,12 +2379,6 @@ BOOL Notepad_plus::notify(SCNotification *notification) if (_syncInfo.doSync()) doSynScorll(HWND(notification->nmhdr.hwndFrom)); - ////if (_linkTriggered) - { - ////_urlHighlighter.highlightView(notifyView); - ////_linkTriggered = false; - } - if (_linkTriggered) { int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; @@ -2342,33 +2387,11 @@ BOOL Notepad_plus::notify(SCNotification *notification) _linkTriggered = false; _isDocModifing = false; } - break; } case SCN_HOTSPOTDOUBLECLICK : { - /* - notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.:?&@=/%#"); - - int pos = notifyView->execute(SCI_GETCURRENTPOS); - int startPos = static_cast(notifyView->execute(SCI_WORDSTARTPOSITION, pos, false)); - int endPos = static_cast(notifyView->execute(SCI_WORDENDPOSITION, pos, false)); - - notifyView->execute(SCI_SETTARGETSTART, startPos); - notifyView->execute(SCI_SETTARGETEND, endPos); - - int length = endPos-startPos+1; - char * currentWord = new char[length]; - notifyView->getText(currentWord, startPos, endPos); - - ::ShellExecute(_hSelf, "open", currentWord, NULL, NULL, SW_SHOW); - //Disabled: This message comes after SCN_DOUBLECLICK, so this method fails and prevents the next doubleclick from working - //_isHotspotDblClicked = true; - notifyView->execute(SCI_SETCHARSDEFAULT); - delete [] currentWord; - break; - */ notifyView->execute(SCI_SETWORDCHARS, 0, (LPARAM)"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-+.:?&@=/%#"); int pos = notifyView->execute(SCI_GETCURRENTPOS); @@ -2378,17 +2401,17 @@ BOOL Notepad_plus::notify(SCNotification *notification) notifyView->execute(SCI_SETTARGETSTART, startPos); notifyView->execute(SCI_SETTARGETEND, endPos); - int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRE), (LPARAM)urlHttpRE); + int posFound = notifyView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); if (posFound != -1) { startPos = int(notifyView->execute(SCI_GETTARGETSTART)); endPos = int(notifyView->execute(SCI_GETTARGETEND)); } - char currentWord[MAX_PATH*2]; - notifyView->getText(currentWord, startPos, endPos); + TCHAR currentWord[MAX_PATH*2]; + notifyView->getGenericText(currentWord, startPos, endPos); - ::ShellExecute(_hSelf, "open", currentWord, NULL, NULL, SW_SHOW); + ::ShellExecute(_hSelf, TEXT("open"), currentWord, NULL, NULL, SW_SHOW); _isHotspotDblClicked = true; notifyView->execute(SCI_SETCHARSDEFAULT); break; @@ -2450,21 +2473,22 @@ BOOL Notepad_plus::notify(SCNotification *notification) } return FALSE; } + void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite) { int caretPos = int(_pEditView->execute(SCI_GETCURRENTPOS)); braceAtCaret = -1; braceOpposite = -1; - char charBefore = '\0'; - //char styleBefore = '\0'; + TCHAR charBefore = '\0'; + //TCHAR styleBefore = '\0'; int lengthDoc = int(_pEditView->execute(SCI_GETLENGTH)); if ((lengthDoc > 0) && (caretPos > 0)) { - charBefore = char(_pEditView->execute(SCI_GETCHARAT, caretPos - 1, 0)); + charBefore = TCHAR(_pEditView->execute(SCI_GETCHARAT, caretPos - 1, 0)); } // Priority goes to character before caret - if (charBefore && strchr("[](){}", charBefore)) + if (charBefore && generic_strchr(TEXT("[](){}"), charBefore)) { braceAtCaret = caretPos - 1; } @@ -2472,8 +2496,8 @@ void Notepad_plus::findMatchingBracePos(int & braceAtCaret, int & braceOpposite) if (lengthDoc > 0 && (braceAtCaret < 0)) { // No brace found so check other side - char charAfter = char(_pEditView->execute(SCI_GETCHARAT, caretPos, 0)); - if (charAfter && strchr("[](){}", charAfter)) + TCHAR charAfter = TCHAR(_pEditView->execute(SCI_GETCHARAT, caretPos, 0)); + if (charAfter && generic_strchr(TEXT("[](){}"), charAfter)) { braceAtCaret = caretPos; } @@ -2509,7 +2533,7 @@ void Notepad_plus::braceMatch() enableCommand(IDM_SEARCH_GOTOMATCHINGBRACE, (braceAtCaret != -1) && (braceOpposite != -1), MENU | TOOLBAR); } -void Notepad_plus::charAdded(char chAdded) +void Notepad_plus::charAdded(TCHAR chAdded) { bool indentMaintain = NppParameters::getInstance()->getNppGUI()._maitainIndent; if (indentMaintain) @@ -2518,7 +2542,6 @@ void Notepad_plus::charAdded(char chAdded) void Notepad_plus::addHotSpot(bool docIsModifing) { - //printStr("addHotSpot begin"); //bool docIsModifing = true; int posBegin2style = 0; if (docIsModifing) @@ -2530,7 +2553,7 @@ void Notepad_plus::addHotSpot(bool docIsModifing) posBegin2style = _pEditView->execute(SCI_GETCURRENTPOS); if (posBegin2style > 0) posBegin2style--; - unsigned char ch = (unsigned char)_pEditView->execute(SCI_GETCHARAT, posBegin2style); + UCHAR ch = (UCHAR)_pEditView->execute(SCI_GETCHARAT, posBegin2style); // determinating the type of EOF to make sure how many steps should we be back if ((ch == 0x0A) || (ch == 0x0D)) @@ -2543,13 +2566,13 @@ void Notepad_plus::addHotSpot(bool docIsModifing) posBegin2style -= 1; } - ch = (unsigned char)_pEditView->execute(SCI_GETCHARAT, posBegin2style); + ch = (UCHAR)_pEditView->execute(SCI_GETCHARAT, posBegin2style); while ((posBegin2style > 0) && ((ch != 0x0A) && (ch != 0x0D))) { - ch = (unsigned char)_pEditView->execute(SCI_GETCHARAT, posBegin2style--); + ch = (UCHAR)_pEditView->execute(SCI_GETCHARAT, posBegin2style--); } } - + int style_hotspot = 30; int startPos = 0; int endPos = _pEditView->execute(SCI_GETTEXTLENGTH); @@ -2559,10 +2582,9 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_SETTARGETSTART, startPos); _pEditView->execute(SCI_SETTARGETEND, endPos); - vector< pair > & hotspotStylers = (_pEditView->getCurrentBuffer())->getClickableStyles(); - int style_hotspot = hotspotStylers.size()==0?30:hotspotStylers[hotspotStylers.size() - 1].second - 1; - - int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRE), (LPARAM)urlHttpRE); + vector > hotspotStylers; + + int posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); while (posFound != -1) { @@ -2570,8 +2592,7 @@ void Notepad_plus::addHotSpot(bool docIsModifing) int end = int(_pEditView->execute(SCI_GETTARGETEND)); int foundTextLen = end - start; int idStyle = _pEditView->execute(SCI_GETSTYLEAT, posFound); -//if (_pEditView->execute(SCI_STYLEGETHOTSPOT, idStyle) == FALSE) -{ + if (end < posBegin2style - 1) { if (style_hotspot > 1) @@ -2580,12 +2601,11 @@ void Notepad_plus::addHotSpot(bool docIsModifing) else { int fs = -1; - size_t i = 0; - for ( ; i < hotspotStylers.size() ; i++) + for (size_t i = 0 ; i < hotspotStylers.size() ; i++) { - if (hotspotStylers[i].first._styleID == idStyle) + if (hotspotStylers[i].second == idStyle) { - fs = hotspotStylers[i].second; + fs = hotspotStylers[i].first; break; } } @@ -2595,57 +2615,33 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_STARTSTYLING, start, 0xFF); _pEditView->execute(SCI_SETSTYLING, foundTextLen, fs); - Style styleToSet = hotspotStylers[i].first; - - if ( styleToSet._colorStyle & COLORSTYLE_FOREGROUND ) - _pEditView->execute(SCI_STYLESETFORE, fs, styleToSet._fgColor); - - if ( styleToSet._colorStyle & COLORSTYLE_BACKGROUND ) - _pEditView->execute(SCI_STYLESETBACK, fs, styleToSet._bgColor); - - if ((!styleToSet._fontName)||(strcmp(styleToSet._fontName, ""))) - _pEditView->execute(SCI_STYLESETFONT, (WPARAM)fs, (LPARAM)styleToSet._fontName); - - int fontStyle = styleToSet._fontStyle; - if (fontStyle != -1) - { - _pEditView->execute(SCI_STYLESETBOLD, (WPARAM)fs, fontStyle & FONTSTYLE_BOLD); - _pEditView->execute(SCI_STYLESETITALIC, (WPARAM)fs, fontStyle & FONTSTYLE_ITALIC); - _pEditView->execute(SCI_STYLESETUNDERLINE, (WPARAM)fs, fontStyle & FONTSTYLE_UNDERLINE); - } - - if (styleToSet._fontSize > 0) - _pEditView->execute(SCI_STYLESETSIZE, fs, styleToSet._fontSize); - - _pEditView->execute(SCI_STYLESETHOTSPOT, fs, TRUE); - _pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, blue); - _pEditView->execute(SCI_SETHOTSPOTSINGLELINE, fs, 0); - } else { + pair p(style_hotspot, idStyle); + hotspotStylers.push_back(p); int activeFG = 0xFF0000; - char fontName[256]; - Style associatedHotspotStyle; + //TCHAR fontName[256]; + Style hotspotStyle; - associatedHotspotStyle._styleID = style_hotspot; - _pEditView->execute(SCI_STYLEGETFONT, idStyle, (LPARAM)fontName); - associatedHotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle); - associatedHotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle); - associatedHotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle); + hotspotStyle._styleID = style_hotspot; + //_pEditView->execute(SCI_STYLEGETFONT, idStyle, (LPARAM)fontName); + hotspotStyle._fgColor = _pEditView->execute(SCI_STYLEGETFORE, idStyle); + hotspotStyle._bgColor = _pEditView->execute(SCI_STYLEGETBACK, idStyle); + hotspotStyle._fontSize = _pEditView->execute(SCI_STYLEGETSIZE, idStyle); int isBold = _pEditView->execute(SCI_STYLEGETBOLD, idStyle); int isItalic = _pEditView->execute(SCI_STYLEGETITALIC, idStyle); int isUnderline = _pEditView->execute(SCI_STYLEGETUNDERLINE, idStyle); - associatedHotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); + hotspotStyle._fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); int fontStyle = (isBold?FONTSTYLE_BOLD:0) | (isItalic?FONTSTYLE_ITALIC:0) | (isUnderline?FONTSTYLE_UNDERLINE:0); int urlAction = (NppParameters::getInstance())->getNppGUI()._styleURL; if (urlAction == 2) - associatedHotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; + hotspotStyle._fontStyle |= FONTSTYLE_UNDERLINE; - _pEditView->setStyle(associatedHotspotStyle); + _pEditView->setStyle(hotspotStyle); _pEditView->execute(SCI_STYLESETHOTSPOT, style_hotspot, TRUE); _pEditView->execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG); @@ -2653,32 +2649,25 @@ void Notepad_plus::addHotSpot(bool docIsModifing) _pEditView->execute(SCI_STARTSTYLING, start, 0x1F); _pEditView->execute(SCI_SETSTYLING, foundTextLen, style_hotspot); if (style_hotspot > 1) - style_hotspot--; - - associatedHotspotStyle._styleID = idStyle; - pair p(associatedHotspotStyle, style_hotspot); - hotspotStylers.push_back(p); + style_hotspot--; } } _pEditView->execute(SCI_SETTARGETSTART, posFound + foundTextLen); _pEditView->execute(SCI_SETTARGETEND, endPos); - posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRE), (LPARAM)urlHttpRE); -} - + + posFound = _pEditView->execute(SCI_SEARCHINTARGET, strlen(urlHttpRegExpr), (LPARAM)urlHttpRegExpr); } _pEditView->execute(SCI_STARTSTYLING, endStyle, 0xFF); _pEditView->execute(SCI_SETSTYLING, 0, 0); - - //printStr("addHotSpot end"); } -void Notepad_plus::MaintainIndentation(char ch) +void Notepad_plus::MaintainIndentation(TCHAR ch) { int eolMode = int(_pEditView->execute(SCI_GETEOLMODE)); int curLine = int(_pEditView->getCurrentLineNumber()); @@ -2777,7 +2766,7 @@ void Notepad_plus::specialCmd(int id, int param) { ValueDlg nbColumnEdgeDlg; ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP(param == 1?SCIV_PRIMARY:SCIV_SECOND); - nbColumnEdgeDlg.init(_hInst, _preference.getHSelf(), svp._edgeNbColumn, "Nb of column:"); + nbColumnEdgeDlg.init(_hInst, _preference.getHSelf(), svp._edgeNbColumn, TEXT("Nb of column:")); nbColumnEdgeDlg.setNBNumber(3); POINT p; @@ -2964,7 +2953,7 @@ void Notepad_plus::command(int id) if (isFirstTime) { - changeDlgLang(_runMacroDlg.getHSelf(), "MultiMacro"); + changeDlgLang(_runMacroDlg.getHSelf(), TEXT("MultiMacro")); } break; @@ -2984,14 +2973,14 @@ void Notepad_plus::command(int id) { Buffer * buf = _pEditView->getCurrentBuffer(); if (id == IDM_EDIT_FULLPATHTOCLIP) { - str2CliboardW(buf->getFilePathW()); + str2Cliboard(buf->getFilePath()); } else if (id == IDM_EDIT_CURRENTDIRTOCLIP) { - wchar_t dir[MAX_PATH]; - wcscpy(dir, buf->getFilePathW()); - PathRemoveFileSpecW((LPWSTR)dir); - str2CliboardW(dir); + TCHAR dir[MAX_PATH]; + lstrcpy(dir, buf->getFilePath()); + PathRemoveFileSpec((TCHAR *)dir); + str2Cliboard(dir); } else if (id == IDM_EDIT_FILENAMETOCLIP) { - str2CliboardW(buf->getFileNameW()); + str2Cliboard(buf->getFileName()); } } break; @@ -3000,37 +2989,54 @@ void Notepad_plus::command(int id) case IDM_SEARCH_REPLACE : { const int strSize = 64; - char str[strSize]; + TCHAR str[strSize]; bool isFirstTime = !_findReplaceDlg.isCreated(); if (_nativeLang) { - TiXmlNode *dlgNode = _nativeLang->FirstChild("Dialog"); + TiXmlNode *dlgNode = _nativeLang->FirstChild(TEXT("Dialog")); if (dlgNode) { - dlgNode = searchDlgNode(dlgNode, "Find"); + dlgNode = searchDlgNode(dlgNode, TEXT("Find")); if (dlgNode) { - const char *titre1 = (dlgNode->ToElement())->Attribute("titleFind"); - const char *titre2 = (dlgNode->ToElement())->Attribute("titleReplace"); - const char *titre3 = (dlgNode->ToElement())->Attribute("titleFindInFiles"); + const TCHAR *titre1 = (dlgNode->ToElement())->Attribute(TEXT("titleFind")); + const TCHAR *titre2 = (dlgNode->ToElement())->Attribute(TEXT("titleReplace")); + const TCHAR *titre3 = (dlgNode->ToElement())->Attribute(TEXT("titleFindInFiles")); if (titre1 && titre2 && titre3) { +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + + const char *pCharStrA = wmc->wchar2char(titre1, CP_ANSI_LATIN_1); + basic_string nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pNppParam->getFindDlgTabTitiles()._find = nameW; + + pCharStrA = wmc->wchar2char(titre2, CP_ANSI_LATIN_1); + nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pNppParam->getFindDlgTabTitiles()._replace = nameW; + + pCharStrA = wmc->wchar2char(titre3, CP_ANSI_LATIN_1); + nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pNppParam->getFindDlgTabTitiles()._findInFiles = nameW; + +#else pNppParam->getFindDlgTabTitiles()._find = titre1; pNppParam->getFindDlgTabTitiles()._replace = titre2; pNppParam->getFindDlgTabTitiles()._findInFiles = titre3; +#endif } } } } _findReplaceDlg.doDialog((id == IDM_SEARCH_FIND)?FIND_DLG:REPLACE_DLG, _isRTL); - _pEditView->getSelectedText(str, strSize); + _pEditView->getGenericSelectedText(str, strSize); _findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit); if (isFirstTime) - changeDlgLang(_findReplaceDlg.getHSelf(), "Find"); + changeDlgLang(_findReplaceDlg.getHSelf(), TEXT("Find")); break; } @@ -3042,9 +3048,9 @@ void Notepad_plus::command(int id) case IDM_SEARCH_FINDINCREMENT : { const int strSize = 64; - char str[strSize]; + TCHAR str[strSize]; - _pEditView->getSelectedText(str, strSize); + _pEditView->getGenericSelectedText(str, strSize); _incrementFindDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit); _incrementFindDlg.display(); @@ -3059,7 +3065,7 @@ void Notepad_plus::command(int id) FindOption op = _findReplaceDlg.getCurrentOptions(); op._whichDirection = (id == IDM_SEARCH_FINDNEXT?DIR_DOWN:DIR_UP); - string s = _findReplaceDlg.getText2search(); + basic_string s = _findReplaceDlg.getText2search(); _findReplaceDlg.processFindNext(s.c_str(), &op); break; @@ -3069,8 +3075,8 @@ void Notepad_plus::command(int id) case IDM_SEARCH_VOLATILE_FINDNEXT : case IDM_SEARCH_VOLATILE_FINDPREV : { - char text2Find[MAX_PATH]; - _pEditView->getSelectedText(text2Find, sizeof(text2Find)); + TCHAR text2Find[MAX_PATH]; + _pEditView->getGenericSelectedText(text2Find, sizeof(text2Find)); FindOption op; op._isWholeWord = false; @@ -3081,8 +3087,8 @@ void Notepad_plus::command(int id) case IDM_SEARCH_MARKALL : { const int strSize = 64; - char text2Find[strSize]; - _pEditView->getSelectedText(text2Find, sizeof(text2Find)); + TCHAR text2Find[strSize]; + _pEditView->getGenericSelectedText(text2Find, sizeof(text2Find)); FindOption op; op._isWholeWord = false; @@ -3103,7 +3109,7 @@ void Notepad_plus::command(int id) bool isFirstTime = !_goToLineDlg.isCreated(); _goToLineDlg.doDialog(_isRTL); if (isFirstTime) - changeDlgLang(_goToLineDlg.getHSelf(), "GoToLine"); + changeDlgLang(_goToLineDlg.getHSelf(), TEXT("GoToLine")); break; } @@ -3112,7 +3118,7 @@ void Notepad_plus::command(int id) bool isFirstTime = !_colEditorDlg.isCreated(); _colEditorDlg.doDialog(_isRTL); if (isFirstTime) - changeDlgLang(_colEditorDlg.getHSelf(), "ColumnEditor"); + changeDlgLang(_colEditorDlg.getHSelf(), TEXT("ColumnEditor")); break; } @@ -3288,10 +3294,10 @@ void Notepad_plus::command(int id) { Buffer * buf = _pEditView->getCurrentBuffer(); - DWORD dwFileAttribs = ::GetFileAttributesW(buf->getFileNameW()); + DWORD dwFileAttribs = ::GetFileAttributes(buf->getFileName()); dwFileAttribs ^= FILE_ATTRIBUTE_READONLY; - ::SetFileAttributesW(buf->getFileNameW(), dwFileAttribs); + ::SetFileAttributes(buf->getFileName(), dwFileAttribs); buf->setFileReadOnly(false); } @@ -3627,7 +3633,7 @@ void Notepad_plus::command(int id) bool isFirstTime = !_runDlg.isCreated(); _runDlg.doDialog(_isRTL); if (isFirstTime) - changeDlgLang(_runDlg.getHSelf(), "Run"); + changeDlgLang(_runDlg.getHSelf(), TEXT("Run")); break; } @@ -3819,7 +3825,7 @@ void Notepad_plus::command(int id) { ValueDlg tabSizeDlg; NppGUI & nppgui = (NppGUI &)(pNppParam->getNppGUI()); - tabSizeDlg.init(_hInst, _preference.getHSelf(), nppgui._tabSize, "Tab Size : "); + tabSizeDlg.init(_hInst, _preference.getHSelf(), nppgui._tabSize, TEXT("Tab Size : ")); POINT p; ::GetCursorPos(&p); ::ScreenToClient(_hParent, &p); @@ -3840,7 +3846,7 @@ void Notepad_plus::command(int id) ValueDlg valDlg; NppGUI & nppGUI = (NppGUI &)((NppParameters::getInstance())->getNppGUI()); - valDlg.init(_hInst, _preference.getHSelf(), nppGUI._autocFromLen, "Nb char : "); + valDlg.init(_hInst, _preference.getHSelf(), nppGUI._autocFromLen, TEXT("Nb TCHAR : ")); POINT p; ::GetCursorPos(&p); ::ScreenToClient(_hParent, &p); @@ -3862,7 +3868,7 @@ void Notepad_plus::command(int id) { ValueDlg nbHistoryDlg; NppParameters *pNppParam = NppParameters::getInstance(); - nbHistoryDlg.init(_hInst, _preference.getHSelf(), pNppParam->getNbMaxFile(), "Max File : "); + nbHistoryDlg.init(_hInst, _preference.getHSelf(), pNppParam->getNbMaxFile(), TEXT("Max File : ")); POINT p; ::GetCursorPos(&p); ::ScreenToClient(_hParent, &p); @@ -3932,12 +3938,18 @@ void Notepad_plus::command(int id) _aboutDlg.doDialog(); if (isFirstTime && _nativeLang) { - const char *lang = (_nativeLang->ToElement())->Attribute("name"); - if (lang && !strcmp(lang, "¤¤¤åÁcÅé")) + const TCHAR *lang = (_nativeLang->ToElement())->Attribute(TEXT("name")); + if (lang && !lstrcmp(lang, TEXT("¤¤¤åÁcÅé"))) { char *authorName = "«J¤µ§^"; HWND hItem = ::GetDlgItem(_aboutDlg.getHSelf(), IDC_AUTHOR_NAME); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const wchar_t *authorNameW = wmc->char2wchar(authorName, CP_BIG5); + ::SetWindowText(hItem, authorNameW); +#else ::SetWindowText(hItem, authorName); +#endif } } break; @@ -3945,45 +3957,45 @@ void Notepad_plus::command(int id) case IDM_HOMESWEETHOME : { - ::ShellExecute(NULL, "open", "http://notepad-plus.sourceforge.net/", NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), TEXT("http://notepad-plus.sourceforge.net/"), NULL, NULL, SW_SHOWNORMAL); break; } case IDM_PROJECTPAGE : { - ::ShellExecute(NULL, "open", "http://sourceforge.net/projects/notepad-plus/", NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), TEXT("http://sourceforge.net/projects/notepad-plus/"), NULL, NULL, SW_SHOWNORMAL); break; } case IDM_ONLINEHELP: { - ::ShellExecute(NULL, "open", "http://notepad-plus.sourceforge.net/uk/generalFAQ.php", NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), TEXT("http://notepad-plus.sourceforge.net/uk/generalFAQ.php"), NULL, NULL, SW_SHOWNORMAL); break; } case IDM_WIKIFAQ: { - ::ShellExecute(NULL, "open", "http://notepad-plus.wiki.sourceforge.net/FAQ", NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), TEXT("http://notepad-plus.wiki.sourceforge.net/FAQ"), NULL, NULL, SW_SHOWNORMAL); break; } case IDM_FORUM: { - ::ShellExecute(NULL, "open", "http://sourceforge.net/forum/?group_id=95717", NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), TEXT("http://sourceforge.net/forum/?group_id=95717"), NULL, NULL, SW_SHOWNORMAL); break; } case IDM_PLUGINSHOME: { - ::ShellExecute(NULL, "open", "https://sourceforge.net/projects/npp-plugins/", NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), TEXT("https://sourceforge.net/projects/npp-plugins/"), NULL, NULL, SW_SHOWNORMAL); break; } case IDM_UPDATE_NPP : { - string updaterDir = pNppParam->getNppPath(); - updaterDir += "\\updater\\"; - string updaterFullPath = updaterDir + "gup.exe"; - string param = "-verbose -v"; + basic_string updaterDir = pNppParam->getNppPath(); + updaterDir += TEXT("\\updater\\"); + basic_string updaterFullPath = updaterDir + TEXT("gup.exe"); + basic_string param = TEXT("-verbose -v"); param += VERSION_VALUE; Process updater(updaterFullPath.c_str(), param.c_str(), updaterDir.c_str()); updater.run(); @@ -3995,7 +4007,7 @@ void Notepad_plus::command(int id) break; case IDM_EDIT_AUTOCOMPLETE_CURRENTFILE : - //MessageBox(NULL, "IDM_EDIT_AUTOCOMPLETE_CURRENTFILE", "", MB_OK); + //MessageBox(NULL, TEXT("IDM_EDIT_AUTOCOMPLETE_CURRENTFILE"), TEXT(""), MB_OK); autoCompFromCurrentFile(); break; @@ -4128,13 +4140,13 @@ void Notepad_plus::command(int id) TiXmlNode *dlgNode = NULL; if (_nativeLang) { - dlgNode = _nativeLang->FirstChild("Dialog"); + dlgNode = _nativeLang->FirstChild(TEXT("Dialog")); if (dlgNode) - dlgNode = searchDlgNode(dlgNode, "Window"); + dlgNode = searchDlgNode(dlgNode, TEXT("Window")); } _windowsDlg.doDialog(dlgNode); - //changeDlgLang(_windowsDlg.getHSelf(), "Window"); + //changeDlgLang(_windowsDlg.getHSelf(), TEXT("Window")); } break; @@ -4148,7 +4160,7 @@ void Notepad_plus::command(int id) } else if ((id > IDM_LANG_USER) && (id < IDM_LANG_USER_LIMIT)) { - char langName[langNameLenMax]; + TCHAR langName[langNameLenMax]; ::GetMenuString(_mainMenuHandle, id, langName, sizeof(langName), MF_BYCOMMAND); _pEditView->getCurrentBuffer()->setLangType(L_USER, langName); } @@ -4411,14 +4423,14 @@ void Notepad_plus::setTitle() //Get the buffer Buffer * buf = _pEditView->getCurrentBuffer(); - wstring result = L""; + basic_string result = TEXT(""); if (buf->isDirty()) { - result += L"*"; + result += TEXT("*"); } - result += buf->getFilePathW(); - result += L" - "; - result += _classNameW; - ::SetWindowTextW(_hSelf, result.c_str()); + result += buf->getFilePath(); + result += TEXT(" - "); + result += _className; + ::SetWindowText(_hSelf, result.c_str()); } void Notepad_plus::activateNextDoc(bool direction) @@ -4468,18 +4480,18 @@ void Notepad_plus::activateDoc(int pos) void Notepad_plus::updateStatusBar() { Buffer * buf = _pEditView->getCurrentBuffer(); - char strLnCol[64]; - sprintf(strLnCol, "Ln : %d Col : %d Sel : %d",\ + TCHAR strLnCol[64]; + wsprintf(strLnCol, TEXT("Ln : %d Col : %d Sel : %d"),\ (_pEditView->getCurrentLineNumber() + 1), \ (_pEditView->getCurrentColumnNumber() + 1),\ (_pEditView->getSelectedByteNumber())); _statusBar.setText(strLnCol, STATUSBAR_CUR_POS); - char strDonLen[64]; - sprintf(strDonLen, "nb char : %d", _pEditView->getCurrentDocLen()); + TCHAR strDonLen[64]; + wsprintf(strDonLen, TEXT("nb char : %d"), _pEditView->getCurrentDocLen()); _statusBar.setText(strDonLen, STATUSBAR_DOC_SIZE); - _statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? "OVR" : "INS", STATUSBAR_TYPING_MODE); + _statusBar.setText(_pEditView->execute(SCI_GETOVERTYPE) ? TEXT("OVR") : TEXT("INS"), STATUSBAR_TYPING_MODE); } @@ -4507,10 +4519,8 @@ void Notepad_plus::dropFiles(HDROP hdrop) BufferID lastOpened = BUFFER_INVALID; for (int i = 0 ; i < filesDropped ; ++i) { - wchar_t pathDroppedW[MAX_PATH]; - ::DragQueryFileW(hdrop, i, pathDroppedW, sizeof(pathDroppedW)); - char pathDropped[MAX_PATH]; - wchar2char(pathDroppedW, pathDropped); + TCHAR pathDropped[MAX_PATH]; + ::DragQueryFile(hdrop, i, pathDropped, sizeof(pathDropped)); BufferID test = doOpen(pathDropped); if (test != BUFFER_INVALID) lastOpened = test; @@ -4830,7 +4840,6 @@ bool Notepad_plus::activateBuffer(BufferID id, int whichOne) { MainFileManager->reloadBuffer(id); pBuf->setNeedReload(false); } - if (whichOne == MAIN_VIEW) { if (_mainDocTab.activateBuffer(id)) //only activate if possible _mainEditView.activateBuffer(id); @@ -4984,70 +4993,107 @@ void Notepad_plus::showFunctionComp() { autoC->showFunctionComplete(); } -void Notepad_plus::changeMenuLang(string & pluginsTrans, string & windowTrans) +void Notepad_plus::changeMenuLang(basic_string & pluginsTrans, basic_string & windowTrans) { if (!_nativeLang) return; - TiXmlNode *mainMenu = _nativeLang->FirstChild("Menu"); + TiXmlNode *mainMenu = _nativeLang->FirstChild(TEXT("Menu")); if (!mainMenu) return; - mainMenu = mainMenu->FirstChild("Main"); + mainMenu = mainMenu->FirstChild(TEXT("Main")); if (!mainMenu) return; - TiXmlNode *entriesRoot = mainMenu->FirstChild("Entries"); + TiXmlNode *entriesRoot = mainMenu->FirstChild(TEXT("Entries")); if (!entriesRoot) return; - const char *idName = NULL; - for (TiXmlNode *childNode = entriesRoot->FirstChildElement("Item"); + const TCHAR *idName = NULL; + +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); +#endif + + for (TiXmlNode *childNode = entriesRoot->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - if (element->Attribute("id", &id)) + if (element->Attribute(TEXT("id"), &id)) { - const char *name = element->Attribute("name"); + const TCHAR *name = element->Attribute(TEXT("name")); + +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::ModifyMenu(_mainMenuHandle, id, MF_BYPOSITION, 0, nameW); +#else ::ModifyMenu(_mainMenuHandle, id, MF_BYPOSITION, 0, name); +#endif } - else if (idName = element->Attribute("idName")) + else if (idName = element->Attribute(TEXT("idName"))) { - const char *name = element->Attribute("name"); - if (!strcmp(idName, "Plugins")) + const TCHAR *name = element->Attribute(TEXT("name")); + if (!lstrcmp(idName, TEXT("Plugins"))) { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + pluginsTrans = nameW; +#else pluginsTrans = name; +#endif } - else if (!strcmp(idName, "Window")) + else if (!lstrcmp(idName, TEXT("Window"))) { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + windowTrans = nameW; +#else windowTrans = name; +#endif } } } - TiXmlNode *menuCommandsRoot = mainMenu->FirstChild("Commands"); + TiXmlNode *menuCommandsRoot = mainMenu->FirstChild(TEXT("Commands")); - for (TiXmlNode *childNode = menuCommandsRoot->FirstChildElement("Item"); + for (TiXmlNode *childNode = menuCommandsRoot->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - element->Attribute("id", &id); - const char *name = element->Attribute("name"); + element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); + +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::ModifyMenu(_mainMenuHandle, id, MF_BYCOMMAND, id, nameW); +#else ::ModifyMenu(_mainMenuHandle, id, MF_BYCOMMAND, id, name); +#endif } - TiXmlNode *subEntriesRoot = mainMenu->FirstChild("SubEntries"); + TiXmlNode *subEntriesRoot = mainMenu->FirstChild(TEXT("SubEntries")); - for (TiXmlNode *childNode = subEntriesRoot->FirstChildElement("Item"); + for (TiXmlNode *childNode = subEntriesRoot->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int x, y; - element->Attribute("posX", &x); - element->Attribute("posY", &y); - const char *name = element->Attribute("name"); + element->Attribute(TEXT("posX"), &x); + element->Attribute(TEXT("posY"), &y); + const TCHAR *name = element->Attribute(TEXT("name")); +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::ModifyMenu(::GetSubMenu(_mainMenuHandle, x), y, MF_BYPOSITION, 0, nameW); +#else ::ModifyMenu(::GetSubMenu(_mainMenuHandle, x), y, MF_BYPOSITION, 0, name); +#endif } ::DrawMenuBar(_hSelf); } @@ -5056,54 +5102,83 @@ void Notepad_plus::changeConfigLang() { if (!_nativeLang) return; - TiXmlNode *styleConfDlgNode = _nativeLang->FirstChild("Dialog"); + TiXmlNode *styleConfDlgNode = _nativeLang->FirstChild(TEXT("Dialog")); if (!styleConfDlgNode) return; - styleConfDlgNode = styleConfDlgNode->FirstChild("StyleConfig"); + styleConfDlgNode = styleConfDlgNode->FirstChild(TEXT("StyleConfig")); if (!styleConfDlgNode) return; HWND hDlg = _configStyleDlg.getHSelf(); - // Set Title - const char *titre = (styleConfDlgNode->ToElement())->Attribute("title"); - if ((titre && titre[0]) && hDlg) - ::SetWindowText(hDlg, titre); - for (TiXmlNode *childNode = styleConfDlgNode->FirstChildElement("Item"); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); +#endif + + // Set Title + const TCHAR *titre = (styleConfDlgNode->ToElement())->Attribute(TEXT("title")); + + if ((titre && titre[0]) && hDlg) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hDlg, nameW); +#else + ::SetWindowText(hDlg, titre); +#endif + } + for (TiXmlNode *childNode = styleConfDlgNode->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - const char *sentinel = element->Attribute("id", &id); - const char *name = element->Attribute("name"); + const TCHAR *sentinel = element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, name); +#endif + } } } hDlg = _configStyleDlg.getHSelf(); - styleConfDlgNode = styleConfDlgNode->FirstChild("SubDialog"); + styleConfDlgNode = styleConfDlgNode->FirstChild(TEXT("SubDialog")); - for (TiXmlNode *childNode = styleConfDlgNode->FirstChildElement("Item"); + for (TiXmlNode *childNode = styleConfDlgNode->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - const char *sentinel = element->Attribute("id", &id); - const char *name = element->Attribute("name"); + const TCHAR *sentinel = element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, name); +#endif + } } } } -void Notepad_plus::changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText) +void Notepad_plus::changeStyleCtrlsLang(HWND hDlg, int *idArray, const TCHAR **translatedText) { const int iColorStyle = 0; const int iUnderline = 8; @@ -5115,7 +5190,17 @@ void Notepad_plus::changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **tr { hItem = ::GetDlgItem(hDlg, idArray[i]); if (hItem) + { +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char *pCharStrA = wmc->wchar2char(translatedText[i], CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, translatedText[i]); +#endif + + } } } } @@ -5124,34 +5209,45 @@ void Notepad_plus::changeUserDefineLang() { if (!_nativeLang) return; - TiXmlNode *userDefineDlgNode = _nativeLang->FirstChild("Dialog"); + TiXmlNode *userDefineDlgNode = _nativeLang->FirstChild(TEXT("Dialog")); if (!userDefineDlgNode) return; - userDefineDlgNode = userDefineDlgNode->FirstChild("UserDefine"); + userDefineDlgNode = userDefineDlgNode->FirstChild(TEXT("UserDefine")); if (!userDefineDlgNode) return; UserDefineDialog *userDefineDlg = _pEditView->getUserDefineDlg(); HWND hDlg = userDefineDlg->getHSelf(); - // Set Title - const char *titre = (userDefineDlgNode->ToElement())->Attribute("title"); - if (titre && titre[0]) - ::SetWindowText(hDlg, titre); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); +#endif + // Set Title + const TCHAR *titre = (userDefineDlgNode->ToElement())->Attribute(TEXT("title")); + if (titre && titre[0]) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hDlg, nameW); +#else + ::SetWindowText(hDlg, titre); +#endif + } // pour ses propres controls const int nbControl = 9; - const char *translatedText[nbControl]; + const TCHAR *translatedText[nbControl]; for (int i = 0 ; i < nbControl ; i++) translatedText[i] = NULL; - for (TiXmlNode *childNode = userDefineDlgNode->FirstChildElement("Item"); + for (TiXmlNode *childNode = userDefineDlgNode->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - const char *sentinel = element->Attribute("id", &id); - const char *name = element->Attribute("name"); + const TCHAR *sentinel = element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); if (sentinel && (name && name[0])) { @@ -5159,7 +5255,15 @@ void Notepad_plus::changeUserDefineLang() { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, name); +#endif + } } else { @@ -5210,7 +5314,7 @@ void Notepad_plus::changeUserDefineLang() }; int nbGpArray[nbDlg] = {nbGrpFolder, nbGrpKeywords, nbGrpComment, nbGrpOperator}; - const char nodeNameArray[nbDlg][16] = {"Folder", "Keywords", "Comment", "Operator"}; + const TCHAR nodeNameArray[nbDlg][16] = {TEXT("Folder"), TEXT("Keywords"), TEXT("Comment"), TEXT("Operator")}; //int **idArrays[nbDlg] = {(int **)folderID, (int **)keywordsID, (int **)commentID, (int **)operatorID}; @@ -5232,23 +5336,38 @@ void Notepad_plus::changeUserDefineLang() if (node) { // Set Title - titre = (node->ToElement())->Attribute("title"); + titre = (node->ToElement())->Attribute(TEXT("title")); if (titre &&titre[0]) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + userDefineDlg->setTabName(i, nameW); +#else userDefineDlg->setTabName(i, titre); - - for (TiXmlNode *childNode = node->FirstChildElement("Item"); +#endif + } + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - const char *sentinel = element->Attribute("id", &id); - const char *name = element->Attribute("name"); + const TCHAR *sentinel = element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlgArrary[i], id); if (hItem) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, name); +#endif + } } } } @@ -5257,46 +5376,116 @@ void Notepad_plus::changeUserDefineLang() void Notepad_plus::changePrefereceDlgLang() { - changeDlgLang(_preference.getHSelf(), "Preference"); + changeDlgLang(_preference.getHSelf(), TEXT("Preference")); - char title[64]; - - changeDlgLang(_preference._barsDlg.getHSelf(), "Global", title); - if (*title) - _preference._ctrlTab.renameTab("Global", title); + TCHAR titre[64]; - changeDlgLang(_preference._marginsDlg.getHSelf(), "Scintillas", title); - if (*title) - _preference._ctrlTab.renameTab("Scintillas", title); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); +#endif - changeDlgLang(_preference._defaultNewDocDlg.getHSelf(), "NewDoc", title); - if (*title) - _preference._ctrlTab.renameTab("NewDoc", title); + changeDlgLang(_preference._barsDlg.getHSelf(), TEXT("Global"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("Global"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("Global"), titre); +#endif + } + changeDlgLang(_preference._marginsDlg.getHSelf(), TEXT("Scintillas"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("Scintillas"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("Scintillas"), titre); +#endif + } - changeDlgLang(_preference._fileAssocDlg.getHSelf(), "FileAssoc", title); - if (*title) - _preference._ctrlTab.renameTab("FileAssoc", title); + changeDlgLang(_preference._defaultNewDocDlg.getHSelf(), TEXT("NewDoc"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("NewDoc"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("NewDoc"), titre); +#endif + } + changeDlgLang(_preference._fileAssocDlg.getHSelf(), TEXT("FileAssoc"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("FileAssoc"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("FileAssoc"), titre); +#endif + } - changeDlgLang(_preference._langMenuDlg.getHSelf(), "LangMenu", title); - if (*title) - _preference._ctrlTab.renameTab("LangMenu", title); - - changeDlgLang(_preference._printSettingsDlg.getHSelf(), "Print1", title); - if (*title) - _preference._ctrlTab.renameTab("Print1", title); - - changeDlgLang(_preference._printSettings2Dlg.getHSelf(), "Print2", title); - if (*title) - _preference._ctrlTab.renameTab("Print2", title); - - changeDlgLang(_preference._settingsDlg.getHSelf(), "MISC", title); - if (*title) - _preference._ctrlTab.renameTab("MISC", title); - - changeDlgLang(_preference._backupDlg.getHSelf(), "Backup", title); - if (*title) - _preference._ctrlTab.renameTab("Backup", title); + changeDlgLang(_preference._langMenuDlg.getHSelf(), TEXT("LangMenu"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("LangMenu"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("LangMenu"), titre); +#endif + } + changeDlgLang(_preference._printSettingsDlg.getHSelf(), TEXT("Print1"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("Print1"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("Print1"), titre); +#endif + } + changeDlgLang(_preference._printSettings2Dlg.getHSelf(), TEXT("Print2"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("Print2"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("Print2"), titre); +#endif + } + changeDlgLang(_preference._settingsDlg.getHSelf(), TEXT("MISC"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("MISC"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("MISC"), titre); +#endif + } + changeDlgLang(_preference._backupDlg.getHSelf(), TEXT("Backup"), titre); + if (*titre) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + _preference._ctrlTab.renameTab(TEXT("Backup"), nameW); +#else + _preference._ctrlTab.renameTab(TEXT("Backup"), titre); +#endif + } } void Notepad_plus::changeShortcutLang() @@ -5309,25 +5498,25 @@ void Notepad_plus::changeShortcutLang() int mainSize = (int)mainshortcuts.size(); int scinSize = (int)scinshortcuts.size(); - TiXmlNode *shortcuts = _nativeLang->FirstChild("Shortcuts"); + TiXmlNode *shortcuts = _nativeLang->FirstChild(TEXT("Shortcuts")); if (!shortcuts) return; - shortcuts = shortcuts->FirstChild("Main"); + shortcuts = shortcuts->FirstChild(TEXT("Main")); if (!shortcuts) return; - TiXmlNode *entriesRoot = shortcuts->FirstChild("Entries"); + TiXmlNode *entriesRoot = shortcuts->FirstChild(TEXT("Entries")); if (!entriesRoot) return; - for (TiXmlNode *childNode = entriesRoot->FirstChildElement("Item"); + for (TiXmlNode *childNode = entriesRoot->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int index, id; - if (element->Attribute("index", &index) && element->Attribute("id", &id)) + if (element->Attribute(TEXT("index"), &index) && element->Attribute(TEXT("id"), &id)) { if (index > -1 && index < mainSize) { //valid index only - const char *name = element->Attribute("name"); + const TCHAR *name = element->Attribute(TEXT("name")); CommandShortcut & csc = mainshortcuts[index]; if (csc.getID() == id) { csc.setName(name); @@ -5337,25 +5526,25 @@ void Notepad_plus::changeShortcutLang() } //Scintilla - shortcuts = _nativeLang->FirstChild("Shortcuts"); + shortcuts = _nativeLang->FirstChild(TEXT("Shortcuts")); if (!shortcuts) return; - shortcuts = shortcuts->FirstChild("Scintilla"); + shortcuts = shortcuts->FirstChild(TEXT("Scintilla")); if (!shortcuts) return; - entriesRoot = shortcuts->FirstChild("Entries"); + entriesRoot = shortcuts->FirstChild(TEXT("Entries")); if (!entriesRoot) return; - for (TiXmlNode *childNode = entriesRoot->FirstChildElement("Item"); + for (TiXmlNode *childNode = entriesRoot->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int index; - if (element->Attribute("index", &index)) + if (element->Attribute(TEXT("index"), &index)) { if (index > -1 && index < scinSize) { //valid index only - const char *name = element->Attribute("name"); + const TCHAR *name = element->Attribute(TEXT("name")); ScintillaKeyMap & skm = scinshortcuts[index]; skm.setName(name); } @@ -5368,22 +5557,22 @@ void Notepad_plus::changeShortcutmapperLang(ShortcutMapper * sm) { if (!_nativeLang) return; - TiXmlNode *shortcuts = _nativeLang->FirstChild("Dialog"); + TiXmlNode *shortcuts = _nativeLang->FirstChild(TEXT("Dialog")); if (!shortcuts) return; - shortcuts = shortcuts->FirstChild("ShortcutMapper"); + shortcuts = shortcuts->FirstChild(TEXT("ShortcutMapper")); if (!shortcuts) return; - for (TiXmlNode *childNode = shortcuts->FirstChildElement("Item"); + for (TiXmlNode *childNode = shortcuts->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int index; - if (element->Attribute("index", &index)) + if (element->Attribute(TEXT("index"), &index)) { if (index > -1 && index < 5) { //valid index only - const char *name = element->Attribute("name"); + const TCHAR *name = element->Attribute(TEXT("name")); sm->translateTab(index, name); } } @@ -5391,7 +5580,7 @@ void Notepad_plus::changeShortcutmapperLang(ShortcutMapper * sm) } -TiXmlNode * searchDlgNode(TiXmlNode *node, const char *dlgTagName) +TiXmlNode * searchDlgNode(TiXmlNode *node, const TCHAR *dlgTagName) { TiXmlNode *dlgNode = node->FirstChild(dlgTagName); if (dlgNode) return dlgNode; @@ -5405,60 +5594,78 @@ TiXmlNode * searchDlgNode(TiXmlNode *node, const char *dlgTagName) return NULL; } -bool Notepad_plus::changeDlgLang(HWND hDlg, const char *dlgTagName, char *title) +bool Notepad_plus::changeDlgLang(HWND hDlg, const TCHAR *dlgTagName, TCHAR *title) { if (title) title[0] = '\0'; if (!_nativeLang) return false; - TiXmlNode *dlgNode = _nativeLang->FirstChild("Dialog"); + TiXmlNode *dlgNode = _nativeLang->FirstChild(TEXT("Dialog")); if (!dlgNode) return false; dlgNode = searchDlgNode(dlgNode, dlgTagName); if (!dlgNode) return false; +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); +#endif + // Set Title - const char *titre = (dlgNode->ToElement())->Attribute("title"); + const TCHAR *titre = (dlgNode->ToElement())->Attribute(TEXT("title")); if ((titre && titre[0]) && hDlg) { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hDlg, nameW); +#else ::SetWindowText(hDlg, titre); +#endif if (title) - strcpy(title, titre); + lstrcpy(title, titre); } // Set the text of child control - for (TiXmlNode *childNode = dlgNode->FirstChildElement("Item"); + for (TiXmlNode *childNode = dlgNode->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - const char *sentinel = element->Attribute("id", &id); - const char *name = element->Attribute("name"); + const TCHAR *sentinel = element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(hDlg, id); if (hItem) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, _nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, name); +#endif + } } } return true; } -static string extractSymbol(char prefix, const char *str2extract) +static basic_string extractSymbol(TCHAR prefix, const TCHAR *str2extract) { bool found = false; - char extracted[128] = ""; + TCHAR extracted[128] = TEXT(""); - for (size_t i = 0, j = 0 ; i < strlen(str2extract) ; i++) + for (int i = 0, j = 0 ; i < lstrlen(str2extract) ; i++) { if (found) { if (!str2extract[i] || str2extract[i] == ' ') { extracted[j] = '\0'; - return string(extracted); + return basic_string(extracted); } extracted[j++] = str2extract[i]; @@ -5466,19 +5673,19 @@ static string extractSymbol(char prefix, const char *str2extract) else { if (!str2extract[i]) - return ""; + return TEXT(""); if (str2extract[i] == prefix) found = true; } } - return string(extracted); + return basic_string(extracted); }; bool Notepad_plus::doBlockComment(comment_mode currCommentMode) { - const char *commentLineSybol; - string symbol; + const TCHAR *commentLineSybol; + basic_string symbol; Buffer * buf = _pEditView->getCurrentBuffer(); if (buf->getLangType() == L_USER) @@ -5497,11 +5704,11 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) if ((!commentLineSybol) || (!commentLineSybol[0])) return false; - string comment(commentLineSybol); - comment += " "; - string long_comment = comment; + basic_string comment(commentLineSybol); + comment += TEXT(" "); + basic_string long_comment = comment; - char linebuf[1000]; + TCHAR linebuf[1000]; size_t comment_length = comment.length(); size_t selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART); size_t selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND); @@ -5528,10 +5735,10 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) } else*/ { lineIndent = _pEditView->execute(SCI_GETLINEINDENTPOSITION, i); - _pEditView->getText(linebuf, lineIndent, lineEnd); + _pEditView->getGenericText(linebuf, lineIndent, lineEnd); } // empty lines are not commented - if (strlen(linebuf) < 1) + if (lstrlen(linebuf) < 1) continue; if (currCommentMode != cm_comment) { @@ -5541,7 +5748,8 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) { // removing comment with space after it _pEditView->execute(SCI_SETSEL, lineIndent, lineIndent + comment_length); - _pEditView->execute(SCI_REPLACESEL, 0, (WPARAM)""); + _pEditView->replaceSelWith(""); + if (i == selStartLine) // is this the first selected line? selectionStart -= comment_length; selectionEnd -= comment_length; // every iteration @@ -5551,7 +5759,7 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) { // removing comment _without_ space _pEditView->execute(SCI_SETSEL, lineIndent, lineIndent + comment_length - 1); - _pEditView->execute(SCI_REPLACESEL, 0, (WPARAM)""); + _pEditView->replaceSelWith(""); if (i == selStartLine) // is this the first selected line? selectionStart -= (comment_length - 1); selectionEnd -= (comment_length - 1); // every iteration @@ -5564,7 +5772,7 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) if (i == selStartLine) // is this the first selected line? selectionStart += comment_length; selectionEnd += comment_length; // every iteration - _pEditView->execute(SCI_INSERTTEXT, lineIndent, (WPARAM)long_comment.c_str()); + _pEditView->insertGenericTextFrom(lineIndent, long_comment.c_str()); } } // after uncommenting selection may promote itself to the lines @@ -5592,11 +5800,11 @@ bool Notepad_plus::doBlockComment(comment_mode currCommentMode) bool Notepad_plus::doStreamComment() { - const char *commentStart; - const char *commentEnd; + const TCHAR *commentStart; + const TCHAR *commentEnd; - string symbolStart; - string symbolEnd; + basic_string symbolStart; + basic_string symbolEnd; Buffer * buf = _pEditView->getCurrentBuffer(); if (buf->getLangType() == L_USER) @@ -5622,9 +5830,9 @@ bool Notepad_plus::doStreamComment() if ((!commentEnd) || (!commentEnd[0])) return false; - string start_comment(commentStart); - string end_comment(commentEnd); - string white_space(" "); + basic_string start_comment(commentStart); + basic_string end_comment(commentEnd); + basic_string white_space(TEXT(" ")); start_comment += white_space; white_space += end_comment; @@ -5642,8 +5850,8 @@ bool Notepad_plus::doStreamComment() int lineIndent = _pEditView->execute(SCI_GETLINEINDENTPOSITION, selLine); int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, selLine); - char linebuf[1000]; - _pEditView->getText(linebuf, lineIndent, lineEnd); + TCHAR linebuf[1000]; + _pEditView->getGenericText(linebuf, lineIndent, lineEnd); int caret = _pEditView->execute(SCI_GETCURRENTPOS); int line = _pEditView->execute(SCI_LINEFROMPOSITION, caret); @@ -5672,10 +5880,10 @@ bool Notepad_plus::doStreamComment() selectionEnd += (end_counter + 1); } _pEditView->execute(SCI_BEGINUNDOACTION); - _pEditView->execute(SCI_INSERTTEXT, selectionStart, (WPARAM)start_comment.c_str()); + _pEditView->insertGenericTextFrom(selectionStart, start_comment.c_str()); selectionEnd += start_comment_length; selectionStart += start_comment_length; - _pEditView->execute(SCI_INSERTTEXT, selectionEnd, (WPARAM)end_comment.c_str()); + _pEditView->insertGenericTextFrom(selectionEnd, end_comment.c_str()); if (move_caret) { // moving caret to the beginning of selected block @@ -5863,6 +6071,7 @@ void Notepad_plus::getTaskListInfo(TaskListInfo *tli) LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { LRESULT result = FALSE; + NppParameters *pNppParam = NppParameters::getInstance(); switch (Message) { @@ -5870,7 +6079,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { // Note: lParam is -1 to prevent endless loops of calls ::SendMessage(_dockingManager.getHSelf(), WM_NCACTIVATE, wParam, (LPARAM)-1); - return ::DefWindowProcW(hwnd, Message, wParam, lParam); + return ::DefWindowProc(hwnd, Message, wParam, lParam); } case WM_CREATE: { @@ -6016,7 +6225,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _dockingManager.init(_hInst, hwnd, &_pMainWindow); if (nppGUI._isMinimizedToTray) - _pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), ""); + _pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); checkSyncState(); @@ -6029,7 +6238,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _scintillaCtrls4Plugins.init(_hInst, hwnd); _pluginsManager.init(nppData); _pluginsManager.loadPlugins(); - const char *appDataNpp = pNppParam->getAppDataNppDir(); + const TCHAR *appDataNpp = pNppParam->getAppDataNppDir(); if (appDataNpp[0]) _pluginsManager.loadPlugins(appDataNpp); @@ -6063,7 +6272,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa // Updater menu item if (!nppGUI._doesExistUpdater) { - //::MessageBox(NULL, "pas de updater", "", MB_OK); + //::MessageBox(NULL, TEXT("pas de updater"), TEXT(""), MB_OK); ::DeleteMenu(_mainMenuHandle, IDM_UPDATE_NPP, MF_BYCOMMAND); ::DrawMenuBar(hwnd); } @@ -6076,10 +6285,10 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa ExternalLangContainer & externalLangContainer = pNppParam->getELCFromIndex(i); int numLangs = ::GetMenuItemCount(hLangMenu); - char buffer[100]; + TCHAR buffer[100]; int x; - for(x = 0; (x == 0 || strcmp(externalLangContainer._name, buffer) > 0) && x < numLangs; x++) + for(x = 0; (x == 0 || lstrcmp(externalLangContainer._name, buffer) > 0) && x < numLangs; x++) { ::GetMenuString(hLangMenu, x, buffer, sizeof(buffer), MF_BYPOSITION); } @@ -6092,7 +6301,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa for (size_t i = 0 ; i < nppGUI._excludedLangList.size() ; i++) { int cmdID = pNppParam->langTypeToCommandID(nppGUI._excludedLangList[i]._langType); - char itemName[256]; + TCHAR itemName[256]; ::GetMenuString(hLangMenu, cmdID, itemName, sizeof(itemName), MF_BYCOMMAND); nppGUI._excludedLangList[i]._cmdID = cmdID; nppGUI._excludedLangList[i]._langName = itemName; @@ -6118,7 +6327,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _lastRecentFileList.initMenu(hFileMenu, IDM_FILEMENU_LASTONE + 1, pos); for (int i = 0 ; i < nbLRFile ; i++) { - string * stdStr = pNppParam->getLRFile(i); + basic_string * stdStr = pNppParam->getLRFile(i); if (nppGUI._checkHistoryFiles) { if (PathFileExists(stdStr->c_str())) @@ -6144,10 +6353,10 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _subEditView.execute(SCI_USEPOPUP, FALSE); } - string pluginsTrans, windowTrans; + basic_string pluginsTrans, windowTrans; changeMenuLang(pluginsTrans, windowTrans); - if (pluginsTrans != "") + if (_pluginsManager.hasPlugins() && pluginsTrans != TEXT("")) { ::ModifyMenu(_mainMenuHandle, MENUINDEX_PLUGINS, MF_BYPOSITION, 0, pluginsTrans.c_str()); } @@ -6157,17 +6366,16 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa // Update context menu strings vector & tmp = pNppParam->getContextMenuItems(); size_t len = tmp.size(); - char menuName[64]; + TCHAR menuName[64]; for (size_t i = 0 ; i < len ; i++) { - if (tmp[i]._itemName == "") + if (tmp[i]._itemName == TEXT("")) { ::GetMenuString(_mainMenuHandle, tmp[i]._cmdID, menuName, 64, MF_BYCOMMAND); tmp[i]._itemName = purgeMenuItemString(menuName); } } - //Input all the menu item names into shortcut list //This will automatically do all translations, since menu translation has been done already vector & shortcuts = pNppParam->getUserShortcuts(); @@ -6321,29 +6529,29 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_REMOVE_USERLANG: { - char name[256]; - strcpy(name, (char *)lParam); - //loop through buffers and reset the language (L_USER, "") if (L_USER, name) + TCHAR name[256]; + lstrcpy(name, (TCHAR *)lParam); + //loop through buffers and reset the language (L_USER, TEXT("")) if (L_USER, name) Buffer * buf; for(int i = 0; i < MainFileManager->getNrBuffers(); i++) { buf = MainFileManager->getBufferByIndex(i); - if (buf->getLangType() == L_USER && !strcmp(buf->getUserDefineLangName(), name)) - buf->setLangType(L_USER, ""); + if (buf->getLangType() == L_USER && !lstrcmp(buf->getUserDefineLangName(), name)) + buf->setLangType(L_USER, TEXT("")); } return TRUE; } case WM_RENAME_USERLANG: { - char oldName[256]; - char newName[256]; - strcpy(oldName, (char *)lParam); - strcpy(newName, (char *)wParam); + TCHAR oldName[256]; + TCHAR newName[256]; + lstrcpy(oldName, (TCHAR *)lParam); + lstrcpy(newName, (TCHAR *)wParam); //loop through buffers and reset the language (L_USER, newName) if (L_USER, oldName) Buffer * buf; for(int i = 0; i < MainFileManager->getNrBuffers(); i++) { buf = MainFileManager->getBufferByIndex(i); - if (buf->getLangType() == L_USER && !strcmp(buf->getUserDefineLangName(), oldName)) + if (buf->getLangType() == L_USER && !lstrcmp(buf->getUserDefineLangName(), oldName)) buf->setLangType(L_USER, newName); } return TRUE; @@ -6379,54 +6587,52 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_LAUNCHFINDINFILESDLG : { const int strSize = 64; - char str[strSize]; + TCHAR str[strSize]; bool isFirstTime = !_findReplaceDlg.isCreated(); _findReplaceDlg.doDialog(FIND_DLG, _isRTL); - _pEditView->getSelectedText(str, strSize); - _findReplaceDlg.setSearchText(str); + _pEditView->getGenericSelectedText(str, strSize); + _findReplaceDlg.setSearchText(str, _pEditView->getCurrentBuffer()->getUnicodeMode() != uni8Bit); if (isFirstTime) - changeDlgLang(_findReplaceDlg.getHSelf(), "Find"); + changeDlgLang(_findReplaceDlg.getHSelf(), TEXT("Find")); _findReplaceDlg.launchFindInFilesDlg(); - const char *dir = NULL; - char currentDir[MAX_PATH]; - string fltr; + const TCHAR *dir = NULL; + TCHAR currentDir[MAX_PATH]; + basic_string fltr; if (wParam) - dir = (const char *)wParam; + dir = (const TCHAR *)wParam; else { - wchar_t currentDirW[MAX_PATH]; - ::GetCurrentDirectoryW(MAX_PATH, currentDirW); - wchar2char(currentDirW, currentDir); + ::GetCurrentDirectory(MAX_PATH, currentDir); dir = currentDir; } if (lParam) { - fltr = (const char *)lParam; + fltr = (const TCHAR *)lParam; } else { LangType lt = _pEditView->getCurrentBuffer()->getLangType(); - const char *ext = NppParameters::getInstance()->getLangExtFromLangType(lt); + const TCHAR *ext = NppParameters::getInstance()->getLangExtFromLangType(lt); if (ext && ext[0]) { - string filtres = ""; - vector vStr; + basic_string filtres = TEXT(""); + vector> vStr; cutString(ext, vStr); for (size_t i = 0 ; i < vStr.size() ; i++) { - filtres += "*."; - filtres += vStr[i] + " "; + filtres += TEXT("*."); + filtres += vStr[i] + TEXT(" "); } fltr = filtres; } else - fltr = "*.*"; + fltr = TEXT("*.*"); } _findReplaceDlg.setFindInFilesDirFilter(dir, fltr.c_str()); return TRUE; @@ -6434,7 +6640,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case WM_DOOPEN: { - BufferID id = doOpen((const char *)lParam); + BufferID id = doOpen((const TCHAR *)lParam); if (id != BUFFER_INVALID) { return switchToFile(id); } @@ -6443,7 +6649,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_RELOADFILE: { - BufferID id = MainFileManager->getBufferFromName((const char *)lParam); + BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); if (id != BUFFER_INVALID) doReload(id, wParam != 0); } @@ -6451,7 +6657,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_SWITCHTOFILE : { - BufferID id = MainFileManager->getBufferFromName((const char *)lParam); + BufferID id = MainFileManager->getBufferFromName((const TCHAR *)lParam); if (id != BUFFER_INVALID) return switchToFile(id); return false; @@ -6524,10 +6730,32 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa break; } - case COPYDATA_FILENAMES : + case COPYDATA_FILENAMESA : { + char *fileNamesA = (char *)pCopyData->lpData; CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); - loadCommandlineParams((const wchar_t *)pCopyData->lpData, &cmdLineParams); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const wchar_t *fileNamesW = wmc->char2wchar(fileNamesA, CP_ACP); + loadCommandlineParams(fileNamesW, &cmdLineParams); +#else + loadCommandlineParams(fileNamesA, &cmdLineParams); +#endif + break; + } + + case COPYDATA_FILENAMESW : + { + wchar_t *fileNamesW = (wchar_t *)pCopyData->lpData; + CmdLineParams & cmdLineParams = pNppParam->getCmdLineParams(); + +#ifdef UNICODE + loadCommandlineParams(fileNamesW, &cmdLineParams); +#else + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char *fileNamesA = wmc->wchar2char(fileNamesW, CP_ACP); + loadCommandlineParams(fileNamesA, &cmdLineParams); +#endif break; } } @@ -6561,87 +6789,83 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETNAMEPART : case NPPM_GETEXTPART : { - wchar_t str[MAX_PATH]; + TCHAR str[MAX_PATH]; // par defaut : NPPM_GETCURRENTDIRECTORY - wchar_t *fileStr = wcscpy(str, _pEditView->getCurrentBuffer()->getFilePathW()); + TCHAR *fileStr = lstrcpy(str, _pEditView->getCurrentBuffer()->getFilePath()); if (Message == NPPM_GETCURRENTDIRECTORY) - PathRemoveFileSpecW(str); + PathRemoveFileSpec(str); else if (Message == NPPM_GETFILENAME) - fileStr = PathFindFileNameW(str); + fileStr = PathFindFileName(str); else if (Message == NPPM_GETNAMEPART) { - fileStr = PathFindFileNameW(str); - PathRemoveExtensionW(fileStr); + fileStr = PathFindFileName(str); + PathRemoveExtension(fileStr); } else if (Message == NPPM_GETEXTPART) - fileStr = PathFindExtensionW(str); + fileStr = PathFindExtension(str); - // For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough. - // otherwise we check if the string buffer size is enough for the string to copy. + // For the compability reason, if wParam is 0, then we assume the size of basic_string buffer (lParam) is large enough. + // otherwise we check if the basic_string buffer size is enough for the basic_string to copy. if (wParam != 0) { - if (wcslen(fileStr) >= wParam) + if (lstrlen(fileStr) >= int(wParam)) { - ::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM error", MB_OK); + ::MessageBox(_hSelf, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM error"), MB_OK); return FALSE; } } - wcscpy((wchar_t *)lParam, fileStr); + lstrcpy((TCHAR *)lParam, fileStr); return TRUE; } case NPPM_GETCURRENTWORD : { const int strSize = MAX_PATH; - char str[strSize]; + TCHAR str[strSize]; - _pEditView->getSelectedText((char *)str, strSize); - // For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough. - // otherwise we check if the string buffer size is enough for the string to copy. + _pEditView->getGenericSelectedText((TCHAR *)str, strSize); + // For the compability reason, if wParam is 0, then we assume the size of basic_string buffer (lParam) is large enough. + // otherwise we check if the basic_string buffer size is enough for the basic_string to copy. if (wParam != 0) { - if (strlen(str) >= wParam) //buffer too small + if (lstrlen(str) >= int(wParam)) //buffer too small { - ::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETCURRENTWORD error", MB_OK); + ::MessageBox(_hSelf, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM_GETCURRENTWORD error"), MB_OK); return FALSE; } else //buffer large enough, perform safe copy { - wchar_t strW[strSize]; - char2wchar(str, strW); - lstrcpynW((wchar_t *)lParam, strW, wParam); + lstrcpyn((TCHAR *)lParam, str, wParam); return TRUE; } } - wchar_t strW[strSize]; - char2wchar(str, strW); - wcscpy((wchar_t *)lParam, strW); + lstrcpy((TCHAR *)lParam, str); return TRUE; } case NPPM_GETNPPDIRECTORY : { const int strSize = MAX_PATH; - wchar_t str[strSize]; + TCHAR str[strSize]; - ::GetModuleFileNameW(NULL, str, strSize); - PathRemoveFileSpecW(str); + ::GetModuleFileName(NULL, str, strSize); + PathRemoveFileSpec(str); - // For the compability reason, if wParam is 0, then we assume the size of string buffer (lParam) is large enough. - // otherwise we check if the string buffer size is enough for the string to copy. + // For the compability reason, if wParam is 0, then we assume the size of basic_string buffer (lParam) is large enough. + // otherwise we check if the basic_string buffer size is enough for the basic_string to copy. if (wParam != 0) { - if (wcslen(str) >= wParam) + if (lstrlen(str) >= int(wParam)) { - ::MessageBox(_hSelf, "Allocated buffer size is not enough to copy the string.", "NPPM_GETNPPDIRECTORY error", MB_OK); + ::MessageBox(_hSelf, TEXT("Allocated buffer size is not enough to copy the string."), TEXT("NPPM_GETNPPDIRECTORY error"), MB_OK); return FALSE; } } - wcscpy((wchar_t *)lParam, str); + lstrcpy((TCHAR *)lParam, str); return TRUE; } @@ -6691,7 +6915,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { if (!wParam) return 0; - char **fileNames = (char **)wParam; + TCHAR **fileNames = (TCHAR **)wParam; int nbFileNames = lParam; int j = 0; @@ -6700,7 +6924,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { BufferID id = _mainDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(id); - strcpy(fileNames[j++], buf->getFilePath()); + lstrcpy(fileNames[j++], buf->getFilePath()); } } if (Message != NPPM_GETOPENFILENAMESPRIMARY) { @@ -6708,7 +6932,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { BufferID id = _subDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(id); - strcpy(fileNames[j++], buf->getFilePath()); + lstrcpy(fileNames[j++], buf->getFilePath()); } } return j; @@ -6765,12 +6989,12 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa activateNextDoc((GET_APPCOMMAND_LPARAM(lParam) == APPCOMMAND_BROWSER_FORWARD)?dirDown:dirUp); _linkTriggered = true; } - return ::DefWindowProcW(hwnd, Message, wParam, lParam); + return ::DefWindowProc(hwnd, Message, wParam, lParam); } case NPPM_GETNBSESSIONFILES : { - const char *sessionFileName = (const char *)lParam; + const TCHAR *sessionFileName = (const TCHAR *)lParam; if ((!sessionFileName) || (sessionFileName[0] == '\0')) return 0; Session session2Load; if (pNppParam->loadSession(session2Load, sessionFileName)) @@ -6782,8 +7006,8 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETSESSIONFILES : { - const char *sessionFileName = (const char *)lParam; - char **sessionFileArray = (char **)wParam; + const TCHAR *sessionFileName = (const TCHAR *)lParam; + TCHAR **sessionFileArray = (TCHAR **)wParam; if ((!sessionFileName) || (sessionFileName[0] == '\0')) return FALSE; @@ -6793,21 +7017,21 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa size_t i = 0; for ( ; i < session2Load.nbMainFiles() ; ) { - const char *pFn = session2Load._mainViewFiles[i]._fileName.c_str(); - strcpy(sessionFileArray[i++], pFn); + const TCHAR *pFn = session2Load._mainViewFiles[i]._fileName.c_str(); + lstrcpy(sessionFileArray[i++], pFn); } for (size_t j = 0 ; j < session2Load.nbSubFiles() ; j++) { - const char *pFn = session2Load._subViewFiles[j]._fileName.c_str(); + const TCHAR *pFn = session2Load._subViewFiles[j]._fileName.c_str(); // comment to remove /* // make sure that the same file is not cloned in another view bool foundInMainView = false; for (size_t k = 0 ; k < session2Load.nbMainFiles() ; k++) { - const char *pFnMain = session2Load._mainViewFiles[k]._fileName.c_str(); - if (strcmp(pFn, pFnMain) == 0) + const TCHAR *pFnMain = session2Load._mainViewFiles[k]._fileName.c_str(); + if (lstrcmp(pFn, pFnMain) == 0) { foundInMainView = true; break; @@ -6815,7 +7039,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } if (!foundInMainView) */ - strcpy(sessionFileArray[i++], pFn); + lstrcpy(sessionFileArray[i++], pFn); } return TRUE; } @@ -6850,7 +7074,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa // set text in target pSci->execute(SCI_CLEARALL); - pSci->execute(SCI_ADDTEXT, length, (LPARAM)UnicodeConvertor.getNewBuf()); + pSci->addText(length, UnicodeConvertor.getNewBuf()); pSci->execute(SCI_EMPTYUNDOBUFFER); pSci->execute(SCI_SETCODEPAGE); @@ -6881,14 +7105,16 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa // get text of current scintilla length = pSci->execute(SCI_GETTEXTLENGTH, 0, 0) + 1; - buffer = (char*)new char[length]; + buffer = new char[length]; pSci->execute(SCI_GETTEXT, length, (LPARAM)buffer); length = UnicodeConvertor.convert(buffer, length-1); // set text in target pSci->execute(SCI_CLEARALL); - pSci->execute(SCI_ADDTEXT, length, (LPARAM)UnicodeConvertor.getNewBuf()); + pSci->addText(length, UnicodeConvertor.getNewBuf()); + + pSci->execute(SCI_EMPTYUNDOBUFFER); @@ -6931,9 +7157,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETNPPVERSION: { - char verStr[16] = VERSION_VALUE; - char mainVerStr[16]; - char auxVerStr[16]; + const TCHAR * verStr = VERSION_VALUE; + TCHAR mainVerStr[16]; + TCHAR auxVerStr[16]; bool isDot = false; int j =0; int k = 0; @@ -6954,9 +7180,9 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa int mainVer, auxVer = 0; if (mainVerStr) - mainVer = atoi(mainVerStr); + mainVer = generic_atoi(mainVerStr); if (auxVerStr) - auxVer = atoi(auxVerStr); + auxVer = generic_atoi(auxVerStr); return MAKELONG(auxVer, mainVer); } @@ -7072,7 +7298,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_SETSTATUSBAR : { - char *str2set = (char *)lParam; + TCHAR *str2set = (TCHAR *)lParam; if (!str2set || !str2set[0]) return FALSE; @@ -7101,13 +7327,13 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_LOADSESSION : { - fileLoadSession((const char *)lParam); + fileLoadSession((const TCHAR *)lParam); return TRUE; } case NPPM_SAVECURRENTSESSION : { - return (LRESULT)fileSaveSession(0, NULL, (const char *)lParam); + return (LRESULT)fileSaveSession(0, NULL, (const TCHAR *)lParam); } case NPPM_SAVESESSION : @@ -7131,7 +7357,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } case NPPM_INTERNAL_CMDLIST_MODIFIED : { - //changeMenuShortcut(lParam, (const char *)wParam); + //changeMenuShortcut(lParam, (const TCHAR *)wParam); ::DrawMenuBar(_hSelf); return TRUE; } @@ -7239,7 +7465,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa } } - return ::DefWindowProcW(hwnd, Message, wParam, lParam); + return ::DefWindowProc(hwnd, Message, wParam, lParam); } case WM_NOTIFY: @@ -7301,7 +7527,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_GETFULLPATHFROMBUFFERID : { - return MainFileManager->getFileNameFromBuffer((BufferID)wParam, (char *)lParam); + return MainFileManager->getFileNameFromBuffer((BufferID)wParam, (TCHAR *)lParam); } case NPPM_ENABLECHECKDOCOPT: @@ -7394,7 +7620,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if ((nppgui._isMinimizedToTray) && (wParam == SC_MINIMIZE)) { if (!_pTrayIco) - _pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), ""); + _pTrayIco = new trayIconControler(_hSelf, IDI_M30ICON, IDC_MINIMIZED_TRAY, ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON)), TEXT("")); _pTrayIco->doTrayIcon(ADD); ::ShowWindow(hwnd, SW_HIDE); @@ -7410,7 +7636,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _sysMenuEntering = true; } - return ::DefWindowProcW(hwnd, Message, wParam, lParam); + return ::DefWindowProc(hwnd, Message, wParam, lParam); } case WM_LBUTTONDBLCLK: @@ -7475,27 +7701,27 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa case NPPM_DMMVIEWOTHERTAB: { - _dockingManager.showDockableDlg((char*)lParam, SW_SHOW); + _dockingManager.showDockableDlg((TCHAR*)lParam, SW_SHOW); return TRUE; } - case NPPM_DMMGETPLUGINHWNDBYNAME : //(const char *windowName, const char *moduleName) + case NPPM_DMMGETPLUGINHWNDBYNAME : //(const TCHAR *windowName, const TCHAR *moduleName) { if (!lParam) return NULL; - char *moduleName = (char *)lParam; - char *windowName = (char *)wParam; + TCHAR *moduleName = (TCHAR *)lParam; + TCHAR *windowName = (TCHAR *)wParam; vector dockContainer = _dockingManager.getContainerInfo(); for (size_t i = 0 ; i < dockContainer.size() ; i++) { vector tbData = dockContainer[i]->getDataOfAllTb(); for (size_t j = 0 ; j < tbData.size() ; j++) { - if (stricmp(moduleName, tbData[j]->pszModuleName) == 0) + if (generic_stricmp(moduleName, tbData[j]->pszModuleName) == 0) { if (!windowName) return (LRESULT)tbData[j]->hClient; - else if (stricmp(windowName, tbData[j]->pszName) == 0) + else if (generic_stricmp(windowName, tbData[j]->pszName) == 0) return (LRESULT)tbData[j]->hClient; } } @@ -7537,19 +7763,19 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (!lParam || !wParam) return FALSE; - const char *pluginsConfigDirPrefix = pNppParam->getAppDataNppDir(); + const TCHAR *pluginsConfigDirPrefix = pNppParam->getAppDataNppDir(); if (!pluginsConfigDirPrefix[0]) pluginsConfigDirPrefix = pNppParam->getNppPath(); - const char *secondPart = "plugins\\Config"; + const TCHAR *secondPart = TEXT("plugins\\Config"); - size_t len = (size_t)wParam; - if (len < strlen(pluginsConfigDirPrefix) + strlen(secondPart)) + int len = wParam; + if (len < lstrlen(pluginsConfigDirPrefix) + lstrlen(secondPart)) return FALSE; - char *pluginsConfigDir = (char *)lParam; - strcpy(pluginsConfigDir, pluginsConfigDirPrefix); + TCHAR *pluginsConfigDir = (TCHAR *)lParam; + lstrcpy(pluginsConfigDir, pluginsConfigDirPrefix); ::PathAppend(pluginsConfigDir, secondPart); return TRUE; @@ -7708,7 +7934,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return TRUE; } - return ::DefWindowProcW(hwnd, Message, wParam, lParam); + return ::DefWindowProc(hwnd, Message, wParam, lParam); } } @@ -7735,7 +7961,7 @@ LRESULT CALLBACK Notepad_plus::Notepad_plus_Proc(HWND hwnd, UINT Message, WPARAM default : { - return ((Notepad_plus *)::GetWindowLongPtrW(hwnd, GWL_USERDATA))->runProc(hwnd, Message, wParam, lParam); + return ((Notepad_plus *)::GetWindowLongPtr(hwnd, GWL_USERDATA))->runProc(hwnd, Message, wParam, lParam); } } } @@ -7901,7 +8127,7 @@ bool Notepad_plus::getIntegralDockingData(tTbData & dockData, int & iCont, bool { const PlugingDlgDockingInfo & pddi = dockingData._pluginDockInfo[i]; - if (!stricmp(pddi._name, dockData.pszModuleName) && (pddi._internalID == dockData.dlgID)) + if (!generic_stricmp(pddi._name, dockData.pszModuleName) && (pddi._internalID == dockData.dlgID)) { iCont = pddi._currContainer; isVisible = pddi._isVisible; @@ -7938,10 +8164,10 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session) { BufferID bufID = _mainDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(bufID); - if (!buf->isUntitled() && PathFileExistsW(buf->getFilePathW())) + if (!buf->isUntitled() && PathFileExists(buf->getFilePath())) { - string languageName = getLangFromMenu( buf ); - const char *langName = languageName.c_str(); + basic_string languageName = getLangFromMenu( buf ); + const TCHAR *langName = languageName.c_str(); sessionFileInfo sfi(buf->getFilePath(), langName, buf->getPosition(&_mainEditView)); @@ -7963,10 +8189,10 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session) { BufferID bufID = _subDocTab.getBufferByIndex(i); Buffer * buf = MainFileManager->getBufferByID(bufID); - if (!buf->isUntitled() && PathFileExistsW(buf->getFilePathW())) + if (!buf->isUntitled() && PathFileExists(buf->getFilePath())) { - string languageName = getLangFromMenu( buf ); - const char *langName = languageName.c_str(); + basic_string languageName = getLangFromMenu( buf ); + const TCHAR *langName = languageName.c_str(); sessionFileInfo sfi(buf->getFilePath(), langName, buf->getPosition(&_subEditView)); @@ -7993,30 +8219,28 @@ void Notepad_plus::getCurrentOpenedFiles(Session & session) _invisibleEditView.execute(SCI_SETDOCPOINTER, 0, oldDoc); } -bool Notepad_plus::fileLoadSession(const char *fn) +bool Notepad_plus::fileLoadSession(const TCHAR *fn) { bool result = false; - const char *sessionFileName = NULL; + const TCHAR *sessionFileName = NULL; if (fn == NULL) { FileDialog fDlg(_hSelf, _hInst); - fDlg.setExtFilter("All types", ".*", NULL); - const char *ext = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); - string sessionExt = ""; + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); + const TCHAR *ext = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); + basic_string sessionExt = TEXT(""); if (*ext != '\0') { if (*ext != '.') - sessionExt += "."; + sessionExt += TEXT("."); sessionExt += ext; - fDlg.setExtFilter("Session file", sessionExt.c_str(), NULL); + fDlg.setExtFilter(TEXT("Session file"), sessionExt.c_str(), NULL); } sessionFileName = fDlg.doOpenSingleFileDlg(); } else { - wchar_t fnW[MAX_PATH]; - char2wchar(fn, fnW); - if (PathFileExistsW(fnW)) + if (PathFileExists(fn)) sessionFileName = fn; } @@ -8037,17 +8261,18 @@ bool Notepad_plus::fileLoadSession(const char *fn) } -const char * Notepad_plus::fileSaveSession(size_t nbFile, char ** fileNames, const char *sessionFile2save) +const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames, const TCHAR *sessionFile2save) { if (sessionFile2save) { Session currentSession; if ((nbFile) && (!fileNames)) { + for (size_t i = 0 ; i < nbFile ; i++) { if (PathFileExists(fileNames[i])) - currentSession._mainViewFiles.push_back(string(fileNames[i])); + currentSession._mainViewFiles.push_back(basic_string(fileNames[i])); } } else @@ -8059,21 +8284,21 @@ const char * Notepad_plus::fileSaveSession(size_t nbFile, char ** fileNames, con return NULL; } -const char * Notepad_plus::fileSaveSession(size_t nbFile, char ** fileNames) +const TCHAR * Notepad_plus::fileSaveSession(size_t nbFile, TCHAR ** fileNames) { - const char *sessionFileName = NULL; + const TCHAR *sessionFileName = NULL; FileDialog fDlg(_hSelf, _hInst); - const char *ext = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); + const TCHAR *ext = NppParameters::getInstance()->getNppGUI()._definedSessionExt.c_str(); - fDlg.setExtFilter("All types", ".*", NULL); - string sessionExt = ""; + fDlg.setExtFilter(TEXT("All types"), TEXT(".*"), NULL); + basic_string sessionExt = TEXT(""); if (*ext != '\0') { if (*ext != '.') - sessionExt += "."; + sessionExt += TEXT("."); sessionExt += ext; - fDlg.setExtFilter("Session file", sessionExt.c_str(), NULL); + fDlg.setExtFilter(TEXT("Session file"), sessionExt.c_str(), NULL); } sessionFileName = fDlg.doSaveDlg(); @@ -8081,7 +8306,7 @@ const char * Notepad_plus::fileSaveSession(size_t nbFile, char ** fileNames) } -bool Notepad_plus::str2Cliboard(const char *str2cpy) +bool Notepad_plus::str2Cliboard(const TCHAR *str2cpy) { if (!str2cpy) return false; @@ -8090,8 +8315,16 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy) return false; ::EmptyClipboard(); - - HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, strlen(str2cpy) + 1); + + int len2Allocate = lstrlen(str2cpy); + unsigned int cilpboardFormat = CF_TEXT; + +#ifdef UNICODE + len2Allocate = len2Allocate * 2 + 3; + cilpboardFormat = CF_UNICODETEXT; +#endif + + HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, len2Allocate); if (hglbCopy == NULL) { @@ -8100,51 +8333,20 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy) } // Lock the handle and copy the text to the buffer. - char *pStr = (char *)::GlobalLock(hglbCopy); - strcpy(pStr, str2cpy); + TCHAR *pStr = (TCHAR *)::GlobalLock(hglbCopy); + lstrcpy(pStr, str2cpy); ::GlobalUnlock(hglbCopy); // Place the handle on the clipboard. - ::SetClipboardData(CF_TEXT, hglbCopy); + ::SetClipboardData(cilpboardFormat, hglbCopy); ::CloseClipboard(); return true; } -bool Notepad_plus::str2CliboardW(const wchar_t *str2cpy) -{ - if (!str2cpy) - return false; - - if (!::OpenClipboard(_hSelf)) - return false; - - ::EmptyClipboard(); - - int size = sizeof(wchar_t); - HGLOBAL hglbCopy = ::GlobalAlloc(GMEM_MOVEABLE, wcslen(str2cpy) * size + size); - - if (hglbCopy == NULL) - { - ::CloseClipboard(); - return false; - } - - // Lock the handle and copy the text to the buffer. - wchar_t *pStr = (wchar_t *)::GlobalLock(hglbCopy); - wcscpy(pStr, str2cpy); - ::GlobalUnlock(hglbCopy); - - // Place the handle on the clipboard. - ::SetClipboardData(CF_UNICODETEXT, hglbCopy); - ::CloseClipboard(); - return true; -} - - //ONLY CALL IN CASE OF EMERGENCY: EXCEPTION //This function is destructive bool Notepad_plus::emergency() { - const char * outdir = "C:\\N++RECOV"; + const TCHAR * outdir = TEXT("C:\\N++RECOV"); bool filestatus = false; bool dumpstatus = false; do { @@ -8152,16 +8354,16 @@ bool Notepad_plus::emergency() { break; } - filestatus = dumpFiles(outdir, "File"); + filestatus = dumpFiles(outdir, TEXT("File")); /* HANDLE hProcess = ::GetCurrentProcess(); DWORD processId = ::GetCurrentProcessId(); - char dumpFile[MAX_PATH]; - _snprintf(dumpFile, MAX_PATH, "%s\\NPP_DUMP.dmp", outdir); + TCHAR dumpFile[MAX_PATH]; + _snprintf(dumpFile, MAX_PATH, TEXT("%s\\NPP_DUMP.dmp"), outdir); HANDLE hFile = ::CreateFile(dumpFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if (hFile == INVALID_HANDLE_VALUE) { - ::MessageBox(NULL, "Failed to write dump file!", dumpFile, MB_OK|MB_ICONWARNING); + ::MessageBox(NULL, TEXT("Failed to write dump file!"), dumpFile, MB_OK|MB_ICONWARNING); } BOOL ret = ::MiniDumpWriteDump(hProcess, processId, hFile, MiniDumpNormal, NULL, NULL, NULL); //might want to add exception info aswell @@ -8173,11 +8375,11 @@ bool Notepad_plus::emergency() { return status; } -bool Notepad_plus::dumpFiles(const char * outdir, const char * fileprefix) { +bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) { //start dumping unsaved files to recovery directory bool somethingsaved = false; bool somedirty = false; - char savePath[MAX_PATH] = {0}; + TCHAR savePath[MAX_PATH] = {0}; //rescue primary for(int i = 0; i < MainFileManager->getNrBuffers(); i++) { @@ -8187,8 +8389,8 @@ bool Notepad_plus::dumpFiles(const char * outdir, const char * fileprefix) { else somedirty = true; - const char * unitext = (docbuf->getUnicodeMode() != uni8Bit)?"_utf8":""; - sprintf(savePath, "%s\\%s%03d%s.dump", outdir, fileprefix, i, unitext); + const TCHAR * unitext = (docbuf->getUnicodeMode() != uni8Bit)?TEXT("_utf8"):TEXT(""); + wsprintf(savePath, TEXT("%s\\%s%03d%s.dump"), outdir, fileprefix, i, unitext); bool res = MainFileManager->saveBuffer(docbuf->getID(), savePath); @@ -8293,9 +8495,9 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) { if (mask & (BufferChangeDirty|BufferChangeFilename)) { checkDocState(); setTitle(); - wchar_t dir[MAX_PATH]; - wcscpy(dir, buffer->getFilePathW()); - PathRemoveFileSpecW(dir); + TCHAR dir[MAX_PATH]; + lstrcpy(dir, buffer->getFilePath()); + PathRemoveFileSpec(dir); setWorkingDir(dir); } if (mask & (BufferChangeLanguage)) { @@ -8338,9 +8540,9 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) { setUniModeText(buf->getUnicodeMode()); setDisplayFormat(buf->getFormat()); enableConvertMenuItems(buf->getFormat()); - wchar_t dir[MAX_PATH]; - wcscpy(dir, buf->getFilePathW()); - PathRemoveFileSpecW(dir); + TCHAR dir[MAX_PATH]; + lstrcpy(dir, buf->getFilePath()); + PathRemoveFileSpec(dir); setWorkingDir(dir); setTitle(); //Make sure the colors of the tab controls match @@ -8350,12 +8552,12 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view) { _linkTriggered = true; } -void Notepad_plus::loadCommandlineParams(const wchar_t * commandLine, CmdLineParams * pCmdParams) { +void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParams * pCmdParams) { if (!commandLine || ! pCmdParams) return; FileNameStringSplitter fnss(commandLine); - const wchar_t *pFn = NULL; + const TCHAR *pFn = NULL; LangType lt = pCmdParams->_langType;//LangType(pCopyData->dwData & LASTBYTEMASK); int ln = pCmdParams->_line2go; @@ -8365,9 +8567,7 @@ void Notepad_plus::loadCommandlineParams(const wchar_t * commandLine, CmdLinePar for (int i = 0 ; i < fnss.size() ; i++) { pFn = fnss.getFileName(i); - char fn[MAX_PATH]; - wchar2char(pFn, fn); - BufferID bufID = doOpen(fn, readOnly); + BufferID bufID = doOpen(pFn, readOnly); if (bufID == BUFFER_INVALID) //cannot open file continue; diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 00c9997c..ba7658e3 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -17,7 +17,7 @@ #ifndef NOTEPAD_PLUS_H #define NOTEPAD_PLUS_H - +#include #include "Window.h" #include "ScintillaEditView.h" #include "ToolBar.h" @@ -49,11 +49,6 @@ #include "AutoCompletion.h" #include "Buffer.h" #include "SmartHighlighter.h" -#include "UniConversion.h" -#include "UrlHighlighter.h" - -#define NOTEPAD_PP_CLASS_NAME "Notepad++" -#define NOTEPAD_PP_CLASS_NAME_W L"Notepad++" #define MENU 0x01 #define TOOLBAR 0x02 @@ -80,14 +75,14 @@ enum Views { */ struct TaskListInfo; -static TiXmlNode * searchDlgNode(TiXmlNode *node, const char *dlgTagName); +static TiXmlNode * searchDlgNode(TiXmlNode *node, const TCHAR *dlgTagName); struct iconLocator { int listIndex; int iconIndex; - std::string iconLocation; + std::basic_string iconLocation; - iconLocator(int iList, int iIcon, const std::string iconLoc) + iconLocator(int iList, int iIcon, const std::basic_string iconLoc) : listIndex(iList), iconIndex(iIcon), iconLocation(iconLoc){}; }; @@ -98,11 +93,11 @@ class Notepad_plus : public Window { public: Notepad_plus(); virtual inline ~Notepad_plus(); - void init(HINSTANCE, HWND, const wchar_t *cmdLine, CmdLineParams *cmdLineParams); + void init(HINSTANCE, HWND, const TCHAR *cmdLine, CmdLineParams *cmdLineParams); inline void killAllChildren(); virtual inline void destroy(); - static const char * Notepad_plus::getClassName() { + static const TCHAR * Notepad_plus::getClassName() { return _className; }; @@ -116,17 +111,16 @@ public: if (unicodeSupported?(::IsDialogMessageW(_hModelessDlgs[i], msg)):(::IsDialogMessageA(_hModelessDlgs[i], msg))) return true; } - return false; }; // fileOperations //The doXXX functions apply to a single buffer and dont need to worry about views, with the excpetion of doClose, since closing one view doesnt have to mean the document is gone - BufferID doOpen(const char *fileName, bool isReadOnly = false); + BufferID doOpen(const TCHAR *fileName, bool isReadOnly = false); bool doReload(BufferID id, bool alert = true); - bool doSave(BufferID, const char * filename, bool isSaveCopy = false); + bool doSave(BufferID, const TCHAR * filename, bool isSaveCopy = false); void doClose(BufferID, int whichOne); - //bool doDelete(const char *fileName) const {return ::DeleteFile(fileName) != 0;}; + //bool doDelete(const TCHAR *fileName) const {return ::DeleteFile(fileName) != 0;}; inline void fileNew(); void fileOpen(); @@ -145,7 +139,7 @@ public: bool switchToFile(BufferID buffer); //find buffer in active view then in other view. // end fileOperations - bool isFileSession(const char * filename); + bool isFileSession(const TCHAR * filename); void filePrint(bool showDialog); bool saveScintillaParams(bool whichOne); @@ -161,20 +155,20 @@ public: void getCurrentOpenedFiles(Session & session); - bool fileLoadSession(const char *fn = NULL); - const char * fileSaveSession(size_t nbFile, char ** fileNames, const char *sessionFile2save); - const char * fileSaveSession(size_t nbFile = 0, char ** fileNames = NULL); + bool fileLoadSession(const TCHAR *fn = NULL); + const TCHAR * fileSaveSession(size_t nbFile, TCHAR ** fileNames, const TCHAR *sessionFile2save); + const TCHAR * fileSaveSession(size_t nbFile = 0, TCHAR ** fileNames = NULL); - bool changeDlgLang(HWND hDlg, const char *dlgTagName, char *title = NULL); + bool changeDlgLang(HWND hDlg, const TCHAR *dlgTagName, TCHAR *title = NULL); void changeConfigLang(); void changeUserDefineLang(); - void changeMenuLang(string & pluginsTrans, string & windowTrans); + void changeMenuLang(basic_string & pluginsTrans, basic_string & windowTrans); void changePrefereceDlgLang(); void changeShortcutLang(); void changeShortcutmapperLang(ShortcutMapper * sm); - const char * getNativeTip(int btnID); + const TCHAR * getNativeTip(int btnID); void changeToolBarIcons(); bool doBlockComment(comment_mode currCommentMode); @@ -193,11 +187,10 @@ public: bool emergency(); void notifyBufferChanged(Buffer * buffer, int mask); + private: - void loadCommandlineParams(const wchar_t * commandLine, CmdLineParams * pCmdParams); - static const char _className[32]; - static const wchar_t _classNameW[32]; - char _nppPath[MAX_PATH]; + static const TCHAR _className[32]; + TCHAR _nppPath[MAX_PATH]; Window *_pMainWindow; DockingManager _dockingManager; @@ -205,9 +198,9 @@ private: AutoCompletion _autoCompleteSub; //each Scintilla has its own autoComplete SmartHighlighter _smartHighlighter; - UrlHighlighter _urlHighlighter; TiXmlNode *_nativeLang, *_toolIcons; + int _nativeLangEncoding; DocTabView _mainDocTab; DocTabView _subDocTab; @@ -361,7 +354,7 @@ private: void command(int id); //Document management - unsigned char _mainWindowStatus; //For 2 views and user dialog if docked + UCHAR _mainWindowStatus; //For 2 views and user dialog if docked int _activeView; //User dialog docking @@ -392,45 +385,37 @@ private: void performPostReload(int whichOne); //END: Document management - int doSaveOrNot(const char *fn) { - wchar_t fnW[MAX_PATH]; - char2wchar(fn, fnW); - wchar_t pattern[64] = L"Save file \"%s\" ?"; - wchar_t phrase[512]; - swprintf(phrase, pattern, fnW); - return doActionOrNot(L"Save", phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); - }; - int doReloadOrNot(const char *fn) { - wchar_t fnW[MAX_PATH]; - char2wchar(fn, fnW); - wchar_t pattern[128] = L"The file \"%s\" is modified by another program.\rReload this file?"; - wchar_t phrase[512]; - swprintf(phrase, pattern, fnW); - return doActionOrNot(L"Reload", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + int doSaveOrNot(const TCHAR *fn) { + TCHAR pattern[64] = TEXT("Save file \"%s\" ?"); + TCHAR phrase[512]; + wsprintf(phrase, pattern, fn); + return doActionOrNot(TEXT("Save"), phrase, MB_YESNOCANCEL | MB_ICONQUESTION | MB_APPLMODAL); }; - int doCloseOrNot(const char *fn) { - wchar_t fnW[MAX_PATH]; - char2wchar(fn, fnW); - wchar_t pattern[128] = L"The file \"%s\" doesn't exist anymore.\rKeep this file in editor?"; - wchar_t phrase[512]; - swprintf(phrase, pattern, fnW); - return doActionOrNot(L"Keep non existing file", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + int doReloadOrNot(const TCHAR *fn) { + TCHAR pattern[128] = TEXT("The file \"%s\" is modified by another program.\rReload this file?"); + TCHAR phrase[512]; + wsprintf(phrase, pattern, fn); + return doActionOrNot(TEXT("Reload"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + }; + + int doCloseOrNot(const TCHAR *fn) { + TCHAR pattern[128] = TEXT("The file \"%s\" doesn't exist anymore.\rKeep this file in editor?"); + TCHAR phrase[512]; + wsprintf(phrase, pattern, fn); + return doActionOrNot(TEXT("Keep non existing file"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); }; - int doDeleteOrNot(const char *fn) { - wchar_t fnW[MAX_PATH]; - char2wchar(fn, fnW); - wchar_t pattern[128] = L"The file \"%s\"\rwill be deleted from your disk and this document will be closed.\rContinue?"; - wchar_t phrase[512]; - swprintf(phrase, pattern, fnW); - return doActionOrNot(L"Delete file", phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); + int doDeleteOrNot(const TCHAR *fn) { + TCHAR pattern[128] = TEXT("The file \"%s\"\rwill be deleted from your disk and this document will be closed.\rContinue?"); + TCHAR phrase[512]; + wsprintf(phrase, pattern, fn); + return doActionOrNot(TEXT("Delete file"), phrase, MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL); }; - int doActionOrNot(const wchar_t *title, const wchar_t *displayText, int type) { - return ::MessageBoxW(_hSelf, displayText, title, type); + int doActionOrNot(const TCHAR *title, const TCHAR *displayText, int type) { + return ::MessageBox(_hSelf, displayText, title, type); }; - void enableMenu(int cmdID, bool doEnable) const { int flag = doEnable?MF_ENABLED | MF_BYCOMMAND:MF_DISABLED | MF_GRAYED | MF_BYCOMMAND; ::EnableMenuItem(_mainMenuHandle, cmdID, flag); @@ -456,43 +441,43 @@ private: void checkUnicodeMenuItems(UniMode um) const; - string getLangDesc(LangType langType, bool shortDesc = false); + basic_string getLangDesc(LangType langType, bool shortDesc = false); void setLangStatus(LangType langType){ _statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE); }; void setDisplayFormat(formatType f) { - std::string str; + std::basic_string str; switch (f) { case MAC_FORMAT : - str = "MAC"; + str = TEXT("MAC"); break; case UNIX_FORMAT : - str = "UNIX"; + str = TEXT("UNIX"); break; default : - str = "Dos\\Windows"; + str = TEXT("Dos\\Windows"); } _statusBar.setText(str.c_str(), STATUSBAR_EOF_FORMAT); }; void setUniModeText(UniMode um) { - char *uniModeText; + TCHAR *uniModeText; switch (um) { case uniUTF8: - uniModeText = "UTF-8"; break; + uniModeText = TEXT("UTF-8"); break; case uni16BE: - uniModeText = "UCS-2 Big Endian"; break; + uniModeText = TEXT("UCS-2 Big Endian"); break; case uni16LE: - uniModeText = "UCS-2 little Endian"; break; + uniModeText = TEXT("UCS-2 little Endian"); break; case uniCookie: - uniModeText = "ANSI as UTF-8"; break; + uniModeText = TEXT("ANSI as UTF-8"); break; default : - uniModeText = "ANSI"; + uniModeText = TEXT("ANSI"); } _statusBar.setText(uniModeText, STATUSBAR_UNICODE_TYPE); }; @@ -538,8 +523,8 @@ private: void checkMenuItem(int itemID, bool willBeChecked) const { ::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED)); }; - void charAdded(char chAdded); - void MaintainIndentation(char ch); + void charAdded(TCHAR chAdded); + void MaintainIndentation(TCHAR ch); void addHotSpot(bool docIsModifing = false); @@ -578,12 +563,12 @@ private: void copyMarkedLines() { int lastLine = _pEditView->lastZeroBasedLineNumber(); - string globalStr = ""; + basic_string globalStr = TEXT(""); for (int i = lastLine ; i >= 0 ; i--) { if (bookmarkPresent(i)) { - string currentStr = getMarkedLine(i) + globalStr; + basic_string currentStr = getMarkedLine(i) + globalStr; globalStr = currentStr; } } @@ -592,14 +577,14 @@ private: void cutMarkedLines() { int lastLine = _pEditView->lastZeroBasedLineNumber(); - string globalStr = ""; + basic_string globalStr = TEXT(""); _pEditView->execute(SCI_BEGINUNDOACTION); for (int i = lastLine ; i >= 0 ; i--) { if (bookmarkPresent(i)) { - string currentStr = getMarkedLine(i) + globalStr; + basic_string currentStr = getMarkedLine(i) + globalStr; globalStr = currentStr; deleteMarkedline(i); @@ -629,7 +614,7 @@ private: int len = ::GlobalSize(clipboardData); LPVOID clipboardDataPtr = ::GlobalLock(clipboardData); - string clipboardStr = (const char *)clipboardDataPtr; + basic_string clipboardStr = (const TCHAR *)clipboardDataPtr; ::GlobalUnlock(clipboardData); ::CloseClipboard(); @@ -650,30 +635,24 @@ private: int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln); bookmarkDelete(ln); - _pEditView->execute(SCI_SETTARGETSTART, lineBegin); - _pEditView->execute(SCI_SETTARGETEND, lineBegin + lineLen); - char emptyString[2] = ""; - _pEditView->execute(SCI_REPLACETARGET, strlen(emptyString), (LPARAM)emptyString); + TCHAR emptyString[2] = TEXT(""); + _pEditView->replaceTarget(emptyString, lineBegin, lineBegin + lineLen); }; - void replaceMarkedline(int ln, const char *str) { - + void replaceMarkedline(int ln, const TCHAR *str) { int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln); int lineEnd = _pEditView->execute(SCI_GETLINEENDPOSITION, ln); - - _pEditView->execute(SCI_SETTARGETSTART, lineBegin); - _pEditView->execute(SCI_SETTARGETEND, lineEnd); - _pEditView->execute(SCI_REPLACETARGET, strlen(str), (LPARAM)str); + _pEditView->replaceTarget(str, lineBegin, lineEnd); }; - string getMarkedLine(int ln) { + basic_string getMarkedLine(int ln) { int lineLen = _pEditView->execute(SCI_LINELENGTH, ln); int lineBegin = _pEditView->execute(SCI_POSITIONFROMLINE, ln); - char * buf = new char[lineLen+1]; - _pEditView->getText(buf, lineBegin, lineBegin + lineLen); - string line = buf; + TCHAR * buf = new TCHAR[lineLen+1]; + _pEditView->getGenericText(buf, lineBegin, lineBegin + lineLen); + basic_string line = buf; delete [] buf; return line; @@ -691,46 +670,45 @@ private: void autoCompFromCurrentFile(bool autoInsert = true); void showFunctionComp(); - void changeStyleCtrlsLang(HWND hDlg, int *idArray, const char **translatedText); + void changeStyleCtrlsLang(HWND hDlg, int *idArray, const TCHAR **translatedText); bool replaceAllFiles(); bool findInOpenedFiles(); bool findInFiles(bool isRecursive, bool isInHiddenDir); - bool matchInList(const char *fileName, const vector & patterns); - void getMatchedFileNames(const char *dir, const vector & patterns, vector & fileNames, bool isRecursive, bool isInHiddenDir); + bool matchInList(const TCHAR *fileName, const vector> & patterns); + void getMatchedFileNames(const TCHAR *dir, const vector> & patterns, vector> & fileNames, bool isRecursive, bool isInHiddenDir); void doSynScorll(HWND hW); - void setWorkingDir(wchar_t *dir) { + void setWorkingDir(TCHAR *dir) { if (NppParameters::getInstance()->getNppGUI()._saveOpenKeepInSameDir) return; - if (!dir || !PathIsDirectoryW(dir)) + if (!dir || !PathIsDirectory(dir)) { //Non existing path, usually occurs when a new 1 file is open. //Set working dir to Notepad++' directory to prevent directory lock. - wchar_t nppDir[MAX_PATH]; + TCHAR nppDir[MAX_PATH]; //wParam set to max_path in case boundary checks will ever be made. - ::SendMessage(_hSelf, NPPM_GETNPPDIRECTORY, (WPARAM)MAX_PATH, (LPARAM)nppDir); - ::SetCurrentDirectoryW(nppDir); + SendMessage(_hSelf, NPPM_GETNPPDIRECTORY, (WPARAM)MAX_PATH, (LPARAM)nppDir); + ::SetCurrentDirectory(nppDir); return; } else - ::SetCurrentDirectoryW(dir); + ::SetCurrentDirectory(dir); } - bool str2Cliboard(const char *str2cpy); - bool str2CliboardW(const wchar_t *str2cpy); - bool bin2Cliboard(const unsigned char *uchar2cpy, size_t length); + bool str2Cliboard(const TCHAR *str2cpy); + bool bin2Cliboard(const UCHAR *uchar2cpy, size_t length); bool getIntegralDockingData(tTbData & dockData, int & iCont, bool & isVisible); - int getLangFromMenuName(const char * langName) { + int getLangFromMenuName(const TCHAR * langName) { int id = 0; - char menuLangName[64]; + TCHAR menuLangName[64]; for ( int i = IDM_LANG_C; i <= IDM_LANG_USER; i++ ) if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ) - if ( !strcmp( langName, menuLangName ) ) + if ( !lstrcmp( langName, menuLangName ) ) { id = i; break; @@ -740,7 +718,7 @@ private: { for ( int i = IDM_LANG_USER + 1; i <= IDM_LANG_USER_LIMIT; i++ ) if ( ::GetMenuString( _mainMenuHandle, i, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ) - if ( !strcmp( langName, menuLangName ) ) + if ( !lstrcmp( langName, menuLangName ) ) { id = i; break; @@ -750,17 +728,17 @@ private: return id; }; - string getLangFromMenu(const Buffer * buf) { + basic_string getLangFromMenu(const Buffer * buf) { int id; - const char * userLangName; - char menuLangName[32]; + const TCHAR * userLangName; + TCHAR menuLangName[32]; id = (NppParameters::getInstance())->langTypeToCommandID( buf->getLangType() ); if ( ( id != IDM_LANG_USER ) || !( buf->isUserDefineLangExt() ) ) { ( ::GetMenuString( _mainMenuHandle, id, menuLangName, sizeof( menuLangName ), MF_BYCOMMAND ) ); - userLangName = (char *)menuLangName; + userLangName = (TCHAR *)menuLangName; } else { @@ -772,7 +750,7 @@ private: void setFileOpenSaveDlgFilters(FileDialog & fDlg); void markSelectedTextInc(bool enable); - Style * getStyleFromName(const char *styleName) { + Style * getStyleFromName(const TCHAR *styleName) { StyleArray & stylers = (NppParameters::getInstance())->getMiscStylerArray(); int i = stylers.getStylerIndexByName(styleName); @@ -785,8 +763,10 @@ private: return st; }; - bool dumpFiles(const char * outdir, const char * fileprefix = ""); //helper func + bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func void drawTabbarColoursFromStylerArray(); + + void loadCommandlineParams(const TCHAR * commandLine, CmdLineParams * pCmdParams); }; #endif //NOTEPAD_PLUS_H diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 17e68fc4..588f8e9f 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -440,10 +440,10 @@ END IDD_ABOUTBOX DIALOGEX 0, 0, 271, 240 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_BORDER | WS_SYSMENU - -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN LTEXT NOTEPAD_PLUS_VERSION, IDC_STATIC,50,16,65,11 + LTEXT UNICODE_ANSI_MODE, IDC_STATIC,120,16,65,11 GROUPBOX "GNU General Public Licence",IDC_STATIC,19,75,231,131,BS_CENTER DEFPUSHBUTTON "Ok",IDOK,106,215,50,14,BS_FLAT,WS_EX_STATICEDGE LTEXT "Author :",IDC_STATIC,21,41,31,8 @@ -451,7 +451,6 @@ BEGIN LTEXT "Home Page :",IDC_STATIC,21,54,47,8 LTEXT "http://notepad-plus.sourceforge.net/",IDC_HOME_ADDR,78,54,126,8 EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL - //LS: CompileDateInAboutDialog: Automatically insert compile date as additional version info! EDITTEXT IDC_BUILD_DATETIME,150,2,150,10, ES_READONLY | NOT WS_BORDER CONTROL "",IDI_M30ICON,"Static",SS_OWNERDRAW,21,10,20,20 END @@ -460,7 +459,7 @@ IDD_GOLINE DIALOGEX 26, 41, 261, 88 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Go To..." -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN CONTROL "Line",IDC_RADIO_GOTOLINE,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,5,9,80,10 CONTROL "Offset",IDC_RADIO_GOTOOFFSET,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,102,9,80,10 @@ -478,7 +477,7 @@ IDD_VALUE_DLG DIALOGEX 0, 0, 74, 17 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN LTEXT "STATIC :",IDC_VALUE_STATIC,6,4,45,8 EDITTEXT IDC_VALUE_EDIT,49,2,18,14,ES_NUMBER,WS_EX_DLGMODALFRAME diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index aac84532..a438df06 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -23,18 +23,18 @@ #include "keys.h" struct WinMenuKeyDefinition { //more or less matches accelerator table definition, easy copy/paste - //const char * name; //name retrieved from menu? + //const TCHAR * name; //name retrieved from menu? int vKey; int functionId; bool isCtrl; bool isAlt; bool isShift; - char * specialName; //Used when no real menu name exists (in case of toggle for example) + TCHAR * specialName; //Used when no real menu name exists (in case of toggle for example) }; struct ScintillaKeyDefinition { - const char * name; + const TCHAR * name; int functionId; bool isCtrl; bool isAlt; @@ -175,7 +175,7 @@ WinMenuKeyDefinition winKeyDefs[] = { //array of accelerator keys for all std me {VK_NULL, IDM_LANGSTYLE_CONFIG_DLG, false, false, false, NULL}, {VK_NULL, IDM_SETTING_SHORTCUT_MAPPER, false, false, false, NULL}, - {VK_R, IDC_EDIT_TOGGLEMACRORECORDING, true, false, true, "Toggle macro record"}, + {VK_R, IDC_EDIT_TOGGLEMACRORECORDING, true, false, true, TEXT("Toggle macro record")}, {VK_P, IDM_MACRO_PLAYBACKRECORDEDMACRO, true, false, true, NULL}, {VK_NULL, IDM_MACRO_SAVECURRENTMACRO, false, false, false, NULL}, {VK_NULL, IDM_MACRO_RUNMULTIMACRODLG, false, false, false, NULL}, @@ -191,141 +191,141 @@ WinMenuKeyDefinition winKeyDefs[] = { //array of accelerator keys for all std me {VK_NULL, IDM_PLUGINSHOME, false, false, false, NULL}, {VK_F1, IDM_ABOUT, false, false, false, NULL}, - {VK_TAB, IDC_PREV_DOC, true, false, true, "Switch to previous document"}, - {VK_TAB, IDC_NEXT_DOC, true, false, false, "Switch to next document"}, + {VK_TAB, IDC_PREV_DOC, true, false, true, TEXT("Switch to previous document")}, + {VK_TAB, IDC_NEXT_DOC, true, false, false, TEXT("Switch to next document")}, }; ScintillaKeyDefinition scintKeyDefs[] = { //array of accelerator keys for all possible scintilla functions, values can be 0 for vKey, which means its unused - {"SCI_CUT", SCI_CUT, true, false, false, VK_X, IDM_EDIT_CUT}, - {"", SCI_CUT, false, false, true, VK_DELETE, 0}, - {"SCI_COPY", SCI_COPY, true, false, false, VK_C, IDM_EDIT_COPY}, - {"", SCI_COPY, true, false, false, VK_INSERT, 0}, - {"SCI_PASTE", SCI_PASTE, true, false, false, VK_V, IDM_EDIT_PASTE}, - {"", SCI_PASTE, false, false, true, VK_INSERT, 0}, - {"SCI_SELECTALL", SCI_SELECTALL, true, false, false, VK_A, IDM_EDIT_SELECTALL}, - {"SCI_CLEAR", SCI_CLEAR, false, false, false, VK_DELETE, IDM_EDIT_DELETE}, - {"SCI_CLEARALL", SCI_CLEARALL, false, false, false, 0, 0}, - {"SCI_UNDO", SCI_UNDO, true, false, false, VK_Z, IDM_EDIT_UNDO}, - {"", SCI_UNDO, false, true, false, VK_BACK, 0}, - {"SCI_REDO", SCI_REDO, true, false, false, VK_Y, IDM_EDIT_REDO}, - {"SCI_NEWLINE", SCI_NEWLINE, false, false, false, VK_RETURN, 0}, - {"", SCI_NEWLINE, false, false, true, VK_RETURN, 0}, - {"SCI_TAB", SCI_TAB, false, false, false, VK_TAB, IDM_EDIT_INS_TAB}, - {"SCI_BACKTAB", SCI_BACKTAB, false, false, true, VK_TAB, IDM_EDIT_RMV_TAB}, - {"SCI_FORMFEED", SCI_FORMFEED, false, false, false, 0, 0}, - {"SCI_ZOOMIN", SCI_ZOOMIN, true, false, false, VK_ADD, IDM_VIEW_ZOOMIN}, - {"SCI_ZOOMOUT", SCI_ZOOMOUT, true, false, false, VK_SUBTRACT,IDM_VIEW_ZOOMOUT}, - {"SCI_SETZOOM", SCI_SETZOOM, true, false, false, VK_DIVIDE, 0}, - {"SCI_SELECTIONDUPLICATE", SCI_SELECTIONDUPLICATE, true, false, false, VK_D, IDM_EDIT_DUP_LINE}, - {"SCI_LINESJOIN", SCI_LINESJOIN, false, false, false, 0, 0}, - {"SCI_SCROLLCARET", SCI_SCROLLCARET, false, false, false, 0, 0}, - {"SCI_EDITTOGGLEOVERTYPE", SCI_EDITTOGGLEOVERTYPE, false, false, false, VK_INSERT, 0}, - {"SCI_MOVECARETINSIDEVIEW", SCI_MOVECARETINSIDEVIEW, false, false, false, 0, 0}, - {"SCI_LINEDOWN", SCI_LINEDOWN, false, false, false, VK_DOWN, 0}, - {"SCI_LINEDOWNEXTEND", SCI_LINEDOWNEXTEND, false, false, true, VK_DOWN, 0}, - {"SCI_LINEDOWNRECTEXTEND", SCI_LINEDOWNRECTEXTEND, false, true, true, VK_DOWN, 0}, - {"SCI_LINESCROLLDOWN", SCI_LINESCROLLDOWN, true, false, false, VK_DOWN, 0}, - {"SCI_LINEUP", SCI_LINEUP, false, false, false, VK_UP, 0}, - {"SCI_LINEUPEXTEND", SCI_LINEUPEXTEND, false, false, true, VK_UP, 0}, - {"SCI_LINEUPRECTEXTEND", SCI_LINEUPRECTEXTEND, false, true, true, VK_UP, 0}, - {"SCI_LINESCROLLUP", SCI_LINESCROLLUP, true, false, false, VK_UP, 0}, - {"SCI_PARADOWN", SCI_PARADOWN, true, false, false, VK_OEM_6, 0}, - {"SCI_PARADOWNEXTEND", SCI_PARADOWNEXTEND, true, false, true, VK_OEM_6, 0}, - {"SCI_PARAUP", SCI_PARAUP, true, false, false, VK_OEM_4, 0}, - {"SCI_PARAUPEXTEND", SCI_PARAUPEXTEND, true, false, true, VK_OEM_4, 0}, - {"SCI_CHARLEFT", SCI_CHARLEFT, false, false, false, VK_LEFT, 0}, - {"SCI_CHARLEFTEXTEND", SCI_CHARLEFTEXTEND, false, false, true, VK_LEFT, 0}, - {"SCI_CHARLEFTRECTEXTEND", SCI_CHARLEFTRECTEXTEND, false, true, true, VK_LEFT, 0}, - {"SCI_CHARRIGHT", SCI_CHARRIGHT, false, false, false, VK_RIGHT, 0}, - {"SCI_CHARRIGHTEXTEND", SCI_CHARRIGHTEXTEND, false, false, true, VK_RIGHT, 0}, - {"SCI_CHARRIGHTRECTEXTEND", SCI_CHARRIGHTRECTEXTEND, false, true, true, VK_RIGHT, 0}, - {"SCI_WORDLEFT", SCI_WORDLEFT, true, false, false, VK_LEFT, 0}, - {"SCI_WORDLEFTEXTEND", SCI_WORDLEFTEXTEND, true, false, true, VK_LEFT, 0}, - {"SCI_WORDRIGHT", SCI_WORDRIGHT, true, false, false, VK_RIGHT, 0}, - {"SCI_WORDRIGHTEXTEND", SCI_WORDRIGHTEXTEND, false, false, false, 0, 0}, - {"SCI_WORDLEFTEND", SCI_WORDLEFTEND, false, false, false, 0, 0}, - {"SCI_WORDLEFTENDEXTEND", SCI_WORDLEFTENDEXTEND, false, false, false, 0, 0}, - {"SCI_WORDRIGHTEND", SCI_WORDRIGHTEND, false, false, false, 0, 0}, - {"SCI_WORDRIGHTENDEXTEND", SCI_WORDRIGHTENDEXTEND, true, false, true, VK_RIGHT, 0}, - {"SCI_WORDPARTLEFT", SCI_WORDPARTLEFT, true, false, false, VK_OEM_2, 0}, - {"SCI_WORDPARTLEFTEXTEND", SCI_WORDPARTLEFTEXTEND, true, false, true, VK_OEM_2, 0}, - {"SCI_WORDPARTRIGHT", SCI_WORDPARTRIGHT, true, false, false, VK_OEM_5, 0}, - {"SCI_WORDPARTRIGHTEXTEND", SCI_WORDPARTRIGHTEXTEND, true, false, true, VK_OEM_5, 0}, - {"SCI_HOME", SCI_HOME, false, false, false, 0, 0}, - {"SCI_HOMEEXTEND", SCI_HOMEEXTEND, false, false, false, 0, 0}, - {"SCI_HOMERECTEXTEND", SCI_HOMERECTEXTEND, false, false, false, 0, 0}, - {"SCI_HOMEDISPLAY", SCI_HOMEDISPLAY, false, true, false, VK_HOME, 0}, - {"SCI_HOMEDISPLAYEXTEND", SCI_HOMEDISPLAYEXTEND, false, false, false, 0, 0}, - {"SCI_HOMEWRAP", SCI_HOMEWRAP, false, false, false, 0, 0}, - {"SCI_HOMEWRAPEXTEND", SCI_HOMEWRAPEXTEND, false, false, false, 0, 0}, - {"SCI_VCHOME", SCI_VCHOME, false, false, false, 0, 0}, - {"SCI_VCHOMEEXTEND", SCI_VCHOMEEXTEND, false, false, true, VK_HOME, 0}, - {"SCI_VCHOMERECTEXTEND", SCI_VCHOMERECTEXTEND, false, true, true, VK_HOME, 0}, - {"SCI_VCHOMEWRAP", SCI_VCHOMEWRAP, false, false, false, VK_HOME, 0}, - {"SCI_VCHOMEWRAPEXTEND", SCI_VCHOMEWRAPEXTEND, false, false, false, 0, 0}, - {"SCI_LINEEND", SCI_LINEEND, false, false, false, 0, 0}, - {"SCI_LINEENDEXTEND", SCI_LINEENDEXTEND, false, false, true, VK_END, 0}, - {"SCI_LINEENDRECTEXTEND", SCI_LINEENDRECTEXTEND, false, true, true, VK_END, 0}, - {"SCI_LINEENDDISPLAY", SCI_LINEENDDISPLAY, false, true, false, VK_END, 0}, - {"SCI_LINEENDDISPLAYEXTEND", SCI_LINEENDDISPLAYEXTEND, false, false, false, 0, 0}, - {"SCI_LINEENDWRAP", SCI_LINEENDWRAP, false, false, false, VK_END, 0}, - {"SCI_LINEENDWRAPEXTEND", SCI_LINEENDWRAPEXTEND, false, false, false, 0, 0}, - {"SCI_DOCUMENTSTART", SCI_DOCUMENTSTART, true, false, false, VK_HOME, 0}, - {"SCI_DOCUMENTSTARTEXTEND", SCI_DOCUMENTSTARTEXTEND, true, false, true, VK_HOME, 0}, - {"SCI_DOCUMENTEND", SCI_DOCUMENTEND, true, false, false, VK_END, 0}, - {"SCI_DOCUMENTENDEXTEND", SCI_DOCUMENTENDEXTEND, true, false, true, VK_END, 0}, - {"SCI_PAGEUP", SCI_PAGEUP, false, false, false, VK_PRIOR, 0}, - {"SCI_PAGEUPEXTEND", SCI_PAGEUPEXTEND, false, false, true, VK_PRIOR, 0}, - {"SCI_PAGEUPRECTEXTEND", SCI_PAGEUPRECTEXTEND, false, true, true, VK_PRIOR, 0}, - {"SCI_PAGEDOWN", SCI_PAGEDOWN, false, false, false, VK_NEXT, 0}, - {"SCI_PAGEDOWNEXTEND", SCI_PAGEDOWNEXTEND, false, false, true, VK_NEXT, 0}, - {"SCI_PAGEDOWNRECTEXTEND", SCI_PAGEDOWNRECTEXTEND, false, true, true, VK_NEXT, 0}, - {"SCI_STUTTEREDPAGEUP", SCI_STUTTEREDPAGEUP, false, false, false, 0, 0}, - {"SCI_STUTTEREDPAGEUPEXTEND", SCI_STUTTEREDPAGEUPEXTEND, false, false, false, 0, 0}, - {"SCI_STUTTEREDPAGEDOWN", SCI_STUTTEREDPAGEDOWN, false, false, false, 0, 0}, - {"SCI_STUTTEREDPAGEDOWNEXTEND", SCI_STUTTEREDPAGEDOWNEXTEND,false, false, false, 0, 0}, - {"SCI_DELETEBACK", SCI_DELETEBACK, false, false, false, VK_BACK, 0}, - {"", SCI_DELETEBACK, false, false, true, VK_BACK, 0}, - {"SCI_DELETEBACKNOTLINE", SCI_DELETEBACKNOTLINE, false, false, false, 0, 0}, - {"SCI_DELWORDLEFT", SCI_DELWORDLEFT, true, false, false, VK_BACK, 0}, - {"SCI_DELWORDRIGHT", SCI_DELWORDRIGHT, true, false, false, VK_DELETE, 0}, - {"SCI_DELLINELEFT", SCI_DELLINELEFT, true, false, true, VK_BACK, 0}, - {"SCI_DELLINERIGHT", SCI_DELLINERIGHT, true, false, true, VK_DELETE, 0}, - {"SCI_LINEDELETE", SCI_LINEDELETE, true, false, true, VK_L, 0}, - {"SCI_LINECUT", SCI_LINECUT, true, false, false, VK_L, 0}, - {"SCI_LINECOPY", SCI_LINECOPY, true, false, true, VK_T, 0}, - {"SCI_LINETRANSPOSE", SCI_LINETRANSPOSE, true, false, false, VK_T, 0}, - {"SCI_LINEDUPLICATE", SCI_LINEDUPLICATE, false, false, false, 0, 0}, - {"SCI_CANCEL", SCI_CANCEL, false, false, false, VK_ESCAPE, 0} - //{"SCI_EMPTYUNDOBUFFER", SCI_EMPTYUNDOBUFFER, false, false, false, 0, 0}, - //{"SCI_TOGGLECARETSTICKY", SCI_TOGGLECARETSTICKY, false, false, false, 0, 0}, - //{"SCI_CALLTIPCANCEL", SCI_CALLTIPCANCEL, false, false, false, 0, 0}, - //{"SCI_SETSAVEPOINT", SCI_SETSAVEPOINT, false, false, false, 0, 0}, - //{"SCI_CLEARDOCUMENTSTYLE", SCI_CLEARDOCUMENTSTYLE, false, false, false, 0, 0}, + {TEXT("SCI_CUT"), SCI_CUT, true, false, false, VK_X, IDM_EDIT_CUT}, + {TEXT(""), SCI_CUT, false, false, true, VK_DELETE, 0}, + {TEXT("SCI_COPY"), SCI_COPY, true, false, false, VK_C, IDM_EDIT_COPY}, + {TEXT(""), SCI_COPY, true, false, false, VK_INSERT, 0}, + {TEXT("SCI_PASTE"), SCI_PASTE, true, false, false, VK_V, IDM_EDIT_PASTE}, + {TEXT(""), SCI_PASTE, false, false, true, VK_INSERT, 0}, + {TEXT("SCI_SELECTALL"), SCI_SELECTALL, true, false, false, VK_A, IDM_EDIT_SELECTALL}, + {TEXT("SCI_CLEAR"), SCI_CLEAR, false, false, false, VK_DELETE, IDM_EDIT_DELETE}, + {TEXT("SCI_CLEARALL"), SCI_CLEARALL, false, false, false, 0, 0}, + {TEXT("SCI_UNDO"), SCI_UNDO, true, false, false, VK_Z, IDM_EDIT_UNDO}, + {TEXT(""), SCI_UNDO, false, true, false, VK_BACK, 0}, + {TEXT("SCI_REDO"), SCI_REDO, true, false, false, VK_Y, IDM_EDIT_REDO}, + {TEXT("SCI_NEWLINE"), SCI_NEWLINE, false, false, false, VK_RETURN, 0}, + {TEXT(""), SCI_NEWLINE, false, false, true, VK_RETURN, 0}, + {TEXT("SCI_TAB"), SCI_TAB, false, false, false, VK_TAB, IDM_EDIT_INS_TAB}, + {TEXT("SCI_BACKTAB"), SCI_BACKTAB, false, false, true, VK_TAB, IDM_EDIT_RMV_TAB}, + {TEXT("SCI_FORMFEED"), SCI_FORMFEED, false, false, false, 0, 0}, + {TEXT("SCI_ZOOMIN"), SCI_ZOOMIN, true, false, false, VK_ADD, IDM_VIEW_ZOOMIN}, + {TEXT("SCI_ZOOMOUT"), SCI_ZOOMOUT, true, false, false, VK_SUBTRACT,IDM_VIEW_ZOOMOUT}, + {TEXT("SCI_SETZOOM"), SCI_SETZOOM, true, false, false, VK_DIVIDE, 0}, + {TEXT("SCI_SELECTIONDUPLICATE"), SCI_SELECTIONDUPLICATE, true, false, false, VK_D, IDM_EDIT_DUP_LINE}, + {TEXT("SCI_LINESJOIN"), SCI_LINESJOIN, false, false, false, 0, 0}, + {TEXT("SCI_SCROLLCARET"), SCI_SCROLLCARET, false, false, false, 0, 0}, + {TEXT("SCI_EDITTOGGLEOVERTYPE"), SCI_EDITTOGGLEOVERTYPE, false, false, false, VK_INSERT, 0}, + {TEXT("SCI_MOVECARETINSIDEVIEW"), SCI_MOVECARETINSIDEVIEW, false, false, false, 0, 0}, + {TEXT("SCI_LINEDOWN"), SCI_LINEDOWN, false, false, false, VK_DOWN, 0}, + {TEXT("SCI_LINEDOWNEXTEND"), SCI_LINEDOWNEXTEND, false, false, true, VK_DOWN, 0}, + {TEXT("SCI_LINEDOWNRECTEXTEND"), SCI_LINEDOWNRECTEXTEND, false, true, true, VK_DOWN, 0}, + {TEXT("SCI_LINESCROLLDOWN"), SCI_LINESCROLLDOWN, true, false, false, VK_DOWN, 0}, + {TEXT("SCI_LINEUP"), SCI_LINEUP, false, false, false, VK_UP, 0}, + {TEXT("SCI_LINEUPEXTEND"), SCI_LINEUPEXTEND, false, false, true, VK_UP, 0}, + {TEXT("SCI_LINEUPRECTEXTEND"), SCI_LINEUPRECTEXTEND, false, true, true, VK_UP, 0}, + {TEXT("SCI_LINESCROLLUP"), SCI_LINESCROLLUP, true, false, false, VK_UP, 0}, + {TEXT("SCI_PARADOWN"), SCI_PARADOWN, true, false, false, VK_OEM_6, 0}, + {TEXT("SCI_PARADOWNEXTEND"), SCI_PARADOWNEXTEND, true, false, true, VK_OEM_6, 0}, + {TEXT("SCI_PARAUP"), SCI_PARAUP, true, false, false, VK_OEM_4, 0}, + {TEXT("SCI_PARAUPEXTEND"), SCI_PARAUPEXTEND, true, false, true, VK_OEM_4, 0}, + {TEXT("SCI_CHARLEFT"), SCI_CHARLEFT, false, false, false, VK_LEFT, 0}, + {TEXT("SCI_CHARLEFTEXTEND"), SCI_CHARLEFTEXTEND, false, false, true, VK_LEFT, 0}, + {TEXT("SCI_CHARLEFTRECTEXTEND"), SCI_CHARLEFTRECTEXTEND, false, true, true, VK_LEFT, 0}, + {TEXT("SCI_CHARRIGHT"), SCI_CHARRIGHT, false, false, false, VK_RIGHT, 0}, + {TEXT("SCI_CHARRIGHTEXTEND"), SCI_CHARRIGHTEXTEND, false, false, true, VK_RIGHT, 0}, + {TEXT("SCI_CHARRIGHTRECTEXTEND"), SCI_CHARRIGHTRECTEXTEND, false, true, true, VK_RIGHT, 0}, + {TEXT("SCI_WORDLEFT"), SCI_WORDLEFT, true, false, false, VK_LEFT, 0}, + {TEXT("SCI_WORDLEFTEXTEND"), SCI_WORDLEFTEXTEND, true, false, true, VK_LEFT, 0}, + {TEXT("SCI_WORDRIGHT"), SCI_WORDRIGHT, true, false, false, VK_RIGHT, 0}, + {TEXT("SCI_WORDRIGHTEXTEND"), SCI_WORDRIGHTEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_WORDLEFTEND"), SCI_WORDLEFTEND, false, false, false, 0, 0}, + {TEXT("SCI_WORDLEFTENDEXTEND"), SCI_WORDLEFTENDEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_WORDRIGHTEND"), SCI_WORDRIGHTEND, false, false, false, 0, 0}, + {TEXT("SCI_WORDRIGHTENDEXTEND"), SCI_WORDRIGHTENDEXTEND, true, false, true, VK_RIGHT, 0}, + {TEXT("SCI_WORDPARTLEFT"), SCI_WORDPARTLEFT, true, false, false, VK_OEM_2, 0}, + {TEXT("SCI_WORDPARTLEFTEXTEND"), SCI_WORDPARTLEFTEXTEND, true, false, true, VK_OEM_2, 0}, + {TEXT("SCI_WORDPARTRIGHT"), SCI_WORDPARTRIGHT, true, false, false, VK_OEM_5, 0}, + {TEXT("SCI_WORDPARTRIGHTEXTEND"), SCI_WORDPARTRIGHTEXTEND, true, false, true, VK_OEM_5, 0}, + {TEXT("SCI_HOME"), SCI_HOME, false, false, false, 0, 0}, + {TEXT("SCI_HOMEEXTEND"), SCI_HOMEEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_HOMERECTEXTEND"), SCI_HOMERECTEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_HOMEDISPLAY"), SCI_HOMEDISPLAY, false, true, false, VK_HOME, 0}, + {TEXT("SCI_HOMEDISPLAYEXTEND"), SCI_HOMEDISPLAYEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_HOMEWRAP"), SCI_HOMEWRAP, false, false, false, 0, 0}, + {TEXT("SCI_HOMEWRAPEXTEND"), SCI_HOMEWRAPEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_VCHOME"), SCI_VCHOME, false, false, false, 0, 0}, + {TEXT("SCI_VCHOMEEXTEND"), SCI_VCHOMEEXTEND, false, false, true, VK_HOME, 0}, + {TEXT("SCI_VCHOMERECTEXTEND"), SCI_VCHOMERECTEXTEND, false, true, true, VK_HOME, 0}, + {TEXT("SCI_VCHOMEWRAP"), SCI_VCHOMEWRAP, false, false, false, VK_HOME, 0}, + {TEXT("SCI_VCHOMEWRAPEXTEND"), SCI_VCHOMEWRAPEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_LINEEND"), SCI_LINEEND, false, false, false, 0, 0}, + {TEXT("SCI_LINEENDEXTEND"), SCI_LINEENDEXTEND, false, false, true, VK_END, 0}, + {TEXT("SCI_LINEENDRECTEXTEND"), SCI_LINEENDRECTEXTEND, false, true, true, VK_END, 0}, + {TEXT("SCI_LINEENDDISPLAY"), SCI_LINEENDDISPLAY, false, true, false, VK_END, 0}, + {TEXT("SCI_LINEENDDISPLAYEXTEND"), SCI_LINEENDDISPLAYEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_LINEENDWRAP"), SCI_LINEENDWRAP, false, false, false, VK_END, 0}, + {TEXT("SCI_LINEENDWRAPEXTEND"), SCI_LINEENDWRAPEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_DOCUMENTSTART"), SCI_DOCUMENTSTART, true, false, false, VK_HOME, 0}, + {TEXT("SCI_DOCUMENTSTARTEXTEND"), SCI_DOCUMENTSTARTEXTEND, true, false, true, VK_HOME, 0}, + {TEXT("SCI_DOCUMENTEND"), SCI_DOCUMENTEND, true, false, false, VK_END, 0}, + {TEXT("SCI_DOCUMENTENDEXTEND"), SCI_DOCUMENTENDEXTEND, true, false, true, VK_END, 0}, + {TEXT("SCI_PAGEUP"), SCI_PAGEUP, false, false, false, VK_PRIOR, 0}, + {TEXT("SCI_PAGEUPEXTEND"), SCI_PAGEUPEXTEND, false, false, true, VK_PRIOR, 0}, + {TEXT("SCI_PAGEUPRECTEXTEND"), SCI_PAGEUPRECTEXTEND, false, true, true, VK_PRIOR, 0}, + {TEXT("SCI_PAGEDOWN"), SCI_PAGEDOWN, false, false, false, VK_NEXT, 0}, + {TEXT("SCI_PAGEDOWNEXTEND"), SCI_PAGEDOWNEXTEND, false, false, true, VK_NEXT, 0}, + {TEXT("SCI_PAGEDOWNRECTEXTEND"), SCI_PAGEDOWNRECTEXTEND, false, true, true, VK_NEXT, 0}, + {TEXT("SCI_STUTTEREDPAGEUP"), SCI_STUTTEREDPAGEUP, false, false, false, 0, 0}, + {TEXT("SCI_STUTTEREDPAGEUPEXTEND"), SCI_STUTTEREDPAGEUPEXTEND, false, false, false, 0, 0}, + {TEXT("SCI_STUTTEREDPAGEDOWN"), SCI_STUTTEREDPAGEDOWN, false, false, false, 0, 0}, + {TEXT("SCI_STUTTEREDPAGEDOWNEXTEND"), SCI_STUTTEREDPAGEDOWNEXTEND,false, false, false, 0, 0}, + {TEXT("SCI_DELETEBACK"), SCI_DELETEBACK, false, false, false, VK_BACK, 0}, + {TEXT(""), SCI_DELETEBACK, false, false, true, VK_BACK, 0}, + {TEXT("SCI_DELETEBACKNOTLINE"), SCI_DELETEBACKNOTLINE, false, false, false, 0, 0}, + {TEXT("SCI_DELWORDLEFT"), SCI_DELWORDLEFT, true, false, false, VK_BACK, 0}, + {TEXT("SCI_DELWORDRIGHT"), SCI_DELWORDRIGHT, true, false, false, VK_DELETE, 0}, + {TEXT("SCI_DELLINELEFT"), SCI_DELLINELEFT, true, false, true, VK_BACK, 0}, + {TEXT("SCI_DELLINERIGHT"), SCI_DELLINERIGHT, true, false, true, VK_DELETE, 0}, + {TEXT("SCI_LINEDELETE"), SCI_LINEDELETE, true, false, true, VK_L, 0}, + {TEXT("SCI_LINECUT"), SCI_LINECUT, true, false, false, VK_L, 0}, + {TEXT("SCI_LINECOPY"), SCI_LINECOPY, true, false, true, VK_T, 0}, + {TEXT("SCI_LINETRANSPOSE"), SCI_LINETRANSPOSE, true, false, false, VK_T, 0}, + {TEXT("SCI_LINEDUPLICATE"), SCI_LINEDUPLICATE, false, false, false, 0, 0}, + {TEXT("SCI_CANCEL"), SCI_CANCEL, false, false, false, VK_ESCAPE, 0} + //{TEXT("SCI_EMPTYUNDOBUFFER"), SCI_EMPTYUNDOBUFFER, false, false, false, 0, 0}, + //{TEXT("SCI_TOGGLECARETSTICKY"), SCI_TOGGLECARETSTICKY, false, false, false, 0, 0}, + //{TEXT("SCI_CALLTIPCANCEL"), SCI_CALLTIPCANCEL, false, false, false, 0, 0}, + //{TEXT("SCI_SETSAVEPOINT"), SCI_SETSAVEPOINT, false, false, false, 0, 0}, + //{TEXT("SCI_CLEARDOCUMENTSTYLE"), SCI_CLEARDOCUMENTSTYLE, false, false, false, 0, 0}, // // - //{"SCI_CHOOSECARETX", SCI_CHOOSECARETX, false, false, false, 0, 0}, - //{"SCI_AUTOCCOMPLETE", SCI_AUTOCCOMPLETE, false, false, false, 0, 0}, - //{"SCI_AUTOCCANCEL", SCI_AUTOCCANCEL, false, false, false, 0, 0}, - //{"SCI_CLEARREGISTEREDIMAGES", SCI_CLEARREGISTEREDIMAGES, false, false, false, 0, 0}, - //{"SCI_HOMEDISPLAYEXTEND", SCI_HOMEDISPLAYEXTEND, false, true, true, VK_HOME, 0}, - //{"SCI_LINEENDDISPLAYEXTEND", SCI_LINEENDDISPLAYEXTEND, false, true, true, VK_END, 0}, + //{TEXT("SCI_CHOOSECARETX"), SCI_CHOOSECARETX, false, false, false, 0, 0}, + //{TEXT("SCI_AUTOCCOMPLETE"), SCI_AUTOCCOMPLETE, false, false, false, 0, 0}, + //{TEXT("SCI_AUTOCCANCEL"), SCI_AUTOCCANCEL, false, false, false, 0, 0}, + //{TEXT("SCI_CLEARREGISTEREDIMAGES"), SCI_CLEARREGISTEREDIMAGES, false, false, false, 0, 0}, + //{TEXT("SCI_HOMEDISPLAYEXTEND"), SCI_HOMEDISPLAYEXTEND, false, true, true, VK_HOME, 0}, + //{TEXT("SCI_LINEENDDISPLAYEXTEND"), SCI_LINEENDDISPLAYEXTEND, false, true, true, VK_END, 0}, // - //{"SCI_DELWORDRIGHTEND", SCI_DELWORDRIGHTEND, false, false, false, 0, 0}, - //{"SCI_LOWERCASE", SCI_LOWERCASE, false, false, false, 0, 0}, - //{"SCI_UPPERCASE", SCI_UPPERCASE, false, false, false, 0, 0}, - //{"SCI_LOWERCASE", SCI_LOWERCASE, true, false, false, VK_U, 0}, - //{"SCI_UPPERCASE", SCI_UPPERCASE, true, false, true, VK_U, 0}, + //{TEXT("SCI_DELWORDRIGHTEND"), SCI_DELWORDRIGHTEND, false, false, false, 0, 0}, + //{TEXT("SCI_LOWERCASE"), SCI_LOWERCASE, false, false, false, 0, 0}, + //{TEXT("SCI_UPPERCASE"), SCI_UPPERCASE, false, false, false, 0, 0}, + //{TEXT("SCI_LOWERCASE"), SCI_LOWERCASE, true, false, false, VK_U, 0}, + //{TEXT("SCI_UPPERCASE"), SCI_UPPERCASE, true, false, true, VK_U, 0}, // - //{"SCI_FORMFEED", SCI_FORMFEED, true, false, false, VK_L, 0}, - //{"SCI_CLEARALLCMDKEYS", SCI_CLEARALLCMDKEYS, false, false, false, 0, 0}, - //{"SCI_STARTRECORD", SCI_STARTRECORD, false, false, false, 0, 0}, - //{"SCI_STOPRECORD", SCI_STOPRECORD, false, false, false, 0, 0}, - //{"SCI_SEARCHANCHOR", SCI_SEARCHANCHOR, false, false, false, 0, 0}, - //{"SCI_TARGETFROMSELECTION", SCI_TARGETFROMSELECTION, false, false, false, 0, 0}, - //{"SCI_STYLERESETDEFAULT", SCI_STYLERESETDEFAULT, false, false, false, 0, 0}, - //{"SCI_STYLECLEARALL", SCI_STYLECLEARALL, false, false, false, 0, 0}, + //{TEXT("SCI_FORMFEED"), SCI_FORMFEED, true, false, false, VK_L, 0}, + //{TEXT("SCI_CLEARALLCMDKEYS"), SCI_CLEARALLCMDKEYS, false, false, false, 0, 0}, + //{TEXT("SCI_STARTRECORD"), SCI_STARTRECORD, false, false, false, 0, 0}, + //{TEXT("SCI_STOPRECORD"), SCI_STOPRECORD, false, false, false, 0, 0}, + //{TEXT("SCI_SEARCHANCHOR"), SCI_SEARCHANCHOR, false, false, false, 0, 0}, + //{TEXT("SCI_TARGETFROMSELECTION"), SCI_TARGETFROMSELECTION, false, false, false, 0, 0}, + //{TEXT("SCI_STYLERESETDEFAULT"), SCI_STYLERESETDEFAULT, false, false, false, 0, 0}, + //{TEXT("SCI_STYLECLEARALL"), SCI_STYLECLEARALL, false, false, false, 0, 0}, // }; @@ -429,15 +429,15 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty _winVersion = getWindowsVersion(); // Prepare for default path - char nppPath[MAX_PATH]; + TCHAR nppPath[MAX_PATH]; ::GetModuleFileName(NULL, nppPath, sizeof(nppPath)); PathRemoveFileSpec(nppPath); - strcpy(_nppPath, nppPath); + lstrcpy(_nppPath, nppPath); _appdataNppDir[0] = '\0'; - char notepadStylePath[MAX_PATH]; - strcpy(notepadStylePath, _nppPath); + TCHAR notepadStylePath[MAX_PATH]; + lstrcpy(notepadStylePath, _nppPath); PathAppend(notepadStylePath, notepadStyleFile); _asNotepadStyle = (PathFileExists(notepadStylePath) == TRUE); @@ -464,13 +464,13 @@ NppParameters::~NppParameters() ::RemoveFontResource(LINEDRAW_FONT); } -void cutString(const char *str2cut, vector & patternVect) +void cutString(const TCHAR *str2cut, vector> & patternVect) { - char str2scan[MAX_PATH]; - strcpy(str2scan, str2cut); - size_t len = strlen(str2scan); + TCHAR str2scan[MAX_PATH]; + lstrcpy(str2scan, str2cut); + size_t len = lstrlen(str2scan); bool isProcessing = false; - char *pBegin = NULL; + TCHAR *pBegin = NULL; for (size_t i = 0 ; i <= len ; i++) { switch(str2scan[i]) @@ -504,11 +504,11 @@ bool NppParameters::load() bool isAllLaoded = true; for (int i = 0 ; i < NB_LANG ; _langList[i] = NULL, i++); - char userPath[MAX_PATH]; + TCHAR userPath[MAX_PATH]; // Make localConf.xml path - char localConfPath[MAX_PATH]; - strcpy(localConfPath, _nppPath); + TCHAR localConfPath[MAX_PATH]; + lstrcpy(localConfPath, _nppPath); PathAppend(localConfPath, localConfFile); // Test if localConf.xml exist @@ -516,7 +516,7 @@ bool NppParameters::load() if (isLocal) { - strcpy(userPath, _nppPath); + lstrcpy(userPath, _nppPath); } else { @@ -524,9 +524,9 @@ bool NppParameters::load() SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); SHGetPathFromIDList(pidl, userPath); - PathAppend(userPath, "Notepad++"); + PathAppend(userPath, TEXT("Notepad++")); - strcpy(_appdataNppDir, userPath); + lstrcpy(_appdataNppDir, userPath); if (!PathFileExists(userPath)) { @@ -537,29 +537,29 @@ bool NppParameters::load() //-------------------------------------// // Transparent function for w2k and xp // //-------------------------------------// - _hUser32 = ::GetModuleHandle("User32"); + _hUser32 = ::GetModuleHandle(TEXT("User32")); if (_hUser32) _transparentFuncAddr = (WNDPROC)::GetProcAddress(_hUser32, "SetLayeredWindowAttributes"); //---------------------------------------------// // Dlg theme texture function for xp and vista // //---------------------------------------------// - _hUXTheme = ::LoadLibrary("uxtheme.dll"); + _hUXTheme = ::LoadLibrary(TEXT("uxtheme.dll")); if (_hUXTheme) _enableThemeDialogTextureFuncAddr = (WNDPROC)::GetProcAddress(_hUXTheme, "EnableThemeDialogTexture"); //---------------------------------------// // langs.xml : for every user statically // //---------------------------------------// - char langs_xml_path[MAX_PATH]; - strcpy(langs_xml_path, _nppPath); + TCHAR langs_xml_path[MAX_PATH]; + lstrcpy(langs_xml_path, _nppPath); - PathAppend(langs_xml_path, "langs.xml"); + PathAppend(langs_xml_path, TEXT("langs.xml")); if (!PathFileExists(langs_xml_path)) { - char srcLangsPath[MAX_PATH]; - strcpy(srcLangsPath, _nppPath); - PathAppend(srcLangsPath, "langs.model.xml"); + TCHAR srcLangsPath[MAX_PATH]; + lstrcpy(srcLangsPath, _nppPath); + PathAppend(srcLangsPath, TEXT("langs.model.xml")); ::CopyFile(srcLangsPath, langs_xml_path, TRUE); } @@ -568,7 +568,7 @@ bool NppParameters::load() bool loadOkay = _pXmlDoc->LoadFile(); if (!loadOkay) { - ::MessageBox(NULL, "Load langs.xml failed!", "Configurator",MB_OK); + ::MessageBox(NULL, TEXT("Load langs.xml failed!"), TEXT("Configurator"),MB_OK); delete _pXmlDoc; _pXmlDoc = NULL; isAllLaoded = false; @@ -579,13 +579,13 @@ bool NppParameters::load() //---------------------------// // config.xml : for per user // //---------------------------// - char configPath[MAX_PATH]; - strcpy(configPath, userPath); - PathAppend(configPath, "config.xml"); + TCHAR configPath[MAX_PATH]; + lstrcpy(configPath, userPath); + PathAppend(configPath, TEXT("config.xml")); - char srcConfigPath[MAX_PATH]; - strcpy(srcConfigPath, _nppPath); - PathAppend(srcConfigPath, "config.model.xml"); + TCHAR srcConfigPath[MAX_PATH]; + lstrcpy(srcConfigPath, _nppPath); + PathAppend(srcConfigPath, TEXT("config.model.xml")); if (!::PathFileExists(configPath)) ::CopyFile(srcConfigPath, configPath, FALSE); @@ -594,7 +594,7 @@ bool NppParameters::load() loadOkay = _pXmlUserDoc->LoadFile(); if (!loadOkay) { - int res = ::MessageBox(NULL, "Load config.xml failed!\rDo you want to recover your config.xml?", "Configurator",MB_YESNO); + int res = ::MessageBox(NULL, TEXT("Load config.xml failed!\rDo you want to recover your config.xml?"), TEXT("Configurator"),MB_YESNO); if (res ==IDYES) { ::CopyFile(srcConfigPath, configPath, FALSE); @@ -602,7 +602,7 @@ bool NppParameters::load() loadOkay = _pXmlUserDoc->LoadFile(); if (!loadOkay) { - ::MessageBox(NULL, "Recover config.xml failed!", "Configurator",MB_OK); + ::MessageBox(NULL, TEXT("Recover config.xml failed!"), TEXT("Configurator"),MB_OK); delete _pXmlUserDoc; _pXmlUserDoc = NULL; isAllLaoded = false; @@ -623,15 +623,15 @@ bool NppParameters::load() //----------------------------// // stylers.xml : for per user // //----------------------------// - char stylerPath[MAX_PATH]; - strcpy(stylerPath, userPath); - PathAppend(stylerPath, "stylers.xml"); + TCHAR stylerPath[MAX_PATH]; + lstrcpy(stylerPath, userPath); + PathAppend(stylerPath, TEXT("stylers.xml")); if (!PathFileExists(stylerPath)) { - char srcStylersPath[MAX_PATH]; - strcpy(srcStylersPath, _nppPath); - PathAppend(srcStylersPath, "stylers.model.xml"); + TCHAR srcStylersPath[MAX_PATH]; + lstrcpy(srcStylersPath, _nppPath); + PathAppend(srcStylersPath, TEXT("stylers.model.xml")); ::CopyFile(srcStylersPath, stylerPath, TRUE); } @@ -640,7 +640,7 @@ bool NppParameters::load() loadOkay = _pXmlUserStylerDoc->LoadFile(); if (!loadOkay) { - ::MessageBox(NULL, "Load stylers.xml failed!", "Configurator",MB_OK); + ::MessageBox(NULL, TEXT("Load stylers.xml failed!"), TEXT("Configurator"),MB_OK); delete _pXmlUserStylerDoc; _pXmlUserStylerDoc = NULL; isAllLaoded = false; @@ -651,8 +651,8 @@ bool NppParameters::load() //-----------------------------------// // userDefineLang.xml : for per user // //-----------------------------------// - strcpy(_userDefineLangPath, userPath); - PathAppend(_userDefineLangPath, "userDefineLang.xml"); + lstrcpy(_userDefineLangPath, userPath); + PathAppend(_userDefineLangPath, TEXT("userDefineLang.xml")); _pXmlUserLangDoc = new TiXmlDocument(_userDefineLangPath); loadOkay = _pXmlUserLangDoc->LoadFile(); @@ -670,14 +670,14 @@ bool NppParameters::load() // In case of absence of user's nativeLang.xml, // // We'll look in the Notepad++ Dir. // //----------------------------------------------// - char nativeLangPath[MAX_PATH]; - strcpy(nativeLangPath, userPath); - PathAppend(nativeLangPath, "nativeLang.xml"); + TCHAR nativeLangPath[MAX_PATH]; + lstrcpy(nativeLangPath, userPath); + PathAppend(nativeLangPath, TEXT("nativeLang.xml")); if (!PathFileExists(nativeLangPath)) { - strcpy(nativeLangPath, _nppPath); - PathAppend(nativeLangPath, "nativeLang.xml"); + lstrcpy(nativeLangPath, _nppPath); + PathAppend(nativeLangPath, TEXT("nativeLang.xml")); } _pXmlNativeLangDoc = new TiXmlDocument(nativeLangPath); @@ -692,9 +692,9 @@ bool NppParameters::load() //---------------------------------// // toolbarIcons.xml : for per user // //---------------------------------// - char toolbarIconsPath[MAX_PATH]; - strcpy(toolbarIconsPath, userPath); - PathAppend(toolbarIconsPath, "toolbarIcons.xml"); + TCHAR toolbarIconsPath[MAX_PATH]; + lstrcpy(toolbarIconsPath, userPath); + PathAppend(toolbarIconsPath, TEXT("toolbarIcons.xml")); _pXmlToolIconsDoc = new TiXmlDocument(toolbarIconsPath); loadOkay = _pXmlToolIconsDoc->LoadFile(); @@ -708,14 +708,14 @@ bool NppParameters::load() //------------------------------// // shortcuts.xml : for per user // //------------------------------// - strcpy(_shortcutsPath, userPath); - PathAppend(_shortcutsPath, "shortcuts.xml"); + lstrcpy(_shortcutsPath, userPath); + PathAppend(_shortcutsPath, TEXT("shortcuts.xml")); if (!PathFileExists(_shortcutsPath)) { - char srcShortcutsPath[MAX_PATH]; - strcpy(srcShortcutsPath, _nppPath); - PathAppend(srcShortcutsPath, "shortcuts.xml"); + TCHAR srcShortcutsPath[MAX_PATH]; + lstrcpy(srcShortcutsPath, _nppPath); + PathAppend(srcShortcutsPath, TEXT("shortcuts.xml")); ::CopyFile(srcShortcutsPath, _shortcutsPath, TRUE); } @@ -742,14 +742,14 @@ bool NppParameters::load() //---------------------------------// // contextMenu.xml : for per user // //---------------------------------// - strcpy(_contextMenuPath, userPath); - PathAppend(_contextMenuPath, "contextMenu.xml"); + lstrcpy(_contextMenuPath, userPath); + PathAppend(_contextMenuPath, TEXT("contextMenu.xml")); if (!PathFileExists(_contextMenuPath)) { - char srcContextMenuPath[MAX_PATH]; - strcpy(srcContextMenuPath, _nppPath); - PathAppend(srcContextMenuPath, "contextMenu.xml"); + TCHAR srcContextMenuPath[MAX_PATH]; + lstrcpy(srcContextMenuPath, _nppPath); + PathAppend(srcContextMenuPath, TEXT("contextMenu.xml")); ::CopyFile(srcContextMenuPath, _contextMenuPath, TRUE); } @@ -768,8 +768,8 @@ bool NppParameters::load() //----------------------------// // session.xml : for per user // //----------------------------// - strcpy(_sessionPath, userPath); - PathAppend(_sessionPath, "session.xml"); + lstrcpy(_sessionPath, userPath); + PathAppend(_sessionPath, TEXT("session.xml")); // Don't load session.xml if not required in order to speed up!! const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI(); @@ -838,7 +838,7 @@ void NppParameters::setFontList(HWND hWnd) LOGFONT lf; _fontlist.clear(); - _fontlist.push_back(""); + _fontlist.push_back(TEXT("")); lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0]='\0'; @@ -852,14 +852,14 @@ void NppParameters::setFontList(HWND hWnd) void NppParameters::getLangKeywordsFromXmlTree() { - TiXmlNode *root = _pXmlDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return; feedKeyWordsParameters(root); } void NppParameters::getExternalLexerFromXmlTree(TiXmlDocument *doc) { - TiXmlNode *root = doc->FirstChild("NotepadPlus"); + TiXmlNode *root = doc->FirstChild(TEXT("NotepadPlus")); if (!root) return; feedKeyWordsParameters(root); feedStylerArray(root); @@ -875,7 +875,7 @@ int NppParameters::addExternalLangToEnd(ExternalLangContainer * externalLang) bool NppParameters::getUserStylersFromXmlTree() { - TiXmlNode *root = _pXmlUserStylerDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; return feedStylerArray(root); } @@ -885,7 +885,7 @@ bool NppParameters::getUserParametersFromXmlTree() if (!_pXmlUserDoc) return false; - TiXmlNode *root = _pXmlUserDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; // GUI @@ -895,11 +895,11 @@ bool NppParameters::getUserParametersFromXmlTree() feedFileListParameters(root); // Raser tout - TiXmlNode *node = root->FirstChildElement("History"); + TiXmlNode *node = root->FirstChildElement(TEXT("History")); root->RemoveChild(node); // Repartir de zero - TiXmlElement HistoryNode("History"); + TiXmlElement HistoryNode(TEXT("History")); root->InsertEndChild(HistoryNode); return true; @@ -910,7 +910,7 @@ bool NppParameters::getUserDefineLangsFromXmlTree() if (!_pXmlUserLangDoc) return false; - TiXmlNode *root = _pXmlUserLangDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlUserLangDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; @@ -923,7 +923,7 @@ bool NppParameters::getShortcutsFromXmlTree() if (!_pXmlShortcutDoc) return false; - TiXmlNode *root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; @@ -936,7 +936,7 @@ bool NppParameters::getMacrosFromXmlTree() if (!_pXmlShortcutDoc) return false; - TiXmlNode *root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; @@ -949,7 +949,7 @@ bool NppParameters::getUserCmdsFromXmlTree() if (!_pXmlShortcutDoc) return false; - TiXmlNode *root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; @@ -963,7 +963,7 @@ bool NppParameters::getPluginCmdsFromXmlTree() if (!_pXmlShortcutDoc) return false; - TiXmlNode *root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; @@ -977,7 +977,7 @@ bool NppParameters::getScintKeysFromXmlTree() if (!_pXmlShortcutDoc) return false; - TiXmlNode *root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; @@ -992,7 +992,7 @@ void NppParameters::initMenuKeys() for(int i = 0; i < nrCommands; i++) { wkd = winKeyDefs[i]; - Shortcut sc( (wkd.specialName?wkd.specialName:""), wkd.isCtrl, wkd.isAlt, wkd.isShift, wkd.vKey); + Shortcut sc( (wkd.specialName?wkd.specialName:TEXT("")), wkd.isCtrl, wkd.isAlt, wkd.isShift, wkd.vKey); _shortcuts.push_back( CommandShortcut(sc, wkd.functionId) ); } } @@ -1027,46 +1027,46 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle) if (!_pXmlContextMenuDoc) return false; - TiXmlNode *root = _pXmlContextMenuDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlContextMenuDoc->FirstChild(TEXT("NotepadPlus")); if (!root) return false; - TiXmlNode *contextMenuRoot = root->FirstChildElement("ScintillaContextMenu"); + TiXmlNode *contextMenuRoot = root->FirstChildElement(TEXT("ScintillaContextMenu")); if (contextMenuRoot) { - for (TiXmlNode *childNode = contextMenuRoot->FirstChildElement("Item"); + for (TiXmlNode *childNode = contextMenuRoot->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { int id; - const char *idStr = (childNode->ToElement())->Attribute("id", &id); + const TCHAR *idStr = (childNode->ToElement())->Attribute(TEXT("id"), &id); if (idStr) { - _contextMenuItems.push_back(MenuItemUnit(id, "")); + _contextMenuItems.push_back(MenuItemUnit(id, TEXT(""))); } else { - const char *menuEntryName = (childNode->ToElement())->Attribute("MenuEntryName"); - const char *menuItemName = (childNode->ToElement())->Attribute("MenuItemName"); + const TCHAR *menuEntryName = (childNode->ToElement())->Attribute(TEXT("MenuEntryName")); + const TCHAR *menuItemName = (childNode->ToElement())->Attribute(TEXT("MenuItemName")); if (menuEntryName && menuItemName) { int nbMenuEntry = ::GetMenuItemCount(mainMenuHadle); for (int i = 0 ; i < nbMenuEntry ; i++) { - char menuEntryString[64]; + TCHAR menuEntryString[64]; ::GetMenuString(mainMenuHadle, i, menuEntryString, 64, MF_BYPOSITION); - if (stricmp(menuEntryName, purgeMenuItemString(menuEntryString).c_str()) == 0) + if (generic_stricmp(menuEntryName, purgeMenuItemString(menuEntryString).c_str()) == 0) { HMENU subMenu = ::GetSubMenu(mainMenuHadle, i); int nbSubMenuCmd = ::GetMenuItemCount(subMenu); for (int j = 0 ; j < nbSubMenuCmd ; j++) { - char cmdStr[256]; + TCHAR cmdStr[256]; ::GetMenuString(subMenu, j, cmdStr, 256, MF_BYPOSITION); - if (stricmp(menuItemName, purgeMenuItemString(cmdStr).c_str()) == 0) + if (generic_stricmp(menuItemName, purgeMenuItemString(cmdStr).c_str()) == 0) { int cmdId = ::GetMenuItemID(subMenu, j); - _contextMenuItems.push_back(MenuItemUnit(cmdId, "")); + _contextMenuItems.push_back(MenuItemUnit(cmdId, TEXT(""))); break; } } @@ -1076,28 +1076,28 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle) } else { - const char *pluginName = (childNode->ToElement())->Attribute("PluginEntryName"); - const char *pluginCmdName = (childNode->ToElement())->Attribute("pluginCommandItemName"); + const TCHAR *pluginName = (childNode->ToElement())->Attribute(TEXT("PluginEntryName")); + const TCHAR *pluginCmdName = (childNode->ToElement())->Attribute(TEXT("pluginCommandItemName")); if (pluginName && pluginName) { HMENU pluginsMenu = ::GetSubMenu(mainMenuHadle, MENUINDEX_PLUGINS); int nbPlugins = ::GetMenuItemCount(pluginsMenu); for (int i = 0 ; i < nbPlugins ; i++) { - char menuItemString[256]; + TCHAR menuItemString[256]; ::GetMenuString(pluginsMenu, i, menuItemString, 256, MF_BYPOSITION); - if (stricmp(pluginName, purgeMenuItemString(menuItemString).c_str()) == 0) + if (generic_stricmp(pluginName, purgeMenuItemString(menuItemString).c_str()) == 0) { HMENU pluginMenu = ::GetSubMenu(pluginsMenu, i); int nbPluginCmd = ::GetMenuItemCount(pluginMenu); for (int j = 0 ; j < nbPluginCmd ; j++) { - char pluginCmdStr[256]; + TCHAR pluginCmdStr[256]; ::GetMenuString(pluginMenu, j, pluginCmdStr, 256, MF_BYPOSITION); - if (stricmp(pluginCmdName, purgeMenuItemString(pluginCmdStr).c_str()) == 0) + if (generic_stricmp(pluginCmdName, purgeMenuItemString(pluginCmdStr).c_str()) == 0) { int pluginCmdId = ::GetMenuItemID(pluginMenu, j); - _contextMenuItems.push_back(MenuItemUnit(pluginCmdId, "")); + _contextMenuItems.push_back(MenuItemUnit(pluginCmdId, TEXT(""))); break; } } @@ -1113,7 +1113,7 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle) return true; } -bool NppParameters::loadSession(Session & session, const char *sessionFileName) +bool NppParameters::loadSession(Session & session, const TCHAR *sessionFileName) { TiXmlDocument *pXmlSessionDocument = new TiXmlDocument(sessionFileName); bool loadOkay = pXmlSessionDocument->LoadFile(); @@ -1141,58 +1141,58 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p if (!*ppSessionDoc) return false; - TiXmlNode *root = (*ppSessionDoc)->FirstChild("NotepadPlus"); + TiXmlNode *root = (*ppSessionDoc)->FirstChild(TEXT("NotepadPlus")); if (!root) return false; - TiXmlNode *sessionRoot = root->FirstChildElement("Session"); + TiXmlNode *sessionRoot = root->FirstChildElement(TEXT("Session")); if (!sessionRoot) return false; TiXmlElement *actView = sessionRoot->ToElement(); size_t index; - const char *str = actView->Attribute("activeView", (int *)&index); + const TCHAR *str = actView->Attribute(TEXT("activeView"), (int *)&index); if (str) { (*ptrSession)._activeView = index; } - TiXmlNode *mainviewRoot = sessionRoot->FirstChildElement("mainView"); + TiXmlNode *mainviewRoot = sessionRoot->FirstChildElement(TEXT("mainView")); if (mainviewRoot) { TiXmlElement *actIndex = mainviewRoot->ToElement(); - str = actIndex->Attribute("activeIndex", (int *)&index); + str = actIndex->Attribute(TEXT("activeIndex"), (int *)&index); if (str) { (*ptrSession)._activeMainIndex = index; } - for (TiXmlNode *childNode = mainviewRoot->FirstChildElement("File"); + for (TiXmlNode *childNode = mainviewRoot->FirstChildElement(TEXT("File")); childNode ; - childNode = childNode->NextSibling("File") ) + childNode = childNode->NextSibling(TEXT("File")) ) { - const char *fileName = (childNode->ToElement())->Attribute("filename"); + const TCHAR *fileName = (childNode->ToElement())->Attribute(TEXT("filename")); if (fileName) { Position position; - (childNode->ToElement())->Attribute("firstVisibleLine", &position._firstVisibleLine); - (childNode->ToElement())->Attribute("xOffset", &position._xOffset); - (childNode->ToElement())->Attribute("startPos", &position._startPos); - (childNode->ToElement())->Attribute("endPos", &position._endPos); - (childNode->ToElement())->Attribute("selMode", &position._selMode); - (childNode->ToElement())->Attribute("scrollWidth", &position._scrollWidth); + (childNode->ToElement())->Attribute(TEXT("firstVisibleLine"), &position._firstVisibleLine); + (childNode->ToElement())->Attribute(TEXT("xOffset"), &position._xOffset); + (childNode->ToElement())->Attribute(TEXT("startPos"), &position._startPos); + (childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos); + (childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode); + (childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth); - const char *langName; - langName = (childNode->ToElement())->Attribute( "lang" ); + const TCHAR *langName; + langName = (childNode->ToElement())->Attribute(TEXT("lang")); sessionFileInfo sfi( fileName, langName, position ); - for (TiXmlNode *markNode = childNode->FirstChildElement("Mark"); + for (TiXmlNode *markNode = childNode->FirstChildElement(TEXT("Mark")); markNode ; - markNode = markNode->NextSibling("Mark") ) + markNode = markNode->NextSibling(TEXT("Mark"))) { int lineNumber; - const char *lineNumberStr = (markNode->ToElement())->Attribute("line", &lineNumber); + const TCHAR *lineNumberStr = (markNode->ToElement())->Attribute(TEXT("line"), &lineNumber); if (lineNumberStr) { sfi.marks.push_back(lineNumber); @@ -1203,41 +1203,41 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p } } - TiXmlNode *subviewRoot = sessionRoot->FirstChildElement("subView"); + TiXmlNode *subviewRoot = sessionRoot->FirstChildElement(TEXT("subView")); if (subviewRoot) { TiXmlElement *actIndex = subviewRoot->ToElement(); - str = actIndex->Attribute("activeIndex", (int *)&index); + str = actIndex->Attribute(TEXT("activeIndex"), (int *)&index); if (str) { (*ptrSession)._activeSubIndex = index; } - for (TiXmlNode *childNode = subviewRoot->FirstChildElement("File"); + for (TiXmlNode *childNode = subviewRoot->FirstChildElement(TEXT("File")); childNode ; - childNode = childNode->NextSibling("File") ) + childNode = childNode->NextSibling(TEXT("File")) ) { - const char *fileName = (childNode->ToElement())->Attribute("filename"); + const TCHAR *fileName = (childNode->ToElement())->Attribute(TEXT("filename")); if (fileName) { Position position; - (childNode->ToElement())->Attribute("firstVisibleLine", &position._firstVisibleLine); - (childNode->ToElement())->Attribute("xOffset", &position._xOffset); - (childNode->ToElement())->Attribute("startPos", &position._startPos); - (childNode->ToElement())->Attribute("endPos", &position._endPos); - (childNode->ToElement())->Attribute("selMode", &position._selMode); - (childNode->ToElement())->Attribute("scrollWidth", &position._scrollWidth); + (childNode->ToElement())->Attribute(TEXT("firstVisibleLine"), &position._firstVisibleLine); + (childNode->ToElement())->Attribute(TEXT("xOffset"), &position._xOffset); + (childNode->ToElement())->Attribute(TEXT("startPos"), &position._startPos); + (childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos); + (childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode); + (childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth); - const char *langName; - langName = (childNode->ToElement())->Attribute( "lang" ); + const TCHAR *langName; + langName = (childNode->ToElement())->Attribute(TEXT("lang")); sessionFileInfo sfi( fileName, langName, position ); - for (TiXmlNode *markNode = childNode->FirstChildElement("Mark"); + for (TiXmlNode *markNode = childNode->FirstChildElement(TEXT("Mark")); markNode ; - markNode = markNode->NextSibling("Mark") ) + markNode = markNode->NextSibling(TEXT("Mark"))) { int lineNumber; - const char *lineNumberStr = (markNode->ToElement())->Attribute("line", &lineNumber); + const TCHAR *lineNumberStr = (markNode->ToElement())->Attribute(TEXT("line"), &lineNumber); if (lineNumberStr) { sfi.marks.push_back(lineNumber); @@ -1255,21 +1255,21 @@ void NppParameters::feedFileListParameters(TiXmlNode *node) { _nbMaxFile = 10; - TiXmlNode *historyRoot = node->FirstChildElement("History"); + TiXmlNode *historyRoot = node->FirstChildElement(TEXT("History")); if (!historyRoot) return; - (historyRoot->ToElement())->Attribute("nbMaxFile", &_nbMaxFile); + (historyRoot->ToElement())->Attribute(TEXT("nbMaxFile"), &_nbMaxFile); if ((_nbMaxFile < 0) || (_nbMaxFile > 30)) return; - for (TiXmlNode *childNode = historyRoot->FirstChildElement("File"); + for (TiXmlNode *childNode = historyRoot->FirstChildElement(TEXT("File")); childNode && (_nbFile < NB_MAX_LRF_FILE); - childNode = childNode->NextSibling("File") ) + childNode = childNode->NextSibling(TEXT("File")) ) { - const char *filePath = (childNode->ToElement())->Attribute("filename"); + const TCHAR *filePath = (childNode->ToElement())->Attribute(TEXT("filename")); if (filePath) { - _LRFileList[_nbFile] = new string(filePath); + _LRFileList[_nbFile] = new basic_string(filePath); _nbFile++; } } @@ -1277,15 +1277,15 @@ void NppParameters::feedFileListParameters(TiXmlNode *node) void NppParameters::feedShortcut(TiXmlNode *node) { - TiXmlNode *shortcutsRoot = node->FirstChildElement("InternalCommands"); + TiXmlNode *shortcutsRoot = node->FirstChildElement(TEXT("InternalCommands")); if (!shortcutsRoot) return; - for (TiXmlNode *childNode = shortcutsRoot->FirstChildElement("Shortcut"); + for (TiXmlNode *childNode = shortcutsRoot->FirstChildElement(TEXT("Shortcut")); childNode ; - childNode = childNode->NextSibling("Shortcut") ) + childNode = childNode->NextSibling(TEXT("Shortcut")) ) { int id; - const char *idStr = (childNode->ToElement())->Attribute("id", &id); + const TCHAR *idStr = (childNode->ToElement())->Attribute(TEXT("id"), &id); if (idStr) { //find the commandid that matches this Shortcut sc and alter it, push back its index in the modified list, if not present @@ -1304,12 +1304,12 @@ void NppParameters::feedShortcut(TiXmlNode *node) void NppParameters::feedMacros(TiXmlNode *node) { - TiXmlNode *macrosRoot = node->FirstChildElement("Macros"); + TiXmlNode *macrosRoot = node->FirstChildElement(TEXT("Macros")); if (!macrosRoot) return; - for (TiXmlNode *childNode = macrosRoot->FirstChildElement("Macro"); + for (TiXmlNode *childNode = macrosRoot->FirstChildElement(TEXT("Macro")); childNode ; - childNode = childNode->NextSibling("Macro") ) + childNode = childNode->NextSibling(TEXT("Macro")) ) { Shortcut sc; if (getShortcuts(childNode, sc))// && sc.isValid()) @@ -1327,27 +1327,27 @@ void NppParameters::feedMacros(TiXmlNode *node) void NppParameters::getActions(TiXmlNode *node, Macro & macro) { - for (TiXmlNode *childNode = node->FirstChildElement("Action"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Action")); childNode ; - childNode = childNode->NextSibling("Action") ) + childNode = childNode->NextSibling(TEXT("Action")) ) { int type; - const char *typeStr = (childNode->ToElement())->Attribute("type", &type); + const TCHAR *typeStr = (childNode->ToElement())->Attribute(TEXT("type"), &type); if ((!typeStr) || (type > 2)) continue; int msg = 0; - const char *msgStr = (childNode->ToElement())->Attribute("message", &msg); + const TCHAR *msgStr = (childNode->ToElement())->Attribute(TEXT("message"), &msg); int wParam = 0; - const char *wParamStr = (childNode->ToElement())->Attribute("wParam", &wParam); + const TCHAR *wParamStr = (childNode->ToElement())->Attribute(TEXT("wParam"), &wParam); int lParam = 0; - const char *lParamStr = (childNode->ToElement())->Attribute("lParam", &lParam); + const TCHAR *lParamStr = (childNode->ToElement())->Attribute(TEXT("lParam"), &lParam); - const char *sParam = (childNode->ToElement())->Attribute("sParam"); + const TCHAR *sParam = (childNode->ToElement())->Attribute(TEXT("sParam")); if (!sParam) - sParam = ""; + sParam = TEXT(""); recordedMacroStep step(type, msg, wParam, lParam, sParam); if (step.isValid()) macro.push_back(step); @@ -1357,12 +1357,12 @@ void NppParameters::getActions(TiXmlNode *node, Macro & macro) void NppParameters::feedUserCmds(TiXmlNode *node) { - TiXmlNode *userCmdsRoot = node->FirstChildElement("UserDefinedCommands"); + TiXmlNode *userCmdsRoot = node->FirstChildElement(TEXT("UserDefinedCommands")); if (!userCmdsRoot) return; - for (TiXmlNode *childNode = userCmdsRoot->FirstChildElement("Command"); + for (TiXmlNode *childNode = userCmdsRoot->FirstChildElement(TEXT("Command")); childNode ; - childNode = childNode->NextSibling("Command") ) + childNode = childNode->NextSibling(TEXT("Command")) ) { Shortcut sc; if (getShortcuts(childNode, sc))// && sc.isValid()) @@ -1370,7 +1370,7 @@ void NppParameters::feedUserCmds(TiXmlNode *node) TiXmlNode *aNode = childNode->FirstChild(); if (aNode) { - const char *cmdStr = aNode->Value(); + const TCHAR *cmdStr = aNode->Value(); if (cmdStr) { int cmdID = ID_USER_CMD + _userCommands.size(); @@ -1385,19 +1385,19 @@ void NppParameters::feedUserCmds(TiXmlNode *node) void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node) { - TiXmlNode *pluginCustomizedCmdsRoot = node->FirstChildElement("PluginCommands"); + TiXmlNode *pluginCustomizedCmdsRoot = node->FirstChildElement(TEXT("PluginCommands")); if (!pluginCustomizedCmdsRoot) return; - for (TiXmlNode *childNode = pluginCustomizedCmdsRoot->FirstChildElement("PluginCommand"); + for (TiXmlNode *childNode = pluginCustomizedCmdsRoot->FirstChildElement(TEXT("PluginCommand")); childNode ; - childNode = childNode->NextSibling("PluginCommand") ) + childNode = childNode->NextSibling(TEXT("PluginCommand")) ) { - const char *moduleName = (childNode->ToElement())->Attribute("moduleName"); + const TCHAR *moduleName = (childNode->ToElement())->Attribute(TEXT("moduleName")); if (!moduleName) continue; int internalID = -1; - const char *internalIDStr = (childNode->ToElement())->Attribute("internalID", &internalID); + const TCHAR *internalIDStr = (childNode->ToElement())->Attribute(TEXT("internalID"), &internalID); if (!internalIDStr) continue; @@ -1407,7 +1407,7 @@ void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node) for(int i = 0; i < len; i++) { PluginCmdShortcut & pscOrig = _pluginCommands[i]; - if (!_strnicmp(pscOrig.getModuleName(), moduleName, strlen(moduleName)) && pscOrig.getInternalID() == internalID) + if (!generic_strnicmp(pscOrig.getModuleName(), moduleName, lstrlen(moduleName)) && pscOrig.getInternalID() == internalID) { //Found matching command getShortcuts(childNode, _pluginCommands[i]); @@ -1420,20 +1420,20 @@ void NppParameters::feedPluginCustomizedCmds(TiXmlNode *node) void NppParameters::feedScintKeys(TiXmlNode *node) { - TiXmlNode *scintKeysRoot = node->FirstChildElement("ScintillaKeys"); + TiXmlNode *scintKeysRoot = node->FirstChildElement(TEXT("ScintillaKeys")); if (!scintKeysRoot) return; - for (TiXmlNode *childNode = scintKeysRoot->FirstChildElement("ScintKey"); + for (TiXmlNode *childNode = scintKeysRoot->FirstChildElement(TEXT("ScintKey")); childNode ; - childNode = childNode->NextSibling("ScintKey") ) + childNode = childNode->NextSibling(TEXT("ScintKey")) ) { int scintKey; - const char *keyStr = (childNode->ToElement())->Attribute("ScintID", &scintKey); + const TCHAR *keyStr = (childNode->ToElement())->Attribute(TEXT("ScintID"), &scintKey); if (!keyStr) continue; int menuID; - keyStr = (childNode->ToElement())->Attribute("menuCmdID", &menuID); + keyStr = (childNode->ToElement())->Attribute(TEXT("menuCmdID"), &menuID); if (!keyStr) continue; @@ -1450,27 +1450,27 @@ void NppParameters::feedScintKeys(TiXmlNode *node) _scintillaKeyCommands[i].setKeyComboByIndex(0, _scintillaKeyCommands[i].getKeyCombo()); addScintillaModifiedIndex(i); KeyCombo kc; - for (TiXmlNode *nextNode = childNode->FirstChildElement("NextKey"); + for (TiXmlNode *nextNode = childNode->FirstChildElement(TEXT("NextKey")); nextNode ; - nextNode = childNode->NextSibling("NextKey") ) + nextNode = childNode->NextSibling(TEXT("NextKey")) ) { - const char *str = (nextNode->ToElement())->Attribute("Ctrl"); + const TCHAR *str = (nextNode->ToElement())->Attribute(TEXT("Ctrl")); if (!str) continue; - kc._isCtrl = !strcmp("yes", str); + kc._isCtrl = !lstrcmp(TEXT("yes"), str); - str = (nextNode->ToElement())->Attribute("Alt"); + str = (nextNode->ToElement())->Attribute(TEXT("Alt")); if (!str) continue; - kc._isAlt = !strcmp("yes", str); + kc._isAlt = !lstrcmp(TEXT("yes"), str); - str = (nextNode->ToElement())->Attribute("Shift"); + str = (nextNode->ToElement())->Attribute(TEXT("Shift")); if (!str) continue; - kc._isShift = !strcmp("yes", str); + kc._isShift = !lstrcmp(TEXT("yes"), str); int key; - str = (nextNode->ToElement())->Attribute("Key", &key); + str = (nextNode->ToElement())->Attribute(TEXT("Key"), &key); if (!str) continue; kc._key = key; @@ -1486,27 +1486,27 @@ bool NppParameters::getShortcuts(TiXmlNode *node, Shortcut & sc) { if (!node) return false; - const char *name = (node->ToElement())->Attribute("name"); + const TCHAR *name = (node->ToElement())->Attribute(TEXT("name")); if (!name) - name = ""; + name = TEXT(""); bool isCtrl = false; - const char *isCtrlStr = (node->ToElement())->Attribute("Ctrl"); + const TCHAR *isCtrlStr = (node->ToElement())->Attribute(TEXT("Ctrl")); if (isCtrlStr) - isCtrl = !strcmp("yes", isCtrlStr); + isCtrl = !lstrcmp(TEXT("yes"), isCtrlStr); bool isAlt = false; - const char *isAltStr = (node->ToElement())->Attribute("Alt"); + const TCHAR *isAltStr = (node->ToElement())->Attribute(TEXT("Alt")); if (isAltStr) - isAlt = !strcmp("yes", isAltStr); + isAlt = !lstrcmp(TEXT("yes"), isAltStr); bool isShift = false; - const char *isShiftStr = (node->ToElement())->Attribute("Shift"); + const TCHAR *isShiftStr = (node->ToElement())->Attribute(TEXT("Shift")); if (isShiftStr) - isShift = !strcmp("yes", isShiftStr); + isShift = !lstrcmp(TEXT("yes"), isShiftStr); int key; - const char *keyStr = (node->ToElement())->Attribute("Key", &key); + const TCHAR *keyStr = (node->ToElement())->Attribute(TEXT("Key"), &key); if (!keyStr) return false; @@ -1519,27 +1519,27 @@ const int loadFailed = 100; const int missingName = 101; void NppParameters::feedUserLang(TiXmlNode *node) { - for (TiXmlNode *childNode = node->FirstChildElement("UserLang"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("UserLang")); childNode && (_nbUserLang < NB_MAX_USER_LANG); - childNode = childNode->NextSibling("UserLang") ) + childNode = childNode->NextSibling(TEXT("UserLang")) ) { - const char *name = (childNode->ToElement())->Attribute("name"); - const char *ext = (childNode->ToElement())->Attribute("ext"); + const TCHAR *name = (childNode->ToElement())->Attribute(TEXT("name")); + const TCHAR *ext = (childNode->ToElement())->Attribute(TEXT("ext")); try { if (!name || !name[0] || !ext) throw int(missingName); _userLangArray[_nbUserLang] = new UserLangContainer(name, ext); _nbUserLang++; - TiXmlNode *settingsRoot = childNode->FirstChildElement("Settings"); + TiXmlNode *settingsRoot = childNode->FirstChildElement(TEXT("Settings")); if (!settingsRoot) throw int(loadFailed); feedUserSettings(settingsRoot); - TiXmlNode *keywordListsRoot = childNode->FirstChildElement("KeywordLists"); + TiXmlNode *keywordListsRoot = childNode->FirstChildElement(TEXT("KeywordLists")); if (!keywordListsRoot) throw int(loadFailed); feedUserKeywordList(keywordListsRoot); - TiXmlNode *stylesRoot = childNode->FirstChildElement("Styles"); + TiXmlNode *stylesRoot = childNode->FirstChildElement(TEXT("Styles")); if (!stylesRoot) throw int(loadFailed); feedUserStyles(stylesRoot); @@ -1558,18 +1558,18 @@ void NppParameters::writeUserDefinedLang() _pXmlUserLangDoc = new TiXmlDocument(_userDefineLangPath); } - //before remove the branch, we allocate and copy the char * which will be destroyed + //before remove the branch, we allocate and copy the TCHAR * which will be destroyed stylerStrOp(DUP); - TiXmlNode *root = _pXmlUserLangDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlUserLangDoc->FirstChild(TEXT("NotepadPlus")); if (root) { _pXmlUserLangDoc->RemoveChild(root); } - _pXmlUserLangDoc->InsertEndChild(TiXmlElement("NotepadPlus")); + _pXmlUserLangDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus"))); - root = _pXmlUserLangDoc->FirstChild("NotepadPlus"); + root = _pXmlUserLangDoc->FirstChild(TEXT("NotepadPlus")); for (int i = 0 ; i < _nbUserLang ; i++) { @@ -1582,142 +1582,142 @@ void NppParameters::writeUserDefinedLang() void NppParameters::insertCmd(TiXmlNode *shortcutsRoot, const CommandShortcut & cmd) { const KeyCombo & key = cmd.getKeyCombo(); - TiXmlNode *sc = shortcutsRoot->InsertEndChild(TiXmlElement("Shortcut")); - sc->ToElement()->SetAttribute("id", cmd.getID()); - sc->ToElement()->SetAttribute("Ctrl", key._isCtrl?"yes":"no"); - sc->ToElement()->SetAttribute("Alt", key._isAlt?"yes":"no"); - sc->ToElement()->SetAttribute("Shift", key._isShift?"yes":"no"); - sc->ToElement()->SetAttribute("Key", key._key); + TiXmlNode *sc = shortcutsRoot->InsertEndChild(TiXmlElement(TEXT("Shortcut"))); + sc->ToElement()->SetAttribute(TEXT("id"), cmd.getID()); + sc->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); + sc->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); + sc->ToElement()->SetAttribute(TEXT("Shift"), key._isShift?TEXT("yes"):TEXT("no")); + sc->ToElement()->SetAttribute(TEXT("Key"), key._key); } void NppParameters::insertMacro(TiXmlNode *macrosRoot, const MacroShortcut & macro) { const KeyCombo & key = macro.getKeyCombo(); - TiXmlNode *macroRoot = macrosRoot->InsertEndChild(TiXmlElement("Macro")); - macroRoot->ToElement()->SetAttribute("name", macro.getMenuName()); - macroRoot->ToElement()->SetAttribute("Ctrl", key._isCtrl?"yes":"no"); - macroRoot->ToElement()->SetAttribute("Alt", key._isAlt?"yes":"no"); - macroRoot->ToElement()->SetAttribute("Shift", key._isShift?"yes":"no"); - macroRoot->ToElement()->SetAttribute("Key", key._key); + TiXmlNode *macroRoot = macrosRoot->InsertEndChild(TiXmlElement(TEXT("Macro"))); + macroRoot->ToElement()->SetAttribute(TEXT("name"), macro.getMenuName()); + macroRoot->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); + macroRoot->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); + macroRoot->ToElement()->SetAttribute(TEXT("Shift"), key._isShift?TEXT("yes"):TEXT("no")); + macroRoot->ToElement()->SetAttribute(TEXT("Key"), key._key); for (size_t i = 0 ; i < macro._macro.size() ; i++) { - TiXmlNode *actionNode = macroRoot->InsertEndChild(TiXmlElement("Action")); + TiXmlNode *actionNode = macroRoot->InsertEndChild(TiXmlElement(TEXT("Action"))); const recordedMacroStep & action = macro._macro[i]; - actionNode->ToElement()->SetAttribute("type", action.MacroType); - actionNode->ToElement()->SetAttribute("message", action.message); - actionNode->ToElement()->SetAttribute("wParam", action.wParameter); - actionNode->ToElement()->SetAttribute("lParam", action.lParameter); - actionNode->ToElement()->SetAttribute("sParam", action.sParameter.c_str()); + actionNode->ToElement()->SetAttribute(TEXT("type"), action.MacroType); + actionNode->ToElement()->SetAttribute(TEXT("message"), action.message); + actionNode->ToElement()->SetAttribute(TEXT("wParam"), action.wParameter); + actionNode->ToElement()->SetAttribute(TEXT("lParam"), action.lParameter); + actionNode->ToElement()->SetAttribute(TEXT("sParam"), action.sParameter.c_str()); } } void NppParameters::insertUserCmd(TiXmlNode *userCmdRoot, const UserCommand & userCmd) { const KeyCombo & key = userCmd.getKeyCombo(); - TiXmlNode *cmdRoot = userCmdRoot->InsertEndChild(TiXmlElement("Command")); - cmdRoot->ToElement()->SetAttribute("name", userCmd.getMenuName()); - cmdRoot->ToElement()->SetAttribute("Ctrl", key._isCtrl?"yes":"no"); - cmdRoot->ToElement()->SetAttribute("Alt", key._isAlt?"yes":"no"); - cmdRoot->ToElement()->SetAttribute("Shift", key._isShift?"yes":"no"); - cmdRoot->ToElement()->SetAttribute("Key", key._key); + TiXmlNode *cmdRoot = userCmdRoot->InsertEndChild(TiXmlElement(TEXT("Command"))); + cmdRoot->ToElement()->SetAttribute(TEXT("name"), userCmd.getMenuName()); + cmdRoot->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); + cmdRoot->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); + cmdRoot->ToElement()->SetAttribute(TEXT("Shift"), key._isShift?TEXT("yes"):TEXT("no")); + cmdRoot->ToElement()->SetAttribute(TEXT("Key"), key._key); cmdRoot->InsertEndChild(TiXmlText(userCmd._cmd.c_str())); } void NppParameters::insertPluginCmd(TiXmlNode *pluginCmdRoot, const PluginCmdShortcut & pluginCmd) { const KeyCombo & key = pluginCmd.getKeyCombo(); - TiXmlNode *pluginCmdNode = pluginCmdRoot->InsertEndChild(TiXmlElement("PluginCommand")); - pluginCmdNode->ToElement()->SetAttribute("moduleName", pluginCmd.getModuleName()); - pluginCmdNode->ToElement()->SetAttribute("internalID", pluginCmd.getInternalID()); - pluginCmdNode->ToElement()->SetAttribute("Ctrl", key._isCtrl?"yes":"no"); - pluginCmdNode->ToElement()->SetAttribute("Alt", key._isAlt?"yes":"no"); - pluginCmdNode->ToElement()->SetAttribute("Shift", key._isShift?"yes":"no"); - pluginCmdNode->ToElement()->SetAttribute("Key", key._key); + TiXmlNode *pluginCmdNode = pluginCmdRoot->InsertEndChild(TiXmlElement(TEXT("PluginCommand"))); + pluginCmdNode->ToElement()->SetAttribute(TEXT("moduleName"), pluginCmd.getModuleName()); + pluginCmdNode->ToElement()->SetAttribute(TEXT("internalID"), pluginCmd.getInternalID()); + pluginCmdNode->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); + pluginCmdNode->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); + pluginCmdNode->ToElement()->SetAttribute(TEXT("Shift"), key._isShift?TEXT("yes"):TEXT("no")); + pluginCmdNode->ToElement()->SetAttribute(TEXT("Key"), key._key); } void NppParameters::insertScintKey(TiXmlNode *scintKeyRoot, const ScintillaKeyMap & scintKeyMap) { - TiXmlNode *keyRoot = scintKeyRoot->InsertEndChild(TiXmlElement("ScintKey")); - keyRoot->ToElement()->SetAttribute("ScintID", scintKeyMap.getScintillaKeyID()); - keyRoot->ToElement()->SetAttribute("menuCmdID", scintKeyMap.getMenuCmdID()); + TiXmlNode *keyRoot = scintKeyRoot->InsertEndChild(TiXmlElement(TEXT("ScintKey"))); + keyRoot->ToElement()->SetAttribute(TEXT("ScintID"), scintKeyMap.getScintillaKeyID()); + keyRoot->ToElement()->SetAttribute(TEXT("menuCmdID"), scintKeyMap.getMenuCmdID()); //Add main shortcut KeyCombo key = scintKeyMap.getKeyComboByIndex(0); - keyRoot->ToElement()->SetAttribute("Ctrl", key._isCtrl?"yes":"no"); - keyRoot->ToElement()->SetAttribute("Alt", key._isAlt?"yes":"no"); - keyRoot->ToElement()->SetAttribute("Shift", key._isShift?"yes":"no"); - keyRoot->ToElement()->SetAttribute("Key", key._key); + keyRoot->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); + keyRoot->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); + keyRoot->ToElement()->SetAttribute(TEXT("Shift"), key._isShift?TEXT("yes"):TEXT("no")); + keyRoot->ToElement()->SetAttribute(TEXT("Key"), key._key); //Add additional shortcuts size_t size = scintKeyMap.getSize(); if (size > 1) { TiXmlNode * keyNext; for(size_t i = 1; i < size; i++) { - keyNext = keyRoot->InsertEndChild(TiXmlElement("NextKey")); + keyNext = keyRoot->InsertEndChild(TiXmlElement(TEXT("NextKey"))); key = scintKeyMap.getKeyComboByIndex(i); - keyNext->ToElement()->SetAttribute("Ctrl", key._isCtrl?"yes":"no"); - keyNext->ToElement()->SetAttribute("Alt", key._isAlt?"yes":"no"); - keyNext->ToElement()->SetAttribute("Shift", key._isShift?"yes":"no"); - keyNext->ToElement()->SetAttribute("Key", key._key); + keyNext->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); + keyNext->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); + keyNext->ToElement()->SetAttribute(TEXT("Shift"), key._isShift?TEXT("yes"):TEXT("no")); + keyNext->ToElement()->SetAttribute(TEXT("Key"), key._key); } } } -void NppParameters::writeSession(const Session & session, const char *fileName) +void NppParameters::writeSession(const Session & session, const TCHAR *fileName) { - const char *pathName = fileName?fileName:_sessionPath; + const TCHAR *pathName = fileName?fileName:_sessionPath; _pXmlSessionDoc = new TiXmlDocument(pathName); - TiXmlNode *root = _pXmlSessionDoc->InsertEndChild(TiXmlElement("NotepadPlus")); + TiXmlNode *root = _pXmlSessionDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus"))); if (root) { - TiXmlNode *sessionNode = root->InsertEndChild(TiXmlElement("Session")); - (sessionNode->ToElement())->SetAttribute("activeView", (int)session._activeView); + TiXmlNode *sessionNode = root->InsertEndChild(TiXmlElement(TEXT("Session"))); + (sessionNode->ToElement())->SetAttribute(TEXT("activeView"), (int)session._activeView); - TiXmlNode *mainViewNode = sessionNode->InsertEndChild(TiXmlElement("mainView")); - (mainViewNode->ToElement())->SetAttribute("activeIndex", (int)session._activeMainIndex); + TiXmlNode *mainViewNode = sessionNode->InsertEndChild(TiXmlElement(TEXT("mainView"))); + (mainViewNode->ToElement())->SetAttribute(TEXT("activeIndex"), (int)session._activeMainIndex); for (size_t i = 0 ; i < session._mainViewFiles.size() ; i++) { - TiXmlNode *fileNameNode = mainViewNode->InsertEndChild(TiXmlElement("File")); + TiXmlNode *fileNameNode = mainViewNode->InsertEndChild(TiXmlElement(TEXT("File"))); - (fileNameNode->ToElement())->SetAttribute("firstVisibleLine", session._mainViewFiles[i]._firstVisibleLine); - (fileNameNode->ToElement())->SetAttribute("xOffset", session._mainViewFiles[i]._xOffset); - (fileNameNode->ToElement())->SetAttribute("scrollWidth", session._mainViewFiles[i]._scrollWidth); - (fileNameNode->ToElement())->SetAttribute("startPos", session._mainViewFiles[i]._startPos); - (fileNameNode->ToElement())->SetAttribute("endPos", session._mainViewFiles[i]._endPos); - (fileNameNode->ToElement())->SetAttribute("selMode", session._mainViewFiles[i]._selMode); - (fileNameNode->ToElement())->SetAttribute("lang", session._mainViewFiles[i]._langName.c_str()); - (fileNameNode->ToElement())->SetAttribute("filename", session._mainViewFiles[i]._fileName.c_str()); + (fileNameNode->ToElement())->SetAttribute(TEXT("firstVisibleLine"), session._mainViewFiles[i]._firstVisibleLine); + (fileNameNode->ToElement())->SetAttribute(TEXT("xOffset"), session._mainViewFiles[i]._xOffset); + (fileNameNode->ToElement())->SetAttribute(TEXT("scrollWidth"), session._mainViewFiles[i]._scrollWidth); + (fileNameNode->ToElement())->SetAttribute(TEXT("startPos"), session._mainViewFiles[i]._startPos); + (fileNameNode->ToElement())->SetAttribute(TEXT("endPos"), session._mainViewFiles[i]._endPos); + (fileNameNode->ToElement())->SetAttribute(TEXT("selMode"), session._mainViewFiles[i]._selMode); + (fileNameNode->ToElement())->SetAttribute(TEXT("lang"), session._mainViewFiles[i]._langName.c_str()); + (fileNameNode->ToElement())->SetAttribute(TEXT("filename"), session._mainViewFiles[i]._fileName.c_str()); for (size_t j = 0 ; j < session._mainViewFiles[i].marks.size() ; j++) { size_t markLine = session._mainViewFiles[i].marks[j]; - TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement("Mark")); - markNode->ToElement()->SetAttribute("line", markLine); + TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark"))); + markNode->ToElement()->SetAttribute(TEXT("line"), markLine); } } - TiXmlNode *subViewNode = sessionNode->InsertEndChild(TiXmlElement("subView")); - (subViewNode->ToElement())->SetAttribute("activeIndex", (int)session._activeSubIndex); + TiXmlNode *subViewNode = sessionNode->InsertEndChild(TiXmlElement(TEXT("subView"))); + (subViewNode->ToElement())->SetAttribute(TEXT("activeIndex"), (int)session._activeSubIndex); for (size_t i = 0 ; i < session._subViewFiles.size() ; i++) { - TiXmlNode *fileNameNode = subViewNode->InsertEndChild(TiXmlElement("File")); + TiXmlNode *fileNameNode = subViewNode->InsertEndChild(TiXmlElement(TEXT("File"))); - (fileNameNode->ToElement())->SetAttribute("firstVisibleLine", session._subViewFiles[i]._firstVisibleLine); - (fileNameNode->ToElement())->SetAttribute("xOffset", session._subViewFiles[i]._xOffset); - (fileNameNode->ToElement())->SetAttribute("scrollWidth", session._subViewFiles[i]._scrollWidth); - (fileNameNode->ToElement())->SetAttribute("startPos", session._subViewFiles[i]._startPos); - (fileNameNode->ToElement())->SetAttribute("endPos", session._subViewFiles[i]._endPos); - (fileNameNode->ToElement())->SetAttribute("selMode", session._subViewFiles[i]._selMode); - (fileNameNode->ToElement())->SetAttribute("lang", session._subViewFiles[i]._langName.c_str()); - (fileNameNode->ToElement())->SetAttribute("filename", session._subViewFiles[i]._fileName.c_str()); + (fileNameNode->ToElement())->SetAttribute(TEXT("firstVisibleLine"), session._subViewFiles[i]._firstVisibleLine); + (fileNameNode->ToElement())->SetAttribute(TEXT("xOffset"), session._subViewFiles[i]._xOffset); + (fileNameNode->ToElement())->SetAttribute(TEXT("scrollWidth"), session._subViewFiles[i]._scrollWidth); + (fileNameNode->ToElement())->SetAttribute(TEXT("startPos"), session._subViewFiles[i]._startPos); + (fileNameNode->ToElement())->SetAttribute(TEXT("endPos"), session._subViewFiles[i]._endPos); + (fileNameNode->ToElement())->SetAttribute(TEXT("selMode"), session._subViewFiles[i]._selMode); + (fileNameNode->ToElement())->SetAttribute(TEXT("lang"), session._subViewFiles[i]._langName.c_str()); + (fileNameNode->ToElement())->SetAttribute(TEXT("filename"), session._subViewFiles[i]._fileName.c_str()); for (size_t j = 0 ; j < session._subViewFiles[i].marks.size() ; j++) { size_t markLine = session._subViewFiles[i].marks[j]; - TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement("Mark")); - markNode->ToElement()->SetAttribute("line", markLine); + TiXmlNode *markNode = fileNameNode->InsertEndChild(TiXmlElement(TEXT("Mark"))); + markNode->ToElement()->SetAttribute(TEXT("line"), markLine); } } } @@ -1733,18 +1733,18 @@ void NppParameters::writeShortcuts() _pXmlShortcutDoc = new TiXmlDocument(_shortcutsPath); } - TiXmlNode *root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + TiXmlNode *root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); if (!root) { - root = _pXmlShortcutDoc->InsertEndChild(TiXmlElement("NotepadPlus")); - //root = _pXmlShortcutDoc->FirstChild("NotepadPlus"); + root = _pXmlShortcutDoc->InsertEndChild(TiXmlElement(TEXT("NotepadPlus"))); + //root = _pXmlShortcutDoc->FirstChild(TEXT("NotepadPlus")); } - TiXmlNode *cmdRoot = root->FirstChild("InternalCommands"); + TiXmlNode *cmdRoot = root->FirstChild(TEXT("InternalCommands")); if (cmdRoot) root->RemoveChild(cmdRoot); - cmdRoot = root->InsertEndChild(TiXmlElement("InternalCommands")); + cmdRoot = root->InsertEndChild(TiXmlElement(TEXT("InternalCommands"))); for (size_t i = 0 ; i < _customizedShortcuts.size() ; i++) { int index = _customizedShortcuts[i]; @@ -1752,43 +1752,43 @@ void NppParameters::writeShortcuts() insertCmd(cmdRoot, csc); } - TiXmlNode *macrosRoot = root->FirstChild("Macros"); + TiXmlNode *macrosRoot = root->FirstChild(TEXT("Macros")); if (macrosRoot) root->RemoveChild(macrosRoot); - macrosRoot = root->InsertEndChild(TiXmlElement("Macros")); + macrosRoot = root->InsertEndChild(TiXmlElement(TEXT("Macros"))); for (size_t i = 0 ; i < _macros.size() ; i++) { insertMacro(macrosRoot, _macros[i]); } - TiXmlNode *userCmdRoot = root->FirstChild("UserDefinedCommands"); + TiXmlNode *userCmdRoot = root->FirstChild(TEXT("UserDefinedCommands")); if (userCmdRoot) root->RemoveChild(userCmdRoot); - userCmdRoot = root->InsertEndChild(TiXmlElement("UserDefinedCommands")); + userCmdRoot = root->InsertEndChild(TiXmlElement(TEXT("UserDefinedCommands"))); for (size_t i = 0 ; i < _userCommands.size() ; i++) { insertUserCmd(userCmdRoot, _userCommands[i]); } - TiXmlNode *pluginCmdRoot = root->FirstChild("PluginCommands"); + TiXmlNode *pluginCmdRoot = root->FirstChild(TEXT("PluginCommands")); if (pluginCmdRoot) root->RemoveChild(pluginCmdRoot); - pluginCmdRoot = root->InsertEndChild(TiXmlElement("PluginCommands")); + pluginCmdRoot = root->InsertEndChild(TiXmlElement(TEXT("PluginCommands"))); for (size_t i = 0 ; i < _pluginCustomizedCmds.size() ; i++) { insertPluginCmd(pluginCmdRoot, _pluginCommands[_pluginCustomizedCmds[i]]); } - TiXmlNode *scitillaKeyRoot = root->FirstChild("ScintillaKeys"); + TiXmlNode *scitillaKeyRoot = root->FirstChild(TEXT("ScintillaKeys")); if (scitillaKeyRoot) root->RemoveChild(scitillaKeyRoot); - scitillaKeyRoot = root->InsertEndChild(TiXmlElement("ScintillaKeys")); + scitillaKeyRoot = root->InsertEndChild(TiXmlElement(TEXT("ScintillaKeys"))); for (size_t i = 0 ; i < _scintillaModifiedKeyIndices.size() ; i++) { insertScintKey(scitillaKeyRoot, _scintillaKeyCommands[_scintillaModifiedKeyIndices[i]]); @@ -1796,13 +1796,13 @@ void NppParameters::writeShortcuts() _pXmlShortcutDoc->SaveFile(); } -int NppParameters::addUserLangToEnd(const UserLangContainer & userLang, const char *newName) +int NppParameters::addUserLangToEnd(const UserLangContainer & userLang, const TCHAR *newName) { if (isExistingUserLangName(newName)) return -1; _userLangArray[_nbUserLang] = new UserLangContainer(); *(_userLangArray[_nbUserLang]) = userLang; - strcpy(_userLangArray[_nbUserLang]->_name, newName); + lstrcpy(_userLangArray[_nbUserLang]->_name, newName); _nbUserLang++; return _nbUserLang-1; } @@ -1817,69 +1817,69 @@ void NppParameters::removeUserLang(int index) _nbUserLang--; } -int NppParameters::getIndexFromKeywordListName(const char *name) +int NppParameters::getIndexFromKeywordListName(const TCHAR *name) { if (!name) return -1; - if (!strcmp(name, "Folder+")) return 1; - else if (!strcmp(name, "Folder-")) return 2; - else if (!strcmp(name, "Operators"))return 3; - else if (!strcmp(name, "Comment")) return 4; - else if (!strcmp(name, "Words1")) return 5; - else if (!strcmp(name, "Words2")) return 6; - else if (!strcmp(name, "Words3")) return 7; - else if (!strcmp(name, "Words4")) return 8; - else if (!strcmp(name, "Delimiters")) return 0; + if (!lstrcmp(name, TEXT("Folder+"))) return 1; + else if (!lstrcmp(name, TEXT("Folder-"))) return 2; + else if (!lstrcmp(name, TEXT("Operators")))return 3; + else if (!lstrcmp(name, TEXT("Comment"))) return 4; + else if (!lstrcmp(name, TEXT("Words1"))) return 5; + else if (!lstrcmp(name, TEXT("Words2"))) return 6; + else if (!lstrcmp(name, TEXT("Words3"))) return 7; + else if (!lstrcmp(name, TEXT("Words4"))) return 8; + else if (!lstrcmp(name, TEXT("Delimiters"))) return 0; else return -1; } void NppParameters::feedUserSettings(TiXmlNode *settingsRoot) { - const char *boolStr; - TiXmlNode *globalSettingNode = settingsRoot->FirstChildElement("Global"); + const TCHAR *boolStr; + TiXmlNode *globalSettingNode = settingsRoot->FirstChildElement(TEXT("Global")); if (globalSettingNode) { - boolStr = (globalSettingNode->ToElement())->Attribute("caseIgnored"); + boolStr = (globalSettingNode->ToElement())->Attribute(TEXT("caseIgnored")); if (boolStr) - _userLangArray[_nbUserLang - 1]->_isCaseIgnored = !strcmp("yes", boolStr); + _userLangArray[_nbUserLang - 1]->_isCaseIgnored = !lstrcmp(TEXT("yes"), boolStr); } - TiXmlNode *treatAsSymbolNode = settingsRoot->FirstChildElement("TreatAsSymbol"); + TiXmlNode *treatAsSymbolNode = settingsRoot->FirstChildElement(TEXT("TreatAsSymbol")); if (treatAsSymbolNode) { - boolStr = (treatAsSymbolNode->ToElement())->Attribute("comment"); + boolStr = (treatAsSymbolNode->ToElement())->Attribute(TEXT("comment")); if (boolStr) - _userLangArray[_nbUserLang - 1]->_isCommentSymbol = !strcmp("yes", boolStr); + _userLangArray[_nbUserLang - 1]->_isCommentSymbol = !lstrcmp(TEXT("yes"), boolStr); - boolStr = (treatAsSymbolNode->ToElement())->Attribute("commentLine"); + boolStr = (treatAsSymbolNode->ToElement())->Attribute(TEXT("commentLine")); if (boolStr) - _userLangArray[_nbUserLang - 1]->_isCommentLineSymbol = !strcmp("yes", boolStr); + _userLangArray[_nbUserLang - 1]->_isCommentLineSymbol = !lstrcmp(TEXT("yes"), boolStr); } - TiXmlNode *prefixNode = settingsRoot->FirstChildElement("Prefix"); + TiXmlNode *prefixNode = settingsRoot->FirstChildElement(TEXT("Prefix")); if (prefixNode) { - char names[nbPrefixListAllowed][7] = {"words1","words2","words3","words4"}; + TCHAR names[nbPrefixListAllowed][7] = {TEXT("words1"), TEXT("words2"), TEXT("words3"), TEXT("words4")}; for (int i = 0 ; i < nbPrefixListAllowed ; i++) { boolStr = (prefixNode->ToElement())->Attribute(names[i]); if (boolStr) - _userLangArray[_nbUserLang - 1]->_isPrefix[i] = !strcmp("yes", boolStr); + _userLangArray[_nbUserLang - 1]->_isPrefix[i] = !lstrcmp(TEXT("yes"), boolStr); } } } void NppParameters::feedUserKeywordList(TiXmlNode *node) { - for (TiXmlNode *childNode = node->FirstChildElement("Keywords"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Keywords")); childNode ; - childNode = childNode->NextSibling("Keywords")) + childNode = childNode->NextSibling(TEXT("Keywords"))) { - const char *keywordsName = (childNode->ToElement())->Attribute("name"); + const TCHAR *keywordsName = (childNode->ToElement())->Attribute(TEXT("name")); int i = getIndexFromKeywordListName(keywordsName); if (i != -1) { TiXmlNode *valueNode = childNode->FirstChild(); if (valueNode) { - const char *kwl = (valueNode)?valueNode->Value():(strcmp(keywordsName, "Delimiters")?"":"000000"); - strcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[i], kwl); + const TCHAR *kwl = (valueNode)?valueNode->Value():(lstrcmp(keywordsName, TEXT("Delimiters"))?TEXT(""):TEXT("000000")); + lstrcpy(_userLangArray[_nbUserLang - 1]->_keywordLists[i], kwl); } } } @@ -1887,12 +1887,12 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node) void NppParameters::feedUserStyles(TiXmlNode *node) { - for (TiXmlNode *childNode = node->FirstChildElement("WordsStyle"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("WordsStyle")); childNode ; - childNode = childNode->NextSibling("WordsStyle")) + childNode = childNode->NextSibling(TEXT("WordsStyle"))) { int id; - const char *styleIDStr = (childNode->ToElement())->Attribute("styleID", &id); + const TCHAR *styleIDStr = (childNode->ToElement())->Attribute(TEXT("styleID"), &id); if (styleIDStr) { _userLangArray[_nbUserLang - 1]->_styleArray.addStyler(id, childNode); @@ -1902,25 +1902,25 @@ void NppParameters::feedUserStyles(TiXmlNode *node) bool NppParameters::feedStylerArray(TiXmlNode *node) { - TiXmlNode *styleRoot = node->FirstChildElement("LexerStyles"); + TiXmlNode *styleRoot = node->FirstChildElement(TEXT("LexerStyles")); if (!styleRoot) return false; // For each lexer - for (TiXmlNode *childNode = styleRoot->FirstChildElement("LexerType"); + for (TiXmlNode *childNode = styleRoot->FirstChildElement(TEXT("LexerType")); childNode ; - childNode = childNode->NextSibling("LexerType") ) + childNode = childNode->NextSibling(TEXT("LexerType")) ) { if (!_lexerStylerArray.hasEnoughSpace()) return false; TiXmlElement *element = childNode->ToElement(); - const char *lexerName = element->Attribute("name"); - const char *lexerDesc = element->Attribute("desc"); - const char *lexerUserExt = element->Attribute("ext"); - const char *lexerExcluded = element->Attribute("excluded"); + const TCHAR *lexerName = element->Attribute(TEXT("name")); + const TCHAR *lexerDesc = element->Attribute(TEXT("desc")); + const TCHAR *lexerUserExt = element->Attribute(TEXT("ext")); + const TCHAR *lexerExcluded = element->Attribute(TEXT("excluded")); if (lexerName) { _lexerStylerArray.addLexerStyler(lexerName, lexerDesc, lexerUserExt, childNode); - if (lexerExcluded != NULL && !strcmp(lexerExcluded, "yes")) + if (lexerExcluded != NULL && !lstrcmp(lexerExcluded, TEXT("yes"))) { int index = getExternalLangIndexFromName(lexerName); if (index != -1) @@ -1930,17 +1930,17 @@ bool NppParameters::feedStylerArray(TiXmlNode *node) } // The global styles for all lexers - TiXmlNode *globalStyleRoot = node->FirstChildElement("GlobalStyles"); + TiXmlNode *globalStyleRoot = node->FirstChildElement(TEXT("GlobalStyles")); if (!globalStyleRoot) return false; - for (TiXmlNode *childNode = globalStyleRoot->FirstChildElement("WidgetStyle"); + for (TiXmlNode *childNode = globalStyleRoot->FirstChildElement(TEXT("WidgetStyle")); childNode ; - childNode = childNode->NextSibling("WidgetStyle") ) + childNode = childNode->NextSibling(TEXT("WidgetStyle")) ) { if (!_widgetStyleArray.hasEnoughSpace()) return false; TiXmlElement *element = childNode->ToElement(); - const char *styleIDStr = element->Attribute("styleID"); + const TCHAR *styleIDStr = element->Attribute(TEXT("styleID")); int styleID = -1; if ((styleID = decStrVal(styleIDStr)) != -1) @@ -1951,7 +1951,7 @@ bool NppParameters::feedStylerArray(TiXmlNode *node) return true; } -void LexerStylerArray::addLexerStyler(const char *lexerName, const char *lexerDesc, const char *lexerUserExt , TiXmlNode *lexerNode) +void LexerStylerArray::addLexerStyler(const TCHAR *lexerName, const TCHAR *lexerDesc, const TCHAR *lexerUserExt , TiXmlNode *lexerNode) { LexerStyler & ls = _lexerStylerArray[_nbLexerStyler++]; ls.setLexerName(lexerName); @@ -1961,15 +1961,15 @@ void LexerStylerArray::addLexerStyler(const char *lexerName, const char *lexerDe if (lexerUserExt) ls.setLexerUserExt(lexerUserExt); - for (TiXmlNode *childNode = lexerNode->FirstChildElement("WordsStyle"); + for (TiXmlNode *childNode = lexerNode->FirstChildElement(TEXT("WordsStyle")); childNode ; - childNode = childNode->NextSibling("WordsStyle") ) + childNode = childNode->NextSibling(TEXT("WordsStyle")) ) { if (!ls.hasEnoughSpace()) return; TiXmlElement *element = childNode->ToElement(); - const char *styleIDStr = element->Attribute("styleID"); + const TCHAR *styleIDStr = element->Attribute(TEXT("styleID")); if (styleIDStr) { @@ -1993,13 +1993,13 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode) // Pour _fgColor, _bgColor : // RGB() | (result & 0xFF000000) c'est pour le cas de -1 (0xFFFFFFFF) // retourné par hexStrVal(str) - const char *str = element->Attribute("name"); + const TCHAR *str = element->Attribute(TEXT("name")); if (str) { _styleArray[_nbStyler]._styleDesc = str; } - str = element->Attribute("fgColor"); + str = element->Attribute(TEXT("fgColor")); if (str) { unsigned long result = hexStrVal(str); @@ -2007,35 +2007,35 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode) } - str = element->Attribute("bgColor"); + str = element->Attribute(TEXT("bgColor")); if (str) { unsigned long result = hexStrVal(str); _styleArray[_nbStyler]._bgColor = (RGB((result >> 16) & 0xFF, (result >> 8) & 0xFF, result & 0xFF)) | (result & 0xFF000000); } - str = element->Attribute("colorStyle"); + str = element->Attribute(TEXT("colorStyle")); if (str) { _styleArray[_nbStyler]._colorStyle = decStrVal(str); } - str = element->Attribute("fontName"); + str = element->Attribute(TEXT("fontName")); _styleArray[_nbStyler]._fontName = str; - str = element->Attribute("fontStyle"); + str = element->Attribute(TEXT("fontStyle")); if (str) { _styleArray[_nbStyler]._fontStyle = decStrVal(str); } - str = element->Attribute("fontSize"); + str = element->Attribute(TEXT("fontSize")); if (str) { _styleArray[_nbStyler]._fontSize = decStrVal(str); } - str = element->Attribute("keywordClass"); + str = element->Attribute(TEXT("keywordClass")); if (str) { _styleArray[_nbStyler]._keywordClass = getKwClassFromName(str); @@ -2044,39 +2044,39 @@ void StyleArray::addStyler(int styleID, TiXmlNode *styleNode) TiXmlNode *v = styleNode->FirstChild(); if (v) { - _styleArray[_nbStyler]._keywords = new string(v->Value()); + _styleArray[_nbStyler]._keywords = new basic_string(v->Value()); } } _nbStyler++; } -bool NppParameters::writeHistory(const char *fullpath) +bool NppParameters::writeHistory(const TCHAR *fullpath) { - TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus"); + TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus")); if (!nppRoot) return false; - TiXmlNode *historyNode = nppRoot->FirstChildElement("History"); + TiXmlNode *historyNode = nppRoot->FirstChildElement(TEXT("History")); if (!historyNode) return false; - TiXmlElement recentFileNode("File"); - (recentFileNode.ToElement())->SetAttribute("filename", fullpath); + TiXmlElement recentFileNode(TEXT("File")); + (recentFileNode.ToElement())->SetAttribute(TEXT("filename"), fullpath); (historyNode->ToElement())->InsertEndChild(recentFileNode); return true; } -TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const char *childName,\ - const char *attributName, const char *attributVal) const +TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const TCHAR *childName,\ + const TCHAR *attributName, const TCHAR *attributVal) const { for (TiXmlNode *childNode = pere->FirstChildElement(childName); childNode ; childNode = childNode->NextSibling(childName)) { TiXmlElement *element = childNode->ToElement(); - const char *val = element->Attribute(attributName); + const TCHAR *val = element->Attribute(attributName); if (val) { - if (!strcmp(val, attributVal)) + if (!lstrcmp(val, attributVal)) return childNode; } } @@ -2084,12 +2084,12 @@ TiXmlNode * NppParameters::getChildElementByAttribut(TiXmlNode *pere, const char } // 2 restes : L_H, L_USER -LangType NppParameters::getLangIDFromStr(const char *langName) +LangType NppParameters::getLangIDFromStr(const TCHAR *langName) { int lang = (int)L_TXT; for(; lang < L_EXTERNAL; lang++) { - const char * name = ScintillaEditView::langNames[lang].lexerName; - if (!strcmp(name, langName)) { //found lang? + const TCHAR * name = ScintillaEditView::langNames[lang].lexerName; + if (!lstrcmp(name, langName)) { //found lang? return (LangType)lang; } } @@ -2108,32 +2108,32 @@ LangType NppParameters::getLangIDFromStr(const char *langName) void NppParameters::feedKeyWordsParameters(TiXmlNode *node) { - TiXmlNode *langRoot = node->FirstChildElement("Languages"); + TiXmlNode *langRoot = node->FirstChildElement(TEXT("Languages")); if (!langRoot) return; - for (TiXmlNode *langNode = langRoot->FirstChildElement("Language"); + for (TiXmlNode *langNode = langRoot->FirstChildElement(TEXT("Language")); langNode ; - langNode = langNode->NextSibling("Language") ) + langNode = langNode->NextSibling(TEXT("Language")) ) { if (_nbLang < NB_LANG) { TiXmlElement *element = langNode->ToElement(); - const char *name = element->Attribute("name"); + const TCHAR *name = element->Attribute(TEXT("name")); if (name) { _langList[_nbLang] = new Lang(getLangIDFromStr(name), name); - _langList[_nbLang]->setDefaultExtList(element->Attribute("ext")); - _langList[_nbLang]->setCommentLineSymbol(element->Attribute("commentLine")); - _langList[_nbLang]->setCommentStart(element->Attribute("commentStart")); - _langList[_nbLang]->setCommentEnd(element->Attribute("commentEnd")); + _langList[_nbLang]->setDefaultExtList(element->Attribute(TEXT("ext"))); + _langList[_nbLang]->setCommentLineSymbol(element->Attribute(TEXT("commentLine"))); + _langList[_nbLang]->setCommentStart(element->Attribute(TEXT("commentStart"))); + _langList[_nbLang]->setCommentEnd(element->Attribute(TEXT("commentEnd"))); - for (TiXmlNode *kwNode = langNode->FirstChildElement("Keywords"); + for (TiXmlNode *kwNode = langNode->FirstChildElement(TEXT("Keywords")); kwNode ; - kwNode = kwNode->NextSibling("Keywords") ) + kwNode = kwNode->NextSibling(TEXT("Keywords")) ) { - const char *indexName = (kwNode->ToElement())->Attribute("name"); + const TCHAR *indexName = (kwNode->ToElement())->Attribute(TEXT("name")); TiXmlNode *kwVal = kwNode->FirstChild(); - const char *keyWords = ""; + const TCHAR *keyWords = TEXT(""); if ((indexName) && (kwVal)) keyWords = kwVal->Value(); @@ -2150,27 +2150,27 @@ void NppParameters::feedKeyWordsParameters(TiXmlNode *node) void NppParameters::feedGUIParameters(TiXmlNode *node) { - TiXmlNode *GUIRoot = node->FirstChildElement("GUIConfigs"); + TiXmlNode *GUIRoot = node->FirstChildElement(TEXT("GUIConfigs")); if (!GUIRoot) return; - for (TiXmlNode *childNode = GUIRoot->FirstChildElement("GUIConfig"); + for (TiXmlNode *childNode = GUIRoot->FirstChildElement(TEXT("GUIConfig")); childNode ; - childNode = childNode->NextSibling("GUIConfig") ) + childNode = childNode->NextSibling(TEXT("GUIConfig")) ) { TiXmlElement *element = childNode->ToElement(); - const char *nm = element->Attribute("name"); + const TCHAR *nm = element->Attribute(TEXT("name")); if (!nm) continue; - const char *val; + const TCHAR *val; - if (!strcmp(nm, "ToolBar")) + if (!lstrcmp(nm, TEXT("ToolBar"))) { - val = element->Attribute("visible"); + val = element->Attribute(TEXT("visible")); if (val) { - if (!strcmp(val, "no")) + if (!lstrcmp(val, TEXT("no"))) _nppGUI._toolbarShow = false; - else// if (!strcmp(val, "yes")) + else// if (!lstrcmp(val, TEXT("yes"))) _nppGUI._toolbarShow = true; } TiXmlNode *n = childNode->FirstChild(); @@ -2179,19 +2179,19 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - //if (!strcmp(val, "hide")) + //if (!lstrcmp(val, TEXT("hide"))) // _nppGUI._toolBarStatus = TB_HIDE; //else - if (!strcmp(val, "small")) + if (!lstrcmp(val, TEXT("small"))) _nppGUI._toolBarStatus = TB_SMALL; - else if (!strcmp(val, "large")) + else if (!lstrcmp(val, TEXT("large"))) _nppGUI._toolBarStatus = TB_LARGE; - else// if (!strcmp(val, "standard")) //assume standard in all other cases + else// if (!lstrcmp(val, TEXT("standard"))) //assume standard in all other cases _nppGUI._toolBarStatus = TB_STANDARD; } } } - else if (!strcmp(nm, "StatusBar")) + else if (!lstrcmp(nm, TEXT("StatusBar"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2199,14 +2199,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "hide")) + if (!lstrcmp(val, TEXT("hide"))) _nppGUI._statusBarShow = false; - else if (!strcmp(val, "show")) + else if (!lstrcmp(val, TEXT("show"))) _nppGUI._statusBarShow = true; } } } - else if (!strcmp(nm, "MenuBar")) + else if (!lstrcmp(nm, TEXT("MenuBar"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2214,109 +2214,109 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "hide")) + if (!lstrcmp(val, TEXT("hide"))) _nppGUI._menuBarShow = false; - else if (!strcmp(val, "show")) + else if (!lstrcmp(val, TEXT("show"))) _nppGUI._menuBarShow = true; } } } - else if (!strcmp(nm, "TabBar")) + else if (!lstrcmp(nm, TEXT("TabBar"))) { bool isFailed = false; int oldValue = _nppGUI._tabStatus; - val = element->Attribute("dragAndDrop"); + val = element->Attribute(TEXT("dragAndDrop")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus = TAB_DRAGNDROP; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus = 0; else isFailed = true; } - val = element->Attribute("drawTopBar"); + val = element->Attribute(TEXT("drawTopBar")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_DRAWTOPBAR; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("drawInactiveTab"); + val = element->Attribute(TEXT("drawInactiveTab")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_DRAWINACTIVETAB; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("reduce"); + val = element->Attribute(TEXT("reduce")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_REDUCE; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("closeButton"); + val = element->Attribute(TEXT("closeButton")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_CLOSEBUTTON; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("doubleClick2Close"); + val = element->Attribute(TEXT("doubleClick2Close")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_DBCLK2CLOSE; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("vertical"); + val = element->Attribute(TEXT("vertical")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_VERTICAL; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("multiLine"); + val = element->Attribute(TEXT("multiLine")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_MULTILINE; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; } - val = element->Attribute("hide"); + val = element->Attribute(TEXT("hide")); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._tabStatus |= TAB_HIDE; - else if (!strcmp(val, "no")) + else if (!lstrcmp(val, TEXT("no"))) _nppGUI._tabStatus |= 0; else isFailed = true; @@ -2326,7 +2326,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } - else if (!strcmp(nm, "Auto-detection")) + else if (!lstrcmp(nm, TEXT("Auto-detection"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2334,15 +2334,15 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._fileAutoDetection = cdEnabled; - else if (!strcmp(val, "auto")) + else if (!lstrcmp(val, TEXT("auto"))) _nppGUI._fileAutoDetection = cdAutoUpdate; - else if (!strcmp(val, "Update2End")) + else if (!lstrcmp(val, TEXT("Update2End"))) _nppGUI._fileAutoDetection = cdGo2end; - else if (!strcmp(val, "autoUpdate2End")) + else if (!lstrcmp(val, TEXT("autoUpdate2End"))) _nppGUI._fileAutoDetection = cdAutoUpdateGo2end; - else //(!strcmp(val, "no")) + else //(!lstrcmp(val, TEXT("no"))) _nppGUI._fileAutoDetection = cdDisabled; _nppGUI._fileAutoDetectionOriginalValue = _nppGUI._fileAutoDetection; @@ -2350,7 +2350,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - else if (!strcmp(nm, "TrayIcon")) + else if (!lstrcmp(nm, TEXT("TrayIcon"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2358,12 +2358,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._isMinimizedToTray = true; } } } - else if (!strcmp(nm, "RememberLastSession")) + else if (!lstrcmp(nm, TEXT("RememberLastSession"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2371,7 +2371,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._rememberLastSession = true; else _nppGUI._rememberLastSession = false; @@ -2379,7 +2379,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - else if (!strcmp(nm, "MaitainIndent")) + else if (!lstrcmp(nm, TEXT("MaitainIndent"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2387,7 +2387,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._maitainIndent = true; else _nppGUI._maitainIndent = false; @@ -2395,7 +2395,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - else if (!strcmp(nm, "SmartHighLight")) + else if (!lstrcmp(nm, TEXT("SmartHighLight"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2403,7 +2403,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "yes")) + if (!lstrcmp(val, TEXT("yes"))) _nppGUI._enableSmartHilite = true; else _nppGUI._enableSmartHilite = false; @@ -2411,7 +2411,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - else if (!strcmp(nm, "TagsMatchHighLight")) + else if (!lstrcmp(nm, TEXT("TagsMatchHighLight"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2419,15 +2419,15 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - _nppGUI._enableTagsMatchHilite = !strcmp(val, "yes"); - const char *tahl = element->Attribute("TagAttrHighLight"); + _nppGUI._enableTagsMatchHilite = !lstrcmp(val, TEXT("yes")); + const TCHAR *tahl = element->Attribute(TEXT("TagAttrHighLight")); if (tahl) - _nppGUI._enableTagAttrsHilite = !strcmp(tahl, "yes"); + _nppGUI._enableTagAttrsHilite = !lstrcmp(tahl, TEXT("yes")); } } } - else if (!strcmp(nm, "TaskList")) + else if (!lstrcmp(nm, TEXT("TaskList"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2435,12 +2435,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - _nppGUI._doTaskList = (!strcmp(val, "yes"))?true:false; + _nppGUI._doTaskList = (!lstrcmp(val, TEXT("yes")))?true:false; } } } - else if (!strcmp(nm, "SaveOpenFileInSameDir")) + else if (!lstrcmp(nm, TEXT("SaveOpenFileInSameDir"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2448,12 +2448,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - _nppGUI._saveOpenKeepInSameDir = (!strcmp(val, "yes"))?true:false; + _nppGUI._saveOpenKeepInSameDir = (!lstrcmp(val, TEXT("yes")))?true:false; } } } - else if (!strcmp(nm, "MRU")) + else if (!lstrcmp(nm, TEXT("MRU"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2461,12 +2461,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - _nppGUI._styleMRU = (!strcmp(val, "yes"))?true:false; + _nppGUI._styleMRU = (!lstrcmp(val, TEXT("yes")))?true:false; } } } - else if (!strcmp(nm, "URL")) + else if (!lstrcmp(nm, TEXT("URL"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2474,9 +2474,9 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "1")) + if (!lstrcmp(val, TEXT("1"))) _nppGUI._styleURL = 1; - else if (!strcmp(val, "2")) + else if (!lstrcmp(val, TEXT("2"))) _nppGUI._styleURL = 2; else _nppGUI._styleURL = 0; @@ -2484,7 +2484,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - else if (!strcmp(nm, "CheckHistoryFiles")) + else if (!lstrcmp(nm, TEXT("CheckHistoryFiles"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2492,12 +2492,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "no")) + if (!lstrcmp(val, TEXT("no"))) _nppGUI._checkHistoryFiles = false; } } } - else if (!strcmp(nm, "ScintillaViewsSplitter")) + else if (!lstrcmp(nm, TEXT("ScintillaViewsSplitter"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2505,14 +2505,14 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "vertical")) + if (!lstrcmp(val, TEXT("vertical"))) _nppGUI._splitterPos = POS_VERTICAL; - else if (!strcmp(val, "horizontal")) + else if (!lstrcmp(val, TEXT("horizontal"))) _nppGUI._splitterPos = POS_HORIZOTAL; } } } - else if (!strcmp(nm, "UserDefineDlg")) + else if (!lstrcmp(nm, TEXT("UserDefineDlg"))) { bool isFailed = false; int oldValue = _nppGUI._userDefineDlgStatus; @@ -2523,20 +2523,20 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - if (!strcmp(val, "hide")) + if (!lstrcmp(val, TEXT("hide"))) _nppGUI._userDefineDlgStatus = 0; - else if (!strcmp(val, "show")) + else if (!lstrcmp(val, TEXT("show"))) _nppGUI._userDefineDlgStatus = UDD_SHOW; else isFailed = true; } } - val = element->Attribute("position"); + val = element->Attribute(TEXT("position")); if (val) { - if (!strcmp(val, "docked")) + if (!lstrcmp(val, TEXT("docked"))) _nppGUI._userDefineDlgStatus |= UDD_DOCKED; - else if (!strcmp(val, "undocked")) + else if (!lstrcmp(val, TEXT("undocked"))) _nppGUI._userDefineDlgStatus |= 0; else isFailed = true; @@ -2544,52 +2544,52 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (isFailed) _nppGUI._userDefineDlgStatus = oldValue; } - else if (!strcmp(nm, "TabSetting")) + else if (!lstrcmp(nm, TEXT("TabSetting"))) { int i; - val = element->Attribute("size", &i); + val = element->Attribute(TEXT("size"), &i); if (val) _nppGUI._tabSize = i; if ((_nppGUI._tabSize == -1) || (_nppGUI._tabSize == 0)) _nppGUI._tabSize = 8; - val = element->Attribute("replaceBySpace"); + val = element->Attribute(TEXT("replaceBySpace")); if (val) - _nppGUI._tabReplacedBySpace = (!strcmp(val, "yes")); + _nppGUI._tabReplacedBySpace = (!lstrcmp(val, TEXT("yes"))); } - else if (!strcmp(nm, "Caret")) + else if (!lstrcmp(nm, TEXT("Caret"))) { int i; - val = element->Attribute("width", &i); + val = element->Attribute(TEXT("width"), &i); if (val) _nppGUI._caretWidth = i; - val = element->Attribute("blinkRate", &i); + val = element->Attribute(TEXT("blinkRate"), &i); if (val) _nppGUI._caretBlinkRate = i; } - else if (!strcmp(nm, "AppPosition")) + else if (!lstrcmp(nm, TEXT("AppPosition"))) { RECT oldRect = _nppGUI._appPos; bool fuckUp = true; int i; - if (element->Attribute("x", &i)) + if (element->Attribute(TEXT("x"), &i)) { _nppGUI._appPos.left = i; - if (element->Attribute("y", &i)) + if (element->Attribute(TEXT("y"), &i)) { _nppGUI._appPos.top = i; - if (element->Attribute("width", &i)) + if (element->Attribute(TEXT("width"), &i)) { _nppGUI._appPos.right = i; - if (element->Attribute("height", &i)) + if (element->Attribute(TEXT("height"), &i)) { _nppGUI._appPos.bottom = i; fuckUp = false; @@ -2601,24 +2601,24 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) _nppGUI._appPos = oldRect; - if (val = element->Attribute("isMaximized")) + if (val = element->Attribute(TEXT("isMaximized"))) { - _nppGUI._isMaximized = (strcmp(val, "yes") == 0); + _nppGUI._isMaximized = (lstrcmp(val, TEXT("yes")) == 0); } } - else if (!strcmp(nm, "NewDocDefaultSettings")) + else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings"))) { int i; - if (element->Attribute("format", &i)) + if (element->Attribute(TEXT("format"), &i)) _nppGUI._newDocDefaultSettings._format = (formatType)i; - if (element->Attribute("encoding", &i)) + if (element->Attribute(TEXT("encoding"), &i)) _nppGUI._newDocDefaultSettings._encoding = (UniMode)i; - if (element->Attribute("lang", &i)) + if (element->Attribute(TEXT("lang"), &i)) _nppGUI._newDocDefaultSettings._lang = (LangType)i; } - else if (!strcmp(nm, "langsExcluded")) + else if (!lstrcmp(nm, TEXT("langsExcluded"))) { int g0 = 0; // up to 8 int g1 = 0; // up to 16 @@ -2631,35 +2631,35 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) const int nbMax = 64; int i; - if (element->Attribute("gr0", &i)) + if (element->Attribute(TEXT("gr0"), &i)) if (i <= 255) g0 = i; - if (element->Attribute("gr1", &i)) + if (element->Attribute(TEXT("gr1"), &i)) if (i <= 255) g1 = i; - if (element->Attribute("gr2", &i)) + if (element->Attribute(TEXT("gr2"), &i)) if (i <= 255) g2 = i; - if (element->Attribute("gr3", &i)) + if (element->Attribute(TEXT("gr3"), &i)) if (i <= 255) g3 = i; - if (element->Attribute("gr4", &i)) + if (element->Attribute(TEXT("gr4"), &i)) if (i <= 255) g4 = i; - if (element->Attribute("gr5", &i)) + if (element->Attribute(TEXT("gr5"), &i)) if (i <= 255) g5 = i; - if (element->Attribute("gr6", &i)) + if (element->Attribute(TEXT("gr6"), &i)) if (i <= 255) g6 = i; - if (element->Attribute("gr7", &i)) + if (element->Attribute(TEXT("gr7"), &i)) if (i <= 255) g7 = i; bool langArray[nbMax]; for (int i = 0 ; i < nbMax ; i++) langArray[i] = false; - unsigned char mask = 1; + UCHAR mask = 1; for (int i = 0 ; i < 8 ; i++) { if (mask & g0) @@ -2724,164 +2724,164 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - else if (!strcmp(nm, "Print")) + else if (!lstrcmp(nm, TEXT("Print"))) { - val = element->Attribute("lineNumber"); + val = element->Attribute(TEXT("lineNumber")); if (val) - _nppGUI._printSettings._printLineNumber = (!strcmp(val, "yes")); + _nppGUI._printSettings._printLineNumber = (!lstrcmp(val, TEXT("yes"))); int i; - if (element->Attribute("printOption", &i)) + if (element->Attribute(TEXT("printOption"), &i)) _nppGUI._printSettings._printOption = i; - val = element->Attribute("headerLeft"); + val = element->Attribute(TEXT("headerLeft")); if (val) _nppGUI._printSettings._headerLeft = val; - val = element->Attribute("headerMiddle"); + val = element->Attribute(TEXT("headerMiddle")); if (val) _nppGUI._printSettings._headerMiddle = val; - val = element->Attribute("headerRight"); + val = element->Attribute(TEXT("headerRight")); if (val) _nppGUI._printSettings._headerRight = val; - val = element->Attribute("footerLeft"); + val = element->Attribute(TEXT("footerLeft")); if (val) _nppGUI._printSettings._footerLeft = val; - val = element->Attribute("footerMiddle"); + val = element->Attribute(TEXT("footerMiddle")); if (val) _nppGUI._printSettings._footerMiddle = val; - val = element->Attribute("footerRight"); + val = element->Attribute(TEXT("footerRight")); if (val) _nppGUI._printSettings._footerRight = val; - val = element->Attribute("headerFontName"); + val = element->Attribute(TEXT("headerFontName")); if (val) _nppGUI._printSettings._headerFontName = val; - val = element->Attribute("footerFontName"); + val = element->Attribute(TEXT("footerFontName")); if (val) _nppGUI._printSettings._footerFontName = val; - if (element->Attribute("headerFontStyle", &i)) + if (element->Attribute(TEXT("headerFontStyle"), &i)) _nppGUI._printSettings._headerFontStyle = i; - if (element->Attribute("footerFontStyle", &i)) + if (element->Attribute(TEXT("footerFontStyle"), &i)) _nppGUI._printSettings._footerFontStyle = i; - if (element->Attribute("headerFontSize", &i)) + if (element->Attribute(TEXT("headerFontSize"), &i)) _nppGUI._printSettings._headerFontSize = i; - if (element->Attribute("footerFontSize", &i)) + if (element->Attribute(TEXT("footerFontSize"), &i)) _nppGUI._printSettings._footerFontSize = i; - if (element->Attribute("margeLeft", &i)) + if (element->Attribute(TEXT("margeLeft"), &i)) _nppGUI._printSettings._marge.left = i; - if (element->Attribute("margeTop", &i)) + if (element->Attribute(TEXT("margeTop"), &i)) _nppGUI._printSettings._marge.top = i; - if (element->Attribute("margeRight", &i)) + if (element->Attribute(TEXT("margeRight"), &i)) _nppGUI._printSettings._marge.right = i; - if (element->Attribute("margeBottom", &i)) + if (element->Attribute(TEXT("margeBottom"), &i)) _nppGUI._printSettings._marge.bottom = i; } - else if (!strcmp(nm, "ScintillaPrimaryView")) + else if (!lstrcmp(nm, TEXT("ScintillaPrimaryView"))) { feedScintillaParam(SCIV_PRIMARY, element); } - else if (!strcmp(nm, "ScintillaSecondaryView")) + else if (!lstrcmp(nm, TEXT("ScintillaSecondaryView"))) { feedScintillaParam(SCIV_SECOND, element); } - else if (!strcmp(nm, "Backup")) + else if (!lstrcmp(nm, TEXT("Backup"))) { int i; - if (element->Attribute("action", &i)) + if (element->Attribute(TEXT("action"), &i)) _nppGUI._backup = (BackupFeature)i; - const char *bDir = element->Attribute("useCustumDir"); - if (bDir && !strcmp(bDir, "yes")) + const TCHAR *bDir = element->Attribute(TEXT("useCustumDir")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._useDir = true; } - const char *pDir = element->Attribute("dir"); + const TCHAR *pDir = element->Attribute(TEXT("dir")); if (pDir) - strcpy(_nppGUI._backupDir, pDir); + lstrcpy(_nppGUI._backupDir, pDir); } - else if (!strcmp(nm, "DockingManager")) + else if (!lstrcmp(nm, TEXT("DockingManager"))) { feedDockingManager(element); } - else if (!strcmp(nm, "globalOverride")) + else if (!lstrcmp(nm, TEXT("globalOverride"))) { - const char *bDir = element->Attribute("fg"); - if (bDir && !strcmp(bDir, "yes")) + const TCHAR *bDir = element->Attribute(TEXT("fg")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableFg = true; } - bDir = element->Attribute("bg"); - if (bDir && !strcmp(bDir, "yes")) + bDir = element->Attribute(TEXT("bg")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableBg = true; } - bDir = element->Attribute("font"); - if (bDir && !strcmp(bDir, "yes")) + bDir = element->Attribute(TEXT("font")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableFont = true; } - bDir = element->Attribute("fontSize"); - if (bDir && !strcmp(bDir, "yes")) + bDir = element->Attribute(TEXT("fontSize")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableFontSize = true; } - bDir = element->Attribute("bold"); - if (bDir && !strcmp(bDir, "yes")) + bDir = element->Attribute(TEXT("bold")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableBold = true; } - bDir = element->Attribute("italic"); - if (bDir && !strcmp(bDir, "yes")) + bDir = element->Attribute(TEXT("italic")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableItalic = true; } - bDir = element->Attribute("underline"); - if (bDir && !strcmp(bDir, "yes")) + bDir = element->Attribute(TEXT("underline")); + if (bDir && !lstrcmp(bDir, TEXT("yes"))) { _nppGUI._globalOverride.enableUnderLine = true; } } - else if (!strcmp(nm, "auto-completion")) + else if (!lstrcmp(nm, TEXT("auto-completion"))) { int i; - if (element->Attribute("autoCAction", &i)) + if (element->Attribute(TEXT("autoCAction"), &i)) _nppGUI._autocStatus = (NppGUI::AutocStatus)i; - if (element->Attribute("triggerFromNbChar", &i)) + if (element->Attribute(TEXT("triggerFromNbChar"), &i)) _nppGUI._autocFromLen = i; - const char * funcParams = element->Attribute("funcParams"); - if (funcParams && !strcmp(funcParams, "yes")) + const TCHAR * funcParams = element->Attribute(TEXT("funcParams")); + if (funcParams && !lstrcmp(funcParams, TEXT("yes"))) { _nppGUI._funcParams = true; } } - else if (!strcmp(nm, "sessionExt")) + else if (!lstrcmp(nm, TEXT("sessionExt"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2891,7 +2891,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) _nppGUI._definedSessionExt = val; } } - else if (!strcmp(nm, "noUpdate")) + else if (!lstrcmp(nm, TEXT("noUpdate"))) { TiXmlNode *n = childNode->FirstChild(); if (n) @@ -2899,7 +2899,7 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) val = n->Value(); if (val) { - _nppGUI._neverUpdate = (!strcmp(val, "yes"))?true:false; + _nppGUI._neverUpdate = (!lstrcmp(val, TEXT("yes")))?true:false; } } } @@ -2912,122 +2912,122 @@ void NppParameters::feedScintillaParam(bool whichOne, TiXmlNode *node) TiXmlElement *element = node->ToElement(); // Line Number Margin - const char *nm = element->Attribute("lineNumberMargin"); + const TCHAR *nm = element->Attribute(TEXT("lineNumberMargin")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._lineNumberMarginShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._lineNumberMarginShow = false; } // Bookmark Margin - nm = element->Attribute("bookMarkMargin"); + nm = element->Attribute(TEXT("bookMarkMargin")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._bookMarkMarginShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._bookMarkMarginShow = false; } // Indent GuideLine - nm = element->Attribute("indentGuideLine"); + nm = element->Attribute(TEXT("indentGuideLine")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._indentGuideLineShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._indentGuideLineShow= false; } // Folder Mark Style - nm = element->Attribute("folderMarkStyle"); + nm = element->Attribute(TEXT("folderMarkStyle")); if (nm) { - if (!strcmp(nm, "box")) + if (!lstrcmp(nm, TEXT("box"))) _svp[whichOne]._folderStyle = FOLDER_STYLE_BOX; - else if (!strcmp(nm, "circle")) + else if (!lstrcmp(nm, TEXT("circle"))) _svp[whichOne]._folderStyle = FOLDER_STYLE_CIRCLE; - else if (!strcmp(nm, "arrow")) + else if (!lstrcmp(nm, TEXT("arrow"))) _svp[whichOne]._folderStyle = FOLDER_STYLE_ARROW; - else if (!strcmp(nm, "simple")) + else if (!lstrcmp(nm, TEXT("simple"))) _svp[whichOne]._folderStyle = FOLDER_STYLE_SIMPLE; } // Current Line Highlighting State - nm = element->Attribute("currentLineHilitingShow"); + nm = element->Attribute(TEXT("currentLineHilitingShow")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._currentLineHilitingShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._currentLineHilitingShow = false; } // Current wrap symbol visibility State - nm = element->Attribute("wrapSymbolShow"); + nm = element->Attribute(TEXT("wrapSymbolShow")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._wrapSymbolShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._wrapSymbolShow = false; } // Do Wrap - nm = element->Attribute("Wrap"); + nm = element->Attribute(TEXT("Wrap")); if (nm) { - if (!strcmp(nm, "yes")) + if (!lstrcmp(nm, TEXT("yes"))) _svp[whichOne]._doWrap = true; - else if (!strcmp(nm, "no")) + else if (!lstrcmp(nm, TEXT("no"))) _svp[whichOne]._doWrap = false; } // Do Edge - nm = element->Attribute("edge"); + nm = element->Attribute(TEXT("edge")); if (nm) { - if (!strcmp(nm, "background")) + if (!lstrcmp(nm, TEXT("background"))) _svp[whichOne]._edgeMode = EDGE_BACKGROUND; - else if (!strcmp(nm, "line")) + else if (!lstrcmp(nm, TEXT("line"))) _svp[whichOne]._edgeMode = EDGE_LINE; else _svp[whichOne]._edgeMode = EDGE_NONE; } int val; - nm = element->Attribute("edgeNbColumn", &val); + nm = element->Attribute(TEXT("edgeNbColumn"), &val); if (nm) { _svp[whichOne]._edgeNbColumn = val; } - nm = element->Attribute("zoom", &val); + nm = element->Attribute(TEXT("zoom"), &val); if (nm) { _svp[whichOne]._zoom = val; } // White Space visibility State - nm = element->Attribute("whiteSpaceShow"); + nm = element->Attribute(TEXT("whiteSpaceShow")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._whiteSpaceShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._whiteSpaceShow = false; } // EOL visibility State - nm = element->Attribute("eolShow"); + nm = element->Attribute(TEXT("eolShow")); if (nm) { - if (!strcmp(nm, "show")) + if (!lstrcmp(nm, TEXT("show"))) _svp[whichOne]._eolShow = true; - else if (!strcmp(nm, "hide")) + else if (!lstrcmp(nm, TEXT("hide"))) _svp[whichOne]._eolShow = false; } } @@ -3038,80 +3038,80 @@ void NppParameters::feedDockingManager(TiXmlNode *node) TiXmlElement *element = node->ToElement(); int i; - if (element->Attribute("leftWidth", &i)) + if (element->Attribute(TEXT("leftWidth"), &i)) _nppGUI._dockingData._leftWidth = i; - if (element->Attribute("rightWidth", &i)) + if (element->Attribute(TEXT("rightWidth"), &i)) _nppGUI._dockingData._rightWidth = i; - if (element->Attribute("topHeight", &i)) + if (element->Attribute(TEXT("topHeight"), &i)) _nppGUI._dockingData._topHeight = i; - if (element->Attribute("bottomHeight", &i)) + if (element->Attribute(TEXT("bottomHeight"), &i)) _nppGUI._dockingData._bottomHight = i; - for (TiXmlNode *childNode = node->FirstChildElement("FloatingWindow"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("FloatingWindow")); childNode ; - childNode = childNode->NextSibling("FloatingWindow") ) + childNode = childNode->NextSibling(TEXT("FloatingWindow")) ) { TiXmlElement *floatElement = childNode->ToElement(); int cont; - if (floatElement->Attribute("cont", &cont)) + if (floatElement->Attribute(TEXT("cont"), &cont)) { int x = 0; int y = 0; int w = 100; int h = 100; - floatElement->Attribute("x", &x); - floatElement->Attribute("y", &y); - floatElement->Attribute("width", &w); - floatElement->Attribute("height", &h); + floatElement->Attribute(TEXT("x"), &x); + floatElement->Attribute(TEXT("y"), &y); + floatElement->Attribute(TEXT("width"), &w); + floatElement->Attribute(TEXT("height"), &h); _nppGUI._dockingData._flaotingWindowInfo.push_back(FloatingWindowInfo(cont, x, y, w, h)); } } - for (TiXmlNode *childNode = node->FirstChildElement("PluginDlg"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("PluginDlg")); childNode ; - childNode = childNode->NextSibling("PluginDlg") ) + childNode = childNode->NextSibling(TEXT("PluginDlg")) ) { TiXmlElement *dlgElement = childNode->ToElement(); - const char *name = dlgElement->Attribute("pluginName"); + const TCHAR *name = dlgElement->Attribute(TEXT("pluginName")); int id; - const char *idStr = dlgElement->Attribute("id", &id); + const TCHAR *idStr = dlgElement->Attribute(TEXT("id"), &id); if (name && idStr) { int curr = 0; // on left int prev = 0; // on left - dlgElement->Attribute("curr", &curr); - dlgElement->Attribute("prev", &prev); + dlgElement->Attribute(TEXT("curr"), &curr); + dlgElement->Attribute(TEXT("prev"), &prev); bool isVisible = false; - const char *val = NULL; - if (val = dlgElement->Attribute("isVisible")) + const TCHAR *val = NULL; + if (val = dlgElement->Attribute(TEXT("isVisible"))) { - isVisible = (strcmp(val, "yes") == 0); + isVisible = (lstrcmp(val, TEXT("yes")) == 0); } _nppGUI._dockingData._pluginDockInfo.push_back(PlugingDlgDockingInfo(name, id, curr, prev, isVisible)); } } - for (TiXmlNode *childNode = node->FirstChildElement("ActiveTabs"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("ActiveTabs")); childNode ; - childNode = childNode->NextSibling("ActiveTabs") ) + childNode = childNode->NextSibling(TEXT("ActiveTabs")) ) { TiXmlElement *dlgElement = childNode->ToElement(); int cont; - if (dlgElement->Attribute("cont", &cont)) + if (dlgElement->Attribute(TEXT("cont"), &cont)) { int activeTab = 0; - dlgElement->Attribute("activeTab", &activeTab); + dlgElement->Attribute(TEXT("activeTab"), &activeTab); _nppGUI._dockingData._containerTabInfo.push_back(ContainerTabInfo(cont, activeTab)); } } @@ -3121,38 +3121,38 @@ bool NppParameters::writeScintillaParams(const ScintillaViewParams & svp, bool w { if (!_pXmlUserDoc) return false; - const char *pViewName = (whichOne == SCIV_PRIMARY)?"ScintillaPrimaryView":"ScintillaSecondaryView"; - TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus"); + const TCHAR *pViewName = (whichOne == SCIV_PRIMARY)?TEXT("ScintillaPrimaryView"):TEXT("ScintillaSecondaryView"); + TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus")); if (!nppRoot) return false; - TiXmlNode *configsRoot = nppRoot->FirstChildElement("GUIConfigs"); + TiXmlNode *configsRoot = nppRoot->FirstChildElement(TEXT("GUIConfigs")); if (!configsRoot) return false; - TiXmlNode *scintNode = getChildElementByAttribut(configsRoot, "GUIConfig", "name", pViewName); + TiXmlNode *scintNode = getChildElementByAttribut(configsRoot, TEXT("GUIConfig"), TEXT("name"), pViewName); if (!scintNode) return false; - (scintNode->ToElement())->SetAttribute("lineNumberMargin", svp._lineNumberMarginShow?"show":"hide"); - (scintNode->ToElement())->SetAttribute("bookMarkMargin", svp._bookMarkMarginShow?"show":"hide"); - (scintNode->ToElement())->SetAttribute("indentGuideLine", svp._indentGuideLineShow?"show":"hide"); - const char *pFolderStyleStr = (svp._folderStyle == FOLDER_STYLE_SIMPLE)?"simple": - (svp._folderStyle == FOLDER_STYLE_ARROW)?"arrow": - (svp._folderStyle == FOLDER_STYLE_CIRCLE)?"circle":"box"; - (scintNode->ToElement())->SetAttribute("folderMarkStyle", pFolderStyleStr); - (scintNode->ToElement())->SetAttribute("currentLineHilitingShow", svp._currentLineHilitingShow?"show":"hide"); - (scintNode->ToElement())->SetAttribute("wrapSymbolShow", svp._wrapSymbolShow?"show":"hide"); - (scintNode->ToElement())->SetAttribute("Wrap", svp._doWrap?"yes":"no"); - char *edgeStr = NULL; + (scintNode->ToElement())->SetAttribute(TEXT("lineNumberMargin"), svp._lineNumberMarginShow?TEXT("show"):TEXT("hide")); + (scintNode->ToElement())->SetAttribute(TEXT("bookMarkMargin"), svp._bookMarkMarginShow?TEXT("show"):TEXT("hide")); + (scintNode->ToElement())->SetAttribute(TEXT("indentGuideLine"), svp._indentGuideLineShow?TEXT("show"):TEXT("hide")); + const TCHAR *pFolderStyleStr = (svp._folderStyle == FOLDER_STYLE_SIMPLE)?TEXT("simple"): + (svp._folderStyle == FOLDER_STYLE_ARROW)?TEXT("arrow"): + (svp._folderStyle == FOLDER_STYLE_CIRCLE)?TEXT("circle"):TEXT("box"); + (scintNode->ToElement())->SetAttribute(TEXT("folderMarkStyle"), pFolderStyleStr); + (scintNode->ToElement())->SetAttribute(TEXT("currentLineHilitingShow"), svp._currentLineHilitingShow?TEXT("show"):TEXT("hide")); + (scintNode->ToElement())->SetAttribute(TEXT("wrapSymbolShow"), svp._wrapSymbolShow?TEXT("show"):TEXT("hide")); + (scintNode->ToElement())->SetAttribute(TEXT("Wrap"), svp._doWrap?TEXT("yes"):TEXT("no")); + TCHAR *edgeStr = NULL; if (svp._edgeMode == EDGE_NONE) - edgeStr = "no"; + edgeStr = TEXT("no"); else if (svp._edgeMode == EDGE_LINE) - edgeStr = "line"; + edgeStr = TEXT("line"); else - edgeStr = "background"; - (scintNode->ToElement())->SetAttribute("edge", edgeStr); - (scintNode->ToElement())->SetAttribute("edgeNbColumn", svp._edgeNbColumn); - (scintNode->ToElement())->SetAttribute("zoom", svp._zoom); - (scintNode->ToElement())->SetAttribute("whiteSpaceShow", svp._whiteSpaceShow?"show":"hide"); - (scintNode->ToElement())->SetAttribute("eolShow", svp._eolShow?"show":"hide"); + edgeStr = TEXT("background"); + (scintNode->ToElement())->SetAttribute(TEXT("edge"), edgeStr); + (scintNode->ToElement())->SetAttribute(TEXT("edgeNbColumn"), svp._edgeNbColumn); + (scintNode->ToElement())->SetAttribute(TEXT("zoom"), svp._zoom); + (scintNode->ToElement())->SetAttribute(TEXT("whiteSpaceShow"), svp._whiteSpaceShow?TEXT("show"):TEXT("hide")); + (scintNode->ToElement())->SetAttribute(TEXT("eolShow"), svp._eolShow?TEXT("show"):TEXT("hide")); return true; } @@ -3161,10 +3161,10 @@ bool NppParameters::writeGUIParams() { if (!_pXmlUserDoc) return false; - TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus"); + TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus")); if (!nppRoot) return false; - TiXmlNode *GUIRoot = nppRoot->FirstChildElement("GUIConfigs"); + TiXmlNode *GUIRoot = nppRoot->FirstChildElement(TEXT("GUIConfigs")); if (!GUIRoot) return false; bool autoDetectionExist = false; @@ -3191,38 +3191,38 @@ bool NppParameters::writeGUIParams() TiXmlNode *dockingParamNode = NULL; - for (TiXmlNode *childNode = GUIRoot->FirstChildElement("GUIConfig"); + for (TiXmlNode *childNode = GUIRoot->FirstChildElement(TEXT("GUIConfig")); childNode ; - childNode = childNode->NextSibling("GUIConfig")) + childNode = childNode->NextSibling(TEXT("GUIConfig"))) { TiXmlElement *element = childNode->ToElement(); - const char *nm = element->Attribute("name"); + const TCHAR *nm = element->Attribute(TEXT("name")); if (!nm) continue; - if (!strcmp(nm, "ToolBar")) + if (!lstrcmp(nm, TEXT("ToolBar"))) { - const char *pStr = (_nppGUI._toolbarShow)?"yes":"no"; - element->SetAttribute("visible", pStr); + const TCHAR *pStr = (_nppGUI._toolbarShow)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("visible"), pStr); - pStr = _nppGUI._toolBarStatus == TB_SMALL?"small":(_nppGUI._toolBarStatus == TB_STANDARD?"standard":"large"); + pStr = _nppGUI._toolBarStatus == TB_SMALL?TEXT("small"):(_nppGUI._toolBarStatus == TB_STANDARD?TEXT("standard"):TEXT("large")); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "StatusBar")) + else if (!lstrcmp(nm, TEXT("StatusBar"))) { - const char *pStr = _nppGUI._statusBarShow?"show":"hide"; + const TCHAR *pStr = _nppGUI._statusBarShow?TEXT("show"):TEXT("hide"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "MenuBar")) + else if (!lstrcmp(nm, TEXT("MenuBar"))) { - const char *pStr = _nppGUI._menuBarShow?"show":"hide"; + const TCHAR *pStr = _nppGUI._menuBarShow?TEXT("show"):TEXT("hide"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); @@ -3231,86 +3231,86 @@ bool NppParameters::writeGUIParams() menuBarExist = true; } - else if (!strcmp(nm, "TabBar")) + else if (!lstrcmp(nm, TEXT("TabBar"))) { - const char *pStr = (_nppGUI._tabStatus & TAB_DRAWTOPBAR)?"yes":"no"; - element->SetAttribute("dragAndDrop", pStr); + const TCHAR *pStr = (_nppGUI._tabStatus & TAB_DRAWTOPBAR)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("dragAndDrop"), pStr); - pStr = (_nppGUI._tabStatus & TAB_DRAGNDROP)?"yes":"no"; - element->SetAttribute("drawTopBar", pStr); + pStr = (_nppGUI._tabStatus & TAB_DRAGNDROP)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("drawTopBar"), pStr); - pStr = (_nppGUI._tabStatus & TAB_DRAWINACTIVETAB)?"yes":"no"; - element->SetAttribute("drawInactiveTab", pStr); + pStr = (_nppGUI._tabStatus & TAB_DRAWINACTIVETAB)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("drawInactiveTab"), pStr); - pStr = (_nppGUI._tabStatus & TAB_REDUCE)?"yes":"no"; - element->SetAttribute("reduce", pStr); + pStr = (_nppGUI._tabStatus & TAB_REDUCE)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("reduce"), pStr); - pStr = (_nppGUI._tabStatus & TAB_CLOSEBUTTON)?"yes":"no"; - element->SetAttribute("closeButton", pStr); + pStr = (_nppGUI._tabStatus & TAB_CLOSEBUTTON)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("closeButton"), pStr); - pStr = (_nppGUI._tabStatus & TAB_DBCLK2CLOSE)?"yes":"no"; - element->SetAttribute("doubleClick2Close", pStr); + pStr = (_nppGUI._tabStatus & TAB_DBCLK2CLOSE)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("doubleClick2Close"), pStr); - pStr = (_nppGUI._tabStatus & TAB_VERTICAL)?"yes":"no"; - element->SetAttribute("vertical", pStr); + pStr = (_nppGUI._tabStatus & TAB_VERTICAL)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("vertical"), pStr); - pStr = (_nppGUI._tabStatus & TAB_MULTILINE)?"yes":"no"; - element->SetAttribute("multiLine", pStr); + pStr = (_nppGUI._tabStatus & TAB_MULTILINE)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("multiLine"), pStr); - pStr = (_nppGUI._tabStatus & TAB_HIDE)?"yes":"no"; - element->SetAttribute("hide", pStr); + pStr = (_nppGUI._tabStatus & TAB_HIDE)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("hide"), pStr); } - else if (!strcmp(nm, "ScintillaViewsSplitter")) + else if (!lstrcmp(nm, TEXT("ScintillaViewsSplitter"))) { - const char *pStr = _nppGUI._splitterPos == POS_VERTICAL?"vertical":"horizontal"; + const TCHAR *pStr = _nppGUI._splitterPos == POS_VERTICAL?TEXT("vertical"):TEXT("horizontal"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "UserDefineDlg")) + else if (!lstrcmp(nm, TEXT("UserDefineDlg"))) { - const char *pStr = _nppGUI._userDefineDlgStatus & UDD_SHOW?"show":"hide"; + const TCHAR *pStr = _nppGUI._userDefineDlgStatus & UDD_SHOW?TEXT("show"):TEXT("hide"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); - pStr = (_nppGUI._userDefineDlgStatus & UDD_DOCKED)?"docked":"undocked"; - element->SetAttribute("position", pStr); + pStr = (_nppGUI._userDefineDlgStatus & UDD_DOCKED)?TEXT("docked"):TEXT("undocked"); + element->SetAttribute(TEXT("position"), pStr); } - else if (!strcmp(nm, "TabSetting")) + else if (!lstrcmp(nm, TEXT("TabSetting"))) { - const char *pStr = _nppGUI._tabReplacedBySpace?"yes":"no"; - element->SetAttribute("replaceBySpace", pStr); - element->SetAttribute("size", _nppGUI._tabSize); + const TCHAR *pStr = _nppGUI._tabReplacedBySpace?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("replaceBySpace"), pStr); + element->SetAttribute(TEXT("size"), _nppGUI._tabSize); } - else if (!strcmp(nm, "Caret")) + else if (!lstrcmp(nm, TEXT("Caret"))) { caretExist = true; - element->SetAttribute("width", _nppGUI._caretWidth); - element->SetAttribute("blinkRate", _nppGUI._caretBlinkRate); + element->SetAttribute(TEXT("width"), _nppGUI._caretWidth); + element->SetAttribute(TEXT("blinkRate"), _nppGUI._caretBlinkRate); } - else if (!strcmp(nm, "Auto-detection")) + else if (!lstrcmp(nm, TEXT("Auto-detection"))) { autoDetectionExist = true; - const char *pStr = "no"; + const TCHAR *pStr = TEXT("no"); switch (_nppGUI._fileAutoDetection) { case cdEnabled: - pStr = "yes"; + pStr = TEXT("yes"); break; case cdAutoUpdate: - pStr = "auto"; + pStr = TEXT("auto"); break; case cdGo2end: - pStr = "Update2End"; + pStr = TEXT("Update2End"); break; case cdAutoUpdateGo2end: - pStr = "autoUpdate2End"; + pStr = TEXT("autoUpdate2End"); break; } TiXmlNode *n = childNode->FirstChild(); @@ -3319,20 +3319,20 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "TrayIcon")) + else if (!lstrcmp(nm, TEXT("TrayIcon"))) { trayIconExist = true; - const char *pStr = _nppGUI._isMinimizedToTray?"yes":"no"; + const TCHAR *pStr = _nppGUI._isMinimizedToTray?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "RememberLastSession")) + else if (!lstrcmp(nm, TEXT("RememberLastSession"))) { rememberLastSessionExist = true; - const char *pStr = _nppGUI._rememberLastSession?"yes":"no"; + const TCHAR *pStr = _nppGUI._rememberLastSession?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); @@ -3340,20 +3340,20 @@ bool NppParameters::writeGUIParams() childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "MaitainIndent")) + else if (!lstrcmp(nm, TEXT("MaitainIndent"))) { maitainIndentExist = true; - const char *pStr = _nppGUI._maitainIndent?"yes":"no"; + const TCHAR *pStr = _nppGUI._maitainIndent?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "SmartHighLight")) + else if (!lstrcmp(nm, TEXT("SmartHighLight"))) { smartHighLightExist = true; - const char *pStr = _nppGUI._enableSmartHilite?"yes":"no"; + const TCHAR *pStr = _nppGUI._enableSmartHilite?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); @@ -3361,23 +3361,23 @@ bool NppParameters::writeGUIParams() childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "TagsMatchHighLight")) + else if (!lstrcmp(nm, TEXT("TagsMatchHighLight"))) { tagsMatchHighLightExist = true; - const char *pStr = _nppGUI._enableTagsMatchHilite?"yes":"no"; + const TCHAR *pStr = _nppGUI._enableTagsMatchHilite?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); else childNode->InsertEndChild(TiXmlText(pStr)); - (childNode->ToElement())->SetAttribute("TagAttrHighLight", _nppGUI._enableTagAttrsHilite?"yes":"no"); + (childNode->ToElement())->SetAttribute(TEXT("TagAttrHighLight"), _nppGUI._enableTagAttrsHilite?TEXT("yes"):TEXT("no")); } - else if (!strcmp(nm, "SaveOpenFileInSameDir")) + else if (!lstrcmp(nm, TEXT("SaveOpenFileInSameDir"))) { saveOpenFileInSameDirExist = true; - const char *pStr = _nppGUI._saveOpenKeepInSameDir?"yes":"no"; + const TCHAR *pStr = _nppGUI._saveOpenKeepInSameDir?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) n->SetValue(pStr); @@ -3385,10 +3385,10 @@ bool NppParameters::writeGUIParams() childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "TaskList")) + else if (!lstrcmp(nm, TEXT("TaskList"))) { doTaskListExist = true; - const char *pStr = _nppGUI._doTaskList?"yes":"no"; + const TCHAR *pStr = _nppGUI._doTaskList?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) @@ -3396,10 +3396,10 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "CheckHistoryFiles")) + else if (!lstrcmp(nm, TEXT("CheckHistoryFiles"))) { checkHistoryFilesExist = true; - const char *pStr = _nppGUI._checkHistoryFiles?"yes":"no"; + const TCHAR *pStr = _nppGUI._checkHistoryFiles?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) @@ -3407,42 +3407,42 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "AppPosition")) + else if (!lstrcmp(nm, TEXT("AppPosition"))) { - element->SetAttribute("x", _nppGUI._appPos.left); - element->SetAttribute("y", _nppGUI._appPos.top); - element->SetAttribute("width", _nppGUI._appPos.right); - element->SetAttribute("height", _nppGUI._appPos.bottom); - element->SetAttribute("isMaximized", _nppGUI._isMaximized?"yes":"no"); + element->SetAttribute(TEXT("x"), _nppGUI._appPos.left); + element->SetAttribute(TEXT("y"), _nppGUI._appPos.top); + element->SetAttribute(TEXT("width"), _nppGUI._appPos.right); + element->SetAttribute(TEXT("height"), _nppGUI._appPos.bottom); + element->SetAttribute(TEXT("isMaximized"), _nppGUI._isMaximized?TEXT("yes"):TEXT("no")); } - else if (!strcmp(nm, "NewDocDefaultSettings")) + else if (!lstrcmp(nm, TEXT("NewDocDefaultSettings"))) { - element->SetAttribute("format", _nppGUI._newDocDefaultSettings._format); - element->SetAttribute("encoding", _nppGUI._newDocDefaultSettings._encoding); - element->SetAttribute("lang", _nppGUI._newDocDefaultSettings._lang); + element->SetAttribute(TEXT("format"), _nppGUI._newDocDefaultSettings._format); + element->SetAttribute(TEXT("encoding"), _nppGUI._newDocDefaultSettings._encoding); + element->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang); newDocDefaultSettingsExist = true; } - else if (!strcmp(nm, "langsExcluded")) + else if (!lstrcmp(nm, TEXT("langsExcluded"))) { writeExcludedLangList(element); langsExcludedLstExist = true; } - else if (!strcmp(nm, "Print")) + else if (!lstrcmp(nm, TEXT("Print"))) { writePrintSetting(element); printSettingExist = true; } - else if (!strcmp(nm, "Backup")) + else if (!lstrcmp(nm, TEXT("Backup"))) { - element->SetAttribute("action", _nppGUI._backup); - element->SetAttribute("useCustumDir", _nppGUI._useDir?"yes":"no"); - element->SetAttribute("dir", _nppGUI._backupDir); + element->SetAttribute(TEXT("action"), _nppGUI._backup); + element->SetAttribute(TEXT("useCustumDir"), _nppGUI._useDir?TEXT("yes"):TEXT("no")); + element->SetAttribute(TEXT("dir"), _nppGUI._backupDir); backExist = true; } - else if (!strcmp(nm, "MRU")) + else if (!lstrcmp(nm, TEXT("MRU"))) { MRUExist = true; - const char *pStr = _nppGUI._styleMRU?"yes":"no"; + const TCHAR *pStr = _nppGUI._styleMRU?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) @@ -3450,14 +3450,14 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "URL")) + else if (!lstrcmp(nm, TEXT("URL"))) { URLExist = true; - const char *pStr = "0"; + const TCHAR *pStr = TEXT("0"); if (_nppGUI._styleURL == 1) - pStr = "1"; + pStr = TEXT("1"); else if (_nppGUI._styleURL == 2) - pStr = "2"; + pStr = TEXT("2"); TiXmlNode *n = childNode->FirstChild(); if (n) @@ -3465,43 +3465,43 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } - else if (!strcmp(nm, "DockingManager")) + else if (!lstrcmp(nm, TEXT("DockingManager"))) { dockingParamNode = childNode; } - else if (!strcmp(nm, "globalOverride")) + else if (!lstrcmp(nm, TEXT("globalOverride"))) { globalOverrideExist = true; - const char *pStr = _nppGUI._globalOverride.enableFg?"yes":"no"; - element->SetAttribute("fg", pStr); + const TCHAR *pStr = _nppGUI._globalOverride.enableFg?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("fg"), pStr); - pStr = (_nppGUI._globalOverride.enableBg)?"yes":"no"; - element->SetAttribute("bg", pStr); + pStr = (_nppGUI._globalOverride.enableBg)?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("bg"), pStr); - pStr = _nppGUI._globalOverride.enableFont?"yes":"no"; - element->SetAttribute("font", pStr); + pStr = _nppGUI._globalOverride.enableFont?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("font"), pStr); - pStr = _nppGUI._globalOverride.enableFontSize?"yes":"no"; - element->SetAttribute("fontSize", pStr); + pStr = _nppGUI._globalOverride.enableFontSize?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("fontSize"), pStr); - pStr = _nppGUI._globalOverride.enableBold?"yes":"no"; - element->SetAttribute("bold", pStr); + pStr = _nppGUI._globalOverride.enableBold?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("bold"), pStr); - pStr = _nppGUI._globalOverride.enableItalic?"yes":"no"; - element->SetAttribute("italic", pStr); + pStr = _nppGUI._globalOverride.enableItalic?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("italic"), pStr); - pStr = _nppGUI._globalOverride.enableUnderLine?"yes":"no"; - element->SetAttribute("underline", pStr); + pStr = _nppGUI._globalOverride.enableUnderLine?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("underline"), pStr); } - else if (!strcmp(nm, "auto-completion")) + else if (!lstrcmp(nm, TEXT("auto-completion"))) { autocExist = true; - element->SetAttribute("autoCAction", _nppGUI._autocStatus); - element->SetAttribute("triggerFromNbChar", _nppGUI._autocFromLen); - const char * pStr = _nppGUI._funcParams?"yes":"no"; - element->SetAttribute("funcParams", pStr); + element->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus); + element->SetAttribute(TEXT("triggerFromNbChar"), _nppGUI._autocFromLen); + const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("funcParams"), pStr); } - else if (!strcmp(nm, "sessionExt")) + else if (!lstrcmp(nm, TEXT("sessionExt"))) { sessionExtExist = true; TiXmlNode *n = childNode->FirstChild(); @@ -3510,10 +3510,10 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str())); } - else if (!strcmp(nm, "noUpdate")) + else if (!lstrcmp(nm, TEXT("noUpdate"))) { noUpdateExist = true; - const char *pStr = _nppGUI._neverUpdate?"yes":"no"; + const TCHAR *pStr = _nppGUI._neverUpdate?TEXT("yes"):TEXT("no"); TiXmlNode *n = childNode->FirstChild(); if (n) @@ -3525,140 +3525,140 @@ bool NppParameters::writeGUIParams() if (!noUpdateExist) { - insertGUIConfigBoolNode(GUIRoot, "noUpdate", _nppGUI._neverUpdate); + insertGUIConfigBoolNode(GUIRoot, TEXT("noUpdate"), _nppGUI._neverUpdate); } if (!autoDetectionExist) { - const char *pStr = "no"; + const TCHAR *pStr = TEXT("no"); switch (_nppGUI._fileAutoDetection) { case cdEnabled: - pStr = "yes"; + pStr = TEXT("yes"); break; case cdAutoUpdate: - pStr = "auto"; + pStr = TEXT("auto"); break; case cdGo2end: - pStr = "Update2End"; + pStr = TEXT("Update2End"); break; case cdAutoUpdateGo2end: - pStr = "autoUpdate2End"; + pStr = TEXT("autoUpdate2End"); break; } - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "Auto-detection"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Auto-detection")); GUIConfigElement->InsertEndChild(TiXmlText(pStr)); } if (!checkHistoryFilesExist) { - insertGUIConfigBoolNode(GUIRoot, "CheckHistoryFiles", _nppGUI._checkHistoryFiles); + insertGUIConfigBoolNode(GUIRoot, TEXT("CheckHistoryFiles"), _nppGUI._checkHistoryFiles); } if (!trayIconExist) { - insertGUIConfigBoolNode(GUIRoot, "TrayIcon", _nppGUI._isMinimizedToTray); + insertGUIConfigBoolNode(GUIRoot, TEXT("TrayIcon"), _nppGUI._isMinimizedToTray); } if (!maitainIndentExist) { - insertGUIConfigBoolNode(GUIRoot, "MaitainIndent", _nppGUI._maitainIndent); + insertGUIConfigBoolNode(GUIRoot, TEXT("MaitainIndent"), _nppGUI._maitainIndent); } if (!smartHighLightExist) { - insertGUIConfigBoolNode(GUIRoot, "SmartHighLight", _nppGUI._enableSmartHilite); + insertGUIConfigBoolNode(GUIRoot, TEXT("SmartHighLight"), _nppGUI._enableSmartHilite); } if (!tagsMatchHighLightExist) { - TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, "TagsMatchHighLight", _nppGUI._enableTagsMatchHilite); - ele->SetAttribute("TagAttrHighLight", _nppGUI._enableTagAttrsHilite?"yes":"no"); + TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, TEXT("TagsMatchHighLight"), _nppGUI._enableTagsMatchHilite); + ele->SetAttribute(TEXT("TagAttrHighLight"), _nppGUI._enableTagAttrsHilite?TEXT("yes"):TEXT("no")); } if (!rememberLastSessionExist) { - insertGUIConfigBoolNode(GUIRoot, "RememberLastSession", _nppGUI._rememberLastSession); + insertGUIConfigBoolNode(GUIRoot, TEXT("RememberLastSession"), _nppGUI._rememberLastSession); } if (!newDocDefaultSettingsExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "NewDocDefaultSettings"); - GUIConfigElement->SetAttribute("format", _nppGUI._newDocDefaultSettings._format); - GUIConfigElement->SetAttribute("encoding", _nppGUI._newDocDefaultSettings._encoding); - GUIConfigElement->SetAttribute("lang", _nppGUI._newDocDefaultSettings._lang); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("NewDocDefaultSettings")); + GUIConfigElement->SetAttribute(TEXT("format"), _nppGUI._newDocDefaultSettings._format); + GUIConfigElement->SetAttribute(TEXT("encoding"), _nppGUI._newDocDefaultSettings._encoding); + GUIConfigElement->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang); } if (!langsExcludedLstExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "langsExcluded"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("langsExcluded")); writeExcludedLangList(GUIConfigElement); } if (!printSettingExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "Print"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Print")); writePrintSetting(GUIConfigElement); } if (!backExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "Backup"); - GUIConfigElement->SetAttribute("action", _nppGUI._backup); - GUIConfigElement->SetAttribute("useCustumDir", _nppGUI._useDir?"yes":"no"); - GUIConfigElement->SetAttribute("dir", _nppGUI._backupDir); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Backup")); + GUIConfigElement->SetAttribute(TEXT("action"), _nppGUI._backup); + GUIConfigElement->SetAttribute(TEXT("useCustumDir"), _nppGUI._useDir?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("dir"), _nppGUI._backupDir); } if (!doTaskListExist) { - insertGUIConfigBoolNode(GUIRoot, "TaskList", _nppGUI._doTaskList); + insertGUIConfigBoolNode(GUIRoot, TEXT("TaskList"), _nppGUI._doTaskList); } if (!MRUExist) { - insertGUIConfigBoolNode(GUIRoot, "MRU", _nppGUI._styleMRU); + insertGUIConfigBoolNode(GUIRoot, TEXT("MRU"), _nppGUI._styleMRU); } if (!URLExist) { - const char *pStr = "0"; + const TCHAR *pStr = TEXT("0"); if (_nppGUI._styleURL == 1) - pStr = "1"; + pStr = TEXT("1"); else if (_nppGUI._styleURL == 2) - pStr = "2"; + pStr = TEXT("2"); - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "URL"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("URL")); GUIConfigElement->InsertEndChild(TiXmlText(pStr)); } if (!globalOverrideExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "globalOverride"); - GUIConfigElement->SetAttribute("fg", _nppGUI._globalOverride.enableFg?"yes":"no"); - GUIConfigElement->SetAttribute("bg", _nppGUI._globalOverride.enableBg?"yes":"no"); - GUIConfigElement->SetAttribute("font", _nppGUI._globalOverride.enableFont?"yes":"no"); - GUIConfigElement->SetAttribute("fontSize", _nppGUI._globalOverride.enableFontSize?"yes":"no"); - GUIConfigElement->SetAttribute("bold", _nppGUI._globalOverride.enableBold?"yes":"no"); - GUIConfigElement->SetAttribute("italic", _nppGUI._globalOverride.enableItalic?"yes":"no"); - GUIConfigElement->SetAttribute("underline", _nppGUI._globalOverride.enableUnderLine?"yes":"no"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("globalOverride")); + GUIConfigElement->SetAttribute(TEXT("fg"), _nppGUI._globalOverride.enableFg?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("bg"), _nppGUI._globalOverride.enableBg?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("font"), _nppGUI._globalOverride.enableFont?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("fontSize"), _nppGUI._globalOverride.enableFontSize?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("bold"), _nppGUI._globalOverride.enableBold?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("italic"), _nppGUI._globalOverride.enableItalic?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("underline"), _nppGUI._globalOverride.enableUnderLine?TEXT("yes"):TEXT("no")); } if (!autocExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "auto-completion"); - GUIConfigElement->SetAttribute("autoCAction", _nppGUI._autocStatus); - GUIConfigElement->SetAttribute("triggerFromNbChar", _nppGUI._autocFromLen); - const char * pStr = _nppGUI._funcParams?"yes":"no"; - GUIConfigElement->SetAttribute("funcParams", pStr); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("auto-completion")); + GUIConfigElement->SetAttribute(TEXT("autoCAction"), _nppGUI._autocStatus); + GUIConfigElement->SetAttribute(TEXT("triggerFromNbChar"), _nppGUI._autocFromLen); + const TCHAR * pStr = _nppGUI._funcParams?TEXT("yes"):TEXT("no"); + GUIConfigElement->SetAttribute(TEXT("funcParams"), pStr); autocExist = true; } if (!saveOpenFileInSameDirExist) { - insertGUIConfigBoolNode(GUIRoot, "SaveOpenFileInSameDir", _nppGUI._saveOpenKeepInSameDir); + insertGUIConfigBoolNode(GUIRoot, TEXT("SaveOpenFileInSameDir"), _nppGUI._saveOpenKeepInSameDir); } if (dockingParamNode) @@ -3669,26 +3669,26 @@ bool NppParameters::writeGUIParams() if (!sessionExtExist) { - //const char *pStr = bVal?"yes":"no"; - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "sessionExt"); + //const TCHAR *pStr = bVal?TEXT("yes"):TEXT("no"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("sessionExt")); GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._definedSessionExt.c_str())); } if (!menuBarExist) { - //const char *pStr = bVal?"yes":"no"; - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "MenuBar"); - GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._menuBarShow?"show":"hide")); + //const TCHAR *pStr = bVal?TEXT("yes"):TEXT("no"); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("MenuBar")); + GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._menuBarShow?TEXT("show"):TEXT("hide"))); } if (!caretExist) { - TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", "Caret"); - GUIConfigElement->SetAttribute("width", _nppGUI._caretWidth); - GUIConfigElement->SetAttribute("blinkRate", _nppGUI._caretBlinkRate); + TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("Caret")); + GUIConfigElement->SetAttribute(TEXT("width"), _nppGUI._caretWidth); + GUIConfigElement->SetAttribute(TEXT("blinkRate"), _nppGUI._caretBlinkRate); } insertDockingParamNode(GUIRoot); @@ -3697,22 +3697,22 @@ bool NppParameters::writeGUIParams() void NppParameters::insertDockingParamNode(TiXmlNode *GUIRoot) { - TiXmlElement DMNode("GUIConfig"); - DMNode.SetAttribute("name", "DockingManager"); - DMNode.SetAttribute("leftWidth", _nppGUI._dockingData._leftWidth); - DMNode.SetAttribute("rightWidth", _nppGUI._dockingData._rightWidth); - DMNode.SetAttribute("topHeight", _nppGUI._dockingData._topHeight); - DMNode.SetAttribute("bottomHeight", _nppGUI._dockingData._bottomHight); + TiXmlElement DMNode(TEXT("GUIConfig")); + DMNode.SetAttribute(TEXT("name"), TEXT("DockingManager")); + DMNode.SetAttribute(TEXT("leftWidth"), _nppGUI._dockingData._leftWidth); + DMNode.SetAttribute(TEXT("rightWidth"), _nppGUI._dockingData._rightWidth); + DMNode.SetAttribute(TEXT("topHeight"), _nppGUI._dockingData._topHeight); + DMNode.SetAttribute(TEXT("bottomHeight"), _nppGUI._dockingData._bottomHight); for (size_t i = 0 ; i < _nppGUI._dockingData._flaotingWindowInfo.size() ; i++) { FloatingWindowInfo & fwi = _nppGUI._dockingData._flaotingWindowInfo[i]; - TiXmlElement FWNode("FloatingWindow"); - FWNode.SetAttribute("cont", fwi._cont); - FWNode.SetAttribute("x", fwi._pos.left); - FWNode.SetAttribute("y", fwi._pos.top); - FWNode.SetAttribute("width", fwi._pos.right); - FWNode.SetAttribute("height", fwi._pos.bottom); + TiXmlElement FWNode(TEXT("FloatingWindow")); + FWNode.SetAttribute(TEXT("cont"), fwi._cont); + FWNode.SetAttribute(TEXT("x"), fwi._pos.left); + FWNode.SetAttribute(TEXT("y"), fwi._pos.top); + FWNode.SetAttribute(TEXT("width"), fwi._pos.right); + FWNode.SetAttribute(TEXT("height"), fwi._pos.bottom); DMNode.InsertEndChild(FWNode); } @@ -3720,22 +3720,22 @@ void NppParameters::insertDockingParamNode(TiXmlNode *GUIRoot) for (size_t i = 0 ; i < _nppGUI._dockingData._pluginDockInfo.size() ; i++) { PlugingDlgDockingInfo & pdi = _nppGUI._dockingData._pluginDockInfo[i]; - TiXmlElement PDNode("PluginDlg"); - PDNode.SetAttribute("pluginName", pdi._name); - PDNode.SetAttribute("id", pdi._internalID); - PDNode.SetAttribute("curr", pdi._currContainer); - PDNode.SetAttribute("prev", pdi._prevContainer); - PDNode.SetAttribute("isVisible", pdi._isVisible?"yes":"no"); + TiXmlElement PDNode(TEXT("PluginDlg")); + PDNode.SetAttribute(TEXT("pluginName"), pdi._name); + PDNode.SetAttribute(TEXT("id"), pdi._internalID); + PDNode.SetAttribute(TEXT("curr"), pdi._currContainer); + PDNode.SetAttribute(TEXT("prev"), pdi._prevContainer); + PDNode.SetAttribute(TEXT("isVisible"), pdi._isVisible?TEXT("yes"):TEXT("no")); DMNode.InsertEndChild(PDNode); - }//printStr("in writeGUIParams"); + }//printStr(TEXT("in writeGUIParams")); for (size_t i = 0 ; i < _nppGUI._dockingData._containerTabInfo.size() ; i++) { ContainerTabInfo & cti = _nppGUI._dockingData._containerTabInfo[i]; - TiXmlElement CTNode("ActiveTabs"); - CTNode.SetAttribute("cont", cti._cont); - CTNode.SetAttribute("activeTab", cti._activeTab); + TiXmlElement CTNode(TEXT("ActiveTabs")); + CTNode.SetAttribute(TEXT("cont"), cti._cont); + CTNode.SetAttribute(TEXT("activeTab"), cti._activeTab); DMNode.InsertEndChild(CTNode); } @@ -3744,29 +3744,29 @@ void NppParameters::insertDockingParamNode(TiXmlNode *GUIRoot) void NppParameters::writePrintSetting(TiXmlElement *element) { - const char *pStr = _nppGUI._printSettings._printLineNumber?"yes":"no"; - element->SetAttribute("lineNumber", pStr); + const TCHAR *pStr = _nppGUI._printSettings._printLineNumber?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("lineNumber"), pStr); - element->SetAttribute("printOption", _nppGUI._printSettings._printOption); + element->SetAttribute(TEXT("printOption"), _nppGUI._printSettings._printOption); - element->SetAttribute("headerLeft", _nppGUI._printSettings._headerLeft.c_str()); - element->SetAttribute("headerMiddle", _nppGUI._printSettings._headerMiddle.c_str()); - element->SetAttribute("headerRight", _nppGUI._printSettings._headerRight.c_str()); - element->SetAttribute("footerLeft", _nppGUI._printSettings._footerLeft.c_str()); - element->SetAttribute("footerMiddle", _nppGUI._printSettings._footerMiddle.c_str()); - element->SetAttribute("footerRight", _nppGUI._printSettings._footerRight.c_str()); + element->SetAttribute(TEXT("headerLeft"), _nppGUI._printSettings._headerLeft.c_str()); + element->SetAttribute(TEXT("headerMiddle"), _nppGUI._printSettings._headerMiddle.c_str()); + element->SetAttribute(TEXT("headerRight"), _nppGUI._printSettings._headerRight.c_str()); + element->SetAttribute(TEXT("footerLeft"), _nppGUI._printSettings._footerLeft.c_str()); + element->SetAttribute(TEXT("footerMiddle"), _nppGUI._printSettings._footerMiddle.c_str()); + element->SetAttribute(TEXT("footerRight"), _nppGUI._printSettings._footerRight.c_str()); - element->SetAttribute("headerFontName", _nppGUI._printSettings._headerFontName.c_str()); - element->SetAttribute("headerFontStyle", _nppGUI._printSettings._headerFontStyle); - element->SetAttribute("headerFontSize", _nppGUI._printSettings._headerFontSize); - element->SetAttribute("footerFontName", _nppGUI._printSettings._footerFontName.c_str()); - element->SetAttribute("footerFontStyle", _nppGUI._printSettings._footerFontStyle); - element->SetAttribute("footerFontSize", _nppGUI._printSettings._footerFontSize); + element->SetAttribute(TEXT("headerFontName"), _nppGUI._printSettings._headerFontName.c_str()); + element->SetAttribute(TEXT("headerFontStyle"), _nppGUI._printSettings._headerFontStyle); + element->SetAttribute(TEXT("headerFontSize"), _nppGUI._printSettings._headerFontSize); + element->SetAttribute(TEXT("footerFontName"), _nppGUI._printSettings._footerFontName.c_str()); + element->SetAttribute(TEXT("footerFontStyle"), _nppGUI._printSettings._footerFontStyle); + element->SetAttribute(TEXT("footerFontSize"), _nppGUI._printSettings._footerFontSize); - element->SetAttribute("margeLeft", _nppGUI._printSettings._marge.left); - element->SetAttribute("margeRight", _nppGUI._printSettings._marge.right); - element->SetAttribute("margeTop", _nppGUI._printSettings._marge.top); - element->SetAttribute("margeBottom", _nppGUI._printSettings._marge.bottom); + element->SetAttribute(TEXT("margeLeft"), _nppGUI._printSettings._marge.left); + element->SetAttribute(TEXT("margeRight"), _nppGUI._printSettings._marge.right); + element->SetAttribute(TEXT("margeTop"), _nppGUI._printSettings._marge.top); + element->SetAttribute(TEXT("margeBottom"), _nppGUI._printSettings._marge.bottom); } void NppParameters::writeExcludedLangList(TiXmlElement *element) @@ -3819,21 +3819,21 @@ void NppParameters::writeExcludedLangList(TiXmlElement *element) } } - element->SetAttribute("gr0", g0); - element->SetAttribute("gr1", g1); - element->SetAttribute("gr2", g2); - element->SetAttribute("gr3", g3); - element->SetAttribute("gr4", g4); - element->SetAttribute("gr5", g5); - element->SetAttribute("gr6", g6); - element->SetAttribute("gr7", g7); + element->SetAttribute(TEXT("gr0"), g0); + element->SetAttribute(TEXT("gr1"), g1); + element->SetAttribute(TEXT("gr2"), g2); + element->SetAttribute(TEXT("gr3"), g3); + element->SetAttribute(TEXT("gr4"), g4); + element->SetAttribute(TEXT("gr5"), g5); + element->SetAttribute(TEXT("gr6"), g6); + element->SetAttribute(TEXT("gr7"), g7); } -TiXmlElement * NppParameters::insertGUIConfigBoolNode(TiXmlNode *r2w, const char *name, bool bVal) +TiXmlElement * NppParameters::insertGUIConfigBoolNode(TiXmlNode *r2w, const TCHAR *name, bool bVal) { - const char *pStr = bVal?"yes":"no"; - TiXmlElement *GUIConfigElement = (r2w->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); - GUIConfigElement->SetAttribute("name", name); + const TCHAR *pStr = bVal?TEXT("yes"):TEXT("no"); + TiXmlElement *GUIConfigElement = (r2w->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), name); GUIConfigElement->InsertEndChild(TiXmlText(pStr)); return GUIConfigElement; } @@ -3968,27 +3968,27 @@ int NppParameters::langTypeToCommandID(LangType lt) const void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & globalStylers) { - TiXmlNode *lexersRoot = (_pXmlUserStylerDoc->FirstChild("NotepadPlus"))->FirstChildElement("LexerStyles"); - for (TiXmlNode *childNode = lexersRoot->FirstChildElement("LexerType"); + TiXmlNode *lexersRoot = (_pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles")); + for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType")); childNode ; - childNode = childNode->NextSibling("LexerType")) + childNode = childNode->NextSibling(TEXT("LexerType"))) { TiXmlElement *element = childNode->ToElement(); - const char *nm = element->Attribute("name"); + const TCHAR *nm = element->Attribute(TEXT("name")); LexerStyler *pLs = _lexerStylerArray.getLexerStylerByName(nm); LexerStyler *pLs2 = lexersStylers.getLexerStylerByName(nm); if (pLs) { - const char *extStr = pLs->getLexerUserExt(); - element->SetAttribute("ext", extStr); - for (TiXmlNode *grChildNode = childNode->FirstChildElement("WordsStyle"); + const TCHAR *extStr = pLs->getLexerUserExt(); + element->SetAttribute(TEXT("ext"), extStr); + for (TiXmlNode *grChildNode = childNode->FirstChildElement(TEXT("WordsStyle")); grChildNode ; - grChildNode = grChildNode->NextSibling("WordsStyle")) + grChildNode = grChildNode->NextSibling(TEXT("WordsStyle"))) { TiXmlElement *grElement = grChildNode->ToElement(); - const char *styleName = grElement->Attribute("name"); + const TCHAR *styleName = grElement->Attribute(TEXT("name")); int i = pLs->getStylerIndexByName(styleName); if (i != -1) @@ -4004,29 +4004,29 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g for(size_t x = 0; x < _pXmlExternalLexerDoc.size(); x++) { - TiXmlNode *lexersRoot = ( _pXmlExternalLexerDoc[x]->FirstChild("NotepadPlus"))->FirstChildElement("LexerStyles"); - for (TiXmlNode *childNode = lexersRoot->FirstChildElement("LexerType"); + TiXmlNode *lexersRoot = ( _pXmlExternalLexerDoc[x]->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("LexerStyles")); + for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType")); childNode ; - childNode = childNode->NextSibling("LexerType")) + childNode = childNode->NextSibling(TEXT("LexerType"))) { TiXmlElement *element = childNode->ToElement(); - const char *nm = element->Attribute("name"); + const TCHAR *nm = element->Attribute(TEXT("name")); LexerStyler *pLs = _lexerStylerArray.getLexerStylerByName(nm); LexerStyler *pLs2 = lexersStylers.getLexerStylerByName(nm); if (pLs) { - const char *extStr = pLs->getLexerUserExt(); + const TCHAR *extStr = pLs->getLexerUserExt(); //pLs2->setLexerUserExt(extStr); - element->SetAttribute("ext", extStr); + element->SetAttribute(TEXT("ext"), extStr); - for (TiXmlNode *grChildNode = childNode->FirstChildElement("WordsStyle"); + for (TiXmlNode *grChildNode = childNode->FirstChildElement(TEXT("WordsStyle")); grChildNode ; - grChildNode = grChildNode->NextSibling("WordsStyle")) + grChildNode = grChildNode->NextSibling(TEXT("WordsStyle"))) { TiXmlElement *grElement = grChildNode->ToElement(); - const char *styleName = grElement->Attribute("name"); + const TCHAR *styleName = grElement->Attribute(TEXT("name")); int i = pLs->getStylerIndexByName(styleName); if (i != -1) @@ -4042,14 +4042,14 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g _pXmlExternalLexerDoc[x]->SaveFile(); } - TiXmlNode *globalStylesRoot = (_pXmlUserStylerDoc->FirstChild("NotepadPlus"))->FirstChildElement("GlobalStyles"); + TiXmlNode *globalStylesRoot = (_pXmlUserStylerDoc->FirstChild(TEXT("NotepadPlus")))->FirstChildElement(TEXT("GlobalStyles")); - for (TiXmlNode *childNode = globalStylesRoot->FirstChildElement("WidgetStyle"); + for (TiXmlNode *childNode = globalStylesRoot->FirstChildElement(TEXT("WidgetStyle")); childNode ; - childNode = childNode->NextSibling("WidgetStyle")) + childNode = childNode->NextSibling(TEXT("WidgetStyle"))) { TiXmlElement *pElement = childNode->ToElement(); - const char *styleName = pElement->Attribute("name"); + const TCHAR *styleName = pElement->Attribute(TEXT("name")); int i = _widgetStyleArray.getStylerIndexByName(styleName); if (i != -1) @@ -4066,50 +4066,50 @@ void NppParameters::writeStyles(LexerStylerArray & lexersStylers, StyleArray & g void NppParameters::writeStyle2Element(Style & style2Wite, Style & style2Sync, TiXmlElement *element) { - const char *styleName = element->Attribute("name"); + const TCHAR *styleName = element->Attribute(TEXT("name")); if (HIBYTE(HIWORD(style2Wite._fgColor)) != 0xFF) { int rgbVal = RGB2int(style2Wite._fgColor); - char fgStr[7]; - sprintf(fgStr, "%.6X", rgbVal); - element->SetAttribute("fgColor", fgStr); + TCHAR fgStr[7]; + wsprintf(fgStr, TEXT("%.6X"), rgbVal); + element->SetAttribute(TEXT("fgColor"), fgStr); } if (HIBYTE(HIWORD(style2Wite._bgColor)) != 0xFF) { int rgbVal = RGB2int(style2Wite._bgColor); - char bgStr[7]; - sprintf(bgStr, "%.6X", rgbVal); - element->SetAttribute("bgColor", bgStr); + TCHAR bgStr[7]; + wsprintf(bgStr, TEXT("%.6X"), rgbVal); + element->SetAttribute(TEXT("bgColor"), bgStr); } if (style2Wite._colorStyle != COLORSTYLE_ALL) { - element->SetAttribute("colorStyle", style2Wite._colorStyle); + element->SetAttribute(TEXT("colorStyle"), style2Wite._colorStyle); } if (style2Wite._fontName) { - const char *oldFontName = element->Attribute("fontName"); - if (strcmp(oldFontName, style2Wite._fontName)) + const TCHAR *oldFontName = element->Attribute(TEXT("fontName")); + if (lstrcmp(oldFontName, style2Wite._fontName)) { - element->SetAttribute("fontName", style2Wite._fontName); - style2Sync._fontName = style2Wite._fontName = element->Attribute("fontName"); + element->SetAttribute(TEXT("fontName"), style2Wite._fontName); + style2Sync._fontName = style2Wite._fontName = element->Attribute(TEXT("fontName")); } } if (style2Wite._fontSize != -1) { if (!style2Wite._fontSize) - element->SetAttribute("fontSize", ""); + element->SetAttribute(TEXT("fontSize"), TEXT("")); else - element->SetAttribute("fontSize", style2Wite._fontSize); + element->SetAttribute(TEXT("fontSize"), style2Wite._fontSize); } if (style2Wite._fontStyle != -1) { - element->SetAttribute("fontStyle", style2Wite._fontStyle); + element->SetAttribute(TEXT("fontStyle"), style2Wite._fontStyle); } @@ -4126,88 +4126,88 @@ void NppParameters::writeStyle2Element(Style & style2Wite, Style & style2Sync, T void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *userLang) { - TiXmlElement *rootElement = (node->InsertEndChild(TiXmlElement("UserLang")))->ToElement(); + TiXmlElement *rootElement = (node->InsertEndChild(TiXmlElement(TEXT("UserLang"))))->ToElement(); - rootElement->SetAttribute("name", userLang->_name); - rootElement->SetAttribute("ext", userLang->_ext); - TiXmlElement *settingsElement = (rootElement->InsertEndChild(TiXmlElement("Settings")))->ToElement(); + rootElement->SetAttribute(TEXT("name"), userLang->_name); + rootElement->SetAttribute(TEXT("ext"), userLang->_ext); + TiXmlElement *settingsElement = (rootElement->InsertEndChild(TiXmlElement(TEXT("Settings"))))->ToElement(); { - TiXmlElement *globalElement = (settingsElement->InsertEndChild(TiXmlElement("Global")))->ToElement(); - globalElement->SetAttribute("caseIgnored", userLang->_isCaseIgnored?"yes":"no"); + TiXmlElement *globalElement = (settingsElement->InsertEndChild(TiXmlElement(TEXT("Global"))))->ToElement(); + globalElement->SetAttribute(TEXT("caseIgnored"), userLang->_isCaseIgnored?TEXT("yes"):TEXT("no")); - TiXmlElement *treatAsSymbolElement = (settingsElement->InsertEndChild(TiXmlElement("TreatAsSymbol")))->ToElement(); - treatAsSymbolElement->SetAttribute("comment", userLang->_isCommentSymbol?"yes":"no"); - treatAsSymbolElement->SetAttribute("commentLine", userLang->_isCommentLineSymbol?"yes":"no"); + TiXmlElement *treatAsSymbolElement = (settingsElement->InsertEndChild(TiXmlElement(TEXT("TreatAsSymbol"))))->ToElement(); + treatAsSymbolElement->SetAttribute(TEXT("comment"), userLang->_isCommentSymbol?TEXT("yes"):TEXT("no")); + treatAsSymbolElement->SetAttribute(TEXT("commentLine"), userLang->_isCommentLineSymbol?TEXT("yes"):TEXT("no")); - TiXmlElement *prefixElement = (settingsElement->InsertEndChild(TiXmlElement("Prefix")))->ToElement(); - char names[nbPrefixListAllowed][7] = {"words1","words2","words3","words4"}; + TiXmlElement *prefixElement = (settingsElement->InsertEndChild(TiXmlElement(TEXT("Prefix"))))->ToElement(); + TCHAR names[nbPrefixListAllowed][7] = {TEXT("words1"), TEXT("words2"), TEXT("words3"), TEXT("words4")}; for (int i = 0 ; i < nbPrefixListAllowed ; i++) - prefixElement->SetAttribute(names[i], userLang->_isPrefix[i]?"yes":"no"); + prefixElement->SetAttribute(names[i], userLang->_isPrefix[i]?TEXT("yes"):TEXT("no")); } - TiXmlElement *kwlElement = (rootElement->InsertEndChild(TiXmlElement("KeywordLists")))->ToElement(); + TiXmlElement *kwlElement = (rootElement->InsertEndChild(TiXmlElement(TEXT("KeywordLists"))))->ToElement(); const int nbKWL = 9; - char kwn[nbKWL][16] = {"Delimiters", "Folder+","Folder-","Operators","Comment","Words1","Words2","Words3","Words4"}; + TCHAR kwn[nbKWL][16] = {TEXT("Delimiters"), TEXT("Folder+"), TEXT("Folder-"), TEXT("Operators"), TEXT("Comment"), TEXT("Words1"), TEXT("Words2"), TEXT("Words3"), TEXT("Words4")}; for (int i = 0 ; i < nbKWL ; i++) { - TiXmlElement *kwElement = (kwlElement->InsertEndChild(TiXmlElement("Keywords")))->ToElement(); - kwElement->SetAttribute("name", kwn[i]); + TiXmlElement *kwElement = (kwlElement->InsertEndChild(TiXmlElement(TEXT("Keywords"))))->ToElement(); + kwElement->SetAttribute(TEXT("name"), kwn[i]); kwElement->InsertEndChild(TiXmlText(userLang->_keywordLists[i])); } - TiXmlElement *styleRootElement = (rootElement->InsertEndChild(TiXmlElement("Styles")))->ToElement(); + TiXmlElement *styleRootElement = (rootElement->InsertEndChild(TiXmlElement(TEXT("Styles"))))->ToElement(); for (int i = 0 ; i < userLang->_styleArray.getNbStyler() ; i++) { - TiXmlElement *styleElement = (styleRootElement->InsertEndChild(TiXmlElement("WordsStyle")))->ToElement(); + TiXmlElement *styleElement = (styleRootElement->InsertEndChild(TiXmlElement(TEXT("WordsStyle"))))->ToElement(); Style style2Wite = userLang->_styleArray.getStyler(i); - styleElement->SetAttribute("name", style2Wite._styleDesc); + styleElement->SetAttribute(TEXT("name"), style2Wite._styleDesc); - styleElement->SetAttribute("styleID", style2Wite._styleID); + styleElement->SetAttribute(TEXT("styleID"), style2Wite._styleID); //if (HIBYTE(HIWORD(style2Wite._fgColor)) != 0xFF) { int rgbVal = RGB2int(style2Wite._fgColor); - char fgStr[7]; - sprintf(fgStr, "%.6X", rgbVal); - styleElement->SetAttribute("fgColor", fgStr); + TCHAR fgStr[7]; + wsprintf(fgStr, TEXT("%.6X"), rgbVal); + styleElement->SetAttribute(TEXT("fgColor"), fgStr); } //if (HIBYTE(HIWORD(style2Wite._bgColor)) != 0xFF) { int rgbVal = RGB2int(style2Wite._bgColor); - char bgStr[7]; - sprintf(bgStr, "%.6X", rgbVal); - styleElement->SetAttribute("bgColor", bgStr); + TCHAR bgStr[7]; + wsprintf(bgStr, TEXT("%.6X"), rgbVal); + styleElement->SetAttribute(TEXT("bgColor"), bgStr); } if (style2Wite._colorStyle != COLORSTYLE_ALL) { - styleElement->SetAttribute("colorStyle", style2Wite._colorStyle); + styleElement->SetAttribute(TEXT("colorStyle"), style2Wite._colorStyle); } if (style2Wite._fontName) { - styleElement->SetAttribute("fontName", style2Wite._fontName); + styleElement->SetAttribute(TEXT("fontName"), style2Wite._fontName); } if (style2Wite._fontStyle == -1) { - styleElement->SetAttribute("fontStyle", "0"); + styleElement->SetAttribute(TEXT("fontStyle"), TEXT("0")); } else { - styleElement->SetAttribute("fontStyle", style2Wite._fontStyle); + styleElement->SetAttribute(TEXT("fontStyle"), style2Wite._fontStyle); } if (style2Wite._fontSize != -1) { if (!style2Wite._fontSize) - styleElement->SetAttribute("fontSize", ""); + styleElement->SetAttribute(TEXT("fontSize"), TEXT("")); else - styleElement->SetAttribute("fontSize", style2Wite._fontSize); + styleElement->SetAttribute(TEXT("fontSize"), style2Wite._fontSize); } } } @@ -4223,16 +4223,16 @@ void NppParameters::stylerStrOp(bool op) if (op == DUP) { - char *str = new char[strlen(style._styleDesc) + 1]; - style._styleDesc = strcpy(str, style._styleDesc); + TCHAR *str = new TCHAR[lstrlen(style._styleDesc) + 1]; + style._styleDesc = lstrcpy(str, style._styleDesc); if (style._fontName) { - str = new char[strlen(style._fontName) + 1]; - style._fontName = strcpy(str, style._fontName); + str = new TCHAR[lstrlen(style._fontName) + 1]; + style._fontName = lstrcpy(str, style._fontName); } else { - str = new char[2]; + str = new TCHAR[2]; str[0] = str[1] = '\0'; style._fontName = str; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e4f8bba6..508646b6 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -28,7 +28,7 @@ #include "colors.h" #include "shortcut.h" #include "ContextMenu.h" -//#include "Buffer.h" +#include "SysMsg.h" using namespace std; @@ -71,18 +71,20 @@ const int LANG_INDEX_TYPE4 = 5; const int LANG_INDEX_TYPE5 = 6; const int COPYDATA_PARAMS = 0; -const int COPYDATA_FILENAMES = 1; +const int COPYDATA_FILENAMESA = 1; +const int COPYDATA_FILENAMESW = 2; + const bool SCIV_PRIMARY = false; const bool SCIV_SECOND = true; -const char fontSizeStrs[][3] = {"", "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28"}; +const TCHAR fontSizeStrs[][3] = {TEXT(""), TEXT("8"), TEXT("9"), TEXT("10"), TEXT("11"), TEXT("12"), TEXT("14"), TEXT("16"), TEXT("18"), TEXT("20"), TEXT("22"), TEXT("24"), TEXT("26"), TEXT("28")}; -#define LINEDRAW_FONT "LINEDRAW.TTF" -const char localConfFile[] = "doLocalConf.xml"; -const char notepadStyleFile[] = "asNotepad.xml"; +const TCHAR LINEDRAW_FONT[] = TEXT("LINEDRAW.TTF"); +const TCHAR localConfFile[] = TEXT("doLocalConf.xml"); +const TCHAR notepadStyleFile[] = TEXT("asNotepad.xml"); -void cutString(const char *str2cut, vector & patternVect); +void cutString(const TCHAR *str2cut, vector> & patternVect); /* struct HeaderLineState { HeaderLineState() : _headerLineNumber(0), _isCollapsed(false){}; @@ -103,19 +105,19 @@ struct Position }; struct sessionFileInfo : public Position { - sessionFileInfo(const char *fn) { + sessionFileInfo(const TCHAR *fn) { if (fn) _fileName = fn; }; - sessionFileInfo(const char *fn, const char *ln, Position pos) : Position(pos) { + sessionFileInfo(const TCHAR *fn, const TCHAR *ln, Position pos) : Position(pos) { if (fn) _fileName = fn; if (ln) _langName = ln; }; - sessionFileInfo(string fn) : _fileName(fn){}; - sessionFileInfo(string fn, Position pos) : Position(pos), _fileName(fn){}; + sessionFileInfo(basic_string fn) : _fileName(fn){}; + sessionFileInfo(basic_string fn, Position pos) : Position(pos), _fileName(fn){}; - string _fileName; - string _langName; + basic_string _fileName; + basic_string _langName; vector marks; }; @@ -152,19 +154,19 @@ struct FloatingWindowInfo { }; struct PlugingDlgDockingInfo { - char _name[MAX_PATH]; + TCHAR _name[MAX_PATH]; int _internalID; int _currContainer; int _prevContainer; bool _isVisible; - PlugingDlgDockingInfo(const char *pluginName, int id, int curr, int prev, bool isVis) : _internalID(id), _currContainer(curr), _prevContainer(prev), _isVisible(isVis){ - strcpy(_name, pluginName); + PlugingDlgDockingInfo(const TCHAR *pluginName, int id, int curr, int prev, bool isVis) : _internalID(id), _currContainer(curr), _prevContainer(prev), _isVisible(isVis){ + lstrcpy(_name, pluginName); }; friend inline const bool operator==(const PlugingDlgDockingInfo & a, const PlugingDlgDockingInfo & b) { - if ((strcmp(a._name, b._name) == 0) && (a._internalID == b._internalID)) + if ((lstrcmp(a._name, b._name) == 0) && (a._internalID == b._internalID)) return true; else return false; @@ -200,34 +202,34 @@ struct DockingManagerData { } }; -static int strVal(const char *str, int base) { +static int strVal(const TCHAR *str, int base) { if (!str) return -1; if (!str[0]) return 0; - char *finStr; - int result = strtol(str, &finStr, base); + TCHAR *finStr; + int result = generic_strtol(str, &finStr, base); if (*finStr != '\0') return -1; return result; }; -static int decStrVal(const char *str) { +static int decStrVal(const TCHAR *str) { return strVal(str, 10); }; -static int hexStrVal(const char *str) { +static int hexStrVal(const TCHAR *str) { return strVal(str, 16); }; -static int getKwClassFromName(const char *str) { - if (!strcmp("instre1", str)) return LANG_INDEX_INSTR; - if (!strcmp("instre2", str)) return LANG_INDEX_INSTR2; - if (!strcmp("type1", str)) return LANG_INDEX_TYPE; - if (!strcmp("type2", str)) return LANG_INDEX_TYPE2; - if (!strcmp("type3", str)) return LANG_INDEX_TYPE3; - if (!strcmp("type4", str)) return LANG_INDEX_TYPE4; - if (!strcmp("type5", str)) return LANG_INDEX_TYPE5; +static int getKwClassFromName(const TCHAR *str) { + if (!lstrcmp(TEXT("instre1"), str)) return LANG_INDEX_INSTR; + if (!lstrcmp(TEXT("instre2"), str)) return LANG_INDEX_INSTR2; + if (!lstrcmp(TEXT("type1"), str)) return LANG_INDEX_TYPE; + if (!lstrcmp(TEXT("type2"), str)) return LANG_INDEX_TYPE2; + if (!lstrcmp(TEXT("type3"), str)) return LANG_INDEX_TYPE3; + if (!lstrcmp(TEXT("type4"), str)) return LANG_INDEX_TYPE4; + if (!lstrcmp(TEXT("type5"), str)) return LANG_INDEX_TYPE5; if ((str[1] == '\0') && (str[0] >= '0') && (str[0] <= '8')) // up to KEYWORDSET_MAX return str[0] - '0'; @@ -246,17 +248,17 @@ const int COLORSTYLE_ALL = COLORSTYLE_FOREGROUND|COLORSTYLE_BACKGROUND; struct Style { int _styleID; - const char *_styleDesc; + const TCHAR *_styleDesc; COLORREF _fgColor; COLORREF _bgColor; int _colorStyle; - const char *_fontName; + const TCHAR *_fontName; int _fontStyle; int _fontSize; int _keywordClass; - string *_keywords; + basic_string *_keywords; Style():_styleID(-1), _fgColor(COLORREF(-1)), _bgColor(COLORREF(-1)), _colorStyle(COLORSTYLE_ALL), _fontName(NULL), _fontStyle(-1), _fontSize(-1), _keywordClass(-1), _keywords(NULL){}; @@ -277,7 +279,7 @@ struct Style _fontStyle = style._fontStyle; _keywordClass = style._keywordClass; if (style._keywords) - _keywords = new string(*(style._keywords)); + _keywords = new basic_string(*(style._keywords)); else _keywords = NULL; }; @@ -296,7 +298,7 @@ struct Style this->_keywordClass = style._keywordClass; if (!(this->_keywords) && style._keywords) - this->_keywords = new string(*(style._keywords)); + this->_keywords = new basic_string(*(style._keywords)); else if (this->_keywords && style._keywords) this->_keywords->assign(*(style._keywords)); else if (this->_keywords && !(style._keywords)) @@ -308,9 +310,9 @@ struct Style return *this; }; - void setKeywords(const char *str) { + void setKeywords(const TCHAR *str) { if (!_keywords) - _keywords = new string(str); + _keywords = new basic_string(str); else *_keywords = str; }; @@ -357,7 +359,7 @@ public: bool hasEnoughSpace() {return (_nbStyler < MAX_STYLE);}; void addStyler(int styleID, TiXmlNode *styleNode); - void addStyler(int styleID, char *styleName) { + void addStyler(int styleID, TCHAR *styleName) { //ZeroMemory(&_styleArray[_nbStyler], sizeof(Style));; _styleArray[_nbStyler]._styleID = styleID; _styleArray[_nbStyler]._styleDesc = styleName; @@ -373,11 +375,11 @@ public: return -1; }; - int getStylerIndexByName(const char *name) const { + int getStylerIndexByName(const TCHAR *name) const { if (!name) return -1; for (int i = 0 ; i < _nbStyler ; i++) - if (!strcmp(_styleArray[i]._styleDesc, name)) + if (!lstrcmp(_styleArray[i]._styleDesc, name)) return i; return -1; }; @@ -397,33 +399,33 @@ public : if (this != &ls) { *((StyleArray *)this) = ls; - strcpy(this->_lexerName, ls._lexerName); - strcpy(this->_lexerDesc, ls._lexerDesc); - strcpy(this->_lexerUserExt, ls._lexerUserExt); + lstrcpy(this->_lexerName, ls._lexerName); + lstrcpy(this->_lexerDesc, ls._lexerDesc); + lstrcpy(this->_lexerUserExt, ls._lexerUserExt); } return *this; } - void setLexerName(const char *lexerName) { - strcpy(_lexerName, lexerName); + void setLexerName(const TCHAR *lexerName) { + lstrcpy(_lexerName, lexerName); }; - void setLexerDesc(const char *lexerDesc) { - strcpy(_lexerDesc, lexerDesc); + void setLexerDesc(const TCHAR *lexerDesc) { + lstrcpy(_lexerDesc, lexerDesc); }; - void setLexerUserExt(const char *lexerUserExt) { - strcpy(_lexerUserExt, lexerUserExt); + void setLexerUserExt(const TCHAR *lexerUserExt) { + lstrcpy(_lexerUserExt, lexerUserExt); }; - const char * getLexerName() const {return _lexerName;}; - const char * getLexerDesc() const {return _lexerDesc;}; - const char * getLexerUserExt() const {return _lexerUserExt;}; + const TCHAR * getLexerName() const {return _lexerName;}; + const TCHAR * getLexerDesc() const {return _lexerDesc;}; + const TCHAR * getLexerUserExt() const {return _lexerUserExt;}; private : - char _lexerName[16]; - char _lexerDesc[32]; - char _lexerUserExt[256]; + TCHAR _lexerName[16]; + TCHAR _lexerDesc[32]; + TCHAR _lexerUserExt[256]; }; const int MAX_LEXER_STYLE = 80; @@ -451,20 +453,20 @@ public : return _lexerStylerArray[index]; }; - const char * getLexerNameFromIndex(int index) const {return _lexerStylerArray[index].getLexerName();} - const char * getLexerDescFromIndex(int index) const {return _lexerStylerArray[index].getLexerDesc();} + const TCHAR * getLexerNameFromIndex(int index) const {return _lexerStylerArray[index].getLexerName();} + const TCHAR * getLexerDescFromIndex(int index) const {return _lexerStylerArray[index].getLexerDesc();} - LexerStyler * getLexerStylerByName(const char *lexerName) { + LexerStyler * getLexerStylerByName(const TCHAR *lexerName) { if (!lexerName) return NULL; for (int i = 0 ; i < _nbLexerStyler ; i++) { - if (!strcmp(_lexerStylerArray[i].getLexerName(), lexerName)) + if (!lstrcmp(_lexerStylerArray[i].getLexerName(), lexerName)) return &(_lexerStylerArray[i]); } return NULL; }; bool hasEnoughSpace() {return (_nbLexerStyler < MAX_LEXER_STYLE);}; - void addLexerStyler(const char *lexerName, const char *lexerDesc, const char *lexerUserExt, TiXmlNode *lexerNode); + void addLexerStyler(const TCHAR *lexerName, const TCHAR *lexerDesc, const TCHAR *lexerUserExt, TiXmlNode *lexerNode); private : LexerStyler _lexerStylerArray[MAX_LEXER_STYLE]; @@ -482,9 +484,9 @@ struct NewDocDefaultSettings struct LangMenuItem { LangType _langType; int _cmdID; - string _langName; + basic_string _langName; - LangMenuItem(LangType lt, int cmdID = 0, string langName = ""): + LangMenuItem(LangType lt, int cmdID = 0, basic_string langName = TEXT("")): _langType(lt), _cmdID(cmdID), _langName(langName){}; }; @@ -492,34 +494,34 @@ struct PrintSettings { bool _printLineNumber; int _printOption; - string _headerLeft; - string _headerMiddle; - string _headerRight; - string _headerFontName; + basic_string _headerLeft; + basic_string _headerMiddle; + basic_string _headerRight; + basic_string _headerFontName; int _headerFontStyle; int _headerFontSize; - string _footerLeft; - string _footerMiddle; - string _footerRight; - string _footerFontName; + basic_string _footerLeft; + basic_string _footerMiddle; + basic_string _footerRight; + basic_string _footerFontName; int _footerFontStyle; int _footerFontSize; RECT _marge; - PrintSettings() : _printLineNumber(true), _printOption(SC_PRINT_NORMAL), _headerLeft(""), _headerMiddle(""), _headerRight(""),\ - _headerFontName(""), _headerFontStyle(0), _headerFontSize(0), _footerLeft(""), _footerMiddle(""), _footerRight(""),\ - _footerFontName(""), _footerFontStyle(0), _footerFontSize(0) { + PrintSettings() : _printLineNumber(true), _printOption(SC_PRINT_NORMAL), _headerLeft(TEXT("")), _headerMiddle(TEXT("")), _headerRight(TEXT("")),\ + _headerFontName(TEXT("")), _headerFontStyle(0), _headerFontSize(0), _footerLeft(TEXT("")), _footerMiddle(TEXT("")), _footerRight(TEXT("")),\ + _footerFontName(TEXT("")), _footerFontStyle(0), _footerFontSize(0) { _marge.left = 0; _marge.top = 0; _marge.right = 0; _marge.bottom = 0; }; bool isHeaderPresent() const { - return ((_headerLeft != "") || (_headerMiddle != "") || (_headerRight != "")); + return ((_headerLeft != TEXT("")) || (_headerMiddle != TEXT("")) || (_headerRight != TEXT(""))); }; bool isFooterPresent() const { - return ((_footerLeft != "") || (_footerMiddle != "") || (_footerRight != "")); + return ((_footerLeft != TEXT("")) || (_footerMiddle != TEXT("")) || (_footerRight != TEXT(""))); }; bool isUserMargePresent() const { @@ -535,7 +537,7 @@ struct NppGUI _checkHistoryFiles(true) ,_enableSmartHilite(true), _enableTagsMatchHilite(true), _enableTagAttrsHilite(true),\ _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ _doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0),\ - _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(""), _neverUpdate(false),\ + _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")), _neverUpdate(false),\ _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1){ _appPos.left = 0; _appPos.top = 0; @@ -594,7 +596,7 @@ struct NppGUI PrintSettings _printSettings; BackupFeature _backup; bool _useDir; - char _backupDir[MAX_PATH]; + TCHAR _backupDir[MAX_PATH]; DockingManagerData _dockingData; GlobalOverride _globalOverride; enum AutocStatus{autoc_none, autoc_func, autoc_word}; @@ -602,7 +604,7 @@ struct NppGUI size_t _autocFromLen; bool _funcParams; - string _definedSessionExt; + basic_string _definedSessionExt; bool _neverUpdate; bool _doesExistUpdater; int _caretBlinkRate; @@ -617,7 +619,7 @@ struct ScintillaViewParams _zoom(0), _whiteSpaceShow(false), _eolShow(false){}; bool _lineNumberMarginShow; bool _bookMarkMarginShow; - folderStyle _folderStyle; //"simple", "arrow", "circle" and "box" + folderStyle _folderStyle; //"simple", TEXT("arrow"), TEXT("circle") and "box" bool _indentGuideLineShow; bool _currentLineHilitingShow; bool _wrapSymbolShow; @@ -639,51 +641,51 @@ const int LANG_NAME_LEN = 32; struct Lang { LangType _langID; - char _langName[LANG_NAME_LEN]; - const char *_defaultExtList; - const char *_langKeyWordList[NB_LIST]; - const char *_pCommentLineSymbol; - const char *_pCommentStart; - const char *_pCommentEnd; + TCHAR _langName[LANG_NAME_LEN]; + const TCHAR *_defaultExtList; + const TCHAR *_langKeyWordList[NB_LIST]; + const TCHAR *_pCommentLineSymbol; + const TCHAR *_pCommentStart; + const TCHAR *_pCommentEnd; Lang() {for (int i = 0 ; i < NB_LIST ; _langKeyWordList[i] = NULL ,i++);}; - Lang(LangType langID, const char *name) : _langID(langID){ + Lang(LangType langID, const TCHAR *name) : _langID(langID){ _langName[0] = '\0'; if (name) - strcpy(_langName, name); + lstrcpy(_langName, name); for (int i = 0 ; i < NB_LIST ; _langKeyWordList[i] = NULL ,i++); }; ~Lang() {}; - void setDefaultExtList(const char *extLst){ + void setDefaultExtList(const TCHAR *extLst){ _defaultExtList = extLst; }; - void setCommentLineSymbol(const char *commentLine){ + void setCommentLineSymbol(const TCHAR *commentLine){ _pCommentLineSymbol = commentLine; }; - void setCommentStart(const char *commentStart){ + void setCommentStart(const TCHAR *commentStart){ _pCommentStart = commentStart; }; - void setCommentEnd(const char *commentEnd){ + void setCommentEnd(const TCHAR *commentEnd){ _pCommentEnd = commentEnd; }; - const char * getDefaultExtList() const { + const TCHAR * getDefaultExtList() const { return _defaultExtList; }; - void setWords(const char *words, int index) { + void setWords(const TCHAR *words, int index) { _langKeyWordList[index] = words; }; - const char * getWords(int index) const { + const TCHAR * getWords(int index) const { return _langKeyWordList[index]; }; LangType getLangID() const {return _langID;}; - const char * getLangName() const {return _langName;}; + const TCHAR * getLangName() const {return _langName;}; }; class UserLangContainer @@ -701,26 +703,26 @@ friend class UserDefineDialog; public : UserLangContainer(){ - strcpy(_name, "new user define"); + lstrcpy(_name, TEXT("new user define")); _ext[0] = '\0'; // Keywords list of Delimiters (index 0) - strcpy(_keywordLists[0], "000000"); + lstrcpy(_keywordLists[0], TEXT("000000")); for (int i = 1 ; i < nbKeywodList ; i++) *_keywordLists[i] = '\0'; }; - UserLangContainer(const char *name, const char *ext){ + UserLangContainer(const TCHAR *name, const TCHAR *ext){ //si le nom est trop long, on le tranche! - int minSize = ((sizeof(_name) - 1) < strlen(name))?(sizeof(_name) - 1):strlen(name); + int minSize = ((sizeof(_name) - 1) < lstrlen(name))?(sizeof(_name) - 1):lstrlen(name); int i = 0; for ( ; i < minSize ; i++) _name[i] = name[i]; _name[i] = '\0'; - strcpy(_ext, ext); + lstrcpy(_ext, ext); // Keywords list of Delimiters (index 0) - strcpy(_keywordLists[0], "000000"); + lstrcpy(_keywordLists[0], TEXT("000000")); for (int j = 1 ; j < nbKeywodList ; j++) *_keywordLists[j] = '\0'; }; @@ -728,8 +730,8 @@ public : UserLangContainer & operator=(const UserLangContainer & ulc) { if (this != &ulc) { - strcpy(this->_name, ulc._name); - strcpy(this->_ext, ulc._ext); + lstrcpy(this->_name, ulc._name); + lstrcpy(this->_ext, ulc._ext); this->_isCaseIgnored = ulc._isCaseIgnored; this->_styleArray = ulc._styleArray; int nbStyler = this->_styleArray.getNbStyler(); @@ -742,20 +744,20 @@ public : st._fgColor = black; } for (int i = 0 ; i < nbKeywodList ; i++) - strcpy(this->_keywordLists[i], ulc._keywordLists[i]); + lstrcpy(this->_keywordLists[i], ulc._keywordLists[i]); } return *this; }; int getNbKeywordList() {return nbKeywodList;}; - char * getName() {return _name;}; + TCHAR * getName() {return _name;}; private: - char _name[langNameLenMax]; - char _ext[extsLenMax]; + TCHAR _name[langNameLenMax]; + TCHAR _ext[extsLenMax]; StyleArray _styleArray; - char _keywordLists[nbKeywodList][max_char]; + TCHAR _keywordLists[nbKeywodList][max_char]; bool _isCaseIgnored; bool _isCommentLineSymbol; @@ -769,12 +771,12 @@ private: class ExternalLangContainer { public: - char _name[MAX_EXTERNAL_LEXER_NAME_LEN]; - char _desc[MAX_EXTERNAL_LEXER_DESC_LEN]; + TCHAR _name[MAX_EXTERNAL_LEXER_NAME_LEN]; + TCHAR _desc[MAX_EXTERNAL_LEXER_DESC_LEN]; - ExternalLangContainer(const char *name, const char *desc) { - strncpy(_name, name, MAX_EXTERNAL_LEXER_NAME_LEN); - strncpy(_desc, desc, MAX_EXTERNAL_LEXER_DESC_LEN); + ExternalLangContainer(const TCHAR *name, const TCHAR *desc) { + generic_strncpy(_name, name, MAX_EXTERNAL_LEXER_NAME_LEN); + generic_strncpy(_desc, desc, MAX_EXTERNAL_LEXER_DESC_LEN); }; }; @@ -787,7 +789,7 @@ class NppParameters { public: static NppParameters * getInstance() {return _pSelf;}; - static LangType getLangIDFromStr(const char *langName); + static LangType getLangIDFromStr(const TCHAR *langName); bool load(/*bool noUserPath = false*/); void destroyInstance(); @@ -798,7 +800,7 @@ public: return _nppGUI; }; - const char * getWordList(LangType langID, int typeIndex) const { + const TCHAR * getWordList(LangType langID, int typeIndex) const { Lang *pLang = getLangFromID(langID); if (!pLang) return NULL; @@ -821,16 +823,16 @@ public: int getNbLang() const {return _nbLang;}; - const char * getLangExtFromName(const char *langName) const { + const TCHAR * getLangExtFromName(const TCHAR *langName) const { for (int i = 0 ; i < _nbLang ; i++) { - if (!strcmp(_langList[i]->_langName, langName)) + if (!lstrcmp(_langList[i]->_langName, langName)) return _langList[i]->_defaultExtList; } return NULL; }; - const char * getLangExtFromLangType(LangType langType) const { + const TCHAR * getLangExtFromLangType(LangType langType) const { for (int i = 0 ; i < _nbLang ; i++) { if (_langList[i]->_langID == langType) @@ -841,7 +843,7 @@ public: int getNbLRFile() const {return _nbFile;}; - string *getLRFile(int index) const { + basic_string *getLRFile(int index) const { return _LRFileList[index]; }; @@ -858,20 +860,20 @@ public: bool writeNbHistoryFile(int nb) { if (!_pXmlUserDoc) return false; - TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild("NotepadPlus"); + TiXmlNode *nppRoot = _pXmlUserDoc->FirstChild(TEXT("NotepadPlus")); if (!nppRoot) return false; - TiXmlNode *historyNode = nppRoot->FirstChildElement("History"); + TiXmlNode *historyNode = nppRoot->FirstChildElement(TEXT("History")); if (!historyNode) return false; - (historyNode->ToElement())->SetAttribute("nbMaxFile", nb); + (historyNode->ToElement())->SetAttribute(TEXT("nbMaxFile"), nb); return true; }; - bool writeHistory(const char *fullpath); + bool writeHistory(const TCHAR *fullpath); - TiXmlNode * getChildElementByAttribut(TiXmlNode *pere, const char *childName,\ - const char *attributName, const char *attributVal) const; + TiXmlNode * getChildElementByAttribut(TiXmlNode *pere, const TCHAR *childName,\ + const TCHAR *attributName, const TCHAR *attributVal) const; bool writeScintillaParams(const ScintillaViewParams & svp, bool whichOne); @@ -886,36 +888,36 @@ public: GlobalOverride & getGlobalOverrideStyle() {return _nppGUI._globalOverride;}; COLORREF getCurLineHilitingColour() { - int i = _widgetStyleArray.getStylerIndexByName("Current line background colour"); + int i = _widgetStyleArray.getStylerIndexByName(TEXT("Current line background colour")); if (i == -1) return i; Style & style = _widgetStyleArray.getStyler(i); return style._bgColor; }; void setCurLineHilitingColour(COLORREF colour2Set) { - int i = _widgetStyleArray.getStylerIndexByName("Current line background colour"); + int i = _widgetStyleArray.getStylerIndexByName(TEXT("Current line background colour")); if (i == -1) return; Style & style = _widgetStyleArray.getStyler(i); style._bgColor = colour2Set; }; void setFontList(HWND hWnd); - const vector & getFontList() const {return _fontlist;}; + const vector> & getFontList() const {return _fontlist;}; int getNbUserLang() const {return _nbUserLang;}; UserLangContainer & getULCFromIndex(int i) {return *_userLangArray[i];}; - UserLangContainer * getULCFromName(const char *userLangName) { + UserLangContainer * getULCFromName(const TCHAR *userLangName) { for (int i = 0 ; i < _nbUserLang ; i++) - if (!strcmp(userLangName, _userLangArray[i]->_name)) + if (!lstrcmp(userLangName, _userLangArray[i]->_name)) return _userLangArray[i]; //qui doit etre jamais passer return NULL; }; int getNbExternalLang() const {return _nbExternalLang;}; - int getExternalLangIndexFromName(const char *externalLangName) const { + int getExternalLangIndexFromName(const TCHAR *externalLangName) const { for (int i = 0 ; i < _nbExternalLang ; i++) { - if (!strcmp(externalLangName, _externalLangArray[i]->_name)) + if (!lstrcmp(externalLangName, _externalLangArray[i]->_name)) return i; } return -1; @@ -929,46 +931,46 @@ public: void writeUserDefinedLang(); void writeShortcuts(); - void writeSession(const Session & session, const char *fileName = NULL); + void writeSession(const Session & session, const TCHAR *fileName = NULL); - bool isExistingUserLangName(const char *newName) const { + bool isExistingUserLangName(const TCHAR *newName) const { if ((!newName) || (!newName[0])) return true; for (int i = 0 ; i < _nbUserLang ; i++) { - if (!strcmp(_userLangArray[i]->_name, newName)) + if (!lstrcmp(_userLangArray[i]->_name, newName)) return true; } return false; }; - const char * getUserDefinedLangNameFromExt(char *ext) { + const TCHAR * getUserDefinedLangNameFromExt(TCHAR *ext) { if ((!ext) || (!ext[0])) return NULL; for (int i = 0 ; i < _nbUserLang ; i++) { - vector extVect; + vector> extVect; cutString(_userLangArray[i]->_ext, extVect); for (size_t j = 0 ; j < extVect.size() ; j++) - if (!stricmp(extVect[j].c_str(), ext)) + if (!generic_stricmp(extVect[j].c_str(), ext)) return _userLangArray[i]->_name; } return NULL; }; - int addUserLangToEnd(const UserLangContainer & userLang, const char *newName); + int addUserLangToEnd(const UserLangContainer & userLang, const TCHAR *newName); void removeUserLang(int index); - bool isExistingExternalLangName(const char *newName) const { + bool isExistingExternalLangName(const TCHAR *newName) const { if ((!newName) || (!newName[0])) return true; for (int i = 0 ; i < _nbExternalLang ; i++) { - if (!strcmp(_externalLangArray[i]->_name, newName)) + if (!lstrcmp(_externalLangArray[i]->_name, newName)) return true; } return false; @@ -1028,53 +1030,53 @@ public: void setScintillaAccelerator(ScintillaAccelerator *pScintAccel) {_pScintAccelerator = pScintAccel;}; ScintillaAccelerator * getScintillaAccelerator() {return _pScintAccelerator;}; - const char * getNppPath() const {return _nppPath;}; - const char * getAppDataNppDir() const {return _appdataNppDir;}; + const TCHAR * getNppPath() const {return _nppPath;}; + const TCHAR * getAppDataNppDir() const {return _appdataNppDir;}; - bool loadSession(Session & session, const char *sessionFileName); + bool loadSession(Session & session, const TCHAR *sessionFileName); int langTypeToCommandID(LangType lt) const; WNDPROC getEnableThemeDlgTexture() const {return _enableThemeDialogTextureFuncAddr;}; struct FindDlgTabTitiles { - string _find; - string _replace; - string _findInFiles; - FindDlgTabTitiles() : _find(""), _replace(""), _findInFiles("") {}; + basic_string _find; + basic_string _replace; + basic_string _findInFiles; + FindDlgTabTitiles() : _find(TEXT("")), _replace(TEXT("")), _findInFiles(TEXT("")) {}; bool isWellFilled() { - return (strcmp(_find.c_str(), "") != 0 && strcmp(_replace.c_str(), "") && strcmp(_findInFiles.c_str(), "")); + return (lstrcmp(_find.c_str(), TEXT("")) != 0 && lstrcmp(_replace.c_str(), TEXT("")) && lstrcmp(_findInFiles.c_str(), TEXT(""))); }; }; FindDlgTabTitiles & getFindDlgTabTitiles() { return _findDlgTabTitiles;}; - const char * getNativeLangMenuString(int itemID) { + const TCHAR * getNativeLangMenuString(int itemID) { if (!_pXmlNativeLangDoc) return NULL; - TiXmlNode * node = _pXmlNativeLangDoc->FirstChild("NotepadPlus"); + TiXmlNode * node = _pXmlNativeLangDoc->FirstChild(TEXT("NotepadPlus")); if (!node) return NULL; - node = node->FirstChild("Native-Langue"); + node = node->FirstChild(TEXT("Native-Langue")); if (!node) return NULL; - node = node->FirstChild("Menu"); + node = node->FirstChild(TEXT("Menu")); if (!node) return NULL; - node = node->FirstChild("Main"); + node = node->FirstChild(TEXT("Main")); if (!node) return NULL; - node = node->FirstChild("Commands"); + node = node->FirstChild(TEXT("Commands")); if (!node) return NULL; - for (TiXmlNode *childNode = node->FirstChildElement("Item"); + for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - if (element->Attribute("id", &id) && (id == itemID)) + if (element->Attribute(TEXT("id"), &id) && (id == itemID)) { - return element->Attribute("name"); + return element->Attribute(TEXT("name")); } } @@ -1105,13 +1107,13 @@ private: Lang *_langList[NB_LANG]; int _nbLang; - string *_LRFileList[NB_MAX_LRF_FILE]; + basic_string *_LRFileList[NB_MAX_LRF_FILE]; int _nbFile; int _nbMaxFile; UserLangContainer *_userLangArray[NB_MAX_USER_LANG]; int _nbUserLang; - char _userDefineLangPath[MAX_PATH]; + TCHAR _userDefineLangPath[MAX_PATH]; ExternalLangContainer *_externalLangArray[NB_MAX_EXTERNAL_LANG]; int _nbExternalLang; @@ -1123,7 +1125,7 @@ private: LexerStylerArray _lexerStylerArray; StyleArray _widgetStyleArray; - vector _fontlist; + vector> _fontlist; HMODULE _hUser32; HMODULE _hUXTheme; @@ -1143,15 +1145,15 @@ private: vector _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations - //vector _noMenuCmdNames; + //vector> _noMenuCmdNames; vector _contextMenuItems; Session _session; - char _shortcutsPath[MAX_PATH]; - char _contextMenuPath[MAX_PATH]; - char _sessionPath[MAX_PATH]; - char _nppPath[MAX_PATH]; - char _appdataNppDir[MAX_PATH]; // sentinel of the absence of "doLocalConf.xml" : (_appdataNppDir == "")?"doLocalConf.xml present":"doLocalConf.xml absent" + TCHAR _shortcutsPath[MAX_PATH]; + TCHAR _contextMenuPath[MAX_PATH]; + TCHAR _sessionPath[MAX_PATH]; + TCHAR _nppPath[MAX_PATH]; + TCHAR _appdataNppDir[MAX_PATH]; // sentinel of the absence of "doLocalConf.xml" : (_appdataNppDir == TEXT(""))?"doLocalConf.xml present":"doLocalConf.xml absent" Accelerator *_pAccelerator; ScintillaAccelerator * _pScintAccelerator; @@ -1162,18 +1164,18 @@ private: winVer _winVersion; static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam) { - vector *pStrVect = (vector *)lParam; + vector> *pStrVect = (vector> *)lParam; size_t vectSize = pStrVect->size(); //Search through all the fonts, EnumFontFamiliesEx never states anything about order //Start at the end though, that's the most likely place to find a duplicate for(int i = vectSize - 1 ; i >= 0 ; i--) { - if ( !strcmp((*pStrVect)[i].c_str(), (const char *)lpelfe->elfLogFont.lfFaceName) ) + if ( !lstrcmp((*pStrVect)[i].c_str(), (const TCHAR *)lpelfe->elfLogFont.lfFaceName) ) return 1; //we already have seen this typeface, ignore it } //We can add the font //Add the face name and not the full name, we do not care about any styles - pStrVect->push_back((char *)lpelfe->elfLogFont.lfFaceName); + pStrVect->push_back((TCHAR *)lpelfe->elfLogFont.lfFaceName); return 1; // I want to get all fonts }; @@ -1196,10 +1198,10 @@ private: void feedDockingManager(TiXmlNode *node); bool feedStylerArray(TiXmlNode *node); - void getAllWordStyles(char *lexerName, TiXmlNode *lexerNode); + void getAllWordStyles(TCHAR *lexerName, TiXmlNode *lexerNode); void feedUserLang(TiXmlNode *node); - int getIndexFromKeywordListName(const char *name); + int getIndexFromKeywordListName(const TCHAR *name); void feedUserStyles(TiXmlNode *node); void feedUserKeywordList(TiXmlNode *node); void feedUserSettings(TiXmlNode *node); @@ -1221,7 +1223,7 @@ private: void insertScintKey(TiXmlNode *scintKeyRoot, const ScintillaKeyMap & scintKeyMap); void insertPluginCmd(TiXmlNode *pluginCmdRoot, const PluginCmdShortcut & pluginCmd); void stylerStrOp(bool op); - TiXmlElement * insertGUIConfigBoolNode(TiXmlNode *r2w, const char *name, bool bVal); + TiXmlElement * insertGUIConfigBoolNode(TiXmlNode *r2w, const TCHAR *name, bool bVal); void insertDockingParamNode(TiXmlNode *GUIRoot); void writeExcludedLangList(TiXmlElement *element); void writePrintSetting(TiXmlElement *element); diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index d245b7b6..f40b9ac0 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -19,7 +19,7 @@ #include "Notepad_plus_msgs.h" #include -static bool isInList(string word, const vector & wordArray) +static bool isInList(basic_string word, const vector> & wordArray) { for (size_t i = 0 ; i < wordArray.size() ; i++) if (wordArray[i] == word) @@ -28,8 +28,8 @@ static bool isInList(string word, const vector & wordArray) }; AutoCompletion::AutoCompletion(ScintillaEditView * pEditView) : _funcCompletionActive(false), _pEditView(pEditView), _funcCalltip(pEditView), - _curLang(L_TXT), _XmlFile(NULL), _activeCompletion(CompletionNone), - _pXmlKeyword(NULL), _ignoreCase(true), _keyWords("") + _curLang(L_TXT), _XmlFile(TEXT("")), _activeCompletion(CompletionNone), + _pXmlKeyword(NULL), _ignoreCase(true), _keyWords(TEXT("")) { //Do not load any language yet } @@ -46,7 +46,6 @@ bool AutoCompletion::showAutoComplete() { int len = curPos-startLinePos; char * lineBuffer = new char[len+1]; _pEditView->getText(lineBuffer, startLinePos, curPos); - //_pEditView->execute(SCI_GETTEXT, (WPARAM)len, (LPARAM)lineBuffer); int offset = len-1; int nrChars = 0; @@ -66,7 +65,7 @@ bool AutoCompletion::showAutoComplete() { _pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM('\n')); _pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase); - _pEditView->execute(SCI_AUTOCSHOW, curPos-startWordPos, WPARAM(_keyWords.c_str())); + _pEditView->showAutoComletion(curPos - startWordPos, _keyWords.c_str()); _activeCompletion = CompletionAuto; return true; @@ -85,25 +84,21 @@ bool AutoCompletion::showWordComplete(bool autoInsert) if (len >= bufSize) return false; - char beginChars[bufSize]; + TCHAR beginChars[bufSize]; - _pEditView->getText(beginChars, startPos, curPos); + _pEditView->getGenericText(beginChars, startPos, curPos); - string expr("\\<"); + basic_string expr(TEXT("\\<")); expr += beginChars; - expr += "[^ \\t.,;:\"()=<>'+!\\[\\]]*"; + expr += TEXT("[^ \\t.,;:\"()=<>'+!\\[\\]]*"); int docLength = int(_pEditView->execute(SCI_GETLENGTH)); int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX; - _pEditView->execute(SCI_SETTARGETSTART, 0); - _pEditView->execute(SCI_SETTARGETEND, docLength); _pEditView->execute(SCI_SETSEARCHFLAGS, flags); - - vector wordArray; - - int posFind = int(_pEditView->execute(SCI_SEARCHINTARGET, expr.length(), (LPARAM)expr.c_str())); + vector> wordArray; + int posFind = _pEditView->searchInTarget(expr.c_str(), 0, docLength); while (posFind != -1) { @@ -114,42 +109,38 @@ bool AutoCompletion::showWordComplete(bool autoInsert) if (foundTextLen < bufSize) { - char w[bufSize]; - _pEditView->getText(w, wordStart, wordEnd); + TCHAR w[bufSize]; + _pEditView->getGenericText(w, wordStart, wordEnd); - if (strcmp(w, beginChars)) + if (lstrcmp(w, beginChars)) if (!isInList(w, wordArray)) wordArray.push_back(w); } - _pEditView->execute(SCI_SETTARGETSTART, wordEnd/*posFind + foundTextLen*/); - _pEditView->execute(SCI_SETTARGETEND, docLength); - posFind = int(_pEditView->execute(SCI_SEARCHINTARGET, expr.length(), (LPARAM)expr.c_str())); + posFind = _pEditView->searchInTarget(expr.c_str(), wordEnd, docLength); } if (wordArray.size() == 0) return false; if (wordArray.size() == 1 && autoInsert) { - _pEditView->execute(SCI_SETTARGETSTART, startPos); - _pEditView->execute(SCI_SETTARGETEND, curPos); - _pEditView->execute(SCI_REPLACETARGETRE, wordArray[0].length(), (LPARAM)wordArray[0].c_str()); - + _pEditView->replaceTargetRegExMode(wordArray[0].c_str(), startPos, curPos); _pEditView->execute(SCI_GOTOPOS, startPos + wordArray[0].length()); return true; } sort(wordArray.begin(), wordArray.end()); - string words(""); + basic_string words(TEXT("")); for (size_t i = 0 ; i < wordArray.size() ; i++) { words += wordArray[i]; if (i != wordArray.size()-1) - words += " "; + words += TEXT(" "); } + // UNICODE TO DO _pEditView->execute(SCI_AUTOCSETSEPARATOR, WPARAM(' ')); _pEditView->execute(SCI_AUTOCSETIGNORECASE, _ignoreCase); - _pEditView->execute(SCI_AUTOCSHOW, curPos - startPos, WPARAM(words.c_str())); + _pEditView->showAutoComletion(curPos - startPos, words.c_str()); _activeCompletion = CompletionWord; return true; @@ -186,10 +177,10 @@ void AutoCompletion::update(int character) if (_pEditView->execute(SCI_AUTOCACTIVE) != 0) return; - char s[64]; + TCHAR s[64]; _pEditView->getWordToCurrentPos(s, sizeof(s)); - if (strlen(s) >= nppGUI._autocFromLen) + if (lstrlen(s) >= int(nppGUI._autocFromLen)) { if (nppGUI._autocStatus == nppGUI.autoc_word) showWordComplete(false); @@ -214,12 +205,12 @@ bool AutoCompletion::setLanguage(LangType language) { return true; _curLang = language; - char path[MAX_PATH]; + TCHAR path[MAX_PATH]; ::GetModuleFileName(NULL, path, MAX_PATH); PathRemoveFileSpec(path); - strcat(path, "\\plugins\\APIs\\"); - strcat(path, getApiFileName()); - strcat(path, ".xml"); + lstrcat(path, TEXT("\\plugins\\APIs\\")); + lstrcat(path, getApiFileName()); + lstrcat(path, TEXT(".xml")); _XmlFile = TiXmlDocument(path); _funcCompletionActive = _XmlFile.LoadFile(); @@ -227,13 +218,13 @@ bool AutoCompletion::setLanguage(LangType language) { TiXmlNode * pAutoNode = NULL; if (_funcCompletionActive) { _funcCompletionActive = false; //safety - TiXmlNode * pNode = _XmlFile.FirstChild("NotepadPlus"); + TiXmlNode * pNode = _XmlFile.FirstChild(TEXT("NotepadPlus")); if (!pNode) return false; - pAutoNode = pNode = pNode->FirstChildElement("AutoComplete"); + pAutoNode = pNode = pNode->FirstChildElement(TEXT("AutoComplete")); if (!pNode) return false; - pNode = pNode->FirstChildElement("KeyWord"); + pNode = pNode->FirstChildElement(TEXT("KeyWord")); if (!pNode) return false; _pXmlKeyword = reinterpret_cast(pNode); @@ -251,24 +242,24 @@ bool AutoCompletion::setLanguage(LangType language) { _funcCalltip._terminal = ';'; _funcCalltip._ignoreCase = true; - TiXmlElement * pElem = pAutoNode->FirstChildElement("Environment"); + TiXmlElement * pElem = pAutoNode->FirstChildElement(TEXT("Environment")); if (pElem) { - const char * val = 0; - val = pElem->Attribute("ignoreCase"); - if (val && !strcmp(val, "no")) { + const TCHAR * val = 0; + val = pElem->Attribute(TEXT("ignoreCase")); + if (val && !lstrcmp(val, TEXT("no"))) { _ignoreCase = false; _funcCalltip._ignoreCase = false; } - val = pElem->Attribute("startFunc"); + val = pElem->Attribute(TEXT("startFunc")); if (val && val[0]) _funcCalltip._start = val[0]; - val = pElem->Attribute("stopFunc"); + val = pElem->Attribute(TEXT("stopFunc")); if (val && val[0]) _funcCalltip._stop = val[0]; - val = pElem->Attribute("paramSeparator"); + val = pElem->Attribute(TEXT("paramSeparator")); if (val && val[0]) _funcCalltip._param = val[0]; - val = pElem->Attribute("terminal"); + val = pElem->Attribute(TEXT("terminal")); if (val && val[0]) _funcCalltip._terminal = val[0]; } @@ -280,23 +271,23 @@ bool AutoCompletion::setLanguage(LangType language) { _funcCalltip.setLanguageXML(NULL); } - _keyWords = ""; + _keyWords = TEXT(""); if (_funcCompletionActive) { //Cache the keywords //Iterate through all keywords TiXmlElement *funcNode = _pXmlKeyword; - const char * name = NULL; - for (; funcNode; funcNode = funcNode->NextSiblingElement("KeyWord") ) { - name = funcNode->Attribute("name"); + const TCHAR * name = NULL; + for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) { + name = funcNode->Attribute(TEXT("name")); if (!name) //malformed node continue; _keyWords.append(name); - _keyWords.append("\n"); + _keyWords.append(TEXT("\n")); } } return _funcCompletionActive; } -const char * AutoCompletion::getApiFileName() { +const TCHAR * AutoCompletion::getApiFileName() { if (_curLang == L_USER) { Buffer * currentBuf = _pEditView->getCurrentBuffer(); diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.h b/PowerEditor/src/ScitillaComponent/AutoCompletion.h index c8e2291d..2a5fba97 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.h +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.h @@ -48,10 +48,10 @@ private: bool _ignoreCase; - std::string _keyWords; + std::basic_string _keyWords; FunctionCallTip _funcCalltip; - const char * getApiFileName(); + const TCHAR * getApiFileName(); }; #endif //AUTOCOMPLETION_H diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 1df0a031..a949791e 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -9,12 +9,11 @@ #include "Notepad_plus.h" #include "ScintillaEditView.h" -#include "UniConversion.h" FileManager * FileManager::_pSelf = new FileManager(); const int blockSize = 128 * 1024 + 4; -const char UNTITLED_STR[] = "new "; +const TCHAR UNTITLED_STR[] = TEXT("new "); // Ordre important!! Ne le changes pas! //SC_EOL_CRLF (0), SC_EOL_CR (1), or SC_EOL_LF (2). @@ -22,13 +21,13 @@ const char UNTITLED_STR[] = "new "; const int CR = 0x0D; const int LF = 0x0A; -static bool isInList(const char *token, const char *list) { +static bool isInList(const TCHAR *token, const TCHAR *list) { if ((!token) || (!list)) return false; - char word[64]; + TCHAR word[64]; int i = 0; int j = 0; - for (; i <= int(strlen(list)) ; i++) + for (; i <= int(lstrlen(list)) ; i++) { if ((list[i] == ' ')||(list[i] == '\0')) { @@ -37,7 +36,7 @@ static bool isInList(const char *token, const char *list) { word[j] = '\0'; j = 0; - if (!stricmp(token, word)) + if (!generic_stricmp(token, word)) return true; } } @@ -50,7 +49,7 @@ static bool isInList(const char *token, const char *list) { return false; }; -void Buffer::determinateFormat(char *data) { +void Buffer::determinateFormat(const char *data) { _format = WIN_FORMAT; size_t len = strlen(data); for (size_t i = 0 ; i < len ; i++) @@ -83,7 +82,7 @@ long Buffer::_recentTagCtr = 0; void Buffer::updateTimeStamp() { struct _stat buf; - time_t timeStamp = (_wstat(_fullPathNameW, &buf)==0)?buf.st_mtime:0; + time_t timeStamp = (generic_stat(_fullPathName, &buf)==0)?buf.st_mtime:0; if (timeStamp != _timeStamp) { _timeStamp = timeStamp; @@ -94,31 +93,29 @@ void Buffer::updateTimeStamp() { // Set full path file name in buffer object, // and determinate its language by its extension. // If the ext is not in the list, the defaultLang passed as argument will be set. -void Buffer::setFileName(const char *fn, LangType defaultLang) +void Buffer::setFileName(const TCHAR *fn, LangType defaultLang) { NppParameters *pNppParamInst = NppParameters::getInstance(); - if (!strcmpi(fn, _fullPathName)) { + if (!lstrcmpi(fn, _fullPathName)) { updateTimeStamp(); doNotify(BufferChangeTimestamp); return; } - strcpy(_fullPathName, fn); - char2wchar(_fullPathName, _fullPathNameW); - _fileNameW = PathFindFileNameW(_fullPathNameW); + lstrcpy(_fullPathName, fn); _fileName = PathFindFileName(_fullPathName); // for _lang LangType newLang = defaultLang; - char *ext = PathFindExtension(_fullPathName); + TCHAR *ext = PathFindExtension(_fullPathName); if (*ext == '.') { //extension found ext += 1; // Define User Lang firstly - const char *langName = NULL; + const TCHAR *langName = NULL; if ((langName = pNppParamInst->getUserDefinedLangNameFromExt(ext))) { newLang = L_USER; - strcpy(_userLangExt, langName); + lstrcpy(_userLangExt, langName); } else // if it's not user lang, then check if it's supported lang { @@ -129,9 +126,9 @@ void Buffer::setFileName(const char *fn, LangType defaultLang) if (newLang == defaultLang || newLang == L_TXT) //language can probably be refined { - if ((!_stricmp(_fileName, "makefile")) || (!_stricmp(_fileName, "GNUmakefile"))) + if ((!generic_stricmp(_fileName, TEXT("makefile"))) || (!generic_stricmp(_fileName, TEXT("GNUmakefile")))) newLang = L_MAKEFILE; - else if (!_stricmp(_fileName, "CmakeLists.txt")) + else if (!generic_stricmp(_fileName, TEXT("CmakeLists.txt"))) newLang = L_CMAKE; } @@ -151,19 +148,20 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i if (_currentStatus == DOC_UNNAMED) //unsaved document cannot change by environment return false; - if (_currentStatus != DOC_DELETED && !PathFileExistsW(_fullPathNameW)) //document has been deleted + if (_currentStatus != DOC_DELETED && !PathFileExists(_fullPathName)) //document has been deleted { _currentStatus = DOC_DELETED; _isFileReadOnly = false; - _isDirty = true; //dirty since no match with filesystem + _isDirty = true; //dirty sicne no match with filesystem _timeStamp = 0; doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp); return true; } - - if (_currentStatus == DOC_DELETED && PathFileExistsW(_fullPathNameW)) + + if (_currentStatus == DOC_DELETED && PathFileExists(_fullPathName)) { //document has returned from its grave - if (!_wstat(_fullPathNameW, &buf)) + + if (!generic_stat(_fullPathName, &buf)) { _isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE)); @@ -171,10 +169,11 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i _timeStamp = buf.st_mtime; doNotify(BufferChangeStatus | BufferChangeReadonly | BufferChangeTimestamp); return true; - } + } + } - if (!_wstat(_fullPathNameW, &buf)) + if (!generic_stat(_fullPathName, &buf)) { int mask = 0; //status always 'changes', even if from modified to modified bool isFileReadOnly = (bool)(!(buf.st_mode & _S_IWRITE)); @@ -197,6 +196,7 @@ bool Buffer::checkFileState() { //returns true if the status has been changed (i return false; } + return false; } @@ -230,7 +230,7 @@ std::vector & Buffer::getHeaderLineState(ScintillaEditView * id return _foldStates.at(index); } -LangType Buffer::getLangFromExt(const char *ext) +LangType Buffer::getLangFromExt(const TCHAR *ext) { NppParameters *pNppParam = NppParameters::getInstance(); int i = pNppParam->getNbLang(); @@ -239,22 +239,22 @@ LangType Buffer::getLangFromExt(const char *ext) { Lang *l = pNppParam->getLangFromIndex(i--); - const char *defList = l->getDefaultExtList(); - const char *userList = NULL; + const TCHAR *defList = l->getDefaultExtList(); + const TCHAR *userList = NULL; LexerStylerArray &lsa = pNppParam->getLStylerArray(); - const char *lName = l->getLangName(); + const TCHAR *lName = l->getLangName(); LexerStyler *pLS = lsa.getLexerStylerByName(lName); if (pLS) userList = pLS->getLexerUserExt(); - std::string list(""); + std::basic_string list(TEXT("")); if (defList) list += defList; if (userList) { - list += " "; + list += TEXT(" "); list += userList; } if (isInList(ext, list.c_str())) @@ -383,12 +383,12 @@ void FileManager::closeBuffer(BufferID id, ScintillaEditView * identifier) { } } -BufferID FileManager::loadFile(const char * filename, Document doc) { +BufferID FileManager::loadFile(const TCHAR * filename, Document doc) { if (doc == NULL) { doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); } - char fullpath[MAX_PATH]; + TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); Utf8_16_Read UnicodeConvertor; //declare here so we can get information after loading is done @@ -446,52 +446,48 @@ bool FileManager::reloadBufferDeferred(BufferID id) { bool FileManager::deleteFile(BufferID id) { Buffer * buf = getBufferByID(id); - const wchar_t *fileNamePath = buf->getFilePathW(); - if (!PathFileExistsW(fileNamePath)) + const TCHAR *fileNamePath = buf->getFilePath(); + if (!PathFileExists(fileNamePath)) return false; - return ::DeleteFileW(fileNamePath) != 0; + return ::DeleteFile(fileNamePath) != 0; } -bool FileManager::moveFile(BufferID id, const char * newFileName) +bool FileManager::moveFile(BufferID id, const TCHAR * newFileName) { Buffer * buf = getBufferByID(id); - const wchar_t *fileNamePath = buf->getFilePathW(); - if (!PathFileExistsW(fileNamePath)) + const TCHAR *fileNamePath = buf->getFilePath(); + if (!PathFileExists(fileNamePath)) return false; - wchar_t newFileNameW[MAX_PATH]; - char2wchar(newFileName, newFileNameW); - if (::MoveFileW(fileNamePath, newFileNameW) == 0) + if (::MoveFile(fileNamePath, newFileName) == 0) return false; buf->setFileName(newFileName); return true; } -bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { +bool FileManager::saveBuffer(BufferID id, const TCHAR * filename, bool isCopy) { Buffer * buffer = getBufferByID(id); bool isHidden = false; bool isSys = false; DWORD attrib; - char fullpath[MAX_PATH]; + TCHAR fullpath[MAX_PATH]; ::GetFullPathName(filename, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); - wchar_t fullpathW[MAX_PATH]; - char2wchar(fullpath, fullpathW); - if (PathFileExistsW(fullpathW)) + if (PathFileExists(fullpath)) { - attrib = ::GetFileAttributesW(fullpathW); + attrib = ::GetFileAttributes(fullpath); if (attrib != INVALID_FILE_ATTRIBUTES) { isHidden = (attrib & FILE_ATTRIBUTE_HIDDEN) != 0; if (isHidden) - ::SetFileAttributesW(fullpathW, attrib & ~FILE_ATTRIBUTE_HIDDEN); + ::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_HIDDEN); isSys = (attrib & FILE_ATTRIBUTE_SYSTEM) != 0; if (isSys) - ::SetFileAttributesW(fullpathW, attrib & ~FILE_ATTRIBUTE_SYSTEM); + ::SetFileAttributes(filename, attrib & ~FILE_ATTRIBUTE_SYSTEM); } } @@ -502,12 +498,11 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { Utf8_16_Write UnicodeConvertor; UnicodeConvertor.setEncoding(mode); - FILE *fp = UnicodeConvertor.fopenW(fullpathW, L"wb"); + FILE *fp = UnicodeConvertor.generic_fopen(fullpath, TEXT("wb")); if (fp) { _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, buffer->_doc); //generate new document - char data[blockSize + 1]; int lengthDoc = _pscratchTilla->getCurrentDocLen(); for (int i = 0; i < lengthDoc; i += blockSize) @@ -522,10 +517,10 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { UnicodeConvertor.fclose(); if (isHidden) - ::SetFileAttributesW(fullpathW, attrib | FILE_ATTRIBUTE_HIDDEN); + ::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_HIDDEN); if (isSys) - ::SetFileAttributesW(fullpathW, attrib | FILE_ATTRIBUTE_SYSTEM); + ::SetFileAttributes(fullpath, attrib | FILE_ATTRIBUTE_SYSTEM); if (isCopy) { _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, _scratchDocDefault); @@ -544,9 +539,9 @@ bool FileManager::saveBuffer(BufferID id, const char * filename, bool isCopy) { } BufferID FileManager::newEmptyDocument() { - char newTitle[10]; - strcpy(newTitle, UNTITLED_STR); - itoa(_nextNewNumber, newTitle+4, 10); + TCHAR newTitle[10]; + lstrcpy(newTitle, UNTITLED_STR); + wsprintf(newTitle+4, TEXT("%d"), _nextNewNumber); _nextNewNumber++; Document doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); //this already sets a reference for filemanager Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle); @@ -559,9 +554,9 @@ BufferID FileManager::newEmptyDocument() { } BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool dontRef) { - char newTitle[10]; - strcpy(newTitle, UNTITLED_STR); - itoa(_nextNewNumber, newTitle+4, 10); + TCHAR newTitle[10]; + lstrcpy(newTitle, UNTITLED_STR); + wsprintf(newTitle+4, TEXT("%d"), _nextNewNumber); if (!dontRef) _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager Buffer * newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle); @@ -575,30 +570,27 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d return id; } -bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read * UnicodeConvertor, LangType language) { +bool FileManager::loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language) { const int blockSize = 128 * 1024; //128 kB char data[blockSize]; - WCHAR filenameW[MAX_PATH]; - char2wchar(filename, filenameW); - - FILE *fp = _wfopen(filenameW, L"rb"); + __try { + FILE *fp = generic_fopen(filename, TEXT("rb")); if (!fp) return false; - __try { //Setup scratchtilla for new filedata _pscratchTilla->execute(SCI_SETDOCPOINTER, 0, doc); bool ro = _pscratchTilla->execute(SCI_GETREADONLY) != 0; - if (ro) { + if (ro) { _pscratchTilla->execute(SCI_SETREADONLY, false); - } + } _pscratchTilla->execute(SCI_CLEARALL); if (language < L_EXTERNAL) { _pscratchTilla->execute(SCI_SETLEXER, ScintillaEditView::langNames[language].lexerID); } else { int id = language - L_EXTERNAL; - char * name = NppParameters::getInstance()->getELCFromIndex(id)._name; + TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; _pscratchTilla->execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name); } @@ -621,17 +613,16 @@ bool FileManager::loadFileData(Document doc, const char * filename, Utf8_16_Read return true; }__except(filter(GetExceptionCode(), GetExceptionInformation())) { - - printStr("File is too big to be opened by Notepad++"); + printStr(TEXT("File is too big to be opened by Notepad++")); return false; } } -BufferID FileManager::getBufferFromName(const char * name) { - char fullpath[MAX_PATH]; +BufferID FileManager::getBufferFromName(const TCHAR * name) { + TCHAR fullpath[MAX_PATH]; ::GetFullPathName(name, MAX_PATH, fullpath, NULL); ::GetLongPathName(fullpath, fullpath, MAX_PATH); for(size_t i = 0; i < _buffers.size(); i++) { - if (!strcmpi(name, _buffers.at(i)->getFilePath())) + if (!lstrcmpi(name, _buffers.at(i)->getFilePath())) return _buffers.at(i)->getID(); } return BUFFER_INVALID; @@ -645,22 +636,19 @@ BufferID FileManager::getBufferFromDocument(Document doc) { return BUFFER_INVALID; } -bool FileManager::createEmptyFile(const char * path) { - WCHAR pathW[MAX_PATH]; - char2wchar(path, pathW); - - FILE * file = _wfopen(pathW, L"wb"); +bool FileManager::createEmptyFile(const TCHAR * path) { + FILE * file = generic_fopen(path, TEXT("wb")); if (!file) return false; fclose(file); return true; } -int FileManager::getFileNameFromBuffer(BufferID id, char * fn2copy) { +int FileManager::getFileNameFromBuffer(BufferID id, TCHAR * fn2copy) { if (getBufferIndexByID(id) == -1) return -1; Buffer * buf = getBufferByID(id); if (fn2copy) - strcpy(fn2copy, buf->_fileName); - return strlen(buf->_fileName); + lstrcpy(fn2copy, buf->_fileName); + return lstrlen(buf->_fileName); } \ No newline at end of file diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 2df48bdb..53259a51 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -76,30 +76,30 @@ public: void addBufferReference(BufferID id, ScintillaEditView * identifer); //called by Scintilla etc indirectly - BufferID loadFile(const char * filename, Document doc = NULL); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document + BufferID loadFile(const TCHAR * filename, Document doc = NULL); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document BufferID newEmptyDocument(); //create Buffer from existing Scintilla, used from new Scintillas. If dontIncrease = true, then the new document number isnt increased afterwards. //usefull for temporary but neccesary docs //If dontRef = false, then no extra reference is added for the doc. Its the responsibility of the caller to do so BufferID bufferFromDocument(Document doc, bool dontIncrease = false, bool dontRef = false); - BufferID getBufferFromName(const char * name); + BufferID getBufferFromName(const TCHAR * name); BufferID getBufferFromDocument(Document doc); bool reloadBuffer(BufferID id); bool reloadBufferDeferred(BufferID id); - bool saveBuffer(BufferID id, const char * filename, bool isCopy = false); + bool saveBuffer(BufferID id, const TCHAR * filename, bool isCopy = false); bool deleteFile(BufferID id); - bool moveFile(BufferID id, const char * newFilename); + bool moveFile(BufferID id, const TCHAR * newFilename); - bool createEmptyFile(const char * path); + bool createEmptyFile(const TCHAR * path); static FileManager * getInstance() {return _pSelf;}; void destroyInstance() { delete _pSelf; }; void increaseDocNr() {_nextNewNumber++;}; - int getFileNameFromBuffer(BufferID id, char * fn2copy); + int getFileNameFromBuffer(BufferID id, TCHAR * fn2copy); private: FileManager() : _nextNewNumber(1), _nextBufferID(0), _pNotepadPlus(NULL), _nrBufs(0), _pscratchTilla(NULL){}; ~FileManager(){}; @@ -115,7 +115,7 @@ private: BufferID _nextBufferID; size_t _nrBufs; - bool loadFileData(Document doc, const char * filename, Utf8_16_Read * UnicodeConvertor, LangType language); + bool loadFileData(Document doc, const TCHAR * filename, Utf8_16_Read * UnicodeConvertor, LangType language); }; #define MainFileManager FileManager::getInstance() @@ -131,7 +131,7 @@ public : //Load the document into Scintilla/add to TabBar //The entire lifetime if the buffer, the Document has reference count of _atleast_ one //Destructor makes sure its purged - Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const char *fileName) //type must be either DOC_REGULAR or DOC_UNNAMED + Buffer(FileManager * pManager, BufferID id, Document doc, DocFileStatus type, const TCHAR *fileName) //type must be either DOC_REGULAR or DOC_UNNAMED : _pManager(pManager), _id(id), _isDirty(false), _doc(doc), _isFileReadOnly(false), _isUserReadOnly(false), _recentTag(-1), _references(0), _canNotify(false), _timeStamp(0), _needReloading(false) { @@ -153,22 +153,18 @@ public : _canNotify = true; }; - LangType getLangFromExt(const char *ext); + LangType getLangFromExt(const TCHAR *ext); // this method 1. copies the file name // 2. determinates the language from the ext of file name // 3. gets the last modified time - void setFileName(const char *fn, LangType defaultLang = L_TXT); + void setFileName(const TCHAR *fn, LangType defaultLang = L_TXT); - const char * getFilePath() const { + const TCHAR * getFilePath() const { return _fullPathName; }; - const wchar_t * getFilePathW() const { - return _fullPathNameW; - }; - const char * getFileName() const { return _fileName; }; - const wchar_t * getFileNameW() const { return _fileNameW; }; + const TCHAR * getFileName() const { return _fileName; }; BufferID getID() const { return _id; @@ -228,12 +224,12 @@ public : return _lang; }; - void setLangType(LangType lang, const char * userLangName = "") { + void setLangType(LangType lang, const TCHAR * userLangName = TEXT("")) { if (lang == _lang && lang != L_USER) return; _lang = lang; if (_lang == L_USER) { - strcpy(_userLangExt, userLangName); + lstrcpy(_userLangExt, userLangName); } _needLexer = true; //change of lang means lexern eeds updating doNotify(BufferChangeLanguage|BufferChangeLexing); @@ -252,10 +248,6 @@ public : return _currentStatus; }; - time_t getTimeStamp() const { - return _timeStamp; - }; - Document getDocument() { return _doc; }; @@ -271,17 +263,17 @@ public : void setHeaderLineState(const std::vector & folds, ScintillaEditView * identifier); std::vector & getHeaderLineState(ScintillaEditView * identifier); - void determinateFormat(char *data); + void determinateFormat(const char *data); bool isUserDefineLangExt() const { return (_userLangExt[0] != '\0'); }; - const char * getUserDefineLangName() const { + const TCHAR * getUserDefineLangName() const { return _userLangExt; }; - const char * getCommentLineSymbol() const { + const TCHAR * getCommentLineSymbol() const { Lang *l = getCurrentLang(); if (!l) return NULL; @@ -289,14 +281,14 @@ public : }; - const char * getCommentStart() const { + const TCHAR * getCommentStart() const { Lang *l = getCurrentLang(); if (!l) return NULL; return l->_pCommentStart; }; - const char * getCommentEnd() const { + const TCHAR * getCommentEnd() const { Lang *l = getCurrentLang(); if (!l) return NULL; @@ -327,13 +319,6 @@ public : void setNeedReload(bool reload) { _needReloading = reload; } - - vector < pair > & getClickableStyles() { - return _clickableStyles; - }; - - - private : FileManager * _pManager; bool _canNotify; @@ -343,7 +328,7 @@ private : //document properties Document _doc; //invariable LangType _lang; - char _userLangExt[userLangNameMax]; // it's useful if only (_lang == L_USER) + TCHAR _userLangExt[userLangNameMax]; // it's useful if only (_lang == L_USER) bool _isDirty; formatType _format; UniMode _unicodeMode; @@ -359,15 +344,12 @@ private : DocFileStatus _currentStatus; time_t _timeStamp; // 0 if it's a new doc bool _isFileReadOnly; - char _fullPathName[MAX_PATH]; - wchar_t _fullPathNameW[MAX_PATH]; - char * _fileName; //points to filename part in _fullPathName - wchar_t * _fileNameW; + TCHAR _fullPathName[MAX_PATH]; + TCHAR * _fileName; //points to filename part in _fullPathName bool _needReloading; //True if Buffer needs to be reloaded on activation long _recentTag; static long _recentTagCtr; - vector < pair > _clickableStyles; void updateTimeStamp(); Lang * getCurrentLang() const; diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.cpp b/PowerEditor/src/ScitillaComponent/DocTabView.cpp index ab01c1f7..d4e9e76e 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScitillaComponent/DocTabView.cpp @@ -23,7 +23,6 @@ #include #include -#include "UniConversion.h" bool DocTabView::_hideTabBarStatus = false; @@ -33,18 +32,16 @@ void DocTabView::addBuffer(BufferID buffer) { if (this->getIndexByBuffer(buffer) != -1) //no duplicates return; Buffer * buf = MainFileManager->getBufferByID(buffer); - TCITEMW tie; + TCITEM tie; tie.mask = TCIF_TEXT | TCIF_IMAGE | TCIF_PARAM; int index = -1; if (_hasImgLst) index = 0; tie.iImage = index; - tie.pszText = (LPWSTR)buf->getFileNameW(); - tie.cchTextMax = lstrlenW(tie.pszText); + tie.pszText = (TCHAR *)buf->getFileName(); tie.lParam = (LPARAM)buffer; - - ::SendMessage(_hSelf, TCM_INSERTITEMW, _nbItem++, reinterpret_cast(&tie)); + ::SendMessage(_hSelf, TCM_INSERTITEM, _nbItem++, reinterpret_cast(&tie)); bufferUpdated(buf, BufferChangeMask); ::SendMessage(_hParent, WM_SIZE, 0, 0); @@ -70,7 +67,7 @@ BufferID DocTabView::activeBuffer() { return (BufferID)getBufferByIndex(index); } -BufferID DocTabView::findBufferByName(const char * fullfilename) { //-1 if not found, something else otherwise +BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) { //-1 if not found, something else otherwise TCITEM tie; tie.lParam = -1; tie.mask = TCIF_PARAM; @@ -78,7 +75,7 @@ BufferID DocTabView::findBufferByName(const char * fullfilename) { //-1 if not f ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast(&tie)); BufferID id = (BufferID)tie.lParam; Buffer * buf = MainFileManager->getBufferByID(id); - if (!strcmp(fullfilename, buf->getFilePath())) { + if (!lstrcmp(fullfilename, buf->getFilePath())) { return id; } } @@ -111,7 +108,7 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask) { if (index == -1) return; - TCITEMW tie; + TCITEM tie; tie.lParam = -1; tie.mask = 0; @@ -126,10 +123,10 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask) { if (mask & BufferChangeFilename) { tie.mask |= TCIF_TEXT; - tie.pszText = (LPWSTR)buffer->getFileNameW(); + tie.pszText = (TCHAR *)buffer->getFileName(); } - ::SendMessage(_hSelf, TCM_SETITEMW, index, reinterpret_cast(&tie)); + ::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast(&tie)); ::SendMessage(_hParent, WM_SIZE, 0, 0); } diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.h b/PowerEditor/src/ScitillaComponent/DocTabView.h index d22c89e3..3f04836c 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.h +++ b/PowerEditor/src/ScitillaComponent/DocTabView.h @@ -52,7 +52,7 @@ public : bool activateBuffer(BufferID buffer); BufferID activeBuffer(); - BufferID findBufferByName(const char * fullfilename); //-1 if not found, something else otherwise + BufferID findBufferByName(const TCHAR * fullfilename); //-1 if not found, something else otherwise int getIndexByBuffer(BufferID id); BufferID getBufferByIndex(int index); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index ba02643c..849b3ea3 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -22,12 +22,12 @@ #include "common_func.h" #include "UniConversion.h" -int Searching::convertExtendedToString(const char * query, char * result, int length) { //query may equal to result, since it always gets smaller +int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length) { //query may equal to result, since it always gets smaller int i = 0, j = 0; int charLeft = length; bool isGood = true; - char current; - while(i < length) { //because the backslash escape quences always reduce the size of the string, no overflow checks have to be made for target, assuming parameters are correct + TCHAR current; + while(i < length) { //because the backslash escape quences always reduce the size of the basic_string, no overflow checks have to be made for target, assuming parameters are correct current = query[i]; charLeft--; if (current == '\\' && charLeft) { //possible escape sequence @@ -67,7 +67,7 @@ int Searching::convertExtendedToString(const char * query, char * result, int le if (charLeft >= size) { int res = 0; if (Searching::readBase(query+(i+1), &res, base, size)) { - result[j] = (char)res; + result[j] = (TCHAR)res; i+=size; break; } @@ -92,13 +92,13 @@ int Searching::convertExtendedToString(const char * query, char * result, int le return j; } -bool Searching::readBase(const char * string, int * value, int base, int size) { +bool Searching::readBase(const TCHAR * str, int * value, int base, int size) { int i = 0, temp = 0; *value = 0; - char max = '0' + base - 1; - char current; + TCHAR max = '0' + base - 1; + TCHAR current; while(i < size) { - current = string[i]; + current = str[i]; if (current >= '0' && current <= max) { temp *= base; temp += (current - '0'); @@ -144,37 +144,49 @@ void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditVi //Make sure the caret is visible, scroll horizontally (this will also fix wrapping problems) pEditView->execute(SCI_GOTOPOS, posStart); pEditView->execute(SCI_GOTOPOS, posEnd); - //pEditView->execute(SCI_SETSEL, start, posEnd); - //pEditView->execute(SCI_SETCURRENTPOS, posEnd); + pEditView->execute(SCI_SETANCHOR, posStart); } -void FindReplaceDlg::addText2Combo(const char * txt2add, HWND hCombo, bool isUTF8) +void FindReplaceDlg::addText2Combo(const TCHAR * txt2add, HWND hCombo, bool isUTF8) { if (!hCombo) return; - if (!strcmp(txt2add, "")) return; - - bool bMustDie9x = _winVer <= WV_ME; - char text[MAX_PATH]; - WCHAR textW[MAX_PATH]; + if (!lstrcmp(txt2add, TEXT(""))) return; + TCHAR text[MAX_PATH]; int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0); bool hasFound = false; int i = 0; - WCHAR wchars2Add[MAX_PATH]; +#ifdef UNICODE + for ( ; i < count ; i++) + { + ::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM)text); + if (!lstrcmp(txt2add, text)) + { + hasFound = true; + break; + } + } + + if (!hasFound) + { + i = ::SendMessage(hCombo, CB_ADDSTRING, 0, (LPARAM)txt2add); + } +#else + bool bMustDie9x = _winVer <= WV_ME; + wchar_t wchars2Add[MAX_PATH]; + wchar_t textW[MAX_PATH]; + if (isUTF8) ::MultiByteToWideChar(CP_UTF8, 0, txt2add, -1, wchars2Add, MAX_PATH - 1); for ( ; i < count ; i++) { - if (isUTF8) { if ( !bMustDie9x ) - { ::SendMessageW(hCombo, CB_GETLBTEXT, i, (LPARAM)textW); - } else { ::SendMessageA(hCombo, CB_GETLBTEXT, i, (LPARAM)text); @@ -196,7 +208,6 @@ void FindReplaceDlg::addText2Combo(const char * txt2add, HWND hCombo, bool isUTF } } } - if (!hasFound) { if (!isUTF8) @@ -204,9 +215,7 @@ void FindReplaceDlg::addText2Combo(const char * txt2add, HWND hCombo, bool isUTF else { if ( !bMustDie9x ) - { i = ::SendMessageW(hCombo, CB_ADDSTRING, 0, (LPARAM)wchars2Add); - } else { ::WideCharToMultiByte(CP_ACP, 0, wchars2Add, -1, text, MAX_PATH - 1, NULL, NULL); @@ -214,17 +223,20 @@ void FindReplaceDlg::addText2Combo(const char * txt2add, HWND hCombo, bool isUTF } } } - +#endif ::SendMessage(hCombo, CB_SETCURSEL, i, 0); } -string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const +basic_string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const { + TCHAR str[MAX_PATH]; +#ifdef UNICODE + ::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str); +#else bool bMustDie9x = _winVer <= WV_ME; - char str[MAX_PATH]; if (isUnicode) { - WCHAR wchars[MAX_PATH]; + wchar_t wchars[MAX_PATH]; if ( !bMustDie9x ) { ::SendMessageW(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)wchars); @@ -241,9 +253,11 @@ string FindReplaceDlg::getTextFromCombo(HWND hCombo, bool isUnicode) const { ::SendMessage(hCombo, WM_GETTEXT, MAX_PATH - 1, (LPARAM)str); } - return string(str); +#endif + return basic_string(str); } + // important : to activate all styles const int STYLING_MASK = 255; @@ -276,11 +290,11 @@ void FindReplaceDlg::create(int dialogID, bool isRTL) //::GetWindowRect(_hSelf, &rect); getClientRect(rect); _tab.init(_hInst, _hSelf, false, false, true); - _tab.setFont("Tahoma", 13); + _tab.setFont(TEXT("Tahoma"), 13); - const char *find = "Find"; - const char *replace = "Replace"; - const char *findInFiles = "Find in files"; + const TCHAR *find = TEXT("Find"); + const TCHAR *replace = TEXT("Replace"); + const TCHAR *findInFiles = TEXT("Find in files"); NppParameters::FindDlgTabTitiles & fdTitles = NppParameters::getInstance()->getFindDlgTabTitiles(); @@ -308,10 +322,10 @@ void FindReplaceDlg::updateCombos() { bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH); - addText2Combo(getTextFromCombo(hReplaceCombo, isUnicode).c_str(), hReplaceCombo, isUnicode); + addText2Combo(getTextFromCombo(hReplaceCombo).c_str(), hReplaceCombo, isUnicode); HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); - addText2Combo(getTextFromCombo(hFindCombo, isUnicode).c_str(), hFindCombo, isUnicode); + addText2Combo(getTextFromCombo(hFindCombo).c_str(), hFindCombo, isUnicode); } bool Finder::notify(SCNotification *notification) @@ -333,7 +347,7 @@ bool Finder::notify(SCNotification *notification) int currentPos = _scintView.execute(SCI_GETCURRENTPOS); if (currentPos) { - char prevChar = (char)_scintView.execute(SCI_GETCHARAT, currentPos - 1); + TCHAR prevChar = (TCHAR)_scintView.execute(SCI_GETCHARAT, currentPos - 1); if (prevChar == 0x0A) currentPos -= 2; } @@ -386,7 +400,7 @@ bool Finder::notify(SCNotification *notification) return true; } catch(...){ - printStr("SCN_DOUBLECLICK problem"); + printStr(TEXT("SCN_DOUBLECLICK problem")); } break; } @@ -460,11 +474,8 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP doDialog((DIALOG_TYPE)indexClicked); if ((DIALOG_TYPE)indexClicked == FINDINFILES_DLG) { - wchar_t currentDirW[MAX_PATH]; - ::GetCurrentDirectoryW(MAX_PATH, currentDirW); - char currentDir[MAX_PATH]; - wchar2char(currentDirW, currentDir); - + TCHAR currentDir[MAX_PATH]; + ::GetCurrentDirectory(MAX_PATH, currentDir); setFindInFilesDirFilter(currentDir, NULL); } } @@ -522,11 +533,11 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP //Single actions case IDOK : // Find Next { + bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; if ((_currentStatus == FIND_DLG) || (_currentStatus == REPLACE_DLG)) { - bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); - string str2Search = getTextFromCombo(hFindCombo, isUnicode); + basic_string str2Search = getTextFromCombo(hFindCombo, isUnicode); updateCombo(IDFINDWHAT); processFindNext(str2Search.c_str()); } @@ -541,11 +552,10 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP { if (_currentStatus == REPLACE_DLG) { - bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH); - string str2Search = getTextFromCombo(hFindCombo, isUnicode); - string str2Replace = getTextFromCombo(hReplaceCombo, isUnicode); + basic_string str2Search = getTextFromCombo(hFindCombo); + basic_string str2Replace = getTextFromCombo(hReplaceCombo); updateCombos(); processReplace(str2Search.c_str(), str2Replace.c_str()); } @@ -566,22 +576,18 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP { if (_currentStatus == FINDINFILES_DLG) { - char filters[256]; - wchar_t filtersW[256]; - ::GetDlgItemTextW(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filtersW, sizeof(filtersW)); - wchar2char(filtersW, filters); - addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO), true); + TCHAR filters[256]; + TCHAR directory[MAX_PATH]; + ::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, sizeof(filters)); + addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO)); _filters = filters; - char directory[MAX_PATH]; - wchar_t directoryW[MAX_PATH]; - ::GetDlgItemTextW(_hSelf, IDD_FINDINFILES_DIR_COMBO, directoryW, sizeof(directoryW)); - wchar2char(directoryW, directory); - addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO), true); + ::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, sizeof(directory)); + addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO)); _directory = directory; - if ((strlen(directory) > 0) && (directory[strlen(directory)-1] != '\\')) - _directory += "\\"; + if ((lstrlen(directory) > 0) && (directory[lstrlen(directory)-1] != '\\')) + _directory += TEXT("\\"); updateCombo(IDFINDWHAT); findAllIn(FILES_IN_DIR); @@ -610,15 +616,15 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP int nbReplaced = processAll(ProcessReplaceAll, NULL, NULL); (*_ppEditView)->execute(SCI_ENDUNDOACTION); - char result[64]; + TCHAR result[64]; if (nbReplaced < 0) - strcpy(result, "The regular expression to search is formed badly"); + lstrcpy(result, TEXT("The regular expression to search is formed badly")); else { - itoa(nbReplaced, result, 10); - strcat(result, " tokens are replaced."); + wsprintf(result, TEXT("%d"), nbReplaced); + lstrcat(result, TEXT(" tokens are replaced.")); } - ::MessageBox(_hSelf, result, "", MB_OK); + ::MessageBox(_hSelf, result, TEXT(""), MB_OK); } } return TRUE; @@ -628,15 +634,15 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP if (_currentStatus == FIND_DLG) { int nbCounted = processAll(ProcessCountAll, NULL, NULL); - char result[128]; + TCHAR result[128]; if (nbCounted < 0) - strcpy(result, "The regular expression to search is formed badly.\r\nIs it resulting in nothing?"); + lstrcpy(result, TEXT("The regular expression to search is formed badly.\r\nIs it resulting in nothing?")); else - { - itoa(nbCounted, result, 10); - strcat(result, " tokens are found."); - } - ::MessageBox(_hSelf, result, "", MB_OK); + { + wsprintf(result, TEXT("%d"), nbCounted); + lstrcat(result, TEXT(" tokens are found.")); + } + ::MessageBox(_hSelf, result, TEXT(""), MB_OK); } } return TRUE; @@ -648,15 +654,15 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP updateCombo(IDFINDWHAT); int nbMarked = processAll(ProcessMarkAll, NULL, NULL); - char result[128]; + TCHAR result[128]; if (nbMarked < 0) - strcpy(result, "The regular expression to search is formed badly.\r\nIs it resulting in nothing?"); + lstrcpy(result, TEXT("The regular expression to search is formed badly.\r\nIs it resulting in nothing?")); else { - itoa(nbMarked, result, 10); - strcat(result, " tokens are found."); + wsprintf(result, TEXT("%d"), nbMarked); + lstrcat(result, TEXT(" tokens are found.")); } - ::MessageBox(_hSelf, result, "", MB_OK); + ::MessageBox(_hSelf, result, TEXT(""), MB_OK); } } return TRUE; @@ -814,16 +820,16 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP // return value : // true : the text2find is found // false : the text2find is not found -bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) +bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, FindOption *options) { if (!txt2find || !txt2find[0]) return false; FindOption *pOptions = options?options:&_options; - int stringSizeFind = strlen(txt2find); - char *pText = new char[stringSizeFind + 1]; - strcpy(pText, txt2find); + int stringSizeFind = lstrlen(txt2find); + TCHAR *pText = new TCHAR[stringSizeFind + 1]; + lstrcpy(pText, txt2find); if (pOptions->_searchType == FindExtended) { stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind); @@ -851,11 +857,9 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) bool isRegExp = pOptions->_searchType == FindRegex; int flags = Searching::buildSearchFlags(pOptions); - (*_ppEditView)->execute(SCI_SETTARGETSTART, startPosition); - (*_ppEditView)->execute(SCI_SETTARGETEND, endPosition); - (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); - int posFind = int((*_ppEditView)->execute(SCI_SEARCHINTARGET, stringSizeFind, (LPARAM)pText)); + (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); + int posFind = (*_ppEditView)->searchInTarget(pText, startPosition, endPosition); if (posFind == -1) //no match found in target, check if a new target should be used { if (pOptions->_isWrapAround) @@ -873,27 +877,18 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) } //new target, search again - (*_ppEditView)->execute(SCI_SETTARGETSTART, startPosition); - (*_ppEditView)->execute(SCI_SETTARGETEND, endPosition); - posFind = int((*_ppEditView)->execute(SCI_SEARCHINTARGET, stringSizeFind, (LPARAM)pText)); + posFind = (*_ppEditView)->searchInTarget(pText, startPosition, endPosition); } if (posFind == -1) { //failed, or failed twice with wrap + if (!pOptions->_isIncremental) //incremental search doesnt trigger messages + { + basic_string msg = TEXT("Can't find the text:\r\n\""); + msg += pText; + msg += TEXT("\""); + ::MessageBox(_hSelf, msg.c_str(), TEXT("Find"), MB_OK); - if (!pOptions->_isIncremental) { //incremental search doesnt trigger messages - const char stringMaxSize = 64; - char message[30 + stringMaxSize + 4]; //message, string, dots - wchar_t messageW[30 + stringMaxSize + 4]; //message, string, dots - strcpy(message, "Can't find the text:\r\n\""); - strncat(message, pText, stringMaxSize); - strcat(message, "\""); - if (strlen(pText) > stringMaxSize) { - strcat(message, "..."); - } - - char2wchar(message, messageW); - ::MessageBoxW(_hSelf, messageW, L"Find", MB_OK); // if the dialog is not shown, pass the focus to his parent(ie. Notepad++) if (!::IsWindowVisible(_hSelf)) ::SetFocus((*_ppEditView)->getHSelf()); @@ -918,7 +913,7 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) // true : the text is replaced, and find the next occurrence // false : the text2find is not found, so the text is NOT replace // || the text is replaced, and do NOT find the next occurrence -bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replace, FindOption *options) +bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2replace, FindOption *options) { if (!txt2find || !txt2find[0] || !txt2replace) return false; @@ -927,12 +922,12 @@ bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replac if ((*_ppEditView)->getCurrentBuffer()->isReadOnly()) return false; - int stringSizeFind = strlen(txt2find); - int stringSizeReplace = strlen(txt2replace); - char *pTextFind = new char[stringSizeFind + 1]; - char *pTextReplace = new char[stringSizeReplace + 1]; - strcpy(pTextFind, txt2find); - strcpy(pTextReplace, txt2replace); + int stringSizeFind = lstrlen(txt2find); + int stringSizeReplace = lstrlen(txt2replace); + TCHAR *pTextFind = new TCHAR[stringSizeFind + 1]; + TCHAR *pTextReplace = new TCHAR[stringSizeReplace + 1]; + lstrcpy(pTextFind, txt2find); + lstrcpy(pTextReplace, txt2replace); if (pOptions->_searchType == FindExtended) { stringSizeFind = Searching::convertExtendedToString(txt2find, pTextFind, stringSizeFind); @@ -943,12 +938,8 @@ bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replac int flags = Searching::buildSearchFlags(pOptions); CharacterRange cr = (*_ppEditView)->getSelection(); - (*_ppEditView)->execute(SCI_SETTARGETSTART, cr.cpMin); - (*_ppEditView)->execute(SCI_SETTARGETEND, cr.cpMax); (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); - - int posFind = int((*_ppEditView)->execute(SCI_SEARCHINTARGET, (WPARAM)stringSizeFind, (LPARAM)pTextFind)); - + int posFind = (*_ppEditView)->searchInTarget(pTextFind, cr.cpMin, cr.cpMax); if (posFind != -1) { if (isRegExp) @@ -958,7 +949,7 @@ bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replac int end = int((*_ppEditView)->execute(SCI_GETTARGETEND)); int foundTextLen = (end >= start)?end - start:start - end; - int replacedLen = (*_ppEditView)->execute(SCI_REPLACETARGETRE, stringSizeReplace, (LPARAM)pTextReplace); + int replacedLen = (*_ppEditView)->replaceTargetRegExMode(pTextReplace); //if (!foundTextLen) (*_ppEditView)->execute(SCI_SETSEL, start, start + replacedLen); @@ -966,7 +957,7 @@ bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replac else { int start = int((*_ppEditView)->execute(SCI_GETTARGETSTART)); - int replacedLen = (*_ppEditView)->execute(SCI_REPLACETARGET, stringSizeReplace, (LPARAM)pTextReplace); + int replacedLen = (*_ppEditView)->replaceTarget(pTextReplace); (*_ppEditView)->execute(SCI_SETSEL, start, start + replacedLen); } } @@ -976,14 +967,14 @@ bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replac return processFindNext(txt2find); //after replacing, find the next section for selection } -int FindReplaceDlg::markAll(const char *txt2find) +int FindReplaceDlg::markAll(const TCHAR *txt2find) { _doStyleFoundToken = true; int nbFound = processAll(ProcessMarkAll, txt2find, NULL, true, NULL); return nbFound; } -int FindReplaceDlg::markAll2(const char *txt2find) +int FindReplaceDlg::markAll2(const TCHAR *txt2find) { FindOption opt; opt._isMatchCase = false; @@ -992,13 +983,13 @@ int FindReplaceDlg::markAll2(const char *txt2find) return nbFound; } -int FindReplaceDlg::markAllInc(const char *txt2find, FindOption *opt) +int FindReplaceDlg::markAllInc(const TCHAR *txt2find, FindOption *opt) { int nbFound = processAll(ProcessMarkAll_IncSearch, txt2find, NULL, true, NULL, opt); return nbFound; } -int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const char *txt2replace, bool isEntire, const char *fileName, FindOption *opt) +int FindReplaceDlg::processAll(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, bool isEntire, const TCHAR *fileName, FindOption *opt) { FindOption *pOptions = opt?opt:&_options; @@ -1043,7 +1034,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const return processRange(op, txt2find, txt2replace, startPosition, endPosition, fileName, opt); } -int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, const char *txt2replace, int startRange, int endRange, const char *fileName, FindOption *opt) +int FindReplaceDlg::processRange(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, int startRange, int endRange, const TCHAR *fileName, FindOption *opt) { int nbProcessed = 0; @@ -1057,7 +1048,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons return nbProcessed; if (!fileName) - fileName = ""; + fileName = TEXT(""); FindOption *pOptions = opt?opt:&_options; bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; @@ -1065,17 +1056,17 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons int stringSizeFind = 0; int stringSizeReplace = 0; - char *pTextFind = NULL;//new char[stringSizeFind + 1]; + TCHAR *pTextFind = NULL;//new TCHAR[stringSizeFind + 1]; if (!txt2find) { HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); - string str2Search = getTextFromCombo(hFindCombo, isUnicode); + basic_string str2Search = getTextFromCombo(hFindCombo, isUnicode); stringSizeFind = str2Search.length(); - pTextFind = new char[stringSizeFind + 1]; - strcpy(pTextFind, str2Search.c_str()); + pTextFind = new TCHAR[stringSizeFind + 1]; + lstrcpy(pTextFind, str2Search.c_str()); } else { - stringSizeFind = strlen(txt2find); - pTextFind = new char[stringSizeFind + 1]; - strcpy(pTextFind, txt2find); + stringSizeFind = lstrlen(txt2find); + pTextFind = new TCHAR[stringSizeFind + 1]; + lstrcpy(pTextFind, txt2find); } if (!pTextFind[0]) { @@ -1083,18 +1074,18 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons return nbProcessed; } - char *pTextReplace = NULL; + TCHAR *pTextReplace = NULL; if (op == ProcessReplaceAll) { if (!txt2replace) { HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH); - string str2Replace = getTextFromCombo(hReplaceCombo, isUnicode); + basic_string str2Replace = getTextFromCombo(hReplaceCombo, isUnicode); stringSizeReplace = str2Replace.length(); - pTextReplace = new char[stringSizeReplace + 1]; - strcpy(pTextReplace, str2Replace.c_str()); + pTextReplace = new TCHAR[stringSizeReplace + 1]; + lstrcpy(pTextReplace, str2Replace.c_str()); } else { - stringSizeReplace = strlen(txt2replace); - pTextReplace = new char[stringSizeReplace + 1]; - strcpy(pTextReplace, txt2replace); + stringSizeReplace = lstrlen(txt2replace); + pTextReplace = new TCHAR[stringSizeReplace + 1]; + lstrcpy(pTextReplace, txt2replace); } } @@ -1107,10 +1098,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons bool isRegExp = pOptions->_searchType == FindRegex; int flags = Searching::buildSearchFlags(pOptions); - //Initial range for searching - (*_ppEditView)->execute(SCI_SETTARGETSTART, startRange); - (*_ppEditView)->execute(SCI_SETTARGETEND, endRange); - (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); + if (op == ProcessMarkAll) //if marking, check if purging is needed { @@ -1126,11 +1114,14 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons int targetStart = 0; int targetEnd = 0; - targetStart = int((*_ppEditView)->execute(SCI_SEARCHINTARGET, (WPARAM)stringSizeFind, (LPARAM)pTextFind)); + //Initial range for searching + (*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags); + targetStart = (*_ppEditView)->searchInTarget(pTextFind, startRange, endRange); if ((targetStart != -1) && (op == ProcessFindAll)) //add new filetitle if this file results in hits { - const int fileNameLen = strlen(fileName); + /* Don't remember why : + const int fileNameLen = lstrlen(fileName); if (fileNameLen > _fileNameLenMax) { @@ -1140,7 +1131,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons _uniFileName = new char[(fileNameLen + 3) * 2 + 1]; } ascii_to_utf8(fileName, fileNameLen, _uniFileName); - _pFinder->addFileNameTitle(_uniFileName); + */ + _pFinder->addFileNameTitle(fileName); } while (targetStart != -1) { @@ -1168,43 +1160,30 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber); int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber); int nbChar = lend - lstart; - bool isRealloc = false; - if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer - { - isRealloc = true; - _maxNbCharAllocated = nbChar; - delete [] _line; - _line = new char[_maxNbCharAllocated + 3]; + // use the static buffer + TCHAR lineBuf[1024]; - // also resize unicode buffer - const int uniCharLen = (_maxNbCharAllocated + 3) * 2 + 1; - delete [] _uniCharLine; - _uniCharLine = new char[uniCharLen]; - } - (*_ppEditView)->execute(SCI_GETLINE, lineNumber, (LPARAM)_line); - _line[nbChar] = 0x0D; - _line[nbChar+1] = 0x0A; - _line[nbChar+2] = '\0'; + if (nbChar > 1024 - 3) + lend = lstart + 1020; - const char *pLine; - if (!isUnicode) - { - ascii_to_utf8(_line, (nbChar + 3), _uniCharLine); - pLine = _uniCharLine; - } - else - { - pLine = _line; - } - _pFinder->add(FoundInfo(targetStart, targetEnd, pLine, fileName, _pFinder->_lineCounter), lineNumber + 1); + (*_ppEditView)->getGenericText(lineBuf, lstart, lend); + basic_string line = lineBuf; + line += TEXT("\r\n"); + + _pFinder->add(FoundInfo(targetStart, targetEnd, line.c_str(), fileName, _pFinder->_lineCounter), lineNumber + 1); break; } case ProcessReplaceAll: { - int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace); + int replacedLength; + if (isRegExp) + replacedLength = (*_ppEditView)->replaceTargetRegExMode(pTextReplace); + else + replacedLength = (*_ppEditView)->replaceTarget(pTextReplace); + replaceDelta = replacedLength - foundTextLen; break; } @@ -1259,13 +1238,10 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons startRange = targetStart + foundTextLen + replaceDelta; //search from result onwards endRange += replaceDelta; //adjust end of range in case of replace - (*_ppEditView)->execute(SCI_SETTARGETSTART, startRange); - (*_ppEditView)->execute(SCI_SETTARGETEND, endRange); nbProcessed++; - targetStart = (int)((*_ppEditView)->execute(SCI_SEARCHINTARGET, (WPARAM)stringSizeFind, (LPARAM)pTextFind)); + targetStart = (*_ppEditView)->searchInTarget(pTextFind, startRange, endRange); } - delete [] pTextFind; delete [] pTextReplace; @@ -1279,7 +1255,7 @@ void FindReplaceDlg::replaceAllInOpenedDocs() void FindReplaceDlg::findAllIn(InWhat op) { - //HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, "findInFilesEvent"); + //HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("findInFilesEvent")); if (!_pFinder) { _pFinder = new Finder(); @@ -1292,7 +1268,7 @@ void FindReplaceDlg::findAllIn(InWhat op) data.hIconTab = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_FIND_RESULT_ICON), IMAGE_ICON, 0, 0, LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); data.pszAddInfo = _findAllResultStr; - data.pszModuleName = "dummy"; + data.pszModuleName = TEXT("dummy"); // the dlgDlg should be the index of funcItem where the current function pointer is // in this case is DOCKABLE_DEMO_INDEX @@ -1329,8 +1305,8 @@ void FindReplaceDlg::findAllIn(InWhat op) finInFileOpt |= _isInHiddenDir?FIND_INHIDDENDIR:0; ::SendMessage(_hParent, (op==ALL_OPEN_DOCS)?WM_FINDALL_INOPENEDDOC:WM_FINDINFILES, 0, (op!=ALL_OPEN_DOCS)?finInFileOpt:0); - //char *pDataToWrite = _findAllResultStr + strlen(FIND_RESULT_DEFAULT_TITLE); - sprintf(_findAllResultStr, "%d hits", _findAllResult); + //TCHAR *pDataToWrite = _findAllResultStr + lstrlen(FIND_RESULT_DEFAULT_TITLE); + wsprintf(_findAllResultStr, TEXT("%d hits"), _findAllResult); ::SendMessage(_hParent, NPPM_DMMSHOW, 0, (LPARAM)_pFinder->getHSelf()); } @@ -1368,7 +1344,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable) ::MoveWindow(::GetDlgItem(_hSelf, IDCANCEL), pClosePos->left, pClosePos->top, pClosePos->right, pClosePos->bottom, TRUE); - char label[MAX_PATH]; + TCHAR label[MAX_PATH]; _tab.getCurrentTitle(label, sizeof(label)); ::SetWindowText(_hSelf, label); } @@ -1410,12 +1386,12 @@ void FindReplaceDlg::enableFindInFilesControls(bool isEnable) ::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK), isEnable?SW_SHOW:SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK), isEnable?SW_SHOW:SW_HIDE); - char label[MAX_PATH]; + TCHAR label[MAX_PATH]; _tab.getCurrentTitle(label, sizeof(label)); ::SetWindowText(_hSelf, label); } -void FindReplaceDlg::getPatterns(vector & patternVect) +void FindReplaceDlg::getPatterns(vector> & patternVect) { cutString(_filters.c_str(), patternVect); } @@ -1485,11 +1461,11 @@ BOOL CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) ::GetCursorPos(&p); ContextMenu scintillaContextmenu; vector tmp; - tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERCOLLAPSE, "Collapse all")); - tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERUNCOLLAPSE, "Uncollapse all")); - tmp.push_back(MenuItemUnit(0, "Separator")); - tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERCOPY, "Copy")); - tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERSELECTALL, "Select All")); + tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERCOLLAPSE, TEXT("Collapse all"))); + tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERUNCOLLAPSE, TEXT("Uncollapse all"))); + tmp.push_back(MenuItemUnit(0, TEXT("Separator"))); + tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERCOPY, TEXT("Copy"))); + tmp.push_back(MenuItemUnit(NPPM_INTERNAL_SCINTILLAFINFERSELECTALL, TEXT("Select All"))); scintillaContextmenu.create(_hSelf, tmp); @@ -1560,7 +1536,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM if (LOWORD(wParam) == IDC_INCFINDPREVOK) fo._whichDirection = DIR_UP; - string str2Search = _pFRDlg->getTextFromCombo(::GetDlgItem(_hSelf, IDC_INCFINDTEXT), isUnicode); + basic_string str2Search = _pFRDlg->getTextFromCombo(::GetDlgItem(_hSelf, IDC_INCFINDTEXT), isUnicode); _pFRDlg->processFindNext(str2Search.c_str(), &fo); } return TRUE; @@ -1576,7 +1552,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM fo._isIncremental = true; fo._isMatchCase = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDMATCHCASE, BM_GETCHECK, 0, 0)); - string str2Search = _pFRDlg->getTextFromCombo(::GetDlgItem(_hSelf, IDC_INCFINDTEXT), isUnicode); + basic_string str2Search = _pFRDlg->getTextFromCombo(::GetDlgItem(_hSelf, IDC_INCFINDTEXT), isUnicode); bool isFound = _pFRDlg->processFindNext(str2Search.c_str(), &fo); if (!isFound) { @@ -1585,7 +1561,7 @@ BOOL CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM } bool isHiLieAll = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_INCFINDHILITEALL, BM_GETCHECK, 0, 0)); - if (str2Search == "") + if (str2Search == TEXT("")) isHiLieAll = false; markSelectedTextInc(isHiLieAll, &fo); @@ -1636,8 +1612,8 @@ void FindIncrementDlg::markSelectedTextInc(bool enable, FindOption *opt) if (range.cpMin == range.cpMax) return; - char text2Find[MAX_PATH]; - (*(_pFRDlg->_ppEditView))->getSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false) + TCHAR text2Find[MAX_PATH]; + (*(_pFRDlg->_ppEditView))->getGenericSelectedText(text2Find, sizeof(text2Find), false); //do not expand selection (false) _pFRDlg->markAllInc(text2Find, opt); } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index d2c9498f..5f3109e1 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -24,7 +24,6 @@ #include "ScintillaEditView.h" #include "StatusBar.h" #include "DockingDlgInterface.h" -#include "UniConversion.h" #define FIND_RECURSIVE 1 @@ -42,12 +41,12 @@ typedef bool InWhat; #define FILES_IN_DIR false struct FoundInfo { - FoundInfo(int start, int end, const char *foundLine, const char *fullPath, size_t lineNum) + FoundInfo(int start, int end, const TCHAR *foundLine, const TCHAR *fullPath, size_t lineNum) : _start(start), _end(end), _foundLine(foundLine), _fullPath(fullPath), _scintLineNumber(lineNum){}; int _start; int _end; - std::string _foundLine; - std::string _fullPath; + std::basic_string _foundLine; + std::basic_string _fullPath; size_t _scintLineNumber; }; @@ -73,7 +72,7 @@ struct FindOption { //This class contains generic search functions as static functions for easy access class Searching { public: - static int convertExtendedToString(const char * query, char * result, int length); + static int convertExtendedToString(const TCHAR * query, TCHAR * result, int length); static TargetRange t; static int buildSearchFlags(FindOption * option) { return (option->_isWholeWord ? SCFIND_WHOLEWORD : 0) | @@ -83,7 +82,7 @@ public: static void displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards = true); private: - static bool readBase(const char * string, int * value, int base, int size); + static bool readBase(const TCHAR * str, int * value, int base, int size); }; @@ -101,34 +100,35 @@ public: _ppEditView = ppEditView; }; - void addFileNameTitle(const char *fileName) { - string str = "["; + void addFileNameTitle(const TCHAR * fileName) { + basic_string str = TEXT("["); str += fileName; - str += "]\n"; + str += TEXT("]\n"); setFinderReadOnly(false); - _scintView.execute(SCI_APPENDTEXT, str.length(), (LPARAM)str.c_str()); + _scintView.appandGenericText(str.c_str()); setFinderReadOnly(true); _lineCounter++; }; void add(FoundInfo fi, int lineNb) { _foundInfos.push_back(fi); - std::string str = "Line "; + std::basic_string str = TEXT("Line "); - char lnb[16]; - str += itoa(lineNb, lnb, 10); - str += " : "; + TCHAR lnb[16]; + wsprintf(lnb, TEXT("%d"), lineNb); + str += lnb; + str += TEXT(" : "); str += fi._foundLine; if (str.length() >= SC_SEARCHRESULT_LINEBUFFERMAXLENGTH) { - const char * endOfLongLine = "...\r\n"; - str = str.substr(0, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - strlen(endOfLongLine) - 1); + const TCHAR * endOfLongLine = TEXT("...\r\n"); + str = str.substr(0, SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - lstrlen(endOfLongLine) - 1); str += endOfLongLine; } setFinderReadOnly(false); - _scintView.execute(SCI_APPENDTEXT, str.length(), (LPARAM)str.c_str()); + _scintView.appandGenericText(str.c_str()); setFinderReadOnly(true); _lineCounter++; }; @@ -164,12 +164,11 @@ public: InWhat getMode() const {return _mode;}; void setMode(InWhat mode) {_mode = mode;}; - void setSearchWord(const char *word2search) { - _scintView.setKeywords(L_SEARCHRESULT, word2search, 0); + void setSearchWord(const TCHAR *word2search) { + _scintView.setHiLiteResultWords(word2search); }; - protected : virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); bool notify(SCNotification *notification); @@ -193,20 +192,17 @@ class FindReplaceDlg : public StaticDialog friend class FindIncrementDlg; public : FindReplaceDlg() : StaticDialog(), _pFinder(NULL), _isRTL(false), _isRecursive(true),_isInHiddenDir(false),\ - _maxNbCharAllocated(1024), _fileNameLenMax(1024) { - _line = new char[_maxNbCharAllocated + 3]; - _uniCharLine = new char[(_maxNbCharAllocated + 3) * 2]; + _fileNameLenMax(1024) { + //_line = new TCHAR[_maxNbCharAllocated + 3]; + //_uniCharLine = new char[(_maxNbCharAllocated + 3) * 2]; _uniFileName = new char[(_fileNameLenMax + 3) * 2]; _winVer = (NppParameters::getInstance())->getWinVersion(); - //strcpy(_findAllResultStr, FIND_RESULT_DEFAULT_TITLE); + //lstrcpy(_findAllResultStr, FIND_RESULT_DEFAULT_TITLE); }; ~FindReplaceDlg() { _tab.destroy(); if (_pFinder) delete _pFinder; - - delete [] _line; - delete [] _uniCharLine; delete [] _uniFileName; }; @@ -252,18 +248,19 @@ public : ::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT)); display(); }; - bool processFindNext(const char *txt2find, FindOption *options = NULL); - bool processReplace(const char *txt2find, const char *txt2replace, FindOption *options = NULL); + bool processFindNext(const TCHAR *txt2find, FindOption *options = NULL); + bool processReplace(const TCHAR *txt2find, const TCHAR *txt2replace, FindOption *options = NULL); - int markAll(const char *str2find); - int markAll2(const char *str2find); - int markAllInc(const char *str2find, FindOption *opt); + int markAll(const TCHAR *str2find); + int markAll2(const TCHAR *str2find); + int markAllInc(const TCHAR *str2find, FindOption *opt); - int processAll(ProcessOperation op, const char *txt2find, const char *txt2replace, bool isEntire = false, const char *fileName = NULL, FindOption *opt = NULL); - int processRange(ProcessOperation op, const char *txt2find, const char *txt2replace, int startRange, int endRange, const char *fileName = NULL, FindOption *opt = NULL); + int processAll(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, bool isEntire = false, const TCHAR *fileName = NULL, FindOption *opt = NULL); + int processRange(ProcessOperation op, const TCHAR *txt2find, const TCHAR *txt2replace, int startRange, int endRange, const TCHAR *fileName = NULL, FindOption *opt = NULL); void replaceAllInOpenedDocs(); void findAllIn(InWhat op); - void setSearchText(const char * txt2find, bool isUTF8 = false) { + + void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) { addText2Combo(txt2find, ::GetDlgItem(_hSelf, IDFINDWHAT), isUTF8); } @@ -280,50 +277,43 @@ public : }; void setSearchWord2Finder(){ - string str2Search = getText2search(); + basic_string str2Search = getText2search(); _pFinder->setSearchWord(str2Search.c_str()); }; - const char * getDir2Search() const {return _directory.c_str();}; + const TCHAR * getDir2Search() const {return _directory.c_str();}; - void getPatterns(vector & patternVect); + void getPatterns(vector> & patternVect); void launchFindInFilesDlg() { doDialog(FINDINFILES_DLG); }; - void setFindInFilesDirFilter(const char *dir, const char *filters) { + void setFindInFilesDirFilter(const TCHAR *dir, const TCHAR *filters) { if (dir) { _directory = dir; - - wchar_t dirW[MAX_PATH]; - char2wchar(dir, dirW); - ::SetDlgItemTextW(_hSelf, IDD_FINDINFILES_DIR_COMBO, dirW); + ::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir); } if (filters) { _filters = filters; - - wchar_t filtersW[MAX_PATH]; - char2wchar(filters, filtersW); - ::SetDlgItemTextW(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filtersW); + ::SetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters); } }; - string getText2search() const { - bool isUnicode = (*_ppEditView)->getCurrentBuffer()->getUnicodeMode() != uni8Bit; - return getTextFromCombo(::GetDlgItem(_hSelf, IDFINDWHAT), isUnicode); + basic_string getText2search() const { + return getTextFromCombo(::GetDlgItem(_hSelf, IDFINDWHAT)); }; - const string & getFilters() const {return _filters;}; - const string & getDirectory() const {return _directory;}; + const basic_string & getFilters() const {return _filters;}; + const basic_string & getDirectory() const {return _directory;}; const FindOption & getCurrentOptions() const {return _options;}; protected : virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); - void addText2Combo(const char * txt2add, HWND comboID, bool isUTF8 = false); - string getTextFromCombo(HWND hCombo, bool isUnicode) const; + void addText2Combo(const TCHAR * txt2add, HWND comboID, bool isUTF8 = false); + basic_string getTextFromCombo(HWND hCombo, bool isUnicode = false) const; private : DIALOG_TYPE _currentStatus; @@ -344,17 +334,17 @@ private : //FindInFilesDlg _findInFilesDlg; int _findAllResult; - char _findAllResultStr[128]; + TCHAR _findAllResultStr[128]; - string _filters; - string _directory; + basic_string _filters; + basic_string _directory; bool _isRecursive; bool _isInHiddenDir; - int _maxNbCharAllocated; + //int _maxNbCharAllocated; int _fileNameLenMax; - char *_line; - char *_uniCharLine; + //TCHAR *_line; + //char *_uniCharLine; char *_uniFileName; TabBar _tab; @@ -406,8 +396,11 @@ public : virtual void destroy(); virtual void display(bool toShow = true) const; - void setSearchText(const char * txt2find, bool isUTF8 = false) { + void setSearchText(const TCHAR * txt2find, bool isUTF8 = false) { _doSearchFromBegin = false; +#ifdef UNICODE + ::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find); +#else if (!isUTF8) { ::SendDlgItemMessage(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)txt2find); @@ -416,6 +409,7 @@ public : WCHAR wchars[256]; ::MultiByteToWideChar(CP_UTF8, 0, txt2find, -1, wchars, 256 / sizeof(WCHAR)); ::SendDlgItemMessageW(_hSelf, IDC_INCFINDTEXT, WM_SETTEXT, 0, (LPARAM)wchars); +#endif } void addToRebar(ReBar * rebar); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc index 16c6dd62..a980abfc 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc @@ -28,7 +28,7 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Replace" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN RTEXT "Find what :",IDFINDWHAT_STATIC,6,22,75,8 COMBOBOX IDFINDWHAT,83,20,125,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP @@ -48,8 +48,8 @@ BEGIN RTEXT "Directory :",IDD_FINDINFILES_DIR_STATIC,7,58,40,8 COMBOBOX IDD_FINDINFILES_DIR_COMBO,49,57,141,150, CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP PUSHBUTTON "...",IDD_FINDINFILES_BROWSE_BUTTON,193,56,16,14 - CONTROL "In all sub-folders",IDD_FINDINFILES_RECURSIVE_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,49,70,80,15 - CONTROL "In hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK, "Button", BS_AUTOCHECKBOX | WS_TABSTOP,129,70,80,15 + CONTROL "In all sub-folders",IDD_FINDINFILES_RECURSIVE_CHECK, TEXT("Button"), BS_AUTOCHECKBOX | WS_TABSTOP,49,70,80,15 + CONTROL "In hidden folders",IDD_FINDINFILES_INHIDDENDIR_CHECK, TEXT("Button"), BS_AUTOCHECKBOX | WS_TABSTOP,129,70,80,15 CONTROL "Match &whole word only",IDWHOLEWORD,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,6,88,110,15 CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,100,110,15 @@ -83,7 +83,7 @@ END IDD_INCREMENT_FIND DIALOGEX 0, 0, 400, 20 STYLE DS_SYSMODAL | DS_CONTROL | DS_FIXEDSYS | WS_CHILD | WS_CLIPCHILDREN //EXSTYLE WS_EX_TRANSPARENT -FONT 8, "MS Shell Dlg" +FONT 8, TEXT("MS Shell Dlg") BEGIN PUSHBUTTON "X",IDCANCEL,2,3,16,14 RTEXT "Find :",IDC_INCSTATIC,20,6,25,12 @@ -98,7 +98,7 @@ IDD_FINDRESULT DIALOGEX 26, 41, 223, 67 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Find result" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN DEFPUSHBUTTON ">",IDC_INCFINDNXTOK,243,0,16,14, NOT WS_VISIBLE END diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp index dcf0c0f6..3f4c230a 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.cpp @@ -19,10 +19,10 @@ struct Token { - char * token; + TCHAR * token; int length; bool isIdentifier; - Token(char * tok, int len, bool isID) : token(tok), length(len), isIdentifier(isID) {}; + Token(TCHAR * tok, int len, bool isID) : token(tok), length(len), isIdentifier(isID) {}; }; struct FunctionValues { @@ -33,11 +33,11 @@ struct FunctionValues { FunctionValues() : lastIdentifier(-1), lastFunctionIdentifier(-1), param(0), scopeLevel(-1) {}; }; -inline bool lower(char c) { +inline bool lower(TCHAR c) { return (c >= 'a' && c <= 'z'); } -inline bool match(char c1, char c2) { +inline bool match(TCHAR c1, TCHAR c2) { if (c1 == c2) return true; if (lower(c1)) return ((c1-32) == c2); @@ -46,9 +46,9 @@ inline bool match(char c1, char c2) { return false; } -//test string case insensitive ala Scintilla +//test basic_string case insensitive ala Scintilla //0 if equal, <0 of before, >0 if after (name1 that is) -int testNameNoCase(const char * name1, const char * name2, int len = -1) { +int testNameNoCase(const TCHAR * name1, const TCHAR * name2, int len = -1) { if (len == -1) { len = 1024; //magic value, but it probably fails way before it reaches this } @@ -120,21 +120,21 @@ bool FunctionCallTip::getCursorFunction() { reset(); return false; //cannot be a func, need name and separator } - char * lineData = new char[len]; - _pEditView->execute(SCI_GETLINE, line, (LPARAM)lineData); + TCHAR * lineData = new TCHAR[len]; + _pEditView->getLine(line, lineData, len); //line aquired, find the functionname //first split line into tokens to parse //token is identifier or some expression, whitespace is ignored std::vector< Token > tokenVector; int tokenLen = 0; - char ch; + TCHAR ch; for (int i = 0; i < offset; i++) { //we dont care about stuff after the offset //tokenVector.push_back(pair(lineData+i, len)); ch = lineData[i]; if (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_') { //part of identifier tokenLen = 0; - char * begin = lineData+i; + TCHAR * begin = lineData+i; while ( (ch >= 'A' && ch <= 'Z' || ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '_') && i < offset) { tokenLen++; i++; @@ -212,16 +212,16 @@ bool FunctionCallTip::getCursorFunction() { bool same = false; if (_funcName) { if(_ignoreCase) - same = testNameNoCase(_funcName, funcToken.token, strlen(_funcName)) == 0; + same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0; else - same = strncmp(_funcName, funcToken.token, strlen(_funcName)) == 0; + same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0; } if (!same) { //check if we need to reload data if (_funcName) { delete [] _funcName; } - _funcName = new char[funcToken.length+1]; - strcpy(_funcName, funcToken.token); + _funcName = new TCHAR[funcToken.length+1]; + lstrcpy(_funcName, funcToken.token); res = loadFunction(); } else { res = true; @@ -240,21 +240,21 @@ bool FunctionCallTip::loadFunction() { _curFunction = NULL; //Iterate through all keywords and find the correct function keyword TiXmlElement *funcNode = _pXmlKeyword; - const char * name = NULL; - for (; funcNode; funcNode = funcNode->NextSiblingElement("KeyWord") ) { - name = funcNode->Attribute("name"); + const TCHAR * name = NULL; + for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) { + name = funcNode->Attribute(TEXT("name")); if (!name) //malformed node continue; int compVal = 0; if (_ignoreCase) - compVal = testNameNoCase(name, _funcName); //strcmpi doesnt work in this case + compVal = testNameNoCase(name, _funcName); //lstrcmpi doesnt work in this case else - compVal = strcmp(name, _funcName); + compVal = lstrcmp(name, _funcName); if (!compVal) { //found it? - const char * val = funcNode->Attribute("func"); + const TCHAR * val = funcNode->Attribute(TEXT("func")); if (val) { - if (!strcmp(val, "yes")) { + if (!lstrcmp(val, TEXT("yes"))) { //what we've been looking for _curFunction = funcNode; break; @@ -274,23 +274,23 @@ bool FunctionCallTip::loadFunction() { stringVec paramVec; - TiXmlElement *overloadNode = _curFunction->FirstChildElement("Overload"); + TiXmlElement *overloadNode = _curFunction->FirstChildElement(TEXT("Overload")); TiXmlElement *paramNode = NULL; - for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement("Overload") ) { - const char * retVal = overloadNode->Attribute("retVal"); + for (; overloadNode ; overloadNode = overloadNode->NextSiblingElement(TEXT("Overload")) ) { + const TCHAR * retVal = overloadNode->Attribute(TEXT("retVal")); if (!retVal) continue; //malformed node _retVals.push_back(retVal); - const char * description = overloadNode->Attribute("descr"); + const TCHAR * description = overloadNode->Attribute(TEXT("descr")); if (description) _descriptions.push_back(description); else - _descriptions.push_back(""); //"no description available" + _descriptions.push_back(TEXT("")); //"no description available" - paramNode = overloadNode->FirstChildElement("Param"); - for (; paramNode ; paramNode = paramNode->NextSiblingElement("Param") ) { - const char * param = paramNode->Attribute("name"); + paramNode = overloadNode->FirstChildElement(TEXT("Param")); + for (; paramNode ; paramNode = paramNode->NextSiblingElement(TEXT("Param")) ) { + const TCHAR * param = paramNode->Attribute(TEXT("name")); if (!param) continue; //malformed node paramVec.push_back(param); @@ -328,60 +328,60 @@ void FunctionCallTip::showCalltip() { } } } - const char * curRetValText = _retVals.at(_currentOverload); - const char * curDescriptionText = _descriptions.at(_currentOverload); + const TCHAR * curRetValText = _retVals.at(_currentOverload); + const TCHAR * curDescriptionText = _descriptions.at(_currentOverload); bool hasDescr = true; if (!curDescriptionText[0]) hasDescr = false; - int bytesNeeded = strlen(curRetValText) + strlen(_funcName) + 5;//'retval funcName (params)\0' + int bytesNeeded = lstrlen(curRetValText) + lstrlen(_funcName) + 5;//'retval funcName (params)\0' if (hasDescr) - bytesNeeded += strlen(curDescriptionText); + bytesNeeded += lstrlen(curDescriptionText); size_t nrParams = params.size(); for(size_t i = 0; i < nrParams; i++) { - bytesNeeded += strlen(params.at(i)) + 2; //'param, ' + bytesNeeded += lstrlen(params.at(i)) + 2; //'param, ' } if (_currentNrOverloads > 1) { bytesNeeded += 24; // /\00001 of 00003\/ } - char * textBuffer = new char[bytesNeeded]; - //char langDepChar[4] = " "; //Language dependant characters, like '(', ')', ',' and ';' + TCHAR * textBuffer = new TCHAR[bytesNeeded]; + //TCHAR langDepChar[4] = TEXT(" "); //Language dependant characters, like '(', ')', ',' and ';' textBuffer[0] = 0; if (_currentNrOverloads > 1) { - sprintf(textBuffer, "\001%u of %u\002", _currentOverload+1, _currentNrOverloads); + wsprintf(textBuffer, TEXT("\001%u of %u\002"), _currentOverload+1, _currentNrOverloads); } - strcat(textBuffer, curRetValText); - strcat(textBuffer, " "); - strcat(textBuffer, _funcName); - strcat(textBuffer, " ("); + lstrcat(textBuffer, curRetValText); + lstrcat(textBuffer, TEXT(" ")); + lstrcat(textBuffer, _funcName); + lstrcat(textBuffer, TEXT(" (L")); int highlightstart = 0; int highlightend = 0; for(size_t i = 0; i < nrParams; i++) { if (i == _currentParam) { - highlightstart = strlen(textBuffer); - highlightend = highlightstart + strlen(params.at(i)); + highlightstart = lstrlen(textBuffer); + highlightend = highlightstart + lstrlen(params.at(i)); } - strcat(textBuffer, params.at(i)); + lstrcat(textBuffer, params.at(i)); if (i < nrParams-1) - strcat(textBuffer, ", "); + lstrcat(textBuffer, TEXT(", L")); } - strcat(textBuffer, ")"); + lstrcat(textBuffer, TEXT(")")); if (hasDescr) { - strcat(textBuffer, "\n"); - strcat(textBuffer, curDescriptionText); + lstrcat(textBuffer, TEXT("\n")); + lstrcat(textBuffer, curDescriptionText); } if (isVisible()) _pEditView->execute(SCI_CALLTIPCANCEL); else _startPos = _curPos; - _pEditView->execute(SCI_CALLTIPSHOW, _startPos, (LPARAM)textBuffer); + _pEditView->showCallTip(_startPos, textBuffer); if (highlightstart != highlightend) { _pEditView->execute(SCI_CALLTIPSETHLT, highlightstart, highlightend); diff --git a/PowerEditor/src/ScitillaComponent/FunctionCallTip.h b/PowerEditor/src/ScitillaComponent/FunctionCallTip.h index 4164b32f..96ace095 100644 --- a/PowerEditor/src/ScitillaComponent/FunctionCallTip.h +++ b/PowerEditor/src/ScitillaComponent/FunctionCallTip.h @@ -20,7 +20,7 @@ #include "ScintillaEditView.h" -typedef std::vector stringVec; +typedef std::vector stringVec; class FunctionCallTip { friend class AutoCompletion; @@ -47,7 +47,7 @@ private: TiXmlElement * _curFunction; //current function element //cache some XML values n stuff - char * _funcName; //name of function + TCHAR * _funcName; //name of function stringVec _retVals; //vector of overload return values/types vector _overloads; //vector of overload params (=vector) stringVec _descriptions; //vecotr of function descriptions @@ -55,10 +55,10 @@ private: int _currentOverload; //current chosen overload int _currentParam; //current highlighted param - char _start; - char _stop; - char _param; - char _terminal; + TCHAR _start; + TCHAR _stop; + TCHAR _param; + TCHAR _terminal; bool _ignoreCase; bool getCursorFunction(); //retrieve data about function at cursor. Returns true if a function was found. Calls loaddata if needed diff --git a/PowerEditor/src/ScitillaComponent/GoToLineDlg.h b/PowerEditor/src/ScitillaComponent/GoToLineDlg.h index 2663213c..5de43885 100644 --- a/PowerEditor/src/ScitillaComponent/GoToLineDlg.h +++ b/PowerEditor/src/ScitillaComponent/GoToLineDlg.h @@ -79,7 +79,7 @@ private : }; void cleanLineEdit() const { - ::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, ""); + ::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT("")); }; int getLine() const { diff --git a/PowerEditor/src/ScitillaComponent/Printer.cpp b/PowerEditor/src/ScitillaComponent/Printer.cpp index 79a2cbf7..b1da9ba7 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.cpp +++ b/PowerEditor/src/ScitillaComponent/Printer.cpp @@ -14,10 +14,10 @@ //You should have received a copy of the GNU General Public License //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#include "Printer.h" -#include "UniConversion.h" -void replaceStr(wstring & str, wstring str2BeReplaced, wstring replacement) +#include "Printer.h" + +void replaceStr(basic_string & str, basic_string str2BeReplaced, basic_string replacement) { size_t pos = str.find(str2BeReplaced); @@ -127,67 +127,63 @@ size_t Printer::doPrint(bool justDoIt) // Convert page size to logical units and we're done! DPtoLP(_pdlg.hDC, &ptPage, 1); - TEXTMETRICW tm; + TEXTMETRIC tm; int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9; int fontWeight = nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; int isFontItalic = nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; - const char *fontFace = (nppGUI._printSettings._headerFontName != "")?nppGUI._printSettings._headerFontName.c_str():"Arial"; - - wchar_t fontFaceW[LF_FACESIZE]; - char2wchar(fontFace, fontFaceW); + const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial"); int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); - //char toto[10]; - //::MessageBox(NULL, itoa(nppGUI._printSettings._headerFontStyle, toto, 10), L"header", MB_OK); + //TCHAR toto[10]; + //::MessageBox(NULL, itoa(nppGUI._printSettings._headerFontStyle, toto, 10), TEXT("header"), MB_OK); - HFONT fontHeader = ::CreateFontW(headerLineHeight, + HFONT fontHeader = ::CreateFont(headerLineHeight, 0, 0, 0, fontWeight, isFontItalic, FALSE, 0, 0, 0, 0, 0, 0, - fontFaceW); + fontFace); ::SelectObject(_pdlg.hDC, fontHeader); - ::GetTextMetricsW(_pdlg.hDC, &tm); + ::GetTextMetrics(_pdlg.hDC, &tm); headerLineHeight = tm.tmHeight + tm.tmExternalLeading; fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9; fontWeight = nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; isFontItalic = nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; - fontFace = (nppGUI._printSettings._footerFontName != "")?nppGUI._printSettings._footerFontName.c_str():"Arial"; - //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), L"footer", MB_OK); - char2wchar(fontFace, fontFaceW); + fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial"); + //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), TEXT("footer"), MB_OK); int footerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); - HFONT fontFooter = ::CreateFontW(footerLineHeight, + HFONT fontFooter = ::CreateFont(footerLineHeight, 0, 0, 0, fontWeight, isFontItalic, FALSE, 0, 0, 0, 0, 0, 0, - fontFaceW); + fontFace); ::SelectObject(_pdlg.hDC, fontFooter); - ::GetTextMetricsW(_pdlg.hDC, &tm); + ::GetTextMetrics(_pdlg.hDC, &tm); footerLineHeight = tm.tmHeight + tm.tmExternalLeading; - ::GetTextMetricsW(_pdlg.hDC, &tm); + ::GetTextMetrics(_pdlg.hDC, &tm); int printMarge = tm.tmHeight + tm.tmExternalLeading; printMarge = printMarge + printMarge / 2; - DOCINFOW docInfo; + DOCINFO docInfo; docInfo.cbSize = sizeof(DOCINFO); - docInfo.lpszDocName = _pSEView->getCurrentBuffer()->getFilePathW(); + docInfo.lpszDocName = _pSEView->getCurrentBuffer()->getFilePath(); docInfo.lpszOutput = NULL; - if (::StartDocW(_pdlg.hDC, &docInfo) < 0) + if (::StartDoc(_pdlg.hDC, &docInfo) < 0) { - MessageBox(NULL, "Can not start printer document.", 0, MB_OK); + MessageBox(NULL, TEXT("Can not start printer document."), 0, MB_OK); return 0; } @@ -234,33 +230,34 @@ size_t Printer::doPrint(bool justDoIt) frPrint.rc.left += printMarge; frPrint.rc.right -= printMarge; - wchar_t headerL[256] = L""; - wchar_t headerM[256] = L""; - wchar_t headerR[256] = L""; - wchar_t footerL[256] = L""; - wchar_t footerM[256] = L""; - wchar_t footerR[256] = L""; + TCHAR headerL[256] = TEXT(""); + TCHAR headerM[256] = TEXT(""); + TCHAR headerR[256] = TEXT(""); + TCHAR footerL[256] = TEXT(""); + TCHAR footerM[256] = TEXT(""); + TCHAR footerR[256] = TEXT(""); - const wchar_t shortDateVar[] = L"$(SHORT_DATE)"; - const wchar_t longDateVar[] = L"$(LONG_DATE)"; - const wchar_t timeVar[] = L"$(TIME)"; - wchar_t shortDate[64]; - wchar_t longDate[64]; - wchar_t time[64]; + const TCHAR shortDateVar[] = TEXT("$(SHORT_DATE)"); + const TCHAR longDateVar[] = TEXT("$(LONG_DATE)"); + const TCHAR timeVar[] = TEXT("$(TIME)"); + + TCHAR shortDate[64]; + TCHAR longDate[64]; + TCHAR time[64]; SYSTEMTIME st; ::GetLocalTime(&st); - ::GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, sizeof(shortDate)); - ::GetDateFormatW(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, sizeof(longDate)); - ::GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, sizeof(time)); + ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, sizeof(shortDate)); + ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, sizeof(longDate)); + ::GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, NULL, time, sizeof(time)); if (nppGUI._printSettings.isHeaderPresent()) { frPrint.rc.top += headerLineHeight + headerLineHeight / 2; - wstring headerLeftPart = string2wstring(nppGUI._printSettings._headerLeft); - if (headerLeftPart != L"") + basic_string headerLeftPart = nppGUI._printSettings._headerLeft; + if (headerLeftPart != TEXT("")) { replaceStr(headerLeftPart, shortDateVar, shortDate); replaceStr(headerLeftPart, longDateVar, longDate); @@ -268,8 +265,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(headerLeftPart.c_str(), headerL, sizeof(headerL), _pdlg.hwndOwner); } - wstring headerMiddlePart = string2wstring(nppGUI._printSettings._headerMiddle); - if (headerMiddlePart != L"") + basic_string headerMiddlePart = nppGUI._printSettings._headerMiddle; + if (headerMiddlePart != TEXT("")) { replaceStr(headerMiddlePart, shortDateVar, shortDate); replaceStr(headerMiddlePart, longDateVar, longDate); @@ -277,8 +274,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(headerMiddlePart.c_str(), headerM, sizeof(headerM), _pdlg.hwndOwner); } - wstring headerRightPart = string2wstring(nppGUI._printSettings._headerRight); - if (headerRightPart != L"") + basic_string headerRightPart = nppGUI._printSettings._headerRight; + if (headerRightPart != TEXT("")) { replaceStr(headerRightPart, shortDateVar, shortDate); replaceStr(headerRightPart, longDateVar, longDate); @@ -292,8 +289,8 @@ size_t Printer::doPrint(bool justDoIt) { frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2; - wstring footerLeftPart = string2wstring(nppGUI._printSettings._footerLeft); - if (footerLeftPart != L"") + basic_string footerLeftPart = nppGUI._printSettings._footerLeft; + if (footerLeftPart != TEXT("")) { replaceStr(footerLeftPart, shortDateVar, shortDate); replaceStr(footerLeftPart, longDateVar, longDate); @@ -301,8 +298,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(footerLeftPart.c_str(), footerL, sizeof(footerL), _pdlg.hwndOwner); } - wstring footerMiddlePart = string2wstring(nppGUI._printSettings._footerMiddle); - if (footerMiddlePart != L"") + basic_string footerMiddlePart = nppGUI._printSettings._footerMiddle; + if (footerMiddlePart != TEXT("")) { replaceStr(footerMiddlePart, shortDateVar, shortDate); replaceStr(footerMiddlePart, longDateVar, longDate); @@ -310,8 +307,8 @@ size_t Printer::doPrint(bool justDoIt) expandNppEnvironmentStrs(footerMiddlePart.c_str(), footerM, sizeof(footerM), _pdlg.hwndOwner); } - wstring footerRightPart = string2wstring(nppGUI._printSettings._footerRight); - if (footerRightPart != L"") + basic_string footerRightPart = nppGUI._printSettings._footerRight; + if (footerRightPart != TEXT("")) { replaceStr(footerRightPart, shortDateVar, shortDate); replaceStr(footerRightPart, longDateVar, longDate); @@ -327,7 +324,7 @@ size_t Printer::doPrint(bool justDoIt) size_t pageNum = 1; bool printPage; - const wchar_t pageVar[] = L"$(CURRENT_PRINTING_PAGE)"; + const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)"); while (lengthPrinted < lengthDoc) { @@ -337,8 +334,8 @@ size_t Printer::doPrint(bool justDoIt) if (!justDoIt) printPage = false; - wchar_t pageString[32]; - wsprintfW(pageString, L"%0d", pageNum); + TCHAR pageString[32]; + wsprintf(pageString, TEXT("%0d"), pageNum); if (printPage) { @@ -362,38 +359,38 @@ size_t Printer::doPrint(bool justDoIt) // Left part if (headerL[0] != '\0') { - wstring headerLeft(headerL); + basic_string headerLeft(headerL); size_t pos = headerLeft.find(pageVar); if (pos != headerLeft.npos) - headerLeft.replace(pos, wcslen(pageVar), pageString); + headerLeft.replace(pos, lstrlen(pageVar), pageString); - ::ExtTextOutW(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, + ::ExtTextOut(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2, ETO_OPAQUE, &rcw, headerLeft.c_str(), static_cast(headerLeft.length()), NULL); } // Middle part if (headerM != '\0') { - wstring headerMiddle(headerM); + basic_string headerMiddle(headerM); size_t pos = headerMiddle.find(pageVar); if (pos != headerMiddle.npos) - headerMiddle.replace(pos, wcslen(pageVar), pageString); + headerMiddle.replace(pos, lstrlen(pageVar), pageString); - ::GetTextExtentPoint32W(_pdlg.hDC, headerMiddle.c_str(), static_cast(headerMiddle.length()), &size); - ::ExtTextOutW(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.top - headerLineHeight / 2, + ::GetTextExtentPoint32(_pdlg.hDC, headerMiddle.c_str(), static_cast(headerMiddle.length()), &size); + ::ExtTextOut(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.top - headerLineHeight / 2, ETO_CLIPPED, &rcw, headerMiddle.c_str(), static_cast(headerMiddle.length()), NULL); } // Right part if (headerR != '\0') { - wstring headerRight(headerR); + basic_string headerRight(headerR); size_t pos = headerRight.find(pageVar); if (pos != headerRight.npos) - headerRight.replace(pos, wcslen(pageVar), pageString); + headerRight.replace(pos, lstrlen(pageVar), pageString); - ::GetTextExtentPoint32W(_pdlg.hDC, headerRight.c_str(), static_cast(headerRight.length()), &size); - ::ExtTextOutW(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2, + ::GetTextExtentPoint32(_pdlg.hDC, headerRight.c_str(), static_cast(headerRight.length()), &size); + ::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2, ETO_CLIPPED, &rcw, headerRight.c_str(), static_cast(headerRight.length()), NULL); } @@ -430,37 +427,36 @@ size_t Printer::doPrint(bool justDoIt) // Left part if (footerL[0] != '\0') { - wstring footerLeft(footerL); + basic_string footerLeft(footerL); size_t pos = footerLeft.find(pageVar); if (pos != footerLeft.npos) - footerLeft.replace(pos, wcslen(pageVar), pageString); + footerLeft.replace(pos, lstrlen(pageVar), pageString); - ::ExtTextOutW(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.bottom + footerLineHeight / 2, + ::ExtTextOut(_pdlg.hDC, frPrint.rc.left + 5, frPrint.rc.bottom + footerLineHeight / 2, ETO_OPAQUE, &rcw, footerLeft.c_str(), static_cast(footerLeft.length()), NULL); } // Middle part if (footerM[0] != '\0') { - wstring footerMiddle(footerM); + basic_string footerMiddle(footerM); size_t pos = footerMiddle.find(pageVar); if (pos != footerMiddle.npos) - footerMiddle.replace(pos, wcslen(pageVar), pageString); + footerMiddle.replace(pos, lstrlen(pageVar), pageString); - ::GetTextExtentPoint32W(_pdlg.hDC, footerMiddle.c_str(), static_cast(footerMiddle.length()), &size); - ::ExtTextOutW(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.bottom + footerLineHeight / 2, + ::GetTextExtentPoint32(_pdlg.hDC, footerMiddle.c_str(), static_cast(footerMiddle.length()), &size); + ::ExtTextOut(_pdlg.hDC, ((frPrint.rc.right - frPrint.rc.left)/2 + frPrint.rc.left) - (size.cx/2), frPrint.rc.bottom + footerLineHeight / 2, ETO_CLIPPED, &rcw, footerMiddle.c_str(), static_cast(footerMiddle.length()), NULL); } // Right part if (footerR[0] != '\0') { - wstring footerRight(footerR); + basic_string footerRight(footerR); size_t pos = footerRight.find(pageVar); if (pos != footerRight.npos) - footerRight.replace(pos, wcslen(pageVar), pageString); - - ::GetTextExtentPoint32W(_pdlg.hDC, footerRight.c_str(), static_cast(footerRight.length()), &size); - ::ExtTextOutW(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.bottom + footerLineHeight / 2, + footerRight.replace(pos, lstrlen(pageVar), pageString); + ::GetTextExtentPoint32(_pdlg.hDC, footerRight.c_str(), static_cast(footerRight.length()), &size); + ::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.bottom + footerLineHeight / 2, ETO_CLIPPED, &rcw, footerRight.c_str(), static_cast(footerRight.length()), NULL); } @@ -483,8 +479,8 @@ size_t Printer::doPrint(bool justDoIt) break; } - //char toto[10]; - //::MessageBox(NULL, itoa(pageNum, toto, 10), "page total", MB_OK); + //TCHAR toto[10]; + //::MessageBox(NULL, itoa(pageNum, toto, 10), TEXT("page total"), MB_OK); if (!nppGUI._printSettings._printLineNumber) _pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, isShown); diff --git a/PowerEditor/src/ScitillaComponent/Printer.h b/PowerEditor/src/ScitillaComponent/Printer.h index 72751a66..461fedca 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.h +++ b/PowerEditor/src/ScitillaComponent/Printer.h @@ -37,7 +37,7 @@ public : Printer(){}; void init(HINSTANCE hInst, HWND hwnd, ScintillaEditView *pSEView, bool showDialog, int startPos, int endPos); size_t Printer::doPrint() { - if (!::PrintDlgW(&_pdlg)) + if (!::PrintDlg(&_pdlg)) return 0; return doPrint(true); @@ -45,7 +45,7 @@ public : size_t doPrint(bool justDoIt); private : - PRINTDLGW _pdlg; + PRINTDLG _pdlg; ScintillaEditView *_pSEView; size_t _startPos; size_t _endPos; diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 8066bac3..3c359fa7 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -24,7 +24,7 @@ // initialize the static variable -HINSTANCE ScintillaEditView::_hLib = ::LoadLibrary("SciLexer.DLL"); +HINSTANCE ScintillaEditView::_hLib = ::LoadLibrary(TEXT("SciLexer.DLL")); int ScintillaEditView::_refCount = 0; UserDefineDialog ScintillaEditView::_userDefineDlg; @@ -57,57 +57,57 @@ const int ScintillaEditView::_markersArray[][NB_FOLDER_STATE] = { //Array with all the names of all languages LanguageName ScintillaEditView::langNames[L_EXTERNAL+1] = { -{"normal", "Normal text", "Normal text file", L_TXT, SCLEX_NULL}, -{"php", "PHP", "PHP Hypertext Preprocessor file", L_PHP, SCLEX_HTML}, -{"c", "C", "C source file", L_C, SCLEX_CPP}, -{"cpp", "C++", "C++ source file", L_CPP, SCLEX_CPP}, -{"cs", "C#", "C# source file", L_CS, }, -{"objc", "Objective-C", "Objective-C source file", L_OBJC, }, -{"java", "Java", "Java source file", L_JAVA, SCLEX_CPP}, -{"rc", "RC", "Windows Resource file", L_RC, SCLEX_CPP}, -{"html", "HTML", "Hyper Text Markup Language file", L_HTML, SCLEX_HTML}, -{"xml", "XML", "eXtensible Markup Language file", L_XML, SCLEX_XML}, -{"makefile", "Makefile", "Makefile", L_MAKEFILE, SCLEX_MAKEFILE}, -{"pascal", "Pascal", "Pascal source file", L_PASCAL, SCLEX_PASCAL}, -{"batch", "Batch", "Batch file", L_BATCH, SCLEX_BATCH}, -{"ini", "ini", "MS ini file", L_INI, SCLEX_PROPERTIES}, -{"nfo", "NFO", "MSDOS Style/ASCII Art", L_NFO, SCLEX_NULL}, -{"udf", "udf", "User Define File", L_USER, SCLEX_USER}, -{"asp", "ASP", "Active Server Pages script file", L_ASP, SCLEX_HTML}, -{"sql", "SQL", "Structured Query Language file", L_SQL, SCLEX_SQL}, -{"vb", "VB", "Visual Basic file", L_VB, SCLEX_VB}, -{"javascript", "JavaScript", "JavaScript file", L_JS, SCLEX_CPP}, -{"css", "CSS", "Cascade Style Sheets File", L_CSS, SCLEX_CSS}, -{"perl", "Perl", "Perl source file", L_PERL, SCLEX_PERL}, -{"python", "Python", "Python file", L_PYTHON, SCLEX_PYTHON}, -{"lua", "Lua", "Lua source File", L_LUA, SCLEX_LUA}, -{"tex", "TeX", "TeX file", L_TEX, SCLEX_TEX}, -{"fortran", "Fortran", "Fortran source file", L_FORTRAN, SCLEX_FORTRAN}, -{"bash", "Shell", "Unix script file", L_BASH, SCLEX_BASH}, -{"actionscript","Flash Action", "Flash Action script file", L_FLASH, SCLEX_OBJC}, //WARNING, was "flash" -{"nsis", "NSIS", "Nullsoft Scriptable Install System script file", L_NSIS, SCLEX_NSIS}, -{"tcl", "TCL", "Tool Command Language file", L_TCL, SCLEX_TCL}, -{"lisp", "Lisp", "List Processing language file", L_LISP, SCLEX_LISP}, -{"scheme", "Scheme", "Scheme file", L_SCHEME, SCLEX_LISP}, -{"asm", "Assembly", "Assembly language source file", L_ASM, SCLEX_ASM}, -{"diff", "Diff", "Diff file", L_DIFF, SCLEX_DIFF}, -{"props", "Properties file", "Properties file", L_PROPS, SCLEX_PROPERTIES}, -{"postscript", "Postscript", "Postscript file", L_PS, SCLEX_PS}, -{"ruby", "Ruby", "Ruby file", L_RUBY, SCLEX_RUBY}, -{"smalltalk", "Smalltalk", "Smalltalk file", L_SMALLTALK, SCLEX_SMALLTALK}, -{"vhdl", "VHDL", "VHSIC Hardware Description Language file", L_VHDL, SCLEX_VHDL}, -{"kix", "KiXtart", "KiXtart file", L_KIX, SCLEX_KIX}, -{"autoit", "AutoIt", "AutoIt", L_AU3, SCLEX_AU3}, -{"caml", "CAML", "Categorical Abstract Machine Language", L_CAML, SCLEX_CAML}, -{"ada", "Ada", "Ada file", L_ADA, SCLEX_ADA}, -{"verilog", "Verilog", "Verilog file", L_VERILOG, SCLEX_VERILOG}, -{"matlab", "MATLAB", "MATrix LABoratory", L_MATLAB, SCLEX_MATLAB}, -{"haskell", "Haskell", "Haskell", L_HASKELL, SCLEX_HASKELL}, -{"inno", "Inno", "Inno Setup script", L_INNO, SCLEX_INNOSETUP}, -{"searchResult","Internal Search", "Internal Search", L_SEARCHRESULT, SCLEX_SEARCHRESULT}, -{"cmake", "CMAKEFILE", "CMAKEFILE", L_CMAKE, SCLEX_CMAKE}, -{"yaml", "YAML", "YAML Ain't Markup Language", L_YAML, SCLEX_YAML}, -{"ext", "External", "External", L_EXTERNAL, SCLEX_NULL} +{TEXT("normal"), TEXT("Normal text"), TEXT("Normal text file"), L_TXT, SCLEX_NULL}, +{TEXT("php"), TEXT("PHP"), TEXT("PHP Hypertext Preprocessor file"), L_PHP, SCLEX_HTML}, +{TEXT("c"), TEXT("C"), TEXT("C source file"), L_C, SCLEX_CPP}, +{TEXT("cpp"), TEXT("C++"), TEXT("C++ source file"), L_CPP, SCLEX_CPP}, +{TEXT("cs"), TEXT("C#"), TEXT("C# source file"), L_CS, }, +{TEXT("objc"), TEXT("Objective-C"), TEXT("Objective-C source file"), L_OBJC, }, +{TEXT("java"), TEXT("Java"), TEXT("Java source file"), L_JAVA, SCLEX_CPP}, +{TEXT("rc"), TEXT("RC"), TEXT("Windows Resource file"), L_RC, SCLEX_CPP}, +{TEXT("html"), TEXT("HTML"), TEXT("Hyper Text Markup Language file"), L_HTML, SCLEX_HTML}, +{TEXT("xml"), TEXT("XML"), TEXT("eXtensible Markup Language file"), L_XML, SCLEX_XML}, +{TEXT("makefile"), TEXT("Makefile"), TEXT("Makefile"), L_MAKEFILE, SCLEX_MAKEFILE}, +{TEXT("pascal"), TEXT("Pascal"), TEXT("Pascal source file"), L_PASCAL, SCLEX_PASCAL}, +{TEXT("batch"), TEXT("Batch"), TEXT("Batch file"), L_BATCH, SCLEX_BATCH}, +{TEXT("ini"), TEXT("ini"), TEXT("MS ini file"), L_INI, SCLEX_PROPERTIES}, +{TEXT("nfo"), TEXT("NFO"), TEXT("MSDOS Style/ASCII Art"), L_NFO, SCLEX_NULL}, +{TEXT("udf"), TEXT("udf"), TEXT("User Define File"), L_USER, SCLEX_USER}, +{TEXT("asp"), TEXT("ASP"), TEXT("Active Server Pages script file"), L_ASP, SCLEX_HTML}, +{TEXT("sql"), TEXT("SQL"), TEXT("Structured Query Language file"), L_SQL, SCLEX_SQL}, +{TEXT("vb"), TEXT("VB"), TEXT("Visual Basic file"), L_VB, SCLEX_VB}, +{TEXT("javascript"), TEXT("JavaScript"), TEXT("JavaScript file"), L_JS, SCLEX_CPP}, +{TEXT("css"), TEXT("CSS"), TEXT("Cascade Style Sheets File"), L_CSS, SCLEX_CSS}, +{TEXT("perl"), TEXT("Perl"), TEXT("Perl source file"), L_PERL, SCLEX_PERL}, +{TEXT("python"), TEXT("Python"), TEXT("Python file"), L_PYTHON, SCLEX_PYTHON}, +{TEXT("lua"), TEXT("Lua"), TEXT("Lua source File"), L_LUA, SCLEX_LUA}, +{TEXT("tex"), TEXT("TeX"), TEXT("TeX file"), L_TEX, SCLEX_TEX}, +{TEXT("fortran"), TEXT("Fortran"), TEXT("Fortran source file"), L_FORTRAN, SCLEX_FORTRAN}, +{TEXT("bash"), TEXT("Shell"), TEXT("Unix script file"), L_BASH, SCLEX_BASH}, +{TEXT("actionscript"), TEXT("Flash Action"), TEXT("Flash Action script file"), L_FLASH, SCLEX_OBJC}, //WARNING, was "flash" +{TEXT("nsis"), TEXT("NSIS"), TEXT("Nullsoft Scriptable Install System script file"), L_NSIS, SCLEX_NSIS}, +{TEXT("tcl"), TEXT("TCL"), TEXT("Tool Command Language file"), L_TCL, SCLEX_TCL}, +{TEXT("lisp"), TEXT("Lisp"), TEXT("List Processing language file"), L_LISP, SCLEX_LISP}, +{TEXT("scheme"), TEXT("Scheme"), TEXT("Scheme file"), L_SCHEME, SCLEX_LISP}, +{TEXT("asm"), TEXT("Assembly"), TEXT("Assembly language source file"), L_ASM, SCLEX_ASM}, +{TEXT("diff"), TEXT("Diff"), TEXT("Diff file"), L_DIFF, SCLEX_DIFF}, +{TEXT("props"), TEXT("Properties file"), TEXT("Properties file"), L_PROPS, SCLEX_PROPERTIES}, +{TEXT("postscript"), TEXT("Postscript"), TEXT("Postscript file"), L_PS, SCLEX_PS}, +{TEXT("ruby"), TEXT("Ruby"), TEXT("Ruby file"), L_RUBY, SCLEX_RUBY}, +{TEXT("smalltalk"), TEXT("Smalltalk"), TEXT("Smalltalk file"), L_SMALLTALK, SCLEX_SMALLTALK}, +{TEXT("vhdl"), TEXT("VHDL"), TEXT("VHSIC Hardware Description Language file"), L_VHDL, SCLEX_VHDL}, +{TEXT("kix"), TEXT("KiXtart"), TEXT("KiXtart file"), L_KIX, SCLEX_KIX}, +{TEXT("autoit"), TEXT("AutoIt"), TEXT("AutoIt"), L_AU3, SCLEX_AU3}, +{TEXT("caml"), TEXT("CAML"), TEXT("Categorical Abstract Machine Language"), L_CAML, SCLEX_CAML}, +{TEXT("ada"), TEXT("Ada"), TEXT("Ada file"), L_ADA, SCLEX_ADA}, +{TEXT("verilog"), TEXT("Verilog"), TEXT("Verilog file"), L_VERILOG, SCLEX_VERILOG}, +{TEXT("matlab"), TEXT("MATLAB"), TEXT("MATrix LABoratory"), L_MATLAB, SCLEX_MATLAB}, +{TEXT("haskell"), TEXT("Haskell"), TEXT("Haskell"), L_HASKELL, SCLEX_HASKELL}, +{TEXT("inno"), TEXT("Inno"), TEXT("Inno Setup script"), L_INNO, SCLEX_INNOSETUP}, +{TEXT("searchResult"), TEXT("Internal Search"), TEXT("Internal Search"), L_SEARCHRESULT, SCLEX_SEARCHRESULT}, +{TEXT("cmake"), TEXT("CMAKEFILE"), TEXT("CMAKEFILE"), L_CMAKE, SCLEX_CMAKE}, +{TEXT("yaml"), TEXT("YAML"), TEXT("YAML Ain't Markup Language"), L_YAML, SCLEX_YAML}, +{TEXT("ext"), TEXT("External"), TEXT("External"), L_EXTERNAL, SCLEX_NULL} }; //const int MASK_RED = 0xFF0000; @@ -118,15 +118,15 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) { if (!_hLib) { - MessageBox( NULL, "Can not load the dynamic library", "SCINTILLA ERROR : ", MB_OK | MB_ICONSTOP); + MessageBox( NULL, TEXT("Can not load the dynamic library"), TEXT("SCINTILLA ERROR : "), MB_OK | MB_ICONSTOP); throw int(106901); } Window::init(hInst, hPere); _hSelf = ::CreateWindowEx( WS_EX_CLIENTEDGE,\ - "Scintilla",\ - "Notepad++",\ + TEXT("Scintilla"),\ + TEXT("Notepad++"),\ WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_CLIPCHILDREN | WS_EX_RTLREADING,\ 0, 0, 100, 100,\ _hParent,\ @@ -136,7 +136,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) if (!_hSelf) { - systemMessage("System Error"); + systemMessage(TEXT("System Error")); throw int(106901); } @@ -147,7 +147,7 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) if (!_pScintillaFunc || !_pScintillaPtr) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(106901); } @@ -187,11 +187,6 @@ void ScintillaEditView::init(HINSTANCE hInst, HWND hPere) execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_TAGMATCH, true); execute(SCI_INDICSETUNDER, SCE_UNIVERSAL_TAGATTR, true); - // URL highlighting - int activeFG = 0xFF0000; - execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, activeFG); - execute(SCI_SETHOTSPOTSINGLELINE, FALSE); - _pParameter = NppParameters::getInstance(); _codepage = ::GetACP(); @@ -227,7 +222,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa execute(SCI_BEGINUNDOACTION); ColumnModeInfo colInfos = getColumnModeSelectInfo(); - columnReplace(colInfos, (char)wParam); + columnReplace(colInfos, (TCHAR)wParam); execute(SCI_ENDUNDOACTION); execute(SCI_SETCURRENTPOS,colInfos[colInfos.size()-1].second); @@ -271,47 +266,6 @@ void ScintillaEditView::setSpecialIndicator(Style & styleToSet) execute(SCI_INDICSETFORE, styleToSet._styleID, styleToSet._bgColor); } -void ScintillaEditView::setHotspotStyle() -{ - vector< pair > clickableStyles = _currentBuffer->getClickableStyles(); - //printStr("getin"); - for (size_t i = 0 ; i < clickableStyles.size() ; i++) - { - - int styleID = clickableStyles[i].second; - - //if (execute(SCI_STYLEGETHOTSPOT, styleID) == FALSE) - { - Style styleToSet = clickableStyles[i].first; - //char toto[512]; - //sprintf(toto, start, end); - //writeLog("c:\npp.log", toto); - if ( styleToSet._colorStyle & COLORSTYLE_FOREGROUND ) - execute(SCI_STYLESETFORE, styleID, styleToSet._fgColor); - - if ( styleToSet._colorStyle & COLORSTYLE_BACKGROUND ) - execute(SCI_STYLESETBACK, styleID, styleToSet._bgColor); - - if ((!styleToSet._fontName)||(strcmp(styleToSet._fontName, ""))) - execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)styleToSet._fontName); - - int fontStyle = styleToSet._fontStyle; - if (fontStyle != -1) - { - execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD); - execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC); - execute(SCI_STYLESETUNDERLINE, (WPARAM)styleID, fontStyle & FONTSTYLE_UNDERLINE); - } - - if (styleToSet._fontSize > 0) - execute(SCI_STYLESETSIZE, styleID, styleToSet._fontSize); - - execute(SCI_STYLESETHOTSPOT, styleID, TRUE); - execute(SCI_SETHOTSPOTACTIVEFORE, TRUE, blue); - execute(SCI_SETHOTSPOTSINGLELINE, styleID, 0); - } - } -} void ScintillaEditView::setSpecialStyle(Style & styleToSet) { @@ -322,9 +276,16 @@ void ScintillaEditView::setSpecialStyle(Style & styleToSet) if ( styleToSet._colorStyle & COLORSTYLE_BACKGROUND ) execute(SCI_STYLESETBACK, styleID, styleToSet._bgColor); - if ((!styleToSet._fontName)||(strcmp(styleToSet._fontName, ""))) + if ((!styleToSet._fontName)||(lstrcmp(styleToSet._fontName, TEXT("")))) + { +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char * fontNameA = wmc->wchar2char(styleToSet._fontName, CP_ACP); + execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)fontNameA); +#else execute(SCI_STYLESETFONT, (WPARAM)styleID, (LPARAM)styleToSet._fontName); - +#endif + } int fontStyle = styleToSet._fontStyle; if (fontStyle != -1) { @@ -345,7 +306,7 @@ void ScintillaEditView::setStyle(Style styleToSet) if (go.isEnable()) { StyleArray & stylers = _pParameter->getMiscStylerArray(); - int i = stylers.getStylerIndexByName("Global override"); + int i = stylers.getStylerIndexByName(TEXT("Global override")); if (i != -1) { Style & style = stylers.getStyler(i); @@ -415,17 +376,22 @@ void ScintillaEditView::setXmlLexer(LangType type) { execute(SCI_SETLEXER, SCLEX_XML); for (int i = 0 ; i < 4 ; i++) - execute(SCI_SETKEYWORDS, i, reinterpret_cast("")); + execute(SCI_SETKEYWORDS, i, reinterpret_cast(TEXT(""))); makeStyle(type); } else if ((type == L_HTML) || (type == L_PHP) || (type == L_ASP)) { execute(SCI_SETLEXER, SCLEX_HTML); + const TCHAR *htmlKeyWords_generic =_pParameter->getWordList(L_HTML, LANG_INDEX_INSTR); - const char *htmlKeyWords =_pParameter->getWordList(L_HTML, LANG_INDEX_INSTR); - execute(SCI_SETKEYWORDS, 0, reinterpret_cast(htmlKeyWords?htmlKeyWords:"")); - +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char *htmlKeyWords = wmc->wchar2char(htmlKeyWords_generic, CP_ACP); + execute(SCI_SETKEYWORDS, 0, reinterpret_cast(htmlKeyWords?htmlKeyWords:"")); +#else + execute(SCI_SETKEYWORDS, 0, reinterpret_cast(htmlKeyWords_generic?htmlKeyWords_generic:"")); +#endif makeStyle(L_HTML); setEmbeddedJSLexer(); @@ -436,15 +402,21 @@ void ScintillaEditView::setXmlLexer(LangType type) void ScintillaEditView::setEmbeddedJSLexer() { - const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; makeStyle(L_JS, pKwArray); - std::string keywordList(""); + basic_string keywordList(""); if (pKwArray[LANG_INDEX_INSTR]) + { +#ifdef UNICODE + basic_string kwlW = pKwArray[LANG_INDEX_INSTR]; + keywordList = wstring2string(kwlW, CP_ACP); +#else keywordList = pKwArray[LANG_INDEX_INSTR]; +#endif + } execute(SCI_SETKEYWORDS, 1, (LPARAM)getCompleteKeywordList(keywordList, L_JS, LANG_INDEX_INSTR)); - execute(SCI_STYLESETEOLFILLED, SCE_HJ_DEFAULT, true); execute(SCI_STYLESETEOLFILLED, SCE_HJ_COMMENT, true); execute(SCI_STYLESETEOLFILLED, SCE_HJ_COMMENTDOC, true); @@ -452,12 +424,19 @@ void ScintillaEditView::setEmbeddedJSLexer() void ScintillaEditView::setPhpEmbeddedLexer() { - const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; makeStyle(L_PHP, pKwArray); - std::string keywordList(""); + basic_string keywordList(""); if (pKwArray[LANG_INDEX_INSTR]) + { +#ifdef UNICODE + basic_string kwlW = pKwArray[LANG_INDEX_INSTR]; + keywordList = wstring2string(kwlW, CP_ACP); +#else keywordList = pKwArray[LANG_INDEX_INSTR]; +#endif + } execute(SCI_SETKEYWORDS, 4, (LPARAM)getCompleteKeywordList(keywordList, L_PHP, LANG_INDEX_INSTR)); @@ -467,19 +446,26 @@ void ScintillaEditView::setPhpEmbeddedLexer() void ScintillaEditView::setEmbeddedAspLexer() { - const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; makeStyle(L_ASP, pKwArray); - std::string keywordList(""); + basic_string keywordList(""); if (pKwArray[LANG_INDEX_INSTR]) + { +#ifdef UNICODE + basic_string kwlW = pKwArray[LANG_INDEX_INSTR]; + keywordList = wstring2string(kwlW, CP_ACP); +#else keywordList = pKwArray[LANG_INDEX_INSTR]; +#endif + } execute(SCI_SETKEYWORDS, 2, (LPARAM)getCompleteKeywordList(keywordList, L_VB, LANG_INDEX_INSTR)); execute(SCI_STYLESETEOLFILLED, SCE_HBA_DEFAULT, true); } -void ScintillaEditView::setUserLexer(const char *userLangName) +void ScintillaEditView::setUserLexer(const TCHAR *userLangName) { execute(SCI_SETLEXER, SCLEX_USER); @@ -511,7 +497,7 @@ void ScintillaEditView::setUserLexer(const char *userLangName) void ScintillaEditView::setExternalLexer(LangType typeDoc) { int id = typeDoc - L_EXTERNAL; - char * name = NppParameters::getInstance()->getELCFromIndex(id)._name; + TCHAR * name = NppParameters::getInstance()->getELCFromIndex(id)._name; execute(SCI_SETLEXERLANGUAGE, 0, (LPARAM)name); LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName(name); @@ -524,12 +510,17 @@ void ScintillaEditView::setExternalLexer(LangType typeDoc) setStyle(style); if (style._keywordClass >= 0 && style._keywordClass <= KEYWORDSET_MAX) - { - string kwl(""); + { + basic_string keywordList(""); if (style._keywords) - kwl = *(style._keywords); - - execute(SCI_SETKEYWORDS, style._keywordClass, (LPARAM)getCompleteKeywordList(kwl, typeDoc, style._keywordClass)); + { +#ifdef UNICODE + keywordList = wstring2string(*(style._keywords), CP_ACP); +#else + keywordList = *(style._keywords); +#endif + } + execute(SCI_SETKEYWORDS, style._keywordClass, (LPARAM)getCompleteKeywordList(keywordList, typeDoc, style._keywordClass)); } } } @@ -539,36 +530,9 @@ void ScintillaEditView::setCppLexer(LangType langType) { const char *cppInstrs; const char *cppTypes; - const char *doxygenKeyWords = _pParameter->getWordList(L_CPP, LANG_INDEX_TYPE2); + const TCHAR *doxygenKeyWords = _pParameter->getWordList(L_CPP, LANG_INDEX_TYPE2); - const char *lexerName = ScintillaEditView::langNames[langType].lexerName; - /*char *lexerName; - switch (langType) - { - case L_C: - lexerName = "c"; break; - - case L_CPP: - lexerName = "cpp"; break; - - case L_JAVA: - lexerName = "java"; break; - - case L_JS: - lexerName = "javascript"; break; - - case L_RC: - lexerName = "rc"; break; - - case L_CS: - lexerName = "cs"; break; - - case L_TCL: - lexerName = "tcl"; break; - - default: - return; - }*/ + const TCHAR *lexerName = ScintillaEditView::langNames[langType].lexerName; execute(SCI_SETLEXER, SCLEX_CPP); if (isCJK()) @@ -581,7 +545,15 @@ void ScintillaEditView::setCppLexer(LangType langType) if ((langType != L_RC) && (langType != L_JS)) { if (doxygenKeyWords) - execute(SCI_SETKEYWORDS, 2, (LPARAM)doxygenKeyWords); + { +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char * doxygenKeyWords_char = wmc->wchar2char(doxygenKeyWords, CP_ACP); + execute(SCI_SETKEYWORDS, 2, (LPARAM)doxygenKeyWords_char); +#else + execute(SCI_SETKEYWORDS, 2, (LPARAM)doxygenKeyWords); +#endif + } } if (langType == L_JS) @@ -617,18 +589,31 @@ void ScintillaEditView::setCppLexer(LangType langType) execute(SCI_STYLESETEOLFILLED, SCE_C_COMMENTDOC, true); } - const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; makeStyle(langType, pKwArray); - std::string instr1(""); + basic_string keywordList(""); if (pKwArray[LANG_INDEX_INSTR]) - instr1 = pKwArray[LANG_INDEX_INSTR]; - cppInstrs = getCompleteKeywordList(instr1, langType, LANG_INDEX_INSTR); + { +#ifdef UNICODE + basic_string kwlW = pKwArray[LANG_INDEX_INSTR]; + keywordList = wstring2string(kwlW, CP_ACP); +#else + keywordList = pKwArray[LANG_INDEX_INSTR]; +#endif + } + cppInstrs = getCompleteKeywordList(keywordList, langType, LANG_INDEX_INSTR); - std::string type1(""); if (pKwArray[LANG_INDEX_TYPE]) - type1 = pKwArray[LANG_INDEX_TYPE]; - cppTypes = getCompleteKeywordList(type1, langType, LANG_INDEX_TYPE); + { +#ifdef UNICODE + basic_string kwlW = pKwArray[LANG_INDEX_TYPE]; + keywordList = wstring2string(kwlW, CP_ACP); +#else + keywordList = pKwArray[LANG_INDEX_INSTR]; +#endif + } + cppTypes = getCompleteKeywordList(keywordList, langType, LANG_INDEX_TYPE); execute(SCI_SETKEYWORDS, 0, (LPARAM)cppInstrs); execute(SCI_SETKEYWORDS, 1, (LPARAM)cppTypes); @@ -639,46 +624,75 @@ void ScintillaEditView::setCppLexer(LangType langType) void ScintillaEditView::setObjCLexer(LangType langType) { execute(SCI_SETLEXER, SCLEX_OBJC); - const char *doxygenKeyWords = _pParameter->getWordList(L_CPP, LANG_INDEX_TYPE2); - const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; - - //const char *lexerName = "objc"; - //if (langType == L_FLASH) - // lexerName = "actionscript"; + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; makeStyle(langType, pKwArray); - std::string objcInstr1Kwl(""); + basic_string objcInstr1Kwl(""); if (pKwArray[LANG_INDEX_INSTR]) + { +#ifdef UNICODE + objcInstr1Kwl = wstring2string(pKwArray[LANG_INDEX_INSTR], CP_ACP); +#else objcInstr1Kwl = pKwArray[LANG_INDEX_INSTR]; +#endif + } const char *objcInstrs = getCompleteKeywordList(objcInstr1Kwl, langType, LANG_INDEX_INSTR); - std::string objcInstr2Kwl(""); + basic_string objcInstr2Kwl(""); if (pKwArray[LANG_INDEX_INSTR2]) + { +#ifdef UNICODE + objcInstr2Kwl = wstring2string(pKwArray[LANG_INDEX_INSTR2], CP_ACP); +#else objcInstr2Kwl = pKwArray[LANG_INDEX_INSTR2]; +#endif + } const char *objCDirective = getCompleteKeywordList(objcInstr2Kwl, langType, LANG_INDEX_INSTR2); - std::string objcTypeKwl(""); + basic_string objcTypeKwl(""); if (pKwArray[LANG_INDEX_TYPE]) + { +#ifdef UNICODE + objcTypeKwl = wstring2string(pKwArray[LANG_INDEX_TYPE], CP_ACP); +#else objcTypeKwl = pKwArray[LANG_INDEX_TYPE]; +#endif + } const char *objcTypes = getCompleteKeywordList(objcTypeKwl, langType, LANG_INDEX_TYPE); - std::string objcType2Kwl(""); + + basic_string objcType2Kwl(""); if (pKwArray[LANG_INDEX_TYPE2]) + { +#ifdef UNICODE + objcType2Kwl = wstring2string(pKwArray[LANG_INDEX_TYPE2], CP_ACP); +#else objcType2Kwl = pKwArray[LANG_INDEX_TYPE2]; +#endif + } const char *objCQualifier = getCompleteKeywordList(objcType2Kwl, langType, LANG_INDEX_TYPE2); + const TCHAR *doxygenKeyWords_generic = _pParameter->getWordList(L_CPP, LANG_INDEX_TYPE2); + const char * doxygenKeyWords; + basic_string doxygenKeyWordsString(""); +#ifdef UNICODE + doxygenKeyWordsString = wstring2string(doxygenKeyWords_generic, CP_ACP); + doxygenKeyWords = doxygenKeyWordsString.c_str(); +#else + doxygenKeyWords = doxygenKeyWords_generic; +#endif execute(SCI_SETKEYWORDS, 0, (LPARAM)objcInstrs); execute(SCI_SETKEYWORDS, 1, (LPARAM)objcTypes); - execute(SCI_SETKEYWORDS, 2, (LPARAM)(doxygenKeyWords?doxygenKeyWords:"")); + execute(SCI_SETKEYWORDS, 2, (LPARAM)doxygenKeyWords); execute(SCI_SETKEYWORDS, 3, (LPARAM)objCDirective); execute(SCI_SETKEYWORDS, 4, (LPARAM)objCQualifier); } void ScintillaEditView::setKeywords(LangType langType, const char *keywords, int index) { - std::string wordList; + std::basic_string wordList; wordList = (keywords)?keywords:""; execute(SCI_SETKEYWORDS, index, (LPARAM)getCompleteKeywordList(wordList, langType, index)); } @@ -687,49 +701,88 @@ void ScintillaEditView::setLexer(int lexerID, LangType langType, int whichList) { execute(SCI_SETLEXER, lexerID); - const char *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + const TCHAR *pKwArray[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; makeStyle(langType, pKwArray); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); +#endif + if (whichList & LIST_0) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_INSTR], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_INSTR); +#else setKeywords(langType, pKwArray[LANG_INDEX_INSTR], LANG_INDEX_INSTR); +#endif } if (whichList & LIST_1) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_INSTR2], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_INSTR2); +#else setKeywords(langType, pKwArray[LANG_INDEX_INSTR2], LANG_INDEX_INSTR2); +#endif } if (whichList & LIST_2) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_TYPE], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_TYPE); +#else setKeywords(langType, pKwArray[LANG_INDEX_TYPE], LANG_INDEX_TYPE); +#endif } if (whichList & LIST_3) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_TYPE2], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_TYPE2); +#else setKeywords(langType, pKwArray[LANG_INDEX_TYPE2], LANG_INDEX_TYPE2); +#endif } if (whichList & LIST_4) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_TYPE3], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_TYPE3); +#else setKeywords(langType, pKwArray[LANG_INDEX_TYPE3], LANG_INDEX_TYPE3); +#endif } if (whichList & LIST_5) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_TYPE4], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_TYPE4); +#else setKeywords(langType, pKwArray[LANG_INDEX_TYPE4], LANG_INDEX_TYPE4); +#endif } if (whichList & LIST_6) { +#ifdef UNICODE + const char * keyWords_char = wmc->wchar2char(pKwArray[LANG_INDEX_TYPE5], CP_ACP); + setKeywords(langType, keyWords_char, LANG_INDEX_TYPE5); +#else setKeywords(langType, pKwArray[LANG_INDEX_TYPE5], LANG_INDEX_TYPE5); +#endif } } -void ScintillaEditView::makeStyle(LangType language, const char **keywordArray) +void ScintillaEditView::makeStyle(LangType language, const TCHAR **keywordArray) { - const char * lexerName = ScintillaEditView::langNames[language].lexerName; + const TCHAR * lexerName = ScintillaEditView::langNames[language].lexerName; LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName(lexerName); if (pStyler) { @@ -748,8 +801,7 @@ void ScintillaEditView::makeStyle(LangType language, const char **keywordArray) void ScintillaEditView::defineDocType(LangType typeDoc) { - //setHotspotStyle(); - //setStyle(STYLE_DEFAULT, black, white, "Verdana", 0, 9); + //setStyle(STYLE_DEFAULT, black, white, TEXT("Verdana"), 0, 9); StyleArray & stylers = _pParameter->getMiscStylerArray(); int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT); if (iStyleDefault != -1) @@ -773,6 +825,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); + //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -780,6 +833,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); + //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -787,6 +841,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); + //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -794,6 +849,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); + //setSpecialStyle(styleFind); setSpecialIndicator(styleFind); } @@ -850,7 +906,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) setIniLexer(); break; case L_USER : { - const char * langExt = _currentBuffer->getUserDefineLangName(); + const TCHAR * langExt = _currentBuffer->getUserDefineLangName(); if (langExt[0]) setUserLexer(langExt); else @@ -859,15 +915,15 @@ void ScintillaEditView::defineDocType(LangType typeDoc) case L_NFO : { - LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName("nfo"); + LexerStyler *pStyler = (_pParameter->getLStylerArray()).getLexerStylerByName(TEXT("nfo")); COLORREF bg = black; COLORREF fg = liteGrey; Style nfoStyle; nfoStyle._styleID = STYLE_DEFAULT; - nfoStyle._fontName = "MS LineDraw"; + nfoStyle._fontName = TEXT("MS LineDraw"); if (pStyler) { - int i = pStyler->getStylerIndexByName("DEFAULT"); + int i = pStyler->getStylerIndexByName(TEXT("DEFAULT")); if (i != -1) { Style & style = pStyler->getStyler(i); @@ -1206,7 +1262,14 @@ void ScintillaEditView::bufferUpdated(Buffer * buffer, int mask) { void ScintillaEditView::collapse(int level2Collapse, bool mode) { - execute(SCI_COLOURISE, 0, -1); //make sure folding is done right (no cut-offs) + // The following code is needed : + execute(SCI_COLOURISE, 0, -1); + // according to the Scitilla document : + // This requests the current lexer or the container (if the lexer is set to SCLEX_CONTAINER) + // to style the document between startPos and endPos. If endPos is -1, the document is styled from startPos to the end. + // If the "fold" property is set to "1" and your lexer or container supports folding, fold levels are also set. + // This message causes a redraw. + int maxLine = execute(SCI_GETLINECOUNT); for (int line = 0; line < maxLine; line++) @@ -1226,7 +1289,14 @@ void ScintillaEditView::collapse(int level2Collapse, bool mode) void ScintillaEditView::foldCurrentPos(bool mode) { - execute(SCI_COLOURISE, 0, -1); //make sure folding is done right (no cut-offs) + // The following code is needed : + execute(SCI_COLOURISE, 0, -1); + // according to the Scitilla document : + // This requests the current lexer or the container (if the lexer is set to SCLEX_CONTAINER) + // to style the document between startPos and endPos. If endPos is -1, the document is styled from startPos to the end. + // If the "fold" property is set to "1" and your lexer or container supports folding, fold levels are also set. + // This message causes a redraw. + int currentLine = this->getCurrentLineNumber(); int headerLine; @@ -1247,7 +1317,14 @@ void ScintillaEditView::foldCurrentPos(bool mode) void ScintillaEditView::foldAll(bool mode) { - execute(SCI_COLOURISE, 0, -1); //make sure folding is done right (no cut-offs) + // The following code is needed : + execute(SCI_COLOURISE, 0, -1); + // according to the Scitilla document : + // This requests the current lexer or the container (if the lexer is set to SCLEX_CONTAINER) + // to style the document between startPos and endPos. If endPos is -1, the document is styled from startPos to the end. + // If the "fold" property is set to "1" and your lexer or container supports folding, fold levels are also set. + // This message causes a redraw. + int maxLine = execute(SCI_GETLINECOUNT); for (int line = 0; line < maxLine; line++) @@ -1268,6 +1345,188 @@ void ScintillaEditView::getText(char *dest, int start, int end) const execute(SCI_GETTEXTRANGE, 0, reinterpret_cast(&tr)); } +void ScintillaEditView::getGenericText(TCHAR *dest, int start, int end) const +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + char *destA = new char[end - start + 1]; + getText(destA, start, end); + unsigned int cp = execute(SCI_GETCODEPAGE); + const TCHAR *destW = wmc->char2wchar(destA, cp); + lstrcpy(dest, destW); + delete [] destA; +#else + getText(dest, start, end); +#endif +} + +void ScintillaEditView::insertGenericTextFrom(int position, const TCHAR *text2insert) const +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *text2insertA = wmc->wchar2char(text2insert, cp); + execute(SCI_INSERTTEXT, position, (WPARAM)text2insertA); +#else + execute(SCI_INSERTTEXT, position, (WPARAM)text2insert); +#endif +} + +void ScintillaEditView::replaceSelWith(const char * replaceText) +{ + execute(SCI_REPLACESEL, 0, (WPARAM)replaceText); +} + +char * ScintillaEditView::getSelectedText(char * txt, int size, bool expand) +{ + if (!size) + return NULL; + CharacterRange range = getSelection(); + if (range.cpMax == range.cpMin && expand) + { + expandWordSelection(); + range = getSelection(); + } + if (!(size > (range.cpMax - range.cpMin))) //there must be atleast 1 byte left for zero terminator + { + range.cpMax = range.cpMin+size-1; //keep room for zero terminator + } + getText(txt, range.cpMin, range.cpMax); + return txt; +} + +TCHAR * ScintillaEditView::getGenericSelectedText(TCHAR * txt, int size, bool expand) +{ + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); +#ifdef UNICODE + char *txtA = new char[size + 1]; + getSelectedText(txtA, size, expand); + + const TCHAR * txtW = wmc->char2wchar(txtA, cp); + lstrcpy(txt, txtW); + delete [] txtA; + return txt; +#else + return getSelectedText(txt, size, expand); +#endif +} + +int ScintillaEditView::searchInTarget(const TCHAR * text2Find, int fromPos, int toPos) const +{ + execute(SCI_SETTARGETSTART, fromPos); + execute(SCI_SETTARGETEND, toPos); + +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *text2FindA = wmc->wchar2char(text2Find, cp); + int targetFound = execute(SCI_SEARCHINTARGET, (WPARAM)strlen(text2FindA), (LPARAM)text2FindA); + return targetFound; +#else + return execute(SCI_SEARCHINTARGET, (WPARAM)strlen(text2Find), (LPARAM)text2Find); +#endif +} + +/* +void ScintillaEditView::appandText(const char * text2Append) const +{ + execute(SCI_APPENDTEXT, strlen(text2Append), (LPARAM)text2Append); +} +*/ + +void ScintillaEditView::appandGenericText(const TCHAR * text2Append) const +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *text2AppendA =wmc->wchar2char(text2Append, cp); + execute(SCI_APPENDTEXT, strlen(text2AppendA), (LPARAM)text2AppendA); +#else + execute(SCI_APPENDTEXT, strlen(text2Append), (LPARAM)text2Append); +#endif +} + +int ScintillaEditView::replaceTarget(const TCHAR * str2replace, int fromTargetPos, int toTargetPos) const +{ + if (fromTargetPos != -1 || toTargetPos != -1) + { + execute(SCI_SETTARGETSTART, fromTargetPos); + execute(SCI_SETTARGETEND, toTargetPos); + } +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *str2replaceA = wmc->wchar2char(str2replace, cp); + return execute(SCI_REPLACETARGET, -1, (LPARAM)str2replaceA); +#else + return execute(SCI_REPLACETARGET, -1, (LPARAM)str2replace); +#endif +} + +int ScintillaEditView::replaceTargetRegExMode(const TCHAR * re, int fromTargetPos, int toTargetPos) const +{ + if (fromTargetPos != -1 || toTargetPos != -1) + { + execute(SCI_SETTARGETSTART, fromTargetPos); + execute(SCI_SETTARGETEND, toTargetPos); + } +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *reA = wmc->wchar2char(re, cp); + return execute(SCI_REPLACETARGETRE, -1, (LPARAM)reA); +#else + return execute(SCI_REPLACETARGETRE, -1, (LPARAM)re); +#endif +} + +void ScintillaEditView::showAutoComletion(int lenEntered, const TCHAR * list) +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *listA = wmc->wchar2char(list, cp); + execute(SCI_AUTOCSHOW, lenEntered, WPARAM(listA)); +#else + execute(SCI_AUTOCSHOW, lenEntered, WPARAM(list)); +#endif +} + +void ScintillaEditView::showCallTip(int startPos, const TCHAR * def) +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *defA = wmc->wchar2char(def, cp); + execute(SCI_CALLTIPSHOW, startPos, LPARAM(defA)); +#else + execute(SCI_CALLTIPSHOW, startPos, (LPARAM)def); +#endif +} + + +void ScintillaEditView::getLine(int lineNumber, TCHAR * line, int lineBufferLen) +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + char *lineA = new char[lineBufferLen]; + execute(SCI_GETLINE, lineNumber, (LPARAM)lineA); + const TCHAR *lineW = wmc->char2wchar(lineA, cp); + lstrcpy(line, lineW); + delete [] lineA; +#else + execute(SCI_GETLINE, lineNumber, (LPARAM)line); +#endif +} + + +void ScintillaEditView::addText(int length, const char *buf) +{ + execute(SCI_ADDTEXT, length, (LPARAM)buf); +} + void ScintillaEditView::marginClick(int position, int modifiers) { int lineClick = int(execute(SCI_LINEFROMPOSITION, position, 0)); @@ -1363,14 +1622,14 @@ void ScintillaEditView::performGlobalStyles() { StyleArray & stylers = _pParameter->getMiscStylerArray(); - int i = stylers.getStylerIndexByName("Current line background colour"); + int i = stylers.getStylerIndexByName(TEXT("Current line background colour")); if (i != -1) { Style & style = stylers.getStyler(i); execute(SCI_SETCARETLINEBACK, style._bgColor); } /* - i = stylers.getStylerIndexByName("Mark colour"); + i = stylers.getStylerIndexByName(TEXT("Mark colour")); if (i != -1) { Style & style = stylers.getStyler(i); @@ -1380,7 +1639,7 @@ void ScintillaEditView::performGlobalStyles() */ COLORREF selectColorBack = grey; - i = stylers.getStylerIndexByName("Selected text colour"); + i = stylers.getStylerIndexByName(TEXT("Selected text colour")); if (i != -1) { Style & style = stylers.getStyler(i); @@ -1398,7 +1657,7 @@ void ScintillaEditView::performGlobalStyles() execute(SCI_SETCARETFORE, caretColor); COLORREF edgeColor = liteGrey; - i = stylers.getStylerIndexByName("Edge colour"); + i = stylers.getStylerIndexByName(TEXT("Edge colour")); if (i != -1) { Style & style = stylers.getStyler(i); @@ -1408,7 +1667,7 @@ void ScintillaEditView::performGlobalStyles() COLORREF foldMarginColor = grey; COLORREF foldMarginHiColor = white; - i = stylers.getStylerIndexByName("Fold margin"); + i = stylers.getStylerIndexByName(TEXT("Fold margin")); if (i != -1) { Style & style = stylers.getStyler(i); @@ -1420,7 +1679,7 @@ void ScintillaEditView::performGlobalStyles() COLORREF foldfgColor = white; COLORREF foldbgColor = grey; - i = stylers.getStylerIndexByName("Fold"); + i = stylers.getStylerIndexByName(TEXT("Fold")); if (i != -1) { @@ -1432,7 +1691,7 @@ void ScintillaEditView::performGlobalStyles() defineMarker(_markersArray[FOLDER_TYPE][j], _markersArray[_folderStyle][j], foldfgColor, foldbgColor); COLORREF wsSymbolFgColor = black; - i = stylers.getStylerIndexByName("White space symbol"); + i = stylers.getStylerIndexByName(TEXT("White space symbol")); if (i != -1) { Style & style = stylers.getStyler(i); @@ -1475,11 +1734,19 @@ void ScintillaEditView::setLineIndent(int line, int indent) const { execute(SCI_SETSEL, crange.cpMin, crange.cpMax); } -const char * ScintillaEditView::getCompleteKeywordList(std::string & kwl, LangType langType, int keywordIndex) +const char * ScintillaEditView::getCompleteKeywordList(std::basic_string & kwl, LangType langType, int keywordIndex) { kwl += " "; - const char *defKwl = _pParameter->getWordList(langType, keywordIndex); + const TCHAR *defKwl_generic = _pParameter->getWordList(langType, keywordIndex); + +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char * defKwl = wmc->wchar2char(defKwl_generic, CP_ACP); kwl += defKwl?defKwl:""; +#else + kwl += defKwl_generic?defKwl_generic:""; +#endif + return kwl.c_str(); } @@ -1496,8 +1763,8 @@ void ScintillaEditView::convertSelectedTextTo(bool Case) ColumnModeInfo cmi = getColumnModeSelectInfo(); const int len = cmi[0].second - cmi[0].first; - char *srcStr = new char[len]; - wchar_t *destStr = new wchar_t[len]; + char *srcStr = new char[len+1]; + wchar_t *destStr = new wchar_t[len+3]; for (size_t i = 0 ; i < cmi.size() ; i++) { int start = cmi[i].first; @@ -1534,9 +1801,9 @@ void ScintillaEditView::convertSelectedTextTo(bool Case) if (strSize) { - char *selectedStr = new char[strSize]; + char *selectedStr = new char[strSize+1]; int strWSize = strSize * 2; - WCHAR *selectedStrW = new WCHAR[strWSize]; + wchar_t *selectedStrW = new wchar_t[strWSize+3]; execute(SCI_GETSELTEXT, 0, (LPARAM)selectedStr); @@ -1571,11 +1838,11 @@ bool ScintillaEditView::expandWordSelection() return false; } -char * int2str(char *str, int strLen, int number, int base, int nbChiffre, bool isZeroLeading) +TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, bool isZeroLeading) { if (nbChiffre >= strLen) return NULL; - char f[64]; - char fStr[2] = "d"; + TCHAR f[64]; + TCHAR fStr[2] = TEXT("d"); if (base == 16) fStr[0] = 'X'; else if (base == 8) @@ -1600,18 +1867,18 @@ char * int2str(char *str, int strLen, int number, int base, int nbChiffre, bool { if (base == 2) { - char *j = str; + TCHAR *j = str; for ( ; *j != '\0' ; j++) if (*j == '1') break; - strcpy(str, j); + lstrcpy(str, j); } else { - sprintf(f, "%%%s", fStr); - sprintf(str, f, number); + wsprintf(f, TEXT("%%%s"), fStr); + wsprintf(str, f, number); } - int i = strlen(str); + int i = lstrlen(str); for ( ; i < nbChiffre ; i++) str[i] = ' '; str[i] = '\0'; @@ -1620,8 +1887,8 @@ char * int2str(char *str, int strLen, int number, int base, int nbChiffre, bool { if (base != 2) { - sprintf(f, "%%.%d%s", nbChiffre, fStr); - sprintf(str, f, number); + wsprintf(f, TEXT("%%.%d%s"), nbChiffre, fStr); + wsprintf(str, f, number); } // else already done. } @@ -1678,30 +1945,35 @@ ColumnModeInfo ScintillaEditView::getColumnModeSelectInfo() return columnModeInfo; } -void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, const char *str) +void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, const TCHAR *str) { //for (int i = (int)cmi.size() - 1 ; i >= 0 ; i--) int totalDiff = 0; for (size_t i = 0 ; i < cmi.size() ; i++) { int len2beReplace = cmi[i].second - cmi[i].first; - int diff = strlen(str) - len2beReplace; + int diff = lstrlen(str) - len2beReplace; cmi[i].first += totalDiff; cmi[i].second += totalDiff; execute(SCI_SETTARGETSTART, cmi[i].first); execute(SCI_SETTARGETEND, cmi[i].second); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *strA = wmc->wchar2char(str, cp); + execute(SCI_REPLACETARGET, -1, (LPARAM)strA); +#else execute(SCI_REPLACETARGET, -1, (LPARAM)str); - +#endif totalDiff += diff; cmi[i].second += diff; - //printStr("fin"); } } -void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int incr, unsigned char format) +void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int incr, UCHAR format) { // 0000 00 00 : Dec BASE_10 // 0000 00 01 : Hex BASE_16 @@ -1711,10 +1983,10 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc // 0000 01 00 : 0 leading //Defined in ScintillaEditView.h : - //const unsigned char MASK_FORMAT = 0x03; - //const unsigned char MASK_ZERO_LEADING = 0x04; + //const UCHAR MASK_FORMAT = 0x03; + //const UCHAR MASK_ZERO_LEADING = 0x04; - unsigned char f = format & MASK_FORMAT; + UCHAR f = format & MASK_FORMAT; bool isZeroLeading = (MASK_ZERO_LEADING & format) != 0; int base = 10; @@ -1730,7 +2002,7 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc int nbInit = getNbChiffre(initial, base); int nb = max(nbInit, nbEnd); - char str[512]; + TCHAR str[512]; int totalDiff = 0; for (size_t i = 0 ; i < cmi.size() ; i++) @@ -1745,25 +2017,38 @@ void ScintillaEditView::columnReplace(ColumnModeInfo & cmi, int initial, int inc execute(SCI_SETTARGETSTART, cmi[i].first); execute(SCI_SETTARGETEND, cmi[i].second); +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *strA = wmc->wchar2char(str, cp); + execute(SCI_REPLACETARGET, -1, (LPARAM)strA); +#else execute(SCI_REPLACETARGET, -1, (LPARAM)str); - +#endif initial += incr; - totalDiff += diff; cmi[i].second += diff; } } -void ScintillaEditView::columnReplace(const ColumnModeInfo & cmi, const char ch) +void ScintillaEditView::columnReplace(const ColumnModeInfo & cmi, const TCHAR ch) { for (size_t i = 0 ; i < cmi.size() ; i++) { int len = cmi[i].second - cmi[i].first; - string str(len, ch); + basic_string str(len, ch); execute(SCI_SETTARGETSTART, cmi[i].first); execute(SCI_SETTARGETEND, cmi[i].second); + +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = execute(SCI_GETCODEPAGE); + const char *strA = wmc->wchar2char(str.c_str(), cp); + execute(SCI_REPLACETARGET, -1, (LPARAM)strA); +#else execute(SCI_REPLACETARGET, -1, (LPARAM)str.c_str()); +#endif } } @@ -1847,6 +2132,17 @@ void ScintillaEditView::hideLines() { _currentBuffer->setHideLineChanged(true, startLine-1); } +void ScintillaEditView::setHiLiteResultWords(const TCHAR *keywords) +{ +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + const char * word2search = wmc->wchar2char(keywords, CP_ACP); + setKeywords(L_SEARCHRESULT, word2search, 0); +#else + setKeywords(L_SEARCHRESULT, keywords, 0); +#endif +} + bool ScintillaEditView::markerMarginClick(int lineNumber) { int state = execute(SCI_MARKERGET, lineNumber); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 5f9c60ad..704ab153 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -64,7 +64,7 @@ typedef void * SCINTILLA_PTR; #define WM_DOOPEN (SCINTILLA_USER + 8) #define WM_FINDINFILES (SCINTILLA_USER + 9) -#define LINEDRAW_FONT "LINEDRAW.TTF" +//const TCHAR * LINEDRAW_FONT = TEXT("LINEDRAW.TTF"); const int NB_FOLDER_STATE = 7; @@ -92,12 +92,12 @@ const bool UPPERCASE = true; const bool LOWERCASE = false; typedef vector > ColumnModeInfo; -const unsigned char MASK_FORMAT = 0x03; -const unsigned char MASK_ZERO_LEADING = 0x04; -const unsigned char BASE_10 = 0x00; // Dec -const unsigned char BASE_16 = 0x01; // Hex -const unsigned char BASE_08 = 0x02; // Oct -const unsigned char BASE_02 = 0x03; // Bin +const UCHAR MASK_FORMAT = 0x03; +const UCHAR MASK_ZERO_LEADING = 0x04; +const UCHAR BASE_10 = 0x00; // Dec +const UCHAR BASE_16 = 0x01; // Hex +const UCHAR BASE_08 = 0x02; // Oct +const UCHAR BASE_02 = 0x03; // Bin static int getNbChiffre(int aNum, int base) { @@ -121,14 +121,14 @@ static int getNbChiffre(int aNum, int base) return nbChiffre; }; -char * int2str(char *str, int strLen, int number, int base, int nbChiffre, bool isZeroLeading); +TCHAR * int2str(TCHAR *str, int strLen, int number, int base, int nbChiffre, bool isZeroLeading); typedef LRESULT (WINAPI *CallWindowProcFunc) (WNDPROC,HWND,UINT,WPARAM,LPARAM); struct LanguageName { - const char * lexerName; - const char * shortName; - const char * longName; + const TCHAR * lexerName; + const TCHAR * shortName; + const TCHAR * longName; LangType LangID; int lexerID; }; @@ -168,13 +168,33 @@ public: void activateBuffer(BufferID buffer); - /*void setCurrentDocUserType(const char *userLangName) { - strcpy(_buffers[_currentIndex]._userLangExt, userLangName); + /*void setCurrentDocUserType(const TCHAR *userLangName) { + lstrcpy(_buffers[_currentIndex]._userLangExt, userLangName); _buffers[_currentIndex]._lang = L_USER; defineDocType(L_USER); };*/ void getText(char *dest, int start, int end) const; + void getGenericText(TCHAR *dest, int start, int end) const; + void insertGenericTextFrom(int position, const TCHAR *text2insert) const; + void replaceSelWith(const char * replaceText); + + int getSelectedTextCount() { + CharacterRange range = getSelection(); + return (range.cpMax - range.cpMin); + }; + + char * getSelectedText(char * txt, int size, bool expand = true); + TCHAR * getGenericSelectedText(TCHAR * txt, int size, bool expand = true); + int searchInTarget(const TCHAR * Text2Find, int fromPos, int toPos) const; + //void appandText(const char * text2Append) const; + void appandGenericText(const TCHAR * text2Append) const; + int replaceTarget(const TCHAR * str2replace, int fromTargetPos = -1, int toTargetPos = -1) const; + int replaceTargetRegExMode(const TCHAR * re, int fromTargetPos = -1, int toTargetPos = -1) const; + void showAutoComletion(int lenEntered, const TCHAR * list); + void showCallTip(int startPos, const TCHAR * def); + void getLine(int lineNumber, TCHAR * line, int lineBufferLen); + void addText(int length, const char *buf); void saveCurrentPos(); void restoreCurrentPos(); @@ -192,13 +212,13 @@ public: return crange; }; - void getWordToCurrentPos(char *str, int strLen) const { + void getWordToCurrentPos(TCHAR * str, int strLen) const { int caretPos = execute(SCI_GETCURRENTPOS); int startPos = static_cast(execute(SCI_WORDSTARTPOSITION, caretPos, true)); str[0] = '\0'; if ((caretPos - startPos) < strLen) - getText(str, startPos, caretPos); + getGenericText(str, startPos, caretPos); }; void doUserDefineDlg(bool willBeShown = true, bool isRTL = false) { @@ -291,28 +311,6 @@ public: execute(SCI_SETWRAPVISUALFLAGS, willBeShown?SC_WRAPVISUALFLAG_END:SC_WRAPVISUALFLAG_NONE); }; - int getSelectedTextCount() { - CharacterRange range = getSelection(); - return (range.cpMax - range.cpMin); - }; - - char * getSelectedText(char * txt, int size, bool expand = true) { - if (!size) - return NULL; - CharacterRange range = getSelection(); - if (range.cpMax == range.cpMin && expand) - { - expandWordSelection(); - range = getSelection(); - } - if (!(size > (range.cpMax - range.cpMin))) //there must be atleast 1 byte left for zero terminator - { - range.cpMax = range.cpMin+size-1; //keep room for zero terminator - } - getText(txt, range.cpMin, range.cpMax); - return txt; - }; - long getCurrentLineNumber()const { return long(execute(SCI_LINEFROMPOSITION, execute(SCI_GETCURRENTPOS))); }; @@ -456,9 +454,9 @@ public: ColumnModeInfo getColumnModeSelectInfo(); - void columnReplace(ColumnModeInfo & cmi, const char *str); - void columnReplace(const ColumnModeInfo & cmi, const char ch); - void columnReplace(ColumnModeInfo & cmi, int initial, int incr, unsigned char format); + void columnReplace(ColumnModeInfo & cmi, const TCHAR *str); + void columnReplace(const ColumnModeInfo & cmi, const TCHAR ch); + void columnReplace(ColumnModeInfo & cmi, int initial, int incr, UCHAR format); void foldChanged(int line, int levelNow, int levelPrev); void clearIndicator(int indicatorNumber) { @@ -500,6 +498,7 @@ public: previousSelRange = currentSelRange; return false; }; + void setHiLiteResultWords(const TCHAR *keywords); protected: static HINSTANCE _hLib; @@ -557,19 +556,18 @@ protected: //Lexers and Styling void defineDocType(LangType typeDoc); //setup stylers for active document void restyleBuffer(); - const char * getCompleteKeywordList(std::string & kwl, LangType langType, int keywordIndex); + const char * getCompleteKeywordList(std::basic_string & kwl, LangType langType, int keywordIndex); void setKeywords(LangType langType, const char *keywords, int index); void setLexer(int lexerID, LangType langType, int whichList); - inline void makeStyle(LangType langType, const char **keywordArray = NULL); + inline void makeStyle(LangType langType, const TCHAR **keywordArray = NULL); void setStyle(Style styleToSet); //NOT by reference (style edited) void setSpecialStyle(Style & styleToSet); //by reference - void setHotspotStyle(); void setSpecialIndicator(Style & styleToSet); //Complex lexers (same lexer, different language) void setXmlLexer(LangType type); void setCppLexer(LangType type); void setObjCLexer(LangType type); - void setUserLexer(const char *userLangName = NULL); + void setUserLexer(const TCHAR *userLangName = NULL); void setExternalLexer(LangType typeDoc); void setEmbeddedJSLexer(); void setPhpEmbeddedLexer(); @@ -625,7 +623,7 @@ protected: void setTeXLexer() { for (int i = 0 ; i < 4 ; i++) - execute(SCI_SETKEYWORDS, i, reinterpret_cast("")); + execute(SCI_SETKEYWORDS, i, reinterpret_cast(TEXT(""))); setLexer(SCLEX_TEX, L_TEX, 0); }; diff --git a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp index e3732701..90a18fa2 100644 --- a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp @@ -55,13 +55,13 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) valid = false; else { - unsigned char c = (unsigned char)pHighlightView->execute(SCI_GETCHARAT, range.cpMax); + UCHAR c = (UCHAR)pHighlightView->execute(SCI_GETCHARAT, range.cpMax); if (c) { if (isWordChar(char(c))) valid = false; } - c = (unsigned char)pHighlightView->execute(SCI_GETCHARAT, range.cpMin-1); + c = (UCHAR)pHighlightView->execute(SCI_GETCHARAT, range.cpMin-1); if (c) { if (isWordChar(char(c))) @@ -90,7 +90,15 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) FindOption fo; fo._isMatchCase = true; fo._isWholeWord = true; + +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + unsigned int cp = pHighlightView->execute(SCI_GETCODEPAGE); + const TCHAR * text2FindW = wmc->char2wchar(text2Find, cp); + _pFRDlg->processRange(ProcessMarkAll_2, text2FindW, NULL, startPos, endPos, NULL, &fo); +#else _pFRDlg->processRange(ProcessMarkAll_2, text2Find, NULL, startPos, endPos, NULL, &fo); +#endif // restore the original targets to avoid conflicts with the search/replace functions pHighlightView->execute(SCI_SETTARGETSTART, originalStartPos); @@ -109,7 +117,7 @@ bool SmartHighlighter::isQualifiedWord(const char *str) const bool SmartHighlighter::isWordChar(char ch) const { - if ((unsigned char)ch < 0x20) + if ((UCHAR)ch < 0x20) return false; switch(ch) diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp index 1c4dd02a..773e872d 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.cpp @@ -62,7 +62,7 @@ void SharedParametersDialog::initControls() //for the font name combos HWND hFontNameCombo = ::GetDlgItem(_hSelf, _fontNameCombo[i]); - const std::vector & fontlist = pNppParam->getFontList(); + const std::vector> & fontlist = pNppParam->getFontList(); for (int j = 0 ; j < int(fontlist.size()) ; j++) { int k = ::SendMessage(hFontNameCombo, CB_ADDSTRING, 0, (LPARAM)fontlist[j].c_str()); @@ -104,11 +104,11 @@ void SharedParametersDialog::styleUpdate(const Style & style, ColourPicker *pFgC i = 0; ::SendMessage(hFontCombo, CB_SETCURSEL, i, 0); - char size[10]; + TCHAR size[10]; if (style._fontSize == -1) size[0] = '\0'; else - itoa(style._fontSize, size, 10); + wsprintf(size, TEXT("%d"), style._fontSize); hFontCombo = ::GetDlgItem(_hSelf, fontSizeComboId); i = ::SendMessage(hFontCombo, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)size); @@ -187,7 +187,7 @@ BOOL CALLBACK SharedParametersDialog::run_dlgProc(UINT Message, WPARAM wParam, L Style & style = _pUserLang->_styleArray.getStyler(k); if (isFontSize) { - char intStr[5]; + TCHAR intStr[5]; if (i != 0) { ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETLBTEXT, i, (LPARAM)intStr); @@ -195,8 +195,8 @@ BOOL CALLBACK SharedParametersDialog::run_dlgProc(UINT Message, WPARAM wParam, L style._fontSize = -1; else { - char *finStr; - style._fontSize = strtol(intStr, &finStr, 10); + TCHAR *finStr; + style._fontSize = generic_strtol(intStr, &finStr, 10); if (*finStr != '\0') style._fontSize = -1; } @@ -204,7 +204,7 @@ BOOL CALLBACK SharedParametersDialog::run_dlgProc(UINT Message, WPARAM wParam, L } else { - style._fontName = (char *)::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETITEMDATA, i, 0); + style._fontName = (TCHAR *)::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETITEMDATA, i, 0); } if (_pScintilla->getCurrentBuffer()->getLangType() == L_USER) _pScintilla->styleChange(); @@ -247,7 +247,7 @@ BOOL CALLBACK SharedParametersDialog::run_dlgProc(UINT Message, WPARAM wParam, L if (style._fontStyle == -1) style._fontStyle = 0; style._fontStyle ^= fontStyleMask; - //::MessageBox(NULL, "Bingo!!!", "", MB_OK); + //::MessageBox(NULL, TEXT("Bingo!!!"), TEXT(""), MB_OK); } } if (_pScintilla->getCurrentBuffer()->getLangType() == L_USER) @@ -573,17 +573,17 @@ void CommentStyleDialog::setKeywords2List(int id) } if (i != -1) { - char commentOpen[max_char]; - char commentClose[max_char]; - char commentLine[max_char]; - char newList[max_char] = ""; + TCHAR commentOpen[max_char]; + TCHAR commentClose[max_char]; + TCHAR commentLine[max_char]; + TCHAR newList[max_char] = TEXT(""); ::GetDlgItemText(_hSelf, IDC_COMMENTOPEN_EDIT, commentOpen, max_char); ::GetDlgItemText(_hSelf, IDC_COMMENTCLOSE_EDIT, commentClose, max_char); ::GetDlgItemText(_hSelf, IDC_COMMENTLINE_EDIT, commentLine, max_char); convertTo(newList, commentOpen, '1'); convertTo(newList, commentClose, '2'); convertTo(newList, commentLine, '0'); - strcpy(_pUserLang->_keywordLists[i], newList); + lstrcpy(_pUserLang->_keywordLists[i], newList); } } @@ -651,12 +651,12 @@ int CommentStyleDialog::getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) } } -void CommentStyleDialog::convertTo(char *dest, const char *toConvert, char prefix) const +void CommentStyleDialog::convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR prefix) const { - int index = strlen(dest); + int index = lstrlen(dest); dest[index++] = ' '; dest[index++] = prefix; - for (int i = 0 ; i < int(strlen(toConvert)) ; i++) + for (int i = 0 ; i < int(lstrlen(toConvert)) ; i++) { if (toConvert[i] == ' ') { @@ -674,12 +674,12 @@ void CommentStyleDialog::convertTo(char *dest, const char *toConvert, char prefi dest[index] = '\0'; } -void CommentStyleDialog::retrieve(char *dest, const char *toRetrieve, char prefix) const +void CommentStyleDialog::retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR prefix) const { int j = 0; bool begin2Copy = false; - for (int i = 0 ; i < int(strlen(toRetrieve)) ; i++) + for (int i = 0 ; i < int(lstrlen(toRetrieve)) ; i++) { if (((i == 0) || toRetrieve[i-1] == ' ') && (toRetrieve[i] == prefix)) { @@ -699,9 +699,9 @@ void CommentStyleDialog::retrieve(char *dest, const char *toRetrieve, char prefi void CommentStyleDialog::updateDlg() { - char commentOpen[256] = ""; - char commentClose[256] = ""; - char commentLine[256] = ""; + TCHAR commentOpen[256] = TEXT(""); + TCHAR commentClose[256] = TEXT(""); + TCHAR commentLine[256] = TEXT(""); retrieve(commentOpen, _pUserLang->_keywordLists[KWL_COMMENT_INDEX], '1'); retrieve(commentClose, _pUserLang->_keywordLists[KWL_COMMENT_INDEX], '2'); @@ -727,7 +727,7 @@ void CommentStyleDialog::updateDlg() ::SendDlgItemMessage(_hSelf, IDC_COMMENTSYMBOL_CHECK, BM_SETCHECK, _pUserLang->_isCommentSymbol, 0); } -char symbolesArray[] = "+-*/.?!:;,%^$&\"'(_)=}]@\\`|[{#~<>"; +TCHAR symbolesArray[] = TEXT("+-*/.?!:;,%^$&\"'(_)=}]@\\`|[{#~<>"); const bool SymbolsStyleDialog::ADD = true; const bool SymbolsStyleDialog::REMOVE = false; @@ -736,9 +736,9 @@ int bgStatic4[] = {IDC_SYMBOL_BG_STATIC, IDC_SYMBOL_BG2_STATIC, IDC_SYMBOL_BG3_S int fontSizeCombo4[] = {IDC_SYMBOL_FONTSIZE_COMBO, IDC_SYMBOL_FONTSIZE2_COMBO, IDC_SYMBOL_FONTSIZE3_COMBO}; int fontNameCombo4[] = {IDC_SYMBOL_FONT_COMBO, IDC_SYMBOL_FONT2_COMBO, IDC_SYMBOL_FONT3_COMBO}; -// 2 static const char * to have the compatibility with the old xml -const char *SymbolsStyleDialog::_delimTag1 = "DELIMINER1"; -const char *SymbolsStyleDialog::_delimTag2 = "DELIMINER2"; +// 2 static const TCHAR * to have the compatibility with the old xml +const TCHAR *SymbolsStyleDialog::_delimTag1 = TEXT("DELIMINER1"); +const TCHAR *SymbolsStyleDialog::_delimTag2 = TEXT("DELIMINER2"); SymbolsStyleDialog::SymbolsStyleDialog() : SharedParametersDialog(3) { @@ -787,7 +787,7 @@ void SymbolsStyleDialog::symbolAction(bool action) idButton2Disable = IDC_REMOVE_BUTTON; } int i = ::SendDlgItemMessage(_hSelf, id2Remove, LB_GETCURSEL, 0, 0); - char s[2]; + TCHAR s[2]; ::SendDlgItemMessage(_hSelf, id2Remove, LB_GETTEXT, i, (LPARAM)s); ::SendDlgItemMessage(_hSelf, id2Add, LB_ADDSTRING, 0, (LPARAM)s); @@ -840,13 +840,13 @@ void SymbolsStyleDialog::updateDlg() { listboxsReInit(); - const char *symbols = _pUserLang->_keywordLists[KWL_OPERATOR_INDEX]; + const TCHAR *symbols = _pUserLang->_keywordLists[KWL_OPERATOR_INDEX]; - for (int i = 0 ; i < int(strlen(symbols)) ; i++) + for (int i = 0 ; i < int(lstrlen(symbols)) ; i++) { if (symbols[i] != ' ') { - char s[2]; + TCHAR s[2]; s[0] = symbols[i]; s[1] = '\0'; int index = ::SendDlgItemMessage(_hSelf, IDC_AVAILABLE_SYMBOLS_LIST, LB_FINDSTRING, (WPARAM)-1, (LPARAM)s); @@ -877,12 +877,12 @@ void SymbolsStyleDialog::updateDlg() } } - const char *delims = _pUserLang->_keywordLists[KWL_DELIM_INDEX]; + const TCHAR *delims = _pUserLang->_keywordLists[KWL_DELIM_INDEX]; // ICI LE TRAITEMENT POUR REMPLIR LES 4 COMBO BOX - char dOpen1[2], dClose1[2], dOpen2[2], dClose2[2], dOpen3[2], dClose3[2]; + TCHAR dOpen1[2], dClose1[2], dOpen2[2], dClose2[2], dOpen3[2], dClose3[2]; dOpen1[0] = dClose1[0] = dOpen2[0] = dClose2[0] = dOpen3[0] = dClose3[0] = '\0'; dOpen1[1] = dClose1[1] = dOpen2[1] = dClose2[1] = dOpen3[1] = dClose3[1] = '\0'; - if (strlen(delims) >= 6) + if (lstrlen(delims) >= 6) { if (delims[0] != '0') dOpen1[0] = delims[0]; @@ -956,14 +956,14 @@ void SymbolsStyleDialog::updateDlg() void SymbolsStyleDialog::listboxsInit() { - ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BO2_COMBO, CB_ADDSTRING, 0, (LPARAM)""); - ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BC2_COMBO, CB_ADDSTRING, 0, (LPARAM)""); - ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BO3_COMBO, CB_ADDSTRING, 0, (LPARAM)""); - ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BC3_COMBO, CB_ADDSTRING, 0, (LPARAM)""); + ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BO2_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("")); + ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BC2_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("")); + ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BO3_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("")); + ::SendDlgItemMessage(_hSelf, IDC_SYMBOL_BC3_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("")); for (int i = 0 ; i < int(sizeof(symbolesArray)-1) ; i++) { - char s[2]; + TCHAR s[2]; s[0] = symbolesArray[i]; s[1] = '\0'; ::SendDlgItemMessage(_hSelf, IDC_AVAILABLE_SYMBOLS_LIST, LB_ADDSTRING, 0, (LPARAM)s); @@ -1031,7 +1031,7 @@ BOOL CALLBACK SymbolsStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, LPARA else if ((LOWORD(wParam) == IDC_SYMBOL_BO2_COMBO) || (LOWORD(wParam) == IDC_SYMBOL_BC2_COMBO) || (LOWORD(wParam) == IDC_SYMBOL_BO3_COMBO) || (LOWORD(wParam) == IDC_SYMBOL_BC3_COMBO)) { - char charStr[5] = ""; + TCHAR charStr[5] = TEXT(""); int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETCURSEL, 0, 0); ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETLBTEXT, i, (LPARAM)charStr); int symbIndex; @@ -1045,7 +1045,7 @@ BOOL CALLBACK SymbolsStyleDialog::run_dlgProc(UINT Message, WPARAM wParam, LPARA else // (LOWORD(wParam) == IDC_SYMBOL_BC3_COMBO) symbIndex = 4; - char *delims = _pUserLang->_keywordLists[KWL_DELIM_INDEX]; + TCHAR *delims = _pUserLang->_keywordLists[KWL_DELIM_INDEX]; delims[symbIndex] = charStr[0]?charStr[0]:'0'; if (_pScintilla->getCurrentBuffer()->getLangType() == L_USER) @@ -1119,7 +1119,7 @@ int SymbolsStyleDialog::getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) } } -char styleName[][32] = {"DEFAULT", "FOLDEROPEN", "FOLDERCLOSE", "KEYWORD1", "KEYWORD2", "KEYWORD3", "KEYWORD4", "COMMENT", "COMMENT LINE", "NUMBER", "OPERATOR", "DELIMINER1", "DELIMINER2", "DELIMINER3"}; +TCHAR styleName[][32] = {TEXT("DEFAULT"), TEXT("FOLDEROPEN"), TEXT("FOLDERCLOSE"), TEXT("KEYWORD1"), TEXT("KEYWORD2"), TEXT("KEYWORD3"), TEXT("KEYWORD4"), TEXT("COMMENT"), TEXT("COMMENT LINE"), TEXT("NUMBER"), TEXT("OPERATOR"), TEXT("DELIMINER1"), TEXT("DELIMINER2"), TEXT("DELIMINER3")}; UserDefineDialog::UserDefineDialog(): SharedParametersDialog(), _status(UNDOCK), _yScrollPos(0), _prevHightVal(0), _isDirty(false) @@ -1152,11 +1152,11 @@ void UserDefineDialog::changeStyle() { display(false); _status = !_status; - ::SetDlgItemText(_hSelf, IDC_DOCK_BUTTON, (_status == DOCK)?"Undock":"Dock"); + ::SetDlgItemText(_hSelf, IDC_DOCK_BUTTON, (_status == DOCK)?TEXT("Undock"):TEXT("Dock")); long style = ::GetWindowLongPtr(_hSelf, GWL_STYLE); if (!style) - ::MessageBox(NULL,"echou GetWindowLongPtr", "", MB_OK); + ::MessageBox(NULL, TEXT("echou GetWindowLongPtr"), TEXT(""), MB_OK); style = (_status == DOCK)? ((style & ~WS_POPUP) & ~DS_MODALFRAME & ~WS_CAPTION) | WS_CHILD : @@ -1164,7 +1164,7 @@ void UserDefineDialog::changeStyle() long result = ::SetWindowLongPtr(_hSelf, GWL_STYLE, style); if (!result) - ::MessageBox(NULL,"echou SetWindowLongPtr", "", MB_OK); + ::MessageBox(NULL, TEXT("echou SetWindowLongPtr"), TEXT(""), MB_OK); if (_status == DOCK) getActualPosSize(); @@ -1210,7 +1210,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM case WM_INITDIALOG : { _ctrlTab.init(_hInst, _hSelf, false); - _ctrlTab.setFont("Tahoma", 13); + _ctrlTab.setFont(TEXT("Tahoma"), 13); _folderStyleDlg.init(_hInst, _hSelf); _folderStyleDlg.create(IDD_FOLDER_STYLE_DLG); @@ -1228,10 +1228,10 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM _symbolsStyleDlg.create(IDD_SYMBOL_STYLE_DLG); _symbolsStyleDlg.display(false); - _wVector.push_back(DlgInfo(&_folderStyleDlg, "Folder && Default")); - _wVector.push_back(DlgInfo(&_keyWordsStyleDlg, "Keywords Lists")); - _wVector.push_back(DlgInfo(&_commentStyleDlg, "Comment && Number")); - _wVector.push_back(DlgInfo(&_symbolsStyleDlg, "Operators")); + _wVector.push_back(DlgInfo(&_folderStyleDlg, TEXT("Folder && Default"))); + _wVector.push_back(DlgInfo(&_keyWordsStyleDlg, TEXT("Keywords Lists"))); + _wVector.push_back(DlgInfo(&_commentStyleDlg, TEXT("Comment && Number"))); + _wVector.push_back(DlgInfo(&_symbolsStyleDlg, TEXT("Operators"))); _ctrlTab.createTabs(_wVector); _ctrlTab.display(); @@ -1255,7 +1255,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM _commentStyleDlg.reSizeTo(rc); _symbolsStyleDlg.reSizeTo(rc); - ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_ADDSTRING, 0, (LPARAM)"User Define Language"); + ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("User Define Language")); for (int i = 0 ; i < pNppParam->getNbUserLang() ; i++) { UserLangContainer & userLangContainer = pNppParam->getULCFromIndex(i); @@ -1380,11 +1380,11 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM case IDC_REMOVELANG_BUTTON : { - int result = ::MessageBox(_hSelf, "Are you sure?", "Remove the current language", MB_YESNO); + int result = ::MessageBox(_hSelf, TEXT("Are you sure?"), TEXT("Remove the current language"), MB_YESNO); if (result == IDYES) { int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); - char langName[256]; + TCHAR langName[256]; ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName); //remove current language from combobox @@ -1405,20 +1405,20 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM } case IDC_RENAME_BUTTON : { - char langName[256]; + TCHAR langName[256]; int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName); StringDlg strDlg; - strDlg.init(_hInst, _hSelf, "Rename Current Language Name", "Name : ", langName, langNameLenMax-1); + strDlg.init(_hInst, _hSelf, TEXT("Rename Current Language Name"), TEXT("Name : "), langName, langNameLenMax-1); - char *newName = (char *)strDlg.doDialog(); + TCHAR *newName = (TCHAR *)strDlg.doDialog(); if (newName) { if (pNppParam->isExistingUserLangName(newName)) { - ::MessageBox(_hSelf, "This name is used by another language,\rplease give another one.", "Err", MB_OK); + ::MessageBox(_hSelf, TEXT("This name is used by another language,\rplease give another one."), TEXT("Err"), MB_OK); ::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0); return TRUE; } @@ -1429,7 +1429,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM //rename current language name in userLangArray UserLangContainer & userLangContainer = pNppParam->getULCFromIndex(i-1); - strcpy(userLangContainer._name, newName); + lstrcpy(userLangContainer._name, newName); //rename current language name in langMenu HWND hNpp = ::GetParent(_hSelf); @@ -1444,7 +1444,7 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM case IDC_ADDNEW_BUTTON : case IDC_SAVEAS_BUTTON : { - //char langName[256]; + //TCHAR langName[256]; int i = ::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETCURSEL, 0, 0); //::SendDlgItemMessage(_hSelf, IDC_LANGNAME_COMBO, CB_GETLBTEXT, i, (LPARAM)langName); if (i == 0) @@ -1452,21 +1452,21 @@ BOOL CALLBACK UserDefineDialog::run_dlgProc(UINT message, WPARAM wParam, LPARAM StringDlg strDlg; if (wParam == IDC_SAVEAS_BUTTON) - strDlg.init(_hInst, _hSelf, "Save Current Language Name As...", "Name : ", "", langNameLenMax-1); + strDlg.init(_hInst, _hSelf, TEXT("Save Current Language Name As..."), TEXT("Name : "), TEXT(""), langNameLenMax-1); else - strDlg.init(_hInst, _hSelf, "Create New Language...", "Name : ", "", langNameLenMax-1); + strDlg.init(_hInst, _hSelf, TEXT("Create New Language..."), TEXT("Name : "), TEXT(""), langNameLenMax-1); - char *tmpName = (char *)strDlg.doDialog(); - //const char *newName = newNameString.c_str(); + TCHAR *tmpName = (TCHAR *)strDlg.doDialog(); + //const TCHAR *newName = newNameString.c_str(); if (tmpName) { - string newNameString(tmpName); - const char *newName = newNameString.c_str(); + basic_string newNameString(tmpName); + const TCHAR *newName = newNameString.c_str(); if (pNppParam->isExistingUserLangName(newName)) { - ::MessageBox(_hSelf, "This name is used by another language,\rplease give another one.", "Err", MB_OK); + ::MessageBox(_hSelf, TEXT("This name is used by another language,\rplease give another one."), TEXT("Err"), MB_OK); ::PostMessage(_hSelf, WM_COMMAND, IDC_RENAME_BUTTON, 0); return TRUE; } diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.h b/PowerEditor/src/ScitillaComponent/UserDefineDialog.h index 2a4900e9..ba4cef97 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.h +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.h @@ -264,8 +264,8 @@ protected : int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const; private : - void convertTo(char *dest, const char *toConvert, char prefix) const; - void retrieve(char *dest, const char *toRetrieve, char prefix) const; + void convertTo(TCHAR *dest, const TCHAR *toConvert, TCHAR prefix) const; + void retrieve(TCHAR *dest, const TCHAR *toRetrieve, TCHAR prefix) const; }; class SymbolsStyleDialog : public SharedParametersDialog @@ -313,9 +313,9 @@ protected : int getGroupeIndexFromCheck(int ctrlID, int & fontStyleMask) const; private : - // 2 static const char * to have the compatibility with the old xml - static const char *_delimTag1; - static const char *_delimTag2; + // 2 static const TCHAR * to have the compatibility with the old xml + static const TCHAR *_delimTag1; + static const TCHAR *_delimTag2; void symbolAction(bool action); void listboxsRemoveAll(); @@ -394,7 +394,7 @@ public : return _symbolsStyleDlg.getHSelf(); }; - void setTabName(int index, const char *name2set) { + void setTabName(int index, const TCHAR *name2set) { _ctrlTab.renameTab(index, name2set); }; protected : @@ -437,11 +437,11 @@ class StringDlg : public StaticDialog { public : StringDlg() : StaticDialog() {}; - void init(HINSTANCE hInst, HWND parent, char *title, char *staticName, char *text2Set, int txtLen = 0) { + void init(HINSTANCE hInst, HWND parent, TCHAR *title, TCHAR *staticName, TCHAR *text2Set, int txtLen = 0) { Window::init(hInst, parent); - strcpy(_title, title); - strcpy(_static, staticName); - strcpy(_textValue, text2Set); + lstrcpy(_title, title); + lstrcpy(_static, staticName); + lstrcpy(_textValue, text2Set); _txtLen = txtLen; }; @@ -495,9 +495,9 @@ protected : } private : - char _title[64]; - char _textValue[256]; - char _static[32]; + TCHAR _title[64]; + TCHAR _textValue[256]; + TCHAR _static[32]; int _txtLen; }; diff --git a/PowerEditor/src/ScitillaComponent/UserDefineDialog.rc b/PowerEditor/src/ScitillaComponent/UserDefineDialog.rc index 78e9601d..4193f5b7 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineDialog.rc +++ b/PowerEditor/src/ScitillaComponent/UserDefineDialog.rc @@ -24,7 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include "UserDefineResource.h" IDD_FOLDER_STYLE_DLG DIALOGEX 36, 44, 320, 460 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN GROUPBOX "Folder Open Keywords Setting", IDC_FOLDEROPEN_DESCGROUP_STATIC,5,114,300,127,BS_CENTER LTEXT "Foreground color",IDC_FOLDEROPEN_FG_STATIC,27,144,58,8, 0,WS_EX_RIGHT @@ -68,7 +68,7 @@ END IDD_KEYWORD_STYLE_DLG DIALOGEX 36, 44, 320, 460 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN LTEXT "Foreground color",IDC_KEYWORD1_FG_STATIC,26,25,56,8,0, WS_EX_RIGHT LTEXT "Background color",IDC_KEYWORD1_BG_STATIC,26,45,56,8,0,WS_EX_RIGHT @@ -130,7 +130,7 @@ END IDD_COMMENT_STYLE_DLG DIALOGEX 36, 44, 320, 460 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN LTEXT "Foreground color ",IDC_COMMENTLINE_FG_STATIC,24,31,58,8,0,WS_EX_RIGHT LTEXT "Background color",IDC_COMMENTLINE_BG_STATIC,24,52,58,8,0,WS_EX_RIGHT @@ -179,7 +179,7 @@ END IDD_SYMBOL_STYLE_DLG DIALOGEX 36, 44, 320, 460 STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN LISTBOX IDC_AVAILABLE_SYMBOLS_LIST,68,33,41,116,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "->",IDC_ADD_BUTTON,127,65,50,14 @@ -238,7 +238,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_VSCROLL | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "User Define" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN PUSHBUTTON "Rename",IDC_RENAME_BUTTON,174,40,62,14 PUSHBUTTON "Create New...",IDC_ADDNEW_BUTTON,34,40,62,14 @@ -258,7 +258,7 @@ IDD_STRING_DLG DIALOGEX 0, 0, 151, 52 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN LTEXT "STATIC :",IDC_STRING_STATIC,6,4,42,8,0,WS_EX_RIGHT EDITTEXT IDC_STRING_EDIT,49,2,88,14 diff --git a/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h b/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h index 9ec00281..0975ea28 100644 --- a/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h +++ b/PowerEditor/src/ScitillaComponent/UserDefineLangReference.h @@ -18,6 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef USER_DEFINE_LANG_REFERENCE_H + #define USER_DEFINE_LANG_REFERENCE_H const int langNameLenMax = 16; @@ -31,3 +32,5 @@ const int nbPrefixListAllowed = 4; #endif //USER_DEFINE_LANG_REFERENCE_H + + diff --git a/PowerEditor/src/ScitillaComponent/columnEditor.cpp b/PowerEditor/src/ScitillaComponent/columnEditor.cpp index 31a5822c..0cda3467 100644 --- a/PowerEditor/src/ScitillaComponent/columnEditor.cpp +++ b/PowerEditor/src/ScitillaComponent/columnEditor.cpp @@ -50,7 +50,7 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l { (*_ppEditView)->execute(SCI_BEGINUNDOACTION); - char str[1024]; + TCHAR str[1024]; bool isTextMode = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_TEXT_RADIO, BM_GETCHECK, 0, 0)); @@ -78,7 +78,7 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos); int lineAllocatedLen = 1024; - char *line = new char[lineAllocatedLen]; + TCHAR *line = new TCHAR[lineAllocatedLen]; for (int i = cursorLine ; i <= endLine ; i++) { @@ -91,14 +91,14 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l if (lineLen > lineAllocatedLen) { delete [] line; - line = new char[lineLen]; + line = new TCHAR[lineLen]; } - (*_ppEditView)->getText(line, lineBegin, lineEnd); - string s2r(line); + (*_ppEditView)->getGenericText(line, lineBegin, lineEnd); + basic_string s2r(line); if (lineEndCol < cursorCol) { - string s_space(cursorCol - lineEndCol, ' '); + basic_string s_space(cursorCol - lineEndCol, ' '); s2r.append(s_space); s2r.append(str); } @@ -108,10 +108,7 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l int posRelative2Start = posAbs2Start - lineBegin; s2r.insert(posRelative2Start, str); } - - (*_ppEditView)->execute(SCI_SETTARGETSTART, lineBegin); - (*_ppEditView)->execute(SCI_SETTARGETEND, lineEnd); - (*_ppEditView)->execute(SCI_REPLACETARGET, -1, (LPARAM)s2r.c_str()); + (*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd); } delete [] line; } @@ -120,7 +117,7 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l { int initialNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INITNUM_EDIT, NULL, TRUE); int increaseNumber = ::GetDlgItemInt(_hSelf, IDC_COL_INCREASENUM_EDIT, NULL, TRUE); - unsigned char format = getFormat(); + UCHAR format = getFormat(); display(false); if ((*_ppEditView)->execute(SCI_SELECTIONISRECTANGLE)) @@ -138,10 +135,10 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l int endLine = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, endPos); int lineAllocatedLen = 1024; - char *line = new char[lineAllocatedLen]; + TCHAR *line = new TCHAR[lineAllocatedLen]; - unsigned char f = format & MASK_FORMAT; + UCHAR f = format & MASK_FORMAT; bool isZeroLeading = (MASK_ZERO_LEADING & format) != 0; int base = 10; @@ -170,20 +167,20 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l if (lineLen > lineAllocatedLen) { delete [] line; - line = new char[lineLen]; + line = new TCHAR[lineLen]; } - (*_ppEditView)->getText(line, lineBegin, lineEnd); - string s2r(line); + (*_ppEditView)->getGenericText(line, lineBegin, lineEnd); + basic_string s2r(line); /* - Calcule string + Calcule basic_string */ int2str(str, sizeof(str), initialNumber, base, nb, isZeroLeading); initialNumber += increaseNumber; if (lineEndCol < cursorCol) { - string s_space(cursorCol - lineEndCol, ' '); + basic_string s_space(cursorCol - lineEndCol, ' '); s2r.append(s_space); s2r.append(str); } @@ -194,9 +191,7 @@ BOOL CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM l s2r.insert(posRelative2Start, str); } - (*_ppEditView)->execute(SCI_SETTARGETSTART, lineBegin); - (*_ppEditView)->execute(SCI_SETTARGETEND, lineEnd); - (*_ppEditView)->execute(SCI_REPLACETARGET, -1, (LPARAM)s2r.c_str()); + (*_ppEditView)->replaceTarget(s2r.c_str(), lineBegin, lineEnd); } delete [] line; } diff --git a/PowerEditor/src/ScitillaComponent/columnEditor.h b/PowerEditor/src/ScitillaComponent/columnEditor.h index 4571f88d..aebcde90 100644 --- a/PowerEditor/src/ScitillaComponent/columnEditor.h +++ b/PowerEditor/src/ScitillaComponent/columnEditor.h @@ -59,9 +59,9 @@ public : void switchTo(bool toText); - unsigned char getFormat() { + UCHAR getFormat() { bool isLeadingZeros = (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_LEADZERO_CHECK, BM_GETCHECK, 0, 0)); - unsigned char f = 0; // Dec by default + UCHAR f = 0; // Dec by default if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_HEX_RADIO, BM_GETCHECK, 0, 0)) f = 1; else if (BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_COL_OCT_RADIO, BM_GETCHECK, 0, 0)) diff --git a/PowerEditor/src/ScitillaComponent/columnEditor.rc b/PowerEditor/src/ScitillaComponent/columnEditor.rc index 4c4e4db0..61eb79b2 100644 --- a/PowerEditor/src/ScitillaComponent/columnEditor.rc +++ b/PowerEditor/src/ScitillaComponent/columnEditor.rc @@ -25,7 +25,7 @@ IDD_COLUMNEDIT DIALOGEX 26, 41, 223, 206 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Column Editor" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN GROUPBOX "Text to insert",IDC_COL_TEXT_GRP_STATIC,12,10,124,54 GROUPBOX "Number to insert",IDC_COL_NUM_GRP_STATIC,12,75,204,119 diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp index cbf1a203..3ab20d8d 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.cpp @@ -110,11 +110,6 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, bool direction = searchEnd > searchStart; - if ((direction == search2Left) && (searchStart <= searchEnd)) - return false; - else if ((direction == search2Right) && (searchStart >= searchEnd)) - return false; - pair foundPos; int ltPosOnR = getFirstTokenPosFrom(searchStart, searchEnd, tag2find, foundPos); if (ltPosOnR == -1) @@ -168,45 +163,80 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd, return true; } } - else if (isInList(ltTag, oppositeTagFound)) + else { - while (true) + // RegExpr is "]", found tag could be a openTag or singleTag + // so we should make sure if it's a singleTag + XmlMatchedTagsPos pos; + if (direction == search2Right && getTagCategory(pos,ltTag+1) == inSingleTag) { - ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos); - if (ltTag == -1) + while (true) { - if (direction == search2Left) - { - return true; - } - else + ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos); + + if (ltTag == -1) { tagsPos.tagCloseStart = foundPos.first; tagsPos.tagCloseEnd = foundPos.second; + return true; } - return true; - } - else if (!isInList(ltTag, oppositeTagFound)) - { - oppositeTagFound.push_back(ltTag); - break; - } - else - { - if (direction == search2Left) + else { - XmlMatchedTagsPos tmpTagsPos; - getTagCategory(tmpTagsPos, ltTag+1); - ltTag = tmpTagsPos.tagCloseEnd; + if (getTagCategory(pos,ltTag+1) == inSingleTag) + { + continue; + } + + if (!isInList(ltTag, oppositeTagFound)) + { + oppositeTagFound.push_back(ltTag); + break; + } + } + } + return getMatchedTagPos(foundPos.second, searchEnd, tag2find, oppositeTag2find, oppositeTagFound, tagsPos); + } + + + if (isInList(ltTag, oppositeTagFound)) + { + while (true) + { + ltTag = getFirstTokenPosFrom(ltTag, e, oppositeTag2find, oppositeTagPos); + if (ltTag == -1) + { + if (direction == search2Left) + { + return true; + } + else + { + tagsPos.tagCloseStart = foundPos.first; + tagsPos.tagCloseEnd = foundPos.second; + } + return true; + } + else if (!isInList(ltTag, oppositeTagFound)) + { + oppositeTagFound.push_back(ltTag); + break; + } + else + { + if (direction == search2Left) + { + XmlMatchedTagsPos tmpTagsPos; + getTagCategory(tmpTagsPos, ltTag+1); + ltTag = tmpTagsPos.tagCloseEnd; + } } } } + else + { + oppositeTagFound.push_back(ltTag); + } } - else - { - oppositeTagFound.push_back(ltTag); - } - int start, end; if (direction == search2Left) { @@ -254,11 +284,11 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos _pEditView->getText(tagName, startPos, endPos); - string closeTag = " closeTag = ""; - string openTag = "<"; + basic_string openTag = "<"; openTag += tagName; openTag += "[ >]"; @@ -278,10 +308,11 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos char * tagName = new char[endPos-startPos+1]; _pEditView->getText(tagName, startPos, endPos); - string openTag = "<"; + basic_string openTag = "<"; openTag += tagName; + openTag += "[ >]"; - string closeTag = " closeTag = ""; @@ -416,9 +447,10 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) if (lang != L_XML && lang != L_HTML && lang != L_PHP && lang != L_ASP) return; - // Get the original targets to restore after tag matching operation + // Get the original targets and search options to restore after tag matching operation int originalStartPos = _pEditView->execute(SCI_GETTARGETSTART); int originalEndPos = _pEditView->execute(SCI_GETTARGETEND); + int originalSearchFlags = _pEditView->execute(SCI_GETSEARCHFLAGS); // Detect if it's a xml/html tag. If yes, Colour it! XmlMatchedTagsPos xmlTags; @@ -450,7 +482,8 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr) } } - // restore the original targets to avoid the conflit with search/replace function + // restore the original targets and search options to avoid the conflit with search/replace function _pEditView->execute(SCI_SETTARGETSTART, originalStartPos); _pEditView->execute(SCI_SETTARGETEND, originalEndPos); + _pEditView->execute(SCI_SETSEARCHFLAGS, originalSearchFlags); } diff --git a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h index 78701d37..70b9566d 100644 --- a/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h +++ b/PowerEditor/src/ScitillaComponent/xmlMatchedTagsHighlighter.h @@ -19,6 +19,8 @@ #define XMLMATCHEDTAGSHIGHLIGHTER_H #include +#include + using namespace std; class ScintillaEditView; diff --git a/PowerEditor/src/TinyXml/tinystr.cpp b/PowerEditor/src/TinyXml/tinystr.cpp index 7d83a443..3fd12cd0 100644 --- a/PowerEditor/src/TinyXml/tinystr.cpp +++ b/PowerEditor/src/TinyXml/tinystr.cpp @@ -33,11 +33,11 @@ distribution. #include "tinystr.h" -// TiXmlString constructor, based on a C string -TiXmlString::TiXmlString (const char* instring) +// TiXmlString constructor, based on a C basic_string +TiXmlString::TiXmlString (const TCHAR* instring) { unsigned newlen; - char * newstring; + TCHAR * newstring; if (!instring) { @@ -46,10 +46,10 @@ TiXmlString::TiXmlString (const char* instring) current_length = 0; return; } - newlen = strlen (instring) + 1; - newstring = new char [newlen]; + newlen = lstrlen (instring) + 1; + newstring = new TCHAR [newlen]; memcpy (newstring, instring, newlen); - // strcpy (newstring, instring); + // lstrcpy (newstring, instring); allocated = newlen; cstring = newstring; current_length = newlen - 1; @@ -59,7 +59,7 @@ TiXmlString::TiXmlString (const char* instring) TiXmlString::TiXmlString (const TiXmlString& copy) { unsigned newlen; - char * newstring; + TCHAR * newstring; // Prevent copy to self! if ( © == this ) @@ -73,8 +73,8 @@ TiXmlString::TiXmlString (const TiXmlString& copy) return; } newlen = copy . length () + 1; - newstring = new char [newlen]; - // strcpy (newstring, copy . cstring); + newstring = new TCHAR [newlen]; + // lstrcpy (newstring, copy . cstring); memcpy (newstring, copy . cstring, newlen); allocated = newlen; cstring = newstring; @@ -82,19 +82,19 @@ TiXmlString::TiXmlString (const TiXmlString& copy) } // TiXmlString = operator. Safe when assign own content -void TiXmlString ::operator = (const char * content) +void TiXmlString ::operator = (const TCHAR * content) { unsigned newlen; - char * newstring; + TCHAR * newstring; if (! content) { empty_it (); return; } - newlen = strlen (content) + 1; - newstring = new char [newlen]; - // strcpy (newstring, content); + newlen = lstrlen (content) + 1; + newstring = new TCHAR [newlen]; + // lstrcpy (newstring, content); memcpy (newstring, content, newlen); empty_it (); allocated = newlen; @@ -106,7 +106,7 @@ void TiXmlString ::operator = (const char * content) void TiXmlString ::operator = (const TiXmlString & copy) { unsigned newlen; - char * newstring; + TCHAR * newstring; if (! copy . length ()) { @@ -114,8 +114,8 @@ void TiXmlString ::operator = (const TiXmlString & copy) return; } newlen = copy . length () + 1; - newstring = new char [newlen]; - // strcpy (newstring, copy . c_str ()); + newstring = new TCHAR [newlen]; + // lstrcpy (newstring, copy . c_str ()); memcpy (newstring, copy . c_str (), newlen); empty_it (); allocated = newlen; @@ -127,20 +127,20 @@ void TiXmlString ::operator = (const TiXmlString & copy) //// Checks if a TiXmlString contains only whitespace (same rules as isspace) //bool TiXmlString::isblank () const //{ -// char * lookup; +// TCHAR * lookup; // for (lookup = cstring; * lookup; lookup++) // if (! isspace (* lookup)) // return false; // return true; //} -// append a const char * to an existing TiXmlString -void TiXmlString::append( const char* str, int len ) +// append a const TCHAR * to an existing TiXmlString +void TiXmlString::append( const TCHAR* str, int len ) { - char * new_string; + TCHAR * new_string; unsigned new_alloc, new_size, size_suffix; - size_suffix = strlen (str); + size_suffix = lstrlen (str); if (len < (int) size_suffix) size_suffix = len; if (! size_suffix) @@ -154,12 +154,12 @@ void TiXmlString::append( const char* str, int len ) new_alloc = assign_new_size (new_size); // allocate new buffer - new_string = new char [new_alloc]; + new_string = new TCHAR [new_alloc]; new_string [0] = 0; // copy the previous allocated buffer into this one if (allocated && cstring) - // strcpy (new_string, cstring); + // lstrcpy (new_string, cstring); memcpy (new_string, cstring, length ()); // append the suffix. It does exist, otherwize we wouldn't be expanding @@ -178,7 +178,7 @@ void TiXmlString::append( const char* str, int len ) } else { - // we know we can safely append the new string + // we know we can safely append the new basic_string // strncat (cstring, str, len); memcpy (cstring + length (), str, @@ -189,13 +189,13 @@ void TiXmlString::append( const char* str, int len ) } -// append a const char * to an existing TiXmlString -void TiXmlString::append( const char * suffix ) +// append a const TCHAR * to an existing TiXmlString +void TiXmlString::append( const TCHAR * suffix ) { - char * new_string; + TCHAR * new_string; unsigned new_alloc, new_size; - new_size = length () + strlen (suffix) + 1; + new_size = length () + lstrlen (suffix) + 1; // check if we need to expand if (new_size > allocated) { @@ -203,19 +203,19 @@ void TiXmlString::append( const char * suffix ) new_alloc = assign_new_size (new_size); // allocate new buffer - new_string = new char [new_alloc]; + new_string = new TCHAR [new_alloc]; new_string [0] = 0; // copy the previous allocated buffer into this one if (allocated && cstring) memcpy (new_string, cstring, 1 + length ()); - // strcpy (new_string, cstring); + // lstrcpy (new_string, cstring); // append the suffix. It does exist, otherwize we wouldn't be expanding - // strcat (new_string, suffix); + // lstrcat (new_string, suffix); memcpy (new_string + length (), suffix, - strlen (suffix) + 1); + lstrlen (suffix) + 1); // return previsously allocated buffer if any if (allocated && cstring) @@ -227,11 +227,11 @@ void TiXmlString::append( const char * suffix ) } else { - // we know we can safely append the new string - // strcat (cstring, suffix); + // we know we can safely append the new basic_string + // lstrcat (cstring, suffix); memcpy (cstring + length (), suffix, - strlen (suffix) + 1); + lstrlen (suffix) + 1); } current_length = new_size - 1; } @@ -239,21 +239,21 @@ void TiXmlString::append( const char * suffix ) // Check for TiXmlString equuivalence //bool TiXmlString::operator == (const TiXmlString & compare) const //{ -// return (! strcmp (c_str (), compare . c_str ())); +// return (! lstrcmp (c_str (), compare . c_str ())); //} //unsigned TiXmlString::length () const //{ // if (allocated) -// // return strlen (cstring); +// // return lstrlen (cstring); // return current_length; // return 0; //} -unsigned TiXmlString::find (char tofind, unsigned offset) const +unsigned TiXmlString::find (TCHAR tofind, unsigned offset) const { - char * lookup; + TCHAR * lookup; if (offset >= length ()) return (unsigned) notfound; @@ -270,7 +270,7 @@ bool TiXmlString::operator == (const TiXmlString & compare) const { assert( cstring ); assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) == 0 ); + return ( lstrcmp( cstring, compare.cstring ) == 0 ); } return false; } @@ -282,7 +282,7 @@ bool TiXmlString::operator < (const TiXmlString & compare) const { assert( cstring ); assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) > 0 ); + return ( lstrcmp( cstring, compare.cstring ) > 0 ); } return false; } @@ -294,7 +294,7 @@ bool TiXmlString::operator > (const TiXmlString & compare) const { assert( cstring ); assert( compare.cstring ); - return ( strcmp( cstring, compare.cstring ) < 0 ); + return ( lstrcmp( cstring, compare.cstring ) < 0 ); } return false; } diff --git a/PowerEditor/src/TinyXml/tinystr.h b/PowerEditor/src/TinyXml/tinystr.h index 64e6934b..0f72bc7d 100644 --- a/PowerEditor/src/TinyXml/tinystr.h +++ b/PowerEditor/src/TinyXml/tinystr.h @@ -33,19 +33,20 @@ distribution. #pragma warning( disable : 4514 ) #include +#include /* - TiXmlString is an emulation of the std::string template. + TiXmlString is an emulation of the std::basic_string template. Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. Only the member functions relevant to the TinyXML project have been implemented. The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. + a basic_string and there's no more room, we allocate a buffer twice as big as we need. */ class TiXmlString { public : - // TiXmlString constructor, based on a string - TiXmlString (const char * instring); + // TiXmlString constructor, based on a basic_string + TiXmlString (const TCHAR * instring); // TiXmlString empty constructor TiXmlString () @@ -64,12 +65,12 @@ class TiXmlString empty_it (); } - // Convert a TiXmlString into a classical char * - const char * c_str () const + // Convert a TiXmlString into a classical TCHAR * + const TCHAR * c_str () const { if (allocated) return cstring; - return ""; + return TEXT(""); } // Return the length of a TiXmlString @@ -79,20 +80,20 @@ class TiXmlString } // TiXmlString = operator - void operator = (const char * content); + void operator = (const TCHAR * content); // = operator void operator = (const TiXmlString & copy); // += operator. Maps to append - TiXmlString& operator += (const char * suffix) + TiXmlString& operator += (const TCHAR * suffix) { append (suffix); return *this; } // += operator. Maps to append - TiXmlString& operator += (char single) + TiXmlString& operator += (TCHAR single) { append (single); return *this; @@ -115,25 +116,25 @@ class TiXmlString } // Checks if a TiXmlString contains only whitespace (same rules as isspace) - // Not actually used in tinyxml. Conflicts with a C macro, "isblank", + // Not actually used in tinyxml. Conflicts with a C macro, TEXT("isblank"), // which is a problem. Commenting out. -lee // bool isblank () const; - // single char extraction - const char& at (unsigned index) const + // single TCHAR extraction + const TCHAR& at (unsigned index) const { assert( index < length ()); return cstring [index]; } - // find a char in a string. Return TiXmlString::notfound if not found - unsigned find (char lookup) const + // find a TCHAR in a basic_string. Return TiXmlString::notfound if not found + unsigned find (TCHAR lookup) const { return find (lookup, 0); } - // find a char in a string from an offset. Return TiXmlString::notfound if not found - unsigned find (char tofind, unsigned offset) const; + // find a TCHAR in a basic_string from an offset. Return TiXmlString::notfound if not found + unsigned find (TCHAR tofind, unsigned offset) const; /* Function to reserve a big amount of data when we know we'll need it. Be aware that this function clears the content of the TiXmlString if any exists. @@ -144,14 +145,14 @@ class TiXmlString if (size) { allocated = size; - cstring = new char [size]; + cstring = new TCHAR [size]; cstring [0] = 0; current_length = 0; } } // [] operator - char& operator [] (unsigned index) const + TCHAR& operator [] (unsigned index) const { assert( index < length ()); return cstring [index]; @@ -161,15 +162,15 @@ class TiXmlString enum { notfound = 0xffffffff, npos = notfound }; - void append (const char *str, int len ); + void append (const TCHAR *str, int len ); protected : - // The base string - char * cstring; + // The base basic_string + TCHAR * cstring; // Number of chars allocated unsigned allocated; - // Current string size + // Current basic_string size unsigned current_length; // New size computation. It is simplistic right now : it returns twice the amount @@ -189,7 +190,7 @@ class TiXmlString current_length = 0; } - void append (const char *suffix ); + void append (const TCHAR *suffix ); // append function for another TiXmlString void append (const TiXmlString & suffix) @@ -197,10 +198,10 @@ class TiXmlString append (suffix . c_str ()); } - // append for a single char. This could be improved a lot if needed - void append (char single) + // append for a single TCHAR. This could be improved a lot if needed + void append (TCHAR single) { - char smallstr [2]; + TCHAR smallstr [2]; smallstr [0] = single; smallstr [1] = 0; append (smallstr); @@ -218,7 +219,7 @@ public : TiXmlOutStream () : TiXmlString () {} // TiXmlOutStream << operator. Maps to TiXmlString::append - TiXmlOutStream & operator << (const char * in) + TiXmlOutStream & operator << (const TCHAR * in) { append (in); return (* this); diff --git a/PowerEditor/src/TinyXml/tinyxml.cpp b/PowerEditor/src/TinyXml/tinyxml.cpp index 19a5a519..01bdb00e 100644 --- a/PowerEditor/src/TinyXml/tinyxml.cpp +++ b/PowerEditor/src/TinyXml/tinyxml.cpp @@ -24,7 +24,7 @@ distribution. #include #include "tinyxml.h" -#include "UniConversion.h" +#include "SysMsg.h" #ifdef TIXML_USE_STL #include @@ -92,14 +92,14 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) { // Easy pass at non-alpha/numeric/symbol // 127 is the delete key. Below 32 is symbolic. - char buf[ 32 ]; - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - outString->append( buf, strlen( buf ) ); + TCHAR buf[ 32 ]; + wsprintf( buf, TEXT("&#x%02X;"), (unsigned) ( c & 0xff ) ); + outString->append( buf, lstrlen( buf ) ); ++i; } else { - char realc = (char) c; + TCHAR realc = (TCHAR) c; outString->append( &realc, 1 ); ++i; } @@ -110,10 +110,10 @@ void TiXmlBase::PutString( const TIXML_STRING& str, TIXML_STRING* outString ) // <-- Strange class for a bug fix. Search for STL_STRING_BUG TiXmlBase::StringToBuffer::StringToBuffer( const TIXML_STRING& str ) { - buffer = new char[ str.length()+1 ]; + buffer = new TCHAR[ str.length()+1 ]; if ( buffer ) { - strcpy( buffer, str.c_str() ); + lstrcpy( buffer, str.c_str() ); } } @@ -297,7 +297,7 @@ bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) return true; } -TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +TiXmlNode* TiXmlNode::FirstChild( const TCHAR * _value ) const { TiXmlNode* node; for ( node = firstChild; node; node = node->next ) @@ -308,7 +308,7 @@ TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const return 0; } -TiXmlNode* TiXmlNode::LastChild( const char * _value ) const +TiXmlNode* TiXmlNode::LastChild( const TCHAR * _value ) const { TiXmlNode* node; for ( node = lastChild; node; node = node->prev ) @@ -332,7 +332,7 @@ TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const } } -TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const +TiXmlNode* TiXmlNode::IterateChildren( const TCHAR * val, TiXmlNode* previous ) const { if ( !previous ) { @@ -345,7 +345,7 @@ TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) c } } -TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +TiXmlNode* TiXmlNode::NextSibling( const TCHAR * _value ) const { TiXmlNode* node; for ( node = next; node; node = node->next ) @@ -357,7 +357,7 @@ TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const } -TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +TiXmlNode* TiXmlNode::PreviousSibling( const TCHAR * _value ) const { TiXmlNode* node; for ( node = prev; node; node = node->prev ) @@ -368,7 +368,7 @@ TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const return 0; } -void TiXmlElement::RemoveAttribute( const char * name ) +void TiXmlElement::RemoveAttribute( const TCHAR * name ) { TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) @@ -392,7 +392,7 @@ TiXmlElement* TiXmlNode::FirstChildElement() const return 0; } -TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const +TiXmlElement* TiXmlNode::FirstChildElement( const TCHAR * _value ) const { TiXmlNode* node; @@ -421,7 +421,7 @@ TiXmlElement* TiXmlNode::NextSiblingElement() const return 0; } -TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const +TiXmlElement* TiXmlNode::NextSiblingElement( const TCHAR * _value ) const { TiXmlNode* node; @@ -450,7 +450,7 @@ TiXmlDocument* TiXmlNode::GetDocument() const } -TiXmlElement::TiXmlElement (const char * _value) +TiXmlElement::TiXmlElement (const TCHAR * _value) : TiXmlNode( TiXmlNode::ELEMENT ) { firstChild = lastChild = 0; @@ -467,7 +467,7 @@ TiXmlElement::~TiXmlElement() } } -const char * TiXmlElement::Attribute( const char * name ) const +const TCHAR * TiXmlElement::Attribute( const TCHAR * name ) const { TiXmlAttribute* node = attributeSet.Find( name ); @@ -478,13 +478,13 @@ const char * TiXmlElement::Attribute( const char * name ) const } -const char * TiXmlElement::Attribute( const char * name, int* i ) const +const TCHAR * TiXmlElement::Attribute( const TCHAR * name, int* i ) const { - const char * s = Attribute( name ); + const TCHAR * s = Attribute( name ); if ( i ) { if ( s ) - *i = atoi( s ); + *i = generic_atoi( s ); else *i = 0; } @@ -492,13 +492,13 @@ const char * TiXmlElement::Attribute( const char * name, int* i ) const } -const char * TiXmlElement::Attribute( const char * name, double* d ) const +const TCHAR * TiXmlElement::Attribute( const TCHAR * name, double* d ) const { - const char * s = Attribute( name ); + const TCHAR * s = Attribute( name ); if ( d ) { if ( s ) - *d = atof( s ); + *d = generic_atof( s ); else *d = 0; } @@ -506,7 +506,7 @@ const char * TiXmlElement::Attribute( const char * name, double* d ) const } -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const +int TiXmlElement::QueryIntAttribute( const TCHAR* name, int* ival ) const { TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) @@ -516,7 +516,7 @@ int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const } -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const +int TiXmlElement::QueryDoubleAttribute( const TCHAR* name, double* dval ) const { TiXmlAttribute* node = attributeSet.Find( name ); if ( !node ) @@ -526,15 +526,15 @@ int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const } -void TiXmlElement::SetAttribute( const char * name, int val ) +void TiXmlElement::SetAttribute( const TCHAR * name, int val ) { - char buf[64]; - sprintf( buf, "%d", val ); + TCHAR buf[64]; + wsprintf( buf, TEXT("%d"), val ); SetAttribute( name, buf ); } -void TiXmlElement::SetAttribute( const char * name, const char * _value ) +void TiXmlElement::SetAttribute( const TCHAR * name, const TCHAR * _value ) { TiXmlAttribute* node = attributeSet.Find( name ); if ( node ) @@ -560,15 +560,15 @@ void TiXmlElement::Print( FILE* cfile, int depth ) const int i; for ( i=0; iNext() ) { - fprintf( cfile, " " ); + generic_fprintf( cfile, TEXT(" ") ); attrib->Print( cfile, depth ); } @@ -579,41 +579,41 @@ void TiXmlElement::Print( FILE* cfile, int depth ) const TiXmlNode* node; if ( !firstChild ) { - fprintf( cfile, " />" ); + generic_fprintf( cfile, TEXT(" />") ); } else if ( firstChild == lastChild && firstChild->ToText() ) { - fprintf( cfile, ">" ); + generic_fprintf( cfile, TEXT(">") ); firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); + generic_fprintf( cfile, TEXT(""), value.c_str() ); } else { - fprintf( cfile, ">" ); + generic_fprintf( cfile, TEXT(">") ); for ( node = firstChild; node; node=node->NextSibling() ) { if ( !node->ToText() ) { - fprintf( cfile, "\n" ); + generic_fprintf( cfile, TEXT("\n") ); } node->Print( cfile, depth+1 ); } - fprintf( cfile, "\n" ); + generic_fprintf( cfile, TEXT("\n") ); for( i=0; i", value.c_str() ); + generic_fprintf( cfile, TEXT(" ") ); + generic_fprintf( cfile, TEXT(""), value.c_str() ); } } void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << "<" << value; + (*stream) << TEXT("<") << value; TiXmlAttribute* attrib; for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) { - (*stream) << " "; + (*stream) << TEXT(" "); attrib->StreamOut( stream ); } @@ -622,17 +622,17 @@ void TiXmlElement::StreamOut( TIXML_OSTREAM * stream ) const TiXmlNode* node; if ( firstChild ) { - (*stream) << ">"; + (*stream) << TEXT(">"); for ( node = firstChild; node; node=node->NextSibling() ) { node->StreamOut( stream ); } - (*stream) << ""; + (*stream) << TEXT(""); } else { - (*stream) << " />"; + (*stream) << TEXT(" />"); } } @@ -668,7 +668,7 @@ TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) ClearError(); } -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +TiXmlDocument::TiXmlDocument( const TCHAR * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { tabsize = 4; value = documentName; @@ -698,7 +698,7 @@ bool TiXmlDocument::SaveFile() const return false; } -bool TiXmlDocument::LoadFile( const char* filename ) +bool TiXmlDocument::LoadFile( const TCHAR* filename ) { // Delete the existing data: Clear(); @@ -706,21 +706,19 @@ bool TiXmlDocument::LoadFile( const char* filename ) // There was a really terrifying little bug here. The code: // value = filename - // in the STL case, cause the assignment method of the std::string to - // be called. What is strange, is that the std::string had the same + // in the STL case, cause the assignment method of the std::basic_string to + // be called. What is strange, is that the std::basic_string had the same // address as it's c_str() method, and so bad things happen. Looks // like a bug in the Microsoft STL implementation. // See STL_STRING_BUG above. // Fixed with the StringToBuffer class. value = filename; - wchar_t filenameW[MAX_PATH]; - char2wchar(filename, filenameW); - FILE* file = _wfopen( filenameW, L"r" ); + FILE* file = generic_fopen( value.c_str (), TEXT("r") ); if ( file ) { - // Get the file size, so we can pre-allocate the string. HUGE speed impact. + // Get the file size, so we can pre-allocate the basic_string. HUGE speed impact. long length = 0; fseek( file, 0, SEEK_END ); length = ftell( file ); @@ -739,9 +737,9 @@ bool TiXmlDocument::LoadFile( const char* filename ) data.reserve( length ); const int BUF_SIZE = 2048; - char buf[BUF_SIZE]; + TCHAR buf[BUF_SIZE]; - while( fgets( buf, BUF_SIZE, file ) ) + while( generic_fgets( buf, BUF_SIZE, file ) ) { data += buf; } @@ -758,12 +756,10 @@ bool TiXmlDocument::LoadFile( const char* filename ) return false; } -bool TiXmlDocument::SaveFile( const char * filename ) const +bool TiXmlDocument::SaveFile( const TCHAR * filename ) const { // The old c stuff lives on... - wchar_t filenameW[MAX_PATH]; - char2wchar(filename, filenameW); - FILE* fp = _wfopen( filenameW, L"w" ); + FILE* fp = generic_fopen( filename, TEXT("w") ); if ( fp ) { Print( fp, 0 ); @@ -799,7 +795,7 @@ void TiXmlDocument::Print( FILE* cfile, int depth ) const for ( node=FirstChild(); node; node=node->NextSibling() ) { node->Print( cfile, depth ); - fprintf( cfile, "\n" ); + generic_fprintf( cfile, TEXT("\n") ); } } @@ -847,9 +843,9 @@ void TiXmlAttribute::Print( FILE* cfile, int /*depth*/ ) const PutString( Value(), &v ); if (value.find ('\"') == TIXML_STRING::npos) - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + generic_fprintf (cfile, TEXT("%s=\"%s\""), n.c_str(), v.c_str() ); else - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + generic_fprintf (cfile, TEXT("%s='%s'"), n.c_str(), v.c_str() ); } @@ -858,55 +854,55 @@ void TiXmlAttribute::StreamOut( TIXML_OSTREAM * stream ) const if (value.find( '\"' ) != TIXML_STRING::npos) { PutString( name, stream ); - (*stream) << "=" << "'"; + (*stream) << TEXT("=") << TEXT("'"); PutString( value, stream ); - (*stream) << "'"; + (*stream) << TEXT("'"); } else { PutString( name, stream ); - (*stream) << "=" << "\""; + (*stream) << TEXT("=") << TEXT("\""); PutString( value, stream ); - (*stream) << "\""; + (*stream) << TEXT("\""); } } int TiXmlAttribute::QueryIntValue( int* ival ) const { - if ( sscanf( value.c_str(), "%d", ival ) == 1 ) + if ( generic_sscanf( value.c_str(), TEXT("%d"), ival ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } int TiXmlAttribute::QueryDoubleValue( double* dval ) const { - if ( sscanf( value.c_str(), "%lf", dval ) == 1 ) + if ( generic_sscanf( value.c_str(), TEXT("%lf"), dval ) == 1 ) return TIXML_SUCCESS; return TIXML_WRONG_TYPE; } void TiXmlAttribute::SetIntValue( int _value ) { - char buf [64]; - sprintf (buf, "%d", _value); + TCHAR buf [64]; + wsprintf (buf, TEXT("%d"), _value); SetValue (buf); } void TiXmlAttribute::SetDoubleValue( double _value ) { - char buf [64]; - sprintf (buf, "%lf", _value); + TCHAR buf [64]; + wsprintf (buf, TEXT("%lf"), _value); SetValue (buf); } const int TiXmlAttribute::IntValue() const { - return atoi (value.c_str ()); + return generic_atoi (value.c_str ()); } const double TiXmlAttribute::DoubleValue() const { - return atof (value.c_str ()); + return generic_atof (value.c_str ()); } void TiXmlComment::Print( FILE* cfile, int depth ) const @@ -915,14 +911,14 @@ void TiXmlComment::Print( FILE* cfile, int depth ) const { fputs( " ", cfile ); } - fprintf( cfile, "", value.c_str() ); + generic_fprintf( cfile, TEXT(""), value.c_str() ); } void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << ""; + (*stream) << TEXT("-->"); } TiXmlNode* TiXmlComment::Clone() const @@ -941,7 +937,7 @@ void TiXmlText::Print( FILE* cfile, int /*depth*/ ) const { TIXML_STRING buffer; PutString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); + generic_fprintf( cfile, TEXT("%s"), buffer.c_str() ); } @@ -954,7 +950,7 @@ void TiXmlText::StreamOut( TIXML_OSTREAM * stream ) const TiXmlNode* TiXmlText::Clone() const { TiXmlText* clone = 0; - clone = new TiXmlText( "" ); + clone = new TiXmlText( TEXT("") ); if ( !clone ) return 0; @@ -964,9 +960,9 @@ TiXmlNode* TiXmlText::Clone() const } -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) +TiXmlDeclaration::TiXmlDeclaration( const TCHAR * _version, + const TCHAR * _encoding, + const TCHAR * _standalone ) : TiXmlNode( TiXmlNode::DECLARATION ) { version = _version; @@ -977,40 +973,40 @@ TiXmlDeclaration::TiXmlDeclaration( const char * _version, void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/ ) const { - fprintf (cfile, ""); + generic_fprintf (cfile, TEXT("standalone=\"%s\" "), standalone.c_str ()); + generic_fprintf (cfile, TEXT("?>")); } void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const { - (*stream) << ""; + (*stream) << TEXT("?>"); } TiXmlNode* TiXmlDeclaration::Clone() const @@ -1031,13 +1027,13 @@ TiXmlNode* TiXmlDeclaration::Clone() const void TiXmlUnknown::Print( FILE* cfile, int depth ) const { for ( int i=0; i"; // Don't use entities hear! It is unknown. + (*stream) << TEXT("<") << value << TEXT(">"); // Don't use entities hear! It is unknown. } TiXmlNode* TiXmlUnknown::Clone() const @@ -1095,7 +1091,7 @@ void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) assert( 0 ); // we tried to remove a non-linked attribute. } -TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const +TiXmlAttribute* TiXmlAttributeSet::Find( const TCHAR * name ) const { TiXmlAttribute* node; @@ -1129,9 +1125,11 @@ TIXML_OSTREAM & operator<< (TIXML_OSTREAM & out, const TiXmlNode & base) #ifdef TIXML_USE_STL -std::string & operator<< (std::string& out, const TiXmlNode& base ) +std::basic_string & operator<< (std::basic_string& out, const TiXmlNode& base ) { - std::ostringstream os_stream( std::ostringstream::out ); + + //std::ostringstream os_stream( std::ostringstream::out ); + std::basic_ostringstream os_stream( std::ostringstream::out ); base.StreamOut( &os_stream ); out.append( os_stream.str() ); @@ -1152,7 +1150,7 @@ TiXmlHandle TiXmlHandle::FirstChild() const } -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const +TiXmlHandle TiXmlHandle::FirstChild( const TCHAR * value ) const { if ( node ) { @@ -1176,7 +1174,7 @@ TiXmlHandle TiXmlHandle::FirstChildElement() const } -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const +TiXmlHandle TiXmlHandle::FirstChildElement( const TCHAR * value ) const { if ( node ) { @@ -1206,7 +1204,7 @@ TiXmlHandle TiXmlHandle::Child( int count ) const } -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const +TiXmlHandle TiXmlHandle::Child( const TCHAR* value, int count ) const { if ( node ) { @@ -1244,7 +1242,7 @@ TiXmlHandle TiXmlHandle::ChildElement( int count ) const } -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const +TiXmlHandle TiXmlHandle::ChildElement( const TCHAR* value, int count ) const { if ( node ) { diff --git a/PowerEditor/src/TinyXml/tinyxml.h b/PowerEditor/src/TinyXml/tinyxml.h index da438d32..d76ee685 100644 --- a/PowerEditor/src/TinyXml/tinyxml.h +++ b/PowerEditor/src/TinyXml/tinyxml.h @@ -37,13 +37,15 @@ distribution. #include #include +#include + // Help out windows: #if defined( _DEBUG ) && !defined( DEBUG ) #define DEBUG #endif #if defined( DEBUG ) && defined( _MSC_VER ) -#include + #define TIXML_LOG OutputDebugString #else #define TIXML_LOG printf @@ -53,9 +55,13 @@ distribution. #include #include //#include - #define TIXML_STRING std::string - #define TIXML_ISTREAM std::istream - #define TIXML_OSTREAM std::ostream + #define TIXML_STRING std::basic_string + //#define TIXML_ISTREAM std::istream + //#define TIXML_OSTREAM std::ostream + #define TIXML_ISTREAM std::basic_istream + #define TIXML_OSTREAM std::basic_ostream + + #else #include "tinystr.h" #define TIXML_STRING TiXmlString @@ -172,10 +178,10 @@ protected: public: StringToBuffer( const TIXML_STRING& str ); ~StringToBuffer(); - char* buffer; + TCHAR* buffer; }; - static const char* SkipWhiteSpace( const char* ); + static const TCHAR* SkipWhiteSpace( const TCHAR* ); inline static bool IsWhiteSpace( int c ) { return ( isspace( c ) || c == '\n' || c == '\r' ); } virtual void StreamOut (TIXML_OSTREAM *) const = 0; @@ -185,28 +191,28 @@ protected: static bool StreamTo( TIXML_ISTREAM * in, int character, TIXML_STRING * tag ); #endif - /* Reads an XML name into the string provided. Returns + /* Reads an XML name into the basic_string provided. Returns a pointer just past the last character of the name, or 0 if the function has an error. */ - static const char* ReadName( const char* p, TIXML_STRING* name ); + static const TCHAR* ReadName( const TCHAR* p, TIXML_STRING* name ); /* Reads text. Returns a pointer past the given end tag. Wickedly complex options, but it keeps the (sensitive) code in one place. */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read + static const TCHAR* ReadText( const TCHAR* in, // where to start + TIXML_STRING* text, // the basic_string read bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text + const TCHAR* endTag, // what ends this text bool ignoreCase ); // whether to ignore case in the end tag - virtual const char* Parse( const char* p, TiXmlParsingData* data ) = 0; + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ) = 0; // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value ); + static const TCHAR* GetEntity( const TCHAR* in, TCHAR* value ); // Get a character, while interpreting entities. - inline static const char* GetChar( const char* p, char* _value ) + inline static const TCHAR* GetChar( const TCHAR* p, TCHAR* _value ) { assert( p ); if ( *p == '&' ) @@ -220,15 +226,15 @@ protected: } } - // Puts a string to a stream, expanding entities as it goes. + // Puts a basic_string to a stream, expanding entities as it goes. // Note this should not contian the '<', '>', etc, or they will be transformed into entities! static void PutString( const TIXML_STRING& str, TIXML_OSTREAM* out ); static void PutString( const TIXML_STRING& str, TIXML_STRING* out ); // Return true if the next characters in the stream are any of the endTag sequences. - static bool StringEqual( const char* p, - const char* endTag, + static bool StringEqual( const TCHAR* p, + const TCHAR* endTag, bool ignoreCase ); @@ -251,16 +257,16 @@ protected: TIXML_ERROR_STRING_COUNT }; - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + static const TCHAR* errorString[ TIXML_ERROR_STRING_COUNT ]; TiXmlCursor location; private: struct Entity { - const char* str; + const TCHAR* str; unsigned int strLength; - char chr; + TCHAR chr; }; enum { @@ -290,7 +296,7 @@ public: /** An input stream operator, for every class. Tolerant of newlines and formatting, but doesn't expect them. */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + friend std::basic_istream& operator >> (std::basic_istream& in, TiXmlNode& base); /** An output stream operator, for every class. Note that this outputs without any newlines or formatting, as opposed to Print(), which @@ -308,10 +314,10 @@ public: A TiXmlDocument will read nodes until it reads a root element, and all the children of that root element. */ - friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + friend std::basic_ostream& operator<< (std::basic_ostream& out, const TiXmlNode& base); - /// Appends the XML node or attribute to a std::string. - friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + /// Appends the XML node or attribute to a std::basic_string. + friend std::basic_string& operator<< (std::basic_string& out, const TiXmlNode& base ); #else // Used internally, not part of the public API. @@ -341,12 +347,12 @@ public: Element: name of the element Comment: the comment text Unknown: the tag contents - Text: the text string + Text: the text basic_string @endverbatim The subclasses will wrap this function. */ - const char * Value() const { return value.c_str (); } + const TCHAR * Value() const { return value.c_str (); } /** Changes the value of the node. Defined as: @verbatim @@ -354,17 +360,17 @@ public: Element: name of the element Comment: the comment text Unknown: the tag contents - Text: the text string + Text: the text basic_string @endverbatim */ - void SetValue(const char * _value) { value = _value;} + void SetValue(const TCHAR * _value) { value = _value;} #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& _value ) + /// STL std::basic_string form. + void SetValue( const std::basic_string& _value ) { StringToBuffer buf( _value ); - SetValue( buf.buffer ? buf.buffer : "" ); + SetValue( buf.buffer ? buf.buffer : TEXT("") ); } #endif @@ -375,14 +381,14 @@ public: TiXmlNode* Parent() const { return parent; } TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const TCHAR * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const TCHAR * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. #ifdef TIXML_USE_STL - TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::basic_string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::basic_string form. + TiXmlNode* LastChild( const std::basic_string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::basic_string form. #endif /** An alternate way to walk the children of a node. @@ -404,10 +410,10 @@ public: TiXmlNode* IterateChildren( TiXmlNode* previous ) const; /// This flavor of IterateChildren searches for children with a particular 'value' - TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TCHAR * value, TiXmlNode* previous ) const; #ifdef TIXML_USE_STL - TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::basic_string& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::basic_string form. #endif /** Add a new node related to this. Adds a child past the LastChild. @@ -449,18 +455,18 @@ public: TiXmlNode* PreviousSibling() const { return prev; } /// Navigate to a sibling node. - TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const TCHAR * ) const; #ifdef TIXML_USE_STL - TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::basic_string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::basic_string form. + TiXmlNode* NextSibling( const std::basic_string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::basic_string form. #endif /// Navigate to a sibling node. TiXmlNode* NextSibling() const { return next; } /// Navigate to a sibling node with the given 'value'. - TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const TCHAR * ) const; /** Convenience function to get through elements. Calls NextSibling and ToElement. Will skip all non-Element @@ -472,20 +478,20 @@ public: Calls NextSibling and ToElement. Will skip all non-Element nodes. Returns 0 if there is not another element. */ - TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const TCHAR * ) const; #ifdef TIXML_USE_STL - TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::basic_string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::basic_string form. #endif /// Convenience function to get through elements. TiXmlElement* FirstChildElement() const; /// Convenience function to get through elements. - TiXmlElement* FirstChildElement( const char * value ) const; + TiXmlElement* FirstChildElement( const TCHAR * value ) const; #ifdef TIXML_USE_STL - TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::basic_string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::basic_string form. #endif /** Query the type (as an enumerated value, above) of this node. @@ -523,7 +529,7 @@ protected: #endif // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start ); + TiXmlNode* Identify( const TCHAR* start ); void CopyToClone( TiXmlNode* target ) const { target->SetValue (value.c_str() ); target->userData = userData; } @@ -564,8 +570,8 @@ public: } #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) + /// std::basic_string constructor. + TiXmlAttribute( const std::basic_string& _name, const std::basic_string& _value ) { name = _name; value = _value; @@ -575,7 +581,7 @@ public: #endif /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ) + TiXmlAttribute( const TCHAR * _name, const TCHAR * _value ) { name = _name; value = _value; @@ -583,12 +589,12 @@ public: prev = next = 0; } - const char* Name() const { return name.c_str (); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str (); } ///< Return the value of this attribute. + const TCHAR* Name() const { return name.c_str (); } ///< Return the name of this attribute. + const TCHAR* Value() const { return value.c_str (); } ///< Return the value of this attribute. const int IntValue() const; ///< Return the value of this attribute, converted to an integer. const double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - /** QueryIntValue examines the value string. It is an alternative to the + /** QueryIntValue examines the value basic_string. It is an alternative to the IntValue() method with richer error checking. If the value is an integer, it is stored in 'value' and the call returns TIXML_SUCCESS. If it is not @@ -598,27 +604,27 @@ public: which is the opposite of almost all other TinyXml calls. */ int QueryIntValue( int* value ) const; - /// QueryDoubleValue examines the value string. See QueryIntValue(). + /// QueryDoubleValue examines the value basic_string. See QueryIntValue(). int QueryDoubleValue( double* value ) const; - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. + void SetName( const TCHAR* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const TCHAR* _value ) { value = _value; } ///< Set the value. void SetIntValue( int value ); ///< Set the value from an integer. void SetDoubleValue( double value ); ///< Set the value from a double. #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) + /// STL std::basic_string form. + void SetName( const std::basic_string& _name ) { StringToBuffer buf( _name ); - SetName ( buf.buffer ? buf.buffer : "error" ); + SetName ( buf.buffer ? buf.buffer : TEXT("error") ); } - /// STL std::string form. - void SetValue( const std::string& _value ) + /// STL std::basic_string form. + void SetValue( const std::basic_string& _value ) { StringToBuffer buf( _value ); - SetValue( buf.buffer ? buf.buffer : "error" ); + SetValue( buf.buffer ? buf.buffer : TEXT("error") ); } #endif @@ -633,9 +639,9 @@ public: /* [internal use] Attribtue parsing starts: first letter of the name - returns: the next char after the value end quote + returns: the next TCHAR after the value end quote */ - virtual const char* Parse( const char* p, TiXmlParsingData* data ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); // [internal use] virtual void Print( FILE* cfile, int depth ) const; @@ -677,7 +683,7 @@ public: TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Find( const char * name ) const; + TiXmlAttribute* Find( const TCHAR * name ) const; private: TiXmlAttribute sentinel; @@ -692,11 +698,11 @@ class TiXmlElement : public TiXmlNode { public: /// Construct an element. - TiXmlElement (const char * in_value); + TiXmlElement (const TCHAR * in_value); #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ) : TiXmlNode( TiXmlNode::ELEMENT ) + /// std::basic_string constructor. + TiXmlElement( const std::basic_string& _value ) : TiXmlNode( TiXmlNode::ELEMENT ) { firstChild = lastChild = 0; value = _value; @@ -708,7 +714,7 @@ public: /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. */ - const char* Attribute( const char* name ) const; + const TCHAR* Attribute( const TCHAR* name ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. @@ -716,7 +722,7 @@ public: the integer value will be put in the return 'i', if 'i' is non-null. */ - const char* Attribute( const char* name, int* i ) const; + const TCHAR* Attribute( const TCHAR* name, int* i ) const; /** Given an attribute name, Attribute() returns the value for the attribute of that name, or null if none exists. @@ -724,7 +730,7 @@ public: the double value will be put in the return 'd', if 'd' is non-null. */ - const char* Attribute( const char* name, double* d ) const; + const TCHAR* Attribute( const TCHAR* name, double* d ) const; /** QueryIntAttribute examines the attribute - it is an alternative to the Attribute() method with richer error checking. @@ -733,29 +739,29 @@ public: an integer, it returns TIXML_WRONG_TYPE. If the attribute does not exist, then TIXML_NO_ATTRIBUTE is returned. */ - int QueryIntAttribute( const char* name, int* value ) const; + int QueryIntAttribute( const TCHAR* name, int* value ) const; /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* value ) const; + int QueryDoubleAttribute( const TCHAR* name, double* value ) const; /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ - void SetAttribute( const char* name, const char * value ); + void SetAttribute( const TCHAR* name, const TCHAR * value ); #ifdef TIXML_USE_STL - const char* Attribute( const std::string& name ) const { return Attribute( name.c_str() ); } - const char* Attribute( const std::string& name, int* i ) const { return Attribute( name.c_str(), i ); } + const TCHAR* Attribute( const std::basic_string& name ) const { return Attribute( name.c_str() ); } + const TCHAR* Attribute( const std::basic_string& name, int* i ) const { return Attribute( name.c_str(), i ); } - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ) + /// STL std::basic_string form. + void SetAttribute( const std::basic_string& name, const std::basic_string& _value ) { StringToBuffer n( name ); StringToBuffer v( _value ); if ( n.buffer && v.buffer ) SetAttribute (n.buffer, v.buffer ); } - ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ) + ///< STL std::basic_string form. + void SetAttribute( const std::basic_string& name, int _value ) { StringToBuffer n( name ); if ( n.buffer ) @@ -766,13 +772,13 @@ public: /** Sets an attribute of name to a given value. The attribute will be created if it does not exist, or changed if it does. */ - void SetAttribute( const char * name, int value ); + void SetAttribute( const TCHAR * name, int value ); /** Deletes an attribute with the given name. */ - void RemoveAttribute( const char * name ); + void RemoveAttribute( const TCHAR * name ); #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + void RemoveAttribute( const std::basic_string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::basic_string form. #endif TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. @@ -793,16 +799,16 @@ protected: virtual void StreamOut( TIXML_OSTREAM * out ) const; /* [internal use] - Attribtue parsing starts: next char past '<' - returns: next char past '>' + Attribtue parsing starts: next TCHAR past '<' + returns: next TCHAR past '>' */ - virtual const char* Parse( const char* p, TiXmlParsingData* data ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); /* [internal use] Reads the "value" of the element -- another element, or text. This should terminate with the current end tag. */ - const char* ReadValue( const char* in, TiXmlParsingData* prevData ); + const TCHAR* ReadValue( const TCHAR* in, TiXmlParsingData* prevData ); private: TiXmlAttributeSet attributeSet; @@ -830,9 +836,9 @@ protected: virtual void StreamOut( TIXML_OSTREAM * out ) const; /* [internal use] Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' + returns: next TCHAR past '>' */ - virtual const char* Parse( const char* p, TiXmlParsingData* data ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); }; @@ -843,7 +849,7 @@ class TiXmlText : public TiXmlNode friend class TiXmlElement; public: /// Constructor. - TiXmlText (const char * initValue) : TiXmlNode (TiXmlNode::TEXT) + TiXmlText (const TCHAR * initValue) : TiXmlNode (TiXmlNode::TEXT) { SetValue( initValue ); } @@ -851,7 +857,7 @@ public: #ifdef TIXML_USE_STL /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) + TiXmlText( const std::basic_string& initValue ) : TiXmlNode (TiXmlNode::TEXT) { SetValue( initValue ); } @@ -867,10 +873,10 @@ protected : // [internal use] bool Blank() const; // returns true if all white space and new lines /* [internal use] - Attribtue parsing starts: First char of the text - returns: next char past '>' + Attribtue parsing starts: First TCHAR of the text + returns: next TCHAR past '>' */ - virtual const char* Parse( const char* p, TiXmlParsingData* data ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); // [internal use] #ifdef TIXML_USE_STL virtual void StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ); @@ -899,9 +905,9 @@ public: #ifdef TIXML_USE_STL /// Constructor. - TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) + TiXmlDeclaration( const std::basic_string& _version, + const std::basic_string& _encoding, + const std::basic_string& _standalone ) : TiXmlNode( TiXmlNode::DECLARATION ) { version = _version; @@ -911,18 +917,18 @@ public: #endif /// Construct. - TiXmlDeclaration( const char* _version, - const char* _encoding, - const char* _standalone ); + TiXmlDeclaration( const TCHAR* _version, + const TCHAR* _encoding, + const TCHAR* _standalone ); virtual ~TiXmlDeclaration() {} /// Version. Will return empty if none was found. - const char * Version() const { return version.c_str (); } + const TCHAR * Version() const { return version.c_str (); } /// Encoding. Will return empty if none was found. - const char * Encoding() const { return encoding.c_str (); } + const TCHAR * Encoding() const { return encoding.c_str (); } /// Is this a standalone document? - const char * Standalone() const { return standalone.c_str (); } + const TCHAR * Standalone() const { return standalone.c_str (); } // [internal use] Creates a new Element and returs it. virtual TiXmlNode* Clone() const; @@ -936,10 +942,10 @@ protected: #endif virtual void StreamOut ( TIXML_OSTREAM * out) const; // [internal use] - // Attribtue parsing starts: next char past '<' - // returns: next char past '>' + // Attribtue parsing starts: next TCHAR past '<' + // returns: next TCHAR past '>' - virtual const char* Parse( const char* p, TiXmlParsingData* data ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); private: TIXML_STRING version; @@ -969,10 +975,10 @@ protected: #endif virtual void StreamOut ( TIXML_OSTREAM * out ) const; /* [internal use] - Attribute parsing starts: First char of the text - returns: next char past '>' + Attribute parsing starts: First TCHAR of the text + returns: next TCHAR past '>' */ - virtual const char* Parse( const char* p, TiXmlParsingData* data ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data ); }; @@ -986,11 +992,11 @@ public: /// Create an empty document, that has no name. TiXmlDocument(); /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); + TiXmlDocument( const TCHAR * documentName ); #ifdef TIXML_USE_STL /// Constructor. - TiXmlDocument( const std::string& documentName ) : + TiXmlDocument( const std::basic_string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) { value = documentName; @@ -1008,17 +1014,17 @@ public: /// Save a file using the current document value. Returns true if successful. bool SaveFile() const; /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename ); + bool LoadFile( const TCHAR * filename ); /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; + bool SaveFile( const TCHAR * filename ) const; #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename ) ///< STL std::string version. + bool LoadFile( const std::basic_string& filename ) ///< STL std::basic_string version. { StringToBuffer f( filename ); return ( f.buffer && LoadFile( f.buffer )); } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. + bool SaveFile( const std::basic_string& filename ) const ///< STL std::basic_string version. { StringToBuffer f( filename ); return ( f.buffer && SaveFile( f.buffer )); @@ -1027,7 +1033,7 @@ public: /** Parse the given null terminated block of xml data. */ - virtual const char* Parse( const char* p, TiXmlParsingData* data = 0 ); + virtual const TCHAR* Parse( const TCHAR* p, TiXmlParsingData* data = 0 ); /** Get the root element -- the only top level element -- of the document. In well formed XML, there should only be one. TinyXml is tolerant of @@ -1043,9 +1049,9 @@ public: bool Error() const { return error; } /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } + const TCHAR * ErrorDesc() const { return errorDesc.c_str (); } - /** Generally, you probably want the error string ( ErrorDesc() ). But if you + /** Generally, you probably want the error basic_string ( ErrorDesc() ). But if you prefer the ErrorId, this function will fetch it. */ const int ErrorId() const { return errorId; } @@ -1089,7 +1095,7 @@ public: */ void ClearError() { error = false; errorId = 0; - errorDesc = ""; + errorDesc = TEXT(""); errorLocation.row = errorLocation.col = 0; //errorLocation.last = 0; } @@ -1100,7 +1106,7 @@ public: // [internal use] virtual void Print( FILE* cfile, int depth = 0 ) const; // [internal use] - void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData ); + void SetError( int err, const TCHAR* errorLocation, TiXmlParsingData* prevData ); protected : virtual void StreamOut ( TIXML_OSTREAM * out) const; @@ -1127,9 +1133,9 @@ private: Take an example: @verbatim - - - + + + @endverbatim @@ -1210,16 +1216,16 @@ public: /// Return a handle to the first child node. TiXmlHandle FirstChild() const; /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const char * value ) const; + TiXmlHandle FirstChild( const TCHAR * value ) const; /// Return a handle to the first child element. TiXmlHandle FirstChildElement() const; /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const char * value ) const; + TiXmlHandle FirstChildElement( const TCHAR * value ) const; /** Return a handle to the "index" child with the given name. The first child is 0, the second 1, etc. */ - TiXmlHandle Child( const char* value, int index ) const; + TiXmlHandle Child( const TCHAR* value, int index ) const; /** Return a handle to the "index" child. The first child is 0, the second 1, etc. */ @@ -1228,7 +1234,7 @@ public: The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. */ - TiXmlHandle ChildElement( const char* value, int index ) const; + TiXmlHandle ChildElement( const TCHAR* value, int index ) const; /** Return a handle to the "index" child element. The first child element is 0, the second 1, etc. Note that only TiXmlElements are indexed: other types are not counted. @@ -1236,11 +1242,11 @@ public: TiXmlHandle ChildElement( int index ) const; #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } + TiXmlHandle FirstChild( const std::basic_string& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::basic_string& _value ) const { return FirstChildElement( _value.c_str() ); } - TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + TiXmlHandle Child( const std::basic_string& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::basic_string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } #endif /// Return the handle as a TiXmlNode. This may return null. diff --git a/PowerEditor/src/TinyXml/tinyxmlerror.cpp b/PowerEditor/src/TinyXml/tinyxmlerror.cpp index d0492cba..0f9c9e20 100644 --- a/PowerEditor/src/TinyXml/tinyxmlerror.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlerror.cpp @@ -23,6 +23,7 @@ distribution. */ #include "tinyxml.h" +//#include "tchar.h" // The goal of the seperate error file is to make the first // step towards localization. tinyxml (currently) only supports @@ -31,20 +32,20 @@ distribution. // It also cleans up the code a bit. // -const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = +const TCHAR* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = { - "No error", - "Error", - "Failed to open file", - "Memory allocation failed.", - "Error parsing Element.", - "Failed to read Element name", - "Error reading Element value.", - "Error reading Attributes.", - "Error: empty tag.", - "Error reading end tag.", - "Error parsing Unknown.", - "Error parsing Comment.", - "Error parsing Declaration.", - "Error document empty." + TEXT("No error"), + TEXT("Error"), + TEXT("Failed to open file"), + TEXT("Memory allocation failed."), + TEXT("Error parsing Element."), + TEXT("Failed to read Element name"), + TEXT("Error reading Element value."), + TEXT("Error reading Attributes."), + TEXT("Error: empty tag."), + TEXT("Error reading end tag."), + TEXT("Error parsing Unknown."), + TEXT("Error parsing Comment."), + TEXT("Error parsing Declaration."), + TEXT("Error document empty.") }; diff --git a/PowerEditor/src/TinyXml/tinyxmlparser.cpp b/PowerEditor/src/TinyXml/tinyxmlparser.cpp index 86ed57c3..f2b69dfa 100644 --- a/PowerEditor/src/TinyXml/tinyxmlparser.cpp +++ b/PowerEditor/src/TinyXml/tinyxmlparser.cpp @@ -24,6 +24,7 @@ distribution. #include "tinyxml.h" #include +#include "SysMsg.h" //#define DEBUG_PARSER @@ -32,11 +33,11 @@ distribution. // or order will break putstring. TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = { - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } + { TEXT("&"), 5, '&' }, + { TEXT("<"), 4, '<' }, + { TEXT(">"), 4, '>' }, + { TEXT("""), 6, '\"' }, + { TEXT("'"), 6, '\'' } }; @@ -44,15 +45,15 @@ class TiXmlParsingData { friend class TiXmlDocument; public: - //TiXmlParsingData( const char* now, const TiXmlParsingData* prevData ); - void Stamp( const char* now ); + //TiXmlParsingData( const TCHAR* now, const TiXmlParsingData* prevData ); + void Stamp( const TCHAR* now ); const TiXmlCursor& Cursor() { return cursor; } - //void Update( const char* now ); + //void Update( const TCHAR* now ); private: // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + TiXmlParsingData( const TCHAR* start, int _tabsize, int row, int col ) { assert( start ); stamp = start; @@ -62,12 +63,12 @@ class TiXmlParsingData } TiXmlCursor cursor; - const char* stamp; + const TCHAR* stamp; int tabsize; }; -void TiXmlParsingData::Stamp( const char* now ) +void TiXmlParsingData::Stamp( const TCHAR* now ) { assert( now ); @@ -80,7 +81,7 @@ void TiXmlParsingData::Stamp( const char* now ) // Get the current row, column. int row = cursor.row; int col = cursor.col; - const char* p = stamp; + const TCHAR* p = stamp; assert( p ); while ( p < now ) @@ -133,7 +134,7 @@ void TiXmlParsingData::Stamp( const char* now ) // Eat the character ++p; - // Normal char - just advance one column + // Normal TCHAR - just advance one column ++col; break; } @@ -147,7 +148,7 @@ void TiXmlParsingData::Stamp( const char* now ) } -const char* TiXmlBase::SkipWhiteSpace( const char* p ) +const TCHAR* TiXmlBase::SkipWhiteSpace( const TCHAR* p ) { if ( !p || !*p ) { @@ -193,9 +194,9 @@ const char* TiXmlBase::SkipWhiteSpace( const char* p ) } #endif -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name ) +const TCHAR* TiXmlBase::ReadName( const TCHAR* p, TIXML_STRING * name ) { - *name = ""; + *name = TEXT(""); assert( p ); // Names start with letters or underscores. @@ -203,10 +204,10 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name ) // hyphens, or colons. (Colons are valid ony for namespaces, // but tinyxml can't tell namespaces from names.) if ( p && *p - && ( isalpha( (unsigned char) *p ) || *p == '_' ) ) + && ( isalpha( (UCHAR) *p ) || *p == '_' ) ) { while( p && *p - && ( isalnum( (unsigned char ) *p ) + && ( isalnum( (UCHAR ) *p ) || *p == '_' || *p == '-' || *p == '.' @@ -220,14 +221,14 @@ const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name ) return 0; } -const char* TiXmlBase::GetEntity( const char* p, char* value ) +const TCHAR* TiXmlBase::GetEntity( const TCHAR* p, TCHAR* value ) { // Presume an entity, and pull it out. TIXML_STRING ent; int i; // Handle the &#x entities. - if ( strncmp( "&#x", p, 3 ) == 0 + if ( generic_strncmp( TEXT("&#x"), p, 3 ) == 0 && *(p+3) && *(p+4) && ( *(p+4) == ';' || *(p+5) == ';' ) @@ -259,9 +260,9 @@ const char* TiXmlBase::GetEntity( const char* p, char* value ) // Now try to match it. for( i=0; igood() && in->peek() != '>' ) { int c = in->get(); - (*tag) += (char) c; + (*tag) += (TCHAR) c; } if ( in->good() ) @@ -435,7 +436,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) #endif -const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData ) +const TCHAR* TiXmlDocument::Parse( const TCHAR* p, TiXmlParsingData* prevData ) { ClearError(); @@ -491,7 +492,7 @@ const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData ) return p; } -void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data ) +void TiXmlDocument::SetError( int err, const TCHAR* pError, TiXmlParsingData* data ) { // The first error in a chain is more accurate - don't set again! if ( error ) @@ -512,7 +513,7 @@ void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* dat } -TiXmlNode* TiXmlNode::Identify( const char* p ) +TiXmlNode* TiXmlNode::Identify( const TCHAR* p ) { TiXmlNode* returnNode = 0; @@ -537,8 +538,8 @@ TiXmlNode* TiXmlNode::Identify( const char* p ) // - Everthing else is unknown to tinyxml. // - const char* xmlHeader = { "good() ) { int c = in->get(); - (*tag) += (char) c ; + (*tag) += (TCHAR) c ; if ( c == '>' ) break; @@ -623,7 +624,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) if ( in->good() && in->peek() != '<' ) { // Yep, text. - TiXmlText text( "" ); + TiXmlText text( TEXT("") ); text.StreamIn( in, tag ); // What follows text is a closing tag or another node. @@ -674,7 +675,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) else { // If not a closing tag, id it, and stream. - const char* tagloc = tag->c_str() + tagIndex; + const TCHAR* tagloc = tag->c_str() + tagIndex; TiXmlNode* node = Identify( tagloc ); if ( !node ) return; @@ -689,7 +690,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag) } #endif -const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data ) +const TCHAR* TiXmlElement::Parse( const TCHAR* p, TiXmlParsingData* data ) { p = SkipWhiteSpace( p ); TiXmlDocument* document = GetDocument(); @@ -716,7 +717,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data ) p = SkipWhiteSpace( p+1 ); // Read the name. - const char* pErr = p; + const TCHAR* pErr = p; p = ReadName( p, &value ); if ( !p || !*p ) @@ -725,9 +726,9 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data ) return 0; } - TIXML_STRING endTag (""; + endTag += TEXT(">"); // Check for and read attributes. Also look for an empty // tag or an end tag. @@ -784,7 +785,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data ) } attrib->SetDocument( document ); - const char* pErr = p; + const TCHAR* pErr = p; p = attrib->Parse( p, data ); if ( !p || !*p ) @@ -810,7 +811,7 @@ const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data ) } -const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data ) +const TCHAR* TiXmlElement::ReadValue( const TCHAR* p, TiXmlParsingData* data ) { TiXmlDocument* document = GetDocument(); @@ -821,7 +822,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data ) if ( *p != '<' ) { // Take what we have, make a text element. - TiXmlText* textNode = new TiXmlText( "" ); + TiXmlText* textNode = new TiXmlText( TEXT("") ); if ( !textNode ) { @@ -840,7 +841,7 @@ const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data ) { // We hit a '<' // Have we hit a new element or an end tag? - if ( StringEqual( p, "' ) { @@ -941,10 +942,10 @@ void TiXmlComment::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) #endif -const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data ) +const TCHAR* TiXmlComment::Parse( const TCHAR* p, TiXmlParsingData* data ) { TiXmlDocument* document = GetDocument(); - value = ""; + value = TEXT(""); p = SkipWhiteSpace( p ); @@ -954,21 +955,21 @@ const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data ) data->Stamp( p ); location = data->Cursor(); } - const char* startTag = ""; + const TCHAR* startTag = TEXT(""); if ( !StringEqual( p, startTag, false ) ) { document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data ); return 0; } - p += strlen( startTag ); + p += lstrlen( startTag ); p = ReadText( p, &value, false, endTag, false ); return p; } -const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data ) +const TCHAR* TiXmlAttribute::Parse( const TCHAR* p, TiXmlParsingData* data ) { p = SkipWhiteSpace( p ); if ( !p || !*p ) return 0; @@ -984,7 +985,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data ) location = data->Cursor(); } // Read the name, the '=' and the value. - const char* pErr = p; + const TCHAR* pErr = p; p = ReadName( p, &name ); if ( !p || !*p ) { @@ -1006,18 +1007,18 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data ) return 0; } - const char* end; + const TCHAR* end; if ( *p == '\'' ) { ++p; - end = "\'"; + end = TEXT("\'"); p = ReadText( p, &value, false, end, false ); } else if ( *p == '"' ) { ++p; - end = "\""; + end = TEXT("\""); p = ReadText( p, &value, false, end, false ); } else @@ -1025,7 +1026,7 @@ const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data ) // All attribute values should be in single or double quotes. // But this is such a common error that the parser will try // its best, even without them. - value = ""; + value = TEXT(""); while ( p && *p // existence && !isspace( *p ) && *p != '\n' && *p != '\r' // whitespace && *p != '/' && *p != '>' ) // tag end @@ -1052,9 +1053,9 @@ void TiXmlText::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) } #endif -const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data ) +const TCHAR* TiXmlText::Parse( const TCHAR* p, TiXmlParsingData* data ) { - value = ""; + value = TEXT(""); // TiXmlParsingData data( p, prevData ); if ( data ) { @@ -1063,7 +1064,7 @@ const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data ) } bool ignoreWhite = true; - const char* end = "<"; + const TCHAR* end = TEXT("<"); p = ReadText( p, &value, ignoreWhite, end, false ); if ( p ) return p-1; // don't truncate the '<' @@ -1087,13 +1088,13 @@ void TiXmlDeclaration::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag ) } #endif -const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data ) +const TCHAR* TiXmlDeclaration::Parse( const TCHAR* p, TiXmlParsingData* data ) { p = SkipWhiteSpace( p ); // Find the beginning, find the end, and look for // the stuff in-between. TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0 ); return 0; @@ -1106,9 +1107,9 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data ) } p += 5; - version = ""; - encoding = ""; - standalone = ""; + version = TEXT(""); + encoding = TEXT(""); + standalone = TEXT(""); while ( p && *p ) { @@ -1119,19 +1120,19 @@ const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data ) } p = SkipWhiteSpace( p ); - if ( StringEqual( p, "version", true ) ) + if ( StringEqual( p, TEXT("version"), true ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data ); version = attrib.Value(); } - else if ( StringEqual( p, "encoding", true ) ) + else if ( StringEqual( p, TEXT("encoding"), true ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data ); encoding = attrib.Value(); } - else if ( StringEqual( p, "standalone", true ) ) + else if ( StringEqual( p, TEXT("standalone"), true ) ) { TiXmlAttribute attrib; p = attrib.Parse( p, data ); diff --git a/PowerEditor/src/UniConversion.cpp b/PowerEditor/src/UniConversion.cpp index 1d8e0944..867039d0 100644 --- a/PowerEditor/src/UniConversion.cpp +++ b/PowerEditor/src/UniConversion.cpp @@ -7,7 +7,6 @@ #include #include -#include #include "UniConversion.h" unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) { @@ -45,19 +44,20 @@ void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned i unsigned int UCS2Length(const char *s, unsigned int len) { unsigned int ulen = 0; for (unsigned int i=0;i(s[i]); + UCHAR ch = static_cast(s[i]); if ((ch < 0x80) || (ch > (0x80 + 0x40))) ulen++; } return ulen; } -unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) { +unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) +{ unsigned int ui=0; - const unsigned char *us = reinterpret_cast(s); + const UCHAR *us = reinterpret_cast(s); unsigned int i=0; while ((i 0) - MultiByteToWideChar(codepage, 0, pszCHAR, -1, pszWCHAR, len); - else - pszWCHAR[0] = 0; -} - -void wchar2char(const wchar_t* pszWCHAR, char* pszCHAR, UINT codepage) -{ - int len = WideCharToMultiByte(codepage, 0, pszWCHAR, -1, pszCHAR, 0, NULL, NULL); - if(len > 0) - WideCharToMultiByte(codepage, 0, pszWCHAR, -1, pszCHAR, len, NULL, NULL); - else - pszCHAR[0] = 0; -} - -std::wstring string2wstring(const std::string& rString, UINT codepage) -{ - int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0); - if(len > 0) - { - std::vector vw(len); - MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len); - return &vw[0]; - } - else - return L""; -} - -std::string wstring2string(const std::wstring& rwString, UINT codepage) -{ - int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL); - if(len > 0) - { - std::vector vw(len); - WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL); - return &vw[0]; - } - else - return ""; -} diff --git a/PowerEditor/src/UniConversion.h b/PowerEditor/src/UniConversion.h index 683e2ff8..c959087c 100644 --- a/PowerEditor/src/UniConversion.h +++ b/PowerEditor/src/UniConversion.h @@ -5,23 +5,9 @@ // Copyright 1998-2001 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. -#ifndef UNICONVERSION_H -#define UNICONVERSION_H - -#include -#include -#include - -unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen); -void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len); -unsigned int UCS2Length(const char *s, unsigned int len); -unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen); -unsigned int ascii_to_utf8(const char* pszASCII, unsigned int lenASCII, char* pszUTF8); -int utf8_to_ascii(const char* pszUTF8, unsigned int lenUTF8, char* pszASCII); - -void char2wchar(const char* pszCHAR, wchar_t* pszWCHAR, UINT codepage = CP_UTF8); -void wchar2char(const wchar_t* pszWCHAR, char* pszCHAR, UINT codepage = CP_UTF8); -std::wstring string2wstring(const std::string& rString, UINT codepage = CP_UTF8); -std::string wstring2string(const std::wstring& rwString, UINT codepage = CP_UTF8); - -#endif //UNICONVERSION_H +unsigned int UTF8Length(const wchar_t * uptr, unsigned int tlen); +void UTF8FromUCS2(const wchar_t * uptr, unsigned int tlen, char * putf, unsigned int len); +unsigned int UCS2Length(const char * s, unsigned int len); +unsigned int UCS2FromUTF8(const char * s, unsigned int len, wchar_t * tbuf, unsigned int tlen); +unsigned int ascii_to_utf8(const char * pszASCII, unsigned int lenASCII, char * pszUTF8); +int utf8_to_ascii(const char * pszUTF8, unsigned int lenUTF8, char * pszASCII); diff --git a/PowerEditor/src/Utf8_16.cpp b/PowerEditor/src/Utf8_16.cpp index d94b8101..4c5b824d 100644 --- a/PowerEditor/src/Utf8_16.cpp +++ b/PowerEditor/src/Utf8_16.cpp @@ -21,7 +21,6 @@ #include #include #include "PluginInterface.h" -#include "UniConversion.h" const Utf8_16::utf8 Utf8_16::k_Boms[][3] = { {0x00, 0x00, 0x00}, // Unknown @@ -214,18 +213,9 @@ Utf8_16_Write::~Utf8_16_Write() fclose(); } -FILE * Utf8_16_Write::fopen(const char *_name, const char *_type) +FILE * Utf8_16_Write::generic_fopen(const TCHAR *_name, const TCHAR *_type) { - m_pFile = ::fopen(_name, _type); - - m_bFirstWrite = true; - - return m_pFile; -} - -FILE * Utf8_16_Write::fopenW(const wchar_t *_name, const wchar_t *_type) -{ - m_pFile = ::_wfopen(_name, _type); + m_pFile = ::generic_fopen(_name, _type); m_bFirstWrite = true; diff --git a/PowerEditor/src/Utf8_16.h b/PowerEditor/src/Utf8_16.h index 98846ce3..541f8b1d 100644 --- a/PowerEditor/src/Utf8_16.h +++ b/PowerEditor/src/Utf8_16.h @@ -18,10 +18,6 @@ // - Removing UCS-Bug in Utf8_Iter // - Add convert function in Utf8_16_Write //////////////////////////////////////////////////////////////////////////////// - -#ifndef UTF8_16_H -#define UTF8_16_H - #pragma once #include @@ -35,8 +31,8 @@ class Utf8_16 { public: typedef unsigned short utf16; // 16 bits - typedef unsigned char utf8; // 8 bits - typedef unsigned char ubyte; + typedef UCHAR utf8; // 8 bits + typedef UCHAR ubyte; static const utf8 k_Boms[uniEnd][3]; }; @@ -112,7 +108,7 @@ public: ~Utf8_16_Read(); size_t convert(char* buf, size_t len); - char* getNewBuf() { return reinterpret_cast(m_pNewBuf); } + char* getNewBuf() { return reinterpret_cast(m_pNewBuf); } UniMode getEncoding() const { return m_eEncoding; } size_t calcCurPos(size_t pos); @@ -138,8 +134,7 @@ public: void setEncoding(UniMode eType); - FILE * fopen(const char *_name, const char *_type); - FILE * fopenW(const wchar_t *_name, const wchar_t *_type); + FILE * generic_fopen(const TCHAR *_name, const TCHAR *_type); size_t fwrite(const void* p, size_t _size); void fclose(); @@ -155,5 +150,3 @@ protected: size_t m_nBufSize; bool m_bFirstWrite; }; - -#endif //UTF8_16_H diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp index c149b61f..626a162d 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp @@ -24,12 +24,20 @@ BOOL CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { case WM_INITDIALOG : { - //LS: CompileDateInAboutDialog: Automatically insert compile date as additional version info in About-dialog! HWND compileDateHandle = ::GetDlgItem(_hSelf, IDC_BUILD_DATETIME); - string buildTime = "Build time : "; + basic_string buildTime = TEXT("Build time : "); + +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + buildTime += wmc->char2wchar(__DATE__, CP_ACP); + buildTime += TEXT(" - "); + buildTime += wmc->char2wchar(__TIME__, CP_ACP); + +#else buildTime += __DATE__; - buildTime += " - "; + buildTime += TEXT(" - "); buildTime += __TIME__; +#endif ::SendMessage(compileDateHandle, WM_SETTEXT, 0, (LPARAM)buildTime.c_str()); ::EnableWindow(compileDateHandle, FALSE); @@ -37,13 +45,13 @@ BOOL CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) ::SendMessage(licenceEditHandle, WM_SETTEXT, 0, (LPARAM)LICENCE_TXT); _emailLink.init(_hInst, _hSelf); - _emailLink.create(::GetDlgItem(_hSelf, IDC_AUTHOR_NAME), "mailto:don.h@free.fr"); + _emailLink.create(::GetDlgItem(_hSelf, IDC_AUTHOR_NAME), TEXT("mailto:don.h@free.fr")); _pageLink.init(_hInst, _hSelf); - _pageLink.create(::GetDlgItem(_hSelf, IDC_HOME_ADDR), "http://notepad-plus.sourceforge.net/"); + _pageLink.create(::GetDlgItem(_hSelf, IDC_HOME_ADDR), TEXT("http://notepad-plus.sourceforge.net/")); //_onLineHelp.init(_hInst, _hSelf); - //_onLineHelp.create(::GetDlgItem(_hSelf, IDC_ONLINEHELP_ADDR), "http://notepad-plus.sourceforge.net/uk/generalFAQ.php"); + //_onLineHelp.create(::GetDlgItem(_hSelf, IDC_ONLINEHELP_ADDR), TEXT("http://notepad-plus.sourceforge.net/uk/generalFAQ.php")); getClientRect(_rc); diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h index ca4ef684..97535ef5 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.h @@ -24,7 +24,7 @@ #include "..\\..\\resource.h" #define LICENCE_TXT \ -"This program is free software; you can redistribute it and/or \ +TEXT("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.\r\n\ @@ -36,7 +36,7 @@ GNU General Public License for more details. \r\n\ \r\n\ You should have received a copy of the GNU General Public License \ along with this program; if not, write to the Free Software \ -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA." +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.") @@ -50,7 +50,6 @@ public : virtual void destroy() { _emailLink.destroy(); _pageLink.destroy(); - //_onLineHelp.destroy(); }; protected : @@ -59,7 +58,6 @@ protected : private : URLCtrl _emailLink; URLCtrl _pageLink; - //URLCtrl _onLineHelp; }; #endif //ABOUT_DLG_H diff --git a/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp b/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp index a2336358..4aa6b266 100644 --- a/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/URLCtrl.cpp @@ -116,14 +116,14 @@ static COLORREF getParentDlgBkColor(HWND hWnd) return crRet; } -void URLCtrl::create(HWND itemHandle, char * link, COLORREF linkColor) +void URLCtrl::create(HWND itemHandle, TCHAR * link, COLORREF linkColor) { // turn on notify style ::SetWindowLongPtr(itemHandle, GWL_STYLE, ::GetWindowLongPtr(itemHandle, GWL_STYLE) | SS_NOTIFY); // set the URL text (not the display text) if (link) - strcpy(_URL, link); + lstrcpy(_URL, link); // set the hyperlink colour _linkColor = linkColor; @@ -204,7 +204,7 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) HANDLE hOld = SelectObject(hdc, _hfUnderlined); // Draw the text! - char szWinText[MAX_PATH]; + TCHAR szWinText[MAX_PATH]; ::GetWindowText(hwnd, szWinText, sizeof szWinText); ::DrawText(hdc, szWinText, -1, &rect, dwDTStyle); @@ -254,13 +254,13 @@ LRESULT URLCtrl::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) // Open a browser if(_URL[0]) { - ::ShellExecute(NULL, "open", _URL, NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), _URL, NULL, NULL, SW_SHOWNORMAL); } else { - char szWinText[MAX_PATH]; + TCHAR szWinText[MAX_PATH]; ::GetWindowText(hwnd, szWinText, sizeof szWinText); - ::ShellExecute(NULL, "open", szWinText, NULL, NULL, SW_SHOWNORMAL); + ::ShellExecute(NULL, TEXT("open"), szWinText, NULL, NULL, SW_SHOWNORMAL); } } } diff --git a/PowerEditor/src/WinControls/AboutDlg/URLCtrl.h b/PowerEditor/src/WinControls/AboutDlg/URLCtrl.h index 1af96739..5a93a011 100644 --- a/PowerEditor/src/WinControls/AboutDlg/URLCtrl.h +++ b/PowerEditor/src/WinControls/AboutDlg/URLCtrl.h @@ -12,7 +12,7 @@ public: URLCtrl():_hfUnderlined(0),_hCursor(0), _msgDest(NULL), _cmdID(0), _oldproc(NULL), \ _linkColor(), _visitedColor(), _clicking(false) {_URL[0] = '\0';}; - void create(HWND itemHandle, char * link, COLORREF linkColor = RGB(0,0,255)); + void create(HWND itemHandle, TCHAR * link, COLORREF linkColor = RGB(0,0,255)); void create(HWND itemHandle, int cmd, HWND msgDest = NULL); void destroy(){ if(_hfUnderlined) @@ -22,7 +22,7 @@ public: }; protected : - char _URL[MAX_PATH]; + TCHAR _URL[MAX_PATH]; HFONT _hfUnderlined; HCURSOR _hCursor; diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp index 1b19587f..e389448b 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPicker.cpp @@ -28,8 +28,8 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent) _hSelf = ::CreateWindowEx( 0, - "Button", - "F", + TEXT("Button"), + TEXT("F"), WS_CHILD | WS_VISIBLE, 0, 0, 25, 25, _hParent, @@ -38,7 +38,7 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent) (LPVOID)0); if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(6969); } diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index 54f67dad..0a1ba9f5 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -37,7 +37,7 @@ void ColourPopup::create(int dialogID) if (!_hSelf) { - systemMessage("ColourPopup"); + systemMessage(TEXT("ColourPopup")); throw int(696); } Window::getClientRect(_rc); @@ -62,14 +62,14 @@ BOOL CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARA { ColourPopup *pColourPopup = (ColourPopup *)(lParam); pColourPopup->_hSelf = hwnd; - ::SetWindowLong(hwnd, GWL_USERDATA, (long)lParam); + ::SetWindowLongPtr(hwnd, GWL_USERDATA, (long)lParam); pColourPopup->run_dlgProc(message, wParam, lParam); return TRUE; } default : { - ColourPopup *pColourPopup = reinterpret_cast(::GetWindowLong(hwnd, GWL_USERDATA)); + ColourPopup *pColourPopup = reinterpret_cast(::GetWindowLongPtr(hwnd, GWL_USERDATA)); if (!pColourPopup) return FALSE; return pColourPopup->run_dlgProc(message, wParam, lParam); diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.rc b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.rc index a21061f9..1f5884e0 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.rc +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.rc @@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. IDD_COLOUR_POPUP DIALOGEX 0, 0, 132, 113 STYLE DS_SETFONT | WS_POPUP | DS_MODALFRAME -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN LISTBOX IDC_COLOUR_LIST,7,7,117,79, LBS_OWNERDRAWFIXED | LBS_NOINTEGRALHEIGHT | diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index cbfb0481..8d29659a 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -41,7 +41,7 @@ BOOL CALLBACK ColourStaticTextHooker::colourStaticProc(HWND hwnd, UINT Message, HANDLE hOld = SelectObject(hdc, hf); // Draw the text! - char text[MAX_PATH]; + TCHAR text[MAX_PATH]; ::GetWindowText(hwnd, text, sizeof(text)); ::DrawText(hdc, text, -1, &rect, DT_LEFT); @@ -100,7 +100,7 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar for(int i = 0 ; i < sizeof(fontSizeStrs)/3 ; i++) ::SendMessage(_hFontSizeCombo, CB_ADDSTRING, 0, (LPARAM)fontSizeStrs[i]); - const std::vector & fontlist = (NppParameters::getInstance())->getFontList(); + const std::vector> & fontlist = (NppParameters::getInstance())->getFontList(); for (size_t i = 0 ; i < fontlist.size() ; i++) { int j = ::SendMessage(_hFontNameCombo, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str()); @@ -204,10 +204,10 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar break; case IDCANCEL : - //::MessageBox(NULL, "cancel", "", MB_OK); + //::MessageBox(NULL, TEXT("cancel"), TEXT(""), MB_OK); if (_isDirty) { - //::MessageBox(NULL, "dirty", "", MB_OK); + //::MessageBox(NULL, TEXT("dirty"), TEXT(""), MB_OK); LexerStylerArray & lsArray = (NppParameters::getInstance())->getLStylerArray(); StyleArray & globalStyles = (NppParameters::getInstance())->getGlobalStylers(); @@ -220,7 +220,7 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar ::SendMessage(_hParent, WM_UPDATESCINTILLAS, 0, 0); } //else - //::MessageBox(NULL, "no dirty", "", MB_OK); + //::MessageBox(NULL, TEXT("no dirty"), TEXT(""), MB_OK); //::EnableWindow(::GetDlgItem(_hSelf, IDOK), FALSE); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SAVECLOSE_BUTTON), !_isSync); display(false); @@ -430,7 +430,7 @@ void WordStyleDlg::updateFontSize() Style & style = getCurrentStyler(); int iFontSizeSel = ::SendMessage(_hFontSizeCombo, CB_GETCURSEL, 0, 0); - char intStr[5]; + TCHAR intStr[5]; if (iFontSizeSel != 0) { ::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr); @@ -438,8 +438,8 @@ void WordStyleDlg::updateFontSize() style._fontSize = -1; else { - char *finStr; - style._fontSize = strtol(intStr, &finStr, 10); + TCHAR *finStr; + style._fontSize = generic_strtol(intStr, &finStr, 10); if (*finStr != '\0') style._fontSize = -1; } @@ -451,7 +451,7 @@ void WordStyleDlg::updateFontSize() void WordStyleDlg::updateExtension() { const int NB_MAX = 256; - char ext[NB_MAX]; + TCHAR ext[NB_MAX]; ::SendDlgItemMessage(_hSelf, IDC_USER_EXT_EDIT, WM_GETTEXT, NB_MAX, (LPARAM)ext); _lsArray.getLexerFromIndex(_currentLexerIndex - 1).setLexerUserExt(ext); } @@ -460,10 +460,10 @@ void WordStyleDlg::updateUserKeywords() { Style & style = getCurrentStyler(); //const int NB_MAX = 2048; - //char kw[NB_MAX]; + //TCHAR kw[NB_MAX]; int len = ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXTLENGTH, 0, 0); len +=1; - char *kw = new char[len]; + TCHAR *kw = new TCHAR[len]; ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_GETTEXT, len, (LPARAM)kw); style.setKeywords(kw); @@ -474,7 +474,7 @@ void WordStyleDlg::updateFontName() { Style & style = getCurrentStyler(); int iFontSel = ::SendMessage(_hFontNameCombo, CB_GETCURSEL, 0, 0); - char *fnStr = (char *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0); + TCHAR *fnStr = (TCHAR *)::SendMessage(_hFontNameCombo, CB_GETITEMDATA, iFontSel, 0); style._fontName = fnStr; } @@ -518,9 +518,9 @@ void WordStyleDlg::setStyleListFromLexer(int index) if (index) { - const char *langName = _lsArray.getLexerNameFromIndex(index - 1); - const char *ext = NppParameters::getInstance()->getLangExtFromName(langName); - const char *userExt = (_lsArray.getLexerStylerByName(langName))->getLexerUserExt(); + const TCHAR *langName = _lsArray.getLexerNameFromIndex(index - 1); + const TCHAR *ext = NppParameters::getInstance()->getLangExtFromName(langName); + const TCHAR *userExt = (_lsArray.getLexerStylerByName(langName))->getLexerUserExt(); ::SendDlgItemMessage(_hSelf, IDC_DEF_EXT_EDIT, WM_SETTEXT, 0, (LPARAM)(ext)); ::SendDlgItemMessage(_hSelf, IDC_USER_EXT_EDIT, WM_SETTEXT, 0, (LPARAM)(userExt)); } @@ -548,7 +548,7 @@ void WordStyleDlg::setVisualFromStyleList() Style & style = getCurrentStyler(); // Global override style - if (strcmp(style._styleDesc, "Global override") == 0) + if (lstrcmp(style._styleDesc, TEXT("Global override")) == 0) { showGlobalOverrideCtrls(true); } @@ -557,7 +557,7 @@ void WordStyleDlg::setVisualFromStyleList() //bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE; COLORREF c = c = RGB(0x00, 0x00, 0xFF); - char str[256]; + TCHAR str[256]; str[0] = '\0'; @@ -569,13 +569,13 @@ void WordStyleDlg::setVisualFromStyleList() i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return; - char styleName[64]; + TCHAR styleName[64]; ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName); - strcat(strcat(str, " : "), styleName); + lstrcat(lstrcat(str, TEXT(" : ")), styleName); // PAD for fix a display glitch - strcat(str, " "); + lstrcat(str, TEXT(" ")); colourHooker.setColour(c); ::SetWindowText(_hStyleInfoStaticText, str); @@ -617,11 +617,11 @@ void WordStyleDlg::setVisualFromStyleList() //-- font size isEnable = false; - char intStr[5] = ""; + TCHAR intStr[5] = TEXT(""); int iFontSize = 0; if (style._fontSize != -1) { - sprintf(intStr, "%d", style._fontSize); + wsprintf(intStr, TEXT("%d"), style._fontSize); iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, (LPARAM)intStr); isEnable = true; } @@ -661,16 +661,16 @@ void WordStyleDlg::setVisualFromStyleList() LangType lType = pNppParams->getLangIDFromStr(lexerStyler.getLexerName()); if (lType == L_TXT) { - string str = lexerStyler.getLexerName(); - str += " is not defined in NppParameters::getLangIDFromStr()"; + basic_string str = lexerStyler.getLexerName(); + str += TEXT(" is not defined in NppParameters::getLangIDFromStr()"); printStr(str.c_str()); } - const char *kws = pNppParams->getWordList(lType, style._keywordClass); + const TCHAR *kws = pNppParams->getWordList(lType, style._keywordClass); if (!kws) - kws = ""; + kws = TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_DEF_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(kws)); - const char *ckwStr = (style._keywords)?style._keywords->c_str():""; + const TCHAR *ckwStr = (style._keywords)?style._keywords->c_str():TEXT(""); ::SendDlgItemMessage(_hSelf, IDC_USER_KEYWORDS_EDIT, WM_SETTEXT, 0, (LPARAM)(ckwStr)); } int showOption = shouldBeDisplayed?SW_SHOW:SW_HIDE; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 2277e949..8f06bda5 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -127,7 +127,7 @@ private : HWND _hFontNameStaticText; HWND _hFontSizeStaticText; HWND _hStyleInfoStaticText; - //char _originalWarning[256]; + //TCHAR _originalWarning[256]; LexerStylerArray _lsArray; StyleArray _globalStyles; @@ -160,19 +160,19 @@ private : int i = ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETCURSEL, 0, 0); if (i == LB_ERR) return -1; - char styleName[128]; + TCHAR styleName[128]; ::SendDlgItemMessage(_hSelf, IDC_STYLES_LIST, LB_GETTEXT, i, (LPARAM)styleName); - if (strcmp(styleName, TABBAR_ACTIVEFOCUSEDINDCATOR) == 0) + if (lstrcmp(styleName, TABBAR_ACTIVEFOCUSEDINDCATOR) == 0) return (int)TabBarPlus::activeFocusedTop; - if (strcmp(styleName, TABBAR_ACTIVEUNFOCUSEDINDCATOR) == 0) + if (lstrcmp(styleName, TABBAR_ACTIVEUNFOCUSEDINDCATOR) == 0) return (int)TabBarPlus::activeUnfocusedTop; - if (strcmp(styleName, TABBAR_ACTIVETEXT) == 0) + if (lstrcmp(styleName, TABBAR_ACTIVETEXT) == 0) return (int)TabBarPlus::activeText; - if (strcmp(styleName, TABBAR_INACTIVETEXT) == 0) + if (lstrcmp(styleName, TABBAR_INACTIVETEXT) == 0) return (int)TabBarPlus::inactiveText; return -1; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc index 10324dfa..d9dc0953 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc @@ -29,7 +29,7 @@ STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Style Configurator" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x0 BEGIN LTEXT "Foreground color",IDC_FG_STATIC,203,48,59,8,0, WS_EX_RIGHT LTEXT "Background color",IDC_BG_STATIC,203,75,59,8,0, WS_EX_RIGHT diff --git a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h index f1da557a..d2fb4a61 100644 --- a/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h +++ b/PowerEditor/src/WinControls/ContextMenu/ContextMenu.h @@ -27,12 +27,12 @@ using namespace std; struct MenuItemUnit { unsigned long _cmdID; - string _itemName; - MenuItemUnit() : _cmdID(0), _itemName("") {}; - MenuItemUnit(unsigned long cmdID, string itemName) : _cmdID(cmdID), _itemName(itemName) {}; - MenuItemUnit(unsigned long cmdID, const char *itemName) : _cmdID(cmdID){ + basic_string _itemName; + MenuItemUnit() : _cmdID(0), _itemName(TEXT("")) {}; + MenuItemUnit(unsigned long cmdID, basic_string itemName) : _cmdID(cmdID), _itemName(itemName) {}; + MenuItemUnit(unsigned long cmdID, const TCHAR *itemName) : _cmdID(cmdID){ if (!itemName) - _itemName = ""; + _itemName = TEXT(""); else _itemName = itemName; }; diff --git a/PowerEditor/src/WinControls/DockingWnd/Docking.h b/PowerEditor/src/WinControls/DockingWnd/Docking.h index bc203dea..6e095757 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Docking.h +++ b/PowerEditor/src/WinControls/DockingWnd/Docking.h @@ -50,18 +50,18 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. typedef struct { HWND hClient; // client Window Handle - char *pszName; // name of plugin (shown in window) + TCHAR *pszName; // name of plugin (shown in window) int dlgID; // a funcItem provides the function pointer to start a dialog. Please parse here these ID // user modifications UINT uMask; // mask params: look to above defines HICON hIconTab; // icon for tabs - char *pszAddInfo; // for plugin to display additional informations + TCHAR *pszAddInfo; // for plugin to display additional informations // internal data, do not use !!! RECT rcFloat; // floating position int iPrevCont; // stores the privious container (toggling between float and dock) - const char* pszModuleName; // it's the plugin file name. It's used to identify the plugin + const TCHAR* pszModuleName; // it's the plugin file name. It's used to identify the plugin } tTbData; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp index 92189097..1cdb2c54 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.cpp @@ -182,14 +182,14 @@ tTbData* DockingCont::findToolbarByWnd(HWND hClient) return pTbData; } -tTbData* DockingCont::findToolbarByName(char* pszName) +tTbData* DockingCont::findToolbarByName(TCHAR* pszName) { tTbData* pTbData = NULL; /* find entry by handle */ for (size_t iTb = 0; iTb < _vTbData.size(); iTb++) { - if (strcmp(pszName, _vTbData[iTb]->pszName) == 0) + if (lstrcmp(pszName, _vTbData[iTb]->pszName) == 0) { pTbData = _vTbData[iTb]; } @@ -304,8 +304,8 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR { DWORD dwError = ::GetLastError(); TCHAR str[128]; - ::wsprintf(str, "GetLastError() returned %lu", dwError); - ::MessageBox(NULL, str, "SetWindowsHookEx(MOUSE) failed", MB_OK | MB_ICONERROR); + ::wsprintf(str, TEXT("GetLastError() returned %lu"), dwError); + ::MessageBox(NULL, str, TEXT("SetWindowsHookEx(MOUSE) failed"), MB_OK | MB_ICONERROR); } ::RedrawWindow(hwnd, NULL, NULL, TRUE); } @@ -415,7 +415,7 @@ LRESULT DockingCont::runProcCaption(HWND hwnd, UINT Message, WPARAM wParam, LPAR } else { - toolTip.Show(rc, "Close", pt.x, pt.y + 20); + toolTip.Show(rc, TEXT("Close"), pt.x, pt.y + 20); } return TRUE; } @@ -454,7 +454,7 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) HBITMAP hBmpCur = NULL; HBITMAP hBmpOld = NULL; HBITMAP hBmpNew = NULL; - UINT length = strlen(_pszCaption); + UINT length = lstrlen(_pszCaption); INT nSavedDC = ::SaveDC(hDc); @@ -550,7 +550,7 @@ void DockingCont::drawCaptionItem(DRAWITEMSTRUCT *pDrawItemStruct) ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, - "MS Shell Dlg"); + TEXT("MS Shell Dlg")); hOldFont = (HFONT)::SelectObject(hDc, hFont); ::DrawText(hDc, _pszCaption, length, &rc, DT_BOTTOM | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX); @@ -823,8 +823,8 @@ void DockingCont::drawTabItem(DRAWITEMSTRUCT *pDrawItemStruct) tcItem.mask = TCIF_PARAM; ::SendMessage(_hContTab, TCM_GETITEM, nTab, (LPARAM)&tcItem); - char* text = ((tTbData*)tcItem.lParam)->pszName; - INT length = strlen(((tTbData*)tcItem.lParam)->pszName); + TCHAR* text = ((tTbData*)tcItem.lParam)->pszName; + INT length = lstrlen(((tTbData*)tcItem.lParam)->pszName); /* get drawing context */ @@ -1278,7 +1278,7 @@ void DockingCont::SelectTab(INT iTab) { if (iTab != -1) { - LPSTR pszMaxTxt = NULL; + TCHAR *pszMaxTxt = NULL; TCITEM tcItem = {0}; SIZE size = {0}; INT maxWidth = 0; @@ -1307,13 +1307,13 @@ void DockingCont::SelectTab(INT iTab) for (INT iItem = 0; iItem < iItemCnt; iItem++) { - LPSTR pszTabTxt = NULL; + TCHAR *pszTabTxt = NULL; ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); pszTabTxt = ((tTbData*)tcItem.lParam)->pszName; /* get current font width */ - GetTextExtentPoint32(hDc, pszTabTxt, strlen(pszTabTxt), &size); + GetTextExtentPoint32(hDc, pszTabTxt, lstrlen(pszTabTxt), &size); if (maxWidth < size.cx) { @@ -1329,18 +1329,18 @@ void DockingCont::SelectTab(INT iTab) if (iItem == iTab) { /* fake here an icon before text ... */ - char szText[64]; + TCHAR szText[64]; - strcpy(szText, " "); - strcat(szText, pszMaxTxt); + lstrcpy(szText, TEXT(" ")); + lstrcat(szText, pszMaxTxt); tcItem.pszText = szText; - tcItem.cchTextMax = strlen(szText); + tcItem.cchTextMax = lstrlen(szText); } else { /* ... and resize old and new item */ - tcItem.pszText = ""; - tcItem.cchTextMax = strlen(""); + tcItem.pszText = TEXT(""); + tcItem.cchTextMax = lstrlen(TEXT("")); } ::SendMessage(_hContTab, TCM_SETITEM, iItem, (LPARAM)&tcItem); } @@ -1369,14 +1369,14 @@ void DockingCont::updateCaption(void) ::SendMessage(_hContTab, TCM_GETITEM, iItem, (LPARAM)&tcItem); /* update caption text */ - strcpy(_pszCaption, ((tTbData*)tcItem.lParam)->pszName); + lstrcpy(_pszCaption, ((tTbData*)tcItem.lParam)->pszName); /* test if additional information are available */ if ((((tTbData*)tcItem.lParam)->uMask & DWS_ADDINFO) && - (strlen(((tTbData*)tcItem.lParam)->pszAddInfo) != 0)) + (lstrlen(((tTbData*)tcItem.lParam)->pszAddInfo) != 0)) { - strcat(_pszCaption, " - "); - strcat(_pszCaption, ((tTbData*)tcItem.lParam)->pszAddInfo); + lstrcat(_pszCaption, TEXT(" - ")); + lstrcat(_pszCaption, ((tTbData*)tcItem.lParam)->pszAddInfo); } if (_isFloating == true) diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h index deb7c69a..edf8fbf2 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingCont.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingCont.h @@ -20,7 +20,7 @@ #define DOCKINGCONT #include "StaticDialog.h" -#include "resource.h" +#include "Resource.h" #include "Docking.h" #include #include @@ -74,7 +74,7 @@ public: tTbData* createToolbar(tTbData data, Window **ppWin); void removeToolbar(tTbData data); tTbData* findToolbarByWnd(HWND hClient); - tTbData* findToolbarByName(char* pszName); + tTbData* findToolbarByName(TCHAR* pszName); void showToolbar(tTbData *pTbData, BOOL state); @@ -194,7 +194,7 @@ private: /* caption params */ BOOL _isTopCaption; - char _pszCaption[256]; + TCHAR _pszCaption[256]; BOOL _isMouseDown; BOOL _isMouseClose; BOOL _isMouseOver; diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h index ca7c1b97..4d7d09cc 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingDlgInterface.h @@ -37,7 +37,7 @@ public: { StaticDialog::init(hInst, parent); ::GetModuleFileName((HMODULE)hInst, _moduleName, MAX_PATH); - strcpy(_moduleName, PathFindFileName(_moduleName)); + lstrcpy(_moduleName, PathFindFileName(_moduleName)); } void create(tTbData * data, bool isRTL = false){ @@ -73,7 +73,7 @@ public: ::SendMessage(_hParent, toShow?NPPM_DMMSHOW:NPPM_DMMHIDE, 0, (LPARAM)_hSelf); }; - const char * getPluginFileName() const { + const TCHAR * getPluginFileName() const { return _moduleName; }; @@ -93,20 +93,20 @@ protected : { case DMN_CLOSE: { - //::MessageBox(_hSelf, "Close Dialog", "Plugin Message", MB_OK); + //::MessageBox(_hSelf, TEXT("Close Dialog"), TEXT("Plugin Message"), MB_OK); break; } case DMN_FLOAT: { - //::MessageBox(_hSelf, "Float Dialog", "Plugin Message", MB_OK); + //::MessageBox(_hSelf, TEXT("Float Dialog"), TEXT("Plugin Message"), MB_OK); _isFloating = true; break; } case DMN_DOCK: { - //char test[256]; - //sprintf(test, "Dock Dialog to %d", HIWORD(pnmh->code)); - //::MessageBox(_hSelf, test, "Plugin Message", MB_OK); + //TCHAR test[256]; + //wsprintf(test, TEXT("Dock Dialog to %d"), HIWORD(pnmh->code)); + //::MessageBox(_hSelf, test, TEXT("Plugin Message"), MB_OK); _iDockedPos = HIWORD(pnmh->code); _isFloating = false; break; @@ -129,8 +129,8 @@ protected : int _dlgID; bool _isFloating; int _iDockedPos; - char _moduleName[MAX_PATH]; - char _pluginName[MAX_PATH]; + TCHAR _moduleName[MAX_PATH]; + TCHAR _pluginName[MAX_PATH]; }; #endif // DOCKINGDLGINTERFACE_H diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingGUIWidget.rc b/PowerEditor/src/WinControls/DockingWnd/DockingGUIWidget.rc index 3ea06f81..64e4e167 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingGUIWidget.rc +++ b/PowerEditor/src/WinControls/DockingWnd/DockingGUIWidget.rc @@ -7,7 +7,7 @@ STYLE DS_SETFONT | DS_SETFOREGROUND | WS_MAXIMIZEBOX | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_TOOLWINDOW CAPTION "Selected Tab" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN CONTROL "Caption",IDC_BTN_CAPTION,"Button",BS_OWNERDRAW | NOT WS_VISIBLE,0,0,186,10 diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index 87119ee8..b14ed025 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -98,7 +98,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin) if (!::RegisterClass(&clz)) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(98); } _isRegistered = TRUE; @@ -107,7 +107,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin) _hSelf = ::CreateWindowEx( 0, DSPC_CLASS_NAME, - "", + TEXT(""), WS_CHILD | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, @@ -118,7 +118,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin) if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(777); } @@ -145,7 +145,7 @@ void DockingManager::init(HINSTANCE hInst, HWND hWnd, Window ** ppWin) if (!gWinCallHook) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(1000); } diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.h b/PowerEditor/src/WinControls/DockingWnd/DockingManager.h index 44c4123c..886138aa 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.h +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.h @@ -29,7 +29,7 @@ #include "dockingResource.h" #include "Parameters.h" -#define DSPC_CLASS_NAME "dockingManager" +#define DSPC_CLASS_NAME TEXT("dockingManager") using namespace std; @@ -97,7 +97,7 @@ public : } }; - void showDockableDlg(char* pszName, BOOL view) { + void showDockableDlg(TCHAR* pszName, BOOL view) { tTbData* pTbData = NULL; for (size_t i = 0; i < _vContainer.size(); i++) diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp index b3c533bf..f2389bfe 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingSplitter.cpp @@ -63,13 +63,13 @@ void DockingSplitter::init(HINSTANCE hInst, HWND hWnd, HWND hMessage, UINT flags { //double sided arrow pointing north-south as cursor wc.hCursor = ::LoadCursor(NULL,IDC_SIZENS); - wc.lpszClassName = "nsdockspliter"; + wc.lpszClassName = TEXT("nsdockspliter"); } else { // double sided arrow pointing east-west as cursor wc.hCursor = ::LoadCursor(NULL,IDC_SIZEWE); - wc.lpszClassName = "wedockspliter"; + wc.lpszClassName = TEXT("wedockspliter"); } if (((_isHoriReg == FALSE) && (flags & DMS_HORIZONTAL)) || @@ -86,7 +86,7 @@ void DockingSplitter::init(HINSTANCE hInst, HWND hWnd, HWND hMessage, UINT flags if (!::RegisterClass(&wc)) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(98); } else if (flags & DMS_HORIZONTAL) @@ -100,13 +100,13 @@ void DockingSplitter::init(HINSTANCE hInst, HWND hWnd, HWND hMessage, UINT flags } /* create splitter windows and initialize it */ - _hSelf = ::CreateWindowEx( 0, wc.lpszClassName, "", WS_CHILD | WS_VISIBLE, + _hSelf = ::CreateWindowEx( 0, wc.lpszClassName, TEXT(""), WS_CHILD | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _hParent, NULL, _hInst, (LPVOID)this); if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(777); } } @@ -154,8 +154,8 @@ LRESULT DockingSplitter::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM { DWORD dwError = ::GetLastError(); TCHAR str[128]; - ::wsprintf(str, "GetLastError() returned %lu", dwError); - ::MessageBox(NULL, str, "SetWindowsHookEx(MOUSE) failed", MB_OK | MB_ICONERROR); + ::wsprintf(str, TEXT("GetLastError() returned %lu"), dwError); + ::MessageBox(NULL, str, TEXT("SetWindowsHookEx(MOUSE) failed"), MB_OK | MB_ICONERROR); } else { diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp index 362d1381..122412c4 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.cpp @@ -135,7 +135,7 @@ void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr, void* pRes if (!::RegisterClass(&clz)) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(98); } _isRegistered = TRUE; @@ -144,7 +144,7 @@ void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr, void* pRes _hSelf = ::CreateWindowEx( 0, MDLG_CLASS_NAME, - "", 0, + TEXT(""), 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, @@ -155,7 +155,7 @@ void Gripper::startGrip(DockingCont* pCont, DockingManager* pDockMgr, void* pRes if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(777); } } @@ -269,8 +269,8 @@ void Gripper::create(void) { DWORD dwError = ::GetLastError(); TCHAR str[128]; - ::wsprintf(str, "GetLastError() returned %lu", dwError); - ::MessageBox(NULL, str, "SetWindowsHookEx(MOUSE) failed", MB_OK | MB_ICONERROR); + ::wsprintf(str, TEXT("GetLastError() returned %lu"), dwError); + ::MessageBox(NULL, str, TEXT("SetWindowsHookEx(MOUSE) failed"), MB_OK | MB_ICONERROR); } winVer winVersion = (NppParameters::getInstance())->getWinVersion(); @@ -281,8 +281,8 @@ void Gripper::create(void) { DWORD dwError = ::GetLastError(); TCHAR str[128]; - ::wsprintf(str, "GetLastError() returned %lu", dwError); - ::MessageBox(NULL, str, "SetWindowsHookEx(KEYBOARD) failed", MB_OK | MB_ICONERROR); + ::wsprintf(str, TEXT("GetLastError() returned %lu"), dwError); + ::MessageBox(NULL, str, TEXT("SetWindowsHookEx(KEYBOARD) failed"), MB_OK | MB_ICONERROR); } } // Removed regarding W9x systems @@ -535,8 +535,8 @@ void Gripper::doTabReordering(POINT pt) #if 0 extern HWND g_hMainWnd; - char str[128]; - sprintf(str, "Size: %i", vCont.size()); + TCHAR str[128]; + wsprintf(str, TEXT("Size: %i"), vCont.size()); ::SetWindowText(g_hMainWnd, str); #endif @@ -792,7 +792,7 @@ void Gripper::initTabInformation(POINT pt) ::SendMessage(_hTabSource, TCM_GETITEMRECT, _iItem, (LPARAM)&_rcItem); /* store item data */ - static char szText[64]; + static TCHAR szText[64]; _tcItem.mask = TCIF_PARAM | TCIF_TEXT; _tcItem.pszText = szText; _tcItem.cchTextMax = 64; diff --git a/PowerEditor/src/WinControls/DockingWnd/Gripper.h b/PowerEditor/src/WinControls/DockingWnd/Gripper.h index 08cd0a29..f864c61f 100644 --- a/PowerEditor/src/WinControls/DockingWnd/Gripper.h +++ b/PowerEditor/src/WinControls/DockingWnd/Gripper.h @@ -34,7 +34,7 @@ static const WORD DotPattern[] = }; -#define MDLG_CLASS_NAME "moveDlg" +#define MDLG_CLASS_NAME TEXT("moveDlg") class Gripper diff --git a/PowerEditor/src/WinControls/DockingWnd/common_func.cpp b/PowerEditor/src/WinControls/DockingWnd/common_func.cpp index 7b66f246..4839385d 100644 --- a/PowerEditor/src/WinControls/DockingWnd/common_func.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/common_func.cpp @@ -1,6 +1,5 @@ #include "common_func.h" #include -#include "UniConversion.h" using namespace std; @@ -53,33 +52,33 @@ void folderBrowser(HWND parent, int outputCtrlID) { // If we were able to get the shell malloc object, // then proceed by initializing the BROWSEINFO stuct - BROWSEINFOW info; + BROWSEINFO info; memset(&info, 0, sizeof(info)); info.hwndOwner = parent; info.pidlRoot = NULL; - wchar_t szDisplayName[MAX_PATH]; + TCHAR szDisplayName[MAX_PATH]; info.pszDisplayName = szDisplayName; - wstring title = L"Select a folder to search from"; + basic_string title = TEXT("Select a folder to search from"); info.lpszTitle = title.c_str(); info.ulFlags = 0; info.lpfn = BrowseCallbackProc; - wchar_t directory[MAX_PATH]; - ::GetDlgItemTextW(parent, outputCtrlID, directory, sizeof(directory)); + TCHAR directory[MAX_PATH]; + ::GetDlgItemText(parent, outputCtrlID, directory, sizeof(directory)); info.lParam = reinterpret_cast(directory); // Execute the browsing dialog. - LPITEMIDLIST pidl = ::SHBrowseForFolderW(&info); + LPITEMIDLIST pidl = ::SHBrowseForFolder(&info); // pidl will be null if they cancel the browse dialog. // pidl will be not null when they select a folder. if (pidl) { - // Try to convert the pidl to a display string. + // Try to convert the pidl to a display basic_string. // Return is true if success. - wchar_t szDirW[MAX_PATH]; - if (::SHGetPathFromIDListW(pidl, szDirW)) + TCHAR szDir[MAX_PATH]; + if (::SHGetPathFromIDList(pidl, szDir)) // Set edit control to the directory path. - ::SetDlgItemTextW(parent, outputCtrlID, szDirW); + ::SetDlgItemText(parent, outputCtrlID, szDir); pShellMalloc->Free(pidl); } pShellMalloc->Release(); diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index 757090a2..e7be3b26 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -11,7 +11,7 @@ Modified by Don HO */ #include "babygrid.h" - +#include "SysMsg.h" #define MAX_GRIDS 20 @@ -31,10 +31,10 @@ struct _gridhandlestruct { UINT gridmenu; HWND hlist1; - char protect[2]; - char title[305]; - char editstring[305]; - char editstringdisplay[305]; + TCHAR protect[2]; + TCHAR title[305]; + TCHAR editstring[305]; + TCHAR editstringdisplay[305]; int rows; int cols; int gridwidth; @@ -98,7 +98,7 @@ _BGCELL BGcell,*LPBGcell; int BG_GridIndex; int FindResult; -char data[1000]; +TCHAR data[1000]; @@ -113,8 +113,8 @@ int AddGrid(UINT); int FindGrid(UINT); void ShowVscroll(HWND,int); void ShowHscroll(HWND,int); -int BinarySearchListBox(HWND,char*); -void DisplayEditString(HWND ,int ,char*); +int BinarySearchListBox(HWND,TCHAR*); +void DisplayEditString(HWND ,int ,TCHAR*); int CountGrids(void); @@ -148,7 +148,7 @@ void RefreshGrid(HWND hWnd) SI=FindGrid((UINT)GetMenu(hWnd)); if(BGHS[SI].EDITING) { - DisplayEditString(hWnd,SI,""); + DisplayEditString(hWnd, SI, TEXT("")); } } @@ -246,7 +246,7 @@ void SetCell(_BGCELL *cell,int row, int col) cell->col = col; } /* -int DetermineDataType(char* data) +int DetermineDataType(TCHAR* data) { //return values: // 1 = Text or Alpha @@ -255,17 +255,17 @@ int DetermineDataType(char* data) // 4 = Boolean FALSE // 5 = Graphic - user drawn (cell text begins with ~) int j,k,numberofperiods,numberofpositives,numberofnegatives; - char tbuffer[1000]; + TCHAR tbuffer[1000]; BOOL DIGIT,ALPHA,PERIOD,WHITESPACE,SYMBOL,POSITIVE,NEGATIVE; - strcpy(tbuffer,data); - k=strlen(tbuffer); + lstrcpy(tbuffer,data); + k=lstrlen(tbuffer); strupr(tbuffer); //is it boolean? - if(!strcmp(tbuffer,"TRUE")) + if(!lstrcmp(tbuffer,"TRUE")) { return 3; } - if(!strcmp(tbuffer,"FALSE")) + if(!lstrcmp(tbuffer,"FALSE")) { return 4; } @@ -427,7 +427,7 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe RECT rect,rectsave; HFONT holdfont; int r; - char buffer[1000]; + TCHAR buffer[1000]; int iDataType,iProtection; if(BGHS[SI].columnwidths[c]==0){return;} @@ -481,7 +481,7 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe } SetCell(&BGcell,r,c); - strcpy(buffer,""); + lstrcpy(buffer, TEXT("")); SendMessage(hWnd,BGM_GETCELLDATA,(WPARAM)&BGcell,(LPARAM)buffer); if(BGHS[SI].COLUMNSNUMBERED) { @@ -493,7 +493,7 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe if(high == 0){high = 32;}else{high+=64;} if(low == 0){low=26;} low += 64; - wsprintf(buffer,"%c%c",high,low); + wsprintf(buffer, TEXT("%c%c"), high,low); } } rectsave=rect; @@ -528,11 +528,11 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe rect.bottom = rect.top + BGHS[SI].rowheight; rectsave=rect; SetCell(&BGcell,r,c); - strcpy(buffer,""); + lstrcpy(buffer, TEXT("")); SendMessage(hWnd,BGM_GETCELLDATA,(WPARAM)&BGcell,(LPARAM)buffer); if((c==0)&&(BGHS[SI].ROWSNUMBERED)) { - wsprintf(buffer,"%d",r); + wsprintf(buffer, TEXT("%d"), r); } if(c==0) { @@ -658,14 +658,14 @@ void DisplayColumn(HWND hWnd,int SI,int c,int offset,HFONT hfont,HFONT hcolumnhe { WPARAM wParam; buffer[0]=0x20; - BGHS[SI].ownerdrawitem = atoi(buffer); + BGHS[SI].ownerdrawitem = generic_atoi(buffer); wParam=MAKEWPARAM((UINT)::GetMenu(hWnd),BGN_OWNERDRAW); SendMessage(GetParent(hWnd),WM_COMMAND,wParam,(LPARAM)&rect); } if(BGHS[SI].EDITING) { - DisplayEditString(hWnd,SI,""); + DisplayEditString(hWnd, SI, TEXT("")); } rect=rectsave; @@ -750,20 +750,20 @@ void SetCurrentCellStatus(HWND hWnd,int SelfIndex) -char GetASCII(WPARAM wParam, LPARAM lParam) +TCHAR GetASCII(WPARAM wParam, LPARAM lParam) { int returnvalue; - char mbuffer[100]; + TCHAR mbuffer[100]; int result; BYTE keys[256]; WORD dwReturnedValue; GetKeyboardState(keys); result=ToAscii(wParam,(lParam >> 16) && 0xff,keys,&dwReturnedValue,0); - returnvalue = (char) dwReturnedValue; + returnvalue = (TCHAR) dwReturnedValue; if(returnvalue < 0){returnvalue = 0;} - wsprintf(mbuffer,"return value = %d",returnvalue); + wsprintf(mbuffer, TEXT("return value = %d"), returnvalue); if(result!=1){returnvalue = 0;} - return (char)returnvalue; + return (TCHAR)returnvalue; } @@ -1200,14 +1200,14 @@ void CloseEdit(HWND hWnd,int SI) cell.row = r; cell.col = c; SendMessage(hWnd,BGM_SETCELLDATA,(WPARAM)&cell,(LPARAM)BGHS[SI].editstring); - strcpy(BGHS[SI].editstring,""); + lstrcpy(BGHS[SI].editstring, TEXT("")); RefreshGrid(hWnd); BGHS[SI].EDITING = FALSE; HideCaret(hWnd); NotifyEditEnd(hWnd,SI); } -void DisplayEditString(HWND hWnd,int SI,char* tstring) +void DisplayEditString(HWND hWnd,int SI,TCHAR* tstring) { int r,c; HFONT holdfont; @@ -1234,10 +1234,10 @@ void DisplayEditString(HWND hWnd,int SI,char* tstring) rt.right -=2; rt.left += 2; - if(strlen(BGHS[SI].editstring)<=300) + if(lstrlen(BGHS[SI].editstring)<=300) { - strcat(BGHS[SI].editstring,tstring); - strcpy(BGHS[SI].editstringdisplay,BGHS[SI].editstring); + lstrcat(BGHS[SI].editstring,tstring); + lstrcpy(BGHS[SI].editstringdisplay,BGHS[SI].editstring); } else { @@ -1275,7 +1275,7 @@ ATOM RegisterGridClass(HINSTANCE hInstance) { BGHS[j].gridmenu = 0; BGHS[j].hlist1 = NULL; - strcpy(BGHS[j].protect,"U"); + lstrcpy(BGHS[j].protect, TEXT("U")); BGHS[j].rows = 100; BGHS[j].cols = 255; BGHS[j].homerow = 1; @@ -1310,7 +1310,7 @@ ATOM RegisterGridClass(HINSTANCE hInstance) BGHS[j].cursortype = 0; BGHS[j].hcolumnheadingfont = NULL; BGHS[j].htitlefont = NULL; - strcpy(BGHS[j].editstring,""); + lstrcpy(BGHS[j].editstring, TEXT("")); for(int k = 0 ; k < MAX_COLS ; k++) { @@ -1331,7 +1331,7 @@ ATOM RegisterGridClass(HINSTANCE hInstance) wclass.hCursor = ::LoadCursor(NULL, IDC_ARROW); wclass.hbrBackground = (HBRUSH)(GetStockObject(GRAY_BRUSH)); - wclass.lpszClassName = "BABYGRID"; + wclass.lpszClassName = TEXT("BABYGRID"); wclass.lpszMenuName = NULL; return RegisterClass(&wclass); @@ -1345,32 +1345,30 @@ void SizeGrid(HWND hWnd,int SI) } -int FindLongestLine(HDC hdc,char* text,SIZE* size) +int FindLongestLine(HDC hdc,TCHAR* text,SIZE* size) {int longest,lines,j; - char temptext[1000]; - char *p; + TCHAR temptext[1000]; + TCHAR *p; longest=0; lines=1; - for(j=0;j<(int)strlen(text);j++) + for(j=0;j<(int)lstrlen(text);j++) { if(text[j]=='\n') { lines++; } } - strcpy(temptext,text); - p=strtok(temptext,"\n"); + lstrcpy(temptext,text); + p = generic_strtok(temptext, TEXT("\n")); while(p) { - GetTextExtentPoint32(hdc,p,strlen(p),size); + GetTextExtentPoint32(hdc,p,lstrlen(p),size); if(size->cx > longest) { longest=size->cx; } - p=strtok('\0',"\n"); + p = generic_strtok('\0', TEXT("\n")); } - - //MessageBox(NULL,text,"FindLongestLine",MB_OK); return longest; } @@ -1380,7 +1378,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; - char buffer[1000]; + TCHAR buffer[1000]; int SelfIndex; int ReturnValue; UINT SelfMenu; @@ -1466,21 +1464,21 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) SIZE size; HDC gdc; HFONT holdfont; - if(strlen((char*)lParam)>300) + if(lstrlen((TCHAR*)lParam)>300) { - strcpy(BGHS[SelfIndex].title,"Title too long (300 chars max)"); + lstrcpy(BGHS[SelfIndex].title, TEXT("Title too long (300 chars max)")); } else { - strcpy(BGHS[SelfIndex].title,(char*)lParam); + lstrcpy(BGHS[SelfIndex].title,(TCHAR*)lParam); } gdc=GetDC(hWnd); //get linecount of title; - if(strlen(BGHS[SelfIndex].title) > 0) + if(lstrlen(BGHS[SelfIndex].title) > 0) { linecount=1; - for(j=0;j<(int)strlen(BGHS[SelfIndex].title);j++) + for(j=0;j<(int)lstrlen(BGHS[SelfIndex].title);j++) { if(BGHS[SelfIndex].title[j]=='\n') { @@ -1489,7 +1487,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } holdfont=(HFONT)SelectObject(gdc,BGHS[SelfIndex].htitlefont); - GetTextExtentPoint32(gdc,BGHS[SelfIndex].title,strlen(BGHS[SelfIndex].title),&size); + GetTextExtentPoint32(gdc,BGHS[SelfIndex].title,lstrlen(BGHS[SelfIndex].title),&size); SelectObject(gdc,holdfont); BGHS[SelfIndex].titleheight = (int)((size.cy*1.2) * linecount); } @@ -1585,7 +1583,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ReturnValue = -1; break; } - wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col); + wsprintf(buffer, TEXT("%05d-%03d"), LPBGcell->row,LPBGcell->col); //see if that cell is already loaded FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer); if(FindResult != LB_ERR) @@ -1607,16 +1605,16 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { //protecting or unprotecting a cell that isn't in the list //add it as blank; - strcat(buffer,"|"); + lstrcat(buffer, TEXT("|")); if((BOOL)lParam) { - strcat(buffer,"PA"); + lstrcat(buffer, TEXT("PA")); } else { - strcat(buffer,"UA"); + lstrcat(buffer, TEXT("UA")); } - strcat(buffer,"|"); + lstrcat(buffer, TEXT("|")); SendMessage(BGHS[SelfIndex].hlist1,LB_ADDSTRING,FindResult,(LPARAM)buffer); } @@ -1630,11 +1628,11 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case BGM_SETPROTECT: if((BOOL)wParam) { - strcpy(BGHS[SelfIndex].protect,"P"); + lstrcpy(BGHS[SelfIndex].protect, TEXT("P")); } else { - strcpy(BGHS[SelfIndex].protect,"U"); + lstrcpy(BGHS[SelfIndex].protect, TEXT("U")); } break; @@ -1669,7 +1667,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ReturnValue = -1; break; } - wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col); + wsprintf(buffer, TEXT("%05d-%03d"), LPBGcell->row,LPBGcell->col); //see if that cell is already loaded FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer); if(FindResult != LB_ERR) @@ -1678,20 +1676,20 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) SendMessage(BGHS[SelfIndex].hlist1,LB_DELETESTRING,FindResult,0); } //now add it - strcat(buffer,"|"); - strcat(buffer,BGHS[SelfIndex].protect); + lstrcat(buffer, TEXT("|")); + lstrcat(buffer,BGHS[SelfIndex].protect); //determine data type (text,numeric, or boolean)(1,2,3) - //iDataType=DetermineDataType((char*)lParam); + //iDataType=DetermineDataType((TCHAR*)lParam); iDataType = 1; - if(iDataType==1){strcat(buffer,"A");} - if(iDataType==2){strcat(buffer,"N");} - if(iDataType==3){strcat(buffer,"T");} - if(iDataType==4){strcat(buffer,"F");} - if(iDataType==5){strcat(buffer,"G");} + if(iDataType==1){lstrcat(buffer, TEXT("A"));} + if(iDataType==2){lstrcat(buffer, TEXT("N"));} + if(iDataType==3){lstrcat(buffer, TEXT("T"));} + if(iDataType==4){lstrcat(buffer, TEXT("F"));} + if(iDataType==5){lstrcat(buffer, TEXT("G"));} - strcat(buffer,"|"); - strcat(buffer,(char*)lParam); + lstrcat(buffer, TEXT("|")); + lstrcat(buffer, (TCHAR*)lParam); FindResult=SendMessage(BGHS[SelfIndex].hlist1,LB_ADDSTRING,0,(LPARAM)buffer); if(FindResult==LB_ERR) @@ -1712,7 +1710,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { SendMessage(BGHS[SelfIndex].hlist1,LB_GETTEXT,j-1,(LPARAM)buffer); buffer[5]=0x00; - j=atoi(buffer); + j=generic_atoi(buffer); if(j>SendMessage(hWnd,BGM_GETROWS,0,0)) { SendMessage(hWnd,BGM_SETGRIDDIM,j,BGHS[SelfIndex].cols); @@ -1745,17 +1743,17 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { holdfont=(HFONT)SelectObject(hdc,BGHS[SelfIndex].hfont); } - //if there are \n codes in the string, find the longest line - longestline=FindLongestLine(hdc,(char*)lParam,&size); - //GetTextExtentPoint32(hdc,(char*)lParam,strlen((char*)lParam),&size); + //if there are \n codes in the basic_string, find the longest line + longestline=FindLongestLine(hdc,(TCHAR*)lParam,&size); + //GetTextExtentPoint32(hdc,(TCHAR*)lParam,lstrlen((TCHAR*)lParam),&size); required_width = longestline+15; required_height = size.cy; //count lines { int count=1; - char tbuffer[255]; - strcpy(tbuffer,(char*)lParam); - for(int j=0;j<(int)strlen(tbuffer);j++) + TCHAR tbuffer[255]; + lstrcpy(tbuffer,(TCHAR*)lParam); + for(int j=0;j<(int)lstrlen(tbuffer);j++) { if(tbuffer[j]=='\n'){count++;} } @@ -1804,17 +1802,17 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ReturnValue = -1; break; } - wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col); + wsprintf(buffer, TEXT("%05d-%03d"),LPBGcell->row,LPBGcell->col); //see if that cell is already loaded FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer); if(FindResult != LB_ERR) { int j,k,c; - char tbuffer[1000]; + TCHAR tbuffer[1000]; //it was found, get it SendMessage(BGHS[SelfIndex].hlist1,LB_GETTEXT,FindResult,(long)lParam); - strcpy(tbuffer,(char*)lParam); - k=strlen(tbuffer); + lstrcpy(tbuffer,(TCHAR*)lParam); + k=lstrlen(tbuffer); c=0; for(j=13;jrow,LPBGcell->col); + wsprintf(buffer, TEXT("%05d-%03d"),LPBGcell->row,LPBGcell->col); //see if that cell is already loaded FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer); if(FindResult != LB_ERR) @@ -1941,7 +1939,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ReturnValue = -1; break; } - wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col); + wsprintf(buffer, TEXT("%05d-%03d"),LPBGcell->row,LPBGcell->col); //see if that cell is already loaded FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer); if(FindResult != LB_ERR) @@ -1969,7 +1967,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ReturnValue = -1; break; } - wsprintf(buffer,"%05d-%03d",LPBGcell->row,LPBGcell->col); + wsprintf(buffer, TEXT("%05d-%03d"),LPBGcell->row,LPBGcell->col); //see if that cell is already loaded ReturnValue = 0; FindResult = BinarySearchListBox(BGHS[SelfIndex].hlist1,buffer); @@ -2320,7 +2318,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(BGHS[SelfIndex].EDITING) { BGHS[SelfIndex].EDITING = FALSE; - strcpy(BGHS[SelfIndex].editstring,""); + lstrcpy(BGHS[SelfIndex].editstring, TEXT("")); HideCaret(hWnd); RefreshGrid(hWnd); NotifyEditEnd(hWnd,SelfIndex); @@ -2339,7 +2337,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(BGHS[SelfIndex].EDITING) { BGHS[SelfIndex].EDITING = FALSE; - strcpy(BGHS[SelfIndex].editstring,""); + lstrcpy(BGHS[SelfIndex].editstring, TEXT("")); HideCaret(hWnd); RefreshGrid(hWnd); NotifyEditEnd(hWnd,SelfIndex); @@ -2646,7 +2644,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) wParam = ascii; if((wParam >= 32)&&(wParam <= 125)) { - char tstring[2]; + TCHAR tstring[2]; if(!BGHS[SelfIndex].EDITING) { NotifyEditBegin(hWnd,SelfIndex); @@ -2665,17 +2663,17 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } BGHS[SelfIndex].EDITING = TRUE; - if(strlen(BGHS[SelfIndex].editstring)==0) + if(lstrlen(BGHS[SelfIndex].editstring)==0) { - DisplayEditString(hWnd,SelfIndex,""); + DisplayEditString(hWnd,SelfIndex, TEXT("")); break; } else { int j; - j=strlen(BGHS[SelfIndex].editstring); + j=lstrlen(BGHS[SelfIndex].editstring); BGHS[SelfIndex].editstring[j-1]=0x00; - DisplayEditString(hWnd,SelfIndex,""); + DisplayEditString(hWnd,SelfIndex, TEXT("")); } break; } @@ -2889,7 +2887,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) BGHS[SelfIndex].gridmenu = 0; BGHS[SelfIndex].hlist1 = NULL; BGHS[SelfIndex].hfont = NULL; - strcpy(BGHS[SelfIndex].protect,"U"); + lstrcpy(BGHS[SelfIndex].protect, TEXT("U")); BGHS[SelfIndex].rows = 100; BGHS[SelfIndex].cols = 255; BGHS[SelfIndex].homerow = 1; @@ -3059,9 +3057,9 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) CLIP_DEFAULT_PRECIS, 0, 0 , - "MS Shell Dlg"); - hfontheader=CreateFont(18,0,0, 0,FW_HEAVY,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,0,0,"MS Shell Dlg"); - hfonttitle=CreateFont(20,0,0, 0,FW_HEAVY,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,0,0,"MS Shell Dlg"); + TEXT("MS Shell Dlg")); + hfontheader=CreateFont(18,0,0, 0,FW_HEAVY,FALSE,FALSE,FALSE,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 0, 0, TEXT("MS Shell Dlg")); + hfonttitle=CreateFont(20,0,0, 0,FW_HEAVY,FALSE,FALSE,FALSE,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, 0, 0, TEXT("MS Shell Dlg")); } @@ -3070,13 +3068,13 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) BGHS[BG_GridIndex].gridmenu = (UINT)GetMenu(hWnd); - BGHS[BG_GridIndex].hlist1=CreateWindowEx(WS_EX_CLIENTEDGE,"LISTBOX","", + BGHS[BG_GridIndex].hlist1=CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("LISTBOX"), TEXT(""), WS_CHILD|LBS_STANDARD,50,150,200,100,hWnd,NULL,hInst,NULL); BGHS[BG_GridIndex].hfont = hfontbody; BGHS[BG_GridIndex].htitlefont = hfonttitle; BGHS[BG_GridIndex].hcolumnheadingfont = hfontheader; - strcpy(BGHS[BG_GridIndex].title,lpcs->lpszName); + lstrcpy(BGHS[BG_GridIndex].title,lpcs->lpszName); SendMessage(hWnd,WM_SETTEXT,0,(LPARAM)lpcs->lpszName); @@ -3165,15 +3163,15 @@ int FindGrid( UINT menuid) -int BinarySearchListBox(HWND lbhWnd,char* searchtext) +int BinarySearchListBox(HWND lbhWnd,TCHAR* searchtext) { int ReturnValue; int lbcount; int head,tail,finger; int FindResult; - char tbuffer[1000]; - char headtext[1000]; - char tailtext[1000]; + TCHAR tbuffer[1000]; + TCHAR headtext[1000]; + TCHAR tailtext[1000]; int p; BOOL FOUND; @@ -3201,7 +3199,7 @@ int BinarySearchListBox(HWND lbhWnd,char* searchtext) SendMessage(lbhWnd,LB_GETTEXT,head,(LPARAM)headtext); headtext[9] = 0x00; - p=strcmp(searchtext,headtext); + p=lstrcmp(searchtext,headtext); if(p==0) { //it was the head @@ -3220,7 +3218,7 @@ int BinarySearchListBox(HWND lbhWnd,char* searchtext) //is it the tail? SendMessage(lbhWnd,LB_GETTEXT,tail,(LPARAM)tailtext); tailtext[9] = 0x00; - p=strcmp(searchtext,tailtext); + p=lstrcmp(searchtext,tailtext); if(p==0) { //it was the tail @@ -3245,7 +3243,7 @@ int BinarySearchListBox(HWND lbhWnd,char* searchtext) SendMessage(lbhWnd,LB_GETTEXT,finger,(LPARAM)tbuffer); tbuffer[9] = 0x00; - p=strcmp(tbuffer,searchtext); + p=lstrcmp(tbuffer,searchtext); if(p==0) { FOUND=TRUE; diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.h b/PowerEditor/src/WinControls/Grid/BabyGrid.h index b52124f8..3922a3b0 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.h +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.h @@ -5,8 +5,7 @@ //Printed BABYGRID message reference and tutorial available. //email: mudcat@mis.net for more information. -#ifndef BABYGRID_H -#define BABYGRID_H + #include #include "resource.h" @@ -105,4 +104,6 @@ void SetCell(_BGCELL *cell,int row, int col); //global variables -#endif //BABYGRID_H + + + diff --git a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp index 6ff03dfa..8c0b9f6b 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "BabyGridWrapper.h" -const char *babyGridClassName = "BABYGRID"; +const TCHAR *babyGridClassName = TEXT("BABYGRID"); bool BabyGridWrapper::_isRegistered = false; @@ -31,7 +31,7 @@ void BabyGridWrapper::init(HINSTANCE hInst, HWND parent, int id) _hSelf = ::CreateWindowEx(WS_EX_CLIENTEDGE, babyGridClassName,\ - "",\ + TEXT(""),\ WS_CHILD | WS_VISIBLE,\ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,\ _hParent,\ diff --git a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.h b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.h index 0033337d..33104541 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGridWrapper.h +++ b/PowerEditor/src/WinControls/Grid/BabyGridWrapper.h @@ -47,7 +47,7 @@ public : ::SendMessage(_hSelf, BGM_SETCOLSNUMBERED, isNumbered?TRUE:FALSE, 0); } - void setText(size_t row, size_t col, const char *text) { + void setText(size_t row, size_t col, const TCHAR *text) { _BGCELL cell; cell.row = row; cell.col = col; diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp index 21e0806d..fba31fe3 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.cpp @@ -36,10 +36,10 @@ void ShortcutMapper::initTabs() { ::SendMessage(hTab, TCM_INSERTITEM, 4, (LPARAM)(&tie) ); } -void ShortcutMapper::translateTab(int index, const char * newname) { +void ShortcutMapper::translateTab(int index, const TCHAR * newname) { if (index < 0 || index > 4) return; - strncpy(tabNames[index], newname, maxTabName); + generic_strncpy(tabNames[index], newname, maxTabName); } void ShortcutMapper::initBabyGrid() { @@ -86,8 +86,8 @@ void ShortcutMapper::fillOutBabyGrid() break; } } - _babygrid.setText(0, 1, "Name"); - _babygrid.setText(0, 2, "Shortcut"); + _babygrid.setText(0, 1, TEXT("Name")); + _babygrid.setText(0, 2, TEXT("Shortcut")); switch(_currentState) { case STATE_MENU: { @@ -277,7 +277,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP case IDM_BABYGRID_DELETE : { NppParameters *nppParam = NppParameters::getInstance(); - if (::MessageBox(_hSelf, "Are you sure you want to delete this shortcut?", "Are you sure?", MB_OKCANCEL) == IDOK) + if (::MessageBox(_hSelf, TEXT("Are you sure you want to delete this shortcut?"), TEXT("Are you sure?"), MB_OKCANCEL) == IDOK) { const int row = _babygrid.getSelectedRow(); int shortcutIndex = row-1; @@ -343,7 +343,7 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP } else { for (size_t i = shortcutIndex ; i < nbElem ; i++) //lower the IDs of the remaining menu items so there are no gaps { - char cmdName[64]; + TCHAR cmdName[64]; ::GetMenuString(hMenu, cmdID, cmdName, sizeof(cmdName), MF_BYCOMMAND); ::ModifyMenu(hMenu, cmdID, MF_BYCOMMAND, cmdID-1, cmdName); //update commandID } @@ -365,8 +365,8 @@ BOOL CALLBACK ShortcutMapper::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP if (!_rightClickMenu.isCreated()) { vector itemUnitArray; - itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_MODIFY, "Modify")); - itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_DELETE, "Delete")); + itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_MODIFY, TEXT("Modify"))); + itemUnitArray.push_back(MenuItemUnit(IDM_BABYGRID_DELETE, TEXT("Delete"))); _rightClickMenu.create(_hSelf, itemUnitArray); } switch(_currentState) { diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h index 40866d32..44c33878 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.h @@ -17,24 +17,25 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef SHORTCUTMAPPER_H -#define SHORTCUTMAPPER_H +#ifndef SHORTCUTMAPPER +#define SHORTCUTMAPPER #include "BabyGridWrapper.h" #include "ShortcutMapper_rc.h" #include "shortcut.h" #include "ContextMenu.h" +#include "SysMsg.h" enum GridState {STATE_MENU, STATE_MACRO, STATE_USER, STATE_PLUGIN, STATE_SCINTILLA}; class ShortcutMapper : public StaticDialog { public: ShortcutMapper() : _currentState(STATE_MENU), StaticDialog() { - strncpy(tabNames[0], "Main menu", maxTabName); - strncpy(tabNames[1], "Macros", maxTabName); - strncpy(tabNames[2], "Run commands", maxTabName); - strncpy(tabNames[3], "Plugin commands", maxTabName); - strncpy(tabNames[4], "Scintilla commands", maxTabName); + generic_strncpy(tabNames[0], TEXT("Main menu"), maxTabName); + generic_strncpy(tabNames[1], TEXT("Macros"), maxTabName); + generic_strncpy(tabNames[2], TEXT("Run commands"), maxTabName); + generic_strncpy(tabNames[3], TEXT("Plugin commands"), maxTabName); + generic_strncpy(tabNames[4], TEXT("Scintilla commands"), maxTabName); }; ~ShortcutMapper() {}; //void init(HINSTANCE hInst, HWND parent) {}; @@ -57,7 +58,7 @@ public: rc.left += 5; }; - void translateTab(int index, const char * newname); + void translateTab(int index, const TCHAR * newname); protected : BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); @@ -70,11 +71,11 @@ private: GridState _currentState; HWND _hTabCtrl; - char tabNames[5][maxTabName]; + TCHAR tabNames[5][maxTabName]; void initTabs(); void initBabyGrid(); void fillOutBabyGrid(); }; -#endif //SHORTCUTMAPPER_H +#endif //SHORTCUTMAPPER diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc b/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc index d65cd42e..96453772 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper.rc @@ -30,7 +30,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU //EXSTYLE WS_EX_TOOLWINDOW CAPTION "Shortcut mapper" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Close",IDOK,172,319,47,14 CONTROL "",IDC_BABYGRID_TABBAR,"SysTabControl32",TCS_BUTTONS,6,6,372, diff --git a/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h b/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h index 2ecf325f..405d095d 100644 --- a/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h +++ b/PowerEditor/src/WinControls/Grid/ShortcutMapper_rc.h @@ -16,13 +16,9 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef SHORTCUTMAPPERRC_H -#define SHORTCUTMAPPERRC_H #define IDD_SHORTCUTMAPPER_DLG 2600 #define IDD_BABYGRID_ID1 (IDD_SHORTCUTMAPPER_DLG + 1) #define IDM_BABYGRID_MODIFY (IDD_SHORTCUTMAPPER_DLG + 2) #define IDM_BABYGRID_DELETE (IDD_SHORTCUTMAPPER_DLG + 3) #define IDC_BABYGRID_TABBAR (IDD_SHORTCUTMAPPER_DLG + 4) - -#endif //SHORTCUTMAPPERRC_H diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp index 365edd9d..231461a3 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp @@ -48,7 +48,7 @@ void ToolBarIcons::destroy() //_iconListVector[HLIST_UGLY].destroy(); } /* -bool IconList::changeIcon(int index, const char *iconLocation) const +bool IconList::changeIcon(int index, const TCHAR *iconLocation) const { HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, iconLocation, IMAGE_ICON, _iconSize, _iconSize, LR_LOADFROMFILE ); if (!hBmp) diff --git a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h index 8297653a..24a3a033 100644 --- a/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h +++ b/PowerEditor/src/WinControls/ImageListSet/ImageListSet.h @@ -65,7 +65,7 @@ public : //::DeleteObject(hBmp); }; - bool changeIcon(int index, const char *iconLocation) const{ + bool changeIcon(int index, const TCHAR *iconLocation) const{ HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, iconLocation, IMAGE_ICON, _iconSize, _iconSize, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); if (!hBmp) return false; @@ -75,7 +75,7 @@ public : return (i == index); }; /* - bool changeIcon(int index, const char *iconLocation, int size) const{ + bool changeIcon(int index, const TCHAR *iconLocation, int size) const{ HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, iconLocation, IMAGE_ICON, size, size, LR_LOADFROMFILE | LR_LOADMAP3DCOLORS | LR_LOADTRANSPARENT); if (!hBmp) return false; @@ -86,7 +86,7 @@ public : /* void addImage(int iconID) const { - HBITMAP hBmp = ::LoadBitmap(_hInst, MAKEINTRESOURCE("STD_FILEOPEN")); + HBITMAP hBmp = ::LoadBitmap(_hInst, MAKEINTRESOURCE(TEXT("STD_FILEOPEN"))); //HBITMAP hBmp = (HBITMAP)::LoadImage(_hInst, MAKEINTRESOURCE(iconID), IMAGE_ICON, _iconSize, _iconSize, LR_LOADMAP3DCOLORS); ImageList_Add(_hImglst, hBmp, NULL); ::DeleteObject(hBmp); @@ -188,7 +188,7 @@ public : return _tbiis[i]._stdIcon; }; - bool replaceIcon(int witchList, int iconIndex, const char *iconLocation) const { + bool replaceIcon(int witchList, int iconIndex, const TCHAR *iconLocation) const { if ((witchList != HLIST_DEFAULT) && (witchList != HLIST_HOT) && (witchList != HLIST_DISABLE)) return false; return _iconListVector[witchList].changeIcon(iconIndex, iconLocation); diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index 044cbfeb..c7b1bb0a 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -28,24 +28,22 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst) for (int i = 0 ; i < nbExtMax ; i++) _extArray[i][0] = '\0'; - memset(_fileExtW, 0x00, sizeof(_fileExtW)); + memset(_fileExt, 0x00, sizeof(_fileExt)); _fileName[0] = '\0'; - _fileNameW[0] = '\0'; - _fileNameW[1] = '\0'; _winVersion = (NppParameters::getInstance())->getWinVersion(); _ofn.lStructSize = sizeof(_ofn); if (_winVersion < WV_W2K) - _ofn.lStructSize = sizeof(OPENFILENAMEW); + _ofn.lStructSize = sizeof(OPENFILENAME); _ofn.hwndOwner = hwnd; _ofn.hInstance = hInst; - _ofn.lpstrFilter = _fileExtW; - _ofn.lpstrCustomFilter = (LPWSTR) NULL; + _ofn.lpstrFilter = _fileExt; + _ofn.lpstrCustomFilter = (LPTSTR) NULL; _ofn.nMaxCustFilter = 0L; _ofn.nFilterIndex = 1L; - _ofn.lpstrFile = _fileNameW; - _ofn.nMaxFile = sizeof(_fileNameW); + _ofn.lpstrFile = _fileName; + _ofn.nMaxFile = sizeof(_fileName); _ofn.lpstrFileTitle = NULL; _ofn.nMaxFileTitle = 0; _ofn.lpstrInitialDir = NULL; @@ -66,132 +64,121 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst) // the file extension which should be ".WHATEVER", otherwise it (they) will be considered as // a file name to filter. Since the nb of arguments is variable, you have to add NULL at the end. // example : -// FileDialog.setExtFilter("c/c++ src file", ".c", ".cpp", ".cxx", ".h", NULL); -// FileDialog.setExtFilter("Makeile", "makefile", "GNUmakefile", NULL); -void FileDialog::setExtFilter(const char *extText, const char *ext, ...) +// FileDialog.setExtFilter(TEXT("c/c++ src file"), TEXT(".c"), TEXT(".cpp"), TEXT(".cxx"), TEXT(".h"), NULL); +// FileDialog.setExtFilter(TEXT("Makeile"), TEXT("makefile"), TEXT("GNUmakefile"), NULL); +void FileDialog::setExtFilter(const TCHAR *extText, const TCHAR *ext, ...) { // fill out the ext array for save as file dialog if (_nbExt < nbExtMax) - strcpy(_extArray[_nbExt++], ext); + lstrcpy(_extArray[_nbExt++], ext); // - std::string extFilter = extText; + std::basic_string extFilter = extText; va_list pArg; va_start(pArg, ext); - std::string exts; + std::basic_string exts; if (ext[0] == '.') - exts += "*"; + exts += TEXT("*"); exts += ext; - exts += ";"; + exts += TEXT(";"); - const char *ext2Concat; + const TCHAR *ext2Concat; - while ((ext2Concat = va_arg(pArg, const char *))) + while ((ext2Concat = va_arg(pArg, const TCHAR *))) { if (ext2Concat[0] == '.') - exts += "*"; + exts += TEXT("*"); exts += ext2Concat; - exts += ";"; + exts += TEXT(";"); } va_end(pArg); // remove the last ';' exts = exts.substr(0, exts.length()-1); - extFilter += " ("; - extFilter += exts + ")"; + extFilter += TEXT(" (L"); + extFilter += exts + TEXT(")"); - wchar_t *pFileExt = _fileExtW + _nbCharFileExt; - wstring extFilterW = string2wstring(extFilter); - wmemcpy(pFileExt, extFilterW.c_str(), extFilterW.length() + 1); - _nbCharFileExt += extFilterW.length() + 1; + TCHAR *pFileExt = _fileExt + _nbCharFileExt; + memcpy(pFileExt, extFilter.c_str(), extFilter.length() + 1); + _nbCharFileExt += extFilter.length() + 1; - pFileExt = _fileExtW + _nbCharFileExt; - wstring extsW = string2wstring(exts); - wmemcpy(pFileExt, extsW.c_str(), extsW.length() + 1); - _nbCharFileExt += extsW.length() + 1; + pFileExt = _fileExt + _nbCharFileExt; + memcpy(pFileExt, exts.c_str(), exts.length() + 1); + _nbCharFileExt += exts.length() + 1; } -int FileDialog::setExtsFilter(const char *extText, const char *exts) +int FileDialog::setExtsFilter(const TCHAR *extText, const TCHAR *exts) { // fill out the ext array for save as file dialog if (_nbExt < nbExtMax) - strcpy(_extArray[_nbExt++], exts); + lstrcpy(_extArray[_nbExt++], exts); // - std::string extFilter = extText; + std::basic_string extFilter = extText; - extFilter += " ("; + extFilter += TEXT(" (L"); extFilter += exts; - extFilter += ")"; + extFilter += TEXT(")"); - wchar_t *pFileExt = _fileExtW + _nbCharFileExt; - wstring extFilterW = string2wstring(extFilter); - wmemcpy(pFileExt, extFilterW.c_str(), extFilterW.length() + 1); - _nbCharFileExt += extFilterW.length() + 1; + TCHAR *pFileExt = _fileExt + _nbCharFileExt; + memcpy(pFileExt, extFilter.c_str(), extFilter.length() + 1); + _nbCharFileExt += extFilter.length() + 1; - pFileExt = _fileExtW + _nbCharFileExt; - wchar_t extsW[MAX_PATH]; - char2wchar(exts, extsW); - wmemcpy(pFileExt, extsW, wcslen(extsW) + 1); - _nbCharFileExt += wcslen(extsW) + 1; + pFileExt = _fileExt + _nbCharFileExt; + memcpy(pFileExt, exts, lstrlen(exts) + 1); + _nbCharFileExt += lstrlen(exts) + 1; return _nbExt; } -char * FileDialog::doOpenSingleFileDlg() +TCHAR * FileDialog::doOpenSingleFileDlg() { - WCHAR dir[MAX_PATH]; - ::GetCurrentDirectoryW(sizeof(dir), dir); + TCHAR dir[MAX_PATH]; + ::GetCurrentDirectory(sizeof(dir), dir); _ofn.lpstrInitialDir = dir; _ofn.Flags |= OFN_FILEMUSTEXIST; - WCHAR *fnW = NULL; + TCHAR *fn = NULL; try { - fnW = ::GetOpenFileNameW((OPENFILENAMEW*)&_ofn)?_fileNameW:NULL; - wchar2char(_fileNameW, _fileName); + fn = ::GetOpenFileName((OPENFILENAME*)&_ofn)?_fileName:NULL; } catch(...) { - ::MessageBox(NULL, "GetSaveFileName crashes!!!", "", MB_OK); + ::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK); } - return fnW?(_fileName):NULL; + return (fn); } stringVector * FileDialog::doOpenMultiFilesDlg() { - WCHAR dir[MAX_PATH]; - ::GetCurrentDirectoryW(sizeof(dir), dir); + TCHAR dir[MAX_PATH]; + ::GetCurrentDirectory(sizeof(dir), dir); _ofn.lpstrInitialDir = dir; _ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT; - if (::GetOpenFileNameW((OPENFILENAMEW*)&_ofn)) + if (::GetOpenFileName((OPENFILENAME*)&_ofn)) { - char fn[MAX_PATH]; - WCHAR fnW[MAX_PATH]; - WCHAR *pFnW = _fileNameW + wcslen(_fileNameW) + 1; - if (!(*pFnW)) - { - wchar2char(_fileNameW, _fileName); - _fileNames.push_back(std::string(_fileName)); - } + TCHAR fn[MAX_PATH]; + TCHAR *pFn = _fileName + lstrlen(_fileName) + 1; + if (!(*pFn)) + _fileNames.push_back(std::basic_string(_fileName)); else { - wcscpy(fnW, _fileNameW); - if (fnW[wcslen(fnW)-1] != '\\') - wcscat(fnW, L"\\"); + lstrcpy(fn, _fileName); + if (fn[lstrlen(fn)-1] != '\\') + lstrcat(fn, TEXT("\\")); } - int term = int(wcslen(fnW)); + int term = int(lstrlen(fn)); - while (*pFnW) + while (*pFn) { - fnW[term] = '\0'; - wcscat(fnW, pFnW); - wchar2char(fnW, fn); - _fileNames.push_back(std::string(fn)); - pFnW += wcslen(pFnW) + 1; + fn[term] = '\0'; + lstrcat(fn, pFn); + _fileNames.push_back(std::basic_string(fn)); + pFn += lstrlen(pFn) + 1; } return &_fileNames; @@ -200,33 +187,31 @@ stringVector * FileDialog::doOpenMultiFilesDlg() return NULL; } -char * FileDialog::doSaveDlg() +TCHAR * FileDialog::doSaveDlg() { - WCHAR dirW[MAX_PATH]; - ::GetCurrentDirectoryW(sizeof(dirW), dirW); + TCHAR dir[MAX_PATH]; + ::GetCurrentDirectory(sizeof(dir), dir); - _ofn.lpstrInitialDir = dirW; + _ofn.lpstrInitialDir = dir; _ofn.Flags |= OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_ENABLESIZING; _ofn.Flags |= OFN_ENABLEHOOK; _ofn.lpfnHook = OFNHookProc; - char *fn = NULL; - WCHAR *fnW = NULL; + TCHAR *fn = NULL; try { - fnW = ::GetSaveFileNameW((OPENFILENAMEW*)&_ofn)?_fileNameW:NULL; - wchar2char(_fileNameW, _fileName); + fn = ::GetSaveFileName((OPENFILENAME*)&_ofn)?_fileName:NULL; } catch(...) { - ::MessageBox(NULL, "GetSaveFileName crashes!!!", "", MB_OK); + ::MessageBox(NULL, TEXT("GetSaveFileName crashes!!!"), TEXT(""), MB_OK); } - return fnW?(_fileName):NULL; + return (fn); } static HWND hFileDlg = NULL; static WNDPROC oldProc = NULL; -static string currentExt = ""; +static basic_string currentExt = TEXT(""); static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -238,14 +223,14 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDOK : { HWND fnControl = ::GetDlgItem(hwnd, FileDialog::_dialogFileBoxId); - char fn[256]; + TCHAR fn[256]; ::GetWindowText(fnControl, fn, sizeof(fn)); if (*fn == '\0') return oldProc(hwnd, message, wParam, lParam); - if (currentExt != "") + if (currentExt != TEXT("")) { - string fnExt = changeExt(fn, currentExt); + basic_string fnExt = changeExt(fn, currentExt); ::SetWindowText(fnControl, fnExt.c_str()); } return oldProc(hwnd, message, wParam, lParam); @@ -259,10 +244,10 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM return oldProc(hwnd, message, wParam, lParam); }; -static char * get1stExt(char *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt) - char *begin = ext; +static TCHAR * get1stExt(TCHAR *ext) { // precondition : ext should be under the format : Batch (*.bat;*.cmd;*.nt) + TCHAR *begin = ext; for ( ; *begin != '.' ; begin++); - char *end = ++begin; + TCHAR *end = ++begin; for ( ; *end != ';' && *end != ')' ; end++); *end = '\0'; if (*begin == '*') @@ -270,17 +255,17 @@ static char * get1stExt(char *ext) { // precondition : ext should be under the f return begin; }; -static string addExt(HWND textCtrl, HWND typeCtrl) { - char fn[256]; +static basic_string addExt(HWND textCtrl, HWND typeCtrl) { + TCHAR fn[256]; ::GetWindowText(textCtrl, fn, sizeof(fn)); int i = ::SendMessage(typeCtrl, CB_GETCURSEL, 0, 0); - char ext[256]; + TCHAR ext[256]; ::SendMessage(typeCtrl, CB_GETLBTEXT, i, (LPARAM)ext); - char *pExt = get1stExt(ext); + TCHAR *pExt = get1stExt(ext); if (*fn != '\0') { - string fnExt = changeExt(fn, pExt); + basic_string fnExt = changeExt(fn, pExt); ::SetWindowText(textCtrl, fnExt.c_str()); } return pExt; @@ -316,7 +301,7 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L default : { - FileDialog *pFileDialog = reinterpret_cast(::GetWindowLong(hWnd, GWL_USERDATA)); + FileDialog *pFileDialog = reinterpret_cast(::GetWindowLongPtr(hWnd, GWL_USERDATA)); if (!pFileDialog) { return FALSE; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h index f9b54064..8f5ce955 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h @@ -26,14 +26,13 @@ #include #include "SysMsg.h" #include "Parameters.h" -#include "UniConversion.h" const int nbExtMax = 256; const int extLenMax = 64; using namespace std; -typedef vector stringVector; +typedef vector> stringVector; //const bool styleOpen = true; //const bool styleSave = false; @@ -41,39 +40,40 @@ struct OPENFILENAMENPP { DWORD lStructSize; HWND hwndOwner; HINSTANCE hInstance; - LPCWSTR lpstrFilter; - LPWSTR lpstrCustomFilter; + LPCTSTR lpstrFilter; + LPTSTR lpstrCustomFilter; DWORD nMaxCustFilter; DWORD nFilterIndex; - LPWSTR lpstrFile; + LPTSTR lpstrFile; DWORD nMaxFile; - LPWSTR lpstrFileTitle; + LPTSTR lpstrFileTitle; DWORD nMaxFileTitle; - LPCWSTR lpstrInitialDir; - LPCWSTR lpstrTitle; + LPCTSTR lpstrInitialDir; + LPCTSTR lpstrTitle; DWORD Flags; WORD nFileOffset; WORD nFileExtension; - LPCWSTR lpstrDefExt; + LPCTSTR lpstrDefExt; LPARAM lCustData; LPOFNHOOKPROC lpfnHook; - LPCWSTR lpTemplateName; + LPCTSTR lpTemplateName; void * pvReserved; DWORD dwReserved; DWORD FlagsEx; }; -static string changeExt(string fn, string ext) + +static basic_string changeExt(basic_string fn, basic_string ext) { - if (ext == "") + if (ext == TEXT("")) return fn; - string fnExt = fn; + basic_string fnExt = fn; - int index = fnExt.find_last_of("."); - string extension = "."; + int index = fnExt.find_last_of(TEXT(".")); + basic_string extension = TEXT("."); extension += ext; - if (index == string::npos) + if (index == basic_string::npos) { fnExt += extension; } @@ -116,14 +116,14 @@ class FileDialog { public: FileDialog(HWND hwnd, HINSTANCE hInst); - void setExtFilter(const char *, const char *, ...); + void setExtFilter(const TCHAR *, const TCHAR *, ...); - int setExtsFilter(const char *extText, const char *exts); - void setDefFileName(const char *fn){strcpy(_fileName, fn); char2wchar(fn, _fileNameW); } + int setExtsFilter(const TCHAR *extText, const TCHAR *exts); + void setDefFileName(const TCHAR *fn){lstrcpy(_fileName, fn);} - char * doSaveDlg(); + TCHAR * doSaveDlg(); stringVector * doOpenMultiFilesDlg(); - char * doOpenSingleFileDlg(); + TCHAR * doOpenSingleFileDlg(); bool isReadOnly() {return _ofn.Flags & OFN_READONLY;}; static int _dialogFileBoxId; @@ -132,10 +132,9 @@ protected : BOOL APIENTRY run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); private: - char _fileName[MAX_PATH*8]; - WCHAR _fileNameW[MAX_PATH*8]; + TCHAR _fileName[MAX_PATH*8]; - WCHAR _fileExtW[MAX_PATH*10]; + TCHAR _fileExt[MAX_PATH*10]; int _nbCharFileExt; stringVector _fileNames; @@ -144,7 +143,7 @@ private: winVer _winVersion; - char _extArray[nbExtMax][extLenMax]; + TCHAR _extArray[nbExtMax][extLenMax]; int _nbExt; static FileDialog *staticThis; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index e20fd963..0a142f54 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -27,14 +27,14 @@ IDD_PREFERENCE_BOX DIALOGEX 0, 0, 395, 231 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE CAPTION "Preferences" -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN PUSHBUTTON "Close",IDC_BUTTON_CLOSE,174,206,45,14 END IDD_PREFERENCE_BAR_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN GROUPBOX "Tool bar",IDC_TOOLBAR_GB_STATIC,17,5,145,68,BS_CENTER CONTROL "Hide",IDC_CHECK_HIDE,"Button",BS_AUTOCHECKBOX,24,15,94,10 @@ -60,7 +60,7 @@ END IDD_PREFERENCE_MARGEIN_BOX DIALOGEX 0, 0, 392, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN GROUPBOX "Folder margin style",IDC_FMS_GB_STATIC,32,75,149,42,BS_CENTER CONTROL "Simple",IDC_RADIO_SIMPLE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,41,88,59,10 @@ -95,7 +95,7 @@ END IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN GROUPBOX "History File Setting",IDC_HISTORY_GB_STATIC,15,4,150,39,BS_CENTER CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY, @@ -133,7 +133,7 @@ END IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN GROUPBOX "Format",IDC_FORMAT_GB_STATIC,62,28,95,83,BS_CENTER CONTROL "Windows",IDC_RADIO_F_WIN,"Button",BS_AUTORADIOBUTTON | WS_GROUP,69,46,63,10 @@ -151,7 +151,7 @@ END IDD_PREFERENCE_LANG_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN LISTBOX IDC_LIST_ENABLEDLANG,80,21,78,140,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP LISTBOX IDC_LIST_DISABLEDLANG,226,21,78,140,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP @@ -163,7 +163,7 @@ END IDD_PREFERENCE_PRINT_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN CONTROL "WYSIWYG",IDC_RADIO_WYSIWYG,"Button",BS_AUTORADIOBUTTON,50,65,123,10 CONTROL "Invert",IDC_RADIO_INVERT,"Button",BS_AUTORADIOBUTTON,50,80,90,10 @@ -184,7 +184,7 @@ END IDD_PREFERENCE_PRINT2_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN EDITTEXT IDC_EDIT_HLEFT,59,48,83,14,ES_AUTOHSCROLL EDITTEXT IDC_EDIT_HMIDDLE,149,48,83,14,ES_CENTER | ES_AUTOHSCROLL @@ -217,7 +217,7 @@ END IDD_PREFERENCE_BACKUP_BOX DIALOGEX 0, 0, 370, 180 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN GROUPBOX "Backup",IDC_BACKUPDIR_GRP_STATIC,46,11,289,86,BS_CENTER CONTROL "None",IDC_RADIO_BKNONE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,71,24,87,10 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 7e310477..5251b104 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -27,7 +27,7 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa case WM_INITDIALOG : { _ctrlTab.init(_hInst, _hSelf, false, true, true); - _ctrlTab.setFont("Tahoma", 13); + _ctrlTab.setFont(TEXT("Tahoma"), 13); _barsDlg.init(_hInst, _hSelf); _barsDlg.create(IDD_PREFERENCE_BAR_BOX); @@ -58,15 +58,15 @@ BOOL CALLBACK PreferenceDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa _backupDlg.init(_hInst, _hSelf); _backupDlg.create(IDD_PREFERENCE_BACKUP_BOX); - _wVector.push_back(DlgInfo(&_barsDlg, "Global", "Global")); - _wVector.push_back(DlgInfo(&_marginsDlg, "Edit Components", "Scintillas")); - _wVector.push_back(DlgInfo(&_defaultNewDocDlg, "New Document", "NewDoc")); - _wVector.push_back(DlgInfo(&_fileAssocDlg, "File Association", "FileAssoc")); - _wVector.push_back(DlgInfo(&_langMenuDlg, "Language Menu", "LangMenu")); - _wVector.push_back(DlgInfo(&_printSettingsDlg, "Print - Colour and Margin", "Print1")); - _wVector.push_back(DlgInfo(&_printSettings2Dlg, "Print - Header and Footer", "Print2")); - _wVector.push_back(DlgInfo(&_backupDlg, "Backup/Auto-completion", "Backup")); - _wVector.push_back(DlgInfo(&_settingsDlg, "MISC", "MISC")); + _wVector.push_back(DlgInfo(&_barsDlg, TEXT("Global"), TEXT("Global"))); + _wVector.push_back(DlgInfo(&_marginsDlg, TEXT("Edit Components"), TEXT("Scintillas"))); + _wVector.push_back(DlgInfo(&_defaultNewDocDlg, TEXT("New Document"), TEXT("NewDoc"))); + _wVector.push_back(DlgInfo(&_fileAssocDlg, TEXT("File Association"), TEXT("FileAssoc"))); + _wVector.push_back(DlgInfo(&_langMenuDlg, TEXT("Language Menu"), TEXT("LangMenu"))); + _wVector.push_back(DlgInfo(&_printSettingsDlg, TEXT("Print - Colour and Margin"), TEXT("Print1"))); + _wVector.push_back(DlgInfo(&_printSettings2Dlg, TEXT("Print - Header and Footer"), TEXT("Print2"))); + _wVector.push_back(DlgInfo(&_backupDlg, TEXT("Backup/Auto-completion"), TEXT("Backup"))); + _wVector.push_back(DlgInfo(&_settingsDlg, TEXT("MISC"), TEXT("MISC"))); _ctrlTab.createTabs(_wVector); _ctrlTab.display(); RECT rc; @@ -302,8 +302,8 @@ void MarginsDlg::changePanelTo(int index) ::EnableWindow(::GetDlgItem(_hSelf, IDC_RADIO_BGMODE), isEnable); ::EnableWindow(::GetDlgItem(_hSelf, IDC_NBCOLONE_STATIC), isEnable); - char nbColStr[10]; - itoa(svp._edgeNbColumn, nbColStr, 10); + TCHAR nbColStr[10]; + wsprintf(nbColStr, TEXT("%d"), svp._edgeNbColumn); ::SetWindowText(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), nbColStr); ::ShowWindow(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), isEnable); @@ -317,8 +317,8 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam { case WM_INITDIALOG : { - char nbStr[10]; - itoa(nppGUI._tabSize, nbStr, 10); + TCHAR nbStr[10]; + wsprintf(nbStr, TEXT("%d"), nppGUI._tabSize); HWND hTabSize_val = ::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC); ::SetWindowText(hTabSize_val, nbStr); @@ -329,11 +329,11 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam _verticalEdgeLineNbColVal.init(_hInst, _hSelf); _verticalEdgeLineNbColVal.create(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), IDM_SETTING_EDGE_SIZE); - ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)"0"); - ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)"1"); - ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)"2"); - ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)"3"); - ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)"Block"); + ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("0")); + ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("1")); + ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("2")); + ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("3")); + ::SendDlgItemMessage(_hSelf, IDC_WIDTH_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("Block")); ::SendMessage(::GetDlgItem(_hSelf, IDC_WIDTH_COMBO), CB_SETCURSEL, nppGUI._caretWidth, 0); @@ -344,8 +344,8 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam ::SendMessage(::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER),TBM_SETPOS, TRUE, nppGUI._caretBlinkRate); - ::SendDlgItemMessage(_hSelf, IDC_COMBO_SCINTILLAVIEWCHOIX, CB_ADDSTRING, 0, (LPARAM)"Primary View"); - ::SendDlgItemMessage(_hSelf, IDC_COMBO_SCINTILLAVIEWCHOIX, CB_ADDSTRING, 0, (LPARAM)"Second View"); + ::SendDlgItemMessage(_hSelf, IDC_COMBO_SCINTILLAVIEWCHOIX, CB_ADDSTRING, 0, (LPARAM)TEXT("Primary View")); + ::SendDlgItemMessage(_hSelf, IDC_COMBO_SCINTILLAVIEWCHOIX, CB_ADDSTRING, 0, (LPARAM)TEXT("Second View")); ::SendDlgItemMessage(_hSelf, IDC_COMBO_SCINTILLAVIEWCHOIX, CB_SETCURSEL, 0, 0); changePanelTo(SCIV_PRIMARY); @@ -376,8 +376,8 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam case IDM_SETTING_TAB_SIZE: { ::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_TAB_SIZE, 0); - char nbStr[10]; - itoa(nppGUI._tabSize, nbStr, 10); + TCHAR nbStr[10]; + wsprintf(nbStr, TEXT("%d"), nppGUI._tabSize); ::SetWindowText(::GetDlgItem(_hSelf, IDC_TABSIZEVAL_STATIC), nbStr); return TRUE; } @@ -457,8 +457,8 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam case IDM_SETTING_EDGE_SIZE: { ::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_EDGE_SIZE, iView); - char nbColStr[10]; - itoa(svp._edgeNbColumn, nbColStr, 10); + TCHAR nbColStr[10]; + wsprintf(nbColStr, TEXT("%d"), svp._edgeNbColumn); ::SetWindowText(::GetDlgItem(_hSelf, IDC_COLONENUMBER_STATIC), nbColStr); return TRUE; } @@ -500,9 +500,8 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara { case WM_INITDIALOG : { - char nbStr[10]; - - itoa(pNppParam->getNbMaxFile(), nbStr, 10); + TCHAR nbStr[10]; + wsprintf(nbStr, TEXT("%d"), pNppParam->getNbMaxFile()); ::SetWindowText(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), nbStr); _nbHistoryVal.init(_hInst, _hSelf); @@ -590,7 +589,7 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara { case IDC_EDIT_SESSIONFILEEXT: { - char sessionExt[MAX_PATH]; + TCHAR sessionExt[MAX_PATH]; ::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_GETTEXT, sizeof(sessionExt), (LPARAM)sessionExt); nppGUI._definedSessionExt = sessionExt; return TRUE; @@ -674,8 +673,8 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara case IDM_SETTING_HISTORY_SIZE: { ::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_HISTORY_SIZE, 0); - char nbStr[10]; - sprintf(nbStr, "%d", pNppParam->getNbMaxFile()); + TCHAR nbStr[10]; + wsprintf(nbStr, TEXT("%d"), pNppParam->getNbMaxFile()); ::SetWindowText(::GetDlgItem(_hSelf, IDC_MAXNBFILEVAL_STATIC), nbStr); return TRUE; } @@ -799,7 +798,7 @@ BOOL CALLBACK DefaultNewDocDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM int index = 0; for (int i = L_TXT ; i < pNppParam->L_END ; i++) { - string str; + basic_string str; if ((LangType)i != L_USER) { int cmdID = pNppParam->langTypeToCommandID((LangType)i); @@ -879,7 +878,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara { for (int i = L_TXT ; i < pNppParam->L_END ; i++) { - string str; + basic_string str; if ((LangType)i != L_USER) { int cmdID = pNppParam->langTypeToCommandID((LangType)i); @@ -980,7 +979,7 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara if (iRemove == -1) return TRUE; - char s[32]; + TCHAR s[32]; ::SendDlgItemMessage(_hSelf, list2Remove, LB_GETTEXT, iRemove, (LPARAM)s); LangMenuItem lmi = pSrcLst->at(iRemove); @@ -1001,16 +1000,16 @@ BOOL CALLBACK LangMenuDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara bool found(false); for(size_t x = 0; x < pNppParam->getExternalLexerDoc()->size() && !found; x++) { - TiXmlNode *lexersRoot = pNppParam->getExternalLexerDoc()->at(x)->FirstChild("NotepadPlus")->FirstChildElement("LexerStyles"); - for (TiXmlNode *childNode = lexersRoot->FirstChildElement("LexerType"); + TiXmlNode *lexersRoot = pNppParam->getExternalLexerDoc()->at(x)->FirstChild(TEXT("NotepadPlus"))->FirstChildElement(TEXT("LexerStyles")); + for (TiXmlNode *childNode = lexersRoot->FirstChildElement(TEXT("LexerType")); childNode ; - childNode = childNode->NextSibling("LexerType")) + childNode = childNode->NextSibling(TEXT("LexerType"))) { TiXmlElement *element = childNode->ToElement(); - if (string(element->Attribute("name")) == lmi._langName) + if (basic_string(element->Attribute(TEXT("name"))) == lmi._langName) { - element->SetAttribute("excluded", (LOWORD(wParam)==IDC_BUTTON_REMOVE)?"yes":"no"); + element->SetAttribute(TEXT("excluded"), (LOWORD(wParam)==IDC_BUTTON_REMOVE)?TEXT("yes"):TEXT("no")); pNppParam->getExternalLexerDoc()->at(x)->SaveFile(); found = true; break; @@ -1068,11 +1067,22 @@ BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM } ::SendDlgItemMessage(_hSelf, ID2Check, BM_SETCHECK, BST_CHECKED, 0); - char valStr[10]; - ::SendDlgItemMessage(_hSelf, IDC_EDIT_ML, WM_SETTEXT, 0, (LPARAM)itoa(nppGUI._printSettings._marge.left, valStr, 10)); - ::SendDlgItemMessage(_hSelf, IDC_EDIT_MR, WM_SETTEXT, 0, (LPARAM)itoa(nppGUI._printSettings._marge.right, valStr, 10)); - ::SendDlgItemMessage(_hSelf, IDC_EDIT_MT, WM_SETTEXT, 0, (LPARAM)itoa(nppGUI._printSettings._marge.top, valStr, 10)); - ::SendDlgItemMessage(_hSelf, IDC_EDIT_MB, WM_SETTEXT, 0, (LPARAM)itoa(nppGUI._printSettings._marge.bottom, valStr, 10)); + TCHAR valStrL[10]; + wsprintf(valStrL, TEXT("%d"), nppGUI._printSettings._marge.left); + + TCHAR valStrR[10]; + wsprintf(valStrR, TEXT("%d"), nppGUI._printSettings._marge.right); + + TCHAR valStrT[10]; + wsprintf(valStrT, TEXT("%d"), nppGUI._printSettings._marge.top); + + TCHAR valStrB[10]; + wsprintf(valStrB, TEXT("%d"), nppGUI._printSettings._marge.bottom); + + ::SendDlgItemMessage(_hSelf, IDC_EDIT_ML, WM_SETTEXT, 0, (LPARAM)valStrL); + ::SendDlgItemMessage(_hSelf, IDC_EDIT_MR, WM_SETTEXT, 0, (LPARAM)valStrR); + ::SendDlgItemMessage(_hSelf, IDC_EDIT_MT, WM_SETTEXT, 0, (LPARAM)valStrT); + ::SendDlgItemMessage(_hSelf, IDC_EDIT_MB, WM_SETTEXT, 0, (LPARAM)valStrB); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); if (enableDlgTheme) @@ -1134,15 +1144,15 @@ BOOL CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM return FALSE; } -void trim(string & str) +void trim(basic_string & str) { - string::size_type pos = str.find_last_not_of(' '); + basic_string::size_type pos = str.find_last_not_of(' '); - if (pos != string::npos) + if (pos != basic_string::npos) { str.erase(pos + 1); pos = str.find_first_not_of(' '); - if(pos != string::npos) str.erase(0, pos); + if(pos != basic_string::npos) str.erase(0, pos); } else str.erase(str.begin(), str.end()); }; @@ -1163,15 +1173,14 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM ::SendDlgItemMessage(_hSelf, IDC_EDIT_FMIDDLE, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._footerMiddle.c_str()); ::SendDlgItemMessage(_hSelf, IDC_EDIT_FRIGHT, WM_SETTEXT, 0, (LPARAM)nppGUI._printSettings._footerRight.c_str()); - char intStr[5]; + TCHAR intStr[5]; for(size_t i = 6 ; i < 15 ; i++) { - - itoa(i, intStr, 10); + wsprintf(intStr, TEXT("%d"), i); ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTSIZE, CB_ADDSTRING, 0, (LPARAM)intStr); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTSIZE, CB_ADDSTRING, 0, (LPARAM)intStr); } - const std::vector & fontlist = pNppParam->getFontList(); + const std::vector> & fontlist = pNppParam->getFontList(); for (size_t i = 0 ; i < fontlist.size() ; i++) { int j = ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTNAME, CB_ADDSTRING, 0, (LPARAM)fontlist[i].c_str()); @@ -1190,9 +1199,9 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM index = 0; ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTNAME, CB_SETCURSEL, index, 0); - itoa(nppGUI._printSettings._headerFontSize, intStr, 10); + wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._headerFontSize); ::SendDlgItemMessage(_hSelf, IDC_COMBO_HFONTSIZE, CB_SELECTSTRING, -1, (LPARAM)intStr); - itoa(nppGUI._printSettings._footerFontSize, intStr, 10); + wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._footerFontSize); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTSIZE, CB_SELECTSTRING, -1, (LPARAM)intStr); ::SendDlgItemMessage(_hSelf, IDC_CHECK_HBOLD, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?TRUE:FALSE, 0); @@ -1200,13 +1209,13 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM ::SendDlgItemMessage(_hSelf, IDC_CHECK_FBOLD, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?TRUE:FALSE, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_FITALIC, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE, 0); - varList.push_back(strCouple("Full file name path", "$(FULL_CURRENT_PATH)")); - varList.push_back(strCouple("File name", "$(FILE_NAME)")); - varList.push_back(strCouple("File directory", "$(FULL_CURRENT_PATH)")); - varList.push_back(strCouple("Page", "$(CURRENT_PRINTING_PAGE)")); - varList.push_back(strCouple("Short date format", "$(SHORT_DATE)")); - varList.push_back(strCouple("Long date format", "$(LONG_DATE)")); - varList.push_back(strCouple("Time", "$(TIME)")); + varList.push_back(strCouple(TEXT("Full file name path"), TEXT("$(FULL_CURRENT_PATH)"))); + varList.push_back(strCouple(TEXT("File name"), TEXT("$(FILE_NAME)"))); + varList.push_back(strCouple(TEXT("File directory"), TEXT("$(FULL_CURRENT_PATH)"))); + varList.push_back(strCouple(TEXT("Page"), TEXT("$(CURRENT_PRINTING_PAGE)"))); + varList.push_back(strCouple(TEXT("Short date format"), TEXT("$(SHORT_DATE)"))); + varList.push_back(strCouple(TEXT("Long date format"), TEXT("$(LONG_DATE)"))); + varList.push_back(strCouple(TEXT("Time"), TEXT("$(TIME)"))); for (size_t i = 0 ; i < varList.size() ; i++) { @@ -1227,7 +1236,7 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM { if (HIWORD(wParam) == EN_CHANGE) { - char str[256]; + TCHAR str[256]; _focusedEditCtrl = LOWORD(wParam); ::GetDlgItemText(_hSelf, _focusedEditCtrl, str, sizeof(str)); ::SendDlgItemMessage(_hSelf, IDC_VIEWPANEL_STATIC, WM_SETTEXT, 0, (LPARAM)str); @@ -1270,7 +1279,7 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM } else if (HIWORD(wParam) == EN_SETFOCUS) { - char str[256]; + TCHAR str[256]; _focusedEditCtrl = LOWORD(wParam); ::GetDlgItemText(_hSelf, _focusedEditCtrl, str, sizeof(str)); //_colourHooker.setColour(RGB(0, 0, 0xFF)); @@ -1289,11 +1298,11 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM } ::GetDlgItemText(_hSelf, groupStatic, str, sizeof(str)); - string title = str; - title += " "; + basic_string title = str; + title += TEXT(" "); ::GetDlgItemText(_hSelf, focusedEditStatic, str, sizeof(str)); title += str; - title += " : "; + title += TEXT(" : "); ::SendDlgItemMessage(_hSelf, IDC_WHICHPART_STATIC, WM_SETTEXT, 0, (LPARAM)title.c_str()); return TRUE; @@ -1307,7 +1316,7 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM case IDC_COMBO_HFONTNAME : case IDC_COMBO_FFONTNAME : { - char *fnStr = (char *)::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETITEMDATA, iSel, 0); + TCHAR *fnStr = (TCHAR *)::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETITEMDATA, iSel, 0); if (LOWORD(wParam) == IDC_COMBO_HFONTNAME) nppGUI._printSettings._headerFontName = fnStr; else @@ -1319,7 +1328,7 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM case IDC_COMBO_HFONTSIZE : case IDC_COMBO_FFONTSIZE : { - char intStr[5]; + TCHAR intStr[5]; ::SendDlgItemMessage(_hSelf, LOWORD(wParam), CB_GETLBTEXT, iSel, (LPARAM)intStr); int *pVal = (LOWORD(wParam) == IDC_COMBO_HFONTSIZE)?&(nppGUI._printSettings._headerFontSize):&(nppGUI._printSettings._footerFontSize); @@ -1327,7 +1336,7 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM if ((!intStr) || (!intStr[0])) *pVal = 0; else - *pVal = strtol(intStr, NULL, 10); + *pVal = generic_strtol(intStr, NULL, 10); } break; @@ -1364,19 +1373,19 @@ BOOL CALLBACK PrintSettings2Dlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM return TRUE; int iSel = ::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETCURSEL, 0, 0); - char *varStr = (char *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0); + TCHAR *varStr = (TCHAR *)::SendDlgItemMessage(_hSelf, IDC_COMBO_VARLIST, CB_GETITEMDATA, iSel, 0); ::SendDlgItemMessage(_hSelf, _focusedEditCtrl, EM_GETSEL, (WPARAM)&_selStart, (LPARAM)&_selEnd); /* - char toto[32]; - sprintf(toto, "_selStart = %d\r_selEnd = %d", _selStart, _selEnd); - ::MessageBox(NULL, toto, "", MB_OK); + TCHAR toto[32]; + wsprintf(toto, TEXT("_selStart = %d\r_selEnd = %d"), _selStart, _selEnd); + ::MessageBox(NULL, toto, TEXT(""), MB_OK); */ - char str[256]; + TCHAR str[256]; ::SendDlgItemMessage(_hSelf, _focusedEditCtrl, WM_GETTEXT, sizeof(str), (LPARAM)str); - //::MessageBox(NULL, str, "", MB_OK); + //::MessageBox(NULL, str, TEXT(""), MB_OK); - string str2Set(str); + basic_string str2Set(str); str2Set.replace(_selStart, _selEnd - _selStart, varStr); ::SetDlgItemText(_hSelf, _focusedEditCtrl, str2Set.c_str()); @@ -1398,8 +1407,8 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { case WM_INITDIALOG : { - char nbStr[10]; - itoa(nppGUI._autocFromLen, nbStr, 10); + TCHAR nbStr[10]; + wsprintf(nbStr, TEXT("%d"), nppGUI._autocFromLen); HWND hNbChar_val = ::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N); ::SetWindowText(hNbChar_val, nbStr); @@ -1453,9 +1462,9 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { case IDC_BACKUPDIR_EDIT: { - char inputDir[MAX_PATH]; + TCHAR inputDir[MAX_PATH]; ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_EDIT, WM_GETTEXT, sizeof(inputDir), (LPARAM)inputDir); - strcpy(nppGUI._backupDir, inputDir); + lstrcpy(nppGUI._backupDir, inputDir); return TRUE; } } @@ -1540,8 +1549,8 @@ BOOL CALLBACK BackupDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) case IDM_SETTING_AUTOCNBCHAR : { ::SendMessage(_hParent, WM_COMMAND, IDM_SETTING_AUTOCNBCHAR, 0); - char nbStr[10]; - sprintf(nbStr, "%d", pNppParam->getNppGUI()._autocFromLen); + TCHAR nbStr[10]; + wsprintf(nbStr, TEXT("%d"), pNppParam->getNppGUI()._autocFromLen); ::SetWindowText(::GetDlgItem(_hSelf, IDD_AUTOC_STATIC_N), nbStr); return TRUE; } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index f51d4920..c7af3899 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -71,8 +71,8 @@ private : struct LangID_Name { LangType _id; - string _name; - LangID_Name(LangType id, string name) : _id(id), _name(name){}; + basic_string _name; + LangID_Name(LangType id, basic_string name) : _id(id), _name(name){}; }; class DefaultNewDocDlg : public StaticDialog @@ -112,9 +112,9 @@ private : }; struct strCouple { - string _varDesc; - string _var; - strCouple(char *varDesc, char *var): _varDesc(varDesc), _var(var){}; + basic_string _varDesc; + basic_string _var; + strCouple(TCHAR *varDesc, TCHAR *var): _varDesc(varDesc), _var(var){}; }; class PrintSettings2Dlg : public StaticDialog diff --git a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp index 90067d98..a2e586b4 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/Splitter.cpp @@ -51,12 +51,12 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, if (hPere == NULL) { - ::MessageBox(NULL, "pas de pere?", "Splitter::init", MB_OK); + ::MessageBox(NULL, TEXT("pas de pere?"), TEXT("Splitter::init"), MB_OK); throw int(96); } if (iSplitRatio < 0) { - ::MessageBox(NULL, "it shoulds be 0 < ratio < 100", "Splitter::init", MB_OK); + ::MessageBox(NULL, TEXT("it shoulds be 0 < ratio < 100"), TEXT("Splitter::init"), MB_OK); throw int(96); } _hParent = hPere; @@ -72,7 +72,7 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, if (iSplitRatio >= 100) { //cant be 100 % or more - ::MessageBox(NULL, "it shoulds be 0 < ratio < 100", "Splitter::init", MB_OK); + ::MessageBox(NULL, TEXT("it shoulds be 0 < ratio < 100"), TEXT("Splitter::init"), MB_OK); throw int(96); } } @@ -129,9 +129,9 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, wcex.hCursor = ::LoadCursor(NULL, IDC_ARROW); // if fixed spliter then choose default cursor type. if (_dwFlags & SV_HORIZONTAL) - wcex.lpszClassName = "fxdnsspliter"; + wcex.lpszClassName = TEXT("fxdnsspliter"); else - wcex.lpszClassName = "fxdwespliter"; + wcex.lpszClassName = TEXT("fxdwespliter"); } else { @@ -139,13 +139,13 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, { //double sided arrow pointing north-south as cursor wcex.hCursor = ::LoadCursor(NULL,IDC_SIZENS); - wcex.lpszClassName = "nsspliter"; + wcex.lpszClassName = TEXT("nsspliter"); } else { // double sided arrow pointing east-west as cursor wcex.hCursor = ::LoadCursor(NULL,IDC_SIZEWE); - wcex.lpszClassName = "wespliter"; + wcex.lpszClassName = TEXT("wespliter"); } } @@ -177,7 +177,7 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, _hSelf = CreateWindowEx( dwExStyle, wcex.lpszClassName, - "", + TEXT(""), dwStyle, _rect.left, _rect.top, @@ -190,7 +190,7 @@ void Splitter::init( HINSTANCE hInst, HWND hPere, int splitterSize, if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(345); } @@ -259,7 +259,7 @@ LRESULT CALLBACK Splitter::spliterWndProc(UINT uMsg, WPARAM wParam, LPARAM lPara /* case WM_LBUTTONDBLCLK: { -::MessageBox(NULL, "", "", MB_OK); +::MessageBox(NULL, TEXT(""), TEXT(""), MB_OK); } return 0; diff --git a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp index 6eb06d2b..5c170f2f 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp +++ b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.cpp @@ -56,7 +56,7 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, if (!::RegisterClass(&splitterContainerClass)) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(98); } _isRegistered = true; @@ -65,7 +65,7 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, _hSelf = ::CreateWindowEx( 0, SPC_CLASS_NAME, - "a koi sert?", + TEXT("a koi sert?"), WS_CHILD | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, @@ -76,7 +76,7 @@ void SplitterContainer::create(Window *pWin0, Window *pWin1, int splitterSize, if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(777); } } @@ -195,8 +195,8 @@ LRESULT SplitterContainer::runProc(UINT message, WPARAM wParam, LPARAM lParam) POINT p; ::GetCursorPos(&p); _hPopupMenu = ::CreatePopupMenu(); - ::InsertMenu(_hPopupMenu, 1, MF_BYPOSITION, ROTATION_A_GAUCHE, "Rotate to left"); - ::InsertMenu(_hPopupMenu, 0, MF_BYPOSITION, ROTATION_A_DROITE, "Rotate to right"); + ::InsertMenu(_hPopupMenu, 1, MF_BYPOSITION, ROTATION_A_GAUCHE, TEXT("Rotate to left")); + ::InsertMenu(_hPopupMenu, 0, MF_BYPOSITION, ROTATION_A_DROITE, TEXT("Rotate to right")); } ::TrackPopupMenu(_hPopupMenu, TPM_LEFTALIGN, p.x, p.y, 0, _hSelf, NULL); diff --git a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h index 07f7f54d..92d29c0f 100644 --- a/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h +++ b/PowerEditor/src/WinControls/SplitterContainer/SplitterContainer.h @@ -21,7 +21,7 @@ #include "Window.h" #include "Splitter.h" -#define SPC_CLASS_NAME "splitterContainer" +#define SPC_CLASS_NAME TEXT("splitterContainer") #define ROTATION_A_GAUCHE 2000 #define ROTATION_A_DROITE 2001 diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp index 460d6880..0215852e 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.cpp @@ -24,11 +24,11 @@ #include "Notepad_plus.h" -void Command::extractArgs(wchar_t *cmd2Exec, wchar_t *args, const wchar_t *cmdEntier) +void Command::extractArgs(TCHAR *cmd2Exec, TCHAR *args, const TCHAR *cmdEntier) { int i = 0; bool quoted = false; - for ( ; i < int(wcslen(cmdEntier)) ; i++) + for ( ; i < int(lstrlen(cmdEntier)) ; i++) { if ((cmdEntier[i] == ' ') && (!quoted)) break; @@ -39,18 +39,18 @@ void Command::extractArgs(wchar_t *cmd2Exec, wchar_t *args, const wchar_t *cmdEn } cmd2Exec[i] = '\0'; - if (i < int(wcslen(cmdEntier))) + if (i < int(lstrlen(cmdEntier))) { - for ( ; (i < int(wcslen(cmdEntier))) && (cmdEntier[i] == ' ') ; i++); - if (i < int(wcslen(cmdEntier))) + for ( ; (i < int(lstrlen(cmdEntier))) && (cmdEntier[i] == ' ') ; i++); + if (i < int(lstrlen(cmdEntier))) { - for (int k = 0 ; i <= int(wcslen(cmdEntier)) ; i++, k++) + for (int k = 0 ; i <= int(lstrlen(cmdEntier)) ; i++, k++) { args[k] = cmdEntier[i]; } } - int l = wcslen(args); + int l = lstrlen(args); if (args[l-1] == ' ') { for (l -= 2 ; (l > 0) && (args[l] == ' ') ; l--); @@ -63,42 +63,42 @@ void Command::extractArgs(wchar_t *cmd2Exec, wchar_t *args, const wchar_t *cmdEn } -int whichVar(wchar_t *str) +int whichVar(TCHAR *str) { - if (!wcscmp(fullCurrentPath, str)) + if (!lstrcmp(fullCurrentPath, str)) return FULL_CURRENT_PATH; - else if (!wcscmp(currentDirectory, str)) + else if (!lstrcmp(currentDirectory, str)) return CURRENT_DIRECTORY; - else if (!wcscmp(onlyFileName, str)) + else if (!lstrcmp(onlyFileName, str)) return FILE_NAME; - else if (!wcscmp(fileNamePart, str)) + else if (!lstrcmp(fileNamePart, str)) return NAME_PART; - else if (!wcscmp(fileExtPart, str)) + else if (!lstrcmp(fileExtPart, str)) return EXT_PART; - else if (!wcscmp(currentWord, str)) + else if (!lstrcmp(currentWord, str)) return CURRENT_WORD; - else if (!wcscmp(nppDir, str)) + else if (!lstrcmp(nppDir, str)) return NPP_DIRECTORY; - else if (!wcscmp(currentLine, str)) + else if (!lstrcmp(currentLine, str)) return CURRENT_LINE; - else if (!wcscmp(currentColumn, str)) + else if (!lstrcmp(currentColumn, str)) return CURRENT_COLUMN; return VAR_NOT_RECOGNIZED; } -// Since I'm sure the length will be 256, I won't check the strlen : watch out! -void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t strDestLen, HWND hWnd) +// Since I'm sure the length will be 256, I won't check the lstrlen : watch out! +void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t strDestLen, HWND hWnd) { size_t j = 0; - for (size_t i = 0 ; i < wcslen(strSrc) ; i++) + for (int i = 0 ; i < lstrlen(strSrc) ; i++) { int iBegin = -1; int iEnd = -1; if ((strSrc[i] == '$') && (strSrc[i+1] == '(')) { iBegin = i += 2; - for ( ; i < wcslen(strSrc) ; i++) + for ( ; i < lstrlen(strSrc) ; i++) { if (strSrc[i] == ')') { @@ -111,7 +111,7 @@ void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t { if (iEnd != -1) { - wchar_t str[256]; + TCHAR str[256]; int m = 0; for (int k = iBegin ; k <= iEnd ; k++) str[m++] = strSrc[k]; @@ -125,16 +125,16 @@ void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t } else { - wchar_t expandedStr[256]; + TCHAR expandedStr[256]; if (internalVar == CURRENT_LINE || internalVar == CURRENT_COLUMN) { int lineNumber = ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, 0, 0); - wsprintfW(expandedStr, L"%d", lineNumber); + wsprintf(expandedStr, TEXT("%d"), lineNumber); } else ::SendMessage(hWnd, RUNCOMMAND_USER + internalVar, MAX_PATH, (LPARAM)expandedStr); - for (size_t p = 0 ; p < wcslen(expandedStr) ; p++) + for (int p = 0 ; p < lstrlen(expandedStr) ; p++) stringDest[j++] = expandedStr[p]; } } @@ -152,26 +152,20 @@ void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t HINSTANCE Command::run(HWND hWnd) { - wchar_t cmdPure[MAX_PATH]; - wchar_t cmdIntermediate[MAX_PATH]; - wchar_t cmd2Exec[MAX_PATH]; - wchar_t args[MAX_PATH]; - wchar_t argsIntermediate[MAX_PATH]; - wchar_t args2Exec[MAX_PATH]; + TCHAR cmdPure[MAX_PATH]; + TCHAR cmdIntermediate[MAX_PATH]; + TCHAR cmd2Exec[MAX_PATH]; + TCHAR args[MAX_PATH]; + TCHAR argsIntermediate[MAX_PATH]; + TCHAR args2Exec[MAX_PATH]; - wstring cmdLineW = string2wstring(_cmdLine); - extractArgs(cmdPure, args, cmdLineW.c_str()); - ::ExpandEnvironmentStringsW(cmdPure, cmdIntermediate, sizeof(cmd2Exec)); - ::ExpandEnvironmentStringsW(args, argsIntermediate, sizeof(args)); + extractArgs(cmdPure, args, _cmdLine.c_str()); + ::ExpandEnvironmentStrings(cmdPure, cmdIntermediate, sizeof(cmd2Exec)); + ::ExpandEnvironmentStrings(args, argsIntermediate, sizeof(args)); expandNppEnvironmentStrs(cmdIntermediate, cmd2Exec, sizeof(cmd2Exec), hWnd); expandNppEnvironmentStrs(argsIntermediate, args2Exec, sizeof(args2Exec), hWnd); - // cmd2Exec needs to be in UTF8 format for searches to work. - char temp[MAX_PATH]; - wchar2char(cmd2Exec, temp); - char2wchar(temp, cmd2Exec); - - return ::ShellExecuteW(hWnd, L"open", cmd2Exec, args2Exec, L".", SW_SHOW); + return ::ShellExecute(hWnd, TEXT("open"), cmd2Exec, args2Exec, TEXT("."), SW_SHOW); } BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) @@ -195,22 +189,19 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDOK : { - char cmd[MAX_PATH]; - wchar_t cmdW[MAX_PATH]; - ::GetDlgItemTextW(_hSelf, IDC_COMBO_RUN_PATH, cmdW, MAX_PATH); - wchar2char(cmdW, cmd); + TCHAR cmd[MAX_PATH]; + ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); _cmdLine = cmd; - wstring cmdLineW = string2wstring(_cmdLine); HINSTANCE hInst = run(_hParent); if (int(hInst) > 32) { - addTextToCombo(cmdLineW.c_str()); + addTextToCombo(_cmdLine.c_str()); display(false); } else { - removeTextFromCombo(cmdLineW.c_str()); + removeTextFromCombo(_cmdLine.c_str()); } return TRUE; } @@ -221,10 +212,8 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) int nbCmd = theUserCmds.size(); int cmdID = ID_USER_CMD + nbCmd; - char cmd[MAX_PATH]; - wchar_t cmdW[MAX_PATH]; - ::GetDlgItemTextW(_hSelf, IDC_COMBO_RUN_PATH, cmdW, MAX_PATH); - wchar2char(cmdW, cmd); + TCHAR cmd[MAX_PATH]; + ::GetDlgItemText(_hSelf, IDC_COMBO_RUN_PATH, cmd, MAX_PATH); UserCommand uc(Shortcut(), cmd, cmdID); uc.init(_hInst, _hSelf); @@ -245,15 +234,11 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) case IDC_BUTTON_FILE_BROWSER : { FileDialog fd(_hSelf, _hInst); - fd.setExtFilter("Executable file : ", ".exe", ".com", ".cmd", ".bat", NULL); - fd.setExtFilter("All files : ", ".*", NULL); + fd.setExtFilter(TEXT("Executable file : "), TEXT(".exe"), TEXT(".com"), TEXT(".cmd"), TEXT(".bat"), NULL); + fd.setExtFilter(TEXT("All files : "), TEXT(".*"), NULL); - if (const char *fn = fd.doOpenSingleFileDlg()) - { - wchar_t fnW[MAX_PATH]; - char2wchar(fn, fnW); - addTextToCombo(fnW); - } + if (const TCHAR *fn = fd.doOpenSingleFileDlg()) + addTextToCombo(fn); return TRUE; } @@ -265,18 +250,18 @@ BOOL CALLBACK RunDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) return FALSE; } -void RunDlg::addTextToCombo(const wchar_t *txt2Add) const +void RunDlg::addTextToCombo(const TCHAR *txt2Add) const { HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH); - int i = ::SendMessageW(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Add); + int i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Add); if (i == CB_ERR) - i = ::SendMessageW(handle, CB_ADDSTRING, 0, (LPARAM)txt2Add); + i = ::SendMessage(handle, CB_ADDSTRING, 0, (LPARAM)txt2Add); ::SendMessage(handle, CB_SETCURSEL, i, 0); } -void RunDlg::removeTextFromCombo(const wchar_t *txt2Remove) const +void RunDlg::removeTextFromCombo(const TCHAR *txt2Remove) const { HWND handle = ::GetDlgItem(_hSelf, IDC_COMBO_RUN_PATH); - int i = ::SendMessageW(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Remove); + int i = ::SendMessage(handle, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)txt2Remove); if (i == CB_ERR) return; ::SendMessage(handle, CB_DELETESTRING, i, 0); diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h index 109bf3c4..c6a6669c 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.h @@ -22,34 +22,34 @@ #include "RunDlg_rc.h" #include -//static void extractArgs(char *cmd2Exec, char *args, const char *cmdEntier); +//static void extractArgs(TCHAR *cmd2Exec, TCHAR *args, const TCHAR *cmdEntier); using namespace std; -const wchar_t fullCurrentPath[] = L"FULL_CURRENT_PATH"; -const wchar_t currentDirectory[] = L"CURRENT_DIRECTORY"; -const wchar_t onlyFileName[] = L"FILE_NAME"; -const wchar_t fileNamePart[] = L"NAME_PART"; -const wchar_t fileExtPart[] = L"EXT_PART"; -const wchar_t currentWord[] = L"CURRENT_WORD"; -const wchar_t nppDir[] = L"NPP_DIRECTORY"; -const wchar_t currentLine[] = L"CURRENT_LINE"; -const wchar_t currentColumn[] = L"CURRENT_COLUMN"; +const TCHAR fullCurrentPath[] = TEXT("FULL_CURRENT_PATH"); +const TCHAR currentDirectory[] = TEXT("CURRENT_DIRECTORY"); +const TCHAR onlyFileName[] = TEXT("FILE_NAME"); +const TCHAR fileNamePart[] = TEXT("NAME_PART"); +const TCHAR fileExtPart[] = TEXT("EXT_PART"); +const TCHAR currentWord[] = TEXT("CURRENT_WORD"); +const TCHAR nppDir[] = TEXT("NPP_DIRECTORY"); +const TCHAR currentLine[] = TEXT("CURRENT_LINE"); +const TCHAR currentColumn[] = TEXT("CURRENT_COLUMN"); -int whichVar(wchar_t *str); -void expandNppEnvironmentStrs(const wchar_t *strSrc, wchar_t *stringDest, size_t strDestLen, HWND hWnd); +int whichVar(TCHAR *str); +void expandNppEnvironmentStrs(const TCHAR *strSrc, TCHAR *stringDest, size_t strDestLen, HWND hWnd); class Command { public : Command(){}; - Command(char *cmd) : _cmdLine(cmd){}; - Command(string cmd) : _cmdLine(cmd){}; + Command(TCHAR *cmd) : _cmdLine(cmd){}; + Command(basic_string cmd) : _cmdLine(cmd){}; HINSTANCE run(HWND hWnd); protected : - string _cmdLine; + basic_string _cmdLine; private : - void extractArgs(wchar_t *cmd2Exec, wchar_t *args, const wchar_t *cmdEntier); + void extractArgs(TCHAR *cmd2Exec, TCHAR *args, const TCHAR *cmdEntier); }; class RunDlg : public Command, public StaticDialog @@ -67,8 +67,8 @@ protected : virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); private : - void addTextToCombo(const wchar_t *txt2Add) const; - void removeTextFromCombo(const wchar_t *txt2Remove) const; + void addTextToCombo(const TCHAR *txt2Add) const; + void removeTextFromCombo(const TCHAR *txt2Remove) const; }; #endif //RUN_DLG_H diff --git a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc index 96d850e8..23dcedc2 100644 --- a/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc +++ b/PowerEditor/src/WinControls/StaticDialog/RunDlg/RunDlg.rc @@ -30,7 +30,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Run..." -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Run!",IDOK,16,74,47,14 PUSHBUTTON "Cancel",IDCANCEL, 121,74,48,14 diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index 826fe6c9..2504fb71 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -100,7 +100,7 @@ void StaticDialog::create(int dialogID, bool isRTL) if (!_hSelf) { - systemMessage("StaticDialog"); + systemMessage(TEXT("StaticDialog")); throw int(666); } diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp index b8fae3fb..36775f70 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp @@ -30,7 +30,7 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts) ::CreateWindowEx( 0, STATUSCLASSNAME, - "", + TEXT(""), WS_CHILD | SBARS_SIZEGRIP , 0, 0, 0, 0, _hParent, @@ -40,7 +40,7 @@ void StatusBar::init(HINSTANCE hInst, HWND hPere, int nbParts) if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(9); } diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.h b/PowerEditor/src/WinControls/StatusBar/StatusBar.h index 60dc8db7..a5c9c980 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.h +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.h @@ -17,7 +17,6 @@ #ifndef STATUS_BAR_H #define STATUS_BAR_H - #include "Window.h" #ifndef _WIN32_IE @@ -67,7 +66,7 @@ public : return Window::getHeight(); }; - bool setText(const char *str, int whichPart) const { + bool setText(const TCHAR *str, int whichPart) const { if (whichPart > _nbParts) return false; return (::SendMessage(_hSelf, SB_SETTEXT, whichPart, (LPARAM)str) == TRUE); diff --git a/PowerEditor/src/WinControls/TabBar/ControlsTab.h b/PowerEditor/src/WinControls/TabBar/ControlsTab.h index 80944358..f448e13f 100644 --- a/PowerEditor/src/WinControls/TabBar/ControlsTab.h +++ b/PowerEditor/src/WinControls/TabBar/ControlsTab.h @@ -27,15 +27,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. struct DlgInfo { Window *_dlg; - char _name[64]; - char _internalName[32]; + TCHAR _name[64]; + TCHAR _internalName[32]; - DlgInfo(Window *dlg, char *name, char *internalName = NULL): _dlg(dlg) { - strcpy(_name, name); + DlgInfo(Window *dlg, TCHAR *name, TCHAR *internalName = NULL): _dlg(dlg) { + lstrcpy(_name, name); if (!internalName) _internalName[0] = '\0'; else - strcpy(_internalName, internalName); + lstrcpy(_internalName, internalName); }; }; @@ -74,20 +74,20 @@ public : activateWindowAt(indexClicked); }; - void renameTab(int index, const char *newName) { + void renameTab(int index, const TCHAR *newName) { TCITEM tie; tie.mask = TCIF_TEXT; - tie.pszText = (LPSTR)newName; + tie.pszText = (TCHAR *)newName; tie.cchTextMax = (sizeof(newName)); TabCtrl_SetItem(_hSelf, index, &tie); }; - bool renameTab(const char *internalName, const char *newName) { + bool renameTab(const TCHAR *internalName, const TCHAR *newName) { bool foundIt = false; size_t i = 0; for ( ; i < _pWinVector->size() ; i++) { - if (!strcmp((*_pWinVector)[i]._internalName, internalName)) + if (!lstrcmp((*_pWinVector)[i]._internalName, internalName)) { foundIt = true; break; diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index f7b54f1b..135995d4 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -65,7 +65,7 @@ void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditio _hSelf = ::CreateWindowEx( 0/*TCS_EX_FLATSEPARATORS*/ , WC_TABCONTROL, - "Tab", + TEXT("Tab"), style, 0, 0, 0, 0, _hParent, @@ -75,12 +75,12 @@ void TabBar::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTraditio if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(69); } } -int TabBar::insertAtEnd(const char *subTabName) +int TabBar::insertAtEnd(const TCHAR *subTabName) { TCITEM tie; tie.mask = TCIF_TEXT | TCIF_IMAGE; @@ -89,11 +89,11 @@ int TabBar::insertAtEnd(const char *subTabName) if (_hasImgLst) index = 0; tie.iImage = index; - tie.pszText = (char *)subTabName; + tie.pszText = (TCHAR *)subTabName; return int(::SendMessage(_hSelf, TCM_INSERTITEM, _nbItem++, reinterpret_cast(&tie))); } -void TabBar::getCurrentTitle(char *title, int titleLen) +void TabBar::getCurrentTitle(TCHAR *title, int titleLen) { TCITEM tci; tci.mask = TCIF_TEXT; @@ -166,12 +166,12 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad //if (isOwnerDrawTab() && (!_isTraditional)) { style |= TCS_OWNERDRAWFIXED; - //printStr("ownerDraw"); + //printStr(TEXT("ownerDraw")); } _hSelf = ::CreateWindowEx( /*TCS_EX_FLATSEPARATORS */0, WC_TABCONTROL, - "Tab", + TEXT("Tab"), style, 0, 0, 0, 0, _hParent, @@ -181,7 +181,7 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(69); } if (!_isTraditional) @@ -201,7 +201,7 @@ void TabBarPlus::init(HINSTANCE hInst, HWND parent, bool isVertical, bool isTrad if (!found) { _ctrlID = -1; - ::MessageBox(NULL, "The nb of Tab Control is over its limit", "Tab Control err", MB_OK); + ::MessageBox(NULL, TEXT("The nb of Tab Control is over its limit"), TEXT("Tab Control err"), MB_OK); destroy(); throw int(96); } @@ -469,20 +469,20 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) int nTab = pDrawItemStruct->itemID; if (nTab < 0) { - ::MessageBox(NULL, "nTab < 0", "", MB_OK); + ::MessageBox(NULL, TEXT("nTab < 0"), TEXT(""), MB_OK); //return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); } bool isSelected = (nTab == ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0)); - wchar_t label[MAX_PATH]; - TCITEMW tci; + TCHAR label[MAX_PATH]; + TCITEM tci; tci.mask = TCIF_TEXT|TCIF_IMAGE; tci.pszText = label; tci.cchTextMax = MAX_PATH-1; - if (!::SendMessage(_hSelf, TCM_GETITEMW, nTab, reinterpret_cast(&tci))) + if (!::SendMessage(_hSelf, TCM_GETITEM, nTab, reinterpret_cast(&tci))) { - ::MessageBox(NULL, "! TCM_GETITEM", "", MB_OK); + ::MessageBox(NULL, TEXT("! TCM_GETITEM"), TEXT(""), MB_OK); //return ::CallWindowProc(_tabBarDefaultProc, hwnd, Message, wParam, lParam); } HDC hDC = pDrawItemStruct->hDC; @@ -583,7 +583,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) HIMAGELIST hImgLst = (HIMAGELIST)::SendMessage(_hSelf, TCM_GETIMAGELIST, 0, 0); SIZE charPixel; - ::GetTextExtentPoint(hDC, " ", 1, &charPixel); + ::GetTextExtentPoint(hDC, TEXT(" "), 1, &charPixel); int spaceUnit = charPixel.cx; if (hImgLst && tci.iImage >= 0) @@ -693,7 +693,7 @@ void TabBarPlus::drawItem(DRAWITEMSTRUCT *pDrawItemStruct) else Flags |= DT_BOTTOM; } - ::DrawTextW(hDC, label, wcslen(label), &rect, Flags); + ::DrawText(hDC, label, lstrlen(label), &rect, Flags); ::RestoreDC(hDC, nSavedDC); } @@ -705,9 +705,9 @@ void TabBarPlus::draggingCursor(POINT screenPoint) ::SetCursor(::LoadCursor(NULL, IDC_ARROW)); else { - char className[256]; + TCHAR className[256]; ::GetClassName(hWin, className, 256); - if ((!strcmp(className, "Scintilla")) || (!strcmp(className, WC_TABCONTROL))) + if ((!lstrcmp(className, TEXT("Scintilla"))) || (!lstrcmp(className, WC_TABCONTROL))) { if (::GetKeyState(VK_LCONTROL) & 0x80000000) ::SetCursor(::LoadCursor(_hInst, MAKEINTRESOURCE(IDC_DRAG_PLUS_TAB))); @@ -736,37 +736,37 @@ void TabBarPlus::exchangeItemData(POINT point) ::SendMessage(_hSelf, TCM_SETCURSEL, nTab, 0); //2. shift their data, and insert the source - TCITEMW itemData_nDraggedTab, itemData_shift; + TCITEM itemData_nDraggedTab, itemData_shift; itemData_nDraggedTab.mask = itemData_shift.mask = TCIF_IMAGE | TCIF_TEXT | TCIF_PARAM; - wchar_t str1[MAX_PATH]; - wchar_t str2[MAX_PATH]; + TCHAR str1[256]; + TCHAR str2[256]; itemData_nDraggedTab.pszText = str1; - itemData_nDraggedTab.cchTextMax = (MAX_PATH-1); + itemData_nDraggedTab.cchTextMax = (sizeof(str1)); itemData_shift.pszText = str2; - itemData_shift.cchTextMax = (MAX_PATH-1); + itemData_shift.cchTextMax = (sizeof(str2)); - ::SendMessage(_hSelf, TCM_GETITEMW, _nTabDragged, reinterpret_cast(&itemData_nDraggedTab)); + ::SendMessage(_hSelf, TCM_GETITEM, _nTabDragged, reinterpret_cast(&itemData_nDraggedTab)); if (_nTabDragged > nTab) { for (int i = _nTabDragged ; i > nTab ; i--) { - ::SendMessage(_hSelf, TCM_GETITEMW, i-1, reinterpret_cast(&itemData_shift)); - ::SendMessage(_hSelf, TCM_SETITEMW, i, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_GETITEM, i-1, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_SETITEM, i, reinterpret_cast(&itemData_shift)); } } else { for (int i = _nTabDragged ; i < nTab ; i++) { - ::SendMessage(_hSelf, TCM_GETITEMW, i+1, reinterpret_cast(&itemData_shift)); - ::SendMessage(_hSelf, TCM_SETITEMW, i, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_GETITEM, i+1, reinterpret_cast(&itemData_shift)); + ::SendMessage(_hSelf, TCM_SETITEM, i, reinterpret_cast(&itemData_shift)); } } // - ::SendMessage(_hSelf, TCM_SETITEMW, nTab, reinterpret_cast(&itemData_nDraggedTab)); + ::SendMessage(_hSelf, TCM_SETITEM, nTab, reinterpret_cast(&itemData_nDraggedTab)); //3. update the current index _nTabDragged = nTab; diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.h b/PowerEditor/src/WinControls/TabBar/TabBar.h index 56453ffd..d8032ede 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.h +++ b/PowerEditor/src/WinControls/TabBar/TabBar.h @@ -38,10 +38,10 @@ const int nbCtrlMax = 10; #include "menuCmdID.h" #include "resource.h" -#define TABBAR_ACTIVEFOCUSEDINDCATOR "Active tab focused indicator" -#define TABBAR_ACTIVEUNFOCUSEDINDCATOR "Active tab unfocused indicator" -#define TABBAR_ACTIVETEXT "Active tab text" -#define TABBAR_INACTIVETEXT "Inactive tabs" +const TCHAR TABBAR_ACTIVEFOCUSEDINDCATOR[64] = TEXT("Active tab focused indicator"); +const TCHAR TABBAR_ACTIVEUNFOCUSEDINDCATOR[64] = TEXT("Active tab unfocused indicator"); +const TCHAR TABBAR_ACTIVETEXT[64] = TEXT("Active tab text"); +const TCHAR TABBAR_INACTIVETEXT[64] = TEXT("Inactive tabs"); struct TBHDR { NMHDR hdr; @@ -76,7 +76,7 @@ public: virtual void reSizeTo(RECT & rc2Ajust); - int insertAtEnd(const char *subTabName); + int insertAtEnd(const TCHAR *subTabName); void activateAt(int index) const { if (getCurrentTabIndex() != index) { @@ -88,7 +88,7 @@ public: nmhdr.tabOrigin = index; }; - void getCurrentTitle(char *title, int titleLen); + void getCurrentTitle(TCHAR *title, int titleLen); int getCurrentTabIndex() const { return ::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0); @@ -112,7 +112,7 @@ public: return _nbItem; }; - void setFont(char *fontName, size_t fontSize) { + void setFont(TCHAR *fontName, size_t fontSize) { if (_hFont) ::DeleteObject(_hFont); diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.cpp b/PowerEditor/src/WinControls/TaskList/TaskList.cpp index 24fcb243..0f2d1026 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.cpp +++ b/PowerEditor/src/WinControls/TaskList/TaskList.cpp @@ -41,7 +41,7 @@ void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem | LVS_SHAREIMAGELISTS/* | WS_BORDER*/; _hSelf = ::CreateWindow(WC_LISTVIEW, - "", + TEXT(""), WS_CHILD | listViewStyles, 0, 0, @@ -53,7 +53,7 @@ void TaskList::init(HINSTANCE hInst, HWND parent, HIMAGELIST hImaLst, int nbItem NULL); if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(69); } @@ -89,7 +89,7 @@ RECT TaskList::adjustSize() for (int i = 0 ; i < _nbItem ; i++) { - char buf[MAX_PATH]; + TCHAR buf[MAX_PATH]; ListView_GetItemText(_hSelf, i, 0, buf, sizeof(buf)); int width = ListView_GetStringWidth(_hSelf, buf); @@ -177,7 +177,7 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) case WM_KEYDOWN : { - //printStr("WM_KEYDOWN"); + //printStr(TEXT("WM_KEYDOWN")); return TRUE; } @@ -226,7 +226,7 @@ LRESULT TaskList::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) } else { - //printStr("else"); + //printStr(TEXT("else")); return TRUE; } //return DLGC_WANTALLKEYS ; diff --git a/PowerEditor/src/WinControls/TaskList/TaskList.h b/PowerEditor/src/WinControls/TaskList/TaskList.h index 04b34e8f..ad4cde7d 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskList.h +++ b/PowerEditor/src/WinControls/TaskList/TaskList.h @@ -48,7 +48,7 @@ public: void init(HINSTANCE hInst, HWND hwnd, HIMAGELIST hImaLst, int nbItem, int index2set); - void setFont(char *fontName, size_t fontSize) { + void setFont(TCHAR *fontName, size_t fontSize) { if (_hFont) ::DeleteObject(_hFont); diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h index 3e1c13d4..3ea4de3a 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.h +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.h @@ -33,10 +33,10 @@ const bool dirDown = false; struct TaskLstFnStatus { int _iView; int _docIndex; - string _fn; + basic_string _fn; int _status; - TaskLstFnStatus(string str, int status) : _fn(str), _status(status){}; - TaskLstFnStatus(int iView, int docIndex, string str, int status) : _iView(iView), _docIndex(docIndex), _fn(str), _status(status) {}; + TaskLstFnStatus(basic_string str, int status) : _fn(str), _status(status){}; + TaskLstFnStatus(int iView, int docIndex, basic_string str, int status) : _iView(iView), _docIndex(docIndex), _fn(str), _status(status) {}; }; struct TaskListInfo { @@ -100,7 +100,7 @@ protected : i2set = 0; _taskList.init(_hInst, _hSelf, _hImalist, nbTotal, i2set); - _taskList.setFont("Verdana", 14); + _taskList.setFont(TEXT("Verdana"), 14); _rc = _taskList.adjustSize(); reSizeTo(_rc); @@ -149,7 +149,7 @@ protected : TaskLstFnStatus & fileNameStatus = _taskListInfo._tlfsLst[lvItem.iItem]; - lvItem.pszText = (char *)fileNameStatus._fn.c_str(); + lvItem.pszText = (TCHAR *)fileNameStatus._fn.c_str(); lvItem.iImage = fileNameStatus._status; return TRUE; @@ -206,7 +206,7 @@ private : RECT rect = lpDrawItemStruct->rcItem; HDC hDC = lpDrawItemStruct->hDC; int nItem = lpDrawItemStruct->itemID; - const char *label = _taskListInfo._tlfsLst[nItem]._fn.c_str(); + const TCHAR *label = _taskListInfo._tlfsLst[nItem]._fn.c_str(); int iImage = _taskListInfo._tlfsLst[nItem]._status; COLORREF textColor = darkGrey; @@ -233,7 +233,7 @@ private : //int yPos = (rect.top + (rect.bottom - rect.top)/2 + (isSelected?0:2)) - (imageRect.bottom - imageRect.top)/2; SIZE charPixel; - ::GetTextExtentPoint(hDC, " ", 1, &charPixel); + ::GetTextExtentPoint(hDC, TEXT(" "), 1, &charPixel); int spaceUnit = charPixel.cx; int marge = spaceUnit; @@ -247,7 +247,7 @@ private : ::SetTextColor(hDC, textColor); rect.top -= ::GetSystemMetrics(SM_CYEDGE); - ::DrawText(hDC, label, strlen(label), &rect, DT_SINGLELINE | DT_VCENTER | DT_LEFT); + ::DrawText(hDC, label, lstrlen(label), &rect, DT_SINGLELINE | DT_VCENTER | DT_LEFT); }; }; diff --git a/PowerEditor/src/WinControls/TaskList/TaskListDlg.rc b/PowerEditor/src/WinControls/TaskList/TaskListDlg.rc index 1c5f69da..1b82e494 100644 --- a/PowerEditor/src/WinControls/TaskList/TaskListDlg.rc +++ b/PowerEditor/src/WinControls/TaskList/TaskListDlg.rc @@ -20,7 +20,7 @@ IDD_TASKLIST_DLG DIALOGEX DISCARDABLE 0, 0, 300, 300 STYLE WS_POPUP | WS_VISIBLE -FONT 8, "MS Shell Dlg", 0, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 0, 0, 0x1 BEGIN END diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp index e4ff440c..64285eca 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp @@ -143,7 +143,7 @@ void ToolBar::reset(bool create) _hSelf = ::CreateWindowEx( WS_EX_PALETTEWINDOW, TOOLBARCLASSNAME, - "", + TEXT(""), WS_TOOLBARSTYLE, 0, 0, 0, 0, @@ -159,7 +159,7 @@ void ToolBar::reset(bool create) if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(9); } @@ -238,7 +238,7 @@ void ToolBar::doPopop(POINT chevPoint) { if (start < _nrCurrentButtons) { //some buttons are hidden HMENU menu = ::CreatePopupMenu(); int cmd; - string text; + basic_string text; while (start < _nrCurrentButtons) { cmd = _pTBB[start].idCommand; getNameStrFromCmd(cmd, text); @@ -248,7 +248,7 @@ void ToolBar::doPopop(POINT chevPoint) { else AppendMenu(menu, MF_DISABLED|MF_GRAYED, cmd, text.c_str()); } else - AppendMenu(menu, MF_SEPARATOR, 0, ""); + AppendMenu(menu, MF_SEPARATOR, 0, TEXT("")); start++; } TrackPopupMenu(menu, 0, chevPoint.x, chevPoint.y, 0, _hSelf, NULL); diff --git a/PowerEditor/src/WinControls/ToolBar/ToolBar.h b/PowerEditor/src/WinControls/ToolBar/ToolBar.h index 9f0973e8..1c0979e4 100644 --- a/PowerEditor/src/WinControls/ToolBar/ToolBar.h +++ b/PowerEditor/src/WinControls/ToolBar/ToolBar.h @@ -104,7 +104,7 @@ public : return _state; }; - bool changeIcons(int whichLst, int iconIndex, const char *iconLocation){ + bool changeIcons(int whichLst, int iconIndex, const TCHAR *iconLocation){ return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation); }; diff --git a/PowerEditor/src/WinControls/ToolTip/ToolTip.cpp b/PowerEditor/src/WinControls/ToolTip/ToolTip.cpp index 15e466cf..34e107ef 100644 --- a/PowerEditor/src/WinControls/ToolTip/ToolTip.cpp +++ b/PowerEditor/src/WinControls/ToolTip/ToolTip.cpp @@ -35,7 +35,7 @@ void ToolTip::init(HINSTANCE hInst, HWND hParent) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, NULL, NULL ); if (!_hSelf) { - systemMessage("System Err"); + systemMessage(TEXT("System Err")); throw int(6969); } @@ -45,12 +45,12 @@ void ToolTip::init(HINSTANCE hInst, HWND hParent) } -void ToolTip::Show(RECT rectTitle, char* pszTitle, int iXOff, int iWidthOff) +void ToolTip::Show(RECT rectTitle, TCHAR * pszTitle, int iXOff, int iWidthOff) { if (isVisible()) destroy(); - if (strlen(pszTitle) == 0) + if (lstrlen(pszTitle) == 0) return; // INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE diff --git a/PowerEditor/src/WinControls/ToolTip/ToolTip.h b/PowerEditor/src/WinControls/ToolTip/ToolTip.h index e586a6d3..aa0db2d4 100644 --- a/PowerEditor/src/WinControls/ToolTip/ToolTip.h +++ b/PowerEditor/src/WinControls/ToolTip/ToolTip.h @@ -45,7 +45,7 @@ public: // Implementation public: virtual void init(HINSTANCE hInst, HWND hParent); - void Show(RECT rectTitle, char* pszTitleText, int iXOff = 0, int iWidthOff = 0); + void Show(RECT rectTitle, TCHAR* pszTitleText, int iXOff = 0, int iWidthOff = 0); protected: WNDPROC _defaultProc; diff --git a/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp b/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp index 08448772..6cd2c4e2 100644 --- a/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp +++ b/PowerEditor/src/WinControls/TrayIcon/trayIconControler.cpp @@ -1,6 +1,6 @@ #include "trayIconControler.h" #include -trayIconControler::trayIconControler(HWND hwnd, UINT uID, UINT uCBMsg, HICON hicon, char *tip) +trayIconControler::trayIconControler(HWND hwnd, UINT uID, UINT uCBMsg, HICON hicon, TCHAR *tip) { _nid.cbSize = sizeof(_nid); _nid.hWnd = hwnd; @@ -8,9 +8,9 @@ trayIconControler::trayIconControler(HWND hwnd, UINT uID, UINT uCBMsg, HICON hic _nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; _nid.uCallbackMessage = uCBMsg; _nid.hIcon = hicon; - strcpy(_nid.szTip, tip); + lstrcpy(_nid.szTip, tip); - ::RegisterWindowMessage("TaskbarCreated"); + ::RegisterWindowMessage(TEXT("TaskbarCreated")); _isIconShowed = false; } diff --git a/PowerEditor/src/WinControls/TrayIcon/trayIconControler.h b/PowerEditor/src/WinControls/TrayIcon/trayIconControler.h index ccd28ecc..c4dd3c44 100644 --- a/PowerEditor/src/WinControls/TrayIcon/trayIconControler.h +++ b/PowerEditor/src/WinControls/TrayIcon/trayIconControler.h @@ -13,7 +13,7 @@ class trayIconControler { public: - trayIconControler(HWND hwnd, UINT uID, UINT uCBMsg, HICON hicon, char *tip); + trayIconControler(HWND hwnd, UINT uID, UINT uCBMsg, HICON hicon, TCHAR *tip); int doTrayIcon(DWORD op); bool isInTray() const {return _isIconShowed;}; diff --git a/PowerEditor/src/WinControls/Window.h b/PowerEditor/src/WinControls/Window.h index c82e4a28..7bd64cbd 100644 --- a/PowerEditor/src/WinControls/Window.h +++ b/PowerEditor/src/WinControls/Window.h @@ -85,7 +85,7 @@ public: /* if (!_hSelf) { - ::MessageBox(NULL, "_hSelf == NULL", "class Window", MB_OK); + ::MessageBox(NULL, TEXT("_hSelf == NULL"), TEXT("class Window"), MB_OK); throw int(999); } */ @@ -103,7 +103,7 @@ public: HINSTANCE getHinst() const { if (!_hInst) { - ::MessageBox(NULL, "_hInst == NULL", "class Window", MB_OK); + ::MessageBox(NULL, TEXT("_hInst == NULL"), TEXT("class Window"), MB_OK); throw int(1999); } return _hInst; diff --git a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h index 672dfdad..2d4f2c8a 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/SizeableDlg.h @@ -1,5 +1,4 @@ -#ifndef SIZABLEDLG_H -#define SIZABLEDLG_H + #include "StaticDialog.h" #include "WindowsDlgRc.h" @@ -19,5 +18,3 @@ protected: virtual void onGetMinMaxInfo(MINMAXINFO* lpMMI); virtual LRESULT onWinMgr(WPARAM wp, LPARAM lp); }; - -#endif //SIZABLEDLG_H diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp index 88b78fb0..88cc623c 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp @@ -21,7 +21,7 @@ inline static DWORD GetExStyle(HWND hWnd) { return (DWORD)GetWindowLongPtr(hWnd, GWL_EXSTYLE); } -const UINT WM_WINMGR = RegisterWindowMessage("WM_WINMGR"); +const UINT WM_WINMGR = RegisterWindowMessage(TEXT("WM_WINMGR")); CWinMgr::CWinMgr(WINRECT* pWinMap) : m_map(pWinMap) { diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index cb651e76..017dfa1f 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -2,10 +2,10 @@ #include "WindowsDlg.h" #include "WindowsDlgRc.h" #include "DocTabView.h" +#include "SysMsg.h" #include #include #include -#include "UniConversion.h" #ifndef _countof #define _countof(x) (sizeof(x)/sizeof((x)[0])) @@ -15,8 +15,8 @@ #define LVS_EX_DOUBLEBUFFER 0x00010000 #endif -static const wchar_t *readonlyString = L" [Read Only]"; -const UINT WDN_NOTIFY = RegisterWindowMessage("WDN_NOTIFY"); +static const TCHAR *readonlyString = TEXT(" [Read Only]"); +const UINT WDN_NOTIFY = RegisterWindowMessage(TEXT("WDN_NOTIFY")); inline static DWORD GetStyle(HWND hWnd) { return (DWORD)GetWindowLongPtr(hWnd, GWL_STYLE); @@ -46,20 +46,20 @@ inline static BOOL ModifyStyleEx(HWND hWnd, DWORD dwRemove, DWORD dwAdd) { struct NumericStringEquivalence { - bool operator()(const char* s1, const char* s2) const + bool operator()(const TCHAR* s1, const TCHAR* s2) const { return numstrcmp(s1, s2) < 0; } - static inline int numstrcmp_get(const char **str, int *length) + static inline int numstrcmp_get(const TCHAR **str, int *length) { - const char *p = *str; + const TCHAR *p = *str; int value = 0; for (*length = 0; isdigit(*p); (*length)++) value = value * 10 + *p++ - '0'; *str = p; return (value); } - static int numstrcmp(const char *str1, const char *str2) + static int numstrcmp(const TCHAR *str1, const TCHAR *str2) { - char *p1, *p2; + TCHAR *p1, *p2; int c1, c2, lcmp; for(;;) { @@ -68,7 +68,7 @@ struct NumericStringEquivalence break; else if (isdigit(c1) && isdigit(c2)) { - lcmp = strtol(str1, &p1, 10) - strtol(str2, &p2, 10); + lcmp = generic_strtol(str1, &p1, 10) - generic_strtol(str2, &p2, 10); if ( lcmp == 0 ) lcmp = (p2 - str2) - (p1 - str1); if ( lcmp != 0 ) @@ -113,14 +113,14 @@ struct BufferEquivalent Buffer * b2 = MainFileManager->getBufferByID(bid2); if (_iColumn == 0) { - const char *s1 = b1->getFileName(); - const char *s2 = b2->getFileName(); + const TCHAR *s1 = b1->getFileName(); + const TCHAR *s2 = b2->getFileName(); return _strequiv(s1, s2); } else if (_iColumn == 1) { - const char *s1 = b1->getFilePath(); - const char *s2 = b2->getFilePath(); + const TCHAR *s1 = b1->getFilePath(); + const TCHAR *s2 = b2->getFilePath(); return _strequiv(s1, s2); //we can compare the full path to sort on directory, since after sorting directories sorting files is the second thing to do (if directories are the same that is) } else if (_iColumn == 2) @@ -231,9 +231,9 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam if (wParam == IDC_WINDOWS_LIST) { NMHDR* pNMHDR = (NMHDR*)lParam; - if (pNMHDR->code == LVN_GETDISPINFOW) + if (pNMHDR->code == LVN_GETDISPINFO) { - NMLVDISPINFOW *pLvdi = (NMLVDISPINFOW *)pNMHDR; + NMLVDISPINFO *pLvdi = (NMLVDISPINFO *)pNMHDR; //if(pLvdi->item.mask & LVIF_IMAGE) // ; if(pLvdi->item.mask & LVIF_TEXT) @@ -250,10 +250,10 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam if (pLvdi->item.iSubItem == 0) // file name { int len = pLvdi->item.cchTextMax; - const wchar_t *fileName = buf->getFileNameW(); - wcsncpy(pLvdi->item.pszText, fileName, len-1); + const TCHAR *fileName = buf->getFileName(); + generic_strncpy(pLvdi->item.pszText, fileName, len-1); pLvdi->item.pszText[len-1] = 0; - len = wcslen(pLvdi->item.pszText); + len = lstrlen(pLvdi->item.pszText); if (buf->isDirty()) { if (len < pLvdi->item.cchTextMax) @@ -264,23 +264,23 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam } else if (buf->isReadOnly()) { - len += wcslen(readonlyString); + len += lstrlen(readonlyString); if (len <= pLvdi->item.cchTextMax) - wcscat(pLvdi->item.pszText, readonlyString); + lstrcat(pLvdi->item.pszText, readonlyString); } } else if (pLvdi->item.iSubItem == 1) // directory { - const wchar_t *fullName = buf->getFilePathW(); - const wchar_t *fileName = buf->getFileNameW(); - int len = wcslen(fullName)-wcslen(fileName); + const TCHAR *fullName = buf->getFilePath(); + const TCHAR *fileName = buf->getFileName(); + int len = lstrlen(fullName)-lstrlen(fileName); if (!len) { len = 1; - fullName = L""; + fullName = TEXT(""); } if (pLvdi->item.cchTextMax < len) len = pLvdi->item.cchTextMax; - wcsncpy(pLvdi->item.pszText, fullName, len-1); + generic_strncpy(pLvdi->item.pszText, fullName, len-1); pLvdi->item.pszText[len-1] = 0; } else if (pLvdi->item.iSubItem == 2) // Type @@ -290,9 +290,7 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam Lang *lang = pNppParameters->getLangFromID(buf->getLangType()); if (NULL != lang) { - wchar_t langName[LANG_NAME_LEN]; - char2wchar(lang->getLangName(), langName); - wcsncpy(pLvdi->item.pszText, langName, len-1); + generic_strncpy(pLvdi->item.pszText, lang->getLangName(), len-1); } } } @@ -384,34 +382,59 @@ void WindowsDlg::updateButtonState() int WindowsDlg::doDialog(TiXmlNode *dlgNode) { _dlgNode = dlgNode; - return ::DialogBoxParamW(_hInst, MAKEINTRESOURCEW(IDD_WINDOWS), _hParent, (DLGPROC)dlgProc, (LPARAM)this); + return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_WINDOWS), _hParent, (DLGPROC)dlgProc, (LPARAM)this); }; bool WindowsDlg::changeDlgLang() { if (!_dlgNode) return false; +#ifdef UNICODE + WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); + int nativeLangEncoding = CP_ACP; + TiXmlDeclaration *declaration = _dlgNode->GetDocument()->FirstChild()->ToDeclaration(); + if (declaration) + { + const TCHAR * encodingStr = declaration->Encoding(); + nativeLangEncoding = getCpFromStringValue(encodingStr); + } +#endif + // Set Title - const char *titre = (_dlgNode->ToElement())->Attribute("title"); + const TCHAR *titre = (_dlgNode->ToElement())->Attribute(TEXT("title")); if (titre && titre[0]) { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(titre, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, nativeLangEncoding); + ::SetWindowText(_hSelf, nameW); +#else ::SetWindowText(_hSelf, titre); +#endif } // Set the text of child control - for (TiXmlNode *childNode = _dlgNode->FirstChildElement("Item"); + for (TiXmlNode *childNode = _dlgNode->FirstChildElement(TEXT("Item")); childNode ; - childNode = childNode->NextSibling("Item") ) + childNode = childNode->NextSibling(TEXT("Item")) ) { TiXmlElement *element = childNode->ToElement(); int id; - const char *sentinel = element->Attribute("id", &id); - const char *name = element->Attribute("name"); + const TCHAR *sentinel = element->Attribute(TEXT("id"), &id); + const TCHAR *name = element->Attribute(TEXT("name")); if (sentinel && (name && name[0])) { HWND hItem = ::GetDlgItem(_hSelf, id); if (hItem) + { +#ifdef UNICODE + const char *pCharStrA = wmc->wchar2char(name, CP_ANSI_LATIN_1); + const wchar_t *nameW = wmc->char2wchar(pCharStrA, nativeLangEncoding); + ::SetWindowText(hItem, nameW); +#else ::SetWindowText(hItem, name); +#endif + } } } return true; @@ -438,22 +461,22 @@ BOOL WindowsDlg::onInitDialog() GetClientRect(_hList, &rc); LONG width = rc.right - rc.left; - LVCOLUMNW lvColumn; + LVCOLUMN lvColumn; memset(&lvColumn, 0, sizeof(lvColumn)); lvColumn.mask = LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM|LVCF_FMT; lvColumn.fmt = LVCFMT_LEFT; - lvColumn.pszText = L"Name"; + lvColumn.pszText = TEXT("Name"); lvColumn.cx = width/4; - SendMessage(_hList, LVM_INSERTCOLUMNW, 0, LPARAM(&lvColumn)); + SendMessage(_hList, LVM_INSERTCOLUMN, 0, LPARAM(&lvColumn)); - lvColumn.pszText = L"Path"; + lvColumn.pszText = TEXT("Path"); lvColumn.cx = 300; - SendMessage(_hList, LVM_INSERTCOLUMNW, 1, LPARAM(&lvColumn)); + SendMessage(_hList, LVM_INSERTCOLUMN, 1, LPARAM(&lvColumn)); lvColumn.fmt = LVCFMT_CENTER; - lvColumn.pszText = L"Type"; + lvColumn.pszText = TEXT("Type"); lvColumn.cx = 40; - SendMessage(_hList, LVM_INSERTCOLUMNW, 2, LPARAM(&lvColumn)); + SendMessage(_hList, LVM_INSERTCOLUMN, 2, LPARAM(&lvColumn)); fitColumnsToSize(); @@ -710,14 +733,14 @@ WindowsMenu::~WindowsMenu() DestroyMenu(_hMenu); } -void WindowsMenu::init(HINSTANCE hInst, HMENU hMainMenu, const char *translation) +void WindowsMenu::init(HINSTANCE hInst, HMENU hMainMenu, const TCHAR *translation) { _hMenu = ::LoadMenu(hInst, MAKEINTRESOURCE(IDR_WINDOWS_MENU)); if (translation && translation[0]) { - string windowStr(translation); - windowStr += "..."; + basic_string windowStr(translation); + windowStr += TEXT("..."); ::ModifyMenu(_hMenu, IDM_WINDOW_WINDOWS, MF_BYCOMMAND, IDM_WINDOW_WINDOWS, windowStr.c_str()); } @@ -734,9 +757,9 @@ void WindowsMenu::init(HINSTANCE hInst, HMENU hMainMenu, const char *translation mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING|MIIM_SUBMENU; - char buffer[32]; + TCHAR buffer[32]; LoadString(hInst, IDR_WINDOWS_MENU, buffer, 32); - mii.dwTypeData = (LPSTR)((translation && translation[0])?translation:buffer); + mii.dwTypeData = (TCHAR *)((translation && translation[0])?translation:buffer); mii.hSubMenu = _hMenu; InsertMenuItem(hMainMenu, pos, TRUE, &mii); } @@ -752,15 +775,15 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab) int id, pos; for (id=IDM_WINDOW_MRU_FIRST, pos=0; idgetBufferByIndex(pos); Buffer * buf = MainFileManager->getBufferByID(bufID); - MENUITEMINFOW mii; + MENUITEMINFO mii; memset(&mii, 0, sizeof(mii)); mii.cbSize = sizeof(mii); mii.fMask = MIIM_STRING|MIIM_STATE|MIIM_ID; - mii.dwTypeData = buildFileName(buffer, 60, pos, buf->getFileNameW()); + mii.dwTypeData = buildFileName(buffer, 60, pos, buf->getFileName()); mii.fState &= ~(MF_GRAYED|MF_DISABLED|MF_CHECKED); if (pos == curDoc) mii.fState |= MF_CHECKED; @@ -768,9 +791,9 @@ void WindowsMenu::initPopupMenu(HMENU hMenu, DocTabView *pTab) UINT state = GetMenuState(hMenu, id, MF_BYCOMMAND); if (state == -1) - InsertMenuItemW(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii); + InsertMenuItem(hMenu, IDM_WINDOW_WINDOWS, FALSE, &mii); else - SetMenuItemInfoW(hMenu, id, FALSE, &mii); + SetMenuItemInfo(hMenu, id, FALSE, &mii); } for ( ; id<=IDM_WINDOW_MRU_LIMIT; ++id) { @@ -787,10 +810,10 @@ void WindowsMenu::uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView) } } */ -static wchar_t* convertFileName(wchar_t *buffer, const wchar_t *filename) +static TCHAR* convertFileName(TCHAR *buffer, const TCHAR *filename) { - wchar_t *b = buffer; - const wchar_t *p = filename; + TCHAR *b = buffer; + const TCHAR *p = filename; while (*p) { if (*p == '&') *b++ = '&'; @@ -800,15 +823,15 @@ static wchar_t* convertFileName(wchar_t *buffer, const wchar_t *filename) return buffer; } -wchar_t *WindowsMenu::buildFileName(wchar_t *buffer, int len, int pos, const wchar_t *filename) +TCHAR *WindowsMenu::buildFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename) { - wchar_t cwd[MAX_PATH]; + TCHAR cwd[MAX_PATH]; buffer[0] = 0; - GetCurrentDirectoryW(_countof(cwd), cwd); - wcscat(cwd, L"\\"); + GetCurrentDirectory(_countof(cwd), cwd); + lstrcat(cwd, TEXT("\\")); - wchar_t *itr = buffer; - wchar_t *end = buffer + len - 1; + TCHAR *itr = buffer; + TCHAR *end = buffer + len - 1; if (pos < 9) { *itr++ = '&'; @@ -822,33 +845,34 @@ wchar_t *WindowsMenu::buildFileName(wchar_t *buffer, int len, int pos, const wch } else { - itr = _itow(pos+1, itr, 10) + wcslen(itr); + wsprintf(itr, TEXT("%d"), pos+1); + itr = itr + lstrlen(itr); } *itr++ = ':'; *itr++ = ' '; - if (0 == wcsnicmp(filename, cwd, wcslen(cwd))) + if (0 == generic_strnicmp(filename, cwd, lstrlen(cwd))) { - wchar_t cnvName[MAX_PATH]; - const wchar_t *s1 = PathFindFileNameW(filename); - int len = wcslen(s1); + TCHAR cnvName[MAX_PATH]; + const TCHAR *s1 = PathFindFileName(filename); + int len = lstrlen(s1); if (len < (end-itr)) { - wcscpy(cnvName, s1); + lstrcpy(cnvName, s1); } else { int n = (len-3-(itr-buffer))/2; - wcsncpy(cnvName, s1, n); - wcscpy(cnvName+n, L"..."); - wcscat(cnvName, s1 + wcslen(s1) - n); + generic_strncpy(cnvName, s1, n); + lstrcpy(cnvName+n, TEXT("...")); + lstrcat(cnvName, s1 + lstrlen(s1) - n); } convertFileName(itr, cnvName); } else { - wchar_t cnvName[MAX_PATH*2]; - const wchar_t *s1 = convertFileName(cnvName, filename); - PathCompactPathExW(itr, filename, len - (itr-buffer), 0); + TCHAR cnvName[MAX_PATH*2]; + const TCHAR *s1 = convertFileName(cnvName, filename); + PathCompactPathEx(itr, filename, len - (itr-buffer), 0); } return buffer; } \ No newline at end of file diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h index 61f3874c..c185c15e 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.h @@ -55,7 +55,7 @@ class WindowsDlg : public SizeableDlg class CachedValue { - std::string fullname; + std::basic_string fullname; int index; }; @@ -101,12 +101,12 @@ class WindowsMenu public: WindowsMenu(); ~WindowsMenu(); - void init(HINSTANCE hInst, HMENU hMainMenu, const char *translation); + void init(HINSTANCE hInst, HMENU hMainMenu, const TCHAR *translation); //void initMenu(HMENU hMenu, ScintillaEditView *pView); void initPopupMenu(HMENU hMenu, DocTabView *pTab); //void uninitPopupMenu(HMENU hMenu, ScintillaEditView *pView); private: - wchar_t *buildFileName(wchar_t *buffer, int len, int pos, const wchar_t *filename); + TCHAR *buildFileName(TCHAR *buffer, int len, int pos, const TCHAR *filename); HMENU _hMenu; }; diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.rc b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.rc index 176f4219..6ee96843 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.rc +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.rc @@ -25,9 +25,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. IDD_WINDOWS DIALOGEX 0, 0, 450, 300 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | DS_MODALFRAME CAPTION "Windows" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN - CONTROL "", IDC_WINDOWS_LIST, "SysListView32", LVS_REPORT | LVS_OWNERDATA | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP, 7, 7, 206, 160 + CONTROL "", IDC_WINDOWS_LIST, TEXT("SysListView32"), LVS_REPORT | LVS_OWNERDATA | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP, 7, 7, 206, 160 DEFPUSHBUTTON "&Activate",IDOK,219,7,60,14 PUSHBUTTON "&Save",IDC_WINDOWS_SAVE,219,26,60,14 PUSHBUTTON "&Close Window(s)",IDC_WINDOWS_CLOSE,219,44,60,14 diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h index 6d943275..dbd18323 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlgRc.h @@ -1,23 +1,3 @@ -//this file is part of notepad++ -//Copyright (C)2003 Don HO -// -//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, write to the Free Software -//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -#ifndef WINDOWSDLG_RC_H -#define WINDOWSDLG_RC_H - #ifdef __GNUC__ #define _WIN32_IE 0x0600 @@ -37,5 +17,3 @@ #define IDM_WINDOW_WINDOWS (IDR_WINDOWS_MENU + 1) #define IDM_WINDOW_MRU_FIRST (IDR_WINDOWS_MENU + 20) #define IDM_WINDOW_MRU_LIMIT (IDR_WINDOWS_MENU + 29) - -#endif //WINDOWSDLG_RC_H diff --git a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp index 443d5973..3fa0b7d4 100644 --- a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp +++ b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.cpp @@ -31,8 +31,8 @@ BOOL CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara { initMacroList(); - char str[512]; - ltoa(m_Times, str, 10); + TCHAR str[512]; + wsprintf(str, TEXT("%d"), m_Times); ::SetDlgItemText(_hSelf, IDC_M_RUN_TIMES, str); switch ( m_Mode ) diff --git a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h index 1dd85dd1..8630caf2 100644 --- a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h +++ b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.h @@ -64,7 +64,7 @@ public : ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_RESETCONTENT, 0, 0); if (::SendMessage(_hParent, WM_ISCURRENTMACRORECORDED, 0, 0)) - ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_ADDSTRING, 0, (LPARAM)"Current recorded macro"); + ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_ADDSTRING, 0, (LPARAM)TEXT("Current recorded macro")); for (size_t i = 0 ; i < macroList.size() ; i++) ::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_ADDSTRING, 0, (LPARAM)macroList[i].getName()); diff --git a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.rc b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.rc index ea7ea868..de6f2166 100644 --- a/PowerEditor/src/WinControls/shortcut/RunMacroDlg.rc +++ b/PowerEditor/src/WinControls/shortcut/RunMacroDlg.rc @@ -27,7 +27,7 @@ STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Run Macro Multiple Times" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN DEFPUSHBUTTON "&Run",IDOK,27,82,50,14 PUSHBUTTON "&Cancel",IDCANCEL,91,82,50,14 diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index 590b7fcb..e7a0c1e4 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -25,127 +25,127 @@ const int KEY_STR_LEN = 16; struct KeyIDNAME { - const char * name; - unsigned char id; + const TCHAR * name; + UCHAR id; }; KeyIDNAME namedKeyArray[] = { -{"None", VK_NULL}, +{TEXT("None"), VK_NULL}, -{"Backspace", VK_BACK}, -{"Tab", VK_TAB}, -{"Enter", VK_RETURN}, -{"Esc", VK_ESCAPE}, -{"Spacebar", VK_SPACE}, +{TEXT("Backspace"), VK_BACK}, +{TEXT("Tab"), VK_TAB}, +{TEXT("Enter"), VK_RETURN}, +{TEXT("Esc"), VK_ESCAPE}, +{TEXT("Spacebar"), VK_SPACE}, -{"Page up", VK_PRIOR}, -{"Page down", VK_NEXT}, -{"End", VK_END}, -{"Home", VK_HOME}, -{"Left", VK_LEFT}, -{"Up", VK_UP}, -{"Right", VK_RIGHT}, -{"Down", VK_DOWN}, +{TEXT("Page up"), VK_PRIOR}, +{TEXT("Page down"), VK_NEXT}, +{TEXT("End"), VK_END}, +{TEXT("Home"), VK_HOME}, +{TEXT("Left"), VK_LEFT}, +{TEXT("Up"), VK_UP}, +{TEXT("Right"), VK_RIGHT}, +{TEXT("Down"), VK_DOWN}, -{"INS", VK_INSERT}, -{"DEL", VK_DELETE}, +{TEXT("INS"), VK_INSERT}, +{TEXT("DEL"), VK_DELETE}, -{"0", VK_0}, -{"1", VK_1}, -{"2", VK_2}, -{"3", VK_3}, -{"4", VK_4}, -{"5", VK_5}, -{"6", VK_6}, -{"7", VK_7}, -{"8", VK_8}, -{"9", VK_9}, -{"A", VK_A}, -{"B", VK_B}, -{"C", VK_C}, -{"D", VK_D}, -{"E", VK_E}, -{"F", VK_F}, -{"G", VK_G}, -{"H", VK_H}, -{"I", VK_I}, -{"J", VK_J}, -{"K", VK_K}, -{"L", VK_L}, -{"M", VK_M}, -{"N", VK_N}, -{"O", VK_O}, -{"P", VK_P}, -{"Q", VK_Q}, -{"R", VK_R}, -{"S", VK_S}, -{"T", VK_T}, -{"U", VK_U}, -{"V", VK_V}, -{"W", VK_W}, -{"X", VK_X}, -{"Y", VK_Y}, -{"Z", VK_Z}, +{TEXT("0"), VK_0}, +{TEXT("1"), VK_1}, +{TEXT("2"), VK_2}, +{TEXT("3"), VK_3}, +{TEXT("4"), VK_4}, +{TEXT("5"), VK_5}, +{TEXT("6"), VK_6}, +{TEXT("7"), VK_7}, +{TEXT("8"), VK_8}, +{TEXT("9"), VK_9}, +{TEXT("A"), VK_A}, +{TEXT("B"), VK_B}, +{TEXT("C"), VK_C}, +{TEXT("D"), VK_D}, +{TEXT("E"), VK_E}, +{TEXT("F"), VK_F}, +{TEXT("G"), VK_G}, +{TEXT("H"), VK_H}, +{TEXT("I"), VK_I}, +{TEXT("J"), VK_J}, +{TEXT("K"), VK_K}, +{TEXT("L"), VK_L}, +{TEXT("M"), VK_M}, +{TEXT("N"), VK_N}, +{TEXT("O"), VK_O}, +{TEXT("P"), VK_P}, +{TEXT("Q"), VK_Q}, +{TEXT("R"), VK_R}, +{TEXT("S"), VK_S}, +{TEXT("T"), VK_T}, +{TEXT("U"), VK_U}, +{TEXT("V"), VK_V}, +{TEXT("W"), VK_W}, +{TEXT("X"), VK_X}, +{TEXT("Y"), VK_Y}, +{TEXT("Z"), VK_Z}, -{"Numpad 0", VK_NUMPAD0}, -{"Numpad 1", VK_NUMPAD1}, -{"Numpad 2", VK_NUMPAD2}, -{"Numpad 3", VK_NUMPAD3}, -{"Numpad 4", VK_NUMPAD4}, -{"Numpad 5", VK_NUMPAD5}, -{"Numpad 6", VK_NUMPAD6}, -{"Numpad 7", VK_NUMPAD7}, -{"Numpad 8", VK_NUMPAD8}, -{"Numpad 9", VK_NUMPAD9}, -{"Num *", VK_MULTIPLY}, -{"Num +", VK_ADD}, -//{"Num Enter", VK_SEPARATOR}, //this one doesnt seem to work -{"Num -", VK_SUBTRACT}, -{"Num .", VK_DECIMAL}, -{"Num /", VK_DIVIDE}, -{"F1", VK_F1}, -{"F2", VK_F2}, -{"F3", VK_F3}, -{"F4", VK_F4}, -{"F5", VK_F5}, -{"F6", VK_F6}, -{"F7", VK_F7}, -{"F8", VK_F8}, -{"F9", VK_F9}, -{"F10", VK_F10}, -{"F11", VK_F11}, -{"F12", VK_F12}, +{TEXT("Numpad 0"), VK_NUMPAD0}, +{TEXT("Numpad 1"), VK_NUMPAD1}, +{TEXT("Numpad 2"), VK_NUMPAD2}, +{TEXT("Numpad 3"), VK_NUMPAD3}, +{TEXT("Numpad 4"), VK_NUMPAD4}, +{TEXT("Numpad 5"), VK_NUMPAD5}, +{TEXT("Numpad 6"), VK_NUMPAD6}, +{TEXT("Numpad 7"), VK_NUMPAD7}, +{TEXT("Numpad 8"), VK_NUMPAD8}, +{TEXT("Numpad 9"), VK_NUMPAD9}, +{TEXT("Num *"), VK_MULTIPLY}, +{TEXT("Num +"), VK_ADD}, +//{TEXT("Num Enter"), VK_SEPARATOR}, //this one doesnt seem to work +{TEXT("Num -"), VK_SUBTRACT}, +{TEXT("Num ."), VK_DECIMAL}, +{TEXT("Num /"), VK_DIVIDE}, +{TEXT("F1"), VK_F1}, +{TEXT("F2"), VK_F2}, +{TEXT("F3"), VK_F3}, +{TEXT("F4"), VK_F4}, +{TEXT("F5"), VK_F5}, +{TEXT("F6"), VK_F6}, +{TEXT("F7"), VK_F7}, +{TEXT("F8"), VK_F8}, +{TEXT("F9"), VK_F9}, +{TEXT("F10"), VK_F10}, +{TEXT("F11"), VK_F11}, +{TEXT("F12"), VK_F12}, -{"~", VK_OEM_3}, -{"-", VK_OEM_MINUS}, -{"=", VK_OEM_PLUS}, -{"[", VK_OEM_4}, -{"]", VK_OEM_6}, -{";", VK_OEM_1}, -{"'", VK_OEM_7}, -{"\\", VK_OEM_5}, -{",", VK_OEM_COMMA}, -{".", VK_OEM_PERIOD}, -{"/", VK_OEM_2}, +{TEXT("~"), VK_OEM_3}, +{TEXT("-"), VK_OEM_MINUS}, +{TEXT("="), VK_OEM_PLUS}, +{TEXT("["), VK_OEM_4}, +{TEXT("]"), VK_OEM_6}, +{TEXT(";"), VK_OEM_1}, +{TEXT("'"), VK_OEM_7}, +{TEXT("\\"), VK_OEM_5}, +{TEXT(","), VK_OEM_COMMA}, +{TEXT("."), VK_OEM_PERIOD}, +{TEXT("/"), VK_OEM_2}, -{"<>", VK_OEM_102}, +{TEXT("<>"), VK_OEM_102}, }; #define nrKeys sizeof(namedKeyArray)/sizeof(KeyIDNAME) /* -char vKeyArray[][KEY_STR_LEN] = \ -{"", "BACKSPACE", "TAB", "ENTER", "PAUSE", "CAPS LOCK", "ESC", "SPACEBAR", "PAGE UP", "PAGE DOWN",\ -"END", "HOME", "LEFT ARROW", "UP ARROW", "RIGHT ARROW", "DOWN ARROW", "INS", "DEL",\ -"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",\ -"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",\ -"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",\ -"NUMPAD0", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD4",\ -"NUMPAD5", "NUMPAD6", "NUMPAD7", "NUMPAD8", "NUMPAD9",\ -"F1", "F2", "F3", "F4", "F5", "F6",\ -"F7", "F8", "F9", "F10", "F11", "F12"}; +TCHAR vKeyArray[][KEY_STR_LEN] = \ +{TEXT(""), TEXT("BACKSPACE"), TEXT("TAB"), TEXT("ENTER"), TEXT("PAUSE"), TEXT("CAPS LOCK"), TEXT("ESC"), TEXT("SPACEBAR"), TEXT("PAGE UP"), TEXT("PAGE DOWN"),\ +"END", TEXT("HOME"), TEXT("LEFT ARROW"), TEXT("UP ARROW"), TEXT("RIGHT ARROW"), TEXT("DOWN ARROW"), TEXT("INS"), TEXT("DEL"),\ +"0", TEXT("1"), TEXT("2"), TEXT("3"), TEXT("4"), TEXT("5"), TEXT("6"), TEXT("7"), TEXT("8"), TEXT("9"),\ +"A", TEXT("B"), TEXT("C"), TEXT("D"), TEXT("E"), TEXT("F"), TEXT("G"), TEXT("H"), TEXT("I"), TEXT("J"), TEXT("K"), TEXT("L"), TEXT("M"),\ +"N", TEXT("O"), TEXT("P"), TEXT("Q"), TEXT("R"), TEXT("S"), TEXT("T"), TEXT("U"), TEXT("V"), TEXT("W"), TEXT("X"), TEXT("Y"), TEXT("Z"),\ +"NUMPAD0", TEXT("NUMPAD1"), TEXT("NUMPAD2"), TEXT("NUMPAD3"), TEXT("NUMPAD4"),\ +"NUMPAD5", TEXT("NUMPAD6"), TEXT("NUMPAD7"), TEXT("NUMPAD8"), TEXT("NUMPAD9"),\ +"F1", TEXT("F2"), TEXT("F3"), TEXT("F4"), TEXT("F5"), TEXT("F6"),\ +"F7", TEXT("F8"), TEXT("F9"), TEXT("F10"), TEXT("F11"), TEXT("F12")}; -unsigned char vkeyValue[] = {\ +UCHAR vkeyValue[] = {\ 0x00, 0x08, 0x09, 0x0D, 0x13, 0x14, 0x1B, 0x20, 0x21, 0x22,\ 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x2D, 0x2E, 0x30, 0x31,\ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42,\ @@ -156,26 +156,26 @@ unsigned char vkeyValue[] = {\ 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B}; */ -string Shortcut::toString() const +basic_string Shortcut::toString() const { - string sc = ""; + basic_string sc = TEXT(""); if (!isEnabled()) return sc; if (_keyCombo._isCtrl) - sc += "Ctrl+"; + sc += TEXT("Ctrl+"); if (_keyCombo._isAlt) - sc += "Alt+"; + sc += TEXT("Alt+"); if (_keyCombo._isShift) - sc += "Shift+"; + sc += TEXT("Shift+"); - string keyString; + basic_string keyString; getKeyStrFromVal(_keyCombo._key, keyString); sc += keyString; return sc; } -void Shortcut::setName(const char * name) { +void Shortcut::setName(const TCHAR * name) { lstrcpyn(_menuName, name, nameLenMax); lstrcpyn(_name, name, nameLenMax); int i = 0, j = 0; @@ -195,24 +195,24 @@ void Shortcut::setName(const char * name) { _name[i] = 0; } -string ScintillaKeyMap::toString() const { +basic_string ScintillaKeyMap::toString() const { return toString(0); } -string ScintillaKeyMap::toString(int index) const { - string sc = ""; +basic_string ScintillaKeyMap::toString(int index) const { + basic_string sc = TEXT(""); if (!isEnabled()) return sc; KeyCombo kc = _keyCombos[index]; if (kc._isCtrl) - sc += "Ctrl+"; + sc += TEXT("Ctrl+"); if (kc._isAlt) - sc += "Alt+"; + sc += TEXT("Alt+"); if (kc._isShift) - sc += "Shift+"; + sc += TEXT("Shift+"); - string keyString; + basic_string keyString; getKeyStrFromVal(kc._key, keyString); sc += keyString; return sc; @@ -261,9 +261,9 @@ size_t ScintillaKeyMap::getSize() const { return size; } -void getKeyStrFromVal(unsigned char keyVal, string & str) +void getKeyStrFromVal(UCHAR keyVal, basic_string & str) { - str = ""; + str = TEXT(""); bool found = false; int i; for (i = 0; i < nrKeys; i++) { @@ -275,10 +275,10 @@ void getKeyStrFromVal(unsigned char keyVal, string & str) if (found) str = namedKeyArray[i].name; else - str = "Unlisted"; + str = TEXT("Unlisted"); } -void getNameStrFromCmd(DWORD cmd, string & str) +void getNameStrFromCmd(DWORD cmd, basic_string & str) { if ((cmd >= ID_MACRO) && (cmd < ID_MACRO_LIMIT)) { @@ -309,13 +309,13 @@ void getNameStrFromCmd(DWORD cmd, string & str) else { HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL); - char cmdName[64]; + TCHAR cmdName[64]; int nbChar = ::GetMenuString((HMENU)::SendMessage(hNotepad_plus, NPPM_INTERNAL_GETMENU, 0, 0), cmd, cmdName, sizeof(cmdName), MF_BYCOMMAND); if (!nbChar) return; bool fin = false; int j = 0; - size_t len = strlen(cmdName); + size_t len = lstrlen(cmdName); for (size_t i = 0 ; i < len; i++) { switch(cmdName[i]) @@ -396,7 +396,7 @@ BOOL CALLBACK Shortcut::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) _keyCombo._isCtrl = _keyCombo._isAlt = _keyCombo._isShift = false; } if (_canModifyName) { - char editName[nameLenMax]; + TCHAR editName[nameLenMax]; ::SendDlgItemMessage(_hSelf, IDC_NAME_EDIT, WM_GETTEXT, nameLenMax, (LPARAM)editName); setName(editName); } @@ -552,7 +552,7 @@ recordedMacroStep::recordedMacroStep(int iMessage, long wParam, long lParam) case SCI_STYLESETFONT : case SCI_SEARCHNEXT : case SCI_SEARCHPREV : - sParameter = *reinterpret_cast(lParameter); + sParameter = *reinterpret_cast(lParameter); MacroType = mtUseSParameter; lParameter = 0; break; @@ -635,7 +635,7 @@ void ScintillaAccelerator::updateKey(ScintillaKeyMap skmOld, ScintillaKeyMap skm void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id) { NppParameters *pNppParam = NppParameters::getInstance(); - char cmdName[64]; + TCHAR cmdName[64]; ::GetMenuString(_hAccelMenu, id, cmdName, sizeof(cmdName), MF_BYCOMMAND); int i = 0; while(cmdName[i] != 0) { @@ -645,10 +645,10 @@ void ScintillaAccelerator::updateMenuItemByID(ScintillaKeyMap skm, int id) { } i++; } - string menuItem = cmdName; + basic_string menuItem = cmdName; if (skm.isEnabled()) { - menuItem += "\t"; - //menuItem += "Sc:"; //sc: scintilla shortcut + menuItem += TEXT("\t"); + //menuItem += TEXT("Sc:"); //sc: scintilla shortcut menuItem += skm.toString(); } ::ModifyMenu(_hAccelMenu, id, MF_BYCOMMAND, id, menuItem.c_str()); @@ -764,7 +764,7 @@ BOOL CALLBACK ScintillaKeyMap::run_dlgProc(UINT Message, WPARAM wParam, LPARAM l if (res > -1) { if (res == oldsize) { ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_INSERTSTRING, -1, (LPARAM)toString(res).c_str()); - }else { //update current string, can happen if it was disabled + }else { //update current basic_string, can happen if it was disabled updateListItem(res); } ::SendDlgItemMessage(_hSelf, IDC_LIST_KEYS, LB_SETCURSEL, res, 0); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.h b/PowerEditor/src/WinControls/shortcut/shortcut.h index 10c6ffc9..2f8ac612 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.h +++ b/PowerEditor/src/WinControls/shortcut/shortcut.h @@ -31,8 +31,8 @@ const size_t nameLenMax = 64; class NppParameters; -void getKeyStrFromVal(unsigned char keyVal, string & str); -void getNameStrFromCmd(DWORD cmd, string & str); +void getKeyStrFromVal(UCHAR keyVal, basic_string & str); +void getNameStrFromCmd(DWORD cmd, basic_string & str); static int keyTranslate(int keyIn) { switch (keyIn) { case VK_DOWN: return SCK_DOWN; @@ -65,25 +65,25 @@ struct KeyCombo { bool _isCtrl; bool _isAlt; bool _isShift; - unsigned char _key; + UCHAR _key; }; class Shortcut : public StaticDialog { public: Shortcut(): _canModifyName(false) { - setName(""); + setName(TEXT("")); _keyCombo._isCtrl = false; _keyCombo._isAlt = false; _keyCombo._isShift = false; _keyCombo._key = 0; }; - Shortcut(const char *name, bool isCtrl, bool isAlt, bool isShift, unsigned char key) : _canModifyName(false) { + Shortcut(const TCHAR *name, bool isCtrl, bool isAlt, bool isShift, UCHAR key) : _canModifyName(false) { _name[0] = '\0'; if (name) { setName(name); } else { - setName(""); + setName(TEXT("")); } _keyCombo._isCtrl = isCtrl; _keyCombo._isAlt = isAlt; @@ -112,7 +112,7 @@ public: return *this; } friend inline const bool operator==(const Shortcut & a, const Shortcut & b) { - return ((strcmp(a.getMenuName(), b.getMenuName()) == 0) && + return ((lstrcmp(a.getMenuName(), b.getMenuName()) == 0) && (a._keyCombo._isCtrl == b._keyCombo._isCtrl) && (a._keyCombo._isAlt == b._keyCombo._isAlt) && (a._keyCombo._isShift == b._keyCombo._isShift) && @@ -143,12 +143,12 @@ public: return (_keyCombo._key != 0); }; - virtual string toString() const; //the hotkey part - string toMenuItemString() const { //string suitable for menu - string str = _menuName; + virtual basic_string toString() const; //the hotkey part + basic_string toMenuItemString() const { //basic_string suitable for menu + basic_string str = _menuName; if(isEnabled()) { - str += "\t"; + str += TEXT("\t"); str += toString(); } return str; @@ -157,22 +157,22 @@ public: return _keyCombo; }; - const char * getName() const { + const TCHAR * getName() const { return _name; }; - const char * getMenuName() const { + const TCHAR * getMenuName() const { return _menuName; } - void setName(const char * name); + void setName(const TCHAR * name); protected : KeyCombo _keyCombo; virtual BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); bool _canModifyName; - char _name[nameLenMax]; //normal name is plain text (for display purposes) - char _menuName[nameLenMax]; //menu name has ampersands for quick keys + TCHAR _name[nameLenMax]; //normal name is plain text (for display purposes) + TCHAR _menuName[nameLenMax]; //menu name has ampersands for quick keys }; class CommandShortcut : public Shortcut { @@ -214,8 +214,8 @@ public: bool isEnabled() const; size_t getSize() const; - string toString() const; - string toString(int index) const; + basic_string toString() const; + basic_string toString(int index) const; int doDialog() { return ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_SHORTCUTSCINT_DLG), _hParent, (DLGPROC)dlgProc, (LPARAM)this); @@ -265,15 +265,15 @@ struct recordedMacroStep { int message; long wParameter; long lParameter; - string sParameter; + basic_string sParameter; MacroTypeIndex MacroType; recordedMacroStep(int iMessage, long wParam, long lParam); recordedMacroStep(int iCommandID) : message(0), wParameter(iCommandID), lParameter(0), MacroType(mtMenuCommand) {}; - recordedMacroStep(int type, int iMessage, long wParam, long lParam, const char *sParam) + recordedMacroStep(int type, int iMessage, long wParam, long lParam, const TCHAR *sParam) : message(iMessage), wParameter(wParam), lParameter(lParam), MacroType(MacroTypeIndex(type)){ - sParameter = *reinterpret_cast(sParam); + sParameter = *reinterpret_cast(sParam); }; bool isValid() const { return true; @@ -297,18 +297,18 @@ private: class UserCommand : public CommandShortcut { friend class NppParameters; public: - UserCommand(Shortcut sc, const char *cmd, int id) : CommandShortcut(sc, id), _cmd(cmd) {_canModifyName = true;}; - const char* getCmd() const {return _cmd.c_str();}; + UserCommand(Shortcut sc, const TCHAR *cmd, int id) : CommandShortcut(sc, id), _cmd(cmd) {_canModifyName = true;}; + const TCHAR* getCmd() const {return _cmd.c_str();}; private: - string _cmd; + basic_string _cmd; }; class PluginCmdShortcut : public CommandShortcut { //friend class NppParameters; public: - PluginCmdShortcut(Shortcut sc, int id, const char *moduleName, unsigned short internalID) :\ + PluginCmdShortcut(Shortcut sc, int id, const TCHAR *moduleName, unsigned short internalID) :\ CommandShortcut(sc, id), _id(id), _internalID(internalID) { - strcpy(_moduleName, moduleName); + lstrcpy(_moduleName, moduleName); }; bool isValid() const { if (!Shortcut::isValid()) @@ -317,13 +317,13 @@ public: return false; return true; } - const char * getModuleName() const {return _moduleName;}; + const TCHAR * getModuleName() const {return _moduleName;}; int getInternalID() const {return _internalID;}; unsigned long getID() const {return _id;}; private : unsigned long _id; - char _moduleName[nameLenMax]; + TCHAR _moduleName[nameLenMax]; int _internalID; }; diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.rc b/PowerEditor/src/WinControls/shortcut/shortcut.rc index 42b2008d..65f0eef8 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.rc +++ b/PowerEditor/src/WinControls/shortcut/shortcut.rc @@ -29,7 +29,7 @@ STYLE DS_SETFONT | /*DS_MODALFRAME |*/ DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Shortcut" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN CONTROL "CTRL",IDC_CTRL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,30,33,10 @@ -53,7 +53,7 @@ IDD_SHORTCUTSCINT_DLG DIALOGEX 0, 0, 286, 114 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_TOOLWINDOW CAPTION "Shortcut" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 +FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1 BEGIN CONTROL "CTRL",IDC_CTRL_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,27,33,10 diff --git a/PowerEditor/src/lastRecentFileList.cpp b/PowerEditor/src/lastRecentFileList.cpp index ecf10f28..feb204dd 100644 --- a/PowerEditor/src/lastRecentFileList.cpp +++ b/PowerEditor/src/lastRecentFileList.cpp @@ -17,7 +17,6 @@ #include "lastRecentFileList.h" #include "menuCmdID.h" -#include "UniConversion.h" void LastRecentFileList::initMenu(HMENU hMenu, int idBase, int posBase) { @@ -31,11 +30,11 @@ void LastRecentFileList::initMenu(HMENU hMenu, int idBase, int posBase) { void LastRecentFileList::updateMenu() { if (!_hasSeparators && _size > 0) { //add separators - const char * nativeLangOpenAllFiles = (NppParameters::getInstance())->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE); - const char * nativeLangCleanFilesList = (NppParameters::getInstance())->getNativeLangMenuString(IDM_CLEAN_RECENT_FILE_LIST); + const TCHAR * nativeLangOpenAllFiles = (NppParameters::getInstance())->getNativeLangMenuString(IDM_OPEN_ALL_RECENT_FILE); + const TCHAR * nativeLangCleanFilesList = (NppParameters::getInstance())->getNativeLangMenuString(IDM_CLEAN_RECENT_FILE_LIST); - const char * openAllFileStr = nativeLangOpenAllFiles?nativeLangOpenAllFiles:"Open All Recent Files"; - const char * cleanFileListStr = nativeLangCleanFilesList?nativeLangCleanFilesList:"Clean Recent Files List"; + const TCHAR * openAllFileStr = nativeLangOpenAllFiles?nativeLangOpenAllFiles:TEXT("Open All Recent Files"); + const TCHAR * cleanFileListStr = nativeLangCleanFilesList?nativeLangCleanFilesList:TEXT("Clean Recent Files List"); ::InsertMenu(_hMenu, _posBase + 0, MF_BYPOSITION, UINT(-1), 0); ::InsertMenu(_hMenu, _posBase + 1, MF_BYPOSITION, IDM_OPEN_ALL_RECENT_FILE, openAllFileStr); ::InsertMenu(_hMenu, _posBase + 2, MF_BYPOSITION, IDM_CLEAN_RECENT_FILE_LIST, cleanFileListStr); @@ -56,22 +55,21 @@ void LastRecentFileList::updateMenu() { ::RemoveMenu(_hMenu, _lrfl.at(i)._id, MF_BYCOMMAND); } //Then readd them, so everything stays in sync - char indexBuffer[4]; + TCHAR indexBuffer[4]; for(int j = 0; j < _size; j++) { - std::string menuString = ""; + std::basic_string menuString = TEXT(""); if (j < 9) { //first 9 have accelerator (0 unused) - menuString += "&"; + menuString += TEXT("&"); } - itoa(j+1, indexBuffer, 10);//one based numbering + wsprintf(indexBuffer, TEXT("%d"), j+1);//one based numbering menuString += indexBuffer; - menuString += " "; + menuString += TEXT(" "); menuString += _lrfl.at(j)._name; - std::wstring menuStringW = string2wstring(menuString); - ::InsertMenuW(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, menuStringW.c_str()); + ::InsertMenu(_hMenu, _posBase + j, MF_BYPOSITION, _lrfl.at(j)._id, menuString.c_str()); } } -void LastRecentFileList::add(const char *fn) { +void LastRecentFileList::add(const TCHAR *fn) { if (_userMax == 0 || _locked) return; @@ -93,7 +91,7 @@ void LastRecentFileList::add(const char *fn) { updateMenu(); }; -void LastRecentFileList::remove(const char *fn) { +void LastRecentFileList::remove(const TCHAR *fn) { int index = find(fn); if (index != -1) remove(index); @@ -126,7 +124,7 @@ void LastRecentFileList::clear() { } -std::string & LastRecentFileList::getItem(int id) { +std::basic_string & LastRecentFileList::getItem(int id) { int i = 0; for(; i < _size; i++) { if (_lrfl.at(i)._id == id) @@ -137,7 +135,7 @@ std::string & LastRecentFileList::getItem(int id) { return _lrfl.at(i)._name; //if not found, return first }; -std::string & LastRecentFileList::getIndex(int index) { +std::basic_string & LastRecentFileList::getIndex(int index) { return _lrfl.at(index)._name; //if not found, return first }; @@ -173,10 +171,10 @@ void LastRecentFileList::saveLRFL() { -int LastRecentFileList::find(const char *fn) { +int LastRecentFileList::find(const TCHAR *fn) { int i = 0; for(int i = 0; i < _size; i++) { - if (!strcmpi(_lrfl.at(i)._name.c_str(), fn)) { + if (!lstrcmpi(_lrfl.at(i)._name.c_str(), fn)) { return i; } } diff --git a/PowerEditor/src/lastRecentFileList.h b/PowerEditor/src/lastRecentFileList.h index 9228e7d1..506fb010 100644 --- a/PowerEditor/src/lastRecentFileList.h +++ b/PowerEditor/src/lastRecentFileList.h @@ -8,8 +8,8 @@ struct RecentItem { int _id; - std::string _name; - RecentItem(const char * name) : _name(name) {}; + std::basic_string _name; + RecentItem(const TCHAR * name) : _name(name) {}; }; typedef std::deque recentList; @@ -25,8 +25,8 @@ public : void updateMenu(); - void add(const char *fn); - void remove(const char *fn); + void add(const TCHAR *fn); + void remove(const TCHAR *fn); void remove(int index); void clear(); @@ -42,8 +42,8 @@ public : return _userMax; }; - std::string & getItem(int id); //use menu id - std::string & getIndex(int index); //use menu id + std::basic_string & getItem(int id); //use menu id + std::basic_string & getIndex(int index); //use menu id void setUserMaxNbLRF(int size); @@ -65,7 +65,7 @@ private: bool _hasSeparators; bool _locked; - int find(const char *fn); + int find(const TCHAR *fn); int popFirstAvailableID(); void setAvailable(int id); diff --git a/PowerEditor/src/lesDlgs.h b/PowerEditor/src/lesDlgs.h index 7decb9a0..8eb4d933 100644 --- a/PowerEditor/src/lesDlgs.h +++ b/PowerEditor/src/lesDlgs.h @@ -24,10 +24,10 @@ class ValueDlg : public StaticDialog { public : ValueDlg() : StaticDialog(), _nbNumber(DEFAULT_NB_NUMBER) {}; - void init(HINSTANCE hInst, HWND parent, int valueToSet, char *text) { + void init(HINSTANCE hInst, HWND parent, int valueToSet, const TCHAR *text) { Window::init(hInst, parent); _defaultValue = valueToSet; - strcpy(_name, text); + lstrcpy(_name, text); }; int doDialog(POINT p, bool isRTL = false) { @@ -123,7 +123,7 @@ protected : private : int _nbNumber; int _defaultValue; - char _name[32]; + TCHAR _name[32]; POINT _p; }; diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 0e3b6ee8..1ea9925e 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -18,9 +18,15 @@ #ifndef RESOURCE_H #define RESOURCE_H -#define NOTEPAD_PLUS_VERSION "Notepad++ v5.0.3" -#define VERSION_VALUE "5.03\0" // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 -#define VERSION_DIGITALVALUE 5, 0, 3, 0 +#define NOTEPAD_PLUS_VERSION TEXT("Notepad++ v5.1") +#define VERSION_VALUE TEXT("5.1\0") // should be X.Y : ie. if VERSION_DIGITALVALUE == 4, 7, 1, 0 , then X = 4, Y = 71 +#define VERSION_DIGITALVALUE 5, 1, 0, 0 + +#ifdef UNICODE +#define UNICODE_ANSI_MODE TEXT("(UNICODE)") +#else +#define UNICODE_ANSI_MODE TEXT("(ANSI)") +#endif #ifndef IDC_STATIC #define IDC_STATIC -1 diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 12d0d001..4bd2264a 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -22,19 +22,19 @@ #include //default C++ exception #include "Win32Exception.h" //Win32 exception -typedef std::vector ParamVector; +typedef std::vector ParamVector; -bool checkSingleFile(const wchar_t * commandLine) { - wchar_t fullpath[MAX_PATH]; - ::GetFullPathNameW(commandLine, MAX_PATH, fullpath, NULL); - if (::PathFileExistsW(fullpath)) { +bool checkSingleFile(const TCHAR * commandLine) { + TCHAR fullpath[MAX_PATH]; + ::GetFullPathName(commandLine, MAX_PATH, fullpath, NULL); + if (::PathFileExists(fullpath)) { return true; } return false; } -void parseCommandLine(wchar_t * commandLine, ParamVector & paramVector) { +void parseCommandLine(TCHAR * commandLine, ParamVector & paramVector) { bool isFile = checkSingleFile(commandLine); //if the commandline specifies only a file, open it as such if (isFile) { paramVector.push_back(commandLine); @@ -43,12 +43,12 @@ void parseCommandLine(wchar_t * commandLine, ParamVector & paramVector) { bool isInFile = false; bool isInWhiteSpace = true; paramVector.clear(); - size_t commandLength = wcslen(commandLine); + size_t commandLength = lstrlen(commandLine); for(size_t i = 0; i < commandLength; i++) { switch(commandLine[i]) { case '\"': { //quoted filename, ignore any following whitespace if (!isInFile) { //" will always be treated as start or end of param, in case the user forgot to add an space - paramVector.push_back(commandLine+i+1); //add next param(since zero terminated string original, no overflow of +1) + paramVector.push_back(commandLine+i+1); //add next param(since zero terminated basic_string original, no overflow of +1) } isInFile = !isInFile; isInWhiteSpace = false; @@ -61,7 +61,7 @@ void parseCommandLine(wchar_t * commandLine, ParamVector & paramVector) { if (!isInFile) commandLine[i] = 0; //zap spaces into zero terminators, unless its part of a filename break; } - default: { //default char, if beginning of word, add it + default: { //default TCHAR, if beginning of word, add it if (!isInFile && isInWhiteSpace) { paramVector.push_back(commandLine+i); //add next param isInWhiteSpace = false; @@ -69,15 +69,15 @@ void parseCommandLine(wchar_t * commandLine, ParamVector & paramVector) { break; } } } - //the commandline string is now a list of zero terminated strings concatenated, and the vector contains all the substrings + //the commandline basic_string is now a list of zero terminated strings concatenated, and the vector contains all the substrings } -bool isInList(const wchar_t *token2Find, ParamVector & params) { +bool isInList(const TCHAR *token2Find, ParamVector & params) { int nrItems = params.size(); for (int i = 0; i < nrItems; i++) { - if (!wcscmp(token2Find, params.at(i))) { + if (!lstrcmp(token2Find, params.at(i))) { params.erase(params.begin() + i); return true; } @@ -85,14 +85,14 @@ bool isInList(const wchar_t *token2Find, ParamVector & params) { return false; }; -bool getParamVal(wchar_t c, ParamVector & params, wstring & value) { - value = L""; +bool getParamVal(TCHAR c, ParamVector & params, basic_string & value) { + value = TEXT(""); int nrItems = params.size(); for (int i = 0; i < nrItems; i++) { - const wchar_t * token = params.at(i); - if (token[0] == '-' && wcslen(token) >= 2 && token[1] == c) { //dash, and enough chars + const TCHAR * token = params.at(i); + if (token[0] == '-' && lstrlen(token) >= 2 && token[1] == c) { //dash, and enough chars value = (token+2); params.erase(params.begin() + i); return true; @@ -102,39 +102,37 @@ bool getParamVal(wchar_t c, ParamVector & params, wstring & value) { } LangType getLangTypeFromParam(ParamVector & params) { - wstring langStr; + basic_string langStr; if (!getParamVal('l', params, langStr)) return L_EXTERNAL; - char lang[MAX_PATH]; - wchar2char(langStr.c_str(), lang); - return NppParameters::getLangIDFromStr(lang); + return NppParameters::getLangIDFromStr(langStr.c_str()); }; int getLn2GoFromParam(ParamVector & params) { - wstring lineNumStr; + basic_string lineNumStr; if (!getParamVal('n', params, lineNumStr)) return -1; - return _wtoi(lineNumStr.c_str()); + return generic_atoi(lineNumStr.c_str()); }; -const wchar_t FLAG_MULTI_INSTANCE[] = L"-multiInst"; -const wchar_t FLAG_NO_PLUGIN[] = L"-noPlugin"; -const wchar_t FLAG_READONLY[] = L"-ro"; -const wchar_t FLAG_NOSESSION[] = L"-nosession"; -const wchar_t FLAG_NOTABBAR[] = L"-notabbar"; +const TCHAR FLAG_MULTI_INSTANCE[] = TEXT("-multiInst"); +const TCHAR FLAG_NO_PLUGIN[] = TEXT("-noPlugin"); +const TCHAR FLAG_READONLY[] = TEXT("-ro"); +const TCHAR FLAG_NOSESSION[] = TEXT("-nosession"); +const TCHAR FLAG_NOTABBAR[] = TEXT("-notabbar"); void doException(Notepad_plus & notepad_plus_plus); -int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmdShow) +int WINAPI NppMainEntry(HINSTANCE hInstance, HINSTANCE, TCHAR * cmdLine, int nCmdShow) { bool TheFirstOne = true; ::SetLastError(NO_ERROR); - ::CreateMutex(NULL, false, "nppInstance"); + ::CreateMutex(NULL, false, TEXT("nppInstance")); if (::GetLastError() == ERROR_ALREADY_EXISTS) TheFirstOne = false; ParamVector params; - parseCommandLine(lpszCmdLine, params); + parseCommandLine(cmdLine, params); CmdLineParams cmdLineParams; bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params); @@ -154,25 +152,30 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmd cmdLineParams._isNoSession = true; } - wstring quotFileName = L""; + basic_string quotFileName = TEXT(""); // tell the running instance the FULL path to the new files to load size_t nrFilesToOpen = params.size(); - const wchar_t * currentFile; - wchar_t fullFileName[MAX_PATH]; + const TCHAR * currentFile; + TCHAR fullFileName[MAX_PATH]; //TODO: try merging the flenames and see if it exists, user may have typed a single spaced filename without quotes - for(size_t i = 0; i < nrFilesToOpen; i++) { + for(size_t i = 0; i < nrFilesToOpen; i++) + { currentFile = params.at(i); //check if relative or full path. Relative paths dont have a colon for driveletter - BOOL isRelative = ::PathIsRelativeW(currentFile); - quotFileName += L"\""; - if (isRelative) { - ::GetFullPathNameW(currentFile, MAX_PATH, fullFileName, NULL); + BOOL isRelative = ::PathIsRelative(currentFile); + quotFileName += TEXT("\""); + if (isRelative) + { + ::GetFullPathName(currentFile, MAX_PATH, fullFileName, NULL); quotFileName += fullFileName; - } else { + } + else + { quotFileName += currentFile; } - quotFileName += L"\" "; + quotFileName += TEXT("\" "); } + if ((!isMultiInst) && (!TheFirstOne)) { HWND hNotepad_plus = ::FindWindow(Notepad_plus::getClassName(), NULL); @@ -183,7 +186,6 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmd pNppParameters->destroyInstance(); MainFileManager->destroyInstance(); - int sw; if (::IsZoomed(hNotepad_plus)) @@ -208,10 +210,10 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmd COPYDATASTRUCT fileNamesData; fileNamesData.dwData = COPYDATA_FILENAMES; fileNamesData.lpData = (void *)quotFileName.c_str(); - fileNamesData.cbData = long((quotFileName.length() + 1) * sizeof(wchar_t)); + fileNamesData.cbData = long(quotFileName.length() + 1)*(sizeof(TCHAR)); - ::SendMessageW(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)¶mData); - ::SendMessageW(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&fileNamesData); + ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)¶mData); + ::SendMessage(hNotepad_plus, WM_COPYDATA, (WPARAM)hInstance, (LPARAM)&fileNamesData); } return 0; } @@ -221,12 +223,12 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmd NppGUI & nppGui = (NppGUI &)pNppParameters->getNppGUI(); - string updaterDir = pNppParameters->getNppPath(); - updaterDir += "\\updater\\"; + basic_string updaterDir = pNppParameters->getNppPath(); + updaterDir += TEXT("\\updater\\"); - string updaterFullPath = updaterDir + "gup.exe"; + basic_string updaterFullPath = updaterDir + TEXT("gup.exe"); - string version = "-v"; + basic_string version = TEXT("-v"); version += VERSION_VALUE; winVer curWinVer = notepad_plus_plus.getWinVersion(); @@ -275,23 +277,23 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmd } } catch(int i) { if (i == 106901) - ::MessageBox(NULL, "Scintilla.init is failed!", "Notepad++ Exception: 106901", MB_OK); + ::MessageBox(NULL, TEXT("Scintilla.init is failed!"), TEXT("Notepad++ Exception: 106901"), MB_OK); else { - char str[50] = "God Damned Exception : "; - char code[10]; - itoa(i, code, 10); - ::MessageBox(NULL, strcat(str, code), "Notepad++ Exception", MB_OK); + TCHAR str[50] = TEXT("God Damned Exception : "); + TCHAR code[10]; + wsprintf(code, TEXT("%d"), i); + ::MessageBox(NULL, lstrcat(str, code), TEXT("Notepad++ Exception"), MB_OK); } doException(notepad_plus_plus); } catch (const Win32Exception & ex) { - char message[1024]; //TODO: sane number - sprintf(message, "An exception occured. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n" - "Code:\t0x%08X\r\nType:\t%s\r\nException address: 0x%08X", + TCHAR message[1024]; //TODO: sane number + wsprintf(message, TEXT("An exception occured. Notepad++ cannot recover and must be shut down.\r\nThe exception details are as follows:\r\n") + TEXT("Code:\t0x%08X\r\nType:\t%s\r\nException address: 0x%08X"), ex.code(), ex.what(), ex.where()); - ::MessageBox(NULL, message, "Win32Exception", MB_OK | MB_ICONERROR); + ::MessageBox(NULL, message, TEXT("Win32Exception"), MB_OK | MB_ICONERROR); doException(notepad_plus_plus); } catch(std::exception ex) { - ::MessageBox(NULL, ex.what(), "C++ Exception", MB_OK); + ::MessageBoxA(NULL, ex.what(), "C++ Exception", MB_OK); doException(notepad_plus_plus); } catch(...) { //this shouldnt ever have to happen doException(notepad_plus_plus); @@ -302,11 +304,11 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpszCmdLine, int nCmd void doException(Notepad_plus & notepad_plus_plus) { Win32Exception::removeHandler(); //disable exception handler after excpetion, we dont want corrupt data structurs to crash the exception handler - ::MessageBox(NULL, "Notepad++ will attempt to save any unsaved data. However, dataloss is very likely.", "Recovery initiating", MB_OK | MB_ICONINFORMATION); + ::MessageBox(NULL, TEXT("Notepad++ will attempt to save any unsaved data. However, dataloss is very likely."), TEXT("Recovery initiating"), MB_OK | MB_ICONINFORMATION); bool res = notepad_plus_plus.emergency(); if (res) { - ::MessageBox(NULL, "Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at C:\\N++RECOV", "Recovery success", MB_OK | MB_ICONINFORMATION); + ::MessageBox(NULL, TEXT("Notepad++ was able to successfully recover some unsaved documents, or nothing to be saved could be found.\r\nYou can find the results at C:\\N++RECOV"), TEXT("Recovery success"), MB_OK | MB_ICONINFORMATION); } else { - ::MessageBox(NULL, "Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data.", "Recovery failure", MB_OK | MB_ICONERROR); + ::MessageBox(NULL, TEXT("Unfortunatly, Notepad++ was not able to save your work. We are sorry for any lost data."), TEXT("Recovery failure"), MB_OK | MB_ICONERROR); } } diff --git a/PowerEditor/src/xpm_icons.h b/PowerEditor/src/xpm_icons.h index aa9e65e8..6881e585 100644 --- a/PowerEditor/src/xpm_icons.h +++ b/PowerEditor/src/xpm_icons.h @@ -15,9 +15,6 @@ //along with this program; if not, write to the Free Software //Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -#ifndef XPMICONS_H -#define XPMICONS_H - static char * acTop_xpm[] = { "12 12 56 1", " c #FFFFFF", @@ -148,7 +145,7 @@ static char * acBottom_xpm[] = { "o c #1233B4", " .+ ", " @#$ ", -" %&*= ", +" %&*= L", " -;>,' ", " )!>~{] ", " ^/(_:<[ ", @@ -241,5 +238,3 @@ static char * bookmark_xpm[] = { " r*@s(tut(s@*r ", " v*w{x&x{w*v ", " l*yyy*l "}; - -#endif //XPMICONS_H diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 0a93cbe7..0775c11b 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -1,11 +1,12 @@ - - - - @@ -719,10 +715,6 @@ RelativePath="..\src\WinControls\AboutDlg\URLCtrl.h" > - -