[NEW_FEATURE] Add hilighting all token wile selecting a word (finished).

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@173 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-04-20 02:17:21 +00:00
parent 544a4916d9
commit 52ebeee049
8 changed files with 75 additions and 31 deletions

View File

@ -8251,6 +8251,10 @@ bool Notepad_plus::str2Cliboard(const char *str2cpy)
void Notepad_plus::markSelectedText() void Notepad_plus::markSelectedText()
{ {
const NppGUI & nppGUI = (NppParameters::getInstance())->getNppGUI();
if (!nppGUI._enableSmartHilite)
return;
//Get selection //Get selection
CharacterRange range = _pEditView->getSelection(); CharacterRange range = _pEditView->getSelection();
//Dont mark if the selection has not changed. //Dont mark if the selection has not changed.

View File

@ -2263,6 +2263,22 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
} }
} }
else if (!strcmp(nm, "SmartHighLight"))
{
TiXmlNode *n = childNode->FirstChild();
if (n)
{
val = n->Value();
if (val)
{
if (!strcmp(val, "yes"))
_nppGUI._enableSmartHilite = true;
else
_nppGUI._enableSmartHilite = false;
}
}
}
else if (!strcmp(nm, "TaskList")) else if (!strcmp(nm, "TaskList"))
{ {
TiXmlNode *n = childNode->FirstChild(); TiXmlNode *n = childNode->FirstChild();
@ -3001,6 +3017,7 @@ bool NppParameters::writeGUIParams()
bool sessionExtExist = false; bool sessionExtExist = false;
bool noUpdateExist = false; bool noUpdateExist = false;
bool menuBarExist = false; bool menuBarExist = false;
bool smartHighLightExist = false;
TiXmlNode *dockingParamNode = NULL; TiXmlNode *dockingParamNode = NULL;
@ -3157,7 +3174,16 @@ bool NppParameters::writeGUIParams()
else else
childNode->InsertEndChild(TiXmlText(pStr)); childNode->InsertEndChild(TiXmlText(pStr));
} }
else if (!strcmp(nm, "SmartHighLight"))
{
smartHighLightExist = true;
const char *pStr = _nppGUI._enableSmartHilite?"yes":"no";
TiXmlNode *n = childNode->FirstChild();
if (n)
n->SetValue(pStr);
else
childNode->InsertEndChild(TiXmlText(pStr));
}
else if (!strcmp(nm, "SaveOpenFileInSameDir")) else if (!strcmp(nm, "SaveOpenFileInSameDir"))
{ {
saveOpenFileInSameDirExist = true; saveOpenFileInSameDirExist = true;
@ -3346,6 +3372,11 @@ bool NppParameters::writeGUIParams()
insertGUIConfigBoolNode(GUIRoot, "MaitainIndent", _nppGUI._maitainIndent); insertGUIConfigBoolNode(GUIRoot, "MaitainIndent", _nppGUI._maitainIndent);
} }
if (!smartHighLightExist)
{
insertGUIConfigBoolNode(GUIRoot, "SmartHighLight", _nppGUI._enableSmartHilite);
}
if (!rememberLastSessionExist) if (!rememberLastSessionExist)
{ {
insertGUIConfigBoolNode(GUIRoot, "RememberLastSession", _nppGUI._rememberLastSession); insertGUIConfigBoolNode(GUIRoot, "RememberLastSession", _nppGUI._rememberLastSession);

View File

@ -526,7 +526,7 @@ struct NppGUI
NppGUI() : _toolBarStatus(TB_LARGE), _toolbarShow(true), _statusBarShow(true), _menuBarShow(true),\ NppGUI() : _toolBarStatus(TB_LARGE), _toolbarShow(true), _statusBarShow(true), _menuBarShow(true),\
_tabStatus(TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP),\ _tabStatus(TAB_DRAWTOPBAR | TAB_DRAWINACTIVETAB | TAB_DRAGNDROP),\
_splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\ _splitterPos(POS_HORIZOTAL), _userDefineDlgStatus(UDD_DOCKED), _tabSize(8),\
_tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true),\ _tabReplacedBySpace(false), _fileAutoDetection(cdEnabled), _checkHistoryFiles(true) ,_enableSmartHilite(true),\
_isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\ _isMaximized(false), _isMinimizedToTray(false), _rememberLastSession(true), _backup(bak_none), _useDir(false),\
_doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0), _doTaskList(true), _maitainIndent(true), _saveOpenKeepInSameDir(false), _styleMRU(true), _styleURL(0),
_autocStatus(autoc_none), _autocFromLen(1), _definedSessionExt(""), _neverUpdate(false), _doesExistUpdater(false){ _autocStatus(autoc_none), _autocFromLen(1), _definedSessionExt(""), _neverUpdate(false), _doesExistUpdater(false){
@ -568,6 +568,7 @@ struct NppGUI
bool _rememberLastSession; bool _rememberLastSession;
bool _doTaskList; bool _doTaskList;
bool _maitainIndent; bool _maitainIndent;
bool _enableSmartHilite;
bool _saveOpenKeepInSameDir; bool _saveOpenKeepInSameDir;
bool _styleMRU; bool _styleMRU;

View File

@ -49,14 +49,17 @@ void Buffer::setFileName(const char *fn, LangType defaultLang)
LangType Buffer::getLangFromExt(const char *ext) LangType Buffer::getLangFromExt(const char *ext)
{ {
int i = 0; NppParameters *pNppParam = NppParameters::getInstance();
Lang *l = NppParameters::getInstance()->getLangFromIndex(i++); int i = pNppParam->getNbLang();
while (l) i--;
while (i >= 0)
{ {
Lang *l = pNppParam->getLangFromIndex(i--);
const char *defList = l->getDefaultExtList(); const char *defList = l->getDefaultExtList();
const char *userList = NULL; const char *userList = NULL;
LexerStylerArray &lsa = (NppParameters::getInstance())->getLStylerArray(); LexerStylerArray &lsa = pNppParam->getLStylerArray();
const char *lName = l->getLangName(); const char *lName = l->getLangName();
LexerStyler *pLS = lsa.getLexerStylerByName(lName); LexerStyler *pLS = lsa.getLexerStylerByName(lName);
@ -73,7 +76,6 @@ LangType Buffer::getLangFromExt(const char *ext)
} }
if (isInList(ext, list.c_str())) if (isInList(ext, list.c_str()))
return l->getLangID(); return l->getLangID();
l = (NppParameters::getInstance())->getLangFromIndex(i++);
} }
return L_TXT; return L_TXT;
} }

View File

@ -343,13 +343,14 @@ private :
Lang * getCurrentLang() const { Lang * getCurrentLang() const {
NppParameters *pNppParam = NppParameters::getInstance(); NppParameters *pNppParam = NppParameters::getInstance();
int i = pNppParam->getNbLang(); int i = 0;
while (i >= 0) Lang *l = pNppParam->getLangFromIndex(i++);
while (l)
{ {
Lang *l = pNppParam->getLangFromIndex(i--);
if (l->_langID == _lang) if (l->_langID == _lang)
return l; return l;
//l = (NppParameters::getInstance())->getLangFromIndex(i++);
l = pNppParam->getLangFromIndex(i++);
} }
return NULL; return NULL;
}; };

View File

@ -91,32 +91,33 @@ BEGIN
RTEXT "Tab size : ",IDC_TABSIZE_STATIC,18,14,58,8 RTEXT "Tab size : ",IDC_TABSIZE_STATIC,18,14,58,8
LTEXT "0",IDC_TABSIZEVAL_STATIC,78,14,18,8 LTEXT "0",IDC_TABSIZEVAL_STATIC,78,14,18,8
GROUPBOX "History File Setting",IDC_HISTORY_GB_STATIC,193,4,150,39,BS_CENTER GROUPBOX "History File Setting",IDC_HISTORY_GB_STATIC,193,4,150,39,BS_CENTER
CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY, CONTROL "Don't check at launch time",IDC_CHECK_DONTCHECKHISTORY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,27,133,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,27,133,10
RTEXT "Max number history file :",IDC_MAXNBFILE_STATIC,196,14,112,8 RTEXT "Max number history file :",IDC_MAXNBFILE_STATIC,196,14,112,8
LTEXT "0",IDC_MAXNBFILEVAL_STATIC,315,14,15,8 LTEXT "0",IDC_MAXNBFILEVAL_STATIC,315,14,15,8
CONTROL "Minimize to sys tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,163,130,10
CONTROL "Remember the current session for next launch",IDC_CHECK_REMEMBERSESSION,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,133,217,11
CONTROL "Enable Notepad++ auto-updater",IDC_CHECK_AUTOUPDATE,
"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,16,102,150,10
CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,58,98,10 CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,58,98,10
GROUPBOX "Clickable link setting",IDC_CLICKABLELINK_STATIC,193,47,150,39,BS_CENTER GROUPBOX "Clickable link setting",IDC_CLICKABLELINK_STATIC,193,47,150,39,BS_CENTER
CONTROL "Don't draw underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, CONTROL "Don't draw underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,71,119,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,71,119,10
EDITTEXT IDC_EDIT_SESSIONFILEEXT,298,162,67,14,ES_AUTOHSCROLL EDITTEXT IDC_EDIT_SESSIONFILEEXT,298,162,67,14,ES_AUTOHSCROLL
LTEXT "Session file ext:",IDC_SESSIONFILEEXT_STATIC,300,150,66,8 LTEXT "Session file ext:",IDC_SESSIONFILEEXT_STATIC,300,150,66,8
CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,117,130,10
CONTROL "Remember the last operation directory",IDC_CHECK_KEEPINSAMEDIR,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,148,210,10
CONTROL "Enable",IDC_CHECK_ENABLEDOCSWITCHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,59,69,10 CONTROL "Enable",IDC_CHECK_ENABLEDOCSWITCHER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,59,69,10
CONTROL "Enable MRU behaviour",IDC_CHECK_STYLEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,72,134,10 CONTROL "Enable MRU behaviour",IDC_CHECK_STYLEMRU,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,72,134,10
GROUPBOX "Document switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,15,48,150,39,BS_CENTER GROUPBOX "Document switcher (Ctrl+TAB)",IDC_DOCUMENTSWITCHER_STATIC,15,48,150,39,BS_CENTER
CONTROL "Enable",IDC_CHECK_FILEAUTODETECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,100,98,10 CONTROL "Enable",IDC_CHECK_FILEAUTODETECTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,100,98,10
GROUPBOX "File Status Auto-detection",IDC_FILEAUTODETECTION_STATIC,193,90,150,50,BS_CENTER GROUPBOX "File Status Auto-detection",IDC_FILEAUTODETECTION_STATIC,193,90,150,50,BS_CENTER
CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,112,103,10 CONTROL "Update silently",IDC_CHECK_UPDATESILENTLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,112,103,10
CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF, CONTROL "Scroll to the last line after update",IDC_CHECK_UPDATEGOTOEOF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,124,141,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,201,124,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
CONTROL "Remember the last operation directory",IDC_CHECK_KEEPINSAMEDIR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
16,151,210,10
CONTROL "Remember the current session for next launch",IDC_CHECK_REMEMBERSESSION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
16,165,217,10
END END
IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 370, 180 IDD_PREFERENCE_NEWDOCSETTING_BOX DIALOGEX 0, 0, 370, 180

View File

@ -506,11 +506,13 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
bool enableMaintainIndent = nppGUI._maitainIndent; bool enableMaintainIndent = nppGUI._maitainIndent;
bool saveOpenKeepInSameDir = nppGUI._saveOpenKeepInSameDir; bool saveOpenKeepInSameDir = nppGUI._saveOpenKeepInSameDir;
bool styleMRU = nppGUI._styleMRU; bool styleMRU = nppGUI._styleMRU;
bool enableSmartHilite = nppGUI._enableSmartHilite;
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCSWITCHER, BM_SETCHECK, enableTaskList, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLEDOCSWITCHER, BM_SETCHECK, enableTaskList, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, enableMaintainIndent, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_MAINTAININDENT, BM_SETCHECK, enableMaintainIndent, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_KEEPINSAMEDIR, BM_SETCHECK, saveOpenKeepInSameDir, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_KEEPINSAMEDIR, BM_SETCHECK, saveOpenKeepInSameDir, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_STYLEMRU, BM_SETCHECK, styleMRU, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_STYLEMRU, BM_SETCHECK, styleMRU, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ENABLSMARTHILITE, BM_SETCHECK, enableSmartHilite, 0);
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
if (enableDlgTheme) if (enableDlgTheme)
enableDlgTheme(_hSelf, ETDT_ENABLETAB); enableDlgTheme(_hSelf, ETDT_ENABLETAB);
@ -633,7 +635,6 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
case IDC_CHECK_ENABLEDOCSWITCHER : case IDC_CHECK_ENABLEDOCSWITCHER :
{ {
NppGUI & nppGUI = (NppGUI &)NppParameters::getInstance()->getNppGUI();
nppGUI._doTaskList = !nppGUI._doTaskList; nppGUI._doTaskList = !nppGUI._doTaskList;
if (nppGUI._doTaskList) if (nppGUI._doTaskList)
{ {
@ -650,21 +651,24 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPara
case IDC_CHECK_KEEPINSAMEDIR : case IDC_CHECK_KEEPINSAMEDIR :
{ {
NppGUI & nppGUI = (NppGUI &)NppParameters::getInstance()->getNppGUI();
nppGUI._saveOpenKeepInSameDir = !nppGUI._saveOpenKeepInSameDir; nppGUI._saveOpenKeepInSameDir = !nppGUI._saveOpenKeepInSameDir;
return TRUE; return TRUE;
} }
case IDC_CHECK_MAINTAININDENT : case IDC_CHECK_MAINTAININDENT :
{ {
NppGUI & nppGUI = (NppGUI &)NppParameters::getInstance()->getNppGUI();
nppGUI._maitainIndent = !nppGUI._maitainIndent; nppGUI._maitainIndent = !nppGUI._maitainIndent;
return TRUE; return TRUE;
} }
case IDC_CHECK_ENABLSMARTHILITE :
{
nppGUI._enableSmartHilite = !nppGUI._enableSmartHilite;
return TRUE;
}
case IDC_CHECK_STYLEMRU : case IDC_CHECK_STYLEMRU :
{ {
NppGUI & nppGUI = (NppGUI &)NppParameters::getInstance()->getNppGUI();
nppGUI._styleMRU = !nppGUI._styleMRU; nppGUI._styleMRU = !nppGUI._styleMRU;
return TRUE; return TRUE;
} }

View File

@ -92,7 +92,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#define IDC_CHECK_AUTOUPDATE (IDD_PREFERENCE_SETTING_BOX + 23) #define IDC_CHECK_AUTOUPDATE (IDD_PREFERENCE_SETTING_BOX + 23)
#define IDC_DOCUMENTSWITCHER_STATIC (IDD_PREFERENCE_SETTING_BOX + 24) #define IDC_DOCUMENTSWITCHER_STATIC (IDD_PREFERENCE_SETTING_BOX + 24)
#define IDC_CHECK_UPDATEGOTOEOF (IDD_PREFERENCE_SETTING_BOX + 25) #define IDC_CHECK_UPDATEGOTOEOF (IDD_PREFERENCE_SETTING_BOX + 25)
#define IDC_CHECK_ENABLEMAEKALLWORDS (IDD_PREFERENCE_SETTING_BOX + 26) #define IDC_CHECK_ENABLSMARTHILITE (IDD_PREFERENCE_SETTING_BOX + 26)
#define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400) #define IDD_PREFERENCE_NEWDOCSETTING_BOX 6400 //(IDD_PREFERENCE_BOX + 400)
#define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1) #define IDC_FORMAT_GB_STATIC (IDD_PREFERENCE_NEWDOCSETTING_BOX + 1)