diff --git a/src/Edit.c b/src/Edit.c index 0e4f5d7b7..03cea6ad3 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -329,6 +329,10 @@ void EditSetNewText(HWND hwnd, const char* lpstrText, DocPosU lenText, bool bCle SciCall_Cancel(); if (SciCall_GetReadOnly()) { SciCall_SetReadOnly(false); } SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK); + for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) { + SciCall_MarkerDeleteAll(m); + WordBookMarks[m].in_use = false; + } EditClearAllOccurrenceMarkers(hwnd); SciCall_SetScrollWidth(1); SciCall_SetXOffset(0); @@ -7701,6 +7705,20 @@ void EditHideNotMarkedLineRange(HWND hwnd, bool bHideLines) } else // ===== fold lines without marker ===== { + // get next free bookmark + int marker; + for (marker = 0; marker < MARKER_NP3_BOOKMARK; ++marker) { + if (!WordBookMarks[marker].in_use) { + WordBookMarks[marker].in_use = true; + break; + } + } + if (marker >= MARKER_NP3_BOOKMARK) { + marker = 0; // wrap around usage + SciCall_MarkerDeleteAll(marker); + WordBookMarks[marker].in_use = true; + } + // prepare hidden (folding) settings FocusedView.CodeFoldingAvailable = true; FocusedView.ShowCodeFolding = true; @@ -7724,6 +7742,7 @@ void EditHideNotMarkedLineRange(HWND hwnd, bool bHideLines) { level = baseLevel; SciCall_SetFoldLevel(iLine, SC_FOLDLEVELHEADERFLAG | level++); + SciCall_MarkerAdd(iLine, marker); } else // hide line { @@ -8687,12 +8706,13 @@ void EditShowZeroLengthCallTip(HWND hwnd, DocPos iPosition) // void EditGetBookmarkList(HWND hwnd, LPWSTR pszBookMarks, int cchLength) { + UNUSED(hwnd); WCHAR tchLine[32]; StringCchCopyW(pszBookMarks, cchLength, L""); int bitmask = (1 << MARKER_NP3_BOOKMARK); DocLn iLine = -1; do { - iLine = (DocLn)SendMessage(hwnd, SCI_MARKERNEXT, iLine + 1, bitmask); + iLine = SciCall_MarkerNext(iLine + 1, bitmask); if (iLine >= 0) { StringCchPrintfW(tchLine, COUNTOF(tchLine), L"%td;", (long long)iLine); StringCchCatW(pszBookMarks, cchLength, tchLine); @@ -8740,14 +8760,23 @@ void EditBookmarkClick(const DocLn ln, const int modifiers) { UNUSED(modifiers); - int const bitmask = SciCall_MarkerGet(ln); + int const bitmask = SciCall_MarkerGet(ln) & bitmask32_n(MARKER_NP3_BOOKMARK + 1); - if (bitmask & (1 << MARKER_NP3_BOOKMARK)) + if (!bitmask) + { + SciCall_MarkerAdd(ln, MARKER_NP3_BOOKMARK); // set + } + else if (bitmask & (1 << MARKER_NP3_BOOKMARK)) { SciCall_MarkerDelete(ln, MARKER_NP3_BOOKMARK); // unset } else { - SciCall_MarkerAdd(ln, MARKER_NP3_BOOKMARK); // set + for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) { + if (bitmask & (1 << m)) { + SciCall_MarkerDeleteAll(m); + WordBookMarks[m].in_use = false; + } + } } if (modifiers & SCMOD_ALT) { diff --git a/src/Helpers.h b/src/Helpers.h index 033148510..d8389ea10 100644 --- a/src/Helpers.h +++ b/src/Helpers.h @@ -374,6 +374,13 @@ __inline ptrdiff_t MultiByteToWideCharEx( // ============================================================================ +inline int32_t bitmask32_n(unsigned short n) +{ + return ((n >= 32) ? 0 - ((int32_t)1) : (((int32_t)1) << n) - 1); +} + +// ============================================================================ + inline int wcscmp_s(const wchar_t* s1, const wchar_t* s2) { return (s1 && s2) ? wcscmp(s1, s2) : ((s1 ? 1 : (s2 ? -1 : 0))); diff --git a/src/Notepad3.c b/src/Notepad3.c index d957ccf31..3d4f35bdf 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -53,6 +53,17 @@ #define RELAUNCH_ELEVATED_BUF_ARG L"tmpfbuf=" +WORDBOOKMARK_T WordBookMarks[MARKER_NP3_BOOKMARK] = { + /*0*/ {false, SC_MARK_BOOKMARK, L"back:#FF0000"}, + /*1*/ {false, SC_MARK_BOOKMARK, L"back:#0000FF"}, + /*2*/ {false, SC_MARK_BOOKMARK, L"back:#00FF00"}, + /*3*/ {false, SC_MARK_BOOKMARK, L"back:#FFFF00"}, + /*4*/ {false, SC_MARK_BOOKMARK, L"back:#00E8E8"}, + /*5*/ {false, SC_MARK_BOOKMARK, L"back:#FF00FF"}, + /*6*/ {false, SC_MARK_BOOKMARK, L"back:#FF8F20"}, + /*7*/ {false, SC_MARK_BOOKMARK, L"back:#950095"}}; + + CONSTANTS_T const Constants = { 2 // StdDefaultLexerID , L"minipath.exe" // FileBrowserMiniPath @@ -1932,8 +1943,8 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl) SendMessage(hwndEditCtrl, SCI_INDICSETSTYLE, INDIC_NP3_COLOR_DEF, INDIC_COMPOSITIONTHIN /*INDIC_HIDDEN*/); // MARKER only SendMessage(hwndEditCtrl, SCI_INDICSETUNDER, INDIC_NP3_COLOR_DEF, true); - SendMessage(hwndEditCtrl, SCI_INDICSETALPHA, INDIC_NP3_COLOR_DEF, 0x00); // reset on hover - SendMessage(hwndEditCtrl, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_COLOR_DEF, 0xFF); + SendMessage(hwndEditCtrl, SCI_INDICSETALPHA, INDIC_NP3_COLOR_DEF, SC_ALPHA_TRANSPARENT); // reset on hover + SendMessage(hwndEditCtrl, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_COLOR_DEF, SC_ALPHA_OPAQUE); SendMessage(hwndEditCtrl, SCI_INDICSETHOVERSTYLE, INDIC_NP3_COLOR_DEF, INDIC_ROUNDBOX); // HOVER SendMessage(hwndEditCtrl, SCI_INDICSETHOVERFORE, INDIC_NP3_COLOR_DEF, RGB(0x00, 0x00, 0x00)); // recalc on hover @@ -1943,8 +1954,8 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl) SendMessage(hwndEditCtrl, SCI_INDICSETSTYLE, INDIC_NP3_UNICODE_POINT, INDIC_COMPOSITIONTHIN /*INDIC_HIDDEN*/); // MARKER only //SendMessage(hwndEditCtrl, SCI_INDICSETUNDER, INDIC_NP3_UNICODE_POINT, false); - SendMessage(hwndEditCtrl, SCI_INDICSETALPHA, INDIC_NP3_UNICODE_POINT, 0x00); - SendMessage(hwndEditCtrl, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_UNICODE_POINT, 0xFF); + SendMessage(hwndEditCtrl, SCI_INDICSETALPHA, INDIC_NP3_UNICODE_POINT, SC_ALPHA_TRANSPARENT); + SendMessage(hwndEditCtrl, SCI_INDICSETOUTLINEALPHA, INDIC_NP3_UNICODE_POINT, SC_ALPHA_NOALPHA); SendMessage(hwndEditCtrl, SCI_INDICSETHOVERSTYLE, INDIC_NP3_UNICODE_POINT, INDIC_ROUNDBOX); // HOVER //SendMessage(hwndEditCtrl, SCI_INDICSETHOVERFORE, INDIC_NP3_UNICODE_POINT, RGB(0xE0, 0xE0, 0xE0)); @@ -4788,41 +4799,39 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) // Main Bookmark Functions case BME_EDIT_BOOKMARKNEXT: { - DocPos const iPos = SciCall_GetCurrentPos(); - DocLn const iLine = SciCall_LineFromPosition(iPos); + DocLn const iLine = Sci_GetCurrentLineNumber(); + int bitmask = SciCall_MarkerGet(iLine) & bitmask32_n(MARKER_NP3_BOOKMARK + 1); + if (!bitmask) { + bitmask = (1 << MARKER_NP3_BOOKMARK); + } - int bitmask = (1 << MARKER_NP3_BOOKMARK); - DocLn iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERNEXT , iLine+1 , bitmask ); - if (iNextLine == (DocLn)-1) - { - iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERNEXT , 0 , bitmask ); - } - - if (iNextLine != (DocLn)-1) - { - SciCall_GotoLine(iNextLine); - EditEnsureSelectionVisible(); - } + DocLn iNextLine = SciCall_MarkerNext(iLine + 1, bitmask); + if (iNextLine == (DocLn)-1) { + iNextLine = SciCall_MarkerNext(0, bitmask); + } + if (iNextLine != (DocLn)-1) { + SciCall_GotoLine(iNextLine); + EditEnsureSelectionVisible(); + } } break; case BME_EDIT_BOOKMARKPREV: { - DocPos const iPos = SciCall_GetCurrentPos(); - DocLn const iLine = SciCall_LineFromPosition(iPos); + DocLn const iLine = Sci_GetCurrentLineNumber(); + int bitmask = SciCall_MarkerGet(iLine) & bitmask32_n(MARKER_NP3_BOOKMARK + 1); + if (!bitmask) { + bitmask = (1 << MARKER_NP3_BOOKMARK); + } - int bitmask = (1 << MARKER_NP3_BOOKMARK); - DocLn iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERPREVIOUS , iLine-1 , bitmask ); - if (iNextLine == (DocLn)-1) - { - iNextLine = (DocLn)SendMessage( Globals.hwndEdit , SCI_MARKERPREVIOUS , SciCall_GetLineCount(), bitmask ); - } - - if (iNextLine != (DocLn)-1) - { - SciCall_GotoLine(iNextLine); - EditEnsureSelectionVisible(); - } + DocLn iNextLine = SciCall_MarkerPrevious(iLine - 1, bitmask); + if (iNextLine == (DocLn)-1) { + iNextLine = SciCall_MarkerPrevious(SciCall_GetLineCount(), bitmask); + } + if (iNextLine != (DocLn)-1) { + SciCall_GotoLine(iNextLine); + EditEnsureSelectionVisible(); + } } break; @@ -4834,6 +4843,10 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) case BME_EDIT_BOOKMARKCLEAR: SciCall_MarkerDeleteAll(MARKER_NP3_BOOKMARK); + for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) { + SciCall_MarkerDeleteAll(m); + WordBookMarks[m].in_use = false; + } break; @@ -6524,23 +6537,23 @@ static DocPos prevCursorPosition = -1; #define RGB_TOLERANCE 0x20 #define RGB_SUB(X, Y) (((X) > (Y)) ? ((X) - (Y)) : ((Y) - (X))) -inline COLORREF _CalcContrastColor(COLORREF rgb, BYTE alpha) +inline COLORREF _CalcContrastColor(COLORREF rgb, int alpha) { - bool const mask = RGB_SUB(MulDiv(rgb >> 0, alpha, 0xFF) & 0xFF, 0x80) <= RGB_TOLERANCE && - RGB_SUB(MulDiv(rgb >> 8, alpha, 0xFF) & 0xFF, 0x80) <= RGB_TOLERANCE && - RGB_SUB(MulDiv(rgb >> 16, alpha, 0xFF) & 0xFF, 0x80) <= RGB_TOLERANCE; + bool const mask = RGB_SUB(MulDiv(rgb >> 0, alpha, SC_ALPHA_OPAQUE) & SC_ALPHA_OPAQUE, 0x80) <= RGB_TOLERANCE && + RGB_SUB(MulDiv(rgb >> 8, alpha, SC_ALPHA_OPAQUE) & SC_ALPHA_OPAQUE, 0x80) <= RGB_TOLERANCE && + RGB_SUB(MulDiv(rgb >> 16, alpha, SC_ALPHA_OPAQUE) & SC_ALPHA_OPAQUE, 0x80) <= RGB_TOLERANCE; - return mask ? (0x7F7F7F + rgb) & 0xFFFFFF : rgb ^ 0xFFFFFF; + return mask ? ((0x7F7F7F + rgb)) & 0xFFFFFF : (rgb ^ 0xFFFFFF); } // ---------------------------------------------------------------------------- -#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 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) // ---------------------------------------------------------------------------- @@ -6652,7 +6665,7 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid) if (sscanf_s(&chText[1], "%x", &iValue) == 1) { COLORREF rgb = 0x000000; - BYTE alpha = 0xFF; + int alpha = SC_ALPHA_OPAQUE; if (length >= 8) // ARGB, RGBA, BGRA { switch (Settings.ColorDefHotspot) { @@ -6676,7 +6689,7 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid) else // RGB { rgb = RGB((iValue >> 16) & 0xFF, (iValue >> 8) & 0xFF, iValue & 0xFF); - alpha = 0xFF; + alpha = SC_ALPHA_OPAQUE; } COLORREF const fgr = _CalcContrastColor(rgb, alpha); @@ -6684,7 +6697,7 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid) SciCall_IndicatorFillRange(firstPos, length); SciCall_IndicSetHoverFore(INDIC_NP3_COLOR_DEF_T, fgr); - SciCall_IndicSetAlpha(INDIC_NP3_COLOR_DEF, alpha); + SciCall_IndicSetAlpha(INDIC_NP3_COLOR_DEF, Sci_ClampAlpha(alpha)); SciCall_IndicSetHoverFore(INDIC_NP3_COLOR_DEF, rgb); } } @@ -6727,7 +6740,7 @@ void HandleDWellStartEnd(const DocPos position, const UINT uid) SciCall_SetIndicatorCurrent(INDIC_NP3_COLOR_DEF_T); SciCall_IndicatorClearRange(0, Sci_GetDocEndPosition()); - SciCall_IndicSetAlpha(INDIC_NP3_COLOR_DEF, 0); + SciCall_IndicSetAlpha(INDIC_NP3_COLOR_DEF, SC_ALPHA_TRANSPARENT); SciCall_IndicSetFore(INDIC_NP3_COLOR_DEF, 0); HandlePosChange(); @@ -6948,22 +6961,25 @@ static void _HandleAutoIndent(int const charAdded) int const eol_mode = SciCall_GetEOLMode(); if (((SC_EOL_CRLF == eol_mode) && (charAdded != '\r')) || (SC_EOL_CRLF != eol_mode)) { - DocPos const iCurPos = SciCall_GetCurrentPos(); - DocLn const iCurLine = SciCall_LineFromPosition(iCurPos); + DocLn const iCurLine = Sci_GetCurrentLineNumber(); // Move bookmark along with line if inserting lines (pressing return within indent area of line) because Scintilla does not do this for us if (iCurLine > 0) { - //DocPos const iPrevLineLength = Sci_GetNetLineLength(iCurLine - 1); + //~DocPos const iPrevLineLength = Sci_GetNetLineLength(iCurLine - 1); if (SciCall_GetLineEndPosition(iCurLine - 1) == SciCall_GetLineIndentPosition(iCurLine - 1)) { - int const bitmask = SciCall_MarkerGet(iCurLine - 1); - if (bitmask & (1 << MARKER_NP3_BOOKMARK)) - { - SciCall_MarkerDelete(iCurLine - 1, MARKER_NP3_BOOKMARK); - SciCall_MarkerAdd(iCurLine, MARKER_NP3_BOOKMARK); + int const bitmask = SciCall_MarkerGet(iCurLine - 1) & bitmask32_n(MARKER_NP3_BOOKMARK + 1); + if (bitmask) { + for (int m = 0; m <= MARKER_NP3_BOOKMARK; ++m) { + if (bitmask & (1 << m)) { + SciCall_MarkerDelete(iCurLine - 1, m); + SciCall_MarkerAdd(iCurLine, m); + } + } } } + //~if (iLineLength <= 2) { DocLn const iPrevLine = iCurLine - 1; diff --git a/src/SciCall.h b/src/SciCall.h index cdc4d0c71..341a99093 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -322,7 +322,7 @@ DeclareSciCallR2(GetLine, GETLINE, DocPos, DocLn, line, const char*, text) DeclareSciCallR2(GetCurLine, GETCURLINE, DocPos, unsigned int, length, const char*, text) inline DocPos SciCall_GetLine_Safe(DocLn iLine, char* pTxtBuf) { - DocPos const iLen = SciCall_GetLine(iLine, pTxtBuf); if (pTxtBuf) pTxtBuf[iLen] = '\0'; return iLen; + DocPos const iLen = SciCall_GetLine(iLine, pTxtBuf); if (pTxtBuf) pTxtBuf[iLen] = '\0'; return (iLen + 1); } @@ -478,8 +478,10 @@ DeclareSciCallR2(MarkerAdd, MARKERADD, int, DocLn, line, int, markerNumber) DeclareSciCallV2(MarkerDelete, MARKERDELETE, DocLn, line, int, markerNumber) DeclareSciCallV1(MarkerDeleteAll, MARKERDELETEALL, int, markerNumber) DeclareSciCallV2(MarkerSetBackSelected, MARKERSETBACKSELECTED, int, markerNumber, int, colour) +DeclareSciCallR2(MarkerNext, MARKERNEXT, DocLn, DocLn, start, int, markerMask) +DeclareSciCallR2(MarkerPrevious, MARKERPREVIOUS, DocLn, DocLn, start, int, markerMask) -//============================================================================= + //============================================================================= // // Line State // @@ -611,6 +613,8 @@ DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool) //~#define Sci_GetDocEndPosition() (SciCall_GetTextLength() - 1) #define Sci_GetDocEndPosition() SciCall_GetLineEndPosition(SciCall_GetLineCount()) +#define Sci_ClampAlpha(alpha) clampi((alpha), SC_ALPHA_TRANSPARENT, /*SC_ALPHA_OPAQUE*/SC_ALPHA_NOALPHA) + // max. line length in range (incl. line-breaks) inline DocPos Sci_GetRangeMaxLineLength(DocLn iBeginLine, DocLn iEndLine) { DocPos iMaxLineLen = 0; diff --git a/src/Styles.c b/src/Styles.c index a2d495fa8..7a9780404 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -430,10 +430,12 @@ float Style_GetBaseFontSize() // int Style_RgbAlpha(int rgbFore, int rgbBack, int alpha) { + alpha = clampi(alpha, SC_ALPHA_TRANSPARENT, SC_ALPHA_OPAQUE); + return (int)RGB(\ (0xFF - alpha) * (int)GetRValue(rgbBack) / 0xFF + alpha * (int)GetRValue(rgbFore) / 0xFF, \ - (0xFF - alpha) * (int)GetGValue(rgbBack) / 0xFF + alpha * (int)GetGValue(rgbFore) / 0xFF, \ - (0xFF - alpha) * (int)GetBValue(rgbBack) / 0xFF + alpha * (int)GetBValue(rgbFore) / 0xFF); + (0xFF - alpha) * (int)GetGValue(rgbBack) / 0xFF + alpha * (int)GetGValue(rgbFore) / 0xFF, \ + (0xFF - alpha) * (int)GetBValue(rgbBack) / 0xFF + alpha * (int)GetBValue(rgbFore) / 0xFF); } @@ -1274,7 +1276,7 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) } else { SendMessage(hwnd, SCI_SETSELALPHA, SC_ALPHA_NOALPHA, 0); - SendMessage(hwnd, SCI_SETADDITIONALSELALPHA, SC_ALPHA_NOALPHA*2/3, 0); + SendMessage(hwnd, SCI_SETADDITIONALSELALPHA, SC_ALPHA_OPAQUE*2/3, 0); } if (Style_StrGetAttrEOLFilled(pCurrentStandard->Styles[STY_SEL_TXT].szValue)) // selection eolfilled @@ -1733,7 +1735,7 @@ void Style_HighlightCurrentLine(HWND hwnd, int iHiLitCurLn) rgb = (backgrColor ? RGB(0xFF, 0xFF, 0x00) : RGB(0xC2, 0xC0, 0xC3)); } - int alpha = 0; + int alpha = SC_ALPHA_TRANSPARENT; if (!Style_StrGetAlpha(GetCurrentStdLexer()->Styles[STY_CUR_LN].szValue, &alpha, true)) { alpha = SC_ALPHA_NOALPHA; } @@ -1814,7 +1816,7 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle) COLORREF bmkFore = clrFore; COLORREF bmkBack = clrBack; - const WCHAR* wchBookMarkStyleStrg = GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue; + const WCHAR* const wchBookMarkStyleStrg = GetCurrentStdLexer()->Styles[STY_BOOK_MARK].szValue; Style_StrGetColor(wchBookMarkStyleStrg, FOREGROUND_LAYER, &bmkFore); Style_StrGetColor(wchBookMarkStyleStrg, BACKGROUND_LAYER, &bmkBack); @@ -1825,11 +1827,9 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle) COLORREF bckgrnd = clrBack; Style_StrGetColor(lpszStyle, BACKGROUND_LAYER, &bckgrnd); - bmkBack = Style_RgbAlpha(bmkBack, bckgrnd, min_i(0xFF, alpha)); + bmkBack = Style_RgbAlpha(bmkBack, bckgrnd, alpha); - //SciCall_MarkerDefine(MARKER_NP3_BOOKMARK, SC_MARK_BOOKMARK); - //SciCall_MarkerDefine(MARKER_NP3_BOOKMARK, SC_MARK_SHORTARROW); - SciCall_MarkerDefine(MARKER_NP3_BOOKMARK, SC_MARK_VERTICALBOOKMARK); + SciCall_MarkerDefine(MARKER_NP3_BOOKMARK, SC_MARK_VERTICALBOOKMARK); // SC_MARK_BOOKMARK/SC_MARK_SHORTARROW SciCall_MarkerSetFore(MARKER_NP3_BOOKMARK, bmkFore); SciCall_MarkerSetBack(MARKER_NP3_BOOKMARK, bmkBack); SciCall_MarkerSetAlpha(MARKER_NP3_BOOKMARK, alpha); @@ -1837,6 +1837,17 @@ void Style_SetMargin(HWND hwnd, int iStyle, LPCWSTR lpszStyle) SciCall_SetMarginSensitiveN(MARGIN_SCI_BOOKMRK, true); SciCall_SetMarginCursorN(MARGIN_SCI_BOOKMRK, SC_NP3_CURSORHAND); + // --- WordBookMarks --- + for (int m = MARKER_NP3_BOOKMARK - 1; m >= 0; --m) + { + COLORREF color; + Style_StrGetColor(WordBookMarks[m].color, BACKGROUND_LAYER, &color); + SciCall_MarkerDefine(m, WordBookMarks[m].sci_symbol); + SciCall_MarkerSetFore(m, color); + SciCall_MarkerSetBack(m, color); + SciCall_MarkerSetAlpha(m, alpha); + } + // --- Code folding --- COLORREF fldHiLight = clrFore; @@ -2849,7 +2860,7 @@ bool Style_StrGetAlpha(LPCWSTR lpszStyle, int* iOutValue, bool bAlpha1st) TrimSpcW(tch); int iValue = 0; if (StrToIntEx(tch, STIF_DEFAULT, &iValue)) { - *iOutValue = clampi(iValue, SC_ALPHA_TRANSPARENT, SC_ALPHA_OPAQUE); + *iOutValue = Sci_ClampAlpha(iValue); return true; } } diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 65dca554f..d1d634022 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -44,9 +44,10 @@ #endif #include "Sci_Position.h" +#include "Scintilla.h" // -// TODO(rkotten): +// TODO: // SCI_CREATEDOCUMENT (SC_DOCUMENTOPTION_TEXT_LARGE) // @@ -249,18 +250,54 @@ typedef struct _cmq // -------------------------------------------------------------------------- -#define MARKER_NP3_BOOKMARK 1 +typedef enum +{ + MARKER_NP3_WORD_0 = 0, + MARKER_NP3_WORD_1, + MARKER_NP3_WORD_2, + MARKER_NP3_WORD_3, + MARKER_NP3_WORD_4, + MARKER_NP3_WORD_5, + MARKER_NP3_WORD_6, + MARKER_NP3_WORD_7, + // std bookmark -> counter is last + MARKER_NP3_BOOKMARK +} MARKER_ID; -#define INDIC_NP3_MARK_OCCURANCE (INDICATOR_CONTAINER + 1) -#define INDIC_NP3_MATCH_BRACE (INDICATOR_CONTAINER + 2) -#define INDIC_NP3_BAD_BRACE (INDICATOR_CONTAINER + 3) -#define INDIC_NP3_FOCUS_VIEW (INDICATOR_CONTAINER + 4) -#define INDIC_NP3_HYPERLINK (INDICATOR_CONTAINER + 5) -#define INDIC_NP3_HYPERLINK_U (INDICATOR_CONTAINER + 6) -#define INDIC_NP3_COLOR_DEF (INDICATOR_CONTAINER + 7) -#define INDIC_NP3_COLOR_DEF_T (INDICATOR_CONTAINER + 8) -#define INDIC_NP3_MULTI_EDIT (INDICATOR_CONTAINER + 9) -#define INDIC_NP3_UNICODE_POINT (INDICATOR_CONTAINER + 10) +// ASSERT( MARKER_NP3_BOOKMARK < SC_MARKNUM_FOLDEREND ) + + +typedef struct _wordbookmark_t +{ + bool in_use; + int sci_symbol; + LPCWSTR color; + +} WORDBOOKMARK_T, *PWORDBOOKMARK_T; + +extern WORDBOOKMARK_T WordBookMarks[]; + + +// -------------------------------------------------------------------------- + + +typedef enum +{ + INDIC_NP3_MARK_OCCURANCE = INDICATOR_CONTAINER, + INDIC_NP3_MATCH_BRACE, + INDIC_NP3_BAD_BRACE, + INDIC_NP3_FOCUS_VIEW, + INDIC_NP3_HYPERLINK, + INDIC_NP3_HYPERLINK_U, + INDIC_NP3_COLOR_DEF, + INDIC_NP3_COLOR_DEF_T, + INDIC_NP3_MULTI_EDIT, + INDIC_NP3_UNICODE_POINT, + // counter is last + INDIC_NP3_ID_CNT +} INDIC_ID; + +// ASSERT( INDIC_NP3_ID_CNT < INDICATOR_IME ) // --------------------------------------------------------------------------