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