mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-09-23 09:58:34 +02:00
[NEW_FEATURE] Try to catch plugin crash.
[BUG_FIXED] (Author : Jocelyn Legault) Fix some memory leaks. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@545 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
22f7f6651c
commit
d36fd964e4
@ -348,3 +348,95 @@ void PluginsManager::setMenu(HMENU hMenu, const TCHAR *menuName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PluginsManager::runPluginCommand(size_t i)
|
||||||
|
{
|
||||||
|
if (i < _pluginsCommands.size())
|
||||||
|
{
|
||||||
|
if (_pluginsCommands[i]._pFunc != NULL)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
_pluginsCommands[i]._pFunc();
|
||||||
|
} catch (...) {
|
||||||
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT("runPluginCommand(size_t i)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PluginsManager::runPluginCommand(const TCHAR *pluginName, int commandID)
|
||||||
|
{
|
||||||
|
for (size_t i = 0 ; i < _pluginsCommands.size() ; i++)
|
||||||
|
{
|
||||||
|
if (!generic_stricmp(_pluginsCommands[i]._pluginName.c_str(), pluginName))
|
||||||
|
{
|
||||||
|
if (_pluginsCommands[i]._funcID == commandID)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
_pluginsCommands[i]._pFunc();
|
||||||
|
} catch (...) {
|
||||||
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT("runPluginCommand(const TCHAR *pluginName, int commandID)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginsManager::notify(SCNotification *notification)
|
||||||
|
{
|
||||||
|
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
||||||
|
{
|
||||||
|
if (_pluginInfos[i]->_hLib)
|
||||||
|
{
|
||||||
|
// To avoid the plugin change the data in SCNotification
|
||||||
|
// Each notification to pass to a plugin is a copy of SCNotification instance
|
||||||
|
SCNotification scNotif = *notification;
|
||||||
|
try {
|
||||||
|
_pluginInfos[i]->_pBeNotified(&scNotif);
|
||||||
|
} catch (...) {
|
||||||
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT("notify(SCNotification *notification)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PluginsManager::relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
||||||
|
{
|
||||||
|
if (_pluginInfos[i]->_hLib)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
||||||
|
} catch (...) {
|
||||||
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT("relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PluginsManager::relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
const TCHAR * moduleName = (const TCHAR *)wParam;
|
||||||
|
if (!moduleName || !moduleName[0] || !lParam)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
||||||
|
{
|
||||||
|
if (_pluginInfos[i]->_moduleName == moduleName)
|
||||||
|
{
|
||||||
|
if (_pluginInfos[i]->_hLib)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
||||||
|
} catch (...) {
|
||||||
|
pluginCrashAlert(_pluginsCommands[i]._pluginName.c_str(), TEXT("relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam)"));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
@ -86,66 +86,16 @@ public:
|
|||||||
|
|
||||||
bool unloadPlugin(int index, HWND nppHandle);
|
bool unloadPlugin(int index, HWND nppHandle);
|
||||||
|
|
||||||
void runPluginCommand(size_t i) {
|
void runPluginCommand(size_t i);
|
||||||
if (i < _pluginsCommands.size())
|
void runPluginCommand(const TCHAR *pluginName, int commandID);
|
||||||
if (_pluginsCommands[i]._pFunc != NULL)
|
|
||||||
_pluginsCommands[i]._pFunc();
|
|
||||||
};
|
|
||||||
|
|
||||||
void runPluginCommand(const TCHAR *pluginName, int commandID) {
|
|
||||||
for (size_t i = 0 ; i < _pluginsCommands.size() ; i++)
|
|
||||||
{
|
|
||||||
if (!generic_stricmp(_pluginsCommands[i]._pluginName.c_str(), pluginName))
|
|
||||||
{
|
|
||||||
if (_pluginsCommands[i]._funcID == commandID)
|
|
||||||
_pluginsCommands[i]._pFunc();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void addInMenuFromPMIndex(int i);
|
void addInMenuFromPMIndex(int i);
|
||||||
void setMenu(HMENU hMenu, const TCHAR *menuName);
|
void setMenu(HMENU hMenu, const TCHAR *menuName);
|
||||||
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
|
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
|
||||||
|
|
||||||
void notify(SCNotification *notification) {
|
void notify(SCNotification *notification);
|
||||||
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
{
|
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||||
if (_pluginInfos[i]->_hLib)
|
|
||||||
{
|
|
||||||
// To avoid the plugin change the data in SCNotification
|
|
||||||
// Each notification to pass to a plugin is a copy of SCNotification instance
|
|
||||||
SCNotification scNotif = *notification;
|
|
||||||
_pluginInfos[i]->_pBeNotified(&scNotif);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam) {
|
|
||||||
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
|
||||||
{
|
|
||||||
if (_pluginInfos[i]->_hLib)
|
|
||||||
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam) {
|
|
||||||
const TCHAR * moduleName = (const TCHAR *)wParam;
|
|
||||||
if (!moduleName || !moduleName[0] || !lParam)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (size_t i = 0 ; i < _pluginInfos.size() ; i++)
|
|
||||||
{
|
|
||||||
if (_pluginInfos[i]->_moduleName == moduleName)
|
|
||||||
{
|
|
||||||
if (_pluginInfos[i]->_hLib)
|
|
||||||
{
|
|
||||||
_pluginInfos[i]->_pMessageProc(Message, wParam, lParam);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
HMENU getMenuHandle() {
|
HMENU getMenuHandle() {
|
||||||
return _hPluginsMenu;
|
return _hPluginsMenu;
|
||||||
@ -161,6 +111,13 @@ private:
|
|||||||
vector<PluginInfo *> _pluginInfos;
|
vector<PluginInfo *> _pluginInfos;
|
||||||
vector<PluginCommand> _pluginsCommands;
|
vector<PluginCommand> _pluginsCommands;
|
||||||
bool _isDisabled;
|
bool _isDisabled;
|
||||||
|
|
||||||
|
void pluginCrashAlert(const TCHAR *pluginName, const TCHAR *funcSignature) {
|
||||||
|
generic_string msg = pluginName;
|
||||||
|
msg += TEXT(" just crash in\r");
|
||||||
|
msg += funcSignature;
|
||||||
|
::MessageBox(NULL, msg.c_str(), TEXT(" just crash in\r"), MB_OK|MB_ICONSTOP);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EXT_LEXER_DECL __stdcall
|
#define EXT_LEXER_DECL __stdcall
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "precompiledHeaders.h"
|
#include "precompiledHeaders.h"
|
||||||
#include "Notepad_plus.h"
|
#include "Notepad_plus.h"
|
||||||
#include "FileDialog.h"
|
#include "FileDialog.h"
|
||||||
//#include "resource.h"
|
|
||||||
#include "printer.h"
|
#include "printer.h"
|
||||||
#include "FileNameStringSplitter.h"
|
#include "FileNameStringSplitter.h"
|
||||||
#include "lesDlgs.h"
|
#include "lesDlgs.h"
|
||||||
@ -1535,6 +1534,8 @@ bool Notepad_plus::replaceAllFiles() {
|
|||||||
::printStr(TEXT("The regular expression to search is formed badly"));
|
::printStr(TEXT("The regular expression to search is formed badly"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (nbTotal)
|
||||||
|
enableCommand(IDM_FILE_SAVEALL, true, MENU | TOOLBAR);
|
||||||
TCHAR result[64];
|
TCHAR result[64];
|
||||||
wsprintf(result, TEXT("%d occurrences replaced."), nbTotal);
|
wsprintf(result, TEXT("%d occurrences replaced."), nbTotal);
|
||||||
::printStr(result);
|
::printStr(result);
|
||||||
@ -2723,7 +2724,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
printStr(TEXT("ToolTip crash is catched!"));
|
//printStr(TEXT("ToolTip crash is caught!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ END
|
|||||||
// Icon with lowest ID value placed first to ensure application icon
|
// Icon with lowest ID value placed first to ensure application icon
|
||||||
// remains consistent on all systems.
|
// remains consistent on all systems.
|
||||||
IDI_M30ICON ICON "icons\\npp.ico"
|
IDI_M30ICON ICON "icons\\npp.ico"
|
||||||
|
IDI_CHAMELEON ICON "icons\\chameleon.ico"
|
||||||
IDI_NEW_OFF_ICON ICON "icons\\new_off.ico"
|
IDI_NEW_OFF_ICON ICON "icons\\new_off.ico"
|
||||||
IDI_OPEN_OFF_ICON ICON "icons\\open_off.ico"
|
IDI_OPEN_OFF_ICON ICON "icons\\open_off.ico"
|
||||||
IDI_SAVE_OFF_ICON ICON "icons\\save_off.ico"
|
IDI_SAVE_OFF_ICON ICON "icons\\save_off.ico"
|
||||||
@ -593,7 +594,7 @@ BEGIN
|
|||||||
LTEXT "http://notepad-plus.sourceforge.net/",IDC_HOME_ADDR,78,54,126,8
|
LTEXT "http://notepad-plus.sourceforge.net/",IDC_HOME_ADDR,78,54,126,8
|
||||||
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
|
EDITTEXT IDC_LICENCE_EDIT,31,99,209,96,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
|
||||||
EDITTEXT IDC_BUILD_DATETIME,150,2,150,10, ES_READONLY | NOT WS_BORDER
|
EDITTEXT IDC_BUILD_DATETIME,150,2,150,10, ES_READONLY | NOT WS_BORDER
|
||||||
CONTROL "",IDI_M30ICON,"Static",SS_OWNERDRAW,21,10,32,32
|
CONTROL "",IDI_CHAMELEON,"Static",SS_OWNERDRAW,21,10,48,48
|
||||||
END
|
END
|
||||||
|
|
||||||
IDD_GOLINE DIALOGEX 26, 41, 261, 88
|
IDD_GOLINE DIALOGEX 26, 41, 261, 88
|
||||||
|
@ -520,11 +520,6 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
|
|||||||
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
|
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
|
||||||
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false)
|
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false)
|
||||||
{
|
{
|
||||||
_findHistory._nbFindHistoryPath = 0;
|
|
||||||
_findHistory._nbFindHistoryFilter = 0;
|
|
||||||
_findHistory._nbFindHistoryFind = 0;
|
|
||||||
_findHistory._nbFindHistoryReplace = 0;
|
|
||||||
|
|
||||||
//Get windows version
|
//Get windows version
|
||||||
_winVersion = getWindowsVersion();
|
_winVersion = getWindowsVersion();
|
||||||
|
|
||||||
@ -565,6 +560,12 @@ NppParameters::~NppParameters()
|
|||||||
if (_hUXTheme)
|
if (_hUXTheme)
|
||||||
FreeLibrary(_hUXTheme);
|
FreeLibrary(_hUXTheme);
|
||||||
|
|
||||||
|
for (std::vector<TiXmlDocument *>::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it )
|
||||||
|
{
|
||||||
|
delete (*it);
|
||||||
|
}
|
||||||
|
_pXmlExternalLexerDoc.clear();
|
||||||
|
|
||||||
::RemoveFontResource(LINEDRAW_FONT);
|
::RemoveFontResource(LINEDRAW_FONT);
|
||||||
}
|
}
|
||||||
void cutString(const TCHAR *str2cut, vector<generic_string> & patternVect)
|
void cutString(const TCHAR *str2cut, vector<generic_string> & patternVect)
|
||||||
@ -1505,13 +1506,13 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
|
|||||||
if ((_findHistory._nbMaxFindHistoryPath > 0) && (_findHistory._nbMaxFindHistoryPath <= NB_MAX_FINDHISTORY_PATH))
|
if ((_findHistory._nbMaxFindHistoryPath > 0) && (_findHistory._nbMaxFindHistoryPath <= NB_MAX_FINDHISTORY_PATH))
|
||||||
{
|
{
|
||||||
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Path"));
|
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Path"));
|
||||||
childNode && (_findHistory._nbFindHistoryPath < NB_MAX_FINDHISTORY_PATH);
|
childNode && (_findHistory._findHistoryPaths.size() < NB_MAX_FINDHISTORY_PATH);
|
||||||
childNode = childNode->NextSibling(TEXT("Path")) )
|
childNode = childNode->NextSibling(TEXT("Path")) )
|
||||||
{
|
{
|
||||||
const TCHAR *filePath = (childNode->ToElement())->Attribute(TEXT("name"));
|
const TCHAR *filePath = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||||
if (filePath)
|
if (filePath)
|
||||||
{
|
{
|
||||||
_findHistory._pFindHistoryPath[_findHistory._nbFindHistoryPath++] = new generic_string(filePath);
|
_findHistory._findHistoryPaths.push_back(generic_string(filePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1520,13 +1521,13 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
|
|||||||
if ((_findHistory._nbMaxFindHistoryFilter > 0) && (_findHistory._nbMaxFindHistoryFilter <= NB_MAX_FINDHISTORY_FILTER))
|
if ((_findHistory._nbMaxFindHistoryFilter > 0) && (_findHistory._nbMaxFindHistoryFilter <= NB_MAX_FINDHISTORY_FILTER))
|
||||||
{
|
{
|
||||||
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Filter"));
|
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Filter"));
|
||||||
childNode && (_findHistory._nbFindHistoryFilter < NB_MAX_FINDHISTORY_FILTER);
|
childNode && (_findHistory._findHistoryFilters.size() < NB_MAX_FINDHISTORY_FILTER);
|
||||||
childNode = childNode->NextSibling(TEXT("Filter")))
|
childNode = childNode->NextSibling(TEXT("Filter")))
|
||||||
{
|
{
|
||||||
const TCHAR *fileFilter = (childNode->ToElement())->Attribute(TEXT("name"));
|
const TCHAR *fileFilter = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||||
if (fileFilter)
|
if (fileFilter)
|
||||||
{
|
{
|
||||||
_findHistory._pFindHistoryFilter[_findHistory._nbFindHistoryFilter++] = new generic_string(fileFilter);
|
_findHistory._findHistoryFilters.push_back(generic_string(fileFilter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1535,13 +1536,13 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
|
|||||||
if ((_findHistory._nbMaxFindHistoryFind > 0) && (_findHistory._nbMaxFindHistoryFind <= NB_MAX_FINDHISTORY_FIND))
|
if ((_findHistory._nbMaxFindHistoryFind > 0) && (_findHistory._nbMaxFindHistoryFind <= NB_MAX_FINDHISTORY_FIND))
|
||||||
{
|
{
|
||||||
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Find"));
|
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Find"));
|
||||||
childNode && (_findHistory._nbFindHistoryFind < NB_MAX_FINDHISTORY_FIND);
|
childNode && (_findHistory._findHistoryFinds.size() < NB_MAX_FINDHISTORY_FIND);
|
||||||
childNode = childNode->NextSibling(TEXT("Find")))
|
childNode = childNode->NextSibling(TEXT("Find")))
|
||||||
{
|
{
|
||||||
const TCHAR *fileFind = (childNode->ToElement())->Attribute(TEXT("name"));
|
const TCHAR *fileFind = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||||
if (fileFind)
|
if (fileFind)
|
||||||
{
|
{
|
||||||
_findHistory._pFindHistoryFind[_findHistory._nbFindHistoryFind++] = new generic_string(fileFind);
|
_findHistory._findHistoryFinds.push_back(generic_string(fileFind));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1550,13 +1551,13 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
|
|||||||
if ((_findHistory._nbMaxFindHistoryReplace > 0) && (_findHistory._nbMaxFindHistoryReplace <= NB_MAX_FINDHISTORY_REPLACE))
|
if ((_findHistory._nbMaxFindHistoryReplace > 0) && (_findHistory._nbMaxFindHistoryReplace <= NB_MAX_FINDHISTORY_REPLACE))
|
||||||
{
|
{
|
||||||
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Replace"));
|
for (TiXmlNode *childNode = findHistoryRoot->FirstChildElement(TEXT("Replace"));
|
||||||
childNode && (_findHistory._nbFindHistoryReplace < NB_MAX_FINDHISTORY_REPLACE);
|
childNode && (_findHistory._findHistoryReplaces.size() < NB_MAX_FINDHISTORY_REPLACE);
|
||||||
childNode = childNode->NextSibling(TEXT("Replace")))
|
childNode = childNode->NextSibling(TEXT("Replace")))
|
||||||
{
|
{
|
||||||
const TCHAR *fileReplace = (childNode->ToElement())->Attribute(TEXT("name"));
|
const TCHAR *fileReplace = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||||
if (fileReplace)
|
if (fileReplace)
|
||||||
{
|
{
|
||||||
_findHistory._pFindHistoryReplace[_findHistory._nbFindHistoryReplace++] = new generic_string(fileReplace);
|
_findHistory._findHistoryReplaces.push_back(generic_string(fileReplace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4176,9 +4177,6 @@ bool NppParameters::writeFindHistory()
|
|||||||
TiXmlElement element(TEXT("FindHistory"));
|
TiXmlElement element(TEXT("FindHistory"));
|
||||||
findHistoryRoot = nppRoot->InsertEndChild(element);
|
findHistoryRoot = nppRoot->InsertEndChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
|
||||||
|
|
||||||
findHistoryRoot->Clear();
|
findHistoryRoot->Clear();
|
||||||
|
|
||||||
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryPath"), _findHistory._nbMaxFindHistoryPath);
|
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryPath"), _findHistory._nbMaxFindHistoryPath);
|
||||||
@ -4204,30 +4202,30 @@ bool NppParameters::writeFindHistory()
|
|||||||
TiXmlElement hist_element(TEXT(""));
|
TiXmlElement hist_element(TEXT(""));
|
||||||
|
|
||||||
hist_element.SetValue(TEXT("Path"));
|
hist_element.SetValue(TEXT("Path"));
|
||||||
for (i = 0; i < _findHistory._nbFindHistoryPath; i++)
|
for (size_t i = 0; i < _findHistory._findHistoryPaths.size(); i++)
|
||||||
{
|
{
|
||||||
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryPath[i]->c_str());
|
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._findHistoryPaths[i].c_str());
|
||||||
findHistoryRoot->InsertEndChild(hist_element);
|
findHistoryRoot->InsertEndChild(hist_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
hist_element.SetValue(TEXT("Filter"));
|
hist_element.SetValue(TEXT("Filter"));
|
||||||
for (i = 0; i < _findHistory._nbFindHistoryFilter; i++)
|
for (size_t i = 0; i < _findHistory._findHistoryFilters.size(); i++)
|
||||||
{
|
{
|
||||||
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryFilter[i]->c_str());
|
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._findHistoryFilters[i].c_str());
|
||||||
findHistoryRoot->InsertEndChild(hist_element);
|
findHistoryRoot->InsertEndChild(hist_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
hist_element.SetValue(TEXT("Find"));
|
hist_element.SetValue(TEXT("Find"));
|
||||||
for (i = 0; i < _findHistory._nbFindHistoryFind; i++)
|
for (size_t i = 0; i < _findHistory._findHistoryFinds.size(); i++)
|
||||||
{
|
{
|
||||||
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryFind[i]->c_str());
|
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._findHistoryFinds[i].c_str());
|
||||||
findHistoryRoot->InsertEndChild(hist_element);
|
findHistoryRoot->InsertEndChild(hist_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
hist_element.SetValue(TEXT("Replace"));
|
hist_element.SetValue(TEXT("Replace"));
|
||||||
for (i = 0; i < _findHistory._nbFindHistoryReplace; i++)
|
for (size_t i = 0; i < _findHistory._findHistoryReplaces.size(); i++)
|
||||||
{
|
{
|
||||||
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._pFindHistoryReplace[i]->c_str());
|
(hist_element.ToElement())->SetAttribute(TEXT("name"), _findHistory._findHistoryReplaces[i].c_str());
|
||||||
findHistoryRoot->InsertEndChild(hist_element);
|
findHistoryRoot->InsertEndChild(hist_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -948,7 +948,6 @@ struct FindHistory {
|
|||||||
enum transparencyMode{none, onLossingFocus, persistant};
|
enum transparencyMode{none, onLossingFocus, persistant};
|
||||||
|
|
||||||
FindHistory() : _nbMaxFindHistoryPath(10), _nbMaxFindHistoryFilter(10), _nbMaxFindHistoryFind(10), _nbMaxFindHistoryReplace(10),\
|
FindHistory() : _nbMaxFindHistoryPath(10), _nbMaxFindHistoryFilter(10), _nbMaxFindHistoryFind(10), _nbMaxFindHistoryReplace(10),\
|
||||||
_nbFindHistoryPath(0), _nbFindHistoryFilter(0),_nbFindHistoryFind(0), _nbFindHistoryReplace(0),\
|
|
||||||
_isMatchWord(false), _isMatchCase(false),_isWrap(true),_isDirectionDown(true),\
|
_isMatchWord(false), _isMatchCase(false),_isWrap(true),_isDirectionDown(true),\
|
||||||
_isFifRecuisive(true), _isFifInHiddenFolder(false), _isDlgAlwaysVisible(false),\
|
_isFifRecuisive(true), _isFifInHiddenFolder(false), _isDlgAlwaysVisible(false),\
|
||||||
_isFilterFollowDoc(false), _isFolderFollowDoc(false),\
|
_isFilterFollowDoc(false), _isFolderFollowDoc(false),\
|
||||||
@ -960,15 +959,10 @@ struct FindHistory {
|
|||||||
int _nbMaxFindHistoryFind;
|
int _nbMaxFindHistoryFind;
|
||||||
int _nbMaxFindHistoryReplace;
|
int _nbMaxFindHistoryReplace;
|
||||||
|
|
||||||
int _nbFindHistoryPath;
|
vector<generic_string> _findHistoryPaths;
|
||||||
int _nbFindHistoryFilter;
|
vector<generic_string> _findHistoryFilters;
|
||||||
int _nbFindHistoryFind;
|
vector<generic_string> _findHistoryFinds;
|
||||||
int _nbFindHistoryReplace;
|
vector<generic_string> _findHistoryReplaces;
|
||||||
|
|
||||||
generic_string *_pFindHistoryPath[NB_MAX_FINDHISTORY_PATH];
|
|
||||||
generic_string *_pFindHistoryFilter[NB_MAX_FINDHISTORY_FILTER];
|
|
||||||
generic_string *_pFindHistoryFind[NB_MAX_FINDHISTORY_FIND];
|
|
||||||
generic_string *_pFindHistoryReplace[NB_MAX_FINDHISTORY_REPLACE];
|
|
||||||
|
|
||||||
bool _isMatchWord;
|
bool _isMatchWord;
|
||||||
bool _isMatchCase;
|
bool _isMatchCase;
|
||||||
|
@ -406,6 +406,13 @@ void Buffer::setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved
|
|||||||
|
|
||||||
//filemanager
|
//filemanager
|
||||||
|
|
||||||
|
FileManager::~FileManager()
|
||||||
|
{
|
||||||
|
for (std::vector<Buffer *>::iterator it = _buffers.begin(), end = _buffers.end(); it != end; ++it)
|
||||||
|
{
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla)
|
void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
FileManager() : _nextNewNumber(1), _nextBufferID(0), _pNotepadPlus(NULL), _nrBufs(0), _pscratchTilla(NULL){};
|
FileManager() : _nextNewNumber(1), _nextBufferID(0), _pNotepadPlus(NULL), _nrBufs(0), _pscratchTilla(NULL){};
|
||||||
~FileManager(){};
|
~FileManager();
|
||||||
static FileManager *_pSelf;
|
static FileManager *_pSelf;
|
||||||
|
|
||||||
Notepad_plus * _pNotepadPlus;
|
Notepad_plus * _pNotepadPlus;
|
||||||
|
@ -314,13 +314,12 @@ void FindReplaceDlg::create(int dialogID, bool isRTL)
|
|||||||
void FindReplaceDlg::fillFindHistory()
|
void FindReplaceDlg::fillFindHistory()
|
||||||
{
|
{
|
||||||
NppParameters *nppParams = NppParameters::getInstance();
|
NppParameters *nppParams = NppParameters::getInstance();
|
||||||
|
FindHistory & findHistory = nppParams->getFindHistory();
|
||||||
|
|
||||||
FindHistory& findHistory = nppParams->getFindHistory();
|
fillComboHistory(IDFINDWHAT, findHistory._findHistoryFinds);
|
||||||
|
fillComboHistory(IDREPLACEWITH, findHistory._findHistoryReplaces);
|
||||||
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbFindHistoryPath, findHistory._pFindHistoryPath);
|
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._findHistoryFilters);
|
||||||
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbFindHistoryFilter, findHistory._pFindHistoryFilter);
|
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._findHistoryPaths);
|
||||||
fillComboHistory(IDFINDWHAT, findHistory._nbFindHistoryFind, findHistory._pFindHistoryFind);
|
|
||||||
fillComboHistory(IDREPLACEWITH, findHistory._nbFindHistoryReplace, findHistory._pFindHistoryReplace);
|
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0);
|
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0);
|
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0);
|
||||||
@ -386,16 +385,14 @@ void FindReplaceDlg::fillFindHistory()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::fillComboHistory(int id, int count, generic_string **pStrings)
|
void FindReplaceDlg::fillComboHistory(int id, const vector<generic_string> & strings)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
bool isUnicode = false;
|
bool isUnicode = false;
|
||||||
HWND hCombo;
|
HWND hCombo = ::GetDlgItem(_hSelf, id);
|
||||||
|
|
||||||
hCombo = ::GetDlgItem(_hSelf, id);
|
for (vector<generic_string>::const_reverse_iterator i = strings.rbegin() ; i != strings.rend(); i++)
|
||||||
for (i = count -1 ; i >= 0 ; i--)
|
|
||||||
{
|
{
|
||||||
addText2Combo(pStrings[i]->c_str(), hCombo, isUnicode);
|
addText2Combo(i->c_str(), hCombo, isUnicode);
|
||||||
}
|
}
|
||||||
::SendMessage(hCombo, CB_SETCURSEL, 0, 0); // select first item
|
::SendMessage(hCombo, CB_SETCURSEL, 0, 0); // select first item
|
||||||
}
|
}
|
||||||
@ -406,32 +403,30 @@ void FindReplaceDlg::saveFindHistory()
|
|||||||
if (! isCreated()) return;
|
if (! isCreated()) return;
|
||||||
FindHistory& findHistory = (NppParameters::getInstance())->getFindHistory();
|
FindHistory& findHistory = (NppParameters::getInstance())->getFindHistory();
|
||||||
|
|
||||||
saveComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbMaxFindHistoryPath, findHistory._nbFindHistoryPath, findHistory._pFindHistoryPath);
|
saveComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbMaxFindHistoryPath, findHistory._findHistoryPaths);
|
||||||
saveComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbMaxFindHistoryFilter, findHistory._nbFindHistoryFilter, findHistory._pFindHistoryFilter);
|
saveComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbMaxFindHistoryFilter, findHistory._findHistoryFilters);
|
||||||
saveComboHistory(IDFINDWHAT, findHistory._nbMaxFindHistoryFind, findHistory._nbFindHistoryFind, findHistory._pFindHistoryFind);
|
saveComboHistory(IDFINDWHAT, findHistory._nbMaxFindHistoryFind, findHistory._findHistoryFinds);
|
||||||
saveComboHistory(IDREPLACEWITH, findHistory._nbMaxFindHistoryReplace, findHistory._nbFindHistoryReplace, findHistory._pFindHistoryReplace);
|
saveComboHistory(IDREPLACEWITH, findHistory._nbMaxFindHistoryReplace, findHistory._findHistoryReplaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::saveComboHistory(int id, int maxcount, int & oldcount, generic_string **pStrings)
|
int FindReplaceDlg::saveComboHistory(int id, int maxcount, vector<generic_string> & strings)
|
||||||
{
|
{
|
||||||
int i, count;
|
|
||||||
|
|
||||||
HWND hCombo;
|
|
||||||
TCHAR text[FINDREPLACE_MAXLENGTH];
|
TCHAR text[FINDREPLACE_MAXLENGTH];
|
||||||
|
HWND hCombo = ::GetDlgItem(_hSelf, id);
|
||||||
hCombo = ::GetDlgItem(_hSelf, id);
|
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||||
count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
|
||||||
count = min(count, maxcount);
|
count = min(count, maxcount);
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
|
if (count == CB_ERR) return 0;
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
strings.clear();
|
||||||
|
|
||||||
|
for (size_t i = 0 ; i < (size_t)count ; i++)
|
||||||
{
|
{
|
||||||
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM) text);
|
::SendMessage(hCombo, CB_GETLBTEXT, i, (LPARAM) text);
|
||||||
if (i < oldcount)
|
strings.push_back(generic_string(text));
|
||||||
*pStrings[i] = text;
|
|
||||||
else
|
|
||||||
pStrings[i] = new generic_string(text);
|
|
||||||
}
|
}
|
||||||
for (; i < oldcount; i++) delete pStrings[i];
|
return count;
|
||||||
oldcount = count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::updateCombos()
|
void FindReplaceDlg::updateCombos()
|
||||||
|
@ -319,8 +319,8 @@ private :
|
|||||||
addText2Combo(getTextFromCombo(hCombo, isUnicode).c_str(), hCombo, isUnicode);
|
addText2Combo(getTextFromCombo(hCombo, isUnicode).c_str(), hCombo, isUnicode);
|
||||||
};
|
};
|
||||||
void fillFindHistory();
|
void fillFindHistory();
|
||||||
void fillComboHistory(int id, int count, generic_string **pStrings);
|
void fillComboHistory(int id, const std::vector<generic_string> & strings);
|
||||||
void saveComboHistory(int id, int maxcount, int& oldcount, generic_string **pStrings);
|
int saveComboHistory(int id, int maxcount, vector<generic_string> & strings);
|
||||||
};
|
};
|
||||||
|
|
||||||
//FindIncrementDlg: incremental search dialog, docked in rebar
|
//FindIncrementDlg: incremental search dialog, docked in rebar
|
||||||
|
@ -70,7 +70,7 @@ BOOL CALLBACK AboutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
|
|
||||||
case WM_DRAWITEM :
|
case WM_DRAWITEM :
|
||||||
{
|
{
|
||||||
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON));
|
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON));
|
||||||
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
|
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
|
||||||
::DrawIcon(pdis->hDC, 0, 0, hIcon);
|
::DrawIcon(pdis->hDC, 0, 0, hIcon);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
BIN
PowerEditor/src/icons/chameleon.ico
Normal file
BIN
PowerEditor/src/icons/chameleon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
@ -33,7 +33,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IDI_M30ICON 100
|
#define IDI_M30ICON 100
|
||||||
#define IDR_MENU1 101
|
#define IDI_CHAMELEON 101
|
||||||
#define IDR_RT_MANIFEST 103
|
#define IDR_RT_MANIFEST 103
|
||||||
|
|
||||||
#define IDI_NEW_OFF_ICON 201
|
#define IDI_NEW_OFF_ICON 201
|
||||||
|
Loading…
x
Reference in New Issue
Block a user