From b4f7260e9be863aa138099f0e835000ed418a858 Mon Sep 17 00:00:00 2001 From: donho Date: Wed, 8 Aug 2007 17:22:48 +0000 Subject: [PATCH] [BUG_FIXED] 1. Fix User Define Language extension recognition problem for sensitive case (now it's insensitive). 2. Fix keyboard shortcut bug in FindReplaceDlg. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@3 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/bin/change.log | 3 +- PowerEditor/src/Parameters.h | 4 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 254 +++++++++++------- .../src/ScitillaComponent/FindReplaceDlg.rc | 4 +- 4 files changed, 155 insertions(+), 110 deletions(-) diff --git a/PowerEditor/bin/change.log b/PowerEditor/bin/change.log index 98d770402..bf6af4e2f 100644 --- a/PowerEditor/bin/change.log +++ b/PowerEditor/bin/change.log @@ -5,7 +5,8 @@ v4.2 fixed bugs and added features (from v4.1.2) : 3. Fixed "To UPPER/lower case" bug in column mode. 4. Fix the display bug in User language define dialog. 5. Add new feature which backups files in a user specific directory. - +6. Fix TeX syntax highlighting corruption problem while switching off then switching back to current document. +7. Fix User Define Language extension recognition problem for sensitive case (now it's insensitive). Plugins included in v4.2 : diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index bfbbeafc1..708d9f6b5 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -468,8 +468,6 @@ struct PrintSettings { bool isUserMargePresent() const { return ((_marge.left != 0) || (_marge.top != 0) || (_marge.right != 0) || (_marge.bottom != 0)); }; - - }; struct NppGUI @@ -834,7 +832,7 @@ public: vector extVect; cutString(_userLangArray[i]->_ext, extVect); for (size_t j = 0 ; j < extVect.size() ; j++) - if (!strcmp(extVect[j].c_str(), ext)) + if (!stricmp(extVect[j].c_str(), ext)) return _userLangArray[i]->_name; } return NULL; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index d717bf4b0..3a261f5cd 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -281,14 +281,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP } return TRUE; } -/* - case WM_SIZE: - { - //resizeFinder(); - //resizeStatusBar(); - return FALSE; - } -*/ + case WM_NOTIFY: { NMHDR *nmhdr = (NMHDR *)lParam; @@ -310,6 +303,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP } break; } + case WM_ACTIVATE : { CharacterRange cr = (*_ppEditView)->getSelection(); @@ -322,6 +316,7 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP ::EnableWindow(::GetDlgItem(_hSelf, IDC_IN_SELECTION_CHECK), isSelected); return TRUE; } + case NPPM_MODELESSDIALOG : return ::SendMessage(_hParent, NPPM_MODELESSDIALOG, wParam, lParam); @@ -335,101 +330,128 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP case IDOK : // Find Next { - bool isUnicode = (*_ppEditView)->getCurrentBuffer().getUnicodeMode() != uni8Bit; - HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); - string str2Search = getTextFromCombo(hFindCombo, isUnicode); - addText2Combo(str2Search.c_str(), hFindCombo, isUnicode); - processFindNext(str2Search.c_str()); + if ((_currentStatus == FIND_DLG) || (_currentStatus == REPLACE_DLG)) + { + bool isUnicode = (*_ppEditView)->getCurrentBuffer().getUnicodeMode() != uni8Bit; + HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); + string str2Search = getTextFromCombo(hFindCombo, isUnicode); + addText2Combo(str2Search.c_str(), hFindCombo, isUnicode); + processFindNext(str2Search.c_str()); + } } return TRUE; case IDREPLACE : { - updateCombos(); - - processReplace(); - return TRUE; + if (_currentStatus == REPLACE_DLG) + { + updateCombos(); + processReplace(); + } } + return TRUE; case IDREPLACEALL : { - updateCombos(); + if (_currentStatus == REPLACE_DLG) + { + updateCombos(); - (*_ppEditView)->execute(SCI_BEGINUNDOACTION); - int nbReplaced = processAll(REPLACE_ALL); - (*_ppEditView)->execute(SCI_ENDUNDOACTION); + (*_ppEditView)->execute(SCI_BEGINUNDOACTION); + int nbReplaced = processAll(REPLACE_ALL); + (*_ppEditView)->execute(SCI_ENDUNDOACTION); - char result[64]; - if (nbReplaced < 0) - strcpy(result, "The regular expression to search is formed badly"); - else - { - itoa(nbReplaced, result, 10); - strcat(result, " tokens are replaced."); + char result[64]; + if (nbReplaced < 0) + strcpy(result, "The regular expression to search is formed badly"); + else + { + itoa(nbReplaced, result, 10); + strcat(result, " tokens are replaced."); + } + ::MessageBox(_hSelf, result, "", MB_OK); } - ::MessageBox(_hSelf, result, "", MB_OK); - return TRUE; } + return TRUE; case IDC_REPLACE_OPENEDFILES : - updateCombos(); - replaceAllInOpenedDocs(); - return TRUE; + { + if (_currentStatus == REPLACE_DLG) + { + updateCombos(); + replaceAllInOpenedDocs(); + } + } + return TRUE; case IDC_FINDALL_OPENEDFILES : - updateCombo(IDFINDWHAT); - findAllIn(ALL_OPEN_DOCS); - return TRUE; + { + if (_currentStatus == FIND_DLG) + { + updateCombo(IDFINDWHAT); + findAllIn(ALL_OPEN_DOCS); + } + } + return TRUE; - case IDD_FINDINFILES_GOBACK_BUTTON : + /*case IDD_FINDINFILES_GOBACK_BUTTON : doDialog(FIND_DLG); return TRUE; case IDC_GETCURRENTDOCTYPE : *((LangType *)lParam) = (*_ppEditView)->getCurrentDocType(); - return TRUE; + return TRUE;*/ case IDCMARKALL : { - updateCombo(IDFINDWHAT); - int nbMarked = processAll(MARK_ALL); - char result[64]; - if (nbMarked < 0) - strcpy(result, "The regular expression to search is formed badly"); - else + if (_currentStatus == FIND_DLG) { - itoa(nbMarked, result, 10); - strcat(result, " tokens are found and marked"); - } + updateCombo(IDFINDWHAT); + int nbMarked = processAll(MARK_ALL); + char result[64]; + if (nbMarked < 0) + strcpy(result, "The regular expression to search is formed badly"); + else + { + itoa(nbMarked, result, 10); + strcat(result, " tokens are found and marked"); + } - ::MessageBox(_hSelf, result, "", MB_OK); - return TRUE; + ::MessageBox(_hSelf, result, "", MB_OK); + } } + return TRUE; case IDC_CLEAR_ALL : { - LangType lt = (*_ppEditView)->getCurrentDocType(); - if (lt == L_TXT) - (*_ppEditView)->defineDocType(L_CPP); - (*_ppEditView)->defineDocType(lt); - (*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_SYMBOLE); - return TRUE; + if (_currentStatus == FIND_DLG) + { + LangType lt = (*_ppEditView)->getCurrentDocType(); + if (lt == L_TXT) + (*_ppEditView)->defineDocType(L_CPP); + (*_ppEditView)->defineDocType(lt); + (*_ppEditView)->execute(SCI_MARKERDELETEALL, MARK_SYMBOLE); + } } + return TRUE; case IDCCOUNTALL : { - int nbCounted = processAll(COUNT_ALL); - char result[64]; - if (nbCounted < 0) - strcpy(result, "The regular expression to search is formed badly"); - else + if (_currentStatus == FIND_DLG) { - itoa(nbCounted, result, 10); - strcat(result, " tokens are found."); + int nbCounted = processAll(COUNT_ALL); + char result[64]; + if (nbCounted < 0) + strcpy(result, "The regular expression to search is formed badly"); + else + { + itoa(nbCounted, result, 10); + strcat(result, " tokens are found."); + } + ::MessageBox(_hSelf, result, "", MB_OK); } - ::MessageBox(_hSelf, result, "", MB_OK); - return TRUE; } + return TRUE; case IDWHOLEWORD : _options._isWholeWord = isCheckedOrNot(IDWHOLEWORD); @@ -467,22 +489,38 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP return TRUE; case IDC_PURGE_CHECK : - _doPurge = isCheckedOrNot(IDC_PURGE_CHECK); - return TRUE; + { + if (_currentStatus == FIND_DLG) + _doPurge = isCheckedOrNot(IDC_PURGE_CHECK); + } + return TRUE; case IDC_MARKLINE_CHECK : - _doMarkLine = isCheckedOrNot(IDC_MARKLINE_CHECK); - ::EnableWindow(::GetDlgItem(_hSelf, IDCMARKALL), (_doMarkLine || _doStyleFoundToken)); - return TRUE; + { + if (_currentStatus == FIND_DLG) + { + _doMarkLine = isCheckedOrNot(IDC_MARKLINE_CHECK); + ::EnableWindow(::GetDlgItem(_hSelf, IDCMARKALL), (_doMarkLine || _doStyleFoundToken)); + } + } + return TRUE; case IDC_STYLEFOUND_CHECK : - _doStyleFoundToken = isCheckedOrNot(IDC_STYLEFOUND_CHECK); - ::EnableWindow(::GetDlgItem(_hSelf, IDCMARKALL), (_doMarkLine || _doStyleFoundToken)); - return TRUE; + { + if (_currentStatus == FIND_DLG) + { + _doStyleFoundToken = isCheckedOrNot(IDC_STYLEFOUND_CHECK); + ::EnableWindow(::GetDlgItem(_hSelf, IDCMARKALL), (_doMarkLine || _doStyleFoundToken)); + } + } + return TRUE; case IDC_IN_SELECTION_CHECK : - _isInSelection = isCheckedOrNot(IDC_IN_SELECTION_CHECK); - return TRUE; + { + if (_currentStatus == FIND_DLG) + _isInSelection = isCheckedOrNot(IDC_IN_SELECTION_CHECK); + } + return TRUE; case IDC_TRANSPARENT_CHECK : { @@ -505,51 +543,59 @@ BOOL CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP case IDD_FINDINFILES_FIND_BUTTON : { - char filters[256]; - char directory[MAX_PATH]; - ::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, sizeof(filters)); - addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO)); - _filters = filters; - - ::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, sizeof(directory)); - addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO)); - _directory = directory; - - if ((strlen(directory) > 0) && (directory[strlen(directory)-1] != '\\')) - _directory += "\\"; + if (_currentStatus == FINDINFILES_DLG) + { + char filters[256]; + char directory[MAX_PATH]; + ::GetDlgItemText(_hSelf, IDD_FINDINFILES_FILTERS_COMBO, filters, sizeof(filters)); + addText2Combo(filters, ::GetDlgItem(_hSelf, IDD_FINDINFILES_FILTERS_COMBO)); + _filters = filters; - //::SendMessage(_hParent, WM_COMMAND, IDC_FINDINFILES_LAUNCH, 0); - updateCombo(IDFINDWHAT); + ::GetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, directory, sizeof(directory)); + addText2Combo(directory, ::GetDlgItem(_hSelf, IDD_FINDINFILES_DIR_COMBO)); + _directory = directory; + + if ((strlen(directory) > 0) && (directory[strlen(directory)-1] != '\\')) + _directory += "\\"; - // thread to launch : - findAllIn(FILES_IN_DIR); + //::SendMessage(_hParent, WM_COMMAND, IDC_FINDINFILES_LAUNCH, 0); + updateCombo(IDFINDWHAT); -//Thread - //HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, "findInFilesEvent"); - //--HANDLE hFindInFilesThread = ::CreateThread(NULL, 0, staticFindInFilesFunc, this, 0, NULL); - + // thread to launch : + findAllIn(FILES_IN_DIR); - //::WaitForSingleObject(hEvent, INFINITE); + //Thread + //HANDLE hEvent = ::CreateEvent(NULL, FALSE, FALSE, "findInFilesEvent"); + //--HANDLE hFindInFilesThread = ::CreateThread(NULL, 0, staticFindInFilesFunc, this, 0, NULL); + - //::CloseHandle(hFindInFilesThread); - //::CloseHandle(hEvent); - //::MessageBox(NULL, "Fin de thread", "", MB_OK); + //::WaitForSingleObject(hEvent, INFINITE); - //display(false); - return TRUE; + //::CloseHandle(hFindInFilesThread); + //::CloseHandle(hEvent); + //::MessageBox(NULL, "Fin de thread", "", MB_OK); + + //display(false); + } + } + return TRUE; case IDD_FINDINFILES_RECURSIVE_CHECK : { - _isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK); - return TRUE; + if (_currentStatus == FINDINFILES_DLG) + _isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK); + } + return TRUE; case IDD_FINDINFILES_BROWSE_BUTTON : { - folderBrowser(_hSelf, IDD_FINDINFILES_DIR_COMBO); - return TRUE; + if (_currentStatus == FINDINFILES_DLG) + folderBrowser(_hSelf, IDD_FINDINFILES_DIR_COMBO); } + return TRUE; + default : break; } diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc index efd000548..4e54bd59d 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.rc @@ -32,7 +32,7 @@ FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN RTEXT "Find what :",IDFINDWHAT_STATIC,6,22,75,8 COMBOBOX IDFINDWHAT,83,20,125,150,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP - RTEXT "Re&place with :",ID_STATICTEXT_REPLACE,6,40,75,8 + RTEXT "Replace with :",ID_STATICTEXT_REPLACE,6,40,75,8 COMBOBOX IDREPLACEWITH,83,39,125,50,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_TABSTOP CONTROL "Mark Line",IDC_MARKLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,38,88,10 CONTROL "Style found token",IDC_STYLEFOUND_CHECK,"Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,13,50,100,15 @@ -53,7 +53,7 @@ BEGIN CONTROL "Match &case",IDMATCHCASE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,103,110,12 CONTROL "Regular &expression",IDREGEXP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,6,116,110,12 - CONTROL "Wrap aroun&d",IDWRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,6,129,102,16 + CONTROL "Wra&p around",IDWRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,6,129,102,16 CONTROL "&Up",IDDIRECTIONUP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,155,94,45,12 CONTROL "&Down",IDDIRECTIONDOWN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,155,106,45,12 GROUPBOX "Direction",IDC_DIR_STATIC,150,86,60,34,WS_GROUP