From 49964f565d5c9919ca5af634c0b1357af9f597e7 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 22 Nov 2011 01:15:03 +0000 Subject: [PATCH] [CHANGE_BEHAVIOUR] Plugins loading from %APPDATA\Notepad++\plugins\% is enabled only if "NPP_INSTALLED_DIR\Notepad++\allowAppDataPlugins.xml" is present. [NEW_FEATURE] Edit Zone border can be customizable via Preferences dialog. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@846 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../MISC/PluginsManager/Notepad_plus_msgs.h | 3 ++ PowerEditor/src/Notepad_plus.cpp | 2 +- PowerEditor/src/Notepad_plus_Window.h | 1 - PowerEditor/src/NppBigSwitch.cpp | 13 +++++++ PowerEditor/src/Parameters.cpp | 9 ++++- PowerEditor/src/Parameters.h | 5 ++- .../src/ScitillaComponent/DocTabView.cpp | 6 ++- .../src/WinControls/Preference/preference.rc | 4 ++ .../WinControls/Preference/preferenceDlg.cpp | 38 +++++++++++++++---- .../WinControls/Preference/preference_rc.h | 4 ++ PowerEditor/src/WinControls/TabBar/TabBar.cpp | 13 ++----- PowerEditor/src/resource.h | 1 - 12 files changed, 76 insertions(+), 23 deletions(-) diff --git a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h index bcef484e8..72c922245 100644 --- a/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h +++ b/PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h @@ -356,6 +356,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV // BOOL NPPM_ISDOCSWITCHERSHOWN(0, 0) // Check to see if doc switcher is shown. + #define NPPM_GETAPPDATAPLUGINSALLOWED (NPPMSG + 87) + // BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0) + // Check to see if loading plugins from "%APPDATA%\Notepad++\plugins" is allowed. #define RUNCOMMAND_USER (WM_USER + 3000) #define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 05101b136..10c1c9509 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -345,7 +345,7 @@ LRESULT Notepad_plus::init(HWND hwnd) // Load plugins firstly from "%APPDATA%/Notepad++/plugins" // if Notepad++ is not in localConf mode. // All the dll loaded are marked. - bool isLoadFromAppDataAllow = true; + bool isLoadFromAppDataAllow = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0) == TRUE; const TCHAR *appDataNpp = pNppParam->getAppDataNppDir(); if (appDataNpp[0] && isLoadFromAppDataAllow) _pluginsManager.loadPlugins(appDataNpp); diff --git a/PowerEditor/src/Notepad_plus_Window.h b/PowerEditor/src/Notepad_plus_Window.h index 76a5e72a6..d89bb37df 100644 --- a/PowerEditor/src/Notepad_plus_Window.h +++ b/PowerEditor/src/Notepad_plus_Window.h @@ -18,7 +18,6 @@ #ifndef NOTEPAD_PLUS_WINDOW_H #define NOTEPAD_PLUS_WINDOW_H -//#include "Window.h" #include "Notepad_plus.h" class Notepad_plus_Window : public Window { diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 9adf13085..e89e23859 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -1834,6 +1834,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa return _pFileSwitcherPanel->isVisible(); } + case NPPM_GETAPPDATAPLUGINSALLOWED: + { + NppParameters *pNppParam = NppParameters::getInstance(); + const TCHAR *appDataNpp = pNppParam->getAppDataNppDir(); + if (appDataNpp[0]) + { + generic_string allowAppDataPluginsPath(pNppParam->getNppPath()); + PathAppend(allowAppDataPluginsPath, allowAppDataPluginsFile); + return ::PathFileExists(allowAppDataPluginsPath.c_str()); + } + return FALSE; + } + // // These are sent by Preferences Dialog // diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 837a33236..d957a64d4 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -3869,6 +3869,13 @@ void NppParameters::feedScintillaParam(TiXmlNode *node) else if (!lstrcmp(nm, TEXT("hide"))) _svp._eolShow = false; } + + nm = element->Attribute(TEXT("borderWidth"), &val); + if (nm) + { + if (val > 0 || val <= 30) + _svp._borderWidth = val; + } } @@ -4000,7 +4007,7 @@ bool NppParameters::writeScintillaParams(const ScintillaViewParams & svp) (scintNode->ToElement())->SetAttribute(TEXT("zoom2"), svp._zoom2); (scintNode->ToElement())->SetAttribute(TEXT("whiteSpaceShow"), svp._whiteSpaceShow?TEXT("show"):TEXT("hide")); (scintNode->ToElement())->SetAttribute(TEXT("eolShow"), svp._eolShow?TEXT("show"):TEXT("hide")); - + (scintNode->ToElement())->SetAttribute(TEXT("borderWidth"), svp._borderWidth); return true; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 5d4eda695..b49f0211f 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -100,6 +100,7 @@ const int COPYDATA_FILENAMESW = 2; const TCHAR fontSizeStrs[][3] = {TEXT(""), 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"); +const TCHAR allowAppDataPluginsFile[] = TEXT("allowAppDataPlugins.xml"); const TCHAR notepadStyleFile[] = TEXT("asNotepad.xml"); void cutString(const TCHAR *str2cut, vector & patternVect); @@ -755,7 +756,7 @@ struct NppGUI struct ScintillaViewParams { - ScintillaViewParams() : _lineNumberMarginShow(true), _bookMarkMarginShow(true),\ + ScintillaViewParams() : _lineNumberMarginShow(true), _bookMarkMarginShow(true),_borderWidth(2),\ _folderStyle(FOLDER_STYLE_BOX), _foldMarginShow(true), _indentGuideLineShow(true),\ _currentLineHilitingShow(true), _wrapSymbolShow(false), _doWrap(false), _edgeNbColumn(80),\ _zoom(0), _zoom2(0), _whiteSpaceShow(false), _eolShow(false), _lineWrapMethod(LINEWRAP_ALIGNED){}; @@ -775,7 +776,7 @@ struct ScintillaViewParams int _zoom2; bool _whiteSpaceShow; bool _eolShow; - + int _borderWidth; }; const int NB_LIST = 20; diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.cpp b/PowerEditor/src/ScitillaComponent/DocTabView.cpp index c6a1eea74..3fb78b630 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScitillaComponent/DocTabView.cpp @@ -147,16 +147,20 @@ void DocTabView::setBuffer(int index, BufferID id) { void DocTabView::reSizeTo(RECT & rc) { + int borderWidth = ((NppParameters::getInstance())->getSVP())._borderWidth; if (_hideTabBarStatus) { RECT rcTmp = rc; - TabBar::reSizeTo(rcTmp); _pView->reSizeTo(rc); } else { TabBar::reSizeTo(rc); + rc.left += borderWidth; + rc.right -= borderWidth * 2; + rc.top += borderWidth; + rc.bottom -= (borderWidth * 2); _pView->reSizeTo(rc); } } \ No newline at end of file diff --git a/PowerEditor/src/WinControls/Preference/preference.rc b/PowerEditor/src/WinControls/Preference/preference.rc index 593665622..ee9904331 100644 --- a/PowerEditor/src/WinControls/Preference/preference.rc +++ b/PowerEditor/src/WinControls/Preference/preference.rc @@ -98,6 +98,10 @@ BEGIN CONTROL "Default",IDC_RADIO_LWDEF,"Button",BS_AUTORADIOBUTTON | WS_GROUP,309,61,59,10 CONTROL "Aligned",IDC_RADIO_LWALIGN,"Button",BS_AUTORADIOBUTTON,309,75,60,10 CONTROL "Indent",IDC_RADIO_LWINDENT,"Button",BS_AUTORADIOBUTTON,309,89,62,10 + + GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,140,126,148,30,BS_CENTER + CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,154,139,67,13 + LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,223,139,12,8 END IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 455, 185 diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 84b1209ec..0d0b52745 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -24,6 +24,10 @@ const int BLINKRATE_FASTEST = 50; const int BLINKRATE_SLOWEST = 2500; const int BLINKRATE_INTERVAL = 50; +const int BORDERWIDTH_SMALLEST = 0; +const int BORDERWIDTH_LARGEST = 30; +const int BORDERWIDTH_INTERVAL = 1; + // This int encoding array is built from "EncodingUnit encodings[]" (see EncodingMapper.cpp) // And DefaultNewDocDlg will use "int encoding array" to get more info from "EncodingUnit encodings[]" int encodings[] = { @@ -452,7 +456,7 @@ void MarginsDlg::initScintParam() } -BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) +BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) { NppParameters *pNppParam = NppParameters::getInstance(); NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI(); @@ -478,7 +482,14 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) ::SendMessage(::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER),TBM_SETPAGESIZE, 0, BLINKRATE_INTERVAL); int blinkRate = (nppGUI._caretBlinkRate==0)?BLINKRATE_SLOWEST:nppGUI._caretBlinkRate; ::SendMessage(::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER),TBM_SETPOS, TRUE, blinkRate); - + + ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETRANGEMIN, TRUE, BORDERWIDTH_SMALLEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETRANGEMAX, TRUE, BORDERWIDTH_LARGEST); + ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPAGESIZE, 0, BLINKRATE_INTERVAL); + const ScintillaViewParams & svp = pNppParam->getSVP(); + ::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPOS, TRUE, svp._borderWidth); + ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, svp._borderWidth, FALSE); + initScintParam(); ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture(); @@ -489,12 +500,25 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM) case WM_HSCROLL: { - int blinkRate = (int)::SendMessage(::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER),TBM_GETPOS, 0, 0); - if (blinkRate == BLINKRATE_SLOWEST) - blinkRate = 0; - nppGUI._caretBlinkRate = blinkRate; + HWND hCaretBlikRateSlider = ::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER); + HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER); + if ((HWND)lParam == hCaretBlikRateSlider) + { + int blinkRate = (int)::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0); + if (blinkRate == BLINKRATE_SLOWEST) + blinkRate = 0; + nppGUI._caretBlinkRate = blinkRate; - ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0); + ::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0); + } + else if ((HWND)lParam == hBorderWidthSlider) + { + int borderWidth = (int)::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0); + ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP(); + svp._borderWidth = borderWidth; + ::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, borderWidth, FALSE); + ::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0); + } return 0; //return zero when handled } diff --git a/PowerEditor/src/WinControls/Preference/preference_rc.h b/PowerEditor/src/WinControls/Preference/preference_rc.h index eb695a701..8ee1181bb 100644 --- a/PowerEditor/src/WinControls/Preference/preference_rc.h +++ b/PowerEditor/src/WinControls/Preference/preference_rc.h @@ -89,6 +89,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #define IDC_RADIO_LWDEF (IDD_PREFERENCE_MARGEIN_BOX + 28) #define IDC_RADIO_LWALIGN (IDD_PREFERENCE_MARGEIN_BOX + 29) #define IDC_RADIO_LWINDENT (IDD_PREFERENCE_MARGEIN_BOX + 30) + + #define IDC_BORDERWIDTH_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 31) + #define IDC_BORDERWIDTHVAL_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 32) + #define IDC_BORDERWIDTH_SLIDER (IDD_PREFERENCE_MARGEIN_BOX + 33) #define IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300) #define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 1) diff --git a/PowerEditor/src/WinControls/TabBar/TabBar.cpp b/PowerEditor/src/WinControls/TabBar/TabBar.cpp index 3cbb47793..039af3672 100644 --- a/PowerEditor/src/WinControls/TabBar/TabBar.cpp +++ b/PowerEditor/src/WinControls/TabBar/TabBar.cpp @@ -181,7 +181,6 @@ void TabBar::reSizeTo(RECT & rc2Ajust) { RECT RowRect; int RowCount, TabsLength; - const int marge = 2; // Important to do that! // Otherwise, the window(s) it contains will take all the resouce of CPU @@ -204,20 +203,16 @@ void TabBar::reSizeTo(RECT & rc2Ajust) TabsLength = RowCount * (RowRect.right - RowRect.left); TabsLength += GetSystemMetrics(SM_CXEDGE); - rc2Ajust.left += TabsLength + marge; - rc2Ajust.right -= TabsLength + (marge * 2); - rc2Ajust.top += marge; - rc2Ajust.bottom -= (marge * 2); + rc2Ajust.left += TabsLength; + rc2Ajust.right -= TabsLength; } else { TabsLength = RowCount * (RowRect.bottom - RowRect.top); TabsLength += GetSystemMetrics(SM_CYEDGE); - rc2Ajust.top += TabsLength + marge; - rc2Ajust.bottom -= TabsLength + (marge * 2); - rc2Ajust.left += marge; - rc2Ajust.right -= marge * 2; + rc2Ajust.top += TabsLength; + rc2Ajust.bottom -= TabsLength; } } diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 18199b357..dc2f94eb7 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -359,7 +359,6 @@ #define NPPM_INTERNAL_RECENTFILELIST_UPDATE (NOTEPADPLUS_USER_INTERNAL + 35) #define NPPM_INTERNAL_RECENTFILELIST_SWITCH (NOTEPADPLUS_USER_INTERNAL + 36) - //wParam: 0 //lParam: document new index // See Notepad_plus_msgs.h