ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.77
Committed: Sat Jun 23 13:43:06 2007 UTC (16 years, 11 months ago) by ayin
Branch: MAIN
CVS Tags: rel-8_3, rel-8_4
Changes since 1.76: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

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