ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.70
Committed: Tue Jan 17 12:22:59 2006 UTC (18 years, 4 months ago) by root
Branch: MAIN
Changes since 1.69: +0 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 #ifndef _RXVTLIB_H_ /* include once only */
2 #define _RXVTLIB_H_
3
4 #include <cstdio>
5 #include <cctype>
6 #include <cerrno>
7 @include_stdarg_h@
8 @include_stdlib_h@
9 @include_stdint_h@
10 #include <sys/types.h>
11 @include_unistd_h@
12 @include_string_h@
13 @include_fcntl_h@
14 @include_util_h@
15 @include_assert_h@
16 @include_sys_ioctl_h@
17 @include_sys_time_h@
18 @include_time_h@
19 @include_sys_select_h@
20 @include_sys_strredir_h@
21
22 #include <sys/wait.h>
23 #include <sys/stat.h>
24
25 #if HAVE_CWCHAR
26 # include <cwchar>
27 #elif HAVE_WCHAR_H
28 # include <wchar.h>
29 #else
30 // stdlib.h might provide it
31 #endif
32
33 extern "C" {
34 #include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
35 }
36
37 /*
38 * If we haven't pulled in typedef's like int16_t then do them ourself
39 * type of (normal and unsigned) basic sizes
40 */
41 @rxvt_int16_typedef@
42 @rxvt_uint16_typedef@
43 @rxvt_int32_typedef@
44 @rxvt_uint32_typedef@
45
46 /* whatever normal size corresponds to a integer pointer */
47 @rxvt_intp_define@
48 /* whatever normal size corresponds to a unsigned integer pointer */
49 @rxvt_u_intp_define@
50
51 struct rxvt_fontset;
52 struct rxvt_color;
53 struct rxvt_vars; /* defined later on */
54 struct rxvt_term;
55 struct rxvt_display;
56 struct rxvt_im;
57 struct rxvt_drawable;
58
59 typedef struct rxvt_term *rxvt_t;
60
61 extern rxvt_t rxvt_current_term;
62
63 #define SET_R(r) rxvt_current_term = const_cast<rxvt_term *>(r)
64 #define GET_R rxvt_current_term
65
66 typedef struct {
67 int row;
68 int col;
69 } row_col_t;
70
71 #if UNICODE_3
72 typedef uint32_t text_t;
73 #else
74 typedef uint16_t text_t; // saves lots of memory
75 #endif
76 typedef uint32_t rend_t;
77 typedef int32_t tlen_t; // was int16_t, but this results in smaller code and memory use
78 typedef int32_t tlen_t_; // specifically for use in the line_t structure
79
80 struct line_t;
81
82 /*
83 * terminal limits:
84 *
85 * width : 1 <= width
86 * height : 1 <= height
87 * ncol : 1 <= ncol <= MAX(tlen_t)
88 * nrow : 1 <= nrow <= MAX(int)
89 * saveLines : 0 <= saveLines <= MAX(int)
90 * term_start : 0 <= term_start < saveLines
91 * total_rows : nrow + saveLines
92 *
93 * top_row : -saveLines <= top_row <= 0
94 * view_start : top_row <= view_start <= 0
95 *
96 * | most coordinates are stored relative to term_start,
97 * ROW_BUF | which is the first line of the terminal screen
98 * |························= row_buf[0]
99 * |························= row_buf[1]
100 * |························= row_buf[2] etc.
101 * |
102 * +------------+···········= term_start + top_row
103 * | scrollback |
104 * | scrollback +---------+·= term_start + view_start
105 * | scrollback | display |
106 * | scrollback | display |
107 * +------------+·display·+·= term_start
108 * | terminal | display |
109 * | terminal +---------+
110 * | terminal |
111 * | terminal |
112 * +------------+···········= term_stat + nrow - 1
113 * |
114 * |
115 * END······················= total_rows
116 */
117
118 struct TermWin_t {
119 int width; /* window width [pixels] */
120 int height; /* window height [pixels] */
121 int fwidth; /* font width [pixels] */
122 int fheight; /* font height [pixels] */
123 int fbase; /* font ascent (baseline) [pixels] */
124 int ncol; /* window columns [characters] */
125 int nrow; /* window rows [characters] */
126 int focus; /* window has focus */
127 int mapped; /* window state mapped? */
128 int int_bwidth; /* internal border width */
129 int ext_bwidth; /* external border width */
130 int lineSpace; /* number of extra pixels between rows */
131 int saveLines; /* number of lines that fit in scrollback */
132 int total_rows; /* total number of rows in this terminal */
133 int term_start; /* term lines start here */
134 int view_start; /* scrollback view starts here */
135 int top_row; /* topmost row index of scrollback */
136 Window parent[6]; /* parent identifiers - we're parent[0] */
137 Window vt; /* vt100 window */
138 GC gc; /* GC for drawing */
139 Pixmap pixmap;
140 rxvt_drawable *drawable;
141 rxvt_fontset *fontset[4];
142 };
143
144 /*
145 * screen accounting:
146 * screen_t elements
147 * row: Cursor row position : 0 <= row < nrow
148 * col: Cursor column position : 0 <= col < ncol
149 * tscroll: Scrolling region top row inclusive : 0 <= row < nrow
150 * bscroll: Scrolling region bottom row inclusive : 0 <= row < nrow
151 *
152 * selection_t elements
153 * clicks: 1, 2 or 3 clicks - 4 indicates a special condition of 1 where
154 * nothing is selected
155 * beg: row/column of beginning of selection : never past mark
156 * mark: row/column of initial click : never past end
157 * end: row/column of one character past end of selection
158 * * Note: -nsaved <= beg.row <= mark.row <= end.row < nrow
159 * * Note: col == -1 ==> we're left of screen
160 *
161 */
162 typedef struct {
163 row_col_t cur; /* cursor position on the screen */
164 int tscroll; /* top of settable scroll region */
165 int bscroll; /* bottom of settable scroll region */
166 unsigned int charset; /* character set number [0..3] */
167 unsigned int flags; /* see below */
168 row_col_t s_cur; /* saved cursor position */
169 unsigned int s_charset; /* saved character set number [0..3] */
170 char s_charset_char;
171 rend_t s_rstyle; /* saved rendition style */
172 } screen_t;
173
174 enum selection_op_t {
175 SELECTION_CLEAR = 0, /* nothing selected */
176 SELECTION_INIT, /* marked a point */
177 SELECTION_BEGIN, /* started a selection */
178 SELECTION_CONT, /* continued selection */
179 SELECTION_DONE /* selection put in CUT_BUFFER0 */
180 };
181
182 typedef struct {
183 wchar_t *text; /* selected text */
184 unsigned int len; /* length of selected text */
185 unsigned int screen; /* screen being used */
186 unsigned int clicks; /* number of clicks */
187 selection_op_t op; /* current operation */
188 bool rect; /* rectangluar selection? */
189 row_col_t beg; /* beginning of selection <= mark */
190 row_col_t mark; /* point of initial click <= end */
191 row_col_t end; /* one character past end point */
192 } selection_t;
193
194 /* ------------------------------------------------------------------------- */
195
196 /* screen_t flags */
197 #define Screen_Relative (1<<0) /* relative origin mode flag */
198 #define Screen_VisibleCursor (1<<1) /* cursor visible? */
199 #define Screen_Autowrap (1<<2) /* auto-wrap flag */
200 #define Screen_Insert (1<<3) /* insert mode (vs. overstrike) */
201 #define Screen_WrapNext (1<<4) /* need to wrap for next char? */
202 #define Screen_DefaultFlags (Screen_VisibleCursor | Screen_Autowrap)
203
204 /* rxvt_vars.options */
205 enum {
206 # define def(name,idx) Opt_ ## name = 1UL << (idx),
207 # define nodef(name) Opt_ ## name = 0,
208 # include "optinc.h"
209 # undef nodef
210 # undef def
211 };
212
213 /* ------------------------------------------------------------------------- */
214
215 typedef struct {
216 char state; /* scrollbar state */
217 char init; /* scrollbar has been initialised */
218 unsigned int beg; /* slider sub-window begin height */
219 unsigned int end; /* slider sub-window end height */
220 unsigned int top; /* slider top position */
221 unsigned int bot; /* slider bottom position */
222 unsigned int style; /* style: rxvt, xterm, next */
223 unsigned int width; /* scrollbar width */
224 Window win;
225 int (rxvt_term::*update)(int, int, int, int);
226
227 void setIdle() { state = 1 ; }
228 void setMotion() { state = 'm'; }
229 void setUp() { state = 'U'; }
230 void setDn() { state = 'D'; }
231 } scrollBar_t;
232
233 struct rxvt_vars : TermWin_t {
234 scrollBar_t scrollBar;
235 uint32_t options;
236 XSizeHints szHint;
237 rxvt_display *display;
238 rxvt_color *pix_colors;
239 rxvt_color *pix_colors_focused;
240 #ifdef OFF_FOCUS_FADING
241 rxvt_color *pix_colors_unfocused;
242 #endif
243 short numpix_colors;
244 Cursor TermWin_cursor; /* cursor for vt window */
245 int sb_shadow; /* scrollbar shadow width */
246 int numlock_state;
247 line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf
248 line_t *drawn_buf; // text on screen
249 line_t *swap_buf; // lines for swap buffer
250 char *tabs; /* per location: 1 == tab-stop */
251 screen_t screen;
252 screen_t swap;
253 selection_t selection;
254 };
255
256 void rxvt_init ();
257 bool rxvt_tainted ();
258
259 #endif /* _RXVTLIB_H_ */
260