1 #ifndef _RXVTLIB_H_ /* include once only */
10 #include <sys/types.h>
19 @include_sys_select_h@
20 @include_sys_strredir_h@
30 // stdlib.h might provide it
34 #include <X11/Intrinsic.h> /* Xlib, Xutil, Xresource, Xfuncproto */
38 * If we haven't pulled in typedef's like int16_t then do them ourself
39 * type of (normal and unsigned) basic sizes
46 /* whatever normal size corresponds to a integer pointer */
48 /* whatever normal size corresponds to a unsigned integer pointer */
53 struct rxvt_vars; /* defined later on */
59 typedef struct rxvt_term *rxvt_t;
61 extern rxvt_t rxvt_current_term;
63 #define SET_R(r) rxvt_current_term = const_cast<rxvt_term *>(r)
64 #define GET_R rxvt_current_term
72 typedef uint32_t text_t;
74 typedef uint16_t text_t; // saves lots of memory
76 typedef uint32_t rend_t;
77 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
86 * height : 1 <= height
87 * ncol : 1 <= ncol <= MAX(tlen_t)
88 * nrow : 1 <= nrow <= MAX(int)
89 * saveLines : 0 <= saveLines <= MAX(int)
90 * term_start : 0 <= term_start < saveLines
91 * total_rows : nrow + saveLines
93 * top_row : -saveLines <= top_row <= 0
94 * view_start : top_row <= view_start <= 0
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.
102 * +------------+···········= term_start + top_row
104 * | scrollback +---------+·= term_start + view_start
105 * | scrollback | display |
106 * | scrollback | display |
107 * +------------+·display·+·= term_start
108 * | terminal | display |
109 * | terminal +---------+
112 * +------------+···········= term_stat + nrow - 1
115 * END······················= total_rows
119 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 int total_rows; /* total number of rows in this terminal */
133 int term_start; /* term lines start here */
134 int view_start; /* scrollback view starts here */
135 int top_row; /* topmost row index of scrollback */
136 Window parent[6]; /* parent identifiers - we're parent[0] */
137 Window vt; /* vt100 window */
138 GC gc; /* GC for drawing */
140 rxvt_drawable *drawable;
141 rxvt_fontset *fontset[4];
147 * 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
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 * * Note: -nsaved <= beg.row <= mark.row <= end.row < nrow
159 * * Note: col == -1 ==> we're left of screen
163 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 unsigned int charset; /* character set number [0..3] */
167 unsigned int flags; /* see below */
168 row_col_t s_cur; /* saved cursor position */
169 unsigned int s_charset; /* saved character set number [0..3] */
171 rend_t s_rstyle; /* saved rendition style */
174 enum selection_op_t {
175 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 */
183 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 */
194 /* ------------------------------------------------------------------------- */
197 #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 #define Screen_DefaultFlags (Screen_VisibleCursor | Screen_Autowrap)
204 /* rxvt_vars.options */
206 # define def(name,idx) Opt_ ## name = 1UL << (idx),
207 # define nodef(name) Opt_ ## name = 0,
213 /* ------------------------------------------------------------------------- */
216 char state; /* scrollbar state */
217 char init; /* scrollbar has been initialised */
218 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 */
225 int (rxvt_term::*update)(int, int, int, int);
227 void setIdle() { state = 1 ; }
228 void setMotion() { state = 'm'; }
229 void setUp() { state = 'U'; }
230 void setDn() { state = 'D'; }
233 struct rxvt_vars : TermWin_t {
234 scrollBar_t scrollBar;
237 rxvt_display *display;
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_ */