From f3db698166c44e8c410687e0cf12a1ff58babc0f Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 17 Jan 2017 02:08:54 +0100 Subject: [PATCH] Fix warning display for Word char list bug --- PowerEditor/src/Parameters.h | 2 +- .../src/ScitillaComponent/FindReplaceDlg.cpp | 4 +-- .../WinControls/Preference/preferenceDlg.cpp | 36 ++++++++++--------- .../WinControls/Preference/preferenceDlg.h | 3 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 61375a5ff..8fd1d8261 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -775,7 +775,7 @@ struct NppGUI final void setTabReplacedBySpace(bool b) {_tabReplacedBySpace = b;}; const NewDocDefaultSettings & getNewDocDefaultSettings() const {return _newDocDefaultSettings;}; std::vector _excludedLangList; - bool _isLangMenuCompact = false; + bool _isLangMenuCompact = true; PrintSettings _printSettings; BackupFeature _backup = bak_none; diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 05491bc8c..965df77e5 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -472,9 +472,7 @@ void Finder::gotoFoundLine() // Then we colourise the double clicked line setFinderStyle(); - //_scintView.execute(SCI_SETLEXER, SCLEX_NULL); // yniq - this line causes a bug!!! (last line suddenly belongs to file header level (?) instead of having level=0x400) - // later it affects DeleteResult and gotoNextFoundResult (assertions) - // fixed by calling setFinderStyle() in deleteResult() + _scintView.execute(SCI_STYLESETEOLFILLED, SCE_SEARCHRESULT_HIGHLIGHT_LINE, true); _scintView.execute(SCI_STARTSTYLING, start, STYLING_MASK); _scintView.execute(SCI_SETSTYLING, end - start + 2, SCE_SEARCHRESULT_HIGHLIGHT_LINE); diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index e331471f3..41f0d3989 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2889,7 +2889,7 @@ INT_PTR CALLBACK MultiInstDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) return FALSE; } -void DelimiterSettingsDlg::detectSpace(const char *text2Check, int & nbSp, int & nbTab) +void DelimiterSettingsDlg::detectSpace(const char *text2Check, int & nbSp, int & nbTab) const { nbSp = nbTab = 0; for (size_t i = 0; i < strlen(text2Check); ++i) @@ -3025,6 +3025,20 @@ generic_string DelimiterSettingsDlg::getWarningText(size_t nbSp, size_t nbTab) c return msg; } +void DelimiterSettingsDlg::setWarningIfNeed() const +{ + generic_string msg; + NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); + if (not nppGUI._isWordCharDefault) + { + int nbSp = 0; + int nbTab = 0; + detectSpace(nppGUI._customWordChars.c_str(), nbSp, nbTab); + msg = getWarningText(nbSp, nbTab); + } + ::SetDlgItemText(_hSelf, IDD_STATIC_WORDCHAR_WARNING, msg.c_str()); +} + INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { NppGUI & nppGUI = const_cast((NppParameters::getInstance())->getNppGUI()); @@ -3081,11 +3095,7 @@ INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, ::SendDlgItemMessage(_hSelf, IDC_RADIO_WORDCHAR_CUSTOM, BM_SETCHECK, not nppGUI._isWordCharDefault ? BST_CHECKED : BST_UNCHECKED, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_WORDCHAR_CUSTOM_EDIT), not nppGUI._isWordCharDefault); - int nbSp = 0; - int nbTab = 0; - detectSpace(nppGUI._customWordChars.c_str(), nbSp, nbTab); - generic_string msg = getWarningText(nbSp, nbTab); - ::SetDlgItemText(_hSelf, IDD_STATIC_WORDCHAR_WARNING, msg.c_str()); + setWarningIfNeed(); NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance())->getNativeLangSpeaker(); generic_string tip2show = pNativeSpeaker->getLocalizedStrFromID("word-chars-list-tip"); @@ -3147,15 +3157,7 @@ INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, char customText[MAX_PATH]; ::GetDlgItemTextA(_hSelf, IDC_WORDCHAR_CUSTOM_EDIT, customText, MAX_PATH-1); nppGUI._customWordChars = customText; - - int nbSp = 0; - int nbTab = 0; - detectSpace(customText, nbSp, nbTab); - generic_string msg = getWarningText(nbSp, nbTab); - ::SetDlgItemText(_hSelf, IDD_STATIC_WORDCHAR_WARNING, msg.c_str()); - - if (not nppGUI._isWordCharDefault) - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETWORDCHARS, 0, 0); + setWarningIfNeed(); return TRUE; } @@ -3183,21 +3185,21 @@ INT_PTR CALLBACK DelimiterSettingsDlg::run_dlgProc(UINT message, WPARAM wParam, case IDC_RADIO_WORDCHAR_DEFAULT: { - //::SendDlgItemMessage(_hSelf, IDC_RADIO_WORDCHAR_DEFAULT, BM_SETCHECK, BST_CHECKED, 0); ::SendDlgItemMessage(_hSelf, IDC_RADIO_WORDCHAR_CUSTOM, BM_SETCHECK, BST_UNCHECKED, 0); nppGUI._isWordCharDefault = true; ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETWORDCHARS, 0, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_WORDCHAR_CUSTOM_EDIT), not nppGUI._isWordCharDefault); + ::SetDlgItemText(_hSelf, IDD_STATIC_WORDCHAR_WARNING, TEXT("")); return TRUE; } case IDC_RADIO_WORDCHAR_CUSTOM: { ::SendDlgItemMessage(_hSelf, IDC_RADIO_WORDCHAR_DEFAULT, BM_SETCHECK, BST_UNCHECKED, 0); - //::SendDlgItemMessage(_hSelf, IDC_RADIO_WORDCHAR_CUSTOM, BM_SETCHECK, BST_CHECKED, 0); nppGUI._isWordCharDefault = false; ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETWORDCHARS, 0, 0); ::EnableWindow(::GetDlgItem(_hSelf, IDC_WORDCHAR_CUSTOM_EDIT), not nppGUI._isWordCharDefault); + setWarningIfNeed(); return TRUE; } diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.h b/PowerEditor/src/WinControls/Preference/preferenceDlg.h index 2edc7aaf3..91363385a 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.h +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.h @@ -200,8 +200,9 @@ private : HWND _tip = nullptr; INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); - void detectSpace(const char *text2Check, int & nbSp, int & nbTab); + void detectSpace(const char *text2Check, int & nbSp, int & nbTab) const; generic_string getWarningText(size_t nbSp, size_t nbTab) const; + void setWarningIfNeed() const; }; class SettingsOnCloudDlg : public StaticDialog