Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef TEXTBUFFER_H
- #define TEXTBUFFER_H
- #include <stdbool.h>
- typedef struct textbuffer *TB;
- typedef struct _matchNode {
- int lineNumber;
- int columnNumber;
- struct _matchNode* next;
- } matchNode;
- typedef matchNode *Match;
- /* Allocate a new textbuffer whose contents is initialised with the text given
- * in the array.
- */
- TB newTB (char text[]);
- /* Free the memory occupied by the given textbuffer. It is an error to access
- * the buffer afterwards.
- */
- void releaseTB (TB tb);
- /* Allocate and return an array containing the text in the given textbuffer.
- * add a prefix corrosponding to line number iff showLineNumbers == TRUE
- */
- char *dumpTB (TB tb, bool showLineNumbers);
- /* Return the number of lines of the given textbuffer.
- */
- int linesTB (TB tb);
- /* Add a given prefix to all lines between pos1 and pos2
- *
- * - The program is to abort() with an error message if line 'pos1' or line
- * 'pos2' is out of range. The first line of a textbuffer is at position 0.
- */
- void addPrefixTB (TB tb, int pos1, int pos2, char* prefix);
- /* Merge 'tb2' into 'tb1' at line 'pos'.
- *
- * - Afterwards line 0 of 'tb2' will be line 'pos' of 'tb1'.
- * - The old line 'pos' of 'tb1' will follow after the last line of 'tb2'.
- * - After this operation 'tb2' can not be used anymore (as if we had used
- * releaseTB() on it).
- * - The program is to abort() with an error message if 'pos' is out of range.
- */
- void mergeTB (TB tb1, int pos, TB tb2);
- /* Copy 'tb2' into 'tb1' at line 'pos'.
- *
- * - Afterwards line 0 of 'tb2' will be line 'pos' of 'tb1'.
- * - The old line 'pos' of 'tb1' will follow after the last line of 'tb2'.
- * - After this operation 'tb2' is unmodified and remains usable independent
- * of 'tb1'.
- * - The program is to abort() with an error message if 'pos' is out of range.
- */
- void pasteTB (TB tb1, int pos, TB tb2);
- /* Cut the lines between and including 'from' and 'to' out of the textbuffer
- * 'tb'.
- *
- * - The result is a new textbuffer (much as one created with newTB()).
- * - The cut lines will be deleted from 'tb'.
- * - The program is to abort() with an error message if 'from' or 'to' is out
- * of range.
- */
- TB cutTB (TB tb, int from, int to);
- /* Return a linked list of Match nodes of all the matches of string search
- * in tb
- *
- * - The textbuffer 'tb' will remain unmodified.
- * - The user is responsible of freeing the returned list
- */
- Match searchTB (TB tb, char* search);
- /* Remove the lines between and including 'from' and 'to' from the textbuffer
- * 'tb'.
- *
- * - The program is to abort() with an error message if 'from' or 'to' is out
- * of range.
- */
- void deleteTB (TB tb, int from, int to);
- /* Search every line of tb for each occurrence of a set of specified subsitituions
- * and alter them accordingly
- *
- * refer to spec for table.
- */
- void formRichText (TB tb);
- /* Your whitebox tests
- */
- void whiteBoxTests();
- /* Bonus Challenges
- */
- char* diffTB (TB tb1, TB tb2) ;
- void undoTB (TB tb) ;
- void redoTB (TB tb) ;
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement