Fix warning display for Word char list bug

pull/2533/merge
Don Ho 8 years ago
parent 6a0b7653b0
commit f3db698166

@ -775,7 +775,7 @@ struct NppGUI final
void setTabReplacedBySpace(bool b) {_tabReplacedBySpace = b;};
const NewDocDefaultSettings & getNewDocDefaultSettings() const {return _newDocDefaultSettings;};
std::vector<LangMenuItem> _excludedLangList;
bool _isLangMenuCompact = false;
bool _isLangMenuCompact = true;
PrintSettings _printSettings;
BackupFeature _backup = bak_none;

@ -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);

@ -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<NppGUI &>((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<NppGUI &>((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;
}

@ -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

Loading…
Cancel
Save