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