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 / TextStorage.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  4.1 KB  |  102 lines  |  [TEXT/KAHL]

  1. /* TextStorage.h */
  2.  
  3. #ifndef Included_DataText_h
  4. #define Included_DataText_h
  5.  
  6. /* TextStorage module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12. /* DataMunging */
  13. /* Array */
  14. /* Files */
  15. /* BufferedFileOutput */
  16.  
  17. struct TextStorageRec;
  18. typedef struct TextStorageRec TextStorageRec;
  19.  
  20. /* to avoid dragging Files.h into the header */
  21. struct FileType;
  22.  
  23. /* allocate a new structure for storing text type data */
  24. TextStorageRec*            NewTextStorage(void);
  25.  
  26. /* dispose the text storage structure and any data it contains */
  27. void                                DisposeTextStorage(TextStorageRec* Storage);
  28.  
  29. /* find out how many lines the text storage object contains */
  30. long                                TextStorageGetLineCount(TextStorageRec* Storage);
  31.  
  32. /* get a copy of the specified line */
  33. char*                                TextStorageGetLineCopy(TextStorageRec* Storage, long LineIndex);
  34.  
  35. /* get a pointer to the actual line as stored in the array.  this line should */
  36. /* not be modified in any way. */
  37. char*                                TextStorageGetActualLine(TextStorageRec* Storage, long LineIndex);
  38.  
  39. /* get the length of the specified line */
  40. long                                TextStorageGetLineLength(TextStorageRec* Storage, long LineIndex);
  41.  
  42. /* put a new line in the text storage object.  the original contents of the */
  43. /* specified line are deleted.  returns False if it couldn't be completed. */
  44. /* (it could fail since a copy of the line is made) */
  45. MyBoolean                        TextStorageChangeLine(TextStorageRec* Storage, long LineIndex,
  46.                                             char* NewLine);
  47.  
  48. /* insert a new empty line at the specified position.  returns False if it failed */
  49. MyBoolean                        TextStorageInsertLine(TextStorageRec* Storage, long LineIndex);
  50.  
  51. /* delete the line at the specified position */
  52. void                                TextStorageDeleteLine(TextStorageRec* Storage, long LineIndex);
  53.  
  54. /* break the line at the specified character index.  this is used for inserting */
  55. /* carriage returns. */
  56. MyBoolean                        TextStorageBreakLine(TextStorageRec* Storage, long LineIndex,
  57.                                             long CharIndex);
  58.  
  59. /* replace the line and the line after it with a single line containing the */
  60. /* second line concatenated onto the end of the first line */
  61. MyBoolean                        TextStorageFoldLines(TextStorageRec* Storage, long LineIndex);
  62.  
  63. /* extract part of the stored data in the form of another text storage object */
  64. TextStorageRec*            TextStorageExtractSection(TextStorageRec* Storage,
  65.                                             long StartLine, long StartChar, long EndLine, long EndChar);
  66.  
  67. /* delete the specified range of data from the storage.  returns False if it */
  68. /* failed.  if this routine fails, it may have left the task partially finished */
  69. MyBoolean                        TextStorageDeleteSection(TextStorageRec* Storage,
  70.                                             long StartLine, long StartChar, long EndLine, long EndChar);
  71.  
  72. /* insert a storage block at the specified position into this storage block. */
  73. /* returns False if it failed.  if it fails, then it may have actually inserted */
  74. /* some of the data into the storage record */
  75. MyBoolean                        TextStorageInsertSection(TextStorageRec* Storage,
  76.                                             long WhereLine, long WhereChar, TextStorageRec* Stuff);
  77.  
  78. /* if the end of line sequence is of the specified length, then calculate how */
  79. /* many characters a packed buffer of text would contain */
  80. long                                TextStorageTotalNumChars(TextStorageRec* Storage, long EOLNSize);
  81.  
  82. /* create a packed buffer of lines separated by the specified end of line sequence. */
  83. /* the end of line sequence is null terminated */
  84. char*                                TextStorageMakeRawBuffer(TextStorageRec* Storage, char* EOLNChar);
  85.  
  86. /* decode the packed buffer of lines and create a text storage record from it. */
  87. TextStorageRec*            TextStorageFromRawBuffer(char* Buffer, char* EOLNChar);
  88.  
  89. /* find out if the data has been changed since the last call to */
  90. /* TextStorageDataIsUpToDate */
  91. MyBoolean                        TextStorageHasDataChanged(TextStorageRec* Storage);
  92.  
  93. /* indicate that any changes in the data have been recognized */
  94. void                                TextStorageDataIsUpToDate(TextStorageRec* Storage);
  95.  
  96. /* write the entire buffer to a file using the specified end of line sequence. */
  97. /* returns True if successful */
  98. MyBoolean                        TextStorageWriteDataToFile(TextStorageRec* Storage,
  99.                                             struct FileType* FileRefNum, char* EOLN);
  100.  
  101. #endif
  102.