2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
24 ** $TOG: TermPrimBufferP.h /main/2 1997/04/17 18:05:11 samborn $
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. *
33 #ifndef _Dt_TermPrimBufferP_h
34 #define _Dt_TermPrimBufferP_h
36 #include "TermPrimBuffer.h"
37 #include "TermPrimSelect.h"
41 #endif /* __cplusplus */
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))
48 ** Make it easier to access members of the Terminal Buffer
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)
65 ** Make it easy to access the term buffer methods
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)
98 ** declare the private enhancement information
100 typedef struct _TermEnhPart
102 int foo; /* placate the compiler */
105 typedef struct _TermEnhRec
107 TermEnhPart term_enh;
108 } TermEnhRec, *TermEnh;
110 typedef struct _TermLineSelectionRec
112 short selectionStart;
114 } TermLineSelectionRec;
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.
122 typedef struct _TermLinePart
124 short width; /* single width columns */
125 short length; /* in characters */
128 Boolean wrapped; /* did this line wrap to the following line? */
132 typedef struct _TermLineRec
134 TermLinePart term_line;
135 } TermLineRec, *TermLine;
138 ** This structure defines the buffer instance part
140 typedef struct _TermBufferPart
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*/
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;
166 TermLineSetLen set_line_len;
167 TermLineSetWidth set_line_width;
168 TermLineClear clear_line;
169 Widget widget; /* the widget that created this buffer */
172 typedef struct _TermBufferRec
174 TermBufferPart term_buffer;
179 _DtTermPrimBufferInsertWc
187 termChar **returnChars,
193 _DtTermPrimBufferClearLineWc
201 } /* close scope of 'extern "C"'... */
202 #endif /* __cplusplus */
204 #endif /* _Dt_TermPrimBufferP_h */
205 /* DON'T ADD ANYTHING AFTER THIS #endif... */