diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 708d9f6b5..2793ba653 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -275,6 +275,19 @@ struct Style }; }; +struct GlobalOverride +{ + bool isEnable() const {return (enableFg || enableBg || enableFont || enableFontSize || enableBold || enableItalic || enableUnderLine);}; + bool enableFg; + bool enableBg; + bool enableFont; + bool enableFontSize; + bool enableBold; + bool enableItalic; + bool enableUnderLine; + GlobalOverride():enableFg(false), enableBg(false), enableFont(false), enableFontSize(false), enableBold(false), enableItalic(false), enableUnderLine(false) {}; +}; + const int MAX_STYLE = 30; struct StyleArray @@ -528,6 +541,7 @@ struct NppGUI bool _useDir; char _backupDir[MAX_PATH]; DockingManagerData _dockingData; + GlobalOverride _globalOverride; }; struct ScintillaViewParams @@ -779,6 +793,7 @@ public: StyleArray & getGlobalStylers() {return _widgetStyleArray;}; StyleArray & getMiscStylerArray() {return _widgetStyleArray;}; + GlobalOverride & getGlobalOverrideStyle() {return _nppGUI._globalOverride;}; COLORREF getCurLineHilitingColour() { int i = _widgetStyleArray.getStylerIndexByName("Current line background colour"); diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index b5a79befa..0646d6a02 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -1023,7 +1023,6 @@ int FindReplaceDlg::processAll(int op, bool isEntire, const char *fileName, cons ascii_to_utf8(fileName, fileNameLen, _uniFileName); */ pLine = _uniCharLine; - //_pFinder->add(FoundInfo(start, end, _uniCharLine, _uniFileName, _pFinder->_lineCounter), lineNumber + 1); } else { diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index e8d3121b8..cb737c429 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -154,8 +154,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa } return ::CallWindowProc(_scintillaDefaultProc, hwnd, Message, wParam, lParam); } - -void ScintillaEditView::setStyle(int styleID, COLORREF fgColour, COLORREF bgColour, const char *fontName, int fontStyle, int fontSize) +void ScintillaEditView::setSpecialStyle(int styleID, COLORREF fgColour, COLORREF bgColour, const char *fontName, int fontStyle, int fontSize) { if (!((fgColour >> 24) & 0xFF)) execute(SCI_STYLESETFORE, styleID, fgColour); @@ -178,7 +177,50 @@ void ScintillaEditView::setStyle(int styleID, COLORREF fgColour, COLORREF bgColo if (fontSize > 0) execute(SCI_STYLESETSIZE, styleID, fontSize); +} +void ScintillaEditView::setStyle(int styleID, COLORREF fgColour, COLORREF bgColour, const char *fontName, int fontStyle, int fontSize) +{ + GlobalOverride & go = _pParameter->getGlobalOverrideStyle(); + //go.enableBg = true; + + const char *localFn = fontName; + + if (go.isEnable()) + { + StyleArray & stylers = _pParameter->getMiscStylerArray(); + int i = stylers.getStylerIndexByName("Global override"); + if (i != -1) + { + Style & style = stylers.getStyler(i); + + if (go.enableFg) + fgColour = style._fgColor; + if (go.enableBg) + bgColour = style._bgColor; + if (go.enableFont && style._fontName && style._fontName[0]) + localFn = style._fontName; + if (go.enableFontSize && (style._fontSize > 0)) + fontSize = style._fontSize; + + if (style._fontStyle != -1) + { + if (go.enableBold) + { + fontStyle |= (style._fontStyle & FONTSTYLE_BOLD)?FONTSTYLE_BOLD:~FONTSTYLE_BOLD; + } + if (go.enableItalic) + { + fontStyle |= (style._fontStyle & FONTSTYLE_ITALIC)?FONTSTYLE_ITALIC:~FONTSTYLE_ITALIC; + } + if (go.enableUnderLine) + { + fontStyle |= (style._fontStyle & FONTSTYLE_UNDERLINE)?FONTSTYLE_UNDERLINE:~FONTSTYLE_UNDERLINE; + } + } + } + } + setSpecialStyle(styleID, fgColour, bgColour, localFn, fontStyle, fontSize); } @@ -515,14 +557,14 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); - setStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); + setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); } iFind = stylers.getStylerIndexByID(SCE_UNIVERSAL_SELECT_STYLE); if (iFind != -1) { Style & styleFind = stylers.getStyler(iFind); - setStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); + setSpecialStyle(styleFind._styleID, styleFind._fgColor, styleFind._bgColor, styleFind._fontName, styleFind._fontStyle, styleFind._fontSize); } int caretWidth = 1; @@ -718,7 +760,7 @@ void ScintillaEditView::defineDocType(LangType typeDoc) if (indexLineNumber != -1) { static Style & styleLN = stylers.getStyler(indexLineNumber); - setStyle(styleLN._styleID, styleLN._fgColor, styleLN._bgColor, styleLN._fontName, styleLN._fontStyle, styleLN._fontSize); + setSpecialStyle(styleLN._styleID, styleLN._fgColor, styleLN._bgColor, styleLN._fontName, styleLN._fontStyle, styleLN._fontSize); } execute(SCI_SETTABWIDTH, ((NppParameters::getInstance())->getNppGUI())._tabSize); diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index b94220faa..7ae8662fc 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -621,6 +621,7 @@ protected: int _maxNbDigit; // For Line Number Marge void setStyle(int styleID, COLORREF fgColor, COLORREF bgColor = -1, const char *fontName = NULL, int fontStyle = -1, int fontSize = 0); + void setSpecialStyle(int styleID, COLORREF fgColor, COLORREF bgColor = -1, const char *fontName = NULL, int fontStyle = -1, int fontSize = 0); void setCppLexer(LangType type); void setXmlLexer(LangType type); void setUserLexer(); @@ -678,9 +679,9 @@ protected: }; void setTeXLexer() { + for (int i = 0 ; i < 4 ; i++) + execute(SCI_SETKEYWORDS, i, reinterpret_cast("")); setLexer(SCLEX_TEX, L_TEX, "tex", 0); - //execute(SCI_SETLEXER, SCLEX_TEX); - //makeStyle("tex"); }; void setNsisLexer() { diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index 35204dcb8..815c947eb 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -73,7 +73,6 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar ::SendDlgItemMessage(_hSelf, IDC_LANGUAGES_LIST, LB_ADDSTRING, 0, (LPARAM)_lsArray.getLexerDescFromIndex(i)); } - //_hStyleList = ::GetDlgItem(_hSelf, IDC_STYLES_LIST); _hCheckBold = ::GetDlgItem(_hSelf, IDC_BOLD_CHECK); _hCheckItalic = ::GetDlgItem(_hSelf, IDC_ITALIC_CHECK); _hCheckUnderline = ::GetDlgItem(_hSelf, IDC_UNDERLINE_CHECK); @@ -242,6 +241,43 @@ BOOL CALLBACK WordStyleDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPar return TRUE; } + case IDC_GLOBAL_FG_CHECK : + { + + return TRUE; + } + + case IDC_GLOBAL_BG_CHECK : + printStr("touched!"); + return TRUE; + + case IDC_GLOBAL_FONT_CHECK : + { + + return TRUE; + } + case IDC_GLOBAL_FONTSIZE_CHECK : + { + + return TRUE; + } + case IDC_GLOBAL_BOLD_CHECK : + { + + return TRUE; + } + + case IDC_GLOBAL_ITALIC_CHECK : + { + + return TRUE; + } + case IDC_GLOBAL_UNDERLINE_CHECK : + { + + return TRUE; + } + default: switch (HIWORD(wParam)) { @@ -436,9 +472,17 @@ void WordStyleDlg::setStyleListFromLexer(int index) void WordStyleDlg::setVisualFromStyleList() { + if (_isShownGOCtrls) + showGlobalOverrideCtrls(false); Style & style = getCurrentStyler(); + // Global override style + if (strcmp(style._styleDesc, "Global override") == 0) + { + showGlobalOverrideCtrls(true); + } + //--Warning text bool showWarning = ((_currentLexerIndex == 0) && (style._styleID == STYLE_DEFAULT));//?SW_SHOW:SW_HIDE; diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h index 95facf5fc..c7eb63509 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h @@ -114,6 +114,7 @@ private : bool _isDirty; bool _isSync; + bool _isShownGOCtrls; BOOL CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam); @@ -169,6 +170,18 @@ private : } void setStyleListFromLexer(int index); void setVisualFromStyleList(); + + void showGlobalOverrideCtrls(bool show) + { + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FG_CHECK), show?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_BG_CHECK), show?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FONT_CHECK), show?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_FONTSIZE_CHECK), show?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_BOLD_CHECK), show?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_ITALIC_CHECK), show?SW_SHOW:SW_HIDE); + ::ShowWindow(::GetDlgItem(_hSelf, IDC_GLOBAL_UNDERLINE_CHECK), show?SW_SHOW:SW_HIDE); + _isShownGOCtrls = show; + } }; #endif //WORD_STYLE_H diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc index 3a49e677f..52703de04 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.rc @@ -64,5 +64,12 @@ BEGIN LTEXT "Language :",IDC_LANGDESC_STATIC,19,10,61,8 GROUPBOX "",IDC_STATIC,181,0,310,184 LTEXT "+",IDC_PLUSSYMBOL2_STATIC,83,193,8,8 + CONTROL "Enable global foreground color",IDC_GLOBAL_FG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,114,132,10 + CONTROL "Enable global background color",IDC_GLOBAL_BG_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,129,131,10 + CONTROL "Enable global font",IDC_GLOBAL_FONT_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,110,153,10 + CONTROL "Enable global font size",IDC_GLOBAL_FONTSIZE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,327,125,135,10 + CONTROL "Enable global bold font style",IDC_GLOBAL_BOLD_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,140,135,10 + CONTROL "Enable global Italic font style",IDC_GLOBAL_ITALIC_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,155,135,10 + CONTROL "Enable global underline font style",IDC_GLOBAL_UNDERLINE_CHECK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,328,170,135,10 END diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h index b67a39653..2aca3a5b5 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlgRes.h @@ -45,6 +45,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define IDC_PLUSSYMBOL_STATIC (IDD_STYLER_DLG + 23) #define IDC_PLUSSYMBOL2_STATIC (IDD_STYLER_DLG + 24) #define IDC_LANGDESC_STATIC (IDD_STYLER_DLG + 25) + + #define IDC_GLOBAL_FG_CHECK (IDD_STYLER_DLG + 26) + #define IDC_GLOBAL_BG_CHECK (IDD_STYLER_DLG + 27) + #define IDC_GLOBAL_FONT_CHECK (IDD_STYLER_DLG + 28) + #define IDC_GLOBAL_FONTSIZE_CHECK (IDD_STYLER_DLG + 29) + #define IDC_GLOBAL_BOLD_CHECK (IDD_STYLER_DLG + 30) + #define IDC_GLOBAL_ITALIC_CHECK (IDD_STYLER_DLG + 31) + #define IDC_GLOBAL_UNDERLINE_CHECK (IDD_STYLER_DLG + 32) # define IDD_GLOBAL_STYLER_DLG 2300 #define IDC_SAVECLOSE_BUTTON (IDD_GLOBAL_STYLER_DLG + 1) diff --git a/PowerEditor/src/stylers.xml b/PowerEditor/src/stylers.xml index fd52701de..3d0f9f45d 100644 --- a/PowerEditor/src/stylers.xml +++ b/PowerEditor/src/stylers.xml @@ -346,10 +346,10 @@ - + - + @@ -691,6 +691,7 @@ + diff --git a/PowerEditor/visual.net/notepadPlus.vcproj b/PowerEditor/visual.net/notepadPlus.vcproj index b8f9f2baa..4affacc55 100644 --- a/PowerEditor/visual.net/notepadPlus.vcproj +++ b/PowerEditor/visual.net/notepadPlus.vcproj @@ -1,7 +1,7 @@