+ enh: handling of default/standard lexer styles

This commit is contained in:
Rainer Kottenhoff 2018-05-10 14:02:57 +02:00
parent ca2129b66b
commit 185e09cde8
3 changed files with 39 additions and 15 deletions

View File

@ -6123,7 +6123,9 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam)
return true;
case STATUS_2ND_DEF:
PostMessage(hwnd, WM_COMMAND, MAKELONG(IDM_VIEW_USE2NDDEFAULT, 1), 0);
if (!Style_IsCurLexerStandard()) {
PostMessage(hwnd, WM_COMMAND, MAKELONG(IDM_VIEW_USE2NDDEFAULT, 1), 0);
}
return true;
case STATUS_LEXER:
@ -7946,17 +7948,25 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
}
// ------------------------------------------------------
static bool s_bUse2ndDefault = -1;
bool bUse2ndDefault = Style_GetUse2ndDefault();
if (s_bUse2ndDefault != bUse2ndDefault) {
if (bUse2ndDefault)
{
StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s2ND", g_mxStatusBarPrefix[STATUS_2ND_DEF]);
}
else {
static int s_iUse2ndDefault = -1;
int iUse2ndDefault = Style_IsCurLexerStandard() ? 0 : (Style_GetUse2ndDefault() ? 2 : 1);
if (s_iUse2ndDefault != iUse2ndDefault) {
switch (iUse2ndDefault) {
case 0:
StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s", g_mxStatusBarPrefix[STATUS_2ND_DEF]);
break;
case 1:
StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sSTD", g_mxStatusBarPrefix[STATUS_2ND_DEF]);
break;
case 2:
StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%s2ND", g_mxStatusBarPrefix[STATUS_2ND_DEF]);
break;
default:
StringCchPrintf(tchStatusBar[STATUS_2ND_DEF], txtWidth, L"%sXXX", g_mxStatusBarPrefix[STATUS_2ND_DEF]);
break;
}
s_bUse2ndDefault = bUse2ndDefault;
s_iUse2ndDefault = iUse2ndDefault;
bIsUpdateNeeded = true;
}
// ------------------------------------------------------
@ -7964,13 +7974,11 @@ static void __fastcall _UpdateStatusbarDelayed(bool bForceRedraw)
static WCHAR tchLexerName[MINI_BUFFER];
static int s_iCurLexer = -1;
static bool s_bIs2ndDefault = -1;
int const iCurLexer = Style_GetCurrentLexerRID();
if ((s_iCurLexer != iCurLexer) || (s_bIs2ndDefault != bUse2ndDefault)) {
if (s_iCurLexer != iCurLexer) {
Style_GetCurrentLexerName(tchLexerName, MINI_BUFFER);
StringCchPrintf(tchStatusBar[STATUS_LEXER], txtWidth, L"%s%s", g_mxStatusBarPrefix[STATUS_LEXER], tchLexerName);
s_iCurLexer = iCurLexer;
s_bIs2ndDefault = bUse2ndDefault;
bIsUpdateNeeded = true;
}
// ------------------------------------------------------

View File

@ -3043,6 +3043,17 @@ PEDITLEXER __fastcall GetDefaultLexer()
}
//=============================================================================
//
// IsLexerStandard()
//
bool Style_IsCurLexerStandard()
{
return IsLexerStandard(g_pLexCurrent);
}
//=============================================================================
//
// _SetBaseFontSize(), _GetBaseFontSize()
@ -3358,10 +3369,14 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
const WCHAR* const wchNewLexerStyleStrg = pLexNew->Styles[STY_DEFAULT].szValue;
// first set standard lexer's default values
if (IsLexerStandard(pLexNew))
if (IsLexerStandard(pLexNew)) {
g_pLexCurrent = pLexNew;
else
EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_USE2NDDEFAULT, false);
}
else {
g_pLexCurrent = GetCurrentStdLexer();
EnableCmd(GetMenu(g_hwndMain), IDM_VIEW_USE2NDDEFAULT, true);
}
const WCHAR* const wchStandardStyleStrg = g_pLexCurrent->Styles[STY_DEFAULT].szValue;

View File

@ -105,6 +105,7 @@ void Style_CopyStyles_IfNotDefined(LPWSTR,LPWSTR,int,bool,bool);
bool Style_SelectFont(HWND,LPWSTR,int,LPCWSTR,LPCWSTR,bool,bool,bool,bool);
bool Style_SelectColor(HWND,bool,LPWSTR,int,bool);
void Style_SetStyles(HWND,int,LPCWSTR,bool);
bool Style_IsCurLexerStandard();
int Style_GetCurrentLexerRID();
void Style_GetCurrentLexerName(LPWSTR,int);
int Style_GetLexerIconId(PEDITLEXER);