More detail for Motif version, and change button labels on help browser to be more...
[nedit.git] / source / textBuf.h
blob3e27f75e52c4d33599723947539dc61e8cdc8961
1 /* $Id: textBuf.h,v 1.9 2002/07/11 21:18:11 slobasso 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 {
11 char selected;
12 char rectangular;
13 int start;
14 int end;
15 int rectStart;
16 int rectEnd;
17 } selection;
19 typedef void (*bufModifyCallbackProc)(int pos, int nInserted, int nDeleted,
20 int nRestyled, char *deletedText, void *cbArg);
21 typedef void (*bufPreDeleteCallbackProc)(int pos, int nDeleted, void *cbArg);
23 typedef struct _textBuffer {
24 int length; /* length of the text in the buffer (the length
25 of the buffer itself must be calculated:
26 gapEnd - gapStart + length) */
27 char *buf; /* allocated memory where the text is stored */
28 int gapStart; /* points to the first character of the gap */
29 int gapEnd; /* points to the first char after the gap */
30 selection primary; /* highlighted areas */
31 selection secondary;
32 selection highlight;
33 int tabDist; /* equiv. number of characters in a tab */
34 int useTabs; /* True if buffer routines are allowed to use
35 tabs for padding in rectangular operations */
36 int nModifyProcs; /* number of modify-redisplay procs attached */
37 bufModifyCallbackProc /* procedures to call when buffer is */
38 *modifyProcs; /* modified to redisplay contents */
39 void **cbArgs; /* caller arguments for modifyProcs above */
40 int nPreDeleteProcs; /* number of pre-delete procs attached */
41 bufPreDeleteCallbackProc /* procedure to call before text is deleted */
42 *preDeleteProcs; /* from the buffer; at most one is supported. */
43 void **preDeleteCbArgs; /* caller argument for pre-delete proc above */
44 int cursorPosHint; /* hint for reasonable cursor position after
45 a buffer modification operation */
46 char nullSubsChar; /* NEdit is based on C null-terminated strings,
47 so ascii-nul characters must be substituted
48 with something else. This is the else, but
49 of course, things get quite messy when you
50 use it */
51 } textBuffer;
53 textBuffer *BufCreate(void);
54 textBuffer *BufCreatePreallocated(int requestedSize);
55 void BufFree(textBuffer *buf);
56 char *BufGetAll(textBuffer *buf);
57 void BufSetAll(textBuffer *buf, const char *text);
58 char *BufGetRange(textBuffer *buf, int start, int end);
59 char BufGetCharacter(textBuffer *buf, int pos);
60 char *BufGetTextInRect(textBuffer *buf, int start, int end,
61 int rectStart, int rectEnd);
62 void BufInsert(textBuffer *buf, int pos, const char *text);
63 void BufRemove(textBuffer *buf, int start, int end);
64 void BufReplace(textBuffer *buf, int start, int end, const char *text);
65 void BufCopyFromBuf(textBuffer *fromBuf, textBuffer *toBuf, int fromStart,
66 int fromEnd, int toPos);
67 void BufInsertCol(textBuffer *buf, int column, int startPos, const char *text,
68 int *charsInserted, int *charsDeleted);
69 void BufReplaceRect(textBuffer *buf, int start, int end, int rectStart,
70 int rectEnd, const char *text);
71 void BufRemoveRect(textBuffer *buf, int start, int end, int rectStart,
72 int rectEnd);
73 void BufOverlayRect(textBuffer *buf, int startPos, int rectStart,
74 int rectEnd, const char *text, int *charsInserted, int *charsDeleted);
75 void BufClearRect(textBuffer *buf, int start, int end, int rectStart,
76 int rectEnd);
77 int BufGetTabDistance(textBuffer *buf);
78 void BufSetTabDistance(textBuffer *buf, int tabDist);
79 void BufSelect(textBuffer *buf, int start, int end);
80 void BufUnselect(textBuffer *buf);
81 void BufRectSelect(textBuffer *buf, int start, int end, int rectStart,
82 int rectEnd);
83 int BufGetSelectionPos(textBuffer *buf, int *start, int *end,
84 int *isRect, int *rectStart, int *rectEnd);
85 char *BufGetSelectionText(textBuffer *buf);
86 void BufRemoveSelected(textBuffer *buf);
87 void BufReplaceSelected(textBuffer *buf, const char *text);
88 void BufSecondarySelect(textBuffer *buf, int start, int end);
89 void BufSecondaryUnselect(textBuffer *buf);
90 void BufSecRectSelect(textBuffer *buf, int start, int end,
91 int rectStart, int rectEnd);
92 int BufGetSecSelectPos(textBuffer *buf, int *start, int *end,
93 int *isRect, int *rectStart, int *rectEnd);
94 char *BufGetSecSelectText(textBuffer *buf);
95 void BufRemoveSecSelect(textBuffer *buf);
96 void BufReplaceSecSelect(textBuffer *buf, const char *text);
97 void BufHighlight(textBuffer *buf, int start, int end);
98 void BufUnhighlight(textBuffer *buf);
99 void BufRectHighlight(textBuffer *buf, int start, int end,
100 int rectStart, int rectEnd);
101 int BufGetHighlightPos(textBuffer *buf, int *start, int *end,
102 int *isRect, int *rectStart, int *rectEnd);
103 char *BufGetHighlightText(textBuffer *buf);
104 void BufAddModifyCB(textBuffer *buf, bufModifyCallbackProc bufModifiedCB,
105 void *cbArg);
106 void BufRemoveModifyCB(textBuffer *buf, bufModifyCallbackProc bufModifiedCB,
107 void *cbArg);
108 void BufAddPreDeleteCB(textBuffer *buf, bufPreDeleteCallbackProc bufPreDeleteCB,
109 void *cbArg);
110 void BufRemovePreDeleteCB(textBuffer *buf, bufPreDeleteCallbackProc
111 bufPreDeleteCB, void *cbArg);
112 char *BufGetLineText(textBuffer *buf, int pos);
113 int BufStartOfLine(textBuffer *buf, int pos);
114 int BufEndOfLine(textBuffer *buf, int pos);
115 int BufGetExpandedChar(textBuffer *buf, int pos, int indent, char *outStr);
116 int BufExpandCharacter(char c, int indent, char *outStr, int tabDist,
117 char nullSubsChar);
118 int BufCharWidth(char c, int indent, int tabDist, char nullSubsChar);
119 int BufCountDispChars(textBuffer *buf, int lineStartPos, int targetPos);
120 int BufCountForwardDispChars(textBuffer *buf, int lineStartPos, int nChars);
121 int BufCountLines(textBuffer *buf, int startPos, int endPos);
122 int BufCountForwardNLines(textBuffer *buf, int startPos, int nLines);
123 int BufCountBackwardNLines(textBuffer *buf, int startPos, int nLines);
124 int BufSearchForward(textBuffer *buf, int startPos, const char *searchChars,
125 int *foundPos);
126 int BufSearchBackward(textBuffer *buf, int startPos, const char *searchChars,
127 int *foundPos);
128 int BufSubstituteNullChars(char *string, int length, textBuffer *buf);
129 void BufUnsubstituteNullChars(char *string, textBuffer *buf);
131 #endif /* NEDIT_TEXTBUF_H_INCLUDED */