[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);
|
||||
|
||||
void runPluginCommand(size_t i) {
|
||||
if (i < _pluginsCommands.size())
|
||||
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 runPluginCommand(size_t i);
|
||||
void runPluginCommand(const TCHAR *pluginName, int commandID);
|
||||
|
||||
void addInMenuFromPMIndex(int i);
|
||||
void setMenu(HMENU hMenu, const TCHAR *menuName);
|
||||
bool getShortcutByCmdID(int cmdID, ShortcutKey *sk);
|
||||
|
||||
void 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;
|
||||
_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;
|
||||
};
|
||||
void notify(SCNotification *notification);
|
||||
void relayNppMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
bool relayPluginMessages(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
HMENU getMenuHandle() {
|
||||
return _hPluginsMenu;
|
||||
@ -157,10 +107,17 @@ public:
|
||||
private:
|
||||
NppData _nppData;
|
||||
HMENU _hPluginsMenu;
|
||||
|
||||
|
||||
vector<PluginInfo *> _pluginInfos;
|
||||
vector<PluginCommand> _pluginsCommands;
|
||||
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
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "precompiledHeaders.h"
|
||||
#include "Notepad_plus.h"
|
||||
#include "FileDialog.h"
|
||||
//#include "resource.h"
|
||||
#include "printer.h"
|
||||
#include "FileNameStringSplitter.h"
|
||||
#include "lesDlgs.h"
|
||||
@ -198,7 +197,7 @@ void Notepad_plus::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLine, CmdL
|
||||
nppClass.cbClsExtra = 0;
|
||||
nppClass.cbWndExtra = 0;
|
||||
nppClass.hInstance = _hInst;
|
||||
nppClass.hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON));
|
||||
nppClass.hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON));
|
||||
nppClass.hCursor = ::LoadCursor(NULL, IDC_ARROW);
|
||||
nppClass.hbrBackground = ::CreateSolidBrush(::GetSysColor(COLOR_MENU));
|
||||
nppClass.lpszMenuName = MAKEINTRESOURCE(IDR_M30_MENU);
|
||||
@ -1535,6 +1534,8 @@ bool Notepad_plus::replaceAllFiles() {
|
||||
::printStr(TEXT("The regular expression to search is formed badly"));
|
||||
else
|
||||
{
|
||||
if (nbTotal)
|
||||
enableCommand(IDM_FILE_SAVEALL, true, MENU | TOOLBAR);
|
||||
TCHAR result[64];
|
||||
wsprintf(result, TEXT("%d occurrences replaced."), nbTotal);
|
||||
::printStr(result);
|
||||
@ -2723,7 +2724,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
|
||||
return FALSE;
|
||||
}
|
||||
} 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
|
||||
// remains consistent on all systems.
|
||||
IDI_M30ICON ICON "icons\\npp.ico"
|
||||
IDI_CHAMELEON ICON "icons\\chameleon.ico"
|
||||
IDI_NEW_OFF_ICON ICON "icons\\new_off.ico"
|
||||
IDI_OPEN_OFF_ICON ICON "icons\\open_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
|
||||
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
|
||||
CONTROL "",IDI_M30ICON,"Static",SS_OWNERDRAW,21,10,32,32
|
||||
CONTROL "",IDI_CHAMELEON,"Static",SS_OWNERDRAW,21,10,48,48
|
||||
END
|
||||
|
||||
IDD_GOLINE DIALOGEX 26, 41, 261, 88
|
||||
|
@ -520,11 +520,6 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
|
||||
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
|
||||
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false), _isFindReplacing(false)
|
||||
{
|
||||
_findHistory._nbFindHistoryPath = 0;
|
||||
_findHistory._nbFindHistoryFilter = 0;
|
||||
_findHistory._nbFindHistoryFind = 0;
|
||||
_findHistory._nbFindHistoryReplace = 0;
|
||||
|
||||
//Get windows version
|
||||
_winVersion = getWindowsVersion();
|
||||
|
||||
@ -565,6 +560,12 @@ NppParameters::~NppParameters()
|
||||
if (_hUXTheme)
|
||||
FreeLibrary(_hUXTheme);
|
||||
|
||||
for (std::vector<TiXmlDocument *>::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it )
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
_pXmlExternalLexerDoc.clear();
|
||||
|
||||
::RemoveFontResource(LINEDRAW_FONT);
|
||||
}
|
||||
void cutString(const TCHAR *str2cut, vector<generic_string> & patternVect)
|
||||
@ -944,8 +945,8 @@ bool NppParameters::load()
|
||||
|
||||
delete _pXmlSessionDoc;
|
||||
for (size_t i = 0 ; i < _pXmlExternalLexerDoc.size() ; i++)
|
||||
if (_pXmlExternalLexerDoc[i])
|
||||
delete _pXmlExternalLexerDoc[i];
|
||||
if (_pXmlExternalLexerDoc[i])
|
||||
delete _pXmlExternalLexerDoc[i];
|
||||
|
||||
_pXmlSessionDoc = NULL;
|
||||
}
|
||||
@ -1505,13 +1506,13 @@ void NppParameters::feedFindHistoryParameters(TiXmlNode *node)
|
||||
if ((_findHistory._nbMaxFindHistoryPath > 0) && (_findHistory._nbMaxFindHistoryPath <= NB_MAX_FINDHISTORY_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")) )
|
||||
{
|
||||
const TCHAR *filePath = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||
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))
|
||||
{
|
||||
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")))
|
||||
{
|
||||
const TCHAR *fileFilter = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||
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))
|
||||
{
|
||||
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")))
|
||||
{
|
||||
const TCHAR *fileFind = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||
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))
|
||||
{
|
||||
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")))
|
||||
{
|
||||
const TCHAR *fileReplace = (childNode->ToElement())->Attribute(TEXT("name"));
|
||||
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"));
|
||||
findHistoryRoot = nppRoot->InsertEndChild(element);
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
findHistoryRoot->Clear();
|
||||
|
||||
(findHistoryRoot->ToElement())->SetAttribute(TEXT("nbMaxFindHistoryPath"), _findHistory._nbMaxFindHistoryPath);
|
||||
@ -4204,30 +4202,30 @@ bool NppParameters::writeFindHistory()
|
||||
TiXmlElement hist_element(TEXT(""));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -948,7 +948,6 @@ struct FindHistory {
|
||||
enum transparencyMode{none, onLossingFocus, persistant};
|
||||
|
||||
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),\
|
||||
_isFifRecuisive(true), _isFifInHiddenFolder(false), _isDlgAlwaysVisible(false),\
|
||||
_isFilterFollowDoc(false), _isFolderFollowDoc(false),\
|
||||
@ -960,15 +959,10 @@ struct FindHistory {
|
||||
int _nbMaxFindHistoryFind;
|
||||
int _nbMaxFindHistoryReplace;
|
||||
|
||||
int _nbFindHistoryPath;
|
||||
int _nbFindHistoryFilter;
|
||||
int _nbFindHistoryFind;
|
||||
int _nbFindHistoryReplace;
|
||||
|
||||
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];
|
||||
vector<generic_string> _findHistoryPaths;
|
||||
vector<generic_string> _findHistoryFilters;
|
||||
vector<generic_string> _findHistoryFinds;
|
||||
vector<generic_string> _findHistoryReplaces;
|
||||
|
||||
bool _isMatchWord;
|
||||
bool _isMatchCase;
|
||||
|
@ -406,6 +406,13 @@ void Buffer::setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved
|
||||
|
||||
//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)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ public:
|
||||
|
||||
private:
|
||||
FileManager() : _nextNewNumber(1), _nextBufferID(0), _pNotepadPlus(NULL), _nrBufs(0), _pscratchTilla(NULL){};
|
||||
~FileManager(){};
|
||||
~FileManager();
|
||||
static FileManager *_pSelf;
|
||||
|
||||
Notepad_plus * _pNotepadPlus;
|
||||
|
@ -314,13 +314,12 @@ void FindReplaceDlg::create(int dialogID, bool isRTL)
|
||||
void FindReplaceDlg::fillFindHistory()
|
||||
{
|
||||
NppParameters *nppParams = NppParameters::getInstance();
|
||||
FindHistory & findHistory = nppParams->getFindHistory();
|
||||
|
||||
FindHistory& findHistory = nppParams->getFindHistory();
|
||||
|
||||
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbFindHistoryPath, findHistory._pFindHistoryPath);
|
||||
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbFindHistoryFilter, findHistory._pFindHistoryFilter);
|
||||
fillComboHistory(IDFINDWHAT, findHistory._nbFindHistoryFind, findHistory._pFindHistoryFind);
|
||||
fillComboHistory(IDREPLACEWITH, findHistory._nbFindHistoryReplace, findHistory._pFindHistoryReplace);
|
||||
fillComboHistory(IDFINDWHAT, findHistory._findHistoryFinds);
|
||||
fillComboHistory(IDREPLACEWITH, findHistory._findHistoryReplaces);
|
||||
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._findHistoryFilters);
|
||||
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._findHistoryPaths);
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 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;
|
||||
HWND hCombo;
|
||||
HWND hCombo = ::GetDlgItem(_hSelf, id);
|
||||
|
||||
hCombo = ::GetDlgItem(_hSelf, id);
|
||||
for (i = count -1 ; i >= 0 ; i--)
|
||||
for (vector<generic_string>::const_reverse_iterator i = strings.rbegin() ; i != strings.rend(); i++)
|
||||
{
|
||||
addText2Combo(pStrings[i]->c_str(), hCombo, isUnicode);
|
||||
addText2Combo(i->c_str(), hCombo, isUnicode);
|
||||
}
|
||||
::SendMessage(hCombo, CB_SETCURSEL, 0, 0); // select first item
|
||||
}
|
||||
@ -406,32 +403,30 @@ void FindReplaceDlg::saveFindHistory()
|
||||
if (! isCreated()) return;
|
||||
FindHistory& findHistory = (NppParameters::getInstance())->getFindHistory();
|
||||
|
||||
saveComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbMaxFindHistoryPath, findHistory._nbFindHistoryPath, findHistory._pFindHistoryPath);
|
||||
saveComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbMaxFindHistoryFilter, findHistory._nbFindHistoryFilter, findHistory._pFindHistoryFilter);
|
||||
saveComboHistory(IDFINDWHAT, findHistory._nbMaxFindHistoryFind, findHistory._nbFindHistoryFind, findHistory._pFindHistoryFind);
|
||||
saveComboHistory(IDREPLACEWITH, findHistory._nbMaxFindHistoryReplace, findHistory._nbFindHistoryReplace, findHistory._pFindHistoryReplace);
|
||||
saveComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._nbMaxFindHistoryPath, findHistory._findHistoryPaths);
|
||||
saveComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._nbMaxFindHistoryFilter, findHistory._findHistoryFilters);
|
||||
saveComboHistory(IDFINDWHAT, findHistory._nbMaxFindHistoryFind, findHistory._findHistoryFinds);
|
||||
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];
|
||||
|
||||
hCombo = ::GetDlgItem(_hSelf, id);
|
||||
count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||
HWND hCombo = ::GetDlgItem(_hSelf, id);
|
||||
int count = ::SendMessage(hCombo, CB_GETCOUNT, 0, 0);
|
||||
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);
|
||||
if (i < oldcount)
|
||||
*pStrings[i] = text;
|
||||
else
|
||||
pStrings[i] = new generic_string(text);
|
||||
strings.push_back(generic_string(text));
|
||||
}
|
||||
for (; i < oldcount; i++) delete pStrings[i];
|
||||
oldcount = count;
|
||||
return count;
|
||||
}
|
||||
|
||||
void FindReplaceDlg::updateCombos()
|
||||
|
@ -319,8 +319,8 @@ private :
|
||||
addText2Combo(getTextFromCombo(hCombo, isUnicode).c_str(), hCombo, isUnicode);
|
||||
};
|
||||
void fillFindHistory();
|
||||
void fillComboHistory(int id, int count, generic_string **pStrings);
|
||||
void saveComboHistory(int id, int maxcount, int& oldcount, generic_string **pStrings);
|
||||
void fillComboHistory(int id, const std::vector<generic_string> & strings);
|
||||
int saveComboHistory(int id, int maxcount, vector<generic_string> & strings);
|
||||
};
|
||||
|
||||
//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 :
|
||||
{
|
||||
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_M30ICON));
|
||||
HICON hIcon = ::LoadIcon(_hInst, MAKEINTRESOURCE(IDI_CHAMELEON));
|
||||
DRAWITEMSTRUCT *pdis = (DRAWITEMSTRUCT *)lParam;
|
||||
::DrawIcon(pdis->hDC, 0, 0, hIcon);
|
||||
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
|
||||
|
||||
#define IDI_M30ICON 100
|
||||
#define IDR_MENU1 101
|
||||
#define IDI_CHAMELEON 101
|
||||
#define IDR_RT_MANIFEST 103
|
||||
|
||||
#define IDI_NEW_OFF_ICON 201
|
||||
|
Loading…
Reference in New Issue
Block a user