From bdf3794a4f48ec3136f7bd7de79a68d6d45e21bb Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Tue, 30 Aug 2022 02:56:09 +0200 Subject: [PATCH] +add: Change History Marker --- Versions/build.txt | 2 +- language/common_res.h | 1 + language/np3_de_de/menu_de_de.rc | 2 + language/np3_en_us/menu_en_us.rc | 2 + res/Notepad3.exe.manifest.conf | 4 +- src/Config/Config.cpp | 2 + src/Notepad3.c | 17 ++++++ src/SciCall.h | 7 ++- src/Styles.c | 53 ++++++++++++++----- src/Styles.h | 14 ++++- src/TypeDefs.h | 1 + src/VersionEx.h | 10 ++-- .../StyleLexers/styleLexCPP/Config.cpp | 6 +-- 13 files changed, 93 insertions(+), 28 deletions(-) diff --git a/Versions/build.txt b/Versions/build.txt index d00491fd7..0cfbf0888 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -1 +2 diff --git a/language/common_res.h b/language/common_res.h index d45f2c72f..3a4da7b39 100644 --- a/language/common_res.h +++ b/language/common_res.h @@ -763,6 +763,7 @@ #define IDM_VIEW_UNICODE_POINTS 41055 #define IDM_VIEW_WIN_DARK_MODE 41056 #define IDM_VIEW_READONLY 41057 +#define IDM_VIEW_CHGHISTORY_MARGIN 41058 // keep Scintilla(SC) order #define IDM_SET_RENDER_TECH_GDI 42000 // SC_TECHNOLOGY_DEFAULT(0) diff --git a/language/np3_de_de/menu_de_de.rc b/language/np3_de_de/menu_de_de.rc index ce677c6fb..04e82ee10 100644 --- a/language/np3_de_de/menu_de_de.rc +++ b/language/np3_de_de/menu_de_de.rc @@ -384,6 +384,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Zeilen &Nummern\tCtrl+Shift+N", IDM_VIEW_LINENUMBERS MENUITEM "&Lesezeichen Rand\tCtrl+Shift+M", IDM_VIEW_BOOKMARK_MARGIN + MENUITEM "Änderung &Historie Rand", IDM_VIEW_CHGHISTORY_MARGIN MENUITEM SEPARATOR POPUP "Code &Faltung" BEGIN @@ -582,6 +583,7 @@ BEGIN MENUITEM "Code Faltung", IDM_VIEW_FOLDING MENUITEM "Zeilen Nummern", IDM_VIEW_LINENUMBERS MENUITEM "Lesezeichen Rand", IDM_VIEW_BOOKMARK_MARGIN + MENUITEM "Änderung Historie Rand", IDM_VIEW_CHGHISTORY_MARGIN END POPUP "+" BEGIN diff --git a/language/np3_en_us/menu_en_us.rc b/language/np3_en_us/menu_en_us.rc index ebb2f2923..7c75d0987 100644 --- a/language/np3_en_us/menu_en_us.rc +++ b/language/np3_en_us/menu_en_us.rc @@ -384,6 +384,7 @@ BEGIN MENUITEM SEPARATOR MENUITEM "Line &Numbers\tCtrl+Shift+N", IDM_VIEW_LINENUMBERS MENUITEM "Bookmark &Margin\tCtrl+Shift+M", IDM_VIEW_BOOKMARK_MARGIN + MENUITEM "Change &History Margin", IDM_VIEW_CHGHISTORY_MARGIN MENUITEM SEPARATOR POPUP "&Folding" BEGIN @@ -582,6 +583,7 @@ BEGIN MENUITEM "Folding", IDM_VIEW_FOLDING MENUITEM "Line Numbers", IDM_VIEW_LINENUMBERS MENUITEM "Bookmark Margin", IDM_VIEW_BOOKMARK_MARGIN + MENUITEM "Change History Margin", IDM_VIEW_CHGHISTORY_MARGIN END POPUP "+" BEGIN diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index d8f1ef790..da43140f9 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,8 +3,8 @@ - Notepad3 beta + Notepad3 LongPath diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 2462e946b..2877afa50 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -1523,6 +1523,7 @@ void LoadSettings() GET_BOOL_VALUE_FROM_INISECTION(AutoDetectIndentSettings, false); GET_BOOL_VALUE_FROM_INISECTION(ShowBookmarkMargin, IniSectionGetBool(IniSecSettings, L"ShowSelectionMargin", true)); + GET_BOOL_VALUE_FROM_INISECTION(ShowChangeHistoryMargin, IniSectionGetBool(IniSecSettings, L"ShowChangeHistoryMargin", true)); GET_BOOL_VALUE_FROM_INISECTION(ShowLineNumbers, true); GET_BOOL_VALUE_FROM_INISECTION(ShowCodeFolding, true); FocusedView.ShowCodeFolding = Settings.ShowCodeFolding; @@ -1986,6 +1987,7 @@ static bool _SaveSettings(bool bForceSaveSettings) IniSectionDelete(IniSecSettings, L"MultiEdgeLines", false); } SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowBookmarkMargin); + SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowChangeHistoryMargin); IniSectionDelete(IniSecSettings, L"ShowSelectionMargin", false); // old SAVE_VALUE_IF_NOT_EQ_DEFAULT(Bool, ShowLineNumbers); diff --git a/src/Notepad3.c b/src/Notepad3.c index 256535d49..37905f9a7 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -2213,7 +2213,13 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl) SciCall_SetMargins(NUMBER_OF_MARGINS); SciCall_SetMarginTypeN(MARGIN_SCI_LINENUM, SC_MARGIN_NUMBER); + SciCall_SetMarginTypeN(MARGIN_SCI_BOOKMRK, SC_MARGIN_SYMBOL); + SciCall_SetMarginMaskN(MARGIN_SCI_BOOKMRK, ~SC_MASK_FOLDERS & ~MARGIN_MARK_HISTORY_MASK); + + SciCall_SetMarginTypeN(MARGIN_SCI_CHGHIST, SC_MARGIN_SYMBOL); + SciCall_SetMarginMaskN(MARGIN_SCI_CHGHIST, MARGIN_MARK_HISTORY_MASK); + SciCall_SetMarginTypeN(MARGIN_SCI_FOLDING, SC_MARGIN_COLOUR); SciCall_SetMarginMaskN(MARGIN_SCI_FOLDING, SC_MASK_FOLDERS); @@ -3702,6 +3708,7 @@ LRESULT MsgContextMenu(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) const SCNotification* const scn = (SCNotification*)lParam; switch (scn->margin) { case MARGIN_SCI_FOLDING: + case MARGIN_SCI_CHGHIST: case MARGIN_SCI_BOOKMRK: case MARGIN_SCI_LINENUM: imenu = MNU_MARGIN; @@ -4137,6 +4144,7 @@ LRESULT MsgInitMenu(HWND hwnd, WPARAM wParam, LPARAM lParam) CheckCmd(hmenu, IDM_VIEW_SHOWINDENTGUIDES, Settings.ShowIndentGuides); CheckCmd(hmenu, IDM_VIEW_LINENUMBERS, Settings.ShowLineNumbers); CheckCmd(hmenu, IDM_VIEW_BOOKMARK_MARGIN, Settings.ShowBookmarkMargin); + CheckCmd(hmenu, IDM_VIEW_CHGHISTORY_MARGIN, Settings.ShowChangeHistoryMargin); CheckCmd(hmenu, IDM_VIEW_CHASING_DOCTAIL, FileWatching.MonitoringLog); CheckCmd(hmenu, IDM_VIEW_MARKOCCUR_ONOFF, IsMarkOccurrencesEnabled()); @@ -5785,6 +5793,11 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) UpdateMarginWidth(true); break; + case IDM_VIEW_CHGHISTORY_MARGIN: + Settings.ShowChangeHistoryMargin = !Settings.ShowChangeHistoryMargin; + UpdateMarginWidth(true); + break; + case IDM_SET_AUTOCOMPLETEWORDS: Settings.AutoCompleteWords = !Settings.AutoCompleteWords; SciCall_AutoCCancel(); @@ -8402,6 +8415,7 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const SCNotification* const scn) case MARGIN_SCI_BOOKMRK: EditBookmarkToggle(Globals.hwndEdit, SciCall_LineFromPosition(scn->position), scn->modifiers); break; + case MARGIN_SCI_CHGHIST: case MARGIN_SCI_LINENUM: //~SciCall_GotoLine(SciCall_LineFromPosition(scn->position)); // fallthrough @@ -9970,6 +9984,7 @@ void UpdateMarginWidth(const bool bForce) SciCall_SetMarginWidthN(MARGIN_SCI_LINENUM, 0); } Style_SetBookmark(Globals.hwndEdit, Settings.ShowBookmarkMargin); + Style_SetChangeHistory(Globals.hwndEdit, Settings.ShowChangeHistoryMargin); Style_SetFolding(Globals.hwndEdit, (FocusedView.CodeFoldingAvailable && FocusedView.ShowCodeFolding)); bShowLnNums = Settings.ShowLineNumbers; prevLineCount = currLineCount; @@ -10067,6 +10082,7 @@ void UndoRedoRecordingStart() InterlockedExchange(&UndoActionToken, UNDOREDO_FREE); // clear _UndoRedoActionMap(-1, NULL); SciCall_SetUndoCollection(true); + SciCall_SetChangeHistory(SC_CHANGE_HISTORY_ENABLED | SC_CHANGE_HISTORY_MARKERS | SC_CHANGE_HISTORY_INDICATORS); } @@ -10083,6 +10099,7 @@ void UndoRedoRecordingStop() _UndoRedoActionMap(-1, NULL); + SciCall_SetChangeHistory(SC_CHANGE_HISTORY_DISABLED); SciCall_SetUndoCollection(false); SciCall_EmptyUndoBuffer(); } diff --git a/src/SciCall.h b/src/SciCall.h index 5b3eb22e8..3c0e644fa 100644 --- a/src/SciCall.h +++ b/src/SciCall.h @@ -163,7 +163,6 @@ DeclareSciCallR0(GetPositionCache, GETPOSITIONCACHE, int); DeclareSciCallV1(SetPositionCache, SETPOSITIONCACHE, int, cache); DeclareSciCallR0(GetLayoutThreads, GETLAYOUTTHREADS, int); DeclareSciCallV1(SetLayoutThreads, SETLAYOUTTHREADS, int, threads); - // Event Masks DeclareSciCallR0(GetModEventMask, GETMODEVENTMASK, int); DeclareSciCallV1(SetModEventMask, SETMODEVENTMASK, int, mask); @@ -411,6 +410,12 @@ DeclareSciCallR2(GetRangePointer, GETRANGEPOINTER, char *const, DocPos, start, D DeclareSciCallR2(GetLine, GETLINE, DocPos, DocLn, line, const char*, text); DeclareSciCallR2(GetCurLine, GETCURLINE, DocPos, unsigned int, length, const char*, text); // NULL: w/o terminating '\0' (SCI v515) +// change history +DeclareSciCallV1(SetChangeHistory, SETCHANGEHISTORY, int, changeHistory); +DeclareSciCallR0(GetChangeHistory, GETCHANGEHISTORY, int); + +//============================================================================= + inline DocPos SciCall_GetLine_Safe(DocLn iLine, char* pTxtBuf) { DocPos const iLen = SciCall_GetLine(iLine, pTxtBuf); diff --git a/src/Styles.c b/src/Styles.c index 5508b4070..3555d4b44 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -277,16 +277,16 @@ static inline int MapFQNameToSciFontQuality(LPCWSTR fqName) { //============================================================================= // ensure to be consistent with -static WCHAR* IndicatorTypes[22] = { +static WCHAR* IndicatorTypes[23] = { L"indic_plain", // 0 INDIC_PLAIN L"indic_squiggle", // 1 INDIC_SQUIGGLE L"indic_tt", // 2 INDIC_TT L"indic_diagonal", // 3 INDIC_DIAGONAL - L"indic_strike", // 4 INDIC_STRIKE 4 - L"indic_hidden", // 5 INDIC_HIDDEN 5 - L"indic_box", // 6 INDIC_BOX 6 - L"indic_roundbox", // 7 INDIC_ROUNDBOX 7 - L"indic_straightbox", // 8 INDIC_STRAIGHTBOX 8 + L"indic_strike", // 4 INDIC_STRIKE + L"indic_hidden", // 5 INDIC_HIDDEN + L"indic_box", // 6 INDIC_BOX + L"indic_roundbox", // 7 INDIC_ROUNDBOX + L"indic_straightbox", // 8 INDIC_STRAIGHTBOX L"indic_dash", // 9 INDIC_DASH L"indic_dots", // 10 INDIC_DOTS L"indic_squigglelow", // 11 INDIC_SQUIGGLELOW @@ -299,7 +299,8 @@ static WCHAR* IndicatorTypes[22] = { L"indic_point", // 18 INDIC_POINT L"indic_pointcharacter", // 19 INDIC_POINTCHARACTER L"indic_gradient", // 20 INDIC_GRADIENT - L"indic_gradientcentre" // 21 INDIC_GRADIENTCENTRE + L"indic_gradientcentre", // 21 INDIC_GRADIENTCENTRE + L"indic_point_top" // 22 INDIC_POINT_TOP }; static inline bool HasIndicStyleStrokeWidth(const int indicStyle) { @@ -1595,6 +1596,9 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) // bookmark line or marker Style_SetBookmark(hwnd, Settings.ShowBookmarkMargin); + + // Change History + Style_SetChangeHistory(hwnd, Settings.ShowChangeHistoryMargin); // Hyperlink (URL) indicators Style_SetUrlHotSpot(hwnd); @@ -2054,6 +2058,16 @@ void Style_SetBookmark(HWND hwnd, bool bShowMargin) } +//============================================================================= +// +// Style_SetChangeHistory() +// +void Style_SetChangeHistory(HWND hwnd, bool bShowMargin) +{ + SciCall_SetMarginWidthN(MARGIN_SCI_CHGHIST, (bShowMargin ? _GetMarkerMarginWidth(hwnd) : 0)); +} + + //============================================================================= // // Style_SetMargin() @@ -2077,13 +2091,23 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE } COLORREF const clrMarginBack = colorRead; + COLORREF fldHiLight = clrLineNumFore; + const WCHAR* wchHighlightStyleStrg = GetCurrentStdLexer()->Styles[STY_SEL_TXT].szValue; + Style_StrGetColor(wchHighlightStyleStrg, FOREGROUND_LAYER, &fldHiLight, true); + + COLORREF clrFoldMarginBack = clrMarginBack; + const WCHAR* wchDefaultStyleStrg = GetCurrentStdLexer()->Styles[STY_DEFAULT].szValue; + Style_StrGetColor(wchDefaultStyleStrg, BACKGROUND_LAYER, &clrFoldMarginBack, true); + + + // --- Line Numbers --- SciCall_StyleSetBack(STYLE_LINENUMBER, clrMarginBack); SciCall_SetMarginBackN(MARGIN_SCI_LINENUM, clrMarginBack); //~SciCall_SetMarginBackN(MARGIN_SCI_LINENUM, clrLineNumBack); SciCall_SetMarginSensitiveN(MARGIN_SCI_LINENUM, false); /// (!) false: allow selection drag - // CallTips + // --- CallTips --- SciCall_CallTipSetBack(clrMarginBack); SciCall_CallTipSetFore(RGB(0x80, 0x80, 0x80)); SciCall_CallTipSetForeHlt(clrLineNumFore); @@ -2137,12 +2161,11 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE SciCall_SetMarginSensitiveN(MARGIN_SCI_BOOKMRK, true); SciCall_SetMarginCursorN(MARGIN_SCI_BOOKMRK, SC_NP3_CURSORHAND); + // --- Change History --- + SciCall_SetMarginBackN(MARGIN_SCI_CHGHIST, clrMarginBack); + SciCall_SetMarginSensitiveN(MARGIN_SCI_CHGHIST, false); // --- Code folding --- - COLORREF fldHiLight = clrLineNumFore; - const WCHAR* wchHighlightStyleStrg = GetCurrentStdLexer()->Styles[STY_SEL_TXT].szValue; - Style_StrGetColor(wchHighlightStyleStrg, FOREGROUND_LAYER, &fldHiLight, true); - SciCall_SetMarginBackN(MARGIN_SCI_FOLDING, clrMarginBack); SciCall_SetMarginSensitiveN(MARGIN_SCI_FOLDING, true); @@ -2183,8 +2206,9 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE } SciCall_MarkerEnableHighlight(true); // highlight folding block - SciCall_SetFoldMarginColour(true, clrMarginBack); // background - SciCall_SetFoldMarginHiColour(true, clrMarginBack); // (!) + // background + SciCall_SetFoldMarginColour(true, clrFoldMarginBack); // background + SciCall_SetFoldMarginHiColour(true, clrFoldMarginBack); // (!) //SciCall_FoldDisplayTextSetStyle(SC_FOLDDISPLAYTEXT_HIDDEN); int fldStyleLn = 0; @@ -2207,6 +2231,7 @@ void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle) /// iStyle == STYLE_LINENUMBE // set width Style_SetBookmark(hwnd, Settings.ShowBookmarkMargin); + Style_SetChangeHistory(hwnd, Settings.ShowChangeHistoryMargin); Style_SetFolding(hwnd, (FocusedView.CodeFoldingAvailable && FocusedView.ShowCodeFolding)); } diff --git a/src/Styles.h b/src/Styles.h index dfa675932..65b832bf7 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -24,8 +24,17 @@ #define MARGIN_SCI_LINENUM 0 #define MARGIN_SCI_BOOKMRK 1 -#define MARGIN_SCI_FOLDING 2 -#define NUMBER_OF_MARGINS 3 +#define MARGIN_SCI_CHGHIST 2 +#define MARGIN_SCI_FOLDING 3 +#define NUMBER_OF_MARGINS 4 + +#define MARGIN_MARK_HISTORY_MASK ( \ + (1 << SC_MARKNUM_HISTORY_REVERTED_TO_ORIGIN) | \ + (1 << SC_MARKNUM_HISTORY_SAVED) | \ + (1 << SC_MARKNUM_HISTORY_MODIFIED) | \ + (1 << SC_MARKNUM_HISTORY_REVERTED_TO_MODIFIED) \ +) + int Style_NumOfLexers(); // Number of Lexers in pLexArray @@ -56,6 +65,7 @@ void Style_SetInvisible(HWND hwnd, bool); void Style_HighlightCurrentLine(HWND hwnd, int); void Style_SetFolding(HWND hwnd, bool bShowMargin); void Style_SetBookmark(HWND hwnd, bool bShowMargin); +void Style_SetChangeHistory(HWND hwnd, bool bShowMargin); void Style_SetMargin(HWND hwnd, LPCWSTR lpszStyle); bool Style_SetLexerFromFile(HWND hwnd,const HPATHL hpath); bool Style_MaybeBinaryFile(HWND hwnd, const HPATHL hpath); diff --git a/src/TypeDefs.h b/src/TypeDefs.h index ebd889456..6d1b4787e 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -551,6 +551,7 @@ typedef struct SETTINGS_T { int LongLinesLimit; int LongLineMode; bool ShowBookmarkMargin; + bool ShowChangeHistoryMargin; bool ShowLineNumbers; bool ShowCodeFolding; bool MarkOccurrences; diff --git a/src/VersionEx.h b/src/VersionEx.h index b5fafe116..c2d01d359 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -9,12 +9,12 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 22 #define VERSION_REV 829 -#define VERSION_BUILD 1 -#define SCINTILLA_VER 520 -#define LEXILLA_VER 515 +#define VERSION_BUILD 2 +#define SCINTILLA_VER 530 +#define LEXILLA_VER 519 #define ONIGURUMA_REGEX_VER 6.9.8 #define UCHARDET_VER 2018.09.27 #define TINYEXPR_VER 2018.05.11 #define UTHASH_VER 2.3.0 -#define VERSION_PATCH beta -#define VERSION_COMMIT_ID dkt1-amr +#define VERSION_PATCH LongPath +#define VERSION_COMMIT_ID metaneoc diff --git a/test/test_files/StyleLexers/styleLexCPP/Config.cpp b/test/test_files/StyleLexers/styleLexCPP/Config.cpp index 141a79841..28be50c2c 100644 --- a/test/test_files/StyleLexers/styleLexCPP/Config.cpp +++ b/test/test_files/StyleLexers/styleLexCPP/Config.cpp @@ -10,7 +10,7 @@ addindex #include #include -// TODO: fkdlkldfdl +// TODO : fkdlkldfdl // ---------------------------------------------------------------------------- @@ -29,11 +29,11 @@ extern "C" WININFO s_WinInfo; extern "C" WININFO s_DefWinInfo; extern "C" const WCHAR* const TBBUTTON_DEFAULT_IDS_V1; -extern "C" const WCHAR* const TBBUTTON_DEFAULT_IDS_V2; +ext ern "C" const WCHAR* const TBBUTTON_DEFAULT_IDS_V2; extern "C" prefix_t s_mxSBPrefix[STATUS_SECTOR_COUNT]; extern "C" prefix_t s_mxSBPostfix[STATUS_SECTOR_COUNT]; -extern "C" bool s_iStatusbarVisible[STATUS_SECTOR_COUNT]; +exte rn "C" bool s_iStatusbarVisible[STATUS_SECTOR_COUNT]; extern "C" int s_iStatusbarWidthSpec[STATUS_SECTOR_COUNT]; extern "C" int s_vSBSOrder[STATUS_SECTOR_COUNT];