Merge pull request #2873 from RaiKoHoff/Dev_NewFeatures

Support Lexer switching while Customize Schemes dialog is open
This commit is contained in:
Rainer Kottenhoff 2020-09-22 16:26:43 +02:00 committed by GitHub
commit e81eeb6dbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 64 additions and 57 deletions

View File

@ -287,7 +287,7 @@ END
IDD_MUI_STYLESELECT DIALOGEX 0, 0, 200, 194
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Syntax Schema auswählen"
CAPTION "Syntax Schema"
FONT 9, "Segoe UI", 400, 0, 0x1
BEGIN
CONTROL "",IDC_STYLELIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,7,184,130
@ -301,7 +301,7 @@ END
IDD_MUI_STYLECONFIG DIALOGEX 0, 0, 467, 254
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Syntax Schemata anpassen"
CAPTION "Syntax Schema"
FONT 9, "Segoe UI", 400, 0, 0x1
BEGIN
CONTROL "",IDC_STYLELIST,"SysTreeView32",TVS_SHOWSELALWAYS | TVS_SINGLEEXPAND | WS_BORDER | WS_HSCROLL | WS_TABSTOP,7,7,164,240
@ -321,7 +321,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,355,232,50,14
PUSHBUTTON "Abbrechen",IDCANCEL,410,232,50,14
GROUPBOX "Information",IDC_INFO_GROUPBOX,181,7,280,127
CTEXT "Syntax Schemata anpassen",IDC_TITLE,240,20,180,24,SS_CENTERIMAGE
CTEXT "Syntax Schema",IDC_TITLE,240,20,180,24,SS_CENTERIMAGE
EDITTEXT IDC_STYLEEDIT_HELP,197,54,252,74,ES_MULTILINE | ES_READONLY | NOT WS_BORDER
END

View File

@ -2609,6 +2609,29 @@ void Float2String(float fValue, LPWSTR lpszStrg, int cchSize)
}
//=============================================================================
//
// CloseNonModalDialogs()
//
void CloseNonModalDialogs() {
if (IsWindow(Globals.hwndDlgFindReplace)) {
SendMessage(Globals.hwndDlgFindReplace, WM_CLOSE, 0, 0);
}
if (IsWindow(Globals.hwndDlgCustomizeSchemes)) {
SendMessage(Globals.hwndDlgCustomizeSchemes, WM_CLOSE, 0, 0);
}
}
//=============================================================================
//
// CloseApplication()
//
void CloseApplication() {
CloseNonModalDialogs();
PostMessage(Globals.hwndMain, WM_CLOSE, 0, 0);
}
///////////////////////////////////////////////////////////////////////////////
/// End of Helpers.c ///

View File

@ -662,6 +662,9 @@ void Float2String(float fValue, LPWSTR lpszStrg, int cchSize);
#define MAX_ESCAPE_HEX_DIGIT 4
int Hex2Char(char* ch, int cnt);
void CloseNonModalDialogs();
void CloseApplication();
// ----------------------------------------------------------------------------
inline bool PathIsExistingFile(LPCWSTR pszPath) { return (PathFileExists(pszPath) && !PathIsDirectory(pszPath)); }

View File

@ -427,6 +427,7 @@ LANGID LoadLanguageResources()
void FreeLanguageResources()
{
if (Globals.hLngResContainer != Globals.hInstance) {
CloseNonModalDialogs();
HINSTANCE const _hLngResContainer = Globals.hLngResContainer;
Globals.hLngResContainer = Globals.hInstance;
MUI_LanguageDLLs[0].bIsActive = true;

View File

@ -3936,8 +3936,6 @@ static void _DynamicLanguageMenuCmd(int cmd)
}
if (!MUI_LanguageDLLs[iLngIdx].bIsActive)
{
CloseNonModalDialogs();
DestroyMenu(Globals.hMainMenu);
// desired language
@ -3959,9 +3957,8 @@ static void _DynamicLanguageMenuCmd(int cmd)
SetMenu(Globals.hwndMain, (Settings.ShowMenubar ? Globals.hMainMenu : NULL));
DrawMenuBar(Globals.hwndMain);
UpdateUI();
UpdateStatusbar(true);
}
return;
}
@ -5949,6 +5946,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
bool const isReplDlg = !!GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE);
PostWMCommand(hwnd, isReplDlg ? IDM_EDIT_FIND : IDM_EDIT_REPLACE); // swap
PostWMCommand(hwnd, isReplDlg ? IDM_EDIT_REPLACE : IDM_EDIT_FIND); // restore
PostMessage(hwnd, WM_SETFOCUS, 0, 0);
}
if (IsWindow(Globals.hwndDlgCustomizeSchemes)) {
@ -5956,9 +5954,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
//~PostWMCommand(hwnd, IDM_VIEW_SCHEMECONFIG);
SendMessage(Globals.hwndDlgCustomizeSchemes, WM_THEMECHANGED, 0, 0);
UpdateTitleBar(Globals.hwndDlgCustomizeSchemes);
PostMessage(hwnd, WM_SETFOCUS, 0, 0);
}
PostMessage(hwnd, WM_SETFOCUS, 0, 0);
PostMessage(hwnd, WM_THEMECHANGED, 0, 0);
}
break;
@ -11553,30 +11551,4 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
}
//=============================================================================
//
// CloseNonModalDialogs()
//
void CloseNonModalDialogs()
{
if (IsWindow(Globals.hwndDlgFindReplace)) {
SendMessage(Globals.hwndDlgFindReplace, WM_CLOSE, 0, 0);
}
if (IsWindow(Globals.hwndDlgCustomizeSchemes)) {
SendMessage(Globals.hwndDlgCustomizeSchemes, WM_CLOSE, 0, 0);
}
}
//=============================================================================
//
// CloseApplication()
//
void CloseApplication()
{
CloseNonModalDialogs();
PostMessage(Globals.hwndMain, WM_CLOSE, 0, 0);
}
/// End of Notepad3.c ///

View File

@ -169,8 +169,6 @@ bool OpenFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir)
bool SaveFileDlg(HWND hwnd,LPWSTR lpstrFile,int cchFile,LPCWSTR lpstrInitialDir);
void CreateBars(HWND hwnd, HINSTANCE hInstance);
void CloseNonModalDialogs();
void CloseApplication();
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
LRESULT MsgCreate(HWND hwnd, WPARAM wParam, LPARAM lParam);

View File

@ -343,12 +343,13 @@ void Style_DynamicThemesMenuCmd(int cmd, unsigned iCurThemeIdx)
_EnableSchemeConfig(iThemeIdx != 0);
CheckCmd(Globals.hMainMenu, Theme_Files[iThemeIdx].rid, true);
Style_ResetCurrentLexer(Globals.hwndEdit);
UpdateToolbar();
UpdateStatusbar(true);
if (IsWindow(Globals.hwndDlgCustomizeSchemes)) {
SendMessage(Globals.hwndDlgCustomizeSchemes, WM_THEMECHANGED, 0, 0);
} else {
Style_ResetCurrentLexer(Globals.hwndEdit);
}
UpdateMarginWidth();
UpdateTitleBar(Globals.hwndMain);
UpdateUI();
}
}
@ -1598,10 +1599,8 @@ void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew)
if (bFocusedView) { EditToggleView(Globals.hwndEdit); }
UpdateToolbar();
UpdateStatusbar(true);
UpdateMarginWidth();
//~UpdateUI();
UpdateStatusbar(true);
}
@ -4071,6 +4070,21 @@ static bool _ApplyDialogItemText(HWND hwnd,
}
static WCHAR s_TitleTxt[128] = { L'\0' };
static void _UpdateTitleText(HWND hwnd)
{
static WCHAR s_OrigTitle[64] = { L'\0' };
if (StrIsEmpty(s_OrigTitle)) {
GetWindowText(hwnd, s_OrigTitle, COUNTOF(s_OrigTitle));
}
unsigned const iTheme = GetModeThemeIndex();
const WCHAR *const strThemeName = (iTheme <= 1) ? L"Standard" : Theme_Files[iTheme].szName;
StringCchPrintf(s_TitleTxt, COUNTOF(s_TitleTxt), L"%s - %s", s_OrigTitle, strThemeName);
SetWindowText(hwnd, s_TitleTxt);
}
INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
static HWND hwndTV;
@ -4084,7 +4098,6 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
static bool bIsStyleSelected = false;
static bool bWarnedNoIniFile = false;
static WCHAR* Style_StylesBackup[NUMLEXERS * AVG_NUM_OF_STYLES_PER_LEXER];
static WCHAR title[128] = { L'\0' };
static WCHAR tchTmpBuffer[max(BUFSIZE_STYLE_VALUE, BUFZIZE_STYLE_EXTENTIONS)] = {L'\0'};
@ -4097,12 +4110,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
SetDialogIconNP3(hwnd);
InitWindowCommon(hwnd, true);
WCHAR buf[80] = { L'\0' };
GetWindowText(hwnd, buf, COUNTOF(buf));
unsigned const iTheme = GetModeThemeIndex();
const WCHAR *const strThemeName = (iTheme <= 1) ? L"Standard" : Theme_Files[iTheme].szName;
StringCchPrintf(title, COUNTOF(title), L"%s - %s", buf, strThemeName);
SetWindowText(hwnd, title);
_UpdateTitleText(hwnd);
#ifdef D_NP3_WIN10_DARK_MODE
if (UseDarkMode()) {
@ -4230,7 +4238,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
}
hFontTitle = CreateFontIndirectW(&lf);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETFONT, (WPARAM)hFontTitle, true);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)title);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)s_TitleTxt);
}
}
return TRUE;
@ -4262,7 +4270,7 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
}
hFontTitle = CreateFontIndirectW(&lf);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETFONT, (WPARAM)hFontTitle, true);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)title);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)s_TitleTxt);
}
MakeBitmapButton(hwnd, IDC_PREVSTYLE, IDB_PREV, -1, -1);
@ -4323,6 +4331,8 @@ INT_PTR CALLBACK Style_CustomizeSchemesDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
SendMessage(hBtn, WM_THEMECHANGED, 0, 0);
}
SendMessage(hwndTV, WM_THEMECHANGED, 0, 0);
_UpdateTitleText(hwnd);
SendDlgItemMessageW(hwnd, IDC_TITLE, WM_SETTEXT, 0, (LPARAM)s_TitleTxt); // scheme may have changed
Style_ResetCurrentLexer(hwnd);
SendWMCommandEx(hwnd, IDC_STYLEEDIT, EN_CHANGE); // button color inlay
UpdateWindowEx(hwnd);

View File

@ -476,7 +476,7 @@ int ReadAndDecryptFile(HWND hwnd, HANDLE hFile, size_t fileSize, void** result,
if (useFileKey) {
// use the file key to decode
/*@@@
/*§§§
char ansiKey[KEY_LEN+1];
ptrdiff_t len = WideCharToMultiByteEx( CP_ACP, WC_NO_BEST_FIT_CHARS, fileKey, -1, ansiKey, KEY_LEN, NULL, NULL );
ansiKey[len] = '\0';
@ -489,7 +489,7 @@ int ReadAndDecryptFile(HWND hwnd, HANDLE hFile, size_t fileSize, void** result,
BYTE binMasterKey[KEY_BYTES];
AES_keyInstance masterdecode;
AES_cipherInstance mastercypher;
/*@@@
/*§§§
char ansiKey[KEY_LEN+1];
int ptrdiff_t = WideCharToMultiByteEx( CP_ACP, WC_NO_BEST_FIT_CHARS, masterKey, -1, ansiKey, KEY_LEN, NULL, NULL );
AES_keygen( ansiKey, binMasterKey );
@ -586,7 +586,7 @@ bool EncryptAndWriteFile(HWND hwnd, HANDLE hFile, BYTE *data, size_t size, size_
{
if (useFileKey) {
// generate the encryption key from the passphrase
/* @@@
/* §§§
char ansiKey[KEY_LEN+1];
int ptrdiff_t = WideCharToMultiByteEx( CP_ACP, WC_NO_BEST_FIT_CHARS, fileKey, -1, ansiKey, KEY_LEN, NULL, NULL );
ansiKey[len] = '\0';
@ -605,7 +605,7 @@ bool EncryptAndWriteFile(HWND hwnd, HANDLE hFile, BYTE *data, size_t size, size_
BYTE binMasterKey[KEY_BYTES];
AES_keyInstance masterencode;
AES_cipherInstance mastercypher;
/* @@@
/* §§§
char ansiKey[KEY_LEN+1];
ptrdiff_t len = WideCharToMultiByteEx( CP_ACP, WC_NO_BEST_FIT_CHARS, masterKey, -1, ansiKey, KEY_LEN, NULL, NULL );
ansiKey[len] = '\0';