Browse Source

Make large file limit (for styling) configurable

Background: because styling large file can cause the performance issue, 200 MB (and bigger) file is not applied to its language (if any) while loading.
This PR makes large file restriction for styling and for other features (smart highlighting, brace match, etc...) configurable via the section Performance of Preferences dialog.

Fix #11389, fix #12260, fix #11670, close #12310
pull/12343/head
Don Ho 2 years ago
parent
commit
8ff003412a
  1. 12
      PowerEditor/installer/nativeLang/english.xml
  2. 12
      PowerEditor/installer/nativeLang/french.xml
  3. 14
      PowerEditor/installer/nativeLang/taiwaneseMandarin.xml
  4. 3
      PowerEditor/src/Notepad_plus.cpp
  5. 16
      PowerEditor/src/NppBigSwitch.cpp
  6. 21
      PowerEditor/src/NppIO.cpp
  7. 6
      PowerEditor/src/NppNotification.cpp
  8. 49
      PowerEditor/src/Parameters.cpp
  9. 17
      PowerEditor/src/Parameters.h
  10. 16
      PowerEditor/src/ScintillaComponent/Buffer.cpp
  11. 7
      PowerEditor/src/ScintillaComponent/Buffer.h
  12. 15
      PowerEditor/src/WinControls/Preference/preference.rc
  13. 200
      PowerEditor/src/WinControls/Preference/preferenceDlg.cpp
  14. 10
      PowerEditor/src/WinControls/Preference/preferenceDlg.h
  15. 12
      PowerEditor/src/WinControls/Preference/preference_rc.h
  16. 7
      PowerEditor/src/localization.cpp
  17. 2
      PowerEditor/src/resource.h

12
PowerEditor/installer/nativeLang/english.xml

@ -1156,6 +1156,18 @@ You can define several column markers by using white space to separate the diffe
(don't choose it unless you know what you're doing)"/>
</Delimiter>
<Performance title="Performance">
<Item id="7141" name="Large File Restriction"/>
<Item id="7142" name="While opening a large file, some features are turned off for optimizing the performance. You can customize them here."/>
<Item id="7143" name="Enable Large File Restriction"/>
<Item id="7144" name="Define Large File Size:"/>
<Item id="7146" name="MB (1 - 4096)"/>
<Item id="7147" name="Allow Brace Match"/>
<Item id="7148" name="Allow Auto-Completion"/>
<Item id="7149" name="Allow Smart Highlighting"/>
<Item id="7150" name="Allow Word Wrap"/>
</Performance>
<Cloud title="Cloud &amp; Link">
<Item id="6262" name="Settings on cloud"/>
<Item id="6263" name="No Cloud"/>

12
PowerEditor/installer/nativeLang/french.xml

@ -1156,6 +1156,18 @@ Vous pouvez définir plusieurs marqueurs de colonne en utilisant un espace pour
(ne pas utiliser cette option si vous ne savez pas ce qu'elle fait)"/>
</Delimiter>
<Performance title="Performance">
<Item id="7141" name="Restriction des fichiers volumineux"/>
<Item id="7142" name="Lors de l'ouverture d'un fichier volumineux, certaines fonctionnalités sont désactivées pour optimiser les performances. Vous pouvez les personnaliser ici."/>
<Item id="7143" name="Activer la restriction des fichiers volumineux"/>
<Item id="7144" name="Définir la taille du fichier volumineux :"/>
<Item id="7146" name="Mo (1 - 4096)"/>
<Item id="7147" name="Permettre de colorer délimiteur symétrique"/>
<Item id="7148" name="Permettre d'activer la complétion automatique"/>
<Item id="7149" name="Permettre d'activer le coloriage automatique"/>
<Item id="7150" name="Permettre d'activer le retour automatique à la ligne"/>
</Performance>
<Cloud title="Cloud &amp; Lien">
<Item id="6262" name="Sauvegarder les paramètres dans le cloud"/>
<Item id="6263" name="Par défaut"/>

14
PowerEditor/installer/nativeLang/taiwaneseMandarin.xml

@ -1128,8 +1128,6 @@
<Item id="6171" name="插入日期時間自訂"/>
<Item id="6175" name="顛倒日期時間內定順序(簡短與完整格式)"/>
<Item id="6172" name="自訂格式:"/>
</MultiInstance>
<Delimiter title="分隔字元">
@ -1141,6 +1139,18 @@
<Item id="6162" name="使用預設的單字字元集(建議)"/>
<Item id="6163" name="添加字元(不了解此選項的話不建議選取)"/>
</Delimiter>
<Performance title="性能">
<Item id="7141" name="大型檔案限制"/>
<Item id="7142" name="在開啟大型文件時,為了優化性能,一些功能會被關閉。 您可以在此處自開啟它們。"/>
<Item id="7143" name="啟動大型檔案限制"/>
<Item id="7144" name="定義大型檔案文件長度大小:"/>
<Item id="7146" name="MB (1 - 4096)"/>
<Item id="7147" name="允許顏色顯示對應括號"/>
<Item id="7148" name="允許自動完成功能"/>
<Item id="7149" name="允許智慧醒目提示"/>
<Item id="7150" name="允許自動換行"/>
</Performance>
<Cloud title="雲端與連結">
<Item id="6262" name="雲端設定"/>

3
PowerEditor/src/Notepad_plus.cpp

@ -2584,7 +2584,8 @@ void Notepad_plus::findMatchingBracePos(intptr_t& braceAtCaret, intptr_t& braceO
bool Notepad_plus::braceMatch()
{
Buffer* currentBuf = _pEditView->getCurrentBuffer();
if (currentBuf->isLargeFile())
const NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
if (currentBuf->isLargeFile() && !nppGui._largeFileLimit._allowBraceMatch)
return false;
intptr_t braceAtCaret = -1;

16
PowerEditor/src/NppBigSwitch.cpp

@ -2719,6 +2719,22 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_INTERNAL_CLEANBRACEMATCH:
{
_mainEditView.execute(SCI_SETHIGHLIGHTGUIDE, 0);
_subEditView.execute(SCI_SETHIGHLIGHTGUIDE, 0);
_mainEditView.execute(SCI_BRACEBADLIGHT, WPARAM(-1));
_subEditView.execute(SCI_BRACEBADLIGHT, WPARAM(-1));
return TRUE;
}
case NPPM_INTERNAL_CLEANSMARTHILITING:
{
_mainEditView.clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
_subEditView.clearIndicator(SCE_UNIVERSAL_FOUND_STYLE_SMART);
return TRUE;
}
case NPPM_INTERNAL_CRLFLAUNCHSTYLECONF:
{
// Launch _configStyleDlg (create or display it)

21
PowerEditor/src/NppIO.cpp

@ -2074,15 +2074,22 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, bool shou
if (lastOpened != BUFFER_INVALID)
{
showView(MAIN_VIEW);
const TCHAR *pLn = session._mainViewFiles[i]._langName.c_str();
int id = getLangFromMenuName(pLn);
const TCHAR* pLn = nullptr;
LangType typeToSet = L_TEXT;
if (id != 0 && id != IDM_LANG_USER)
typeToSet = menuID2LangType(id);
if (typeToSet == L_EXTERNAL )
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
Buffer* buf = MainFileManager.getBufferByID(lastOpened);
Buffer *buf = MainFileManager.getBufferByID(lastOpened);
if (!buf->isLargeFile())
{
pLn = session._mainViewFiles[i]._langName.c_str();
int id = getLangFromMenuName(pLn);
if (id != 0 && id != IDM_LANG_USER)
typeToSet = menuID2LangType(id);
if (typeToSet == L_EXTERNAL)
typeToSet = (LangType)(id - IDM_LANG_EXTERNAL + L_EXTERNAL);
}
if (session._mainViewFiles[i]._foldStates.size() > 0)
{

6
PowerEditor/src/NppNotification.cpp

@ -676,7 +676,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
maintainIndentation(static_cast<TCHAR>(notification->ch));
Buffer* currentBuf = _pEditView->getCurrentBuffer();
if (!currentBuf->isLargeFile())
if (!currentBuf->isLargeFile() || nppGui._largeFileLimit._allowAutoCompletion)
{
AutoCompletion* autoC = isFromPrimary ? &_autoCompleteMain : &_autoCompleteSub;
bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode)
@ -884,7 +884,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
Buffer* currentBuf = _pEditView->getCurrentBuffer();
if (notification->nmhdr.hwndFrom != _pEditView->getHSelf() && !currentBuf->isLargeFile()) // notification come from unfocus view - both views ae visible
if (notification->nmhdr.hwndFrom != _pEditView->getHSelf() && (!currentBuf->isLargeFile() || nppGui._largeFileLimit._allowSmartHilite)) // notification come from unfocus view - both views ae visible
{
if (nppGui._smartHiliteOnAnotherView)
{
@ -903,7 +903,7 @@ BOOL Notepad_plus::notify(SCNotification *notification)
xmlTagMatchHiliter.tagMatch(nppGui._enableTagAttrsHilite);
}
if (nppGui._enableSmartHilite && !currentBuf->isLargeFile())
if (nppGui._enableSmartHilite && (!currentBuf->isLargeFile() || nppGui._largeFileLimit._allowSmartHilite))
{
if (nppGui._disableSmartHiliteTmp)
nppGui._disableSmartHiliteTmp = false;

49
PowerEditor/src/Parameters.cpp

@ -5387,6 +5387,43 @@ void NppParameters::feedGUIParameters(TiXmlNode *node)
else
_nppGUI._delimiterSelectionOnEntireDocument = false;
}
else if (!lstrcmp(nm, TEXT("largeFileLimit")))
{
int fileSizeLimit4StylingMB = 0;
element->Attribute(TEXT("fileSizeMB"), &fileSizeLimit4StylingMB);
if (fileSizeLimit4StylingMB > 0 && fileSizeLimit4StylingMB < 4096)
_nppGUI._largeFileLimit._largeFileSizeDefInByte = (fileSizeLimit4StylingMB * 1024 * 1024);
const TCHAR* boolVal = element->Attribute(TEXT("isEnabled"));
if (boolVal != NULL && !lstrcmp(boolVal, TEXT("yes")))
_nppGUI._largeFileLimit._isEnabled = true;
else
_nppGUI._largeFileLimit._isEnabled = false;
boolVal = element->Attribute(TEXT("allowAutoCompletion"));
if (boolVal != NULL && !lstrcmp(boolVal, TEXT("no")))
_nppGUI._largeFileLimit._allowAutoCompletion = false;
else
_nppGUI._largeFileLimit._allowAutoCompletion = true;
boolVal = element->Attribute(TEXT("allowBraceMatch"));
if (boolVal != NULL && !lstrcmp(boolVal, TEXT("no")))
_nppGUI._largeFileLimit._allowBraceMatch = false;
else
_nppGUI._largeFileLimit._allowBraceMatch = true;
boolVal = element->Attribute(TEXT("allowSmartHilite"));
if (boolVal != NULL && !lstrcmp(boolVal, TEXT("no")))
_nppGUI._largeFileLimit._allowSmartHilite = false;
else
_nppGUI._largeFileLimit._allowSmartHilite = true;
boolVal = element->Attribute(TEXT("allowWordWrap"));
if (boolVal != NULL && !lstrcmp(boolVal, TEXT("no")))
_nppGUI._largeFileLimit._allowWordWrap = false;
else
_nppGUI._largeFileLimit._allowWordWrap = true;
}
else if (!lstrcmp(nm, TEXT("multiInst")))
{
int val = 0;
@ -6607,6 +6644,18 @@ void NppParameters::createXmlTreeFromGUIParams()
GUIConfigElement->SetAttribute(TEXT("delimiterSelectionOnEntireDocument"), _nppGUI._delimiterSelectionOnEntireDocument ? TEXT("yes") : TEXT("no"));
}
// <GUIConfig name="largeFileLimit" fileSizeMB="200" isEnabled="yes" allowAutoCompletion="no" allowBraceMatch="no" allowSmartHilite="no" allowWordWrap="no" />
{
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();
GUIConfigElement->SetAttribute(TEXT("name"), TEXT("largeFileLimit"));
GUIConfigElement->SetAttribute(TEXT("fileSizeMB"), static_cast<int>((_nppGUI._largeFileLimit._largeFileSizeDefInByte / 1024) / 1024));
GUIConfigElement->SetAttribute(TEXT("isEnabled"), _nppGUI._largeFileLimit._isEnabled ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("allowAutoCompletion"), _nppGUI._largeFileLimit._allowAutoCompletion ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("allowBraceMatch"), _nppGUI._largeFileLimit._allowBraceMatch ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("allowSmartHilite"), _nppGUI._largeFileLimit._allowSmartHilite ? TEXT("yes") : TEXT("no"));
GUIConfigElement->SetAttribute(TEXT("allowWordWrap"), _nppGUI._largeFileLimit._allowWordWrap ? TEXT("yes") : TEXT("no"));
}
// <GUIConfig name="multiInst" setting="0" />
{
TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement();

17
PowerEditor/src/Parameters.h

@ -133,6 +133,8 @@ const int COPYDATA_FULL_CMDLINE = 3;
#define ONEDRIVE_AVAILABLE 2
#define GOOGLEDRIVE_AVAILABLE 4
#define NPP_STYLING_FILESIZE_LIMIT_DEFAULT (200 * 1024 * 1024) // 200MB+ file won't be styled
const TCHAR fontSizeStrs[][3] = {TEXT(""), TEXT("5"), TEXT("6"), TEXT("7"), TEXT("8"), TEXT("9"), TEXT("10"), TEXT("11"), TEXT("12"), TEXT("14"), TEXT("16"), TEXT("18"), TEXT("20"), TEXT("22"), TEXT("24"), TEXT("26"), TEXT("28")};
const TCHAR localConfFile[] = TEXT("doLocalConf.xml");
@ -720,6 +722,18 @@ struct DarkModeConf final
NppDarkMode::Colors _customColors = NppDarkMode::getDarkModeDefaultColors();
};
struct LargeFileLimitSettings final
{
int64_t _largeFileSizeDefInByte = NPP_STYLING_FILESIZE_LIMIT_DEFAULT;
bool _isEnabled = true;
bool _allowBraceMatch = false;
bool _allowAutoCompletion = false;
bool _allowSmartHilite = false;
bool _allowWordWrap = false;
};
struct NppGUI final
{
NppGUI()
@ -890,8 +904,11 @@ struct NppGUI final
DarkModeConf _darkmode;
DarkModeConf _darkmodeplugins;
LargeFileLimitSettings _largeFileLimit;
};
struct ScintillaViewParams
{
bool _lineNumberMarginShow = true;

16
PowerEditor/src/ScintillaComponent/Buffer.cpp

@ -38,6 +38,7 @@ static const int LF = 0x0A;
long Buffer::_recentTagCtr = 0;
namespace // anonymous
{
static EolType getEOLFormatForm(const char* const data, size_t length, EolType defvalue = EolType::osdefault)
@ -669,10 +670,13 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding
// * the auto-completion feature will be disabled for large files
// * the session snapshotsand periodic backups feature will be disabled for large files
// * the backups on save feature will be disabled for large files
bool isLargeFile = fileSize >= NPP_STYLING_FILESIZE_LIMIT;
NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
bool isLargeFile = false;
if (nppGui._largeFileLimit._isEnabled)
isLargeFile = fileSize >= nppGui._largeFileLimit._largeFileSizeDefInByte;
// Due to the performance issue, the Word Wrap feature will be disabled if it's ON
if (isLargeFile)
if (isLargeFile && !nppGui._largeFileLimit._allowWordWrap)
{
bool isWrap = _pNotepadPlus->_pEditView->isWrap();
if (isWrap)
@ -1511,6 +1515,8 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil
if (isFirstTime)
{
NppGUI& nppGui = NppParameters::getInstance().getNppGUI();
// check if file contain any BOM
if (Utf8_16_Read::determineEncoding((unsigned char *)data, lenFile) != uni8Bit)
{
@ -1520,11 +1526,11 @@ bool FileManager::loadFileData(Document doc, int64_t fileSize, const TCHAR * fil
}
else if (fileFormat._encoding == -1)
{
if (nppParam.getNppGUI()._detectEncoding)
if (nppGui._detectEncoding)
fileFormat._encoding = detectCodepage(data, lenFile);
}
bool isLargeFile = fileSize >= NPP_STYLING_FILESIZE_LIMIT;
bool isLargeFile = fileSize >= nppGui._largeFileLimit._largeFileSizeDefInByte;
if (!isLargeFile && fileFormat._language == L_TEXT)
{
// check the language du fichier

7
PowerEditor/src/ScintillaComponent/Buffer.h

@ -13,18 +13,17 @@
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma once
#include <mutex>
#include <mutex>
#include "Utf8_16.h"
class Notepad_plus;
class Buffer;
typedef Buffer* BufferID; //each buffer has unique ID by which it can be retrieved
#define BUFFER_INVALID reinterpret_cast<BufferID>(0)
#define NPP_STYLING_FILESIZE_LIMIT (200 * 1024 * 1024) // 200MB+ file won't be styled
typedef sptr_t Document;
@ -128,8 +127,6 @@ private:
bool loadFileData(Document doc, int64_t fileSize, const TCHAR* filename, char* buffer, Utf8_16_Read* UnicodeConvertor, LoadedFileFormat& fileFormat);
LangType detectLanguageFromTextBegining(const unsigned char *data, size_t dataLen);
private:
Notepad_plus* _pNotepadPlus = nullptr;
ScintillaEditView* _pscratchTilla = nullptr;
Document _scratchDocDefault = 0;

15
PowerEditor/src/WinControls/Preference/preference.rc

@ -474,6 +474,21 @@ BEGIN
LTEXT "Example: https://www.google.com/search?q=$(CURRENT_WORD)",IDD_SEARCHENGINE_NOTE_STATIC,114,134,245,20
END
IDD_PREFERENCE_SUB_PERFORMANCE DIALOGEX 0, 0, 455, 185
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
LTEXT "While opening a large file, some features are turned off for optimizing the performance. You can customize them here.",IDC_STATIC_PERFORMANCE_TIP,90,19,280,16
CONTROL "Enable Large File Restriction",IDC_CHECK_PERFORMANCE_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,100,41,210,10
RTEXT "Define Large File Size:",IDC_STATIC_PERFORMANCE_FILESIZE,75,59,125,8
EDITTEXT IDC_EDIT_PERFORMANCE_FILESIZE,201,57,24,14,ES_RIGHT | ES_NUMBER
LTEXT "MB (1 - 4096)",IDC_STATIC_PERFORMANCE_MB,228,59,90,8
CONTROL "Allow Brace Match",IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,127,80,200,10
CONTROL "Allow Auto-Completion",IDC_CHECK_PERFORMANCE_ALLOWAUTOCOMPLETION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,95,200,10
CONTROL "Allow Smart Highlighting",IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,127,110,200,10
CONTROL "Allow Word Wrap",IDC_CHECK_PERFORMANCE_ALLOWWORDWRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,127,125,200,10
END
IDD_PREFERENCE_SUB_MISC DIALOGEX 0, 0, 455, 200
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD

200
PowerEditor/src/WinControls/Preference/preferenceDlg.cpp

@ -166,6 +166,9 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_delimiterSubDlg.init(_hInst, _hSelf);
_delimiterSubDlg.create(IDD_PREFERENCE_SUB_DELIMITER, false, false);
_performanceSubDlg.init(_hInst, _hSelf);
_performanceSubDlg.create(IDD_PREFERENCE_SUB_PERFORMANCE, false, false);
_cloudAndLinkSubDlg.init(_hInst, _hSelf);
_cloudAndLinkSubDlg.create(IDD_PREFERENCE_SUB_CLOUD_LINK, false, false);
@ -189,6 +192,7 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_wVector.push_back(DlgInfo(&_autoCompletionSubDlg, TEXT("Auto-Completion"), TEXT("AutoCompletion")));
_wVector.push_back(DlgInfo(&_multiInstanceSubDlg, TEXT("Multi-Instance & Date"), TEXT("MultiInstance")));
_wVector.push_back(DlgInfo(&_delimiterSubDlg, TEXT("Delimiter"), TEXT("Delimiter")));
_wVector.push_back(DlgInfo(&_performanceSubDlg, TEXT("Performance"), TEXT("Performance")));
_wVector.push_back(DlgInfo(&_cloudAndLinkSubDlg, TEXT("Cloud & Link"), TEXT("Cloud")));
_wVector.push_back(DlgInfo(&_searchEngineSubDlg, TEXT("Search Engine"), TEXT("SearchEngine")));
_wVector.push_back(DlgInfo(&_miscSubDlg, TEXT("MISC."), TEXT("MISC")));
@ -219,6 +223,7 @@ intptr_t CALLBACK PreferenceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
_autoCompletionSubDlg.reSizeTo(rc);
_multiInstanceSubDlg.reSizeTo(rc);
_delimiterSubDlg.reSizeTo(rc);
_performanceSubDlg.reSizeTo(rc);
_cloudAndLinkSubDlg.reSizeTo(rc);
_searchEngineSubDlg.reSizeTo(rc);
@ -422,6 +427,7 @@ void PreferenceDlg::destroy()
_autoCompletionSubDlg.destroy();
_multiInstanceSubDlg.destroy();
_delimiterSubDlg.destroy();
_performanceSubDlg.destroy();
}
void GeneralSubDlg::setToolIconsFromStdToSmall()
@ -3820,7 +3826,6 @@ void BackupSubDlg::updateBackupGUI()
isEnableGlobableCheck = true;
isEnableLocalCheck = BST_CHECKED == ::SendDlgItemMessage(_hSelf, IDC_BACKUPDIR_CHECK, BM_GETCHECK, 0, 0);
}
//::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_USERCUSTOMDIR_GRPSTATIC), isEnableGlobableCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_CHECK), isEnableGlobableCheck);
::EnableWindow(::GetDlgItem(_hSelf, IDC_BACKUPDIR_EDIT), isEnableLocalCheck);
@ -4847,6 +4852,199 @@ intptr_t CALLBACK CloudAndLinkSubDlg::run_dlgProc(UINT message, WPARAM wParam, L
return FALSE;
}
intptr_t CALLBACK PerformanceSubDlg::run_dlgProc(UINT message , WPARAM wParam, LPARAM lParam)
{
NppGUI& nppGUI = NppParameters::getInstance().getNppGUI();
if (HIWORD(wParam) == EN_CHANGE)
{
switch (LOWORD(wParam))
{
case IDC_EDIT_PERFORMANCE_FILESIZE:
{
const int stringSize = 16;
TCHAR str[stringSize];
::GetDlgItemText(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, str, stringSize);
if (lstrcmp(str, TEXT("")) == 0)
return TRUE;
size_t fileLenInMB = ::GetDlgItemInt(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, NULL, FALSE);
if (fileLenInMB > 4096)
{
fileLenInMB = 4096;
::SetDlgItemInt(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, UINT(fileLenInMB), FALSE);
}
nppGUI._largeFileLimit._largeFileSizeDefInByte = fileLenInMB * 1024 * 1024;
}
return TRUE;
}
}
else if (HIWORD(wParam) == EN_KILLFOCUS)
{
switch (LOWORD(wParam))
{
case IDC_EDIT_PERFORMANCE_FILESIZE:
{
const int stringSize = 16;
TCHAR str[stringSize];
::GetDlgItemText(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, str, stringSize);
if (lstrcmp(str, TEXT("")) == 0)
{
::SetDlgItemInt(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, (NPP_STYLING_FILESIZE_LIMIT_DEFAULT / 1024) / 1024, FALSE);
return TRUE;
}
size_t fileLenInMB = ::GetDlgItemInt(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, NULL, FALSE);
if (fileLenInMB == 0)
{
fileLenInMB = (NPP_STYLING_FILESIZE_LIMIT_DEFAULT / 1024) / 1024;
::SetDlgItemInt(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, UINT(fileLenInMB), FALSE);
return TRUE;
}
}
return TRUE;
}
}
switch (message)
{
case WM_INITDIALOG:
{
int64_t fileLenInMB = (nppGUI._largeFileLimit._largeFileSizeDefInByte / 1024) / 1024;
::SetDlgItemInt(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE, UINT(fileLenInMB), FALSE);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ENABLE, BM_SETCHECK, nppGUI._largeFileLimit._isEnabled ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH, BM_SETCHECK, nppGUI._largeFileLimit._allowBraceMatch ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWAUTOCOMPLETION, BM_SETCHECK, nppGUI._largeFileLimit._allowAutoCompletion ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE, BM_SETCHECK, nppGUI._largeFileLimit._allowSmartHilite ? BST_CHECKED : BST_UNCHECKED, 0);
::SendDlgItemMessage(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWWORDWRAP, BM_SETCHECK, nppGUI._largeFileLimit._allowWordWrap ? BST_CHECKED : BST_UNCHECKED, 0);
bool largeFileRestrictionEnabled = isCheckedOrNot(IDC_CHECK_PERFORMANCE_ENABLE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWAUTOCOMPLETION), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWWORDWRAP), largeFileRestrictionEnabled);
}
break;
case WM_CTLCOLOREDIT:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORDLG:
{
if (NppDarkMode::isEnabled())
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
break;
}
case WM_CTLCOLORSTATIC:
{
auto hdcStatic = reinterpret_cast<HDC>(wParam);
auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
bool isStaticText = (dlgCtrlID == IDC_STATIC_PERFORMANCE_FILESIZE || dlgCtrlID == IDC_STATIC_PERFORMANCE_MB);
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (isStaticText)
{
bool isTextEnabled = isCheckedOrNot(IDC_CHECK_PERFORMANCE_ENABLE);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
}
if (NppDarkMode::isEnabled())
{
if (dlgCtrlID == IDC_EDIT_PERFORMANCE_FILESIZE)
{
return NppDarkMode::onCtlColor(hdcStatic);
}
return NppDarkMode::onCtlColorDarker(hdcStatic);
}
return FALSE;
}
case WM_PRINTCLIENT:
{
if (NppDarkMode::isEnabled())
{
return TRUE;
}
break;
}
case WM_COMMAND:
{
switch (wParam)
{
case IDC_CHECK_PERFORMANCE_ENABLE:
{
bool largeFileRestrictionEnabled = isCheckedOrNot(IDC_CHECK_PERFORMANCE_ENABLE);
nppGUI._largeFileLimit._isEnabled = largeFileRestrictionEnabled;
::EnableWindow(::GetDlgItem(_hSelf, IDC_EDIT_PERFORMANCE_FILESIZE), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWAUTOCOMPLETION), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE), largeFileRestrictionEnabled);
::EnableWindow(::GetDlgItem(_hSelf, IDC_CHECK_PERFORMANCE_ALLOWWORDWRAP), largeFileRestrictionEnabled);
redraw();
}
return TRUE;
case IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH:
{
bool isAllowed = isCheckedOrNot(int(wParam));
nppGUI._largeFileLimit._allowBraceMatch = isAllowed;
if (!isAllowed)
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CLEANBRACEMATCH, 0, 0);
}
return TRUE;
case IDC_CHECK_PERFORMANCE_ALLOWAUTOCOMPLETION:
{
bool isAllowed = isCheckedOrNot(int(wParam));
nppGUI._largeFileLimit._allowAutoCompletion = isAllowed;
}
return TRUE;
case IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE:
{
bool isAllowed = isCheckedOrNot(int(wParam));
nppGUI._largeFileLimit._allowSmartHilite = isAllowed;
if (!isAllowed)
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_CLEANSMARTHILITING, 0, 0);
}
return TRUE;
case IDC_CHECK_PERFORMANCE_ALLOWWORDWRAP:
{
bool isAllowed = isCheckedOrNot(int(wParam));
nppGUI._largeFileLimit._allowWordWrap = isAllowed;
}
return TRUE;
default:
return FALSE;
}
}
break;
}
return FALSE;
}
intptr_t CALLBACK SearchEngineSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
{
NppParameters& nppParams = NppParameters::getInstance();

10
PowerEditor/src/WinControls/Preference/preferenceDlg.h

@ -252,6 +252,15 @@ private :
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};
class PerformanceSubDlg : public StaticDialog
{
public :
PerformanceSubDlg() = default;
private :
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
};
class PreferenceDlg : public StaticDialog
{
friend class NativeLangSpeaker;
@ -306,6 +315,7 @@ private :
AutoCompletionSubDlg _autoCompletionSubDlg;
MultiInstanceSubDlg _multiInstanceSubDlg;
DelimiterSubDlg _delimiterSubDlg;
PerformanceSubDlg _performanceSubDlg;
CloudAndLinkSubDlg _cloudAndLinkSubDlg;
SearchEngineSubDlg _searchEngineSubDlg;
SearchingSubDlg _searchingSubDlg;

12
PowerEditor/src/WinControls/Preference/preference_rc.h

@ -434,4 +434,16 @@
#define IDD_CUSTOMIZED_COLOR12_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 27)
#define IDD_CUSTOMIZED_RESET_BUTTON (IDD_PREFERENCE_SUB_DARKMODE + 30)
#define IDC_DARKMODE_TONES_GB_STATIC (IDD_PREFERENCE_SUB_DARKMODE + 35)
#define IDD_PREFERENCE_SUB_PERFORMANCE 7140 //(IDD_PREFERENCE_BOX + 1100)
#define IDC_GROUPSTATIC_PERFORMANCE_RESTRICTION (IDD_PREFERENCE_SUB_PERFORMANCE + 1)
#define IDC_STATIC_PERFORMANCE_TIP (IDD_PREFERENCE_SUB_PERFORMANCE + 2)
#define IDC_CHECK_PERFORMANCE_ENABLE (IDD_PREFERENCE_SUB_PERFORMANCE + 3)
#define IDC_STATIC_PERFORMANCE_FILESIZE (IDD_PREFERENCE_SUB_PERFORMANCE + 4)
#define IDC_EDIT_PERFORMANCE_FILESIZE (IDD_PREFERENCE_SUB_PERFORMANCE + 5)
#define IDC_STATIC_PERFORMANCE_MB (IDD_PREFERENCE_SUB_PERFORMANCE + 6)
#define IDC_CHECK_PERFORMANCE_ALLOWBRACEMATCH (IDD_PREFERENCE_SUB_PERFORMANCE + 7)
#define IDC_CHECK_PERFORMANCE_ALLOWAUTOCOMPLETION (IDD_PREFERENCE_SUB_PERFORMANCE + 8)
#define IDC_CHECK_PERFORMANCE_ALLOWSMARTHILITE (IDD_PREFERENCE_SUB_PERFORMANCE + 9)
#define IDC_CHECK_PERFORMANCE_ALLOWWORDWRAP (IDD_PREFERENCE_SUB_PERFORMANCE + 10)
#endif //PREFERENCE_RC_H

7
PowerEditor/src/localization.cpp

@ -983,6 +983,13 @@ void NativeLangSpeaker::changePrefereceDlgLang(PreferenceDlg & preference)
preference.renameDialogTitle(TEXT("Delimiter"), nameW);
}
changeDlgLang(preference._performanceSubDlg.getHSelf(), "Performance", titre, titreMaxSize);
if (titre[0] != '\0')
{
const wchar_t *nameW = wmc.char2wchar(titre, _nativeLangEncoding);
preference.renameDialogTitle(TEXT("Performance"), nameW);
}
changeDlgLang(preference._cloudAndLinkSubDlg.getHSelf(), "Cloud", titre, titreMaxSize);
if (titre[0] != '\0')
{

2
PowerEditor/src/resource.h

@ -641,6 +641,8 @@
#define NPPM_INTERNAL_CRLFLAUNCHSTYLECONF (NOTEPADPLUS_USER_INTERNAL + 65)
#define NPPM_INTERNAL_LAUNCHPREFERENCES (NOTEPADPLUS_USER_INTERNAL + 66)
#define NPPM_INTERNAL_ENABLECHANGEHISTORY (NOTEPADPLUS_USER_INTERNAL + 67)
#define NPPM_INTERNAL_CLEANSMARTHILITING (NOTEPADPLUS_USER_INTERNAL + 68)
#define NPPM_INTERNAL_CLEANBRACEMATCH (NOTEPADPLUS_USER_INTERNAL + 69)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)

Loading…
Cancel
Save