From f009a104f4ebe9fc275a70b3e40f140a69318111 Mon Sep 17 00:00:00 2001 From: "METANEOCORTEX\\Kotti" Date: Mon, 20 Feb 2023 22:15:31 +0100 Subject: [PATCH] +fix: correction to LineSpace evaluation TEXT files --- res/StdDarkModeScheme.ini | 6 ++--- src/StyleLexers/styleLexStandard.c | 4 ++-- src/Styles.c | 37 ++++++++++++++++++------------ src/Styles.h | 2 +- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/res/StdDarkModeScheme.ini b/res/StdDarkModeScheme.ini index 82c46677b..60e5d780a 100644 --- a/res/StdDarkModeScheme.ini +++ b/res/StdDarkModeScheme.ini @@ -64,11 +64,11 @@ Inline-IME Color=fore:#4EF64D [Text Files] Default=font:$Text; size:11 Margins and Line Numbers=font:Consolas; size:-1; fore:#DEDEDE; back:#454545 -Extra Line Spacing (Size)=size:+1 +Extra Line Spacing (Size)=size:2 [ANSI Art] Default=font:Lucida Console; thin; size:11; smoothing:aliased -Margins and Line Numbers=font:Lucida Console; size:-2; fore:#DEDEDE; back:#454545 -Extra Line Spacing (Size)=size:-2 +Margins and Line Numbers=font:Lucida Console; size:-1; fore:#DEDEDE; back:#454545 +Extra Line Spacing (Size)=size:-1 [Apache Config Files] Comment=fore:#DBF873 String=fore:#F651F6 diff --git a/src/StyleLexers/styleLexStandard.c b/src/StyleLexers/styleLexStandard.c index 9b3156eb8..38545cc24 100644 --- a/src/StyleLexers/styleLexStandard.c +++ b/src/StyleLexers/styleLexStandard.c @@ -71,7 +71,7 @@ EDITLEXER lexTEXT = &KeyWords_NULL,{ { {STYLE_DEFAULT}, IDS_LEX_STR_63126, L"Default", L"font:$Text; size:11", L"" }, { {STYLE_LINENUMBER}, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"font:Consolas; size:-1", L"" }, - { {STYLE_BRACELIGHT}, IDS_LEX_STD_X_SPC, L"Extra Line Spacing (Size)", L"size:+1", L"" }, + { {STYLE_BRACELIGHT}, IDS_LEX_STD_X_SPC, L"Extra Line Spacing (Size)", L"size:2", L"" }, EDITLEXER_SENTINEL } }; @@ -85,7 +85,7 @@ EDITLEXER lexANSI = { {STYLE_LINENUMBER}, IDS_LEX_STD_MARGIN, L"Margins and Line Numbers", L"font:Lucida Console; size:-2", L"" }, { {STYLE_BRACELIGHT}, IDS_LEX_STD_BRACE, L"Matching Braces", L"", L"" }, { {STYLE_BRACEBAD}, IDS_LEX_STD_BRACE_FAIL, L"Matching Braces Error", L"", L"" }, - { {STYLE_CONTROLCHAR}, IDS_LEX_STD_X_SPC, L"Extra Line Spacing (Size)", L"size:-2", L"" }, + { {STYLE_CONTROLCHAR}, IDS_LEX_STD_X_SPC, L"Extra Line Spacing (Size)", L"size:-1", L"" }, EDITLEXER_SENTINEL } }; diff --git a/src/Styles.c b/src/Styles.c index fd57614bf..84cb866b7 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -1656,7 +1656,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) size_t const cnt = ReadVectorFromString(Globals.fvCurFile.wchMultiEdgeLines, edgeColumns, COUNTOF(edgeColumns), 0, LONG_LINES_MARKER_LIMIT, 0, true); Style_SetMultiEdgeLine(edgeColumns, cnt); - Style_SetExtraLineSpace(hwnd, pCurrentStandard->Styles[STY_X_LN_SPACE].szValue, 0); + + int iLnSpc = 0; + if (Style_StrGetSizeIntEx(pCurrentStandard->Styles[STY_X_LN_SPACE].szValue, &iLnSpc)) { + Style_SetExtraLineSpace(iLnSpc); + } + else { + Style_SetExtraLineSpace(0); + } if (SciCall_GetIndentationGuides() != SC_IV_NONE) { Style_SetIndentGuides(hwnd, true); @@ -1682,9 +1689,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) pCurrentStandard->Styles[STY_BRACE_BAD].szValue, fBaseFontSize); } - int const curSpc = (SciCall_GetExtraAscent() + SciCall_GetExtraDescent()) >> 1; - Style_SetExtraLineSpace(hwnd, s_pLexCurrent->Styles[STY_CTRL_CHR].szValue, curSpc); - + iLnSpc = 0; // do not inherit from base + if (Style_StrGetSizeIntEx(s_pLexCurrent->Styles[4].szValue, &iLnSpc)) { + Style_SetExtraLineSpace(iLnSpc); + } } else if (s_pLexCurrent == &lexTEXT) { @@ -1693,7 +1701,10 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) Style_CopyStyles_IfNotDefined(pCurrentStandard->Styles[STY_MARGIN].szValue, wchStylesBuffer, COUNTOF(wchStylesBuffer)); Style_SetMargin(hwnd, wchStylesBuffer); - Style_SetExtraLineSpace(hwnd, s_pLexCurrent->Styles[STY_BRACE_OK].szValue, 0); + iLnSpc = (SciCall_GetExtraAscent() + SciCall_GetExtraDescent()) >> 1; // inherit from base + if (Style_StrGetSizeIntEx(s_pLexCurrent->Styles[2].szValue, &iLnSpc)) { + Style_SetExtraLineSpace(iLnSpc); + } } else if (s_pLexCurrent->lexerID != SCLEX_NULL) { @@ -2835,19 +2846,15 @@ void Style_SetIndentGuides(HWND hwnd,bool bShow) // // Style_SetExtraLineSpace() // -void Style_SetExtraLineSpace(HWND hwnd, LPWSTR lpszStyle, int iValue) +void Style_SetExtraLineSpace(int iValue) { - UNREFERENCED_PARAMETER(hwnd); - int iAscent = 0, iDescent = 0; - if (Style_StrGetSizeIntEx(lpszStyle, &iValue)) { - if ((iValue % 2) != 0) { - iAscent++; - iValue--; - } - iAscent += (iValue >> 1); - iDescent += (iValue >> 1); + if ((iValue % 2) != 0) { + iAscent++; + iValue--; } + iAscent += (iValue >> 1); + iDescent += (iValue >> 1); SciCall_SetExtraAscent(iAscent); SciCall_SetExtraDescent(iDescent); } diff --git a/src/Styles.h b/src/Styles.h index f80855b6a..d105e7ead 100644 --- a/src/Styles.h +++ b/src/Styles.h @@ -82,7 +82,7 @@ void Style_ToggleUse2ndDefault(HWND hwnd); bool Style_GetUse2ndDefault(); void Style_SetUse2ndDefault(bool); void Style_SetIndentGuides(HWND hwnd,bool); -void Style_SetExtraLineSpace(HWND hwnd, LPWSTR lpszStyle, int iValue); +void Style_SetExtraLineSpace(int iValue); bool Style_GetFileFilterStr(LPWSTR lpszFilter, int cchFilter, LPWSTR lpszDefExt, int cchExt, bool bSaveAs); bool Style_StrGetFontName(LPCWSTR lpszStyle,LPWSTR lpszFont,int cchFont); bool Style_StrGetFontQuality(LPCWSTR lpszStyle, LPWSTR lpszQuality, int cchQuality, int* iSciQuality_out);