… | |
… | |
77 | typedef uint32_t text_t; |
77 | typedef uint32_t text_t; |
78 | #else |
78 | #else |
79 | typedef uint16_t text_t; // saves lots of memory |
79 | typedef uint16_t text_t; // saves lots of memory |
80 | #endif |
80 | #endif |
81 | typedef uint32_t rend_t; |
81 | typedef uint32_t rend_t; |
|
|
82 | typedef int16_t tlen_t; |
|
|
83 | |
|
|
84 | #define LINE_CONT -1 |
|
|
85 | |
|
|
86 | struct line_t { |
|
|
87 | text_t *t; // terminal the text |
|
|
88 | rend_t *r; // rendition, uses RS_ flags |
|
|
89 | tlen_t l; // length of each text line, LINE_CONT == continued on next line |
|
|
90 | |
|
|
91 | bool is_longer () |
|
|
92 | { |
|
|
93 | return l < 0; |
|
|
94 | } |
|
|
95 | |
|
|
96 | void set_is_longer () |
|
|
97 | { |
|
|
98 | l = LINE_CONT; |
|
|
99 | } |
|
|
100 | |
|
|
101 | void clear () |
|
|
102 | { |
|
|
103 | t = 0; |
|
|
104 | r = 0; |
|
|
105 | l = 0; |
|
|
106 | } |
|
|
107 | }; |
82 | |
108 | |
83 | /* |
109 | /* |
84 | * TermWin elements limits |
110 | * TermWin elements limits |
85 | * width : 1 <= width |
111 | * width : 1 <= width |
86 | * height : 1 <= height |
112 | * height : 1 <= height |
87 | * ncol : 1 <= ncol <= MAX(int16_t) |
113 | * ncol : 1 <= ncol <= MAX(int16_t) |
88 | * nrow : 1 <= nrow <= MAX(int16_t) |
114 | * nrow : 1 <= nrow <= MAX(int16_t) |
89 | * saveLines : 0 <= saveLines <= MAX(int16_t) |
115 | * saveLines : 0 <= saveLines <= MAX(int16_t) |
90 | * nscrolled : 0 <= nscrolled <= saveLines |
116 | * nsaved : 0 <= nscrolled <= saveLines |
|
|
117 | * term_start: 0 <= term_start < saveLines |
91 | * view_start: 0 <= view_start <= nscrolled |
118 | * view_start: 0 <= view_start < saveLines |
92 | */ |
119 | */ |
93 | |
120 | |
94 | typedef struct { |
121 | struct TermWin_t { |
95 | int width; /* window width [pixels] */ |
122 | int width; /* window width [pixels] */ |
96 | int height; /* window height [pixels] */ |
123 | int height; /* window height [pixels] */ |
97 | int fwidth; /* font width [pixels] */ |
124 | int fwidth; /* font width [pixels] */ |
98 | int fheight; /* font height [pixels] */ |
125 | int fheight; /* font height [pixels] */ |
99 | int fweight, fslant; |
126 | int fweight, fslant; |
… | |
… | |
104 | int mapped; /* window state mapped? */ |
131 | int mapped; /* window state mapped? */ |
105 | int int_bwidth; /* internal border width */ |
132 | int int_bwidth; /* internal border width */ |
106 | int ext_bwidth; /* external border width */ |
133 | int ext_bwidth; /* external border width */ |
107 | int lineSpace; /* number of extra pixels between rows */ |
134 | int lineSpace; /* number of extra pixels between rows */ |
108 | int saveLines; /* number of lines that fit in scrollback */ |
135 | int saveLines; /* number of lines that fit in scrollback */ |
109 | int nscrolled; /* number of line actually scrolled */ |
136 | int nsaved; /* number of line actually scrolled */ |
|
|
137 | int nscrolled; /*D*///TODO remove |
|
|
138 | int term_start; /* term lines start here */ |
110 | int view_start; /* scrollback view starts here */ |
139 | int view_start; /* scrollback view starts here */ |
111 | Window parent[6]; /* parent identifiers - we're parent[0] */ |
140 | Window parent[6]; /* parent identifiers - we're parent[0] */ |
112 | Window vt; /* vt100 window */ |
141 | Window vt; /* vt100 window */ |
113 | GC gc; /* GC for drawing */ |
142 | GC gc; /* GC for drawing */ |
114 | Pixmap pixmap; |
143 | Pixmap pixmap; |
115 | rxvt_drawable *drawable; |
144 | rxvt_drawable *drawable; |
116 | rxvt_fontset *fontset[4]; |
145 | rxvt_fontset *fontset[4]; |
117 | } TermWin_t; |
146 | }; |
118 | |
147 | |
119 | /* |
148 | /* |
120 | * screen accounting: |
149 | * screen accounting: |
121 | * screen_t elements |
150 | * screen_t elements |
122 | * text: Contains all text information including the scrollback buffer. |
151 | * text: Contains all text information including the scrollback buffer. |
123 | * Each line is length TermWin.ncol |
152 | * Each line is length ncol |
124 | * tlen: The length of the line or -1 for wrapped lines. |
153 | * tlen: The length of the line or -1 for wrapped lines. |
125 | * rend: Contains rendition information: font, bold, colour, etc. |
154 | * rend: Contains rendition information: font, bold, colour, etc. |
126 | * * Note: Each line for both text and rend are only allocated on demand, and |
155 | * * Note: Each line for both text and rend are only allocated on demand, and |
127 | * text[x] is allocated <=> rend[x] is allocated for all x. |
156 | * text[x] is allocated <=> rend[x] is allocated for all x. |
128 | * row: Cursor row position : 0 <= row < TermWin.nrow |
157 | * row: Cursor row position : 0 <= row < nrow |
129 | * col: Cursor column position : 0 <= col < TermWin.ncol |
158 | * col: Cursor column position : 0 <= col < ncol |
130 | * tscroll: Scrolling region top row inclusive : 0 <= row < TermWin.nrow |
159 | * tscroll: Scrolling region top row inclusive : 0 <= row < nrow |
131 | * bscroll: Scrolling region bottom row inclusive : 0 <= row < TermWin.nrow |
160 | * bscroll: Scrolling region bottom row inclusive : 0 <= row < nrow |
132 | * |
161 | * |
133 | * selection_t elements |
162 | * selection_t elements |
134 | * clicks: 1, 2 or 3 clicks - 4 indicates a special condition of 1 where |
163 | * clicks: 1, 2 or 3 clicks - 4 indicates a special condition of 1 where |
135 | * nothing is selected |
164 | * nothing is selected |
136 | * beg: row/column of beginning of selection : never past mark |
165 | * beg: row/column of beginning of selection : never past mark |
137 | * mark: row/column of initial click : never past end |
166 | * mark: row/column of initial click : never past end |
138 | * end: row/column of one character past end of selection |
167 | * end: row/column of one character past end of selection |
139 | * * Note: -TermWin.nscrolled <= beg.row <= mark.row <= end.row < TermWin.nrow |
168 | * * Note: -nscrolled <= beg.row <= mark.row <= end.row < nrow |
140 | * * Note: col == -1 ==> we're left of screen |
169 | * * Note: col == -1 ==> we're left of screen |
141 | * |
170 | * |
142 | * Layout of text/rend information in the screen_t text/rend structures: |
171 | * Layout of text/rend information in the screen_t text/rend structures: |
143 | * Rows [0] ... [TermWin.saveLines - 1] |
172 | * Rows [0] ... [saveLines - 1] |
144 | * scrollback region : we're only here if TermWin.view_start != 0 |
173 | * scrollback region : we're only here if view_start != 0 |
145 | * Rows [TermWin.saveLines] ... [TermWin.saveLines + TermWin.nrow - 1] |
174 | * Rows [saveLines] ... [saveLines + nrow - 1] |
146 | * normal `unscrolled' screen region |
175 | * normal `unscrolled' screen region |
147 | */ |
176 | */ |
148 | typedef struct { |
177 | typedef struct { |
149 | int16_t *tlen; /* length of each text line */ |
178 | line_t **line; |
150 | text_t **text; /* _all_ the text */ |
179 | |
151 | rend_t **rend; /* rendition, uses RS_ flags */ |
|
|
152 | row_col_t cur; /* cursor position on the screen */ |
180 | row_col_t cur; /* cursor position on the screen */ |
153 | unsigned int tscroll; /* top of settable scroll region */ |
181 | unsigned int tscroll; /* top of settable scroll region */ |
154 | unsigned int bscroll; /* bottom of settable scroll region */ |
182 | unsigned int bscroll; /* bottom of settable scroll region */ |
155 | unsigned int charset; /* character set number [0..3] */ |
183 | unsigned int charset; /* character set number [0..3] */ |
156 | unsigned int flags; /* see below */ |
184 | unsigned int flags; /* see below */ |
… | |
… | |
254 | void setMotion() { state = 'm'; } |
282 | void setMotion() { state = 'm'; } |
255 | void setUp() { state = 'U'; } |
283 | void setUp() { state = 'U'; } |
256 | void setDn() { state = 'D'; } |
284 | void setDn() { state = 'D'; } |
257 | } scrollBar_t; |
285 | } scrollBar_t; |
258 | |
286 | |
259 | struct rxvt_vars { |
287 | struct rxvt_vars : TermWin_t { |
260 | TermWin_t TermWin; |
|
|
261 | scrollBar_t scrollBar; |
288 | scrollBar_t scrollBar; |
262 | menuBar_t menuBar; |
289 | menuBar_t menuBar; |
263 | unsigned long options; |
290 | unsigned long options; |
264 | XSizeHints szHint; |
291 | XSizeHints szHint; |
265 | rxvt_display *display; |
292 | rxvt_display *display; |
… | |
… | |
271 | short numpix_colors; |
298 | short numpix_colors; |
272 | Cursor TermWin_cursor; /* cursor for vt window */ |
299 | Cursor TermWin_cursor; /* cursor for vt window */ |
273 | int sb_shadow; /* scrollbar shadow width */ |
300 | int sb_shadow; /* scrollbar shadow width */ |
274 | rxvt_ptytty pty; |
301 | rxvt_ptytty pty; |
275 | int numlock_state; |
302 | int numlock_state; |
276 | text_t **drawn_text; /* text drawn on screen (characters) */ |
303 | line_t *save; // all lines, scorllback + terminal, circular |
277 | rend_t **drawn_rend; /* text drawn on screen (rendition) */ |
304 | line_t *drawn; // text on screen |
278 | text_t **buf_text; |
305 | line_t *buf; // temporary buffer |
279 | rend_t **buf_rend; |
306 | line_t *swap_save; // lines for swap buffer |
280 | char *tabs; /* per location: 1 == tab-stop */ |
307 | char *tabs; /* per location: 1 == tab-stop */ |
281 | screen_t screen; |
308 | screen_t screen; |
282 | screen_t swap; |
309 | screen_t swap; |
283 | selection_t selection; |
310 | selection_t selection; |
284 | }; |
311 | }; |