home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / WASTE 1.1 / WASTEIntf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-02  |  29.2 KB  |  721 lines  |  [TEXT/MPCC]

  1. /*
  2. // { WASTE PROJECT: }
  3. // { Internal interface: constants, types and inline code }
  4.  
  5. // { Copyright © 1993-1994 Marco Piovanelli }
  6. // { All Rights Reserved }
  7. */
  8.  
  9. #ifndef __LONGCOORDINATES__
  10. #ifndef _LongCoords_
  11. #include "LongCoords.h"
  12. #endif
  13. #endif
  14.  
  15. /*    useful macros for testing, setting and clearing bits */
  16.  
  17. #include <TextEdit.h>
  18. #include <Scrap.h>
  19. #include <TextServices.h>
  20. #include <Script.h>
  21. #include <ToolUtils.h>
  22. #include <TextUtils.h>
  23. #include <LowMem.h>
  24. #include <AERegistry.h>
  25. #include <Drag.h>
  26.  
  27. #define BTST( FLAGS, BIT )    (((FLAGS) & (1L << (BIT))) ? 1 : 0)
  28. #define BSET( FLAGS, BIT )  ((FLAGS) |= (1L << (BIT)))
  29. #define BCLR( FLAGS, BIT )  ((FLAGS) &= (~(1L << (BIT))))
  30.  
  31. #define ABS(A) ((A) > 0 ? (A) : -(A))
  32.  
  33. #define BSL(A, B)    (((long)A) << (B))
  34. #define BSR(A, B)    (((long)A) >> (B))
  35.  
  36. // if WASTE_TABS is defined, Mark Alldritt's tab modifications are included
  37. // WASTE_TAB_SIZE defines the width in pixels between the tab stops
  38. #define WASTE_TABS            1
  39. #define WASTE_TAB_SIZE        30L
  40.  
  41. // if WEREDRAW_SPEED is defined, Mark Alldritt's optimizations of _WERedraw are used
  42. #define WEREDRAW_SPEED        1
  43.  
  44. // if WEPINSCROLL is defined, Chris Thomas's modifications are used to make WEScroll()
  45. // behave like TEPinScroll()
  46. #define WEPINSCROLL            1
  47.  
  48. // Don't let WASTE synchronize keyboard and fonts
  49. #define WASTENOSYNCH        1
  50.  
  51. #include "LongCoords.h"
  52. #include <limits.h>
  53.  
  54. /* result codes */
  55. enum{
  56.         weNotAnObjectErr         = -9482,    // { selection is not an embedded object }
  57.         weUnknownSelectorErr     = -9480        // { unknown selector code }
  58. };
  59.  
  60. enum {
  61.         weCantUndoErr            = -9479        /* can't undo */
  62. };
  63.  
  64. enum {
  65.         weUnknownObjectTypeErr = -9478            // { specified object type was not registered }
  66. };
  67.  
  68. // { values for WEInstallObjectHandler handlerSelector parameter }
  69. enum {
  70.         weNewHandler = 'new ',
  71.         weDisposeHandler = 'free',
  72.         weDrawHandler = 'draw',
  73.         weClickHandler = 'clik',
  74.         weCursorHandler = 'curs'
  75. };
  76.  
  77. /*    action kinds */
  78.  
  79. enum {
  80.     weAKNone            =    0,        /* null action */
  81.     weAKUnspecified        =    1,        /* action of unspecified nature */
  82.     weAKTyping            =    2,        /* some text has been typed in */
  83.     weAKCut                =    3,        /* the selection range has been cut */
  84.     weAKPaste            =    4,        /* something has been pasted */
  85.     weAKClear            =    5,        /* the selection range has been deleted */
  86.     weAKDrag            =    6,        /* drag and drop operation */
  87.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  88. };
  89.  
  90. /* action flags */
  91.  
  92. enum {
  93.     weAFIsRedo            =    0x0001,    // action saves edit state prior to a WEUndo call
  94.     weAFDontSaveText    =    0x0002, // don't save text
  95.     weAFDontSaveStyles    =    0x0004,    // don't save styles
  96.     weAFDontSaveSoup    =    0x0008
  97. };
  98.  
  99. typedef short WEActionKind;
  100. typedef short WEActionFlags;
  101.  
  102. /*    alignment styles */
  103.  
  104. enum {
  105.     weFlushLeft         =    -2,        /* flush left */
  106.     weFlushRight        =    -1,        /* flush right */
  107.     weFlushDefault        =     0,        /* flush according to system direction */
  108.     weCenter            =     1,        /* centered */
  109.     weJustify            =     2        /* fully justified */
  110. };
  111.  
  112. // { values for the edge parameter }
  113.  
  114. enum {
  115.     kLeadingEdge = -1,
  116.     kTrailingEdge = 0
  117. };
  118.  
  119. // { control character codes }
  120.  
  121. enum {
  122.     kObjectMarker = 1,
  123.     kBackspace = 8,
  124.     kEOL = 13,
  125.     kArrowLeft = 28,
  126.     kArrowRight = 29,
  127.     kArrowUp = 30,
  128.     kArrowDown = 31
  129. };
  130.  
  131. // { bit equates for QuickDraw styles }
  132.  
  133. enum {
  134.     tsBold = 0,
  135.     tsItalic = 1,
  136.     tsUnderline = 2,
  137.     tsOutline = 3,
  138.     tsShadow = 4,
  139.     tsCondense = 5,
  140.     tsExtend = 6
  141. };
  142.  
  143. // { bit equates for the tsFlags field of the WETextStyle record }
  144. enum {
  145.     tsTSMHilite = 4,                        // { set if style run is part of active input area }
  146.     tsTSMSelected = 5,                        // { set for selected raw/converted text }
  147.     tsTSMConverted = 6,                        // { set for converted text, clear for raw text }
  148.     tsRightToLeft = 7                        // { reserved for future use }
  149. };
  150.  
  151. // { bit equates for the mode parameter in WESetStyle and WEContinuousStyle }
  152. enum {
  153.     kModeFont = 0,
  154.     kModeFace = 1,
  155.     kModeSize = 2,
  156.     kModeColor = 3,
  157.     kModeAddSize = 4,
  158.     kModeToggleFace = 5,
  159.     kModeReplaceFace = 6,
  160.     kModeObject = 14,
  161.     kModeFlags = 15
  162. };
  163.  
  164. // { values for the mode parameter in WESetStyle and WEContinuousStyle }
  165. enum {
  166.     weDoFont            =    0x0001,
  167.     weDoFace            =    0x0002,
  168.     weDoSize            =    0x0004,
  169.     weDoColor            =    0x0008,
  170.     weDoAll                =    weDoFont + weDoFace + weDoSize + weDoColor,
  171.     weDoAddSize            =    0x0010,
  172.     weDoToggleFace        =    0x0020,
  173.     weDoReplaceFace        =    0x0040,
  174.     weDoObject            =    0x4000,
  175.     weDoFlags            =    0x8000
  176. };
  177.  
  178. // { values for WEFeatureFlag action parameter }
  179. enum {
  180.     weBitClear = 0,                                // { disables the specified feature }
  181.     weBitSet = 1,                                // { enables the specified feature }
  182.     weBitTest = -1                                // { returns the current setting of the specified feature }
  183. };
  184.  
  185. // { bit equates for the flags field in the WE record }
  186. // { bits 0..15 can be used to turn on and off specific features with WEFeatureFlag }
  187. // { bits 16..31 are used internally and should not be modified }
  188.  
  189. // { private flags }
  190. enum {
  191.     weFHasColorQD = 31,                        // { Color QuickDraw is available }
  192.     weFHasTextServices = 30,                // { Text Services Manager is available }
  193.     weFNonRoman = 29,                        // { at least one non-Roman script is enabled }
  194.     weFDoubleByte = 28,                        // { a double-byte script is installed }
  195.     weFCaretVisible = 24,                    // { the caret is currently visible }
  196.     weFMouseTracking = 23,                    // { set internally during mouse tracking }
  197.     weFAnchorIsEnd = 22,                    // { anchor offset is selEnd }
  198.     weFUseNullStyle = 21,                    // { a null style is associated with the empty selection }
  199.     weFActive = 20,                            // { we're active }
  200.     weFHilited = 19,                        // { TRUE if text pane is highlighted (for Drag & Drop) }
  201.     weFCanAcceptDrag = 18,                    // { The drag in the text pane can be accepted }
  202.     weFDragCaretVisible = 17                // { Drag caret is currently visible }
  203. };
  204.  
  205. // { public flags }
  206. enum {
  207.     weFDrawOffscreen = 11,                    // { draw text offscreen for smoother visual results }
  208.     weFUseTempMem = 10,                        // { use temporary memory for main data structures }
  209.     weFInhibitRecal = 9,                    // { if set, recals and redraws are inhibited }
  210.     weFDragAndDrop = 8,                        // { Text drag-and-drop }
  211.     weFIntCutAndPaste = 7,                    // { Intelligent Cut & Paste }
  212.     weFUndoSupport = 6,                        // { Support Undo/Redo }
  213.     weFOutlineHilite = 2,                    // { frame selection range when text pane is inactive }
  214.     weFAutoScroll = 0                        // { automatically scroll text when cursor is outside pane }
  215. };
  216.  
  217. // { masks for setting the feature bits }
  218. enum {
  219.     weDoAutoScroll = 1 << weFAutoScroll,
  220.     weDoOutlineHilite = 1 << weFOutlineHilite,
  221.     weDoUndoSupport = 1 << weFUndoSupport,
  222.     weDoIntCutAndPaste = 1 << weFIntCutAndPaste,
  223.     weDoDragAndDrop = 1 << weFDragAndDrop,
  224.     weDoInhibitRecal =  1 << weFInhibitRecal,
  225.     weDoUseTempMem = 1 << weFUseTempMem,
  226.     weDoDrawOffscreen = 1 << weFDrawOffscreen 
  227. };
  228.  
  229. // { scrap types }
  230. enum {
  231.     kTypeText = 'TEXT',
  232.     kTypeStyles = 'styl',
  233.     kTypePicture = 'PICT',
  234.     kTypeSoup = 'SOUP'
  235. };
  236.  
  237. // { selectors for WEGetInfo/WESetInfo }
  238. enum {
  239.     weClickLoop = 'clik',
  240.     weCurrentDrag = 'drag',
  241.     weLineArray = 'line',
  242.     wePort = 'port',
  243.     weRefCon = 'refc',
  244.     weRunArray = 'runa',
  245.     weScrollProc = 'scrl',
  246.     weStyleTable = 'styl',
  247.     weText = 'text',
  248.     weTSMDocumentID = 'tsmd',
  249.     weTSMPostUpdate = 'post',
  250.     weTSMPreUpdate = 'pre '
  251. };
  252.  
  253. // { possible values returned by WEIntelligentPaste }
  254. enum {
  255.     weDontAddSpaces = 0,
  256.     weAddSpaceOnLeftSide = -1,
  257.     weAddSpaceOnRightSide = 1
  258. };
  259.  
  260. // { values for WEAllocate allocFlags parameter }
  261. enum {
  262.     kAllocClear = 0x0001,                        // { clear handle after allocation }
  263.     kAllocTemp = 0x0002                        // { use temporary memory if available }
  264. };
  265.  
  266. // { other miscellaneous constants }
  267. enum {
  268.     kCaretWidth = 1,                    // { width of the caret, in pixels }
  269.     kMinFontSize = 1,                    // { minimum valid font size }
  270.     kMaxFontSize = SHRT_MAX,            // { maximum valid font size }
  271.     kInvalidOffset = -1,                 // { used to flag an invalid or nonexistent offset }
  272.     kNullDrag = 0                        // { null or nonexistent drag reference }
  273. };
  274.  
  275. // from WEMouse.c
  276. enum {
  277.     noDragErr = 128,
  278.     kTextMargin = 3,        // { width of border area surrounding the text (in pixels) }
  279.     kAutoScrollDelay = 10    // { delay before auto-scroll starts (in ticks) }
  280. };
  281.  
  282.  
  283. static long kOneToOneScaling = 0x00010001;        // { 1:1 scaling ratio }
  284.  
  285. // { WETextStyle is just a familiar TextStyle record as defined by TextEdit, where }
  286. // { tsFace is redefined as SignedByte (rather than Style) so that the filler byte }
  287. // { becomes "visible" from Pascal and can be used to store internal flags }
  288.  
  289. #if defined(powerc) || defined (__powerc)
  290. #pragma options align=mac68k
  291. #endif
  292.  
  293. typedef struct WETextStyle {
  294.     short tsFont;                /* font family number */
  295.     char tsFace;                /* set of QuickDraw styles */
  296.     char tsFlags;                /* flags (FOR INTERNAL USE ONLY) */
  297.     short tsSize;                /* font size, in integer points */
  298.     RGBColor tsColor;            /* absolute red-green-blue color */
  299.     Handle tsObject;            // { handle to object descriptor }
  300. } WETextStyle, *WETextStylePtr, **WETextStyleHandle;
  301.  
  302. typedef struct WERunAttributes {
  303.     short runHeight;            /* style run height (ascent + descent + leading) */
  304.     short runAscent;            /* font ascent */
  305.     WETextStyle runStyle;        /* text style */
  306. } WERunAttributes, *WERunAttributesPtr, **WERunAttributesHandle;
  307.  
  308. typedef struct WERunInfo {
  309.     long runStart;                /* byte offset to first character of this style run */
  310.     long runEnd;                /* byte offset to first character of next style run */
  311.     WERunAttributes runAttrs;    /* run attributes */
  312. } WERunInfo, *WERunInfoPtr, **WERunInfoHandle;
  313.  
  314. typedef struct WEStyleScrapElement {
  315.     long scrpStartChar;
  316.     WERunAttributes scrpAttrs;
  317. } WEStyleScrapElement, *WEStyleScrapElementPtr, **WEStyleScrapElementHandle;
  318.  
  319. // { another "view" for the familiar TextEdit 'styl' Clipboard type }
  320. /*
  321. typedef struct WEStyleScrap {
  322.     short scrpNStyles;
  323.     WEStyleScrapElement scrpStyleTab[1];
  324. } WEStyleScrap, *WEStyleScrapPtr, **WEStyleScrapHandle;
  325. */
  326. // { the purpose of the GrafPort1 declaration is to redefine the txFace field as SignedByte, }
  327. // { rather than Style ( = set of StyleItem), to avoid using THINK Pascal runtime routines }
  328. // { for set manipulation }
  329.  
  330. typedef struct GrafPort1
  331. {
  332.     short                        device;
  333.     BitMap                        portBits;
  334.     Rect                        portRect;
  335.     RgnHandle                    visRgn;
  336.     RgnHandle                    clipRgn;
  337.     Pattern                        bkPat;
  338.     Pattern                        fillPat;
  339.     Point                        pnLoc;
  340.     Point                        pnSize;
  341.     short                        pnMode;
  342.     Pattern                        pnPat;
  343.     short                        pnVis;
  344.     short                        txFont;
  345.     char                        txFace;
  346.     char                        filler;
  347.     short                        txMode;
  348.     short                        txSize;
  349.     Fixed                        spExtra;
  350.     long                        fgColor;
  351.     long                        bkColor;
  352.     short                        colrBit;
  353.     short                        patStretch;
  354.     Handle                        picSave;
  355.     Handle                        rgnSave;
  356.     Handle                        polySave;
  357.     QDProcsPtr                    grafProcs;
  358. } GrafPort1, *GrafPtr1;
  359.  
  360. typedef struct QDEnvironment {
  361.     GrafPtr envPort;
  362.     PenState envPen;
  363.     WETextStyle envStyle;
  364.     short envMode;
  365. } QDEnvironment;
  366.  
  367. typedef struct RunArrayElement {
  368.     long runStart;                        // { offset to first character in style run }
  369.     long styleIndex;                    // { index into style table (high word currently unused) }
  370. } RunArrayElement, *RunArrayElementPtr, **RunArrayElementHandle;
  371.  
  372. typedef struct RunArrayPair {
  373.     RunArrayElement first;
  374.     RunArrayElement second;
  375. } RunArrayPair, *RunArrayPeek;
  376.  
  377. typedef struct TERunAttributes {
  378.     short runHeight;
  379.     short runAscent;
  380.     TextStyle runTEStyle;
  381. } TERunAttributes, *TERunAttributesPtr;
  382.  
  383. typedef struct TEStyleScrapElement {
  384.     long scrpStartChar;
  385.     TERunAttributes scrpTEAttrs;
  386. } TEStyleScrapElement, *TEStyleScrapElementPtr;
  387.  
  388. typedef struct TEStyleScrap {
  389.     short scrpNStyles;
  390.     TEStyleScrapElement *scrpStyleTab;
  391. } TEStyleScrap, *TEStyleScrapPtr, **TEStyleScrapHandle;
  392.  
  393. typedef struct TEStyleScrapPair {
  394.     TEStyleScrapElement first;
  395.     TEStyleScrapElement second;
  396. } TEStyleScrapPair, *TEStyleScrapPeek;
  397.  
  398.  
  399. // const kRunArrayMaxIndex = (maxLong / sizeOf(RunArrayElement)) - 1;
  400.  
  401. typedef RunArrayElement *RunArrayPtr;
  402. typedef RunArrayPtr *RunArrayHandle;
  403.  
  404. typedef struct StyleTableElement {
  405.     long refCount;                    // { reference count }
  406.     WERunAttributes info;            // { style information }
  407. } StyleTableElement, *StyleTableElementPtr, **StyleTableElementHandle;
  408.  
  409. //        kStyleTableMaxIndex = (maxint div SizeOf(StyleTableElement)) - 1;
  410.  
  411. typedef StyleTableElement *StyleTablePtr;
  412. typedef StyleTablePtr *StyleTableHandle;
  413.  
  414. typedef struct LineRec {
  415.     long lineStart;                /* byte offset to first character in line */
  416.     long lineOrigin;            /* pixel offset from destRect.top */
  417.     short lineAscent;            /* maximum font ascent for this line */
  418.     short lineSlop;                /* extra pixels needed to fill up the line */
  419.     Fixed lineJustAmount;        /* normalized slop value, used for justification */
  420. } LineRec, *LinePtr, **LineHandle;
  421.  
  422.  
  423. typedef struct LinePair {
  424.     LineRec first;
  425.     LineRec second;
  426. } LinePair, *LinePeek;
  427.  
  428. //        kLineArrayMaxIndex = (maxLongInt div SizeOf(LineRec)) - 1;
  429.  
  430. typedef LineRec *LineArrayPtr;
  431. typedef LineArrayPtr *LineArrayHandle;
  432.  
  433. typedef struct    WERec {
  434.     GrafPtr port;                /* graphics port text is drawn into */
  435.     Handle hText;                /* handle to the text */
  436.     LineArrayHandle hLines;        /* handle to the line array */
  437.     StyleTableHandle hStyles;    /* handle to the style table */
  438.     RunArrayHandle hRuns;        /* handle to the style run array */
  439.     long textLength;            /* length of text */
  440.     long nLines;                /* number of lines */
  441.     long nStyles;                /* number of unique styles in the style table */
  442.     long nRuns;                    /* number of style runs */
  443.     LongRect viewRect;            /* view rectangle, all drawing is clipped to this */
  444.     LongRect destRect;            /* destination rectangle */
  445.     long selStart;                /* start of selection range */
  446.     long selEnd;                /* end of selection range */
  447.     long flags;                    /* 32 bits of miscellaneous flags */
  448.     long caretTime;                /* time of most recent caret drawing, in ticks */
  449.     long clickTime;                /* time of most recent click, in ticks */
  450.     long clickLoc;                /* byte offset of most recent click */
  451.     long anchorStart;            /* start offset of anchor word/line */
  452.     long anchorEnd;                /* end offset of anchor word/line */
  453.     ProcPtr clickLoop;            /* click loop callback */
  454.     char unused1;                /* unused */
  455.     char clickEdge;                /* edge of character hit by most recent click */
  456.     char unused2;                /* unused */
  457.     char firstByte;                /* first byte of a double-byte character */
  458.     GrafPtr offscreenPort;        /* offscreen graphics world */
  459.     RgnHandle viewRgn;            /* handle to the view region */
  460.     ProcPtr scrollProc;            /* scroll callback */
  461.     short clickCount;            /* multiple click count */    
  462.     char alignment;                /* alignment style */
  463.     long refCon;                /* reference value for client use */
  464.     TSMDocumentID tsmReference;    /* reference value for the text services manager */
  465.     long tsmAreaStart;            /* start of active input area (for TSM) */
  466.     long tsmAreaEnd;            /* end of active input area */
  467.     ProcPtr tsmPreUpdate;        /* TSM pre-update callback */
  468.     ProcPtr tsmPostUpdate;        /* TSM post-update callback */
  469.     DragReference currentDrag;    /* refereence of drag being tracked by _WEDrag */
  470.     long dragCaretOffset;        /* offset to caret displayed during a drag */
  471.     Handle hActionStack;        /* action stack for undo */
  472.     WERunAttributes nullStyle;    /* style for null selection */
  473. } WERec, *WEPtr, **WEHandle;
  474.  
  475.  
  476. typedef struct WEAction {
  477.     WEHandle hOwner;            // handle to associated WE instance
  478.     struct WEAction **hNext;    // used to keep a linked list of actions
  479.     Handle hText;                // handle to saved text
  480.     Handle hStyles;                // handle to saved styles
  481.     Handle hSoup;                // handle to saved "soup"
  482.     long delRangeStart;            // start of range to delete
  483.     long delRangeLength;        // length of range to delete
  484.     long insRangeLength;        // lenfth of range to insert
  485.     long hiliteStart;            // start of range to hilite
  486.     long hiliteEnd;                // end of range to hilite
  487.     WEActionKind actionKind;    // identifies event that caused this action to be pushed
  488.     WEActionFlags actionFlags;    // miscellaneous flags
  489. } WEAction, *WEActionPtr, **WEActionHandle;
  490.  
  491. typedef struct WEObjectDesc {
  492.     OSType objectType;            // { 4-letter tag identifying object type }
  493.     Handle objectDataHandle;    // { handle to object data }
  494.     Point objectSize;            // { object height and width, in pixels }
  495.     short objectIndex;            // { index into object handler table (USED INTERNALLY) }
  496.     WEHandle objectOwner;        // { handle to owner WE instance }
  497.     long objectRefCon;            // { free for use by object handlers }
  498. } WEObjectDesc, *WEObjectDescPtr, **WEObjectDescHandle;
  499.  
  500. // { a WESoup record describes an object embedded in the text }
  501. // { the 'SOUP' clipboard type is just a collection of WESoup records }
  502. // { this clipboard type complements the standard TEXT/styl pair }
  503.  
  504. typedef struct WESoup {
  505.     long soupOffset;            // { insertion offset for this object }
  506.     OSType soupType;            // { 4-letter tag identifying object type }
  507.     long soupReserved1;            // { reserved for future use; set to zero }
  508.     Size soupDataSize;            // { size of object data (following this record) }
  509.     Point soupSize;                // { object height and width, in pixels }
  510.     long soupReserved2;            // { reserved for future use; set to zero }
  511.     WEObjectDesc soupDesc;        // { object descriptor }
  512. } WESoup, *WESoupPtr, **WESoupHandle;
  513.  
  514. /*    callback prototypes */
  515.  
  516. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  517. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  518. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  519. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  520.         long fixLength, long inputAreaStart, long inputAreaEnd,
  521.         long pinRangeStart, long pinRangeEnd);
  522. typedef pascal OSErr (*WENewObjectProcPtr)(WEObjectDescHandle objectRef,
  523.         Point *defaultObjectSize);
  524. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectDescHandle objectRef);
  525. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  526.         WEObjectDescHandle objectRef);
  527.  
  528. typedef Boolean (*SegmentLoopProcPtr)
  529.                 (LinePtr pLine,
  530.                  WERunAttributesPtr pAttrs,
  531.                  Ptr pSegment,
  532.                  long segmentStart,
  533.                  long segmentLength,
  534.                  JustStyleCode styleRunPosition,
  535.                  void *callbackData);
  536.  
  537. struct SLDrawData {
  538.     WEPtr pWE;
  539.     Rect bounds;                /* same rectangle, but in global coords */
  540.     Boolean usingColor;            /* true if drawing in color */
  541.     Boolean usingOffscreen;        /* true if an offscreen graphics world has been set up */
  542.     Boolean drawingOffscreen;    /* true if actually drawing to an offscreen buffer */
  543.     Boolean doErase;
  544. };
  545.  
  546. struct SLCalcSlopData {
  547.     WEPtr pWE;
  548.     short lineWidth;
  549.     short totalSlop;
  550.     Fixed totalProportion;
  551. };
  552.  
  553. struct SLPixelToCharData {
  554.     WEPtr pWE;
  555. #ifdef WASTE_TABS
  556.     Fixed hPos;
  557. #endif
  558.     Fixed pixelWidth;
  559.     long offset;
  560.     char *edge;
  561. };
  562.  
  563. struct SLCharToPixelData {
  564.     WEPtr pWE;
  565.     long offset;
  566.     LongPt *thePoint;
  567. };
  568.  
  569. typedef struct WEFieldDescriptor {
  570.     short fOffset;
  571.     short fLength;
  572. } WEFieldDescriptor;
  573.  
  574. typedef struct WELookupTable {
  575.     OSType selector;
  576.     WEFieldDescriptor desc;
  577. } WELookupTable;
  578.  
  579. #if defined(powerc) || defined (__powerc)
  580. #pragma options align=reset
  581. #endif
  582.  
  583.  
  584. // Routines in WEUtilities.c
  585.  
  586. pascal void _WEForgetHandle(Handle *h);
  587. pascal Boolean _WESetHandleLock(Handle h, Boolean lock);
  588. pascal void _WEBlockClr(Ptr block, long blockSize);
  589. pascal Boolean _WEBlockCmp(Ptr block1, Ptr block2, long blockSize);
  590. pascal void _WEReorder(long *a, long *b);
  591. pascal OSErr _WEAllocate(Size blockSize, short allocFlags, Handle *h);
  592.  
  593. // in WEArrays.c
  594. pascal OSErr _WEInsertSlot(Handle h, Ptr element, long insertAt, long slotSize);
  595. pascal OSErr _WERemoveSlot(Handle h, long removeAt, long slotSize);
  596.  
  597. // in WEInlineInput.c
  598. pascal OSErr _WEHiliteRangeArray(TextRangeArrayHandle hTray, WEHandle hWE);
  599. pascal OSErr _WEHandleUpdateActiveInputArea(AppleEvent *ae, AppleEvent *reply,
  600.         long handlerRefCon);
  601. pascal OSErr _WEHandlePositionToOffset(AppleEvent *ae, AppleEvent *reply,
  602.         long handlerRefCon);
  603. pascal OSErr _WEHandleOffsetToPosition(AppleEvent *ae, AppleEvent *reply, long handlerRefCon);
  604. pascal OSErr WEInstallTSMHandlers(void);
  605.  
  606. // in WELongCoords.c
  607. pascal long _WEPinInRange(long value, long rangeStart, long rangeEnd);
  608. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  609. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  610. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  611. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  612. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  613. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  614. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  615.  
  616. // in WEDrawing.c
  617. pascal long WEOffsetToLine (long offset, WEHandle hWE);
  618. pascal long _WEPixelToLine(long vOffset, WEHandle hWE);
  619. pascal long _WEOffsetToRun (long offset, WEHandle hWE);
  620. pascal void _WEGetIndStyle(long runIndex, WERunInfo *info, WEHandle hWE);
  621. pascal void WEGetRunInfo(long offset, WERunInfo *info, WEHandle hWE);
  622. pascal Boolean _WEIsEmbeddedObject(long offset, WEObjectDescHandle *hObjectDesc, WEHandle hWE);
  623. pascal void _WEContinuousStyleRange(long rangeStart, long rangeEnd, short *mode,
  624.         WETextStyle *ts, WEHandle hWE);
  625. pascal void _WESynchNullStyle(WEHandle hWE);
  626. pascal Boolean WEContinuousStyle (short *mode, TextStyle *ts, WEHandle hWE);
  627. pascal void _WESegmentLoop(long firstLine, long lastLine, SegmentLoopProcPtr callback, void *callbackData,
  628.         WEHandle hWE);
  629. pascal void _WEDrawTSMHilite(Rect *segmentRect, short tsFlags);
  630. pascal void _WEDrawLines (long firstLine, long lastLine, Boolean doErase, WEHandle hWE);
  631. pascal short _WECalcPenIndent(short slop, short alignment);
  632. pascal void _WESaveQDEnvironment(GrafPtr port, Boolean saveColor, QDEnvironment *theEnvironment);
  633. pascal void _WERestoreQDEnvironment(QDEnvironment *theEnvironment);
  634. pascal void _WEFillFontInfo (GrafPtr port, WERunAttributes *targetStyle);
  635. pascal void _WECopyStyle (WETextStyle *sourceStyle, WETextStyle *targetStyle, short offStyles,
  636.         short mode);
  637. pascal Boolean _WEOffsetInRange(long offset, char edge, long rangeStart, long rangeEnd);
  638.  
  639. /*** in WELineLayout.c ***/
  640. pascal OSErr _WERegisterWithTSM(WEHandle hWE);
  641. pascal void WEStopInlineSession(WEHandle hWE);
  642. pascal OSErr WENew(LongRect *destRect, LongRect *viewRect, short flags, WEHandle *hWE);
  643. pascal void WEDispose(WEHandle hWE);
  644. pascal OSErr _WERemoveLine(long lineIndex, WEPtr pWE);
  645. pascal OSErr InsertLine(long lineIndex, LineRec *theLine, WEPtr pWE);
  646. pascal void _WEBumpOrigin(long lineIndex, long deltaOrigin, WEPtr pWE);
  647. pascal long _WEFindLineBreak(long lineStart, WEHandle hWE);
  648. pascal void _WECalcHeights(long rangeStart, long rangeEnd, short *lineAscent, short *lineDescent,
  649.         WEHandle hWE);
  650. pascal OSErr _WERecalBreaks(long *startLine, long *endLine, WEHandle hWE);
  651. pascal void _WERecalSlops(long firstLine, long lastLine, WEHandle hWE);
  652. pascal OSErr WECalText(WEHandle hWE);
  653. pascal OSErr WEUseText(Handle text, WEHandle hWE);
  654. pascal char WEGetAlignment(WEHandle hWE);
  655. pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
  656. pascal void WESetDestRect(LongRect *destRect, WEHandle hWE);
  657. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  658. pascal void WESetViewRect(LongRect *viewRect, WEHandle hWE);
  659. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  660. pascal long WEGetTextLength(WEHandle hWE);
  661. pascal long WECountLines(WEHandle hWE);
  662. pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
  663. pascal Handle WEGetText(WEHandle hWE);
  664. pascal char WEGetChar(long offset, WEHandle hWE);
  665. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, Handle
  666.                     hStyles, Handle hSoup, WEHandle hWE);
  667. pascal OSErr WECopy(WEHandle hWE);
  668. pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
  669.  
  670. // WESelecting.c
  671. pascal void ClearHiliteBit(void);
  672. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEHandle hWE);
  673. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEHandle hWE);
  674. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
  675. pascal long _WEGetLineStart(long lineNo, WEHandle hWE);
  676. pascal short _WEGetContext(long offset, long *contextStart, long *contextEnd,
  677.                         WEHandle hWE);
  678. pascal short _WEGetRestrictedContext(long offset, long *contextStart, long *contextEnd,
  679.                         WEHandle hWE);
  680. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
  681. pascal short WECharByte(long offset, WEHandle hWE);
  682. pascal short WECharType(long offset, WEHandle hWE);
  683. pascal void _WEDrawCaret(long offset, WEHandle hWE);
  684. pascal void _WEBlinkCaret(WEHandle hWE);
  685. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEHandle hWE);
  686. pascal void _WEHiliteRange(long rangeStart, long rangeEnd, WEHandle hWE);
  687. pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
  688. pascal void WESetAlignment(char alignment, WEHandle hWE);
  689. pascal long _WEArrowOffset(short action, long offset, WEHandle hWE);
  690. pascal void _WEDoArrowKey (short arrow, short modifiers, WEHandle hWE);
  691. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  692. pascal void WEIdle(long *maxSleep, WEHandle hWE);
  693. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  694. pascal void WEDeactivate(WEHandle hWE);
  695. pascal void WEActivate(WEHandle hWE);
  696. pascal Boolean WEIsActive(WEHandle hWE);
  697. pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
  698. pascal Boolean _WEScrollIntoView (long offset, WEHandle hWE);
  699. pascal void WESelView(WEHandle hWE);
  700.  
  701. // WELowLevelEditing.c
  702. pascal Boolean _WEIsWordRange(long rangeStart, long rangeEnd, WEHandle hWE);
  703. pascal Boolean _WEIsPunct(long offset, WEHandle hWE);
  704. pascal void _WEIntelligentCut(long *rangeStart, long *rangeEnd, WEHandle hWE);
  705. pascal short _WEInteectDesc);
  706. pascal OSErr _WEFreeObject(WEObjectDescHandle hObjectDesc);
  707. pascal OSErr _WEDrawObject(WEObjectDescHandle hObjectDesc);
  708. pascal OSErr WEInstallObjectHandler(OSType objectType, OSType handlerSelector, ProcPtr handler);
  709.  
  710.  
  711. /*** in WESelectors.c ***/
  712. #define weUndefinedSelectorErr            -50 /* paramErr */
  713.  
  714. pascal void _WELookupSelector(WELookupTable *table, OSType selector, WEFieldDescriptor *desc);
  715. pascal OSErr _WEGetField(WELookupTable *table, OSType selector, long *info, void *structure);
  716. pascal OSErr _WESetField(WELookupTable *table, OSType selector, long *info, void *structure);
  717. pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
  718. pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
  719.  
  720.  
  721.