annotate Mac/Python/macglue.c @ 21283:d4907cdcc299 legacy-trunk

Use an immutable tuple for __slots instead of a mutable list Bump version number
author Andrew M. Kuchling <amk@amk.ca>
date Fri, 07 Dec 2001 14:22:13 +0000
parents ed3dce17fc79
children 848f6988829f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2224
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
1 /***********************************************************
5079
d6b292a33cfe Added/updated copyright notices
Jack Jansen <jack.jansen@cwi.nl>
parents: 4522
diff changeset
2 Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
2224
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
3 The Netherlands.
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
4
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
5 All Rights Reserved
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
6
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
7 Permission to use, copy, modify, and distribute this software and its
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
8 documentation for any purpose and without fee is hereby granted,
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
9 provided that the above copyright notice appear in all copies and that
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
10 both that copyright notice and this permission notice appear in
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
11 supporting documentation, and that the names of Stichting Mathematisch
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
12 Centrum or CWI not be used in advertising or publicity pertaining to
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
13 distribution of the software without specific, written prior permission.
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
14
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
22
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
23 ******************************************************************/
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24
4024
53d511c0029f Fixed command-. handling
Jack Jansen <jack.jansen@cwi.nl>
parents: 4018
diff changeset
25
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 #include "Python.h"
2337
71e60871c681 ported to Think C
Guido van Rossum <guido@python.org>
parents: 2333
diff changeset
27
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28 #include "macglue.h"
2350
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
29 #include "marshal.h"
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
30 #include "import.h"
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
31 #include "importdl.h"
17862
97ece9321c53 Merged mactoolboxglue.c into macglue.c. A later step will be to separate out
Jack Jansen <jack.jansen@cwi.nl>
parents: 17814
diff changeset
32 #include "pymactoolbox.h"
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
34 #include "pythonresources.h"
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
35
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
36 #ifdef WITHOUT_FRAMEWORKS
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
37 #include <OSUtils.h> /* for Set(Current)A5 */
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
38 #include <Files.h>
2312
40aec48cd1e2 Added PyMac_GetPythonDir routine which obtains python home directory
Jack Jansen <jack.jansen@cwi.nl>
parents: 2276
diff changeset
39 #include <StandardFile.h>
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
40 #include <Resources.h>
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
41 #include <Memory.h>
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
42 #include <Windows.h>
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
43 #include <Traps.h>
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
44 #include <Processes.h>
2382
6450d8828d2b added applet initialization;
Guido van Rossum <guido@python.org>
parents: 2350
diff changeset
45 #include <Fonts.h>
6450d8828d2b added applet initialization;
Guido van Rossum <guido@python.org>
parents: 2350
diff changeset
46 #include <Menus.h>
2747
e41669a1dea0 Added code to obtain sys.path from a resource
Jack Jansen <jack.jansen@cwi.nl>
parents: 2668
diff changeset
47 #include <TextUtils.h>
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
48 #include <LowMem.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
49 #include <Events.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
50 #else
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
51 #include <Carbon/Carbon.h>
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
52 #endif
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
53
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
54 #if !TARGET_API_MAC_OS8
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
55 /* Unfortunately this call is probably slower... */
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
56 #define LMGetTicks() TickCount()
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
57 #endif
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
58
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
59 #ifdef __MWERKS__
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
60 #include <SIOUX.h>
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
61 extern void SIOUXSetupMenus(void);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
62 extern void SIOUXDoAboutBox(void);
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
63 #endif
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
64 #ifdef USE_GUSI
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
65 /* Functions we redefine because they're in obscure libraries */
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
66 extern void SpinCursor(short x);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
67 extern void RotateCursor(short x);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
68 extern pascal void PLstrcpy(unsigned char *, unsigned char *);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
69 extern pascal int PLstrcmp(unsigned char *, unsigned char *);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
70 extern pascal unsigned char *PLstrrchr(unsigned char *, unsigned char);
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
71
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
72 #endif
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
73
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
74 #ifdef USE_GUSI1
3431
26bec9e22e5d Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents: 3278
diff changeset
75 #include <TFileSpec.h> /* For Path2FSSpec */
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
76 #include <GUSI.h>
3431
26bec9e22e5d Added code to make fsspecs work for gusi-python
Jack Jansen <jack.jansen@cwi.nl>
parents: 3278
diff changeset
77 #endif
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
78
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
79 /* The ID of the Sioux apple menu */
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
80 #define SIOUX_APPLEID 32000
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
81
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
82 #include <signal.h>
2350
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
83 #include <stdio.h>
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
84
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
85 /*
3914
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
86 ** When less than this amount of stackspace is left we
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
87 ** raise a MemoryError.
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
88 */
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
89 #ifndef MINIMUM_STACK_SIZE
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
90 #define MINIMUM_STACK_SIZE 8192
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
91 #endif
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
92
16437
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
93 #if TARGET_API_MAC_CARBON
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
94 /*
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
95 ** On MacOSX StackSpace() lies: it gives the distance from heap end to stack pointer,
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
96 ** but the stack cannot grow that far due to rlimit values. We cannot get at this value
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
97 ** from Carbon, so we set a maximum to the stack here that is based on the default
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
98 ** stack limit of 512K.
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
99 */
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
100 #define MAXIMUM_STACK_SIZE (256*1024)
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
101 #endif
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
102
3914
524cf501c851 - Minimum stacksize is now 8K for PPC, 4K for 68K
Jack Jansen <jack.jansen@cwi.nl>
parents: 3786
diff changeset
103 /*
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
104 ** We have to be careful, since we can't handle
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
105 ** things like updates (and they'll keep coming back if we don't
2443
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
106 ** handle them). Note that we don't know who has windows open, so
2dcf7538347a Under MW also be more conservative about events to request
Jack Jansen <jack.jansen@cwi.nl>
parents: 2429
diff changeset
107 ** even handing updates off to SIOUX under MW isn't going to work.
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
108 */
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
109 #define MAINLOOP_EVENTMASK (mDownMask|keyDownMask|osMask|activMask)
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
110
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
111 #include <signal.h>
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
112
2224
32435d33f34a cosmetics: copyright, comments
Guido van Rossum <guido@python.org>
parents: 2209
diff changeset
113 /* XXX We should include Errors.h here, but it has a name conflict
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
114 ** with the python errors.h. */
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
115 #define fnfErr -43
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
116
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
117 /* Interrupt code variables: */
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
118 static int interrupted; /* Set to true when cmd-. seen */
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12855
diff changeset
119 static RETSIGTYPE intcatcher(int);
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
120
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
121 #if !TARGET_API_MAC_OSX
13542
ddd6138c9e6f ANSIfication step 1: get rid of Py_PROTO and Py_FPROTO.
Jack Jansen <jack.jansen@cwi.nl>
parents: 12855
diff changeset
122 static int PyMac_Yield(void);
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
123 #endif
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
124
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
125 /*
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
126 ** These are the real scheduling parameters that control what we check
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
127 ** in the event loop, and how often we check. The values are initialized
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
128 ** from pyMac_SchedParamStruct.
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
129 */
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
130
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
131 struct real_sched_param_struct {
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
132 int check_interrupt; /* if true check for command-dot */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
133 int process_events; /* if nonzero enable evt processing, this mask */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
134 int besocial; /* if nonzero be a little social with CPU */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
135 unsigned long check_interval; /* how often to check, in ticks */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
136 unsigned long bg_yield; /* yield so long when in background */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
137 /* these are computed from previous and clock and such */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
138 int enabled; /* check_interrupt OR process_event OR yield */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
139 unsigned long next_check; /* when to check/yield next, in ticks */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
140 };
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
141
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
142 static struct real_sched_param_struct schedparams =
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
143 { 1, MAINLOOP_EVENTMASK, 1, 15, 15, 1, 0};
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
144
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
145 /*
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
146 ** Workaround for sioux/gusi combo: set when we are exiting
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
147 */
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
148 int PyMac_ConsoleIsDead;
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
149
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
150 /*
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
151 ** Sioux menu bar, saved early so we can restore it
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
152 */
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
153 static MenuBarHandle sioux_mbar;
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
154
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
155 /*
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
156 ** Some stuff for our GetDirectory and PromptGetFile routines
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
157 */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
158 struct hook_args {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
159 int selectcur_hit; /* Set to true when "select current" selected */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
160 char *prompt; /* The prompt */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
161 };
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
162 #if !TARGET_API_MAC_OS8
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
163 /* The StandardFile hooks don't exist in Carbon. This breaks GetDirectory,
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
164 ** but the macfsn code will replace it by a NavServices version anyway.
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
165 */
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
166 #define myhook_upp NULL
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
167 #else
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
168 static DlgHookYDUPP myhook_upp;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
169 static int upp_inited = 0;
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
170 #endif
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
171
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
172 /*
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
173 ** The python-code event handler
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
174 */
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
175 static PyObject *python_event_handler;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
176
11529
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 8790
diff changeset
177 /*
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 8790
diff changeset
178 ** Set to true if we're appearance-compliant
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 8790
diff changeset
179 */
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 8790
diff changeset
180 int PyMac_AppearanceCompliant;
f83b74273da2 First bits and pieces of appearance support: an init routine, a global flag PyMac_AppearanceCompliant (exported thru MacOS). If USE_APPEARANCE
Jack Jansen <jack.jansen@cwi.nl>
parents: 8790
diff changeset
181
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
182 /* Given an FSSpec, return the FSSpec of the parent folder */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
183
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
184 static OSErr
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
185 get_folder_parent (FSSpec * fss, FSSpec * parent)
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
186 {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
187 CInfoPBRec rec;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
188 short err;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
189
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
190 * parent = * fss;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
191 rec.hFileInfo.ioNamePtr = parent->name;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
192 rec.hFileInfo.ioVRefNum = parent->vRefNum;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
193 rec.hFileInfo.ioDirID = parent->parID;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
194 rec.hFileInfo.ioFDirIndex = -1;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
195 rec.hFileInfo.ioFVersNum = 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
196 if (err = PBGetCatInfoSync (& rec))
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
197 return err;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
198 parent->parID = rec.dirInfo.ioDrParID;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
199 /* parent->name[0] = 0; */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
200 return 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
201 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
202
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
203 /* Given an FSSpec return a full, colon-separated pathname */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
204
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
205 OSErr
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
206 PyMac_GetFullPathname (FSSpec *fss, char *buf, int length)
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
207 {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
208 short err;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
209 FSSpec fss_parent, fss_current;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
210 char tmpbuf[1024];
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
211 int plen;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
212
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
213 fss_current = *fss;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
214 plen = fss_current.name[0];
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
215 if ( plen+2 > length ) {
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
216 *buf = 0;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
217 return errFSNameTooLong;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
218 }
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
219 memcpy(buf, &fss_current.name[1], plen);
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
220 buf[plen] = 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
221 /* Special case for disk names */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
222 if ( fss_current.parID <= 1 ) {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
223 buf[plen++] = ':';
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
224 buf[plen] = 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
225 return 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
226 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
227 while (fss_current.parID > 1) {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
228 /* Get parent folder name */
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
229 if (err = get_folder_parent(&fss_current, &fss_parent)) {
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
230 *buf = 0;
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
231 return err;
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
232 }
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
233 fss_current = fss_parent;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
234 /* Prepend path component just found to buf */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
235 plen = fss_current.name[0];
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
236 if (strlen(buf) + plen + 1 > 1024) {
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
237 /* Oops... Not enough space (shouldn't happen) */
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
238 *buf = 0;
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
239 return errFSNameTooLong;
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
240 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
241 memcpy(tmpbuf, &fss_current.name[1], plen);
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
242 tmpbuf[plen] = ':';
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
243 strcpy(&tmpbuf[plen+1], buf);
19850
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
244 if ( strlen(tmpbuf) > length ) {
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
245 *buf = 0;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
246 return errFSNameTooLong;
2b581f4c69b4 Implemented PyMac_GetFullPathname for MacPython.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19641
diff changeset
247 }
17866
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
248 strcpy(buf, tmpbuf);
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
249 }
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
250 return 0;
042dca1d4526 Moved PyMac_GetFullPath from macgetargv.c to macglue.c. It should
Jack Jansen <jack.jansen@cwi.nl>
parents: 17862
diff changeset
251 }
13701
c68003efb796 Added PyMac_getscript() which returns the pythonic name of the current script. Not ideal and not complete, but good enough for the time being. Idea and most of the code by Fredrik Lund.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13608
diff changeset
252
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
253 #ifdef USE_GUSI1
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
254 /*
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
255 ** GUSI (1.6.0 and earlier, at the least) do not set the MacOS idea of
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
256 ** the working directory. Hence, we call this routine after each call
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
257 ** to chdir() to rectify things.
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
258 */
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
259 void
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
260 PyMac_FixGUSIcd()
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
261 {
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
262 WDPBRec pb;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
263 FSSpec curdirfss;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
264
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
265 if ( Path2FSSpec(":x", &curdirfss) != noErr )
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
266 return;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
267
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
268 /* Set MacOS "working directory" */
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
269 pb.ioNamePtr= "\p";
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
270 pb.ioVRefNum= curdirfss.vRefNum;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
271 pb.ioWDDirID= curdirfss.parID;
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
272 if (PBHSetVolSync(&pb) != noErr)
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
273 return;
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
274 }
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
275 #endif
4013
aa9548885b3f Dummy SpinCursor() if __CFM68K__ is defined
Jack Jansen <jack.jansen@cwi.nl>
parents: 3914
diff changeset
276
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
277 #ifdef USE_GUSI
4238
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
278 /*
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
279 ** SpinCursor (needed by GUSI) drags in heaps of stuff, so we
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
280 ** provide a dummy here.
6c86d9136c09 - Put all options in a struct
Jack Jansen <jack.jansen@cwi.nl>
parents: 4215
diff changeset
281 */
4018
Jack Jansen <jack.jansen@cwi.nl>
parents: 4013
diff changeset
282 void SpinCursor(short x) { /* Dummy */ }
7438
cd11690cb14b - Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents: 6461
diff changeset
283 void RotateCursor(short x) { /* Dummy */ }
4018
Jack Jansen <jack.jansen@cwi.nl>
parents: 4013
diff changeset
284
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
285 /*
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
286 ** Replacement GUSI Spin function
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
287 */
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
288 #ifdef USE_GUSI1
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
289 static int
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
290 PyMac_GUSISpin(spin_msg msg, long arg)
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
291 {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
292 static Boolean inForeground = true;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
293 int maxsleep = 6; /* 6 ticks is "normal" sleeptime */
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
294
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
295 if (PyMac_ConsoleIsDead) return 0;
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
296 #if 0
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
297 if (inForeground)
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
298 SpinCursor(msg == SP_AUTO_SPIN ? short(arg) : 1);
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
299 #endif
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
300
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
301
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
302 if ( msg == SP_AUTO_SPIN )
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
303 maxsleep = 0;
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
304 if ( msg==SP_SLEEP||msg==SP_SELECT ) {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
305 maxsleep = arg;
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
306 /*
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
307 ** We force-scan for interrupts. Not pretty, but otherwise
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
308 ** a program may hang in select or sleep forever.
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
309 */
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
310 scan_event_queue(1);
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
311 }
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
312 if (interrupted) {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
313 interrupted = 0;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
314 return -1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
315 }
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
316
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
317 PyMac_DoYield(maxsleep, 0); /* XXXX or is it safe to call python here? */
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
318
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
319 return 0;
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
320 }
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
321
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
322 void
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
323 PyMac_SetGUSISpin() {
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
324 GUSISetHook(GUSI_SpinHook, (GUSIHook)PyMac_GUSISpin);
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
325 }
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
326 #endif
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
327
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
328 /* Called at exit() time thru atexit(), to stop event processing */
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
329 void
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
330 PyMac_StopGUSISpin() {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
331 PyMac_ConsoleIsDead = 1;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
332 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
333
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
334 #if TARGET_API_MAC_OS8
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
335 /*
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
336 ** Replacement routines for the PLstr... functions so we don't need
15825
4328ffe647bf Disabled a few other routines that are available in CarbonLib.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15786
diff changeset
337 ** StdCLib.
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
338 */
11548
c042e4140f1e Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
339 pascal void
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
340 PLstrcpy(unsigned char *to, unsigned char *fr)
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
341 {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
342 memcpy(to, fr, fr[0]+1);
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
343 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
344
11548
c042e4140f1e Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
345 pascal int
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
346 PLstrcmp(unsigned char *s1, unsigned char *s2)
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
347 {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
348 int res;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
349 int l = s1[0] < s2[0] ? s1[0] : s2[0];
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
350
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
351 res = memcmp(s1+1, s2+1, l);
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
352 if ( res != 0 )
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
353 return res;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
354
8790
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
355 if ( s1[0] < s2[0] )
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
356 return -1;
8790
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
357 else if ( s1[0] > s2[0] )
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
358 return 1;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
359 else
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
360 return 0;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
361 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
362
11548
c042e4140f1e Oops, PLstring funcs should be "pascal". Funny this never caused problems before...
Jack Jansen <jack.jansen@cwi.nl>
parents: 11529
diff changeset
363 pascal unsigned char *
13547
db963a615bc9 ANSIfication step 2: make sure all needed prototypes are available, and all needed
Jack Jansen <jack.jansen@cwi.nl>
parents: 13542
diff changeset
364 PLstrrchr(unsigned char *str, unsigned char chr)
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
365 {
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
366 unsigned char *ptr = 0;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
367 unsigned char *p;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
368
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
369 for(p=str+1; p<str+str[0]; p++)
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
370 if ( *p == chr )
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
371 ptr = p;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
372 return ptr;
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
373 }
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
374
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
375 #endif /* TARGET_API_MAC_OS8 */
5617
70855574516b - Added Py_GetProgramFullPath
Jack Jansen <jack.jansen@cwi.nl>
parents: 5270
diff changeset
376 #endif /* USE_GUSI */
3433
578ca302a598 Replaced previous gusi-chdir() fix by a call to PyMac_FixGUSIcd()
Jack Jansen <jack.jansen@cwi.nl>
parents: 3431
diff changeset
377
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
378
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
379 /* Convert C to Pascal string. Returns pointer to static buffer. */
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
380 unsigned char *
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
381 Pstring(char *str)
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
382 {
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
383 static Str255 buf;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
384 int len;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
385
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
386 len = strlen(str);
2209
4053d4cb50e0 renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents: 2183
diff changeset
387 if (len > 255)
4053d4cb50e0 renamed Get routines to PyMac_Get; added macfs to config.c
Guido van Rossum <guido@python.org>
parents: 2183
diff changeset
388 len = 255;
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
389 buf[0] = (unsigned char)len;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
390 strncpy((char *)buf+1, str, len);
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
391 return buf;
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
392 }
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
393
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
394 #if TARGET_API_MAC_OS8
15529
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
395 void
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
396 c2pstrcpy(unsigned char *dst, const char *src)
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
397 {
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
398 int len;
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
399
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
400 len = strlen(src);
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
401 if ( len > 255 ) len = 255;
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
402 strncpy((char *)dst+1, src, len);
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
403 dst[0] = len;
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
404 }
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
405 #endif /* TARGET_API_MAC_OS8 */
15529
a93d79da4f8c Added a c2pstrcpy() function.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14476
diff changeset
406
3786
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
407 #ifdef USE_STACKCHECK
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
408 /* Check for stack overflow */
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
409 int
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
410 PyOS_CheckStack()
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
411 {
14197
2787e93817c6 Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13701
diff changeset
412 char here;
2787e93817c6 Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13701
diff changeset
413 static char *sentinel = 0;
14476
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
414 static PyThreadState *thread_for_sentinel = 0;
3786
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
415
16437
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
416 if ( sentinel == 0 ) {
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
417 unsigned long stackspace = StackSpace();
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
418
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
419 #ifdef MAXIMUM_STACK_SIZE
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
420 /* See the comment at the definition */
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
421 if ( stackspace > MAXIMUM_STACK_SIZE )
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
422 stackspace = MAXIMUM_STACK_SIZE;
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
423 #endif
679f826b24ca On MacOSX StackSpace() may lie because it doesn't know about the stack rlimit. For now we set a hard limit of 256K (default rlimit is 512K).
Jack Jansen <jack.jansen@cwi.nl>
parents: 15839
diff changeset
424 sentinel = &here - stackspace + MINIMUM_STACK_SIZE;
14197
2787e93817c6 Cheaper implementation of PyOS_CheckStack: only call StackSpace once and keep a sentinel in a static variable.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13701
diff changeset
425 }
14476
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
426 if ( thread_for_sentinel == 0 ) {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
427 thread_for_sentinel = PyThreadState_Get();
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
428 }
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
429 if ( &here < sentinel ) {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
430 if (thread_for_sentinel == PyThreadState_Get()) {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
431 return -1;
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
432 #if 0
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
433 } else {
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
434 /* Else we are unsure... */
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
435 fprintf(stderr, "Stackcheck in other thread (was %x now %x)\n", thread_for_sentinel,PyThreadState_Get());
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
436 #endif
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
437 }
71456782d8fd PyOS_CheckStack now understands multiple threads. Other threads are not stack-checked, but at least they don't appear to always be out of stack.
Jack Jansen <jack.jansen@cwi.nl>
parents: 14197
diff changeset
438 }
3786
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
439 return 0;
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
440 }
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
441 #endif /* USE_STACKCHECK */
718c8af7be2a Added PyOS_CheckStack() function which returns -1 when we are running
Jack Jansen <jack.jansen@cwi.nl>
parents: 3655
diff changeset
442
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
443 #if !TARGET_API_MAC_OSX
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
444 /* The catcher routine (which may not be used for all compilers) */
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
445 static RETSIGTYPE
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
446 intcatcher(sig)
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
447 int sig;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
448 {
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
449 interrupted = 1;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
450 signal(SIGINT, intcatcher);
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
451 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
452
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
453 void
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
454 PyOS_InitInterrupts()
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
455 {
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
456 if (signal(SIGINT, SIG_IGN) != SIG_IGN)
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
457 signal(SIGINT, intcatcher);
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
458 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
459
5962
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
460 void
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
461 PyOS_FiniInterrupts()
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
462 {
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
463 }
23e014839ab0 Added (dummy) PyOS_FiniInterrupts
Jack Jansen <jack.jansen@cwi.nl>
parents: 5744
diff changeset
464
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
465 /* Check whether we are in the foreground */
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
466 static int
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
467 PyMac_InForeground(void)
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
468 {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
469 static ProcessSerialNumber ours;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
470 static inited;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
471 ProcessSerialNumber curfg;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
472 Boolean eq;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
473
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
474 if ( inited == 0 ) {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
475 (void)GetCurrentProcess(&ours);
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
476 inited = 1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
477 }
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
478 if ( GetFrontProcess(&curfg) < 0 )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
479 eq = 1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
480 else if ( SameProcess(&ours, &curfg, &eq) < 0 )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
481 eq = 1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
482 return (int)eq;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
483 }
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
484
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
485 /*
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
486 ** This routine scans the event queue looking for cmd-.
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
487 */
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
488 static void
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
489 scan_event_queue(force)
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
490 int force;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
491 {
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
492 #if !TARGET_API_MAC_OS8
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
493 if ( interrupted || (!schedparams.check_interrupt && !force) )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
494 return;
15839
3b643653e078 Fixed Carbon command-dot handling. There is still a problem, though, and you may have to hit it repeatedly.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15825
diff changeset
495 if ( CheckEventQueueForUserCancel() )
3b643653e078 Fixed Carbon command-dot handling. There is still a problem, though, and you may have to hit it repeatedly.
Jack Jansen <jack.jansen@cwi.nl>
parents: 15825
diff changeset
496 interrupted = 1;
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
497 #else
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
498 register EvQElPtr q;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
499
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
500 if ( interrupted || (!schedparams.check_interrupt && !force) || !PyMac_InForeground() )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
501 return;
7438
cd11690cb14b - Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents: 6461
diff changeset
502 q = (EvQElPtr) LMGetEventQueue()->qHead;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
503
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
504 for (; q; q = (EvQElPtr)q->qLink) {
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
505 if (q->evtQWhat == keyDown &&
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
506 (char)q->evtQMessage == '.' &&
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
507 (q->evtQModifiers & cmdKey) != 0) {
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20949
diff changeset
508 FlushEvents(keyDownMask, 0);
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
509 interrupted = 1;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
510 break;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
511 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
512 }
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
513 #endif
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
514 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
515
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
516 int
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
517 PyErr_CheckSignals()
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
518 {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
519 if (schedparams.enabled) {
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
520 if ( interrupted || (unsigned long)LMGetTicks() > schedparams.next_check ) {
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
521 scan_event_queue(0);
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
522 if (interrupted) {
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
523 interrupted = 0;
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
524 PyErr_SetNone(PyExc_KeyboardInterrupt);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
525 return -1;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
526 }
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
527 if ( PyMac_Yield() < 0)
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
528 return -1;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
529 schedparams.next_check = (unsigned long)LMGetTicks()
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
530 + schedparams.check_interval;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
531 }
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
532 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
533 return 0;
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
534 }
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
535
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
536 int
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
537 PyOS_InterruptOccurred()
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
538 {
20949
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
539 scan_event_queue(0);
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
540 if ( !interrupted )
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
541 return 0;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
542 interrupted = 0;
d27ce8fe43f8 Fixed various problems with command-dot handling (some very old):
Jack Jansen <jack.jansen@cwi.nl>
parents: 20828
diff changeset
543 return 1;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
544 }
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
545 #endif
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
546
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
547 int
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
548 PyMac_SetEventHandler(PyObject *evh)
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
549 {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
550 if ( evh && python_event_handler ) {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
551 PyErr_SetString(PyExc_RuntimeError, "Python event handler already set");
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
552 return 0;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
553 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
554 if ( python_event_handler )
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
555 Py_DECREF(python_event_handler);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
556 if ( evh )
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
557 Py_INCREF(evh);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
558 python_event_handler = evh;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
559 return 1;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
560 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
561
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
562 /*
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
563 ** Handle an event, either one found in the mainloop eventhandler or
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
564 ** one passed back from the python program.
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
565 */
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
566 void
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
567 PyMac_HandleEventIntern(evp)
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
568 EventRecord *evp;
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
569 {
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
570 #if TARGET_API_MAC_OS8
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
571 if ( evp->what == mouseDown ) {
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
572 WindowPtr wp;
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
573
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
574 if ( FindWindow(evp->where, &wp) == inSysWindow ) {
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
575 SystemClick(evp, wp);
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
576 return;
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
577 }
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
578 }
12833
41c0c60dcaf5 Removed (within an #ifdef) Carbon-incompatabilities:
Jack Jansen <jack.jansen@cwi.nl>
parents: 12281
diff changeset
579 #endif
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
580 #ifdef __MWERKS__
3248
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
581 {
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
582 int siouxdidit;
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
583
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
584 /* If SIOUX wants it we're done */
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
585 siouxdidit = SIOUXHandleOneEvent(evp);
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
586 if ( siouxdidit )
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
587 return;
5e101ead1e69 Cosmetic change to event handling.
Jack Jansen <jack.jansen@cwi.nl>
parents: 3052
diff changeset
588 }
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
589 #else
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
590 /* Other compilers are just unlucky... */
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
591 #endif /* !__MWERKS__ */
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
592 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
593
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
594 /*
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
595 ** Handle an event, either through HandleEvent or by passing it to the Python
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
596 ** event handler.
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
597 */
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
598 int
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
599 PyMac_HandleEvent(evp)
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
600 EventRecord *evp;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
601 {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
602 PyObject *rv;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
603
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
604 if ( python_event_handler ) {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
605 rv = PyObject_CallFunction(python_event_handler, "(O&)",
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
606 PyMac_BuildEventRecord, evp);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
607 if ( rv )
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
608 Py_DECREF(rv);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
609 else
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
610 return -1; /* Propagate exception */
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
611 } else {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
612 PyMac_HandleEventIntern(evp);
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
613 }
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
614 return 0;
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
615 }
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
616
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
617 #if !TARGET_API_MAC_OSX
2276
66d6d13df4f8 Added HandleEvent method to macos, so python programs can hand back
Jack Jansen <jack.jansen@cwi.nl>
parents: 2265
diff changeset
618 /*
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
619 ** Yield the CPU to other tasks without processing events.
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
620 */
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
621 int
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
622 PyMac_DoYield(int maxsleep, int maycallpython)
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
623 {
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
624 EventRecord ev;
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
625 int gotone;
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
626 long latest_time_ready;
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
627 static int in_here = 0;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
628
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
629 in_here++;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
630
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
631 /*
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
632 ** Check which of the eventloop cases we have:
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
633 ** - process events
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
634 ** - don't process events but do yield
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
635 ** - do neither
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
636 */
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
637 if( in_here > 1 || !schedparams.process_events ||
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
638 (python_event_handler && !maycallpython) ) {
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
639 if ( maxsleep >= 0 ) {
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
640 #if TARGET_API_MAC_OS8
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
641 SystemTask();
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
642 #else
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
643 int xxx = 0;
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
644 #endif
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
645 }
4197
b70baba1c789 - Fixed PyMac_DoYield:
Jack Jansen <jack.jansen@cwi.nl>
parents: 4024
diff changeset
646 } else {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
647 latest_time_ready = LMGetTicks() + maxsleep;
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
648 do {
6162
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
649 /* XXXX Hack by Jack.
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
650 ** In time.sleep() you can click to another application
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
651 ** once only. If you come back to Python you cannot get away
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
652 ** again.
9183a3c6b85f Handle systemclicks ourselves, in stead of passing them to Sioux. This
Jack Jansen <jack.jansen@cwi.nl>
parents: 5962
diff changeset
653 **/
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
654 gotone = WaitNextEvent(schedparams.process_events, &ev, maxsleep, NULL);
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
655 /* Get out quickly if nothing interesting is happening */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
656 if ( !gotone || ev.what == nullEvent )
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
657 break;
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
658 if ( PyMac_HandleEvent(&ev) < 0 ) {
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
659 in_here--;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
660 return -1;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
661 }
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
662 maxsleep = latest_time_ready - LMGetTicks();
12281
51c0c3b6d919 Started on GUSI2 and threading support.
Jack Jansen <jack.jansen@cwi.nl>
parents: 11676
diff changeset
663 } while ( maxsleep > 0 );
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
664 }
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
665 in_here--;
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
666 return 0;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
667 }
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
668
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
669 /*
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
670 ** Process events and/or yield the CPU to other tasks if opportune
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
671 */
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
672 int
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
673 PyMac_Yield() {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
674 unsigned long maxsleep;
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
675
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
676 if( PyMac_InForeground() )
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
677 maxsleep = 0;
2262
03bd79432f06 - Moved interrupt code to macglue.c
Jack Jansen <jack.jansen@cwi.nl>
parents: 2255
diff changeset
678 else
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
679 maxsleep = schedparams.bg_yield;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
680
5744
ea8a0b090908 Added PyMac_SetEventHandler which allows you to replace complete event
Jack Jansen <jack.jansen@cwi.nl>
parents: 5737
diff changeset
681 return PyMac_DoYield(maxsleep, 1);
2251
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
682 }
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
683
e0a3242d5ae7 Added eventhandling in mainloop/busywait routine plus leaving some
Jack Jansen <jack.jansen@cwi.nl>
parents: 2231
diff changeset
684 /*
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
685 ** Return current scheduler parameters
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
686 */
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
687 void
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
688 PyMac_GetSchedParams(PyMacSchedParams *sp)
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
689 {
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
690 sp->check_interrupt = schedparams.check_interrupt;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
691 sp->process_events = schedparams.process_events;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
692 sp->besocial = schedparams.besocial;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
693 sp->check_interval = schedparams.check_interval / 60.0;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
694 sp->bg_yield = schedparams.bg_yield / 60.0;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
695 }
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
696
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
697 /*
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
698 ** Set current scheduler parameters
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
699 */
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
700 void
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
701 PyMac_SetSchedParams(PyMacSchedParams *sp)
2035
ce69742f2e77 New routines:
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
702 {
5711
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
703 schedparams.check_interrupt = sp->check_interrupt;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
704 schedparams.process_events = sp->process_events;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
705 schedparams.besocial = sp->besocial;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
706 schedparams.check_interval = (unsigned long)(sp->check_interval*60);
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
707 schedparams.bg_yield = (unsigned long)(sp->bg_yield*60);
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
708 if ( schedparams.check_interrupt || schedparams.process_events ||
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
709 schedparams.besocial )
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
710 schedparams.enabled = 1;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
711 else
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
712 schedparams.enabled = 0;
fb170ce82951 Removed old scheduler parameterizing calls and replaced with something
Jack Jansen <jack.jansen@cwi.nl>
parents: 5617
diff changeset
713 schedparams.next_check = 0; /* Check immedeately */
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
714 }
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
715
2350
a2054933775b Added support for loading pyc code from a resource.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2337
diff changeset
716 /*
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
717 ** Install our menu bar.
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
718 */
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
719 void
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
720 PyMac_InitMenuBar()
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
721 {
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
722 MenuHandle applemenu;
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
723
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
724 if ( sioux_mbar ) return;
20828
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
725 #if 0
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
726 /* This code does not seem to work anymore: apparently
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
727 ** we now always have a menubar (since MacOS9?).
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
728 ** So we simply always setup the Sioux menus here.
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
729 */
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
730 if ( (sioux_mbar=GetMenuBar()) == NULL ) {
20828
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
731 #else
21113
ed3dce17fc79 Merged changes made on r22b2-branch between r22b2 and r22b2-mac (the
Jack Jansen <jack.jansen@cwi.nl>
parents: 20949
diff changeset
732 if ( (sioux_mbar=GetMenuBar()) == NULL || GetMenuHandle(SIOUX_APPLEID) == NULL) {
20828
6f259f7bbed8 We always install the Sioux menubar, in stead of only when no menubar
Jack Jansen <jack.jansen@cwi.nl>
parents: 19850
diff changeset
733 #endif
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
734 /* Sioux menu not installed yet. Do so */
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
735 SIOUXSetupMenus();
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
736 if ( (sioux_mbar=GetMenuBar()) == NULL )
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
737 return;
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
738 }
5270
de9d0c5249b0 Changed the few old routine names still used to the new ones
Jack Jansen <jack.jansen@cwi.nl>
parents: 5153
diff changeset
739 if ( (applemenu=GetMenuHandle(SIOUX_APPLEID)) == NULL ) return;
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
740 SetMenuItemText(applemenu, 1, "\pAbout Python...");
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
741 }
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
742
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
743 /*
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
744 ** Restore sioux menu bar
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
745 */
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
746 void
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
747 PyMac_RestoreMenuBar()
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
748 {
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
749 #if 1
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
750 /* This doesn't seem to work anymore? Or only for Carbon? */
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
751 MenuBarHandle curmenubar;
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
752
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
753 curmenubar = GetMenuBar();
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
754 if ( sioux_mbar ) {
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
755 SetMenuBar(sioux_mbar);
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
756 DrawMenuBar();
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
757 } else {
7438
cd11690cb14b - Universal Headers 3 mods
Jack Jansen <jack.jansen@cwi.nl>
parents: 6461
diff changeset
758 PyMac_InitMenuBar();
16647
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
759 DrawMenuBar();
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
760 }
728c11562187 More changes to attempt to get the menubar back on exit. Without success:-(
Jack Jansen <jack.jansen@cwi.nl>
parents: 16557
diff changeset
761 #endif
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
762 }
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
763
17629
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
764 void
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
765 PyMac_RaiseConsoleWindow()
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
766 {
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
767 /* Note: this is a hack. SIOUXTextWindow is SIOUX's internal structure
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
768 ** and we happen to know that the first entry is the window pointer.
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
769 */
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
770 extern WindowRef *SIOUXTextWindow;
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
771
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
772 if ( SIOUXTextWindow == NULL || *SIOUXTextWindow == NULL )
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
773 return;
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
774 if ( FrontWindow() != *SIOUXTextWindow )
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
775 BringToFront(*SIOUXTextWindow);
a9485d404f05 - Raise console window on input. Fixes Carbon hang.
Jack Jansen <jack.jansen@cwi.nl>
parents: 16647
diff changeset
776 }
5732
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
777
f027dd0a85e4 - Restore SIOUX menubar just before exiting, if the console window is kept
Jack Jansen <jack.jansen@cwi.nl>
parents: 5711
diff changeset
778 /*
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
779 ** Our replacement about box
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
780 */
8790
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
781
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
782 #include "patchlevel.h"
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
783
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
784 void
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
785 SIOUXDoAboutBox(void)
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
786 {
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
787 DialogPtr theDialog;
8790
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
788 WindowPtr theWindow;
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
789 short item;
8790
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
790 short fontID;
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
791
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
792 if( (theDialog = GetNewDialog(ABOUT_ID, NULL, (WindowPtr)-1)) == NULL )
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
793 return;
4325
12c3865aeaa0 Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
794 theWindow = GetDialogWindow(theDialog);
8790
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
795 SetPortWindowPort(theWindow);
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
796 GetFNum("\pPython-Sans", &fontID);
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
797 if (fontID == 0)
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
798 fontID = kFontIDGeneva;
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
799 TextFont(fontID);
1076a028365a New about box, with the version mesage filled in in a text item, and
Jack Jansen <jack.jansen@cwi.nl>
parents: 8665
diff changeset
800 TextSize(9);
19393
0f873d06ac13 PATCHLEVEL is outdated, use PY_VERSION.
Jack Jansen <jack.jansen@cwi.nl>
parents: 19064
diff changeset
801 ParamText(Pstring(PY_VERSION), "\p", "\p", "\p");
4325
12c3865aeaa0 Changed default background yield time to 1 tick
Jack Jansen <jack.jansen@cwi.nl>
parents: 4238
diff changeset
802 ShowWindow(theWindow);
4215
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
803 ModalDialog(NULL, &item);
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
804 DisposeDialog(theDialog);
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
805 }
0410ed3808ee Python about box implemented. Slightly convoluted, since (a) we have
Jack Jansen <jack.jansen@cwi.nl>
parents: 4204
diff changeset
806
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
807 #endif /* !TARGET_API_MAC_OSX */
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
808
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
809 #if TARGET_API_MAC_OS8
5737
d0c6b49d7101 Make imports faster on the Mac, by
Jack Jansen <jack.jansen@cwi.nl>
parents: 5732
diff changeset
810 /*
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
811 ** Helper routine for GetDirectory
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
812 */
2412
75ae104f7e6c ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents: 2403
diff changeset
813 static pascal short
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
814 myhook_proc(short item, DialogPtr theDialog, struct hook_args *dataptr)
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
815 {
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
816 if ( item == sfHookFirstCall && dataptr->prompt) {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
817 Handle prompth;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
818 short type;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
819 Rect rect;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
820
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
821 GetDialogItem(theDialog, PROMPT_ITEM, &type, &prompth, &rect);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
822 if ( prompth )
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
823 SetDialogItemText(prompth, (unsigned char *)dataptr->prompt);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
824 } else
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
825 if ( item == SELECTCUR_ITEM ) {
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
826 item = sfItemCancelButton;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
827 dataptr->selectcur_hit = 1;
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
828 }
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
829 return item;
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
830 }
17814
2211c8995a5f Got the first MacPython module working under MacOSX/MachO (gestalt). Main changes
Jack Jansen <jack.jansen@cwi.nl>
parents: 17813
diff changeset
831
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
832 /*
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
833 ** Ask the user for a directory. I still can't understand
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
834 ** why Apple doesn't provide a standard solution for this...
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
835 */
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
836 int
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
837 PyMac_GetDirectory(dirfss, prompt)
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
838 FSSpec *dirfss;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
839 char *prompt;
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
840 {
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
841 static SFTypeList list = {'fldr', 0, 0, 0};
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
842 static Point where = {-1, -1};
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
843 StandardFileReply reply;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
844 struct hook_args hook_args;
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
845
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
846 if ( !upp_inited ) {
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
847 myhook_upp = NewDlgHookYDProc(myhook_proc);
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
848 upp_inited = 1;
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
849 }
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
850 if ( prompt && *prompt )
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
851 hook_args.prompt = (char *)Pstring(prompt);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
852 else
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
853 hook_args.prompt = NULL;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
854 hook_args.selectcur_hit = 0;
2412
75ae104f7e6c ported to MPW, moved main() here
Guido van Rossum <guido@python.org>
parents: 2403
diff changeset
855 CustomGetFile((FileFilterYDUPP)0, 1, list, &reply, GETDIR_ID, where, myhook_upp,
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
856 NULL, NULL, NULL, (void *)&hook_args);
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
857
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
858 reply.sfFile.name[0] = 0;
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
859 if( FSMakeFSSpec(reply.sfFile.vRefNum, reply.sfFile.parID, reply.sfFile.name, dirfss) )
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
860 return 0;
2988
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
861 return hook_args.selectcur_hit;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
862 }
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
863
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
864 /*
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
865 ** Slightly extended StandardGetFile: accepts a prompt */
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
866 void PyMac_PromptGetFile(short numTypes, ConstSFTypeListPtr typeList,
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
867 StandardFileReply *reply, char *prompt)
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
868 {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
869 static Point where = {-1, -1};
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
870 struct hook_args hook_args;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
871
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
872 if ( !upp_inited ) {
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
873 myhook_upp = NewDlgHookYDProc(myhook_proc);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
874 upp_inited = 1;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
875 }
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
876 if ( prompt && *prompt )
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
877 hook_args.prompt = (char *)Pstring(prompt);
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
878 else
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
879 hook_args.prompt = NULL;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
880 hook_args.selectcur_hit = 0;
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
881 CustomGetFile((FileFilterYDUPP)0, numTypes, typeList, reply, GETFILEPROMPT_ID, where,
2fe9d0371ecd Lots of stuff moved to other files.
Jack Jansen <jack.jansen@cwi.nl>
parents: 2913
diff changeset
882 myhook_upp, NULL, NULL, NULL, (void *)&hook_args);
2403
72c715c004c8 - Added PyMac_GetDirectory call which asks the user to select a
Jack Jansen <jack.jansen@cwi.nl>
parents: 2394
diff changeset
883 }
17813
8cd8741ebec0 Be more sensible about when to use TARGET_API_MAC_OS8 in stead of !TARGET_API_MAC_CARBON. This should greatly facilitate porting stuff to OSX in its MachO/BSD incarnation.
Jack Jansen <jack.jansen@cwi.nl>
parents: 17629
diff changeset
884 #endif /* TARGET_API_MAC_OS8 */
2176
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
885
1e9e74944bb5 - Moved some useful routines from macosmodule.c here
Jack Jansen <jack.jansen@cwi.nl>
parents: 2136
diff changeset
886