0b66c8809e46b59556932864535e57ff775cae72
[coreboot.git] / payloads / libpayload / curses / PDCurses-3.4 / x11 / pdcx11.h
1 /* Public Domain Curses */
2
3 /* $Id: pdcx11.h,v 1.64 2008/07/14 04:24:52 wmcbrine Exp $ */
4
5 #include <curspriv.h>
6
7 #ifdef HAVE_UNISTD_H
8 # include <unistd.h>
9 #endif
10
11 #include <signal.h>
12 #include <ctype.h>
13 #include <pwd.h>
14
15 #include <sys/types.h>
16 #include <sys/socket.h>
17 #ifdef HAVE_FCNTL_H
18 # include <fcntl.h>
19 #endif
20 #ifdef HAVE_SYS_SELECT_H
21 # include <sys/select.h>   /* AIX needs this for FD_ZERO etc macros */
22 #endif
23 #include <sys/ipc.h>
24 #include <sys/shm.h>
25
26 #ifdef TIME_WITH_SYS_TIME
27 # include <sys/time.h>
28 # include <time.h>
29 #else
30 # ifdef HAVE_SYS_TIME_H
31 #  include <sys/time.h>
32 # else
33 #  include <time.h>
34 # endif
35 #endif
36
37 #include <Intrinsic.h>
38 #include <StringDefs.h>
39 #include <Shell.h>
40
41 #ifdef USE_XAW3D
42 # include <Xaw3d/Box.h>
43 # include <Xaw3d/Scrollbar.h>
44 #elif defined(USE_NEXTAW)
45 # include <neXtaw/Box.h>
46 # include <neXtaw/Scrollbar.h>
47 #else
48 # include <Xaw/Box.h>
49 # include <Xaw/Scrollbar.h>
50 #endif
51 #include "x11/ScrollBox.h"
52
53 #include "Xmu/StdSel.h"
54 #include "Xmu/Atoms.h"
55
56 #include <keysym.h>
57 #include <Xatom.h>
58
59 #define XCURSCR_Y_SIZE      (XCursesLINES * XCursesCOLS * sizeof(chtype))
60 #define XCURSCR_FLAG_SIZE   (XCursesLINES * sizeof(int))
61 #define XCURSCR_START_SIZE  (XCursesLINES * sizeof(int))
62 #define XCURSCR_LENGTH_SIZE (XCursesLINES * sizeof(int))
63 #define XCURSCR_ATRTAB_SIZE (PDC_COLOR_PAIRS * 2 * sizeof(short))
64 #define XCURSCR_SIZE        (XCURSCR_FLAG_SIZE + XCURSCR_START_SIZE + \
65         XCURSCR_LENGTH_SIZE + XCURSCR_Y_SIZE + XCURSCR_ATRTAB_SIZE + \
66         sizeof(XColor))
67
68 #define XCURSCR_Y_OFF(y)    ((y) * XCursesCOLS * sizeof(chtype))
69 #define XCURSCR_FLAG_OFF    (XCURSCR_Y_OFF(0) + XCURSCR_Y_SIZE)
70 #define XCURSCR_START_OFF   (XCURSCR_FLAG_OFF + XCURSCR_FLAG_SIZE)
71 #define XCURSCR_LENGTH_OFF  (XCURSCR_START_OFF + XCURSCR_START_SIZE)
72 #define XCURSCR_ATRTAB_OFF  (XCURSCR_LENGTH_OFF + XCURSCR_LENGTH_SIZE)
73 #define XCURSCR_XCOLOR_OFF  (XCURSCR_ATRTAB_OFF + XCURSCR_ATRTAB_SIZE)
74
75 typedef struct
76 {
77     int lines;
78     int cols;
79     Pixel cursorColor;
80     Pixel colorBlack;
81     Pixel colorRed;
82     Pixel colorGreen;
83     Pixel colorYellow;
84     Pixel colorBlue;
85     Pixel colorMagenta;
86     Pixel colorCyan;
87     Pixel colorWhite;
88     Pixel colorBoldBlack;
89     Pixel colorBoldRed;
90     Pixel colorBoldGreen;
91     Pixel colorBoldYellow;
92     Pixel colorBoldBlue;
93     Pixel colorBoldMagenta;
94     Pixel colorBoldCyan;
95     Pixel colorBoldWhite;
96     Pixel pointerForeColor;
97     Pixel pointerBackColor;
98     XFontStruct *normalFont;
99     XFontStruct *italicFont;
100     char *bitmap;
101 #ifdef HAVE_XPM_H
102     char *pixmap;
103 #endif
104     char *composeKey;
105     Cursor pointer;
106     int shmmin;
107     int borderWidth;
108     int borderColor;
109     int clickPeriod;
110     int doubleClickPeriod;
111     int scrollbarWidth;
112     int cursorBlinkRate;
113     char *textCursor;
114 } XCursesAppData;
115
116 extern XCursesAppData xc_app_data;
117
118 #define XCURSESSHMMIN xc_app_data.shmmin
119
120 #define XCLOGMSG (XCursesProcess ? "     X" : "CURSES")
121
122 void XC_get_line_lock(int);
123 void XC_release_line_lock(int);
124
125 int PDC_display_cursor(int, int, int, int, int);
126
127 void XCursesExitCursesProcess(int, char *);
128 int XCursesInstruct(int);
129 int XCursesInstructAndWait(int);
130 int XCursesInitscr(int, char **);
131
132 int XC_write_socket(int, const void *, int);
133 int XC_read_socket(int, void *, int);
134 int XC_write_display_socket_int(int);
135
136 int XCursesSetupX(int argc, char *argv[]);
137 RETSIGTYPE XCursesSigwinchHandler(int signo);
138
139 #ifdef _HPUX_SOURCE
140 # define FD_SET_CAST int *
141 #else
142 # define FD_SET_CAST fd_set *
143 #endif
144
145 extern fd_set xc_readfds;
146
147 extern unsigned char *Xcurscr;
148 extern int XCursesProcess;
149 extern int shmidSP;
150 extern int shmid_Xcurscr;
151 extern int shmkeySP;
152 extern int shmkey_Xcurscr;
153 extern int xc_otherpid;
154 extern int XCursesLINES;
155 extern int XCursesCOLS;
156 extern int xc_display_sock;
157 extern int xc_key_sock;
158 extern int xc_display_sockets[2];
159 extern int xc_key_sockets[2];
160 extern int xc_exit_sock;
161
162 typedef RETSIGTYPE (*signal_handler)();
163
164 signal_handler XCursesSetSignal(int, signal_handler);
165
166 #ifdef PDCDEBUG
167 void XC_say(const char *msg);
168 # define XC_LOG(x) XC_say x
169 #else
170 # define XC_LOG(x)
171 #endif
172
173 #ifdef MOUSE_DEBUG
174 # define MOUSE_LOG(x) printf x
175 #else
176 # define MOUSE_LOG(x)
177 #endif
178
179 enum
180 {
181     CURSES_CLEAR_SELECTION, CURSES_DISPLAY_CURSOR, CURSES_SET_SELECTION, 
182     CURSES_GET_SELECTION, CURSES_TITLE, CURSES_REFRESH_SCROLLBAR, 
183     CURSES_RESIZE, CURSES_BELL, CURSES_CONTINUE, CURSES_CURSOR, 
184     CURSES_CHILD, CURSES_REFRESH, CURSES_GET_COLOR, CURSES_SET_COLOR, 
185     CURSES_EXIT
186 };
187
188 extern short *xc_atrtab;