home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Level 1 Extensions 29Sep94 / TextView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  7.5 KB  |  199 lines  |  [TEXT/KAHL]

  1. /* TextView.h */
  2.  
  3. #ifndef Included_TextView_h
  4. #define Included_TextView_h
  5.  
  6. /* TextView module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* TextStorage */
  12. /* EventLoop */
  13. /* Memory */
  14. /* Screen */
  15.  
  16. #include "Screen.h"
  17.  
  18. struct TextViewRec;
  19. typedef struct TextViewRec TextViewRec;
  20.  
  21. /* so we can avoid dragging include files into the header */
  22. struct FileType;
  23. struct TextStorageRec;
  24.  
  25. /* create a new text view object */
  26. TextViewRec*            NewTextView(WinType* Window, OrdType X, OrdType Y,
  27.                                         OrdType Width, OrdType Height, long SpacesPerTab,
  28.                                         FontType Font, FontSizeType PointSize);
  29.  
  30. /* dispose the text view object and all data it contains */
  31. void                            DisposeTextView(TextViewRec* View);
  32.  
  33.  
  34. /* find out where the text view object is located on the screen */
  35. OrdType                        GetTextViewXLoc(TextViewRec* View);
  36. OrdType                        GetTextViewYLoc(TextViewRec* View);
  37. OrdType                        GetTextViewWidth(TextViewRec* View);
  38. OrdType                        GetTextViewHeight(TextViewRec* View);
  39.  
  40. /* find out what font the text is being displayed in */
  41. FontType                    GetTextViewFont(TextViewRec* View);
  42. FontSizeType            GetTextViewPointSize(TextViewRec* View);
  43.  
  44. /* find out how many spaces are displayed for each tab */
  45. long                            GetTextViewSpacesPerTab(TextViewRec* View);
  46.  
  47. /* find out what the index of the top line on the display is */
  48. long                            GetTextViewTopLine(TextViewRec* View);
  49.  
  50. /* find out what the pixel position of the leftmost character displayed is */
  51. OrdType                        GetTextViewPixelIndent(TextViewRec* View);
  52.  
  53. /* returns True if the selection contains more than 0 characters */
  54. MyBoolean                    TextViewIsThereValidSelection(TextViewRec* View);
  55.  
  56. /* get the index of the starting line of the selection */
  57. long                            GetTextViewSelectStartLine(TextViewRec* View);
  58.  
  59. /* get the index of the last line of the selection */
  60. long                            GetTextViewSelectEndLine(TextViewRec* View);
  61.  
  62. /* get the index of the starting character of the selection */
  63. long                            GetTextViewSelectStartChar(TextViewRec* View);
  64.  
  65. /* get the index of the character after the end of the selection.  if the starting */
  66. /* line == ending line, and starting char == last char + 1, then there is no */
  67. /* selection, but instead an insertion point */
  68. long                            GetTextViewSelectEndCharPlusOne(TextViewRec* View);
  69.  
  70. /* find out if display of inverted selection text is enabled */
  71. MyBoolean                    TextViewIsShowSelectionEnabled(TextViewRec* View);
  72.  
  73. /* find out if any changes have been made to the text view object since */
  74. /* the last call to TextViewHasBeenSaved */
  75. MyBoolean                    TextViewDoesItNeedToBeSaved(TextViewRec* View);
  76.  
  77. /* see if the specified position is within the text view box */
  78. MyBoolean                    TextViewHitTest(TextViewRec* View, OrdType X, OrdType Y);
  79.  
  80. /* find out the total number of lines in the text view box */
  81. long                            GetTextViewNumLines(TextViewRec* View);
  82.  
  83. /* find out how many characters the specified line contains */
  84. long                            GetTextViewLineLength(TextViewRec* View, long LineIndex);
  85.  
  86. /* get the height of a line of text (font height) */
  87. OrdType                        GetTextViewLineHeight(TextViewRec* View);
  88.  
  89.  
  90. /* change where in the window the text view box is located */
  91. void                            SetTextViewPosition(TextViewRec* View, OrdType X, OrdType Y,
  92.                                         OrdType Width, OrdType Height);
  93.  
  94. /* change the font being used to display the text */
  95. void                            SetTextViewFontStuff(TextViewRec* View, FontType Font,
  96.                                         FontSizeType Size);
  97.  
  98. /* change the number of spaces displayed for each tab */
  99. void                            SetTextViewTabSize(TextViewRec* View, long SpacesPerTab);
  100.  
  101. /* set the index of the top line being displayed in the text box */
  102. void                            SetTextViewTopLine(TextViewRec* View, long NewTopLine);
  103.  
  104. /* set the index of the leftmost character in the text edit box */
  105. void                            SetTextViewPixelIndent(TextViewRec* View, OrdType NewPixelIndent);
  106.  
  107. /* set the selection to the specified area */
  108. void                            SetTextViewSelection(TextViewRec* View, long StartLine,
  109.                                         long StartChar, long EndLine, long EndCharPlusOne);
  110.  
  111. /* set the selection to an insertion point at the specified position */
  112. void                            SetTextViewInsertionPoint(TextViewRec* View, long Line, long Char);
  113.  
  114. /* enable the display of inverted selected text */
  115. void                            EnableTextViewSelection(TextViewRec* View);
  116.  
  117. /* disable the display of inverted selected text */
  118. void                            DisableTextViewSelection(TextViewRec* View);
  119.  
  120. /* indicate that any changes to the text have been recognized */
  121. void                            TextViewHasBeenSaved(TextViewRec* View);
  122.  
  123. /* break the specified line at the specified character index.  this is used */
  124. /* for when they hit carriage return in the middle of a line */
  125. MyBoolean                    TextViewBreakLine(TextViewRec* View, long LineIndex, long CharIndex);
  126.  
  127. /* concatenate the line after the specified line onto the end of the */
  128. /* specified line.  Used for hitting delete at the beginning of a line */
  129. MyBoolean                    TextViewFoldLines(TextViewRec* View, long LineIndex);
  130.  
  131.  
  132. /* do a complete redraw of the text view box */
  133. void                            TextViewFullRedraw(TextViewRec* View);
  134.  
  135. /* redraw the specified line */
  136. void                            TextViewRedrawLine(TextViewRec* View, long LineIndex);
  137.  
  138. /* redraw a series of lines */
  139. void                            TextViewRedrawRange(TextViewRec* View, long StartLine, long EndLine);
  140.  
  141. /* update the cursor.  this should be called every time there is an idle */
  142. /* event.  periodically, it will blink the insertion point state (if there */
  143. /* is no valid selection) */
  144. void                            TextViewUpdateCursor(TextViewRec* View);
  145.  
  146. /* find out the pixel index of the left edge of the specified character */
  147. OrdType                        TextViewScreenXFromCharIndex(TextViewRec* View, long LineIndex,
  148.                                         long CharIndex);
  149.  
  150. /* convert a pixel position into the nearest character */
  151. long                            TextViewCharIndexFromScreenX(TextViewRec* View, long LineIndex,
  152.                                         OrdType ScreenX);
  153.  
  154. /* find out how many lines are visible on the screen */
  155. long                            TextViewNumVisibleLines(TextViewRec* View);
  156.  
  157. /* get the width of the horizontal scrollable area */
  158. OrdType                        TextViewGetVirtualWindowWidth(TextViewRec* View);
  159.  
  160.  
  161. /* get a copy of the specified line */
  162. char*                            GetTextViewLine(TextViewRec* View, long LineIndex);
  163.  
  164. /* get a copy of the specified line, but first convert all tabs to the */
  165. /* appropriate number of spaces */
  166. char*                            GetTextViewSpaceFromTabLine(TextViewRec* View, long LineIndex);
  167.  
  168. /* given a character index, calculate where the corresponding position is */
  169. /* when tabs have been converted into spaces */
  170. long                            TextViewCalculateColumnFromCharIndex(TextViewRec* View,
  171.                                         long LineIndex, long CharIndex);
  172.  
  173. /* put a new line of data in.  data on the old line is replaced */
  174. MyBoolean                    SetTextViewLine(TextViewRec* View, long LineIndex, char* LineToCopy);
  175.  
  176. /* get a copy of the selected area */
  177. struct TextStorageRec*    TextViewGetSelection(TextViewRec* View);
  178.  
  179. /* delete the selection.  if this fails, the selection may have been partially */
  180. /* deleted */
  181. MyBoolean                    TextViewDeleteSelection(TextViewRec* View);
  182.  
  183. /* insert a new block of data at the insertion point, deleting any existing */
  184. /* selection first.  if this fails, the block may have been partially inserted */
  185. MyBoolean                    TextViewInsertBlock(TextViewRec* View, struct TextStorageRec* Data);
  186.  
  187. /* convert the text view box into a packed buffer of lines. */
  188. char*                            TextViewGetRawData(TextViewRec* View, char* EOLN);
  189.  
  190. /* delete the old data in the text view object and replace it with the */
  191. /* specified block of data */
  192. MyBoolean                    TextViewNewRawData(TextViewRec* View, char* EOLN, char* RawData);
  193.  
  194. /* write the data to a file.  returns True if successful */
  195. MyBoolean                    TextViewWriteDataToFile(TextViewRec* View,
  196.                                         struct FileType* FileRefNum, char* EOLN);
  197.  
  198. #endif
  199.