ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.82
Committed: Tue Dec 11 18:07:08 2007 UTC (16 years, 7 months ago) by ayin
Branch: MAIN
CVS Tags: rel-8_8
Changes since 1.81: +0 -9 lines
Log Message:
Use autoconf macros to define exact-width types if missing.

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