From 4a5eb967b8b50bfc301d83d5d3234501db8f0a17 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 22 Sep 2000 21:50:11 +0000 Subject: [PATCH] Keepconsole is now a 4-way option: never/errorexit/unseen output/always. Default is "unseen output". Upped the Popt version number. --- Mac/Include/macbuildno.h | 2 +- Mac/Include/pythonresources.h | 27 +++++++-------- Mac/Lib/pythonprefs.py | 6 ++-- Mac/Python/macmain.c | 55 ++++++++++++++++++++++++------- Mac/Resources/dialogs.rsrc | Bin 17829 -> 17903 bytes Mac/Resources/pythonpath.r | 11 ++++--- Mac/scripts/EditPythonPrefs.py | 42 ++++++++++++++++------- Mac/scripts/EditPythonPrefs.rsrc | Bin 8994 -> 9068 bytes 8 files changed, 97 insertions(+), 46 deletions(-) diff --git a/Mac/Include/macbuildno.h b/Mac/Include/macbuildno.h index 7cced7773f1c..f1bf41a5a6fc 100644 --- a/Mac/Include/macbuildno.h +++ b/Mac/Include/macbuildno.h @@ -1 +1 @@ -#define BUILD 55 +#define BUILD 66 diff --git a/Mac/Include/pythonresources.h b/Mac/Include/pythonresources.h index 178260826c24..0b74328d0207 100644 --- a/Mac/Include/pythonresources.h +++ b/Mac/Include/pythonresources.h @@ -68,9 +68,11 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define OPT_OPTIMIZE 5 #define OPT_UNBUFFERED 6 #define OPT_DEBUGGING 7 -#define OPT_KEEPNORMAL 8 -#define OPT_KEEPERROR 9 -#define OPT_CMDLINE 10 +#define OPT_KEEPALWAYS 8 +#define OPT_KEEPOUTPUT 9 +#define OPT_KEEPERROR 10 +#define OPT_KEEPNEVER 11 +#define OPT_CMDLINE 12 #define OPT_TABWARN 13 #define OPT_NOSITE 14 #define OPT_HELP 15 @@ -134,17 +136,12 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* The Python options resource and offset of its members */ #define PYTHONOPTIONS_ID 228 #define PYTHONOPTIONSOVERRIDE_ID 229 -#if 0 -#define POPT_INSPECT 0 -#define POPT_VERBOSE 1 -#define POPT_OPTIMIZE 2 -#define POPT_UNBUFFERED 3 -#define POPT_DEBUGGING 4 -#define POPT_KEEPNORM 5 -#define POPT_KEEPERR 6 -#endif -#define POPT_VERSION_CURRENT 5 /* Current version number */ +#define POPT_VERSION_CURRENT 6 /* Current version number */ +#define POPT_KEEPCONSOLE_NEVER 0 +#define POPT_KEEPCONSOLE_OUTPUT 1 +#define POPT_KEEPCONSOLE_ERROR 2 +#define POPT_KEEPCONSOLE_ALWAYS 3 #ifndef rez typedef struct PyMac_PrefRecord { @@ -154,8 +151,8 @@ typedef struct PyMac_PrefRecord { unsigned char optimize; unsigned char unbuffered; unsigned char debugging; - unsigned char keep_normal; - unsigned char keep_error; + unsigned char unused; + unsigned char keep_console; unsigned char nointopt; unsigned char noargs; unsigned char tabwarn; diff --git a/Mac/Lib/pythonprefs.py b/Mac/Lib/pythonprefs.py index 916ec9f2b375..81d095f3f679 100644 --- a/Mac/Lib/pythonprefs.py +++ b/Mac/Lib/pythonprefs.py @@ -16,7 +16,7 @@ OVERRIDE_POPT_ID = 229 OVERRIDE_GUSI_ID = 10241 # version -CUR_VERSION=5 +CUR_VERSION=6 preffilename = PstringLoader(AnyResLoader('STR ', resname=PREFNAME_NAME)).load() pref_fss = preferencefile(preffilename, 'Pyth', 'pref') @@ -88,7 +88,7 @@ class PythonOptions: dict['creator'], dict['type'], dict['delayconsole'] = self.gusi.load() flags = self.popt.load() dict['version'], dict['inspect'], dict['verbose'], dict['optimize'], \ - dict['unbuffered'], dict['debugging'], dict['keepopen'], dict['keeperror'], \ + dict['unbuffered'], dict['debugging'], dummy, dict['keep_console'], \ dict['nointopt'], dict['noargs'], dict['tabwarn'], \ dict['nosite'], dict['nonavservice'] = flags return dict @@ -99,7 +99,7 @@ class PythonOptions: self.dir.save(diralias) self.gusi.save((dict['creator'], dict['type'], dict['delayconsole'])) flags = dict['version'], dict['inspect'], dict['verbose'], dict['optimize'], \ - dict['unbuffered'], dict['debugging'], dict['keepopen'], dict['keeperror'], \ + dict['unbuffered'], dict['debugging'], 0, dict['keep_console'], \ dict['nointopt'], dict['noargs'], dict['tabwarn'], \ dict['nosite'], dict['nonavservice'] self.popt.save(flags) diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c index c46fd2f62e0e..3531f4c2bac6 100644 --- a/Mac/Python/macmain.c +++ b/Mac/Python/macmain.c @@ -53,6 +53,9 @@ extern int ccommand(char ***); #ifdef USE_MAC_SHARED_LIBRARY extern PyMac_AddLibResources(void); #endif +#ifdef USE_GUSI +#include "GUSISIOUX.h" +#endif #define STARTUP "PythonStartup" @@ -151,8 +154,15 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp) SET_OPT_ITEM(OPT_OPTIMIZE, optimize); SET_OPT_ITEM(OPT_UNBUFFERED, unbuffered); SET_OPT_ITEM(OPT_DEBUGGING, debugging); - SET_OPT_ITEM(OPT_KEEPNORMAL, keep_normal); - SET_OPT_ITEM(OPT_KEEPERROR, keep_error); + GetDialogItem(dialog, OPT_KEEPALWAYS, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ALWAYS)); + GetDialogItem(dialog, OPT_KEEPOUTPUT, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_OUTPUT)); + GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ERROR)); + GetDialogItem(dialog, OPT_KEEPNEVER, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_NEVER)); +/* SET_OPT_ITEM(OPT_KEEPCONSOLE, keep_console); */ SET_OPT_ITEM(OPT_TABWARN, tabwarn); SET_OPT_ITEM(OPT_NOSITE, nosite); SET_OPT_ITEM(OPT_NONAVSERV, nonavservice); @@ -204,8 +214,18 @@ PyMac_InteractiveOptions(PyMac_PrefRecord *p, int *argcp, char ***argvp) OPT_ITEM(OPT_OPTIMIZE, optimize); OPT_ITEM(OPT_UNBUFFERED, unbuffered); OPT_ITEM(OPT_DEBUGGING, debugging); - OPT_ITEM(OPT_KEEPNORMAL, keep_normal); - OPT_ITEM(OPT_KEEPERROR, keep_error); + if ( item == OPT_KEEPALWAYS ) p->keep_console = POPT_KEEPCONSOLE_ALWAYS; + if ( item == OPT_KEEPOUTPUT ) p->keep_console = POPT_KEEPCONSOLE_OUTPUT; + if ( item == OPT_KEEPERROR ) p->keep_console = POPT_KEEPCONSOLE_ERROR; + if ( item == OPT_KEEPNEVER ) p->keep_console = POPT_KEEPCONSOLE_NEVER; + GetDialogItem(dialog, OPT_KEEPALWAYS, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ALWAYS)); + GetDialogItem(dialog, OPT_KEEPOUTPUT, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_OUTPUT)); + GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_ERROR)); + GetDialogItem(dialog, OPT_KEEPNEVER, &type, (Handle *)&handle, &rect); + SetControlValue(handle, (short)(p->keep_console == POPT_KEEPCONSOLE_NEVER)); OPT_ITEM(OPT_TABWARN, tabwarn); OPT_ITEM(OPT_NOSITE, nosite); OPT_ITEM(OPT_NONAVSERV, nonavservice); @@ -252,7 +272,7 @@ init_common(int *argcp, char ***argvp, int embedded) #endif /* Get options from preference file (or from applet resource fork) */ - options.keep_error = 1; /* default-default */ + options.keep_console = POPT_KEEPCONSOLE_OUTPUT; /* default-default */ PyMac_PreferenceOptions(&options); if ( embedded ) { @@ -281,7 +301,7 @@ init_common(int *argcp, char ***argvp, int embedded) } /* Copy selected options to where the machine-independent stuff wants it */ - Py_VerboseFlag = options.verbose *2; + Py_VerboseFlag = options.verbose; /* Py_SuppressPrintingFlag = options.suppress_print; */ Py_OptimizeFlag = options.optimize; Py_DebugFlag = options.debugging; @@ -525,18 +545,31 @@ void PyMac_Exit(status) int status; { - int keep; + int keep = 0; #if __profile__ == 1 ProfilerDump("\pPython Profiler Results"); ProfilerTerm(); #endif - if ( status ) - keep = options.keep_error; - else - keep = options.keep_normal; #ifdef USE_SIOUX + switch (options.keep_console) { + case POPT_KEEPCONSOLE_NEVER: + keep = 0; + break; + case POPT_KEEPCONSOLE_OUTPUT: + if (gusisioux_state == GUSISIOUX_STATE_LASTWRITE || + gusisioux_state == GUSISIOUX_STATE_UNKNOWN ) + keep = 1; + else + keep = 0; + break; + case POPT_KEEPCONSOLE_ERROR: + keep = (status != 0); + break; + default: + keep = 1; + } if (keep) { SIOUXSettings.standalone = 1; SIOUXSettings.autocloseonquit = 0; diff --git a/Mac/Resources/dialogs.rsrc b/Mac/Resources/dialogs.rsrc index 907b9d012bb9564af372fdfbccc7999a29b00c07..4a84dd63cd501c59185e7c3f9c0705b90ca2f9a8 100644 GIT binary patch delta 604 zc-mXq&G^2Xae^&l??gLo);|mkHh(te`I&C+v+Q7DV(^(9XlXb3fUW=wQxSvE`WFwwi=kt!Q=&GH-g!mOff+AYA~CLsb7J?EE&vZW?BSfw@$w2Pyn>{|9=Js^DcV6sQD(6Oq0Hg|#2p~E$v%kPAhu~J#11g~GQ@5W z+squyW?;$zivI_*8JTK<;?kQpIdL#ezT|RQf_bY=OBRfM6E4N>MQEp<6 zLTW{32@?Ydd}Ua`$j->c%9UDFlwSmvnEb@raPn#!4c3PY91I^P->^}hENY|0$S~Q# zCRN;r0SPp+FfcMaXJBBIn`98kC^$LJHgs~ot;FQh#ypeX1F^I|&*a%aKD(W`4!@jD z#fOK7+uMN*pjHWnDU6F4UodTBU}OXu0tP^n47h-_%j7^S=ZP0sHt#iUXAuEO+JgPW zz`#C{?PKg2mS>ww>~t7K7@jk+Fff=zfb=qQGM!^!u&SE8#r^_FLWF_A{1{Z?K2USi zh+#$*p<-vYDQnF4_9A7C~IQ<4IMWiZr~5+J)4%w}R* zuE1br3T87i?EkZ5=atjiVcrMcd>rj&V#DL6bwAd}1KV z%pW0?*_1)t0b*NBfY=RUTdG6s0JE1u>;|!|IKgZNrWT<1MKGI@X)2KYcJm)64kiiy b;F83mlF|Z&{DP9q{Jdgze+WI9#q}}(vG9lN diff --git a/Mac/Resources/pythonpath.r b/Mac/Resources/pythonpath.r index 7f23c15a312c..25b59cdb6d7a 100644 --- a/Mac/Resources/pythonpath.r +++ b/Mac/Resources/pythonpath.r @@ -15,8 +15,11 @@ type 'Popt' { byte noOptimize = 0, optimize = 1; byte noUnbuffered = 0, unbuffered = 1; byte noDebugParser = 0, debugParser = 1; - byte closeOnNormalExit = 0, noCloseOnNormalExit = 1; - byte closeOnErrorExit = 0, noCloseOnErrorExit = 1; + byte unused_0 = 0, unused_1 = 1; + byte closeAlways = POPT_KEEPCONSOLE_NEVER, + noCloseOutput = POPT_KEEPCONSOLE_OUTPUT, + noCloseError = POPT_KEEPCONSOLE_ERROR, + closeNever = POPT_KEEPCONSOLE_ALWAYS; byte interactiveOptions = 0, noInteractiveOptions = 1; byte argcArgv = 0, noArgcArgv = 1; byte newStandardExceptions = 0, oldStandardExceptions = 1; @@ -62,8 +65,8 @@ resource 'Popt' (PYTHONOPTIONS_ID, "Options") { noOptimize, noUnbuffered, noDebugParser, - closeOnNormalExit, - noCloseOnErrorExit, + unused_0, + noCloseOutput, interactiveOptions, argcArgv, newStandardExceptions, diff --git a/Mac/scripts/EditPythonPrefs.py b/Mac/scripts/EditPythonPrefs.py index d9f30f103ccb..f49f3985cce0 100644 --- a/Mac/scripts/EditPythonPrefs.py +++ b/Mac/scripts/EditPythonPrefs.py @@ -36,32 +36,35 @@ OPT_DIALOG_ID = 510 # Map dialog item numbers to option names (and the reverse) opt_dialog_map = [ + None, None, "inspect", "verbose", "optimize", "unbuffered", "debugging", - "keepopen", - "keeperror", + "tabwarn", + "nosite", + "nonavservice", "nointopt", "noargs", "delayconsole", - None, None, None, None, None, None, None, None, # 11-18 are different - "tabwarn", - "nosite", - "nonavservice"] + ] opt_dialog_dict = {} for i in range(len(opt_dialog_map)): if opt_dialog_map[i]: opt_dialog_dict[opt_dialog_map[i]] = i # 1 thru 10 are the options # The GUSI creator/type and delay-console -OD_CREATOR_ITEM = 11 -OD_TYPE_ITEM = 12 -OD_OK_ITEM = 13 -OD_CANCEL_ITEM = 14 -OD_HELP_ITEM = 22 +OD_CREATOR_ITEM = 18 +OD_TYPE_ITEM = 19 +OD_OK_ITEM = 1 +OD_CANCEL_ITEM = 2 +OD_HELP_ITEM = 20 +OD_KEEPALWAYS_ITEM = 14 +OD_KEEPOUTPUT_ITEM = 15 +OD_KEEPERROR_ITEM = 16 +OD_KEEPNEVER_ITEM = 17 def optinteract(options): """Let the user interact with the options dialog""" @@ -72,12 +75,19 @@ def optinteract(options): SetDialogItemText(htext, options['type']) d.SetDialogDefaultItem(OD_OK_ITEM) d.SetDialogCancelItem(OD_CANCEL_ITEM) - while 1: for name in opt_dialog_dict.keys(): num = opt_dialog_dict[name] ctl = d.GetDialogItemAsControl(num) ctl.SetControlValue(options[name]) + ctl = d.GetDialogItemAsControl(OD_KEEPALWAYS_ITEM) + ctl.SetControlValue(options['keep_console'] == 3) + ctl = d.GetDialogItemAsControl(OD_KEEPOUTPUT_ITEM) + ctl.SetControlValue(options['keep_console'] == 1) + ctl = d.GetDialogItemAsControl(OD_KEEPERROR_ITEM) + ctl.SetControlValue(options['keep_console'] == 2) + ctl = d.GetDialogItemAsControl(OD_KEEPNEVER_ITEM) + ctl.SetControlValue(options['keep_console'] == 0) n = ModalDialog(None) if n == OD_OK_ITEM: htext = d.GetDialogItemAsControl(OD_CREATOR_ITEM) @@ -94,6 +104,14 @@ def optinteract(options): return elif n in (OD_CREATOR_ITEM, OD_TYPE_ITEM): pass + elif n == OD_KEEPALWAYS_ITEM: + options['keep_console'] = 3; + elif n == OD_KEEPOUTPUT_ITEM: + options['keep_console'] = 1; + elif n == OD_KEEPERROR_ITEM: + options['keep_console'] = 2; + elif n == OD_KEEPNEVER_ITEM: + options['keep_console'] = 0; elif n == OD_HELP_ITEM: onoff = Help.HMGetBalloons() Help.HMSetBalloons(not onoff) diff --git a/Mac/scripts/EditPythonPrefs.rsrc b/Mac/scripts/EditPythonPrefs.rsrc index f4b893f683e9edfb2bd844b373d6f3604e49bc73..cc35df240448ead911067e12b1430736fa81a3e2 100644 GIT binary patch delta 606 zc-mX!_Qq|34U;n0L^~}uMOFp|1=fvuGJKo!gg5ePFsm>~FaQB#KErXwW=2L9CVy`z zpM$ZP!Ig#0IWaFeHD_`!-_gmB1X|e`4S^EQlRNpfSzUpwu*p05Raql|tgOk8`L*kB zFvu{xV3@$h=9p8SSXm4*is1%BAHxeqCN|#CyyDcR=?D;)FK72lUNw$F^Vv}6aXt=lmYT|U_1tPhK~&5K<7I! zy*xD8Qy?S^sG5UOlwoRzs7q>EVrfo^LRw}{szP#6YGO%#krflv3=T$Jpc)|*H6@h= zsa6a~ppk`vk?|i;ecj}2-auwa2Byi0LgJHogghn**{HH0sl>^i>?x!?`GyeBqI(0U9Q0P3P?&Ygfl*1e9rWNMVOI+5#mFjjRssmM#^MC;h4!2c)3JC5|9{V zU|?cpJKbr+Qa9OHae_!jN=`b^jjMt~f|P+e4`n8oBu&1q*d!(22sY~f|NjgOTn8b> zg4j~mCl@OPG0Fa)d|XMvT7iLA6{b#sfxjEX&d3F^1#%I3~wu4F(y8R}5XO+FCVy`zpMx=*!Ig#0IWaFeHD~f}xezvn z4?sc2$)fV|tSms5=wwTI>B$scdqs;slY*g2sjK}-V5lLeI(tQi;tSHk2J7=$=s idK4H$@