Applied coding style / cleanup

pull/473/merge
Damien GERARD 2015-07-15 14:09:31 +02:00
parent 0cd514de13
commit 23cd144198
26 changed files with 898 additions and 744 deletions

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -39,17 +39,19 @@
WcharMbcsConvertor * WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor; WcharMbcsConvertor * WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor;
void printInt(int int2print) void printInt(int int2print)
{ {
TCHAR str[32]; TCHAR str[32];
wsprintf(str, TEXT("%d"), int2print); wsprintf(str, TEXT("%d"), int2print);
::MessageBox(NULL, str, TEXT(""), MB_OK); ::MessageBox(NULL, str, TEXT(""), MB_OK);
}; }
void printStr(const TCHAR *str2print)
void printStr(const TCHAR *str2print)
{ {
::MessageBox(NULL, str2print, TEXT(""), MB_OK); ::MessageBox(NULL, str2print, TEXT(""), MB_OK);
}; }
std::string getFileContent(const TCHAR *file2read) std::string getFileContent(const TCHAR *file2read)
{ {
@ -59,7 +61,8 @@ std::string getFileContent(const TCHAR *file2read)
FILE *fp = generic_fopen(file2read, TEXT("rb")); FILE *fp = generic_fopen(file2read, TEXT("rb"));
size_t lenFile = 0; size_t lenFile = 0;
do { do
{
lenFile = fread(data, 1, blockSize - 1, fp); lenFile = fread(data, 1, blockSize - 1, fp);
if (lenFile <= 0) break; if (lenFile <= 0) break;
@ -69,8 +72,8 @@ std::string getFileContent(const TCHAR *file2read)
data[lenFile] = '\0'; data[lenFile] = '\0';
wholeFileContent += data; wholeFileContent += data;
}
} while (lenFile > 0); while (lenFile > 0);
fclose(fp); fclose(fp);
return wholeFileContent; return wholeFileContent;
@ -90,6 +93,7 @@ char getDriveLetter()
return drive; return drive;
} }
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath) generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
{ {
generic_string fullFilePathName = TEXT(""); generic_string fullFilePathName = TEXT("");
@ -114,16 +118,18 @@ generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
return fullFilePathName; return fullFilePathName;
} }
void writeFileContent(const TCHAR *file2write, const char *content2write) void writeFileContent(const TCHAR *file2write, const char *content2write)
{ {
FILE *f = generic_fopen(file2write, TEXT("w+")); FILE *f = generic_fopen(file2write, TEXT("w+"));
fwrite(content2write, sizeof(content2write[0]), strlen(content2write), f); fwrite(content2write, sizeof(content2write[0]), strlen(content2write), f);
fflush(f); fflush(f);
fclose(f); fclose(f);
} }
void writeLog(const TCHAR *logFileName, const char *log2write) void writeLog(const TCHAR *logFileName, const char *log2write)
{ {
FILE *f = generic_fopen(logFileName, TEXT("a+")); FILE *f = generic_fopen(logFileName, TEXT("a+"));
fwrite(log2write, sizeof(log2write[0]), strlen(log2write), f); fwrite(log2write, sizeof(log2write[0]), strlen(log2write), f);
fputc('\n', f); fputc('\n', f);
@ -131,6 +137,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
fclose(f); fclose(f);
} }
// Set a call back with the handle after init to set the path. // Set a call back with the handle after init to set the path.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData) static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
@ -140,6 +147,7 @@ static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pDa
return 0; return 0;
}; };
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr) void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
{ {
// This code was copied and slightly modifed from: // This code was copied and slightly modifed from:
@ -177,7 +185,7 @@ void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
// pidl will be null if they cancel the browse dialog. // pidl will be null if they cancel the browse dialog.
// pidl will be not null when they select a folder. // pidl will be not null when they select a folder.
if (pidl) if (pidl)
{ {
// Try to convert the pidl to a display generic_string. // Try to convert the pidl to a display generic_string.
// Return is true if success. // Return is true if success.
@ -214,7 +222,7 @@ generic_string getFolderName(HWND parent, const TCHAR *defaultDir)
// pidl will be null if they cancel the browse dialog. // pidl will be null if they cancel the browse dialog.
// pidl will be not null when they select a folder. // pidl will be not null when they select a folder.
if (pidl) if (pidl)
{ {
// Try to convert the pidl to a display generic_string. // Try to convert the pidl to a display generic_string.
// Return is true if success. // Return is true if success.
@ -245,9 +253,11 @@ void ClientRectToScreenRect(HWND hWnd, RECT* rect)
::ClientToScreen( hWnd, &pt ); ::ClientToScreen( hWnd, &pt );
rect->right = pt.x; rect->right = pt.x;
rect->bottom = pt.y; rect->bottom = pt.y;
}; }
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim) {
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim)
{
//Vector is created on stack and copied on return //Vector is created on stack and copied on return
std::vector<generic_string> tokens; std::vector<generic_string> tokens;
@ -268,6 +278,7 @@ std::vector<generic_string> tokenizeString(const generic_string & tokenString, c
return tokens; return tokens;
} }
void ScreenRectToClientRect(HWND hWnd, RECT* rect) void ScreenRectToClientRect(HWND hWnd, RECT* rect)
{ {
POINT pt; POINT pt;
@ -283,9 +294,10 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect)
::ScreenToClient( hWnd, &pt ); ::ScreenToClient( hWnd, &pt );
rect->right = pt.x; rect->right = pt.x;
rect->bottom = pt.y; rect->bottom = pt.y;
}; }
int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
{ {
if (code == EXCEPTION_ACCESS_VIOLATION) if (code == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
@ -293,7 +305,9 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
return EXCEPTION_CONTINUE_SEARCH; return EXCEPTION_CONTINUE_SEARCH;
} }
bool isInList(const TCHAR *token, const TCHAR *list) {
bool isInList(const TCHAR *token, const TCHAR *list)
{
if ((!token) || (!list)) if ((!token) || (!list))
return false; return false;
TCHAR word[64]; TCHAR word[64];
@ -307,12 +321,12 @@ bool isInList(const TCHAR *token, const TCHAR *list) {
{ {
word[j] = '\0'; word[j] = '\0';
j = 0; j = 0;
if (!generic_stricmp(token, word)) if (!generic_stricmp(token, word))
return true; return true;
} }
} }
else else
{ {
word[j] = list[i]; word[j] = list[i];
++j; ++j;
@ -327,7 +341,7 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
TCHAR cleanedName[64] = TEXT(""); TCHAR cleanedName[64] = TEXT("");
size_t j = 0; size_t j = 0;
size_t menuNameLen = lstrlen(menuItemStr); size_t menuNameLen = lstrlen(menuItemStr);
for(size_t k = 0 ; k < menuNameLen ; ++k) for(size_t k = 0 ; k < menuNameLen ; ++k)
{ {
if (menuItemStr[k] == '\t') if (menuItemStr[k] == '\t')
{ {
@ -347,7 +361,8 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
} }
cleanedName[j] = 0; cleanedName[j] = 0;
return cleanedName; return cleanedName;
}; }
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed) const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed)
{ {
@ -366,7 +381,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs, NULL, 0); lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs, NULL, 0);
} }
// Otherwise, test if we are cutting a multi-byte character at end of buffer // Otherwise, test if we are cutting a multi-byte character at end of buffer
else if(lenMbcs != -1 && codepage == CP_UTF8) // For UTF-8, we know how to test it else if (lenMbcs != -1 && codepage == CP_UTF8) // For UTF-8, we know how to test it
{ {
int indexOfLastChar = Utf8::characterStart(mbcs2Convert, lenMbcs-1); // get index of last character int indexOfLastChar = Utf8::characterStart(mbcs2Convert, lenMbcs-1); // get index of last character
if (indexOfLastChar != 0 && !Utf8::isValid(mbcs2Convert+indexOfLastChar, lenMbcs-indexOfLastChar)) // if it is not valid we do not process it right now (unless its the only character in string, to ensure that we always progress, e.g. that bytesNotProcessed < lenMbcs) if (indexOfLastChar != 0 && !Utf8::isValid(mbcs2Convert+indexOfLastChar, lenMbcs-indexOfLastChar)) // if it is not valid we do not process it right now (unless its the only character in string, to ensure that we always progress, e.g. that bytesNotProcessed < lenMbcs)
@ -404,11 +419,12 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
else else
_wideCharStr.empty(); _wideCharStr.empty();
if(pLenWc) *pLenWc = lenWc; if (pLenWc) *pLenWc = lenWc;
if(pBytesNotProcessed) *pBytesNotProcessed = bytesNotProcessed; if (pBytesNotProcessed) *pBytesNotProcessed = bytesNotProcessed;
return _wideCharStr; return _wideCharStr;
} }
// "mstart" and "mend" are pointers to indexes in mbcs2Convert, // "mstart" and "mend" are pointers to indexes in mbcs2Convert,
// which are converted to the corresponding indexes in the returned wchar_t string. // which are converted to the corresponding indexes in the returned wchar_t string.
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend) const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
@ -440,9 +456,10 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
*mend = 0; *mend = 0;
} }
return _wideCharStr; return _wideCharStr;
} }
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, int lenWc, int *pLenMbcs)
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, int lenWc, int *pLenMbcs)
{ {
// Do not process NULL pointer // Do not process NULL pointer
if (!wcharStr2Convert) return NULL; if (!wcharStr2Convert) return NULL;
@ -456,11 +473,13 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
else else
_multiByteStr.empty(); _multiByteStr.empty();
if(pLenMbcs) *pLenMbcs = lenMbcs; if (pLenMbcs)
*pLenMbcs = lenMbcs;
return _multiByteStr; return _multiByteStr;
} }
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, long *mstart, long *mend)
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, long *mstart, long *mend)
{ {
// Do not process NULL pointer // Do not process NULL pointer
if (!wcharStr2Convert) return NULL; if (!wcharStr2Convert) return NULL;
@ -488,11 +507,12 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
return _multiByteStr; return _multiByteStr;
} }
std::wstring string2wstring(const std::string & rString, UINT codepage) std::wstring string2wstring(const std::string & rString, UINT codepage)
{ {
int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0); int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0);
if(len > 0) if (len > 0)
{ {
std::vector<wchar_t> vw(len); std::vector<wchar_t> vw(len);
MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len); MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len);
return &vw[0]; return &vw[0];
@ -504,8 +524,8 @@ std::wstring string2wstring(const std::string & rString, UINT codepage)
std::string wstring2string(const std::wstring & rwString, UINT codepage) std::string wstring2string(const std::wstring & rwString, UINT codepage)
{ {
int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL); int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL);
if(len > 0) if (len > 0)
{ {
std::vector<char> vw(len); std::vector<char> vw(len);
WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL); WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL);
return &vw[0]; return &vw[0];
@ -563,7 +583,7 @@ generic_string uintToString(unsigned int val)
return generic_string(vt.rbegin(), vt.rend()); return generic_string(vt.rbegin(), vt.rend());
} }
// Build Recent File menu entries from given // Build Recent File menu entries from given
generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename) generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generic_string &filename)
{ {
generic_string strTemp; generic_string strTemp;
@ -582,7 +602,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
strTemp.append(uintToString(pos + 1)); strTemp.append(uintToString(pos + 1));
} }
strTemp.append(TEXT(": ")); strTemp.append(TEXT(": "));
if (filenameLen > 0) if (filenameLen > 0)
{ {
std::vector<TCHAR> vt(filenameLen + 1); std::vector<TCHAR> vt(filenameLen + 1);
@ -614,6 +634,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
return strTemp; return strTemp;
} }
generic_string PathRemoveFileSpec(generic_string & path) generic_string PathRemoveFileSpec(generic_string & path)
{ {
generic_string::size_type lastBackslash = path.find_last_of(TEXT('\\')); generic_string::size_type lastBackslash = path.find_last_of(TEXT('\\'));
@ -636,6 +657,7 @@ generic_string PathRemoveFileSpec(generic_string & path)
return path; return path;
} }
generic_string PathAppend(generic_string &strDest, const generic_string & str2append) generic_string PathAppend(generic_string &strDest, const generic_string & str2append)
{ {
if (strDest == TEXT("") && str2append == TEXT("")) // "" + "" if (strDest == TEXT("") && str2append == TEXT("")) // "" + ""
@ -671,6 +693,7 @@ generic_string PathAppend(generic_string &strDest, const generic_string & str2ap
return strDest; return strDest;
} }
COLORREF getCtrlBgColor(HWND hWnd) COLORREF getCtrlBgColor(HWND hWnd)
{ {
COLORREF crRet = CLR_INVALID; COLORREF crRet = CLR_INVALID;
@ -709,12 +732,14 @@ COLORREF getCtrlBgColor(HWND hWnd)
return crRet; return crRet;
} }
generic_string stringToUpper(generic_string strToConvert) generic_string stringToUpper(generic_string strToConvert)
{ {
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper); std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper);
return strToConvert; return strToConvert;
} }
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace) generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace)
{ {
size_t pos = 0; size_t pos = 0;
@ -726,6 +751,7 @@ generic_string stringReplace(generic_string subject, const generic_string& searc
return subject; return subject;
} }
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter) std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter)
{ {
auto start = 0U; auto start = 0U;
@ -742,6 +768,7 @@ std::vector<generic_string> stringSplit(const generic_string& input, const gener
return output; return output;
} }
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator) generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator)
{ {
generic_string joined; generic_string joined;
@ -757,6 +784,7 @@ generic_string stringJoin(const std::vector<generic_string>& strings, const gene
return joined; return joined;
} }
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable) generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable)
{ {
// Find first non-admissable character in "input", and remove everything after it. // Find first non-admissable character in "input", and remove everything after it.
@ -771,6 +799,7 @@ generic_string stringTakeWhileAdmissable(const generic_string& input, const gene
} }
} }
double stodLocale(const generic_string& str, _locale_t loc, size_t* idx) double stodLocale(const generic_string& str, _locale_t loc, size_t* idx)
{ {
// Copied from the std::stod implementation but uses _wcstod_l instead of wcstod. // Copied from the std::stod implementation but uses _wcstod_l instead of wcstod.
@ -832,4 +861,7 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd)
return false; return false;
} }
return true; return true;
} }

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -126,7 +126,7 @@ public:
const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend); const wchar_t * char2wchar(const char *mbcs2Convert, UINT codepage, int *mstart, int *mend);
const char * wchar2char(const wchar_t *wcStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL); const char * wchar2char(const wchar_t *wcStr, UINT codepage, int lenIn=-1, int *pLenOut=NULL);
const char * wchar2char(const wchar_t *wcStr, UINT codepage, long *mstart, long *mend); const char * wchar2char(const wchar_t *wcStr, UINT codepage, long *mstart, long *mend);
const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL) { const char * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL) {
int lenWc = 0; int lenWc = 0;
const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed); const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed);
@ -134,19 +134,20 @@ public:
}; };
protected: protected:
WcharMbcsConvertor() { WcharMbcsConvertor() {}
}; ~WcharMbcsConvertor() {}
~WcharMbcsConvertor() {
};
static WcharMbcsConvertor * _pSelf; static WcharMbcsConvertor * _pSelf;
template <class T> template <class T>
class StringBuffer { class StringBuffer
{
public: public:
StringBuffer() : _str(0), _allocLen(0) { } StringBuffer() : _str(0), _allocLen(0) { }
~StringBuffer() { if(_allocLen) delete [] _str; } ~StringBuffer() { if(_allocLen) delete [] _str; }
void sizeTo(size_t size) { void sizeTo(size_t size)
{
if(_allocLen < size) if(_allocLen < size)
{ {
if(_allocLen) delete[] _str; if(_allocLen) delete[] _str;
@ -154,7 +155,8 @@ protected:
_str = new T[_allocLen]; _str = new T[_allocLen];
} }
} }
void empty() { void empty()
{
static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case
if(_allocLen == 0) if(_allocLen == 0)
_str = &nullStr; _str = &nullStr;
@ -176,9 +178,10 @@ protected:
private: private:
// Since there's no public ctor, we need to void the default assignment operator. // Since there's no public ctor, we need to void the default assignment operator.
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&); WcharMbcsConvertor& operator= (const WcharMbcsConvertor&);
}; };
#define MACRO_RECORDING_IN_PROGRESS 1 #define MACRO_RECORDING_IN_PROGRESS 1
#define MACRO_RECORDING_HAS_STOPPED 2 #define MACRO_RECORDING_HAS_STOPPED 2

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.

View File

@ -10,10 +10,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.

View File

@ -10,10 +10,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -49,4 +49,4 @@ public:
bool writeDump(EXCEPTION_POINTERS * pExceptionInfo); bool writeDump(EXCEPTION_POINTERS * pExceptionInfo);
}; };
#endif //MDUMP_H #endif //MDUMP_H

View File

@ -13,10 +13,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -35,11 +35,13 @@
#include "Win32Exception.h" #include "Win32Exception.h"
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) { Win32Exception::Win32Exception(EXCEPTION_POINTERS * info)
{
_location = info->ExceptionRecord->ExceptionAddress; _location = info->ExceptionRecord->ExceptionAddress;
_code = info->ExceptionRecord->ExceptionCode; _code = info->ExceptionRecord->ExceptionCode;
_info = info; _info = info;
switch (_code) { switch (_code)
{
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
_event = "Access violation"; _event = "Access violation";
break; break;
@ -52,17 +54,21 @@ Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
} }
} }
void Win32Exception::installHandler() { void Win32Exception::installHandler()
{
_set_se_translator(Win32Exception::translate); _set_se_translator(Win32Exception::translate);
} }
void Win32Exception::removeHandler() { void Win32Exception::removeHandler()
{
_set_se_translator(NULL); _set_se_translator(NULL);
} }
void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) { void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info)
{
// Windows guarantees that *(info->ExceptionRecord) is valid // Windows guarantees that *(info->ExceptionRecord) is valid
switch (code) { switch (code)
{
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
throw Win32AccessViolation(info); throw Win32AccessViolation(info);
break; break;
@ -71,7 +77,12 @@ void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) {
} }
} }
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info) : Win32Exception(info) {
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info)
: Win32Exception(info)
{
_isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1; _isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1;
_badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]); _badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]);
} }

View File

@ -13,10 +13,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -42,16 +42,16 @@ typedef const void* ExceptionAddress; // OK on Win32 platform
class Win32Exception : public std::exception class Win32Exception : public std::exception
{ {
public: public:
static void installHandler(); static void installHandler();
static void removeHandler(); static void removeHandler();
virtual const char* what() const throw() { return _event; }; virtual const char* what() const throw() { return _event; }
ExceptionAddress where() const { return _location; }; ExceptionAddress where() const { return _location; }
unsigned int code() const { return _code; }; unsigned int code() const { return _code; }
EXCEPTION_POINTERS* info() const { return _info; }; EXCEPTION_POINTERS* info() const { return _info; }
protected: protected:
Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler
static void translate(unsigned code, EXCEPTION_POINTERS * info); static void translate(unsigned code, EXCEPTION_POINTERS * info);
private: private:
const char * _event; const char * _event;
@ -61,11 +61,12 @@ private:
EXCEPTION_POINTERS * _info; EXCEPTION_POINTERS * _info;
}; };
class Win32AccessViolation: public Win32Exception class Win32AccessViolation: public Win32Exception
{ {
public: public:
bool isWrite() const { return _isWrite; }; bool isWrite() const { return _isWrite; }
ExceptionAddress badAddress() const { return _badAddress; }; ExceptionAddress badAddress() const { return _badAddress; }
private: private:
Win32AccessViolation(EXCEPTION_POINTERS * info); Win32AccessViolation(EXCEPTION_POINTERS * info);
@ -75,4 +76,4 @@ private:
friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info); friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info);
}; };
#endif // WIN32_EXCEPTION_H #endif // WIN32_EXCEPTION_H

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -31,10 +31,13 @@
typedef std::vector<generic_string> stringVector; typedef std::vector<generic_string> stringVector;
class FileNameStringSplitter class FileNameStringSplitter
{ {
public : public:
FileNameStringSplitter(const TCHAR *fileNameStr) { FileNameStringSplitter(const TCHAR *fileNameStr)
{
//if (!fileNameStr) return; //if (!fileNameStr) return;
TCHAR *pStr = NULL; TCHAR *pStr = NULL;
bool isInsideQuotes = false; bool isInsideQuotes = false;
@ -43,6 +46,7 @@ public :
TCHAR str[filePathLength]; TCHAR str[filePathLength];
int i = 0; int i = 0;
bool fini = false; bool fini = false;
for (pStr = (TCHAR *)fileNameStr ; !fini ; ) for (pStr = (TCHAR *)fileNameStr ; !fini ; )
{ {
if (i >= filePathLength) if (i >= filePathLength)
@ -50,7 +54,8 @@ public :
switch (*pStr) switch (*pStr)
{ {
case '"' : case '"':
{
if (isInsideQuotes) if (isInsideQuotes)
{ {
str[i] = '\0'; str[i] = '\0';
@ -61,12 +66,14 @@ public :
isInsideQuotes = !isInsideQuotes; isInsideQuotes = !isInsideQuotes;
pStr++; pStr++;
break; break;
}
case ' ' :
case ' ':
{
if (isInsideQuotes) if (isInsideQuotes)
{ {
str[i] = *pStr; str[i] = *pStr;
i++; i++;
} }
else else
{ {
@ -77,34 +84,41 @@ public :
} }
pStr++; pStr++;
break; break;
}
case '\0' :
case '\0':
{
str[i] = *pStr; str[i] = *pStr;
if (str[0]) if (str[0])
_fileNames.push_back(generic_string(str)); _fileNames.push_back(generic_string(str));
fini = true; fini = true;
break; break;
}
default : default :
{
str[i] = *pStr; str[i] = *pStr;
i++; pStr++; i++; pStr++;
break; break;
}
} }
} }
}; }
const TCHAR * getFileName(size_t index) const { const TCHAR * getFileName(size_t index) const {
if (index >= _fileNames.size()) if (index >= _fileNames.size())
return NULL; return NULL;
return _fileNames[index].c_str(); return _fileNames[index].c_str();
}; }
int size() const { int size() const {
return int(_fileNames.size()); return int(_fileNames.size());
}; }
private : private :
stringVector _fileNames; stringVector _fileNames;
}; };
#endif //FILENAME_STRING_SPLITTER_H #endif //FILENAME_STRING_SPLITTER_H

View File

@ -9,10 +9,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -50,4 +50,4 @@ int IDAllocator::allocate(int quantity)
return retVal; return retVal;
} }

View File

@ -9,10 +9,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -35,7 +35,7 @@ class IDAllocator
{ {
public: public:
IDAllocator(int start, int maximumID); IDAllocator(int start, int maximumID);
/// Returns -1 if not enough available /// Returns -1 if not enough available
int allocate(int quantity); int allocate(int quantity);

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -46,7 +46,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//Here you can find how to use these messages : http://docs.notepad-plus-plus.org/index.php/Messages_And_Notifications //Here you can find how to use these messages : http://docs.notepad-plus-plus.org/index.php/Messages_And_Notifications
#define NPPMSG (WM_USER + 1000) #define NPPMSG (WM_USER + 1000)
#define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4) #define NPPM_GETCURRENTSCINTILLA (NPPMSG + 4)
@ -78,7 +78,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
#define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17) #define NPPM_GETOPENFILENAMESPRIMARY (NPPMSG + 17)
#define NPPM_GETOPENFILENAMESSECOND (NPPMSG + 18) #define NPPM_GETOPENFILENAMESSECOND (NPPMSG + 18)
#define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20) #define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20)
#define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21) #define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21)
#define NPPM_GETNBUSERLANG (NPPMSG + 22) #define NPPM_GETNBUSERLANG (NPPMSG + 22)
@ -105,7 +105,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//ascii file to unicode //ascii file to unicode
//int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0) //int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0)
//return new unicodeMode //return new unicodeMode
#define NPPM_DECODESCI (NPPMSG + 27) #define NPPM_DECODESCI (NPPMSG + 27)
//unicode file to ascii //unicode file to ascii
//int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0) //int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0)
@ -164,7 +164,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName) //HWND WM_DMM_GETPLUGINHWNDBYNAME(const TCHAR *windowName, const TCHAR *moduleName)
// if moduleName is NULL, then return value is NULL // 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 // if windowName is NULL, then the first found window handle which matches with the moduleName will be returned
#define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44) #define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0) //BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)
@ -189,13 +189,13 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// uncomment //#include "menuCmdID.h" // uncomment //#include "menuCmdID.h"
// in the beginning of this file then use the command symbols defined in "menuCmdID.h" file // in the beginning of this file then use the command symbols defined in "menuCmdID.h" file
// to access all the Notepad++ menu command items // to access all the Notepad++ menu command items
#define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49) #define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49)
//void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate) //void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate)
#define NPPM_GETNPPVERSION (NPPMSG + 50) #define NPPM_GETNPPVERSION (NPPMSG + 50)
// int NPPM_GETNPPVERSION(0, 0) // int NPPM_GETNPPVERSION(0, 0)
// return version // return version
// ex : v4.6 // ex : v4.6
// HIWORD(version) == 4 // HIWORD(version) == 4
// LOWORD(version) == 6 // LOWORD(version) == 6
@ -215,14 +215,14 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing // Return VIEW|INDEX from a buffer ID. -1 if the bufferID non existing
// if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly // if priorityView set to SUB_VIEW, then SUB_VIEW will be search firstly
// //
// VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits) // VIEW takes 2 highest bits and INDEX (0 based) takes the rest (30 bits)
// Here's the values for the view : // Here's the values for the view :
// MAIN_VIEW 0 // MAIN_VIEW 0
// SUB_VIEW 1 // SUB_VIEW 1
#define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58) #define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58)
// INT NPPM_GETFULLPATHFROMBUFFERID(INT bufferID, TCHAR *fullFilePath) // INT NPPM_GETFULLPATHFROMBUFFERID(INT bufferID, TCHAR *fullFilePath)
// Get full path file name from a bufferID. // Get full path file name from a bufferID.
// Return -1 if the bufferID non existing, otherwise the number of TCHAR copied/to copy // 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), // 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 // allocate fullFilePath with the return values + 1, then call it again to get full path file name
@ -365,7 +365,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// Get programing language name from the given language type (LangType) // Get programing language name from the given language type (LangType)
// Return value is the number of copied character / number of character to copy (\0 is not included) // Return value is the number of copied character / number of character to copy (\0 is not included)
// You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy. // You should call this function 2 times - the first time you pass langName as NULL to get the number of characters to copy.
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGENAME function the 2nd time
// by passing allocated buffer as argument langName // by passing allocated buffer as argument langName
#define NPPM_GETLANGUAGEDESC (NPPMSG + 84) #define NPPM_GETLANGUAGEDESC (NPPMSG + 84)
@ -373,7 +373,7 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
// Get programing language short description from the given language type (LangType) // Get programing language short description from the given language type (LangType)
// Return value is the number of copied character / number of character to copy (\0 is not included) // Return value is the number of copied character / number of character to copy (\0 is not included)
// You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy. // You should call this function 2 times - the first time you pass langDesc as NULL to get the number of characters to copy.
// You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time // You allocate a buffer of the length of (the number of characters + 1) then call NPPM_GETLANGUAGEDESC function the 2nd time
// by passing allocated buffer as argument langDesc // by passing allocated buffer as argument langDesc
#define NPPM_SHOWDOCSWITCHER (NPPMSG + 85) #define NPPM_SHOWDOCSWITCHER (NPPMSG + 85)
@ -470,12 +470,12 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID; //scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved #define NPPN_FILEBEFORESAVE (NPPN_FIRST + 7) // To notify plugins that the current file is about to be saved
//scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN; //scnNotification->nmhdr.code = NPPN_FILEBEFOREOPEN;
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;
//scnNotification->nmhdr.idFrom = BufferID; //scnNotification->nmhdr.idFrom = BufferID;
#define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved #define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved
//scnNotification->nmhdr.code = NPPN_FILESAVED; //scnNotification->nmhdr.code = NPPN_FILESAVED;
//scnNotification->nmhdr.hwndFrom = hwndNpp; //scnNotification->nmhdr.hwndFrom = hwndNpp;

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -41,7 +41,8 @@ const int nbChar = 64;
typedef const TCHAR * (__cdecl * PFUNCGETNAME)(); typedef const TCHAR * (__cdecl * PFUNCGETNAME)();
struct NppData { struct NppData
{
HWND _nppHandle; HWND _nppHandle;
HWND _scintillaMainHandle; HWND _scintillaMainHandle;
HWND _scintillaSecondHandle; HWND _scintillaSecondHandle;
@ -53,14 +54,16 @@ typedef void (__cdecl * PBENOTIFIED)(SCNotification *);
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam); typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);
struct ShortcutKey { struct ShortcutKey
{
bool _isCtrl; bool _isCtrl;
bool _isAlt; bool _isAlt;
bool _isShift; bool _isShift;
UCHAR _key; UCHAR _key;
}; };
struct FuncItem { struct FuncItem
{
TCHAR _itemName[nbChar]; TCHAR _itemName[nbChar];
PFUNCPLUGINCMD _pFunc; PFUNCPLUGINCMD _pFunc;
int _cmdID; int _cmdID;

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -35,6 +35,10 @@ using namespace std;
const TCHAR * USERMSG = TEXT("This plugin is not compatible with current version of Notepad++.\n\n\ const TCHAR * USERMSG = TEXT("This plugin is not compatible with current version of Notepad++.\n\n\
Do you want to remove this plugin from plugins directory to prevent this message from the next launch time?"); Do you want to remove this plugin from plugins directory to prevent this message from the next launch time?");
bool PluginsManager::unloadPlugin(int index, HWND nppHandle) bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
{ {
SCNotification scnN; SCNotification scnN;
@ -58,6 +62,7 @@ bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
return true; return true;
} }
int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_string> & dll2Remove) int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_string> & dll2Remove)
{ {
const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath); const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath);
@ -65,9 +70,10 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
return 0; return 0;
PluginInfo *pi = new PluginInfo; PluginInfo *pi = new PluginInfo;
try { try
{
pi->_moduleName = PathFindFileName(pluginFilePath); pi->_moduleName = PathFindFileName(pluginFilePath);
pi->_hLib = ::LoadLibrary(pluginFilePath); pi->_hLib = ::LoadLibrary(pluginFilePath);
if (!pi->_hLib) if (!pi->_hLib)
throw generic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem.")); throw generic_string(TEXT("Load Library is failed.\nMake \"Runtime Library\" setting of this project as \"Multi-threaded(/MT)\" may cure this problem."));
@ -77,7 +83,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
throw generic_string(TEXT("This ANSI plugin is not compatible with your Unicode Notepad++.")); throw generic_string(TEXT("This ANSI plugin is not compatible with your Unicode Notepad++."));
pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo"); pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo");
if (!pi->_pFuncSetInfo) if (!pi->_pFuncSetInfo)
throw generic_string(TEXT("Missing \"setInfo\" function")); throw generic_string(TEXT("Missing \"setInfo\" function"));
@ -92,11 +98,11 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
pi->_pMessageProc = (PMESSAGEPROC)GetProcAddress(pi->_hLib, "messageProc"); pi->_pMessageProc = (PMESSAGEPROC)GetProcAddress(pi->_hLib, "messageProc");
if (!pi->_pMessageProc) if (!pi->_pMessageProc)
throw generic_string(TEXT("Missing \"messageProc\" function")); throw generic_string(TEXT("Missing \"messageProc\" function"));
pi->_pFuncSetInfo(_nppData); pi->_pFuncSetInfo(_nppData);
pi->_pFuncGetFuncsArray = (PFUNCGETFUNCSARRAY)GetProcAddress(pi->_hLib, "getFuncsArray"); pi->_pFuncGetFuncsArray = (PFUNCGETFUNCSARRAY)GetProcAddress(pi->_hLib, "getFuncsArray");
if (!pi->_pFuncGetFuncsArray) if (!pi->_pFuncGetFuncsArray)
throw generic_string(TEXT("Missing \"getFuncsArray\" function")); throw generic_string(TEXT("Missing \"getFuncsArray\" function"));
pi->_funcItems = pi->_pFuncGetFuncsArray(&pi->_nbFuncItem); pi->_funcItems = pi->_pFuncGetFuncsArray(&pi->_nbFuncItem);
@ -105,7 +111,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
throw generic_string(TEXT("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly")); throw generic_string(TEXT("Missing \"FuncItems\" array, or the nb of Function Item is not set correctly"));
pi->_pluginMenu = ::CreateMenu(); pi->_pluginMenu = ::CreateMenu();
GetLexerCountFn GetLexerCount = (GetLexerCountFn)::GetProcAddress(pi->_hLib, "GetLexerCount"); GetLexerCountFn GetLexerCount = (GetLexerCountFn)::GetProcAddress(pi->_hLib, "GetLexerCount");
// it's a lexer plugin // it's a lexer plugin
if (GetLexerCount) if (GetLexerCount)
@ -128,7 +134,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
int numLexers = GetLexerCount(); int numLexers = GetLexerCount();
NppParameters * nppParams = NppParameters::getInstance(); NppParameters * nppParams = NppParameters::getInstance();
ExternalLangContainer *containers[30]; ExternalLangContainer *containers[30];
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance(); WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
@ -158,7 +164,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
PathAppend(xmlPath, pi->_moduleName.c_str()); PathAppend(xmlPath, pi->_moduleName.c_str());
PathRemoveExtension( xmlPath ); PathRemoveExtension( xmlPath );
PathAddExtension( xmlPath, TEXT(".xml") ); PathAddExtension( xmlPath, TEXT(".xml") );
if (! PathFileExists( xmlPath ) ) if (! PathFileExists( xmlPath ) )
{ {
throw generic_string(generic_string(xmlPath) + TEXT(" is missing.")); throw generic_string(generic_string(xmlPath) + TEXT(" is missing."));
@ -173,24 +179,30 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
pXmlDoc = NULL; pXmlDoc = NULL;
throw generic_string(generic_string(xmlPath) + TEXT(" failed to load.")); throw generic_string(generic_string(xmlPath) + TEXT(" failed to load."));
} }
for (int x = 0; x < numLexers; ++x) // postpone adding in case the xml is missing/corrupt for (int x = 0; x < numLexers; ++x) // postpone adding in case the xml is missing/corrupt
{
if (containers[x] != NULL) if (containers[x] != NULL)
nppParams->addExternalLangToEnd(containers[x]); nppParams->addExternalLangToEnd(containers[x]);
}
nppParams->getExternalLexerFromXmlTree(pXmlDoc); nppParams->getExternalLexerFromXmlTree(pXmlDoc);
nppParams->getExternalLexerDoc()->push_back(pXmlDoc); nppParams->getExternalLexerDoc()->push_back(pXmlDoc);
const char *pDllName = wmc->wchar2char(pluginFilePath, CP_ACP); const char *pDllName = wmc->wchar2char(pluginFilePath, CP_ACP);
::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)pDllName); ::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)pDllName);
} }
addInLoadedDlls(pluginFileName); addInLoadedDlls(pluginFileName);
_pluginInfos.push_back(pi); _pluginInfos.push_back(pi);
return (_pluginInfos.size() - 1); return (_pluginInfos.size() - 1);
} catch(std::exception e) { }
catch (std::exception e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
return -1; return -1;
} catch(generic_string s) { }
catch (generic_string s)
{
s += TEXT("\n\n"); s += TEXT("\n\n");
s += USERMSG; s += USERMSG;
if (::MessageBox(NULL, s.c_str(), pluginFilePath, MB_YESNO) == IDYES) if (::MessageBox(NULL, s.c_str(), pluginFilePath, MB_YESNO) == IDYES)
@ -199,7 +211,9 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
} }
delete pi; delete pi;
return -1; return -1;
} catch(...) { }
catch (...)
{
generic_string msg = TEXT("Failed to load"); generic_string msg = TEXT("Failed to load");
msg += TEXT("\n\n"); msg += TEXT("\n\n");
msg += USERMSG; msg += USERMSG;
@ -256,7 +270,7 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
{ {
loadPlugin(dllNames[i].c_str(), dll2Remove); loadPlugin(dllNames[i].c_str(), dll2Remove);
} }
} }
for (size_t j = 0, len = dll2Remove.size() ; j < len ; ++j) for (size_t j = 0, len = dll2Remove.size() ; j < len ; ++j)
@ -306,9 +320,9 @@ void PluginsManager::addInMenuFromPMIndex(int i)
::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT("")); ::InsertMenu(_pluginInfos[i]->_pluginMenu, j, MF_BYPOSITION | MF_SEPARATOR, 0, TEXT(""));
continue; continue;
} }
_pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName.c_str(), j, _pluginInfos[i]->_funcItems[j]._pFunc)); _pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName.c_str(), j, _pluginInfos[i]->_funcItems[j]._pFunc));
int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1); int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1);
_pluginInfos[i]->_funcItems[j]._cmdID = cmdID; _pluginInfos[i]->_funcItems[j]._cmdID = cmdID;
generic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName; generic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName;
@ -366,11 +380,16 @@ void PluginsManager::runPluginCommand(size_t i)
{ {
if (_pluginsCommands[i]._pFunc != NULL) if (_pluginsCommands[i]._pFunc != NULL)
{ {
try { try
{
_pluginsCommands[i]._pFunc(); _pluginsCommands[i]._pFunc();
} catch(std::exception e) { }
catch (std::exception e)
{
::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK);
} catch (...) { }
catch (...)
{
TCHAR funcInfo[128]; TCHAR funcInfo[128];
generic_sprintf(funcInfo, TEXT("runPluginCommand(size_t i : %d)"), i); generic_sprintf(funcInfo, TEXT("runPluginCommand(size_t i : %d)"), i);
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
@ -388,11 +407,16 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
{ {
if (_pluginsCommands[i]._funcID == commandID) if (_pluginsCommands[i]._funcID == commandID)
{ {
try { try
{
_pluginsCommands[i]._pFunc(); _pluginsCommands[i]._pFunc();
} catch(std::exception e) { }
catch (std::exception e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) { }
catch (...)
{
TCHAR funcInfo[128]; TCHAR funcInfo[128];
generic_sprintf(funcInfo, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID); generic_sprintf(funcInfo, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID);
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
@ -402,6 +426,7 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
} }
} }
void PluginsManager::notify(const SCNotification *notification) void PluginsManager::notify(const SCNotification *notification)
{ {
for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i) for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i)
@ -411,11 +436,16 @@ void PluginsManager::notify(const SCNotification *notification)
// To avoid the plugin change the data in SCNotification // To avoid the plugin change the data in SCNotification
// Each notification to pass to a plugin is a copy of SCNotification instance // Each notification to pass to a plugin is a copy of SCNotification instance
SCNotification scNotif = *notification; SCNotification scNotif = *notification;
try { try
{
_pluginInfos[i]->_pBeNotified(&scNotif); _pluginInfos[i]->_pBeNotified(&scNotif);
} catch(std::exception e) { }
catch (std::exception e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) { }
catch (...)
{
TCHAR funcInfo[128]; TCHAR funcInfo[128];
generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %d"),\ generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %d"),\
scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom); scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom);
@ -425,17 +455,23 @@ void PluginsManager::notify(const SCNotification *notification)
} }
} }
void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam) void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam)
{ {
for (size_t i = 0, len = _pluginInfos.size(); i < len ; ++i) for (size_t i = 0, len = _pluginInfos.size(); i < len ; ++i)
{ {
if (_pluginInfos[i]->_hLib) if (_pluginInfos[i]->_hLib)
{ {
try { try
{
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam); _pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
} catch(std::exception e) { }
catch (std::exception e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) { }
catch (...)
{
TCHAR funcInfo[128]; TCHAR funcInfo[128];
generic_sprintf(funcInfo, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam); generic_sprintf(funcInfo, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT("")); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT(""));
@ -444,6 +480,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam
} }
} }
bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam) bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam)
{ {
const TCHAR * moduleName = (const TCHAR *)wParam; const TCHAR * moduleName = (const TCHAR *)wParam;
@ -456,11 +493,16 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa
{ {
if (_pluginInfos[i]->_hLib) if (_pluginInfos[i]->_hLib)
{ {
try { try
{
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam); _pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
} catch(std::exception e) { }
catch (std::exception e)
{
::MessageBoxA(NULL, e.what(), "Exception", MB_OK); ::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
} catch (...) { }
catch (...)
{
TCHAR funcInfo[128]; TCHAR funcInfo[128];
generic_sprintf(funcInfo, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam); generic_sprintf(funcInfo, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo); pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
@ -497,4 +539,5 @@ bool PluginsManager::allocateMarker(int numberRequired, int *start)
retVal = false; retVal = false;
} }
return retVal; return retVal;
} }

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -47,24 +47,27 @@
typedef BOOL (__cdecl * PFUNCISUNICODE)(); typedef BOOL (__cdecl * PFUNCISUNICODE)();
struct PluginCommand { struct PluginCommand
{
generic_string _pluginName; generic_string _pluginName;
int _funcID; int _funcID;
PFUNCPLUGINCMD _pFunc; PFUNCPLUGINCMD _pFunc;
PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc), _pluginName(pluginName){}; PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc), _pluginName(pluginName){};
}; };
struct PluginInfo { struct PluginInfo
{
PluginInfo() :_hLib(NULL), _pluginMenu(NULL), _pFuncSetInfo(NULL),\ PluginInfo() :_hLib(NULL), _pluginMenu(NULL), _pFuncSetInfo(NULL),\
_pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\ _pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\
_nbFuncItem(0){}; _nbFuncItem(0){}
~PluginInfo(){ ~PluginInfo()
{
if (_pluginMenu) if (_pluginMenu)
::DestroyMenu(_pluginMenu); ::DestroyMenu(_pluginMenu);
if (_hLib) if (_hLib)
::FreeLibrary(_hLib); ::FreeLibrary(_hLib);
}; }
HINSTANCE _hLib; HINSTANCE _hLib;
HMENU _pluginMenu; HMENU _pluginMenu;
@ -75,31 +78,34 @@ struct PluginInfo {
PFUNCGETFUNCSARRAY _pFuncGetFuncsArray; PFUNCGETFUNCSARRAY _pFuncGetFuncsArray;
PMESSAGEPROC _pMessageProc; PMESSAGEPROC _pMessageProc;
PFUNCISUNICODE _pFuncIsUnicode; PFUNCISUNICODE _pFuncIsUnicode;
FuncItem *_funcItems; FuncItem *_funcItems;
int _nbFuncItem; int _nbFuncItem;
generic_string _moduleName; generic_string _moduleName;
}; };
class PluginsManager { class PluginsManager
{
public: public:
PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false), _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT), PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false), _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT),
_markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {}; _markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {}
~PluginsManager() { ~PluginsManager()
{
for (size_t i = 0, len = _pluginInfos.size(); i < len; ++i) for (size_t i = 0, len = _pluginInfos.size(); i < len; ++i)
delete _pluginInfos[i]; delete _pluginInfos[i];
if (_hPluginsMenu) if (_hPluginsMenu)
DestroyMenu(_hPluginsMenu); DestroyMenu(_hPluginsMenu);
}; }
void init(const NppData & nppData) {
void init(const NppData & nppData)
{
_nppData = nppData; _nppData = nppData;
}; }
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove); int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
bool loadPlugins(const TCHAR *dir = NULL); bool loadPlugins(const TCHAR *dir = NULL);
bool unloadPlugin(int index, HWND nppHandle); bool unloadPlugin(int index, HWND nppHandle);
void runPluginCommand(size_t i); void runPluginCommand(size_t i);
@ -113,12 +119,10 @@ public:
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam); void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam); bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam);
HMENU getMenuHandle() { HMENU getMenuHandle() const { return _hPluginsMenu; }
return _hPluginsMenu;
};
void disable() {_isDisabled = true;}; void disable() {_isDisabled = true;}
bool hasPlugins(){return (_pluginInfos.size()!= 0);}; bool hasPlugins() {return (_pluginInfos.size()!= 0);}
bool allocateCmdID(int numberRequired, int *start); bool allocateCmdID(int numberRequired, int *start);
bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); } bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); }
@ -135,22 +139,26 @@ private:
bool _isDisabled; bool _isDisabled;
IDAllocator _dynamicIDAlloc; IDAllocator _dynamicIDAlloc;
IDAllocator _markerAlloc; IDAllocator _markerAlloc;
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) {
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature)
{
generic_string msg = pluginName; generic_string msg = pluginName;
msg += TEXT(" just crash in\r"); msg += TEXT(" just crash in\r");
msg += funcSignature; msg += funcSignature;
::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP); ::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP);
}; }
bool isInLoadedDlls(const TCHAR *fn) const {
bool isInLoadedDlls(const TCHAR *fn) const
{
for (size_t i = 0; i < _loadedDlls.size(); ++i) for (size_t i = 0; i < _loadedDlls.size(); ++i)
if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0) if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0)
return true; return true;
return false; return false;
}; }
void addInLoadedDlls(const TCHAR *fn) { void addInLoadedDlls(const TCHAR *fn) {
_loadedDlls.push_back(fn); _loadedDlls.push_back(fn);
}; }
}; };
#define EXT_LEXER_DECL __stdcall #define EXT_LEXER_DECL __stdcall

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -31,14 +31,14 @@
enum progType {WIN32_PROG, CONSOLE_PROG}; enum progType {WIN32_PROG, CONSOLE_PROG};
class Process class Process
{ {
public: public:
Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir) Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir)
:_command(cmd), _args(args), _curDir(cDir){}; :_command(cmd), _args(args), _curDir(cDir){}
void run(); void run();
protected: protected:
generic_string _command; generic_string _command;
generic_string _args; generic_string _args;

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -30,6 +30,9 @@
#include "process.h" #include "process.h"
//#include "SysMsg.h" //#include "SysMsg.h"
BOOL Process::run() BOOL Process::run()
{ {
BOOL result = TRUE; BOOL result = TRUE;
@ -47,11 +50,12 @@ BOOL Process::run()
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle
try { try
{
// Create stdout pipe // Create stdout pipe
if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0)) if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0))
error(TEXT("CreatePipe"), result, 1000); error(TEXT("CreatePipe"), result, 1000);
// Create stderr pipe // Create stderr pipe
if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0)) if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0))
error(TEXT("CreatePipe"), result, 1001); error(TEXT("CreatePipe"), result, 1001);
@ -76,32 +80,34 @@ BOOL Process::run()
_curDir, // inherit directory _curDir, // inherit directory
&startup, // STARTUPINFO &startup, // STARTUPINFO
&procinfo); // PROCESS_INFORMATION &procinfo); // PROCESS_INFORMATION
_hProcess = procinfo.hProcess; _hProcess = procinfo.hProcess;
_hProcessThread = procinfo.hThread; _hProcessThread = procinfo.hThread;
if(!started) if (!started)
error(TEXT("CreateProcess"), result, 1002); error(TEXT("CreateProcess"), result, 1002);
hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent")); hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent"));
if(!hListenerEvent[0]) if (!hListenerEvent[0])
error(TEXT("CreateEvent"), result, 1003); error(TEXT("CreateEvent"), result, 1003);
hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent")); hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent"));
if(!hListenerEvent[1]) if (!hListenerEvent[1])
error(TEXT("CreateEvent"), result, 1004); error(TEXT("CreateEvent"), result, 1004);
hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL); hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL);
if (!hListenerStdOutThread) if (!hListenerStdOutThread)
error(TEXT("CreateThread"), result, 1005); error(TEXT("CreateThread"), result, 1005);
hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL); hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL);
if (!hListenerStdErrThread) if (!hListenerStdErrThread)
error(TEXT("CreateThread"), result, 1006); error(TEXT("CreateThread"), result, 1006);
::WaitForSingleObject(_hProcess, INFINITE); ::WaitForSingleObject(_hProcess, INFINITE);
::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE); ::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE);
} catch (int /*coderr*/){} }
catch (int /*coderr*/)
{}
// on va fermer toutes les handles // on va fermer toutes les handles
if (hPipeOutW) if (hPipeOutW)
@ -136,7 +142,7 @@ void Process::listenerStdOut()
TCHAR bufferOut[MAX_LINE_LENGTH + 1]; TCHAR bufferOut[MAX_LINE_LENGTH + 1];
int nExitCode = STILL_ACTIVE; int nExitCode = STILL_ACTIVE;
DWORD outbytesRead; DWORD outbytesRead;
::ResumeThread(_hProcessThread); ::ResumeThread(_hProcessThread);
@ -144,19 +150,19 @@ void Process::listenerStdOut()
bool goOn = true; bool goOn = true;
while (goOn) while (goOn)
{ // got data { // got data
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1); memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
int taille = sizeof(bufferOut) - sizeof(TCHAR); int taille = sizeof(bufferOut) - sizeof(TCHAR);
Sleep(50); Sleep(50);
if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL)) if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL))
{ {
bytesAvail = 0; bytesAvail = 0;
goOn = false; goOn = false;
break; break;
} }
if(outbytesRead) if (outbytesRead)
{ {
result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL); result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL);
if ((!result) && (outbytesRead == 0)) if ((!result) && (outbytesRead == 0))
@ -184,7 +190,7 @@ void Process::listenerStdOut()
} }
_exitCode = nExitCode; _exitCode = nExitCode;
if(!::SetEvent(hListenerEvent)) if (!::SetEvent(hListenerEvent))
{ {
systemMessage(TEXT("Thread listenerStdOut")); systemMessage(TEXT("Thread listenerStdOut"));
} }
@ -202,7 +208,7 @@ void Process::listenerStdErr()
::ResumeThread(_hProcessThread); ::ResumeThread(_hProcessThread);
bool goOn = true; bool goOn = true;
while (goOn) while (goOn)
{ // got data { // got data
memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1); memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1);
@ -210,14 +216,14 @@ void Process::listenerStdErr()
Sleep(50); Sleep(50);
DWORD errbytesRead; DWORD errbytesRead;
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL)) if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
{ {
bytesAvail = 0; bytesAvail = 0;
goOn = false; goOn = false;
break; break;
} }
if(errbytesRead) if (errbytesRead)
{ {
result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL); result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL);
if ((!result) && (errbytesRead == 0)) if ((!result) && (errbytesRead == 0))
@ -244,15 +250,17 @@ void Process::listenerStdErr()
} }
//_exitCode = nExitCode; //_exitCode = nExitCode;
if(!::SetEvent(hListenerEvent)) if (!::SetEvent(hListenerEvent))
{ {
systemMessage(TEXT("Thread stdout listener")); systemMessage(TEXT("Thread stdout listener"));
} }
} }
void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode) void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode)
{ {
systemMessage(txt2display); systemMessage(txt2display);
returnCode = FALSE; returnCode = FALSE;
throw int(errCode); throw int(errCode);
} }

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -33,45 +33,45 @@
//#include <string> //#include <string>
using namespace std; using namespace std;
class Process class Process
{ {
public: public:
Process() {}; Process() {}
Process(const TCHAR *cmd, const TCHAR *cDir) Process(const TCHAR *cmd, const TCHAR *cDir)
: _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL), : _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL),
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) { _hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL)
{
lstrcpy(_command, cmd); lstrcpy(_command, cmd);
lstrcpy(_curDir, cDir); lstrcpy(_curDir, cDir);
}; }
BOOL run(); BOOL run();
const TCHAR * getStdout() const { const TCHAR * getStdout() const {
return _stdoutStr.c_str(); return _stdoutStr.c_str();
}; }
const TCHAR * getStderr() const { const TCHAR * getStderr() const {
return _stderrStr.c_str(); return _stderrStr.c_str();
}; }
int getExitCode() const { int getExitCode() const {
return _exitCode; return _exitCode;
}; }
bool hasStdout() { bool hasStdout() {
return (_stdoutStr.compare(TEXT("")) != 0); return (_stdoutStr.compare(TEXT("")) != 0);
}; }
bool hasStderr() { bool hasStderr() {
return (_stderrStr.compare(TEXT("")) != 0); return (_stderrStr.compare(TEXT("")) != 0);
}; }
protected: protected:
// LES ENTREES // LES ENTREES
TCHAR _command[256]; TCHAR _command[256];
TCHAR _curDir[256]; TCHAR _curDir[256];
// LES SORTIES // LES SORTIES
generic_string _stdoutStr; generic_string _stdoutStr;
generic_string _stderrStr; generic_string _stderrStr;
@ -84,7 +84,7 @@ protected:
HANDLE _hProcessThread; HANDLE _hProcessThread;
//UINT _pid; // process ID assigned by caller //UINT _pid; // process ID assigned by caller
static DWORD WINAPI staticListenerStdOut(void * myself){ static DWORD WINAPI staticListenerStdOut(void * myself){
((Process *)myself)->listenerStdOut(); ((Process *)myself)->listenerStdOut();
return 0; return 0;

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -33,14 +33,17 @@
class ProcessThread class ProcessThread
{ {
public : public:
ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd) : _hwnd(hwnd) { ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd)
: _hwnd(hwnd)
{
lstrcpy(_appName, appName); lstrcpy(_appName, appName);
lstrcpy(_command, cmd); lstrcpy(_command, cmd);
lstrcpy(_curDir, cDir); lstrcpy(_curDir, cDir);
}; }
BOOL run(){ BOOL run()
{
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent")); HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent"));
_hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL); _hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL);
@ -49,9 +52,10 @@ public :
::CloseHandle(hEvent); ::CloseHandle(hEvent);
return TRUE; return TRUE;
}; }
protected :
protected:
// ENTREES // ENTREES
TCHAR _appName[256]; TCHAR _appName[256];
TCHAR _command[256]; TCHAR _command[256];
@ -59,12 +63,14 @@ protected :
HWND _hwnd; HWND _hwnd;
HANDLE _hProcessThread; HANDLE _hProcessThread;
static DWORD WINAPI staticLauncher(void *myself) { static DWORD WINAPI staticLauncher(void *myself)
{
((ProcessThread *)myself)->launch(); ((ProcessThread *)myself)->launch();
return TRUE; return TRUE;
}; }
bool launch() { bool launch()
{
HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent")); HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent"));
HWND hwnd = _hwnd; HWND hwnd = _hwnd;
TCHAR appName[256]; TCHAR appName[256];
@ -73,24 +79,22 @@ protected :
Process process(_command, _curDir); Process process(_command, _curDir);
if(!::SetEvent(hEvent)) if (!::SetEvent(hEvent))
{
systemMessage(TEXT("Thread launcher")); systemMessage(TEXT("Thread launcher"));
}
process.run(); process.run();
int code = process.getExitCode(); int code = process.getExitCode();
TCHAR codeStr[256]; TCHAR codeStr[256];
generic_sprintf(codeStr, TEXT("%s : %0.4X"), appName, code); generic_sprintf(codeStr, TEXT("%s : %0.4X"), appName, code);
::MessageBox(hwnd, process.getStdout(), codeStr, MB_OK); ::MessageBox(hwnd, process.getStdout(), codeStr, MB_OK);
if (process.hasStderr()) if (process.hasStderr())
::MessageBox(hwnd, process.getStderr(), codeStr, MB_OK); ::MessageBox(hwnd, process.getStderr(), codeStr, MB_OK);
::CloseHandle(hMyself); ::CloseHandle(hMyself);
return true; return true;
}; }
}; };
#endif PROCESS_THREAD_H #endif PROCESS_THREAD_H

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -24,14 +24,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // 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.
#include "Common.h" #include "Common.h"
#include "regExtDlg.h" #include "regExtDlg.h"
#include "resource.h" #include "resource.h"
const TCHAR *nppName = TEXT("Notepad++_file");
const TCHAR *nppBackup = TEXT("Notepad++_backup");
const TCHAR *nppDoc = TEXT("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 nbSupportedLang = 9;
const int nbExtMax = 10; const int nbExtMax = 10;
@ -80,18 +81,19 @@ TCHAR defExtArray[nbSupportedLang][nbExtMax][extNameMax] = {
void RegExtDlg::doDialog(bool isRTL) void RegExtDlg::doDialog(bool isRTL)
{ {
if (isRTL) if (isRTL)
{ {
DLGTEMPLATE *pMyDlgTemplate = NULL; DLGTEMPLATE *pMyDlgTemplate = nullptr;
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate); HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate);
::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); ::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this);
::GlobalFree(hMyDlgTemplate); ::GlobalFree(hMyDlgTemplate);
} }
else else
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, (LPARAM)this); ::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, (LPARAM)this);
}; }
INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
{ {
@ -105,7 +107,6 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETLIMITTEXT, extNameMax-1, 0); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETLIMITTEXT, extNameMax-1, 0);
return TRUE; return TRUE;
} }
@ -117,7 +118,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
return TRUE; return TRUE;
} }
case WM_COMMAND : case WM_COMMAND :
{ {
switch (wParam) switch (wParam)
{ {
@ -137,7 +138,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
{ {
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)ext2Add); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)ext2Add);
int i = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)ext2Add); int i = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)ext2Add);
if (i != LB_ERR) if (i != LB_ERR)
return TRUE; return TRUE;
addExt(ext2Add); addExt(ext2Add);
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)TEXT("")); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_SETTEXT, 0, (LPARAM)TEXT(""));
@ -172,14 +173,15 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
return TRUE; return TRUE;
} }
case IDCANCEL : case IDCANCEL:
{
::EndDialog(_hSelf, 0); ::EndDialog(_hSelf, 0);
return TRUE; return TRUE;
}
} }
if (HIWORD(wParam) == EN_CHANGE) if (HIWORD(wParam) == EN_CHANGE)
{ {
TCHAR text[extNameMax] = TEXT(""); TCHAR text[extNameMax] = TEXT("");
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text);
if ((lstrlen(text) == 1) && (text[0] != '.')) if ((lstrlen(text) == 1) && (text[0] != '.'))
@ -195,7 +197,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
} }
if (HIWORD(wParam) == LBN_SELCHANGE) if (HIWORD(wParam) == LBN_SELCHANGE)
{ {
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST) if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST)
{ {
@ -216,7 +218,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
{ {
::ShowWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANGEXT_LIST), SW_SHOW); ::ShowWindow(::GetDlgItem(_hSelf, IDC_REGEXT_LANGEXT_LIST), SW_SHOW);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMEXT_EDIT), SW_HIDE); ::ShowWindow(::GetDlgItem(_hSelf, IDC_CUSTOMEXT_EDIT), SW_HIDE);
_isCustomize = false; _isCustomize = false;
} }
int count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0); int count = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_GETCOUNT, 0, 0);
@ -224,38 +226,41 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0);
for (int j = 1 ; j < nbExtMax ; ++j) for (int j = 1 ; j < nbExtMax ; ++j)
{
if (lstrcmp(TEXT(""), defExtArray[i][j])) if (lstrcmp(TEXT(""), defExtArray[i][j]))
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]); int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
if (index == -1) if (index == -1)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
} }
}
} }
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
} }
} }
else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST) else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST)
{ {
if (i != LB_ERR) if (i != LB_ERR)
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true);
} }
else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST) else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST)
{ {
if (i != LB_ERR) if (i != LB_ERR)
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true);
} }
} }
// break; // no break here
} }
default : default :
return FALSE; return FALSE;
} }
//return FALSE; //return FALSE;
} }
void RegExtDlg::getRegisteredExts() void RegExtDlg::getRegisteredExts()
{ {
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT); int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
@ -264,7 +269,7 @@ void RegExtDlg::getRegisteredExts()
TCHAR extName[extNameLen]; TCHAR extName[extNameLen];
//FILETIME fileTime; //FILETIME fileTime;
int extNameActualLen = extNameLen; int extNameActualLen = extNameLen;
int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, NULL, NULL, NULL, NULL); int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, nullptr, nullptr, nullptr, nullptr);
if ((res == ERROR_SUCCESS) && (extName[0] == '.')) if ((res == ERROR_SUCCESS) && (extName[0] == '.'))
{ {
//TCHAR valName[extNameLen]; //TCHAR valName[extNameLen];
@ -274,8 +279,8 @@ void RegExtDlg::getRegisteredExts()
HKEY hKey2Check; HKEY hKey2Check;
extNameActualLen = extNameLen; extNameActualLen = extNameLen;
::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check); ::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check);
::RegQueryValueEx(hKey2Check, TEXT(""), NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); ::RegQueryValueEx(hKey2Check, TEXT(""), nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
//::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); //::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
if ((valType == REG_SZ) && (!lstrcmp(valData, nppName))) if ((valType == REG_SZ) && (!lstrcmp(valData, nppName)))
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName);
::RegCloseKey(hKey2Check); ::RegCloseKey(hKey2Check);
@ -283,6 +288,7 @@ void RegExtDlg::getRegisteredExts()
} }
} }
void RegExtDlg::getDefSupportedExts() void RegExtDlg::getDefSupportedExts()
{ {
for (int i = 0 ; i < nbSupportedLang ; ++i) for (int i = 0 ; i < nbSupportedLang ; ++i)
@ -292,37 +298,30 @@ void RegExtDlg::getDefSupportedExts()
void RegExtDlg::addExt(TCHAR *ext) void RegExtDlg::addExt(TCHAR *ext)
{ {
HKEY hKey; HKEY hKey;
DWORD dwDisp; DWORD dwDisp;
long nRet; long nRet;
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ext, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
ext,
0, if (nRet == ERROR_SUCCESS)
NULL, {
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS)
{
TCHAR valData[MAX_PATH]; TCHAR valData[MAX_PATH];
int valDataLen = MAX_PATH * sizeof(TCHAR); int valDataLen = MAX_PATH * sizeof(TCHAR);
if (dwDisp == REG_OPENED_EXISTING_KEY) if (dwDisp == REG_OPENED_EXISTING_KEY)
{ {
int res = ::RegQueryValueEx(hKey, TEXT(""), NULL, NULL, (LPBYTE)valData, (LPDWORD)&valDataLen); int res = ::RegQueryValueEx(hKey, TEXT(""), nullptr, nullptr, (LPBYTE)valData, (LPDWORD)&valDataLen);
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen); ::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen);
} }
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR)); ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR));
::RegCloseKey(hKey); ::RegCloseKey(hKey);
} }
} }
bool RegExtDlg::deleteExts(const TCHAR *ext2Delete) bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
{ {
HKEY hKey; HKEY hKey;
@ -342,20 +341,21 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
TCHAR valData[extNameLen]; TCHAR valData[extNameLen];
int valDataLen = extNameLen*sizeof(TCHAR); int valDataLen = extNameLen*sizeof(TCHAR);
int valType; int valType;
int res = ::RegQueryValueEx(hKey, nppBackup, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); int res = ::RegQueryValueEx(hKey, nppBackup, nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
::RegSetValueEx(hKey, NULL, 0, valType, (LPBYTE)valData, valDataLen); ::RegSetValueEx(hKey, nullptr, 0, valType, (LPBYTE)valData, valDataLen);
::RegDeleteValue(hKey, nppBackup); ::RegDeleteValue(hKey, nppBackup);
} }
else else
::RegDeleteValue(hKey, NULL); ::RegDeleteValue(hKey, nullptr);
} }
return true; return true;
} }
void RegExtDlg::writeNppPath() void RegExtDlg::writeNppPath()
{ {
HKEY hKey, hRootKey; HKEY hKey, hRootKey;
@ -364,16 +364,7 @@ void RegExtDlg::writeNppPath()
generic_string regStr(nppName); generic_string regStr(nppName);
regStr += TEXT("\\shell\\open\\command"); regStr += TEXT("\\shell\\open\\command");
nRet = ::RegCreateKeyEx( nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
HKEY_CLASSES_ROOT,
regStr.c_str(),
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS) if (nRet == ERROR_SUCCESS)
@ -382,7 +373,7 @@ void RegExtDlg::writeNppPath()
{ {
// Write the value for new document // Write the value for new document
::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey); ::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey);
::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR)); ::RegSetValueEx(hRootKey, nullptr, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
RegCloseKey(hRootKey); RegCloseKey(hRootKey);
TCHAR nppPath[MAX_PATH]; TCHAR nppPath[MAX_PATH];
@ -391,7 +382,7 @@ void RegExtDlg::writeNppPath()
TCHAR nppPathParam[MAX_PATH] = TEXT("\""); TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\"")); lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
@ -399,16 +390,7 @@ void RegExtDlg::writeNppPath()
//Set default icon value //Set default icon value
regStr = nppName; regStr = nppName;
regStr += TEXT("\\DefaultIcon"); regStr += TEXT("\\DefaultIcon");
nRet = ::RegCreateKeyEx( nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
HKEY_CLASSES_ROOT,
regStr.c_str(),
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS) if (nRet == ERROR_SUCCESS)
{ {
@ -420,8 +402,10 @@ void RegExtDlg::writeNppPath()
TCHAR nppPathParam[MAX_PATH] = TEXT("\""); TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0")); lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
} }

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -46,7 +46,7 @@ private :
bool _isCustomize; bool _isCustomize;
INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
void getRegisteredExts(); void getRegisteredExts();
void getDefSupportedExts(); void getDefSupportedExts();
void addExt(TCHAR *ext); void addExt(TCHAR *ext);
@ -57,13 +57,13 @@ private :
int nbSubKey; int nbSubKey;
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL); long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return (result == ERROR_SUCCESS)?nbSubKey:0; return (result == ERROR_SUCCESS)?nbSubKey:0;
}; }
int getNbSubValue(HKEY hKey) const { int getNbSubValue(HKEY hKey) const {
int nbSubValue; int nbSubValue;
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL); long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
return (result == ERROR_SUCCESS)?nbSubValue:0; return (result == ERROR_SUCCESS)?nbSubValue:0;
}; }
}; };
#endif //REG_EXT_DLG_H #endif //REG_EXT_DLG_H

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -31,15 +31,15 @@
#define IDD_REGEXT_BOX 4000 #define IDD_REGEXT_BOX 4000
#define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1) #define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1)
#define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2) #define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2)
#define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3) #define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3)
#define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4) #define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4)
#define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5) #define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5)
#define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6) #define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6)
#define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7) #define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7)
#define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8) #define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8)
#define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9) #define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9)
#define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10) #define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10)
#endif //REGEXTDLGRC_H #endif //REGEXTDLGRC_H

File diff suppressed because it is too large Load Diff

View File

@ -7,10 +7,10 @@
// version 2 of the License, or (at your option) any later version. // version 2 of the License, or (at your option) any later version.
// //
// Note that the GPL places important restrictions on "derived works", yet // Note that the GPL places important restrictions on "derived works", yet
// it does not provide a detailed definition of that term. To avoid // it does not provide a detailed definition of that term. To avoid
// misunderstandings, we consider an application to constitute a // misunderstandings, we consider an application to constitute a
// "derivative work" for the purpose of this license if it does any of the // "derivative work" for the purpose of this license if it does any of the
// following: // following:
// 1. Integrates source code from Notepad++. // 1. Integrates source code from Notepad++.
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable // 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
// installer, such as those produced by InstallShield. // installer, such as those produced by InstallShield.
@ -164,7 +164,7 @@ struct TaskListInfo;
struct VisibleGUIConf { struct VisibleGUIConf {
bool isPostIt; bool isPostIt;
bool isFullScreen; bool isFullScreen;
//Used by both views //Used by both views
bool isMenuShown; bool isMenuShown;
//bool isToolbarShown; //toolbar forcefully hidden by hiding rebar //bool isToolbarShown; //toolbar forcefully hidden by hiding rebar
@ -196,8 +196,8 @@ class ProjectPanel;
class DocumentMap; class DocumentMap;
class FunctionListPanel; class FunctionListPanel;
class Notepad_plus { class Notepad_plus
{
friend class Notepad_plus_Window; friend class Notepad_plus_Window;
friend class FileManager; friend class FileManager;
@ -234,7 +234,7 @@ public:
bool fileReload() { bool fileReload() {
BufferID buf = _pEditView->getCurrentBufferID(); BufferID buf = _pEditView->getCurrentBufferID();
return doReload(buf, buf->isDirty()); return doReload(buf, buf->isDirty());
}; }
bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
bool fileCloseAll(bool doDeleteBackup, bool isSnapshotMode = false); bool fileCloseAll(bool doDeleteBackup, bool isSnapshotMode = false);
@ -263,17 +263,17 @@ public:
void saveUserDefineLangs() { void saveUserDefineLangs() {
if (ScintillaEditView::getUserDefineDlg()->isDirty()) if (ScintillaEditView::getUserDefineDlg()->isDirty())
(NppParameters::getInstance())->writeUserDefinedLang(); (NppParameters::getInstance())->writeUserDefinedLang();
}; }
void saveShortcuts(){ void saveShortcuts(){
NppParameters::getInstance()->writeShortcuts(); NppParameters::getInstance()->writeShortcuts();
}; }
void saveSession(const Session & session); void saveSession(const Session & session);
void saveCurrentSession(); void saveCurrentSession();
void saveFindHistory(){ void saveFindHistory(){
_findReplaceDlg.saveFindHistory(); _findReplaceDlg.saveFindHistory();
(NppParameters::getInstance())->writeFindHistory(); (NppParameters::getInstance())->writeFindHistory();
}; }
void getCurrentOpenedFiles(Session & session, bool includUntitledDoc = false); void getCurrentOpenedFiles(Session & session, bool includUntitledDoc = false);
@ -286,13 +286,13 @@ public:
bool doStreamComment(); bool doStreamComment();
//--FLS: undoStreamComment: New function unDoStreamComment() //--FLS: undoStreamComment: New function unDoStreamComment()
bool undoStreamComment(); bool undoStreamComment();
bool addCurrentMacro(); bool addCurrentMacro();
void macroPlayback(Macro); void macroPlayback(Macro);
void loadLastSession(); void loadLastSession();
bool loadSession(Session & session, bool isSnapshotMode = false); bool loadSession(Session & session, bool isSnapshotMode = false);
void notifyBufferChanged(Buffer * buffer, int mask); void notifyBufferChanged(Buffer * buffer, int mask);
bool findInFiles(); bool findInFiles();
bool replaceInFiles(); bool replaceInFiles();
@ -301,16 +301,16 @@ public:
int getHtmlXmlEncoding(const TCHAR *fileName) const; int getHtmlXmlEncoding(const TCHAR *fileName) const;
HACCEL getAccTable() const{ HACCEL getAccTable() const{
return _accelerator.getAccTable(); return _accelerator.getAccTable();
}; }
bool emergency(generic_string emergencySavedDir); bool emergency(generic_string emergencySavedDir);
Buffer * getCurrentBuffer() { Buffer * getCurrentBuffer() {
return _pEditView->getCurrentBuffer(); return _pEditView->getCurrentBuffer();
}; }
void launchDocumentBackupTask(); void launchDocumentBackupTask();
int getQuoteIndexFrom(const char *quoter) const; int getQuoteIndexFrom(const char *quoter) const;
void showQuoteFromIndex(int index) const; void showQuoteFromIndex(int index) const;
void showQuote(const char *quote, const char *quoter, bool doTrolling) const; void showQuote(const char *quote, const char *quoter, bool doTrolling) const;
private: private:
Notepad_plus_Window *_pPublicInterface; Notepad_plus_Window *_pPublicInterface;
Window *_pMainWindow; Window *_pMainWindow;
@ -341,7 +341,7 @@ private:
ToolBar _toolBar; ToolBar _toolBar;
IconList _docTabIconList; IconList _docTabIconList;
StatusBar _statusBar; StatusBar _statusBar;
bool _toReduceTabBar; bool _toReduceTabBar;
ReBar _rebarTop; ReBar _rebarTop;
@ -357,7 +357,7 @@ private:
WordStyleDlg _configStyleDlg; WordStyleDlg _configStyleDlg;
PreferenceDlg _preference; PreferenceDlg _preference;
FindCharsInRangeDlg _findCharsInRangeDlg; FindCharsInRangeDlg _findCharsInRangeDlg;
// a handle list of all the Notepad++ dialogs // a handle list of all the Notepad++ dialogs
std::vector<HWND> _hModelessDlgs; std::vector<HWND> _hModelessDlgs;
@ -369,7 +369,7 @@ private:
HMENU _mainMenuHandle; HMENU _mainMenuHandle;
bool _sysMenuEntering; bool _sysMenuEntering;
// For FullScreen/PostIt features // For FullScreen/PostIt features
VisibleGUIConf _beforeSpecialView; VisibleGUIConf _beforeSpecialView;
@ -389,23 +389,27 @@ private:
//For Dynamic selection highlight //For Dynamic selection highlight
CharacterRange _prevSelectedRange; CharacterRange _prevSelectedRange;
struct ActivateAppInfo { struct ActivateAppInfo
{
bool _isActivated; bool _isActivated;
int _x; int _x;
int _y; int _y;
ActivateAppInfo() : _isActivated(false), _x(0), _y(0){}; ActivateAppInfo() : _isActivated(false), _x(0), _y(0){};
} _activeAppInf; }
_activeAppInf;
//Synchronized Scolling //Synchronized Scolling
struct SyncInfo { struct SyncInfo
{
int _line; int _line;
int _column; int _column;
bool _isSynScollV; bool _isSynScollV;
bool _isSynScollH; bool _isSynScollH;
SyncInfo():_line(0), _column(0), _isSynScollV(false), _isSynScollH(false){}; SyncInfo():_line(0), _column(0), _isSynScollV(false), _isSynScollH(false){};
bool doSync() const {return (_isSynScollV || _isSynScollH); }; bool doSync() const {return (_isSynScollV || _isSynScollH); };
} _syncInfo; }
_syncInfo;
bool _isUDDocked; bool _isUDDocked;
@ -459,15 +463,15 @@ private:
int currentView(){ int currentView(){
return _activeView; return _activeView;
}; }
int otherView(){ int otherView(){
return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW); return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
}; }
int otherFromView(int whichOne){ int otherFromView(int whichOne){
return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW); return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
}; }
bool canHideView(int whichOne); //true if view can safely be hidden (no open docs etc) bool canHideView(int whichOne); //true if view can safely be hidden (no open docs etc)
@ -510,7 +514,7 @@ private:
void setLangStatus(LangType langType){ void setLangStatus(LangType langType){
_statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE); _statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE);
}; }
void setDisplayFormat(formatType f); void setDisplayFormat(formatType f);
int getCmdIDFromEncoding(int encoding) const; int getCmdIDFromEncoding(int encoding) const;
@ -523,45 +527,54 @@ private:
void checkMenuItem(int itemID, bool willBeChecked) const { void checkMenuItem(int itemID, bool willBeChecked) const {
::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED)); ::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED));
}; }
bool isConditionExprLine(int lineNumber); bool isConditionExprLine(int lineNumber);
int findMachedBracePos(size_t startPos, size_t endPos, char targetSymbol, char matchedSymbol); int findMachedBracePos(size_t startPos, size_t endPos, char targetSymbol, char matchedSymbol);
void maintainIndentation(TCHAR ch); void maintainIndentation(TCHAR ch);
void addHotSpot(); void addHotSpot();
void bookmarkAdd(int lineno) const { void bookmarkAdd(int lineno) const
{
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = _pEditView->getCurrentLineNumber();
if (!bookmarkPresent(lineno)) if (!bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
}; }
void bookmarkDelete(int lineno) const {
void bookmarkDelete(int lineno) const
{
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = _pEditView->getCurrentLineNumber();
if ( bookmarkPresent(lineno)) if ( bookmarkPresent(lineno))
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
}; }
bool bookmarkPresent(int lineno) const {
bool bookmarkPresent(int lineno) const
{
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = _pEditView->getCurrentLineNumber();
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno); LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
return ((state & (1 << MARK_BOOKMARK)) != 0); return ((state & (1 << MARK_BOOKMARK)) != 0);
}; }
void bookmarkToggle(int lineno) const {
void bookmarkToggle(int lineno) const
{
if (lineno == -1) if (lineno == -1)
lineno = _pEditView->getCurrentLineNumber(); lineno = _pEditView->getCurrentLineNumber();
if (bookmarkPresent(lineno)) if (bookmarkPresent(lineno))
bookmarkDelete(lineno); bookmarkDelete(lineno);
else else
bookmarkAdd(lineno); bookmarkAdd(lineno);
}; }
void bookmarkNext(bool forwardScan); void bookmarkNext(bool forwardScan);
void bookmarkClearAll() const { void bookmarkClearAll() const
{
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
}; }
void copyMarkedLines(); void copyMarkedLines();
void cutMarkedLines(); void cutMarkedLines();
@ -619,7 +632,7 @@ private:
bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const; bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const;
bool goToNextIndicator(int indicID2Search, bool isWrap = true) const; bool goToNextIndicator(int indicID2Search, bool isWrap = true) const;
int wordCount(); int wordCount();
void wsTabConvert(spaceTab whichWay); void wsTabConvert(spaceTab whichWay);
void doTrim(trimOp whichPart); void doTrim(trimOp whichPart);
void removeEmptyLine(bool isBlankContained); void removeEmptyLine(bool isBlankContained);
@ -636,13 +649,15 @@ private:
static bool deleteBack(ScintillaEditView *pCurrentView, BufferID targetBufID); static bool deleteBack(ScintillaEditView *pCurrentView, BufferID targetBufID);
static bool deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID); static bool deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID);
static bool selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID); static bool selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID);
static int getRandomNumber(int rangeMax = -1) { static int getRandomNumber(int rangeMax = -1)
{
int randomNumber = rand(); int randomNumber = rand();
if (rangeMax == -1) if (rangeMax == -1)
return randomNumber; return randomNumber;
return (rand() % rangeMax); return (rand() % rangeMax);
}; }
static DWORD WINAPI backupDocument(void *params); static DWORD WINAPI backupDocument(void *params);
}; };