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