Skip to content

Commit

Permalink
Allow set background color and alpha for additional selection.
Browse files Browse the repository at this point in the history
use `fore` and `outline` from Selected Text for additional selection,
leaving `back` and `alpha` for main selection.
  • Loading branch information
zufuliu committed Apr 9, 2020
1 parent c5918ad commit f7ee5bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/EditLexers/stlDefault.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static EDITSTYLE Styles_Global[] = {
{ 0, NP2StyleX_MatchingBraceError, L"fore:#FF0000; alpha:50; outline:200" },
{ STYLE_CONTROLCHAR, NP2StyleX_ControlCharacter, L"size:-1" },
{ STYLE_INDENTGUIDE, NP2StyleX_IndentationGuide, L"fore:#FF8000" },
{ SCI_SETSELFORE + SCI_SETSELBACK, NP2StyleX_SelectedText, L"eolfilled; alpha:95" },
{ SCI_SETSELFORE + SCI_SETSELBACK, NP2StyleX_SelectedText, L"eolfilled; alpha:95; outline:50" },
{ SCI_SETWHITESPACEFORE + SCI_SETWHITESPACEBACK + SCI_SETWHITESPACESIZE, NP2StyleX_Whitespace, L"size:1; fore:#FF4000" },
{ SCI_SETCARETLINEBACK, NP2StyleX_CurrentLine, L"size:2; fore:#C2C0C3; back:#FFFF00; alpha:90; outline:90" },
{ SCI_SETCARETFORE + SCI_SETCARETWIDTH, NP2StyleX_Caret, L"back:#FF0000" },
Expand All @@ -37,7 +37,7 @@ static EDITSTYLE Styles_2ndGlobal[] = {
{ 0, NP2StyleX_MatchingBraceError, L"fore:#FF0000; alpha:50; outline:200" },
{ STYLE_CONTROLCHAR, NP2StyleX_ControlCharacter, L"size:-1" },
{ STYLE_INDENTGUIDE, NP2StyleX_IndentationGuide, L"fore:#605F63" },
{ SCI_SETSELFORE + SCI_SETSELBACK, NP2StyleX_SelectedText, L"eolfilled; alpha:95" },
{ SCI_SETSELFORE + SCI_SETSELBACK, NP2StyleX_SelectedText, L"eolfilled; alpha:95; outline:50" },
{ SCI_SETWHITESPACEFORE + SCI_SETWHITESPACEBACK + SCI_SETWHITESPACESIZE, NP2StyleX_Whitespace, L"size:1; fore:#FF4000" },
{ SCI_SETCARETLINEBACK, NP2StyleX_CurrentLine, L"size:2; fore:#C2C0C3; back:#FFFF00; alpha:25; outline:25" },
{ SCI_SETCARETFORE + SCI_SETCARETWIDTH, NP2StyleX_Caret, L"fore:#FFFFFF; back:#00FF00" },
Expand Down
29 changes: 14 additions & 15 deletions src/Styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,16 @@ enum GlobalStyleIndex {
GlobalStyleIndex_LineNumber, // inherited style, except for background color (default to COLOR_3DFACE).
GlobalStyleIndex_MatchBrace, // indicator style. `fore`, `alpha`, `outline`
GlobalStyleIndex_MatchBraceError, // indicator style. `fore`, `alpha`, `outline`
GlobalStyleIndex_ControlCharacter, // inherited style. font attributes (white on black)
GlobalStyleIndex_ControlCharacter, // inherited style. font attributes (inverted text/background color, e.g. white on black or black on white based on theme)
GlobalStyleIndex_IndentationGuide, // inherited style. `fore`, `back`
GlobalStyleIndex_Selection, // standalone style. `fore`, `back`, `alpha`, `eolfilled`
GlobalStyleIndex_Selection, // standalone style. main selection (`back`, `alpha`), additional selection (`fore`, `outline`), `eolfilled`
GlobalStyleIndex_Whitespace, // standalone style. `fore`, `back`, `size`: dot size
GlobalStyleIndex_CurrentLine, // standalone style. frame (`fore`, `size`, `outline`), background (`back`, `alpha`)
GlobalStyleIndex_Caret, // standalone style. `fore`: main caret color, `back`: additional caret color
GlobalStyleIndex_IMEIndicator, // indicator style. `fore`: IME indicator color
GlobalStyleIndex_LongLineMarker, // standalone style. `fore`: edge line color, `back`: edge background color
GlobalStyleIndex_LongLineMarker, // standalone style. `fore`: edge line color, `back`: background color for text exceeds long line limit
GlobalStyleIndex_ExtraLineSpacing, // standalone style. descent = `size`/2, ascent = `size` - descent
GlobalStyleIndex_FoldingMarker, // standalone style. `fore`: folder line color, `back`: folder box fill color
GlobalStyleIndex_FoldingMarker, // standalone style. `fore`: folding line color, `back`: folder box fill color
GlobalStyleIndex_FoldDispalyText, // inherited style.
GlobalStyleIndex_MarkOccurrence, // indicator style. `fore`, `alpha`, `outline`
GlobalStyleIndex_Bookmark, // indicator style. `fore`, `back`, `alpha`
Expand Down Expand Up @@ -1483,26 +1483,25 @@ void Style_SetLexer(PEDITLEXER pLexNew, BOOL bLexerChanged) {

//! begin GlobalStyleIndex_Selection
szValue = pLexGlobal->Styles[GlobalStyleIndex_Selection].szValue;
if (Style_StrGetForeColor(szValue, &rgb)) {
SciCall_SetSelFore(TRUE, rgb);
//SciCall_SetAdditionalSelFore(rgb);
} else {
SciCall_SetSelFore(FALSE, 0);
//SciCall_SetAdditionalSelFore(0);
}
// never change text color on selecting.
SciCall_SetSelFore(FALSE, 0);

// always set background color
if (!Style_StrGetBackColor(szValue, &rgb)) {
rgb = GetSysColor(COLOR_HIGHLIGHT);
}
SciCall_SetSelBack(TRUE, rgb);
//SciCall_SetAdditionalSelBack(rgb);
if (Style_StrGetForeColor(szValue, &rgb)) {
SciCall_SetAdditionalSelBack(rgb);
}

if (!Style_StrGetAlpha(szValue, &iValue)) {
iValue = SC_ALPHA_NOALPHA;
}
SciCall_SetSelAlpha(iValue);
//SciCall_SetAdditionalSelAlpha(iValue);

// TODO: add separate styles for additional selection
if (Style_StrGetOutlineAlpha(szValue, &iValue)) {
SciCall_SetAdditionalSelAlpha(iValue);
}

SciCall_SetSelEOLFilled(Style_StrGetEOLFilled(szValue));
//! end GlobalStyleIndex_Selection
Expand Down

0 comments on commit f7ee5bc

Please sign in to comment.