Skip to content

Commit 58d56f4

Browse files
committed
[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. - Notepad-plus svn trunk @ 846
1 parent b3da943 commit 58d56f4

File tree

12 files changed

+75
-22
lines changed

12 files changed

+75
-22
lines changed

PowerEditor/src/MISC/PluginsManager/Notepad_plus_msgs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ enum winVer{WV_UNKNOWN, WV_WIN32S, WV_95, WV_98, WV_ME, WV_NT, WV_W2K, WV_XP, WV
356356
// BOOL NPPM_ISDOCSWITCHERSHOWN(0, 0)
357357
// Check to see if doc switcher is shown.
358358

359+
#define NPPM_GETAPPDATAPLUGINSALLOWED (NPPMSG + 87)
360+
// BOOL NPPM_GETAPPDATAPLUGINSALLOWED(0, 0)
361+
// Check to see if loading plugins from "%APPDATA%\Notepad++\plugins" is allowed.
359362

360363
#define RUNCOMMAND_USER (WM_USER + 3000)
361364
#define NPPM_GETFULLCURRENTPATH (RUNCOMMAND_USER + FULL_CURRENT_PATH)

PowerEditor/src/Notepad_plus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
345345
// Load plugins firstly from "%APPDATA%/Notepad++/plugins"
346346
// if Notepad++ is not in localConf mode.
347347
// All the dll loaded are marked.
348-
bool isLoadFromAppDataAllow = true;
348+
bool isLoadFromAppDataAllow = ::SendMessage(_pPublicInterface->getHSelf(), NPPM_GETAPPDATAPLUGINSALLOWED, 0, 0) == TRUE;
349349
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
350350
if (appDataNpp[0] && isLoadFromAppDataAllow)
351351
_pluginsManager.loadPlugins(appDataNpp);

PowerEditor/src/Notepad_plus_Window.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#ifndef NOTEPAD_PLUS_WINDOW_H
1919
#define NOTEPAD_PLUS_WINDOW_H
2020

21-
//#include "Window.h"
2221
#include "Notepad_plus.h"
2322

2423
class Notepad_plus_Window : public Window {

PowerEditor/src/NppBigSwitch.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,19 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa
18341834
return _pFileSwitcherPanel->isVisible();
18351835
}
18361836

1837+
case NPPM_GETAPPDATAPLUGINSALLOWED:
1838+
{
1839+
NppParameters *pNppParam = NppParameters::getInstance();
1840+
const TCHAR *appDataNpp = pNppParam->getAppDataNppDir();
1841+
if (appDataNpp[0])
1842+
{
1843+
generic_string allowAppDataPluginsPath(pNppParam->getNppPath());
1844+
PathAppend(allowAppDataPluginsPath, allowAppDataPluginsFile);
1845+
return ::PathFileExists(allowAppDataPluginsPath.c_str());
1846+
}
1847+
return FALSE;
1848+
}
1849+
18371850
//
18381851
// These are sent by Preferences Dialog
18391852
//

PowerEditor/src/Parameters.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3869,6 +3869,13 @@ void NppParameters::feedScintillaParam(TiXmlNode *node)
38693869
else if (!lstrcmp(nm, TEXT("hide")))
38703870
_svp._eolShow = false;
38713871
}
3872+
3873+
nm = element->Attribute(TEXT("borderWidth"), &val);
3874+
if (nm)
3875+
{
3876+
if (val > 0 || val <= 30)
3877+
_svp._borderWidth = val;
3878+
}
38723879
}
38733880

38743881

@@ -4000,7 +4007,7 @@ bool NppParameters::writeScintillaParams(const ScintillaViewParams & svp)
40004007
(scintNode->ToElement())->SetAttribute(TEXT("zoom2"), svp._zoom2);
40014008
(scintNode->ToElement())->SetAttribute(TEXT("whiteSpaceShow"), svp._whiteSpaceShow?TEXT("show"):TEXT("hide"));
40024009
(scintNode->ToElement())->SetAttribute(TEXT("eolShow"), svp._eolShow?TEXT("show"):TEXT("hide"));
4003-
4010+
(scintNode->ToElement())->SetAttribute(TEXT("borderWidth"), svp._borderWidth);
40044011
return true;
40054012
}
40064013

PowerEditor/src/Parameters.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ const int COPYDATA_FILENAMESW = 2;
100100
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")};
101101

102102
const TCHAR localConfFile[] = TEXT("doLocalConf.xml");
103+
const TCHAR allowAppDataPluginsFile[] = TEXT("allowAppDataPlugins.xml");
103104
const TCHAR notepadStyleFile[] = TEXT("asNotepad.xml");
104105

105106
void cutString(const TCHAR *str2cut, vector<generic_string> & patternVect);
@@ -755,7 +756,7 @@ struct NppGUI
755756

756757
struct ScintillaViewParams
757758
{
758-
ScintillaViewParams() : _lineNumberMarginShow(true), _bookMarkMarginShow(true),\
759+
ScintillaViewParams() : _lineNumberMarginShow(true), _bookMarkMarginShow(true),_borderWidth(2),\
759760
_folderStyle(FOLDER_STYLE_BOX), _foldMarginShow(true), _indentGuideLineShow(true),\
760761
_currentLineHilitingShow(true), _wrapSymbolShow(false), _doWrap(false), _edgeNbColumn(80),\
761762
_zoom(0), _zoom2(0), _whiteSpaceShow(false), _eolShow(false), _lineWrapMethod(LINEWRAP_ALIGNED){};
@@ -775,7 +776,7 @@ struct ScintillaViewParams
775776
int _zoom2;
776777
bool _whiteSpaceShow;
777778
bool _eolShow;
778-
779+
int _borderWidth;
779780
};
780781

781782
const int NB_LIST = 20;

PowerEditor/src/ScitillaComponent/DocTabView.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,20 @@ void DocTabView::setBuffer(int index, BufferID id) {
147147

148148
void DocTabView::reSizeTo(RECT & rc)
149149
{
150+
int borderWidth = ((NppParameters::getInstance())->getSVP())._borderWidth;
150151
if (_hideTabBarStatus)
151152
{
152153
RECT rcTmp = rc;
153-
154154
TabBar::reSizeTo(rcTmp);
155155
_pView->reSizeTo(rc);
156156
}
157157
else
158158
{
159159
TabBar::reSizeTo(rc);
160+
rc.left += borderWidth;
161+
rc.right -= borderWidth * 2;
162+
rc.top += borderWidth;
163+
rc.bottom -= (borderWidth * 2);
160164
_pView->reSizeTo(rc);
161165
}
162166
}

PowerEditor/src/WinControls/Preference/preference.rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ BEGIN
9898
CONTROL "Default",IDC_RADIO_LWDEF,"Button",BS_AUTORADIOBUTTON | WS_GROUP,309,61,59,10
9999
CONTROL "Aligned",IDC_RADIO_LWALIGN,"Button",BS_AUTORADIOBUTTON,309,75,60,10
100100
CONTROL "Indent",IDC_RADIO_LWINDENT,"Button",BS_AUTORADIOBUTTON,309,89,62,10
101+
102+
GROUPBOX "Border Width",IDC_BORDERWIDTH_STATIC,140,126,148,30,BS_CENTER
103+
CONTROL "",IDC_BORDERWIDTH_SLIDER,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,154,139,67,13
104+
LTEXT "0",IDC_BORDERWIDTHVAL_STATIC,223,139,12,8
101105
END
102106

103107
IDD_PREFERENCE_SETTING_BOX DIALOGEX 0, 0, 455, 185

PowerEditor/src/WinControls/Preference/preferenceDlg.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ const int BLINKRATE_FASTEST = 50;
2424
const int BLINKRATE_SLOWEST = 2500;
2525
const int BLINKRATE_INTERVAL = 50;
2626

27+
const int BORDERWIDTH_SMALLEST = 0;
28+
const int BORDERWIDTH_LARGEST = 30;
29+
const int BORDERWIDTH_INTERVAL = 1;
30+
2731
// This int encoding array is built from "EncodingUnit encodings[]" (see EncodingMapper.cpp)
2832
// And DefaultNewDocDlg will use "int encoding array" to get more info from "EncodingUnit encodings[]"
2933
int encodings[] = {
@@ -452,7 +456,7 @@ void MarginsDlg::initScintParam()
452456
}
453457

454458

455-
BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
459+
BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam)
456460
{
457461
NppParameters *pNppParam = NppParameters::getInstance();
458462
NppGUI & nppGUI = (NppGUI &)pNppParam->getNppGUI();
@@ -479,6 +483,13 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
479483
int blinkRate = (nppGUI._caretBlinkRate==0)?BLINKRATE_SLOWEST:nppGUI._caretBlinkRate;
480484
::SendMessage(::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER),TBM_SETPOS, TRUE, blinkRate);
481485

486+
::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETRANGEMIN, TRUE, BORDERWIDTH_SMALLEST);
487+
::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETRANGEMAX, TRUE, BORDERWIDTH_LARGEST);
488+
::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPAGESIZE, 0, BLINKRATE_INTERVAL);
489+
const ScintillaViewParams & svp = pNppParam->getSVP();
490+
::SendMessage(::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER),TBM_SETPOS, TRUE, svp._borderWidth);
491+
::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, svp._borderWidth, FALSE);
492+
482493
initScintParam();
483494

484495
ETDTProc enableDlgTheme = (ETDTProc)pNppParam->getEnableThemeDlgTexture();
@@ -489,12 +500,25 @@ BOOL CALLBACK MarginsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM)
489500

490501
case WM_HSCROLL:
491502
{
492-
int blinkRate = (int)::SendMessage(::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER),TBM_GETPOS, 0, 0);
493-
if (blinkRate == BLINKRATE_SLOWEST)
494-
blinkRate = 0;
495-
nppGUI._caretBlinkRate = blinkRate;
503+
HWND hCaretBlikRateSlider = ::GetDlgItem(_hSelf, IDC_CARETBLINKRATE_SLIDER);
504+
HWND hBorderWidthSlider = ::GetDlgItem(_hSelf, IDC_BORDERWIDTH_SLIDER);
505+
if ((HWND)lParam == hCaretBlikRateSlider)
506+
{
507+
int blinkRate = (int)::SendMessage(hCaretBlikRateSlider, TBM_GETPOS, 0, 0);
508+
if (blinkRate == BLINKRATE_SLOWEST)
509+
blinkRate = 0;
510+
nppGUI._caretBlinkRate = blinkRate;
496511

497-
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0);
512+
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_SETCARETBLINKRATE, 0, 0);
513+
}
514+
else if ((HWND)lParam == hBorderWidthSlider)
515+
{
516+
int borderWidth = (int)::SendMessage(hBorderWidthSlider, TBM_GETPOS, 0, 0);
517+
ScintillaViewParams & svp = (ScintillaViewParams &)pNppParam->getSVP();
518+
svp._borderWidth = borderWidth;
519+
::SetDlgItemInt(_hSelf, IDC_BORDERWIDTHVAL_STATIC, borderWidth, FALSE);
520+
::SendMessage(::GetParent(_hParent), WM_SIZE, 0, 0);
521+
}
498522
return 0; //return zero when handled
499523

500524
}

PowerEditor/src/WinControls/Preference/preference_rc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
9090
#define IDC_RADIO_LWALIGN (IDD_PREFERENCE_MARGEIN_BOX + 29)
9191
#define IDC_RADIO_LWINDENT (IDD_PREFERENCE_MARGEIN_BOX + 30)
9292

93+
#define IDC_BORDERWIDTH_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 31)
94+
#define IDC_BORDERWIDTHVAL_STATIC (IDD_PREFERENCE_MARGEIN_BOX + 32)
95+
#define IDC_BORDERWIDTH_SLIDER (IDD_PREFERENCE_MARGEIN_BOX + 33)
96+
9397
#define IDD_PREFERENCE_SETTING_BOX 6300 //(IDD_PREFERENCE_BOX + 300)
9498
#define IDC_TABSETTING_GB_STATIC (IDD_PREFERENCE_SETTING_BOX + 1)
9599
#define IDC_CHECK_REPLACEBYSPACE (IDD_PREFERENCE_SETTING_BOX + 2)

0 commit comments

Comments
 (0)