Kaydet (Commit) fb2a169c authored tarafından Ronald Oussoren's avatar Ronald Oussoren

Drop Mac wrappers for the WASTE library.

üst f70b14fb
......@@ -95,14 +95,3 @@ audio tracks.
The \module{W} widgets are used extensively in the \program{IDE}.
\section{\module{waste} --- non-Apple \program{TextEdit} replacement}
\declaremodule{standard}{waste}
\platform{Mac}
\modulesynopsis{Interface to the ``WorldScript-Aware Styled Text Engine.''}
\begin{seealso}
\seetitle[http://www.merzwaren.com/waste/]{About WASTE}{Information
about the WASTE widget and library, including
documentation and downloads.}
\end{seealso}
# Generated from 'WASTE.h'
kPascalStackBased = None # workaround for header parsing
def FOUR_CHAR_CODE(x): return x
weCantUndoErr = -10015
weEmptySelectionErr = -10013
weUnknownObjectTypeErr = -9478
weObjectNotFoundErr = -9477
weReadOnlyErr = -9476
weTextNotFoundErr = -9474
weInvalidTextEncodingErr = -9473
weDuplicateAttributeErr = -9472
weInvalidAttributeSizeErr = -9471
weReadOnlyAttributeErr = -9470
weOddByteCountErr = -9469
weHandlerNotFoundErr = -1717
weNotHandledErr = -1708
weNewerVersionErr = -1706
weCorruptDataErr = -1702
weProtocolErr = -603
weUndefinedSelectorErr = -50
weFlushLeft = -2
weFlushRight = -1
weFlushDefault = 0
weCenter = 1
weJustify = 2
weDirDefault = 1
weDirRightToLeft = -1
weDirLeftToRight = 0
weDoFont = 0x0001
weDoFace = 0x0002
weDoSize = 0x0004
weDoColor = 0x0008
weDoAll = weDoFont | weDoFace | weDoSize | weDoColor
weDoAddSize = 0x0010
weDoToggleFace = 0x0020
weDoReplaceFace = 0x0040
weDoPreserveScript = 0x0080
weDoExtractSubscript = 0x0100
weDoFaceMask = 0x0200
weDoDirection = 0x00000001
weDoAlignment = 0x00000002
weDoLeftIndent = 0x00000004
weDoRightIndent = 0x00000008
weDoFirstLineIndent = 0x00000010
weDoLineSpacing = 0x00000020
weDoSpaceBefore = 0x00000040
weDoSpaceAfter = 0x00000080
weDoBottomBorderStyle = 0x00000400
kLeadingEdge = -1
kTrailingEdge = 0
kObjectEdge = 2
weFAutoScroll = 0
weFOutlineHilite = 2
weFReadOnly = 5
weFUndo = 6
weFIntCutAndPaste = 7
weFDragAndDrop = 8
weFInhibitRecal = 9
weFUseTempMem = 10
weFDrawOffscreen = 11
weFInhibitRedraw = 12
weFMonoStyled = 13
weFMultipleUndo = 14
weFNoKeyboardSync = 29
weFInhibitICSupport = 30
weFInhibitColor = 31
# weDoAutoScroll = 1UL << weFAutoScroll
# weDoOutlineHilite = 1UL << weFOutlineHilite
# weDoReadOnly = 1UL << weFReadOnly
# weDoUndo = 1UL << weFUndo
# weDoIntCutAndPaste = 1UL << weFIntCutAndPaste
# weDoDragAndDrop = 1UL << weFDragAndDrop
# weDoInhibitRecal = 1UL << weFInhibitRecal
# weDoUseTempMem = 1UL << weFUseTempMem
# weDoDrawOffscreen = 1UL << weFDrawOffscreen
# weDoInhibitRedraw = 1UL << weFInhibitRedraw
# weDoMonoStyled = 1UL << weFMonoStyled
# weDoMultipleUndo = 1UL << weFMultipleUndo
# weDoNoKeyboardSync = 1UL << weFNoKeyboardSync
# weDoInhibitICSupport = 1UL << weFInhibitICSupport
# weDoInhibitColor = 1UL << weFInhibitColor
weBitToggle = -2
weBitTest = -1
weBitClear = 0
weBitSet = 1
weLowerCase = 0
weUpperCase = 1
weFindWholeWords = 0x00000001
weFindCaseInsensitive = 0x00000002
weFindDiacriticalInsensitive = 0x00000004
wePutIntCutAndPaste = 0x00000001
wePutAddToTypingSequence = 0x00000002
wePutDetectUnicodeBOM = 0x00000200
weStreamDestinationKindMask = 0x000000FF
weStreamIncludeObjects = 0x00000100
weGetAddUnicodeBOM = 0x00000200
weGetLittleEndian = 0x00000400
weTagFontFamily = FOUR_CHAR_CODE('font')
weTagFontSize = FOUR_CHAR_CODE('ptsz')
weTagPlain = FOUR_CHAR_CODE('plan')
weTagBold = FOUR_CHAR_CODE('bold')
weTagItalic = FOUR_CHAR_CODE('ital')
weTagUnderline = FOUR_CHAR_CODE('undl')
weTagOutline = FOUR_CHAR_CODE('outl')
weTagShadow = FOUR_CHAR_CODE('shad')
weTagCondensed = FOUR_CHAR_CODE('cond')
weTagExtended = FOUR_CHAR_CODE('pexp')
weTagStrikethrough = FOUR_CHAR_CODE('strk')
weTagTextColor = FOUR_CHAR_CODE('colr')
weTagBackgroundColor = FOUR_CHAR_CODE('pbcl')
weTagTransferMode = FOUR_CHAR_CODE('pptm')
weTagVerticalShift = FOUR_CHAR_CODE('xshf')
weTagAlignment = FOUR_CHAR_CODE('pjst')
weTagDirection = FOUR_CHAR_CODE('LDIR')
weTagLineSpacing = FOUR_CHAR_CODE('ledg')
weTagLeftIndent = FOUR_CHAR_CODE('lein')
weTagRightIndent = FOUR_CHAR_CODE('riin')
weTagFirstLineIndent = FOUR_CHAR_CODE('fidt')
weTagSpaceBefore = FOUR_CHAR_CODE('spbe')
weTagSpaceAfter = FOUR_CHAR_CODE('spaf')
weTagBottomBorderStyle = FOUR_CHAR_CODE('BBRD')
weTagForceFontFamily = FOUR_CHAR_CODE('ffnt')
weTagAddFontSize = FOUR_CHAR_CODE('+siz')
weTagAddVerticalShift = FOUR_CHAR_CODE('+shf')
weTagTextEncoding = FOUR_CHAR_CODE('ptxe')
weTagQDStyles = FOUR_CHAR_CODE('qdst')
weTagTETextStyle = FOUR_CHAR_CODE('tets')
weTagAlignmentDefault = FOUR_CHAR_CODE('deft')
weTagAlignmentLeft = FOUR_CHAR_CODE('left')
weTagAlignmentCenter = FOUR_CHAR_CODE('cent')
weTagAlignmentRight = FOUR_CHAR_CODE('rght')
weTagAlignmentFull = FOUR_CHAR_CODE('full')
weTagDirectionDefault = FOUR_CHAR_CODE('deft')
weTagDirectionLeftToRight = FOUR_CHAR_CODE('L->R')
weTagDirectionRightToLeft = FOUR_CHAR_CODE('R->L')
weTagBorderStyleNone = FOUR_CHAR_CODE('NONE')
weTagBorderStyleThin = FOUR_CHAR_CODE('SLDL')
weTagBorderStyleDotted = FOUR_CHAR_CODE('DTDL')
weTagBorderStyleThick = FOUR_CHAR_CODE('THKL')
weLineSpacingSingle = 0x00000000
weLineSpacingOneAndHalf = 0x00008000
weLineSpacingDouble = 0x00010000
weCharByteHook = FOUR_CHAR_CODE('cbyt')
weCharToPixelHook = FOUR_CHAR_CODE('c2p ')
weCharTypeHook = FOUR_CHAR_CODE('ctyp')
weClickLoop = FOUR_CHAR_CODE('clik')
weCurrentDrag = FOUR_CHAR_CODE('drag')
weDrawTextHook = FOUR_CHAR_CODE('draw')
weDrawTSMHiliteHook = FOUR_CHAR_CODE('dtsm')
weEraseHook = FOUR_CHAR_CODE('eras')
weFontFamilyToNameHook = FOUR_CHAR_CODE('ff2n')
weFontNameToFamilyHook = FOUR_CHAR_CODE('fn2f')
weFluxProc = FOUR_CHAR_CODE('flux')
weHiliteDropAreaHook = FOUR_CHAR_CODE('hidr')
weLineBreakHook = FOUR_CHAR_CODE('lbrk')
wePixelToCharHook = FOUR_CHAR_CODE('p2c ')
wePort = FOUR_CHAR_CODE('port')
wePreTrackDragHook = FOUR_CHAR_CODE('ptrk')
weRefCon = FOUR_CHAR_CODE('refc')
weScrollProc = FOUR_CHAR_CODE('scrl')
weText = FOUR_CHAR_CODE('text')
weTranslateDragHook = FOUR_CHAR_CODE('xdrg')
weTranslucencyThreshold = FOUR_CHAR_CODE('tluc')
weTSMDocumentID = FOUR_CHAR_CODE('tsmd')
weTSMPreUpdate = FOUR_CHAR_CODE('pre ')
weTSMPostUpdate = FOUR_CHAR_CODE('post')
weURLHint = FOUR_CHAR_CODE('urlh')
weWordBreakHook = FOUR_CHAR_CODE('wbrk')
weNewHandler = FOUR_CHAR_CODE('new ')
weDisposeHandler = FOUR_CHAR_CODE('free')
weDrawHandler = FOUR_CHAR_CODE('draw')
weClickHandler = FOUR_CHAR_CODE('clik')
weStreamHandler = FOUR_CHAR_CODE('strm')
weHoverHandler = FOUR_CHAR_CODE('hovr')
kTypeText = FOUR_CHAR_CODE('TEXT')
kTypeStyles = FOUR_CHAR_CODE('styl')
kTypeSoup = FOUR_CHAR_CODE('SOUP')
kTypeFontTable = FOUR_CHAR_CODE('FISH')
kTypeParaFormat = FOUR_CHAR_CODE('WEpf')
kTypeRulerScrap = FOUR_CHAR_CODE('WEru')
kTypeCharFormat = FOUR_CHAR_CODE('WEcf')
kTypeStyleScrap = FOUR_CHAR_CODE('WEst')
kTypeUnicodeText = FOUR_CHAR_CODE('utxt')
kTypeUTF8Text = FOUR_CHAR_CODE('UTF8')
kTypeStyledText = FOUR_CHAR_CODE('STXT')
weAKNone = 0
weAKUnspecified = 1
weAKTyping = 2
weAKCut = 3
weAKPaste = 4
weAKClear = 5
weAKDrag = 6
weAKSetStyle = 7
weAKSetRuler = 8
weAKBackspace = 9
weAKFwdDelete = 10
weAKCaseChange = 11
weAKObjectChange = 12
weToScrap = 0
weToDrag = 1
weToSoup = 2
weMouseEnter = 0
weMouseWithin = 1
weMouseLeave = 2
kCurrentSelection = -1
kNullStyle = -2
# Generated from 'WASTE.h'
kPascalStackBased = None # workaround for header parsing
def FOUR_CHAR_CODE(x): return x
weCantUndoErr = -10015
weEmptySelectionErr = -10013
weUnknownObjectTypeErr = -9478
weObjectNotFoundErr = -9477
weReadOnlyErr = -9476
weTextNotFoundErr = -9474
weInvalidTextEncodingErr = -9473
weDuplicateAttributeErr = -9472
weInvalidAttributeSizeErr = -9471
weReadOnlyAttributeErr = -9470
weOddByteCountErr = -9469
weHandlerNotFoundErr = -1717
weNotHandledErr = -1708
weNewerVersionErr = -1706
weCorruptDataErr = -1702
weProtocolErr = -603
weUndefinedSelectorErr = -50
weFlushLeft = -2
weFlushRight = -1
weFlushDefault = 0
weCenter = 1
weJustify = 2
weDirDefault = 1
weDirRightToLeft = -1
weDirLeftToRight = 0
weDoFont = 0x0001
weDoFace = 0x0002
weDoSize = 0x0004
weDoColor = 0x0008
weDoAll = weDoFont | weDoFace | weDoSize | weDoColor
weDoAddSize = 0x0010
weDoToggleFace = 0x0020
weDoReplaceFace = 0x0040
weDoPreserveScript = 0x0080
weDoExtractSubscript = 0x0100
weDoFaceMask = 0x0200
weDoDirection = 0x00000001
weDoAlignment = 0x00000002
weDoLeftIndent = 0x00000004
weDoRightIndent = 0x00000008
weDoFirstLineIndent = 0x00000010
weDoLineSpacing = 0x00000020
weDoSpaceBefore = 0x00000040
weDoSpaceAfter = 0x00000080
weDoBottomBorderStyle = 0x00000400
kLeadingEdge = -1
kTrailingEdge = 0
kObjectEdge = 2
weFAutoScroll = 0
weFOutlineHilite = 2
weFReadOnly = 5
weFUndo = 6
weFIntCutAndPaste = 7
weFDragAndDrop = 8
weFInhibitRecal = 9
weFUseTempMem = 10
weFDrawOffscreen = 11
weFInhibitRedraw = 12
weFMonoStyled = 13
weFMultipleUndo = 14
weFNoKeyboardSync = 29
weFInhibitICSupport = 30
weFInhibitColor = 31
weDoAutoScroll = 1 << weFAutoScroll
weDoOutlineHilite = 1 << weFOutlineHilite
weDoReadOnly = 1 << weFReadOnly
weDoUndo = 1 << weFUndo
weDoIntCutAndPaste = 1 << weFIntCutAndPaste
weDoDragAndDrop = 1 << weFDragAndDrop
weDoInhibitRecal = 1 << weFInhibitRecal
weDoUseTempMem = 1 << weFUseTempMem
weDoDrawOffscreen = 1 << weFDrawOffscreen
weDoInhibitRedraw = 1 << weFInhibitRedraw
weDoMonoStyled = 1 << weFMonoStyled
weDoMultipleUndo = 1 << weFMultipleUndo
weDoNoKeyboardSync = 1 << weFNoKeyboardSync
weDoInhibitICSupport = 1 << weFInhibitICSupport
# weDoInhibitColor = 1 << weFInhibitColor
weBitToggle = -2
weBitTest = -1
weBitClear = 0
weBitSet = 1
weLowerCase = 0
weUpperCase = 1
weFindWholeWords = 0x00000001
weFindCaseInsensitive = 0x00000002
weFindDiacriticalInsensitive = 0x00000004
wePutIntCutAndPaste = 0x00000001
wePutAddToTypingSequence = 0x00000002
wePutDetectUnicodeBOM = 0x00000200
weStreamDestinationKindMask = 0x000000FF
weStreamIncludeObjects = 0x00000100
weGetAddUnicodeBOM = 0x00000200
weGetLittleEndian = 0x00000400
weTagFontFamily = FOUR_CHAR_CODE('font')
weTagFontSize = FOUR_CHAR_CODE('ptsz')
weTagPlain = FOUR_CHAR_CODE('plan')
weTagBold = FOUR_CHAR_CODE('bold')
weTagItalic = FOUR_CHAR_CODE('ital')
weTagUnderline = FOUR_CHAR_CODE('undl')
weTagOutline = FOUR_CHAR_CODE('outl')
weTagShadow = FOUR_CHAR_CODE('shad')
weTagCondensed = FOUR_CHAR_CODE('cond')
weTagExtended = FOUR_CHAR_CODE('pexp')
weTagStrikethrough = FOUR_CHAR_CODE('strk')
weTagTextColor = FOUR_CHAR_CODE('colr')
weTagBackgroundColor = FOUR_CHAR_CODE('pbcl')
weTagTransferMode = FOUR_CHAR_CODE('pptm')
weTagVerticalShift = FOUR_CHAR_CODE('xshf')
weTagAlignment = FOUR_CHAR_CODE('pjst')
weTagDirection = FOUR_CHAR_CODE('LDIR')
weTagLineSpacing = FOUR_CHAR_CODE('ledg')
weTagLeftIndent = FOUR_CHAR_CODE('lein')
weTagRightIndent = FOUR_CHAR_CODE('riin')
weTagFirstLineIndent = FOUR_CHAR_CODE('fidt')
weTagSpaceBefore = FOUR_CHAR_CODE('spbe')
weTagSpaceAfter = FOUR_CHAR_CODE('spaf')
weTagBottomBorderStyle = FOUR_CHAR_CODE('BBRD')
weTagForceFontFamily = FOUR_CHAR_CODE('ffnt')
weTagAddFontSize = FOUR_CHAR_CODE('+siz')
weTagAddVerticalShift = FOUR_CHAR_CODE('+shf')
weTagTextEncoding = FOUR_CHAR_CODE('ptxe')
weTagQDStyles = FOUR_CHAR_CODE('qdst')
weTagTETextStyle = FOUR_CHAR_CODE('tets')
weTagAlignmentDefault = FOUR_CHAR_CODE('deft')
weTagAlignmentLeft = FOUR_CHAR_CODE('left')
weTagAlignmentCenter = FOUR_CHAR_CODE('cent')
weTagAlignmentRight = FOUR_CHAR_CODE('rght')
weTagAlignmentFull = FOUR_CHAR_CODE('full')
weTagDirectionDefault = FOUR_CHAR_CODE('deft')
weTagDirectionLeftToRight = FOUR_CHAR_CODE('L->R')
weTagDirectionRightToLeft = FOUR_CHAR_CODE('R->L')
weTagBorderStyleNone = FOUR_CHAR_CODE('NONE')
weTagBorderStyleThin = FOUR_CHAR_CODE('SLDL')
weTagBorderStyleDotted = FOUR_CHAR_CODE('DTDL')
weTagBorderStyleThick = FOUR_CHAR_CODE('THKL')
weLineSpacingSingle = 0x00000000
weLineSpacingOneAndHalf = 0x00008000
weLineSpacingDouble = 0x00010000
weCharByteHook = FOUR_CHAR_CODE('cbyt')
weCharToPixelHook = FOUR_CHAR_CODE('c2p ')
weCharTypeHook = FOUR_CHAR_CODE('ctyp')
weClickLoop = FOUR_CHAR_CODE('clik')
weCurrentDrag = FOUR_CHAR_CODE('drag')
weDrawTextHook = FOUR_CHAR_CODE('draw')
weDrawTSMHiliteHook = FOUR_CHAR_CODE('dtsm')
weEraseHook = FOUR_CHAR_CODE('eras')
weFontFamilyToNameHook = FOUR_CHAR_CODE('ff2n')
weFontNameToFamilyHook = FOUR_CHAR_CODE('fn2f')
weFluxProc = FOUR_CHAR_CODE('flux')
weHiliteDropAreaHook = FOUR_CHAR_CODE('hidr')
weLineBreakHook = FOUR_CHAR_CODE('lbrk')
wePixelToCharHook = FOUR_CHAR_CODE('p2c ')
wePort = FOUR_CHAR_CODE('port')
wePreTrackDragHook = FOUR_CHAR_CODE('ptrk')
weRefCon = FOUR_CHAR_CODE('refc')
weScrollProc = FOUR_CHAR_CODE('scrl')
weText = FOUR_CHAR_CODE('text')
weTranslateDragHook = FOUR_CHAR_CODE('xdrg')
weTranslucencyThreshold = FOUR_CHAR_CODE('tluc')
weTSMDocumentID = FOUR_CHAR_CODE('tsmd')
weTSMPreUpdate = FOUR_CHAR_CODE('pre ')
weTSMPostUpdate = FOUR_CHAR_CODE('post')
weURLHint = FOUR_CHAR_CODE('urlh')
weWordBreakHook = FOUR_CHAR_CODE('wbrk')
weNewHandler = FOUR_CHAR_CODE('new ')
weDisposeHandler = FOUR_CHAR_CODE('free')
weDrawHandler = FOUR_CHAR_CODE('draw')
weClickHandler = FOUR_CHAR_CODE('clik')
weStreamHandler = FOUR_CHAR_CODE('strm')
weHoverHandler = FOUR_CHAR_CODE('hovr')
kTypeText = FOUR_CHAR_CODE('TEXT')
kTypeStyles = FOUR_CHAR_CODE('styl')
kTypeSoup = FOUR_CHAR_CODE('SOUP')
kTypeFontTable = FOUR_CHAR_CODE('FISH')
kTypeParaFormat = FOUR_CHAR_CODE('WEpf')
kTypeRulerScrap = FOUR_CHAR_CODE('WEru')
kTypeCharFormat = FOUR_CHAR_CODE('WEcf')
kTypeStyleScrap = FOUR_CHAR_CODE('WEst')
kTypeUnicodeText = FOUR_CHAR_CODE('utxt')
kTypeUTF8Text = FOUR_CHAR_CODE('UTF8')
kTypeStyledText = FOUR_CHAR_CODE('STXT')
weAKNone = 0
weAKUnspecified = 1
weAKTyping = 2
weAKCut = 3
weAKPaste = 4
weAKClear = 5
weAKDrag = 6
weAKSetStyle = 7
weAKSetRuler = 8
weAKBackspace = 9
weAKFwdDelete = 10
weAKCaseChange = 11
weAKObjectChange = 12
weToScrap = 0
weToDrag = 1
weToSoup = 2
weMouseEnter = 0
weMouseWithin = 1
weMouseLeave = 2
kCurrentSelection = -1
kNullStyle = -2
......@@ -73,10 +73,6 @@ with MacPython.
how to use <code>FrameWork</code> application framework and the
<code>TextEdit</code> toolbox to build a text editor.
<LI>
<A HREF="waste.html">Using WASTE</A> expands on this editor by using
WASTE, an extended TextEdit replacement.
<LI>
<A HREF="plugins.html">Creating a C extension module on the Macintosh</A>
is meant for the hardcore programmer, and shows how to create an
......
......@@ -80,8 +80,7 @@ A modeless dialog window initialized from a DLOG resource. See the
Let us have a look at <A HREF="textedit/ped.py">ped.py</A> (in the Demo:textedit folder), the Pathetic
EDitor. It has multiple windows, cut/copy/paste and keyboard input, but that is about all. It looks
as if you can resize the window but it does not work. Still, it serves as an example. We will improve
on ped later, in a <A HREF="waste.html">waste-based example</A>. <p>
as if you can resize the window but it does not work. Still, it serves as an example.
Ped creates two classes, <code>TEWindow</code> and <code>Ped</code>. Let us start with the latter one,
which is a subclass of <code>FrameWork.Application</code> and our main application. The init function
......
<HTML><HEAD><TITLE>Using WASTE</TITLE></HEAD>
<BODY>
<H1>Using WASTE</H1>
<HR>
WASTE is an almost-compatible TextEdit replacement which overcomes
some of the limitations of it (like the 32K limit) and provides some extensions
(drag and drop, images, undo support). Moreover, it has a much cleaner interface
and is therefore easier integrated in Python. <p>
WASTE is written by Marco Piovanelli, <A HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>,
and copyrighted by him. You can always obtain the latest version (for use in C
or Pascal programs) and the documentation from
<A HREF="http://www.boingo.com/waste/">&lt;http://www.boingo.com/waste/&gt;</A>.
We explain the useage of waste here by showing how to modify the TextEdit based
<A HREF="textedit/ped.py">ped.py</A> of the
<A HREF="textedit.html">previous example</A> into the waste-based <A HREF="waste/wed.py">wed.py</A>,
so you should have both sources handy. <p>
Functionally, <code>wed.py</code> provides three new things: resizable windows, a horizontal
scroll bar and undo. <p>
Let us look at the code, first at the application class <code>Wed</code>. The only real change is that
we now handle <code>undo</code>. Aside from enabling it in the creation routine and the addition of
a callback routine there is a bit of new code in <code>updatemenubar</code>: Waste not only handles
the full details of implementing undo, it will also tell us what the next undo operation will undo
(or redo). We use this to our advantage by changing the undo menu label to tell the user. <p>
The <code>WasteWindow</code> has seen a bit more change. Initialization of the waste data structure is
a bit different, in that we can specify some options at creation time. Also, waste has no <code>SetText</code>
method but a <code>UseText</code> which expects a handle as parameter. We have to be <EM>very</EM> careful
that we keep this handle around, because Python will happily free the handle if we have no more references
to it (and I doubt that Waste would like this:-). A final difference in <code>open</code>
is that we use a large number for the destination rectangle width, because we will use a horizontal scroll
bar. <p>
The <code>idle</code> method is a bit more involved, since we also call <code>WEAdjustCursor</code> to
provide the correct cursor based on mouse-position. Users like this. <p>
<code>Getscrollbarvalues</code> is simpler than its' TextEdit counterpart because Waste correctly
updates the destination rectangle when the document changes. Also note that waste uses accessor functions
to get at internal values, as opposed to direct struct access for TextEdit. <p>
<code>Scrollbar_callback</code> on the other hand is more elaborate (but also provides more functionality).
It also handles horizontal scrolls (scrolling one-tenth and half a screenful with the buttons). This
function is also "multi-font-ready" in that scrolling one line will do the expected thing in case of multiple
fonts. We will implement a multi-font editor later. A minor annoyance of Waste is that is does not provide
a pinned scroll, so at the end of our callback routine we have to check that we have not scrolled past the
beginning or end of the document, and adjust when needed. <p>
<code>do_update</code> is also changed, because Waste is completely region-based (as opposed to rect-based).
Hence, we erase regions here and we can also return immedeately if there is nothing to update. <p>
<code>Do_postresize</code> is new: because Waste uses accessor functions we can now modify the viewRect from
Python, which is impossible in the Python TextEdit interface, and hence we can implement resize. The
<code>do_key</code> and <code>do_contentclick</code> methods have also seen minor changes, because the
corresponding waste routines need a bit more information than their TextEdit counterparts. The Cut/copy/paste
code is simplified, because Waste uses the normal desktop scrap. <p>
Implementing undo is a wonder of simplicity: Waste handles all the details for us. Also, the new
<code>can_paste</code> method (which controls greying out of the paste menu entry) is an improvement
over what <code>ped</code> did: in ped it was possible that paste was enabled but that the data on the
scrap was incompatible with TextEdit. No more such problems here. <p>
That is all for now. There is an undocumented extended version of wed, <a href="waste/swed.py">swed.py</a>,
which supports multiple fonts, sizes and faces, and uses Waste's tab-calculation to do tab characters "right".
There is also an even more elaborate example, <a href="waste/htmled.py">htmled.py</a> which extends swed with
the ability to import html files, showing the use of color and how to use embedded object (rulers, in this case).
These two programs have not been documented yet, though, so you will have to look at them without guidance. <p>
<hr>
Back to the <A HREF="index.html">index</A> to pick another example.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# Scan an Apple header file, generating a Python file of generator calls.
import sys
import os
from bgenlocations import TOOLBOXDIR, BGENDIR
sys.path.append(BGENDIR)
from scantools import Scanner
WASTEDIR='/Users/jack/src/waste/C_C++ Headers/'
if not os.path.exists(WASTEDIR):
raise 'Error: not found: %s', WASTEDIR
OBJECT = "TEHandle"
SHORT = "waste"
OBJECT = "WEReference"
OBJECT2 = "WEObjectReference"
def main():
input = WASTEDIR + "WASTE.h"
output = SHORT + "gen.py"
defsoutput = os.path.join(os.path.split(TOOLBOXDIR)[0], "WASTEconst.py")
scanner = MyScanner(input, output, defsoutput)
scanner.scan()
## scanner.gentypetest(SHORT+"typetest.py")
scanner.close()
print "=== Testing definitions output code ==="
execfile(defsoutput, {}, {})
print "=== Done scanning and generating, now importing the generated code... ==="
exec "import " + SHORT + "support"
print "=== Done. It's up to you to compile it now! ==="
#class MyScanner(Scanner_PreUH3):
class MyScanner(Scanner):
def destination(self, type, name, arglist):
classname = "Function"
listname = "functions"
if arglist:
t, n, m = arglist[-1]
# This is non-functional today
if t == OBJECT and m == "InMode":
classname = "Method"
listname = "methods"
else:
t, n, m = arglist[0]
if t == OBJECT2 and m == "InMode":
classname = "Method2"
listname = "methods2"
return classname, listname
def writeinitialdefs(self):
self.defsfile.write("kPascalStackBased = None # workaround for header parsing\n")
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
def makeblacklistnames(self):
return [
"WEDispose",
"WESetInfo", # Argument type unknown...
"WEGetInfo",
"WEVersion", # Unfortunately...
"WEPut", # XXXX TBD: needs array of flavortypes.
"WEGetOneAttribute", # XXXX TBD: output buffer
# Incompatible constant definitions
"weDoAutoScroll",
"weDoOutlineHilite",
"weDoReadOnly",
"weDoUndo",
"weDoIntCutAndPaste",
"weDoDragAndDrop",
"weDoInhibitRecal",
"weDoUseTempMem",
"weDoDrawOffscreen",
"weDoInhibitRedraw",
"weDoMonoStyled",
"weDoMultipleUndo",
"weDoNoKeyboardSync",
"weDoInhibitICSupport",
"weDoInhibitColor",
]
def makeblacklisttypes(self):
return [
"DragReference", # For now...
"UniversalProcPtr",
"WEFontIDToNameUPP",
"WEFontNameToIDUPP",
"WEClickLoopUPP",
"WEScrollUPP",
"WETSMPreUpdateUPP",
"WETSMPostUpdateUPP",
"WEPreTrackDragUPP",
"WETranslateDragUPP",
"WEHiliteDropAreaUPP",
"WEDrawTextUPP",
"WEDrawTSMHiliteUPP",
"WEPixelToCharUPP",
"WECharToPixelUPP",
"WELineBreakUPP",
"WEWordBreakUPP",
"WECharByteUPP",
"WECharTypeUPP",
"WEEraseUPP",
"WEFluxUPP",
"WENewObjectUPP",
"WEDisposeObjectUPP",
"WEDrawObjectUPP",
"WEClickObjectUPP",
"WEStreamObjectUPP",
"WEHoverObjectUPP",
"WERuler", # XXXX To be done
"WERuler_ptr", # ditto
"WEParaInfo", # XXXX To be done
"WEPrintSession", # XXXX To be done
"WEPrintOptions_ptr", # XXXX To be done
]
def makerepairinstructions(self):
return [
([("void_ptr", "*", "InMode"), ("SInt32", "*", "InMode")],
[("InBuffer", "*", "*")]),
# WEContinuousStyle
([("WEStyleMode", "ioMode", "OutMode"), ("TextStyle", "outTextStyle", "OutMode")],
[("WEStyleMode", "*", "InOutMode"), ("TextStyle", "*", "*")]),
# WECopyRange
([('Handle', 'outText', 'InMode'), ('StScrpHandle', 'outStyles', 'InMode'),
('WESoupHandle', 'outSoup', 'InMode')],
[('OptHandle', '*', '*'), ('OptStScrpHandle', '*', '*'),
('OptSoupHandle', '*', '*')]),
# WEInsert
([('StScrpHandle', 'inStyles', 'InMode'), ('WESoupHandle', 'inSoup', 'InMode')],
[('OptStScrpHandle', '*', '*'), ('OptSoupHandle', '*', '*')]),
# WEGetObjectOwner
("WEGetObjectOwner",
[('WEReference', '*', 'ReturnMode')],
[('ExistingWEReference', '*', 'ReturnMode')]),
# WEFindParagraph
([("char_ptr", "inKey", "InMode")],
[("stringptr", "*", "*")]),
# WESetOneAttribute
([("void_ptr", "*", "InMode"), ("ByteCount", "*", "InMode")],
[("InBuffer", "*", "*")]),
]
if __name__ == "__main__":
main()
This diff is collapsed.
......@@ -1095,29 +1095,6 @@ class PyBuildExt(build_ext):
extra_link_args=['-framework', 'QuickTime',
'-framework', 'Carbon']) )
# As there is no standardized place (yet) to put
# user-installed Mac libraries on OSX, we search for "waste"
# in parent directories of the Python source tree. You
# should put a symlink to your Waste installation in the
# same folder as your python source tree. Or modify the
# next few lines:-)
waste_incs = find_file("WASTE.h", [],
['../'*n + 'waste/C_C++ Headers' for n in (0,1,2,3,4)])
waste_libs = find_library_file(self.compiler, "WASTE", [],
["../"*n + "waste/Static Libraries" for n in (0,1,2,3,4)])
if waste_incs != None and waste_libs != None:
exts.append( Extension('waste',
['waste/wastemodule.c'] + [
os.path.join(srcdir, d) for d in
'Mac/Wastemods/WEObjectHandlers.c',
'Mac/Wastemods/WETabHooks.c',
'Mac/Wastemods/WETabs.c'
],
include_dirs = waste_incs + [os.path.join(srcdir, 'Mac/Wastemods')],
library_dirs = waste_libs,
libraries = ['WASTE'],
extra_link_args = ['-framework', 'Carbon'],
) )
self.extensions.extend(exts)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment