1
#ifndef _RXVTLIB_H_ /* include once only */
10
#include <sys/types.h>
14
/* #include <util.h> */
16
#include <sys/ioctl.h>
19
#include <sys/select.h>
20
/* #include <sys/strredir.h> */
30
// stdlib.h might provide it
35
#include <X11/Xutil.h>
36
#include <X11/Xresource.h>
40
* If we haven't pulled in typedef's like int16_t then do them ourself
41
* type of (normal and unsigned) basic sizes
43
/* typedef short int16_t; */
44
/* typedef unsigned short uint16_t; */
45
/* typedef int int32_t; */
46
/* typedef unsigned int uint32_t; */
48
/* whatever normal size corresponds to a integer pointer */
49
#define intp_t int64_t
50
/* whatever normal size corresponds to a unsigned integer pointer */
51
#define u_intp_t u_int64_t
55
struct rxvt_vars; /* defined later on */
60
typedef struct rxvt_term *rxvt_t;
62
extern rxvt_t rxvt_current_term;
64
#define SET_R(r) rxvt_current_term = const_cast<rxvt_term *>(r)
65
#define GET_R rxvt_current_term
73
typedef uint32_t text_t;
75
typedef uint16_t text_t; // saves lots of memory
77
typedef uint32_t rend_t;
78
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
87
* height : 1 <= height
88
* ncol : 1 <= ncol <= MAX(tlen_t)
89
* nrow : 1 <= nrow <= MAX(int)
90
* saveLines : 0 <= saveLines <= MAX(int)
91
* term_start : 0 <= term_start < saveLines
92
* total_rows : nrow + saveLines
94
* top_row : -saveLines <= top_row <= 0
95
* view_start : top_row <= view_start <= 0
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.
103
* +------------+···········= term_start + top_row
105
* | scrollback +---------+·= term_start + view_start
106
* | scrollback | display |
107
* | scrollback | display |
108
* +------------+·display·+·= term_start
109
* | terminal | display |
110
* | terminal +---------+
113
* +------------+···········= term_stat + nrow - 1
116
* END······················= total_rows
120
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
int total_rows; /* total number of rows in this terminal */
134
int term_start; /* term lines start here */
135
int view_start; /* scrollback view starts here */
136
int top_row; /* topmost row index of scrollback */
137
Window parent[6]; /* parent identifiers - we're parent[0] */
138
Window vt; /* vt100 window */
139
GC gc; /* GC for drawing */
141
rxvt_drawable *drawable;
142
rxvt_fontset *fontset[4];
148
* 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
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
* * Note: -nsaved <= beg.row <= mark.row <= end.row < nrow
160
* * Note: col == -1 ==> we're left of screen
164
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
unsigned int charset; /* character set number [0..3] */
168
unsigned int flags; /* see below */
169
row_col_t s_cur; /* saved cursor position */
170
unsigned int s_charset; /* saved character set number [0..3] */
172
rend_t s_rstyle; /* saved rendition style */
175
enum selection_op_t {
176
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 */
184
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 */
195
/* ------------------------------------------------------------------------- */
198
#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
#define Screen_DefaultFlags (Screen_VisibleCursor | Screen_Autowrap)
205
/* rxvt_vars.options */
207
# define def(name,idx) Opt_ ## name = 1UL << (idx),
208
# define nodef(name) Opt_ ## name = 0,
214
/* ------------------------------------------------------------------------- */
217
char state; /* scrollbar state */
218
char init; /* scrollbar has been initialised */
219
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 */
226
int (rxvt_term::*update)(int, int, int, int);
228
void setIdle() { state = 1 ; }
229
void setMotion() { state = 'm'; }
230
void setUp() { state = 'U'; }
231
void setDn() { state = 'D'; }
234
struct rxvt_vars : TermWin_t {
235
scrollBar_t scrollBar;
238
rxvt_color *pix_colors;
239
rxvt_color *pix_colors_focused;
240
#ifdef OFF_FOCUS_FADING
241
rxvt_color *pix_colors_unfocused;
244
Cursor TermWin_cursor; /* cursor for vt window */
245
int sb_shadow; /* scrollbar shadow width */
247
line_t *row_buf; // all lines, scrollback + terminal, circular, followed by temp_buf
248
line_t *drawn_buf; // text on screen
249
line_t *swap_buf; // lines for swap buffer
250
char *tabs; /* per location: 1 == tab-stop */
253
selection_t selection;
258
#endif /* _RXVTLIB_H_ */