From 7229faa1deb8d14ffd431a2e39288c2e315117d8 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Tue, 10 Aug 2021 01:15:24 +0200 Subject: [PATCH] +rfc: some refactorings and code cleanup --- scintilla/win32/ScintillaWin.cxx | 7 ++ src/Notepad3.c | 12 +--- src/SciCall.h | 45 +++++++++---- src/Styles.c | 111 ++++++++++++++----------------- src/TypeDefs.h | 19 ++++-- 5 files changed, 104 insertions(+), 90 deletions(-) diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index d30ac5c6f..5df18ad09 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -3746,6 +3746,13 @@ sptr_t SCI_METHOD Scintilla_DirectFunction( ScintillaWin * sci, UINT iMessage, uptr_t wParam, sptr_t lParam) { return sci->WndProc(static_cast(iMessage), wParam, lParam); } +extern "C" +sptr_t SCI_METHOD Scintilla_DirectStatusFunction( + ScintillaWin * sci, UINT iMessage, uptr_t wParam, sptr_t lParam, int* pStatus) { + const sptr_t returnValue = sci->WndProc(static_cast(iMessage), wParam, lParam); + *pStatus = static_cast(sci->errorStatus); + return returnValue; +} #endif // <<<<<<<<<<<<<<< END NON STD SCI PATCH <<<<<<<<<<<<<<< } diff --git a/src/Notepad3.c b/src/Notepad3.c index b8af53d5c..37c9a8f7a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -2054,7 +2054,7 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl) SciCall_IndicSetStyle(INDIC_NP3_UNICODE_POINT, INDIC_COMPOSITIONTHIN /*INDIC_HIDDEN*/); //SciCall_IndicSetUnder(INDIC_NP3_UNICODE_POINT, false); SciCall_IndicSetAlpha(INDIC_NP3_UNICODE_POINT, SC_ALPHA_TRANSPARENT); - SciCall_IndicSetOutlineAlpha(INDIC_NP3_UNICODE_POINT, SC_ALPHA_NOALPHA); + SciCall_IndicSetOutlineAlpha(INDIC_NP3_UNICODE_POINT, SC_ALPHA_OPAQUE); SciCall_IndicSetHoverStyle(INDIC_NP3_UNICODE_POINT, INDIC_ROUNDBOX); //SciCall_IndicSetHoverFore(INDIC_NP3_UNICODE_POINT, RGB(0xE0, 0xE0, 0xE0); @@ -6804,16 +6804,6 @@ LRESULT MsgSysCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // static DocPos prevCursorPosition = -1; -#define ARGB_TO_COLREF(X) (RGB(((X) >> 16) & SC_ALPHA_OPAQUE, ((X) >> 8) & SC_ALPHA_OPAQUE, (X) & SC_ALPHA_OPAQUE)) -#define RGBA_TO_COLREF(X) (RGB(((X) >> 24) & SC_ALPHA_OPAQUE, ((X) >> 16) & SC_ALPHA_OPAQUE, ((X) >> 8) & SC_ALPHA_OPAQUE)) -#define BGRA_TO_COLREF(X) (RGB(((X) >> 8) & SC_ALPHA_OPAQUE, ((X) >> 16) & SC_ALPHA_OPAQUE, ((X) >> 24) & SC_ALPHA_OPAQUE)) -#define ARGB_GET_ALPHA(A) (((A) >> 24) & SC_ALPHA_OPAQUE) -#define RGBA_GET_ALPHA(A) ((A) & SC_ALPHA_OPAQUE) -#define BGRA_GET_ALPHA(A) RGBA_GET_ALPHA(A) - -// ---------------------------------------------------------------------------- - - void HandleDWellStartEnd(const DocPos position, const UINT uid) { static DocPos prevStartPosition = -1; diff --git a/src/SciCall.h b/src/SciCall.h index d9bd6c1c5..ced506e88 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -57,7 +57,6 @@ #include "Scintilla.h" #include "TypeDefs.h" - //============================================================================= // // Scintilla Window Handle @@ -82,6 +81,9 @@ __forceinline void InitScintillaHandle(HWND hwnd) { LRESULT WINAPI Scintilla_DirectFunction(HANDLE, UINT, WPARAM, LPARAM); #define SciCall(m, w, l) Scintilla_DirectFunction(g_hndlScintilla, (m), (w), (l)) +LRESULT WINAPI Scintilla_DirectStatusFunction(HANDLE, UINT, WPARAM, LPARAM, LPINT); +#define SciCallEx(m, w, l, i) Scintilla_DirectStatusFunction(g_hndlScintilla, (m), (w), (l), (i)) + #else #define SciCall(m, w, l) SendMessage(g_hndlScintilla, m, w, l) @@ -176,17 +178,10 @@ DeclareSciCallV1(SetMultiPaste, SETMULTIPASTE, int, option); DeclareSciCallR0(GetAdditionalSelectionTyping, GETADDITIONALSELECTIONTYPING, bool); DeclareSciCallV1(SetAdditionalSelectionTyping, SETADDITIONALSELECTIONTYPING, bool, flag); DeclareSciCallV1(SetMouseSelectionRectangularSwitch, SETMOUSESELECTIONRECTANGULARSWITCH, bool, flag); -// Caret -DeclareSciCallV1(SetCaretFore, SETCARETFORE, int, color); -DeclareSciCallV1(SetAdditionalCaretFore, SETADDITIONALCARETFORE, int, color); -DeclareSciCallV1(SetAdditionalCaretsBlink, SETADDITIONALCARETSBLINK, bool, flag); -DeclareSciCallV1(SetAdditionalCaretsVisible, SETADDITIONALCARETSVISIBLE, bool, flag); +DeclareSciCallV1(SetCaretLineLayer, SETCARETLINELAYER, int, layer); DeclareSciCallV1(SetCaretLineFrame, SETCARETLINEFRAME, int, frm); -DeclareSciCallV1(SetCaretLineVisible, SETCARETLINEVISIBLE, bool, flag); DeclareSciCallV1(SetCaretLineVisibleAlways, SETCARETLINEVISIBLEALWAYS, bool, flag); -DeclareSciCallV1(SetCaretLineBack, SETCARETLINEBACK, COLORREF, colour); -DeclareSciCallV1(SetCaretLineBackAlpha, SETCARETLINEBACKALPHA, int, alpha); DeclareSciCallV1(SetAutomaticFold, SETAUTOMATICFOLD, int, option); @@ -207,6 +202,16 @@ DeclareSciCallV01(AddRefDocument, ADDREFDOCUMENT, sptr_t, pdoc); DeclareSciCallV01(ReleaseDocument, RELEASEDOCUMENT, sptr_t, pdoc); DeclareSciCallR0(GetDocumentOptions, GETDOCUMENTOPTIONS, int); +// Element Colors +DeclareSciCallV2(SetElementColour, SETELEMENTCOLOUR, int, element, COLORALPHAREF, colourElement); +DeclareSciCallR1(GetElementColour, GETELEMENTCOLOUR, COLORALPHAREF, int, element); +DeclareSciCallR1(GetElementBaseColour, GETELEMENTBASECOLOUR, COLORALPHAREF, int, element); +DeclareSciCallV1(ResetElementColour, RESETELEMENTCOLOUR, int, element); +//SCI_GETELEMENTISSET(int element) → bool +//SCI_GETELEMENTALLOWSTRANSLUCENT(int element) → bool +//SCI_GETELEMENTBASECOLOUR(int element) → colouralpha + + // Selection, positions and information DeclareSciCallR0(GetReadOnly, GETREADONLY, bool); DeclareSciCallV1(SetReadOnly, SETREADONLY, bool, flag); @@ -222,6 +227,8 @@ DeclareSciCallR0(GetFocus, GETFOCUS, bool); DeclareSciCallR0(GetPasteConvertEndings, GETPASTECONVERTENDINGS, bool); DeclareSciCallR0(GetOverType, GETOVERTYPE, bool); +DeclareSciCallV1(SetSelectionLayer, SETSELECTIONLAYER, int, layer); +DeclareSciCallR0(GetSelectionLayer, GETSELECTIONLAYER, int); DeclareSciCallV1(SetEmptySelection, SETEMPTYSELECTION, DocPos, position); DeclareSciCallR0(GetCurrentPos, GETCURRENTPOS, DocPos); @@ -339,6 +346,8 @@ DeclareSciCallR2(GetText, GETTEXT, DocPos, DocPos, length, const char*, text); DeclareSciCallR01(GetTextRange, GETTEXTRANGE, DocPos, struct Sci_TextRange*, textrange); DeclareSciCallV0(UpperCase, UPPERCASE); DeclareSciCallV0(LowerCase, LOWERCASE); +DeclareSciCallV2(ReplaceRectangular, REPLACERECTANGULAR, DocPos, length, const char *, text); + //DeclareSciCallR01(TargetAsUTF8, TARGETASUTF8, DocPos, const char*, text); // WideCharToMultiByteEx(Encoding_SciCP); // SCI_ENCODEDFROMUTF8 - no need, internal CP is UTF8 always (fixed const for Notepad3); @@ -523,8 +532,6 @@ DeclareSciCallR0(GetEndStyled, GETENDSTYLED, DocPos); DeclareSciCallR1(StyleGetHotspot, STYLEGETHOTSPOT, bool, int, style); DeclareSciCallV2(StyleSetHotspot, STYLESETHOTSPOT, int, style, bool, hotspot); -DeclareSciCallV2(SetHotspotActiveFore, SETHOTSPOTACTIVEFORE, bool, useSetting, int, colour); -DeclareSciCallV2(SetHotspotActiveBack, SETHOTSPOTACTIVEBACK, bool, useSetting, int, colour); DeclareSciCallV1(SetHotspotActiveUnderline, SETHOTSPOTACTIVEUNDERLINE, bool, underline); DeclareSciCallV1(SetHotspotSigleLine, SETHOTSPOTSINGLELINE, bool, singleline); @@ -538,6 +545,11 @@ DeclareSciCallV2(StyleSetItalic, STYLESETITALIC, int, style, bool, oblique); DeclareSciCallV1(SetFontQuality, SETFONTQUALITY, int, qual); DeclareSciCallV01(SetFontLocale, SETFONTLOCALE, const char*, localeName); +DeclareSciCallV1(SetSelEOLFilled, SETSELEOLFILLED, bool, filled); +DeclareSciCallV1(SetWhiteSpaceSize, SETWHITESPACESIZE, int, size); +DeclareSciCallR0(GetWhiteSpaceSize, GETWHITESPACESIZE, int); + + //============================================================================= // // Indentation Guides and Wraping @@ -550,6 +562,7 @@ DeclareSciCallV1(SetWrapStartIndent, SETWRAPSTARTINDENT, int, mode); DeclareSciCallV1(SetWrapVisualFlags, SETWRAPVISUALFLAGS, int, opts); DeclareSciCallV1(SetWrapVisualFlagsLocation, SETWRAPVISUALFLAGSLOCATION, int, opts); DeclareSciCallR1(WrapCount, WRAPCOUNT, DocLn, DocLn, line); +DeclareSciCallR0(GetIndentationGuides, GETINDENTATIONGUIDES, int); DeclareSciCallV1(SetEdgeMode, SETEDGEMODE, int, mode); DeclareSciCallR0(GetEdgeMode, GETEDGEMODE, int); @@ -618,7 +631,8 @@ DeclareSciCallV2(MarkerSetBackSelected, MARKERSETBACKSELECTED, int, markerID, CO DeclareSciCallV2(MarkerSetBackSelectedTranslucent, MARKERSETBACKSELECTEDTRANSLUCENT, int, markerID, COLORALPHAREF, colouralpha); DeclareSciCallV2(MarkerSetStrokeWidth, MARKERSETSTROKEWIDTH, int, markerID, int, hundredths); DeclareSciCallV1(MarkerEnableHighlight, MARKERENABLEHIGHLIGHT, bool, flag); -//~DeclareSciCallV2(MarkerSetAlpha, MARKERSETALPHA, int, markerID, int, alpha); // deprecated w/ v5.0.1 ? +DeclareSciCallV2(MarkerSetLayer, MARKERSETLAYER, int, markerID, int, layer); +DeclareSciCallV2(MarkerSetAlpha, MARKERSETALPHA, int, markerID, int, alpha); DeclareSciCallR2(MarkerAdd, MARKERADD, int, DocLn, line, int, markerID); DeclareSciCallV2(MarkerAddSet, MARKERADDSET, DocLn, line, int, markerMask); DeclareSciCallV2(MarkerDelete, MARKERDELETE, DocLn, line, int, markerID); @@ -663,10 +677,15 @@ DeclareSciCallV2(Colourise, COLOURISE, DocPos, startPos, DocPos, endPos); //============================================================================= // -// Cursor +// Cursor, Caret // DeclareSciCallV1(SetCursor, SETCURSOR, int, flags); +DeclareSciCallV1(SetCaretStyle, SETCARETSTYLE, int, style); +DeclareSciCallV1(SetCaretWidth, SETCARETWIDTH, int, pixel); +DeclareSciCallV1(SetCaretPeriod, SETCARETPERIOD, int, msec); +DeclareSciCallV1(SetAdditionalCaretsBlink, SETADDITIONALCARETSBLINK, bool, flag); +DeclareSciCallV1(SetAdditionalCaretsVisible, SETADDITIONALCARETSVISIBLE, bool, flag); //============================================================================= // diff --git a/src/Styles.c b/src/Styles.c index a998b4d75..b7e4d2521 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1300,6 +1300,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // margin (line number, bookmarks, folding) style Style_SetMargin(hwnd, pCurrentStandard->Styles[STY_MARGIN].szValue); + bool bFlag; int iValue; COLORREF dColor; WCHAR wchSpecificStyle[128] = { L'\0' }; @@ -1471,51 +1472,40 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } Style_SetStyles(hwnd, pCurrentStandard->Styles[STY_INDENT_GUIDE].iStyle, pCurrentStandard->Styles[STY_INDENT_GUIDE].szValue); // indent guide - // TODO: @@@ DirectFunction instead of SendMsg if (Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, FOREGROUND_LAYER, &rgb, false)) { // selection fore - SendMessage(hwnd, SCI_SETSELFORE, true, rgb); - SendMessage(hwnd, SCI_SETADDITIONALSELFORE, rgb, 0); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_TEXT, RGBxA(rgb, SC_ALPHA_OPAQUE)); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, RGBxA(rgb, SC_ALPHA_OPAQUE)); } else { - SendMessage(hwnd, SCI_SETSELFORE, 0, 0); - SendMessage(hwnd, SCI_SETADDITIONALSELFORE, 0, 0); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_TEXT, RGBxA(0, SC_ALPHA_OPAQUE)); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_TEXT, RGBxA(0, SC_ALPHA_OPAQUE)); } rgb = RGB(0xC0, 0xC0, 0xC0); Style_StrGetColor(pCurrentStandard->Styles[STY_SEL_TXT].szValue, BACKGROUND_LAYER, &rgb, true); // selection back - SendMessage(hwnd, SCI_SETSELBACK, true, rgb); - SendMessage(hwnd, SCI_SETADDITIONALSELBACK, rgb, 0); + iValue = SC_ALPHA_OPAQUE; + Style_StrGetAlpha(pCurrentStandard->Styles[STY_SEL_TXT].szValue, &iValue, true); + SciCall_SetSelectionLayer(SC_LAYER_UNDER_TEXT); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_BACK, RGBxA(rgb, iValue)); + SciCall_SetElementColour(SC_ELEMENT_SELECTION_ADDITIONAL_BACK, RGBxA(rgb, iValue*2/3)); - if (Style_StrGetAlpha(pCurrentStandard->Styles[STY_SEL_TXT].szValue, &iValue, true)) { // selection alpha - SendMessage(hwnd, SCI_SETSELALPHA, iValue, 0); - SendMessage(hwnd, SCI_SETADDITIONALSELALPHA, iValue*2/3, 0); - } else { - SendMessage(hwnd, SCI_SETSELALPHA, SC_ALPHA_NOALPHA, 0); - SendMessage(hwnd, SCI_SETADDITIONALSELALPHA, SC_ALPHA_OPAQUE*2/3, 0); - } + // selection eolfilled + bFlag = Style_StrHasAttribute(pCurrentStandard->Styles[STY_SEL_TXT].szValue, FontEffects[FE_EOLFILLED]); + SciCall_SetSelEOLFilled(bFlag); - if (Style_StrHasAttribute(pCurrentStandard->Styles[STY_SEL_TXT].szValue, FontEffects[FE_EOLFILLED])) { // selection eolfilled - SendMessage(hwnd, SCI_SETSELEOLFILLED, 1, 0); - } else { - SendMessage(hwnd, SCI_SETSELEOLFILLED, 0, 0); - } + // whitespace colors + rgb = RGB(0, 0, 0); + Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, FOREGROUND_LAYER, &rgb, false); + SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE, RGBxA(rgb, SC_ALPHA_OPAQUE/2)); - if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, FOREGROUND_LAYER, &rgb, false)) { // whitespace fore - SendMessage(hwnd, SCI_SETWHITESPACEFORE, true, rgb); - } else { - SendMessage(hwnd, SCI_SETWHITESPACEFORE, 0, 0); - } - - if (Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, BACKGROUND_LAYER, &rgb, false)) { // whitespace back - SendMessage(hwnd, SCI_SETWHITESPACEBACK, true, rgb); - } else { - SendMessage(hwnd, SCI_SETWHITESPACEBACK, 0, 0); // use a default value... - } + Style_StrGetColor(pCurrentStandard->Styles[STY_WHITESPACE].szValue, BACKGROUND_LAYER, &rgb, true); + SciCall_SetElementColour(SC_ELEMENT_WHITE_SPACE_BACK, RGBxA(rgb, SC_ALPHA_OPAQUE)); // whitespace dot size - iValue = 1; - float fValue = 1.0; + iValue = 4; + float fValue = 4.0; if (Style_StrGetSizeFloat(pCurrentStandard->Styles[STY_WHITESPACE].szValue, &fValue)) { + iValue = clampi(float2int(fValue), 0, 12); WCHAR tch[32] = { L'\0' }; @@ -1538,7 +1528,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) COUNTOF(pCurrentStandard->Styles[STY_WHITESPACE].szValue), tch); } } - SendMessage(hwnd, SCI_SETWHITESPACESIZE, iValue, 0); + SciCall_SetWhiteSpaceSize(iValue); // current line background Style_HighlightCurrentLine(hwnd, Settings.HighlightCurrentLine); @@ -1555,9 +1545,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (StrStr(pCurrentStandard->Styles[STY_CARET].szValue, L"block")) { StringCchCat(wchSpecificStyle, COUNTOF(wchSpecificStyle), L"; block"); - SendMessage(hwnd, SCI_SETCARETSTYLE, (CARETSTYLE_BLOCK | ovrstrk_mode), 0); + SciCall_SetCaretStyle(CARETSTYLE_BLOCK | ovrstrk_mode); } else { - SendMessage(hwnd, SCI_SETCARETSTYLE, (CARETSTYLE_LINE | ovrstrk_mode), 0); + SciCall_SetCaretStyle(CARETSTYLE_LINE | ovrstrk_mode); iValue = 1; fValue = 1.0f; // default caret width @@ -1565,7 +1555,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (Style_StrGetSizeFloat(pCurrentStandard->Styles[STY_CARET].szValue, &fValue)) { iValue = clampi(float2int(fValue), 1, 3); // don't allow invisible 0 } - SendMessage(hwnd, SCI_SETCARETWIDTH, iValue, 0); + SciCall_SetCaretWidth(iValue); if (iValue != 1) { StringCchPrintf(wch, COUNTOF(wch), L"; size:%i", iValue); @@ -1577,13 +1567,13 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } if (StrStr(pCurrentStandard->Styles[STY_CARET].szValue,L"noblink")) { - SendMessage(hwnd,SCI_SETCARETPERIOD,(WPARAM)0,0); - SendMessage(hwnd, SCI_SETADDITIONALCARETSBLINK, false, 0); + SciCall_SetCaretPeriod(0); + SciCall_SetAdditionalCaretsBlink(false); StringCchCat(wchSpecificStyle,COUNTOF(wchSpecificStyle),L"; noblink"); } else { const UINT uCaretBlinkTime = GetCaretBlinkTime(); - SendMessage(hwnd, SCI_SETCARETPERIOD, (WPARAM)uCaretBlinkTime, 0); - SendMessage(hwnd, SCI_SETADDITIONALCARETSBLINK, ((uCaretBlinkTime != 0) ? true : false), 0); + SciCall_SetCaretPeriod(uCaretBlinkTime); + SciCall_SetAdditionalCaretsBlink(uCaretBlinkTime != 0); } // caret fore if (!Style_StrGetColor(pCurrentStandard->Styles[STY_CARET].szValue, FOREGROUND_LAYER, &rgb, false)) { @@ -1596,8 +1586,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (!VerifyContrast(rgb, SciCall_StyleGetBack(0))) { rgb = SciCall_StyleGetFore(0); } - SciCall_SetCaretFore(rgb); - SciCall_SetAdditionalCaretFore(RGB(240, 0, 0)); + + SciCall_SetElementColour(SC_ELEMENT_CARET, RGBxA(rgb, SC_ALPHA_OPAQUE)); + SciCall_SetElementColour(SC_ELEMENT_CARET_ADDITIONAL, RGBxA(RGB(220, 0, 0), SC_ALPHA_OPAQUE)); StrTrim(wchSpecificStyle, L" ;"); StringCchCopy(pCurrentStandard->Styles[STY_CARET].szValue, @@ -1610,7 +1601,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) Style_SetExtraLineSpace(hwnd, pCurrentStandard->Styles[STY_X_LN_SPACE].szValue, COUNTOF(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue)); - if (SendMessage(hwnd, SCI_GETINDENTATIONGUIDES, 0, 0) != SC_IV_NONE) { + if (SciCall_GetIndentationGuides() != SC_IV_NONE) { Style_SetIndentGuides(hwnd, true); } @@ -1947,24 +1938,20 @@ void Style_SetMultiEdgeLine(const int colVec[], const size_t count) void Style_HighlightCurrentLine(HWND hwnd, int iHiLitCurLn) { SciCall_SetCaretLineFrame(0); - SciCall_SetCaretLineVisible(false); SciCall_SetCaretLineVisibleAlways(false); + int alpha = SC_ALPHA_OPAQUE; + bool const backgrColor = (iHiLitCurLn == 1); + LPCWSTR szValue = GetCurrentStdLexer()->Styles[STY_CUR_LN].szValue; + + COLORREF rgb; + if (!Style_StrGetColor(szValue, (backgrColor ? BACKGROUND_LAYER : FOREGROUND_LAYER), &rgb, false)) { + rgb = (backgrColor ? RGB(0xFF, 0xFF, 0x00) : RGB(0xC2, 0xC0, 0xC3)); + } + if (iHiLitCurLn > 0) { - bool const backgrColor = (iHiLitCurLn == 1); - - LPCWSTR szValue = GetCurrentStdLexer()->Styles[STY_CUR_LN].szValue; - - COLORREF rgb; - if (!Style_StrGetColor(szValue, (backgrColor ? BACKGROUND_LAYER : FOREGROUND_LAYER), &rgb, false)) { - rgb = (backgrColor ? RGB(0xFF, 0xFF, 0x00) : RGB(0xC2, 0xC0, 0xC3)); - } - - int alpha = SC_ALPHA_TRANSPARENT; - if (!Style_StrGetAlpha(GetCurrentStdLexer()->Styles[STY_CUR_LN].szValue, &alpha, true)) { - alpha = SC_ALPHA_NOALPHA; - } + Style_StrGetAlpha(GetCurrentStdLexer()->Styles[STY_CUR_LN].szValue, &alpha, true); if (!backgrColor) { int iFrameSize = 0; @@ -1975,11 +1962,13 @@ void Style_HighlightCurrentLine(HWND hwnd, int iHiLitCurLn) SciCall_SetCaretLineFrame(iFrameSize); } - SciCall_SetCaretLineBack(rgb); - SciCall_SetCaretLineBackAlpha(alpha); - SciCall_SetCaretLineVisibleAlways(true); - SciCall_SetCaretLineVisible(true); + } else { + alpha = SC_ALPHA_TRANSPARENT; } + + SciCall_SetCaretLineLayer(SC_LAYER_UNDER_TEXT); + SciCall_SetElementColour(SC_ELEMENT_CARET_LINE_BACK, RGBxA(rgb, alpha)); + SciCall_SetCaretLineVisibleAlways(iHiLitCurLn > 0); } diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 94d507f07..a14794199 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -99,14 +99,23 @@ extern WININFO g_IniWinInfo; extern WININFO g_DefWinInfo; // ---------------------------------------------------------------------------- - +// see windef.h and wingdi.h +//-typedef DWORD COLORREF; typedef int COLORALPHAREF; +//-#define RGB(r, g, b) ((COLORREF)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16))) #define RGBA(r, g, b, a) ((COLORALPHAREF)(((BYTE)(r) | ((WORD)((BYTE)(g)) << 8)) | (((DWORD)(BYTE)(b)) << 16) | (((DWORD)(BYTE)(a)) << 24))) #define RGBxA(rgb, a) ((COLORALPHAREF)(((DWORD)(rgb)&0xffffff) | (((DWORD)(BYTE)(a)) << 24))) -#define GetRedValue(rgba) (LOBYTE(rgba)) -#define GetGreenValue(rgba) (LOBYTE(((WORD)(rgba)) >> 8)) -#define GetBlueValue(rgba) (LOBYTE((rgba) >> 16)) -#define GetAlphaValue(rgba) (LOBYTE((rgba) >> 24)) +//-#define GetRValue(rgba) (LOBYTE(rgba)) +//-#define GetGValue(rgba) (LOBYTE(((WORD)(rgba)) >> 8)) +//-#define GetBValue(rgba) (LOBYTE((rgba) >> 16)) +#define GetAValue(rgba) (LOBYTE((rgba) >> 24)) + +#define ARGB_TO_COLREF(X) (RGB(((X) >> 16) & 0xff, ((X) >> 8) & 0xff, (X)&0xff)) +#define RGBA_TO_COLREF(X) (RGB(((X) >> 24) & 0xff, ((X) >> 16) & 0xff, ((X) >> 8) & 0xff)) +#define BGRA_TO_COLREF(X) (RGB(((X) >> 8) & 0xff, ((X) >> 16) & 0xff, ((X) >> 24) & 0xff)) +#define ARGB_GET_ALPHA(A) (((A) >> 24) & 0xff) +#define RGBA_GET_ALPHA(A) ((A)&0xff) +#define BGRA_GET_ALPHA(A) RGBA_GET_ALPHA(A) // ----------------------------------------------------------------------------