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