FreeBSD 10 clang port
[oweals/cde.git] / cde / lib / DtTerm / TermPrim / TermPrimData.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  * $XConsortium: TermPrimData.h /main/2 1996/10/30 13:00:24 cde-hp $";
25  */
26
27 /*                                                                      *
28  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
29  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
30  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
31  * (c) Copyright 1993, 1994 Novell, Inc.                                *
32  * (c) Copyright 1995       Digital Equipment Corporation               *
33  */
34
35 #ifndef _Dt_TermPrimData_h
36 #define _Dt_TermPrimData_h
37
38 #include "TermHeader.h"
39 #include "TermPrimBuffer.h"
40 #include "TermPrimParser.h"
41 #include "TermPrimPendingText.h"
42 #include "TermPrimRender.h"
43 #include "TermPrimSelect.h"
44 #include "TermPrimLineFont.h"
45 #include <stdio.h>
46 #include <limits.h>
47
48 #define NUM_FONTS       4
49 #define KEYBOARD_LOCKED(kbdLocked) ((kbdLocked).escape      || \
50                                     (kbdLocked).xferPending || \
51                                     (kbdLocked).error       || \
52                                     (kbdLocked).record)
53     
54 typedef struct {
55     Font fid;
56     Pixel foreground;
57     Pixel background;
58     GC gc;
59 } TermGC;
60
61 /* 
62 ** There are 4 reasons that the keyboard could be locked...
63 */
64 typedef struct _TermKbdLockStatus
65 {
66     Boolean escape;         /* escape sequence (or auto lock)       */
67     Boolean xferPending;    /* a transfer is pending                */
68     Boolean error;          /* an error message is being displayed  */
69     Boolean record;         /* we're in record mode                 */
70 } TermKbdLockStatus;
71
72
73 typedef struct _OnTheSpotData {
74     short row;
75     short column;
76     short start;
77     short end;
78     short pre_len;
79     short cursor;
80     Boolean under_preedit;
81 } OnTheSpotDataRec, *OnTheSpotData;
82
83 #define PreRow(w) ((w)->term.tpd->onthespot->row)
84 #define PreColumn(w) ((w)->term.tpd->onthespot->column)
85 #define PreStart(w) ((w)->term.tpd->onthespot->start)
86 #define PreEnd(w) ((w)->term.tpd->onthespot->end)
87 #define PreLen(w) ((w)->term.tpd->onthespot->pre_len)
88 #define PreCursor(w) ((w)->term.tpd->onthespot->cursor)
89 #define PreUnder(w) ((w)->term.tpd->onthespot->under_preedit)
90
91
92 typedef struct termData {
93     /*********************************************************************
94      * Pty
95      */
96     XtInputId ptyOutputId;              /* pty master Xt output id      */
97     XtInputId ptyInputId;               /* pty master Xt input id       */
98
99     /*********************************************************************
100      * Font
101      */
102     TermFont termFont;                  /* passed in base term font     */
103     TermFont boldTermFont;              /* passed in bold term font     */
104     TermFont defaultTermFont;           /* default base term font       */
105     TermFont defaultBoldTermFont;       /* default bold term font       */
106 #ifdef  DKS
107     unsigned char renderTermFontsNum;   /* number of above fonts        */
108     unsigned char baseFontIndex;        /* number of base font          */
109     unsigned char altFontIndex;         /* number of alternate font     */
110 #endif  /* DKS */
111     short cellWidth;                    /* width of base font           */
112     short cellHeight;                   /* height of base font          */
113     short ascent;                       /* ascent of base font          */
114
115     /*********************************************************************
116      * Buffer
117      */
118     TermBuffer  termBuffer;             /* character/enhancment buffer  */    
119     short bufferRows;                   /* rows of term buffer memory   */
120     short bufferRowRatio;               /* scaled ratio of term buffer
121                                          * memory to term window
122                                          */
123
124     TermBuffer  historyBuffer;          /* history character buffer     */
125     short historyBufferRows;            /* rows of term history buffer  */
126     
127     short leftMargin;                   /* left margin                  */
128     short rightMargin;                  /* right margin                 */
129     /* 
130     ** 
131     */
132     short topRow;                       /* number of top row on screen  */
133     short cursorColumn;                 /* current cursor position, col */
134     short cursorRow;                    /* current cursor position, row */
135     short lastUsedRow;                  /* number of last used buffer row.
136                                          * if == 0, no rows used, if == 1,
137                                          * 1 row used, etc.
138                                          */
139     short lastUsedHistoryRow;
140     short offsetX;                      /* width of internal window
141                                          * border.  With Motif, this is
142                                          * the width of the
143                                          * highlightThickness and
144                                          * shadowThickness.
145                                          */
146     short offsetY;                      /* height of internal window
147                                          * border (see above)
148                                          */
149
150     /* 
151     ** Generic mode information...
152     */
153     Boolean transmitFunctions;          /* if true, transmit functions   (A) */
154     Boolean autoWrapRight;              /* if true, wrap at right margin (C) */
155     Boolean wrapRightAfterInsert;       /* if true, wrap after insert       */
156     enum {
157         WRAPbetweenMargins = 0,
158         WRAPatRightMargin,
159         WRAPpastRightMargin
160     }       wrapState;                  /* margin wrap state                */
161
162     /* 
163     ** Memory lock status...
164     */
165     enum {
166         SCROLL_LOCKoff = 0,
167         SCROLL_LOCKon,
168         SCROLL_LOCKprotect
169     }       scrollLockMode;             /* memory lock mode                 */
170     short   scrollLockTopRow;           /* bottom of top scroll lock region */
171     short   scrollLockBottomRow;        /* top of bottom scroll lock region */
172
173    /*  for mapOnOutput */
174     time_t creationTime ;
175     Boolean windowMapped;
176
177    /* pointer blanking */
178     Boolean  pointerFirst;                /* for initialization */
179     Boolean  pointerOn;                   /* Is pointer on? */
180     XtIntervalId pointerTimeoutID;        /* ID of current timeout */
181     Boolean  pointerFrozen;               /* Is pointer outside window? */
182     Cursor   noPointer;                   /* blank pointer pixmap       */
183
184    /* logging */
185     FILE *logStream;                       /* file pointer for logging */
186     uid_t uid;                             /* user id of user   */
187     gid_t gid;                             /* group id of user   */
188     char *shell;                           /* users shell */
189         
190
191 /* these will go away when the associated files are updated...
192  */
193 #define memoryLockRow           scrollLockTopRow
194 #define memoryLockMode          scrollLockMode
195 #define MEMORY_LOCKoff          SCROLL_LOCKoff
196 #define MEMORY_LOCKon           SCROLL_LOCKon
197 #define MEMORY_LOCKprotect      SCROLL_LOCKprotect
198
199
200     /*********************************************************************
201      * Parser
202      */
203     ParserContext   context;            /* context of the parser        */
204     Boolean         parserNotInStartState;
205     int             mbCurMax;           /* max bytes per char for locale*/
206     unsigned char   mbPartialChar[MB_LEN_MAX];
207                                         /* partial multi-byte char      */
208     int             mbPartialCharLen;   /* length of above              */
209
210     /*********************************************************************
211      * Render GCs
212      */
213     TermGC renderGC;                    /* GC for rendering text        */
214     TermGC renderReverseGC;             /* GC for rendering text        */
215     TermGC clearGC;                     /* GC for clearing text         */
216
217     /*********************************************************************
218      * Cursor
219      */
220     XtIntervalId cursorTimeoutId;       /* cursor timeout id            */
221     TermGC cursorGC;                    /* GC for blinking cursor       */
222     enum {
223         CURSORon,
224         CURSORoff,
225         CURSORblink
226     } cursorState;                      /* state of cursor              */
227     Boolean cursorVisible;              /* true if cursor is visible    */
228
229     /*********************************************************************
230      * Input Method
231      */
232     Boolean IMHasFocus;                 /* true if IM has focus         */
233     /* The following are in character positions, not pixel positions...
234      */
235     short IMCursorColumn;               /* current IM cursor column     */
236     short IMCursorRow;                  /* current IM cursor row        */
237
238     /*********************************************************************
239      * Scroll
240      */
241     /* the following data reflects the copy area in progress to be used
242      * for filling in possible holes in exposure events...
243      */
244     short scrollSrcX;                   /* x src coord of scrolled area */
245     short scrollSrcY;                   /* y src coord of scrolled area */
246     short scrollDestX;                  /* x dest coord of scrolled area*/
247     short scrollDestY;                  /* y dest coord of scrolled area*/
248     short scrollWidth;                  /* width of scrolled area       */
249     short scrollHeight;                 /* height of scrolled area      */
250     short scrollTopRow;                 /* row of scroll top            */
251     short scrollBottomRow;              /* row of scroll bottom         */
252     Boolean *scrollRefreshRows;         /* flags for rows that need to
253                                          * be refreshed after a scroll
254                                          */
255
256     Boolean useHistoryBuffer;           /* true if separate history buf */
257     Boolean allowScrollBelowBuffer;     /* true allows scrolling below
258                                          * the terminal buffer
259                                          */
260
261     /* the following is for data for both any current scroll-in-progress
262      * as well as any pending (queued) scroll...
263      */
264     Boolean scrollInProgress;           /* true if scroll in progresss  */
265     union {
266         struct {
267             short scrollLines;          /* number of lines to scroll    */
268             short scrollsPending;       /* number of scrolls pending    */
269             Boolean scrolled;           /* true when scrolled, cleared
270                                          * when updated
271                                          */
272         } jump;
273         struct {
274             short pendingScrollLines;   /* number of lines in pending   */
275             short pendingScrollTopRow;  /* top row of pending scroll    */
276             short pendingScrollBottomRow;
277                                         /* bottom row of pending scroll */
278             Boolean pendingScroll;      /* True if scroll queued up     */
279         } nojump;
280     } scroll;
281
282     /* the following is for stuffing input data when we have turned off
283      * input processing during a scroll...
284      */
285     PendingText pendingRead;            /* pending read data            */
286     Boolean readInProgress;             /* True if now reading from pty */
287
288     /* 
289     ** Set up a linked list of text chunks, data stored here is waiting
290     ** to be written.
291     */
292     PendingText pendingWrite;           /* pending write data           */
293     
294     /* 
295     ** Keyboard state information...
296     */
297     TermKbdLockStatus   keyboardLocked; /* if true, keyboard is locked  */
298     DtTermInsertCharMode  insertCharMode;       /* insert char mode             */
299     Boolean autoLineFeed;               /* if true, in auto LF mode     */
300     Boolean halfDuplex;                 /* if true, half duplex         */
301
302     /*********************************************************************
303      * Caps lock tracking
304      */
305     Boolean capsLock;                   /* true == caps lock set        */
306     KeyCode *capsLockKeyCodes;          /* keyboard's modifier keymap   */
307     short numCapsLockKeyCodes;          /* number of caps lock modifiers*/
308
309     /*********************************************************************
310      * kshmode tracking
311      */
312     unsigned int metaMask;              /* mod mask used for meta       */
313
314     /*********************************************************************
315      * STOP indicator tracking
316      */
317     Boolean outputStopped;              /* true == out from pty stopped */
318     Boolean oneSecondPause;             /* true == esc @ pause          */
319
320     /*********************************************************************
321      * Warning/error dialog
322      */
323     Widget warningDialog;               /* warning dialog               */
324     Boolean mapWarningDialog;           /* map dialog when window mapped*/
325     Boolean warningDialogMapped;        /* true if dialog is mapped     */
326     enum {
327         userMessage,
328         memoryFull
329     } warningDialogType;
330
331     /*********************************************************************
332      * /etc/utmp stuff
333      */
334     char *utmpId;                       /* id of /etc/utmp entry        */
335 #ifdef  UTMPID_PROPERTY_NOTIFY
336     enum {
337         utmpIdInvalid = 0,
338         utmpIdValidNotClear,
339         utmpIdValid,
340         utmpIdError
341     } utmpIdState;
342 #endif  /* UTMPID_PROPERTY_NOTIFY */
343 #ifdef  UTMPID_PIPE_NOTIFY
344     int utmpNotifyPipe[2];
345     XtInputId utmpNotifyPipeInputId;
346     XtInputId utmpNotifyPipeExceptId;
347 #endif  /* UTMPID_PIPE_NOTIFY */
348
349     /* 
350     ** Selections...
351     */
352     TermSelectInfo  selectInfo;
353
354     /*
355     ** On the spot input method data
356     */
357     OnTheSpotData onthespot;
358
359 } DtTermPrimDataRec, *DtTermPrimData;
360
361
362 #endif  /* _Dt_TermPrimData_h */