Skip to content

Commit 40bfaf2

Browse files
CFrankCFrank
authored andcommitted
config file and configuration related changes
1 parent ce3d15d commit 40bfaf2

File tree

6 files changed

+75
-26
lines changed

6 files changed

+75
-26
lines changed

PythonScript/res/PythonScript.rc

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1
5757
BEGIN
5858
DEFPUSHBUTTON "OK",IDOK,143,168,50,14
5959
LTEXT "Python Script",IDC_STATIC,146,7,49,8
60-
LTEXT "(C) 2010, 2011, 2014, 2018 Dave Brotherstone",IDC_STATIC,92,30,154,8
61-
CONTROL 118,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE,118,42,93,34
60+
LTEXT "(C) 2010, 2011, 2014 Dave Brotherstone",IDC_STATIC,105,30,133,8
61+
CONTROL IDB_PYTHONPOWERED,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE,118,42,93,34
6262
EDITTEXT IDC_COPYRIGHT,7,84,324,74,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
6363
CTEXT "1.0",IDC_VERSION,156,19,26,8
6464
END
@@ -73,32 +73,38 @@ BEGIN
7373
LTEXT ">>>",IDC_PROMPT,7,161,17,8
7474
END
7575

76-
IDD_SCRIPTCONFIG DIALOGEX 0, 0, 376, 363
76+
IDD_SCRIPTCONFIG DIALOGEX 0, 0, 377, 406
7777
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
7878
CAPTION "Python Script Shortcut Configuration"
7979
FONT 8, "MS Shell Dlg", 400, 0, 0x1
8080
BEGIN
81-
DEFPUSHBUTTON "OK",IDOK,265,342,50,14
82-
PUSHBUTTON "Cancel",IDCANCEL,319,342,50,14
81+
DEFPUSHBUTTON "OK",IDOK,265,383,50,14
82+
PUSHBUTTON "Cancel",IDCANCEL,320,383,50,14
8383
CONTROL "",IDC_FILETREE,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_BORDER | WS_HSCROLL | WS_TABSTOP,14,31,343,105
84-
GROUPBOX "Scripts",IDC_STATIC,7,7,362,136
84+
GROUPBOX "Scripts",IDC_STATIC,7,7,363,136
8585
CONTROL "Machine Scripts",IDC_RADMACHINE,"Button",BS_AUTORADIOBUTTON,19,18,65,10
8686
CONTROL "User Scripts",IDC_RADUSER,"Button",BS_AUTORADIOBUTTON,94,18,54,10
8787
PUSHBUTTON "Add",IDC_MENUADD,21,146,50,14
8888
PUSHBUTTON "Remove",IDC_MENUREMOVE,89,146,50,14
89-
PUSHBUTTON "Add",IDC_TOOLBARADD,187,146,50,14
89+
PUSHBUTTON "Add",IDC_TOOLBARADD,187,145,50,14
9090
PUSHBUTTON "Remove",IDC_TOOLBARREMOVE,245,146,50,14
91-
LTEXT "Menu items",IDC_STATIC,10,161,37,8
91+
LTEXT "Menu items",IDC_STATIC,10,162,37,8
9292
LTEXT "Toolbar icons",IDC_STATIC,186,161,43,8
93-
CONTROL "",IDC_TOOLBARITEMLIST2,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,185,172,184,104
93+
CONTROL "",IDC_TOOLBARITEMLIST2,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,186,172,184,104
9494
PUSHBUTTON "Set Icon",IDC_TOOLBARSETICON,304,146,50,14
95-
CONTROL "",IDC_MENUITEMLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,172,173,104
96-
COMBOBOX IDC_COMBOINITIALISATION,58,285,69,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
95+
CONTROL "",IDC_MENUITEMLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,7,171,173,106
96+
COMBOBOX IDC_COMBOINITIALISATION,55,285,69,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
9797
LTEXT "Initialisation:",IDC_STATIC,9,287,44,12
9898
LTEXT "Lazy initialisation initialises Python when it is first used. Use ATSTARTUP if you want your startup.py scripts to run as soon as Notepad++ starts.",IDC_STATIC,131,282,232,21
9999
CONTROL "Prefer installed Python libraries - use only if you have Python 2.7 installed, and you have copied the python27.dll from your Windows directory to the Notepad++ directory. ",IDC_CHECKPREFERINSTALLEDPYTHON,
100100
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,303,352,19
101-
LTEXT "This has the effect that the directories under Notepad++ that contain Python libraries are searched AFTER the standard Python directories. If in doubt, leave unchecked.",IDC_STATIC,21,321,348,19
101+
LTEXT "This has the effect that the directories under Notepad++ that contain Python libraries are searched AFTER the standard Python directories. If in doubt, leave unchecked.",IDC_STATIC,22,321,348,19
102+
CONTROL "Add an additional end of line character for run statements and error messages to the console",IDC_CHECKADDEXTRALINETOOUTPUT,
103+
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,342,352,11
104+
CONTROL "Automatically open console on error",IDC_CHECKOPENCONSOLEONERROR,
105+
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,355,352,11
106+
CONTROL "Color output from run statements differently",IDC_CHECKCOLORIZEOUTPUT,
107+
"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | WS_TABSTOP,11,368,157,11
102108
END
103109

104110
IDD_PROMPTDIALOG DIALOGEX 0, 0, 313, 105
@@ -140,9 +146,9 @@ BEGIN
140146
IDD_SCRIPTCONFIG, DIALOG
141147
BEGIN
142148
LEFTMARGIN, 7
143-
RIGHTMARGIN, 369
149+
RIGHTMARGIN, 370
144150
TOPMARGIN, 7
145-
BOTTOMMARGIN, 356
151+
BOTTOMMARGIN, 399
146152
END
147153

148154
IDD_PROMPTDIALOG, DIALOG
@@ -164,17 +170,34 @@ END
164170
// Icon with lowest ID value placed first to ensure application icon
165171
// remains consistent on all systems.
166172
IDI_FOLDERCLOSED ICON "FolderClosed.ico"
173+
167174
IDI_FOLDEROPEN ICON "FolderOpen.ico"
175+
168176
IDI_PYTHON ICON "python.ico"
177+
169178
IDI_PYTHON8 ICON "python2.ico"
170179

180+
171181
/////////////////////////////////////////////////////////////////////////////
172182
//
173183
// Bitmap
174184
//
175185

176186
IDB_PYTHON BITMAP "python.bmp"
187+
177188
IDB_PYTHONPOWERED BITMAP "python-powered-w-140x56.bmp"
189+
190+
191+
/////////////////////////////////////////////////////////////////////////////
192+
//
193+
// AFX_DIALOG_LAYOUT
194+
//
195+
196+
IDD_SCRIPTCONFIG AFX_DIALOG_LAYOUT
197+
BEGIN
198+
0
199+
END
200+
178201
#endif // English (United Kingdom) resources
179202
/////////////////////////////////////////////////////////////////////////////
180203

0 Bytes
Binary file not shown.

PythonScript/res/resource.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@
3838
#define IDC_COPYRIGHT 1018
3939
#define IDC_VERSION 1019
4040
#define IDC_CHECKPREFERINSTALLEDPYTHON 1020
41+
#define IDC_CHECKADDEXTRALINETOOUTPUT 1021
42+
#define IDC_CHECKOPENCONSOLEONERROR 1022
43+
#define IDC_CHECKCOLORIZEOUTPUT 1023
4144

4245
// Next default values for new objects
4346
//
4447
#ifdef APSTUDIO_INVOKED
4548
#ifndef APSTUDIO_READONLY_SYMBOLS
46-
#define _APS_NEXT_RESOURCE_VALUE 119
49+
#define _APS_NEXT_RESOURCE_VALUE 120
4750
#define _APS_NEXT_COMMAND_VALUE 40001
4851
#define _APS_NEXT_CONTROL_VALUE 1021
4952
#define _APS_NEXT_SYMED_VALUE 101

PythonScript/src/ConfigFile.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ ConfigFile::ConfigFile(const TCHAR *configDir, const TCHAR *pluginDir, HINSTANCE
2626
m_machineScriptsDir.append(_T("\\PythonScript\\scripts"));
2727
m_userScriptsDir.append(_T("\\PythonScript\\scripts"));
2828

29+
initSettings();
2930
readConfig();
3031
}
3132

@@ -39,6 +40,14 @@ ConfigFile::~ConfigFile()
3940

4041
}
4142

43+
void ConfigFile::initSettings()
44+
{
45+
setSetting(_T("ADDEXTRALINETOOUTPUT"), _T("0"));
46+
setSetting(_T("COLORIZEOUTPUT"), _T("-1"));
47+
setSetting(_T("OPENCONSOLEONERROR"), _T("0"));
48+
setSetting(_T("PREFERINSTALLEDPYTHON"), _T("0"));
49+
setSetting(_T("STARTUP"), _T("LAZY"));
50+
}
4251

4352
void ConfigFile::readConfig()
4453
{
@@ -89,7 +98,7 @@ void ConfigFile::readConfig()
8998
{
9099
element = strtok_s(NULL, "/", &context);
91100
char *settingValue = strtok_s(NULL, "/", &context);
92-
m_settings.insert(std::pair<tstring, tstring>(tstring(WcharMbcsConverter::char2tchar(element).get()), tstring(WcharMbcsConverter::char2tchar(settingValue).get())));
101+
m_settings.insert_or_assign(tstring(WcharMbcsConverter::char2tchar(element).get()), tstring(WcharMbcsConverter::char2tchar(settingValue).get()));
93102
}
94103
}
95104

PythonScript/src/ConfigFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ConfigFile
3838

3939
protected:
4040
void readConfig();
41+
void initSettings();
4142

4243
private:
4344
ConfigFile(); // default constructor disabled

PythonScript/src/ShortcutDlg.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,18 @@ void ShortcutDlg::populateCurrentItems()
500500
ComboBox_SetCurSel(m_hComboInitialisation, 0);
501501
}
502502

503-
if (configFile->getSetting(_T("PREFERINSTALLEDPYTHON")) == _T("1")) {
504-
CheckDlgButton(_hSelf, IDC_CHECKPREFERINSTALLEDPYTHON, BST_CHECKED);
505-
} else {
506-
CheckDlgButton(_hSelf, IDC_CHECKPREFERINSTALLEDPYTHON, BST_UNCHECKED);
507-
}
503+
bool preferInstallPython = (configFile->getSetting(_T("PREFERINSTALLEDPYTHON")) == _T("1"));
504+
CheckDlgButton(_hSelf, IDC_CHECKPREFERINSTALLEDPYTHON, preferInstallPython ? BST_CHECKED : BST_UNCHECKED);
505+
506+
bool addExtraLine = (configFile->getSetting(_T("ADDEXTRALINETOOUTPUT")) == _T("1"));
507+
CheckDlgButton(_hSelf, IDC_CHECKADDEXTRALINETOOUTPUT, addExtraLine ? BST_CHECKED : BST_UNCHECKED);
508+
509+
bool colorOutput = (configFile->getSetting(_T("COLORIZEOUTPUT")) >= _T("0"));
510+
CheckDlgButton(_hSelf, IDC_CHECKCOLORIZEOUTPUT, colorOutput ? BST_CHECKED : BST_UNCHECKED);
511+
512+
bool openOnError = (configFile->getSetting(_T("OPENCONSOLEONERROR")) == _T("1"));
513+
CheckDlgButton(_hSelf, IDC_CHECKOPENCONSOLEONERROR, openOnError ? BST_CHECKED : BST_UNCHECKED);
514+
508515
}
509516

510517

@@ -530,12 +537,18 @@ void ShortcutDlg::saveConfig()
530537
ComboBox_GetText(m_hComboInitialisation, startupBuffer, 50);
531538
configFile->setSetting(_T("STARTUP"), startupBuffer);
532539

533-
if (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKPREFERINSTALLEDPYTHON)) {
534-
configFile->setSetting(_T("PREFERINSTALLEDPYTHON"), _T("1"));
535-
} else {
536-
configFile->setSetting(_T("PREFERINSTALLEDPYTHON"), _T("0"));
537-
}
540+
bool preferInstallPython = (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKPREFERINSTALLEDPYTHON));
541+
configFile->setSetting(_T("PREFERINSTALLEDPYTHON"), preferInstallPython ? _T("1") : _T("0"));
542+
543+
bool addExtraLine = (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKADDEXTRALINETOOUTPUT));
544+
configFile->setSetting(_T("ADDEXTRALINETOOUTPUT"), addExtraLine ? _T("1"): _T("0"));
545+
546+
bool colorOutput = (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKCOLORIZEOUTPUT));
547+
configFile->setSetting(_T("COLORIZEOUTPUT"), colorOutput ? _T("1234567") : _T("-1"));
538548

549+
bool openOnError = (BST_CHECKED == IsDlgButtonChecked(_hSelf, IDC_CHECKOPENCONSOLEONERROR));
550+
configFile->setSetting(_T("OPENCONSOLEONERROR"), openOnError ? _T("1") : _T("0"));
551+
539552
configFile->save();
540553
}
541554

0 commit comments

Comments
 (0)