From 3e705b3e6428f36a9e4922e871ed9e504f1ab6d2 Mon Sep 17 00:00:00 2001 From: donho Date: Thu, 1 May 2008 17:15:15 +0000 Subject: [PATCH] [RELEASE_4_9] Release 4.9. Fix the replace bug while replacing nothing. Fix the F3 searching direction bug. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@194 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/bin/change.log | 29 +++++-- PowerEditor/installer/nppSetup.nsi | 6 +- .../MISC/PluginsManager/Notepad_plus_msgs.h | 17 ++-- PowerEditor/src/Notepad_plus.cpp | 11 +-- PowerEditor/src/Notepad_plus.h | 4 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 83 +++++++++++-------- .../src/ScitillaComponent/FindReplaceDlg.h | 10 +-- .../ScitillaComponent/ScintillaEditView.cpp | 9 +- PowerEditor/src/stylers.model.xml | 4 +- 9 files changed, 99 insertions(+), 74 deletions(-) diff --git a/PowerEditor/bin/change.log b/PowerEditor/bin/change.log index 444663a9..0e8bf301 100644 --- a/PowerEditor/bin/change.log +++ b/PowerEditor/bin/change.log @@ -1,12 +1,22 @@ -Notepad++ v4.8.5 fixed bugs and added features (from v4.8.2) : +Notepad++ v4.9 fixed bugs and added features (from v4.8.5) : -1. Fix crash bug while a "New 2" is in session.xml. -2. Fix the Drag N Drop text bug between 2 views. -3. Fix the annoying acrobat reader dialog problem. -4. Fix the bug that the first new document encoding is not set as the setting in "New Document settings". -5. Fix crash bug while running the command "Close All But Me" in some context. -6. Add scroll to end line feature after document reloading from disk. -7. Enhance checking modification from outside feature. +1. Add smart highlighting feature (double click a word to highlight all the same word in the document). +2. Enhance visual effect of Mark all feature. +3. Enhance Incremental search dialog docking. +4. Enhance Incremental search : add Highlight all feature. +5. Add auto-hide menu feature (IE7 style menu - Alt or F10 to toggle) +6. Enhance tool bar GUI usability (display a chevron while some tool icons hidden). +7. Add style transparency feature, right click on color to enable. +8. Fix the files not opening by DnD bug. +9. Enhance Find Replace dialog : Add "Extended" option - search (and replace) for tabs(\t), newline(\n\r), and a characters by it's value (\o, \x, \b, \d, \t, \n, \r and \\). +10. Bug fixed : Find dialog always scrolls text into view now. +11. Add places bar in save as dialog +12. Fix non-recognized relative path bug in command line mode (under Dos prompt). +13. Add 2 messages for doc monitor plugin. +14. Fix the transparency bug (in Styler Configurator). +15. Make search in hidden directory (for Find in files) optional. +16. Fix the replace bug while replacing nothing. +17. Fix the F3 searching direction bug. Included plugins : @@ -19,4 +29,5 @@ Included plugins : 6. NppExport v0.2.7.3 7. Compare plugin v1.5.1 8. Light Explorer v1.4 -9. Doc Monitor v2.0 +9. Doc Monitor v2.1 + diff --git a/PowerEditor/installer/nppSetup.nsi b/PowerEditor/installer/nppSetup.nsi index 1c9e73be..80fe6d58 100644 --- a/PowerEditor/installer/nppSetup.nsi +++ b/PowerEditor/installer/nppSetup.nsi @@ -17,16 +17,16 @@ ; Define the application name !define APPNAME "Notepad++" -!define APPNAMEANDVERSION "Notepad++ v4.8.5" +!define APPNAMEANDVERSION "Notepad++ v4.9" !define VERSION_MAJOR 4 -!define VERSION_MINOR 85 +!define VERSION_MINOR 9 ; Main Install settings Name "${APPNAMEANDVERSION}" InstallDir "$PROGRAMFILES\Notepad++" InstallDirRegKey HKLM "Software\${APPNAME}" "" -OutFile "..\bin\npp.4.8.5.Installer.exe" +OutFile "..\bin\npp.4.9.Installer.exe" ; GetWindowsVersion ; diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index e1fd0ff1..c0a0f680 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -201,20 +201,23 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV #define CHECKDOCOPT_UPDATESILENTLY 1 #define CHECKDOCOPT_UPDATEGO2END 2 - #define NPPM_ADDREBAR (NPPMSG + 55) + #define NPPM_GETCHECKDOCOPT (NPPMSG + 55) + // INT NPPM_GETCHECKDOCOPT(0, 0) + #define NPPM_SETCHECKDOCOPT (NPPMSG + 56) + // INT NPPM_SETCHECKDOCOPT(OPT, 0) + +/* + #define NPPM_ADDREBAR (NPPMSG + 57) // BOOL NPPM_ADDREBAR(0, REBARBANDINFO *) // Returns assigned ID in wID value of struct pointer - #define NPPM_UPDATEREBAR (NPPMSG + 56) + #define NPPM_UPDATEREBAR (NPPMSG + 58) // BOOL NPPM_ADDREBAR(INT ID, REBARBANDINFO *) //Use ID assigned with NPPM_ADDREBAR - #define NPPM_REMOVEREBAR (NPPMSG + 57) + #define NPPM_REMOVEREBAR (NPPMSG + 59) // BOOL NPPM_ADDREBAR(INT ID, 0) //Use ID assigned with NPPM_ADDREBAR +*/ - #define NPPM_GETCHECKDOCOPT (NPPMSG + 58) - // INT NPPM_GETCHECKDOCOPT(0, 0) - #define NPPM_SETCHECKDOCOPT (NPPMSG + 59) - // INT NPPM_SETCHECKDOCOPT(OPT, 0) #define RUNCOMMAND_USER (WM_USER + 3000) #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 064b139c..f758baa3 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2866,10 +2866,11 @@ void Notepad_plus::command(int id) if (!_findReplaceDlg.isCreated()) return; - _findReplaceDlg.setSearchDirection(id == IDM_SEARCH_FINDNEXT?DIR_DOWN:DIR_UP); - + FindOption op = _findReplaceDlg.getCurrentOptions(); + op._whichDirection = (id == IDM_SEARCH_FINDNEXT?DIR_DOWN:DIR_UP); string s = _findReplaceDlg.getText2search(); - _findReplaceDlg.processFindNext(s.c_str()); + + _findReplaceDlg.processFindNext(s.c_str(), &op); break; } break; @@ -7758,7 +7759,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { return _mainDocTab.getHideTabBarStatus(); } - +/* case NPPM_ADDREBAR : { if (!lParam) @@ -7782,7 +7783,7 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _rebarTop.removeBand((int)wParam); return TRUE; } - +*/ case NPPM_INTERNAL_ISFOCUSEDTAB : { ScintillaEditView *cv = getCurrentEditView(); diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 1654a699..cba0be10 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -104,7 +104,7 @@ public: return false; }; -#pragma region fileOperation + // fileOperation bool doOpen(const char *fileName, bool isReadOnly = false); bool doSimpleOpen(const char *fileName); bool doReload(const char *fileName, bool alert = true); @@ -120,7 +120,7 @@ public: bool fileSaveAs(); bool doSave(const char *filename, UniMode mode); -#pragma endregion fileOperation + // end fileOperation void filePrint(bool showDialog); bool saveScintillaParams(bool whichOne); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 73fda41e..a38217b1 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -111,6 +111,44 @@ bool Searching::readBase(const char * string, int * value, int base, int size) { return true; } +void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards) +{ + // to make sure the found result is visible + //When searching up, the beginning of the (possible multiline) result is important, when scrolling down the end + int testPos = (isDownwards)?posEnd:posStart; + pEditView->execute(SCI_SETCURRENTPOS, testPos); + int currentlineNumberDoc = (int)pEditView->execute(SCI_LINEFROMPOSITION, testPos); + int currentlineNumberVis = (int)pEditView->execute(SCI_VISIBLEFROMDOCLINE, currentlineNumberDoc); + pEditView->execute(SCI_ENSUREVISIBLE, currentlineNumberDoc); // make sure target line is unfolded + + int firstVisibleLineVis = (int)pEditView->execute(SCI_GETFIRSTVISIBLELINE); + int linesVisible = (int)pEditView->execute(SCI_LINESONSCREEN) - 1; //-1 for the scrollbar + int lastVisibleLineVis = (int)linesVisible + firstVisibleLineVis; + + //if out of view vertically, scroll line into (center of) view + int linesToScroll = 0; + if (currentlineNumberVis < firstVisibleLineVis) + { + linesToScroll = currentlineNumberVis - firstVisibleLineVis; + //use center + linesToScroll -= linesVisible/2; + } + else if (currentlineNumberVis > lastVisibleLineVis) + { + linesToScroll = currentlineNumberVis - lastVisibleLineVis; + //use center + linesToScroll += linesVisible/2; + } + pEditView->scroll(0, linesToScroll); + + //Make sure the caret is visible, scroll horizontally (this will also fix wrapping problems) + pEditView->execute(SCI_GOTOPOS, posStart); + pEditView->execute(SCI_GOTOPOS, posEnd); + //pEditView->execute(SCI_SETSEL, start, posEnd); + //pEditView->execute(SCI_SETCURRENTPOS, posEnd); + pEditView->execute(SCI_SETANCHOR, posStart); +} + void FindReplaceDlg::addText2Combo(const char * txt2add, HWND hCombo, bool isUTF8) { if (!hCombo) return; @@ -326,7 +364,7 @@ bool Finder::notify(SCNotification *notification) int cmd = getMode()==FILES_IN_DIR?WM_DOOPEN:NPPM_SWITCHTOFILE; ::SendMessage(::GetParent(_hParent), cmd, 0, (LPARAM)fInfo._fullPath.c_str()); - (*_ppEditView)->execute(SCI_SETSEL, fInfo._start, fInfo._end); + Searching::displaySectionCentered(fInfo._start, fInfo._end, *_ppEditView); // we set the current mark here int nb = (*_ppEditView)->getCurrentLineNumber(); @@ -621,6 +659,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP if (_currentStatus == FIND_DLG) { (*_ppEditView)->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE); + (*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_BOOKMARK); } } return TRUE; @@ -858,39 +897,8 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) int end = int((*_ppEditView)->execute(SCI_GETTARGETEND)); // to make sure the found result is visible - //When searching up, the beginning of the (possible multiline) result is important, when scrolling down the end - int testPos = (_options._whichDirection == DIR_DOWN)?end:start; - (*_ppEditView)->execute(SCI_SETCURRENTPOS, testPos); - int currentlineNumberDoc = (int)(*_ppEditView)->execute(SCI_LINEFROMPOSITION, testPos); - int currentlineNumberVis = (int)(*_ppEditView)->execute(SCI_VISIBLEFROMDOCLINE, currentlineNumberDoc); - (*_ppEditView)->execute(SCI_ENSUREVISIBLE, currentlineNumberDoc); + Searching::displaySectionCentered(start, end, *_ppEditView, pOptions->_whichDirection == DIR_DOWN); - int firstVisibleLineVis = (int)(*_ppEditView)->execute(SCI_GETFIRSTVISIBLELINE); - int linesVisible = (int)(*_ppEditView)->execute(SCI_LINESONSCREEN) - 1; //-1 for the scrollbar - int lastVisibleLineVis = (int)linesVisible + firstVisibleLineVis; - - //if out of view vertically, scroll line into (center of) view - int linesToScroll = 0; - if (currentlineNumberVis < firstVisibleLineVis) - { - linesToScroll = currentlineNumberVis - firstVisibleLineVis; - //use center - linesToScroll -= linesVisible/2; - } - else if (currentlineNumberVis > lastVisibleLineVis) - { - linesToScroll = currentlineNumberVis - lastVisibleLineVis; - //use center - linesToScroll += linesVisible/2; - } - (*_ppEditView)->scroll(0, linesToScroll); - - //Make sure the caret is visible, scroll horizontally (this will also fix wrapping problems) - (*_ppEditView)->execute(SCI_GOTOPOS, start); - (*_ppEditView)->execute(SCI_GOTOPOS, end); - //(*_ppEditView)->execute(SCI_SETSEL, start, end); - //(*_ppEditView)->execute(SCI_SETCURRENTPOS, end); - (*_ppEditView)->execute(SCI_SETANCHOR, start); delete [] pText; return true; @@ -902,7 +910,7 @@ bool FindReplaceDlg::processFindNext(const char *txt2find, FindOption *options) // || the text is replaced, and do NOT find the next occurrence bool FindReplaceDlg::processReplace(const char *txt2find, const char *txt2replace, FindOption *options) { - if (!txt2find || !txt2find[0] || !txt2replace || !txt2replace[0]) + if (!txt2find || !txt2find[0] || !txt2replace) return false; FindOption *pOptions = options?options:&_options; @@ -1010,7 +1018,12 @@ int FindReplaceDlg::processAll(ProcessOperation op, const char *txt2find, const strcpy(pTextFind, txt2find); } - char *pTextReplace = NULL;//new char[stringSizeReplace + 1]; + if (!pTextFind[0]) { + delete [] pTextFind; + return nbReplaced; + } + + char *pTextReplace = NULL; if (op == ProcessReplaceAll) { if (!txt2replace) { HWND hReplaceCombo = ::GetDlgItem(_hSelf, IDREPLACEWITH); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h index ed7e8c4c..fa60aa61 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.h @@ -79,6 +79,8 @@ public: (option->_isMatchCase ? SCFIND_MATCHCASE : 0) | (option->_searchType == FindRegex ? SCFIND_REGEXP|SCFIND_POSIX : 0); }; + static void displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards = true); + private: static bool readBase(const char * string, int * value, int base, int size); @@ -267,13 +269,6 @@ public : _pFinder->setSearchWord(str2Search.c_str()); }; - /// Sets the direction in which to search. - /// \param dir Direction to search (DIR_UP or DIR_DOWN) - /// - void setSearchDirection(bool dir) { - _options._whichDirection = dir; - }; - const char * getDir2Search() const {return _directory.c_str();}; void getPatterns(vector & patternVect); @@ -303,6 +298,7 @@ public : const string & getFilters() const {return _filters;}; const string & getDirectory() const {return _directory;}; + const FindOption & getCurrentOptions() const {return _options;}; protected : virtual BOOL CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index bd8f56ab..3618b5c5 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -290,9 +290,6 @@ void ScintillaEditView::setStyle(Style styleToSet) void ScintillaEditView::setXmlLexer(LangType type) { - - execute(SCI_SETSTYLEBITS, 7, 0); - if (type == L_XML) { execute(SCI_SETLEXER, SCLEX_HTML); @@ -644,6 +641,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) } execute(SCI_STYLECLEARALL); + execute(SCI_CLEARDOCUMENTSTYLE); int iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_FOUND_STYLE); if (iFind != -1) @@ -686,8 +684,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) execute(SCI_SETCODEPAGE, _codepage); } - execute(SCI_SETSTYLEBITS, 5); - showMargin(_SC_MARGE_FOLDER, isNeededFolderMarge(typeDoc)); switch (typeDoc) { @@ -884,6 +880,9 @@ void ScintillaEditView::defineDocType(LangType typeDoc) execute(SCI_SETTABWIDTH, ((NppParameters::getInstance())->getNppGUI())._tabSize); execute(SCI_SETUSETABS, !((NppParameters::getInstance())->getNppGUI())._tabReplacedBySpace); + int bitsNeeded = execute(SCI_GETSTYLEBITSNEEDED); + execute(SCI_SETSTYLEBITS, bitsNeeded); + execute(SCI_COLOURISE, 0, -1); } diff --git a/PowerEditor/src/stylers.model.xml b/PowerEditor/src/stylers.model.xml index 108cc708..013f9f78 100644 --- a/PowerEditor/src/stylers.model.xml +++ b/PowerEditor/src/stylers.model.xml @@ -709,11 +709,13 @@ - + + +