Make select text foreground color setting optional

Make selected text with syntax highlighting as default behaviour.
To override the default behaviour, user can add an empty xml file named "enableSelectFgColor.xml" (beside of "config.xml") to set the select foreground color in Style Configurator.
This commit is contained in:
Don HO 2021-05-01 20:02:09 +02:00
parent 44b2bef69b
commit cd1a468b1c
4 changed files with 27 additions and 14 deletions

View File

@ -1440,18 +1440,17 @@ bool NppParameters::load()
delete _pXmlExternalLexerDoc[i]; delete _pXmlExternalLexerDoc[i];
} }
//------------------------------// //-------------------------------------------------------------//
// blacklist.xml : for per user // // enableSelectFgColor.xml : for per user //
//------------------------------// // This empty xmj file is optional - user adds this empty file //
_blacklistPath = _userPath; // manually in order to set selected text's foreground color. //
PathAppend(_blacklistPath, TEXT("blacklist.xml")); //-------------------------------------------------------------//
generic_string enableSelectFgColorPath = _userPath;
PathAppend(enableSelectFgColorPath, TEXT("enableSelectFgColor.xml"));
if (PathFileExists(_blacklistPath.c_str())) if (PathFileExists(enableSelectFgColorPath.c_str()))
{ {
_pXmlBlacklistDoc = new TiXmlDocument(_blacklistPath); _isSelectFgColorEnabled = true;
loadOkay = _pXmlBlacklistDoc->LoadFile();
if (loadOkay)
getBlackListFromXmlTree();
} }
return isAllLaoded; return isAllLaoded;
} }

View File

@ -1810,6 +1810,7 @@ public:
void setAdminMode(bool isAdmin) { _isAdminMode = isAdmin; } void setAdminMode(bool isAdmin) { _isAdminMode = isAdmin; }
bool isAdmin() const { return _isAdminMode; } bool isAdmin() const { return _isAdminMode; }
bool regexBackward4PowerUser() const { return _findHistory._regexBackward4PowerUser; } bool regexBackward4PowerUser() const { return _findHistory._regexBackward4PowerUser; }
bool isSelectFgColorEnabled() const { return _isSelectFgColorEnabled; };
private: private:
bool _isAnyShortcutModified = false; bool _isAnyShortcutModified = false;
@ -1837,7 +1838,6 @@ private:
generic_string _shortcutsPath; generic_string _shortcutsPath;
generic_string _contextMenuPath; generic_string _contextMenuPath;
generic_string _sessionPath; generic_string _sessionPath;
generic_string _blacklistPath;
generic_string _nppPath; generic_string _nppPath;
generic_string _userPath; generic_string _userPath;
generic_string _stylerPath; generic_string _stylerPath;
@ -1873,6 +1873,8 @@ private:
bool _isElevationRequired = false; bool _isElevationRequired = false;
bool _isAdminMode = false; bool _isAdminMode = false;
bool _isSelectFgColorEnabled = false;
public: public:
generic_string getWingupFullPath() const { return _wingupFullPath; }; generic_string getWingupFullPath() const { return _wingupFullPath; };
generic_string getWingupParams() const { return _wingupParams; }; generic_string getWingupParams() const { return _wingupParams; };

View File

@ -2557,7 +2557,8 @@ void ScintillaEditView::expand(size_t& line, bool doExpand, bool force, int visL
void ScintillaEditView::performGlobalStyles() void ScintillaEditView::performGlobalStyles()
{ {
StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray(); NppParameters& nppParams = NppParameters::getInstance();
StyleArray & stylers = nppParams.getMiscStylerArray();
int i = stylers.getStylerIndexByName(TEXT("Current line background colour")); int i = stylers.getStylerIndexByName(TEXT("Current line background colour"));
if (i != -1) if (i != -1)
@ -2576,7 +2577,9 @@ void ScintillaEditView::performGlobalStyles()
selectColorFore = style._fgColor; selectColorFore = style._fgColor;
} }
execute(SCI_SETSELBACK, 1, selectColorBack); execute(SCI_SETSELBACK, 1, selectColorBack);
execute(SCI_SETSELFORE, 1, selectColorFore);
if (nppParams.isSelectFgColorEnabled())
execute(SCI_SETSELFORE, 1, selectColorFore);
COLORREF caretColor = black; COLORREF caretColor = black;
i = stylers.getStylerIndexByID(SCI_SETCARETFORE); i = stylers.getStylerIndexByID(SCI_SETCARETFORE);
@ -2640,7 +2643,7 @@ void ScintillaEditView::performGlobalStyles()
COLORREF foldfgColor = white, foldbgColor = grey, activeFoldFgColor = red; COLORREF foldfgColor = white, foldbgColor = grey, activeFoldFgColor = red;
getFoldColor(foldfgColor, foldbgColor, activeFoldFgColor); getFoldColor(foldfgColor, foldbgColor, activeFoldFgColor);
ScintillaViewParams & svp = (ScintillaViewParams &)NppParameters::getInstance().getSVP(); ScintillaViewParams & svp = (ScintillaViewParams &)nppParams.getSVP();
for (int j = 0 ; j < NB_FOLDER_STATE ; ++j) for (int j = 0 ; j < NB_FOLDER_STATE ; ++j)
defineMarker(_markersArray[FOLDER_TYPE][j], _markersArray[svp._folderStyle][j], foldfgColor, foldbgColor, activeFoldFgColor); defineMarker(_markersArray[FOLDER_TYPE][j], _markersArray[svp._folderStyle][j], foldfgColor, foldbgColor, activeFoldFgColor);

View File

@ -751,6 +751,15 @@ void WordStyleDlg::setVisualFromStyleList()
_pFgColour->setEnabled((style._colorStyle & COLORSTYLE_FOREGROUND) != 0); _pFgColour->setEnabled((style._colorStyle & COLORSTYLE_FOREGROUND) != 0);
isEnable = true; isEnable = true;
} }
// Selected text colour style
if (style._styleDesc && lstrcmp(style._styleDesc, TEXT("Selected text colour")) == 0)
{
isEnable = false; // disable by default for "Selected text colour" style
if (NppParameters::getInstance().isSelectFgColorEnabled())
isEnable = true;
}
enableFg(isEnable); enableFg(isEnable);
isEnable = false; isEnable = false;