[UPDATE] Add STYLE_NOT_USED constant to make source code more readable.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@982 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
cb383ab1b6
commit
60ed8107ba
|
@ -5296,7 +5296,7 @@ void NppParameters::writeStyle2Element(Style & style2Write, Style & style2Sync,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style2Write._fontSize != -1)
|
if (style2Write._fontSize != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
if (!style2Write._fontSize)
|
if (!style2Write._fontSize)
|
||||||
element->SetAttribute(TEXT("fontSize"), TEXT(""));
|
element->SetAttribute(TEXT("fontSize"), TEXT(""));
|
||||||
|
@ -5304,7 +5304,7 @@ void NppParameters::writeStyle2Element(Style & style2Write, Style & style2Sync,
|
||||||
element->SetAttribute(TEXT("fontSize"), style2Write._fontSize);
|
element->SetAttribute(TEXT("fontSize"), style2Write._fontSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style2Write._fontStyle != -1)
|
if (style2Write._fontStyle != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
element->SetAttribute(TEXT("fontStyle"), style2Write._fontStyle);
|
element->SetAttribute(TEXT("fontStyle"), style2Write._fontStyle);
|
||||||
}
|
}
|
||||||
|
@ -5392,7 +5392,7 @@ void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *user
|
||||||
styleElement->SetAttribute(TEXT("fontName"), style2Write._fontName);
|
styleElement->SetAttribute(TEXT("fontName"), style2Write._fontName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style2Write._fontStyle == -1)
|
if (style2Write._fontStyle == STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
styleElement->SetAttribute(TEXT("fontStyle"), TEXT("0"));
|
styleElement->SetAttribute(TEXT("fontStyle"), TEXT("0"));
|
||||||
}
|
}
|
||||||
|
@ -5401,7 +5401,7 @@ void NppParameters::insertUserLang2Tree(TiXmlNode *node, UserLangContainer *user
|
||||||
styleElement->SetAttribute(TEXT("fontStyle"), style2Write._fontStyle);
|
styleElement->SetAttribute(TEXT("fontStyle"), style2Write._fontStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style2Write._fontSize != -1)
|
if (style2Write._fontSize != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
if (!style2Write._fontSize)
|
if (!style2Write._fontSize)
|
||||||
styleElement->SetAttribute(TEXT("fontSize"), TEXT(""));
|
styleElement->SetAttribute(TEXT("fontSize"), TEXT(""));
|
||||||
|
|
|
@ -257,6 +257,8 @@ const int FONTSTYLE_BOLD = 1;
|
||||||
const int FONTSTYLE_ITALIC = 2;
|
const int FONTSTYLE_ITALIC = 2;
|
||||||
const int FONTSTYLE_UNDERLINE = 4;
|
const int FONTSTYLE_UNDERLINE = 4;
|
||||||
|
|
||||||
|
const int STYLE_NOT_USED = -1;
|
||||||
|
|
||||||
const int COLORSTYLE_FOREGROUND = 0x01;
|
const int COLORSTYLE_FOREGROUND = 0x01;
|
||||||
const int COLORSTYLE_BACKGROUND = 0x02;
|
const int COLORSTYLE_BACKGROUND = 0x02;
|
||||||
const int COLORSTYLE_ALL = COLORSTYLE_FOREGROUND|COLORSTYLE_BACKGROUND;
|
const int COLORSTYLE_ALL = COLORSTYLE_FOREGROUND|COLORSTYLE_BACKGROUND;
|
||||||
|
@ -277,7 +279,8 @@ struct Style
|
||||||
int _keywordClass;
|
int _keywordClass;
|
||||||
generic_string *_keywords;
|
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(){
|
~Style(){
|
||||||
if (_keywords)
|
if (_keywords)
|
||||||
|
|
|
@ -424,7 +424,7 @@ void ScintillaEditView::setSpecialStyle(const Style & styleToSet)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
int fontStyle = styleToSet._fontStyle;
|
int fontStyle = styleToSet._fontStyle;
|
||||||
if (fontStyle != -1)
|
if (fontStyle != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD);
|
execute(SCI_STYLESETBOLD, (WPARAM)styleID, fontStyle & FONTSTYLE_BOLD);
|
||||||
execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC);
|
execute(SCI_STYLESETITALIC, (WPARAM)styleID, fontStyle & FONTSTYLE_ITALIC);
|
||||||
|
@ -489,7 +489,7 @@ void ScintillaEditView::setStyle(Style styleToSet)
|
||||||
if (go.enableFontSize && (style._fontSize > 0))
|
if (go.enableFontSize && (style._fontSize > 0))
|
||||||
styleToSet._fontSize = style._fontSize;
|
styleToSet._fontSize = style._fontSize;
|
||||||
|
|
||||||
if (style._fontStyle != -1)
|
if (style._fontStyle != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
if (go.enableBold)
|
if (go.enableBold)
|
||||||
{
|
{
|
||||||
|
@ -771,7 +771,7 @@ void ScintillaEditView::setUserLexer(const TCHAR *userLangName)
|
||||||
{
|
{
|
||||||
Style & style = userLangContainer->_styleArray.getStyler(i);
|
Style & style = userLangContainer->_styleArray.getStyler(i);
|
||||||
|
|
||||||
if (style._styleID == -1)
|
if (style._styleID == STYLE_NOT_USED)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i < 10) itoa(i, (nestingBuffer+20), 10);
|
if (i < 10) itoa(i, (nestingBuffer+20), 10);
|
||||||
|
@ -1140,7 +1140,7 @@ void ScintillaEditView::makeStyle(LangType language, const TCHAR **keywordArray)
|
||||||
setStyle(style);
|
setStyle(style);
|
||||||
if (keywordArray)
|
if (keywordArray)
|
||||||
{
|
{
|
||||||
if ((style._keywordClass != -1) && (style._keywords))
|
if ((style._keywordClass != STYLE_NOT_USED) && (style._keywords))
|
||||||
keywordArray[style._keywordClass] = style._keywords->c_str();
|
keywordArray[style._keywordClass] = style._keywords->c_str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2196,15 +2196,7 @@ void ScintillaEditView::performGlobalStyles()
|
||||||
Style & style = stylers.getStyler(i);
|
Style & style = stylers.getStyler(i);
|
||||||
execute(SCI_SETCARETLINEBACK, style._bgColor);
|
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;
|
COLORREF selectColorBack = grey;
|
||||||
|
|
||||||
i = stylers.getStylerIndexByName(TEXT("Selected text colour"));
|
i = stylers.getStylerIndexByName(TEXT("Selected text colour"));
|
||||||
|
@ -2270,26 +2262,6 @@ void ScintillaEditView::performGlobalStyles()
|
||||||
|
|
||||||
execute(SCI_MARKERENABLEHIGHLIGHT, true);
|
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;
|
COLORREF wsSymbolFgColor = black;
|
||||||
i = stylers.getStylerIndexByName(TEXT("White space symbol"));
|
i = stylers.getStylerIndexByName(TEXT("White space symbol"));
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
|
|
|
@ -546,13 +546,13 @@ void WordStyleDlg::updateFontSize()
|
||||||
{
|
{
|
||||||
::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr);
|
::SendMessage(_hFontSizeCombo, CB_GETLBTEXT, iFontSizeSel, (LPARAM)intStr);
|
||||||
if (!intStr[0])
|
if (!intStr[0])
|
||||||
style._fontSize = -1;
|
style._fontSize = STYLE_NOT_USED;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TCHAR *finStr;
|
TCHAR *finStr;
|
||||||
style._fontSize = generic_strtol(intStr, &finStr, 10);
|
style._fontSize = generic_strtol(intStr, &finStr, 10);
|
||||||
if (*finStr != '\0')
|
if (*finStr != '\0')
|
||||||
style._fontSize = -1;
|
style._fontSize = STYLE_NOT_USED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -592,8 +592,8 @@ void WordStyleDlg::updateFontName()
|
||||||
void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle)
|
void WordStyleDlg::updateFontStyleStatus(fontStyleType whitchStyle)
|
||||||
{
|
{
|
||||||
Style & style = getCurrentStyler();
|
Style & style = getCurrentStyler();
|
||||||
if (style._fontStyle == -1)
|
if (style._fontStyle == STYLE_NOT_USED)
|
||||||
style._fontStyle = 0;
|
style._fontStyle = FONTSTYLE_NONE;
|
||||||
|
|
||||||
int fontStyle = FONTSTYLE_UNDERLINE;
|
int fontStyle = FONTSTYLE_UNDERLINE;
|
||||||
HWND hWnd = _hCheckUnderline;
|
HWND hWnd = _hCheckUnderline;
|
||||||
|
@ -774,7 +774,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
||||||
isEnable = false;
|
isEnable = false;
|
||||||
TCHAR intStr[5] = TEXT("");
|
TCHAR intStr[5] = TEXT("");
|
||||||
int iFontSize = 0;
|
int iFontSize = 0;
|
||||||
if (style._fontSize != -1)
|
if (style._fontSize != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
wsprintf(intStr, TEXT("%d"), style._fontSize);
|
wsprintf(intStr, TEXT("%d"), style._fontSize);
|
||||||
iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, (LPARAM)intStr);
|
iFontSize = ::SendMessage(_hFontSizeCombo, CB_FINDSTRING, 1, (LPARAM)intStr);
|
||||||
|
@ -786,7 +786,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
||||||
//-- font style : bold & italic
|
//-- font style : bold & italic
|
||||||
isEnable = false;
|
isEnable = false;
|
||||||
int isBold, isItalic, isUnderline;
|
int isBold, isItalic, isUnderline;
|
||||||
if (style._fontStyle != -1)
|
if (style._fontStyle != STYLE_NOT_USED)
|
||||||
{
|
{
|
||||||
isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED;
|
isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED;
|
||||||
isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?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);
|
::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0);
|
||||||
isEnable = true;
|
isEnable = true;
|
||||||
}
|
}
|
||||||
else // -1 : reset them all
|
else // STYLE_NOT_USED : reset them all
|
||||||
{
|
{
|
||||||
::SendMessage(_hCheckBold, BM_SETCHECK, BST_UNCHECKED, 0);
|
::SendMessage(_hCheckBold, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||||
::SendMessage(_hCheckItalic, BM_SETCHECK, BST_UNCHECKED, 0);
|
::SendMessage(_hCheckItalic, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||||
|
@ -807,7 +807,7 @@ void WordStyleDlg::setVisualFromStyleList()
|
||||||
|
|
||||||
|
|
||||||
//-- Default Keywords
|
//-- Default Keywords
|
||||||
bool shouldBeDisplayed = style._keywordClass != -1;
|
bool shouldBeDisplayed = style._keywordClass != STYLE_NOT_USED;
|
||||||
if (shouldBeDisplayed)
|
if (shouldBeDisplayed)
|
||||||
{
|
{
|
||||||
LexerStyler & lexerStyler = _lsArray.getLexerFromIndex(_currentLexerIndex - 1);
|
LexerStyler & lexerStyler = _lsArray.getLexerFromIndex(_currentLexerIndex - 1);
|
||||||
|
|
Loading…
Reference in New Issue