ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.82
Committed: Tue Dec 11 18:07:08 2007 UTC (16 years, 5 months ago) by ayin
Branch: MAIN
CVS Tags: rel-8_8
Changes since 1.81: +0 -9 lines
Log Message:
Use autoconf macros to define exact-width types if missing.

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