From cf8ddc18c9833fb8f19df1c44dc769926a274d47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=28x*ln=287=29=29=E2=81=BB=C2=B9?=
<100133857+DerivativeOfLog7@users.noreply.github.com>
Date: Tue, 29 Aug 2023 17:34:52 +0200
Subject: [PATCH] Add supperss 2GB file warning option for x64
Fix #14055, close #14069
---
PowerEditor/installer/nativeLang/english.xml | 1 +
.../nativeLang/english_customizable.xml | 1 +
PowerEditor/src/Parameters.cpp | 9 +++++-
PowerEditor/src/Parameters.h | 2 ++
PowerEditor/src/ScintillaComponent/Buffer.cpp | 31 ++++++++++---------
.../src/WinControls/Preference/preference.rc | 4 ++-
.../WinControls/Preference/preferenceDlg.cpp | 11 +++++++
.../WinControls/Preference/preference_rc.h | 1 +
8 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml
index 23c906ba9..e6303fa33 100644
--- a/PowerEditor/installer/nativeLang/english.xml
+++ b/PowerEditor/installer/nativeLang/english.xml
@@ -1250,6 +1250,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 740428e65..8d82e688f 100644
--- a/PowerEditor/installer/nativeLang/english_customizable.xml
+++ b/PowerEditor/installer/nativeLang/english_customizable.xml
@@ -1251,6 +1251,7 @@ You can define several column markers by using white space to separate the diffe
+
diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp
index 86eeb410e..1a995418f 100644
--- a/PowerEditor/src/Parameters.cpp
+++ b/PowerEditor/src/Parameters.cpp
@@ -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"));
}
- //
+ //
{
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"));
}
//
diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h
index 89161960f..f0bdeafb2 100644
--- a/PowerEditor/src/Parameters.h
+++ b/PowerEditor/src/Parameters.h
@@ -740,6 +740,8 @@ struct LargeFileRestriction final
bool _allowAutoCompletion = false;
bool _allowSmartHilite = false;
bool _allowClickableLink = false;
+
+ bool _suppress2GBWarning = false;
};
struct NppGUI final
diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp
index da407701a..b0a5e2cd9 100644
--- a/PowerEditor/src/ScintillaComponent/Buffer.cpp
+++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp
@@ -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;
+ }
}
}
}
diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc
index df46bf4d2..9263aa983 100644
--- a/PowerEditor/src/WinControls/Preference/preference.rc
+++ b/PowerEditor/src/WinControls/Preference/preference.rc
@@ -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
diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
index dcb316a0c..c4a0c16db 100644
--- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
+++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
@@ -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;
}
diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h
index 9bde02eab..36d7f6fbf 100644
--- a/PowerEditor/src/WinControls/Preference/preference_rc.h
+++ b/PowerEditor/src/WinControls/Preference/preference_rc.h
@@ -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