home *** CD-ROM | disk | FTP | other *** search
- /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
- /* UTranscriptView.p */
- /* Copyright © 1985-1990 Apple Computer, Inc. All rights reserved. */
- /* This unit implements the debug window, called the "transcript view." TTranscriptView
- is not
- for the faint of heart, but it is possible to subclass it and override its methods, thereby
- customizing the debug window's behavior (but not the debugger's behaviour since the debugger
- USES a TTranscriptView). */
- #ifndef __UTranscriptView__
- #define __UTranscriptView__ 0
- #endif
- #if ! __UTranscriptView__
- #define __UTranscriptView__ 1
-
- /* • Auto-Include the requirements for this unit's interface. */
- #ifndef __UMacApp__
- #include "UMacApp.h"
- #endif
-
- const short kHMargin = 4;
- const short kVMargin = 4;
- const short kWWEol ='\n'; /* Character to consider the line break */
- const short kForceDepth = 10;
- /* Maximum number of forceOption changes that
- will be remembered */
-
- typedef enum {WrForceOn, WrForceOff, WrForceUnchanged} WrForceOptions; /* corresponds to
- TrcForceOptions. See TTranscriptView.ForceOutput and .EndForce. */
-
- typedef unsigned char AText[10001];
- typedef AText *TextPtr;
- typedef TextPtr *TextHandle; /* Handy (get it? handy) way of referring to
- the stored text */
-
- typedef short ALineLens[10001]; /* Kinda like a brain damaged TE, we
- keep track of line lengths to aid
- in rendering */
- typedef ALineLens *LineLensPtr;
- typedef LineLensPtr *LineLensHandle;
-
- struct ForceState {
- /* If toWindow is TRUE, output to the window.
- If toFile is TRUE, output to the redirect
- file. A stack of these is maintained by
- the TTranscriptView. */
- Boolean toWindow;
- Boolean toFile;
- };
-
- class TTranscriptView : public TView {
- public:
- /* C A U T I O N -- this object is not really
- for public consumption. Use it at your own
- risk! */
- Boolean fWrToWindow;
- /* set to TRUE to enable writelns to window */
- Boolean fWrToFile; /* set to TRUE to enable writelns to file */
- short fCols; /* Max characters per line */
- short fRows; /* Number of lines saved. After this number
- of lines is exceeded, the oldest lines
- start falling off. */
- short fTotal;
- /* number of characters in all lines together
- */
- TextHandle fText; /* the ring buffer: blanks pad each line to
- 80 chars */
- LineLensHandle fLineLengths; /* linelength of each line.
- fBufferLinesLens^^[0] is # of characters
- in the line that begins with fText^^[0] */
- LineLensHandle fLineStarts; /* offset into the fText handle of the first
- character in the line*/
- short fFirstLineIndex; /* index where in the linelengths/starts
- array the top line starts */
-
- TextStyle fTextStyle; /* The style to with which to display the
- view */
- FontInfo fFontInfo; /* Font Info derived from the style */
- short fFontHeight; /* font height */
-
- Boolean fGotRefnum; /* TRUE if there is a valid file refnum in
- fRefnum and fVRefNum. */
- short fRefnum; /* refnum for redirect output */
- short fVRefNum; /* vRefNum for redirected output. */
-
- ForceState fForceStack[10];
- /* A stack of forced output
- states. ForceOutput and
- EndForce methods push
- and pop this stack,
-
- respectively. */
- short fForcePtr; /* Top of the stack in fForceStack. */
-
- Ptr fHelpProc; /* Call this to show help in response to the
- "Help" key. Default is no help. */
- long fLastInsertionPointTime; /* Last time InsertionPoint was on */
- Boolean fInsertionPointOn; /* True if InsertionPoint was turned on by
- idle */
- Point fInsertionPt;
- /* location of the insertion pt in Row, col */
- short fLastCh; /* last character typed */
- RgnHandle fUpdateRgn; /* used in scrolling shortcut */
-
- virtual pascal Boolean DoIdle(IdlePhase phase);
- /* Blinks the insertion point. */
-
- virtual pascal TCommand *DoHelp(EventInfo *info, long *message);
- /* If fHelpis non-NIL, it is called. Called in response to a "Help" keypress. */
-
- virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
-
- /* Handles return, enter, arrows, home, end, and help keys only - they all perform the
- natural scrolling actions. Sets fLastCh to ch. */
-
- virtual pascal void Draw(Rect *area);
- /* Draws the visible portion of the stored text. */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this classes
- fields. */
-
- virtual pascal void Free(void);
- /* Frees the text buffers before freeing SELF. Turns off output redirection if it is
- on. */
-
- virtual pascal Boolean HandleMouseDown(VPoint *theMouse, EventInfo *info, Point *hysteresis,
- TCommand **theCommand);
- /* Calls INHERITED HandleMouseDown. */
-
- /* TranscriptWindow Specific methods */
- virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
-
- /* Calls INHERITED IRes, SELF.CommonInit, then sets the view size to the correct size
- for the line width. */
-
- virtual pascal void AddText(Ptr textBuf, short byteCount);
- /* If fWrToWindow is currently TRUE, inserts the text in textBuf at the current
- insertion point. If fWrToFile is true, calls SELF.AddTextToFile to append textBuf
- to the redirect file. Can handle backspace characters and multiple line feeds in
- textBuf. */
-
- virtual pascal void AddTextToFile(Ptr textBuf, short byteCount);
- /* Appends the text in textBuf to the file fRefNum. */
-
- virtual pascal void RevealInsertionPoint(void);
- /* Scrolls the insertion point into view. */
-
- virtual pascal void EndForce(void);
-
- /* Sets fWrToWindow and fWrToFile to their prior states by popping the old states off
- the fForceStack stack. */
-
- virtual pascal void ForceOutput(WrForceOptions wrToWindow, WrForceOptions wrToFile);
-
- /* Pushes the current states of fWrToWindow and fWrToFile onto the fForceStack stack,
-
- then sets them according to the arguments. If wrToWindow is not WrForceUnchanged,
-
- fWrToWindow is set to the boolean value of "wrToWindow = WrForceOn"; otherwise
- fWrToWindow is left unchanged. Likewise for wrToFile and fWrToFile. */
-
- virtual pascal Rect GetInsertionPointRect(void);
- /* Returns the rectangle which defines the insertion point. */
-
- virtual pascal void CommonInit(TView *itsSuperView, short outputFont, short outputSize, short
- numLines, short numCharsPerLine);
- /* Performs general initialization of the view according to the arguments given. */
-
- virtual pascal void ITranscriptView(TView *itsSuperView, short outputFont, short outputSize,
- short numLines, short numCharsPerLine);
-
- /* Calls IView, then CommonInit, then sets the view size to the correct dimensions for
- the line width. */
-
- virtual pascal short PrevIndex(short ln);
- /* Returns the index into the line buffers for the line immediately preceeding ln,
-
- wrapping backwards if necessary. */
-
- virtual pascal short SuccIndex(short ln);
- /* Returns the index into the line buffers for the line immediately succeeding ln,
-
- wrapping to 0 if necessary. */
-
- virtual pascal short IndexToRow(short index);
- /* Converts index from an index into the line buffers into a relative line number in
- the output. */
-
- virtual pascal short RowToIndex(short row);
- /* Converts the output line number row into its index into the line buffers. */
-
- virtual pascal short IndexToLocal(short index);
-
- /* Converts an index into the line buffers into a vertical local drawing coordinate in
- the view. */
-
- virtual pascal void InstallTextStyle(TextStyle *theStyle);
- /* Makes theStyle the text style for the view, resizing as necessary. */
-
- virtual pascal short LocalToIndex(short local);
- /* Converts a vertical local drawing coordinate in the view into an index into the
- line buffers. */
-
- virtual pascal Point IndexColToLocal(short index, short col);
- /* Converts an index into the line buffers and a column number into local drawing
- coordinates. */
-
- virtual pascal short LocalToCol(short local);
- /* Converts a horizontal drawing coordinate into a column number. */
-
- virtual pascal OSErr Redirect(short vRefnum, StringPtr fileName);
- /* Opens the given file for the purpose of redirecting output. If fileName contains
- '>>', the file is opened for append; otherwise, it is truncated to zero length
- first. Does not set the fWrToFile state variable. */
-
- virtual pascal void Scroll(short howManyLines);
- /* Scrolls the view by howManyLines lines. */
-
- virtual pascal void RevealInsertionPointLine(void);
- /* Scrolls the insertion point into view. */
- };
-
- extern pascal void IDUTranscriptView(void);
- /* Displays the compile date and time of this unit. */
-
- #endif
-
-