Add supperss 2GB file warning option for x64

Fix #14055, close #14069
This commit is contained in:
(x*ln(7))⁻¹ 2023-08-29 17:34:52 +02:00 committed by Don Ho
parent f5c60d26cd
commit cf8ddc18c9
8 changed files with 44 additions and 16 deletions

View File

@ -1250,6 +1250,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="7149" name="Allow Smart Highlighting"/>
<Item id="7150" name="Deactivate Word Wrap globally"/>
<Item id="7151" name="Allow URL Clickable Link"/>
<Item id="7152" name="Suppress warning when opening ≥2GB files"/>
</Performance>
<Cloud title="Cloud &amp; Link">

View File

@ -1251,6 +1251,7 @@ You can define several column markers by using white space to separate the diffe
<Item id="7149" name="Allow Smart Highlighting"/>
<Item id="7150" name="Deactivate Word Wrap globally"/>
<Item id="7151" name="Allow URL Clickable Link"/>
<Item id="7152" name="Suppress warning when opening ≥2GB files"/>
</Performance>
<Cloud title="Cloud &amp; Link">

View File

@ -5864,6 +5864,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
_nppGUI._largeFileRestriction._deactivateWordWrap = false;
else
_nppGUI._largeFileRestriction._deactivateWordWrap = true;
boolVal = element->Attribute(TEXT("suppress2GBWarning"));
if (boolVal != NULL && !lstrcmp(boolVal, TEXT("yes")))
_nppGUI._largeFileRestriction._suppress2GBWarning = true;
else
_nppGUI._largeFileRestriction._suppress2GBWarning = false;
}
else if (!lstrcmp(nm, TEXT("multiInst")))
{
@ -7222,7 +7228,7 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), _nppGUI._delimiterSelectionOnEntireDocument ? TEXT("yes") : TEXT("no"));
}
// <GUIConfig name="largeFileRestriction" fileSizeMB="200" isEnabled="yes" allowAutoCompletion="no" allowBraceMatch="no" deactivateWordWrap="yes" allowClickableLink="no" />
// <GUIConfig name="largeFileRestriction" fileSizeMB="200" isEnabled="yes" allowAutoCompletion="no" allowBraceMatch="no" deactivateWordWrap="yes" allowClickableLink="no" suppress2GBWarning="no" />
{
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("largeFileRestriction"));
@ -7233,6 +7239,7 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("allowSmartHilite"), _nppGUI._largeFileRestriction._allowSmartHilite ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("allowClickableLink"), _nppGUI._largeFileRestriction._allowClickableLink ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("deactivateWordWrap"), _nppGUI._largeFileRestriction._deactivateWordWrap ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("suppress2GBWarning"), _nppGUI._largeFileRestriction._suppress2GBWarning ? TEXT("yes") : TEXT("no"));
}
// <GUIConfig name="multiInst" setting="0" />

View File

@ -740,6 +740,8 @@ struct LargeFileRestriction final
bool _allowAutoCompletion = false;
bool _allowSmartHilite = false;
bool _allowClickableLink = false;
bool _suppress2GBWarning = false;
};
struct NppGUI final

View File

@ -1483,21 +1483,24 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil
}
else // x64
{
int res = pNativeSpeaker->messageBox("WantToOpenHugeFile",
_pNotepadPlus->_pEditView->getHSelf(),
TEXT("Opening a huge file of 2GB+ could take several minutes.\nDo you want to open it?"),
TEXT("Opening huge file warning"),
MB_YESNO | MB_APPLMODAL);
if (res == IDYES)
NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
if (!nppGui._largeFileRestriction._suppress2GBWarning)
{
// Do nothing
}
else
{
fclose(fp);
return false;
int res = pNativeSpeaker->messageBox("WantToOpenHugeFile",
_pNotepadPlus->_pEditView->getHSelf(),
TEXT("Opening a huge file of 2GB+ could take several minutes.\nDo you want to open it?"),
TEXT("Opening huge file warning"),
MB_YESNO | MB_APPLMODAL);
if (res == IDYES)
{
// Do nothing
}
else
{
fclose(fp);
return false;
}
}
}
}

View File

@ -528,7 +528,7 @@ IDD_PREFERENCE_SUB_PERFORMANCE DIALOGEX 115, 10, 460, 205
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Large File Restriction",IDC_GROUPSTATIC_PERFORMANCE_RESTRICTION,73,7,301,151,BS_CENTER
GROUPBOX "Large File Restriction",IDC_GROUPSTATIC_PERFORMANCE_RESTRICTION,73,7,301,189,BS_CENTER
PUSHBUTTON "?",IDD_PERFORMANCE_TIP_QUESTION_BUTTON,215,21,16,14
CONTROL "Enable Large File Restriction (no syntax highlighting)",IDC_CHECK_PERFORMANCE_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,78,41,290,10
RTEXT "Define Large File Size:",IDC_STATIC_PERFORMANCE_FILESIZE,75,59,125,8
@ -539,6 +539,8 @@ BEGIN
CONTROL "Allow Smart Highlighting",IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,110,200,10
CONTROL "Allow Brace Match", IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 127, 125, 200, 10
CONTROL "Allow URL Clickable Link", IDC_CHECK_PERFORMANCE_ALLOWCLICKABLELINK, "Button", BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP, 127, 140, 200, 10
CONTROL "Suppress warning when opening ≥2GB files", IDC_CHECK_PERFORMANCE_SUPPRESS2GBWARNING, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 78, 178, 280, 10
END
IDD_PREFERENCE_SUB_MISC DIALOGEX 115, 10, 460, 205

View File

@ -5229,6 +5229,7 @@ intptr_t CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, L
intptr_t CALLBACK PerformanceSubDlg::run_dlgProc(UINT message , WPARAM wParam, LPARAM lParam)
{
NppParameters& nppParam = NppParameters::getInstance();
NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
if (HIWORD(wParam) == EN_CHANGE)
@ -5299,7 +5300,10 @@ intptr_t CALLBACK PerformanceSubDlg::run_dlgProc(UINT message , WPARAM wParam, L
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE, BM_SETCHECK, nppGUI._largeFileRestriction._allowSmartHilite ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWCLICKABLELINK, BM_SETCHECK, nppGUI._largeFileRestriction._allowClickableLink ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_DEACTIVATEWORDWRAP, BM_SETCHECK, nppGUI._largeFileRestriction._deactivateWordWrap ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_SUPPRESS2GBWARNING, BM_SETCHECK, nppGUI._largeFileRestriction._suppress2GBWarning ? BST_CHECKED : BST_UNCHECKED, 0);
::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_SUPPRESS2GBWARNING), nppParam.archType() != IMAGE_FILE_MACHINE_I386 ? SW_SHOW : SW_HIDE);
bool largeFileRestrictionEnabled = isCheckedOrNot(IDC_CHECK_PERFORMANCE_ENABLE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH), largeFileRestrictionEnabled);
@ -5425,6 +5429,13 @@ intptr_t CALLBACK PerformanceSubDlg::run_dlgProc(UINT message , WPARAM wParam, L
}
return TRUE;
case IDC_CHECK_PERFORMANCE_SUPPRESS2GBWARNING:
{
bool isDeactivated = isCheckedOrNot(int(wParam));
nppGUI._largeFileRestriction._suppress2GBWarning = isDeactivated;
}
return TRUE;
default:
return FALSE;
}

View File

@ -480,4 +480,5 @@
#define IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE (IDD_PREFERENCE_SUB_PERFORMANCE + 9)
#define IDC_CHECK_PERFORMANCE_DEACTIVATEWORDWRAP (IDD_PREFERENCE_SUB_PERFORMANCE + 10)
#define IDC_CHECK_PERFORMANCE_ALLOWCLICKABLELINK (IDD_PREFERENCE_SUB_PERFORMANCE + 11)
#define IDC_CHECK_PERFORMANCE_SUPPRESS2GBWARNING (IDD_PREFERENCE_SUB_PERFORMANCE + 12)
#endif //PREFERENCE_RC_H