From 61503a2dcd6b208e266d57efff4575c0195d8adf Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 4 Jun 2023 00:38:39 +0200 Subject: [PATCH] Add "open new blank document in addition on startup" ability To enable/disable this feature, go to New Document section of Preferences dialog, and check/uncheck "Always open a new document in addition at startup" checkbox. Fix #11134, fix #9535, fix #5527, close #13738 --- PowerEditor/installer/nativeLang/english.xml | 1 + PowerEditor/installer/nativeLang/english_customizable.xml | 1 + PowerEditor/installer/nativeLang/french.xml | 1 + PowerEditor/installer/nativeLang/taiwaneseMandarin.xml | 1 + PowerEditor/src/Notepad_plus_Window.cpp | 6 ++++++ PowerEditor/src/Parameters.cpp | 4 ++++ PowerEditor/src/Parameters.h | 1 + PowerEditor/src/WinControls/Preference/preference.rc | 5 +++-- PowerEditor/src/WinControls/Preference/preferenceDlg.cpp | 8 ++++++++ PowerEditor/src/WinControls/Preference/preference_rc.h | 1 + 10 files changed, 27 insertions(+), 2 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 2617318a7..ea42b527c 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1030,6 +1030,7 @@ You can define several column markers by using white space to separate the diffe + diff --git a/PowerEditor/installer/nativeLang/english_customizable.xml b/PowerEditor/installer/nativeLang/english_customizable.xml index 8f782aac4..e1da036ed 100644 --- a/PowerEditor/installer/nativeLang/english_customizable.xml +++ b/PowerEditor/installer/nativeLang/english_customizable.xml @@ -1030,6 +1030,7 @@ You can define several column markers by using white space to separate the diffe + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index d6c424cb5..be8f9b1e9 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1027,6 +1027,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 260e4574b..2b080fe2d 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -986,6 +986,7 @@ + diff --git a/PowerEditor/src/Notepad_plus_Window.cpp b/PowerEditor/src/Notepad_plus_Window.cpp index eb0615f1c..5a1cba9e4 100644 --- a/PowerEditor/src/Notepad_plus_Window.cpp +++ b/PowerEditor/src/Notepad_plus_Window.cpp @@ -316,6 +316,12 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin ::SendMessage(_hSelf, NPPM_INTERNAL_ENABLECHANGEHISTORY, 0, 0); + + if (nppGUI._newDocDefaultSettings._addNewDocumentOnStartup) + { + ::SendMessage(_hSelf, WM_COMMAND, IDM_FILE_NEW, 0); + } + // Notify plugins that Notepad++ is ready SCNotification scnN{}; scnN.nmhdr.code = NPPN_READY; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index f4d725115..8ada9b1d2 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -5261,6 +5261,9 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (val) _nppGUI._newDocDefaultSettings._openAnsiAsUtf8 = (lstrcmp(val, TEXT("yes")) == 0); + val = element->Attribute(TEXT("addNewDocumentOnStartup")); + if (val) + _nppGUI._newDocDefaultSettings._addNewDocumentOnStartup = (lstrcmp(val, TEXT("yes")) == 0); } else if (!lstrcmp(nm, TEXT("langsExcluded"))) @@ -7000,6 +7003,7 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang); GUIConfigElement->SetAttribute(TEXT("codepage"), _nppGUI._newDocDefaultSettings._codepage); GUIConfigElement->SetAttribute(TEXT("openAnsiAsUTF8"), _nppGUI._newDocDefaultSettings._openAnsiAsUtf8 ? TEXT("yes") : TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("addNewDocumentOnStartup"), _nppGUI._newDocDefaultSettings._addNewDocumentOnStartup ? TEXT("yes") : TEXT("no")); } // diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index d14f9f386..e85252594 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -571,6 +571,7 @@ struct NewDocDefaultSettings final bool _openAnsiAsUtf8 = true; LangType _lang = L_TEXT; int _codepage = -1; // -1 when not using + bool _addNewDocumentOnStartup = false; }; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index db88e9284..38f1b376d 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -207,8 +207,9 @@ BEGIN CONTROL "UTF-16 Little Endian with BOM",IDC_RADIO_UTF16SMALL,"Button",BS_AUTORADIOBUTTON,242,111,110,10 CONTROL "",IDC_RADIO_OTHERCP,"Button",BS_AUTORADIOBUTTON,242,126,10,10 COMBOBOX IDC_COMBO_OTHERCP,257,125,100,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - RTEXT "Default language :",IDC_DEFAULTLANG_STATIC,16,130,77,8 - COMBOBOX IDC_COMBO_DEFAULTLANG,98,128,100,140,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + RTEXT "Default language :",IDC_DEFAULTLANG_STATIC,16,125,77,8 + COMBOBOX IDC_COMBO_DEFAULTLANG,98,123,100,140,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + CONTROL "Always open a new document in addition at startup",IDC_CHECK_ADDNEWDOCONSTARTUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,23,152,250,10 END diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index f54c76ba9..52040b0e2 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2347,6 +2347,8 @@ intptr_t CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP } ::SendDlgItemMessage(_hSelf, IDC_COMBO_DEFAULTLANG, CB_SETCURSEL, j, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_ADDNEWDOCONSTARTUP, BM_SETCHECK, ndds._addNewDocumentOnStartup, 0); + return TRUE; } @@ -2438,6 +2440,12 @@ intptr_t CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP return TRUE; } + case IDC_CHECK_ADDNEWDOCONSTARTUP: + { + ndds._addNewDocumentOnStartup = isCheckedOrNot(IDC_CHECK_ADDNEWDOCONSTARTUP); + return TRUE; + } + default: { if (HIWORD(wParam) == CBN_SELCHANGE) diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 4151d1dbf..7646e46b5 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -293,6 +293,7 @@ //#define IDC_CUSTOMIZELENGTHVAL_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 28) #define IDC_DISPLAY_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 29) #define IDC_OPENSAVEDIR_CHECK_DRROPFOLDEROPENFILES (IDD_PREFERENCE_SUB_NEWDOCUMENT + 31) + #define IDC_CHECK_ADDNEWDOCONSTARTUP (IDD_PREFERENCE_SUB_NEWDOCUMENT + 32) #define IDD_PREFERENCE_SUB_DEFAULTDIRECTORY 6450 //(IDD_PREFERENCE_BOX + 400) #define IDD_PREFERENCE_SUB_RECENTFILESHISTORY 6460 //(IDD_PREFERENCE_BOX + 400)