diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 0e1a06d08..3b3feff28 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5296,7 +5296,7 @@ void NppParameters::writeStyle2Element(Style & style2Write, Style & style2Sync, } } - if (style2Write._fontSize != -1) + if (style2Write._fontSize != STYLE_NOT_USED) { if (!style2Write._fontSize) element->SetAttribute(TEXT("fontSize"), TEXT("")); @@ -5304,7 +5304,7 @@ void NppParameters::writeStyle2Element(Style & style2Write, Style & style2Sync, element->SetAttribute(TEXT("fontSize"), style2Write._fontSize); } - if (style2Write._fontStyle != -1) + if (style2Write._fontStyle != STYLE_NOT_USED) { element->SetAttribute(TEXT("fontStyle"), style2Write._fontStyle); } @@ -5392,7 +5392,7 @@ void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *user styleElement->SetAttribute(TEXT("fontName"), style2Write._fontName); } - if (style2Write._fontStyle == -1) + if (style2Write._fontStyle == STYLE_NOT_USED) { styleElement->SetAttribute(TEXT("fontStyle"), TEXT("0")); } @@ -5401,7 +5401,7 @@ void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *user styleElement->SetAttribute(TEXT("fontStyle"), style2Write._fontStyle); } - if (style2Write._fontSize != -1) + if (style2Write._fontSize != STYLE_NOT_USED) { if (!style2Write._fontSize) styleElement->SetAttribute(TEXT("fontSize"), TEXT("")); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 46249f35e..7d8585773 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -257,6 +257,8 @@ const int FONTSTYLE_BOLD = 1; const int FONTSTYLE_ITALIC = 2; const int FONTSTYLE_UNDERLINE = 4; +const int STYLE_NOT_USED = -1; + const int COLORSTYLE_FOREGROUND = 0x01; const int COLORSTYLE_BACKGROUND = 0x02; const int COLORSTYLE_ALL = COLORSTYLE_FOREGROUND|COLORSTYLE_BACKGROUND; @@ -277,7 +279,8 @@ struct Style int _keywordClass; generic_string *_keywords; - Style():_styleID(-1), _styleDesc(NULL), _fgColor(COLORREF(-1)), _bgColor(COLORREF(-1)), _colorStyle(COLORSTYLE_ALL), _fontName(NULL), _fontStyle(-1), _fontSize(-1), _keywordClass(-1), _keywords(NULL){}; + Style():_styleID(-1), _styleDesc(NULL), _fgColor(COLORREF(STYLE_NOT_USED)), _bgColor(COLORREF(STYLE_NOT_USED)), _colorStyle(COLORSTYLE_ALL),\ + _fontName(NULL), _fontStyle(STYLE_NOT_USED), _fontSize(STYLE_NOT_USED), _keywordClass(STYLE_NOT_USED), _keywords(NULL){}; ~Style(){ if (_keywords) diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index c2142c736..f0077ab20 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -424,7 +424,7 @@ void ScintillaEditView::setSpecialStyle(const Style & styleToSet) #endif } int fontStyle = styleToSet._fontStyle; - if (fontStyle != -1) + if (fontStyle != STYLE_NOT_USED) { execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD); execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC); @@ -489,7 +489,7 @@ void ScintillaEditView::setStyle(Style styleToSet) if (go.enableFontSize && (style._fontSize > 0)) styleToSet._fontSize = style._fontSize; - if (style._fontStyle != -1) + if (style._fontStyle != STYLE_NOT_USED) { if (go.enableBold) { @@ -771,7 +771,7 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName) { Style & style = userLangContainer->_styleArray.getStyler(i); - if (style._styleID == -1) + if (style._styleID == STYLE_NOT_USED) continue; if (i < 10) itoa(i, (nestingBuffer+20), 10); @@ -1140,7 +1140,7 @@ void ScintillaEditView::makeStyle(LangType language, const TCHAR **keywordArray) setStyle(style); if (keywordArray) { - if ((style._keywordClass != -1) && (style._keywords)) + if ((style._keywordClass != STYLE_NOT_USED) && (style._keywords)) keywordArray[style._keywordClass] = style._keywords->c_str(); } } @@ -2196,15 +2196,7 @@ void ScintillaEditView::performGlobalStyles() Style & style = stylers.getStyler(i); execute(SCI_SETCARETLINEBACK, style._bgColor); } -/* - i = stylers.getStylerIndexByName(TEXT("Mark colour")); - if (i != -1) - { - Style & style = stylers.getStyler(i); - execute(SCI_MARKERSETFORE, 1, style._fgColor); - execute(SCI_MARKERSETBACK, 1, style._bgColor); - } -*/ + COLORREF selectColorBack = grey; i = stylers.getStylerIndexByName(TEXT("Selected text colour")); @@ -2270,26 +2262,6 @@ void ScintillaEditView::performGlobalStyles() execute(SCI_MARKERENABLEHIGHLIGHT, true); - -/* - COLORREF unsavedChangebgColor = liteRed; - i = stylers.getStylerIndexByName(TEXT("Unsaved change marker")); - if (i != -1) - { - Style & style = stylers.getStyler(i); - unsavedChangebgColor = style._bgColor; - } - execute(SCI_MARKERSETBACK, MARK_LINEMODIFIEDUNSAVED, unsavedChangebgColor); - - COLORREF savedChangebgColor = liteBlueGreen; - i = stylers.getStylerIndexByName(TEXT("Saved change marker")); - if (i != -1) - { - Style & style = stylers.getStyler(i); - savedChangebgColor = style._bgColor; - } - execute(SCI_MARKERSETBACK, MARK_LINEMODIFIEDSAVED, savedChangebgColor); -*/ COLORREF wsSymbolFgColor = black; i = stylers.getStylerIndexByName(TEXT("White space symbol")); if (i != -1) diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index e268903ce..34e289708 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -546,13 +546,13 @@ void WordStyleDlg::updateFontSize() { ::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr); if (!intStr[0]) - style._fontSize = -1; + style._fontSize = STYLE_NOT_USED; else { TCHAR *finStr; style._fontSize = generic_strtol(intStr, &finStr, 10); if (*finStr != '\0') - style._fontSize = -1; + style._fontSize = STYLE_NOT_USED; } } else @@ -592,8 +592,8 @@ void WordStyleDlg::updateFontName() void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle) { Style & style = getCurrentStyler(); - if (style._fontStyle == -1) - style._fontStyle = 0; + if (style._fontStyle == STYLE_NOT_USED) + style._fontStyle = FONTSTYLE_NONE; int fontStyle = FONTSTYLE_UNDERLINE; HWND hWnd = _hCheckUnderline; @@ -774,7 +774,7 @@ void WordStyleDlg::setVisualFromStyleList() isEnable = false; TCHAR intStr[5] = TEXT(""); int iFontSize = 0; - if (style._fontSize != -1) + if (style._fontSize != STYLE_NOT_USED) { wsprintf(intStr, TEXT("%d"), style._fontSize); iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, (LPARAM)intStr); @@ -786,7 +786,7 @@ void WordStyleDlg::setVisualFromStyleList() //-- font style : bold & italic isEnable = false; int isBold, isItalic, isUnderline; - if (style._fontStyle != -1) + if (style._fontStyle != STYLE_NOT_USED) { isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED; @@ -796,7 +796,7 @@ void WordStyleDlg::setVisualFromStyleList() ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); isEnable = true; } - else // -1 : reset them all + else // STYLE_NOT_USED : reset them all { ::SendMessage(_hCheckBold, BM_SETCHECK, BST_UNCHECKED, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, BST_UNCHECKED, 0); @@ -807,7 +807,7 @@ void WordStyleDlg::setVisualFromStyleList() //-- Default Keywords - bool shouldBeDisplayed = style._keywordClass != -1; + bool shouldBeDisplayed = style._keywordClass != STYLE_NOT_USED; if (shouldBeDisplayed) { LexerStyler & lexerStyler = _lsArray.getLexerFromIndex(_currentLexerIndex - 1);