Added missing shell/macroMenuValid initializations.
[nedit.git] / source / textBuf.h
blobd8ac891cc8d456f0b3c337db3c990a5bb23badca
1 /* $Id: textBuf.h,v 1.15 2003/11/22 13:03:40 edg Exp $ */
3 #ifndef NEDIT_TEXTBUF_H_INCLUDED
4 #define NEDIT_TEXTBUF_H_INCLUDED
6 /* Maximum length in characters of a tab or control character expansion
7 of a single buffer character */
8 #define MAX_EXP_CHAR_LEN 20
10 typedef struct _RangesetTable RangesetTable;
12 typedef struct {
13 char selected; /* True if the selection is active */
14 char rectangular; /* True if the selection is rectangular */
15 char zeroWidth; /* Width 0 selections aren't "real" selections, but
16 they can be useful when creating rectangular
17 selections from the keyboard. */
18 int start; /* Pos. of start of selection, or if rectangular
19 start of line containing it. */
20 int end; /* Pos. of end of selection, or if rectangular
21 end of line containing it. */
22 int rectStart; /* Indent of left edge of rect. selection */
23 int rectEnd; /* Indent of right edge of rect. selection */
24 } selection;
26 typedef void (*bufModifyCallbackProc)(int pos, int nInserted, int nDeleted,
27 int nRestyled, char *deletedText, void *cbArg);
28 typedef void (*bufPreDeleteCallbackProc)(int pos, int nDeleted, void *cbArg);
30 typedef struct _textBuffer {
31 int length; /* length of the text in the buffer (the length
32 of the buffer itself must be calculated:
33 gapEnd - gapStart + length) */
34 char *buf; /* allocated memory where the text is stored */
35 int gapStart; /* points to the first character of the gap */
36 int gapEnd; /* points to the first char after the gap */
37 selection primary; /* highlighted areas */
38 selection secondary;
39 selection highlight;
40 int tabDist; /* equiv. number of characters in a tab */
41 int useTabs; /* True if buffer routines are allowed to use
42 tabs for padding in rectangular operations */
43 int nModifyProcs; /* number of modify-redisplay procs attached */
44 bufModifyCallbackProc /* procedures to call when buffer is */
45 *modifyProcs; /* modified to redisplay contents */
46 void **cbArgs; /* caller arguments for modifyProcs above */
47 int nPreDeleteProcs; /* number of pre-delete procs attached */
48 bufPreDeleteCallbackProc /* procedure to call before text is deleted */
49 *preDeleteProcs; /* from the buffer; at most one is supported. */
50 void **preDeleteCbArgs; /* caller argument for pre-delete proc above */
51 int cursorPosHint; /* hint for reasonable cursor position after
52 a buffer modification operation */
53 char nullSubsChar; /* NEdit is based on C null-terminated strings,
54 so ascii-nul characters must be substituted
55 with something else. This is the else, but
56 of course, things get quite messy when you
57 use it */
58 RangesetTable *rangesetTable;
59 /* current range sets */
60 } textBuffer;
62 textBuffer *BufCreate(void);
63 textBuffer *BufCreatePreallocated(int requestedSize);
64 void BufFree(textBuffer *buf);
65 char *BufGetAll(textBuffer *buf);
66 void BufSetAll(textBuffer *buf, const char *text);
67 char *BufGetRange(textBuffer *buf, int start, int end);
68 char BufGetCharacter(textBuffer *buf, int pos);
69 char *BufGetTextInRect(textBuffer *buf, int start, int end,
70 int rectStart, int rectEnd);
71 void BufInsert(textBuffer *buf, int pos, const char *text);
72 void BufRemove(textBuffer *buf, int start, int end);
73 void BufReplace(textBuffer *buf, int start, int end, const char *text);
74 void BufCopyFromBuf(textBuffer *fromBuf, textBuffer *toBuf, int fromStart,
75 int fromEnd, int toPos);
76 void BufInsertCol(textBuffer *buf, int column, int startPos, const char *text,
77 int *charsInserted, int *charsDeleted);
78 void BufReplaceRect(textBuffer *buf, int start, int end, int rectStart,
79 int rectEnd, const char *text);
80 void BufRemoveRect(textBuffer *buf, int start, int end, int rectStart,
81 int rectEnd);
82 void BufOverlayRect(textBuffer *buf, int startPos, int rectStart,
83 int rectEnd, const char *text, int *charsInserted, int *charsDeleted);
84 void BufClearRect(textBuffer *buf, int start, int end, int rectStart,
85 int rectEnd);
86 int BufGetTabDistance(textBuffer *buf);
87 void BufSetTabDistance(textBuffer *buf, int tabDist);
88 void BufCheckDisplay(textBuffer *buf, int start, int end);
89 void BufSelect(textBuffer *buf, int start, int end);
90 void BufUnselect(textBuffer *buf);
91 void BufRectSelect(textBuffer *buf, int start, int end, int rectStart,
92 int rectEnd);
93 int BufGetSelectionPos(textBuffer *buf, int *start, int *end,
94 int *isRect, int *rectStart, int *rectEnd);
95 int BufGetEmptySelectionPos(textBuffer *buf, int *start, int *end,
96 int *isRect, int *rectStart, int *rectEnd);
97 char *BufGetSelectionText(textBuffer *buf);
98 void BufRemoveSelected(textBuffer *buf);
99 void BufReplaceSelected(textBuffer *buf, const char *text);
100 void BufSecondarySelect(textBuffer *buf, int start, int end);
101 void BufSecondaryUnselect(textBuffer *buf);
102 void BufSecRectSelect(textBuffer *buf, int start, int end,
103 int rectStart, int rectEnd);
104 int BufGetSecSelectPos(textBuffer *buf, int *start, int *end,
105 int *isRect, int *rectStart, int *rectEnd);
106 char *BufGetSecSelectText(textBuffer *buf);
107 void BufRemoveSecSelect(textBuffer *buf);
108 void BufReplaceSecSelect(textBuffer *buf, const char *text);
109 void BufHighlight(textBuffer *buf, int start, int end);
110 void BufUnhighlight(textBuffer *buf);
111 void BufRectHighlight(textBuffer *buf, int start, int end,
112 int rectStart, int rectEnd);
113 int BufGetHighlightPos(textBuffer *buf, int *start, int *end,
114 int *isRect, int *rectStart, int *rectEnd);
115 char *BufGetHighlightText(textBuffer *buf);
116 void BufAddModifyCB(textBuffer *buf, bufModifyCallbackProc bufModifiedCB,
117 void *cbArg);
118 void BufAddHighPriorityModifyCB(textBuffer *buf, bufModifyCallbackProc bufModifiedCB,
119 void *cbArg);
120 void BufRemoveModifyCB(textBuffer *buf, bufModifyCallbackProc bufModifiedCB,
121 void *cbArg);
122 void BufAddPreDeleteCB(textBuffer *buf, bufPreDeleteCallbackProc bufPreDeleteCB,
123 void *cbArg);
124 void BufRemovePreDeleteCB(textBuffer *buf, bufPreDeleteCallbackProc
125 bufPreDeleteCB, void *cbArg);
126 char *BufGetLineText(textBuffer *buf, int pos);
127 int BufStartOfLine(textBuffer *buf, int pos);
128 int BufEndOfLine(textBuffer *buf, int pos);
129 int BufGetExpandedChar(textBuffer *buf, int pos, int indent, char *outStr);
130 int BufExpandCharacter(char c, int indent, char *outStr, int tabDist,
131 char nullSubsChar);
132 int BufCharWidth(char c, int indent, int tabDist, char nullSubsChar);
133 int BufCountDispChars(textBuffer *buf, int lineStartPos, int targetPos);
134 int BufCountForwardDispChars(textBuffer *buf, int lineStartPos, int nChars);
135 int BufCountLines(textBuffer *buf, int startPos, int endPos);
136 int BufCountForwardNLines(textBuffer *buf, int startPos, int nLines);
137 int BufCountBackwardNLines(textBuffer *buf, int startPos, int nLines);
138 int BufSearchForward(textBuffer *buf, int startPos, const char *searchChars,
139 int *foundPos);
140 int BufSearchBackward(textBuffer *buf, int startPos, const char *searchChars,
141 int *foundPos);
142 int BufSubstituteNullChars(char *string, int length, textBuffer *buf);
143 void BufUnsubstituteNullChars(char *string, textBuffer *buf);
144 int BufCmp(textBuffer * buf, int pos, int len, const char *cmpText);
146 #endif /* NEDIT_TEXTBUF_H_INCLUDED */