Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a5eb96

Browse files
committed
Keepconsole is now a 4-way option: never/errorexit/unseen output/always. Default is "unseen output". Upped the Popt version number.
1 parent e126233 commit 4a5eb96

8 files changed

Lines changed: 97 additions & 46 deletions

File tree

Mac/Include/macbuildno.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define BUILD 55
1+
#define BUILD 66

Mac/Include/pythonresources.h

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6868
#define OPT_OPTIMIZE 5
6969
#define OPT_UNBUFFERED 6
7070
#define OPT_DEBUGGING 7
71-
#define OPT_KEEPNORMAL 8
72-
#define OPT_KEEPERROR 9
73-
#define OPT_CMDLINE 10
71+
#define OPT_KEEPALWAYS 8
72+
#define OPT_KEEPOUTPUT 9
73+
#define OPT_KEEPERROR 10
74+
#define OPT_KEEPNEVER 11
75+
#define OPT_CMDLINE 12
7476
#define OPT_TABWARN 13
7577
#define OPT_NOSITE 14
7678
#define OPT_HELP 15
@@ -134,17 +136,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
134136
/* The Python options resource and offset of its members */
135137
#define PYTHONOPTIONS_ID 228
136138
#define PYTHONOPTIONSOVERRIDE_ID 229
137-
#if 0
138-
#define POPT_INSPECT 0
139-
#define POPT_VERBOSE 1
140-
#define POPT_OPTIMIZE 2
141-
#define POPT_UNBUFFERED 3
142-
#define POPT_DEBUGGING 4
143-
#define POPT_KEEPNORM 5
144-
#define POPT_KEEPERR 6
145-
#endif
146139

147-
#define POPT_VERSION_CURRENT 5 /* Current version number */
140+
#define POPT_VERSION_CURRENT 6 /* Current version number */
141+
#define POPT_KEEPCONSOLE_NEVER 0
142+
#define POPT_KEEPCONSOLE_OUTPUT 1
143+
#define POPT_KEEPCONSOLE_ERROR 2
144+
#define POPT_KEEPCONSOLE_ALWAYS 3
148145

149146
#ifndef rez
150147
typedef struct PyMac_PrefRecord {
@@ -154,8 +151,8 @@ typedef struct PyMac_PrefRecord {
154151
unsigned char optimize;
155152
unsigned char unbuffered;
156153
unsigned char debugging;
157-
unsigned char keep_normal;
158-
unsigned char keep_error;
154+
unsigned char unused;
155+
unsigned char keep_console;
159156
unsigned char nointopt;
160157
unsigned char noargs;
161158
unsigned char tabwarn;

Mac/Lib/pythonprefs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
OVERRIDE_GUSI_ID = 10241
1717

1818
# version
19-
CUR_VERSION=5
19+
CUR_VERSION=6
2020

2121
preffilename = PstringLoader(AnyResLoader('STR ', resname=PREFNAME_NAME)).load()
2222
pref_fss = preferencefile(preffilename, 'Pyth', 'pref')
@@ -88,7 +88,7 @@ def load(self):
8888
dict['creator'], dict['type'], dict['delayconsole'] = self.gusi.load()
8989
flags = self.popt.load()
9090
dict['version'], dict['inspect'], dict['verbose'], dict['optimize'], \
91-
dict['unbuffered'], dict['debugging'], dict['keepopen'], dict['keeperror'], \
91+
dict['unbuffered'], dict['debugging'], dummy, dict['keep_console'], \
9292
dict['nointopt'], dict['noargs'], dict['tabwarn'], \
9393
dict['nosite'], dict['nonavservice'] = flags
9494
return dict
@@ -99,7 +99,7 @@ def save(self, dict):
9999
self.dir.save(diralias)
100100
self.gusi.save((dict['creator'], dict['type'], dict['delayconsole']))
101101
flags = dict['version'], dict['inspect'], dict['verbose'], dict['optimize'], \
102-
dict['unbuffered'], dict['debugging'], dict['keepopen'], dict['keeperror'], \
102+
dict['unbuffered'], dict['debugging'], 0, dict['keep_console'], \
103103
dict['nointopt'], dict['noargs'], dict['tabwarn'], \
104104
dict['nosite'], dict['nonavservice']
105105
self.popt.save(flags)

Mac/Python/macmain.c

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ extern int ccommand(char ***);
5353
#ifdef USE_MAC_SHARED_LIBRARY
5454
extern PyMac_AddLibResources(void);
5555
#endif
56+
#ifdef USE_GUSI
57+
#include "GUSISIOUX.h"
58+
#endif
5659

5760
#define STARTUP "PythonStartup"
5861

@@ -151,8 +154,15 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
151154
SET_OPT_ITEM(OPT_OPTIMIZE, optimize);
152155
SET_OPT_ITEM(OPT_UNBUFFERED, unbuffered);
153156
SET_OPT_ITEM(OPT_DEBUGGING, debugging);
154-
SET_OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
155-
SET_OPT_ITEM(OPT_KEEPERROR, keep_error);
157+
GetDialogItem(dialog, OPT_KEEPALWAYS, &type, (Handle *)&handle, &rect);
158+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ALWAYS));
159+
GetDialogItem(dialog, OPT_KEEPOUTPUT, &type, (Handle *)&handle, &rect);
160+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_OUTPUT));
161+
GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect);
162+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ERROR));
163+
GetDialogItem(dialog, OPT_KEEPNEVER, &type, (Handle *)&handle, &rect);
164+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_NEVER));
165+
/* SET_OPT_ITEM(OPT_KEEPCONSOLE, keep_console); */
156166
SET_OPT_ITEM(OPT_TABWARN, tabwarn);
157167
SET_OPT_ITEM(OPT_NOSITE, nosite);
158168
SET_OPT_ITEM(OPT_NONAVSERV, nonavservice);
@@ -204,8 +214,18 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp)
204214
OPT_ITEM(OPT_OPTIMIZE, optimize);
205215
OPT_ITEM(OPT_UNBUFFERED, unbuffered);
206216
OPT_ITEM(OPT_DEBUGGING, debugging);
207-
OPT_ITEM(OPT_KEEPNORMAL, keep_normal);
208-
OPT_ITEM(OPT_KEEPERROR, keep_error);
217+
if ( item == OPT_KEEPALWAYS ) p->keep_console = POPT_KEEPCONSOLE_ALWAYS;
218+
if ( item == OPT_KEEPOUTPUT ) p->keep_console = POPT_KEEPCONSOLE_OUTPUT;
219+
if ( item == OPT_KEEPERROR ) p->keep_console = POPT_KEEPCONSOLE_ERROR;
220+
if ( item == OPT_KEEPNEVER ) p->keep_console = POPT_KEEPCONSOLE_NEVER;
221+
GetDialogItem(dialog, OPT_KEEPALWAYS, &type, (Handle *)&handle, &rect);
222+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ALWAYS));
223+
GetDialogItem(dialog, OPT_KEEPOUTPUT, &type, (Handle *)&handle, &rect);
224+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_OUTPUT));
225+
GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect);
226+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ERROR));
227+
GetDialogItem(dialog, OPT_KEEPNEVER, &type, (Handle *)&handle, &rect);
228+
SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_NEVER));
209229
OPT_ITEM(OPT_TABWARN, tabwarn);
210230
OPT_ITEM(OPT_NOSITE, nosite);
211231
OPT_ITEM(OPT_NONAVSERV, nonavservice);
@@ -252,7 +272,7 @@ init_common(int *argcp, char ***argvp, int embedded)
252272
#endif
253273

254274
/* Get options from preference file (or from applet resource fork) */
255-
options.keep_error = 1; /* default-default */
275+
options.keep_console = POPT_KEEPCONSOLE_OUTPUT; /* default-default */
256276
PyMac_PreferenceOptions(&options);
257277

258278
if ( embedded ) {
@@ -281,7 +301,7 @@ init_common(int *argcp, char ***argvp, int embedded)
281301
}
282302

283303
/* Copy selected options to where the machine-independent stuff wants it */
284-
Py_VerboseFlag = options.verbose *2;
304+
Py_VerboseFlag = options.verbose;
285305
/* Py_SuppressPrintingFlag = options.suppress_print; */
286306
Py_OptimizeFlag = options.optimize;
287307
Py_DebugFlag = options.debugging;
@@ -525,18 +545,31 @@ void
525545
PyMac_Exit(status)
526546
int status;
527547
{
528-
int keep;
548+
int keep = 0;
529549

530550
#if __profile__ == 1
531551
ProfilerDump("\pPython Profiler Results");
532552
ProfilerTerm();
533553
#endif
534-
if ( status )
535-
keep = options.keep_error;
536-
else
537-
keep = options.keep_normal;
538554

539555
#ifdef USE_SIOUX
556+
switch (options.keep_console) {
557+
case POPT_KEEPCONSOLE_NEVER:
558+
keep = 0;
559+
break;
560+
case POPT_KEEPCONSOLE_OUTPUT:
561+
if (gusisioux_state == GUSISIOUX_STATE_LASTWRITE ||
562+
gusisioux_state == GUSISIOUX_STATE_UNKNOWN )
563+
keep = 1;
564+
else
565+
keep = 0;
566+
break;
567+
case POPT_KEEPCONSOLE_ERROR:
568+
keep = (status != 0);
569+
break;
570+
default:
571+
keep = 1;
572+
}
540573
if (keep) {
541574
SIOUXSettings.standalone = 1;
542575
SIOUXSettings.autocloseonquit = 0;

Mac/Resources/dialogs.rsrc

74 Bytes
Binary file not shown.

Mac/Resources/pythonpath.r

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ type 'Popt' {
1515
byte noOptimize = 0, optimize = 1;
1616
byte noUnbuffered = 0, unbuffered = 1;
1717
byte noDebugParser = 0, debugParser = 1;
18-
byte closeOnNormalExit = 0, noCloseOnNormalExit = 1;
19-
byte closeOnErrorExit = 0, noCloseOnErrorExit = 1;
18+
byte unused_0 = 0, unused_1 = 1;
19+
byte closeAlways = POPT_KEEPCONSOLE_NEVER,
20+
noCloseOutput = POPT_KEEPCONSOLE_OUTPUT,
21+
noCloseError = POPT_KEEPCONSOLE_ERROR,
22+
closeNever = POPT_KEEPCONSOLE_ALWAYS;
2023
byte interactiveOptions = 0, noInteractiveOptions = 1;
2124
byte argcArgv = 0, noArgcArgv = 1;
2225
byte newStandardExceptions = 0, oldStandardExceptions = 1;
@@ -62,8 +65,8 @@ resource 'Popt' (PYTHONOPTIONS_ID, "Options") {
6265
noOptimize,
6366
noUnbuffered,
6467
noDebugParser,
65-
closeOnNormalExit,
66-
noCloseOnErrorExit,
68+
unused_0,
69+
noCloseOutput,
6770
interactiveOptions,
6871
argcArgv,
6972
newStandardExceptions,

Mac/scripts/EditPythonPrefs.py

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,35 @@
3636

3737
# Map dialog item numbers to option names (and the reverse)
3838
opt_dialog_map = [
39+
None,
3940
None,
4041
"inspect",
4142
"verbose",
4243
"optimize",
4344
"unbuffered",
4445
"debugging",
45-
"keepopen",
46-
"keeperror",
46+
"tabwarn",
47+
"nosite",
48+
"nonavservice",
4749
"nointopt",
4850
"noargs",
4951
"delayconsole",
50-
None, None, None, None, None, None, None, None, # 11-18 are different
51-
"tabwarn",
52-
"nosite",
53-
"nonavservice"]
52+
]
5453
opt_dialog_dict = {}
5554
for i in range(len(opt_dialog_map)):
5655
if opt_dialog_map[i]:
5756
opt_dialog_dict[opt_dialog_map[i]] = i
5857
# 1 thru 10 are the options
5958
# The GUSI creator/type and delay-console
60-
OD_CREATOR_ITEM = 11
61-
OD_TYPE_ITEM = 12
62-
OD_OK_ITEM = 13
63-
OD_CANCEL_ITEM = 14
64-
OD_HELP_ITEM = 22
59+
OD_CREATOR_ITEM = 18
60+
OD_TYPE_ITEM = 19
61+
OD_OK_ITEM = 1
62+
OD_CANCEL_ITEM = 2
63+
OD_HELP_ITEM = 20
64+
OD_KEEPALWAYS_ITEM = 14
65+
OD_KEEPOUTPUT_ITEM = 15
66+
OD_KEEPERROR_ITEM = 16
67+
OD_KEEPNEVER_ITEM = 17
6568

6669
def optinteract(options):
6770
"""Let the user interact with the options dialog"""
@@ -72,12 +75,19 @@ def optinteract(options):
7275
SetDialogItemText(htext, options['type'])
7376
d.SetDialogDefaultItem(OD_OK_ITEM)
7477
d.SetDialogCancelItem(OD_CANCEL_ITEM)
75-
7678
while 1:
7779
for name in opt_dialog_dict.keys():
7880
num = opt_dialog_dict[name]
7981
ctl = d.GetDialogItemAsControl(num)
8082
ctl.SetControlValue(options[name])
83+
ctl = d.GetDialogItemAsControl(OD_KEEPALWAYS_ITEM)
84+
ctl.SetControlValue(options['keep_console'] == 3)
85+
ctl = d.GetDialogItemAsControl(OD_KEEPOUTPUT_ITEM)
86+
ctl.SetControlValue(options['keep_console'] == 1)
87+
ctl = d.GetDialogItemAsControl(OD_KEEPERROR_ITEM)
88+
ctl.SetControlValue(options['keep_console'] == 2)
89+
ctl = d.GetDialogItemAsControl(OD_KEEPNEVER_ITEM)
90+
ctl.SetControlValue(options['keep_console'] == 0)
8191
n = ModalDialog(None)
8292
if n == OD_OK_ITEM:
8393
htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM)
@@ -94,6 +104,14 @@ def optinteract(options):
94104
return
95105
elif n in (OD_CREATOR_ITEM, OD_TYPE_ITEM):
96106
pass
107+
elif n == OD_KEEPALWAYS_ITEM:
108+
options['keep_console'] = 3;
109+
elif n == OD_KEEPOUTPUT_ITEM:
110+
options['keep_console'] = 1;
111+
elif n == OD_KEEPERROR_ITEM:
112+
options['keep_console'] = 2;
113+
elif n == OD_KEEPNEVER_ITEM:
114+
options['keep_console'] = 0;
97115
elif n == OD_HELP_ITEM:
98116
onoff = Help.HMGetBalloons()
99117
Help.HMSetBalloons(not onoff)

Mac/scripts/EditPythonPrefs.rsrc

74 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)