diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 6f5f6c54d..726a2f871 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2632,7 +2632,11 @@ vector< pair > Notepad_plus::getAttributesPos(int start, int end) } void Notepad_plus::tagMatch() -{ +{ + const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI(); + if (!nppGUI._enableTagsMatchHilite) + return; + // Clean up all marks of previous action _pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH); _pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR); @@ -2665,11 +2669,14 @@ void Notepad_plus::tagMatch() _pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagOpenStart, xmlTags.tagNameEnd - xmlTags.tagOpenStart); _pEditView->execute(SCI_INDICATORFILLRANGE, xmlTags.tagOpenEnd - openTagTailLen, openTagTailLen); - vector< pair > attributes = getAttributesPos(xmlTags.tagNameEnd, xmlTags.tagOpenEnd - openTagTailLen); - _pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_TAGATTR); - for (size_t i = 0 ; i < attributes.size() ; i++) + if (nppGUI._enableTagAttrsHilite) { - _pEditView->execute(SCI_INDICATORFILLRANGE, attributes[i].first, attributes[i].second - attributes[i].first); + vector> attributes = getAttributesPos(xmlTags.tagNameEnd, xmlTags.tagOpenEnd - openTagTailLen); + _pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_TAGATTR); + for (size_t i = 0 ; i < attributes.size() ; i++) + { + _pEditView->execute(SCI_INDICATORFILLRANGE, attributes[i].first, attributes[i].second - attributes[i].first); + } } } @@ -7769,6 +7776,17 @@ LRESULT Notepad_plus::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa _pEditView->clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_2); return TRUE; } + case NPPM_INTERNAL_CLEARINDICATORTAGMATCH : + { + _pEditView->clearIndicator(SCE_UNIVERSAL_TAGMATCH); + _pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR); + return TRUE; + } + case NPPM_INTERNAL_CLEARINDICATORTAGATTR : + { + _pEditView->clearIndicator(SCE_UNIVERSAL_TAGATTR); + return TRUE; + } case WM_INITMENUPOPUP: { diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 6cd4ee169..1f92fea7e 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2406,6 +2406,22 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } + else if (!strcmp(nm, "TagsMatchHighLight")) + { + TiXmlNode *n = childNode->FirstChild(); + if (n) + { + val = n->Value(); + if (val) + { + _nppGUI._enableTagsMatchHilite = !strcmp(val, "yes"); + const char *tahl = element->Attribute("TagAttrHighLight"); + if (tahl) + _nppGUI._enableTagAttrsHilite = !strcmp(tahl, "yes"); + } + } + } + else if (!strcmp(nm, "TaskList")) { TiXmlNode *n = childNode->FirstChild(); @@ -3165,6 +3181,7 @@ bool NppParameters::writeGUIParams() bool noUpdateExist = false; bool menuBarExist = false; bool smartHighLightExist = false; + bool tagsMatchHighLightExist = false; bool caretExist = false; TiXmlNode *dockingParamNode = NULL; @@ -3338,6 +3355,20 @@ bool NppParameters::writeGUIParams() else childNode->InsertEndChild(TiXmlText(pStr)); } + + else if (!strcmp(nm, "TagsMatchHighLight")) + { + tagsMatchHighLightExist = true; + const char *pStr = _nppGUI._enableTagsMatchHilite?"yes":"no"; + TiXmlNode *n = childNode->FirstChild(); + if (n) + n->SetValue(pStr); + else + childNode->InsertEndChild(TiXmlText(pStr)); + + (childNode->ToElement())->SetAttribute("TagAttrHighLight", _nppGUI._enableTagsMatchHilite?"yes":"no"); + } + else if (!strcmp(nm, "SaveOpenFileInSameDir")) { saveOpenFileInSameDirExist = true; @@ -3532,7 +3563,11 @@ bool NppParameters::writeGUIParams() { insertGUIConfigBoolNode(GUIRoot, "SmartHighLight", _nppGUI._enableSmartHilite); } - + if (!tagsMatchHighLightExist) + { + TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, "TagsMatchHighLight", _nppGUI._enableTagsMatchHilite); + ele->SetAttribute("TagAttrHighLight", _nppGUI._enableTagsMatchHilite?"yes":"no"); + } if (!rememberLastSessionExist) { insertGUIConfigBoolNode(GUIRoot, "RememberLastSession", _nppGUI._rememberLastSession); @@ -3789,12 +3824,13 @@ void NppParameters::writeExcludedLangList(TiXmlElement *element) element->SetAttribute("gr7", g7); } -void NppParameters::insertGUIConfigBoolNode(TiXmlNode *r2w, const char *name, bool bVal) +TiXmlElement * NppParameters::insertGUIConfigBoolNode(TiXmlNode *r2w, const char *name, bool bVal) { const char *pStr = bVal?"yes":"no"; TiXmlElement *GUIConfigElement = (r2w->InsertEndChild(TiXmlElement("GUIConfig")))->ToElement(); GUIConfigElement->SetAttribute("name", name); GUIConfigElement->InsertEndChild(TiXmlText(pStr)); + return GUIConfigElement; } int RGB2int(COLORREF color) { diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index b8c24a014..eae4ef0ed 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -530,9 +530,9 @@ struct PrintSettings { struct NppGUI { NppGUI() : _toolBarStatus(TB_LARGE), _toolbarShow(true), _statusBarShow(true), _menuBarShow(true),\ - _tabStatus(TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP),\ - _splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\ - _tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true) ,_enableSmartHilite(true),\ + _tabStatus(TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP), _splitterPos(POS_HORIZOTAL),\ + _userDefineDlgStatus(UDD_DOCKED), _tabSize(8), _tabReplacedBySpace(false), _fileAutoDetection(cdEnabled),\ + _checkHistoryFiles(true) ,_enableSmartHilite(true), _enableTagsMatchHilite(true), _enableTagAttrsHilite(true),\ _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ _doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0),\ _autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(""), _neverUpdate(false),\ @@ -576,6 +576,8 @@ struct NppGUI bool _doTaskList; bool _maitainIndent; bool _enableSmartHilite; + bool _enableTagsMatchHilite; + bool _enableTagAttrsHilite; bool _saveOpenKeepInSameDir; bool _styleMRU; @@ -1218,7 +1220,7 @@ private: void insertScintKey(TiXmlNode *scintKeyRoot, const ScintillaKeyMap & scintKeyMap); void insertPluginCmd(TiXmlNode *pluginCmdRoot, const PluginCmdShortcut & pluginCmd); void stylerStrOp(bool op); - void insertGUIConfigBoolNode(TiXmlNode *r2w, const char *name, bool bVal); + TiXmlElement * insertGUIConfigBoolNode(TiXmlNode *r2w, const char *name, bool bVal); void insertDockingParamNode(TiXmlNode *GUIRoot); void writeExcludedLangList(TiXmlElement *element); void writePrintSetting(TiXmlElement *element); diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 8c4af4031..d6dd94b89 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -117,15 +117,18 @@ BEGIN CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,81,141,10 CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,95,150,10 - CONTROL "Enable smart highlighting",IDC_CHECK_ENABLSMARTHILITE, - "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,109,150,10 - CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,123,130,10 - CONTROL "Minimize to sys tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,137,130,10 + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,101,150,10 + CONTROL "Smart highlighting",IDC_CHECK_ENABLSMARTHILITE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,201,102,141,10 + CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,115,130,10 + CONTROL "Minimize to sys tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,129,130,10 CONTROL "Remember the last operation directory",IDC_CHECK_KEEPINSAMEDIR, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,151,210,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,143,210,10 CONTROL "Remember the current session for next launch",IDC_CHECK_REMEMBERSESSION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,165,217,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,157,217,10 + CONTROL "Tags match highlighting",IDC_CHECK_ENABLTAGSMATCHHILITE, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,201,117,131,10 + CONTROL "Attributes highlighting",IDC_CHECK_ENABLTAGATTRHILITE, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,214,131,131,10 END IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 370, 180 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 2c9c27cbc..513bf997e 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -548,17 +548,16 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara ::SendDlgItemMessage(_hSelf, IDC_EDIT_SESSIONFILEEXT, WM_SETTEXT, 0, (LPARAM)nppGUI._definedSessionExt.c_str()); - bool enableTaskList = nppGUI._doTaskList; - bool enableMaintainIndent = nppGUI._maitainIndent; - bool saveOpenKeepInSameDir = nppGUI._saveOpenKeepInSameDir; - bool styleMRU = nppGUI._styleMRU; - bool enableSmartHilite = nppGUI._enableSmartHilite; + ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCSWITCHER, BM_SETCHECK, nppGUI._doTaskList, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, nppGUI._maitainIndent, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_KEEPINSAMEDIR, BM_SETCHECK, nppGUI._saveOpenKeepInSameDir, 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_ENABLTAGSMATCHHILITE, BM_SETCHECK, nppGUI._enableTagsMatchHilite, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE, BM_SETCHECK, nppGUI._enableTagAttrsHilite, 0); + + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE), nppGUI._enableTagsMatchHilite); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCSWITCHER, BM_SETCHECK, enableTaskList, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, enableMaintainIndent, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_KEEPINSAMEDIR, BM_SETCHECK, saveOpenKeepInSameDir, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_STYLEMRU, BM_SETCHECK, styleMRU, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLSMARTHILITE, BM_SETCHECK, enableSmartHilite, 0); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); if (enableDlgTheme) enableDlgTheme(_hSelf, ETDT_ENABLETAB); @@ -703,8 +702,28 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara ::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATOR, 0, 0); } return TRUE; - } - + } + case IDC_CHECK_ENABLTAGSMATCHHILITE: + { + nppGUI._enableTagsMatchHilite = !nppGUI._enableTagsMatchHilite; + if (!nppGUI._enableTagsMatchHilite) + { + HWND grandParent = ::GetParent(_hParent); + ::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATORTAGMATCH, 0, 0); + } + ::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE), nppGUI._enableTagsMatchHilite); + return TRUE; + } + case IDC_CHECK_ENABLTAGATTRHILITE: + { + nppGUI._enableTagAttrsHilite = !nppGUI._enableTagAttrsHilite; + if (!nppGUI._enableTagAttrsHilite) + { + HWND grandParent = ::GetParent(_hParent); + ::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATORTAGATTR, 0, 0); + } + return TRUE; + } case IDC_CHECK_STYLEMRU : { nppGUI._styleMRU = !nppGUI._styleMRU; diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 60ee55b3e..805a28047 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -101,6 +101,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define IDC_DOCUMENTSWITCHER_STATIC (IDD_PREFERENCE_SETTING_BOX + 24) #define IDC_CHECK_UPDATEGOTOEOF (IDD_PREFERENCE_SETTING_BOX + 25) #define IDC_CHECK_ENABLSMARTHILITE (IDD_PREFERENCE_SETTING_BOX + 26) + #define IDC_CHECK_ENABLTAGSMATCHHILITE (IDD_PREFERENCE_SETTING_BOX + 27) + #define IDC_CHECK_ENABLTAGATTRHILITE (IDD_PREFERENCE_SETTING_BOX + 28) #define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400) #define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1) diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 5a2fffb52..483e9d8c9 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -289,6 +289,8 @@ #define NPPM_INTERNAL_SCINTILLAFINFERSELECTALL (NOTEPADPLUS_USER_INTERNAL + 17) #define NPPM_INTERNAL_SETCARETWIDTH (NOTEPADPLUS_USER_INTERNAL + 18) #define NPPM_INTERNAL_SETCARETBLINKRATE (NOTEPADPLUS_USER_INTERNAL + 19) + #define NPPM_INTERNAL_CLEARINDICATORTAGMATCH (NOTEPADPLUS_USER_INTERNAL + 20) + #define NPPM_INTERNAL_CLEARINDICATORTAGATTR (NOTEPADPLUS_USER_INTERNAL + 21) // See Notepad_plus_msgs.h //#define NOTEPADPLUS_USER (WM_USER + 1000) diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index 879abe924..a134cc225 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -606,6 +606,10 @@ RelativePath="..\src\resource.h" > + +