Applied coding style / cleanup
This commit is contained in:
parent
0cd514de13
commit
23cd144198
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -39,17 +39,19 @@
|
|||
|
||||
WcharMbcsConvertor * WcharMbcsConvertor::_pSelf = new WcharMbcsConvertor;
|
||||
|
||||
void printInt(int int2print)
|
||||
void printInt(int int2print)
|
||||
{
|
||||
TCHAR str[32];
|
||||
wsprintf(str, TEXT("%d"), int2print);
|
||||
::MessageBox(NULL, str, TEXT(""), MB_OK);
|
||||
};
|
||||
}
|
||||
|
||||
void printStr(const TCHAR *str2print)
|
||||
|
||||
void printStr(const TCHAR *str2print)
|
||||
{
|
||||
::MessageBox(NULL, str2print, TEXT(""), MB_OK);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
std::string getFileContent(const TCHAR *file2read)
|
||||
{
|
||||
|
@ -59,7 +61,8 @@ std::string getFileContent(const TCHAR *file2read)
|
|||
FILE *fp = generic_fopen(file2read, TEXT("rb"));
|
||||
|
||||
size_t lenFile = 0;
|
||||
do {
|
||||
do
|
||||
{
|
||||
lenFile = fread(data, 1, blockSize - 1, fp);
|
||||
if (lenFile <= 0) break;
|
||||
|
||||
|
@ -69,8 +72,8 @@ std::string getFileContent(const TCHAR *file2read)
|
|||
data[lenFile] = '\0';
|
||||
|
||||
wholeFileContent += data;
|
||||
|
||||
} while (lenFile > 0);
|
||||
}
|
||||
while (lenFile > 0);
|
||||
|
||||
fclose(fp);
|
||||
return wholeFileContent;
|
||||
|
@ -90,6 +93,7 @@ char getDriveLetter()
|
|||
return drive;
|
||||
}
|
||||
|
||||
|
||||
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
|
||||
{
|
||||
generic_string fullFilePathName = TEXT("");
|
||||
|
@ -114,16 +118,18 @@ generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
|
|||
return fullFilePathName;
|
||||
}
|
||||
|
||||
|
||||
void writeFileContent(const TCHAR *file2write, const char *content2write)
|
||||
{
|
||||
{
|
||||
FILE *f = generic_fopen(file2write, TEXT("w+"));
|
||||
fwrite(content2write, sizeof(content2write[0]), strlen(content2write), f);
|
||||
fflush(f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
void writeLog(const TCHAR *logFileName, const char *log2write)
|
||||
{
|
||||
{
|
||||
FILE *f = generic_fopen(logFileName, TEXT("a+"));
|
||||
fwrite(log2write, sizeof(log2write[0]), strlen(log2write), f);
|
||||
fputc('\n', f);
|
||||
|
@ -131,6 +137,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
// 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
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
|
||||
{
|
||||
// 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 not null when they select a folder.
|
||||
if (pidl)
|
||||
if (pidl)
|
||||
{
|
||||
// Try to convert the pidl to a display generic_string.
|
||||
// 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 not null when they select a folder.
|
||||
if (pidl)
|
||||
if (pidl)
|
||||
{
|
||||
// Try to convert the pidl to a display generic_string.
|
||||
// Return is true if success.
|
||||
|
@ -245,9 +253,11 @@ void ClientRectToScreenRect(HWND hWnd, RECT* rect)
|
|||
::ClientToScreen( hWnd, &pt );
|
||||
rect->right = pt.x;
|
||||
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
|
||||
std::vector<generic_string> tokens;
|
||||
|
||||
|
@ -268,6 +278,7 @@ std::vector<generic_string> tokenizeString(const generic_string & tokenString, c
|
|||
return tokens;
|
||||
}
|
||||
|
||||
|
||||
void ScreenRectToClientRect(HWND hWnd, RECT* rect)
|
||||
{
|
||||
POINT pt;
|
||||
|
@ -283,9 +294,10 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect)
|
|||
::ScreenToClient( hWnd, &pt );
|
||||
rect->right = pt.x;
|
||||
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)
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
|
@ -293,7 +305,9 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
|
|||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
bool isInList(const TCHAR *token, const TCHAR *list) {
|
||||
|
||||
bool isInList(const TCHAR *token, const TCHAR *list)
|
||||
{
|
||||
if ((!token) || (!list))
|
||||
return false;
|
||||
TCHAR word[64];
|
||||
|
@ -307,12 +321,12 @@ bool isInList(const TCHAR *token, const TCHAR *list) {
|
|||
{
|
||||
word[j] = '\0';
|
||||
j = 0;
|
||||
|
||||
|
||||
if (!generic_stricmp(token, word))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
word[j] = list[i];
|
||||
++j;
|
||||
|
@ -327,7 +341,7 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
|
|||
TCHAR cleanedName[64] = TEXT("");
|
||||
size_t j = 0;
|
||||
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')
|
||||
{
|
||||
|
@ -347,7 +361,8 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
|
|||
}
|
||||
cleanedName[j] = 0;
|
||||
return cleanedName;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
// 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
|
||||
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
|
||||
_wideCharStr.empty();
|
||||
|
||||
if(pLenWc) *pLenWc = lenWc;
|
||||
if(pBytesNotProcessed) *pBytesNotProcessed = bytesNotProcessed;
|
||||
if (pLenWc) *pLenWc = lenWc;
|
||||
if (pBytesNotProcessed) *pBytesNotProcessed = bytesNotProcessed;
|
||||
return _wideCharStr;
|
||||
}
|
||||
|
||||
|
||||
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
|
||||
// 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)
|
||||
|
@ -440,9 +456,10 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
|||
*mend = 0;
|
||||
}
|
||||
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
|
||||
if (!wcharStr2Convert) return NULL;
|
||||
|
@ -456,11 +473,13 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
|
|||
else
|
||||
_multiByteStr.empty();
|
||||
|
||||
if(pLenMbcs) *pLenMbcs = lenMbcs;
|
||||
if (pLenMbcs)
|
||||
*pLenMbcs = lenMbcs;
|
||||
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
|
||||
if (!wcharStr2Convert) return NULL;
|
||||
|
@ -488,11 +507,12 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
|
|||
return _multiByteStr;
|
||||
}
|
||||
|
||||
|
||||
std::wstring string2wstring(const std::string & rString, UINT codepage)
|
||||
{
|
||||
int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0);
|
||||
if(len > 0)
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
std::vector<wchar_t> vw(len);
|
||||
MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len);
|
||||
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)
|
||||
{
|
||||
int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL);
|
||||
if(len > 0)
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
std::vector<char> vw(len);
|
||||
WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL);
|
||||
return &vw[0];
|
||||
|
@ -563,7 +583,7 @@ generic_string uintToString(unsigned int val)
|
|||
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 strTemp;
|
||||
|
@ -582,7 +602,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
|
|||
strTemp.append(uintToString(pos + 1));
|
||||
}
|
||||
strTemp.append(TEXT(": "));
|
||||
|
||||
|
||||
if (filenameLen > 0)
|
||||
{
|
||||
std::vector<TCHAR> vt(filenameLen + 1);
|
||||
|
@ -614,6 +634,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
|
|||
return strTemp;
|
||||
}
|
||||
|
||||
|
||||
generic_string PathRemoveFileSpec(generic_string & path)
|
||||
{
|
||||
generic_string::size_type lastBackslash = path.find_last_of(TEXT('\\'));
|
||||
|
@ -636,6 +657,7 @@ generic_string PathRemoveFileSpec(generic_string & path)
|
|||
return path;
|
||||
}
|
||||
|
||||
|
||||
generic_string PathAppend(generic_string &strDest, const generic_string & str2append)
|
||||
{
|
||||
if (strDest == TEXT("") && str2append == TEXT("")) // "" + ""
|
||||
|
@ -671,6 +693,7 @@ generic_string PathAppend(generic_string &strDest, const generic_string & str2ap
|
|||
return strDest;
|
||||
}
|
||||
|
||||
|
||||
COLORREF getCtrlBgColor(HWND hWnd)
|
||||
{
|
||||
COLORREF crRet = CLR_INVALID;
|
||||
|
@ -709,12 +732,14 @@ COLORREF getCtrlBgColor(HWND hWnd)
|
|||
return crRet;
|
||||
}
|
||||
|
||||
|
||||
generic_string stringToUpper(generic_string strToConvert)
|
||||
{
|
||||
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper);
|
||||
return strToConvert;
|
||||
}
|
||||
|
||||
|
||||
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace)
|
||||
{
|
||||
size_t pos = 0;
|
||||
|
@ -726,6 +751,7 @@ generic_string stringReplace(generic_string subject, const generic_string& searc
|
|||
return subject;
|
||||
}
|
||||
|
||||
|
||||
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter)
|
||||
{
|
||||
auto start = 0U;
|
||||
|
@ -742,6 +768,7 @@ std::vector<generic_string> stringSplit(const generic_string& input, const gener
|
|||
return output;
|
||||
}
|
||||
|
||||
|
||||
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator)
|
||||
{
|
||||
generic_string joined;
|
||||
|
@ -757,6 +784,7 @@ generic_string stringJoin(const std::vector<generic_string>& strings, const gene
|
|||
return joined;
|
||||
}
|
||||
|
||||
|
||||
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// 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 true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// 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 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 * encode(UINT fromCodepage, UINT toCodepage, const char *txt2Encode, int lenIn=-1, int *pLenOut=NULL, int *pBytesNotProcessed=NULL) {
|
||||
int lenWc = 0;
|
||||
const wchar_t * strW = char2wchar(txt2Encode, fromCodepage, lenIn, &lenWc, pBytesNotProcessed);
|
||||
|
@ -134,19 +134,20 @@ public:
|
|||
};
|
||||
|
||||
protected:
|
||||
WcharMbcsConvertor() {
|
||||
};
|
||||
~WcharMbcsConvertor() {
|
||||
};
|
||||
WcharMbcsConvertor() {}
|
||||
~WcharMbcsConvertor() {}
|
||||
|
||||
static WcharMbcsConvertor * _pSelf;
|
||||
|
||||
template <class T>
|
||||
class StringBuffer {
|
||||
class StringBuffer
|
||||
{
|
||||
public:
|
||||
StringBuffer() : _str(0), _allocLen(0) { }
|
||||
~StringBuffer() { if(_allocLen) delete [] _str; }
|
||||
|
||||
void sizeTo(size_t size) {
|
||||
void sizeTo(size_t size)
|
||||
{
|
||||
if(_allocLen < size)
|
||||
{
|
||||
if(_allocLen) delete[] _str;
|
||||
|
@ -154,7 +155,8 @@ protected:
|
|||
_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
|
||||
if(_allocLen == 0)
|
||||
_str = &nullStr;
|
||||
|
@ -176,9 +178,10 @@ protected:
|
|||
private:
|
||||
// Since there's no public ctor, we need to void the default assignment operator.
|
||||
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define MACRO_RECORDING_IN_PROGRESS 1
|
||||
#define MACRO_RECORDING_HAS_STOPPED 2
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -49,4 +49,4 @@ public:
|
|||
bool writeDump(EXCEPTION_POINTERS * pExceptionInfo);
|
||||
};
|
||||
|
||||
#endif //MDUMP_H
|
||||
#endif //MDUMP_H
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -35,11 +35,13 @@
|
|||
#include "Win32Exception.h"
|
||||
|
||||
|
||||
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
|
||||
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info)
|
||||
{
|
||||
_location = info->ExceptionRecord->ExceptionAddress;
|
||||
_code = info->ExceptionRecord->ExceptionCode;
|
||||
_info = info;
|
||||
switch (_code) {
|
||||
switch (_code)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
_event = "Access violation";
|
||||
break;
|
||||
|
@ -52,17 +54,21 @@ Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
|
|||
}
|
||||
}
|
||||
|
||||
void Win32Exception::installHandler() {
|
||||
void Win32Exception::installHandler()
|
||||
{
|
||||
_set_se_translator(Win32Exception::translate);
|
||||
}
|
||||
|
||||
void Win32Exception::removeHandler() {
|
||||
void Win32Exception::removeHandler()
|
||||
{
|
||||
_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
|
||||
switch (code) {
|
||||
switch (code)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
throw Win32AccessViolation(info);
|
||||
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;
|
||||
_badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -42,16 +42,16 @@ typedef const void* ExceptionAddress; // OK on Win32 platform
|
|||
class Win32Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
static void installHandler();
|
||||
static void removeHandler();
|
||||
virtual const char* what() const throw() { return _event; };
|
||||
ExceptionAddress where() const { return _location; };
|
||||
unsigned int code() const { return _code; };
|
||||
EXCEPTION_POINTERS* info() const { return _info; };
|
||||
|
||||
static void installHandler();
|
||||
static void removeHandler();
|
||||
virtual const char* what() const throw() { return _event; }
|
||||
ExceptionAddress where() const { return _location; }
|
||||
unsigned int code() const { return _code; }
|
||||
EXCEPTION_POINTERS* info() const { return _info; }
|
||||
|
||||
protected:
|
||||
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:
|
||||
const char * _event;
|
||||
|
@ -61,11 +61,12 @@ private:
|
|||
EXCEPTION_POINTERS * _info;
|
||||
};
|
||||
|
||||
|
||||
class Win32AccessViolation: public Win32Exception
|
||||
{
|
||||
public:
|
||||
bool isWrite() const { return _isWrite; };
|
||||
ExceptionAddress badAddress() const { return _badAddress; };
|
||||
bool isWrite() const { return _isWrite; }
|
||||
ExceptionAddress badAddress() const { return _badAddress; }
|
||||
private:
|
||||
Win32AccessViolation(EXCEPTION_POINTERS * info);
|
||||
|
||||
|
@ -75,4 +76,4 @@ private:
|
|||
friend void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS* info);
|
||||
};
|
||||
|
||||
#endif // WIN32_EXCEPTION_H
|
||||
#endif // WIN32_EXCEPTION_H
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -31,10 +31,13 @@
|
|||
|
||||
typedef std::vector<generic_string> stringVector;
|
||||
|
||||
|
||||
|
||||
class FileNameStringSplitter
|
||||
{
|
||||
public :
|
||||
FileNameStringSplitter(const TCHAR *fileNameStr) {
|
||||
public:
|
||||
FileNameStringSplitter(const TCHAR *fileNameStr)
|
||||
{
|
||||
//if (!fileNameStr) return;
|
||||
TCHAR *pStr = NULL;
|
||||
bool isInsideQuotes = false;
|
||||
|
@ -43,6 +46,7 @@ public :
|
|||
TCHAR str[filePathLength];
|
||||
int i = 0;
|
||||
bool fini = false;
|
||||
|
||||
for (pStr = (TCHAR *)fileNameStr ; !fini ; )
|
||||
{
|
||||
if (i >= filePathLength)
|
||||
|
@ -50,7 +54,8 @@ public :
|
|||
|
||||
switch (*pStr)
|
||||
{
|
||||
case '"' :
|
||||
case '"':
|
||||
{
|
||||
if (isInsideQuotes)
|
||||
{
|
||||
str[i] = '\0';
|
||||
|
@ -61,12 +66,14 @@ public :
|
|||
isInsideQuotes = !isInsideQuotes;
|
||||
pStr++;
|
||||
break;
|
||||
|
||||
case ' ' :
|
||||
}
|
||||
|
||||
case ' ':
|
||||
{
|
||||
if (isInsideQuotes)
|
||||
{
|
||||
str[i] = *pStr;
|
||||
i++;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -77,34 +84,41 @@ public :
|
|||
}
|
||||
pStr++;
|
||||
break;
|
||||
|
||||
case '\0' :
|
||||
}
|
||||
|
||||
case '\0':
|
||||
{
|
||||
str[i] = *pStr;
|
||||
if (str[0])
|
||||
_fileNames.push_back(generic_string(str));
|
||||
fini = true;
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
{
|
||||
str[i] = *pStr;
|
||||
i++; pStr++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
const TCHAR * getFileName(size_t index) const {
|
||||
if (index >= _fileNames.size())
|
||||
return NULL;
|
||||
return _fileNames[index].c_str();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
int size() const {
|
||||
return int(_fileNames.size());
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private :
|
||||
stringVector _fileNames;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //FILENAME_STRING_SPLITTER_H
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -50,4 +50,4 @@ int IDAllocator::allocate(int quantity)
|
|||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -35,7 +35,7 @@ class IDAllocator
|
|||
{
|
||||
public:
|
||||
IDAllocator(int start, int maximumID);
|
||||
|
||||
|
||||
/// Returns -1 if not enough available
|
||||
int allocate(int quantity);
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// 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 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_GETOPENFILENAMESSECOND (NPPMSG + 18)
|
||||
|
||||
|
||||
#define NPPM_CREATESCINTILLAHANDLE (NPPMSG + 20)
|
||||
#define NPPM_DESTROYSCINTILLAHANDLE (NPPMSG + 21)
|
||||
#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
|
||||
//int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0)
|
||||
//return new unicodeMode
|
||||
|
||||
|
||||
#define NPPM_DECODESCI (NPPMSG + 27)
|
||||
//unicode file to ascii
|
||||
//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)
|
||||
// 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
|
||||
|
||||
|
||||
#define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
|
||||
//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"
|
||||
// in the beginning of this file then use the command symbols defined in "menuCmdID.h" file
|
||||
// to access all the Notepad++ menu command items
|
||||
|
||||
|
||||
#define NPPM_TRIGGERTABBARCONTEXTMENU (NPPMSG + 49)
|
||||
//void NPPM_TRIGGERTABBARCONTEXTMENU(int view, int index2Activate)
|
||||
|
||||
#define NPPM_GETNPPVERSION (NPPMSG + 50)
|
||||
// int NPPM_GETNPPVERSION(0, 0)
|
||||
// return version
|
||||
// return version
|
||||
// ex : v4.6
|
||||
// HIWORD(version) == 4
|
||||
// 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
|
||||
// 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 :
|
||||
// MAIN_VIEW 0
|
||||
// SUB_VIEW 1
|
||||
|
||||
#define NPPM_GETFULLPATHFROMBUFFERID (NPPMSG + 58)
|
||||
// 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
|
||||
// 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
|
||||
|
@ -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)
|
||||
// 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 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
|
||||
|
||||
#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)
|
||||
// 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 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
|
||||
|
||||
#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.hwndFrom = hwndNpp;
|
||||
//scnNotification->nmhdr.idFrom = BufferID;
|
||||
|
||||
|
||||
#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.hwndFrom = hwndNpp;
|
||||
//scnNotification->nmhdr.idFrom = BufferID;
|
||||
|
||||
|
||||
#define NPPN_FILESAVED (NPPN_FIRST + 8) // To notify plugins that the current file is just saved
|
||||
//scnNotification->nmhdr.code = NPPN_FILESAVED;
|
||||
//scnNotification->nmhdr.hwndFrom = hwndNpp;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -41,7 +41,8 @@ const int nbChar = 64;
|
|||
|
||||
typedef const TCHAR * (__cdecl * PFUNCGETNAME)();
|
||||
|
||||
struct NppData {
|
||||
struct NppData
|
||||
{
|
||||
HWND _nppHandle;
|
||||
HWND _scintillaMainHandle;
|
||||
HWND _scintillaSecondHandle;
|
||||
|
@ -53,14 +54,16 @@ typedef void (__cdecl * PBENOTIFIED)(SCNotification *);
|
|||
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
struct ShortcutKey {
|
||||
struct ShortcutKey
|
||||
{
|
||||
bool _isCtrl;
|
||||
bool _isAlt;
|
||||
bool _isShift;
|
||||
UCHAR _key;
|
||||
};
|
||||
|
||||
struct FuncItem {
|
||||
struct FuncItem
|
||||
{
|
||||
TCHAR _itemName[nbChar];
|
||||
PFUNCPLUGINCMD _pFunc;
|
||||
int _cmdID;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// 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\
|
||||
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)
|
||||
{
|
||||
SCNotification scnN;
|
||||
|
@ -58,6 +62,7 @@ bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_string> & dll2Remove)
|
||||
{
|
||||
const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath);
|
||||
|
@ -65,9 +70,10 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
|||
return 0;
|
||||
|
||||
PluginInfo *pi = new PluginInfo;
|
||||
try {
|
||||
try
|
||||
{
|
||||
pi->_moduleName = PathFindFileName(pluginFilePath);
|
||||
|
||||
|
||||
pi->_hLib = ::LoadLibrary(pluginFilePath);
|
||||
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."));
|
||||
|
@ -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++."));
|
||||
|
||||
pi->_pFuncSetInfo = (PFUNCSETINFO)GetProcAddress(pi->_hLib, "setInfo");
|
||||
|
||||
|
||||
if (!pi->_pFuncSetInfo)
|
||||
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");
|
||||
if (!pi->_pMessageProc)
|
||||
throw generic_string(TEXT("Missing \"messageProc\" function"));
|
||||
|
||||
|
||||
pi->_pFuncSetInfo(_nppData);
|
||||
|
||||
pi->_pFuncGetFuncsArray = (PFUNCGETFUNCSARRAY)GetProcAddress(pi->_hLib, "getFuncsArray");
|
||||
if (!pi->_pFuncGetFuncsArray)
|
||||
if (!pi->_pFuncGetFuncsArray)
|
||||
throw generic_string(TEXT("Missing \"getFuncsArray\" function"));
|
||||
|
||||
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"));
|
||||
|
||||
pi->_pluginMenu = ::CreateMenu();
|
||||
|
||||
|
||||
GetLexerCountFn GetLexerCount = (GetLexerCountFn)::GetProcAddress(pi->_hLib, "GetLexerCount");
|
||||
// it's a lexer plugin
|
||||
if (GetLexerCount)
|
||||
|
@ -128,7 +134,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
|||
int numLexers = GetLexerCount();
|
||||
|
||||
NppParameters * nppParams = NppParameters::getInstance();
|
||||
|
||||
|
||||
ExternalLangContainer *containers[30];
|
||||
|
||||
WcharMbcsConvertor *wmc = WcharMbcsConvertor::getInstance();
|
||||
|
@ -158,7 +164,7 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
|||
PathAppend(xmlPath, pi->_moduleName.c_str());
|
||||
PathRemoveExtension( xmlPath );
|
||||
PathAddExtension( xmlPath, TEXT(".xml") );
|
||||
|
||||
|
||||
if (! PathFileExists( xmlPath ) )
|
||||
{
|
||||
throw generic_string(generic_string(xmlPath) + TEXT(" is missing."));
|
||||
|
@ -173,24 +179,30 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
|||
pXmlDoc = NULL;
|
||||
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
|
||||
{
|
||||
if (containers[x] != NULL)
|
||||
nppParams->addExternalLangToEnd(containers[x]);
|
||||
}
|
||||
|
||||
nppParams->getExternalLexerFromXmlTree(pXmlDoc);
|
||||
nppParams->getExternalLexerDoc()->push_back(pXmlDoc);
|
||||
const char *pDllName = wmc->wchar2char(pluginFilePath, CP_ACP);
|
||||
::SendMessage(_nppData._scintillaMainHandle, SCI_LOADLEXERLIBRARY, 0, (LPARAM)pDllName);
|
||||
|
||||
|
||||
}
|
||||
addInLoadedDlls(pluginFileName);
|
||||
_pluginInfos.push_back(pi);
|
||||
return (_pluginInfos.size() - 1);
|
||||
} catch(std::exception e) {
|
||||
}
|
||||
catch (std::exception e)
|
||||
{
|
||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||
return -1;
|
||||
} catch(generic_string s) {
|
||||
}
|
||||
catch (generic_string s)
|
||||
{
|
||||
s += TEXT("\n\n");
|
||||
s += USERMSG;
|
||||
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;
|
||||
return -1;
|
||||
} catch(...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
generic_string msg = TEXT("Failed to load");
|
||||
msg += TEXT("\n\n");
|
||||
msg += USERMSG;
|
||||
|
@ -256,7 +270,7 @@ bool PluginsManager::loadPlugins(const TCHAR *dir)
|
|||
{
|
||||
loadPlugin(dllNames[i].c_str(), dll2Remove);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
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(""));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
_pluginsCommands.push_back(PluginCommand(_pluginInfos[i]->_moduleName.c_str(), j, _pluginInfos[i]->_funcItems[j]._pFunc));
|
||||
|
||||
|
||||
int cmdID = ID_PLUGINS_CMD + (_pluginsCommands.size() - 1);
|
||||
_pluginInfos[i]->_funcItems[j]._cmdID = cmdID;
|
||||
generic_string itemName = _pluginInfos[i]->_funcItems[j]._itemName;
|
||||
|
@ -366,11 +380,16 @@ void PluginsManager::runPluginCommand(size_t i)
|
|||
{
|
||||
if (_pluginsCommands[i]._pFunc != NULL)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
_pluginsCommands[i]._pFunc();
|
||||
} catch(std::exception e) {
|
||||
}
|
||||
catch (std::exception e)
|
||||
{
|
||||
::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK);
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
TCHAR funcInfo[128];
|
||||
generic_sprintf(funcInfo, TEXT("runPluginCommand(size_t i : %d)"), i);
|
||||
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
||||
|
@ -388,11 +407,16 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
|
|||
{
|
||||
if (_pluginsCommands[i]._funcID == commandID)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
_pluginsCommands[i]._pFunc();
|
||||
} catch(std::exception e) {
|
||||
}
|
||||
catch (std::exception e)
|
||||
{
|
||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
TCHAR funcInfo[128];
|
||||
generic_sprintf(funcInfo, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID);
|
||||
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)
|
||||
{
|
||||
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
|
||||
// Each notification to pass to a plugin is a copy of SCNotification instance
|
||||
SCNotification scNotif = *notification;
|
||||
try {
|
||||
try
|
||||
{
|
||||
_pluginInfos[i]->_pBeNotified(&scNotif);
|
||||
} catch(std::exception e) {
|
||||
}
|
||||
catch (std::exception e)
|
||||
{
|
||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
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"),\
|
||||
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)
|
||||
{
|
||||
for (size_t i = 0, len = _pluginInfos.size(); i < len ; ++i)
|
||||
{
|
||||
if (_pluginInfos[i]->_hLib)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
||||
} catch(std::exception e) {
|
||||
}
|
||||
catch (std::exception e)
|
||||
{
|
||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
TCHAR funcInfo[128];
|
||||
generic_sprintf(funcInfo, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
|
||||
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)
|
||||
{
|
||||
const TCHAR * moduleName = (const TCHAR *)wParam;
|
||||
|
@ -456,11 +493,16 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
if (_pluginInfos[i]->_hLib)
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
||||
} catch(std::exception e) {
|
||||
}
|
||||
catch (std::exception e)
|
||||
{
|
||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||
} catch (...) {
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
TCHAR funcInfo[128];
|
||||
generic_sprintf(funcInfo, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
|
||||
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
||||
|
@ -497,4 +539,5 @@ bool PluginsManager::allocateMarker(int numberRequired, int *start)
|
|||
retVal = false;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -47,24 +47,27 @@
|
|||
|
||||
typedef BOOL (__cdecl * PFUNCISUNICODE)();
|
||||
|
||||
struct PluginCommand {
|
||||
struct PluginCommand
|
||||
{
|
||||
generic_string _pluginName;
|
||||
int _funcID;
|
||||
PFUNCPLUGINCMD _pFunc;
|
||||
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),\
|
||||
_pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\
|
||||
_nbFuncItem(0){};
|
||||
~PluginInfo(){
|
||||
_nbFuncItem(0){}
|
||||
~PluginInfo()
|
||||
{
|
||||
if (_pluginMenu)
|
||||
::DestroyMenu(_pluginMenu);
|
||||
|
||||
if (_hLib)
|
||||
::FreeLibrary(_hLib);
|
||||
};
|
||||
}
|
||||
|
||||
HINSTANCE _hLib;
|
||||
HMENU _pluginMenu;
|
||||
|
@ -75,31 +78,34 @@ struct PluginInfo {
|
|||
PFUNCGETFUNCSARRAY _pFuncGetFuncsArray;
|
||||
PMESSAGEPROC _pMessageProc;
|
||||
PFUNCISUNICODE _pFuncIsUnicode;
|
||||
|
||||
|
||||
FuncItem *_funcItems;
|
||||
int _nbFuncItem;
|
||||
generic_string _moduleName;
|
||||
};
|
||||
|
||||
class PluginsManager {
|
||||
class PluginsManager
|
||||
{
|
||||
public:
|
||||
PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false), _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT),
|
||||
_markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {};
|
||||
~PluginsManager() {
|
||||
|
||||
_markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {}
|
||||
~PluginsManager()
|
||||
{
|
||||
for (size_t i = 0, len = _pluginInfos.size(); i < len; ++i)
|
||||
delete _pluginInfos[i];
|
||||
|
||||
if (_hPluginsMenu)
|
||||
DestroyMenu(_hPluginsMenu);
|
||||
};
|
||||
void init(const NppData & nppData) {
|
||||
}
|
||||
|
||||
void init(const NppData & nppData)
|
||||
{
|
||||
_nppData = nppData;
|
||||
};
|
||||
}
|
||||
|
||||
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
||||
bool loadPlugins(const TCHAR *dir = NULL);
|
||||
|
||||
|
||||
bool unloadPlugin(int index, HWND nppHandle);
|
||||
|
||||
void runPluginCommand(size_t i);
|
||||
|
@ -113,12 +119,10 @@ public:
|
|||
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
HMENU getMenuHandle() {
|
||||
return _hPluginsMenu;
|
||||
};
|
||||
HMENU getMenuHandle() const { return _hPluginsMenu; }
|
||||
|
||||
void disable() {_isDisabled = true;};
|
||||
bool hasPlugins(){return (_pluginInfos.size()!= 0);};
|
||||
void disable() {_isDisabled = true;}
|
||||
bool hasPlugins() {return (_pluginInfos.size()!= 0);}
|
||||
|
||||
bool allocateCmdID(int numberRequired, int *start);
|
||||
bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); }
|
||||
|
@ -135,22 +139,26 @@ private:
|
|||
bool _isDisabled;
|
||||
IDAllocator _dynamicIDAlloc;
|
||||
IDAllocator _markerAlloc;
|
||||
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) {
|
||||
|
||||
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature)
|
||||
{
|
||||
generic_string msg = pluginName;
|
||||
msg += TEXT(" just crash in\r");
|
||||
msg += funcSignature;
|
||||
::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)
|
||||
if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0)
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
void addInLoadedDlls(const TCHAR *fn) {
|
||||
_loadedDlls.push_back(fn);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#define EXT_LEXER_DECL __stdcall
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -31,14 +31,14 @@
|
|||
|
||||
enum progType {WIN32_PROG, CONSOLE_PROG};
|
||||
|
||||
class Process
|
||||
class Process
|
||||
{
|
||||
public:
|
||||
Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir)
|
||||
:_command(cmd), _args(args), _curDir(cDir){};
|
||||
:_command(cmd), _args(args), _curDir(cDir){}
|
||||
|
||||
void run();
|
||||
|
||||
|
||||
protected:
|
||||
generic_string _command;
|
||||
generic_string _args;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -30,6 +30,9 @@
|
|||
#include "process.h"
|
||||
//#include "SysMsg.h"
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL Process::run()
|
||||
{
|
||||
BOOL result = TRUE;
|
||||
|
@ -47,11 +50,12 @@ BOOL Process::run()
|
|||
|
||||
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
// Create stdout pipe
|
||||
if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0))
|
||||
error(TEXT("CreatePipe"), result, 1000);
|
||||
|
||||
|
||||
// Create stderr pipe
|
||||
if (!::CreatePipe(&_hPipeErrR, &hPipeErrW, &sa, 0))
|
||||
error(TEXT("CreatePipe"), result, 1001);
|
||||
|
@ -76,32 +80,34 @@ BOOL Process::run()
|
|||
_curDir, // inherit directory
|
||||
&startup, // STARTUPINFO
|
||||
&procinfo); // PROCESS_INFORMATION
|
||||
|
||||
|
||||
_hProcess = procinfo.hProcess;
|
||||
_hProcessThread = procinfo.hThread;
|
||||
|
||||
if(!started)
|
||||
if (!started)
|
||||
error(TEXT("CreateProcess"), result, 1002);
|
||||
|
||||
hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent"));
|
||||
if(!hListenerEvent[0])
|
||||
if (!hListenerEvent[0])
|
||||
error(TEXT("CreateEvent"), result, 1003);
|
||||
|
||||
hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent"));
|
||||
if(!hListenerEvent[1])
|
||||
if (!hListenerEvent[1])
|
||||
error(TEXT("CreateEvent"), result, 1004);
|
||||
|
||||
hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL);
|
||||
if (!hListenerStdOutThread)
|
||||
error(TEXT("CreateThread"), result, 1005);
|
||||
|
||||
|
||||
hListenerStdErrThread = ::CreateThread(NULL, 0, staticListenerStdErr, this, 0, NULL);
|
||||
if (!hListenerStdErrThread)
|
||||
error(TEXT("CreateThread"), result, 1006);
|
||||
|
||||
::WaitForSingleObject(_hProcess, INFINITE);
|
||||
::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE);
|
||||
} catch (int /*coderr*/){}
|
||||
}
|
||||
catch (int /*coderr*/)
|
||||
{}
|
||||
|
||||
// on va fermer toutes les handles
|
||||
if (hPipeOutW)
|
||||
|
@ -136,7 +142,7 @@ void Process::listenerStdOut()
|
|||
TCHAR bufferOut[MAX_LINE_LENGTH + 1];
|
||||
|
||||
int nExitCode = STILL_ACTIVE;
|
||||
|
||||
|
||||
DWORD outbytesRead;
|
||||
|
||||
::ResumeThread(_hProcessThread);
|
||||
|
@ -144,19 +150,19 @@ void Process::listenerStdOut()
|
|||
bool goOn = true;
|
||||
while (goOn)
|
||||
{ // got data
|
||||
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
|
||||
memset(bufferOut,0x00,MAX_LINE_LENGTH + 1);
|
||||
int taille = sizeof(bufferOut) - sizeof(TCHAR);
|
||||
|
||||
|
||||
Sleep(50);
|
||||
|
||||
if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL))
|
||||
if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL))
|
||||
{
|
||||
bytesAvail = 0;
|
||||
goOn = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(outbytesRead)
|
||||
if (outbytesRead)
|
||||
{
|
||||
result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL);
|
||||
if ((!result) && (outbytesRead == 0))
|
||||
|
@ -184,7 +190,7 @@ void Process::listenerStdOut()
|
|||
}
|
||||
_exitCode = nExitCode;
|
||||
|
||||
if(!::SetEvent(hListenerEvent))
|
||||
if (!::SetEvent(hListenerEvent))
|
||||
{
|
||||
systemMessage(TEXT("Thread listenerStdOut"));
|
||||
}
|
||||
|
@ -202,7 +208,7 @@ void Process::listenerStdErr()
|
|||
|
||||
::ResumeThread(_hProcessThread);
|
||||
|
||||
bool goOn = true;
|
||||
bool goOn = true;
|
||||
while (goOn)
|
||||
{ // got data
|
||||
memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1);
|
||||
|
@ -210,14 +216,14 @@ void Process::listenerStdErr()
|
|||
|
||||
Sleep(50);
|
||||
DWORD errbytesRead;
|
||||
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
|
||||
if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL))
|
||||
{
|
||||
bytesAvail = 0;
|
||||
goOn = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if(errbytesRead)
|
||||
if (errbytesRead)
|
||||
{
|
||||
result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL);
|
||||
if ((!result) && (errbytesRead == 0))
|
||||
|
@ -244,15 +250,17 @@ void Process::listenerStdErr()
|
|||
}
|
||||
//_exitCode = nExitCode;
|
||||
|
||||
if(!::SetEvent(hListenerEvent))
|
||||
if (!::SetEvent(hListenerEvent))
|
||||
{
|
||||
systemMessage(TEXT("Thread stdout listener"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode)
|
||||
{
|
||||
systemMessage(txt2display);
|
||||
returnCode = FALSE;
|
||||
throw int(errCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -33,45 +33,45 @@
|
|||
//#include <string>
|
||||
using namespace std;
|
||||
|
||||
class Process
|
||||
class Process
|
||||
{
|
||||
public:
|
||||
Process() {};
|
||||
Process() {}
|
||||
Process(const TCHAR *cmd, const TCHAR *cDir)
|
||||
: _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL),
|
||||
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) {
|
||||
|
||||
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL)
|
||||
{
|
||||
lstrcpy(_command, cmd);
|
||||
lstrcpy(_curDir, cDir);
|
||||
};
|
||||
}
|
||||
|
||||
BOOL run();
|
||||
|
||||
const TCHAR * getStdout() const {
|
||||
return _stdoutStr.c_str();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
const TCHAR * getStderr() const {
|
||||
return _stderrStr.c_str();
|
||||
};
|
||||
}
|
||||
|
||||
int getExitCode() const {
|
||||
return _exitCode;
|
||||
};
|
||||
}
|
||||
|
||||
bool hasStdout() {
|
||||
return (_stdoutStr.compare(TEXT("")) != 0);
|
||||
};
|
||||
}
|
||||
|
||||
bool hasStderr() {
|
||||
return (_stderrStr.compare(TEXT("")) != 0);
|
||||
};
|
||||
}
|
||||
|
||||
protected:
|
||||
// LES ENTREES
|
||||
TCHAR _command[256];
|
||||
TCHAR _curDir[256];
|
||||
|
||||
|
||||
// LES SORTIES
|
||||
generic_string _stdoutStr;
|
||||
generic_string _stderrStr;
|
||||
|
@ -84,7 +84,7 @@ protected:
|
|||
HANDLE _hProcessThread;
|
||||
|
||||
//UINT _pid; // process ID assigned by caller
|
||||
|
||||
|
||||
static DWORD WINAPI staticListenerStdOut(void * myself){
|
||||
((Process *)myself)->listenerStdOut();
|
||||
return 0;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -33,14 +33,17 @@
|
|||
|
||||
class ProcessThread
|
||||
{
|
||||
public :
|
||||
ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd) : _hwnd(hwnd) {
|
||||
public:
|
||||
ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd)
|
||||
: _hwnd(hwnd)
|
||||
{
|
||||
lstrcpy(_appName, appName);
|
||||
lstrcpy(_command, cmd);
|
||||
lstrcpy(_curDir, cDir);
|
||||
};
|
||||
|
||||
BOOL run(){
|
||||
}
|
||||
|
||||
BOOL run()
|
||||
{
|
||||
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent"));
|
||||
|
||||
_hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL);
|
||||
|
@ -49,9 +52,10 @@ public :
|
|||
|
||||
::CloseHandle(hEvent);
|
||||
return TRUE;
|
||||
};
|
||||
}
|
||||
|
||||
protected :
|
||||
|
||||
protected:
|
||||
// ENTREES
|
||||
TCHAR _appName[256];
|
||||
TCHAR _command[256];
|
||||
|
@ -59,12 +63,14 @@ protected :
|
|||
HWND _hwnd;
|
||||
HANDLE _hProcessThread;
|
||||
|
||||
static DWORD WINAPI staticLauncher(void *myself) {
|
||||
static DWORD WINAPI staticLauncher(void *myself)
|
||||
{
|
||||
((ProcessThread *)myself)->launch();
|
||||
return TRUE;
|
||||
};
|
||||
}
|
||||
|
||||
bool launch() {
|
||||
bool launch()
|
||||
{
|
||||
HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent"));
|
||||
HWND hwnd = _hwnd;
|
||||
TCHAR appName[256];
|
||||
|
@ -73,24 +79,22 @@ protected :
|
|||
|
||||
Process process(_command, _curDir);
|
||||
|
||||
if(!::SetEvent(hEvent))
|
||||
{
|
||||
if (!::SetEvent(hEvent))
|
||||
systemMessage(TEXT("Thread launcher"));
|
||||
}
|
||||
|
||||
process.run();
|
||||
|
||||
|
||||
int code = process.getExitCode();
|
||||
TCHAR codeStr[256];
|
||||
generic_sprintf(codeStr, TEXT("%s : %0.4X"), appName, code);
|
||||
::MessageBox(hwnd, process.getStdout(), codeStr, MB_OK);
|
||||
|
||||
|
||||
if (process.hasStderr())
|
||||
::MessageBox(hwnd, process.getStderr(), codeStr, MB_OK);
|
||||
|
||||
::CloseHandle(hMyself);
|
||||
return true;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif PROCESS_THREAD_H
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -24,14 +24,15 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#include "Common.h"
|
||||
#include "regExtDlg.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 nbExtMax = 10;
|
||||
|
@ -80,18 +81,19 @@ TCHAR defExtArray[nbSupportedLang][nbExtMax][extNameMax] = {
|
|||
|
||||
|
||||
|
||||
void RegExtDlg::doDialog(bool isRTL)
|
||||
void RegExtDlg::doDialog(bool isRTL)
|
||||
{
|
||||
if (isRTL)
|
||||
{
|
||||
DLGTEMPLATE *pMyDlgTemplate = NULL;
|
||||
DLGTEMPLATE *pMyDlgTemplate = nullptr;
|
||||
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate);
|
||||
::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this);
|
||||
::GlobalFree(hMyDlgTemplate);
|
||||
}
|
||||
else
|
||||
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, (LPARAM)this);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
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_REMOVEEXT_BUTTON), false);
|
||||
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETLIMITTEXT, extNameMax-1, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_COMMAND :
|
||||
case WM_COMMAND :
|
||||
{
|
||||
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);
|
||||
int i = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)ext2Add);
|
||||
if (i != LB_ERR)
|
||||
if (i != LB_ERR)
|
||||
return TRUE;
|
||||
addExt(ext2Add);
|
||||
::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;
|
||||
}
|
||||
|
||||
case IDCANCEL :
|
||||
case IDCANCEL:
|
||||
{
|
||||
::EndDialog(_hSelf, 0);
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
{
|
||||
TCHAR text[extNameMax] = TEXT("");
|
||||
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text);
|
||||
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)
|
||||
{
|
||||
{
|
||||
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
|
||||
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_CUSTOMEXT_EDIT), SW_HIDE);
|
||||
|
||||
|
||||
_isCustomize = false;
|
||||
}
|
||||
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);
|
||||
|
||||
for (int j = 1 ; j < nbExtMax ; ++j)
|
||||
{
|
||||
if (lstrcmp(TEXT(""), defExtArray[i][j]))
|
||||
{
|
||||
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
|
||||
if (index == -1)
|
||||
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
|
||||
}
|
||||
}
|
||||
|
||||
else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST)
|
||||
{
|
||||
if (i != LB_ERR)
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true);
|
||||
|
||||
}
|
||||
|
||||
else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST)
|
||||
{
|
||||
if (i != LB_ERR)
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true);
|
||||
}
|
||||
}
|
||||
|
||||
// break; // no break here
|
||||
}
|
||||
|
||||
default :
|
||||
return FALSE;
|
||||
}
|
||||
//return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void RegExtDlg::getRegisteredExts()
|
||||
{
|
||||
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
|
||||
|
@ -264,7 +269,7 @@ void RegExtDlg::getRegisteredExts()
|
|||
TCHAR extName[extNameLen];
|
||||
//FILETIME fileTime;
|
||||
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] == '.'))
|
||||
{
|
||||
//TCHAR valName[extNameLen];
|
||||
|
@ -274,8 +279,8 @@ void RegExtDlg::getRegisteredExts()
|
|||
HKEY hKey2Check;
|
||||
extNameActualLen = extNameLen;
|
||||
::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check);
|
||||
::RegQueryValueEx(hKey2Check, TEXT(""), NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
||||
//::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
||||
::RegQueryValueEx(hKey2Check, TEXT(""), nullptr, (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)))
|
||||
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName);
|
||||
::RegCloseKey(hKey2Check);
|
||||
|
@ -283,6 +288,7 @@ void RegExtDlg::getRegisteredExts()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void RegExtDlg::getDefSupportedExts()
|
||||
{
|
||||
for (int i = 0 ; i < nbSupportedLang ; ++i)
|
||||
|
@ -292,37 +298,30 @@ void RegExtDlg::getDefSupportedExts()
|
|||
|
||||
void RegExtDlg::addExt(TCHAR *ext)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dwDisp;
|
||||
long nRet;
|
||||
|
||||
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT,
|
||||
ext,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisp);
|
||||
|
||||
if (nRet == ERROR_SUCCESS)
|
||||
{
|
||||
HKEY hKey;
|
||||
DWORD dwDisp;
|
||||
long nRet;
|
||||
|
||||
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ext, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
|
||||
|
||||
if (nRet == ERROR_SUCCESS)
|
||||
{
|
||||
TCHAR valData[MAX_PATH];
|
||||
int valDataLen = MAX_PATH * sizeof(TCHAR);
|
||||
int valDataLen = MAX_PATH * sizeof(TCHAR);
|
||||
|
||||
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)
|
||||
::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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
|
||||
{
|
||||
HKEY hKey;
|
||||
|
@ -342,20 +341,21 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
|
|||
TCHAR valData[extNameLen];
|
||||
int valDataLen = extNameLen*sizeof(TCHAR);
|
||||
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)
|
||||
{
|
||||
::RegSetValueEx(hKey, NULL, 0, valType, (LPBYTE)valData, valDataLen);
|
||||
::RegSetValueEx(hKey, nullptr, 0, valType, (LPBYTE)valData, valDataLen);
|
||||
::RegDeleteValue(hKey, nppBackup);
|
||||
}
|
||||
else
|
||||
::RegDeleteValue(hKey, NULL);
|
||||
::RegDeleteValue(hKey, nullptr);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void RegExtDlg::writeNppPath()
|
||||
{
|
||||
HKEY hKey, hRootKey;
|
||||
|
@ -364,16 +364,7 @@ void RegExtDlg::writeNppPath()
|
|||
generic_string regStr(nppName);
|
||||
regStr += TEXT("\\shell\\open\\command");
|
||||
|
||||
nRet = ::RegCreateKeyEx(
|
||||
HKEY_CLASSES_ROOT,
|
||||
regStr.c_str(),
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisp);
|
||||
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
|
||||
|
||||
|
||||
if (nRet == ERROR_SUCCESS)
|
||||
|
@ -382,7 +373,7 @@ void RegExtDlg::writeNppPath()
|
|||
{
|
||||
// Write the value for new document
|
||||
::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey);
|
||||
::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
|
||||
::RegSetValueEx(hRootKey, nullptr, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
|
||||
RegCloseKey(hRootKey);
|
||||
|
||||
TCHAR nppPath[MAX_PATH];
|
||||
|
@ -391,7 +382,7 @@ void RegExtDlg::writeNppPath()
|
|||
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
||||
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);
|
||||
}
|
||||
|
@ -399,16 +390,7 @@ void RegExtDlg::writeNppPath()
|
|||
//Set default icon value
|
||||
regStr = nppName;
|
||||
regStr += TEXT("\\DefaultIcon");
|
||||
nRet = ::RegCreateKeyEx(
|
||||
HKEY_CLASSES_ROOT,
|
||||
regStr.c_str(),
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&hKey,
|
||||
&dwDisp);
|
||||
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
|
||||
|
||||
if (nRet == ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -420,8 +402,10 @@ void RegExtDlg::writeNppPath()
|
|||
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -46,7 +46,7 @@ private :
|
|||
bool _isCustomize;
|
||||
|
||||
INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
void getRegisteredExts();
|
||||
void getDefSupportedExts();
|
||||
void addExt(TCHAR *ext);
|
||||
|
@ -57,13 +57,13 @@ private :
|
|||
int nbSubKey;
|
||||
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
return (result == ERROR_SUCCESS)?nbSubKey:0;
|
||||
};
|
||||
}
|
||||
|
||||
int getNbSubValue(HKEY hKey) const {
|
||||
int nbSubValue;
|
||||
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
|
||||
return (result == ERROR_SUCCESS)?nbSubValue:0;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
#endif //REG_EXT_DLG_H
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -31,15 +31,15 @@
|
|||
|
||||
#define IDD_REGEXT_BOX 4000
|
||||
|
||||
#define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1)
|
||||
#define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2)
|
||||
#define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3)
|
||||
#define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4)
|
||||
#define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5)
|
||||
#define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6)
|
||||
#define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7)
|
||||
#define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8)
|
||||
#define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9)
|
||||
#define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10)
|
||||
#define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1)
|
||||
#define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2)
|
||||
#define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3)
|
||||
#define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4)
|
||||
#define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5)
|
||||
#define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6)
|
||||
#define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7)
|
||||
#define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8)
|
||||
#define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9)
|
||||
#define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10)
|
||||
|
||||
#endif //REGEXTDLGRC_H
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,10 +7,10 @@
|
|||
// version 2 of the License, or (at your option) any later version.
|
||||
//
|
||||
// Note that the GPL places important restrictions on "derived works", yet
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// it does not provide a detailed definition of that term. To avoid
|
||||
// misunderstandings, we consider an application to constitute a
|
||||
// "derivative work" for the purpose of this license if it does any of the
|
||||
// following:
|
||||
// following:
|
||||
// 1. Integrates source code from Notepad++.
|
||||
// 2. Integrates/includes/aggregates Notepad++ into a proprietary executable
|
||||
// installer, such as those produced by InstallShield.
|
||||
|
@ -164,7 +164,7 @@ struct TaskListInfo;
|
|||
struct VisibleGUIConf {
|
||||
bool isPostIt;
|
||||
bool isFullScreen;
|
||||
|
||||
|
||||
//Used by both views
|
||||
bool isMenuShown;
|
||||
//bool isToolbarShown; //toolbar forcefully hidden by hiding rebar
|
||||
|
@ -196,8 +196,8 @@ class ProjectPanel;
|
|||
class DocumentMap;
|
||||
class FunctionListPanel;
|
||||
|
||||
class Notepad_plus {
|
||||
|
||||
class Notepad_plus
|
||||
{
|
||||
friend class Notepad_plus_Window;
|
||||
friend class FileManager;
|
||||
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
bool fileReload() {
|
||||
BufferID buf = _pEditView->getCurrentBufferID();
|
||||
return doReload(buf, buf->isDirty());
|
||||
};
|
||||
}
|
||||
|
||||
bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
|
||||
bool fileCloseAll(bool doDeleteBackup, bool isSnapshotMode = false);
|
||||
|
@ -263,17 +263,17 @@ public:
|
|||
void saveUserDefineLangs() {
|
||||
if (ScintillaEditView::getUserDefineDlg()->isDirty())
|
||||
(NppParameters::getInstance())->writeUserDefinedLang();
|
||||
};
|
||||
}
|
||||
void saveShortcuts(){
|
||||
NppParameters::getInstance()->writeShortcuts();
|
||||
};
|
||||
}
|
||||
void saveSession(const Session & session);
|
||||
void saveCurrentSession();
|
||||
|
||||
void saveFindHistory(){
|
||||
_findReplaceDlg.saveFindHistory();
|
||||
(NppParameters::getInstance())->writeFindHistory();
|
||||
};
|
||||
}
|
||||
|
||||
void getCurrentOpenedFiles(Session & session, bool includUntitledDoc = false);
|
||||
|
||||
|
@ -286,13 +286,13 @@ public:
|
|||
bool doStreamComment();
|
||||
//--FLS: undoStreamComment: New function unDoStreamComment()
|
||||
bool undoStreamComment();
|
||||
|
||||
|
||||
bool addCurrentMacro();
|
||||
void macroPlayback(Macro);
|
||||
|
||||
|
||||
void loadLastSession();
|
||||
bool loadSession(Session & session, bool isSnapshotMode = false);
|
||||
|
||||
|
||||
void notifyBufferChanged(Buffer * buffer, int mask);
|
||||
bool findInFiles();
|
||||
bool replaceInFiles();
|
||||
|
@ -301,16 +301,16 @@ public:
|
|||
int getHtmlXmlEncoding(const TCHAR *fileName) const;
|
||||
HACCEL getAccTable() const{
|
||||
return _accelerator.getAccTable();
|
||||
};
|
||||
}
|
||||
bool emergency(generic_string emergencySavedDir);
|
||||
Buffer * getCurrentBuffer() {
|
||||
return _pEditView->getCurrentBuffer();
|
||||
};
|
||||
}
|
||||
void launchDocumentBackupTask();
|
||||
int getQuoteIndexFrom(const char *quoter) const;
|
||||
void showQuoteFromIndex(int index) const;
|
||||
void showQuote(const char *quote, const char *quoter, bool doTrolling) const;
|
||||
|
||||
|
||||
private:
|
||||
Notepad_plus_Window *_pPublicInterface;
|
||||
Window *_pMainWindow;
|
||||
|
@ -341,7 +341,7 @@ private:
|
|||
|
||||
ToolBar _toolBar;
|
||||
IconList _docTabIconList;
|
||||
|
||||
|
||||
StatusBar _statusBar;
|
||||
bool _toReduceTabBar;
|
||||
ReBar _rebarTop;
|
||||
|
@ -357,7 +357,7 @@ private:
|
|||
WordStyleDlg _configStyleDlg;
|
||||
PreferenceDlg _preference;
|
||||
FindCharsInRangeDlg _findCharsInRangeDlg;
|
||||
|
||||
|
||||
// a handle list of all the Notepad++ dialogs
|
||||
std::vector<HWND> _hModelessDlgs;
|
||||
|
||||
|
@ -369,7 +369,7 @@ private:
|
|||
HMENU _mainMenuHandle;
|
||||
|
||||
bool _sysMenuEntering;
|
||||
|
||||
|
||||
|
||||
// For FullScreen/PostIt features
|
||||
VisibleGUIConf _beforeSpecialView;
|
||||
|
@ -389,23 +389,27 @@ private:
|
|||
//For Dynamic selection highlight
|
||||
CharacterRange _prevSelectedRange;
|
||||
|
||||
struct ActivateAppInfo {
|
||||
struct ActivateAppInfo
|
||||
{
|
||||
bool _isActivated;
|
||||
int _x;
|
||||
int _y;
|
||||
ActivateAppInfo() : _isActivated(false), _x(0), _y(0){};
|
||||
} _activeAppInf;
|
||||
}
|
||||
_activeAppInf;
|
||||
|
||||
//Synchronized Scolling
|
||||
|
||||
struct SyncInfo {
|
||||
|
||||
struct SyncInfo
|
||||
{
|
||||
int _line;
|
||||
int _column;
|
||||
bool _isSynScollV;
|
||||
bool _isSynScollH;
|
||||
SyncInfo():_line(0), _column(0), _isSynScollV(false), _isSynScollH(false){};
|
||||
bool doSync() const {return (_isSynScollV || _isSynScollH); };
|
||||
} _syncInfo;
|
||||
}
|
||||
_syncInfo;
|
||||
|
||||
bool _isUDDocked;
|
||||
|
||||
|
@ -459,15 +463,15 @@ private:
|
|||
|
||||
int currentView(){
|
||||
return _activeView;
|
||||
};
|
||||
}
|
||||
|
||||
int otherView(){
|
||||
return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
||||
};
|
||||
}
|
||||
|
||||
int otherFromView(int whichOne){
|
||||
return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
||||
};
|
||||
}
|
||||
|
||||
bool canHideView(int whichOne); //true if view can safely be hidden (no open docs etc)
|
||||
|
||||
|
@ -510,7 +514,7 @@ private:
|
|||
|
||||
void setLangStatus(LangType langType){
|
||||
_statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE);
|
||||
};
|
||||
}
|
||||
|
||||
void setDisplayFormat(formatType f);
|
||||
int getCmdIDFromEncoding(int encoding) const;
|
||||
|
@ -523,45 +527,54 @@ private:
|
|||
|
||||
void checkMenuItem(int itemID, bool willBeChecked) const {
|
||||
::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED));
|
||||
};
|
||||
}
|
||||
|
||||
bool isConditionExprLine(int lineNumber);
|
||||
int findMachedBracePos(size_t startPos, size_t endPos, char targetSymbol, char matchedSymbol);
|
||||
void maintainIndentation(TCHAR ch);
|
||||
|
||||
|
||||
void addHotSpot();
|
||||
|
||||
void bookmarkAdd(int lineno) const {
|
||||
void bookmarkAdd(int lineno) const
|
||||
{
|
||||
if (lineno == -1)
|
||||
lineno = _pEditView->getCurrentLineNumber();
|
||||
if (!bookmarkPresent(lineno))
|
||||
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
|
||||
};
|
||||
void bookmarkDelete(int lineno) const {
|
||||
}
|
||||
|
||||
void bookmarkDelete(int lineno) const
|
||||
{
|
||||
if (lineno == -1)
|
||||
lineno = _pEditView->getCurrentLineNumber();
|
||||
if ( bookmarkPresent(lineno))
|
||||
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
|
||||
};
|
||||
bool bookmarkPresent(int lineno) const {
|
||||
}
|
||||
|
||||
bool bookmarkPresent(int lineno) const
|
||||
{
|
||||
if (lineno == -1)
|
||||
lineno = _pEditView->getCurrentLineNumber();
|
||||
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
|
||||
return ((state & (1 << MARK_BOOKMARK)) != 0);
|
||||
};
|
||||
void bookmarkToggle(int lineno) const {
|
||||
}
|
||||
|
||||
void bookmarkToggle(int lineno) const
|
||||
{
|
||||
if (lineno == -1)
|
||||
lineno = _pEditView->getCurrentLineNumber();
|
||||
|
||||
if (bookmarkPresent(lineno))
|
||||
bookmarkDelete(lineno);
|
||||
else
|
||||
bookmarkAdd(lineno);
|
||||
};
|
||||
bookmarkAdd(lineno);
|
||||
}
|
||||
|
||||
void bookmarkNext(bool forwardScan);
|
||||
void bookmarkClearAll() const {
|
||||
void bookmarkClearAll() const
|
||||
{
|
||||
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||
};
|
||||
}
|
||||
|
||||
void copyMarkedLines();
|
||||
void cutMarkedLines();
|
||||
|
@ -619,7 +632,7 @@ private:
|
|||
bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const;
|
||||
bool goToNextIndicator(int indicID2Search, bool isWrap = true) const;
|
||||
int wordCount();
|
||||
|
||||
|
||||
void wsTabConvert(spaceTab whichWay);
|
||||
void doTrim(trimOp whichPart);
|
||||
void removeEmptyLine(bool isBlankContained);
|
||||
|
@ -636,13 +649,15 @@ private:
|
|||
static bool deleteBack(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
||||
static bool deleteForward(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();
|
||||
if (rangeMax == -1)
|
||||
return randomNumber;
|
||||
return (rand() % rangeMax);
|
||||
};
|
||||
}
|
||||
|
||||
static DWORD WINAPI backupDocument(void *params);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue