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
pull/13755/head
Don Ho 2 years ago
parent ccf80a0699
commit 61503a2dcd

@ -1030,6 +1030,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="6411" name="Default language :"/> <Item id="6411" name="Default language :"/>
<Item id="6419" name="New Document"/> <Item id="6419" name="New Document"/>
<Item id="6420" name="Apply to opened ANSI files"/> <Item id="6420" name="Apply to opened ANSI files"/>
<Item id="6432" name="Always open a new document in addition at startup"/>
</NewDoc> </NewDoc>
<DefaultDir title="Default Directory"> <DefaultDir title="Default Directory">

@ -1030,6 +1030,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="6411" name="Default language :"/> <Item id="6411" name="Default language :"/>
<Item id="6419" name="New Document"/> <Item id="6419" name="New Document"/>
<Item id="6420" name="Apply to opened ANSI files"/> <Item id="6420" name="Apply to opened ANSI files"/>
<Item id="6432" name="Always open a new document in addition at startup"/>
</NewDoc> </NewDoc>
<DefaultDir title="Default Directory"> <DefaultDir title="Default Directory">

@ -1027,6 +1027,7 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour
<Item id="6411" name="Langage par défaut :"/> <Item id="6411" name="Langage par défaut :"/>
<Item id="6419" name="Nouveau document"/> <Item id="6419" name="Nouveau document"/>
<Item id="6420" name="Appliquer aux fichiers ANSI ouverts"/> <Item id="6420" name="Appliquer aux fichiers ANSI ouverts"/>
<Item id="6432" name="Toujours ouvrir un nouveau document en plus au démarrage"/>
</NewDoc> </NewDoc>
<DefaultDir title="Dossier par défaut"> <DefaultDir title="Dossier par défaut">

@ -986,6 +986,7 @@
<Item id="6411" name="預設程式語言:"/> <Item id="6411" name="預設程式語言:"/>
<Item id="6419" name="新文件預設設定"/> <Item id="6419" name="新文件預設設定"/>
<Item id="6420" name="套用至 ANSI 檔案"/> <Item id="6420" name="套用至 ANSI 檔案"/>
<Item id="6432" name="在啟動時另外打開一個新文件"/>
</NewDoc> </NewDoc>
<DefaultDir title="預設資料夾"> <DefaultDir title="預設資料夾">

@ -316,6 +316,12 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
::SendMessage(_hSelf, NPPM_INTERNAL_ENABLECHANGEHISTORY, 0, 0); ::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 // Notify plugins that Notepad++ is ready
SCNotification scnN{}; SCNotification scnN{};
scnN.nmhdr.code = NPPN_READY; scnN.nmhdr.code = NPPN_READY;

@ -5261,6 +5261,9 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
if (val) if (val)
_nppGUI._newDocDefaultSettings._openAnsiAsUtf8 = (lstrcmp(val, TEXT("yes")) == 0); _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"))) else if (!lstrcmp(nm, TEXT("langsExcluded")))
@ -7000,6 +7003,7 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang); GUIConfigElement->SetAttribute(TEXT("lang"), _nppGUI._newDocDefaultSettings._lang);
GUIConfigElement->SetAttribute(TEXT("codepage"), _nppGUI._newDocDefaultSettings._codepage); GUIConfigElement->SetAttribute(TEXT("codepage"), _nppGUI._newDocDefaultSettings._codepage);
GUIConfigElement->SetAttribute(TEXT("openAnsiAsUTF8"), _nppGUI._newDocDefaultSettings._openAnsiAsUtf8 ? TEXT("yes") : TEXT("no")); GUIConfigElement->SetAttribute(TEXT("openAnsiAsUTF8"), _nppGUI._newDocDefaultSettings._openAnsiAsUtf8 ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("addNewDocumentOnStartup"), _nppGUI._newDocDefaultSettings._addNewDocumentOnStartup ? TEXT("yes") : TEXT("no"));
} }
// <GUIConfig name = "langsExcluded" gr0 = "0" gr1 = "0" gr2 = "0" gr3 = "0" gr4 = "0" gr5 = "0" gr6 = "0" gr7 = "0" langMenuCompact = "yes" / > // <GUIConfig name = "langsExcluded" gr0 = "0" gr1 = "0" gr2 = "0" gr3 = "0" gr4 = "0" gr5 = "0" gr6 = "0" gr7 = "0" langMenuCompact = "yes" / >

@ -571,6 +571,7 @@ struct NewDocDefaultSettings final
bool _openAnsiAsUtf8 = true; bool _openAnsiAsUtf8 = true;
LangType _lang = L_TEXT; LangType _lang = L_TEXT;
int _codepage = -1; // -1 when not using int _codepage = -1; // -1 when not using
bool _addNewDocumentOnStartup = false;
}; };

@ -207,8 +207,9 @@ BEGIN
CONTROL "UTF-16 Little Endian with BOM",IDC_RADIO_UTF16SMALL,"Button",BS_AUTORADIOBUTTON,242,111,110,10 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 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 COMBOBOX IDC_COMBO_OTHERCP,257,125,100,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Default language :",IDC_DEFAULTLANG_STATIC,16,130,77,8 RTEXT "Default language :",IDC_DEFAULTLANG_STATIC,16,125,77,8
COMBOBOX IDC_COMBO_DEFAULTLANG,98,128,100,140,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP 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 END

@ -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_COMBO_DEFAULTLANG, CB_SETCURSEL, j, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_ADDNEWDOCONSTARTUP, BM_SETCHECK, ndds._addNewDocumentOnStartup, 0);
return TRUE; return TRUE;
} }
@ -2438,6 +2440,12 @@ intptr_t CALLBACK NewDocumentSubDlg::run_dlgProc(UINT message, WPARAM wParam, LP
return TRUE; return TRUE;
} }
case IDC_CHECK_ADDNEWDOCONSTARTUP:
{
ndds._addNewDocumentOnStartup = isCheckedOrNot(IDC_CHECK_ADDNEWDOCONSTARTUP);
return TRUE;
}
default: default:
{ {
if (HIWORD(wParam) == CBN_SELCHANGE) if (HIWORD(wParam) == CBN_SELCHANGE)

@ -293,6 +293,7 @@
//#define IDC_CUSTOMIZELENGTHVAL_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 28) //#define IDC_CUSTOMIZELENGTHVAL_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 28)
#define IDC_DISPLAY_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 29) #define IDC_DISPLAY_STATIC (IDD_PREFERENCE_SUB_NEWDOCUMENT + 29)
#define IDC_OPENSAVEDIR_CHECK_DRROPFOLDEROPENFILES (IDD_PREFERENCE_SUB_NEWDOCUMENT + 31) #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_DEFAULTDIRECTORY 6450 //(IDD_PREFERENCE_BOX + 400)
#define IDD_PREFERENCE_SUB_RECENTFILESHISTORY 6460 //(IDD_PREFERENCE_BOX + 400) #define IDD_PREFERENCE_SUB_RECENTFILESHISTORY 6460 //(IDD_PREFERENCE_BOX + 400)

Loading…
Cancel
Save