[NEW_FEATURE] Make tag match highlighting on non html zone optional.

Fix bug that ansi->utf8 w/o BOM and utf8 w/o BOM-> ansi make buffer dirty.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@326 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-09-18 23:05:37 +00:00
parent 7b643b860d
commit 576ee8ea8c
6 changed files with 32 additions and 10 deletions

View File

@ -3683,9 +3683,11 @@ void Notepad_plus::command(int id)
Buffer * buf = _pEditView->getCurrentBuffer();
UniMode um;
bool shoulBeDirty = true;
switch (id)
{
case IDM_FORMAT_AS_UTF_8:
shoulBeDirty = buf->getUnicodeMode() != uni8Bit;
um = uniCookie;
break;
@ -3702,13 +3704,15 @@ void Notepad_plus::command(int id)
break;
default : // IDM_FORMAT_ANSI
shoulBeDirty = buf->getUnicodeMode() != uniCookie;
um = uni8Bit;
}
if (buf->getUnicodeMode() != um)
{
buf->setUnicodeMode(um);
buf->setDirty(true);
if (shoulBeDirty)
buf->setDirty(true);
}
break;
}

View File

@ -2451,6 +2451,10 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
const TCHAR *tahl = element->Attribute(TEXT("TagAttrHighLight"));
if (tahl)
_nppGUI._enableTagAttrsHilite = !lstrcmp(tahl, TEXT("yes"));
tahl = element->Attribute(TEXT("HighLightNonHtmlZone"));
if (tahl)
_nppGUI._enableHiliteNonHTMLZone = !lstrcmp(tahl, TEXT("yes"));
}
}
}
@ -3409,6 +3413,7 @@ bool NppParameters::writeGUIParams()
childNode->InsertEndChild(TiXmlText(pStr));
(childNode->ToElement())->SetAttribute(TEXT("TagAttrHighLight"), _nppGUI._enableTagAttrsHilite?TEXT("yes"):TEXT("no"));
(childNode->ToElement())->SetAttribute(TEXT("HighLightNonHtmlZone"), _nppGUI._enableHiliteNonHTMLZone?TEXT("yes"):TEXT("no"));
}
else if (!lstrcmp(nm, TEXT("TaskList")))
@ -3604,6 +3609,7 @@ bool NppParameters::writeGUIParams()
{
TiXmlElement * ele = insertGUIConfigBoolNode(GUIRoot, TEXT("TagsMatchHighLight"), _nppGUI._enableTagsMatchHilite);
ele->SetAttribute(TEXT("TagAttrHighLight"), _nppGUI._enableTagAttrsHilite?TEXT("yes"):TEXT("no"));
ele->SetAttribute(TEXT("HighLightNonHtmlZone"), _nppGUI._enableHiliteNonHTMLZone?TEXT("yes"):TEXT("no"));
}
if (!rememberLastSessionExist)
{

View File

@ -530,7 +530,7 @@ 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), _fileAutoDetectionOriginalValue(_fileAutoDetection),\
_checkHistoryFiles(true) ,_enableSmartHilite(true), _enableTagsMatchHilite(true), _enableTagAttrsHilite(true),\
_checkHistoryFiles(true) ,_enableSmartHilite(true), _enableTagsMatchHilite(true), _enableTagAttrsHilite(true), _enableHiliteNonHTMLZone(false),\
_isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\
_doTaskList(true), _maitainIndent(true), _openSaveDir(dir_followCurrent), _styleMRU(true), _styleURL(0),\
_autocStatus(autoc_none), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")), _neverUpdate(false),\
@ -579,7 +579,7 @@ struct NppGUI
bool _enableSmartHilite;
bool _enableTagsMatchHilite;
bool _enableTagAttrsHilite;
//bool _saveOpenKeepInSameDir;
bool _enableHiliteNonHTMLZone;
bool _styleMRU;
// 0 : do nothing

View File

@ -116,8 +116,9 @@ bool XmlMatchedTagsHighlighter::getMatchedTagPos(int searchStart, int searchEnd,
return false;
// if the tag is found in non html zone, we skip it
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
int idStyle = _pEditView->execute(SCI_GETSTYLEAT, ltPosOnR);
if (idStyle >= SCE_HJ_START)
if (idStyle >= SCE_HJ_START && !nppGUI._enableHiliteNonHTMLZone)
{
int start = (direction == search2Left)?foundPos.first:foundPos.second;
int end = searchEnd;
@ -259,8 +260,9 @@ bool XmlMatchedTagsHighlighter::getXmlMatchedTagsPos(XmlMatchedTagsPos & tagsPos
int caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
// if the tag is found in non html zone, then quit
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
int idStyle = _pEditView->execute(SCI_GETSTYLEAT, caretPos);
if (idStyle >= SCE_HJ_START)
if (!nppGUI._enableHiliteNonHTMLZone && idStyle >= SCE_HJ_START)
return false;
int docLen = _pEditView->getCurrentDocLen();
@ -444,9 +446,10 @@ void XmlMatchedTagsHighlighter::tagMatch(bool doHiliteAttr)
// Detect the current lang type. It works only with html and xml
LangType lang = (_pEditView->getCurrentBuffer())->getLangType();
if (lang != L_XML && lang != L_HTML && lang != L_PHP && lang != L_ASP)
return;
// Get the original targets and search options to restore after tag matching operation
int originalStartPos = _pEditView->execute(SCI_GETTARGETSTART);
int originalEndPos = _pEditView->execute(SCI_GETTARGETEND);

View File

@ -564,13 +564,14 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
::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);
::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);
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme)
@ -718,6 +719,7 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
::SendMessage(grandParent, NPPM_INTERNAL_CLEARINDICATORTAGMATCH, 0, 0);
}
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_ENABLTAGATTRHILITE), nppGUI._enableTagsMatchHilite);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_HIGHLITENONEHTMLZONE), nppGUI._enableTagsMatchHilite);
return TRUE;
}
case IDC_CHECK_ENABLTAGATTRHILITE:
@ -730,6 +732,13 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
}
return TRUE;
}
case IDC_CHECK_HIGHLITENONEHTMLZONE:
{
nppGUI._enableHiliteNonHTMLZone = !nppGUI._enableHiliteNonHTMLZone;
return TRUE;
}
case IDC_CHECK_STYLEMRU :
{
nppGUI._styleMRU = !nppGUI._styleMRU;

View File

@ -110,7 +110,7 @@
IntermediateDirectory="Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops;.\no_ms_shit.vsprops"
CharacterSet="1"
CharacterSet="2"
WholeProgramOptimization="1"
>
<Tool
@ -608,11 +608,11 @@
>
</File>
<File
RelativePath="..\src\resource.h"
RelativePath="..\src\WinControls\Preference\resource.h"
>
</File>
<File
RelativePath="..\src\WinControls\Preference\resource.h"
RelativePath="..\src\resource.h"
>
</File>
<File