ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.7 by pcg, Tue Dec 16 23:04:13 2003 UTC vs.
Revision 1.14 by pcg, Fri Dec 26 07:42:23 2003 UTC

1/*--------------------------------*-C-*--------------------------------------* 1/*--------------------------------*-C-*--------------------------------------*
2 * File: screen.c 2 * File: screen.c
3 *---------------------------------------------------------------------------* 3 *---------------------------------------------------------------------------*
4 * $Id: screen.C,v 1.7 2003/12/16 23:04:13 pcg Exp $ 4 * $Id: screen.C,v 1.14 2003/12/26 07:42:23 pcg Exp $
5 * 5 *
6 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 6 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
31#include <X11/Xmd.h> /* get the typedef for CARD32 */ 31#include <X11/Xmd.h> /* get the typedef for CARD32 */
32 32
33#include <stdint.h> 33#include <stdint.h>
34#include <wchar.h> 34#include <wchar.h>
35 35
36#include "salloc.C" // HACK!!
37
36inline void fill_text (text_t *start, text_t value, int len) 38inline void fill_text (text_t *start, text_t value, int len)
37{ 39{
38 while (len--) 40 while (len--)
39 *start++ = value; 41 *start++ = value;
40} 42}
87/* 89/*
88 * CLEAR_ROWS : clear <num> rows starting from row <row> 90 * CLEAR_ROWS : clear <num> rows starting from row <row>
89 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> 91 * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y>
90 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour 92 * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour
91 */ 93 */
92#define drawBuffer (R->TermWin.vt) 94#define drawBuffer TermWin.vt
93 95
94#define CLEAR_ROWS(row, num) \ 96#define CLEAR_ROWS(row, num) \
95 if (R->TermWin.mapped) \ 97 if (TermWin.mapped) \
96 XClearArea(R->Xdisplay, drawBuffer, R->TermWin.int_bwidth, \ 98 XClearArea (Xdisplay, drawBuffer, TermWin.int_bwidth, \
97 Row2Pixel(row), (unsigned int)R->TermWin.width, \ 99 Row2Pixel(row), (unsigned int)TermWin.width, \
98 (unsigned int)Height2Pixel(num), False) 100 (unsigned int)Height2Pixel(num), False)
99 101
100#define CLEAR_CHARS(x, y, num) \ 102#define CLEAR_CHARS(x, y, num) \
101 if (R->TermWin.mapped) \ 103 if (TermWin.mapped) \
102 XClearArea(R->Xdisplay, drawBuffer, x, y, \ 104 XClearArea (Xdisplay, drawBuffer, x, y, \
103 (unsigned int)Width2Pixel(num), \ 105 (unsigned int)Width2Pixel(num), \
104 (unsigned int)Height2Pixel(1), False) 106 (unsigned int)Height2Pixel(1), False)
105 107
106#define ERASE_ROWS(row, num) \ 108#define ERASE_ROWS(row, num) \
107 XFillRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, \ 109 XFillRectangle (Xdisplay, drawBuffer, TermWin.gc, \
108 R->TermWin.int_bwidth, Row2Pixel(row), \ 110 TermWin.int_bwidth, Row2Pixel(row), \
109 (unsigned int)R->TermWin.width, \ 111 (unsigned int)TermWin.width, \
110 (unsigned int)Height2Pixel(num)) 112 (unsigned int)Height2Pixel(num))
111 113
112/* ------------------------------------------------------------------------- * 114/* ------------------------------------------------------------------------- *
113 * SCREEN `COMMON' ROUTINES * 115 * SCREEN `COMMON' ROUTINES *
114 * ------------------------------------------------------------------------- */ 116 * ------------------------------------------------------------------------- */
115/* Fill part/all of a line with blanks. */ 117/* Fill part/all of a line with blanks. */
116/* INTPROTO */
117void 118void
118rxvt_blank_line(pR_ text_t *et, rend_t *er, unsigned int width, rend_t efs) 119rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs)
119{ 120{
120 efs &= ~RS_baseattrMask; 121 efs &= ~RS_baseattrMask;
121 efs = SET_FONT (efs, R->TermWin.fontset->find_font (' ')); 122 efs = SET_FONT (efs, TermWin.fontset->find_font (' '));
122 123
123 while (width--) 124 while (width--)
124 { 125 {
125 *et++ = ' '; 126 *et++ = ' ';
126 *er++ = efs; 127 *er++ = efs;
127 } 128 }
128} 129}
129 130
130/* ------------------------------------------------------------------------- */ 131/* ------------------------------------------------------------------------- */
131/* Fill a full line with blanks - make sure it is allocated first */ 132/* Fill a full line with blanks - make sure it is allocated first */
132/* INTPROTO */
133void 133void
134rxvt_blank_screen_mem(pR_ text_t **tp, rend_t **rp, unsigned int row, rend_t efs) 134rxvt_term::scr_blank_screen_mem (text_t **tp, rend_t **rp, unsigned int row, rend_t efs)
135{ 135{
136 int width = R->TermWin.ncol;
137 rend_t *er;
138
139#ifdef DEBUG_STRICT 136#ifdef DEBUG_STRICT
140 assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL)); 137 assert((tp[row] && rp[row]) || (tp[row] == NULL && rp[row] == NULL));
141#endif 138#endif
142 if (tp[row] == NULL) { 139 if (tp[row] == NULL)
143 tp[row] = (text_t *)rxvt_malloc(sizeof(text_t) * width);
144 rp[row] = (rend_t *)rxvt_malloc(sizeof(rend_t) * width);
145 } 140 {
141 tp[row] = (text_t *)talloc->alloc ();
142 rp[row] = (rend_t *)ralloc->alloc ();
143 }
144
146 rxvt_blank_line (aR_ tp[row], rp[row], width, efs); 145 scr_blank_line (tp[row], rp[row], TermWin.ncol, efs);
147} 146}
148 147
149/* ------------------------------------------------------------------------- * 148/* ------------------------------------------------------------------------- *
150 * SCREEN INITIALISATION * 149 * SCREEN INITIALISATION *
151 * ------------------------------------------------------------------------- */ 150 * ------------------------------------------------------------------------- */
152/* EXTPROTO */
153void 151void
154rxvt_scr_reset(pR) 152rxvt_term::scr_reset ()
155{ 153{
156 unsigned int ncol, nrow, prev_ncol, prev_nrow, 154 unsigned int ncol, nrow, total_rows, prev_total_rows;
157 total_rows, prev_total_rows;
158 unsigned int p, q; 155 unsigned int p, q;
159 int k; 156 int k;
160 rend_t setrstyle; 157 rend_t setrstyle;
161 158
162 D_SCREEN((stderr, "rxvt_scr_reset()")); 159 D_SCREEN((stderr, "rxvt_scr_reset()"));
163 160
164 R->TermWin.view_start = 0; 161 TermWin.view_start = 0;
165 R->num_scr = 0; 162 num_scr = 0;
166 163
167 prev_ncol = R->prev_ncol;
168 prev_nrow = R->prev_nrow;
169 if (R->TermWin.ncol == 0) 164 if (TermWin.ncol == 0)
170 R->TermWin.ncol = 80; 165 TermWin.ncol = 80;
166
171 if (R->TermWin.nrow == 0) 167 if (TermWin.nrow == 0)
172 R->TermWin.nrow = 24; 168 TermWin.nrow = 24;
169
173 ncol = R->TermWin.ncol; 170 ncol = TermWin.ncol;
174 nrow = R->TermWin.nrow; 171 nrow = TermWin.nrow;
172
175 if (ncol == prev_ncol && nrow == prev_nrow) 173 if (ncol == prev_ncol && nrow == prev_nrow)
176 return; 174 return;
177 175
178 R->want_refresh = 1; 176 want_refresh = 1;
179 177
180 total_rows = nrow + R->TermWin.saveLines; 178 total_rows = nrow + TermWin.saveLines;
181 prev_total_rows = prev_nrow + R->TermWin.saveLines; 179 prev_total_rows = prev_nrow + TermWin.saveLines;
182 180
183 R->screen.tscroll = 0; 181 screen.tscroll = 0;
184 R->screen.bscroll = nrow - 1; 182 screen.bscroll = nrow - 1;
185 183
184 if (!talloc)
185 {
186 talloc = new rxvt_salloc (ncol * sizeof (text_t));
187 ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
188 }
189
186 if (prev_nrow == 0) { 190 if (prev_nrow == 0)
187/* 191 {
192 /*
188 * A: first time called so just malloc everything : don't rely on realloc 193 * first time called so just malloc everything : don't rely on realloc
189 * Note: this is still needed so that all the scrollback lines are NULL 194 * Note: this is still needed so that all the scrollback lines are NULL
190 */ 195 */
191 R->screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); 196 screen.text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *));
192 R->buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *)); 197 buf_text = (text_t **)rxvt_calloc(total_rows, sizeof(text_t *));
193 R->drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); 198 drawn_text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *));
194 R->swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *)); 199 swap.text = (text_t **)rxvt_calloc(nrow, sizeof(text_t *));
195 200
196 R->screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t)); 201 screen.tlen = (int16_t *)rxvt_calloc(total_rows, sizeof(int16_t));
197 R->swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t)); 202 swap.tlen = (int16_t *)rxvt_calloc(nrow, sizeof(int16_t));
198 203
199 R->screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); 204 screen.rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *));
200 R->buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *)); 205 buf_rend = (rend_t **)rxvt_calloc(total_rows, sizeof(rend_t *));
201 R->drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); 206 drawn_rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *));
202 R->swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *)); 207 swap.rend = (rend_t **)rxvt_calloc(nrow, sizeof(rend_t *));
203 208
204 for (p = 0; p < nrow; p++) { 209 for (p = 0; p < nrow; p++)
210 {
205 q = p + R->TermWin.saveLines; 211 q = p + TermWin.saveLines;
206 rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, 212 scr_blank_screen_mem (screen.text, screen.rend, q, DEFAULT_RSTYLE);
207 q, DEFAULT_RSTYLE); 213 scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE);
208 rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend,
209 p, DEFAULT_RSTYLE);
210 R->screen.tlen[q] = R->swap.tlen[p] = 0; 214 screen.tlen[q] = swap.tlen[p] = 0;
211 rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, 215 scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE);
212 p, DEFAULT_RSTYLE);
213 } 216 }
217
214 MEMSET(R->charsets, 'B', sizeof(R->charsets)); 218 MEMSET(charsets, 'B', sizeof(charsets));
215 R->TermWin.nscrolled = 0; /* no saved lines */ 219 TermWin.nscrolled = 0; /* no saved lines */
216 R->rstyle = DEFAULT_RSTYLE; 220 rstyle = DEFAULT_RSTYLE;
217 R->screen.flags = Screen_DefaultFlags; 221 screen.flags = Screen_DefaultFlags;
218 R->screen.cur.row = R->screen.cur.col = 0; 222 screen.cur.row = screen.cur.col = 0;
219 R->screen.charset = 0; 223 screen.charset = 0;
220 R->current_screen = PRIMARY; 224 current_screen = PRIMARY;
221 rxvt_scr_cursor(aR_ SAVE); 225 rxvt_scr_cursor (this, SAVE);
226
222#if NSCREENS 227#if NSCREENS
223 R->swap.flags = Screen_DefaultFlags; 228 swap.flags = Screen_DefaultFlags;
224 R->swap.cur.row = R->swap.cur.col = 0; 229 swap.cur.row = swap.cur.col = 0;
225 R->swap.charset = 0; 230 swap.charset = 0;
226 R->current_screen = SECONDARY; 231 current_screen = SECONDARY;
227 rxvt_scr_cursor(aR_ SAVE); 232 rxvt_scr_cursor (this, SAVE);
228 R->current_screen = PRIMARY; 233 current_screen = PRIMARY;
229#endif 234#endif
235
230 R->selection.text = NULL; 236 selection.text = NULL;
231 R->selection.len = 0; 237 selection.len = 0;
232 R->selection.op = SELECTION_CLEAR; 238 selection.op = SELECTION_CLEAR;
233 R->selection.screen = PRIMARY; 239 selection.screen = PRIMARY;
234 R->selection.clicks = 0; 240 selection.clicks = 0;
235 CLEAR_ALL_SELECTION(R); 241 CLEAR_ALL_SELECTION (this);
236 R->rvideo = 0; 242 rvideo = 0;
237 243 }
238 } else { 244 else
239/* 245 {
246 /*
240 * B1: add or delete rows as appropriate 247 * add or delete rows as appropriate
241 */ 248 */
242 setrstyle = DEFAULT_RSTYLE; 249 setrstyle = DEFAULT_RSTYLE;
243 250
244 if (nrow < prev_nrow) { 251 if (nrow < prev_nrow)
252 {
245 /* delete rows */ 253 /* delete rows */
246 k = min(R->TermWin.nscrolled, prev_nrow - nrow); 254 k = min (TermWin.nscrolled, prev_nrow - nrow);
247 rxvt_scroll_text(aR_ 0, (int)prev_nrow - 1, k, 1); 255 scr_scroll_text (0, (int)prev_nrow - 1, k, 1);
256
248 for (p = nrow; p < prev_nrow; p++) { 257 for (p = nrow; p < prev_nrow; p++)
258 {
249 q = p + R->TermWin.saveLines; 259 q = p + TermWin.saveLines;
250 if (R->screen.text[q]) { 260 if (screen.text[q])
261 {
251#ifdef DEBUG_STRICT 262#ifdef DEBUG_STRICT
252 assert(R->screen.rend[q]); 263 assert (screen.rend[q]);
253#endif 264#endif
254 free(R->screen.text[q]); 265 talloc->free (screen.text[q]);
255 free(R->screen.rend[q]); 266 ralloc->free (screen.rend[q]);
256 } 267 }
257 if (R->swap.text[p]) { 268 if (swap.text[p])
269 {
258#ifdef DEBUG_STRICT 270#ifdef DEBUG_STRICT
259 assert(R->swap.rend[p]); 271 assert (swap.rend[p]);
260#endif 272#endif
261 free(R->swap.text[p]); 273 talloc->free (swap.text[p]);
262 free(R->swap.rend[p]); 274 ralloc->free (swap.rend[p]);
263 } 275 }
264#ifdef DEBUG_STRICT 276#ifdef DEBUG_STRICT
265 assert(R->drawn_text[p] && R->drawn_rend[p]); 277 assert (drawn_text[p] && drawn_rend[p]);
266#endif 278#endif
267 free(R->drawn_text[p]); 279 talloc->free (drawn_text[p]);
268 free(R->drawn_rend[p]); 280 ralloc->free (drawn_rend[p]);
269 } 281 }
282
270 /* we have fewer rows so fix up cursor position */ 283 /* we have fewer rows so fix up cursor position */
271 MIN_IT(R->screen.cur.row, (int32_t)nrow - 1); 284 MIN_IT (screen.cur.row, (int32_t)nrow - 1);
272 MIN_IT(R->swap.cur.row, (int32_t)nrow - 1); 285 MIN_IT (swap.cur.row, (int32_t)nrow - 1);
273 286
274 rxvt_scr_reset_realloc(aR); /* realloc _last_ */ 287 scr_reset_realloc (); /* realloc _last_ */
275 288 }
276 } else if (nrow > prev_nrow) { 289 else if (nrow > prev_nrow)
290 {
277 /* add rows */ 291 /* add rows */
278 rxvt_scr_reset_realloc(aR); /* realloc _first_ */ 292 scr_reset_realloc (); /* realloc _first_ */
279 293
294 TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this
295
280 k = min(R->TermWin.nscrolled, nrow - prev_nrow); 296 k = min (TermWin.nscrolled, nrow - prev_nrow);
297
281 for (p = prev_total_rows; p < total_rows; p++) { 298 for (p = prev_total_rows; p < total_rows; p++)
299 {
282 R->screen.tlen[p] = 0; 300 screen.tlen[p] = 0;
283 R->screen.text[p] = NULL; 301 screen.text[p] = NULL;
284 R->screen.rend[p] = NULL; 302 screen.rend[p] = NULL;
285 } 303 }
304
286 for (p = prev_total_rows; p < total_rows - k; p++) 305 for (p = prev_total_rows; p < total_rows - k; p++)
287 rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, 306 scr_blank_screen_mem (screen.text, screen.rend, p, setrstyle);
288 p, setrstyle); 307
289 for (p = prev_nrow; p < nrow; p++) { 308 for (p = prev_nrow; p < nrow; p++)
309 {
290 R->swap.tlen[p] = 0; 310 swap.tlen[p] = 0;
291 R->swap.text[p] = NULL; 311 swap.text[p] = NULL;
292 R->swap.rend[p] = NULL; 312 swap.rend[p] = NULL;
293 R->drawn_text[p] = NULL; 313 drawn_text[p] = NULL;
294 R->drawn_rend[p] = NULL; 314 drawn_rend[p] = NULL;
295 rxvt_blank_screen_mem(aR_ R->swap.text, R->swap.rend, 315 scr_blank_screen_mem (swap.text, swap.rend, p, setrstyle);
296 p, setrstyle);
297 rxvt_blank_screen_mem(aR_ R->drawn_text, R->drawn_rend, 316 scr_blank_screen_mem (drawn_text, drawn_rend, p, setrstyle);
298 p, setrstyle);
299 } 317 }
318
300 if (k > 0) { 319 if (k > 0)
320 {
301 rxvt_scroll_text(aR_ 0, (int)nrow - 1, -k, 1); 321 scr_scroll_text (0, (int)nrow - 1, -k, 1);
302 R->screen.cur.row += k; 322 screen.cur.row += k;
303 R->screen.s_cur.row += k; 323 screen.s_cur.row += k;
304 R->TermWin.nscrolled -= k; 324 TermWin.nscrolled -= k;
305 } 325 }
306#ifdef DEBUG_STRICT 326#ifdef DEBUG_STRICT
307 assert(R->screen.cur.row < R->TermWin.nrow); 327 assert(screen.cur.row < TermWin.nrow);
308 assert(R->swap.cur.row < R->TermWin.nrow); 328 assert(swap.cur.row < TermWin.nrow);
309#else /* drive with your eyes closed */ 329#else /* drive with your eyes closed */
330
310 MIN_IT(R->screen.cur.row, nrow - 1); 331 MIN_IT(screen.cur.row, nrow - 1);
311 MIN_IT(R->swap.cur.row, nrow - 1); 332 MIN_IT(swap.cur.row, nrow - 1);
312#endif 333#endif
334 TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this
313 } 335 }
336
314/* B2: resize columns */ 337 /* resize columns */
315 if (ncol != prev_ncol) { 338 if (ncol != prev_ncol)
339 {
340 int common = min (prev_ncol, ncol);
341 rxvt_salloc *ta = new rxvt_salloc (ncol * sizeof (text_t));
342 rxvt_salloc *ra = new rxvt_salloc (ncol * sizeof (rend_t));
343
316 for (p = 0; p < total_rows; p++) { 344 for (p = 0; p < total_rows; p++)
345 {
317 if (R->screen.text[p]) { 346 if (screen.text[p])
318 R->screen.text[p] = (text_t *)rxvt_realloc(R->screen.text[p], ncol * sizeof(text_t)); 347 {
319 R->screen.rend[p] = (rend_t *)rxvt_realloc(R->screen.rend[p], ncol * sizeof(rend_t)); 348 text_t *t = (text_t *)ta->alloc (); memcpy (t, screen.text[p], common * sizeof (text_t)); screen.text[p] = t;
349 rend_t *r = (rend_t *)ra->alloc (); memcpy (r, screen.rend[p], common * sizeof (rend_t)); screen.rend[p] = r;
350
320 MIN_IT(R->screen.tlen[p], (int16_t)ncol); 351 MIN_IT(screen.tlen[p], (int16_t)ncol);
352
321 if (ncol > prev_ncol) 353 if (ncol > prev_ncol)
322 rxvt_blank_line(aR_ 354 scr_blank_line (&(screen.text[p][prev_ncol]),
323 &(R->screen.text[p][prev_ncol]),
324 &(R->screen.rend[p][prev_ncol]), 355 &(screen.rend[p][prev_ncol]),
325 ncol - prev_ncol, 356 ncol - prev_ncol,
326 setrstyle); 357 setrstyle);
327 } 358 }
328 } 359 }
360
329 for (p = 0; p < nrow; p++) { 361 for (p = 0; p < nrow; p++)
330 R->drawn_text[p] = (text_t *)rxvt_realloc(R->drawn_text[p], ncol * sizeof(text_t)); 362 {
331 R->drawn_rend[p] = (rend_t *)rxvt_realloc(R->drawn_rend[p], ncol * sizeof(rend_t)); 363 text_t *t = (text_t *)ta->alloc (); memcpy (t, drawn_text[p], common * sizeof (text_t)); drawn_text[p] = t;
364 rend_t *r = (rend_t *)ra->alloc (); memcpy (r, drawn_rend[p], common * sizeof (rend_t)); drawn_rend[p] = r;
365
366 if (ncol > prev_ncol)
367 scr_blank_line (&(drawn_text[p][prev_ncol]),
368 &(drawn_rend[p][prev_ncol]),
369 ncol - prev_ncol, setrstyle);
370
332 if (R->swap.text[p]) { 371 if (swap.text[p])
333 R->swap.text[p] = (text_t *)rxvt_realloc(R->swap.text[p], ncol * sizeof(text_t)); 372 {
334 R->swap.rend[p] = (rend_t *)rxvt_realloc(R->swap.rend[p], ncol * sizeof(rend_t)); 373 text_t *t = (text_t *)ta->alloc (); memcpy (t, swap.text[p], common * sizeof (text_t)); swap.text[p] = t;
374 rend_t *r = (rend_t *)ra->alloc (); memcpy (r, swap.rend[p], common * sizeof (rend_t)); swap.rend[p] = r;
375
335 MIN_IT(R->swap.tlen[p], (int16_t)ncol); 376 MIN_IT(swap.tlen[p], (int16_t)ncol);
377
336 if (ncol > prev_ncol) 378 if (ncol > prev_ncol)
337 rxvt_blank_line(aR_ 379 scr_blank_line (&(swap.text[p][prev_ncol]),
338 &(R->swap.text[p][prev_ncol]),
339 &(R->swap.rend[p][prev_ncol]), 380 &(swap.rend[p][prev_ncol]),
340 ncol - prev_ncol, setrstyle); 381 ncol - prev_ncol, setrstyle);
341 } 382 }
342 if (ncol > prev_ncol) 383
343 rxvt_blank_line(aR_
344 &(R->drawn_text[p][prev_ncol]),
345 &(R->drawn_rend[p][prev_ncol]),
346 ncol - prev_ncol, setrstyle);
347 } 384 }
385
348 MIN_IT(R->screen.cur.col, (int16_t)ncol - 1); 386 MIN_IT (screen.cur.col, (int16_t)ncol - 1);
349 MIN_IT(R->swap.cur.col, (int16_t)ncol - 1); 387 MIN_IT (swap.cur.col, (int16_t)ncol - 1);
388
389 delete talloc; talloc = ta;
390 delete ralloc; ralloc = ra;
350 } 391 }
392
351 if (R->tabs) 393 if (tabs)
352 free(R->tabs); 394 free(tabs);
353 } 395 }
354 396
397 prev_nrow = nrow;
398 prev_ncol = ncol;
399
355 R->tabs = (char *)rxvt_malloc(ncol * sizeof(char)); 400 tabs = (char *)rxvt_malloc (ncol * sizeof(char));
356 401
357 for (p = 0; p < ncol; p++) 402 for (p = 0; p < ncol; p++)
358 R->tabs[p] = (p % TABSIZE == 0) ? 1 : 0; 403 tabs[p] = (p % TABSIZE == 0) ? 1 : 0;
359 404
360 R->prev_nrow = nrow;
361 R->prev_ncol = ncol;
362
363 R->tt_winch (); 405 tt_winch ();
364} 406}
365 407
366/* INTPROTO */
367void 408void
368rxvt_scr_reset_realloc(pR) 409rxvt_term::scr_reset_realloc()
369{ 410{
370 uint16_t total_rows, nrow; 411 uint16_t total_rows, nrow;
371 412
372 nrow = R->TermWin.nrow; 413 nrow = TermWin.nrow;
373 total_rows = nrow + R->TermWin.saveLines; 414 total_rows = nrow + TermWin.saveLines;
374/* *INDENT-OFF* */ 415 /* *INDENT-OFF* */
375 R->screen.text = (text_t **)rxvt_realloc(R->screen.text, total_rows * sizeof(text_t *)); 416 screen.text = (text_t **)rxvt_realloc(screen.text, total_rows * sizeof(text_t *));
376 R->buf_text = (text_t **)rxvt_realloc(R->buf_text , total_rows * sizeof(text_t *)); 417 buf_text = (text_t **)rxvt_realloc(buf_text , total_rows * sizeof(text_t *));
377 R->drawn_text = (text_t **)rxvt_realloc(R->drawn_text , nrow * sizeof(text_t *)); 418 drawn_text = (text_t **)rxvt_realloc(drawn_text , nrow * sizeof(text_t *));
378 R->swap.text = (text_t **)rxvt_realloc(R->swap.text , nrow * sizeof(text_t *)); 419 swap.text = (text_t **)rxvt_realloc(swap.text , nrow * sizeof(text_t *));
379 420
380 R->screen.tlen = (int16_t *)rxvt_realloc(R->screen.tlen, total_rows * sizeof(int16_t)); 421 screen.tlen = (int16_t *)rxvt_realloc(screen.tlen, total_rows * sizeof(int16_t));
381 R->swap.tlen = (int16_t *)rxvt_realloc(R->swap.tlen , total_rows * sizeof(int16_t)); 422 swap.tlen = (int16_t *)rxvt_realloc(swap.tlen , total_rows * sizeof(int16_t));
382 423
383 R->screen.rend = (rend_t **)rxvt_realloc(R->screen.rend, total_rows * sizeof(rend_t *)); 424 screen.rend = (rend_t **)rxvt_realloc(screen.rend, total_rows * sizeof(rend_t *));
384 R->buf_rend = (rend_t **)rxvt_realloc(R->buf_rend , total_rows * sizeof(rend_t *)); 425 buf_rend = (rend_t **)rxvt_realloc(buf_rend , total_rows * sizeof(rend_t *));
385 R->drawn_rend = (rend_t **)rxvt_realloc(R->drawn_rend , nrow * sizeof(rend_t *)); 426 drawn_rend = (rend_t **)rxvt_realloc(drawn_rend , nrow * sizeof(rend_t *));
386 R->swap.rend = (rend_t **)rxvt_realloc(R->swap.rend , nrow * sizeof(rend_t *)); 427 swap.rend = (rend_t **)rxvt_realloc(swap.rend , nrow * sizeof(rend_t *));
387/* *INDENT-ON* */ 428 /* *INDENT-ON* */
388} 429}
389 430
390/* ------------------------------------------------------------------------- */ 431/* ------------------------------------------------------------------------- */
391/* 432/*
392 * Free everything. That way malloc debugging can find leakage. 433 * Free everything. That way malloc debugging can find leakage.
393 */ 434 */
394/* EXTPROTO */
395void 435void
396rxvt_scr_release(pR) 436rxvt_term::scr_release()
397{ 437{
398 uint16_t total_rows; 438 uint16_t total_rows;
399 int i; 439 int i;
400 440
401 total_rows = R->TermWin.nrow + R->TermWin.saveLines; 441 total_rows = TermWin.nrow + TermWin.saveLines;
402 for (i = 0; i < total_rows; i++) { 442
403 if (R->screen.text[i]) { /* then so is R->screen.rend[i] */
404 free(R->screen.text[i]);
405#ifdef DEBUG_STRICT 443#ifdef DEBUG_STRICT
444 for (i = 0; i < total_rows; i++)
445 {
446 if (screen.text[i])
447 /* then so is screen.rend[i] */
406 assert(R->screen.rend[i]); 448 assert(screen.rend[i]);
407#endif
408 free(R->screen.rend[i]);
409 }
410 } 449 }
411 for (i = 0; i < R->TermWin.nrow; i++) { 450#endif
412 free(R->drawn_text[i]); 451
413 free(R->drawn_rend[i]); 452 delete talloc;
414 free(R->swap.text[i]); 453 delete ralloc;
415 free(R->swap.rend[i]); 454
416 }
417 free(R->screen.text); 455 free (screen.text);
418 free(R->screen.tlen); 456 free (screen.tlen);
419 free(R->screen.rend); 457 free (screen.rend);
420 free(R->drawn_text); 458 free (drawn_text);
421 free(R->drawn_rend); 459 free (drawn_rend);
422 free(R->swap.text); 460 free (swap.text);
423 free(R->swap.tlen); 461 free (swap.tlen);
424 free(R->swap.rend); 462 free (swap.rend);
425 free(R->buf_text); 463 free (buf_text);
426 free(R->buf_rend); 464 free (buf_rend);
427 free(R->tabs); 465 free (tabs);
428 466
429/* NULL these so if anything tries to use them, we'll know about it */ 467 /* NULL these so if anything tries to use them, we'll know about it */
430 R->screen.text = R->drawn_text = R->swap.text = NULL; 468 screen.text = drawn_text = swap.text = NULL;
431 R->screen.rend = R->drawn_rend = R->swap.rend = NULL; 469 screen.rend = drawn_rend = swap.rend = NULL;
432 R->screen.tlen = R->swap.tlen = NULL; 470 screen.tlen = swap.tlen = NULL;
433 R->buf_text = NULL; 471 buf_text = NULL;
434 R->buf_rend = NULL; 472 buf_rend = NULL;
435 R->tabs = NULL; 473 tabs = NULL;
436} 474}
437 475
438/* ------------------------------------------------------------------------- */ 476/* ------------------------------------------------------------------------- */
439/* 477/*
440 * Hard reset 478 * Hard reset
441 */ 479 */
442/* EXTPROTO */ 480/* EXTPROTO */
443void 481void
444rxvt_scr_poweron(pR) 482rxvt_scr_poweron(pR)
445{ 483{
446 D_SCREEN((stderr, "rxvt_scr_poweron()")); 484 D_SCREEN((stderr, "rxvt_scr_poweron()"));
447 485
448 rxvt_scr_release(aR); 486 R->scr_release ();
449 R->prev_nrow = R->prev_ncol = 0; 487 R->prev_nrow = R->prev_ncol = 0;
450 rxvt_scr_reset(aR); 488 R->scr_reset ();
451 489
452 rxvt_scr_clear(aR); 490 R->scr_clear ();
453 rxvt_scr_refresh(aR_ SLOW_REFRESH); 491 R->scr_refresh (SLOW_REFRESH);
454#ifdef RXVT_GRAPHICS 492#ifdef RXVT_GRAPHICS
455 rxvt_Gr_reset(aR); 493 rxvt_Gr_reset (aR);
456#endif 494#endif
457} 495}
458 496
459/* ------------------------------------------------------------------------- * 497/* ------------------------------------------------------------------------- *
460 * PROCESS SCREEN COMMANDS * 498 * PROCESS SCREEN COMMANDS *
576 if (R->current_screen == PRIMARY 614 if (R->current_screen == PRIMARY
577# ifdef RXVT_GRAPHICS 615# ifdef RXVT_GRAPHICS
578 && !rxvt_Gr_Displayed(aR) 616 && !rxvt_Gr_Displayed(aR)
579# endif 617# endif
580 ) 618 )
581 rxvt_scroll_text(aR_ 0, (R->prev_nrow - 1), R->prev_nrow, 0); 619 R->scr_scroll_text(0, (R->prev_nrow - 1), R->prev_nrow, 0);
582# endif 620# endif
583#endif 621#endif
584 return scrn; 622 return scrn;
585} 623}
586 624
620 * Scroll text between <row1> and <row2> inclusive, by <count> lines 658 * Scroll text between <row1> and <row2> inclusive, by <count> lines
621 * count positive ==> scroll up 659 * count positive ==> scroll up
622 * count negative ==> scroll down 660 * count negative ==> scroll down
623 * spec == 0 for normal routines 661 * spec == 0 for normal routines
624 */ 662 */
625/* EXTPROTO */
626int 663int
627rxvt_scroll_text(pR_ int row1, int row2, int count, int spec) 664rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec)
628{ 665{
629 int i, j; 666 int i, j;
630 long nscrolled; 667 long nscrolled;
631 668
632 if (count == 0 || (row1 > row2)) 669 if (count == 0 || (row1 > row2))
633 return 0; 670 return 0;
634 671
635 R->want_refresh = 1; 672 want_refresh = 1;
636 D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (R->current_screen == PRIMARY) ? "Primary" : "Secondary")); 673 D_SCREEN((stderr, "rxvt_scroll_text(%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary"));
637 674
638 if ((count > 0) && (row1 == 0) && (R->current_screen == PRIMARY)) { 675 if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY))
676 {
639 nscrolled = (long)R->TermWin.nscrolled + (long)count;; 677 nscrolled = (long)TermWin.nscrolled + (long)count;
678
640 if (nscrolled > (long)R->TermWin.saveLines) 679 if (nscrolled > (long)TermWin.saveLines)
641 R->TermWin.nscrolled = R->TermWin.saveLines; 680 TermWin.nscrolled = TermWin.saveLines;
642 else 681 else
643 R->TermWin.nscrolled = (uint16_t)nscrolled; 682 TermWin.nscrolled = (uint16_t)nscrolled;
683
644 if ((R->Options & Opt_scrollWithBuffer) 684 if ((Options & Opt_scrollWithBuffer)
645 && R->TermWin.view_start != 0 685 && TermWin.view_start != 0
646 && R->TermWin.view_start != R->TermWin.saveLines) 686 && TermWin.view_start != TermWin.saveLines)
647 rxvt_scr_page(aR_ UP, count); 687 rxvt_scr_page (this, UP, count);
688 }
648 } else if (!spec) 689 else if (!spec)
649 row1 += R->TermWin.saveLines;
650 row2 += R->TermWin.saveLines; 690 row1 += TermWin.saveLines;
651 691
692 row2 += TermWin.saveLines;
693
652 if (R->selection.op && R->current_screen == R->selection.screen) { 694 if (selection.op && current_screen == selection.screen)
695 {
653 i = R->selection.beg.row + R->TermWin.saveLines; 696 i = selection.beg.row + TermWin.saveLines;
654 j = R->selection.end.row + R->TermWin.saveLines; 697 j = selection.end.row + TermWin.saveLines;
655 if ((i < row1 && j > row1) 698 if ((i < row1 && j > row1)
656 || (i < row2 && j > row2) 699 || (i < row2 && j > row2)
657 || (i - count < row1 && i >= row1) 700 || (i - count < row1 && i >= row1)
658 || (i - count > row2 && i <= row2) 701 || (i - count > row2 && i <= row2)
659 || (j - count < row1 && j >= row1) 702 || (j - count < row1 && j >= row1)
660 || (j - count > row2 && j <= row2)) { 703 || (j - count > row2 && j <= row2))
704 {
661 CLEAR_ALL_SELECTION(R); 705 CLEAR_ALL_SELECTION (this);
662 R->selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ 706 selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */
707 }
663 } else if (j >= row1 && j <= row2) { 708 else if (j >= row1 && j <= row2)
709 {
664 /* move selected region too */ 710 /* move selected region too */
665 R->selection.beg.row -= count; 711 selection.beg.row -= count;
666 R->selection.end.row -= count; 712 selection.end.row -= count;
667 R->selection.mark.row -= count; 713 selection.mark.row -= count;
668 } 714 }
669 } 715 }
716
670 rxvt_selection_check(aR_ 0); /* _after_ R->TermWin.nscrolled update */ 717 rxvt_selection_check (this, 0); /* _after_ TermWin.nscrolled update */
671 718
672 R->num_scr += count; 719 num_scr += count;
673 j = count; 720 j = count;
721
674 if (count < 0) 722 if (count < 0)
675 count = -count; 723 count = -count;
724
676 i = row2 - row1 + 1; 725 i = row2 - row1 + 1;
677 MIN_IT(count, i); 726 MIN_IT(count, i);
678 727
679 if (j > 0) { 728 if (j > 0)
729 {
680/* A: scroll up */ 730 /* A: scroll up */
681 731
682/* A1: Copy lines that will get clobbered by the rotation */ 732 /* A1: Copy lines that will get clobbered by the rotation */
683 for (i = 0, j = row1; i < count; i++, j++) { 733 for (i = 0, j = row1; i < count; i++, j++)
734 {
684 R->buf_text[i] = R->screen.text[j]; 735 buf_text[i] = screen.text[j];
685 R->buf_rend[i] = R->screen.rend[j]; 736 buf_rend[i] = screen.rend[j];
686 } 737 }
687/* A2: Rotate lines */ 738 /* A2: Rotate lines */
688 for (j = row1, i = j + count; i <= row2; i++, j++) { 739 for (j = row1, i = j + count; i <= row2; i++, j++)
740 {
689 R->screen.tlen[j] = R->screen.tlen[i]; 741 screen.tlen[j] = screen.tlen[i];
690 R->screen.text[j] = R->screen.text[i]; 742 screen.text[j] = screen.text[i];
691 R->screen.rend[j] = R->screen.rend[i]; 743 screen.rend[j] = screen.rend[i];
692 } 744 }
693 j = row2 - count + 1, i = count; 745 j = row2 - count + 1, i = count;
746 }
694 } else /* if (j < 0) */ { 747 else /* if (j < 0) */
748 {
695/* B: scroll down */ 749 /* B: scroll down */
696 750
697/* B1: Copy lines that will get clobbered by the rotation */ 751 /* B1: Copy lines that will get clobbered by the rotation */
698 for (i = 0, j = row2; i < count; i++, j--) { 752 for (i = 0, j = row2; i < count; i++, j--)
753 {
699 R->buf_text[i] = R->screen.text[j]; 754 buf_text[i] = screen.text[j];
700 R->buf_rend[i] = R->screen.rend[j]; 755 buf_rend[i] = screen.rend[j];
701 } 756 }
702/* B2: Rotate lines */ 757 /* B2: Rotate lines */
703 for (j = row2, i = j - count; i >= row1; i--, j--) { 758 for (j = row2, i = j - count; i >= row1; i--, j--)
759 {
704 R->screen.tlen[j] = R->screen.tlen[i]; 760 screen.tlen[j] = screen.tlen[i];
705 R->screen.text[j] = R->screen.text[i]; 761 screen.text[j] = screen.text[i];
706 R->screen.rend[j] = R->screen.rend[i]; 762 screen.rend[j] = screen.rend[i];
707 } 763 }
708 j = row1, i = count; 764 j = row1, i = count;
709 count = -count; 765 count = -count;
710 } 766 }
711 767
712/* C: Resurrect lines */ 768 /* C: Resurrect lines */
713 for (; i--; j++) { 769 for (; i--; j++)
770 {
714 R->screen.tlen[j] = 0; 771 screen.tlen[j] = 0;
715 R->screen.text[j] = R->buf_text[i]; 772 screen.text[j] = buf_text[i];
716 R->screen.rend[j] = R->buf_rend[i]; 773 screen.rend[j] = buf_rend[i];
774
717 if (!spec) /* line length may not equal TermWin.ncol */ 775 if (!spec) /* line length may not equal TermWin.ncol */
718 rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, 776 scr_blank_screen_mem (screen.text, screen.rend,
719 (unsigned int)j, R->rstyle); 777 (unsigned int)j, rstyle);
720 } 778 }
721 779
722#ifdef RXVT_GRAPHICS 780#ifdef RXVT_GRAPHICS
723 if (rxvt_Gr_Displayed(aR)) 781 if (rxvt_Gr_Displayed (this))
724 rxvt_Gr_scroll(aR_ count); 782 rxvt_Gr_scroll(this, count);
725#endif 783#endif
784
726 return count; 785 return count;
727} 786}
728 787
729/* ------------------------------------------------------------------------- */ 788/* ------------------------------------------------------------------------- */
730/* 789/*
731 * Add text given in <str> of length <len> to screen struct 790 * Add text given in <str> of length <len> to screen struct
752 nlines += (R->screen.cur.row - R->screen.bscroll); 811 nlines += (R->screen.cur.row - R->screen.bscroll);
753 if ((nlines > 0) 812 if ((nlines > 0)
754 && (R->screen.tscroll == 0) 813 && (R->screen.tscroll == 0)
755 && (R->screen.bscroll == (R->TermWin.nrow - 1))) { 814 && (R->screen.bscroll == (R->TermWin.nrow - 1))) {
756 /* _at least_ this many lines need to be scrolled */ 815 /* _at least_ this many lines need to be scrolled */
757 rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, nlines, 816 R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, nlines, 0);
758 0);
759 R->screen.cur.row -= nlines; 817 R->screen.cur.row -= nlines;
760 } 818 }
761 } 819 }
762#ifdef DEBUG_STRICT 820#ifdef DEBUG_STRICT
763 assert(R->screen.cur.col < last_col); 821 assert(R->screen.cur.col < last_col);
779 837
780 for (i = 0; i < len;) { 838 for (i = 0; i < len;) {
781 c = str[i++]; 839 c = str[i++];
782 switch (c) { 840 switch (c) {
783 case '\t': 841 case '\t':
784 rxvt_scr_tab(aR_ 1); 842 rxvt_scr_tab (aR_ 1);
785 continue; 843 continue;
786 case '\n': 844 case '\n':
787 if (R->screen.tlen[row] != -1) /* XXX: think about this */ 845 if (R->screen.tlen[row] != -1) /* XXX: think about this */
788 MAX_IT(R->screen.tlen[row], R->screen.cur.col); 846 MAX_IT(R->screen.tlen[row], R->screen.cur.col);
789 R->screen.flags &= ~Screen_WrapNext; 847 R->screen.flags &= ~Screen_WrapNext;
790 if (R->screen.cur.row == R->screen.bscroll) 848 if (R->screen.cur.row == R->screen.bscroll)
791 rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); 849 R->scr_scroll_text (R->screen.tscroll, R->screen.bscroll, 1, 0);
792 else if (R->screen.cur.row < (R->TermWin.nrow - 1)) 850 else if (R->screen.cur.row < (R->TermWin.nrow - 1))
793 row = (++R->screen.cur.row) + R->TermWin.saveLines; 851 row = (++R->screen.cur.row) + R->TermWin.saveLines;
794 stp = R->screen.text[row]; /* _must_ refresh */ 852 stp = R->screen.text[row]; /* _must_ refresh */
795 srp = R->screen.rend[row]; /* _must_ refresh */ 853 srp = R->screen.rend[row]; /* _must_ refresh */
796 continue; 854 continue;
813 clearsel = 1; 871 clearsel = 1;
814 } 872 }
815 if (R->screen.flags & Screen_WrapNext) { 873 if (R->screen.flags & Screen_WrapNext) {
816 R->screen.tlen[row] = -1; 874 R->screen.tlen[row] = -1;
817 if (R->screen.cur.row == R->screen.bscroll) 875 if (R->screen.cur.row == R->screen.bscroll)
818 rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, 1, 0); 876 R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, 1, 0);
819 else if (R->screen.cur.row < (R->TermWin.nrow - 1)) 877 else if (R->screen.cur.row < (R->TermWin.nrow - 1))
820 row = (++R->screen.cur.row) + R->TermWin.saveLines; 878 row = (++R->screen.cur.row) + R->TermWin.saveLines;
821 stp = R->screen.text[row]; /* _must_ refresh */ 879 stp = R->screen.text[row]; /* _must_ refresh */
822 srp = R->screen.rend[row]; /* _must_ refresh */ 880 srp = R->screen.rend[row]; /* _must_ refresh */
823 R->screen.cur.col = 0; 881 R->screen.cur.col = 0;
841 case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; 899 case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break;
842 case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; 900 case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
843 } 901 }
844 902
845 rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); 903 rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c));
904 // rely on wcwidth to tell us the character width, at least for non-ascii
905 int width = c <= 128 ? 1 : wcwidth (c);
846 906
847 stp[R->screen.cur.col] = c; 907 // width 0 characters (e.g. combining chars) are ignored. your problem, really
848 srp[R->screen.cur.col] = rend; 908 while (width-- > 0)
849
850 if (c > 255)
851 { 909 {
852 // rely on wcwidth to tell us the character width, at least for non iso-8859-1 910 stp[R->screen.cur.col] = c;
853 int width = wcwidth (c); 911 srp[R->screen.cur.col] = rend;
912
913 if (R->screen.cur.col < last_col - 1)
914 R->screen.cur.col++;
854 915 else
855 if (width > 1)
856 { 916 {
857 while (--width > 0 && R->screen.cur.col < last_col - 1) 917 R->screen.tlen[row] = last_col;
918 if (R->screen.flags & Screen_Autowrap)
919 R->screen.flags |= Screen_WrapNext;
858 { 920 break;
859
860 srp[R->screen.cur.col] |= RS_wide;
861
862 R->screen.cur.col++;
863 stp[R->screen.cur.col] = NOCHAR;
864 srp[R->screen.cur.col] = rend;
865 }
866 } 921 }
922
923 c = NOCHAR;
867 } 924 }
868
869 if (R->screen.cur.col < last_col - 1)
870 R->screen.cur.col++;
871 else {
872 R->screen.tlen[row] = last_col;
873 if (R->screen.flags & Screen_Autowrap)
874 R->screen.flags |= Screen_WrapNext;
875 }
876 } 925 }
877 if (R->screen.tlen[row] != -1) /* XXX: think about this */ 926 if (R->screen.tlen[row] != -1) /* XXX: think about this */
878 MAX_IT(R->screen.tlen[row], R->screen.cur.col); 927 MAX_IT(R->screen.tlen[row], R->screen.cur.col);
879 928
880/* 929/*
1075#endif 1124#endif
1076 1125
1077 R->screen.flags &= ~Screen_WrapNext; 1126 R->screen.flags &= ~Screen_WrapNext;
1078 if ((R->screen.cur.row == R->screen.bscroll && direction == UP) 1127 if ((R->screen.cur.row == R->screen.bscroll && direction == UP)
1079 || (R->screen.cur.row == R->screen.tscroll && direction == DN)) 1128 || (R->screen.cur.row == R->screen.tscroll && direction == DN))
1080 rxvt_scroll_text(aR_ R->screen.tscroll, R->screen.bscroll, dirn, 0); 1129 R->scr_scroll_text(R->screen.tscroll, R->screen.bscroll, dirn, 0);
1081 else 1130 else
1082 R->screen.cur.row += dirn; 1131 R->screen.cur.row += dirn;
1083 MAX_IT(R->screen.cur.row, 0); 1132 MAX_IT(R->screen.cur.row, 0);
1084 MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1); 1133 MIN_IT(R->screen.cur.row, (int32_t)R->TermWin.nrow - 1);
1085 rxvt_selection_check(aR_ 0); 1134 rxvt_selection_check(aR_ 0);
1094 */ 1143 */
1095/* EXTPROTO */ 1144/* EXTPROTO */
1096void 1145void
1097rxvt_scr_erase_line(pR_ int mode) 1146rxvt_scr_erase_line(pR_ int mode)
1098{ 1147{
1099 unsigned int row, col, num; 1148 unsigned int row, col, num;
1100 1149
1101 R->want_refresh = 1; 1150 R->want_refresh = 1;
1102 D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row)); 1151 D_SCREEN((stderr, "rxvt_scr_erase_line(%d) at screen row: %d", mode, R->screen.cur.row));
1103 ZERO_SCROLLBACK(R); 1152 ZERO_SCROLLBACK (R);
1104 1153
1105#ifdef RXVT_GRAPHICS 1154#ifdef RXVT_GRAPHICS
1106 if (rxvt_Gr_Displayed(aR)) 1155 if (rxvt_Gr_Displayed (aR))
1107 rxvt_Gr_scroll(aR_ 0); 1156 rxvt_Gr_scroll (aR_ 0);
1108#endif 1157#endif
1109 1158
1110 rxvt_selection_check(aR_ 1); 1159 rxvt_selection_check (aR_ 1);
1111 1160
1112 R->screen.flags &= ~Screen_WrapNext; 1161 R->screen.flags &= ~Screen_WrapNext;
1113 1162
1114 row = R->TermWin.saveLines + R->screen.cur.row; 1163 row = R->TermWin.saveLines + R->screen.cur.row;
1115 switch (mode) { 1164 switch (mode)
1165 {
1116 case 0: /* erase to end of line */ 1166 case 0: /* erase to end of line */
1117 col = R->screen.cur.col; 1167 col = R->screen.cur.col;
1118 num = R->TermWin.ncol - col; 1168 num = R->TermWin.ncol - col;
1119 MIN_IT(R->screen.tlen[row], (int16_t)col); 1169 MIN_IT(R->screen.tlen[row], (int16_t)col);
1120 if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur) 1170 if (ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.beg, R->screen.cur)
1121 || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur)) 1171 || ROWCOL_IN_ROW_AT_OR_AFTER(R->selection.end, R->screen.cur))
1122 CLEAR_SELECTION(R); 1172 CLEAR_SELECTION(R);
1123 break; 1173 break;
1124 case 1: /* erase to beginning of line */ 1174 case 1: /* erase to beginning of line */
1125 col = 0; 1175 col = 0;
1126 num = R->screen.cur.col + 1; 1176 num = R->screen.cur.col + 1;
1127 if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur) 1177 if (ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.beg, R->screen.cur)
1128 || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur)) 1178 || ROWCOL_IN_ROW_AT_OR_BEFORE(R->selection.end, R->screen.cur))
1129 CLEAR_SELECTION(R); 1179 CLEAR_SELECTION(R);
1130 break; 1180 break;
1131 case 2: /* erase whole line */ 1181 case 2: /* erase whole line */
1132 col = 0; 1182 col = 0;
1133 num = R->TermWin.ncol; 1183 num = R->TermWin.ncol;
1134 R->screen.tlen[row] = 0; 1184 R->screen.tlen[row] = 0;
1135 if (R->selection.beg.row <= R->screen.cur.row 1185 if (R->selection.beg.row <= R->screen.cur.row
1136 && R->selection.end.row >= R->screen.cur.row) 1186 && R->selection.end.row >= R->screen.cur.row)
1137 CLEAR_SELECTION(R); 1187 CLEAR_SELECTION(R);
1138 break; 1188 break;
1139 default: 1189 default:
1140 return; 1190 return;
1141 } 1191 }
1192
1142 if (R->screen.text[row]) 1193 if (R->screen.text[row])
1143 rxvt_blank_line(aR_ 1194 R->scr_blank_line (&(R->screen.text[row][col]),
1144 &(R->screen.text[row][col]),
1145 &(R->screen.rend[row][col]), num, R->rstyle); 1195 &(R->screen.rend[row][col]), num, R->rstyle);
1146 else 1196 else
1147 rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, row, 1197 R->scr_blank_screen_mem (R->screen.text, R->screen.rend, row, R->rstyle);
1148 R->rstyle);
1149} 1198}
1150 1199
1151/* ------------------------------------------------------------------------- */ 1200/* ------------------------------------------------------------------------- */
1152/* 1201/*
1153 * Erase part of whole of the screen 1202 * Erase part of whole of the screen
1154 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J 1203 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J
1155 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J 1204 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J
1156 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1205 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1157 */ 1206 */
1158/* EXTPROTO */
1159void 1207void
1160rxvt_scr_erase_screen(pR_ int mode) 1208rxvt_term::scr_erase_screen (int mode)
1161{ 1209{
1162 int num; 1210 int num;
1163 int32_t row, row_offset; 1211 int32_t row, row_offset;
1164 rend_t ren; 1212 rend_t ren;
1165 XGCValues gcvalue; 1213 XGCValues gcvalue;
1166 1214
1167 R->want_refresh = 1; 1215 want_refresh = 1;
1168 D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, R->screen.cur.row)); 1216 D_SCREEN((stderr, "rxvt_scr_erase_screen(%d) at screen row: %d", mode, screen.cur.row));
1169 ZERO_SCROLLBACK(R); 1217 ZERO_SCROLLBACK(this);
1170 row_offset = (int32_t)R->TermWin.saveLines; 1218 row_offset = (int32_t)TermWin.saveLines;
1171 1219
1172 switch (mode) { 1220 switch (mode) {
1173 case 0: /* erase to end of screen */ 1221 case 0: /* erase to end of screen */
1174 rxvt_selection_check(aR_ 1); 1222 rxvt_selection_check(this,1);
1175 rxvt_scr_erase_line(aR_ 0); 1223 rxvt_scr_erase_line(this,0);
1176 row = R->screen.cur.row + 1; /* possible OOB */ 1224 row = screen.cur.row + 1; /* possible OOB */
1177 num = R->TermWin.nrow - row; 1225 num = TermWin.nrow - row;
1178 break; 1226 break;
1179 case 1: /* erase to beginning of screen */ 1227 case 1: /* erase to beginning of screen */
1180 rxvt_selection_check(aR_ 3); 1228 rxvt_selection_check(this,3);
1181 rxvt_scr_erase_line(aR_ 1); 1229 rxvt_scr_erase_line(this,1);
1182 row = 0; 1230 row = 0;
1183 num = R->screen.cur.row; 1231 num = screen.cur.row;
1184 break; 1232 break;
1185 case 2: /* erase whole screen */ 1233 case 2: /* erase whole screen */
1186 rxvt_selection_check(aR_ 3); 1234 rxvt_selection_check (this, 3);
1187#ifdef RXVT_GRAPHICS 1235#ifdef RXVT_GRAPHICS
1188 rxvt_Gr_ClearScreen(aR); 1236 rxvt_Gr_ClearScreen (this);
1189#endif 1237#endif
1190 row = 0; 1238 row = 0;
1191 num = R->TermWin.nrow; 1239 num = TermWin.nrow;
1192 break; 1240 break;
1193 default: 1241 default:
1194 return; 1242 return;
1195 } 1243 }
1196 R->refresh_type |= REFRESH_BOUNDS; 1244 refresh_type |= REFRESH_BOUNDS;
1197 if (R->selection.op && R->current_screen == R->selection.screen 1245 if (selection.op && current_screen == selection.screen
1198 && ((R->selection.beg.row >= row && R->selection.beg.row <= row + num) 1246 && ((selection.beg.row >= row && selection.beg.row <= row + num)
1199 || (R->selection.end.row >= row 1247 || (selection.end.row >= row
1200 && R->selection.end.row <= row + num))) 1248 && selection.end.row <= row + num)))
1201 CLEAR_SELECTION(R); 1249 CLEAR_SELECTION (this);
1202 if (row >= R->TermWin.nrow) /* Out Of Bounds */ 1250 if (row >= TermWin.nrow) /* Out Of Bounds */
1203 return; 1251 return;
1204 MIN_IT(num, (R->TermWin.nrow - row)); 1252 MIN_IT(num, (TermWin.nrow - row));
1205 if (R->rstyle & (RS_RVid | RS_Uline)) 1253 if (rstyle & (RS_RVid | RS_Uline))
1206 ren = (rend_t) ~RS_None; 1254 ren = (rend_t) ~RS_None;
1207 else if (GET_BASEBG(R->rstyle) == Color_bg) { 1255 else if (GET_BASEBG(rstyle) == Color_bg) {
1208 ren = DEFAULT_RSTYLE; 1256 ren = DEFAULT_RSTYLE;
1209 CLEAR_ROWS(row, num); 1257 CLEAR_ROWS(row, num);
1210 } else { 1258 } else {
1211 ren = (R->rstyle & (RS_fgMask | RS_bgMask)); 1259 ren = (rstyle & (RS_fgMask | RS_bgMask));
1212 gcvalue.foreground = R->PixColors[GET_BGCOLOR(R->rstyle)]; 1260 gcvalue.foreground = PixColors[GET_BGCOLOR(rstyle)];
1213 XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); 1261 XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue);
1214 ERASE_ROWS(row, num); 1262 ERASE_ROWS(row, num);
1215 gcvalue.foreground = R->PixColors[Color_fg]; 1263 gcvalue.foreground = PixColors[Color_fg];
1216 XChangeGC(R->Xdisplay, R->TermWin.gc, GCForeground, &gcvalue); 1264 XChangeGC(Xdisplay, TermWin.gc, GCForeground, &gcvalue);
1217 } 1265 }
1218 for (; num--; row++) { 1266 for (; num--; row++) {
1219 rxvt_blank_screen_mem(aR_ R->screen.text, R->screen.rend, 1267 scr_blank_screen_mem (screen.text, screen.rend,
1220 (unsigned int)(row + row_offset), R->rstyle); 1268 (unsigned int)(row + row_offset), rstyle);
1221 R->screen.tlen[row + row_offset] = 0; 1269 screen.tlen[row + row_offset] = 0;
1222 rxvt_blank_line(aR_ 1270 scr_blank_line (drawn_text[row], drawn_rend[row],
1223 R->drawn_text[row], R->drawn_rend[row],
1224 (unsigned int)R->TermWin.ncol, ren); 1271 (unsigned int)TermWin.ncol, ren);
1225 } 1272 }
1226} 1273}
1227 1274
1228/* ------------------------------------------------------------------------- */ 1275/* ------------------------------------------------------------------------- */
1229/* 1276/*
1280 else if (insdel == INSERT) 1327 else if (insdel == INSERT)
1281 count = end; 1328 count = end;
1282 } 1329 }
1283 R->screen.flags &= ~Screen_WrapNext; 1330 R->screen.flags &= ~Screen_WrapNext;
1284 1331
1285 rxvt_scroll_text(aR_ R->screen.cur.row, R->screen.bscroll, insdel * count, 1332 R->scr_scroll_text(R->screen.cur.row, R->screen.bscroll, insdel * count, 0);
1286 0);
1287} 1333}
1288 1334
1289/* ------------------------------------------------------------------------- */ 1335/* ------------------------------------------------------------------------- */
1290/* 1336/*
1291 * Insert/Delete <count> characters from the current position 1337 * Insert/Delete <count> characters from the current position
1340 R->selection.beg.col += count; 1386 R->selection.beg.col += count;
1341 R->selection.mark.col += count; /* XXX: yes? */ 1387 R->selection.mark.col += count; /* XXX: yes? */
1342 R->selection.end.col += count; 1388 R->selection.end.col += count;
1343 } 1389 }
1344 } 1390 }
1345 rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), 1391 R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]),
1346 (unsigned int)count, R->rstyle); 1392 (unsigned int)count, R->rstyle);
1347 break; 1393 break;
1348 case ERASE: 1394 case ERASE:
1349 R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */ 1395 R->screen.cur.col += count; /* don't worry if > R->TermWin.ncol */
1350 rxvt_selection_check(aR_ 1); 1396 rxvt_selection_check(aR_ 1);
1351 R->screen.cur.col -= count; 1397 R->screen.cur.col -= count;
1352 rxvt_blank_line(aR_ &(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]), 1398 R->scr_blank_line (&(stp[R->screen.cur.col]), &(srp[R->screen.cur.col]),
1353 (unsigned int)count, R->rstyle); 1399 (unsigned int)count, R->rstyle);
1354 break; 1400 break;
1355 case DELETE: 1401 case DELETE:
1356 tr = srp[R->TermWin.ncol - 1] 1402 tr = srp[R->TermWin.ncol - 1]
1357 & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1403 & (RS_fgMask | RS_bgMask | RS_baseattrMask);
1358 for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) { 1404 for (col = R->screen.cur.col; (col + count) < R->TermWin.ncol; col++) {
1359 stp[col] = stp[col + count]; 1405 stp[col] = stp[col + count];
1360 srp[col] = srp[col + count]; 1406 srp[col] = srp[col + count];
1361 } 1407 }
1362 rxvt_blank_line(aR_ 1408 R->scr_blank_line (&(stp[R->TermWin.ncol - count]),
1363 &(stp[R->TermWin.ncol - count]),
1364 &(srp[R->TermWin.ncol - count]), 1409 &(srp[R->TermWin.ncol - count]),
1365 (unsigned int)count, tr); 1410 (unsigned int)count, tr);
1366 if (*slp == -1) /* break line continuation */ 1411 if (*slp == -1) /* break line continuation */
1367 *slp = R->TermWin.ncol; 1412 *slp = R->TermWin.ncol;
1368 *slp -= count; 1413 *slp -= count;
1369 MAX_IT(*slp, 0); 1414 MAX_IT(*slp, 0);
1370 if (R->selection.op && R->current_screen == R->selection.screen 1415 if (R->selection.op && R->current_screen == R->selection.screen
1515 1560
1516 gcvalue.foreground = R->PixColors[Color_fg]; 1561 gcvalue.foreground = R->PixColors[Color_fg];
1517 gcvalue.background = R->PixColors[Color_bg]; 1562 gcvalue.background = R->PixColors[Color_bg];
1518 XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground, 1563 XChangeGC(R->Xdisplay, R->TermWin.gc, GCBackground | GCForeground,
1519 &gcvalue); 1564 &gcvalue);
1520 rxvt_scr_clear(aR); 1565 R->scr_clear ();
1521 rxvt_scr_touch(aR_ True); 1566 R->scr_touch (true);
1522 } 1567 }
1523} 1568}
1524 1569
1525/* ------------------------------------------------------------------------- */ 1570/* ------------------------------------------------------------------------- */
1526/* 1571/*
1629 PART_BEG = 0, 1674 PART_BEG = 0,
1630 PART_END, 1675 PART_END,
1631 RC_COUNT 1676 RC_COUNT
1632}; 1677};
1633 1678
1634/* EXTPROTO */
1635void 1679void
1636rxvt_scr_expose(pR_ int x, int y, int width, int height, Bool refresh) 1680rxvt_term::scr_expose (int x, int y, int width, int height, bool refresh)
1637{ 1681{
1638 int i; 1682 int i;
1639 row_col_t rc[RC_COUNT]; 1683 row_col_t rc[RC_COUNT];
1640 1684
1641 if (R->drawn_text == NULL) /* sanity check */ 1685 if (drawn_text == NULL) /* sanity check */
1642 return; 1686 return;
1643 1687
1644#ifdef DEBUG_STRICT 1688#ifdef DEBUG_STRICT
1645 x = max(x, (int)R->TermWin.int_bwidth); 1689 x = max(x, (int)TermWin.int_bwidth);
1646 x = min(x, (int)R->TermWin.width); 1690 x = min(x, (int)TermWin.width);
1647 y = max(y, (int)R->TermWin.int_bwidth); 1691 y = max(y, (int)TermWin.int_bwidth);
1648 y = min(y, (int)R->TermWin.height); 1692 y = min(y, (int)TermWin.height);
1649#endif 1693#endif
1650 1694
1651/* round down */ 1695/* round down */
1652 rc[PART_BEG].col = Pixel2Col(x); 1696 rc[PART_BEG].col = Pixel2Col(x);
1653 rc[PART_BEG].row = Pixel2Row(y); 1697 rc[PART_BEG].row = Pixel2Row(y);
1654/* round up */ 1698/* round up */
1655 rc[PART_END].col = Pixel2Width(x + width + R->TermWin.fwidth - 1); 1699 rc[PART_END].col = Pixel2Width(x + width + TermWin.fwidth - 1);
1656 rc[PART_END].row = Pixel2Row(y + height + R->TermWin.fheight - 1); 1700 rc[PART_END].row = Pixel2Row(y + height + TermWin.fheight - 1);
1657 1701
1658/* sanity checks */ 1702/* sanity checks */
1659 for (i = PART_BEG; i < RC_COUNT; i++) { 1703 for (i = PART_BEG; i < RC_COUNT; i++)
1704 {
1660 MIN_IT(rc[i].col, R->TermWin.ncol - 1); 1705 MIN_IT(rc[i].col, TermWin.ncol - 1);
1661 MIN_IT(rc[i].row, R->TermWin.nrow - 1); 1706 MIN_IT(rc[i].row, TermWin.nrow - 1);
1662 } 1707 }
1663 1708
1664 D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); 1709 D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row));
1665 1710
1666 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1711 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1667 fill_text (&(R->drawn_text[i][rc[PART_BEG].col]), 0, 1712 fill_text (&(drawn_text[i][rc[PART_BEG].col]), 0,
1668 (rc[PART_END].col - rc[PART_BEG].col + 1)); 1713 (rc[PART_END].col - rc[PART_BEG].col + 1));
1669 1714
1670 if (refresh) 1715 if (refresh)
1671 rxvt_scr_refresh(aR_ SLOW_REFRESH | REFRESH_BOUNDS); 1716 scr_refresh (SLOW_REFRESH | REFRESH_BOUNDS);
1672} 1717}
1673 1718
1674/* ------------------------------------------------------------------------- */ 1719/* ------------------------------------------------------------------------- */
1675/* 1720/*
1676 * Refresh the entire screen 1721 * Refresh the entire screen
1677 */ 1722 */
1678/* EXTPROTO */
1679void 1723void
1680rxvt_scr_touch(pR_ Bool refresh) 1724rxvt_term::scr_touch (bool refresh)
1681{ 1725{
1682 rxvt_scr_expose(aR_ 0, 0, R->TermWin.width, R->TermWin.height, refresh); 1726 scr_expose (0, 0, TermWin.width, TermWin.height, refresh);
1683} 1727}
1684 1728
1685/* ------------------------------------------------------------------------- */ 1729/* ------------------------------------------------------------------------- */
1686/* 1730/*
1687 * Move the display so that the line represented by scrollbar value Y is at 1731 * Move the display so that the line represented by scrollbar value Y is at
1824#define FONT_LBEAR(X, Y) \ 1868#define FONT_LBEAR(X, Y) \
1825 (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing 1869 (X)->per_char[(Y) - (X)->min_char_or_byte2].lbearing
1826#define IS_FONT_CHAR(X, Y) \ 1870#define IS_FONT_CHAR(X, Y) \
1827 ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2) 1871 ((Y) >= (X)->min_char_or_byte2 && (Y) <= (X)->max_char_or_byte2)
1828 1872
1829/* EXTPROTO */
1830void 1873void
1831rxvt_scr_refresh(pR_ unsigned char refresh_type) 1874rxvt_term::scr_refresh (unsigned char refresh_type)
1832{ 1875{
1833 unsigned char clearfirst, /* first character writes before cell */ 1876 unsigned char clearfirst, /* first character writes before cell */
1834 clearlast, /* last character writes beyond cell */ 1877 clearlast, /* last character writes beyond cell */
1835 must_clear, /* use draw_string not draw_image_string */ 1878 must_clear, /* use draw_string not draw_image_string */
1836#ifndef NO_BOLDFONT 1879#ifndef NO_BOLDFONT
1849 rend_t cc1; /* store colours at cursor position(s) */ 1892 rend_t cc1; /* store colours at cursor position(s) */
1850 rend_t cc2; /* store colours at cursor position(s) */ 1893 rend_t cc2; /* store colours at cursor position(s) */
1851#endif 1894#endif
1852 rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ 1895 rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */
1853 text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ 1896 text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */
1854 char *buffer; /* local copy of R->buffer */
1855 1897
1856 if (refresh_type == NO_REFRESH || !R->TermWin.mapped) 1898 if (refresh_type == NO_REFRESH || !TermWin.mapped)
1857 return; 1899 return;
1858 1900
1859 /* 1901 /*
1860 * A: set up vars 1902 * A: set up vars
1861 */ 1903 */
1862 clearfirst = clearlast = must_clear = wbyte = 0; 1904 clearfirst = clearlast = must_clear = wbyte = 0;
1863#ifndef NO_BOLDFONT 1905#ifndef NO_BOLDFONT
1864 bfont = 0; 1906 bfont = 0;
1865#endif 1907#endif
1866 1908
1867 if (R->currmaxcol < R->TermWin.ncol) 1909 if (currmaxcol < TermWin.ncol)
1868 { 1910 {
1869 R->currmaxcol = R->TermWin.ncol; 1911 currmaxcol = TermWin.ncol;
1870 R->buffer = (char *)rxvt_realloc (R->buffer, 1912 buffer = (char *)rxvt_realloc (buffer,
1871 sizeof(char) * (R->currmaxcol + 1) * MB_CUR_MAX); 1913 sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX);
1872 } 1914 }
1873 1915
1874 buffer = R->buffer;
1875 R->refresh_count = 0; 1916 refresh_count = 0;
1876 1917
1877 row_offset = R->TermWin.saveLines - R->TermWin.view_start; 1918 row_offset = TermWin.saveLines - TermWin.view_start;
1878 1919
1879 if ((refresh_type & REFRESH_BOUNDS)) 1920 if ((refresh_type & REFRESH_BOUNDS))
1880 { 1921 {
1881 clearfirst = clearlast = 1; 1922 clearfirst = clearlast = 1;
1882 R->refresh_type &= ~REFRESH_BOUNDS; 1923 refresh_type &= ~REFRESH_BOUNDS;
1883 } 1924 }
1884 1925
1885#if defined(XPM_BACKGROUND) 1926#if defined(XPM_BACKGROUND)
1886 must_clear |= (R->bgPixmap.pixmap != None); 1927 must_clear |= (bgPixmap.pixmap != None);
1887#endif 1928#endif
1888#if defined(TRANSPARENT) 1929#if defined(TRANSPARENT)
1889 must_clear |= ((R->Options & Opt_transparent) && R->am_transparent); 1930 must_clear |= ((Options & Opt_transparent) && am_transparent);
1890#endif 1931#endif
1891 ocrow = R->oldcursor.row; /* is there an old outline cursor on screen? */ 1932 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1892 1933
1893/* 1934 /*
1894 * B: reverse any characters which are selected 1935 * B: reverse any characters which are selected
1895 */ 1936 */
1896 rxvt_scr_reverse_selection(aR); 1937 rxvt_scr_reverse_selection (this);
1897 1938
1898/* 1939 /*
1899 * C: set the cursor character(s) 1940 * C: set the cursor character(s)
1900 */ 1941 */
1901 { 1942 {
1902 unsigned char setoldcursor; 1943 unsigned char setoldcursor;
1903 rend_t ccol1, /* Cursor colour */ 1944 rend_t ccol1, /* Cursor colour */
1904 ccol2; /* Cursor colour2 */ 1945 ccol2; /* Cursor colour2 */
1905 1946
1906 showcursor = (R->screen.flags & Screen_VisibleCursor); 1947 showcursor = (screen.flags & Screen_VisibleCursor);
1907 cursorwidth = 0; 1948 cursorwidth = 0;
1908#ifdef CURSOR_BLINK 1949#ifdef CURSOR_BLINK
1909 if (R->hidden_cursor) 1950 if (hidden_cursor)
1910 showcursor = 0; 1951 showcursor = 0;
1911#endif 1952#endif
1912 1953
1913 cursorwidth = 0; 1954 cursorwidth = 0;
1914 1955
1915 if (showcursor) 1956 if (showcursor)
1916 { 1957 {
1917 cursorwidth++; 1958 cursorwidth++;
1918 1959
1919 srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] 1960 srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
1920 [R->screen.cur.col]); 1961 [screen.cur.col]);
1921 1962
1922 if (showcursor && R->TermWin.focus) 1963 if (showcursor && TermWin.focus)
1923 { 1964 {
1924 *srp ^= RS_RVid; 1965 *srp ^= RS_RVid;
1925#ifndef NO_CURSORCOLOR 1966#ifndef NO_CURSORCOLOR
1926 cc1 = *srp & (RS_fgMask | RS_bgMask); 1967 cc1 = *srp & (RS_fgMask | RS_bgMask);
1927 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) 1968 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor))
1928 ccol1 = Color_cursor; 1969 ccol1 = Color_cursor;
1929 else 1970 else
1930#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 1971#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1931 ccol1 = GET_FGCOLOR(R->rstyle); 1972 ccol1 = GET_FGCOLOR(rstyle);
1932#else 1973#else
1933 ccol1 = Color_fg; 1974 ccol1 = Color_fg;
1934#endif 1975#endif
1935 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor2)) 1976 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor2))
1936 ccol2 = Color_cursor2; 1977 ccol2 = Color_cursor2;
1937 else 1978 else
1938#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 1979#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1939 ccol2 = GET_BGCOLOR(R->rstyle); 1980 ccol2 = GET_BGCOLOR(rstyle);
1940#else 1981#else
1941 ccol2 = Color_bg; 1982 ccol2 = Color_bg;
1942#endif 1983#endif
1943 *srp = SET_FGCOLOR(*srp, ccol1); 1984 *srp = SET_FGCOLOR(*srp, ccol1);
1944 *srp = SET_BGCOLOR(*srp, ccol2); 1985 *srp = SET_BGCOLOR(*srp, ccol2);
1950 } 1991 }
1951 1992
1952 /* make sure no outline cursor is left around */ 1993 /* make sure no outline cursor is left around */
1953 setoldcursor = 0; 1994 setoldcursor = 0;
1954 if (ocrow != -1) { 1995 if (ocrow != -1) {
1955 if (R->screen.cur.row + R->TermWin.view_start != ocrow 1996 if (screen.cur.row + TermWin.view_start != ocrow
1956 || R->screen.cur.col != R->oldcursor.col) { 1997 || screen.cur.col != oldcursor.col) {
1957 if (ocrow < R->TermWin.nrow 1998 if (ocrow < TermWin.nrow
1958 && R->oldcursor.col < R->TermWin.ncol) { 1999 && oldcursor.col < TermWin.ncol) {
1959 R->drawn_rend[ocrow][R->oldcursor.col] ^= (RS_RVid | RS_Uline); 2000 drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline);
1960 } 2001 }
1961 if (R->TermWin.focus || !showcursor) 2002 if (TermWin.focus || !showcursor)
1962 R->oldcursor.row = -1; 2003 oldcursor.row = -1;
1963 else 2004 else
1964 setoldcursor = 1; 2005 setoldcursor = 1;
1965 } 2006 }
1966 } else if (!R->TermWin.focus) 2007 } else if (!TermWin.focus)
1967 setoldcursor = 1; 2008 setoldcursor = 1;
1968 if (setoldcursor) { 2009 if (setoldcursor) {
1969 if (R->screen.cur.row + R->TermWin.view_start >= R->TermWin.nrow) 2010 if (screen.cur.row + TermWin.view_start >= TermWin.nrow)
1970 R->oldcursor.row = -1; 2011 oldcursor.row = -1;
1971 else { 2012 else {
1972 R->oldcursor.row = R->screen.cur.row + R->TermWin.view_start; 2013 oldcursor.row = screen.cur.row + TermWin.view_start;
1973 R->oldcursor.col = R->screen.cur.col; 2014 oldcursor.col = screen.cur.col;
1974 } 2015 }
1975 } 2016 }
1976 } 2017 }
1977 2018
1978#ifndef NO_SLOW_LINK_SUPPORT 2019#ifndef NO_SLOW_LINK_SUPPORT
1979/* 2020 /*
1980 * D: CopyArea pass - very useful for slower links 2021 * D: CopyArea pass - very useful for slower links
1981 * This has been deliberately kept simple. 2022 * This has been deliberately kept simple.
1982 */ 2023 */
1983 i = R->num_scr; 2024 i = num_scr;
1984 if (refresh_type == FAST_REFRESH && R->num_scr_allow && i 2025 if (refresh_type == FAST_REFRESH && num_scr_allow && i
1985 && abs(i) < R->TermWin.nrow && !must_clear) 2026 && abs(i) < TermWin.nrow && !must_clear)
1986 { 2027 {
1987 int16_t nits; 2028 int16_t nits;
1988 int j; 2029 int j;
1989 rend_t *drp2; 2030 rend_t *drp2;
1990 text_t *dtp2; 2031 text_t *dtp2;
1991 int len, wlen; 2032 int len, wlen;
1992 2033
1993 j = R->TermWin.nrow; 2034 j = TermWin.nrow;
1994 wlen = len = -1; 2035 wlen = len = -1;
1995 row = i > 0 ? 0 : j - 1; 2036 row = i > 0 ? 0 : j - 1;
1996 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2037 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
1997 { 2038 {
1998 if (row + i >= 0 && row + i < R->TermWin.nrow && row + i != ocrow) 2039 if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow)
1999 { 2040 {
2000 stp = R->screen.text[row + row_offset]; 2041 stp = screen.text[row + row_offset];
2001 srp = R->screen.rend[row + row_offset]; 2042 srp = screen.rend[row + row_offset];
2002 dtp = R->drawn_text[row]; 2043 dtp = drawn_text[row];
2003 dtp2 = R->drawn_text[row + i]; 2044 dtp2 = drawn_text[row + i];
2004 drp = R->drawn_rend[row]; 2045 drp = drawn_rend[row];
2005 drp2 = R->drawn_rend[row + i]; 2046 drp2 = drawn_rend[row + i];
2006 2047
2007 for (nits = 0, col = R->TermWin.ncol; col--; ) 2048 for (nits = 0, col = TermWin.ncol; col--; )
2008 if (stp[col] != dtp2[col] || srp[col] != drp2[col]) 2049 if (stp[col] != dtp2[col] || srp[col] != drp2[col])
2009 nits--; 2050 nits--;
2010 else if (stp[col] != dtp[col] || srp[col] != drp[col]) 2051 else if (stp[col] != dtp[col] || srp[col] != drp[col])
2011 nits++; 2052 nits++;
2012 2053
2013 if (nits > 8) /* XXX: arbitrary choice */ 2054 if (nits > 8) /* XXX: arbitrary choice */
2014 { 2055 {
2015 for (col = R->TermWin.ncol; col--; ) 2056 for (col = TermWin.ncol; col--; )
2016 { 2057 {
2017 *dtp++ = *dtp2++; 2058 *dtp++ = *dtp2++;
2018 *drp++ = *drp2++; 2059 *drp++ = *drp2++;
2019 } 2060 }
2020 2061
2029 if (len != -1) 2070 if (len != -1)
2030 { 2071 {
2031 /* also comes here at end if needed because of >= above */ 2072 /* also comes here at end if needed because of >= above */
2032 if (wlen < len) 2073 if (wlen < len)
2033 SWAP_IT(wlen, len, int); 2074 SWAP_IT(wlen, len, int);
2075
2034 D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); 2076 D_SCREEN((stderr, "rxvt_scr_refresh(): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1));
2035 XCopyArea(R->Xdisplay, R->TermWin.vt, R->TermWin.vt, 2077 XCopyArea (Xdisplay, TermWin.vt, TermWin.vt,
2036 R->TermWin.gc, 0, Row2Pixel(len + i), 2078 TermWin.gc, 0, Row2Pixel (len + i),
2037 (unsigned int)TermWin_TotalWidth(), 2079 (unsigned int)TermWin_TotalWidth (),
2038 (unsigned int)Height2Pixel(wlen - len + 1), 2080 (unsigned int)Height2Pixel (wlen - len + 1),
2039 0, Row2Pixel(len)); 2081 0, Row2Pixel (len));
2040 len = -1; 2082 len = -1;
2041 } 2083 }
2042 } 2084 }
2043 } 2085 }
2044#endif 2086#endif
2045 2087
2046/* 2088 /*
2047 * E: main pass across every character 2089 * E: main pass across every character
2048 */ 2090 */
2049 for (row = 0; row < R->TermWin.nrow; row++) 2091 for (row = 0; row < TermWin.nrow; row++)
2050 { 2092 {
2051 stp = R->screen.text[row + row_offset]; 2093 stp = screen.text[row + row_offset];
2052 srp = R->screen.rend[row + row_offset]; 2094 srp = screen.rend[row + row_offset];
2053 dtp = R->drawn_text[row]; 2095 dtp = drawn_text[row];
2054 drp = R->drawn_rend[row]; 2096 drp = drawn_rend[row];
2055 2097
2056/* 2098 /*
2057 * E2: OK, now the real pass 2099 * E2: OK, now the real pass
2058 */ 2100 */
2059 int ypixel = (int)Row2Pixel(row); 2101 int ypixel = (int)Row2Pixel(row);
2060 2102
2061 for (col = 0; col < R->TermWin.ncol; col++) 2103 for (col = 0; col < TermWin.ncol; col++)
2062 { 2104 {
2063 /* compare new text with old - if exactly the same then continue */ 2105 /* compare new text with old - if exactly the same then continue */
2064 rend_t rend = srp[col]; /* screen rendition (target rendtion) */ 2106 rend_t rend = srp[col]; /* screen rendition (target rendtion) */
2065 2107
2066 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2108 if (stp[col] == dtp[col] /* Must match characters to skip. */
2082 2124
2083 int xpixel = Col2Pixel(col); 2125 int xpixel = Col2Pixel(col);
2084 2126
2085 // this loop looks very messy, it can probably be optimized 2127 // this loop looks very messy, it can probably be optimized
2086 // and cleaned a bit by you? 2128 // and cleaned a bit by you?
2087 for (i = 0; ++col < R->TermWin.ncol; ) 2129 for (i = 0; ++col < TermWin.ncol; )
2088 { 2130 {
2089 if (stp[col] == NOCHAR) 2131 if (stp[col] == NOCHAR)
2090 { 2132 {
2091 dtp[col] = stp[col]; 2133 dtp[col] = stp[col];
2092 drp[col] = rend; 2134 drp[col] = rend;
2118 } 2160 }
2119 2161
2120 col--; /* went one too far. move back */ 2162 col--; /* went one too far. move back */
2121 count -= i; /* dump any matching trailing chars */ 2163 count -= i; /* dump any matching trailing chars */
2122 2164
2123/* 2165 /*
2124 * Determine the attributes for the string 2166 * Determine the attributes for the string
2125 */ 2167 */
2126 int fid = GET_FONT(rend); 2168 int fid = GET_FONT(rend);
2127 fore = GET_FGCOLOR(rend); 2169 fore = GET_FGCOLOR(rend);
2128 back = GET_BGCOLOR(rend); 2170 back = GET_BGCOLOR(rend);
2129 rend = GET_ATTR(rend); 2171 rend = GET_ATTR(rend);
2130 2172
2131 rvid = (rend & RS_RVid) ? 1 : 0; 2173 rvid = (rend & RS_RVid) ? 1 : 0;
2132#ifdef OPTION_HC 2174#ifdef OPTION_HC
2133 if (!rvid && (rend & RS_Blink)) 2175 if (!rvid && (rend & RS_Blink))
2134 { 2176 {
2135 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_HC)) 2177 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC))
2136 back = Color_HC; 2178 back = Color_HC;
2137 else 2179 else
2138 rvid = !rvid; /* fall back */ 2180 rvid = !rvid; /* fall back */
2139 } 2181 }
2140#endif 2182#endif
2141 if (rvid) 2183 if (rvid)
2142 { 2184 {
2143 SWAP_IT(fore, back, int); 2185 SWAP_IT(fore, back, int);
2144 2186
2145#ifndef NO_BOLD_UNDERLINE_REVERSE 2187#ifndef NO_BOLD_UNDERLINE_REVERSE
2146 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_RV) 2188 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_RV)
2147# ifndef NO_CURSORCOLOR 2189# ifndef NO_CURSORCOLOR
2148 && !ISSET_PIXCOLOR(R, Color_cursor) 2190 && !ISSET_PIXCOLOR (this, Color_cursor)
2149# endif 2191# endif
2150 ) 2192 )
2151 back = Color_RV; 2193 back = Color_RV;
2152#endif 2194#endif
2153 } 2195 }
2154#ifndef NO_BOLD_UNDERLINE_REVERSE 2196#ifndef NO_BOLD_UNDERLINE_REVERSE
2155 else if (rend & RS_Bold) 2197 else if (rend & RS_Bold)
2156 { 2198 {
2157 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_BD)) 2199 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD))
2158 { 2200 {
2159 fore = Color_BD; 2201 fore = Color_BD;
2160# ifndef VERYBOLD 2202# ifndef VERYBOLD
2161 rend &= ~RS_Bold; /* we've taken care of it */ 2203 rend &= ~RS_Bold; /* we've taken care of it */
2162# endif 2204# endif
2163 } 2205 }
2164 } 2206 }
2165 else if (rend & RS_Uline) 2207 else if (rend & RS_Uline)
2166 { 2208 {
2167 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_UL)) 2209 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL))
2168 { 2210 {
2169 fore = Color_UL; 2211 fore = Color_UL;
2170 rend &= ~RS_Uline; /* we've taken care of it */ 2212 rend &= ~RS_Uline; /* we've taken care of it */
2171 } 2213 }
2172 } 2214 }
2173#endif 2215#endif
2174 2216
2175/* 2217 /*
2176 * Actually do the drawing of the string here 2218 * Actually do the drawing of the string here
2177 */ 2219 */
2178 rxvt_font *font = (*R->TermWin.fontset)[fid]; 2220 rxvt_font *font = (*TermWin.fontset)[fid];
2179 2221
2180 if (back == Color_bg) 2222 if (back == Color_bg)
2181 { 2223 {
2182 if (must_clear) 2224 if (must_clear)
2183 { 2225 {
2186 { 2228 {
2187 font->draw (xpixel, ypixel, text, count, fore, -1); 2229 font->draw (xpixel, ypixel, text, count, fore, -1);
2188 goto nodraw; 2230 goto nodraw;
2189 } 2231 }
2190 2232
2191 CLEAR_CHARS(xpixel, ypixel, count); 2233 CLEAR_CHARS (xpixel, ypixel, count);
2192nodraw: ; 2234nodraw: ;
2193 } 2235 }
2194 else 2236 else
2195 font->draw (xpixel, ypixel, text, count, fore, Color_bg); 2237 font->draw (xpixel, ypixel, text, count, fore, Color_bg);
2196 } 2238 }
2197 else 2239 else
2198 font->draw (xpixel, ypixel, text, count, fore, back); 2240 font->draw (xpixel, ypixel, text, count, fore, back);
2199 2241
2200 if ((rend & RS_Uline) && (font->descent > 1)) 2242 if ((rend & RS_Uline) && (font->descent > 1))
2201 XDrawLine(R->Xdisplay, drawBuffer, R->TermWin.gc, 2243 XDrawLine(Xdisplay, drawBuffer, TermWin.gc,
2202 xpixel, ypixel + font->ascent + 1, 2244 xpixel, ypixel + font->ascent + 1,
2203 xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); 2245 xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1);
2204 } /* for (col....) */ 2246 } /* for (col....) */
2205 } /* for (row....) */ 2247 } /* for (row....) */
2206 2248
2207/* 2249 /*
2208 * G: cleanup cursor and display outline cursor if necessary 2250 * G: cleanup cursor and display outline cursor if necessary
2209 */ 2251 */
2210 if (showcursor) { 2252 if (showcursor) {
2211 if (R->TermWin.focus) { 2253 if (TermWin.focus) {
2212 srp = &(R->screen.rend[R->screen.cur.row + R->TermWin.saveLines] 2254 srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
2213 [R->screen.cur.col]); 2255 [screen.cur.col]);
2214 *srp ^= RS_RVid; 2256 *srp ^= RS_RVid;
2215#ifndef NO_CURSORCOLOR 2257#ifndef NO_CURSORCOLOR
2216 *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1; 2258 *srp = (*srp & ~(RS_fgMask | RS_bgMask)) | cc1;
2217#endif 2259#endif
2218 } else if (R->oldcursor.row >= 0) { 2260 } else if (oldcursor.row >= 0) {
2219#ifndef NO_CURSORCOLOR 2261#ifndef NO_CURSORCOLOR
2220 unsigned long gcmask; /* Graphics Context mask */ 2262 unsigned long gcmask; /* Graphics Context mask */
2221 2263
2222 if (XDEPTH > 2 && ISSET_PIXCOLOR(R, Color_cursor)) { 2264 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_cursor))
2223 XSetForeground (R->Xdisplay, R->TermWin.gc, R->PixColors[Color_cursor]); 2265 XSetForeground (Xdisplay, TermWin.gc, PixColors[Color_cursor]);
2224 }
2225#endif 2266#endif
2226 XDrawRectangle(R->Xdisplay, drawBuffer, R->TermWin.gc, 2267 XDrawRectangle(Xdisplay, drawBuffer, TermWin.gc,
2227 Col2Pixel(R->oldcursor.col), 2268 Col2Pixel(oldcursor.col),
2228 Row2Pixel(R->oldcursor.row), 2269 Row2Pixel(oldcursor.row),
2229 (unsigned int)(Width2Pixel(cursorwidth) - 1), 2270 (unsigned int)(Width2Pixel(cursorwidth) - 1),
2230 (unsigned int)(Height2Pixel(1) - R->TermWin.lineSpace - 1)); 2271 (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1));
2231 } 2272 }
2232 } 2273 }
2233/* 2274
2275 /*
2234 * H: cleanup selection 2276 * H: cleanup selection
2235 */ 2277 */
2236 rxvt_scr_reverse_selection(aR); 2278 rxvt_scr_reverse_selection (this);
2237 2279
2238/* 2280 /*
2239 * I: other general cleanup 2281 * I: other general cleanup
2240 */ 2282 */
2241 if (clearfirst && R->TermWin.int_bwidth) 2283 if (clearfirst && TermWin.int_bwidth)
2242 /* 2284 /*
2243 * clear the whole screen height, note that width == 0 is treated 2285 * clear the whole screen height, note that width == 0 is treated
2244 * specially by XClearArea 2286 * specially by XClearArea
2245 */ 2287 */
2246 XClearArea(R->Xdisplay, R->TermWin.vt, 0, 0, 2288 XClearArea(Xdisplay, TermWin.vt, 0, 0,
2247 (unsigned int)R->TermWin.int_bwidth, 2289 (unsigned int)TermWin.int_bwidth,
2248 (unsigned int)TermWin_TotalHeight(), False); 2290 (unsigned int)TermWin_TotalHeight(), False);
2249 if (clearlast && R->TermWin.int_bwidth) 2291 if (clearlast && TermWin.int_bwidth)
2250 /* 2292 /*
2251 * clear the whole screen height, note that width == 0 is treated 2293 * clear the whole screen height, note that width == 0 is treated
2252 * specially by XClearArea 2294 * specially by XClearArea
2253 */ 2295 */
2254 XClearArea(R->Xdisplay, R->TermWin.vt, 2296 XClearArea(Xdisplay, TermWin.vt,
2255 R->TermWin.width + R->TermWin.int_bwidth, 0, 2297 TermWin.width + TermWin.int_bwidth, 0,
2256 (unsigned int)R->TermWin.int_bwidth, 2298 (unsigned int)TermWin.int_bwidth,
2257 (unsigned int)TermWin_TotalHeight(), False); 2299 (unsigned int)TermWin_TotalHeight(), False);
2258 if (refresh_type & SMOOTH_REFRESH) 2300 if (refresh_type & SMOOTH_REFRESH)
2259 XSync(R->Xdisplay, False); 2301 XSync(Xdisplay, False);
2260 2302
2261 R->num_scr = 0; 2303 num_scr = 0;
2262 R->num_scr_allow = 1; 2304 num_scr_allow = 1;
2263 R->want_refresh = 0; /* screen is current */ 2305 want_refresh = 0; /* screen is current */
2264} 2306}
2265/* ------------------------------------------------------------------------- */
2266 2307
2267/* EXTPROTO */ 2308/* ------------------------------------------------------------------------- */
2268void 2309void
2269rxvt_scr_clear(pR) 2310rxvt_term::scr_clear()
2270{ 2311{
2271 if (!R->TermWin.mapped) 2312 if (!TermWin.mapped)
2272 return; 2313 return;
2314
2273 R->num_scr_allow = 0; 2315 num_scr_allow = 0;
2274 R->want_refresh = 1; 2316 want_refresh = 1;
2275#ifdef TRANSPARENT 2317#ifdef TRANSPARENT
2276 if ((R->Options & Opt_transparent) && (R->am_pixmap_trans == 0)) { 2318 if ((Options & Opt_transparent) && (am_pixmap_trans == 0))
2277 int i; 2319 {
2320 int i;
2278 2321
2279 if (!(R->Options & Opt_transparent_all)) 2322 if (!(Options & Opt_transparent_all))
2280 i = 0; 2323 i = 0;
2281 else 2324 else
2282 i = (int)(sizeof(R->TermWin.parent) / sizeof(Window)); 2325 i = (int)(sizeof(TermWin.parent) / sizeof(Window));
2283 for (; i--;) 2326
2327 while (i--)
2284 if (R->TermWin.parent[i] != None) 2328 if (TermWin.parent[i] != None)
2285 XClearWindow(R->Xdisplay, R->TermWin.parent[i]); 2329 XClearWindow(Xdisplay, TermWin.parent[i]);
2286 } 2330 }
2287#endif 2331#endif
2332
2288 XClearWindow(R->Xdisplay, R->TermWin.vt); 2333 XClearWindow (Xdisplay, TermWin.vt);
2289} 2334}
2290 2335
2291/* ------------------------------------------------------------------------- */ 2336/* ------------------------------------------------------------------------- */
2292/* INTPROTO */ 2337/* INTPROTO */
2293void 2338void
2401rxvt_term::paste (const unsigned char *data, unsigned int len) 2446rxvt_term::paste (const unsigned char *data, unsigned int len)
2402{ 2447{
2403 unsigned int i, j, n; 2448 unsigned int i, j, n;
2404 unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); 2449 unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE);
2405 2450
2451#if 0
2452 /* a paste should act like the user is typing, so check scrollTtyKeypress */
2453 ZERO_SCROLLBACK (r);
2454#endif
2455
2406 /* convert normal newline chars into common keyboard Return key sequence */ 2456 /* convert normal newline chars into common keyboard Return key sequence */
2407 for (i = 0; i < len; i += PROP_SIZE) 2457 for (i = 0; i < len; i += PROP_SIZE)
2408 { 2458 {
2409 n = min (len - i, PROP_SIZE); 2459 n = min (len - i, PROP_SIZE);
2410 MEMCPY (ds, data + i, n); 2460 MEMCPY (ds, data + i, n);
2762/* ------------------------------------------------------------------------- */ 2812/* ------------------------------------------------------------------------- */
2763/* 2813/*
2764 * Mark or select text based upon number of clicks: 1, 2, or 3 2814 * Mark or select text based upon number of clicks: 1, 2, or 3
2765 * EXT: button 1 press 2815 * EXT: button 1 press
2766 */ 2816 */
2767/* EXTPROTO */
2768void 2817void
2769rxvt_selection_click(pR_ int clicks, int x, int y) 2818rxvt_term::selection_click (int clicks, int x, int y)
2770{ 2819{
2771 D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y)); 2820 D_SELECT((stderr, "rxvt_selection_click(%d, %d, %d)", clicks, x, y));
2772 2821
2773 clicks = ((clicks - 1) % 3) + 1; 2822 clicks = ((clicks - 1) % 3) + 1;
2774 R->selection.clicks = clicks; /* save clicks so extend will work */ 2823 selection.clicks = clicks; /* save clicks so extend will work */
2775 2824
2776 rxvt_selection_start_colrow(aR_ Pixel2Col(x), Pixel2Row(y)); 2825 rxvt_selection_start_colrow (this, Pixel2Col(x), Pixel2Row(y));
2826
2777 if (clicks == 2 || clicks == 3) 2827 if (clicks == 2 || clicks == 3)
2778 rxvt_selection_extend_colrow(aR_ R->selection.mark.col, 2828 rxvt_selection_extend_colrow (this, selection.mark.col,
2779 R->selection.mark.row
2780 + R->TermWin.view_start, 2829 selection.mark.row + TermWin.view_start,
2781 0, /* button 3 */ 2830 0, /* button 3 */
2782 1, /* button press */ 2831 1, /* button press */
2783 0); /* click change */ 2832 0); /* click change */
2784} 2833}
2785 2834
2786/* ------------------------------------------------------------------------- */ 2835/* ------------------------------------------------------------------------- */
2787/* 2836/*
2788 * Mark a selection at the specified col/row 2837 * Mark a selection at the specified col/row
2898 * EXT: button 3 press; button 1 or 3 drag 2947 * EXT: button 3 press; button 1 or 3 drag
2899 * flag == 0 ==> button 1 2948 * flag == 0 ==> button 1
2900 * flag == 1 ==> button 3 press 2949 * flag == 1 ==> button 3 press
2901 * flag == 2 ==> button 3 motion 2950 * flag == 2 ==> button 3 motion
2902 */ 2951 */
2903/* EXTPROTO */
2904void 2952void
2905rxvt_selection_extend(pR_ int x, int y, int flag) 2953rxvt_term::selection_extend (int x, int y, int flag)
2906{ 2954{
2907 int col, row; 2955 int col, row;
2908 2956
2909 col = Pixel2Col(x); 2957 col = Pixel2Col(x);
2910 row = Pixel2Row(y); 2958 row = Pixel2Row(y);
2911 MAX_IT(row, 0); 2959 MAX_IT(row, 0);
2912 MIN_IT(row, (int)R->TermWin.nrow - 1); 2960 MIN_IT(row, (int)TermWin.nrow - 1);
2913 MAX_IT(col, 0); 2961 MAX_IT(col, 0);
2914 MIN_IT(col, (int)R->TermWin.ncol); 2962 MIN_IT(col, (int)TermWin.ncol);
2963
2915#ifndef NO_NEW_SELECTION 2964#ifndef NO_NEW_SELECTION
2916/* 2965 /*
2917 * If we're selecting characters (single click) then we must check first 2966 * If we're selecting characters (single click) then we must check first
2918 * if we are at the same place as the original mark. If we are then 2967 * if we are at the same place as the original mark. If we are then
2919 * select nothing. Otherwise, if we're to the right of the mark, you have to 2968 * select nothing. Otherwise, if we're to the right of the mark, you have to
2920 * be _past_ a character for it to be selected. 2969 * be _past_ a character for it to be selected.
2921 */ 2970 */
2922 if (R->selection_style != OLD_SELECT) { 2971 if (selection_style != OLD_SELECT)
2972 {
2923 if (((R->selection.clicks % 3) == 1) && !flag 2973 if (((selection.clicks % 3) == 1) && !flag
2924 && (col == R->selection.mark.col 2974 && (col == selection.mark.col
2925 && (row == R->selection.mark.row + R->TermWin.view_start))) { 2975 && (row == selection.mark.row + TermWin.view_start)))
2976 {
2926 /* select nothing */ 2977 /* select nothing */
2927 R->selection.beg.row = R->selection.end.row = 0; 2978 selection.beg.row = selection.end.row = 0;
2928 R->selection.beg.col = R->selection.end.col = 0; 2979 selection.beg.col = selection.end.col = 0;
2929 R->selection.clicks = 4; 2980 selection.clicks = 4;
2930 R->want_refresh = 1; 2981 want_refresh = 1;
2931 D_SELECT((stderr, "rxvt_selection_extend() R->selection.clicks = 4")); 2982 D_SELECT((stderr, "rxvt_selection_extend() selection.clicks = 4"));
2932 return; 2983 return;
2933 } 2984 }
2934 } 2985 }
2935#endif 2986#endif
2936 if (R->selection.clicks == 4) 2987 if (selection.clicks == 4)
2937 R->selection.clicks = 1; 2988 selection.clicks = 1;
2989
2938 rxvt_selection_extend_colrow(aR_ col, row, !!flag, /* ? button 3 */ 2990 rxvt_selection_extend_colrow (this, col, row, !!flag, /* ? button 3 */
2939 flag == 1 ? 1 : 0, /* ? button press */ 2991 flag == 1 ? 1 : 0, /* ? button press */
2940 0); /* no click change */ 2992 0); /* no click change */
2941} 2993}
2942 2994
2943/* ------------------------------------------------------------------------- */ 2995/* ------------------------------------------------------------------------- */
2944/* 2996/*
2945 * Extend the selection to the specified col/row 2997 * Extend the selection to the specified col/row
3199/* ------------------------------------------------------------------------- */ 3251/* ------------------------------------------------------------------------- */
3200/* 3252/*
3201 * Double click on button 3 when already selected 3253 * Double click on button 3 when already selected
3202 * EXT: button 3 double click 3254 * EXT: button 3 double click
3203 */ 3255 */
3204/* EXTPROTO */
3205void 3256void
3206rxvt_selection_rotate(pR_ int x, int y) 3257rxvt_term::selection_rotate (int x, int y)
3207{ 3258{
3208 R->selection.clicks = R->selection.clicks % 3 + 1; 3259 selection.clicks = selection.clicks % 3 + 1;
3209 rxvt_selection_extend_colrow(aR_ Pixel2Col(x), Pixel2Row(y), 1, 0, 1); 3260 rxvt_selection_extend_colrow (this, Pixel2Col(x), Pixel2Row(y), 1, 0, 1);
3210} 3261}
3211 3262
3212/* ------------------------------------------------------------------------- */ 3263/* ------------------------------------------------------------------------- */
3213/* 3264/*
3214 * On some systems, the Atom typedef is 64 bits wide. We need to have a type 3265 * On some systems, the Atom typedef is 64 bits wide. We need to have a type
3318 * ------------------------------------------------------------------------- */ 3369 * ------------------------------------------------------------------------- */
3319 3370
3320/* 3371/*
3321 * return col/row values corresponding to x/y pixel values 3372 * return col/row values corresponding to x/y pixel values
3322 */ 3373 */
3323/* EXTPROTO */
3324void 3374void
3325rxvt_pixel_position(pR_ int *x, int *y) 3375rxvt_term::pixel_position (int *x, int *y)
3326{ 3376{
3327 *x = Pixel2Col(*x); 3377 *x = Pixel2Col(*x);
3328/* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */ 3378 /* MAX_IT(*x, 0); MIN_IT(*x, (int)R->TermWin.ncol - 1); */
3329 *y = Pixel2Row(*y); 3379 *y = Pixel2Row(*y);
3330/* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */ 3380 /* MAX_IT(*y, 0); MIN_IT(*y, (int)R->TermWin.nrow - 1); */
3331} 3381}
3382
3332/* ------------------------------------------------------------------------- */ 3383/* ------------------------------------------------------------------------- */
3333#ifdef USE_XIM 3384#ifdef USE_XIM
3334/* EXTPROTO */
3335void 3385void
3336rxvt_setPosition(pR_ XPoint *pos) 3386rxvt_term::set_position (XPoint *pos)
3337{ 3387{
3338 XWindowAttributes xwa; 3388 XWindowAttributes xwa;
3339 3389
3340 XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &xwa); 3390 XGetWindowAttributes (Xdisplay, TermWin.vt, &xwa);
3341 pos->x = Col2Pixel(R->screen.cur.col) + xwa.x; 3391 pos->x = Col2Pixel (screen.cur.col) + xwa.x;
3342 pos->y = Height2Pixel((R->screen.cur.row + 1)) + xwa.y 3392 pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace;
3343 - R->TermWin.lineSpace;
3344} 3393}
3394
3345#endif 3395#endif
3346/* ------------------------------------------------------------------------- */ 3396/* ------------------------------------------------------------------------- */
3347 3397
3348/* ------------------------------------------------------------------------- * 3398/* ------------------------------------------------------------------------- *
3349 * DEBUG ROUTINES * 3399 * DEBUG ROUTINES *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines