+ feature: Dual configuration of Default Text Font or Current Scheme's Default Text Font

This commit is contained in:
Rainer Kottenhoff 2017-12-19 21:54:01 +01:00
parent c3a1c9fb4a
commit d3b8dbdc74
5 changed files with 74 additions and 14 deletions

View File

@ -4047,11 +4047,16 @@ LRESULT MsgCommand(HWND hwnd,WPARAM wParam,LPARAM lParam)
case IDM_VIEW_FONT:
Style_SetDefaultFont(hwndEdit);
Style_SetDefaultFont(hwndEdit, TRUE);
UpdateStatusbar();
UpdateLineNumberWidth();
break;
case IDM_VIEW_CURRENTSCHEME:
Style_SetDefaultFont(hwndEdit, FALSE);
UpdateStatusbar();
UpdateLineNumberWidth();
break;
case IDM_VIEW_WORDWRAP:
bWordWrap = (bWordWrap) ? FALSE : TRUE;

Binary file not shown.

View File

@ -2215,7 +2215,7 @@ EDITLEXER lexLATEX = { SCLEX_LATEX, 63281, L"LaTeX Files", L"tex; latex; sty", L
{ -1, 00000, L"", L"", L"" } } };
EDITLEXER lexANSI = { SCLEX_NULL, 63258, L"ANSI Art", L"nfo; diz", L"", &KeyWords_NULL, {
EDITLEXER lexANSI = { SCLEX_NULL, 63266, L"ANSI Art", L"nfo; diz", L"", &KeyWords_NULL, {
{ STYLE_DEFAULT, 63126, L"Default", L"font:Lucida Console", L"" },
{ STYLE_LINENUMBER, 63101, L"Margins and Line Numbers", L"font:Lucida Console; size:-2", L"" },
{ STYLE_BRACELIGHT, 63102, L"Matching Braces", L"size:+0", L"" },
@ -4025,10 +4025,40 @@ void Style_ToggleUse2ndDefault(HWND hwnd)
}
//=============================================================================
//
// Style_SetDefaultFont()
//
void Style_SetDefaultFont(HWND hwnd, BOOL bGlobalDefault)
{
WCHAR newStyle[BUFSIZE_STYLE_VALUE] = { L'\0' };
int iIdx = 0;
PEDITLEXER pLexer = pLexCurrent;
if (pLexCurrent == &lexDefault) {
bGlobalDefault = TRUE;
iIdx = (bUse2ndDefaultStyle) ? STY_CNT_LAST : 0;
pLexer = &lexDefault;
}
StringCchCopyW(newStyle, COUNTOF(newStyle), pLexer->Styles[STY_DEFAULT + iIdx].szValue);
if (Style_SelectFont(hwnd, newStyle, COUNTOF(newStyle), bGlobalDefault, FALSE, TRUE))
{
// set new styles to current lexer's default text
StringCchCopyW(pLexer->Styles[STY_DEFAULT + iIdx].szValue, COUNTOF(pLexer->Styles[STY_DEFAULT + iIdx].szValue), newStyle);
fStylesModified = TRUE;
// redraw current lexer
Style_SetLexer(hwnd, pLexCurrent);
}
}
/*
void Style_SetDefaultFont(HWND hwnd)
{
const int iIdx = (bUse2ndDefaultStyle) ? STY_CNT_LAST : 0;
@ -4038,7 +4068,7 @@ void Style_SetDefaultFont(HWND hwnd)
StringCchCopyW(font, COUNTOF(font), lexDefault.Styles[STY_DEFAULT + iIdx].szValue);
if (Style_SelectFont(hwnd, font, COUNTOF(font), TRUE, TRUE, FALSE))
if (Style_SelectFont(hwnd, font, COUNTOF(font), TRUE, FALSE, FALSE))
{
INT_PTR answer = IDNO;
if (pLexCurrent != &lexDefault) {
@ -4072,6 +4102,7 @@ void Style_SetDefaultFont(HWND hwnd)
}
}
}
*/
//=============================================================================
@ -4556,6 +4587,24 @@ void Style_CopyStyles_IfNotDefined(LPWSTR lpszStyleSrc, LPWSTR lpszStyleDest, in
static const WCHAR* FontSelTitle1 = L"Global Default Font";
static const WCHAR* FontSelTitle2 = L"Current Scheme Default Font";
/// Callback to set the font dialog's title
static UINT CALLBACK Style_FontDialogHook(
HWND hdlg, // handle to the dialog box window
UINT uiMsg, // message identifier
WPARAM wParam, // message parameter
LPARAM lParam // message parameter
)
{
if (uiMsg == WM_INITDIALOG) {
SetWindowText(hdlg, (WCHAR*)((CHOOSEFONT*)lParam)->lCustData);
}
UNUSED(wParam);
return 0; // Allow the default handler a chance to process
}
//=============================================================================
//
// Style_SelectFont()
@ -4612,6 +4661,7 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,
if (Style_StrGetColor(TRUE, lpszStyle, &iValue)) {
color = iValue;
}
// Init cf
CHOOSEFONT cf;
ZeroMemory(&cf, sizeof(CHOOSEFONT));
@ -4619,11 +4669,13 @@ BOOL Style_SelectFont(HWND hwnd,LPWSTR lpszStyle,int cchStyle,
cf.hwndOwner = hwnd;
cf.rgbColors = color;
cf.lpLogFont = &lf;
cf.lpfnHook = (LPCFHOOKPROC)Style_FontDialogHook; // Register the callback
cf.lCustData = (LPARAM)(bDefaultStyle ? FontSelTitle1 : FontSelTitle2);
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_NOSCRIPTSEL | CF_BOTH | CF_WYSIWYG | CF_FORCEFONTEXIST | CF_ENABLEHOOK;
if (bWithEffects)
cf.Flags = CF_INITTOLOGFONTSTRUCT | CF_EFFECTS | CF_NOSCRIPTSEL | CF_BOTH | CF_WYSIWYG | CF_FORCEFONTEXIST;
else
cf.Flags = CF_INITTOLOGFONTSTRUCT /*| CF_EFFECTS | CF_NOSCRIPTSEL*/ | CF_BOTH | CF_WYSIWYG | CF_FORCEFONTEXIST;
cf.Flags |= CF_EFFECTS;
if (HIBYTE(GetKeyState(VK_SHIFT)))
cf.Flags |= CF_FIXEDPITCHONLY;
@ -5354,9 +5406,11 @@ INT_PTR CALLBACK Style_ConfigDlgProc(HWND hwnd,UINT umsg,WPARAM wParam,LPARAM lP
{
WCHAR tch[BUFSIZE_STYLE_VALUE] = { L'\0' };
GetDlgItemText(hwnd,IDC_STYLEEDIT,tch,COUNTOF(tch));
if (Style_SelectFont(hwnd,tch,COUNTOF(tch),
StringCchCompareIX(pCurrentStyle->pszName,L"Default Style") == 0 ||
StringCchCompareIX(pCurrentStyle->pszName,L"2nd Default Style") == 0, FALSE, TRUE)) {
BOOL bIsGlobalDefault =
(StringCchCompareIX(pCurrentStyle->pszName, L"Default Style") == 0) ||
(StringCchCompareIX(pCurrentStyle->pszName, L"2nd Default Style") == 0);
if (Style_SelectFont(hwnd,tch,COUNTOF(tch), bIsGlobalDefault, FALSE, TRUE)) {
SetDlgItemText(hwnd,IDC_STYLEEDIT,tch);
}
}

View File

@ -78,7 +78,7 @@ void Style_SetDefaultLexer(HWND);
void Style_SetHTMLLexer(HWND);
void Style_SetXMLLexer(HWND);
void Style_SetLexerFromID(HWND,int);
void Style_SetDefaultFont(HWND);
void Style_SetDefaultFont(HWND,BOOL);
void Style_ToggleUse2ndDefault(HWND);
BOOL Style_GetUse2ndDefault();
void Style_SetIndentGuides(HWND,BOOL);

View File

@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Notepad3.rc
// Von Microsoft Visual C++ generierte Includedatei.
// Verwendet durch Notepad3.rc
//
#define IDR_RT_MANIFEST 1
#define IDR_MAINWND 100
@ -387,6 +387,7 @@
#define IDM_VIEW_ACCELWORDNAV 40451
#define IDM_VIEW_NOPRESERVECARET 40452
#define IDM_VIEW_HYPERLINKHOTSPOTS 40453
#define IDM_VIEW_CURRENTSCHEME 40454
#define IDM_HELP_ABOUT 40500
#define IDM_HELP_CMD 40501
#define IDM_TRAY_RESTORE 40600
@ -473,9 +474,9 @@
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 600
#define _APS_NEXT_RESOURCE_VALUE 601
#define _APS_NEXT_COMMAND_VALUE 701
#define _APS_NEXT_CONTROL_VALUE 801
#define _APS_NEXT_SYMED_VALUE 900
#define _APS_NEXT_SYMED_VALUE 901
#endif
#endif