ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.81
Committed: Tue Dec 11 17:42:04 2007 UTC (16 years, 5 months ago) by ayin
Branch: MAIN
Changes since 1.80: +5 -9 lines
Log Message:
Headers cleanup.

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