diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp index 982e1611..d9a8fbfd 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.cpp @@ -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; +} \ No newline at end of file diff --git a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h index 88c10bca..d482cf66 100644 --- a/PowerEditor/src/MISC/PluginsManager/PluginsManager.h +++ b/PowerEditor/src/MISC/PluginsManager/PluginsManager.h @@ -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 _pluginInfos; vector _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 diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 2a41d73d..139ff7de 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -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!")); } } diff --git a/PowerEditor/src/Notepad_plus.rc b/PowerEditor/src/Notepad_plus.rc index 14eeebd6..ed299891 100644 --- a/PowerEditor/src/Notepad_plus.rc +++ b/PowerEditor/src/Notepad_plus.rc @@ -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 diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 6e84f521..13abdf46 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -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::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it ) + { + delete (*it); + } + _pXmlExternalLexerDoc.clear(); + ::RemoveFontResource(LINEDRAW_FONT); } void cutString(const TCHAR *str2cut, vector & 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); } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index a4d86983..9783d977 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -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 _findHistoryPaths; + vector _findHistoryFilters; + vector _findHistoryFinds; + vector _findHistoryReplaces; bool _isMatchWord; bool _isMatchCase; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 8c571ab7..7672baac 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -406,6 +406,13 @@ void Buffer::setLineUndoState(size_t currentLine, size_t undoLevel, bool isSaved //filemanager +FileManager::~FileManager() +{ + for (std::vector::iterator it = _buffers.begin(), end = _buffers.end(); it != end; ++it) + { + delete *it; + } +} void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratchTilla) { diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index a33b221e..182aa563 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -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; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 6c944656..9e7adbe4 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -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 & 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::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 & 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() diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index d7dcaaf2..89c7d9ce 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -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 & strings); + int saveComboHistory(int id, int maxcount, vector & strings); }; //FindIncrementDlg: incremental search dialog, docked in rebar diff --git a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp index ce4b95fd..b7c69e8c 100644 --- a/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp +++ b/PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp @@ -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; diff --git a/PowerEditor/src/icons/chameleon.ico b/PowerEditor/src/icons/chameleon.ico new file mode 100644 index 00000000..1ae54139 Binary files /dev/null and b/PowerEditor/src/icons/chameleon.ico differ diff --git a/PowerEditor/src/icons/npp.ico b/PowerEditor/src/icons/npp.ico index 1ae54139..bd272c7e 100644 Binary files a/PowerEditor/src/icons/npp.ico and b/PowerEditor/src/icons/npp.ico differ diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 9f643557..4de39c85 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -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