From 3cff6841c8f2376eb529f925c293e14745e011e4 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 9 May 2018 08:54:55 +0200 Subject: [PATCH] + fix: issue regarding selection of default and 2nd default styling --- src/Notepad3.c | 2 +- src/Styles.c | 27 +++++++++++---------------- src/Version.h | Bin 26398 -> 26406 bytes 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index 30870349d..2287d4b7a 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -7950,7 +7950,7 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw) // ------------------------------------------------------ static bool s_bUse2ndDefault = -1; - bool const bUse2ndDefault = Style_GetUse2ndDefault(); + bool bUse2ndDefault = Style_GetUse2ndDefault(); if (s_bUse2ndDefault != bUse2ndDefault) { if (bUse2ndDefault) { diff --git a/src/Styles.c b/src/Styles.c index 95a03bc68..04a911da8 100644 --- a/src/Styles.c +++ b/src/Styles.c @@ -3135,7 +3135,7 @@ void Style_Load() LoadIniSection(L"Styles",pIniSection,cchIniSection); // 2nd default - Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", 0)); + Style_SetUse2ndDefault(IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", false)); // default scheme g_iDefaultLexer = IniSectionGetInt(pIniSection,L"DefaultScheme",0); @@ -3348,13 +3348,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) if (!pLexNew) { pLexNew = GetDefaultLexer(); } - if (IsLexerStandard(pLexNew)) { - pLexNew = Style_GetUse2ndDefault() ? &lexStandard2nd : &lexStandard; - } const WCHAR* const wchNewLexerStyleStrg = pLexNew->Styles[STY_DEFAULT].szValue; // first set standard lexer's default values - g_pLexCurrent = GetCurrentStdLexer(); + if (IsLexerStandard(pLexNew)) + g_pLexCurrent = pLexNew; + else + g_pLexCurrent = GetCurrentStdLexer(); + const WCHAR* const wchStandardStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue; // Lexer @@ -4463,7 +4464,7 @@ void Style_SetLexerFromID(HWND hwnd,int id) // void Style_ToggleUse2ndDefault(HWND hwnd) { - bool use2ndDefStyle = Style_GetUse2ndDefault(); + bool const use2ndDefStyle = Style_GetUse2ndDefault(); Style_SetUse2ndDefault(use2ndDefStyle ? false : true); // swap Style_SetLexer(hwnd,g_pLexCurrent); } @@ -4477,8 +4478,8 @@ void Style_SetDefaultFont(HWND hwnd, bool bGlobalDefault) { WCHAR newStyle[BUFSIZE_STYLE_VALUE] = { L'\0' }; - const PEDITLEXER pLexer = bGlobalDefault ? GetCurrentStdLexer() : g_pLexCurrent; - const PEDITSTYLE pLexerDefStyle = &(pLexer->Styles[STY_DEFAULT]); + PEDITLEXER const pLexer = bGlobalDefault ? GetCurrentStdLexer() : g_pLexCurrent; + PEDITSTYLE const pLexerDefStyle = &(pLexer->Styles[STY_DEFAULT]); StringCchCopyW(newStyle, COUNTOF(newStyle), pLexer->Styles[STY_DEFAULT].szValue); @@ -5661,13 +5662,8 @@ int Style_GetCurrentLexerRID() // void Style_GetCurrentLexerName(LPWSTR lpszName, int cchName) { - if (IsLexerStandard(g_pLexCurrent)) { - StringCchPrintfW(lpszName, cchName, L" %s", GetCurrentStdLexer()->pszName); - } - else { - if (!GetString(g_pLexCurrent->resID, lpszName, cchName)) { - StringCchCopyW(lpszName, cchName, g_pLexCurrent->pszName); - } + if (!GetString(g_pLexCurrent->resID, lpszName, cchName)) { + StringCchCopyW(lpszName, cchName, g_pLexCurrent->pszName); } } @@ -6644,7 +6640,6 @@ void Style_SelectLexerDlg(HWND hwnd) MAKEINTRESOURCE(IDD_STYLESELECT), GetParent(hwnd), Style_SelectLexerDlgProc, 0)) - Style_SetUse2ndDefault(g_pLexCurrent == &lexStandard2nd); Style_SetLexer(hwnd, g_pLexCurrent); } diff --git a/src/Version.h b/src/Version.h index 06c6e1af16e97b053a0ab155c6f1e6587477205d..4e5cb6f1f1cb4b01e2add733c8dad8353cba2232 100644 GIT binary patch delta 32 ocmbPtj&a#J#tnypSTz_77<4B)hDc5hh-8`kAl6~COfZuO0LC>6`Tzg` delta 20 ccmZ2>j&a^O#tnyp7!4*DhDB~x31$)j0AE!H%K!iX