FreeBSD 10 clang port
[oweals/cde.git] / cde / lib / DtTerm / TermPrim / TermPrimBufferP.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* 
24 ** $TOG: TermPrimBufferP.h /main/2 1997/04/17 18:05:11 samborn $
25 */
26 /*                                                                      *
27  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
28  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
29  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
30  * (c) Copyright 1993, 1994 Novell, Inc.                                *
31  */
32
33 #ifndef   _Dt_TermPrimBufferP_h
34 #define   _Dt_TermPrimBufferP_h
35
36 #include  "TermPrimBuffer.h"
37 #include  "TermPrimSelect.h"
38
39 #ifdef     __cplusplus
40 extern "C" {
41 #endif  /* __cplusplus */
42
43 #define VALID_ROW(tb, r)    (((r) >= 0) && ((r) < (tb)->term_buffer.rows))
44 #define VALID_COL(tb, c)    (((c) >= 0) && ((c) < (tb)->term_buffer.cols))
45 #define VALID_LENGTH(tb, l) (((l) >= 0) && ((l) <= (tb)->term_buffer.cols))
46
47 /*
48 ** Make it easier to access members of the Terminal Buffer
49 */
50 #define LINES(tb)          ((tb)->term_buffer.lines)
51 #define LINE_OF_TBUF(tb, row)  (LINES(tb)[row])
52 #define ROWS(tb)           ((tb)->term_buffer.rows)
53 #define COLS(tb)           ((tb)->term_buffer.cols)
54 #define MAX_ROWS(tb)       ((tb)->term_buffer.maxRows)
55 #define MAX_COLS(tb)       ((tb)->term_buffer.maxCols)
56 #define TABS(tb)           ((tb)->term_buffer.tabs)
57 #define NUM_ENH_FIELDS(tb) ((tb)->term_buffer.numFields)
58 #define SIZE_OF_BUFFER(tb) ((tb)->term_buffer.sizeOfBuffer)
59 #define SIZE_OF_LINE(tb)   ((tb)->term_buffer.sizeOfLine)
60 #define SIZE_OF_ENH(tb)    ((tb)->term_buffer.sizeOfEnh)
61 #define VALUE_LIST(tb)     ((tb)->term_buffer.valueList)
62 #define WIDGET(tb)         ((tb)->term_buffer.widget)
63
64 /*
65 ** Make it easy to access the term buffer methods
66 */
67 #define BUFFER_CREATE(tb)  ((tb)->term_buffer.buffer_create_proc)
68 #define BUFFER_FREE(tb)    ((tb)->term_buffer.buffer_free_proc)
69 #define BUFFER_RESIZE(tb)  ((tb)->term_buffer.buffer_resize_proc)
70 #define ENH_PROC(tb)       ((tb)->term_buffer.enh_proc)
71 #define CLEAR_ENH(tb)      ((tb)->term_buffer.clear_enh)
72 #define INSERT_ENH(tb)     ((tb)->term_buffer.insert_enh)
73 #define DELETE_ENH(tb)     ((tb)->term_buffer.delete_enh)
74 #define SET_ENH(tb)        ((tb)->term_buffer.set_enh)
75 #define GET_ENH(tb)        ((tb)->term_buffer.get_enh)
76 #define SET_LINE_WIDTH(tb) ((tb)->term_buffer.set_line_width)
77 #define SET_LINE_LENGTH(tb)((tb)->term_buffer.set_line_len)
78 #define CLEAR_LINE(tb)     ((tb)->term_buffer.clear_line)
79 #define NEXT_BUFFER(tb)    ((tb)->term_buffer.nextBuffer)
80 #define PREV_BUFFER(tb)    ((tb)->term_buffer.prevBuffer)
81 #define BUFFER_SELECT_INFO(tb) ((tb)->term_buffer.selectInfo)
82 #define WIDTH(l)           ((l)->term_line.width)
83 #define LENGTH(l)          ((l)->term_line.length)
84 #define BUFFER(l)          ((l)->term_line.buffer)
85 #define WRAPPED(l)         ((l)->term_line.wrapped)
86 #define IN_SELECTION(l)    ((l)->term_line.inSelection)
87 #define IS_IN_SELECTION(l,s,e) \
88                    (!(((l)->term_line.inSelection.selectionStart > e) || \
89                    ((l)->term_line.inSelection.selectionEnd < s)))
90 #define START_SELECTION(l) ((l)->term_line.inSelection.selectionStart)
91 #define END_SELECTION(l)   ((l)->term_line.inSelection.selectionEnd)
92 #define MIN_SELECTION_COL  (0)
93 #define MAX_SELECTION_COL  (32700)
94 #define NON_SELECTION_COL  (-1)
95 #define BYTES_PER_CHAR(tb) ((tb)->term_buffer.bytesPerChar) 
96
97 /* 
98 ** declare the private enhancement information
99 */
100 typedef struct _TermEnhPart
101 {
102     int foo;    /* placate the compiler */
103 } TermEnhPart;
104
105 typedef struct _TermEnhRec
106 {
107     TermEnhPart term_enh;
108 } TermEnhRec, *TermEnh;
109
110 typedef struct _TermLineSelectionRec
111 {
112     short           selectionStart;
113     short           selectionEnd;
114 } TermLineSelectionRec;
115
116 /* 
117 ** Lines have a column length, and a character length, these two numbers are
118 ** not always equal, since, in some locales (i.e. Japanese) the character
119 ** glyphs can be two columns wide.  We also want to know if this line wrapped
120 ** to the following line.
121 */
122 typedef struct _TermLinePart
123 {
124     short           width;   /* single width columns */
125     short           length;  /* in characters        */
126     TermLineSelectionRec
127                     inSelection;
128     Boolean         wrapped; /* did this line wrap to the following line? */
129     termChar       *buffer;
130 } TermLinePart;
131
132 typedef struct _TermLineRec
133 {
134     TermLinePart term_line;
135 } TermLineRec, *TermLine;
136
137 /* 
138 ** This structure defines the buffer instance part
139 */
140 typedef struct _TermBufferPart
141 {
142     short               rows;  /* height (in chars) of character buffer      */
143     short               cols;  /* width  (in single width cols) of buffer    */
144     short               maxRows;  /* maximum height (before any resize)      */
145     short               maxCols;  /* maximum width  (before any resize)      */
146     short               bytesPerChar; /* bytes per character */
147     Boolean            *tabs;         /* array of flags showing tab positions*/
148     unsigned char       numFields;    /* number of fields in an enhancement  */
149     short               sizeOfBuffer; /* bytes per buffer record             */
150     short               sizeOfLine;   /* bytes per enhancement record        */
151     short               sizeOfEnh;    /* bytes per line record               */
152     enhValues           valueList;    /* local storage for enhancement values*/
153     TermLine           *lines;
154     TermBuffer          nextBuffer;   /* next term buffer in list            */
155     TermBuffer          prevBuffer;   /* previous term buffer in list        */
156     TermSelectInfo      selectInfo;   /* current select info record          */
157     BufferCreateProc    buffer_create_proc;
158     BufferResizeProc    buffer_resize_proc;
159     BufferFreeProc      buffer_free_proc;
160     TermEnhProc         enh_proc;
161     TermEnhClear        clear_enh;
162     TermEnhInsert       insert_enh;
163     TermEnhDelete       delete_enh;
164     TermEnhSet          set_enh;
165     TermEnhGet          get_enh;
166     TermLineSetLen      set_line_len;
167     TermLineSetWidth    set_line_width;
168     TermLineClear       clear_line;
169     Widget              widget;       /* the widget that created this buffer */
170 } TermBufferPart;
171
172 typedef struct _TermBufferRec
173 {
174     TermBufferPart term_buffer;
175 } TermBufferRec;
176
177 extern
178 short
179 _DtTermPrimBufferInsertWc
180 (
181     const TermBuffer  tb,
182     const short       row,
183     const short       col,
184           wchar_t    *newChars,
185           short       numChars,
186           Boolean     insertFlag,
187           termChar  **returnChars,
188           short      *returnLength
189 );
190
191 extern
192 Boolean
193 _DtTermPrimBufferClearLineWc
194 (
195     const TermBuffer  tb,
196     const short       row,
197           short       newWidth
198 );
199
200 #ifdef  __cplusplus
201 } /* close scope of 'extern "C"'... */
202 #endif  /* __cplusplus */
203
204 #endif /* _Dt_TermPrimBufferP_h */
205 /* DON'T ADD ANYTHING AFTER THIS #endif... */