ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.72
Committed: Wed Jan 25 21:03:04 2006 UTC (18 years, 4 months ago) by root
Branch: MAIN
CVS Tags: rel-7_3, rel-7_4, rel-7_3a
Changes since 1.71: +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_im;
56 struct rxvt_drawable;
57
58 typedef struct rxvt_term *rxvt_t;
59
60 extern rxvt_t rxvt_current_term;
61
62 #define SET_R(r) rxvt_current_term = const_cast<rxvt_term *>(r)
63 #define GET_R rxvt_current_term
64
65 typedef struct {
66 int row;
67 int col;
68 } row_col_t;
69
70 #if UNICODE_3
71 typedef uint32_t text_t;
72 #else
73 typedef uint16_t text_t; // saves lots of memory
74 #endif
75 typedef uint32_t rend_t;
76 typedef int32_t tlen_t; // was int16_t, but this results in smaller code and memory use
77 typedef int32_t tlen_t_; // specifically for use in the line_t structure
78
79 struct line_t;
80
81 /*
82 * terminal limits:
83 *
84 * width : 1 <= width
85 * height : 1 <= height
86 * ncol : 1 <= ncol <= MAX(tlen_t)
87 * nrow : 1 <= nrow <= MAX(int)
88 * saveLines : 0 <= saveLines <= MAX(int)
89 * term_start : 0 <= term_start < saveLines
90 * total_rows : nrow + saveLines
91 *
92 * top_row : -saveLines <= top_row <= 0
93 * view_start : top_row <= view_start <= 0
94 *
95 * | most coordinates are stored relative to term_start,
96 * ROW_BUF | which is the first line of the terminal screen
97 * |························= row_buf[0]
98 * |························= row_buf[1]
99 * |························= row_buf[2] etc.
100 * |
101 * +------------+···········= term_start + top_row
102 * | scrollback |
103 * | scrollback +---------+·= term_start + view_start
104 * | scrollback | display |
105 * | scrollback | display |
106 * +------------+·display·+·= term_start
107 * | terminal | display |
108 * | terminal +---------+
109 * | terminal |
110 * | terminal |
111 * +------------+···········= term_stat + nrow - 1
112 * |
113 * |
114 * END······················= total_rows
115 */
116
117 struct TermWin_t {
118 int width; /* window width [pixels] */
119 int height; /* window height [pixels] */
120 int fwidth; /* font width [pixels] */
121 int fheight; /* font height [pixels] */
122 int fbase; /* font ascent (baseline) [pixels] */
123 int ncol; /* window columns [characters] */
124 int nrow; /* window rows [characters] */
125 int focus; /* window has focus */
126 int mapped; /* window state mapped? */
127 int int_bwidth; /* internal border width */
128 int ext_bwidth; /* external border width */
129 int lineSpace; /* number of extra pixels between rows */
130 int saveLines; /* number of lines that fit in scrollback */
131 int total_rows; /* total number of rows in this terminal */
132 int term_start; /* term lines start here */
133 int view_start; /* scrollback view starts here */
134 int top_row; /* topmost row index of scrollback */
135 Window parent[6]; /* parent identifiers - we're parent[0] */
136 Window vt; /* vt100 window */
137 GC gc; /* GC for drawing */
138 Pixmap pixmap;
139 rxvt_drawable *drawable;
140 rxvt_fontset *fontset[4];
141 };
142
143 /*
144 * screen accounting:
145 * screen_t elements
146 * row: Cursor row position : 0 <= row < nrow
147 * col: Cursor column position : 0 <= col < ncol
148 * tscroll: Scrolling region top row inclusive : 0 <= row < nrow
149 * bscroll: Scrolling region bottom row inclusive : 0 <= row < nrow
150 *
151 * selection_t elements
152 * clicks: 1, 2 or 3 clicks - 4 indicates a special condition of 1 where
153 * nothing is selected
154 * beg: row/column of beginning of selection : never past mark
155 * mark: row/column of initial click : never past end
156 * end: row/column of one character past end of selection
157 * * Note: -nsaved <= beg.row <= mark.row <= end.row < nrow
158 * * Note: col == -1 ==> we're left of screen
159 *
160 */
161 typedef struct {
162 row_col_t cur; /* cursor position on the screen */
163 int tscroll; /* top of settable scroll region */
164 int bscroll; /* bottom of settable scroll region */
165 unsigned int charset; /* character set number [0..3] */
166 unsigned int flags; /* see below */
167 row_col_t s_cur; /* saved cursor position */
168 unsigned int s_charset; /* saved character set number [0..3] */
169 char s_charset_char;
170 rend_t s_rstyle; /* saved rendition style */
171 } screen_t;
172
173 enum selection_op_t {
174 SELECTION_CLEAR = 0, /* nothing selected */
175 SELECTION_INIT, /* marked a point */
176 SELECTION_BEGIN, /* started a selection */
177 SELECTION_CONT, /* continued selection */
178 SELECTION_DONE /* selection put in CUT_BUFFER0 */
179 };
180
181 typedef struct {
182 wchar_t *text; /* selected text */
183 unsigned int len; /* length of selected text */
184 unsigned int screen; /* screen being used */
185 unsigned int clicks; /* number of clicks */
186 selection_op_t op; /* current operation */
187 bool rect; /* rectangluar selection? */
188 row_col_t beg; /* beginning of selection <= mark */
189 row_col_t mark; /* point of initial click <= end */
190 row_col_t end; /* one character past end point */
191 } selection_t;
192
193 /* ------------------------------------------------------------------------- */
194
195 /* screen_t flags */
196 #define Screen_Relative (1<<0) /* relative origin mode flag */
197 #define Screen_VisibleCursor (1<<1) /* cursor visible? */
198 #define Screen_Autowrap (1<<2) /* auto-wrap flag */
199 #define Screen_Insert (1<<3) /* insert mode (vs. overstrike) */
200 #define Screen_WrapNext (1<<4) /* need to wrap for next char? */
201 #define Screen_DefaultFlags (Screen_VisibleCursor | Screen_Autowrap)
202
203 /* rxvt_vars.options */
204 enum {
205 # define def(name,idx) Opt_ ## name = 1UL << (idx),
206 # define nodef(name) Opt_ ## name = 0,
207 # include "optinc.h"
208 # undef nodef
209 # undef def
210 };
211
212 /* ------------------------------------------------------------------------- */
213
214 typedef struct {
215 char state; /* scrollbar state */
216 char init; /* scrollbar has been initialised */
217 unsigned int beg; /* slider sub-window begin height */
218 unsigned int end; /* slider sub-window end height */
219 unsigned int top; /* slider top position */
220 unsigned int bot; /* slider bottom position */
221 unsigned int style; /* style: rxvt, xterm, next */
222 unsigned int width; /* scrollbar width */
223 Window win;
224 int (rxvt_term::*update)(int, int, int, int);
225
226 void setIdle() { state = 1 ; }
227 void setMotion() { state = 'm'; }
228 void setUp() { state = 'U'; }
229 void setDn() { state = 'D'; }
230 } scrollBar_t;
231
232 struct rxvt_vars : TermWin_t {
233 scrollBar_t scrollBar;
234 uint32_t options;
235 XSizeHints szHint;
236 rxvt_color *pix_colors;
237 rxvt_color *pix_colors_focused;
238 #ifdef OFF_FOCUS_FADING
239 rxvt_color *pix_colors_unfocused;
240 #endif
241 short numpix_colors;
242 Cursor TermWin_cursor; /* cursor for vt window */
243 int sb_shadow; /* scrollbar shadow width */
244 int numlock_state;
245 line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf
246 line_t *drawn_buf; // text on screen
247 line_t *swap_buf; // lines for swap buffer
248 char *tabs; /* per location: 1 == tab-stop */
249 screen_t screen;
250 screen_t swap;
251 selection_t selection;
252 };
253
254 void rxvt_init ();
255
256 #endif /* _RXVTLIB_H_ */
257