Applied coding style / cleanup

This commit is contained in:
Damien GERARD 2015-07-15 14:09:31 +02:00
parent 0cd514de13
commit 23cd144198
26 changed files with 898 additions and 744 deletions

View File

@ -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)
{ {
@ -366,7 +381,7 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs, NULL, 0); lenWc = MultiByteToWideChar(codepage, 0, mbcs2Convert, lenMbcs, NULL, 0);
} }
// Otherwise, test if we are cutting a multi-byte character at end of buffer // Otherwise, test if we are cutting a multi-byte character at end of buffer
else if(lenMbcs != -1 && codepage == CP_UTF8) // For UTF-8, we know how to test it else if (lenMbcs != -1 && codepage == CP_UTF8) // For UTF-8, we know how to test it
{ {
int indexOfLastChar = Utf8::characterStart(mbcs2Convert, lenMbcs-1); // get index of last character int indexOfLastChar = Utf8::characterStart(mbcs2Convert, lenMbcs-1); // get index of last character
if (indexOfLastChar != 0 && !Utf8::isValid(mbcs2Convert+indexOfLastChar, lenMbcs-indexOfLastChar)) // if it is not valid we do not process it right now (unless its the only character in string, to ensure that we always progress, e.g. that bytesNotProcessed < lenMbcs) if (indexOfLastChar != 0 && !Utf8::isValid(mbcs2Convert+indexOfLastChar, lenMbcs-indexOfLastChar)) // if it is not valid we do not process it right now (unless its the only character in string, to ensure that we always progress, e.g. that bytesNotProcessed < lenMbcs)
@ -404,11 +419,12 @@ const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT c
else else
_wideCharStr.empty(); _wideCharStr.empty();
if(pLenWc) *pLenWc = lenWc; if (pLenWc) *pLenWc = lenWc;
if(pBytesNotProcessed) *pBytesNotProcessed = bytesNotProcessed; if (pBytesNotProcessed) *pBytesNotProcessed = bytesNotProcessed;
return _wideCharStr; return _wideCharStr;
} }
// "mstart" and "mend" are pointers to indexes in mbcs2Convert, // "mstart" and "mend" are pointers to indexes in mbcs2Convert,
// which are converted to the corresponding indexes in the returned wchar_t string. // which are converted to the corresponding indexes in the returned wchar_t string.
const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend) const wchar_t * WcharMbcsConvertor::char2wchar(const char * mbcs2Convert, UINT codepage, int *mstart, int *mend)
@ -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,10 +507,11 @@ const char * WcharMbcsConvertor::wchar2char(const wchar_t * wcharStr2Convert, UI
return _multiByteStr; return _multiByteStr;
} }
std::wstring string2wstring(const std::string & rString, UINT codepage) std::wstring string2wstring(const std::string & rString, UINT codepage)
{ {
int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0); int len = MultiByteToWideChar(codepage, 0, rString.c_str(), -1, NULL, 0);
if(len > 0) if (len > 0)
{ {
std::vector<wchar_t> vw(len); std::vector<wchar_t> vw(len);
MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len); MultiByteToWideChar(codepage, 0, rString.c_str(), -1, &vw[0], len);
@ -504,7 +524,7 @@ std::wstring string2wstring(const std::string & rString, UINT codepage)
std::string wstring2string(const std::wstring & rwString, UINT codepage) std::string wstring2string(const std::wstring & rwString, UINT codepage)
{ {
int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL); int len = WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, NULL, 0, NULL, NULL);
if(len > 0) if (len > 0)
{ {
std::vector<char> vw(len); std::vector<char> vw(len);
WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL); WideCharToMultiByte(codepage, 0, rwString.c_str(), -1, &vw[0], len, NULL, NULL);
@ -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;
} }

View File

@ -134,19 +134,20 @@ public:
}; };
protected: protected:
WcharMbcsConvertor() { WcharMbcsConvertor() {}
}; ~WcharMbcsConvertor() {}
~WcharMbcsConvertor() {
};
static WcharMbcsConvertor * _pSelf; static WcharMbcsConvertor * _pSelf;
template <class T> template <class T>
class StringBuffer { class StringBuffer
{
public: public:
StringBuffer() : _str(0), _allocLen(0) { } StringBuffer() : _str(0), _allocLen(0) { }
~StringBuffer() { if(_allocLen) delete [] _str; } ~StringBuffer() { if(_allocLen) delete [] _str; }
void sizeTo(size_t size) { void sizeTo(size_t size)
{
if(_allocLen < size) if(_allocLen < size)
{ {
if(_allocLen) delete[] _str; if(_allocLen) delete[] _str;
@ -154,7 +155,8 @@ protected:
_str = new T[_allocLen]; _str = new T[_allocLen];
} }
} }
void empty() { void empty()
{
static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case static T nullStr = 0; // routines may return an empty string, with null terminator, without allocating memory; a pointer to this null character will be returned in that case
if(_allocLen == 0) if(_allocLen == 0)
_str = &nullStr; _str = &nullStr;
@ -176,9 +178,10 @@ protected:
private: private:
// Since there's no public ctor, we need to void the default assignment operator. // Since there's no public ctor, we need to void the default assignment operator.
WcharMbcsConvertor& operator= (const WcharMbcsConvertor&); WcharMbcsConvertor& operator= (const WcharMbcsConvertor&);
}; };
#define MACRO_RECORDING_IN_PROGRESS 1 #define MACRO_RECORDING_IN_PROGRESS 1
#define MACRO_RECORDING_HAS_STOPPED 2 #define MACRO_RECORDING_HAS_STOPPED 2

View File

@ -35,11 +35,13 @@
#include "Win32Exception.h" #include "Win32Exception.h"
Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) { Win32Exception::Win32Exception(EXCEPTION_POINTERS * info)
{
_location = info->ExceptionRecord->ExceptionAddress; _location = info->ExceptionRecord->ExceptionAddress;
_code = info->ExceptionRecord->ExceptionCode; _code = info->ExceptionRecord->ExceptionCode;
_info = info; _info = info;
switch (_code) { switch (_code)
{
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
_event = "Access violation"; _event = "Access violation";
break; break;
@ -52,17 +54,21 @@ Win32Exception::Win32Exception(EXCEPTION_POINTERS * info) {
} }
} }
void Win32Exception::installHandler() { void Win32Exception::installHandler()
{
_set_se_translator(Win32Exception::translate); _set_se_translator(Win32Exception::translate);
} }
void Win32Exception::removeHandler() { void Win32Exception::removeHandler()
{
_set_se_translator(NULL); _set_se_translator(NULL);
} }
void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) { void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info)
{
// Windows guarantees that *(info->ExceptionRecord) is valid // Windows guarantees that *(info->ExceptionRecord) is valid
switch (code) { switch (code)
{
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
throw Win32AccessViolation(info); throw Win32AccessViolation(info);
break; break;
@ -71,7 +77,12 @@ void Win32Exception::translate(unsigned code, EXCEPTION_POINTERS * info) {
} }
} }
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info) : Win32Exception(info) {
Win32AccessViolation::Win32AccessViolation(EXCEPTION_POINTERS * info)
: Win32Exception(info)
{
_isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1; _isWrite = info->ExceptionRecord->ExceptionInformation[0] == 1;
_badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]); _badAddress = reinterpret_cast<ExceptionAddress>(info->ExceptionRecord->ExceptionInformation[1]);
} }

View File

@ -42,16 +42,16 @@ typedef const void* ExceptionAddress; // OK on Win32 platform
class Win32Exception : public std::exception class Win32Exception : public std::exception
{ {
public: public:
static void installHandler(); static void installHandler();
static void removeHandler(); static void removeHandler();
virtual const char* what() const throw() { return _event; }; virtual const char* what() const throw() { return _event; }
ExceptionAddress where() const { return _location; }; ExceptionAddress where() const { return _location; }
unsigned int code() const { return _code; }; unsigned int code() const { return _code; }
EXCEPTION_POINTERS* info() const { return _info; }; EXCEPTION_POINTERS* info() const { return _info; }
protected: protected:
Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler Win32Exception(EXCEPTION_POINTERS * info); //Constructor only accessible by exception handler
static void translate(unsigned code, EXCEPTION_POINTERS * info); static void translate(unsigned code, EXCEPTION_POINTERS * info);
private: private:
const char * _event; const char * _event;
@ -61,11 +61,12 @@ private:
EXCEPTION_POINTERS * _info; EXCEPTION_POINTERS * _info;
}; };
class Win32AccessViolation: public Win32Exception class Win32AccessViolation: public Win32Exception
{ {
public: public:
bool isWrite() const { return _isWrite; }; bool isWrite() const { return _isWrite; }
ExceptionAddress badAddress() const { return _badAddress; }; ExceptionAddress badAddress() const { return _badAddress; }
private: private:
Win32AccessViolation(EXCEPTION_POINTERS * info); Win32AccessViolation(EXCEPTION_POINTERS * info);

View File

@ -31,10 +31,13 @@
typedef std::vector<generic_string> stringVector; typedef std::vector<generic_string> stringVector;
class FileNameStringSplitter class FileNameStringSplitter
{ {
public : public:
FileNameStringSplitter(const TCHAR *fileNameStr) { FileNameStringSplitter(const TCHAR *fileNameStr)
{
//if (!fileNameStr) return; //if (!fileNameStr) return;
TCHAR *pStr = NULL; TCHAR *pStr = NULL;
bool isInsideQuotes = false; bool isInsideQuotes = false;
@ -43,6 +46,7 @@ public :
TCHAR str[filePathLength]; TCHAR str[filePathLength];
int i = 0; int i = 0;
bool fini = false; bool fini = false;
for (pStr = (TCHAR *)fileNameStr ; !fini ; ) for (pStr = (TCHAR *)fileNameStr ; !fini ; )
{ {
if (i >= filePathLength) if (i >= filePathLength)
@ -50,7 +54,8 @@ public :
switch (*pStr) switch (*pStr)
{ {
case '"' : case '"':
{
if (isInsideQuotes) if (isInsideQuotes)
{ {
str[i] = '\0'; str[i] = '\0';
@ -61,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

View File

@ -41,7 +41,8 @@ const int nbChar = 64;
typedef const TCHAR * (__cdecl * PFUNCGETNAME)(); typedef const TCHAR * (__cdecl * PFUNCGETNAME)();
struct NppData { struct NppData
{
HWND _nppHandle; HWND _nppHandle;
HWND _scintillaMainHandle; HWND _scintillaMainHandle;
HWND _scintillaSecondHandle; HWND _scintillaSecondHandle;
@ -53,14 +54,16 @@ typedef void (__cdecl * PBENOTIFIED)(SCNotification *);
typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam); typedef LRESULT (__cdecl * PMESSAGEPROC)(UINT Message, WPARAM wParam, LPARAM lParam);
struct ShortcutKey { struct ShortcutKey
{
bool _isCtrl; bool _isCtrl;
bool _isAlt; bool _isAlt;
bool _isShift; bool _isShift;
UCHAR _key; UCHAR _key;
}; };
struct FuncItem { struct FuncItem
{
TCHAR _itemName[nbChar]; TCHAR _itemName[nbChar];
PFUNCPLUGINCMD _pFunc; PFUNCPLUGINCMD _pFunc;
int _cmdID; int _cmdID;

View File

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

View File

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

View File

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

View File

@ -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);
@ -80,15 +84,15 @@ BOOL Process::run()
_hProcess = procinfo.hProcess; _hProcess = procinfo.hProcess;
_hProcessThread = procinfo.hThread; _hProcessThread = procinfo.hThread;
if(!started) if (!started)
error(TEXT("CreateProcess"), result, 1002); error(TEXT("CreateProcess"), result, 1002);
hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent")); hListenerEvent[0] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerEvent"));
if(!hListenerEvent[0]) if (!hListenerEvent[0])
error(TEXT("CreateEvent"), result, 1003); error(TEXT("CreateEvent"), result, 1003);
hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent")); hListenerEvent[1] = ::CreateEvent(NULL, FALSE, FALSE, TEXT("listenerStdErrEvent"));
if(!hListenerEvent[1]) if (!hListenerEvent[1])
error(TEXT("CreateEvent"), result, 1004); error(TEXT("CreateEvent"), result, 1004);
hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL); hListenerStdOutThread = ::CreateThread(NULL, 0, staticListenerStdOut, this, 0, NULL);
@ -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)
@ -156,7 +162,7 @@ void Process::listenerStdOut()
break; break;
} }
if(outbytesRead) if (outbytesRead)
{ {
result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL); result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL);
if ((!result) && (outbytesRead == 0)) if ((!result) && (outbytesRead == 0))
@ -184,7 +190,7 @@ void Process::listenerStdOut()
} }
_exitCode = nExitCode; _exitCode = nExitCode;
if(!::SetEvent(hListenerEvent)) if (!::SetEvent(hListenerEvent))
{ {
systemMessage(TEXT("Thread listenerStdOut")); systemMessage(TEXT("Thread listenerStdOut"));
} }
@ -217,7 +223,7 @@ void Process::listenerStdErr()
break; break;
} }
if(errbytesRead) if (errbytesRead)
{ {
result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL); result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL);
if ((!result) && (errbytesRead == 0)) if ((!result) && (errbytesRead == 0))
@ -244,15 +250,17 @@ void Process::listenerStdErr()
} }
//_exitCode = nExitCode; //_exitCode = nExitCode;
if(!::SetEvent(hListenerEvent)) if (!::SetEvent(hListenerEvent))
{ {
systemMessage(TEXT("Thread stdout listener")); systemMessage(TEXT("Thread stdout listener"));
} }
} }
void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode) void Process::error(const TCHAR *txt2display, BOOL & returnCode, int errCode)
{ {
systemMessage(txt2display); systemMessage(txt2display);
returnCode = FALSE; returnCode = FALSE;
throw int(errCode); throw int(errCode);
} }

View File

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

View File

@ -33,14 +33,17 @@
class ProcessThread class ProcessThread
{ {
public : public:
ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd) : _hwnd(hwnd) { ProcessThread(const TCHAR *appName, const TCHAR *cmd, const TCHAR *cDir, HWND hwnd)
: _hwnd(hwnd)
{
lstrcpy(_appName, appName); lstrcpy(_appName, appName);
lstrcpy(_command, cmd); lstrcpy(_command, cmd);
lstrcpy(_curDir, cDir); lstrcpy(_curDir, cDir);
}; }
BOOL run(){ BOOL run()
{
HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent")); HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, TEXT("localVarProcessEvent"));
_hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL); _hProcessThread = ::CreateThread(NULL, 0, staticLauncher, this, 0, NULL);
@ -49,9 +52,10 @@ public :
::CloseHandle(hEvent); ::CloseHandle(hEvent);
return TRUE; return TRUE;
}; }
protected :
protected:
// ENTREES // ENTREES
TCHAR _appName[256]; TCHAR _appName[256];
TCHAR _command[256]; TCHAR _command[256];
@ -59,12 +63,14 @@ protected :
HWND _hwnd; HWND _hwnd;
HANDLE _hProcessThread; HANDLE _hProcessThread;
static DWORD WINAPI staticLauncher(void *myself) { static DWORD WINAPI staticLauncher(void *myself)
{
((ProcessThread *)myself)->launch(); ((ProcessThread *)myself)->launch();
return TRUE; return TRUE;
}; }
bool launch() { bool launch()
{
HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent")); HANDLE hEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("localVarProcessEvent"));
HWND hwnd = _hwnd; HWND hwnd = _hwnd;
TCHAR appName[256]; TCHAR appName[256];
@ -73,10 +79,8 @@ 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

View File

@ -24,14 +24,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "Common.h" #include "Common.h"
#include "regExtDlg.h" #include "regExtDlg.h"
#include "resource.h" #include "resource.h"
const TCHAR *nppName = TEXT("Notepad++_file");
const TCHAR *nppBackup = TEXT("Notepad++_backup");
const TCHAR *nppDoc = TEXT("Notepad++ Document"); const TCHAR* nppName = TEXT("Notepad++_file");
const TCHAR* nppBackup = TEXT("Notepad++_backup");
const TCHAR* nppDoc = TEXT("Notepad++ Document");
const int nbSupportedLang = 9; const int nbSupportedLang = 9;
const int nbExtMax = 10; const int nbExtMax = 10;
@ -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;
} }
@ -172,14 +173,15 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
return TRUE; return TRUE;
} }
case IDCANCEL : case IDCANCEL:
{
::EndDialog(_hSelf, 0); ::EndDialog(_hSelf, 0);
return TRUE; return TRUE;
}
} }
if (HIWORD(wParam) == EN_CHANGE) if (HIWORD(wParam) == EN_CHANGE)
{ {
TCHAR text[extNameMax] = TEXT(""); TCHAR text[extNameMax] = TEXT("");
::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text); ::SendDlgItemMessage(_hSelf, IDC_CUSTOMEXT_EDIT, WM_GETTEXT, extNameMax, (LPARAM)text);
if ((lstrlen(text) == 1) && (text[0] != '.')) if ((lstrlen(text) == 1) && (text[0] != '.'))
@ -195,7 +197,7 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
} }
if (HIWORD(wParam) == LBN_SELCHANGE) if (HIWORD(wParam) == LBN_SELCHANGE)
{ {
int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0); int i = ::SendDlgItemMessage(_hSelf, LOWORD(wParam), LB_GETCURSEL, 0, 0);
if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST) if (LOWORD(wParam) == IDC_REGEXT_LANG_LIST)
{ {
@ -224,38 +226,41 @@ INT_PTR CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_DELETESTRING, count, 0);
for (int j = 1 ; j < nbExtMax ; ++j) for (int j = 1 ; j < nbExtMax ; ++j)
{
if (lstrcmp(TEXT(""), defExtArray[i][j])) if (lstrcmp(TEXT(""), defExtArray[i][j]))
{ {
int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]); int index = ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_FINDSTRINGEXACT, 0, (LPARAM)defExtArray[i][j]);
if (index == -1) if (index == -1)
::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_LANGEXT_LIST, LB_ADDSTRING, 0, (LPARAM)defExtArray[i][j]);
} }
}
} }
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), false);
} }
} }
else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST) else if (LOWORD(wParam) == IDC_REGEXT_LANGEXT_LIST)
{ {
if (i != LB_ERR) if (i != LB_ERR)
::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_ADDFROMLANGEXT_BUTTON), true);
} }
else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST) else if (LOWORD(wParam) == IDC_REGEXT_REGISTEREDEXTS_LIST)
{ {
if (i != LB_ERR) if (i != LB_ERR)
::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_REMOVEEXT_BUTTON), true);
} }
} }
// break; // no break here
} }
default : default :
return FALSE; return FALSE;
} }
//return FALSE; //return FALSE;
} }
void RegExtDlg::getRegisteredExts() void RegExtDlg::getRegisteredExts()
{ {
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT); int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
@ -264,7 +269,7 @@ void RegExtDlg::getRegisteredExts()
TCHAR extName[extNameLen]; TCHAR extName[extNameLen];
//FILETIME fileTime; //FILETIME fileTime;
int extNameActualLen = extNameLen; int extNameActualLen = extNameLen;
int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, NULL, NULL, NULL, NULL); int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, (LPDWORD)&extNameActualLen, nullptr, nullptr, nullptr, nullptr);
if ((res == ERROR_SUCCESS) && (extName[0] == '.')) if ((res == ERROR_SUCCESS) && (extName[0] == '.'))
{ {
//TCHAR valName[extNameLen]; //TCHAR valName[extNameLen];
@ -274,8 +279,8 @@ void RegExtDlg::getRegisteredExts()
HKEY hKey2Check; HKEY hKey2Check;
extNameActualLen = extNameLen; extNameActualLen = extNameLen;
::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check); ::RegOpenKeyEx(HKEY_CLASSES_ROOT, extName, 0, KEY_ALL_ACCESS, &hKey2Check);
::RegQueryValueEx(hKey2Check, TEXT(""), NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); ::RegQueryValueEx(hKey2Check, TEXT(""), nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
//::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); //::RegEnumValue(hKey2Check, 0, valName, (LPDWORD)&extNameActualLen, nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
if ((valType == REG_SZ) && (!lstrcmp(valData, nppName))) if ((valType == REG_SZ) && (!lstrcmp(valData, nppName)))
::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName); ::SendDlgItemMessage(_hSelf, IDC_REGEXT_REGISTEREDEXTS_LIST, LB_ADDSTRING, 0, (LPARAM)extName);
::RegCloseKey(hKey2Check); ::RegCloseKey(hKey2Check);
@ -283,6 +288,7 @@ void RegExtDlg::getRegisteredExts()
} }
} }
void RegExtDlg::getDefSupportedExts() void RegExtDlg::getDefSupportedExts()
{ {
for (int i = 0 ; i < nbSupportedLang ; ++i) for (int i = 0 ; i < nbSupportedLang ; ++i)
@ -292,37 +298,30 @@ void RegExtDlg::getDefSupportedExts()
void RegExtDlg::addExt(TCHAR *ext) void RegExtDlg::addExt(TCHAR *ext)
{ {
HKEY hKey; HKEY hKey;
DWORD dwDisp; DWORD dwDisp;
long nRet; long nRet;
nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, ext, 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
ext,
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS) if (nRet == ERROR_SUCCESS)
{ {
TCHAR valData[MAX_PATH]; TCHAR valData[MAX_PATH];
int valDataLen = MAX_PATH * sizeof(TCHAR); int valDataLen = MAX_PATH * sizeof(TCHAR);
if (dwDisp == REG_OPENED_EXISTING_KEY) if (dwDisp == REG_OPENED_EXISTING_KEY)
{ {
int res = ::RegQueryValueEx(hKey, TEXT(""), NULL, NULL, (LPBYTE)valData, (LPDWORD)&valDataLen); int res = ::RegQueryValueEx(hKey, TEXT(""), nullptr, nullptr, (LPBYTE)valData, (LPDWORD)&valDataLen);
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen); ::RegSetValueEx(hKey, nppBackup, 0, REG_SZ, (LPBYTE)valData, valDataLen);
} }
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR)); ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppName, (lstrlen(nppName)+1)*sizeof(TCHAR));
::RegCloseKey(hKey); ::RegCloseKey(hKey);
} }
} }
bool RegExtDlg::deleteExts(const TCHAR *ext2Delete) bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
{ {
HKEY hKey; HKEY hKey;
@ -342,20 +341,21 @@ bool RegExtDlg::deleteExts(const TCHAR *ext2Delete)
TCHAR valData[extNameLen]; TCHAR valData[extNameLen];
int valDataLen = extNameLen*sizeof(TCHAR); int valDataLen = extNameLen*sizeof(TCHAR);
int valType; int valType;
int res = ::RegQueryValueEx(hKey, nppBackup, NULL, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen); int res = ::RegQueryValueEx(hKey, nppBackup, nullptr, (LPDWORD)&valType, (LPBYTE)valData, (LPDWORD)&valDataLen);
if (res == ERROR_SUCCESS) if (res == ERROR_SUCCESS)
{ {
::RegSetValueEx(hKey, NULL, 0, valType, (LPBYTE)valData, valDataLen); ::RegSetValueEx(hKey, nullptr, 0, valType, (LPBYTE)valData, valDataLen);
::RegDeleteValue(hKey, nppBackup); ::RegDeleteValue(hKey, nppBackup);
} }
else else
::RegDeleteValue(hKey, NULL); ::RegDeleteValue(hKey, nullptr);
} }
return true; return true;
} }
void RegExtDlg::writeNppPath() void RegExtDlg::writeNppPath()
{ {
HKEY hKey, hRootKey; HKEY hKey, hRootKey;
@ -364,16 +364,7 @@ void RegExtDlg::writeNppPath()
generic_string regStr(nppName); generic_string regStr(nppName);
regStr += TEXT("\\shell\\open\\command"); regStr += TEXT("\\shell\\open\\command");
nRet = ::RegCreateKeyEx( nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
HKEY_CLASSES_ROOT,
regStr.c_str(),
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS) if (nRet == ERROR_SUCCESS)
@ -382,7 +373,7 @@ void RegExtDlg::writeNppPath()
{ {
// Write the value for new document // Write the value for new document
::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey); ::RegOpenKeyEx(HKEY_CLASSES_ROOT, nppName, 0, KEY_ALL_ACCESS, &hRootKey);
::RegSetValueEx(hRootKey, NULL, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR)); ::RegSetValueEx(hRootKey, nullptr, 0, REG_SZ, (LPBYTE)nppDoc, (lstrlen(nppDoc)+1)*sizeof(TCHAR));
RegCloseKey(hRootKey); RegCloseKey(hRootKey);
TCHAR nppPath[MAX_PATH]; TCHAR nppPath[MAX_PATH];
@ -391,7 +382,7 @@ void RegExtDlg::writeNppPath()
TCHAR nppPathParam[MAX_PATH] = TEXT("\""); TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\"")); lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
@ -399,16 +390,7 @@ void RegExtDlg::writeNppPath()
//Set default icon value //Set default icon value
regStr = nppName; regStr = nppName;
regStr += TEXT("\\DefaultIcon"); regStr += TEXT("\\DefaultIcon");
nRet = ::RegCreateKeyEx( nRet = ::RegCreateKeyEx(HKEY_CLASSES_ROOT, regStr.c_str(), 0, nullptr, 0, KEY_ALL_ACCESS, nullptr, &hKey, &dwDisp);
HKEY_CLASSES_ROOT,
regStr.c_str(),
0,
NULL,
0,
KEY_ALL_ACCESS,
NULL,
&hKey,
&dwDisp);
if (nRet == ERROR_SUCCESS) if (nRet == ERROR_SUCCESS)
{ {
@ -420,8 +402,10 @@ void RegExtDlg::writeNppPath()
TCHAR nppPathParam[MAX_PATH] = TEXT("\""); TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0")); lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR)); ::RegSetValueEx(hKey, nullptr, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
} }
RegCloseKey(hKey); RegCloseKey(hKey);
} }
} }

View File

@ -57,13 +57,13 @@ private :
int nbSubKey; int nbSubKey;
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL); long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
return (result == ERROR_SUCCESS)?nbSubKey:0; return (result == ERROR_SUCCESS)?nbSubKey:0;
}; }
int getNbSubValue(HKEY hKey) const { int getNbSubValue(HKEY hKey) const {
int nbSubValue; int nbSubValue;
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL); long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
return (result == ERROR_SUCCESS)?nbSubValue:0; return (result == ERROR_SUCCESS)?nbSubValue:0;
}; }
}; };
#endif //REG_EXT_DLG_H #endif //REG_EXT_DLG_H

View File

@ -31,15 +31,15 @@
#define IDD_REGEXT_BOX 4000 #define IDD_REGEXT_BOX 4000
#define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1) #define IDC_REGEXT_LANG_LIST (IDD_REGEXT_BOX + 1)
#define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2) #define IDC_REGEXT_LANGEXT_LIST (IDD_REGEXT_BOX + 2)
#define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3) #define IDC_REGEXT_REGISTEREDEXTS_LIST (IDD_REGEXT_BOX + 3)
#define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4) #define IDC_ADDFROMLANGEXT_BUTTON (IDD_REGEXT_BOX + 4)
#define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5) #define IDI_POUPELLE_ICON (IDD_REGEXT_BOX + 5)
#define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6) #define IDC_CUSTOMEXT_EDIT (IDD_REGEXT_BOX + 6)
#define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7) #define IDC_REMOVEEXT_BUTTON (IDD_REGEXT_BOX + 7)
#define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8) #define IDC_POUPELLE_STATIC (IDD_REGEXT_BOX + 8)
#define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9) #define IDC_SUPPORTEDEXTS_STATIC (IDD_REGEXT_BOX + 9)
#define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10) #define IDC_REGISTEREDEXTS_STATIC (IDD_REGEXT_BOX + 10)
#endif //REGEXTDLGRC_H #endif //REGEXTDLGRC_H

View File

@ -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),
@ -162,9 +165,9 @@ Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(N
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup; PSID AdministratorsGroup;
is_admin = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup); is_admin = AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &AdministratorsGroup);
if(is_admin) if (is_admin)
{ {
if(!CheckTokenMembership(NULL, AdministratorsGroup, &is_admin)) if (!CheckTokenMembership(NULL, AdministratorsGroup, &is_admin))
is_admin = FALSE; is_admin = FALSE;
FreeSid(AdministratorsGroup); FreeSid(AdministratorsGroup);
} }
@ -175,47 +178,27 @@ Notepad_plus::Notepad_plus(): _mainWindowStatus(0), _pDocTab(NULL), _pEditView(N
_isAdministrator = is_admin ? true : false; _isAdministrator = is_admin ? true : false;
} }
// ATTENTION : the order of the destruction is very important
// because if the parent's window handle is destroyed before
// the destruction of its children windows' handles,
// its children windows' handles will be destroyed automatically!
Notepad_plus::~Notepad_plus() Notepad_plus::~Notepad_plus()
{ {
// ATTENTION : the order of the destruction is very important
// because if the parent's window handle is destroyed before
// the destruction of its children windows' handles,
// its children windows' handles will be destroyed automatically!
(NppParameters::getInstance())->destroyInstance(); (NppParameters::getInstance())->destroyInstance();
MainFileManager->destroyInstance(); MainFileManager->destroyInstance();
(WcharMbcsConvertor::getInstance())->destroyInstance(); (WcharMbcsConvertor::getInstance())->destroyInstance();
if (_pTrayIco)
delete _pTrayIco;
if (_pAnsiCharPanel) delete _pTrayIco;
delete _pAnsiCharPanel; delete _pAnsiCharPanel;
delete _pClipboardHistoryPanel;
if (_pClipboardHistoryPanel) delete _pFileSwitcherPanel;
delete _pClipboardHistoryPanel; delete _pProjectPanel_1;
delete _pProjectPanel_2;
if (_pFileSwitcherPanel) delete _pProjectPanel_3;
delete _pFileSwitcherPanel; delete _pDocMap;
delete _pFuncList;
if (_pProjectPanel_1)
{
delete _pProjectPanel_1;
}
if (_pProjectPanel_2)
{
delete _pProjectPanel_2;
}
if (_pProjectPanel_3)
{
delete _pProjectPanel_3;
}
if (_pDocMap)
{
delete _pDocMap;
}
if (_pFuncList)
{
delete _pFuncList;
}
} }
@ -243,7 +226,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
_subEditView.init(_pPublicInterface->getHinst(), hwnd); _subEditView.init(_pPublicInterface->getHinst(), hwnd);
_fileEditView.init(_pPublicInterface->getHinst(), hwnd); _fileEditView.init(_pPublicInterface->getHinst(), hwnd);
MainFileManager->init(this, &_fileEditView); //get it up and running asap. MainFileManager->init(this, &_fileEditView); //get it up and running asap.
pNppParam->setFontList(hwnd); pNppParam->setFontList(hwnd);
@ -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());
@ -494,7 +479,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
TCHAR buffer[bufferSize]; TCHAR buffer[bufferSize];
int x; int x;
for(x = 0; (x == 0 || lstrcmp(externalLangContainer._name, buffer) > 0) && x < numLangs; ++x) for (x = 0; (x == 0 || lstrcmp(externalLangContainer._name, buffer) > 0) && x < numLangs; ++x)
{ {
::GetMenuString(hLangMenu, x, buffer, bufferSize, MF_BYPOSITION); ::GetMenuString(hLangMenu, x, buffer, bufferSize, MF_BYPOSITION);
} }
@ -584,7 +569,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts(); vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
len = shortcuts.size(); len = shortcuts.size();
for(size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
{ {
CommandShortcut & csc = shortcuts[i]; CommandShortcut & csc = shortcuts[i];
if (!csc.getName()[0]) if (!csc.getName()[0])
@ -1798,7 +1783,7 @@ void Notepad_plus::checkDocState()
bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE; bool isFileExisting = PathFileExists(curBuf->getFullPathName()) != FALSE;
if (!isCurrentDirty) if (!isCurrentDirty)
{ {
for(int i = 0; i < MainFileManager->getNrBuffers(); ++i) for (int i = 0; i < MainFileManager->getNrBuffers(); ++i)
{ {
if (MainFileManager->getBufferByIndex(i)->isDirty()) if (MainFileManager->getBufferByIndex(i)->isDirty())
{ {
@ -2803,7 +2788,7 @@ void Notepad_plus::setTitle()
result += TEXT(" - "); result += TEXT(" - ");
result += _pPublicInterface->getClassName(); result += _pPublicInterface->getClassName();
if(_isAdministrator) if (_isAdministrator)
result += TEXT(" [Administrator]"); result += TEXT(" [Administrator]");
::SendMessage(_pPublicInterface->getHSelf(), WM_SETTEXT, 0, (LPARAM)result.c_str()); ::SendMessage(_pPublicInterface->getHSelf(), WM_SETTEXT, 0, (LPARAM)result.c_str());
@ -2942,7 +2927,7 @@ size_t Notepad_plus::getCurrentDocCharCount(UniMode u)
unsigned char* buf = (unsigned char*)_pEditView->execute(SCI_GETCHARACTERPOINTER); // Scintilla doc said the pointer can be invalidated by any other "execute" unsigned char* buf = (unsigned char*)_pEditView->execute(SCI_GETCHARACTERPOINTER); // Scintilla doc said the pointer can be invalidated by any other "execute"
#ifdef _OPENMP // parallel counting of characters with OpenMP #ifdef _OPENMP // parallel counting of characters with OpenMP
if(endpos > 50000) // starting threads takes time; for small files it is better to simply count in one thread if (endpos > 50000) // starting threads takes time; for small files it is better to simply count in one thread
{ {
#pragma omp parallel reduction(+: result) #pragma omp parallel reduction(+: result)
{ {
@ -4585,7 +4570,7 @@ bool Notepad_plus::dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix) {
TCHAR savePath[MAX_PATH] = {0}; TCHAR savePath[MAX_PATH] = {0};
//rescue primary //rescue primary
for(int i = 0; i < MainFileManager->getNrBuffers(); ++i) { for (int i = 0; i < MainFileManager->getNrBuffers(); ++i) {
Buffer * docbuf = MainFileManager->getBufferByIndex(i); Buffer * docbuf = MainFileManager->getBufferByIndex(i);
if (!docbuf->isDirty()) //skip saved documents if (!docbuf->isDirty()) //skip saved documents
continue; continue;
@ -4763,7 +4748,7 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
if (mask & (BufferChangeDirty|BufferChangeFilename)) if (mask & (BufferChangeDirty|BufferChangeFilename))
{ {
if(mask & BufferChangeFilename) if (mask & BufferChangeFilename)
command(IDM_VIEW_REFRESHTABAR); command(IDM_VIEW_REFRESHTABAR);
checkDocState(); checkDocState();
setTitle(); setTitle();
@ -5153,7 +5138,7 @@ bool Notepad_plus::reloadLang()
vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts(); vector<CommandShortcut> & shortcuts = pNppParam->getUserShortcuts();
len = shortcuts.size(); len = shortcuts.size();
for(size_t i = 0; i < len; ++i) for (size_t i = 0; i < len; ++i)
{ {
CommandShortcut & csc = shortcuts[i]; CommandShortcut & csc = shortcuts[i];
::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND); ::GetMenuString(_mainMenuHandle, csc.getID(), menuName, 64, MF_BYCOMMAND);
@ -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,239 +5490,246 @@ 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."}, {
{"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."}, {"Notepad++", "Good programmers use Notepad++ to code.\nExtreme programmers use MS Word to code, in Comic Sans, center aligned."},
{"L. Peter Deutsch", "To iterate is human, to recurse divine."}, {"Martin Golding", "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."},
{"Seymour Cray", "The trouble with programmers is that you can never tell what a programmer is doing until it's too late."}, {"L. Peter Deutsch", "To iterate is human, to recurse divine."},
{"Brian Kernighan", "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."}, {"Seymour Cray", "The trouble with programmers is that you can never tell what a programmer is doing until it's too late."},
{"Alan Kay", "Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves."}, {"Brian Kernighan", "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."},
{"Bill Gates", "Measuring programming progress by lines of code is like measuring aircraft building progress by weight."}, {"Alan Kay", "Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves."},
{"Christopher Thompson", "Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday's code."}, {"Bill Gates", "Measuring programming progress by lines of code is like measuring aircraft building progress by weight."},
{"Vidiu Platon", "I don't care if it works on your machine! We are not shipping your machine!"}, {"Christopher Thompson", "Sometimes it pays to stay in bed on Monday, rather than spending the rest of the week debugging Monday's code."},
{"Edward V Berard", "Walking on water and developing software from a specification are easy if both are frozen."}, {"Vidiu Platon", "I don't care if it works on your machine! We are not shipping your machine!"},
{"pixadel", "Fine, Java MIGHT be a good example of what a programming language should be like. But Java applications are good examples of what applications SHOULDN'T be like."}, {"Edward V Berard", "Walking on water and developing software from a specification are easy if both are frozen."},
{"Oktal", "I think Microsoft named .Net so it wouldn't show up in a Unix directory listing."}, {"pixadel", "Fine, Java MIGHT be a good example of what a programming language should be like. But Java applications are good examples of what applications SHOULDN'T be like."},
{"Bjarne Stroustrup", "In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg."}, {"Oktal", "I think Microsoft named .Net so it wouldn't show up in a Unix directory listing."},
{"Mosher's Law of Software Engineering", "Don't worry if it doesn't work right. If everything did, you'd be out of a job."}, {"Bjarne Stroustrup", "In C++ it's harder to shoot yourself in the foot, but when you do, you blow off your whole leg."},
{"Bob Gray", "Writing in C or C++ is like running a chain saw with all the safety guards removed."}, {"Mosher's Law of Software Engineering", "Don't worry if it doesn't work right. If everything did, you'd be out of a job."},
{"Roberto Waltman", "In the one and only true way. The object-oriented version of \"Spaghetti code\" is, of course, \"Lasagna code\". (Too many layers)"}, {"Bob Gray", "Writing in C or C++ is like running a chain saw with all the safety guards removed."},
{"Gavin Russell Baker", "C++ : Where friends have access to your private members."}, {"Roberto Waltman", "In the one and only true way. The object-oriented version of \"Spaghetti code\" is, of course, \"Lasagna code\". (Too many layers)"},
{"Linus Torvalds", "Software is like sex: It's better when it's free."}, {"Gavin Russell Baker", "C++ : Where friends have access to your private members."},
{"Cult of vi", "Emacs is a great operating system, lacking only a decent editor."}, {"Linus Torvalds", "Software is like sex: It's better when it's free."},
{"Church of Emacs", "vi has two modes - \"beep repeatedly\" and \"break everything\"."}, {"Cult of vi", "Emacs is a great operating system, lacking only a decent editor."},
{"Steve Jobs", "Picasso had a saying: \"Good artists copy, great artists steal.\".\nWe have always been shameless about stealing great ideas."}, {"Church of Emacs", "vi has two modes - \"beep repeatedly\" and \"break everything\"."},
{"brotips #1001", "Do everything for greatness, not money. Money follows greatness."}, {"Steve Jobs", "Picasso had a saying: \"Good artists copy, great artists steal.\".\nWe have always been shameless about stealing great ideas."},
{"brotips #1212", "Cheating is like eating fast food: you do it, you enjoy it, and then you feel like shit."}, {"brotips #1001", "Do everything for greatness, not money. Money follows greatness."},
{"Robin Williams", "God gave men both a penis and a brain, but unfortunately not enough blood supply to run both at the same time."}, {"brotips #1212", "Cheating is like eating fast food: you do it, you enjoy it, and then you feel like shit."},
{"Darth Vader", "You don't get to 500 million star systems without making a few enemies."}, {"Robin Williams", "God gave men both a penis and a brain, but unfortunately not enough blood supply to run both at the same time."},
{"Doug Linder", "A good programmer is someone who always looks both ways before crossing a one-way street."}, {"Darth Vader", "You don't get to 500 million star systems without making a few enemies."},
{"Jean-Claude van Damme", "A cookie has no soul, it's just a cookie. But before it was milk and eggs.\nAnd in eggs there's the potential for life."}, {"Doug Linder", "A good programmer is someone who always looks both ways before crossing a one-way street."},
{"Michael Feldman", "Java is, in many ways, C++--."}, {"Jean-Claude van Damme", "A cookie has no soul, it's just a cookie. But before it was milk and eggs.\nAnd in eggs there's the potential for life."},
{"Don Ho", "Je mange donc je chie."}, {"Michael Feldman", "Java is, in many ways, C++--."},
{"Don Ho #2", "RTFM is the true path of every developer.\nBut it would happen only if there's no way out."}, {"Don Ho", "Je mange donc je chie."},
{"Don Ho #3", "Smartphone is the best invention of 21st century for avoiding the eyes contact while crossing people you know on the street."}, {"Don Ho #2", "RTFM is the true path of every developer.\nBut it would happen only if there's no way out."},
{"Anonymous #1", "Does your ass ever get jealous of all the shit that comes out of your month?"}, {"Don Ho #3", "Smartphone is the best invention of 21st century for avoiding the eyes contact while crossing people you know on the street."},
{"Anonymous #2", "Before sex, you help each other get naked, after sex you only dress yourself.\nMoral of the story: in life no one helps you once you're fucked."}, {"Anonymous #1", "Does your ass ever get jealous of all the shit that comes out of your month?"},
{"Anonymous #3", "I'm not totally useless. I can be used as a bad example."}, {"Anonymous #2", "Before sex, you help each other get naked, after sex you only dress yourself.\nMoral of the story: in life no one helps you once you're fucked."},
{"Anonymous #4", "Life is too short to remove USB safely."}, {"Anonymous #3", "I'm not totally useless. I can be used as a bad example."},
{"Anonymous #5", "\"SEX\" is not the answer.\nSex is the question, \"YES\" is the answer."}, {"Anonymous #4", "Life is too short to remove USB safely."},
{"Anonymous #6", "Going to Mc Donald's for a salad is like going to a whore for a hug."}, {"Anonymous #5", "\"SEX\" is not the answer.\nSex is the question, \"YES\" is the answer."},
{"Anonymous #7", "I need a six month holiday, TWICE A YEAR!"}, {"Anonymous #6", "Going to Mc Donald's for a salad is like going to a whore for a hug."},
{"Anonymous #8", "Everything is a knife if you're strong enough."}, {"Anonymous #7", "I need a six month holiday, TWICE A YEAR!"},
{"Anonymous #9", "I just read a list of \"the 100 things to do before you die\". I'm pretty surprised \"yell for help\" wasn't one of them..."}, {"Anonymous #8", "Everything is a knife if you're strong enough."},
{"Anonymous #10", "Roses are red,\nViolets are red,\nTulips are red,\nBushes are red,\nTrees are red,\nHOLY SHIT MY\nGARDEN'S ON FIRE!!"}, {"Anonymous #9", "I just read a list of \"the 100 things to do before you die\". I'm pretty surprised \"yell for help\" wasn't one of them..."},
{"Anonymous #11", "We stopped checking for monsters under our bed, when we realized they were inside us."}, {"Anonymous #10", "Roses are red,\nViolets are red,\nTulips are red,\nBushes are red,\nTrees are red,\nHOLY SHIT MY\nGARDEN'S ON FIRE!!"},
{"Anonymous #12", "I would rather check my facebook than face my checkbook."}, {"Anonymous #11", "We stopped checking for monsters under our bed, when we realized they were inside us."},
{"Anonymous #13", "Whoever says Paper beats Rock is an idiot. Next time I see someone say that I will throw a rock at them while they hold up a sheet of paper."}, {"Anonymous #12", "I would rather check my facebook than face my checkbook."},
{"Anonymous #14", "A better world is where chickens can cross the road without having their motives questioned."}, {"Anonymous #13", "Whoever says Paper beats Rock is an idiot. Next time I see someone say that I will throw a rock at them while they hold up a sheet of paper."},
{"Anonymous #15", "If I didn't drink, how would my friends know I love them at 2 AM?"}, {"Anonymous #14", "A better world is where chickens can cross the road without having their motives questioned."},
{"Anonymous #16", "What you do after sex?\n A. Smoke a cigarette\n B. Kiss your partener\n C. Clear browser history\n"}, {"Anonymous #15", "If I didn't drink, how would my friends know I love them at 2 AM?"},
{"Anonymous #17", "All you need is love,\nall you want is sex,\nall you have is porn.\n"}, {"Anonymous #16", "What you do after sex?\n A. Smoke a cigarette\n B. Kiss your partener\n C. Clear browser history\n"},
{"Anonymous #18", "Never get into fights with ugly people, they have nothing to lose."}, {"Anonymous #17", "All you need is love,\nall you want is sex,\nall you have is porn.\n"},
{"Anonymous #19", "F_CK: All I need is U."}, {"Anonymous #18", "Never get into fights with ugly people, they have nothing to lose."},
{"Anonymous #20", "Never make eye contact while eating a banana."}, {"Anonymous #19", "F_CK: All I need is U."},
{"Anonymous #21", "I love my sixpack so much, I protect it with a layer of fat."}, {"Anonymous #20", "Never make eye contact while eating a banana."},
{"Anonymous #22", "\"It's impossible.\" said pride.\n\"It's risky.\" said experience.\n\"It's pointless.\" said reason.\n\"Give it a try.\" whispered the heart.\n...\n\"What the hell was that?!?!?!?!?!\" shouted the anus two minutes later."}, {"Anonymous #21", "I love my sixpack so much, I protect it with a layer of fat."},
{"Anonymous #23", "Everybody talks about leaving a better planet for the children.\nWhy nobody tries to leave better children to the planet?"}, {"Anonymous #22", "\"It's impossible.\" said pride.\n\"It's risky.\" said experience.\n\"It's pointless.\" said reason.\n\"Give it a try.\" whispered the heart.\n...\n\"What the hell was that?!?!?!?!?!\" shouted the anus two minutes later."},
{"Anonymous #24", "An Architect's dream is an Engineer's nightmare."}, {"Anonymous #23", "Everybody talks about leaving a better planet for the children.\nWhy nobody tries to leave better children to the planet?"},
{"Anonymous #25", "In a way, I feel sorry for the kids of this generation.\nThey'll have parents who know how to check browser history."}, {"Anonymous #24", "An Architect's dream is an Engineer's nightmare."},
{"Anonymous #26", "I would never bungee jump.\nI came into this world because of a broken rubber, and I'm not going out cause of one."}, {"Anonymous #25", "In a way, I feel sorry for the kids of this generation.\nThey'll have parents who know how to check browser history."},
{"Anonymous #27", "I don't have a problem with caffeine.\nI have a problem without caffeine."}, {"Anonymous #26", "I would never bungee jump.\nI came into this world because of a broken rubber, and I'm not going out cause of one."},
{"Anonymous #28", "Why 6 afraid of 7?\nBecause 7 8 9 (seven ate nine) while 6 and 9 were flirting."}, {"Anonymous #27", "I don't have a problem with caffeine.\nI have a problem without caffeine."},
{"Anonymous #30", "Why do Java developers wear glasses?\nBecause they don't C#."}, {"Anonymous #28", "Why 6 afraid of 7?\nBecause 7 8 9 (seven ate nine) while 6 and 9 were flirting."},
{"Anonymous #31", "A baby's laughter is one of the most beautiful sounds you will ever hear. Unless it's 3 AM. And you're home alone. And you don't have a baby."}, {"Anonymous #30", "Why do Java developers wear glasses?\nBecause they don't C#."},
{"Anonymous #32", "Two bytes meet. The first byte asks, \"You look terrible. Are you OK?\"\nThe second byte replies, \"No, just feeling a bit off.\""}, {"Anonymous #31", "A baby's laughter is one of the most beautiful sounds you will ever hear. Unless it's 3 AM. And you're home alone. And you don't have a baby."},
{"Anonymous #33", "Programmer - an organism that turns coffee into software."}, {"Anonymous #32", "Two bytes meet. The first byte asks, \"You look terrible. Are you OK?\"\nThe second byte replies, \"No, just feeling a bit off.\""},
{"Anonymous #34", "It's not a bug - it's an undocumented feature."}, {"Anonymous #33", "Programmer - an organism that turns coffee into software."},
{"Anonymous #35", "Should array index start at 0 or 1?\nMy compromised solution is 0.5"}, {"Anonymous #34", "It's not a bug - it's an undocumented feature."},
{"Anonymous #36", "Every single time when I'm about to hug someone extremely sexy, I hit the mirror."}, {"Anonymous #35", "Should array index start at 0 or 1?\nMy compromised solution is 0.5"},
{"Anonymous #37", "My software never has bugs. It just develops random features."}, {"Anonymous #36", "Every single time when I'm about to hug someone extremely sexy, I hit the mirror."},
{"Anonymous #38", "LISP = Lots of Irritating Silly Parentheses."}, {"Anonymous #37", "My software never has bugs. It just develops random features."},
{"Anonymous #39", "Perl, the only language that looks the same before and after RSA encryption."}, {"Anonymous #38", "LISP = Lots of Irritating Silly Parentheses."},
{"Anonymous #40", "People ask me why, as an atheist, I still say: OH MY GOD.\nIt makes perfect sense: We say \"Oh my God\" when something is UNBELIEVABLE."}, {"Anonymous #39", "Perl, the only language that looks the same before and after RSA encryption."},
{"Anonymous #41", "1. Dig a hole.\n2. Name it love.\n3. Watch people falling in love.\n"}, {"Anonymous #40", "People ask me why, as an atheist, I still say: OH MY GOD.\nIt makes perfect sense: We say \"Oh my God\" when something is UNBELIEVABLE."},
{"Anonymous #42", "Don't think of yourself as an ugly person.\nThink of yourself as a beautiful monkey."}, {"Anonymous #41", "1. Dig a hole.\n2. Name it love.\n3. Watch people falling in love.\n"},
{"Anonymous #43", "Afraid to die alone?\nBecome a bus driver."}, {"Anonymous #42", "Don't think of yourself as an ugly person.\nThink of yourself as a beautiful monkey."},
{"Anonymous #44", "The first 5 days after the weekend are always the hardest."}, {"Anonymous #43", "Afraid to die alone?\nBecome a bus driver."},
{"Anonymous #45", "Rhinos are just fat unicorns."}, {"Anonymous #44", "The first 5 days after the weekend are always the hardest."},
{"Anonymous #46", "Today, I asked a girl out. She replied, \"Sorry, I'm suddenly a lesbian.\" FML"}, {"Anonymous #45", "Rhinos are just fat unicorns."},
{"Anonymous #47", "Kids are like fart.\nYou can only stand yours."}, {"Anonymous #46", "Today, I asked a girl out. She replied, \"Sorry, I'm suddenly a lesbian.\" FML"},
{"Anonymous #48", "If you were born in Israel, you'd probably be Jewish.\nIf you were born in Saudi Arabia, you'd probably be Muslim.\nIf you were born in India, you'd probably be Hindu.\nBut because you were born in North America, you're Christian.\nYour faith is not inspired by some divine, constant truth.\nIt's simply geography."}, {"Anonymous #47", "Kids are like fart.\nYou can only stand yours."},
{"Anonymous #49", "There are 2 types of people in this world:\nPeople who say they pee in the shower, and the dirty fucking liars."}, {"Anonymous #48", "If you were born in Israel, you'd probably be Jewish.\nIf you were born in Saudi Arabia, you'd probably be Muslim.\nIf you were born in India, you'd probably be Hindu.\nBut because you were born in North America, you're Christian.\nYour faith is not inspired by some divine, constant truth.\nIt's simply geography."},
{"Anonymous #50", "London 2012 Olympic Games - A bunch of countries coming across the ocean to put their flags in britain and try to get a bunch of gold... it's like history but opposite."}, {"Anonymous #49", "There are 2 types of people in this world:\nPeople who say they pee in the shower, and the dirty fucking liars."},
{"Anonymous #51", "I don't need a stable relationship,\nI just need a stable Internet connection."}, {"Anonymous #50", "London 2012 Olympic Games - A bunch of countries coming across the ocean to put their flags in britain and try to get a bunch of gold... it's like history but opposite."},
{"Anonymous #52", "What's the difference between religion and bullshit?\nThe bull."}, {"Anonymous #51", "I don't need a stable relationship,\nI just need a stable Internet connection."},
{"Anonymous #53", "Today, as I was waiting for my girlfriend in the street, I saw a woman who looked a lot like her. I ran towards her, my arms in the air ready to give her a hug, only to realise it wasn't her. I then had to pass the woman, my arms in the air, still running. FML"}, {"Anonymous #52", "What's the difference between religion and bullshit?\nThe bull."},
{"Anonymous #54", "Today, I finally got my hands on the new iPhone 5, after I pulled it out of a patient's rectum. FML"}, {"Anonymous #53", "Today, as I was waiting for my girlfriend in the street, I saw a woman who looked a lot like her. I ran towards her, my arms in the air ready to give her a hug, only to realise it wasn't her. I then had to pass the woman, my arms in the air, still running. FML"},
{"Anonymous #55", "Violent video games won't change our behaviour.\nIf people were influenced by video games, then the majority of Facebook users would be farmers right now."}, {"Anonymous #54", "Today, I finally got my hands on the new iPhone 5, after I pulled it out of a patient's rectum. FML"},
{"Anonymous #56", "Religion is like circumcision.\nIf you wait until someone is 21 to tell them about it they probably won't be interested."}, {"Anonymous #55", "Violent video games won't change our behaviour.\nIf people were influenced by video games, then the majority of Facebook users would be farmers right now."},
{"Anonymous #57", "No, no, no, I'm not insulting you.\nI'm describing you."}, {"Anonymous #56", "Religion is like circumcision.\nIf you wait until someone is 21 to tell them about it they probably won't be interested."},
{"Anonymous #58", "I bought a dog once. Named him \"Stay\".\n\"Come here, Stay.\"\nHe's insane now."}, {"Anonymous #57", "No, no, no, I'm not insulting you.\nI'm describing you."},
{"Anonymous #60", "Yesterday I named my Wifi network \"hack me if you can\"\nToday when I woke up it was changed to \"challenge accepted\"."}, {"Anonymous #58", "I bought a dog once. Named him \"Stay\".\n\"Come here, Stay.\"\nHe's insane now."},
{"Anonymous #61", "Your mother is so fat,\nthe recursive function computing her mass causes a stack overflow."}, {"Anonymous #60", "Yesterday I named my Wifi network \"hack me if you can\"\nToday when I woke up it was changed to \"challenge accepted\"."},
{"Anonymous #62", "Oral sex makes my day, but anal sex makes my hole weak."}, {"Anonymous #61", "Your mother is so fat,\nthe recursive function computing her mass causes a stack overflow."},
{"Anonymous #63", "I'm not saying I am Batman, I am just saying no one has ever seen me and Batman in the same room together."}, {"Anonymous #62", "Oral sex makes my day, but anal sex makes my hole weak."},
{"Anonymous #64", "I took a taxi today.\nThe driver told me \"I love my job, I own this car, I've got my own business, I'm my own boss, NO ONE tells me what to do!\"\nI said \"TURN LEFT HERE\".\n"}, {"Anonymous #63", "I'm not saying I am Batman, I am just saying no one has ever seen me and Batman in the same room together."},
{"Anonymous #65", "A man without God is like a fish without a bicycle."}, {"Anonymous #64", "I took a taxi today.\nThe driver told me \"I love my job, I own this car, I've got my own business, I'm my own boss, NO ONE tells me what to do!\"\nI said \"TURN LEFT HERE\".\n"},
{"Anonymous #66", "I hate how spiders just sit there on the walls and act like they pay rent!"}, {"Anonymous #65", "A man without God is like a fish without a bicycle."},
{"Anonymous #67", "Whenever someone starts a sentence by saying \"I'm not racist...\",they are about to say something super racist."}, {"Anonymous #66", "I hate how spiders just sit there on the walls and act like they pay rent!"},
{"Anonymous #68", "I'm not laughing at you, I'm laughing with you, you're just not laughing."}, {"Anonymous #67", "Whenever someone starts a sentence by saying \"I'm not racist...\",they are about to say something super racist."},
{"Anonymous #69", "Women need a reason to have sex. Men just need a place."}, {"Anonymous #68", "I'm not laughing at you, I'm laughing with you, you're just not laughing."},
{"Anonymous #70", "If abortion is murder then are condoms kidnapping?"}, {"Anonymous #69", "Women need a reason to have sex. Men just need a place."},
{"Anonymous #71", "Men also have feelings.\nFor example, they can feel hungry."}, {"Anonymous #70", "If abortion is murder then are condoms kidnapping?"},
{"Anonymous #72", "Project Manager:\nA person who thinks 9 women can deliver a baby in 1 month."}, {"Anonymous #71", "Men also have feelings.\nFor example, they can feel hungry."},
{"Anonymous #73", "If you try and don't succeed, cheat. Repeat until caught. Then lie."}, {"Anonymous #72", "Project Manager:\nA person who thinks 9 women can deliver a baby in 1 month."},
{"Anonymous #74", "Olympics is the stupidest thing.\nPeople are so proud to be competing for their country.\nThey play their stupid song and raise some dumb flags.\nI'd love to see no flags raised, no song, no mention of country.\nOnly people."}, {"Anonymous #73", "If you try and don't succeed, cheat. Repeat until caught. Then lie."},
{"Anonymous #75", "I think therefore I am\nnot religious."}, {"Anonymous #74", "Olympics is the stupidest thing.\nPeople are so proud to be competing for their country.\nThey play their stupid song and raise some dumb flags.\nI'd love to see no flags raised, no song, no mention of country.\nOnly people."},
{"Anonymous #76", "Even if being gay were a choice, so what?\nPeople choose to be assholes and they can get married."}, {"Anonymous #75", "I think therefore I am\nnot religious."},
{"Anonymous #77", "Governments are like diapers.\nThey should be changed often, and for the same reason."}, {"Anonymous #76", "Even if being gay were a choice, so what?\nPeople choose to be assholes and they can get married."},
{"Anonymous #78", "If you expect the world to be fair with you because you are fair, you're fooling yourself.\nThat's like expecting the lion not to eat you because you didn't eat him."}, {"Anonymous #77", "Governments are like diapers.\nThey should be changed often, and for the same reason."},
{"Anonymous #79", "I'm a creationist.\nI believe man create God."}, {"Anonymous #78", "If you expect the world to be fair with you because you are fair, you're fooling yourself.\nThat's like expecting the lion not to eat you because you didn't eat him."},
{"Anonymous #80", "Let's eat kids.\nLet's eat, kids.\n\nUse a comma.\nSave lives."}, {"Anonymous #79", "I'm a creationist.\nI believe man create God."},
{"Anonymous #81", "A male engineering student was crossing a road one day when a frog called out to him and said, \"If you kiss me, I'll turn into a beautiful princess.\" He bent over, picked up the frog, and put it in his pocket.\n\nThe frog spoke up again and said, \"If you kiss me and turn me back into a beautiful princess, I will stay with you for one week.\" The engineering student took the frog out of his pocket, smiled at it; and returned it to his pocket.\n\nThe frog then cried out, \"If you kiss me and turn me back into a princess, I'll stay with you and do ANYTHING you want.\" Again the boy took the frog out, smiled at it, and put it back into his pocket.\n\nFinally, the frog asked, \"What is the matter? I've told you I'm a beautiful princess, that I'll stay with you for a week and do anything you want. Why won't you kiss me?\" The boy said, \"Look I'm an engineer. I don't have time for a girlfriend, but a talking frog is cool.\"\n"}, {"Anonymous #80", "Let's eat kids.\nLet's eat, kids.\n\nUse a comma.\nSave lives."},
{"Anonymous #82", "Programmers never die.\nThey just go offline."}, {"Anonymous #81", "A male engineering student was crossing a road one day when a frog called out to him and said, \"If you kiss me, I'll turn into a beautiful princess.\" He bent over, picked up the frog, and put it in his pocket.\n\nThe frog spoke up again and said, \"If you kiss me and turn me back into a beautiful princess, I will stay with you for one week.\" The engineering student took the frog out of his pocket, smiled at it; and returned it to his pocket.\n\nThe frog then cried out, \"If you kiss me and turn me back into a princess, I'll stay with you and do ANYTHING you want.\" Again the boy took the frog out, smiled at it, and put it back into his pocket.\n\nFinally, the frog asked, \"What is the matter? I've told you I'm a beautiful princess, that I'll stay with you for a week and do anything you want. Why won't you kiss me?\" The boy said, \"Look I'm an engineer. I don't have time for a girlfriend, but a talking frog is cool.\"\n"},
{"Anonymous #83", "Copy from one, it's plagiarism.\nCopy from two, it's research."}, {"Anonymous #82", "Programmers never die.\nThey just go offline."},
{"Anonymous #84", "Saying that Java is nice because it works on all OSes is like saying that anal sex is nice because it works on all genders."}, {"Anonymous #83", "Copy from one, it's plagiarism.\nCopy from two, it's research."},
{"Anonymous #85", "Race, religion, ethnic pride and nationalism etc... does nothing but teach you how to hate people that you've never met."}, {"Anonymous #84", "Saying that Java is nice because it works on all OSes is like saying that anal sex is nice because it works on all genders."},
{"Anonymous #86", "Farts are just the ghosts of the things we eat."}, {"Anonymous #85", "Race, religion, ethnic pride and nationalism etc... does nothing but teach you how to hate people that you've never met."},
{"Anonymous #87", "I promised I would never kill someone who had my blood.\nBut that mosquito made me break my word."}, {"Anonymous #86", "Farts are just the ghosts of the things we eat."},
//{"Anonymous #88", ""}, {"Anonymous #87", "I promised I would never kill someone who had my blood.\nBut that mosquito made me break my word."},
{"Anonymous #89", "I'm drunk and you're still ugly."}, //{"Anonymous #88", ""},
{"Anonymous #90", "Clapping:\n(verb)\nRepeatedly high-fiving yourself for someone else's accomplishments."}, {"Anonymous #89", "I'm drunk and you're still ugly."},
{"Anonymous #91", "CV: ctrl-C, ctrl-V"}, {"Anonymous #90", "Clapping:\n(verb)\nRepeatedly high-fiving yourself for someone else's accomplishments."},
{"Anonymous #92", "Mondays are not so bad.\nIt's your job that sucks."}, {"Anonymous #91", "CV: ctrl-C, ctrl-V"},
{"Anonymous #93", "[In a job interview]\nInterviewer: What's your greatest weakness?\nCandidate: Honesty.\nInterviewer: I don't think honesty is a weakness.\nCandidate: I don't give a fuck what you think."}, {"Anonymous #92", "Mondays are not so bad.\nIt's your job that sucks."},
{"Anonymous #94", "Hey, I just met you\nAnd this is crazy\nHere's my number 127.0.0.1\nPing me maybe?"}, {"Anonymous #93", "[In a job interview]\nInterviewer: What's your greatest weakness?\nCandidate: Honesty.\nInterviewer: I don't think honesty is a weakness.\nCandidate: I don't give a fuck what you think."},
{"Anonymous #95", "YES!\nI'm a programmer, and\nNO!\nIt doesn't mean that I have to fix your PC!"}, {"Anonymous #94", "Hey, I just met you\nAnd this is crazy\nHere's my number 127.0.0.1\nPing me maybe?"},
{"Anonymous #96", "Code for 6 minutes, debug for 6 hours."}, {"Anonymous #95", "YES!\nI'm a programmer, and\nNO!\nIt doesn't mean that I have to fix your PC!"},
{"Anonymous #97", "Real Programmers don't comment their code.\nIf it was hard to write, it should be hard to read."}, {"Anonymous #96", "Code for 6 minutes, debug for 6 hours."},
{"Anonymous #98", "My neighbours listen to good music.\nWhether they like it or not."}, {"Anonymous #97", "Real Programmers don't comment their code.\nIf it was hard to write, it should be hard to read."},
{"Anonymous #99", "I've been using Vim for about 2 years now,\nmostly because I can't figure out how to exit it."}, {"Anonymous #98", "My neighbours listen to good music.\nWhether they like it or not."},
{"Anonymous #100", "Dear YouTube,\nI can deal with Ads.\nI can deal with Buffer.\nBut when Ads buffer, I suffer."}, {"Anonymous #99", "I've been using Vim for about 2 years now,\nmostly because I can't figure out how to exit it."},
{"Anonymous #101", "It's always sad when a man and his dick share only one brain...\nand it turns out to be the dick's."}, {"Anonymous #100", "Dear YouTube,\nI can deal with Ads.\nI can deal with Buffer.\nBut when Ads buffer, I suffer."},
{"Anonymous #102", "If IE is brave enough to ask you to set it as your default browser,\ndon't tell me you dare not ask a girl out."}, {"Anonymous #101", "It's always sad when a man and his dick share only one brain...\nand it turns out to be the dick's."},
{"Anonymous #103", "Turn on your brain, turn off TV."}, {"Anonymous #102", "If IE is brave enough to ask you to set it as your default browser,\ndon't tell me you dare not ask a girl out."},
{"Anonymous #104", "The main idea of \"Inception\":\nif you run a VM inside a VM inside a VM inside a VM inside a VM,\neverything will be very slow."}, {"Anonymous #103", "Turn on your brain, turn off TV."},
//{"Anonymous #105", ""}, {"Anonymous #104", "The main idea of \"Inception\":\nif you run a VM inside a VM inside a VM inside a VM inside a VM,\neverything will be very slow."},
{"Anonymous #106", "When I die, I want to go peacefully like my grandfather did, in his sleep\n- not screaming, like the passengers in his car."}, //{"Anonymous #105", ""},
{"Anonymous #107", "Remember, YOUR God is real.\nAll those other Gods are ridiculous, made-up nonsense.\nBut not yours.\nYour God is real. Whichever one that is."}, {"Anonymous #106", "When I die, I want to go peacefully like my grandfather did, in his sleep\n- not screaming, like the passengers in his car."},
{"Anonymous #108", "I hope Bruce Willis dies of a Viagra overdose,\nThe way you can see the headline:\nBruce Willis, Died Hard"}, {"Anonymous #107", "Remember, YOUR God is real.\nAll those other Gods are ridiculous, made-up nonsense.\nBut not yours.\nYour God is real. Whichever one that is."},
//{"Anonymous #109", ""}, {"Anonymous #108", "I hope Bruce Willis dies of a Viagra overdose,\nThe way you can see the headline:\nBruce Willis, Died Hard"},
{"Anonymous #110", "A programmer had a problem, so he decided to use threads.\nNow 2 has. He problems."}, //{"Anonymous #109", ""},
{"Anonymous #111", "I love how the internet has improved people's grammar far more than any English teacher has.\nIf you write \"your\" instead of \"you're\" in English class, all you get is a red mark.\nMess up on the internet, and may God have mercy on your soul."}, {"Anonymous #110", "A programmer had a problem, so he decided to use threads.\nNow 2 has. He problems."},
{"Anonymous #112", "#hulk {\n height: 200%;\n width: 200%;\n color: green;\n}"}, {"Anonymous #111", "I love how the internet has improved people's grammar far more than any English teacher has.\nIf you write \"your\" instead of \"you're\" in English class, all you get is a red mark.\nMess up on the internet, and may God have mercy on your soul."},
{"Anonymous #113", "Open source is communism.\nAt least it is what communism was meant to be."}, {"Anonymous #112", "#hulk {\n height: 200%;\n width: 200%;\n color: green;\n}"},
{"Anonymous #114", "How can you face your problem if your problem is your face?"}, {"Anonymous #113", "Open source is communism.\nAt least it is what communism was meant to be."},
{"Anonymous #115", "YOLOLO:\nYou Only LOL Once."}, {"Anonymous #114", "How can you face your problem if your problem is your face?"},
{"Anonymous #116", "Every exit is an entrance to new experiences."}, {"Anonymous #115", "YOLOLO:\nYou Only LOL Once."},
{"Anonymous #117", "A Native American was asked:\n\"Do you celebrate Columbus day?\"\nHe replied:\n\"I don't know, do Jews celebrate Hitler's birthday?\""}, {"Anonymous #116", "Every exit is an entrance to new experiences."},
{"Anonymous #118", "I love necrophilia, but i can't stand the awkward silences."}, {"Anonymous #117", "A Native American was asked:\n\"Do you celebrate Columbus day?\"\nHe replied:\n\"I don't know, do Jews celebrate Hitler's birthday?\""},
{"Anonymous #119", "\"I'm gonna Google that. BING that, Bing that, sorry.\"\n- The CEO of Bing (many times per day still)"}, {"Anonymous #118", "I love necrophilia, but i can't stand the awkward silences."},
{"Anonymous #120", "Life is what happens to you while you're looking at your smartphone."}, {"Anonymous #119", "\"I'm gonna Google that. BING that, Bing that, sorry.\"\n- The CEO of Bing (many times per day still)"},
{"Anonymous #121", "Thing to do today:\n1. Get up\n2. Go back to bed"}, {"Anonymous #120", "Life is what happens to you while you're looking at your smartphone."},
{"Anonymous #122", "Nerd?\nI prefer the term \"Intellectual badass\"."}, {"Anonymous #121", "Thing to do today:\n1. Get up\n2. Go back to bed"},
{"Anonymous #123", "How can you face your problem if your problem is your face?"}, {"Anonymous #122", "Nerd?\nI prefer the term \"Intellectual badass\"."},
{"Anonymous #124", "You don't need religion to have morals.\nIf you can't determine right from wrong then you lack empathy, not religion."}, {"Anonymous #123", "How can you face your problem if your problem is your face?"},
{"Anonymous #125", "Pooping with the door opened is the meaning of true freedom."}, {"Anonymous #124", "You don't need religion to have morals.\nIf you can't determine right from wrong then you lack empathy, not religion."},
{"Anonymous #126", "Social media does not make people stupid.\nIt just makes stupid people more visible."}, {"Anonymous #125", "Pooping with the door opened is the meaning of true freedom."},
{"Anonymous #127", "Don't give up your dreams.\nKeep sleeping."}, {"Anonymous #126", "Social media does not make people stupid.\nIt just makes stupid people more visible."},
{"Anonymous #128", "I love sleep.\nNot because I'm lazy.\nBut because my dreams are better than my real life."}, {"Anonymous #127", "Don't give up your dreams.\nKeep sleeping."},
//{"Anonymous #129", ""}, {"Anonymous #128", "I love sleep.\nNot because I'm lazy.\nBut because my dreams are better than my real life."},
{"Anonymous #130", "Common sense is so rare, it's kinda like a superpower..."}, //{"Anonymous #129", ""},
{"Anonymous #131", "The best thing about a boolean is even if you are wrong, you are only off by a bit."}, {"Anonymous #130", "Common sense is so rare, it's kinda like a superpower..."},
{"Anonymous #132", "Benchmarks don't lie, but liars do benchmarks."}, {"Anonymous #131", "The best thing about a boolean is even if you are wrong, you are only off by a bit."},
{"Anonymous #133", "Multitasking: Screwing up several things at once."}, {"Anonymous #132", "Benchmarks don't lie, but liars do benchmarks."},
{"Anonymous #134", "Linux is user friendly.\nIt's just picky about its friends."}, {"Anonymous #133", "Multitasking: Screwing up several things at once."},
{"Anonymous #135", "Theory is when you know something, but it doesn't work.\nPractice is when something works, but you don't know why.\nProgrammers combine theory and practice: nothing works and they don't know why."}, {"Anonymous #134", "Linux is user friendly.\nIt's just picky about its friends."},
{"Anonymous #136", "Documentation is like sex:\nwhen it's good, it's very, very good;\nwhen it's bad, it's better than nothing."}, {"Anonymous #135", "Theory is when you know something, but it doesn't work.\nPractice is when something works, but you don't know why.\nProgrammers combine theory and practice: nothing works and they don't know why."},
{"Anonymous #137", "Home is where you poop most comfortably."}, {"Anonymous #136", "Documentation is like sex:\nwhen it's good, it's very, very good;\nwhen it's bad, it's better than nothing."},
{"Anonymous #138", "Laptop Speakers problem: too quiet for music, too loud for porn."}, {"Anonymous #137", "Home is where you poop most comfortably."},
{"Anonymous #139", "Chinese food to go: $16\nGas to go get the food: $2\nDrove home just to realize they forgot one of your containers: RICELESS"}, {"Anonymous #138", "Laptop Speakers problem: too quiet for music, too loud for porn."},
{"Anonymous #140", "MS Windows is like religion to most people: they are born into it, accept it as default, never consider switching to another."}, {"Anonymous #139", "Chinese food to go: $16\nGas to go get the food: $2\nDrove home just to realize they forgot one of your containers: RICELESS"},
{"Anonymous #141", "To most religious people, the holy books are like a software license (EULA).\nNobody actually reads it. They just scroll to the bottom and click \"I agree\"."}, {"Anonymous #140", "MS Windows is like religion to most people: they are born into it, accept it as default, never consider switching to another."},
{"Anonymous #142", "You are nothing but a number of days,\nwhenever each day passes then part of you has gone."}, {"Anonymous #141", "To most religious people, the holy books are like a software license (EULA).\nNobody actually reads it. They just scroll to the bottom and click \"I agree\"."},
{"Anonymous #143", "If 666 is evil, does that make 25.8069758011 the root of all evil?"}, {"Anonymous #142", "You are nothing but a number of days,\nwhenever each day passes then part of you has gone."},
{"Anonymous #144", "I don't want to sound like a badass but...\nI eject my USB drive without removing it safely."}, {"Anonymous #143", "If 666 is evil, does that make 25.8069758011 the root of all evil?"},
{"Anonymous #145", "feet (noun)\na device used for finding legos in the dark"}, {"Anonymous #144", "I don't want to sound like a badass but...\nI eject my USB drive without removing it safely."},
{"Anonymous #146", "Buy a sheep\nName it \"Relation\"\nNow you have a Relationsheep\n"}, {"Anonymous #145", "feet (noun)\na device used for finding legos in the dark"},
{"Anonymous #147", "I dig, you dig, we dig,\nhe dig, she dig, they dig...\n\nIt's not a beautiful poem,\nbut it's very deep."}, {"Anonymous #146", "Buy a sheep\nName it \"Relation\"\nNow you have a Relationsheep\n"},
{"Anonymous #148", "UNIX command line Russian roulette:\n[ $[ $RANDOM % 6 ] == 0 ] && rm -rf /* || echo *Click*"}, {"Anonymous #147", "I dig, you dig, we dig,\nhe dig, she dig, they dig...\n\nIt's not a beautiful poem,\nbut it's very deep."},
{"Anonymous #149", "unzip, strip, top, less, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep.\n\nNo, it's not porn. It's Unix."}, {"Anonymous #148", "UNIX command line Russian roulette:\n[ $[ $RANDOM % 6 ] == 0 ] && rm -rf /* || echo *Click*"},
{"Anonymous #150", "To understand what recursion is, you must first understand recursion."}, {"Anonymous #149", "unzip, strip, top, less, touch, finger, grep, mount, fsck, more, yes, fsck, fsck, fsck, umount, sleep.\n\nNo, it's not porn. It's Unix."},
{"Anonymous #151", "Q: What's the object-oriented way to become wealthy?\nA: Inheritance."}, {"Anonymous #150", "To understand what recursion is, you must first understand recursion."},
{"Anonymous #152", "A SQL query goes into a bar, walks up to two tables and asks, \"Can I join you?\""}, {"Anonymous #151", "Q: What's the object-oriented way to become wealthy?\nA: Inheritance."},
{"Anonymous #153", "You are not fat, you are just more visible."}, {"Anonymous #152", "A SQL query goes into a bar, walks up to two tables and asks, \"Can I join you?\""},
{"Anonymous #154", "Minimalist\n (. .)\n ) (\n ( Y )\nASCII Art"}, {"Anonymous #153", "You are not fat, you are just more visible."},
{"Louis C.K.", "I'm a good citizen. I'm a good father. I recycle and I masturbate."}, {"Anonymous #154", "Minimalist\n (. .)\n ) (\n ( Y )\nASCII Art"},
{"Mary Oliver", "Someone I loved once gave me a box full of darkness.\nIt took me years to understand that this, too, was a gift."}, {"Louis C.K.", "I'm a good citizen. I'm a good father. I recycle and I masturbate."},
{"Floor", "If you fall, I will be there."}, {"Mary Oliver", "Someone I loved once gave me a box full of darkness.\nIt took me years to understand that this, too, was a gift."},
{"Simon Amstell", "If you have some problem in your life and need to deal with it, then use religion, that's fine.\nI use Google."}, {"Floor", "If you fall, I will be there."},
{"James Bond", "James, James Bond."}, {"Simon Amstell", "If you have some problem in your life and need to deal with it, then use religion, that's fine.\nI use Google."},
{"Albert Einstein", "Only 3 things are infinite:\n1. Universe.\n2. Human Stupidity.\n3. Winrar's free trial."}, {"James Bond", "James, James Bond."},
{"Terry Pratchett", "Artificial Intelligence is no match for natural stupidity."}, {"Albert Einstein", "Only 3 things are infinite:\n1. Universe.\n2. Human Stupidity.\n3. Winrar's free trial."},
{"Stewart Brand", "Once a new technology starts rolling, if you're not part of the steamroller,\nyou're part of the road."}, {"Terry Pratchett", "Artificial Intelligence is no match for natural stupidity."},
{"Sam Redwine", "Software and cathedrals are much the same - first we build them, then we pray."}, {"Stewart Brand", "Once a new technology starts rolling, if you're not part of the steamroller,\nyou're part of the road."},
{"Jan L. A. van de Snepscheut", "In theory, there is no difference between theory and practice. But, in practice, there is."}, {"Sam Redwine", "Software and cathedrals are much the same - first we build them, then we pray."},
{"Jessica Gaston", "One man's crappy software is another man's full time job."}, {"Jan L. A. van de Snepscheut", "In theory, there is no difference between theory and practice. But, in practice, there is."},
{"Barack Obama", "Yes, we scan!"}, {"Jessica Gaston", "One man's crappy software is another man's full time job."},
{"George W. Bush", "Where is my Nobel prize?\nI bombed people too."}, {"Barack Obama", "Yes, we scan!"},
{"Gandhi", "Earth provides enough to satisfy every man's need, but not every man's greed."}, {"George W. Bush", "Where is my Nobel prize?\nI bombed people too."},
{"R. D. Laing", "Life is a sexually transmitted disease and the mortality rate is one hundred percent."}, {"Gandhi", "Earth provides enough to satisfy every man's need, but not every man's greed."},
{"Apple fan boy", "I'll buy a second iPhone 5 and buy a lot of iOS applications so that Apple will be able to buy Samsung (this shitty company)\nto shut it down and all the Apple haters will be forced to have an iPhone. Muhahaha..."}, {"R. D. Laing", "Life is a sexually transmitted disease and the mortality rate is one hundred percent."},
{"Hustle Man", "Politicians are like sperm.\nOne in a million turn out to be an actual human being."}, {"Apple fan boy", "I'll buy a second iPhone 5 and buy a lot of iOS applications so that Apple will be able to buy Samsung (this shitty company)\nto shut it down and all the Apple haters will be forced to have an iPhone. Muhahaha..."},
{"Mark Twain", "Censorship is telling a man he can't have a steak just because a baby can't chew it."}, {"Hustle Man", "Politicians are like sperm.\nOne in a million turn out to be an actual human being."},
{"Friedrich Nietzsche", "There is not enough love and goodness in the world to permit giving any of it away to imaginary beings."}, {"Mark Twain", "Censorship is telling a man he can't have a steak just because a baby can't chew it."},
{"Dhalsim", "Pain is a state of mind and I don't mind your pain."}, {"Friedrich Nietzsche", "There is not enough love and goodness in the world to permit giving any of it away to imaginary beings."},
{"Elie Wiesel", "Human beings can be beautiful or more beautiful,\nthey can be fat or skinny, they can be right or wrong,\nbut illegal? How can a human being be illegal?"}, {"Dhalsim", "Pain is a state of mind and I don't mind your pain."},
{"Dennis Ritchie", "Empty your memory, with a free(), like a pointer.\nIf you cast a pointer to a integer, it becomes the integer.\nIf you cast a pointer to a struct, it becomes the struct.\nThe pointer can crash, and can overflow.\nBe a pointer my friend."}, {"Elie Wiesel", "Human beings can be beautiful or more beautiful,\nthey can be fat or skinny, they can be right or wrong,\nbut illegal? How can a human being be illegal?"},
{"Chewbacca", "Uuuuuuuuuur Ahhhhrrrrrr\nUhrrrr Ahhhhrrrrrr\nAaaarhg..."}, {"Dennis Ritchie", "Empty your memory, with a free(), like a pointer.\nIf you cast a pointer to a integer, it becomes the integer.\nIf you cast a pointer to a struct, it becomes the struct.\nThe pointer can crash, and can overflow.\nBe a pointer my friend."},
{"#JeSuisCharlie", "Freedom of expression is like the air we breathe, we don't feel it, until people take it away from us.\n\nFor this reason, Je suis Charlie, not because I endorse everything they published, but because I cherish the right to speak out freely without risk even when it offends others.\nAnd no, you cannot just take someone's life for whatever he/she expressed.\n\nHence this \"Je suis Charlie\" edition.\n" } {"Chewbacca", "Uuuuuuuuuur Ahhhhrrrrrr\nUhrrrr Ahhhhrrrrrr\nAaaarhg..."},
{"#JeSuisCharlie", "Freedom of expression is like the air we breathe, we don't feel it, until people take it away from us.\n\nFor this reason, Je suis Charlie, not because I endorse everything they published, but because I cherish the right to speak out freely without risk even when it offends others.\nAnd no, you cannot just take someone's life for whatever he/she expressed.\n\nHence this \"Je suis Charlie\" edition.\n" }
}; };
const int nbWtf = 6; const int nbWtf = 6;
char *wtf[nbWtf] = { char* wtf[nbWtf] =
"WTF?!", {
"lol", "WTF?!",
"FAP FAP FAP", "lol",
"ROFL", "FAP FAP FAP",
"OMFG", "ROFL",
"Husband is not an ATM machine!!!" "OMFG",
"Husband is not an ATM machine!!!"
}; };
const int nbIntervalTime = 5; const int nbIntervalTime = 5;
@ -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,13 +6276,15 @@ 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);
else if (selectionEnd <= posEndComment) else if (selectionEnd <= posEndComment)
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() -------------------------------

View File

@ -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,37 +535,46 @@ 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();
if (bookmarkPresent(lineno)) if (bookmarkPresent(lineno))
bookmarkDelete(lineno); bookmarkDelete(lineno);
else else
bookmarkAdd(lineno); bookmarkAdd(lineno);
}; }
void bookmarkNext(bool forwardScan); void bookmarkNext(bool forwardScan);
void bookmarkClearAll() const { void bookmarkClearAll() const
{
_pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK); _pEditView->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK);
}; }
void copyMarkedLines(); void copyMarkedLines();
void cutMarkedLines(); void cutMarkedLines();
@ -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);
}; };