ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.79
Committed: Tue Dec 11 08:54:08 2007 UTC (16 years, 5 months ago) by ayin
Branch: MAIN
Changes since 1.78: +0 -1 lines
Log Message:
libptytty takes care of including util.h.

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