-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextbuffer.h
More file actions
116 lines (94 loc) · 3.11 KB
/
textbuffer.h
File metadata and controls
116 lines (94 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
#ifndef TEXTBUFFER_H
#define TEXTBUFFER_H
typedef struct textbuffer *TB;
typedef struct _matchNode {
int lineNumber;
int charIndex;
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, int 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