Applied coding style / cleanup
parent
0cd514de13
commit
23cd144198
|
@ -44,12 +44,14 @@ void printInt(int int2print)
|
||||||
TCHAR str[32];
|
TCHAR str[32];
|
||||||
wsprintf(str, TEXT("%d"), int2print);
|
wsprintf(str, TEXT("%d"), int2print);
|
||||||
::MessageBox(NULL, str, TEXT(""), MB_OK);
|
::MessageBox(NULL, str, TEXT(""), MB_OK);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
void printStr(const TCHAR *str2print)
|
void printStr(const TCHAR *str2print)
|
||||||
{
|
{
|
||||||
::MessageBox(NULL, str2print, TEXT(""), MB_OK);
|
::MessageBox(NULL, str2print, TEXT(""), MB_OK);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string getFileContent(const TCHAR *file2read)
|
std::string getFileContent(const TCHAR *file2read)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +61,8 @@ std::string getFileContent(const TCHAR *file2read)
|
||||||
FILE *fp = generic_fopen(file2read, TEXT("rb"));
|
FILE *fp = generic_fopen(file2read, TEXT("rb"));
|
||||||
|
|
||||||
size_t lenFile = 0;
|
size_t lenFile = 0;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
lenFile = fread(data, 1, blockSize - 1, fp);
|
lenFile = fread(data, 1, blockSize - 1, fp);
|
||||||
if (lenFile <= 0) break;
|
if (lenFile <= 0) break;
|
||||||
|
|
||||||
|
@ -69,8 +72,8 @@ std::string getFileContent(const TCHAR *file2read)
|
||||||
data[lenFile] = '\0';
|
data[lenFile] = '\0';
|
||||||
|
|
||||||
wholeFileContent += data;
|
wholeFileContent += data;
|
||||||
|
}
|
||||||
} while (lenFile > 0);
|
while (lenFile > 0);
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return wholeFileContent;
|
return wholeFileContent;
|
||||||
|
@ -90,6 +93,7 @@ char getDriveLetter()
|
||||||
return drive;
|
return drive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
|
generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
|
||||||
{
|
{
|
||||||
generic_string fullFilePathName = TEXT("");
|
generic_string fullFilePathName = TEXT("");
|
||||||
|
@ -114,6 +118,7 @@ generic_string relativeFilePathToFullFilePath(const TCHAR *relativeFilePath)
|
||||||
return fullFilePathName;
|
return fullFilePathName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void writeFileContent(const TCHAR *file2write, const char *content2write)
|
void writeFileContent(const TCHAR *file2write, const char *content2write)
|
||||||
{
|
{
|
||||||
FILE *f = generic_fopen(file2write, TEXT("w+"));
|
FILE *f = generic_fopen(file2write, TEXT("w+"));
|
||||||
|
@ -122,6 +127,7 @@ void writeFileContent(const TCHAR *file2write, const char *content2write)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void writeLog(const TCHAR *logFileName, const char *log2write)
|
void writeLog(const TCHAR *logFileName, const char *log2write)
|
||||||
{
|
{
|
||||||
FILE *f = generic_fopen(logFileName, TEXT("a+"));
|
FILE *f = generic_fopen(logFileName, TEXT("a+"));
|
||||||
|
@ -131,6 +137,7 @@ void writeLog(const TCHAR *logFileName, const char *log2write)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set a call back with the handle after init to set the path.
|
// Set a call back with the handle after init to set the path.
|
||||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp
|
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/callbackfunctions/browsecallbackproc.asp
|
||||||
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
|
static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
|
||||||
|
@ -140,6 +147,7 @@ static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pDa
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
|
void folderBrowser(HWND parent, int outputCtrlID, const TCHAR *defaultStr)
|
||||||
{
|
{
|
||||||
// This code was copied and slightly modifed from:
|
// This code was copied and slightly modifed from:
|
||||||
|
@ -245,9 +253,11 @@ void ClientRectToScreenRect(HWND hWnd, RECT* rect)
|
||||||
::ClientToScreen( hWnd, &pt );
|
::ClientToScreen( hWnd, &pt );
|
||||||
rect->right = pt.x;
|
rect->right = pt.x;
|
||||||
rect->bottom = pt.y;
|
rect->bottom = pt.y;
|
||||||
};
|
}
|
||||||
|
|
||||||
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim) {
|
|
||||||
|
std::vector<generic_string> tokenizeString(const generic_string & tokenString, const char delim)
|
||||||
|
{
|
||||||
//Vector is created on stack and copied on return
|
//Vector is created on stack and copied on return
|
||||||
std::vector<generic_string> tokens;
|
std::vector<generic_string> tokens;
|
||||||
|
|
||||||
|
@ -268,6 +278,7 @@ std::vector<generic_string> tokenizeString(const generic_string & tokenString, c
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ScreenRectToClientRect(HWND hWnd, RECT* rect)
|
void ScreenRectToClientRect(HWND hWnd, RECT* rect)
|
||||||
{
|
{
|
||||||
POINT pt;
|
POINT pt;
|
||||||
|
@ -283,7 +294,8 @@ void ScreenRectToClientRect(HWND hWnd, RECT* rect)
|
||||||
::ScreenToClient( hWnd, &pt );
|
::ScreenToClient( hWnd, &pt );
|
||||||
rect->right = pt.x;
|
rect->right = pt.x;
|
||||||
rect->bottom = pt.y;
|
rect->bottom = pt.y;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
|
int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
|
||||||
{
|
{
|
||||||
|
@ -293,7 +305,9 @@ int filter(unsigned int code, struct _EXCEPTION_POINTERS *)
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInList(const TCHAR *token, const TCHAR *list) {
|
|
||||||
|
bool isInList(const TCHAR *token, const TCHAR *list)
|
||||||
|
{
|
||||||
if ((!token) || (!list))
|
if ((!token) || (!list))
|
||||||
return false;
|
return false;
|
||||||
TCHAR word[64];
|
TCHAR word[64];
|
||||||
|
@ -347,7 +361,8 @@ generic_string purgeMenuItemString(const TCHAR * menuItemStr, bool keepAmpersand
|
||||||
}
|
}
|
||||||
cleanedName[j] = 0;
|
cleanedName[j] = 0;
|
||||||
return cleanedName;
|
return cleanedName;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed)
|
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int lenMbcs, int *pLenWc, int *pBytesNotProcessed)
|
||||||
{
|
{
|
||||||
|
@ -409,6 +424,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||||
return _wideCharStr;
|
return _wideCharStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
|
// "mstart" and "mend" are pointers to indexes in mbcs2Convert,
|
||||||
// which are converted to the corresponding indexes in the returned wchar_t string.
|
// which are converted to the corresponding indexes in the returned wchar_t string.
|
||||||
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
|
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
|
||||||
|
@ -442,6 +458,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
|
||||||
return _wideCharStr;
|
return _wideCharStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, int lenWc, int *pLenMbcs)
|
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, int lenWc, int *pLenMbcs)
|
||||||
{
|
{
|
||||||
// Do not process NULL pointer
|
// Do not process NULL pointer
|
||||||
|
@ -456,10 +473,12 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
|
||||||
else
|
else
|
||||||
_multiByteStr.empty();
|
_multiByteStr.empty();
|
||||||
|
|
||||||
if(pLenMbcs) *pLenMbcs = lenMbcs;
|
if (pLenMbcs)
|
||||||
|
*pLenMbcs = lenMbcs;
|
||||||
return _multiByteStr;
|
return _multiByteStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, long *mstart, long *mend)
|
const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UINT codepage, long *mstart, long *mend)
|
||||||
{
|
{
|
||||||
// Do not process NULL pointer
|
// Do not process NULL pointer
|
||||||
|
@ -488,6 +507,7 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
|
||||||
return _multiByteStr;
|
return _multiByteStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::wstring string2wstring(const std::string & rString, UINT codepage)
|
std::wstring string2wstring(const std::string & rString, UINT codepage)
|
||||||
{
|
{
|
||||||
int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0);
|
int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0);
|
||||||
|
@ -614,6 +634,7 @@ generic_string BuildMenuFileName(int filenameLen, unsigned int pos, const generi
|
||||||
return strTemp;
|
return strTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string PathRemoveFileSpec(generic_string & path)
|
generic_string PathRemoveFileSpec(generic_string & path)
|
||||||
{
|
{
|
||||||
generic_string::size_type lastBackslash = path.find_last_of(TEXT('\\'));
|
generic_string::size_type lastBackslash = path.find_last_of(TEXT('\\'));
|
||||||
|
@ -636,6 +657,7 @@ generic_string PathRemoveFileSpec(generic_string & path)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string PathAppend(generic_string &strDest, const generic_string & str2append)
|
generic_string PathAppend(generic_string &strDest, const generic_string & str2append)
|
||||||
{
|
{
|
||||||
if (strDest == TEXT("") && str2append == TEXT("")) // "" + ""
|
if (strDest == TEXT("") && str2append == TEXT("")) // "" + ""
|
||||||
|
@ -671,6 +693,7 @@ generic_string PathAppend(generic_string &strDest, const generic_string & str2ap
|
||||||
return strDest;
|
return strDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
COLORREF getCtrlBgColor(HWND hWnd)
|
COLORREF getCtrlBgColor(HWND hWnd)
|
||||||
{
|
{
|
||||||
COLORREF crRet = CLR_INVALID;
|
COLORREF crRet = CLR_INVALID;
|
||||||
|
@ -709,12 +732,14 @@ COLORREF getCtrlBgColor(HWND hWnd)
|
||||||
return crRet;
|
return crRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string stringToUpper(generic_string strToConvert)
|
generic_string stringToUpper(generic_string strToConvert)
|
||||||
{
|
{
|
||||||
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper);
|
std::transform(strToConvert.begin(), strToConvert.end(), strToConvert.begin(), ::toupper);
|
||||||
return strToConvert;
|
return strToConvert;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace)
|
generic_string stringReplace(generic_string subject, const generic_string& search, const generic_string& replace)
|
||||||
{
|
{
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
@ -726,6 +751,7 @@ generic_string stringReplace(generic_string subject, const generic_string& searc
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter)
|
std::vector<generic_string> stringSplit(const generic_string& input, const generic_string& delimiter)
|
||||||
{
|
{
|
||||||
auto start = 0U;
|
auto start = 0U;
|
||||||
|
@ -742,6 +768,7 @@ std::vector<generic_string> stringSplit(const generic_string& input, const gener
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator)
|
generic_string stringJoin(const std::vector<generic_string>& strings, const generic_string& separator)
|
||||||
{
|
{
|
||||||
generic_string joined;
|
generic_string joined;
|
||||||
|
@ -757,6 +784,7 @@ generic_string stringJoin(const std::vector<generic_string>& strings, const gene
|
||||||
return joined;
|
return joined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable)
|
generic_string stringTakeWhileAdmissable(const generic_string& input, const generic_string& admissable)
|
||||||
{
|
{
|
||||||
// Find first non-admissable character in "input", and remove everything after it.
|
// Find first non-admissable character in "input", and remove everything after it.
|
||||||
|
@ -771,6 +799,7 @@ generic_string stringTakeWhileAdmissable(const generic_string& input, const gene
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double stodLocale(const generic_string& str, _locale_t loc, size_t* idx)
|
double stodLocale(const generic_string& str, _locale_t loc, size_t* idx)
|
||||||
{
|
{
|
||||||
// Copied from the std::stod implementation but uses _wcstod_l instead of wcstod.
|
// Copied from the std::stod implementation but uses _wcstod_l instead of wcstod.
|
||||||
|
@ -833,3 +862,6 @@ bool str2Clipboard(const generic_string &str2cpy, HWND hwnd)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -134,19 +134,20 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WcharMbcsConvertor() {
|
WcharMbcsConvertor() {}
|
||||||
};
|
~WcharMbcsConvertor() {}
|
||||||
~WcharMbcsConvertor() {
|
|
||||||
};
|
|
||||||
static WcharMbcsConvertor * _pSelf;
|
static WcharMbcsConvertor * _pSelf;
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class StringBuffer {
|
class StringBuffer
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
StringBuffer() : _str(0), _allocLen(0) { }
|
StringBuffer() : _str(0), _allocLen(0) { }
|
||||||
~StringBuffer() { if(_allocLen) delete [] _str; }
|
~StringBuffer() { if(_allocLen) delete [] _str; }
|
||||||
|
|
||||||
void sizeTo(size_t size) {
|
void sizeTo(size_t size)
|
||||||
|
{
|
||||||
if(_allocLen < size)
|
if(_allocLen < size)
|
||||||
{
|
{
|
||||||
if(_allocLen) delete[] _str;
|
if(_allocLen) delete[] _str;
|
||||||
|
@ -154,7 +155,8 @@ protected:
|
||||||
_str = new T[_allocLen];
|
_str = new T[_allocLen];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void empty() {
|
void empty()
|
||||||
|
{
|
||||||
static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case
|
static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case
|
||||||
if(_allocLen == 0)
|
if(_allocLen == 0)
|
||||||
_str = &nullStr;
|
_str = &nullStr;
|
||||||
|
@ -176,9 +178,10 @@ protected:
|
||||||
private:
|
private:
|
||||||
// Since there's no public ctor, we need to void the default assignment operator.
|
// Since there's no public ctor, we need to void the default assignment operator.
|
||||||
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&);
|
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MACRO_RECORDING_IN_PROGRESS 1
|
#define MACRO_RECORDING_IN_PROGRESS 1
|
||||||
#define MACRO_RECORDING_HAS_STOPPED 2
|
#define MACRO_RECORDING_HAS_STOPPED 2
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,13 @@
|
||||||
#include "Win32Exception.h"
|
#include "Win32Exception.h"
|
||||||
|
|
||||||
|
|
||||||
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
|
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info)
|
||||||
|
{
|
||||||
_location = info->ExceptionRecord->ExceptionAddress;
|
_location = info->ExceptionRecord->ExceptionAddress;
|
||||||
_code = info->ExceptionRecord->ExceptionCode;
|
_code = info->ExceptionRecord->ExceptionCode;
|
||||||
_info = info;
|
_info = info;
|
||||||
switch (_code) {
|
switch (_code)
|
||||||
|
{
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
_event = "Access violation";
|
_event = "Access violation";
|
||||||
break;
|
break;
|
||||||
|
@ -52,17 +54,21 @@ Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Exception::installHandler() {
|
void Win32Exception::installHandler()
|
||||||
|
{
|
||||||
_set_se_translator(Win32Exception::translate);
|
_set_se_translator(Win32Exception::translate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Exception::removeHandler() {
|
void Win32Exception::removeHandler()
|
||||||
|
{
|
||||||
_set_se_translator(NULL);
|
_set_se_translator(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) {
|
void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info)
|
||||||
|
{
|
||||||
// Windows guarantees that *(info->ExceptionRecord) is valid
|
// Windows guarantees that *(info->ExceptionRecord) is valid
|
||||||
switch (code) {
|
switch (code)
|
||||||
|
{
|
||||||
case EXCEPTION_ACCESS_VIOLATION:
|
case EXCEPTION_ACCESS_VIOLATION:
|
||||||
throw Win32AccessViolation(info);
|
throw Win32AccessViolation(info);
|
||||||
break;
|
break;
|
||||||
|
@ -71,7 +77,12 @@ void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info) : Win32Exception(info) {
|
|
||||||
|
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info)
|
||||||
|
: Win32Exception(info)
|
||||||
|
{
|
||||||
_isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1;
|
_isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1;
|
||||||
_badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]);
|
_badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,10 @@ class Win32Exception : public std::exception
|
||||||
public:
|
public:
|
||||||
static void installHandler();
|
static void installHandler();
|
||||||
static void removeHandler();
|
static void removeHandler();
|
||||||
virtual const char* what() const throw() { return _event; };
|
virtual const char* what() const throw() { return _event; }
|
||||||
ExceptionAddress where() const { return _location; };
|
ExceptionAddress where() const { return _location; }
|
||||||
unsigned int code() const { return _code; };
|
unsigned int code() const { return _code; }
|
||||||
EXCEPTION_POINTERS* info() const { return _info; };
|
EXCEPTION_POINTERS* info() const { return _info; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler
|
Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler
|
||||||
|
@ -61,11 +61,12 @@ private:
|
||||||
EXCEPTION_POINTERS * _info;
|
EXCEPTION_POINTERS * _info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Win32AccessViolation: public Win32Exception
|
class Win32AccessViolation: public Win32Exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool isWrite() const { return _isWrite; };
|
bool isWrite() const { return _isWrite; }
|
||||||
ExceptionAddress badAddress() const { return _badAddress; };
|
ExceptionAddress badAddress() const { return _badAddress; }
|
||||||
private:
|
private:
|
||||||
Win32AccessViolation(EXCEPTION_POINTERS * info);
|
Win32AccessViolation(EXCEPTION_POINTERS * info);
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,13 @@
|
||||||
|
|
||||||
typedef std::vector<generic_string> stringVector;
|
typedef std::vector<generic_string> stringVector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FileNameStringSplitter
|
class FileNameStringSplitter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileNameStringSplitter(const TCHAR *fileNameStr) {
|
FileNameStringSplitter(const TCHAR *fileNameStr)
|
||||||
|
{
|
||||||
//if (!fileNameStr) return;
|
//if (!fileNameStr) return;
|
||||||
TCHAR *pStr = NULL;
|
TCHAR *pStr = NULL;
|
||||||
bool isInsideQuotes = false;
|
bool isInsideQuotes = false;
|
||||||
|
@ -43,6 +46,7 @@ public :
|
||||||
TCHAR str[filePathLength];
|
TCHAR str[filePathLength];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
bool fini = false;
|
bool fini = false;
|
||||||
|
|
||||||
for (pStr = (TCHAR *)fileNameStr ; !fini ; )
|
for (pStr = (TCHAR *)fileNameStr ; !fini ; )
|
||||||
{
|
{
|
||||||
if (i >= filePathLength)
|
if (i >= filePathLength)
|
||||||
|
@ -51,6 +55,7 @@ public :
|
||||||
switch (*pStr)
|
switch (*pStr)
|
||||||
{
|
{
|
||||||
case '"':
|
case '"':
|
||||||
|
{
|
||||||
if (isInsideQuotes)
|
if (isInsideQuotes)
|
||||||
{
|
{
|
||||||
str[i] = '\0';
|
str[i] = '\0';
|
||||||
|
@ -61,8 +66,10 @@ public :
|
||||||
isInsideQuotes = !isInsideQuotes;
|
isInsideQuotes = !isInsideQuotes;
|
||||||
pStr++;
|
pStr++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ' ':
|
case ' ':
|
||||||
|
{
|
||||||
if (isInsideQuotes)
|
if (isInsideQuotes)
|
||||||
{
|
{
|
||||||
str[i] = *pStr;
|
str[i] = *pStr;
|
||||||
|
@ -77,34 +84,41 @@ public :
|
||||||
}
|
}
|
||||||
pStr++;
|
pStr++;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case '\0':
|
case '\0':
|
||||||
|
{
|
||||||
str[i] = *pStr;
|
str[i] = *pStr;
|
||||||
if (str[0])
|
if (str[0])
|
||||||
_fileNames.push_back(generic_string(str));
|
_fileNames.push_back(generic_string(str));
|
||||||
fini = true;
|
fini = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
|
{
|
||||||
str[i] = *pStr;
|
str[i] = *pStr;
|
||||||
i++; pStr++;
|
i++; pStr++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const TCHAR * getFileName(size_t index) const {
|
const TCHAR * getFileName(size_t index) const {
|
||||||
if (index >= _fileNames.size())
|
if (index >= _fileNames.size())
|
||||||
return NULL;
|
return NULL;
|
||||||
return _fileNames[index].c_str();
|
return _fileNames[index].c_str();
|
||||||
};
|
}
|
||||||
|
|
||||||
int size() const {
|
int size() const {
|
||||||
return int(_fileNames.size());
|
return int(_fileNames.size());
|
||||||
};
|
}
|
||||||
|
|
||||||
private :
|
private :
|
||||||
stringVector _fileNames;
|
stringVector _fileNames;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //FILENAME_STRING_SPLITTER_H
|
#endif //FILENAME_STRING_SPLITTER_H
|
||||||
|
|
|
@ -41,7 +41,8 @@ const int nbChar = 64;
|
||||||
|
|
||||||
typedef const TCHAR * (__cdecl * PFUNCGETNAME)();
|
typedef const TCHAR * (__cdecl * PFUNCGETNAME)();
|
||||||
|
|
||||||
struct NppData {
|
struct NppData
|
||||||
|
{
|
||||||
HWND _nppHandle;
|
HWND _nppHandle;
|
||||||
HWND _scintillaMainHandle;
|
HWND _scintillaMainHandle;
|
||||||
HWND _scintillaSecondHandle;
|
HWND _scintillaSecondHandle;
|
||||||
|
@ -53,14 +54,16 @@ typedef void (__cdecl * PBENOTIFIED)(SCNotification *);
|
||||||
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);
|
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
|
||||||
struct ShortcutKey {
|
struct ShortcutKey
|
||||||
|
{
|
||||||
bool _isCtrl;
|
bool _isCtrl;
|
||||||
bool _isAlt;
|
bool _isAlt;
|
||||||
bool _isShift;
|
bool _isShift;
|
||||||
UCHAR _key;
|
UCHAR _key;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FuncItem {
|
struct FuncItem
|
||||||
|
{
|
||||||
TCHAR _itemName[nbChar];
|
TCHAR _itemName[nbChar];
|
||||||
PFUNCPLUGINCMD _pFunc;
|
PFUNCPLUGINCMD _pFunc;
|
||||||
int _cmdID;
|
int _cmdID;
|
||||||
|
|
|
@ -35,6 +35,10 @@ using namespace std;
|
||||||
const TCHAR * USERMSG = TEXT("This plugin is not compatible with current version of Notepad++.\n\n\
|
const TCHAR * USERMSG = TEXT("This plugin is not compatible with current version of Notepad++.\n\n\
|
||||||
Do you want to remove this plugin from plugins directory to prevent this message from the next launch time?");
|
Do you want to remove this plugin from plugins directory to prevent this message from the next launch time?");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
|
bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
|
||||||
{
|
{
|
||||||
SCNotification scnN;
|
SCNotification scnN;
|
||||||
|
@ -58,6 +62,7 @@ bool PluginsManager::unloadPlugin(int index, HWND nppHandle)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_string> & dll2Remove)
|
int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_string> & dll2Remove)
|
||||||
{
|
{
|
||||||
const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath);
|
const TCHAR *pluginFileName = ::PathFindFileName(pluginFilePath);
|
||||||
|
@ -65,7 +70,8 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
PluginInfo *pi = new PluginInfo;
|
PluginInfo *pi = new PluginInfo;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
pi->_moduleName = PathFindFileName(pluginFilePath);
|
pi->_moduleName = PathFindFileName(pluginFilePath);
|
||||||
|
|
||||||
pi->_hLib = ::LoadLibrary(pluginFilePath);
|
pi->_hLib = ::LoadLibrary(pluginFilePath);
|
||||||
|
@ -175,8 +181,10 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int x = 0; x < numLexers; ++x) // postpone adding in case the xml is missing/corrupt
|
for (int x = 0; x < numLexers; ++x) // postpone adding in case the xml is missing/corrupt
|
||||||
|
{
|
||||||
if (containers[x] != NULL)
|
if (containers[x] != NULL)
|
||||||
nppParams->addExternalLangToEnd(containers[x]);
|
nppParams->addExternalLangToEnd(containers[x]);
|
||||||
|
}
|
||||||
|
|
||||||
nppParams->getExternalLexerFromXmlTree(pXmlDoc);
|
nppParams->getExternalLexerFromXmlTree(pXmlDoc);
|
||||||
nppParams->getExternalLexerDoc()->push_back(pXmlDoc);
|
nppParams->getExternalLexerDoc()->push_back(pXmlDoc);
|
||||||
|
@ -187,10 +195,14 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
||||||
addInLoadedDlls(pluginFileName);
|
addInLoadedDlls(pluginFileName);
|
||||||
_pluginInfos.push_back(pi);
|
_pluginInfos.push_back(pi);
|
||||||
return (_pluginInfos.size() - 1);
|
return (_pluginInfos.size() - 1);
|
||||||
} catch(std::exception e) {
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||||
return -1;
|
return -1;
|
||||||
} catch(generic_string s) {
|
}
|
||||||
|
catch (generic_string s)
|
||||||
|
{
|
||||||
s += TEXT("\n\n");
|
s += TEXT("\n\n");
|
||||||
s += USERMSG;
|
s += USERMSG;
|
||||||
if (::MessageBox(NULL, s.c_str(), pluginFilePath, MB_YESNO) == IDYES)
|
if (::MessageBox(NULL, s.c_str(), pluginFilePath, MB_YESNO) == IDYES)
|
||||||
|
@ -199,7 +211,9 @@ int PluginsManager::loadPlugin(const TCHAR *pluginFilePath, vector<generic_strin
|
||||||
}
|
}
|
||||||
delete pi;
|
delete pi;
|
||||||
return -1;
|
return -1;
|
||||||
} catch(...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
generic_string msg = TEXT("Failed to load");
|
generic_string msg = TEXT("Failed to load");
|
||||||
msg += TEXT("\n\n");
|
msg += TEXT("\n\n");
|
||||||
msg += USERMSG;
|
msg += USERMSG;
|
||||||
|
@ -366,11 +380,16 @@ void PluginsManager::runPluginCommand(size_t i)
|
||||||
{
|
{
|
||||||
if (_pluginsCommands[i]._pFunc != NULL)
|
if (_pluginsCommands[i]._pFunc != NULL)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
_pluginsCommands[i]._pFunc();
|
_pluginsCommands[i]._pFunc();
|
||||||
} catch(std::exception e) {
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK);
|
::MessageBoxA(NULL, e.what(), "PluginsManager::runPluginCommand Exception", MB_OK);
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
TCHAR funcInfo[128];
|
TCHAR funcInfo[128];
|
||||||
generic_sprintf(funcInfo, TEXT("runPluginCommand(size_t i : %d)"), i);
|
generic_sprintf(funcInfo, TEXT("runPluginCommand(size_t i : %d)"), i);
|
||||||
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
||||||
|
@ -388,11 +407,16 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
|
||||||
{
|
{
|
||||||
if (_pluginsCommands[i]._funcID == commandID)
|
if (_pluginsCommands[i]._funcID == commandID)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
_pluginsCommands[i]._pFunc();
|
_pluginsCommands[i]._pFunc();
|
||||||
} catch(std::exception e) {
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
TCHAR funcInfo[128];
|
TCHAR funcInfo[128];
|
||||||
generic_sprintf(funcInfo, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID);
|
generic_sprintf(funcInfo, TEXT("runPluginCommand(const TCHAR *pluginName : %s, int commandID : %d)"), pluginName, commandID);
|
||||||
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
||||||
|
@ -402,6 +426,7 @@ void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PluginsManager::notify(const SCNotification *notification)
|
void PluginsManager::notify(const SCNotification *notification)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i)
|
for (size_t i = 0, len = _pluginInfos.size() ; i < len ; ++i)
|
||||||
|
@ -411,11 +436,16 @@ void PluginsManager::notify(const SCNotification *notification)
|
||||||
// To avoid the plugin change the data in SCNotification
|
// To avoid the plugin change the data in SCNotification
|
||||||
// Each notification to pass to a plugin is a copy of SCNotification instance
|
// Each notification to pass to a plugin is a copy of SCNotification instance
|
||||||
SCNotification scNotif = *notification;
|
SCNotification scNotif = *notification;
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
_pluginInfos[i]->_pBeNotified(&scNotif);
|
_pluginInfos[i]->_pBeNotified(&scNotif);
|
||||||
} catch(std::exception e) {
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
TCHAR funcInfo[128];
|
TCHAR funcInfo[128];
|
||||||
generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %d"),\
|
generic_sprintf(funcInfo, TEXT("notify(SCNotification *notification) : \r notification->nmhdr.code == %d\r notification->nmhdr.hwndFrom == %p\r notification->nmhdr.idFrom == %d"),\
|
||||||
scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom);
|
scNotif.nmhdr.code, scNotif.nmhdr.hwndFrom, scNotif.nmhdr.idFrom);
|
||||||
|
@ -425,17 +455,23 @@ void PluginsManager::notify(const SCNotification *notification)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam)
|
void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, len = _pluginInfos.size(); i < len ; ++i)
|
for (size_t i = 0, len = _pluginInfos.size(); i < len ; ++i)
|
||||||
{
|
{
|
||||||
if (_pluginInfos[i]->_hLib)
|
if (_pluginInfos[i]->_hLib)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
||||||
} catch(std::exception e) {
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
TCHAR funcInfo[128];
|
TCHAR funcInfo[128];
|
||||||
generic_sprintf(funcInfo, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
|
generic_sprintf(funcInfo, TEXT("relayNppMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
|
||||||
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT(""));
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT(""));
|
||||||
|
@ -444,6 +480,7 @@ void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam)
|
bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
const TCHAR * moduleName = (const TCHAR *)wParam;
|
const TCHAR * moduleName = (const TCHAR *)wParam;
|
||||||
|
@ -456,11 +493,16 @@ bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lPa
|
||||||
{
|
{
|
||||||
if (_pluginInfos[i]->_hLib)
|
if (_pluginInfos[i]->_hLib)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
||||||
} catch(std::exception e) {
|
}
|
||||||
|
catch (std::exception e)
|
||||||
|
{
|
||||||
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
::MessageBoxA(NULL, e.what(), "Exception", MB_OK);
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
TCHAR funcInfo[128];
|
TCHAR funcInfo[128];
|
||||||
generic_sprintf(funcInfo, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
|
generic_sprintf(funcInfo, TEXT("relayPluginMessages(UINT Message : %d, WPARAM wParam : %d, LPARAM lParam : %d)"), Message, wParam, lParam);
|
||||||
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), funcInfo);
|
||||||
|
@ -498,3 +540,4 @@ bool PluginsManager::allocateMarker(int numberRequired, int *start)
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,24 +47,27 @@
|
||||||
|
|
||||||
typedef BOOL (__cdecl * PFUNCISUNICODE)();
|
typedef BOOL (__cdecl * PFUNCISUNICODE)();
|
||||||
|
|
||||||
struct PluginCommand {
|
struct PluginCommand
|
||||||
|
{
|
||||||
generic_string _pluginName;
|
generic_string _pluginName;
|
||||||
int _funcID;
|
int _funcID;
|
||||||
PFUNCPLUGINCMD _pFunc;
|
PFUNCPLUGINCMD _pFunc;
|
||||||
PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc), _pluginName(pluginName){};
|
PluginCommand(const TCHAR *pluginName, int funcID, PFUNCPLUGINCMD pFunc): _funcID(funcID), _pFunc(pFunc), _pluginName(pluginName){};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PluginInfo {
|
struct PluginInfo
|
||||||
|
{
|
||||||
PluginInfo() :_hLib(NULL), _pluginMenu(NULL), _pFuncSetInfo(NULL),\
|
PluginInfo() :_hLib(NULL), _pluginMenu(NULL), _pFuncSetInfo(NULL),\
|
||||||
_pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\
|
_pFuncGetFuncsArray(NULL), _pFuncGetName(NULL), _funcItems(NULL),\
|
||||||
_nbFuncItem(0){};
|
_nbFuncItem(0){}
|
||||||
~PluginInfo(){
|
~PluginInfo()
|
||||||
|
{
|
||||||
if (_pluginMenu)
|
if (_pluginMenu)
|
||||||
::DestroyMenu(_pluginMenu);
|
::DestroyMenu(_pluginMenu);
|
||||||
|
|
||||||
if (_hLib)
|
if (_hLib)
|
||||||
::FreeLibrary(_hLib);
|
::FreeLibrary(_hLib);
|
||||||
};
|
}
|
||||||
|
|
||||||
HINSTANCE _hLib;
|
HINSTANCE _hLib;
|
||||||
HMENU _pluginMenu;
|
HMENU _pluginMenu;
|
||||||
|
@ -81,21 +84,24 @@ struct PluginInfo {
|
||||||
generic_string _moduleName;
|
generic_string _moduleName;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PluginsManager {
|
class PluginsManager
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false), _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT),
|
PluginsManager() : _hPluginsMenu(NULL), _isDisabled(false), _dynamicIDAlloc(ID_PLUGINS_CMD_DYNAMIC, ID_PLUGINS_CMD_DYNAMIC_LIMIT),
|
||||||
_markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {};
|
_markerAlloc(MARKER_PLUGINS, MARKER_PLUGINS_LIMIT) {}
|
||||||
~PluginsManager() {
|
~PluginsManager()
|
||||||
|
{
|
||||||
for (size_t i = 0, len = _pluginInfos.size(); i < len; ++i)
|
for (size_t i = 0, len = _pluginInfos.size(); i < len; ++i)
|
||||||
delete _pluginInfos[i];
|
delete _pluginInfos[i];
|
||||||
|
|
||||||
if (_hPluginsMenu)
|
if (_hPluginsMenu)
|
||||||
DestroyMenu(_hPluginsMenu);
|
DestroyMenu(_hPluginsMenu);
|
||||||
};
|
}
|
||||||
void init(const NppData & nppData) {
|
|
||||||
|
void init(const NppData & nppData)
|
||||||
|
{
|
||||||
_nppData = nppData;
|
_nppData = nppData;
|
||||||
};
|
}
|
||||||
|
|
||||||
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
int loadPlugin(const TCHAR *pluginFilePath, std::vector<generic_string> & dll2Remove);
|
||||||
bool loadPlugins(const TCHAR *dir = NULL);
|
bool loadPlugins(const TCHAR *dir = NULL);
|
||||||
|
@ -113,12 +119,10 @@ public:
|
||||||
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
HMENU getMenuHandle() {
|
HMENU getMenuHandle() const { return _hPluginsMenu; }
|
||||||
return _hPluginsMenu;
|
|
||||||
};
|
|
||||||
|
|
||||||
void disable() {_isDisabled = true;};
|
void disable() {_isDisabled = true;}
|
||||||
bool hasPlugins(){return (_pluginInfos.size()!= 0);};
|
bool hasPlugins() {return (_pluginInfos.size()!= 0);}
|
||||||
|
|
||||||
bool allocateCmdID(int numberRequired, int *start);
|
bool allocateCmdID(int numberRequired, int *start);
|
||||||
bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); }
|
bool inDynamicRange(int id) { return _dynamicIDAlloc.isInRange(id); }
|
||||||
|
@ -135,22 +139,26 @@ private:
|
||||||
bool _isDisabled;
|
bool _isDisabled;
|
||||||
IDAllocator _dynamicIDAlloc;
|
IDAllocator _dynamicIDAlloc;
|
||||||
IDAllocator _markerAlloc;
|
IDAllocator _markerAlloc;
|
||||||
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) {
|
|
||||||
|
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature)
|
||||||
|
{
|
||||||
generic_string msg = pluginName;
|
generic_string msg = pluginName;
|
||||||
msg += TEXT(" just crash in\r");
|
msg += TEXT(" just crash in\r");
|
||||||
msg += funcSignature;
|
msg += funcSignature;
|
||||||
::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP);
|
::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP);
|
||||||
};
|
}
|
||||||
bool isInLoadedDlls(const TCHAR *fn) const {
|
|
||||||
|
bool isInLoadedDlls(const TCHAR *fn) const
|
||||||
|
{
|
||||||
for (size_t i = 0; i < _loadedDlls.size(); ++i)
|
for (size_t i = 0; i < _loadedDlls.size(); ++i)
|
||||||
if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0)
|
if (generic_stricmp(fn, _loadedDlls[i].c_str()) == 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
};
|
}
|
||||||
|
|
||||||
void addInLoadedDlls(const TCHAR *fn) {
|
void addInLoadedDlls(const TCHAR *fn) {
|
||||||
_loadedDlls.push_back(fn);
|
_loadedDlls.push_back(fn);
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EXT_LEXER_DECL __stdcall
|
#define EXT_LEXER_DECL __stdcall
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Process
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir)
|
Process(const TCHAR *cmd, const TCHAR *args, const TCHAR *cDir)
|
||||||
:_command(cmd), _args(args), _curDir(cDir){};
|
:_command(cmd), _args(args), _curDir(cDir){}
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
//#include "SysMsg.h"
|
//#include "SysMsg.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL Process::run()
|
BOOL Process::run()
|
||||||
{
|
{
|
||||||
BOOL result = TRUE;
|
BOOL result = TRUE;
|
||||||
|
@ -47,7 +50,8 @@ BOOL Process::run()
|
||||||
|
|
||||||
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle
|
SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; // inheritable handle
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
// Create stdout pipe
|
// Create stdout pipe
|
||||||
if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0))
|
if (!::CreatePipe(&_hPipeOutR, &hPipeOutW, &sa, 0))
|
||||||
error(TEXT("CreatePipe"), result, 1000);
|
error(TEXT("CreatePipe"), result, 1000);
|
||||||
|
@ -101,7 +105,9 @@ BOOL Process::run()
|
||||||
|
|
||||||
::WaitForSingleObject(_hProcess, INFINITE);
|
::WaitForSingleObject(_hProcess, INFINITE);
|
||||||
::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE);
|
::WaitForMultipleObjects(2, hListenerEvent, TRUE, INFINITE);
|
||||||
} catch (int /*coderr*/){}
|
}
|
||||||
|
catch (int /*coderr*/)
|
||||||
|
{}
|
||||||
|
|
||||||
// on va fermer toutes les handles
|
// on va fermer toutes les handles
|
||||||
if (hPipeOutW)
|
if (hPipeOutW)
|
||||||
|
@ -250,9 +256,11 @@ void Process::listenerStdErr()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode)
|
void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode)
|
||||||
{
|
{
|
||||||
systemMessage(txt2display);
|
systemMessage(txt2display);
|
||||||
returnCode = FALSE;
|
returnCode = FALSE;
|
||||||
throw int(errCode);
|
throw int(errCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,36 +36,36 @@ using namespace std;
|
||||||
class Process
|
class Process
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Process() {};
|
Process() {}
|
||||||
Process(const TCHAR *cmd, const TCHAR *cDir)
|
Process(const TCHAR *cmd, const TCHAR *cDir)
|
||||||
: _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL),
|
: _stdoutStr(TEXT("")), _stderrStr(TEXT("")), _hPipeOutR(NULL),
|
||||||
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL) {
|
_hPipeErrR(NULL), _hProcess(NULL), _hProcessThread(NULL)
|
||||||
|
{
|
||||||
lstrcpy(_command, cmd);
|
lstrcpy(_command, cmd);
|
||||||
lstrcpy(_curDir, cDir);
|
lstrcpy(_curDir, cDir);
|
||||||
};
|
}
|
||||||
|
|
||||||
BOOL run();
|
BOOL run();
|
||||||
|
|
||||||
const TCHAR * getStdout() const {
|
const TCHAR * getStdout() const {
|
||||||
return _stdoutStr.c_str();
|
return _stdoutStr.c_str();
|
||||||
};
|
}
|
||||||
|
|
||||||
const TCHAR * getStderr() const {
|
const TCHAR * getStderr() const {
|
||||||
return _stderrStr.c_str();
|
return _stderrStr.c_str();
|
||||||
};
|
}
|
||||||
|
|
||||||
int getExitCode() const {
|
int getExitCode() const {
|
||||||
return _exitCode;
|
return _exitCode;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool hasStdout() {
|
bool hasStdout() {
|
||||||
return (_stdoutStr.compare(TEXT("")) != 0);
|
return (_stdoutStr.compare(TEXT("")) != 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool hasStderr() {
|
bool hasStderr() {
|
||||||
return (_stderrStr.compare(TEXT("")) != 0);
|
return (_stderrStr.compare(TEXT("")) != 0);
|
||||||
};
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// LES ENTREES
|
// LES ENTREES
|
||||||
|
|
|
@ -34,13 +34,16 @@
|
||||||
class ProcessThread
|
class ProcessThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd) : _hwnd(hwnd) {
|
ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd)
|
||||||
|
: _hwnd(hwnd)
|
||||||
|
{
|
||||||
lstrcpy(_appName, appName);
|
lstrcpy(_appName, appName);
|
||||||
lstrcpy(_command, cmd);
|
lstrcpy(_command, cmd);
|
||||||
lstrcpy(_curDir, cDir);
|
lstrcpy(_curDir, cDir);
|
||||||
};
|
}
|
||||||
|
|
||||||
BOOL run(){
|
BOOL run()
|
||||||
|
{
|
||||||
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent"));
|
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent"));
|
||||||
|
|
||||||
_hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL);
|
_hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL);
|
||||||
|
@ -49,7 +52,8 @@ public :
|
||||||
|
|
||||||
::CloseHandle(hEvent);
|
::CloseHandle(hEvent);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ENTREES
|
// ENTREES
|
||||||
|
@ -59,12 +63,14 @@ protected :
|
||||||
HWND _hwnd;
|
HWND _hwnd;
|
||||||
HANDLE _hProcessThread;
|
HANDLE _hProcessThread;
|
||||||
|
|
||||||
static DWORD WINAPI staticLauncher(void *myself) {
|
static DWORD WINAPI staticLauncher(void *myself)
|
||||||
|
{
|
||||||
((ProcessThread *)myself)->launch();
|
((ProcessThread *)myself)->launch();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
};
|
}
|
||||||
|
|
||||||
bool launch() {
|
bool launch()
|
||||||
|
{
|
||||||
HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent"));
|
HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent"));
|
||||||
HWND hwnd = _hwnd;
|
HWND hwnd = _hwnd;
|
||||||
TCHAR appName[256];
|
TCHAR appName[256];
|
||||||
|
@ -74,9 +80,7 @@ protected :
|
||||||
Process process(_command, _curDir);
|
Process process(_command, _curDir);
|
||||||
|
|
||||||
if (!::SetEvent(hEvent))
|
if (!::SetEvent(hEvent))
|
||||||
{
|
|
||||||
systemMessage(TEXT("Thread launcher"));
|
systemMessage(TEXT("Thread launcher"));
|
||||||
}
|
|
||||||
|
|
||||||
process.run();
|
process.run();
|
||||||
|
|
||||||
|
@ -90,7 +94,7 @@ protected :
|
||||||
|
|
||||||
::CloseHandle(hMyself);
|
::CloseHandle(hMyself);
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif PROCESS_THREAD_H
|
#endif PROCESS_THREAD_H
|
||||||
|
|
|
@ -24,11 +24,12 @@
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "regExtDlg.h"
|
#include "regExtDlg.h"
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const TCHAR* nppName = TEXT("Notepad++_file");
|
const TCHAR* nppName = TEXT("Notepad++_file");
|
||||||
const TCHAR* nppBackup = TEXT("Notepad++_backup");
|
const TCHAR* nppBackup = TEXT("Notepad++_backup");
|
||||||
const TCHAR* nppDoc = TEXT("Notepad++ Document");
|
const TCHAR* nppDoc = TEXT("Notepad++ Document");
|
||||||
|
@ -84,14 +85,15 @@ void RegExtDlg::doDialog(bool isRTL)
|
||||||
{
|
{
|
||||||
if (isRTL)
|
if (isRTL)
|
||||||
{
|
{
|
||||||
DLGTEMPLATE *pMyDlgTemplate = NULL;
|
DLGTEMPLATE *pMyDlgTemplate = nullptr;
|
||||||
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate);
|
HGLOBAL hMyDlgTemplate = makeRTLResource(IDD_REGEXT_BOX, &pMyDlgTemplate);
|
||||||
::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this);
|
::DialogBoxIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this);
|
||||||
::GlobalFree(hMyDlgTemplate);
|
::GlobalFree(hMyDlgTemplate);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, (LPARAM)this);
|
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_REGEXT_BOX), _hParent, dlgProc, (LPARAM)this);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -105,7 +107,6 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), false);
|
||||||
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETLIMITTEXT, extNameMax-1, 0);
|
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, EM_SETLIMITTEXT, extNameMax-1, 0);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +174,10 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
|
{
|
||||||
::EndDialog(_hSelf, 0);
|
::EndDialog(_hSelf, 0);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HIWORD(wParam) == EN_CHANGE)
|
if (HIWORD(wParam) == EN_CHANGE)
|
||||||
|
@ -224,6 +226,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
|
||||||
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0);
|
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0);
|
||||||
|
|
||||||
for (int j = 1 ; j < nbExtMax ; ++j)
|
for (int j = 1 ; j < nbExtMax ; ++j)
|
||||||
|
{
|
||||||
if (lstrcmp(TEXT(""), defExtArray[i][j]))
|
if (lstrcmp(TEXT(""), defExtArray[i][j]))
|
||||||
{
|
{
|
||||||
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
|
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
|
||||||
|
@ -231,31 +234,33 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
|
||||||
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
|
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST)
|
else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST)
|
||||||
{
|
{
|
||||||
if (i != LB_ERR)
|
if (i != LB_ERR)
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST)
|
else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST)
|
||||||
{
|
{
|
||||||
if (i != LB_ERR)
|
if (i != LB_ERR)
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true);
|
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// break; // no break here
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
//return FALSE;
|
//return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RegExtDlg::getRegisteredExts()
|
void RegExtDlg::getRegisteredExts()
|
||||||
{
|
{
|
||||||
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
|
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
|
||||||
|
@ -264,7 +269,7 @@ void RegExtDlg::getRegisteredExts()
|
||||||
TCHAR extName[extNameLen];
|
TCHAR extName[extNameLen];
|
||||||
//FILETIME fileTime;
|
//FILETIME fileTime;
|
||||||
int extNameActualLen = extNameLen;
|
int extNameActualLen = extNameLen;
|
||||||
int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, NULL, NULL, NULL, NULL);
|
int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, nullptr, nullptr, nullptr, nullptr);
|
||||||
if ((res == ERROR_SUCCESS) && (extName[0] == '.'))
|
if ((res == ERROR_SUCCESS) && (extName[0] == '.'))
|
||||||
{
|
{
|
||||||
//TCHAR valName[extNameLen];
|
//TCHAR valName[extNameLen];
|
||||||
|
@ -274,8 +279,8 @@ void RegExtDlg::getRegisteredExts()
|
||||||
HKEY hKey2Check;
|
HKEY hKey2Check;
|
||||||
extNameActualLen = extNameLen;
|
extNameActualLen = extNameLen;
|
||||||
::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check);
|
::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check);
|
||||||
::RegQueryValueEx(hKey2Check, TEXT(""), NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
::RegQueryValueEx(hKey2Check, TEXT(""), nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
||||||
//::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
//::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
||||||
if ((valType == REG_SZ) && (!lstrcmp(valData, nppName)))
|
if ((valType == REG_SZ) && (!lstrcmp(valData, nppName)))
|
||||||
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName);
|
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName);
|
||||||
::RegCloseKey(hKey2Check);
|
::RegCloseKey(hKey2Check);
|
||||||
|
@ -283,6 +288,7 @@ void RegExtDlg::getRegisteredExts()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RegExtDlg::getDefSupportedExts()
|
void RegExtDlg::getDefSupportedExts()
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < nbSupportedLang ; ++i)
|
for (int i = 0 ; i < nbSupportedLang ; ++i)
|
||||||
|
@ -296,15 +302,7 @@ void RegExtDlg::addExt(TCHAR *ext)
|
||||||
DWORD dwDisp;
|
DWORD dwDisp;
|
||||||
long nRet;
|
long nRet;
|
||||||
|
|
||||||
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT,
|
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ext, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
|
||||||
ext,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
NULL,
|
|
||||||
&hKey,
|
|
||||||
&dwDisp);
|
|
||||||
|
|
||||||
if (nRet == ERROR_SUCCESS)
|
if (nRet == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -313,16 +311,17 @@ void RegExtDlg::addExt(TCHAR *ext)
|
||||||
|
|
||||||
if (dwDisp == REG_OPENED_EXISTING_KEY)
|
if (dwDisp == REG_OPENED_EXISTING_KEY)
|
||||||
{
|
{
|
||||||
int res = ::RegQueryValueEx(hKey, TEXT(""), NULL, NULL, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
int res = ::RegQueryValueEx(hKey, TEXT(""), nullptr, nullptr, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen);
|
::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen);
|
||||||
}
|
}
|
||||||
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR));
|
::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR));
|
||||||
|
|
||||||
::RegCloseKey(hKey);
|
::RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
|
bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
|
@ -342,20 +341,21 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
|
||||||
TCHAR valData[extNameLen];
|
TCHAR valData[extNameLen];
|
||||||
int valDataLen = extNameLen*sizeof(TCHAR);
|
int valDataLen = extNameLen*sizeof(TCHAR);
|
||||||
int valType;
|
int valType;
|
||||||
int res = ::RegQueryValueEx(hKey, nppBackup, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
int res = ::RegQueryValueEx(hKey, nppBackup, nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
|
||||||
|
|
||||||
if (res == ERROR_SUCCESS)
|
if (res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
::RegSetValueEx(hKey, NULL, 0, valType, (LPBYTE)valData, valDataLen);
|
::RegSetValueEx(hKey, nullptr, 0, valType, (LPBYTE)valData, valDataLen);
|
||||||
::RegDeleteValue(hKey, nppBackup);
|
::RegDeleteValue(hKey, nppBackup);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::RegDeleteValue(hKey, NULL);
|
::RegDeleteValue(hKey, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RegExtDlg::writeNppPath()
|
void RegExtDlg::writeNppPath()
|
||||||
{
|
{
|
||||||
HKEY hKey, hRootKey;
|
HKEY hKey, hRootKey;
|
||||||
|
@ -364,16 +364,7 @@ void RegExtDlg::writeNppPath()
|
||||||
generic_string regStr(nppName);
|
generic_string regStr(nppName);
|
||||||
regStr += TEXT("\\shell\\open\\command");
|
regStr += TEXT("\\shell\\open\\command");
|
||||||
|
|
||||||
nRet = ::RegCreateKeyEx(
|
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
|
||||||
HKEY_CLASSES_ROOT,
|
|
||||||
regStr.c_str(),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
NULL,
|
|
||||||
&hKey,
|
|
||||||
&dwDisp);
|
|
||||||
|
|
||||||
|
|
||||||
if (nRet == ERROR_SUCCESS)
|
if (nRet == ERROR_SUCCESS)
|
||||||
|
@ -382,7 +373,7 @@ void RegExtDlg::writeNppPath()
|
||||||
{
|
{
|
||||||
// Write the value for new document
|
// Write the value for new document
|
||||||
::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey);
|
::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey);
|
||||||
::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
|
::RegSetValueEx(hRootKey, nullptr, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
|
||||||
RegCloseKey(hRootKey);
|
RegCloseKey(hRootKey);
|
||||||
|
|
||||||
TCHAR nppPath[MAX_PATH];
|
TCHAR nppPath[MAX_PATH];
|
||||||
|
@ -391,7 +382,7 @@ void RegExtDlg::writeNppPath()
|
||||||
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
||||||
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
|
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
|
||||||
|
|
||||||
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
@ -399,16 +390,7 @@ void RegExtDlg::writeNppPath()
|
||||||
//Set default icon value
|
//Set default icon value
|
||||||
regStr = nppName;
|
regStr = nppName;
|
||||||
regStr += TEXT("\\DefaultIcon");
|
regStr += TEXT("\\DefaultIcon");
|
||||||
nRet = ::RegCreateKeyEx(
|
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
|
||||||
HKEY_CLASSES_ROOT,
|
|
||||||
regStr.c_str(),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
KEY_ALL_ACCESS,
|
|
||||||
NULL,
|
|
||||||
&hKey,
|
|
||||||
&dwDisp);
|
|
||||||
|
|
||||||
if (nRet == ERROR_SUCCESS)
|
if (nRet == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -420,8 +402,10 @@ void RegExtDlg::writeNppPath()
|
||||||
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
||||||
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
|
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
|
||||||
|
|
||||||
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -57,13 +57,13 @@ private :
|
||||||
int nbSubKey;
|
int nbSubKey;
|
||||||
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
return (result == ERROR_SUCCESS)?nbSubKey:0;
|
return (result == ERROR_SUCCESS)?nbSubKey:0;
|
||||||
};
|
}
|
||||||
|
|
||||||
int getNbSubValue(HKEY hKey) const {
|
int getNbSubValue(HKEY hKey) const {
|
||||||
int nbSubValue;
|
int nbSubValue;
|
||||||
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
|
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
|
||||||
return (result == ERROR_SUCCESS)?nbSubValue:0;
|
return (result == ERROR_SUCCESS)?nbSubValue:0;
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //REG_EXT_DLG_H
|
#endif //REG_EXT_DLG_H
|
||||||
|
|
|
@ -119,10 +119,13 @@ ToolBarButtonUnit toolBarIcons[] = {
|
||||||
{IDM_MACRO_PLAYBACKRECORDEDMACRO, IDI_PLAYRECORD_OFF_ICON, IDI_PLAYRECORD_ON_ICON, IDI_PLAYRECORD_DISABLE_ICON, IDR_PLAYRECORD},
|
{IDM_MACRO_PLAYBACKRECORDEDMACRO, IDI_PLAYRECORD_OFF_ICON, IDI_PLAYRECORD_ON_ICON, IDI_PLAYRECORD_DISABLE_ICON, IDR_PLAYRECORD},
|
||||||
{IDM_MACRO_RUNMULTIMACRODLG, IDI_MMPLAY_OFF_ICON, IDI_MMPLAY_ON_ICON, IDI_MMPLAY_DIS_ICON, IDR_M_PLAYRECORD},
|
{IDM_MACRO_RUNMULTIMACRODLG, IDI_MMPLAY_OFF_ICON, IDI_MMPLAY_ON_ICON, IDI_MMPLAY_DIS_ICON, IDR_M_PLAYRECORD},
|
||||||
{IDM_MACRO_SAVECURRENTMACRO, IDI_SAVERECORD_OFF_ICON, IDI_SAVERECORD_ON_ICON, IDI_SAVERECORD_DISABLE_ICON, IDR_SAVERECORD}
|
{IDM_MACRO_SAVECURRENTMACRO, IDI_SAVERECORD_OFF_ICON, IDI_SAVERECORD_ON_ICON, IDI_SAVERECORD_DISABLE_ICON, IDR_SAVERECORD}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
|
Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(NULL),
|
||||||
_pMainSplitter(NULL),
|
_pMainSplitter(NULL),
|
||||||
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _pFileSwitcherPanel(NULL),
|
_recordingMacro(false), _pTrayIco(NULL), _isUDDocked(false), _pFileSwitcherPanel(NULL),
|
||||||
|
@ -175,48 +178,28 @@ Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(N
|
||||||
_isAdministrator = is_admin ? true : false;
|
_isAdministrator = is_admin ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Notepad_plus::~Notepad_plus()
|
||||||
|
{
|
||||||
// ATTENTION : the order of the destruction is very important
|
// ATTENTION : the order of the destruction is very important
|
||||||
// because if the parent's window handle is destroyed before
|
// because if the parent's window handle is destroyed before
|
||||||
// the destruction of its children windows' handles,
|
// the destruction of its children windows' handles,
|
||||||
// its children windows' handles will be destroyed automatically!
|
// its children windows' handles will be destroyed automatically!
|
||||||
Notepad_plus::~Notepad_plus()
|
|
||||||
{
|
|
||||||
(NppParameters::getInstance())->destroyInstance();
|
(NppParameters::getInstance())->destroyInstance();
|
||||||
MainFileManager->destroyInstance();
|
MainFileManager->destroyInstance();
|
||||||
(WcharMbcsConvertor::getInstance())->destroyInstance();
|
(WcharMbcsConvertor::getInstance())->destroyInstance();
|
||||||
if (_pTrayIco)
|
|
||||||
delete _pTrayIco;
|
delete _pTrayIco;
|
||||||
|
|
||||||
if (_pAnsiCharPanel)
|
|
||||||
delete _pAnsiCharPanel;
|
delete _pAnsiCharPanel;
|
||||||
|
|
||||||
if (_pClipboardHistoryPanel)
|
|
||||||
delete _pClipboardHistoryPanel;
|
delete _pClipboardHistoryPanel;
|
||||||
|
|
||||||
if (_pFileSwitcherPanel)
|
|
||||||
delete _pFileSwitcherPanel;
|
delete _pFileSwitcherPanel;
|
||||||
|
|
||||||
if (_pProjectPanel_1)
|
|
||||||
{
|
|
||||||
delete _pProjectPanel_1;
|
delete _pProjectPanel_1;
|
||||||
}
|
|
||||||
if (_pProjectPanel_2)
|
|
||||||
{
|
|
||||||
delete _pProjectPanel_2;
|
delete _pProjectPanel_2;
|
||||||
}
|
|
||||||
if (_pProjectPanel_3)
|
|
||||||
{
|
|
||||||
delete _pProjectPanel_3;
|
delete _pProjectPanel_3;
|
||||||
}
|
|
||||||
if (_pDocMap)
|
|
||||||
{
|
|
||||||
delete _pDocMap;
|
delete _pDocMap;
|
||||||
}
|
|
||||||
if (_pFuncList)
|
|
||||||
{
|
|
||||||
delete _pFuncList;
|
delete _pFuncList;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -451,6 +434,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||||
::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, (unsigned int)-1, 0);
|
::InsertMenu(hMacroMenu, posBase + nbMacro + 1, MF_BYPOSITION, (unsigned int)-1, 0);
|
||||||
::InsertMenu(hMacroMenu, posBase + nbMacro + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro..."));
|
::InsertMenu(hMacroMenu, posBase + nbMacro + 2, MF_BYCOMMAND, IDM_SETTING_SHORTCUT_MAPPER_MACRO, TEXT("Modify Shortcut/Delete Macro..."));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run Menu
|
// Run Menu
|
||||||
std::vector<UserCommand> & userCommands = pNppParam->getUserCommandList();
|
std::vector<UserCommand> & userCommands = pNppParam->getUserCommandList();
|
||||||
HMENU hRunMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_RUN);
|
HMENU hRunMenu = ::GetSubMenu(_mainMenuHandle, MENUINDEX_RUN);
|
||||||
|
@ -458,6 +442,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||||
size_t nbUserCommand = userCommands.size();
|
size_t nbUserCommand = userCommands.size();
|
||||||
if (nbUserCommand >= 1)
|
if (nbUserCommand >= 1)
|
||||||
::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, (unsigned int)-1, 0);
|
::InsertMenu(hRunMenu, runPosBase - 1, MF_BYPOSITION, (unsigned int)-1, 0);
|
||||||
|
|
||||||
for (size_t i = 0 ; i < nbUserCommand ; ++i)
|
for (size_t i = 0 ; i < nbUserCommand ; ++i)
|
||||||
{
|
{
|
||||||
::InsertMenu(hRunMenu, runPosBase + i, MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str());
|
::InsertMenu(hRunMenu, runPosBase + i, MF_BYPOSITION, ID_USER_CMD + i, userCommands[i].toMenuItemString().c_str());
|
||||||
|
@ -5226,6 +5211,7 @@ bool Notepad_plus::reloadLang()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchClipboardHistoryPanel()
|
void Notepad_plus::launchClipboardHistoryPanel()
|
||||||
{
|
{
|
||||||
if (!_pClipboardHistoryPanel)
|
if (!_pClipboardHistoryPanel)
|
||||||
|
@ -5267,6 +5253,7 @@ void Notepad_plus::launchClipboardHistoryPanel()
|
||||||
_pClipboardHistoryPanel->display();
|
_pClipboardHistoryPanel->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchFileSwitcherPanel()
|
void Notepad_plus::launchFileSwitcherPanel()
|
||||||
{
|
{
|
||||||
if (!_pFileSwitcherPanel)
|
if (!_pFileSwitcherPanel)
|
||||||
|
@ -5308,12 +5295,12 @@ void Notepad_plus::launchFileSwitcherPanel()
|
||||||
_pFileSwitcherPanel->display();
|
_pFileSwitcherPanel->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchAnsiCharPanel()
|
void Notepad_plus::launchAnsiCharPanel()
|
||||||
{
|
{
|
||||||
if (!_pAnsiCharPanel)
|
if (!_pAnsiCharPanel)
|
||||||
{
|
{
|
||||||
_pAnsiCharPanel = new AnsiCharPanel();
|
_pAnsiCharPanel = new AnsiCharPanel();
|
||||||
|
|
||||||
_pAnsiCharPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), &_pEditView);
|
_pAnsiCharPanel->init(_pPublicInterface->getHinst(), _pPublicInterface->getHSelf(), &_pEditView);
|
||||||
|
|
||||||
tTbData data = {0};
|
tTbData data = {0};
|
||||||
|
@ -5350,6 +5337,7 @@ void Notepad_plus::launchAnsiCharPanel()
|
||||||
_pAnsiCharPanel->display();
|
_pAnsiCharPanel->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID)
|
void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID)
|
||||||
{
|
{
|
||||||
if (!(*pProjPanel))
|
if (!(*pProjPanel))
|
||||||
|
@ -5396,6 +5384,7 @@ void Notepad_plus::launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int
|
||||||
(*pProjPanel)->display();
|
(*pProjPanel)->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchDocMap()
|
void Notepad_plus::launchDocMap()
|
||||||
{
|
{
|
||||||
if (!(NppParameters::getInstance())->isTransparentAvailable())
|
if (!(NppParameters::getInstance())->isTransparentAvailable())
|
||||||
|
@ -5441,6 +5430,7 @@ void Notepad_plus::launchDocMap()
|
||||||
_pEditView->getFocus();
|
_pEditView->getFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchFunctionList()
|
void Notepad_plus::launchFunctionList()
|
||||||
{
|
{
|
||||||
if (!_pFuncList)
|
if (!_pFuncList)
|
||||||
|
@ -5486,7 +5476,13 @@ void Notepad_plus::launchFunctionList()
|
||||||
_pEditView->getFocus();
|
_pEditView->getFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TextPlayerParams {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct TextPlayerParams
|
||||||
|
{
|
||||||
HWND _nppHandle;
|
HWND _nppHandle;
|
||||||
ScintillaEditView *_pCurrentView;
|
ScintillaEditView *_pCurrentView;
|
||||||
const char *_text2display;
|
const char *_text2display;
|
||||||
|
@ -5494,20 +5490,26 @@ struct TextPlayerParams {
|
||||||
bool _shouldBeTrolling;
|
bool _shouldBeTrolling;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TextTrollerParams {
|
struct TextTrollerParams
|
||||||
|
{
|
||||||
ScintillaEditView *_pCurrentView;
|
ScintillaEditView *_pCurrentView;
|
||||||
const char *_text2display;
|
const char *_text2display;
|
||||||
BufferID _targetBufID;
|
BufferID _targetBufID;
|
||||||
HANDLE _mutex;
|
HANDLE _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Quote{
|
struct Quote
|
||||||
|
{
|
||||||
const char *_quoter;
|
const char *_quoter;
|
||||||
const char *_quote;
|
const char *_quote;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const int nbQuote = 203;
|
const int nbQuote = 203;
|
||||||
Quote quotes[nbQuote] = {
|
Quote quotes[nbQuote] =
|
||||||
|
{
|
||||||
{"Notepad++", "Good programmers use Notepad++ to code.\nExtreme programmers use MS Word to code, in Comic Sans, center aligned."},
|
{"Notepad++", "Good programmers use Notepad++ to code.\nExtreme programmers use MS Word to code, in Comic Sans, center aligned."},
|
||||||
{"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."},
|
{"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."},
|
||||||
{"L. Peter Deutsch", "To iterate is human, to recurse divine."},
|
{"L. Peter Deutsch", "To iterate is human, to recurse divine."},
|
||||||
|
@ -5720,7 +5722,8 @@ Quote quotes[nbQuote] = {
|
||||||
|
|
||||||
|
|
||||||
const int nbWtf = 6;
|
const int nbWtf = 6;
|
||||||
char *wtf[nbWtf] = {
|
char* wtf[nbWtf] =
|
||||||
|
{
|
||||||
"WTF?!",
|
"WTF?!",
|
||||||
"lol",
|
"lol",
|
||||||
"FAP FAP FAP",
|
"FAP FAP FAP",
|
||||||
|
@ -5740,11 +5743,13 @@ const int nbAct = 30;
|
||||||
int actionArray[nbAct] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0};
|
int actionArray[nbAct] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0};
|
||||||
const int maxRange = 200;
|
const int maxRange = 200;
|
||||||
|
|
||||||
|
|
||||||
int Notepad_plus::getRandomAction(int ranNum)
|
int Notepad_plus::getRandomAction(int ranNum)
|
||||||
{
|
{
|
||||||
return actionArray[ranNum % nbAct];
|
return actionArray[ranNum % nbAct];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool isInList(int elem, vector<int> elemList)
|
bool isInList(int elem, vector<int> elemList)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, len = elemList.size(); i < len; ++i)
|
for (size_t i = 0, len = elemList.size(); i < len; ++i)
|
||||||
|
@ -5755,6 +5760,7 @@ bool isInList(int elem, vector<int> elemList)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
|
DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
|
||||||
{
|
{
|
||||||
// random seed generation needs only one time.
|
// random seed generation needs only one time.
|
||||||
|
@ -5781,10 +5787,10 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
|
||||||
int nbTrolling = 0;
|
int nbTrolling = 0;
|
||||||
vector<int> generatedRans;
|
vector<int> generatedRans;
|
||||||
char previousChar = '\0';
|
char previousChar = '\0';
|
||||||
|
|
||||||
for (size_t i = 0, len = strlen(text2display); i < len ; ++i)
|
for (size_t i = 0, len = strlen(text2display); i < len ; ++i)
|
||||||
{
|
{
|
||||||
int ranNum = getRandomNumber(maxRange);
|
int ranNum = getRandomNumber(maxRange);
|
||||||
|
|
||||||
int action = act_doNothing;
|
int action = act_doNothing;
|
||||||
|
|
||||||
if (shouldBeTrolling && (i > 20 && previousChar == ' ') && nbTrolling < nbMaxTrolling)
|
if (shouldBeTrolling && (i > 20 && previousChar == ' ') && nbTrolling < nbMaxTrolling)
|
||||||
|
@ -5836,6 +5842,7 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
|
||||||
//sprintf(ch, "writting char == %c", text2display[i]);
|
//sprintf(ch, "writting char == %c", text2display[i]);
|
||||||
//writeLog(TEXT("c:\\tmp\\log.txt"), ch);
|
//writeLog(TEXT("c:\\tmp\\log.txt"), ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
//writeLog(TEXT("c:\\tmp\\log.txt"), "\n\n\n\n");
|
//writeLog(TEXT("c:\\tmp\\log.txt"), "\n\n\n\n");
|
||||||
const char * quoter = ((TextPlayerParams *)params)->_quoter;
|
const char * quoter = ((TextPlayerParams *)params)->_quoter;
|
||||||
string quoter_str = quoter;
|
string quoter_str = quoter;
|
||||||
|
@ -5867,6 +5874,7 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
|
DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
|
||||||
{
|
{
|
||||||
WaitForSingleObject(((TextTrollerParams *)params)->_mutex, INFINITE);
|
WaitForSingleObject(((TextTrollerParams *)params)->_mutex, INFINITE);
|
||||||
|
@ -5947,6 +5955,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Notepad_plus::deleteBack(ScintillaEditView *pCurrentView, BufferID targetBufID)
|
bool Notepad_plus::deleteBack(ScintillaEditView *pCurrentView, BufferID targetBufID)
|
||||||
{
|
{
|
||||||
int ranNum = getRandomNumber(maxRange - 100);
|
int ranNum = getRandomNumber(maxRange - 100);
|
||||||
|
@ -5958,6 +5967,7 @@ bool Notepad_plus::deleteBack(ScintillaEditView *pCurrentView, BufferID targetBu
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Notepad_plus::deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID)
|
bool Notepad_plus::deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID)
|
||||||
{
|
{
|
||||||
int ranNum = getRandomNumber(maxRange - 100);
|
int ranNum = getRandomNumber(maxRange - 100);
|
||||||
|
@ -5970,6 +5980,7 @@ bool Notepad_plus::deleteForward(ScintillaEditView *pCurrentView, BufferID targe
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Notepad_plus::selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID)
|
bool Notepad_plus::selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID)
|
||||||
{
|
{
|
||||||
int ranNum = getRandomNumber(maxRange - 100);
|
int ranNum = getRandomNumber(maxRange - 100);
|
||||||
|
@ -5984,14 +5995,14 @@ bool Notepad_plus::selectBack(ScintillaEditView *pCurrentView, BufferID targetBu
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Notepad_plus::getQuoteIndexFrom(const char *quoter) const
|
int Notepad_plus::getQuoteIndexFrom(const char *quoter) const
|
||||||
{
|
{
|
||||||
if (!quoter)
|
if (!quoter)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (stricmp(quoter, "Get them all!!!") == 0)
|
if (stricmp(quoter, "Get them all!!!") == 0)
|
||||||
{
|
|
||||||
return -2;
|
return -2;
|
||||||
}
|
|
||||||
|
|
||||||
if (stricmp(quoter, "random") == 0)
|
if (stricmp(quoter, "random") == 0)
|
||||||
{
|
{
|
||||||
|
@ -6007,11 +6018,12 @@ int Notepad_plus::getQuoteIndexFrom(const char *quoter) const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::showAllQuotes() const
|
void Notepad_plus::showAllQuotes() const
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void Notepad_plus::showQuoteFromIndex(int index) const
|
void Notepad_plus::showQuoteFromIndex(int index) const
|
||||||
{
|
{
|
||||||
|
@ -6036,8 +6048,8 @@ void Notepad_plus::showQuoteFromIndex(int index) const
|
||||||
showQuote(quotes[index]._quote, quotes[index]._quoter, index < 20);
|
showQuote(quotes[index]._quote, quotes[index]._quoter, index < 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad_plus::showQuote(const char *quote, const char *quoter, bool doTrolling) const
|
|
||||||
|
|
||||||
|
void Notepad_plus::showQuote(const char *quote, const char *quoter, bool doTrolling) const
|
||||||
{
|
{
|
||||||
static TextPlayerParams params;
|
static TextPlayerParams params;
|
||||||
params._nppHandle = Notepad_plus::_pPublicInterface->getHSelf();
|
params._nppHandle = Notepad_plus::_pPublicInterface->getHSelf();
|
||||||
|
@ -6049,6 +6061,7 @@ void Notepad_plus::showQuote(const char *quote, const char *quoter, bool doTroll
|
||||||
::CloseHandle(hThread);
|
::CloseHandle(hThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Notepad_plus::launchDocumentBackupTask()
|
void Notepad_plus::launchDocumentBackupTask()
|
||||||
{
|
{
|
||||||
HANDLE hThread = ::CreateThread(NULL, 0, backupDocument, NULL, 0, NULL);
|
HANDLE hThread = ::CreateThread(NULL, 0, backupDocument, NULL, 0, NULL);
|
||||||
|
@ -6056,6 +6069,7 @@ void Notepad_plus::launchDocumentBackupTask()
|
||||||
::CloseHandle(hThread);
|
::CloseHandle(hThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI Notepad_plus::backupDocument(void * /*param*/)
|
DWORD WINAPI Notepad_plus::backupDocument(void * /*param*/)
|
||||||
{
|
{
|
||||||
bool isSnapshotMode = true;
|
bool isSnapshotMode = true;
|
||||||
|
@ -6084,6 +6098,8 @@ DWORD WINAPI Notepad_plus::backupDocument(void * /*param*/)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#pragma warning( disable : 4127 )
|
#pragma warning( disable : 4127 )
|
||||||
//--FLS: undoStreamComment: New function to undo stream comment around or within selection end-points.
|
//--FLS: undoStreamComment: New function to undo stream comment around or within selection end-points.
|
||||||
bool Notepad_plus::undoStreamComment()
|
bool Notepad_plus::undoStreamComment()
|
||||||
|
@ -6130,8 +6146,9 @@ bool Notepad_plus::undoStreamComment()
|
||||||
int start_comment_length = start_comment.length();
|
int start_comment_length = start_comment.length();
|
||||||
int end_comment_length = end_comment.length();
|
int end_comment_length = end_comment.length();
|
||||||
|
|
||||||
do { // do as long as stream-comments are within selection
|
// do as long as stream-comments are within selection
|
||||||
|
do
|
||||||
|
{
|
||||||
int selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART);
|
int selectionStart = _pEditView->execute(SCI_GETSELECTIONSTART);
|
||||||
int selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND);
|
int selectionEnd = _pEditView->execute(SCI_GETSELECTIONEND);
|
||||||
int caretPosition = _pEditView->execute(SCI_GETCURRENTPOS);
|
int caretPosition = _pEditView->execute(SCI_GETCURRENTPOS);
|
||||||
|
@ -6172,16 +6189,18 @@ bool Notepad_plus::undoStreamComment()
|
||||||
//-- Check, if selectionStart or selectionEnd is within a stream comment -----
|
//-- Check, if selectionStart or selectionEnd is within a stream comment -----
|
||||||
// or if the selection includes a complete stream-comment!! ----------------
|
// or if the selection includes a complete stream-comment!! ----------------
|
||||||
bool blnCommentFound = false;
|
bool blnCommentFound = false;
|
||||||
|
|
||||||
//-- First, check if there is a stream-comment around the selectionStart position:
|
//-- First, check if there is a stream-comment around the selectionStart position:
|
||||||
if ((blnStartCommentBefore[iSelStart] && blnEndCommentAfter[iSelStart])
|
if ((blnStartCommentBefore[iSelStart] && blnEndCommentAfter[iSelStart])
|
||||||
&& (!blnEndCommentBefore[iSelStart] || (posStartCommentBefore[iSelStart] >= posEndCommentBefore[iSelStart]))
|
&& (!blnEndCommentBefore[iSelStart] || (posStartCommentBefore[iSelStart] >= posEndCommentBefore[iSelStart]))
|
||||||
&& (!blnStartCommentAfter[iSelStart] || (posEndCommentAfter[iSelStart] <= posStartCommentAfter[iSelStart]))) {
|
&& (!blnStartCommentAfter[iSelStart] || (posEndCommentAfter[iSelStart] <= posStartCommentAfter[iSelStart])))
|
||||||
|
{
|
||||||
blnCommentFound = true;
|
blnCommentFound = true;
|
||||||
posStartComment = posStartCommentBefore[iSelStart];
|
posStartComment = posStartCommentBefore[iSelStart];
|
||||||
posEndComment = posEndCommentAfter[iSelStart];
|
posEndComment = posEndCommentAfter[iSelStart];
|
||||||
}
|
}
|
||||||
//-- Second, check if there is a stream-comment around the selectionEnd position:
|
else //-- Second, check if there is a stream-comment around the selectionEnd position:
|
||||||
else {
|
{
|
||||||
//-- Find all start- and end-comments before and after the selectionEnd position.
|
//-- Find all start- and end-comments before and after the selectionEnd position.
|
||||||
//-- Direction DIR_UP ---
|
//-- Direction DIR_UP ---
|
||||||
posStartCommentBefore[iSelEnd] = _pEditView->searchInTarget(start_comment.c_str(), start_comment_length, selectionEnd, 0);
|
posStartCommentBefore[iSelEnd] = _pEditView->searchInTarget(start_comment.c_str(), start_comment_length, selectionEnd, 0);
|
||||||
|
@ -6193,35 +6212,40 @@ bool Notepad_plus::undoStreamComment()
|
||||||
(posStartCommentAfter[iSelEnd] == -1 ? blnStartCommentAfter[iSelEnd] = false : blnStartCommentAfter[iSelEnd] = true);
|
(posStartCommentAfter[iSelEnd] == -1 ? blnStartCommentAfter[iSelEnd] = false : blnStartCommentAfter[iSelEnd] = true);
|
||||||
posEndCommentAfter[iSelEnd] = _pEditView->searchInTarget(end_comment.c_str(), end_comment_length, selectionEnd, docLength);
|
posEndCommentAfter[iSelEnd] = _pEditView->searchInTarget(end_comment.c_str(), end_comment_length, selectionEnd, docLength);
|
||||||
(posEndCommentAfter[iSelEnd] == -1 ? blnEndCommentAfter[iSelEnd] = false : blnEndCommentAfter[iSelEnd] = true);
|
(posEndCommentAfter[iSelEnd] == -1 ? blnEndCommentAfter[iSelEnd] = false : blnEndCommentAfter[iSelEnd] = true);
|
||||||
|
|
||||||
if ((blnStartCommentBefore[iSelEnd] && blnEndCommentAfter[iSelEnd])
|
if ((blnStartCommentBefore[iSelEnd] && blnEndCommentAfter[iSelEnd])
|
||||||
&& (!blnEndCommentBefore[iSelEnd] || (posStartCommentBefore[iSelEnd] >= posEndCommentBefore[iSelEnd]))
|
&& (!blnEndCommentBefore[iSelEnd] || (posStartCommentBefore[iSelEnd] >= posEndCommentBefore[iSelEnd]))
|
||||||
&& (!blnStartCommentAfter[iSelEnd] || (posEndCommentAfter[iSelEnd] <= posStartCommentAfter[iSelEnd]))) {
|
&& (!blnStartCommentAfter[iSelEnd] || (posEndCommentAfter[iSelEnd] <= posStartCommentAfter[iSelEnd])))
|
||||||
|
{
|
||||||
blnCommentFound = true;
|
blnCommentFound = true;
|
||||||
posStartComment = posStartCommentBefore[iSelEnd];
|
posStartComment = posStartCommentBefore[iSelEnd];
|
||||||
posEndComment = posEndCommentAfter[iSelEnd];
|
posEndComment = posEndCommentAfter[iSelEnd];
|
||||||
}
|
}
|
||||||
//-- Third, check if there is a stream-comment within the selected area:
|
//-- Third, check if there is a stream-comment within the selected area:
|
||||||
else if ( (blnStartCommentAfter[iSelStart] && (posStartCommentAfter[iSelStart] < selectionEnd))
|
else if ( (blnStartCommentAfter[iSelStart] && (posStartCommentAfter[iSelStart] < selectionEnd))
|
||||||
&& (blnEndCommentBefore[iSelEnd] && (posEndCommentBefore[iSelEnd] > selectionStart))) {
|
&& (blnEndCommentBefore[iSelEnd] && (posEndCommentBefore[iSelEnd] > selectionStart)))
|
||||||
|
{
|
||||||
//-- If there are more than one stream-comment within the selection, take the first one after selectionStart!!
|
//-- If there are more than one stream-comment within the selection, take the first one after selectionStart!!
|
||||||
blnCommentFound = true;
|
blnCommentFound = true;
|
||||||
posStartComment = posStartCommentAfter[iSelStart];
|
posStartComment = posStartCommentAfter[iSelStart];
|
||||||
posEndComment = posEndCommentAfter[iSelStart];
|
posEndComment = posEndCommentAfter[iSelStart];
|
||||||
}
|
}
|
||||||
//-- Finally, if there is no stream-comment, return
|
//-- Finally, if there is no stream-comment, return
|
||||||
else {
|
else
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//-- Ok, there are valid start-comment and valid end-comment around the caret-position.
|
//-- Ok, there are valid start-comment and valid end-comment around the caret-position.
|
||||||
// Now, un-comment stream-comment:
|
// Now, un-comment stream-comment:
|
||||||
retVal = true;
|
retVal = true;
|
||||||
int startCommentLength = start_comment_length;
|
int startCommentLength = start_comment_length;
|
||||||
int endCommentLength = end_comment_length;
|
int endCommentLength = end_comment_length;
|
||||||
|
|
||||||
//-- First delete end-comment, so that posStartCommentBefore does not change!
|
//-- First delete end-comment, so that posStartCommentBefore does not change!
|
||||||
//-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too!
|
//-- Get character before end-comment to decide, if there is a white character before the end-comment, which will be removed too!
|
||||||
_pEditView->getGenericText(charbuf, charbufLen, posEndComment-1, posEndComment);
|
_pEditView->getGenericText(charbuf, charbufLen, posEndComment-1, posEndComment);
|
||||||
if (generic_strncmp(charbuf, white_space.c_str(), white_space.length()) == 0) {
|
if (generic_strncmp(charbuf, white_space.c_str(), white_space.length()) == 0)
|
||||||
|
{
|
||||||
endCommentLength +=1;
|
endCommentLength +=1;
|
||||||
posEndComment-=1;
|
posEndComment-=1;
|
||||||
}
|
}
|
||||||
|
@ -6232,9 +6256,9 @@ bool Notepad_plus::undoStreamComment()
|
||||||
|
|
||||||
//-- Get character after start-comment to decide, if there is a white character after the start-comment, which will be removed too!
|
//-- Get character after start-comment to decide, if there is a white character after the start-comment, which will be removed too!
|
||||||
_pEditView->getGenericText(charbuf, charbufLen, posStartComment+startCommentLength, posStartComment+startCommentLength+1);
|
_pEditView->getGenericText(charbuf, charbufLen, posStartComment+startCommentLength, posStartComment+startCommentLength+1);
|
||||||
if (generic_strncmp(charbuf, white_space.c_str(), white_space.length()) == 0) {
|
if (generic_strncmp(charbuf, white_space.c_str(), white_space.length()) == 0)
|
||||||
startCommentLength +=1;
|
startCommentLength +=1;
|
||||||
}
|
|
||||||
//-- Delete starting stream-comment string ---------
|
//-- Delete starting stream-comment string ---------
|
||||||
_pEditView->execute(SCI_SETSEL, posStartComment, posStartComment + startCommentLength);
|
_pEditView->execute(SCI_SETSEL, posStartComment, posStartComment + startCommentLength);
|
||||||
_pEditView->execute(SCI_REPLACESEL, 0, (WPARAM)"");
|
_pEditView->execute(SCI_REPLACESEL, 0, (WPARAM)"");
|
||||||
|
@ -6243,7 +6267,8 @@ bool Notepad_plus::undoStreamComment()
|
||||||
//-- Reset selection before calling the routine
|
//-- Reset selection before calling the routine
|
||||||
//-- Determine selection movement
|
//-- Determine selection movement
|
||||||
// selectionStart
|
// selectionStart
|
||||||
if (selectionStart > posStartComment) {
|
if (selectionStart > posStartComment)
|
||||||
|
{
|
||||||
if (selectionStart >= posStartComment+startCommentLength)
|
if (selectionStart >= posStartComment+startCommentLength)
|
||||||
selectionStartMove = -(int)startCommentLength;
|
selectionStartMove = -(int)startCommentLength;
|
||||||
else
|
else
|
||||||
|
@ -6251,6 +6276,7 @@ bool Notepad_plus::undoStreamComment()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
selectionStartMove = 0;
|
selectionStartMove = 0;
|
||||||
|
|
||||||
// selectionEnd
|
// selectionEnd
|
||||||
if (selectionEnd >= posEndComment+endCommentLength)
|
if (selectionEnd >= posEndComment+endCommentLength)
|
||||||
selectionEndMove = -(int)(startCommentLength+endCommentLength);
|
selectionEndMove = -(int)(startCommentLength+endCommentLength);
|
||||||
|
@ -6258,6 +6284,7 @@ bool Notepad_plus::undoStreamComment()
|
||||||
selectionEndMove = -(int)startCommentLength;
|
selectionEndMove = -(int)startCommentLength;
|
||||||
else
|
else
|
||||||
selectionEndMove = -(int)(startCommentLength + (selectionEnd - posEndComment));
|
selectionEndMove = -(int)(startCommentLength + (selectionEnd - posEndComment));
|
||||||
|
|
||||||
//-- Reset selection of text without deleted stream-comment-string
|
//-- Reset selection of text without deleted stream-comment-string
|
||||||
if (move_caret)
|
if (move_caret)
|
||||||
{
|
{
|
||||||
|
@ -6269,7 +6296,8 @@ bool Notepad_plus::undoStreamComment()
|
||||||
{
|
{
|
||||||
_pEditView->execute(SCI_SETSEL, selectionStart+selectionStartMove, selectionEnd+selectionEndMove);
|
_pEditView->execute(SCI_SETSEL, selectionStart+selectionStartMove, selectionEnd+selectionEndMove);
|
||||||
}
|
}
|
||||||
} while(1); //do as long as stream-comments are within selection
|
}
|
||||||
|
while(1); //do as long as stream-comments are within selection
|
||||||
//return retVal;
|
//return retVal;
|
||||||
} //----- undoStreamComment() -------------------------------
|
} //----- undoStreamComment() -------------------------------
|
||||||
|
|
||||||
|
|
|
@ -196,8 +196,8 @@ class ProjectPanel;
|
||||||
class DocumentMap;
|
class DocumentMap;
|
||||||
class FunctionListPanel;
|
class FunctionListPanel;
|
||||||
|
|
||||||
class Notepad_plus {
|
class Notepad_plus
|
||||||
|
{
|
||||||
friend class Notepad_plus_Window;
|
friend class Notepad_plus_Window;
|
||||||
friend class FileManager;
|
friend class FileManager;
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ public:
|
||||||
bool fileReload() {
|
bool fileReload() {
|
||||||
BufferID buf = _pEditView->getCurrentBufferID();
|
BufferID buf = _pEditView->getCurrentBufferID();
|
||||||
return doReload(buf, buf->isDirty());
|
return doReload(buf, buf->isDirty());
|
||||||
};
|
}
|
||||||
|
|
||||||
bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
|
bool fileClose(BufferID id = BUFFER_INVALID, int curView = -1); //use curView to override view to close from
|
||||||
bool fileCloseAll(bool doDeleteBackup, bool isSnapshotMode = false);
|
bool fileCloseAll(bool doDeleteBackup, bool isSnapshotMode = false);
|
||||||
|
@ -263,17 +263,17 @@ public:
|
||||||
void saveUserDefineLangs() {
|
void saveUserDefineLangs() {
|
||||||
if (ScintillaEditView::getUserDefineDlg()->isDirty())
|
if (ScintillaEditView::getUserDefineDlg()->isDirty())
|
||||||
(NppParameters::getInstance())->writeUserDefinedLang();
|
(NppParameters::getInstance())->writeUserDefinedLang();
|
||||||
};
|
}
|
||||||
void saveShortcuts(){
|
void saveShortcuts(){
|
||||||
NppParameters::getInstance()->writeShortcuts();
|
NppParameters::getInstance()->writeShortcuts();
|
||||||
};
|
}
|
||||||
void saveSession(const Session & session);
|
void saveSession(const Session & session);
|
||||||
void saveCurrentSession();
|
void saveCurrentSession();
|
||||||
|
|
||||||
void saveFindHistory(){
|
void saveFindHistory(){
|
||||||
_findReplaceDlg.saveFindHistory();
|
_findReplaceDlg.saveFindHistory();
|
||||||
(NppParameters::getInstance())->writeFindHistory();
|
(NppParameters::getInstance())->writeFindHistory();
|
||||||
};
|
}
|
||||||
|
|
||||||
void getCurrentOpenedFiles(Session & session, bool includUntitledDoc = false);
|
void getCurrentOpenedFiles(Session & session, bool includUntitledDoc = false);
|
||||||
|
|
||||||
|
@ -301,11 +301,11 @@ public:
|
||||||
int getHtmlXmlEncoding(const TCHAR *fileName) const;
|
int getHtmlXmlEncoding(const TCHAR *fileName) const;
|
||||||
HACCEL getAccTable() const{
|
HACCEL getAccTable() const{
|
||||||
return _accelerator.getAccTable();
|
return _accelerator.getAccTable();
|
||||||
};
|
}
|
||||||
bool emergency(generic_string emergencySavedDir);
|
bool emergency(generic_string emergencySavedDir);
|
||||||
Buffer * getCurrentBuffer() {
|
Buffer * getCurrentBuffer() {
|
||||||
return _pEditView->getCurrentBuffer();
|
return _pEditView->getCurrentBuffer();
|
||||||
};
|
}
|
||||||
void launchDocumentBackupTask();
|
void launchDocumentBackupTask();
|
||||||
int getQuoteIndexFrom(const char *quoter) const;
|
int getQuoteIndexFrom(const char *quoter) const;
|
||||||
void showQuoteFromIndex(int index) const;
|
void showQuoteFromIndex(int index) const;
|
||||||
|
@ -389,23 +389,27 @@ private:
|
||||||
//For Dynamic selection highlight
|
//For Dynamic selection highlight
|
||||||
CharacterRange _prevSelectedRange;
|
CharacterRange _prevSelectedRange;
|
||||||
|
|
||||||
struct ActivateAppInfo {
|
struct ActivateAppInfo
|
||||||
|
{
|
||||||
bool _isActivated;
|
bool _isActivated;
|
||||||
int _x;
|
int _x;
|
||||||
int _y;
|
int _y;
|
||||||
ActivateAppInfo() : _isActivated(false), _x(0), _y(0){};
|
ActivateAppInfo() : _isActivated(false), _x(0), _y(0){};
|
||||||
} _activeAppInf;
|
}
|
||||||
|
_activeAppInf;
|
||||||
|
|
||||||
//Synchronized Scolling
|
//Synchronized Scolling
|
||||||
|
|
||||||
struct SyncInfo {
|
struct SyncInfo
|
||||||
|
{
|
||||||
int _line;
|
int _line;
|
||||||
int _column;
|
int _column;
|
||||||
bool _isSynScollV;
|
bool _isSynScollV;
|
||||||
bool _isSynScollH;
|
bool _isSynScollH;
|
||||||
SyncInfo():_line(0), _column(0), _isSynScollV(false), _isSynScollH(false){};
|
SyncInfo():_line(0), _column(0), _isSynScollV(false), _isSynScollH(false){};
|
||||||
bool doSync() const {return (_isSynScollV || _isSynScollH); };
|
bool doSync() const {return (_isSynScollV || _isSynScollH); };
|
||||||
} _syncInfo;
|
}
|
||||||
|
_syncInfo;
|
||||||
|
|
||||||
bool _isUDDocked;
|
bool _isUDDocked;
|
||||||
|
|
||||||
|
@ -459,15 +463,15 @@ private:
|
||||||
|
|
||||||
int currentView(){
|
int currentView(){
|
||||||
return _activeView;
|
return _activeView;
|
||||||
};
|
}
|
||||||
|
|
||||||
int otherView(){
|
int otherView(){
|
||||||
return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
return (_activeView == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
||||||
};
|
}
|
||||||
|
|
||||||
int otherFromView(int whichOne){
|
int otherFromView(int whichOne){
|
||||||
return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
return (whichOne == MAIN_VIEW?SUB_VIEW:MAIN_VIEW);
|
||||||
};
|
}
|
||||||
|
|
||||||
bool canHideView(int whichOne); //true if view can safely be hidden (no open docs etc)
|
bool canHideView(int whichOne); //true if view can safely be hidden (no open docs etc)
|
||||||
|
|
||||||
|
@ -510,7 +514,7 @@ private:
|
||||||
|
|
||||||
void setLangStatus(LangType langType){
|
void setLangStatus(LangType langType){
|
||||||
_statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE);
|
_statusBar.setText(getLangDesc(langType).c_str(), STATUSBAR_DOC_TYPE);
|
||||||
};
|
}
|
||||||
|
|
||||||
void setDisplayFormat(formatType f);
|
void setDisplayFormat(formatType f);
|
||||||
int getCmdIDFromEncoding(int encoding) const;
|
int getCmdIDFromEncoding(int encoding) const;
|
||||||
|
@ -523,7 +527,7 @@ private:
|
||||||
|
|
||||||
void checkMenuItem(int itemID, bool willBeChecked) const {
|
void checkMenuItem(int itemID, bool willBeChecked) const {
|
||||||
::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED));
|
::CheckMenuItem(_mainMenuHandle, itemID, MF_BYCOMMAND | (willBeChecked?MF_CHECKED:MF_UNCHECKED));
|
||||||
};
|
}
|
||||||
|
|
||||||
bool isConditionExprLine(int lineNumber);
|
bool isConditionExprLine(int lineNumber);
|
||||||
int findMachedBracePos(size_t startPos, size_t endPos, char targetSymbol, char matchedSymbol);
|
int findMachedBracePos(size_t startPos, size_t endPos, char targetSymbol, char matchedSymbol);
|
||||||
|
@ -531,25 +535,32 @@ private:
|
||||||
|
|
||||||
void addHotSpot();
|
void addHotSpot();
|
||||||
|
|
||||||
void bookmarkAdd(int lineno) const {
|
void bookmarkAdd(int lineno) const
|
||||||
|
{
|
||||||
if (lineno == -1)
|
if (lineno == -1)
|
||||||
lineno = _pEditView->getCurrentLineNumber();
|
lineno = _pEditView->getCurrentLineNumber();
|
||||||
if (!bookmarkPresent(lineno))
|
if (!bookmarkPresent(lineno))
|
||||||
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
|
_pEditView->execute(SCI_MARKERADD, lineno, MARK_BOOKMARK);
|
||||||
};
|
}
|
||||||
void bookmarkDelete(int lineno) const {
|
|
||||||
|
void bookmarkDelete(int lineno) const
|
||||||
|
{
|
||||||
if (lineno == -1)
|
if (lineno == -1)
|
||||||
lineno = _pEditView->getCurrentLineNumber();
|
lineno = _pEditView->getCurrentLineNumber();
|
||||||
if ( bookmarkPresent(lineno))
|
if ( bookmarkPresent(lineno))
|
||||||
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
|
_pEditView->execute(SCI_MARKERDELETE, lineno, MARK_BOOKMARK);
|
||||||
};
|
}
|
||||||
bool bookmarkPresent(int lineno) const {
|
|
||||||
|
bool bookmarkPresent(int lineno) const
|
||||||
|
{
|
||||||
if (lineno == -1)
|
if (lineno == -1)
|
||||||
lineno = _pEditView->getCurrentLineNumber();
|
lineno = _pEditView->getCurrentLineNumber();
|
||||||
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
|
LRESULT state = _pEditView->execute(SCI_MARKERGET, lineno);
|
||||||
return ((state & (1 << MARK_BOOKMARK)) != 0);
|
return ((state & (1 << MARK_BOOKMARK)) != 0);
|
||||||
};
|
}
|
||||||
void bookmarkToggle(int lineno) const {
|
|
||||||
|
void bookmarkToggle(int lineno) const
|
||||||
|
{
|
||||||
if (lineno == -1)
|
if (lineno == -1)
|
||||||
lineno = _pEditView->getCurrentLineNumber();
|
lineno = _pEditView->getCurrentLineNumber();
|
||||||
|
|
||||||
|
@ -557,11 +568,13 @@ private:
|
||||||
bookmarkDelete(lineno);
|
bookmarkDelete(lineno);
|
||||||
else
|
else
|
||||||
bookmarkAdd(lineno);
|
bookmarkAdd(lineno);
|
||||||
};
|
}
|
||||||
|
|
||||||
void bookmarkNext(bool forwardScan);
|
void bookmarkNext(bool forwardScan);
|
||||||
void bookmarkClearAll() const {
|
void bookmarkClearAll() const
|
||||||
|
{
|
||||||
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
|
||||||
};
|
}
|
||||||
|
|
||||||
void copyMarkedLines();
|
void copyMarkedLines();
|
||||||
void cutMarkedLines();
|
void cutMarkedLines();
|
||||||
|
@ -637,12 +650,14 @@ private:
|
||||||
static bool deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
static bool deleteForward(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
||||||
static bool selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
static bool selectBack(ScintillaEditView *pCurrentView, BufferID targetBufID);
|
||||||
|
|
||||||
static int getRandomNumber(int rangeMax = -1) {
|
static int getRandomNumber(int rangeMax = -1)
|
||||||
|
{
|
||||||
int randomNumber = rand();
|
int randomNumber = rand();
|
||||||
if (rangeMax == -1)
|
if (rangeMax == -1)
|
||||||
return randomNumber;
|
return randomNumber;
|
||||||
return (rand() % rangeMax);
|
return (rand() % rangeMax);
|
||||||
};
|
}
|
||||||
|
|
||||||
static DWORD WINAPI backupDocument(void *params);
|
static DWORD WINAPI backupDocument(void *params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue