89bd5c2a7f39390efe8c5057935511eb21b3ea1d
[framework/uifw/xorg/lib/libxaw.git] / include / X11 / Xaw / TextSrc.h
1 /***********************************************************
2
3 Copyright 1987, 1988, 1994, 1998  The Open Group
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
24
25
26 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
27
28                         All Rights Reserved
29
30 Permission to use, copy, modify, and distribute this software and its 
31 documentation for any purpose and without fee is hereby granted, 
32 provided that the above copyright notice appear in all copies and that
33 both that copyright notice and this permission notice appear in 
34 supporting documentation, and that the name of Digital not be
35 used in advertising or publicity pertaining to distribution of the
36 software without specific, written prior permission.  
37
38 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
39 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
40 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
41 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
42 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
44 SOFTWARE.
45
46 ******************************************************************/
47
48 #ifndef _XawTextSrc_h
49 #define _XawTextSrc_h
50
51 #include <X11/Xaw/Text.h>
52
53 /* Resources:
54
55  Name                Class              RepType         Default Value
56  ----                -----              -------         -------------
57  callback            Callback           Callback        NULL
58  editType            EditType           XawTextEditType XawtextRead
59  enableUndo          Undo               Boolean         False
60  sourceChanged       Changed            Boolean         False
61
62 */
63  
64 /* Class record constants */
65 extern WidgetClass textSrcObjectClass;
66
67 typedef struct _TextSrcClassRec *TextSrcObjectClass;
68 typedef struct _TextSrcRec      *TextSrcObject;
69
70 typedef enum {
71     XawstPositions,
72     XawstWhiteSpace,
73     XawstEOL,
74     XawstParagraph,
75     XawstAll,
76     XawstAlphaNumeric
77   } XawTextScanType;
78
79 typedef enum {
80     Normal,
81     Selected
82 } highlightType;
83
84 typedef enum {
85     XawsmTextSelect,
86     XawsmTextExtend
87 } XawTextSelectionMode;
88
89 typedef enum {
90     XawactionStart,
91     XawactionAdjust,
92     XawactionEnd
93 } XawTextSelectionAction;
94
95 #define XawTextReadError -1
96 #define XawTextScanError -1
97
98 #ifndef OLDXAW
99 #define XtNenableUndo           "enableUndo"
100 #define XtCUndo                 "Undo"
101
102 #define XtNsourceChanged        "sourceChanged"
103 #define XtCChanged              "Changed"
104
105 #define XtNpropertyCallback     "propertyCallback"
106 #endif
107
108 /*
109  * Public Functions
110  */
111 _XFUNCPROTOBEGIN
112
113 /*
114  * Function:
115  *      XawTextSourceRead
116  *
117  * Parameters:
118  *      w      - TextSrc Object
119  *      pos    - position of the text to retreive
120  *      text   - text block that will contain returned text
121  *      length - maximum number of characters to read
122  *
123  * Description:
124  *      This function reads the source.
125  *
126  * Returns:
127  *      The number of characters read into the buffer
128  */
129 XawTextPosition XawTextSourceRead
130 (
131  Widget                 w,
132  XawTextPosition        pos,
133  XawTextBlock           *text_return,
134  int                    length
135  );
136
137 /*
138  * Function:
139  *      XawTextSourceReplace
140  *
141  * Parameters:
142  *      src      - Text Source Object
143  *      startPos - ends of text that will be removed
144  *      endPos   - ""
145  *      text     - new text to be inserted into buffer at startPos
146  *
147  * Description:
148  *      Replaces a block of text with new text
149  *
150  * Returns:
151  *      XawEditError or XawEditDone
152  */
153 int XawTextSourceReplace
154 (
155  Widget                 w,
156  XawTextPosition        start,
157  XawTextPosition        end,
158  XawTextBlock           *text
159  );
160
161 /*
162  * Function:
163  *      XawTextSourceScan
164  *
165  * Parameters:
166  *      w        - TextSrc Object
167  *      position - position to start scanning
168  *      type     - type of thing to scan for
169  *      dir      - direction to scan
170  *      count    - which occurance if this thing to search for
171  *      include  - whether or not to include the character found in
172  *                 the position that is returned. 
173  *
174  * Description:
175  *      Scans the text source for the number and type of item specified.
176  *
177  * Returns:
178  *      The position of the text
179  */
180 XawTextPosition XawTextSourceScan
181 (
182  Widget                 w,
183  XawTextPosition        position,
184 #if NeedWidePrototypes
185  int                    type,
186  int                    dir,
187  int                    count,
188  int                    include
189 #else
190  XawTextScanType        type,
191  XawTextScanDirection   dir,
192  int                    count,
193  Boolean                include
194 #endif
195  );
196
197 /*
198  * Function:
199  *      XawTextSourceSearch
200  *
201  * Parameters:
202  *      w        - TextSource Object
203  *      position - position to start scanning
204  *      dir      - direction to search
205  *      text     - the text block to search for
206  *
207  * Description:
208  *      Searchs the text source for the text block passed.
209  *
210  * Returns:
211  *      The position of the text we are searching for or XawTextSearchError
212  */
213 XawTextPosition XawTextSourceSearch
214 (
215  Widget                 w,
216  XawTextPosition        position,
217 #if NeedWidePrototypes
218  int                    dir,
219 #else
220  XawTextScanDirection   dir,
221 #endif
222  XawTextBlock           *text
223  );
224
225 /*
226  * Function:
227  *      XawTextSourceConvertSelection
228  *
229  * Parameters:
230  *      w         - TextSrc object
231  *      selection - current selection atom
232  *      target    - current target atom
233  *      type      - type to conver the selection to
234  *      value     - return value that has been converted
235  *      length    - ""
236  *      format    - format of the returned value
237  *
238  * Returns:
239  *      True if the selection has been converted
240  */
241 Boolean XawTextSourceConvertSelection
242 (
243  Widget                 w,
244  Atom                   *selection,
245  Atom                   *target,
246  Atom                   *type,
247  XtPointer              *value_return,
248  unsigned long          *length_return,
249  int                    *format_return
250  );
251
252 /*
253  * Function:
254  *      XawTextSourceSetSelection
255  *
256  * Parameters:
257  *      w         - TextSrc object
258  *      left      - bounds of the selection
259  *      right     - ""
260  *      selection - selection atom
261  *
262  * Description:
263  *      Allows special setting of the selection.
264  */
265 void XawTextSourceSetSelection
266 (
267  Widget                 w,
268  XawTextPosition        start,
269  XawTextPosition        end,
270  Atom                   selection
271  );
272
273 _XFUNCPROTOEND
274
275 #endif /* _XawTextSrc_h */