[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
This commit is contained in:
donho 2008-09-06 00:53:53 +00:00
parent 90f5488b59
commit 147278ac61
134 changed files with 5423 additions and 4881 deletions

View File

@ -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"

View File

@ -4,28 +4,6 @@
//By Bennett
//Formatting Slightly modified for N++
/*
this file is part of Notepad++
Copyright (C)2003 Don HO <donho@altern.org>
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 <exception>
@ -63,5 +41,3 @@ private:
friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info);
};
#endif //WIN32EXCEPTION_H

View File

@ -18,19 +18,19 @@
#ifndef FILENAME_STRING_SPLITTER_H
#define FILENAME_STRING_SPLITTER_H
typedef std::vector<std::wstring> stringVectorW;
typedef std::vector<std::basic_string<TCHAR>> 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<TCHAR>(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<TCHAR>(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<TCHAR>(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

View File

@ -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<TCHAR> operation success
// Otherwise (allocated array size is too small) FALSE
#define NPPM_GETCURRENTLINE (RUNCOMMAND_USER + CURRENT_LINE)

View File

@ -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

View File

@ -18,34 +18,34 @@
#include <shlwapi.h>
#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<string> dllNames;
const char *pNppPath = (NppParameters::getInstance())->getNppPath();
vector<basic_string<TCHAR>> dllNames;
const TCHAR *pNppPath = (NppParameters::getInstance())->getNppPath();
string pluginsFullPathFilter = (dir && dir[0])?dir:pNppPath;
basic_string<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR>(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<TCHAR>(TEXT("This ANSI plugin is not compatible with your Unicode Notepad++."));
#else
if (pi->_pFuncIsUnicode)
throw basic_string<TCHAR>(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<TCHAR>(TEXT("Missing \"setInfo\" function"));
pi->_pFuncGetName = (PFUNCGETNAME)GetProcAddress(pi->_hLib, "getName");
if (!pi->_pFuncGetName)
throw string("Missing \"getName\" function");
throw basic_string<TCHAR>(TEXT("Missing \"getName\" function"));
pi->_pBeNotified = (PBENOTIFIED)GetProcAddress(pi->_hLib, "beNotified");
if (!pi->_pBeNotified)
throw string("Missing \"beNotified\" function");
throw basic_string<TCHAR>(TEXT("Missing \"beNotified\" function"));
pi->_pMessageProc = (PMESSAGEPROC)GetProcAddress(pi->_hLib, "messageProc");
if (!pi->_pMessageProc)
throw string("Missing \"messageProc\" function");
throw basic_string<TCHAR>(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<TCHAR>(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<TCHAR>(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<TCHAR>(TEXT("Loading GetLexerName function failed."));
GetLexerStatusTextFn GetLexerStatusText = (GetLexerStatusTextFn)::GetProcAddress(pi->_hLib, "GetLexerStatusText");
if (!GetLexerStatusText)
throw string("Loading GetLexerStatusText function failed.");
throw basic_string<TCHAR>(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<TCHAR>(basic_string<TCHAR>(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<TCHAR>(basic_string<TCHAR>(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<TCHAR> 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<TCHAR> 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<PluginCmdShortcut> & 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<TCHAR> 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

View File

@ -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<PluginInfo *> _pluginInfos;
vector<PluginCommand> _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

View File

@ -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<TCHAR> 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>
(TCHAR *)cmd.c_str(), // (writeable) command basic_string<TCHAR>
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<TCHAR> 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<TCHAR> 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;

View File

@ -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<TCHAR> _stdoutStr;
basic_string<TCHAR> _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

View File

@ -19,25 +19,26 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include <windows.h>
#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);
}

View File

@ -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 {

View File

@ -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

View File

@ -19,7 +19,9 @@
#include <memory>
#include <algorithm>
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<TCHAR> 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;
};
};
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<wchar_t> 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<char> vw(len);
WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL);
return &vw[0];
}
else
return "";
}

View File

@ -20,14 +20,92 @@
#include <windows.h>
#include <string>
#include <vector>
#include <time.h>
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<TCHAR> 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

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,7 @@
#ifndef NOTEPAD_PLUS_H
#define NOTEPAD_PLUS_H
#include <window.h>
#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<TCHAR> iconLocation;
iconLocator(int iList, int iIcon, const std::string iconLoc)
iconLocator(int iList, int iIcon, const std::basic_string<TCHAR> 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<TCHAR> & pluginsTrans, basic_string<TCHAR> & 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<TCHAR> 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<TCHAR> 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<TCHAR> globalStr = TEXT("");
for (int i = lastLine ; i >= 0 ; i--)
{
if (bookmarkPresent(i))
{
string currentStr = getMarkedLine(i) + globalStr;
basic_string<TCHAR> currentStr = getMarkedLine(i) + globalStr;
globalStr = currentStr;
}
}
@ -592,14 +577,14 @@ private:
void cutMarkedLines() {
int lastLine = _pEditView->lastZeroBasedLineNumber();
string globalStr = "";
basic_string<TCHAR> globalStr = TEXT("");
_pEditView->execute(SCI_BEGINUNDOACTION);
for (int i = lastLine ; i >= 0 ; i--)
{
if (bookmarkPresent(i))
{
string currentStr = getMarkedLine(i) + globalStr;
basic_string<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<string> & patterns);
void getMatchedFileNames(const char *dir, const vector<string> & patterns, vector<string> & fileNames, bool isRecursive, bool isInHiddenDir);
bool matchInList(const TCHAR *fileName, const vector<basic_string<TCHAR>> & patterns);
void getMatchedFileNames(const TCHAR *dir, const vector<basic_string<TCHAR>> & patterns, vector<basic_string<TCHAR>> & 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<TCHAR> 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

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -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<string> & patternVect);
void cutString(const TCHAR *str2cut, vector<basic_string<TCHAR>> & 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<TCHAR> fn) : _fileName(fn){};
sessionFileInfo(basic_string<TCHAR> fn, Position pos) : Position(pos), _fileName(fn){};
string _fileName;
string _langName;
basic_string<TCHAR> _fileName;
basic_string<TCHAR> _langName;
vector<size_t> 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<TCHAR> *_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<TCHAR>(*(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<TCHAR>(*(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<TCHAR>(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<TCHAR> _langName;
LangMenuItem(LangType lt, int cmdID = 0, string langName = ""):
LangMenuItem(LangType lt, int cmdID = 0, basic_string<TCHAR> 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<TCHAR> _headerLeft;
basic_string<TCHAR> _headerMiddle;
basic_string<TCHAR> _headerRight;
basic_string<TCHAR> _headerFontName;
int _headerFontStyle;
int _headerFontSize;
string _footerLeft;
string _footerMiddle;
string _footerRight;
string _footerFontName;
basic_string<TCHAR> _footerLeft;
basic_string<TCHAR> _footerMiddle;
basic_string<TCHAR> _footerRight;
basic_string<TCHAR> _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<TCHAR> _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<TCHAR> *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<string> & getFontList() const {return _fontlist;};
const vector<basic_string<TCHAR>> & 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<string> extVect;
vector<basic_string<TCHAR>> 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<TCHAR> _find;
basic_string<TCHAR> _replace;
basic_string<TCHAR> _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<TCHAR> *_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<string> _fontlist;
vector<basic_string<TCHAR>> _fontlist;
HMODULE _hUser32;
HMODULE _hUXTheme;
@ -1143,15 +1145,15 @@ private:
vector<int> _scintillaModifiedKeyIndices; //modified scintilla keys. Indices static, determined by searching for commandId. Needed when saving alterations
//vector<string> _noMenuCmdNames;
//vector<basic_string<TCHAR>> _noMenuCmdNames;
vector<MenuItemUnit> _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<string> *pStrVect = (vector<string> *)lParam;
vector<basic_string<TCHAR>> *pStrVect = (vector<basic_string<TCHAR>> *)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);

View File

@ -19,7 +19,7 @@
#include "Notepad_plus_msgs.h"
#include <algorithm>
static bool isInList(string word, const vector<string> & wordArray)
static bool isInList(basic_string<TCHAR> word, const vector<basic_string<TCHAR>> & 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<string> & 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<TCHAR> 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<string> wordArray;
int posFind = int(_pEditView->execute(SCI_SEARCHINTARGET, expr.length(), (LPARAM)expr.c_str()));
vector<basic_string<TCHAR>> 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<TCHAR> 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<TiXmlElement *>(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();

View File

@ -48,10 +48,10 @@ private:
bool _ignoreCase;
std::string _keyWords;
std::basic_string<TCHAR> _keyWords;
FunctionCallTip _funcCalltip;
const char * getApiFileName();
const TCHAR * getApiFileName();
};
#endif //AUTOCOMPLETION_H

View File

@ -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<HeaderLineState> & 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<TCHAR> 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);
}

View File

@ -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<HeaderLineState> & folds, ScintillaEditView * identifier);
std::vector<HeaderLineState> & 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<Style, int> > & 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<Style, int> > _clickableStyles;
void updateTimeStamp();
Lang * getCurrentLang() const;

View File

@ -23,7 +23,6 @@
#include <commctrl.h>
#include <shlwapi.h>
#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<LPARAM>(&tie));
::SendMessage(_hSelf, TCM_INSERTITEM, _nbItem++, reinterpret_cast<LPARAM>(&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<LPARAM>(&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<LPARAM>(&tie));
::SendMessage(_hSelf, TCM_SETITEM, index, reinterpret_cast<LPARAM>(&tie));
::SendMessage(_hParent, WM_SIZE, 0, 0);
}

View File

@ -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);

View File

@ -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<TCHAR>, 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<TCHAR> 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<TCHAR>(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<TCHAR> 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<TCHAR> str2Search = getTextFromCombo(hFindCombo);
basic_string<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<string> & patternVect)
void FindReplaceDlg::getPatterns(vector<basic_string<TCHAR>> & 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<MenuItemUnit> 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<TCHAR> 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<TCHAR> 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);
}

View File

@ -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<TCHAR> _foundLine;
std::basic_string<TCHAR> _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<TCHAR> 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<TCHAR> 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<TCHAR> 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<string> & patternVect);
void getPatterns(vector<basic_string<TCHAR>> & 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<TCHAR> getText2search() const {
return getTextFromCombo(::GetDlgItem(_hSelf, IDFINDWHAT));
};
const string & getFilters() const {return _filters;};
const string & getDirectory() const {return _directory;};
const basic_string<TCHAR> & getFilters() const {return _filters;};
const basic_string<TCHAR> & 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<TCHAR> 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<TCHAR> _filters;
basic_string<TCHAR> _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);

View File

@ -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

View File

@ -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<TCHAR> 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);

View File

@ -20,7 +20,7 @@
#include "ScintillaEditView.h"
typedef std::vector<const char *> stringVec;
typedef std::vector<const TCHAR *> 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<stringVec> _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

View File

@ -79,7 +79,7 @@ private :
};
void cleanLineEdit() const {
::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, "");
::SetDlgItemText(_hSelf, ID_GOLINE_EDIT, TEXT(""));
};
int getLine() const {

View File

@ -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<TCHAR> & str, basic_string<TCHAR> str2BeReplaced, basic_string<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<int>(headerLeft.length()), NULL);
}
// Middle part
if (headerM != '\0')
{
wstring headerMiddle(headerM);
basic_string<TCHAR> 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<int>(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<int>(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<int>(headerMiddle.length()), NULL);
}
// Right part
if (headerR != '\0')
{
wstring headerRight(headerR);
basic_string<TCHAR> 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<int>(headerRight.length()), &size);
::ExtTextOutW(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2,
::GetTextExtentPoint32(_pdlg.hDC, headerRight.c_str(), static_cast<int>(headerRight.length()), &size);
::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.top - headerLineHeight / 2,
ETO_CLIPPED, &rcw, headerRight.c_str(), static_cast<int>(headerRight.length()), NULL);
}
@ -430,37 +427,36 @@ size_t Printer::doPrint(bool justDoIt)
// Left part
if (footerL[0] != '\0')
{
wstring footerLeft(footerL);
basic_string<TCHAR> 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<int>(footerLeft.length()), NULL);
}
// Middle part
if (footerM[0] != '\0')
{
wstring footerMiddle(footerM);
basic_string<TCHAR> 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<int>(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<int>(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<int>(footerMiddle.length()), NULL);
}
// Right part
if (footerR[0] != '\0')
{
wstring footerRight(footerR);
basic_string<TCHAR> 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<int>(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<int>(footerRight.length()), &size);
::ExtTextOut(_pdlg.hDC, frPrint.rc.right - size.cx, frPrint.rc.bottom + footerLineHeight / 2,
ETO_CLIPPED, &rcw, footerRight.c_str(), static_cast<int>(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);

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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<pair<int, int> > 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<int>(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<char> & 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<LPARAM>(""));
execute(SCI_SETKEYWORDS, i, reinterpret_cast<LPARAM>(TEXT("")));
setLexer(SCLEX_TEX, L_TEX, 0);
};

View File

@ -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)

View File

@ -62,7 +62,7 @@ void SharedParametersDialog::initControls()
//for the font name combos
HWND hFontNameCombo = ::GetDlgItem(_hSelf, _fontNameCombo[i]);
const std::vector<std::string> & fontlist = pNppParam->getFontList();
const std::vector<std::basic_string<TCHAR>> & 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<TCHAR> 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;
}

View File

@ -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;
};

View File

@ -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

View File

@ -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

View File

@ -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<TCHAR> s2r(line);
if (lineEndCol < cursorCol)
{
string s_space(cursorCol - lineEndCol, ' ');
basic_string<TCHAR> 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<TCHAR> s2r(line);
/*
Calcule string
Calcule basic_string<TCHAR>
*/
int2str(str, sizeof(str), initialNumber, base, nb, isZeroLeading);
initialNumber += increaseNumber;
if (lineEndCol < cursorCol)
{
string s_space(cursorCol - lineEndCol, ' ');
basic_string<TCHAR> 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;
}

View File

@ -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))

View File

@ -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

View File

@ -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<int, int> 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 "<tagName[ >]", 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 = "</";
basic_string<char> closeTag = "</";
closeTag += tagName;
closeTag += "[ ]*>";
string openTag = "<";
basic_string<char> 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<char> openTag = "<";
openTag += tagName;
openTag += "[ >]";
string closeTag = "</";
basic_string<char> closeTag = "</";
closeTag += tagName;
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);
}

View File

@ -19,6 +19,8 @@
#define XMLMATCHEDTAGSHIGHLIGHTER_H
#include <vector>
#include <windows.h>
using namespace std;
class ScintillaEditView;

View File

@ -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<TCHAR>
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 ( &copy == 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<TCHAR>
// 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<TCHAR>
// 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;
}

View File

@ -33,19 +33,20 @@ distribution.
#pragma warning( disable : 4514 )
#include <assert.h>
#include <windows.h>
/*
TiXmlString is an emulation of the std::string template.
TiXmlString is an emulation of the std::basic_string<TCHAR> 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<TCHAR> 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<TCHAR>
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<TCHAR>. 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<TCHAR> 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>
TCHAR * cstring;
// Number of chars allocated
unsigned allocated;
// Current string size
// Current basic_string<TCHAR> 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);

View File

@ -24,7 +24,7 @@ distribution.
#include <ctype.h>
#include "tinyxml.h"
#include "UniConversion.h"
#include "SysMsg.h"
#ifdef TIXML_USE_STL
#include <sstream>
@ -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; i<depth; i++ )
{
fprintf( cfile, " " );
generic_fprintf( cfile, TEXT(" ") );
}
fprintf( cfile, "<%s", value.c_str() );
generic_fprintf( cfile, TEXT("<%s"), value.c_str() );
TiXmlAttribute* attrib;
for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
{
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, "</%s>", value.c_str() );
generic_fprintf( cfile, TEXT("</%s>"), 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<depth; ++i )
fprintf( cfile, " " );
fprintf( cfile, "</%s>", value.c_str() );
generic_fprintf( cfile, TEXT(" ") );
generic_fprintf( cfile, TEXT("</%s>"), 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) << "</" << value << ">";
(*stream) << TEXT("</") << value << 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<TCHAR> to
// be called. What is strange, is that the std::basic_string<TCHAR> 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<TCHAR>. 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, "<!--%s-->", value.c_str() );
generic_fprintf( cfile, TEXT("<!--%s-->"), value.c_str() );
}
void TiXmlComment::StreamOut( TIXML_OSTREAM * stream ) const
{
(*stream) << "<!--";
(*stream) << TEXT("<!--");
PutString( value, stream );
(*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, "<?xml ");
generic_fprintf (cfile, TEXT("<?xml "));
if ( !version.empty() )
fprintf (cfile, "version=\"%s\" ", version.c_str ());
generic_fprintf (cfile, TEXT("version=\"%s\" "), version.c_str ());
if ( !encoding.empty() )
fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
generic_fprintf (cfile, TEXT("encoding=\"%s\" "), encoding.c_str ());
if ( !standalone.empty() )
fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
fprintf (cfile, "?>");
generic_fprintf (cfile, TEXT("standalone=\"%s\" "), standalone.c_str ());
generic_fprintf (cfile, TEXT("?>"));
}
void TiXmlDeclaration::StreamOut( TIXML_OSTREAM * stream ) const
{
(*stream) << "<?xml ";
(*stream) << TEXT("<?xml ");
if ( !version.empty() )
{
(*stream) << "version=\"";
(*stream) << TEXT("version=\"");
PutString( version, stream );
(*stream) << "\" ";
(*stream) << TEXT("\" ");
}
if ( !encoding.empty() )
{
(*stream) << "encoding=\"";
(*stream) << TEXT("encoding=\"");
PutString( encoding, stream );
(*stream ) << "\" ";
(*stream ) << TEXT("\" ");
}
if ( !standalone.empty() )
{
(*stream) << "standalone=\"";
(*stream) << TEXT("standalone=\"");
PutString( standalone, stream );
(*stream) << "\" ";
(*stream) << TEXT("\" ");
}
(*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<depth; i++ )
fprintf( cfile, " " );
fprintf( cfile, "%s", value.c_str() );
generic_fprintf( cfile, TEXT(" ") );
generic_fprintf( cfile, TEXT("%s"), value.c_str() );
}
void TiXmlUnknown::StreamOut( TIXML_OSTREAM * stream ) const
{
(*stream) << "<" << value << ">"; // 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<TCHAR> & operator<< (std::basic_string<TCHAR>& out, const TiXmlNode& base )
{
std::ostringstream os_stream( std::ostringstream::out );
//std::ostringstream os_stream( std::ostringstream::out );
std::basic_ostringstream<TCHAR> 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 )
{

View File

@ -37,13 +37,15 @@ distribution.
#include <string.h>
#include <assert.h>
#include <windows.h>
// Help out windows:
#if defined( _DEBUG ) && !defined( DEBUG )
#define DEBUG
#endif
#if defined( DEBUG ) && defined( _MSC_VER )
#include <windows.h>
#define TIXML_LOG OutputDebugString
#else
#define TIXML_LOG printf
@ -53,9 +55,13 @@ distribution.
#include <string>
#include <iostream>
//#include <ostream>
#define TIXML_STRING std::string
#define TIXML_ISTREAM std::istream
#define TIXML_OSTREAM std::ostream
#define TIXML_STRING std::basic_string<TCHAR>
//#define TIXML_ISTREAM std::istream
//#define TIXML_OSTREAM std::ostream
#define TIXML_ISTREAM std::basic_istream<TCHAR>
#define TIXML_OSTREAM std::basic_ostream<TCHAR>
#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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR>& operator >> (std::basic_istream<TCHAR>& 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<TCHAR>& operator<< (std::basic_ostream<TCHAR>& 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<TCHAR>.
friend std::basic_string<TCHAR>& operator<< (std::basic_string<TCHAR>& 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<TCHAR>
@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<TCHAR>
@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<TCHAR> form.
void SetValue( const std::basic_string<TCHAR>& _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<TCHAR>& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::basic_string<TCHAR> form.
TiXmlNode* LastChild( const std::basic_string<TCHAR>& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::basic_string<TCHAR> 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<TCHAR>& _value, TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::basic_string<TCHAR> 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<TCHAR>& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::basic_string<TCHAR> form.
TiXmlNode* NextSibling( const std::basic_string<TCHAR>& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::basic_string<TCHAR> 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<TCHAR>& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::basic_string<TCHAR> 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<TCHAR>& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::basic_string<TCHAR> 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<TCHAR> constructor.
TiXmlAttribute( const std::basic_string<TCHAR>& _name, const std::basic_string<TCHAR>& _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<TCHAR>. 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<TCHAR>. 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<TCHAR> form.
void SetName( const std::basic_string<TCHAR>& _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<TCHAR> form.
void SetValue( const std::basic_string<TCHAR>& _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<TCHAR> constructor.
TiXmlElement( const std::basic_string<TCHAR>& _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<TCHAR>& name ) const { return Attribute( name.c_str() ); }
const TCHAR* Attribute( const std::basic_string<TCHAR>& 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<TCHAR> form.
void SetAttribute( const std::basic_string<TCHAR>& name, const std::basic_string<TCHAR>& _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<TCHAR> form.
void SetAttribute( const std::basic_string<TCHAR>& 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<TCHAR>& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::basic_string<TCHAR> 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<TCHAR>& 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<TCHAR>& _version,
const std::basic_string<TCHAR>& _encoding,
const std::basic_string<TCHAR>& _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<TCHAR>& 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<TCHAR>& filename ) ///< STL std::basic_string<TCHAR> 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<TCHAR>& filename ) const ///< STL std::basic_string<TCHAR> 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<TCHAR> ( 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
<Document>
<Element attributeA = "valueA">
<Child attributeB = "value1" />
<Child attributeB = "value2" />
<Element attributeA = TEXT("valueA")>
<Child attributeB = TEXT("value1") />
<Child attributeB = TEXT("value2") />
</Element>
<Document>
@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<TCHAR>& _value ) const { return FirstChild( _value.c_str() ); }
TiXmlHandle FirstChildElement( const std::basic_string<TCHAR>& _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<TCHAR>& _value, int index ) const { return Child( _value.c_str(), index ); }
TiXmlHandle ChildElement( const std::basic_string<TCHAR>& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
#endif
/// Return the handle as a TiXmlNode. This may return null.

View File

@ -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.")
};

View File

@ -24,6 +24,7 @@ distribution.
#include "tinyxml.h"
#include <ctype.h>
#include "SysMsg.h"
//#define DEBUG_PARSER
@ -32,11 +33,11 @@ distribution.
// or order will break putstring.
TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
{
{ "&amp;", 5, '&' },
{ "&lt;", 4, '<' },
{ "&gt;", 4, '>' },
{ "&quot;", 6, '\"' },
{ "&apos;", 6, '\'' }
{ TEXT("&amp;"), 5, '&' },
{ TEXT("&lt;"), 4, '<' },
{ TEXT("&gt;"), 4, '>' },
{ TEXT("&quot;"), 6, '\"' },
{ TEXT("&apos;"), 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; i<NUM_ENTITY; ++i )
{
if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
if ( generic_strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
{
assert( strlen( entity[i].str ) == entity[i].strLength );
assert( lstrlen( entity[i].str ) == entity[i].strLength );
*value = entity[i].chr;
return ( p + entity[i].strLength );
}
@ -273,8 +274,8 @@ const char* TiXmlBase::GetEntity( const char* p, char* value )
}
bool TiXmlBase::StringEqual( const char* p,
const char* tag,
bool TiXmlBase::StringEqual( const TCHAR* p,
const TCHAR* tag,
bool ignoreCase )
{
assert( p );
@ -286,7 +287,7 @@ bool TiXmlBase::StringEqual( const char* p,
if ( tolower( *p ) == tolower( *tag ) )
{
const char* q = p;
const TCHAR* q = p;
if (ignoreCase)
{
@ -318,13 +319,13 @@ bool TiXmlBase::StringEqual( const char* p,
return false;
}
const char* TiXmlBase::ReadText( const char* p,
const TCHAR* TiXmlBase::ReadText( const TCHAR* p,
TIXML_STRING * text,
bool trimWhiteSpace,
const char* endTag,
const TCHAR* endTag,
bool caseInsensitive )
{
*text = "";
*text = TEXT("");
if ( !trimWhiteSpace // certain tags always keep whitespace
|| !condenseWhiteSpace ) // if true, whitespace is always kept
{
@ -333,7 +334,7 @@ const char* TiXmlBase::ReadText( const char* p,
&& !StringEqual( p, endTag, caseInsensitive )
)
{
char c;
TCHAR c;
p = GetChar( p, &c );
(* text) += c;
}
@ -366,13 +367,13 @@ const char* TiXmlBase::ReadText( const char* p,
(* text) += ' ';
whitespace = false;
}
char c;
TCHAR c;
p = GetChar( p, &c );
(* text) += c;
}
}
}
return p + strlen( endTag );
return p + lstrlen( endTag );
}
#ifdef TIXML_USE_STL
@ -398,7 +399,7 @@ void TiXmlDocument::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
while ( in->good() && 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 = { "<?xml" };
const char* commentHeader = { "<!--" };
const TCHAR* xmlHeader = { TEXT("<?xml") };
const TCHAR* commentHeader = { TEXT("<!--") };
if ( StringEqual( p, xmlHeader, true ) )
{
@ -553,7 +554,7 @@ TiXmlNode* TiXmlNode::Identify( const char* p )
#ifdef DEBUG_PARSER
TIXML_LOG( "XML parsing Element\n" );
#endif
returnNode = new TiXmlElement( "" );
returnNode = new TiXmlElement( TEXT("") );
}
else if ( StringEqual( p, commentHeader, false ) )
{
@ -592,7 +593,7 @@ void TiXmlElement::StreamIn (TIXML_ISTREAM * in, TIXML_STRING * tag)
while( in->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 ("</");
TIXML_STRING endTag (TEXT("</"));
endTag += value;
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, "</", false ) )
if ( StringEqual( p, TEXT("</"), false ) )
{
return p;
}
@ -887,7 +888,7 @@ void TiXmlUnknown::StreamIn( TIXML_ISTREAM * in, TIXML_STRING * tag )
#endif
const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data )
const TCHAR* TiXmlUnknown::Parse( const TCHAR* p, TiXmlParsingData* data )
{
TiXmlDocument* document = GetDocument();
p = SkipWhiteSpace( p );
@ -904,7 +905,7 @@ const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data )
return 0;
}
++p;
value = "";
value = TEXT("");
while ( p && *p && *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 char* endTag = "-->";
const TCHAR* startTag = TEXT("<!--");
const TCHAR* endTag = 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, "<?xml", true ) )
if ( !p || !*p || !StringEqual( p, TEXT("<?xml"), true ) )
{
if ( document ) document->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 );

View File

@ -7,7 +7,6 @@
#include <stdlib.h>
#include <windows.h>
#include <vector>
#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<len;i++) {
unsigned char ch = static_cast<unsigned char>(s[i]);
UCHAR ch = static_cast<UCHAR>(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<const unsigned char *>(s);
const UCHAR *us = reinterpret_cast<const UCHAR *>(s);
unsigned int i=0;
while ((i<len) && (ui<tlen)) {
unsigned char ch = us[i++];
UCHAR ch = us[i++];
if (ch < 0x80) {
tbuf[ui] = ch;
} else if (ch < 0x80 + 0x40 + 0x20) {
@ -77,7 +77,7 @@ unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsign
}
unsigned int ascii_to_utf8(const char* pszASCII, unsigned int lenASCII, char* pszUTF8)
unsigned int ascii_to_utf8(const char * pszASCII, unsigned int lenASCII, char * pszUTF8)
{
// length of pszUTF8 must be enough;
// its maximum is (lenASCII*3 + 1)
@ -105,7 +105,7 @@ unsigned int ascii_to_utf8(const char* pszASCII, unsigned int lenASCII, char* ps
return lenUTF8;
}
int utf8_to_ascii(const char* pszUTF8, unsigned int lenUTF8, char* pszASCII)
int utf8_to_ascii(const char * pszUTF8, unsigned int lenUTF8, char * pszASCII)
{
// length of pszASCII must be enough;
// its maximum is (lenUTF8 + 1)
@ -134,46 +134,3 @@ int utf8_to_ascii(const char* pszUTF8, unsigned int lenUTF8, char* pszASCII)
return nbByte;
}
void char2wchar(const char* pszCHAR, wchar_t* pszWCHAR, UINT codepage)
{
int len = MultiByteToWideChar(codepage, 0, pszCHAR, -1, pszWCHAR, 0);
if(len > 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<wchar_t> 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<char> vw(len);
WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL);
return &vw[0];
}
else
return "";
}

View File

@ -5,23 +5,9 @@
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef UNICONVERSION_H
#define UNICONVERSION_H
#include <Windows.h>
#include <TCHAR.H>
#include <string>
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);

View File

@ -21,7 +21,6 @@
#include <stdio.h>
#include <windows.h>
#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;

View File

@ -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 <stdio.h>
@ -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<char*>(m_pNewBuf); }
char* getNewBuf() { return reinterpret_cast<char *>(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

View File

@ -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<TCHAR> 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);

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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<ColourPopup *>(::GetWindowLong(hwnd, GWL_USERDATA));
ColourPopup *pColourPopup = reinterpret_cast<ColourPopup *>(::GetWindowLongPtr(hwnd, GWL_USERDATA));
if (!pColourPopup)
return FALSE;
return pColourPopup->run_dlgProc(message, wParam, lParam);

View File

@ -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 |

View File

@ -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<std::string> & fontlist = (NppParameters::getInstance())->getFontList();
const std::vector<std::basic_string<TCHAR>> & 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<TCHAR> 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;

View File

@ -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;

View File

@ -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

View File

@ -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<TCHAR> _itemName;
MenuItemUnit() : _cmdID(0), _itemName(TEXT("")) {};
MenuItemUnit(unsigned long cmdID, basic_string<TCHAR> itemName) : _cmdID(cmdID), _itemName(itemName) {};
MenuItemUnit(unsigned long cmdID, const TCHAR *itemName) : _cmdID(cmdID){
if (!itemName)
_itemName = "";
_itemName = TEXT("");
else
_itemName = itemName;
};

View File

@ -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;

View File

@ -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)

View File

@ -20,7 +20,7 @@
#define DOCKINGCONT
#include "StaticDialog.h"
#include "resource.h"
#include "Resource.h"
#include "Docking.h"
#include <windows.h>
#include <string>
@ -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;

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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++)

View File

@ -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
{

View File

@ -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;

View File

@ -34,7 +34,7 @@ static const WORD DotPattern[] =
};
#define MDLG_CLASS_NAME "moveDlg"
#define MDLG_CLASS_NAME TEXT("moveDlg")
class Gripper

View File

@ -1,6 +1,5 @@
#include "common_func.h"
#include <string>
#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<TCHAR> 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<LPARAM>(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<TCHAR>.
// 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();

View File

@ -11,7 +11,7 @@ Modified by Don HO <don.h@free.fr>
*/
#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<TCHAR>, 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;j<k;j++)
{
@ -1822,11 +1820,11 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
c++;
}
buffer[c]=0x00;
strcpy((char*)lParam,buffer);
lstrcpy((TCHAR*)lParam,buffer);
}
else
{
strcpy((char*)lParam,"");
lstrcpy((TCHAR*)lParam, TEXT(""));
}
break;
@ -1853,7 +1851,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)
@ -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;

View File

@ -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 <windows.h>
#include "resource.h"
@ -105,4 +104,6 @@ void SetCell(_BGCELL *cell,int row, int col);
//global variables
#endif //BABYGRID_H

View File

@ -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,\

View File

@ -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;

View File

@ -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<MenuItemUnit> 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) {

View File

@ -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

View File

@ -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,

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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<TCHAR> extFilter = extText;
va_list pArg;
va_start(pArg, ext);
std::string exts;
std::basic_string<TCHAR> 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<TCHAR> 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<TCHAR>(_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<TCHAR>(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<TCHAR> 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<TCHAR> 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<TCHAR> 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<TCHAR> 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<FileDialog *>(::GetWindowLong(hWnd, GWL_USERDATA));
FileDialog *pFileDialog = reinterpret_cast<FileDialog *>(::GetWindowLongPtr(hWnd, GWL_USERDATA));
if (!pFileDialog)
{
return FALSE;

View File

@ -26,14 +26,13 @@
#include <string>
#include "SysMsg.h"
#include "Parameters.h"
#include "UniConversion.h"
const int nbExtMax = 256;
const int extLenMax = 64;
using namespace std;
typedef vector<string> stringVector;
typedef vector<basic_string<TCHAR>> 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<TCHAR> changeExt(basic_string<TCHAR> fn, basic_string<TCHAR> ext)
{
if (ext == "")
if (ext == TEXT(""))
return fn;
string fnExt = fn;
basic_string<TCHAR> fnExt = fn;
int index = fnExt.find_last_of(".");
string extension = ".";
int index = fnExt.find_last_of(TEXT("."));
basic_string<TCHAR> extension = TEXT(".");
extension += ext;
if (index == string::npos)
if (index == basic_string<TCHAR>::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;

View File

@ -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

View File

@ -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<TCHAR> 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<TCHAR> 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<TCHAR>(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<TCHAR> & str)
{
string::size_type pos = str.find_last_not_of(' ');
basic_string<TCHAR>::size_type pos = str.find_last_not_of(' ');
if (pos != string::npos)
if (pos != basic_string<TCHAR>::npos)
{
str.erase(pos + 1);
pos = str.find_first_not_of(' ');
if(pos != string::npos) str.erase(0, pos);
if(pos != basic_string<TCHAR>::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<std::string> & fontlist = pNppParam->getFontList();
const std::vector<std::basic_string<TCHAR>> & 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<TCHAR> 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<TCHAR> 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;
}

View File

@ -71,8 +71,8 @@ private :
struct LangID_Name
{
LangType _id;
string _name;
LangID_Name(LangType id, string name) : _id(id), _name(name){};
basic_string<TCHAR> _name;
LangID_Name(LangType id, basic_string<TCHAR> 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<TCHAR> _varDesc;
basic_string<TCHAR> _var;
strCouple(TCHAR *varDesc, TCHAR *var): _varDesc(varDesc), _var(var){};
};
class PrintSettings2Dlg : public StaticDialog

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -22,34 +22,34 @@
#include "RunDlg_rc.h"
#include <string>
//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<TCHAR> cmd) : _cmdLine(cmd){};
HINSTANCE run(HWND hWnd);
protected :
string _cmdLine;
basic_string<TCHAR> _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

View File

@ -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

View File

@ -100,7 +100,7 @@ void StaticDialog::create(int dialogID, bool isRTL)
if (!_hSelf)
{
systemMessage("StaticDialog");
systemMessage(TEXT("StaticDialog"));
throw int(666);
}

View File

@ -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);
}

Some files were not shown because too many files have changed in this diff Show More