diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1996-02-21 16:46:57 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1996-02-21 16:46:57 (GMT) |
commit | a4b7e14df87e0a39e06d5655ac29cb71cc052721 (patch) | |
tree | 572705439d12bf0842e004dc91bb08ca32523b00 /Mac | |
parent | 532e3c2bf61d964a34af054f7c270d0322682eac (diff) | |
download | cpython-a4b7e14df87e0a39e06d5655ac29cb71cc052721.zip cpython-a4b7e14df87e0a39e06d5655ac29cb71cc052721.tar.gz cpython-a4b7e14df87e0a39e06d5655ac29cb71cc052721.tar.bz2 |
Store default startup options in preference file or
app.
Diffstat (limited to 'Mac')
-rw-r--r-- | Mac/Include/pythonresources.h | 11 | ||||
-rw-r--r-- | Mac/Python/macgetpath.c | 34 | ||||
-rw-r--r-- | Mac/Python/macmain.c | 25 |
3 files changed, 66 insertions, 4 deletions
diff --git a/Mac/Include/pythonresources.h b/Mac/Include/pythonresources.h index 4b353c5..ca00a23 100644 --- a/Mac/Include/pythonresources.h +++ b/Mac/Include/pythonresources.h @@ -65,3 +65,14 @@ /* The alis resource for locating the python home directory */ #define PYTHONHOME_ID 128 + +/* The Python options resource and offset of its members */ +#define PYTHONOPTIONS_ID 128 +#define POPT_INSPECT 0 +#define POPT_VERBOSE 1 +#define POPT_SUPPRESS 2 +#define POPT_UNBUFFERED 3 +#define POPT_DEBUGGING 4 +#define POPT_KEEPNORM 5 +#define POPT_KEEPERR 6 + diff --git a/Mac/Python/macgetpath.c b/Mac/Python/macgetpath.c index 5e528f7..b782736 100644 --- a/Mac/Python/macgetpath.c +++ b/Mac/Python/macgetpath.c @@ -263,3 +263,37 @@ out: } #endif /* !USE_BUILTIN_PATH */ +void +PyMac_PreferenceOptions(int *inspect, int *verbose, int *suppress_print, + int *unbuffered, int *debugging, int *keep_normal, + int *keep_error) +{ + short oldrh, prefrh; + Handle handle; + int size; + char *p; + + + oldrh = CurResFile(); + prefrh = PyMac_OpenPrefFile(); + handle = GetResource('Popt', PYTHONOPTIONS_ID); + if ( handle == NULL ) { + return; + } + HLock(handle); + size = GetHandleSize(handle); + p = (char *)*handle; + + if ( size > POPT_INSPECT ) *inspect = p[POPT_INSPECT]; + if ( size > POPT_VERBOSE ) *verbose = p[POPT_VERBOSE]; + if ( size > POPT_SUPPRESS ) *suppress_print = p[POPT_SUPPRESS]; + if ( size > POPT_UNBUFFERED ) *unbuffered = p[POPT_UNBUFFERED]; + if ( size > POPT_DEBUGGING ) *debugging = p[POPT_DEBUGGING]; + if ( size > POPT_KEEPNORM ) *keep_normal = p[POPT_KEEPNORM]; + if ( size > POPT_KEEPERR ) *keep_error = p[POPT_KEEPERR]; + + HUnlock(handle); + + CloseResFile(prefrh); + UseResFile(oldrh); +} diff --git a/Mac/Python/macmain.c b/Mac/Python/macmain.c index f6b1dee..ecaa018 100644 --- a/Mac/Python/macmain.c +++ b/Mac/Python/macmain.c @@ -178,6 +178,12 @@ PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print, DialogPtr dialog; Rect rect; + /* Default-defaults: */ + *keep_error = 1; + /* Get default settings from our preference file */ + PyMac_PreferenceOptions(&inspect, &Py_VerboseFlag, &Py_SuppressPrintingFlag, + &unbuffered, &Py_DebugFlag, &keep_normal, &keep_error); + /* If option is pressed override these */ GetKeys(rmap); map = (unsigned char *)rmap; if ( ( map[0x3a>>3] & (1<<(0x3a&7)) ) == 0 ) /* option key is 3a */ @@ -189,9 +195,20 @@ PyMac_InteractiveOptions(int *inspect, int *verbose, int *suppress_print, return; } - /* Set keep-open-on-error */ - GetDialogItem(dialog, OPT_KEEPERROR, &type, (Handle *)&handle, &rect); - SetCtlValue(handle, *keep_error); + /* Set default values */ +#define SET_OPT_ITEM(num, var) \ + GetDialogItem(dialog, (num), &type, (Handle *)&handle, &rect); \ + SetCtlValue(handle, (short)*(var)); + + SET_OPT_ITEM(OPT_INSPECT, inspect); + SET_OPT_ITEM(OPT_VERBOSE, verbose); + SET_OPT_ITEM(OPT_SUPPRESS, suppress_print); + 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); + +#undef SET_OPT_ITEM while (1) { handle = NULL; @@ -310,7 +327,7 @@ PyMac_Exit(status) if (keep) { SIOUXSettings.standalone = 1; SIOUXSettings.autocloseonquit = 0; - SIOUXSetTitle("\pÇterminatedÈ"); + SIOUXSetTitle("\p«terminated»"); } else SIOUXSettings.autocloseonquit = 1; |