From 4d11f5d26ab375408d5b6d80e9cde4365c461314 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 29 Aug 2012 09:39:13 +0000 Subject: [PATCH] [NEW_FEATURE] (Author: Andreas Jonsson) Add case sensitive option for smart highlighting feature. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@945 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Parameters.cpp | 31 +++++++++++++++++++ PowerEditor/src/Parameters.h | 4 ++- .../ScitillaComponent/SmartHighlighter.cpp | 4 ++- .../src/WinControls/Preference/preference.rc | 17 +++++----- .../WinControls/Preference/preferenceDlg.cpp | 14 +++++++++ .../WinControls/Preference/preference_rc.h | 1 + 6 files changed, 61 insertions(+), 10 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 9b01de21..981d55d2 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -3183,6 +3183,22 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } + else if (!lstrcmp(nm, TEXT("SmartHighLightCaseSensitive"))) + { + TiXmlNode *n = childNode->FirstChild(); + if (n) + { + val = n->Value(); + if (val) + { + if (!lstrcmp(val, TEXT("yes"))) + _nppGUI._smartHiliteCaseSensitive = true; + else + _nppGUI._smartHiliteCaseSensitive = false; + } + } + } + else if (!lstrcmp(nm, TEXT("TagsMatchHighLight"))) { TiXmlNode *n = childNode->FirstChild(); @@ -4059,6 +4075,7 @@ bool NppParameters::writeGUIParams() bool noUpdateExist = false; bool menuBarExist = false; bool smartHighLightExist = false; + bool smartHighLightCaseSensitiveExist = false; bool tagsMatchHighLightExist = false; bool caretExist = false; bool ScintillaGlobalSettingsExist = false; @@ -4242,6 +4259,16 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } + else if (!lstrcmp(nm, TEXT("SmartHighLightCaseSensitive"))) + { + smartHighLightCaseSensitiveExist = true; + const TCHAR *pStr = _nppGUI._smartHiliteCaseSensitive?TEXT("yes"):TEXT("no"); + TiXmlNode *n = childNode->FirstChild(); + if (n) + n->SetValue(pStr); + else + childNode->InsertEndChild(TiXmlText(pStr)); + } else if (!lstrcmp(nm, TEXT("TagsMatchHighLight"))) { @@ -4466,6 +4493,10 @@ bool NppParameters::writeGUIParams() { insertGUIConfigBoolNode(GUIRoot, TEXT("SmartHighLight"), _nppGUI._enableSmartHilite); } + if( !smartHighLightCaseSensitiveExist) + { + insertGUIConfigBoolNode(GUIRoot, TEXT("SmartHighLightCaseSensitive"), _nppGUI._smartHiliteCaseSensitive); + } if (!tagsMatchHighLightExist) { TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, TEXT("TagsMatchHighLight"), _nppGUI._enableTagsMatchHilite); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e9361d8a..6c06246b 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -671,7 +671,8 @@ struct NppGUI _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false), _backupDir(TEXT("")),\ _doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\ _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")),\ - _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _enableMultiSelection(false), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false) { + _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _enableMultiSelection(false), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false), + _smartHiliteCaseSensitive(false) { _appPos.left = 0; _appPos.top = 0; _appPos.right = 700; @@ -713,6 +714,7 @@ struct NppGUI bool _doTaskList; bool _maitainIndent; bool _enableSmartHilite; + bool _smartHiliteCaseSensitive; bool _disableSmartHiliteTmp; bool _enableTagsMatchHilite; bool _enableTagAttrsHilite; diff --git a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp index 518bd543..f34b16c9 100644 --- a/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp +++ b/PowerEditor/src/ScitillaComponent/SmartHighlighter.cpp @@ -97,8 +97,10 @@ void SmartHighlighter::highlightView(ScintillaEditView * pHighlightView) int currentLine = firstLine; int prevDocLineChecked = -1; //invalid start + const NppGUI & nppGUI = NppParameters::getInstance()->getNppGUI(); + FindOption fo; - fo._isMatchCase = false; + fo._isMatchCase = nppGUI._smartHiliteCaseSensitive; fo._isWholeWord = true; const TCHAR * searchText = NULL; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index b98a7ee1..dbb73d10 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -117,35 +117,36 @@ IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 455, 185 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - GROUPBOX "Document Switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,37,4,155,39,BS_CENTER CONTROL "Enable",IDC_CHECK_ENABLEDOCSWITCHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,15,69,10 CONTROL "Enable MRU behaviour",IDC_CHECK_STYLEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,45,28,140,10 CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,94,150,10 - CONTROL "Smart highlighting",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,136,150,10 - CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,108,150,10 - CONTROL "Minimize to system tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,122,150,10 + CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,94,150,10 + CONTROL "Minimize to system tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,108,150,10 + CONTROL "Smart highlighting",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,122,150,10 + CONTROL "Highlighting is case sensitive",IDC_CHECK_SMARTHILITECASESENSITIVE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,136,150,10 CONTROL "Show only filename in title bar",IDC_CHECK_SHORTTITLE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,150,217,10 CONTROL "Remember current session for next launch",IDC_CHECK_REMEMBERSESSION, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,164,217,10 - GROUPBOX "Clickable Link Settings",IDC_CLICKABLELINK_STATIC,259,4,155,39,BS_CENTER CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,15,140,10 CONTROL "No underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,28,140,10 - GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,47,155,50,BS_CENTER CONTROL "Enable",IDC_CHECK_FILEAUTODETECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,57,140,10 CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,69,140,10 CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,81,140,10 - GROUPBOX "Highlight Matching Tags",IDC_TAGMATCHEDHILITE_STATIC,259,101,155,50,BS_CENTER CONTROL "Enable",IDC_CHECK_ENABLTAGSMATCHHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,267,111,140,10 CONTROL "Highlight tag attributes",IDC_CHECK_ENABLTAGATTRHILITE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,267,123,140,10 CONTROL "Highlight comment/php/asp zone",IDC_CHECK_HIGHLITENONEHTMLZONE, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,267,136,140,10 - RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,271,160,108,8 EDITTEXT IDC_EDIT_SESSIONFILEEXT,381,157,34,14,ES_AUTOHSCROLL + GROUPBOX "Document Switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,37,4,155,39,BS_CENTER + GROUPBOX "Clickable Link Settings",IDC_CLICKABLELINK_STATIC,259,4,155,39,BS_CENTER + GROUPBOX "File Status Auto-Detection",IDC_FILEAUTODETECTION_STATIC,259,47,155,50,BS_CENTER + GROUPBOX "Highlight Matching Tags",IDC_TAGMATCHEDHILITE_STATIC,259,101,155,50,BS_CENTER + RTEXT "Session file ext.:",IDC_SESSIONFILEEXT_STATIC,271,160,108,8 END IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 455, 185 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 8bf4af1b..d8087996 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -753,12 +753,14 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, nppGUI._maitainIndent, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_STYLEMRU, BM_SETCHECK, nppGUI._styleMRU, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLSMARTHILITE, BM_SETCHECK, nppGUI._enableSmartHilite, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_SMARTHILITECASESENSITIVE, BM_SETCHECK, nppGUI._smartHiliteCaseSensitive, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLTAGSMATCHHILITE, BM_SETCHECK, nppGUI._enableTagsMatchHilite, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE, BM_SETCHECK, nppGUI._enableTagAttrsHilite, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_HIGHLITENONEHTMLZONE, BM_SETCHECK, nppGUI._enableHiliteNonHTMLZone, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE), nppGUI._enableTagsMatchHilite); ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_HIGHLITENONEHTMLZONE), nppGUI._enableTagsMatchHilite); + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_SMARTHILITECASESENSITIVE), nppGUI._enableSmartHilite); ::SendDlgItemMessage(_hSelf, IDC_CHECK_SHORTTITLE, BM_SETCHECK, nppGUI._shortTitlebar, 0); @@ -884,8 +886,20 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) HWND grandParent = ::GetParent(_hParent); ::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0); } + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_SMARTHILITECASESENSITIVE), nppGUI._enableSmartHilite); return TRUE; } + case IDC_CHECK_SMARTHILITECASESENSITIVE: + { + nppGUI._smartHiliteCaseSensitive = !nppGUI._smartHiliteCaseSensitive; + if (!nppGUI._smartHiliteCaseSensitive) + { + HWND grandParent = ::GetParent(_hParent); + ::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0); + } + return TRUE; + } + case IDC_CHECK_ENABLTAGSMATCHHILITE: { nppGUI._enableTagsMatchHilite = !nppGUI._enableTagsMatchHilite; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 805f36b2..e2d459d9 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -135,6 +135,7 @@ #define IDC_TAGMATCHEDHILITE_STATIC (IDD_PREFERENCE_SETTING_BOX + 29) #define IDC_CHECK_HIGHLITENONEHTMLZONE (IDD_PREFERENCE_SETTING_BOX + 30) #define IDC_CHECK_SHORTTITLE (IDD_PREFERENCE_SETTING_BOX + 31) + #define IDC_CHECK_SMARTHILITECASESENSITIVE (IDD_PREFERENCE_SETTING_BOX + 32) #define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400) #define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1)