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

Skip to content

Commit e229d86

Browse files
committed
Misc Mac mods by Jack. Added libmacic.tex, and these patches:
libmacfs.tex Document NewAliasMinimalFromFullPath libmacos.tex Document SetEventHandler and SchedParams libmacui.tex Document asynchronous event handling libmailbox.tex Removed mime-turds that somehow got in here
1 parent 9918e0c commit e229d86

13 files changed

Lines changed: 379 additions & 97 deletions

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ LIBFILES = lib.tex \
112112
libuser.tex libanydbm.tex librandom.tex libsite.tex libwhichdb.tex \
113113
libbase64.tex libfnmatch.tex libquopri.tex libzlib.tex libsocksvr.tex \
114114
libmailbox.tex libcommands.tex libcmath.tex libni.tex libgzip.tex \
115-
libpprint.tex libcode.tex libmimify.tex libre.tex
115+
libpprint.tex libcode.tex libmimify.tex libre.tex libmacic.tex
116116

117117
# Library document
118118
lib.dvi: $(LIBFILES)

Doc/lib.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
\input{libmacconsole}
196196
\input{libmacdnr}
197197
\input{libmacfs}
198+
\input{libmacic}
198199
\input{libmacos}
199200
\input{libmacostools}
200201
\input{libmactcp}

Doc/lib/lib.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@
195195
\input{libmacconsole}
196196
\input{libmacdnr}
197197
\input{libmacfs}
198+
\input{libmacic}
198199
\input{libmacos}
199200
\input{libmacostools}
200201
\input{libmactcp}

Doc/lib/libmailbox.tex

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ \subsection{Mailbox Objects}
3131
method:
3232

3333
\begin{funcdesc}{next}{}
34-
Return the next message in the mailbox, as a \code{rfc822.Message} object=
35-
=2E
34+
Return the next message in the mailbox, as a \code{rfc822.Message} object.
3635
Depending on the mailbox implementation the \var{fp} attribute of this
37-
object may be a true file object or a class instance simulating a file ob=
38-
ject,
39-
taking care of things like message boundaries if multiple mail messages a=
40-
re
36+
object may be a true file object or a class instance simulating a file object,
37+
taking care of things like message boundaries if multiple mail messages are
4138
contained in a single file, etc.
4239
\end{funcdesc}
40+

Doc/libmacfs.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ \section{Built-in Module \sectcode{macfs}}
8686
locate. Setting \var{create} causes the folder to be created if it
8787
does not exist. Returns a \code{(vrefnum, dirid)} tuple.
8888

89+
\begin{funcdesc}{NewAliasMinimalFromFullPath}{pathname}
90+
Return a minimal alias record object that points to the given file, which
91+
must be specified as a full pathname. This is the only way to create an
92+
alias record pointing to a non-existing file.
93+
8994
The constants for \var{where} and \var{which} can be obtained from the
9095
standard module \var{MACFS}.
9196
\end{funcdesc}
@@ -164,7 +169,9 @@ \subsection{alias objects}
164169
Resolve the alias. If the alias was created as a relative alias you
165170
should pass the file relative to which it is. Return the FSSpec for
166171
the file pointed to and a flag indicating whether the alias object
167-
itself was modified during the search process.
172+
itself was modified during the search process. If the file does
173+
not exist but the path leading up to it does exist a valid fsspec
174+
is returned.
168175
\end{funcdesc}
169176

170177
\begin{funcdesc}{GetInfo}{num}

Doc/libmacic.tex

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
\section{Standard Module \sectcode{ic}}
2+
\bimodindex{ic}
3+
4+
\renewcommand{\indexsubitem}{(in module ic)}
5+
6+
This module provides access to macintosh Internet Config package,
7+
which stores preferences for Internet programs such as mail address,
8+
default homepage, etc. Also, Internet Config contains an elaborate set
9+
of mappings from Macintosh creator/type codes to foreign filename
10+
extensions plus information on how to transfer files (binary, ascii,
11+
etc).
12+
13+
There is a low-level companion module \code{icglue} which provides the
14+
basic ic access functionality. This low-level module is not
15+
documented, but the docstrings of the routines document the parameters
16+
and the routine names are the same as for the Pascal or C API to
17+
Internet Config, so the standard IC programmers documentation can be
18+
used if this module is needed.
19+
20+
The \code{ic} module defines the \code{error} exception and symbolic
21+
names for all error codes IC can produce, see the source for details.
22+
23+
The \code{ic} module defines the following functions:
24+
25+
\begin{funcdesc}{IC}{\optional{signature\, ic}}
26+
Create an internet config object. The signature is a 4-char creator
27+
code of the current application (default \code{'Pyth'}) which may
28+
influence some of ICs settings. The optional \var{ic} argument is a
29+
low-level \code{icinstance} created beforehand, this may be useful if
30+
you want to get preferences from a different config file, etc.
31+
\end{funcdesc}
32+
33+
\begin{funcdesc}{launchurl}{url \optional{\, hint}}
34+
\end{funcdesc}
35+
\begin{funcdesc}{parseurl}{data \optional{\, start\, end\, hint}}
36+
\end{funcdesc}
37+
\begin{funcdesc}{mapfile}{file}
38+
\end{funcdesc}
39+
\begin{funcdesc}{maptypecreator}{type\, creator \optional{\,
40+
filename}}
41+
\end{funcdesc}
42+
\begin{funcdesc}{settypecreator}{file}
43+
These functions are ``shortcuts'' to the methods of the same name,
44+
described below.
45+
\end{funcdesc}
46+
47+
48+
\subsection{IC objects}
49+
50+
IC objects have a mapping interface, hence to obtain the mail address
51+
you simply get \code{ic['MailAddress']}. Assignment also works, and
52+
changes the option in the configuration file.
53+
54+
The module knows about various datatypes, and converts the internal IC
55+
representation to a ``logical'' python datastructure. Running the
56+
\code{ic} module standalone will run a test program that lists all
57+
keys and values in your IC database, this will have to server as
58+
documentation.
59+
60+
If the module does not know how to represent the data it returns an
61+
instance of the \var{ICOpaqueData} type, with the raw data in its
62+
\var{data} attribute. Objects of this type are also acceptable values
63+
for assignment.
64+
65+
Besides the dictionary interface IC objects have the following methods:
66+
67+
\renewcommand{\indexsubitem}{(IC object attribute)}
68+
69+
\begin{funcdesc}{launchurl}{url \optional{\, hint}}
70+
Parse the given URL, lauch the correct application and pass it the
71+
URL. The optional \var{hint} can be a scheme name such as
72+
\code{mailto:}, in which case incomplete URLs are completed with this
73+
scheme (otherwise incomplete URLs are invalid).
74+
\end{funcdesc}
75+
76+
\begin{funcdesc}{parseurl}{data \optional{\, start\, end\, hint}}
77+
Find an URL somewhere in \var{data} and return start position, end
78+
position and the URL. The optional \var{start} and \var{end} can be
79+
used to limit the search, so for instance if a user clicks in a long
80+
textfield you can pass the whole textfield and the click-position in
81+
\var{start} and this routine will return the whole URL in which the
82+
user clicked. \var{Hint} is again an optional scheme used to complete
83+
incomplete URLs.
84+
\end{funcdesc}
85+
86+
\begin{funcdesc}{mapfile}{file}
87+
Return the mapping entry for the given \var{file}, which can be passed
88+
as either a filename or an \var{FSSpec} object, and which need not
89+
exist.
90+
91+
The mapping entry is returned as a tuple \code{(version\, type\,
92+
creator\, postcreator\, flags\, extension\, appname\, postappname\,
93+
mimetype\, entryname)}, where \var{version} is the entry version
94+
number, \var{type} is the 4-char filetype, \var{creator} is the 4-char
95+
creator type, \var{postcreator} is the 4-char creator code of an
96+
optional application to post-process the file after downloading,
97+
\var{flags} are various bits specifying whether to transfer in binary
98+
or ascii and such, \var{extension} is the filename extension for this
99+
file type, \var{appname} is the printable name of the application to
100+
which this file belongs, \var{postappname} is the name of the
101+
postprocessing application, \var{mimetype} is the MIME type of this
102+
file and \var{entryname} is the name of this entry.
103+
\end{funcdesc}
104+
105+
\begin{funcdesc}{maptypecreator}{type\, creator \optional{\,
106+
filename}}
107+
Return the mapping entry for files with given 4-char \var{type} and
108+
\var{creator} codes. The optional \var{filename} may be specified to
109+
further help finding the correct entry (if the creator code is
110+
\code{'????'}, for instance).
111+
112+
The mapping entry is returned in the same format as for \var{mapfile}.
113+
\end{funcdesc}
114+
115+
\begin{funcdesc}{settypecreator}{file}
116+
Given an existing \var{file}, specified either as a filename or as an
117+
\var{FSSpec} record, set its creator and type correctly based on its
118+
extension. The finder is told about the change, so the finder icon
119+
will be updated quickly.
120+
\end{funcdesc}

Doc/libmacos.tex

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,48 +20,35 @@ \section{Built-in Module \sectcode{MacOS}}
2020
module \var{macerrors}.
2121
\end{excdesc}
2222

23-
\begin{funcdesc}{SetHighLevelEventHandler}{handler}
24-
Pass a python function that will be called upon reception of a
25-
high-level event. The previous handler is returned. The handler
26-
function is called with the event as argument.
27-
28-
Note that your event handler is currently only called dependably if
29-
your main event loop is in \var{stdwin}.
30-
\end{funcdesc}
31-
32-
\begin{funcdesc}{AcceptHighLevelEvent}{}
33-
Read a high-level event. The return value is a tuple \code{(sender,
34-
refcon, data)}.
35-
\end{funcdesc}
36-
37-
\begin{funcdesc}{SetScheduleTimes}{fgi\, fgy \optional{\, bgi\, bgy}}
38-
Controls how often the interpreter checks the event queue and how
39-
long it will yield the processor to other processes. \var{fgi}
40-
specifies after how many clicks (one click is one 60th of a second)
41-
the interpreter should check the event queue, and \var{fgy} specifies
42-
for how many clicks the CPU should be yielded when in the
43-
foreground. The optional \var{bgi} and \var{bgy} allow you to specify
44-
different values to use when python runs in the background, otherwise
45-
the background values will be set the the same as the foreground
46-
values. The function returns nothing.
47-
48-
The default values, which are based on minimal empirical testing, are 12, 1, 6
49-
and 2 respectively.
23+
\begin{funcdesc}{SetEventHandler}{handler}
24+
In the inner interpreter loop Python will occasionally check for events,
25+
unless disabled with \var{ScheduleParams}. With this function you
26+
can pass a Python event-handler function that will be called if an event
27+
is available. The event is passed as parameter and the function should return
28+
non-zero if the event has been fully processed, otherwise event processing
29+
continues (by passing the event to the console window package, for instance).
30+
31+
Call SetEventHandler without parameter to clear the event handler. Setting
32+
an eventhandler while one is already set is an error.
5033
\end{funcdesc}
5134

52-
\begin{funcdesc}{EnableAppswitch}{onoff}
53-
Enable or disable the python event loop, based on the value of
54-
\var{onoff}. The old value is returned. If the event loop is disabled
55-
no time is granted to other applications, checking for command-period
56-
is not performed and it is impossible to switch applications. This
57-
should only be used by programs providing their own complete event
58-
loop.
59-
60-
Note that based on the compiler used to build python it is still
61-
possible to loose events even with the python event loop disabled. If
62-
you have a \code{sys.stdout} window its handler will often also look
63-
in the event queue. Making sure nothing is ever printed works around
64-
this.
35+
\begin{funcdesc}{SchedParams}{\optional{doint\, evtmask\, besocial\,
36+
interval\, bgyield}}
37+
Influence the interpreter inner loop event handling. \var{Interval}
38+
specifies how often (in seconds, floating point) the interpreter
39+
should enter the event processing code. When true, \var{doint} causes
40+
interrupt (command-dot) checking to be done. \var{Evtmask} tells the
41+
interpreter to do event processing for events in the mask (redraws,
42+
mouseclicks to switch to other applications, etc). \bar{Besocial}
43+
gives other processes a chance to run. They are granted minimal
44+
runtime when Python is in the foreground and \var{bgyield} seconds per
45+
\var{interval} when Python runs in the background.
46+
47+
All parameters are optional, and default to the current value. The return
48+
value of this function is a tuple with the old values of these options.
49+
Initial defaults are that all processing is enabled, checking is done every
50+
quarter second and the CPU is given up for a quarter second when in the
51+
background.
6552
\end{funcdesc}
6653

6754
\begin{funcdesc}{HandleEvent}{ev}
@@ -70,6 +57,9 @@ \section{Built-in Module \sectcode{MacOS}}
7057
compiler used to build python). This allows python programs that do
7158
their own event handling to still have some command-period and
7259
window-switching capability.
60+
61+
If you attempt to call this function from an event handler set through
62+
\code{SetEventHandler} you will get an exception.
7363
\end{funcdesc}
7464

7565
\begin{funcdesc}{GetErrorString}{errno}

Doc/libmacui.tex

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ \section{Standard module \sectcode{EasyDialogs}}
44

55
The \code{EasyDialogs} module contains some simple dialogs for
66
the Macintosh, modelled after the \code{stdwin} dialogs with similar
7-
names.
7+
names. All routines have an optional parameter \var{id} with which you
8+
can override the DLOG resource used for the dialog, as long as the
9+
item numbers correspond. See the source for details.
810

911
The \code{EasyDialogs} module defines the following functions:
1012

@@ -170,6 +172,29 @@ \subsection{Application objects}
170172
overridden. The default methods take care of dispatching events to
171173
windows and dialogs, handling drags and resizes, Apple Events, events
172174
for non-FrameWork windows, etc.
175+
176+
In general, all event handlers should return 1 if the event is fully
177+
handled and 0 otherwise (because the front window was not a FrameWork
178+
window, for instance). This is needed so that update events and such
179+
can be passed on to other windows like the Sioux console window.
180+
Calling \code{MacOS.HandleEvent} is not allowed within \var{our_dispatch}
181+
or its callees, since this may result in an infinite loop if the
182+
code is called through the python inner-loop event handler.
183+
\end{funcdesc}
184+
185+
\begin{funcdesc}{asyncevents}{onoff}
186+
Call this method with a nonzero parameter to enable
187+
asynchronous event handling. This will tell the inner interpreter loop
188+
to call the application event handler \var{async_dispatch} whenever events
189+
are available. This will cause FrameWork window updates and the user
190+
interface to remain working during long computations, but will slow the
191+
interpreter down and may cause surprising results in non-reentrant code
192+
(such as FrameWork itself). By default \var{async_dispatch} will immedeately
193+
call \var{our_dispatch} but you may override this to handle only certain
194+
events asynchronously. Events you do not handle will be passed to Sioux
195+
and such.
196+
197+
The old on/off value is returned.
173198
\end{funcdesc}
174199

175200
\begin{funcdesc}{_quit}{}

Doc/libmailbox.tex

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ \subsection{Mailbox Objects}
3131
method:
3232

3333
\begin{funcdesc}{next}{}
34-
Return the next message in the mailbox, as a \code{rfc822.Message} object=
35-
=2E
34+
Return the next message in the mailbox, as a \code{rfc822.Message} object.
3635
Depending on the mailbox implementation the \var{fp} attribute of this
37-
object may be a true file object or a class instance simulating a file ob=
38-
ject,
39-
taking care of things like message boundaries if multiple mail messages a=
40-
re
36+
object may be a true file object or a class instance simulating a file object,
37+
taking care of things like message boundaries if multiple mail messages are
4138
contained in a single file, etc.
4239
\end{funcdesc}
40+

Doc/mac/libmacfs.tex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ \section{Built-in Module \sectcode{macfs}}
8686
locate. Setting \var{create} causes the folder to be created if it
8787
does not exist. Returns a \code{(vrefnum, dirid)} tuple.
8888

89+
\begin{funcdesc}{NewAliasMinimalFromFullPath}{pathname}
90+
Return a minimal alias record object that points to the given file, which
91+
must be specified as a full pathname. This is the only way to create an
92+
alias record pointing to a non-existing file.
93+
8994
The constants for \var{where} and \var{which} can be obtained from the
9095
standard module \var{MACFS}.
9196
\end{funcdesc}
@@ -164,7 +169,9 @@ \subsection{alias objects}
164169
Resolve the alias. If the alias was created as a relative alias you
165170
should pass the file relative to which it is. Return the FSSpec for
166171
the file pointed to and a flag indicating whether the alias object
167-
itself was modified during the search process.
172+
itself was modified during the search process. If the file does
173+
not exist but the path leading up to it does exist a valid fsspec
174+
is returned.
168175
\end{funcdesc}
169176

170177
\begin{funcdesc}{GetInfo}{num}

0 commit comments

Comments
 (0)