From 73603b2357966ad0c73964c801de00e29b64e317 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 30 Apr 2014 22:04:43 +0000 Subject: [PATCH] [NEW_FEATURE] (Author: Andreas Jonsson) Make backslash as an escape character optional in SQL. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1230 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Parameters.cpp | 12 +++++++++++- PowerEditor/src/Parameters.h | 3 ++- .../src/ScitillaComponent/ScintillaEditView.h | 3 ++- PowerEditor/src/WinControls/Preference/preference.rc | 1 + .../src/WinControls/Preference/preferenceDlg.cpp | 7 +++++++ .../src/WinControls/Preference/preference_rc.h | 1 + 6 files changed, 24 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 52f21a596..657261f1c 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -4102,6 +4102,12 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) { _nppGUI._fileSwitcherWithoutExtColumn = true; } + + optName = element->Attribute(TEXT("backSlashIsEscapeCharacterForSql")); + if (optName && !lstrcmp(optName, TEXT("yes"))) + { + _nppGUI._backSlashIsEscapeCharacterForSql = true; + } } } } @@ -4841,6 +4847,9 @@ bool NppParameters::writeGUIParams() const TCHAR * pStr = _nppGUI._fileSwitcherWithoutExtColumn?TEXT("yes"):TEXT("no"); element->SetAttribute(TEXT("fileSwitcherWithoutExtColumn"), pStr); + + pStr = _nppGUI._backSlashIsEscapeCharacterForSql?TEXT("yes"):TEXT("no"); + element->SetAttribute(TEXT("backSlashIsEscapeCharacterForSql"), pStr); } else if (!lstrcmp(nm, TEXT("sessionExt"))) { @@ -5149,8 +5158,9 @@ bool NppParameters::writeGUIParams() { TiXmlElement *GUIConfigElement = (GUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); GUIConfigElement->SetAttribute(TEXT("name"), TEXT("MISC")); - + GUIConfigElement->SetAttribute(TEXT("fileSwitcherWithoutExtColumn"), _nppGUI._fileSwitcherWithoutExtColumn?TEXT("yes"):TEXT("no")); + GUIConfigElement->SetAttribute(TEXT("backSlashIsEscapeCharacterForSql"), _nppGUI._backSlashIsEscapeCharacterForSql?TEXT("yes"):TEXT("no")); } insertDockingParamNode(GUIRoot); return true; diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index ff5e0ae8e..c4327d3c9 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -714,7 +714,7 @@ struct NppGUI _autocStatus(autoc_both), _autocFromLen(1), _funcParams(false), _definedSessionExt(TEXT("")),\ _doesExistUpdater(false), _caretBlinkRate(250), _caretWidth(1), _enableMultiSelection(false), _shortTitlebar(false), _themeName(TEXT("")), _isLangMenuCompact(false),\ _smartHiliteCaseSensitive(false), _leftmostDelimiter('('), _rightmostDelimiter(')'), _delimiterSelectionOnEntireDocument(false), _multiInstSetting(monoInst),\ - _fileSwitcherWithoutExtColumn(false), _isSnapshotMode(true), _snapshotBackupTiming(7000) { + _fileSwitcherWithoutExtColumn(false), _isSnapshotMode(true), _snapshotBackupTiming(7000), _backSlashIsEscapeCharacterForSql(true) { _appPos.left = 0; _appPos.top = 0; _appPos.right = 700; @@ -765,6 +765,7 @@ struct NppGUI bool _styleMRU; char _leftmostDelimiter, _rightmostDelimiter; bool _delimiterSelectionOnEntireDocument; + bool _backSlashIsEscapeCharacterForSql; // 0 : do nothing diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h index 29d3f0a73..fea3ba7ce 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.h @@ -715,7 +715,8 @@ protected: void setSqlLexer() { - execute(SCI_SETPROPERTY, (WPARAM)"sql.backslash.escapes", (LPARAM)"1"); + if(NppParameters::getInstance()->getNppGUI()._backSlashIsEscapeCharacterForSql) + execute(SCI_SETPROPERTY, (WPARAM)"sql.backslash.escapes", (LPARAM)"1"); setLexer(SCLEX_SQL, L_SQL, LIST_0); }; diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index f297fc5e7..49a89e5a7 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -130,6 +130,7 @@ BEGIN CONTROL "Auto-indent",IDC_CHECK_MAINTAININDENT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,130,150,10 CONTROL "Minimize to system tray",IDC_CHECK_MIN2SYSTRAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,145,150,10 CONTROL "Show only filename in title bar",IDC_CHECK_SHORTTITLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,37,160,217,10 + CONTROL "Backslash is escape character for SQL",IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,37,175,217,10 CONTROL "Enable",IDC_CHECK_CLICKABLELINK_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,15,140,10 CONTROL "No underline",IDC_CHECK_CLICKABLELINK_NOUNDERLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,267,28,140,10 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 6c4b1d983..ed2f72ec5 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -830,6 +830,7 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) ::SendDlgItemMessage(_hSelf, IDC_CHECK_MIN2SYSTRAY, BM_SETCHECK, nppGUI._isMinimizedToTray, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_DETECTENCODING, BM_SETCHECK, nppGUI._detectEncoding, 0); ::SendDlgItemMessage(_hSelf, IDC_CHECK_AUTOUPDATE, BM_SETCHECK, nppGUI._autoUpdateOpt._doAutoUpdate, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL, BM_SETCHECK, nppGUI._backSlashIsEscapeCharacterForSql, 0); ::ShowWindow(::GetDlgItem(_hSelf, IDC_CHECK_AUTOUPDATE), nppGUI._doesExistUpdater?SW_SHOW:SW_HIDE); @@ -1049,6 +1050,12 @@ BOOL CALLBACK SettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) ::SendMessage(grandParent, NPPM_INTERNAL_UPDATETITLEBAR, 0, 0); return TRUE; } + + case IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL : + { + nppGUI._backSlashIsEscapeCharacterForSql = isCheckedOrNot(IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL); + return TRUE; + } } } } diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index 0edd1470c..173d8d040 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -159,6 +159,7 @@ #define IDC_CHECK_SMARTHILITECASESENSITIVE (IDD_PREFERENCE_SETTING_BOX + 32) #define IDC_SMARTHILITING_STATIC (IDD_PREFERENCE_SETTING_BOX + 33) #define IDC_CHECK_DETECTENCODING (IDD_PREFERENCE_SETTING_BOX + 34) + #define IDC_CHECK_BACKSLASHISESCAPECHARACTERFORSQL (IDD_PREFERENCE_SETTING_BOX + 35) //-- FLS: xFileEditViewHistoryParameterGUI: Additional Checkbox for enabling the history for restoring the edit view per file. #define IDC_PREFERENCE_OFFSET_FLS 40 #define IDC_CHECK_REMEMBEREDITVIEWPERFILE (IDD_PREFERENCE_SETTING_BOX + IDC_PREFERENCE_OFFSET_FLS + 1)