ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtlib.h.in
Revision: 1.86
Committed: Fri Dec 28 14:00:47 2007 UTC (16 years, 4 months ago) by ayin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.85: +0 -0 lines
State: FILE REMOVED
Log Message:
Merge rxvtlib.h.in in rxvt.h.

File Contents

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