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.399 by sf-exg, Thu Nov 3 10:42:17 2011 UTC vs.
Revision 1.415 by root, Mon May 28 14:25:16 2012 UTC

98 98
99/* Fill part/all of a line with blanks. */ 99/* Fill part/all of a line with blanks. */
100void 100void
101rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW 101rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW
102{ 102{
103 if (!l.t) 103 if (!l.valid ())
104 { 104 {
105 lalloc (l); 105 l.alloc ();
106 col = 0; 106 col = 0;
107 width = ncol; 107 width = ncol;
108 } 108 }
109 109
110 l.touch (); 110 l.touch ();
157/* ------------------------------------------------------------------------- * 157/* ------------------------------------------------------------------------- *
158 * SCREEN INITIALISATION * 158 * SCREEN INITIALISATION *
159 * ------------------------------------------------------------------------- */ 159 * ------------------------------------------------------------------------- */
160 160
161void 161void
162rxvt_term::scr_alloc ()
163{
164 int tsize = sizeof (text_t) * ncol;
165 int rsize = sizeof (rend_t) * ncol;
166
167 // we assume that rend_t size is a sufficient alignment
168 // factor for tetx_t and line_t values, and we only
169 // need to adjust tsize.
170 tsize = (tsize + sizeof (rend_t) - 1);
171 tsize -= tsize % sizeof (rend_t);
172
173 int all_rows = total_rows + nrow + nrow;
174
175 chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows;
176 chunk = rxvt_malloc (chunk_size);
177
178 char *base = (char *)chunk + sizeof (line_t) * all_rows;
179
180 for (int row = 0; row < all_rows; ++row)
181 {
182 line_t &l = ((line_t *)chunk) [row];
183
184 l.t = (text_t *)base; base += tsize;
185 l.r = (rend_t *)base; base += rsize;
186 l.l = -1;
187 l.f = 0;
188 }
189
190 drawn_buf = (line_t *)chunk;
191 swap_buf = drawn_buf + nrow;
192 row_buf = swap_buf + nrow;
193}
194
195void
162rxvt_term::scr_reset () 196rxvt_term::scr_reset ()
163{ 197{
164#if ENABLE_OVERLAY 198#if ENABLE_OVERLAY
165 scr_overlay_off (); 199 scr_overlay_off ();
166#endif 200#endif
192 total_rows = nrow + saveLines; 226 total_rows = nrow + saveLines;
193 227
194 screen.tscroll = 0; 228 screen.tscroll = 0;
195 screen.bscroll = nrow - 1; 229 screen.bscroll = nrow - 1;
196 230
231 void *prev_chunk = chunk;
232 line_t *prev_drawn_buf = drawn_buf;
233 line_t *prev_swap_buf = swap_buf;
234 line_t *prev_row_buf = row_buf;
235
236 int common_col = min (prev_ncol, ncol);
237
238 scr_alloc ();
239
197 if (!row_buf) 240 if (!prev_row_buf)
198 { 241 {
199 /* 242 /*
200 * first time called so just malloc everything: don't rely on realloc 243 * first time called so just malloc everything: don't rely on realloc
201 */ 244 */
202 top_row = 0; 245 top_row = 0;
203 term_start = 0; 246 term_start = 0;
204
205 talloc = new rxvt_salloc (ncol * sizeof (text_t));
206 ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
207
208 row_buf = (line_t *)rxvt_calloc (total_rows , sizeof (line_t));
209 drawn_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t));
210 swap_buf = (line_t *)rxvt_calloc (nrow , sizeof (line_t));
211
212 for (int row = nrow; row--; )
213 {
214 scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE);
215 scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
216 scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE);
217 }
218 247
219 memset (charsets, 'B', sizeof (charsets)); 248 memset (charsets, 'B', sizeof (charsets));
220 rstyle = DEFAULT_RSTYLE; 249 rstyle = DEFAULT_RSTYLE;
221 screen.flags = Screen_DefaultFlags; 250 screen.flags = Screen_DefaultFlags;
222 screen.cur.row = screen.cur.col = 0; 251 screen.cur.row = screen.cur.col = 0;
245 { 274 {
246 /* 275 /*
247 * add or delete rows as appropriate 276 * add or delete rows as appropriate
248 */ 277 */
249 278
250 rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t));
251 rxvt_salloc *old_ra = ralloc; ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
252
253#if 0
254 if (nrow < prev_nrow)
255 {
256 for (int row = nrow; row < prev_nrow; row++)
257 {
258 lfree (swap_buf [row]);
259 lfree (drawn_buf[row]);
260 }
261 }
262#endif
263
264 drawn_buf = (line_t *)rxvt_realloc (drawn_buf, nrow * sizeof (line_t));
265 swap_buf = (line_t *)rxvt_realloc (swap_buf , nrow * sizeof (line_t));
266
267 for (int row = min (nrow, prev_nrow); row--; ) 279 for (int row = min (nrow, prev_nrow); row--; )
268 { 280 {
269 lresize (drawn_buf[row]); 281 scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
270 lresize (swap_buf [row]); 282 scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
271 }
272 283
273 for (int row = prev_nrow; row < nrow; row++) 284 memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col);
285 memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col);
286 memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col);
287 memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col);
274 { 288 }
275 swap_buf [row].clear (); scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
276 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE);
277 }
278
279 line_t *old_buf = row_buf;
280 row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t));
281 289
282 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 290 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
283 int pend = MOD (term_start + top_row , prev_total_rows); 291 int pend = MOD (term_start + top_row , prev_total_rows);
284 int q = total_rows; // rewrapped row 292 int q = total_rows; // rewrapped row
285 293
293 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 301 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
294 302
295 do 303 do
296 { 304 {
297 p = MOD (p - 1, prev_total_rows); 305 p = MOD (p - 1, prev_total_rows);
298 assert (old_buf [MOD (p, prev_total_rows)].t); 306 assert (prev_row_buf [MOD (p, prev_total_rows)].t);
299 int plines = 1; 307 int plines = 1;
300 int llen = old_buf [MOD (p, prev_total_rows)].l; 308 int llen = prev_row_buf [MOD (p, prev_total_rows)].l;
301 309
302 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) 310 while (p != pend && prev_row_buf [MOD (p - 1, prev_total_rows)].is_longer ())
303 { 311 {
304 p = MOD (p - 1, prev_total_rows); 312 p = MOD (p - 1, prev_total_rows);
305 313
306 plines++; 314 plines++;
307 llen += prev_ncol; 315 llen += prev_ncol;
320 328
321 // re-assemble the full line by destination lines 329 // re-assemble the full line by destination lines
322 for (int qrow = q; qlines--; qrow++) 330 for (int qrow = q; qlines--; qrow++)
323 { 331 {
324 qline = row_buf + qrow; 332 qline = row_buf + qrow;
325 lalloc (*qline); 333 qline->alloc (); // redundant with next line
326 qline->l = ncol; 334 qline->l = ncol;
327 qline->is_longer (1); 335 qline->is_longer (1);
328 336
329 int qcol = 0; 337 int qcol = 0;
330 338
345 // this seems to upset applications/shells/readline 353 // this seems to upset applications/shells/readline
346 // least. 354 // least.
347 if (prow == ocur.row) 355 if (prow == ocur.row)
348 screen.cur.row = q - (total_rows - nrow); 356 screen.cur.row = q - (total_rows - nrow);
349 357
350 line_t &pline = old_buf [prow]; 358 line_t &pline = prev_row_buf [prow];
351 359
352 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); 360 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
353 361
354 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); 362 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
355 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); 363 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
376 { 384 {
377 // if no scrollback exists (yet), wing, instead of wrap 385 // if no scrollback exists (yet), wing, instead of wrap
378 386
379 for (int row = min (nrow, prev_nrow); row--; ) 387 for (int row = min (nrow, prev_nrow); row--; )
380 { 388 {
381 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; 389 line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)];
382 line_t &qline = row_buf [row]; 390 line_t &dst = row_buf [row];
383 391
384 qline = pline; 392 scr_blank_screen_mem (dst, DEFAULT_RSTYLE);
385 lresize (qline); 393
394 memcpy (dst.t, src.t, sizeof (text_t) * common_col);
395 memcpy (dst.r, src.r, sizeof (rend_t) * common_col);
386 } 396 }
387 397
388 for (int row = prev_nrow; row < nrow; row++) 398 for (int row = prev_nrow; row < nrow; row++)
389 {
390 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); 399 scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
391 }
392 400
393 term_start = 0; 401 term_start = 0;
394 } 402 }
395
396 free (old_buf);
397 delete old_ta;
398 delete old_ra;
399 403
400 clamp_it (screen.cur.row, 0, nrow - 1); 404 clamp_it (screen.cur.row, 0, nrow - 1);
401 clamp_it (screen.cur.col, 0, ncol - 1); 405 clamp_it (screen.cur.col, 0, ncol - 1);
402 } 406 }
403 407
408 for (int row = nrow; row--; )
409 {
410 if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE);
411 if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
412 if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
413 }
414
415 free (prev_chunk);
416
404 free (tabs); 417 free (tabs);
405 tabs = (char *)rxvt_malloc (ncol); 418 tabs = (char *)rxvt_malloc (ncol);
406 419
407 for (int col = ncol; col--; ) 420 for (int col = ncol; col--; )
408 tabs [col] = col % TABSIZE == 0; 421 tabs [col] = col % TABSIZE == 0;
422 * Free everything. That way malloc debugging can find leakage. 435 * Free everything. That way malloc debugging can find leakage.
423 */ 436 */
424void 437void
425rxvt_term::scr_release () NOTHROW 438rxvt_term::scr_release () NOTHROW
426{ 439{
427 if (row_buf) 440 free (chunk);
428 {
429 delete talloc; talloc = 0;
430 delete ralloc; ralloc = 0;
431
432 free (row_buf);
433 free (swap_buf);
434 free (drawn_buf);
435 row_buf = 0; // signal that we freed all the arrays above
436
437 free (tabs); 441 free (tabs);
438 tabs = 0;
439 }
440} 442}
441 443
442/* ------------------------------------------------------------------------- */ 444/* ------------------------------------------------------------------------- */
443/* 445/*
444 * Hard/Soft reset 446 * Hard/Soft reset
445 */ 447 */
446void 448void
447rxvt_term::scr_poweron () 449rxvt_term::scr_poweron ()
448{ 450{
449 scr_release (); 451 scr_release ();
452
453 row_buf = 0;
454 tabs = 0;
450 prev_nrow = prev_ncol = 0; 455 prev_nrow = prev_ncol = 0;
451 rvideo_mode = false; 456 rvideo_mode = false;
452 scr_soft_reset (); 457 scr_soft_reset ();
453 scr_reset (); 458 scr_reset ();
454 459
455 scr_clear (true); 460 scr_clear (true);
456 scr_refresh (); 461 scr_refresh ();
457} 462}
458 463
459void 464void
460rxvt_term::scr_soft_reset () 465rxvt_term::scr_soft_reset () NOTHROW
461{ 466{
462 /* only affects modes, nothing drastic such as clearing the screen */ 467 /* only affects modes, nothing drastic such as clearing the screen */
463#if ENABLE_OVERLAY 468#if ENABLE_OVERLAY
464 scr_overlay_off (); 469 scr_overlay_off ();
465#endif 470#endif
520 assert (s->cur.row >= 0); 525 assert (s->cur.row >= 0);
521 assert (s->cur.col >= 0); 526 assert (s->cur.col >= 0);
522} 527}
523 528
524void 529void
525rxvt_term::scr_swap_screen () 530rxvt_term::scr_swap_screen () NOTHROW
526{ 531{
527 if (!option (Opt_secondaryScreen)) 532 if (!option (Opt_secondaryScreen))
528 return; 533 return;
529 534
530 for (int i = prev_nrow; i--; ) 535 for (int i = prev_nrow; i--; )
549 return; 554 return;
550 555
551 want_refresh = 1; 556 want_refresh = 1;
552 view_start = 0; 557 view_start = 0;
553 558
554 selection_check (2); /* check for boundary cross */ 559 /* check for boundary cross */
560 row_col_t pos;
561 pos.row = pos.col = 0;
562 if (ROWCOL_IS_BEFORE (selection.beg, pos)
563 && ROWCOL_IS_AFTER (selection.end, pos))
564 CLEAR_SELECTION ();
555 565
556 current_screen = scrn; 566 current_screen = scrn;
557 567
558#if NSCREENS 568#if NSCREENS
559 if (option (Opt_secondaryScreen)) 569 if (option (Opt_secondaryScreen))
681 } 691 }
682 else 692 else
683 scr_blank_screen_mem (l, rstyle); 693 scr_blank_screen_mem (l, rstyle);
684 } 694 }
685 695
696 // move and/or clear selection, if any
697 if (selection.op && current_screen == selection.screen
698 && selection.beg.row <= row2)
699 {
700 selection.beg.row -= count;
701 selection.end.row -= count;
702 selection.mark.row -= count;
703
704 selection_check (0);
705 }
706
686 // finally move the view window, if desired 707 // finally move the view window, if desired
687 if (option (Opt_scrollWithBuffer) 708 if (option (Opt_scrollWithBuffer)
688 && view_start != 0 709 && view_start != 0
689 && view_start != -saveLines) 710 && view_start != -saveLines)
690 scr_page (UP, count); 711 scr_page (UP, count);
692 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 713 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
693 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); 714 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END));
694 } 715 }
695 else 716 else
696 { 717 {
718 if (selection.op && current_screen == selection.screen)
719 {
720 if ((selection.beg.row < row1 && selection.end.row > row1)
721 || (selection.beg.row < row2 && selection.end.row > row2)
722 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
723 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
724 || (selection.end.row - count < row1 && selection.end.row >= row1)
725 || (selection.end.row - count > row2 && selection.end.row <= row2))
726 {
727 CLEAR_ALL_SELECTION ();
728 selection.op = SELECTION_CLEAR;
729 }
730 else if (selection.end.row >= row1 && selection.end.row <= row2)
731 {
732 /* move selected region too */
733 selection.beg.row -= count;
734 selection.end.row -= count;
735 selection.mark.row -= count;
736
737 selection_check (0);
738 }
739 }
740
697 // use a simple and robust scrolling algorithm, this 741 // use a simple and robust scrolling algorithm, this
698 // part of scr_scroll_text is not time-critical. 742 // part of scr_scroll_text is not time-critical.
699 743
700 // sever line above scroll region 744 // sever line above scroll region
701 if (row1) 745 if (row1)
728 l.is_longer (0); 772 l.is_longer (0);
729 l.touch (); 773 l.touch ();
730 } 774 }
731 } 775 }
732 776
733 // move and/or clear selection, if any
734 if (selection.op && current_screen == selection.screen)
735 {
736 if ((selection.beg.row < row1 && selection.end.row > row1)
737 || (selection.beg.row < row2 && selection.end.row > row2)
738 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
739 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
740 || (selection.end.row - count < row1 && selection.end.row >= row1)
741 || (selection.end.row - count > row2 && selection.end.row <= row2))
742 CLEAR_ALL_SELECTION ();
743 else if (selection.end.row >= row1 && selection.end.row <= row2)
744 {
745 /* move selected region too */
746 selection.beg.row -= count;
747 selection.end.row -= count;
748 selection.mark.row -= count;
749
750 selection_check (0);
751 }
752 }
753
754 return count; 777 return count;
755} 778}
756 779
757/* ------------------------------------------------------------------------- */ 780/* ------------------------------------------------------------------------- */
758/* 781/*
762rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW 785rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
763{ 786{
764 if (len <= 0) /* sanity */ 787 if (len <= 0) /* sanity */
765 return; 788 return;
766 789
767 unsigned char checksel; 790 bool checksel;
768 unicode_t c; 791 unicode_t c;
769 int ncol = this->ncol; 792 int ncol = this->ncol;
770 const wchar_t *strend = str + len; 793 const wchar_t *strend = str + len;
771 794
772 want_refresh = 1; 795 want_refresh = 1;
1294 scr_blank_line (line, col, num, rstyle); 1317 scr_blank_line (line, col, num, rstyle);
1295} 1318}
1296 1319
1297/* ------------------------------------------------------------------------- */ 1320/* ------------------------------------------------------------------------- */
1298/* 1321/*
1299 * Erase part of whole of the screen 1322 * Erase part or whole of the screen
1300 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J 1323 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J
1301 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J 1324 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J
1302 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1325 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1303 */ 1326 */
1304void 1327void
1313 ZERO_SCROLLBACK (); 1336 ZERO_SCROLLBACK ();
1314 1337
1315 switch (mode) 1338 switch (mode)
1316 { 1339 {
1317 case 0: /* erase to end of screen */ 1340 case 0: /* erase to end of screen */
1318 selection_check (1);
1319 scr_erase_line (0); 1341 scr_erase_line (0);
1320 row = screen.cur.row + 1; /* possible OOB */ 1342 row = screen.cur.row + 1; /* possible OOB */
1321 num = nrow - row; 1343 num = nrow - row;
1322 break; 1344 break;
1323 case 1: /* erase to beginning of screen */ 1345 case 1: /* erase to beginning of screen */
1324 selection_check (3);
1325 scr_erase_line (1); 1346 scr_erase_line (1);
1326 row = 0; 1347 row = 0;
1327 num = screen.cur.row; 1348 num = screen.cur.row;
1328 break; 1349 break;
1329 case 2: /* erase whole screen */ 1350 case 2: /* erase whole screen */
1330 selection_check (3);
1331 row = 0; 1351 row = 0;
1332 num = nrow; 1352 num = nrow;
1333 break; 1353 break;
1334 default: 1354 default:
1335 return; 1355 return;
1352 { 1372 {
1353 ren = DEFAULT_RSTYLE; 1373 ren = DEFAULT_RSTYLE;
1354 1374
1355 if (mapped) 1375 if (mapped)
1356 XClearArea (dpy, vt, 0, 1376 XClearArea (dpy, vt, 0,
1357 Row2Pixel (row - view_start), (unsigned int)width, 1377 Row2Pixel (row - view_start), (unsigned int)vt_width,
1358 (unsigned int)Height2Pixel (num), False); 1378 (unsigned int)Height2Pixel (num), False);
1359 } 1379 }
1360 else 1380 else
1361 { 1381 {
1362 ren = rstyle & (RS_fgMask | RS_bgMask); 1382 ren = rstyle & (RS_fgMask | RS_bgMask);
1365 { 1385 {
1366 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1386 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1367 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1387 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1368 XFillRectangle (dpy, vt, gc, 1388 XFillRectangle (dpy, vt, gc,
1369 0, Row2Pixel (row - view_start), 1389 0, Row2Pixel (row - view_start),
1370 (unsigned int)width, 1390 (unsigned int)vt_width,
1371 (unsigned int)Height2Pixel (num)); 1391 (unsigned int)Height2Pixel (num));
1372 gcvalue.foreground = pix_colors[Color_fg]; 1392 gcvalue.foreground = pix_colors[Color_fg];
1373 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1393 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1374 } 1394 }
1375 } 1395 }
1406 1426
1407 want_refresh = 1; 1427 want_refresh = 1;
1408 ZERO_SCROLLBACK (); 1428 ZERO_SCROLLBACK ();
1409 1429
1410 num_scr_allow = 0; 1430 num_scr_allow = 0;
1411 selection_check (3); 1431
1432 row_col_t pos;
1433 pos.row = pos.col = 0;
1434 if (ROWCOL_IS_AFTER (selection.end, pos))
1435 CLEAR_SELECTION ();
1412 1436
1413 fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); 1437 fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E'));
1414 for (int row = nrow; row--; ) 1438 for (int row = nrow; row--; )
1415 { 1439 {
1416 line_t &line = ROW(row); 1440 line_t &line = ROW(row);
1857 * Refresh the entire screen 1881 * Refresh the entire screen
1858 */ 1882 */
1859void 1883void
1860rxvt_term::scr_touch (bool refresh) NOTHROW 1884rxvt_term::scr_touch (bool refresh) NOTHROW
1861{ 1885{
1862 scr_expose (0, 0, width, height, refresh); 1886 scr_expose (0, 0, vt_width, vt_height, refresh);
1863} 1887}
1864 1888
1865/* ------------------------------------------------------------------------- */ 1889/* ------------------------------------------------------------------------- */
1866/* 1890/*
1867 * Move the display so that the line represented by scrollbar value Y is at 1891 * Move the display so that the line represented by scrollbar value Y is at
2029 * A: set up vars 2053 * A: set up vars
2030 */ 2054 */
2031 refresh_count = 0; 2055 refresh_count = 0;
2032 2056
2033 unsigned int old_screen_flags = screen.flags; 2057 unsigned int old_screen_flags = screen.flags;
2034 char have_bg = 0; 2058 bool have_bg = 0;
2035#ifdef HAVE_BG_PIXMAP 2059#ifdef HAVE_BG_PIXMAP
2036 have_bg = bg_pixmap != None; 2060 have_bg = bg_pixmap != None;
2037#endif 2061#endif
2038 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2062 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2039 2063
2045 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); 2069 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2046#if ENABLE_OVERLAY 2070#if ENABLE_OVERLAY
2047 scr_swap_overlay (); 2071 scr_swap_overlay ();
2048#endif 2072#endif
2049 2073
2050 char showcursor = screen.flags & Screen_VisibleCursor; 2074 bool showcursor = screen.flags & Screen_VisibleCursor;
2051 2075
2052 /* 2076 /*
2053 * C: set the cursor character (s) 2077 * C: set the cursor character (s)
2054 */ 2078 */
2055 { 2079 {
2056 unsigned char setoldcursor; 2080 bool setoldcursor;
2057 2081
2058#ifdef CURSOR_BLINK 2082#ifdef CURSOR_BLINK
2059 if (hidden_cursor) 2083 if (hidden_cursor)
2060 showcursor = 0; 2084 showcursor = 0;
2061#endif 2085#endif
2148 { 2172 {
2149 int16_t nits; 2173 int16_t nits;
2150 int i = num_scr; 2174 int i = num_scr;
2151 int j; 2175 int j;
2152 int len, wlen; 2176 int len, wlen;
2153 dLocal (int, num_scr);
2154 2177
2155 j = nrow; 2178 j = nrow;
2156 wlen = len = -1; 2179 wlen = len = -1;
2157 row = i > 0 ? 0 : j - 1; 2180 row = i > 0 ? 0 : j - 1;
2158 2181
2463 2486
2464 XDrawRectangle (dpy, vt, gc, 2487 XDrawRectangle (dpy, vt, gc,
2465 Col2Pixel (col), 2488 Col2Pixel (col),
2466 Row2Pixel (oldcursor.row), 2489 Row2Pixel (oldcursor.row),
2467 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2490 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2468 (unsigned int) (Height2Pixel (1) - lineSpace - 1)); 2491 (unsigned int) (Height2Pixel (1) - 1));
2469 } 2492 }
2470 } 2493 }
2471 2494
2472 /* 2495 /*
2473 * H: cleanup selection 2496 * H: cleanup selection
2485} 2508}
2486 2509
2487void 2510void
2488rxvt_term::scr_remap_chars (line_t &l) NOTHROW 2511rxvt_term::scr_remap_chars (line_t &l) NOTHROW
2489{ 2512{
2490 if (!l.t) 2513 if (!l.valid ())
2491 return; 2514 return;
2492 2515
2493 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant 2516 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant
2494 2517
2495 for (int i = ncol; i--; ) 2518 for (int i = ncol; i--; )
2649 */ 2672 */
2650#if 0 2673#if 0
2651void 2674void
2652rxvt_term::scr_dump (int fd) NOTHROW 2675rxvt_term::scr_dump (int fd) NOTHROW
2653{ 2676{
2654 int row, wrote; 2677 // if this method is needed, it can be implemented by factoring the
2655 unsigned int width, towrite; 2678 // relevant code in scr_printscreen
2656 const char r1[] = "\n";
2657
2658 for (row = saveLines + top_row;
2659 row < saveLines + nrow - 1; row++)
2660 {
2661 width = row_buf[row].l >= 0 ? row_buf[row].l
2662 : ncol;
2663 for (towrite = width; towrite; towrite -= wrote)
2664 {
2665 wrote = write (fd, & (row_buf[row].t[width - towrite]),
2666 towrite);
2667 if (wrote < 0)
2668 return; /* XXX: death, no report */
2669 }
2670 if (row_buf[row].l >= 0)
2671 if (write (fd, r1, 1) <= 0)
2672 return; /* XXX: death, no report */
2673 }
2674} 2679}
2675#endif 2680#endif
2676 2681
2677/* ------------------------------------------------------------------------- * 2682/* ------------------------------------------------------------------------- *
2678 * CHARACTER SELECTION * 2683 * CHARACTER SELECTION *
2680void 2685void
2681rxvt_term::selection_check (int check_more) NOTHROW 2686rxvt_term::selection_check (int check_more) NOTHROW
2682{ 2687{
2683 if (!selection.op) 2688 if (!selection.op)
2684 return; 2689 return;
2685
2686 row_col_t pos;
2687 pos.row = pos.col = 0;
2688 2690
2689 if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) 2691 if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow)
2690 || !IN_RANGE_EXC (selection.mark.row, top_row, nrow) 2692 || !IN_RANGE_EXC (selection.mark.row, top_row, nrow)
2691 || !IN_RANGE_EXC (selection.end.row, top_row, nrow) 2693 || !IN_RANGE_EXC (selection.end.row, top_row, nrow)
2692 || (check_more == 1 2694 || (check_more == 1
2693 && current_screen == selection.screen 2695 && current_screen == selection.screen
2694 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 2696 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
2695 && ROWCOL_IS_BEFORE (screen.cur, selection.end)) 2697 && ROWCOL_IS_BEFORE (screen.cur, selection.end)))
2696 || (check_more == 2
2697 && ROWCOL_IS_BEFORE (selection.beg, pos)
2698 && ROWCOL_IS_AFTER (selection.end, pos))
2699 || (check_more == 3
2700 && ROWCOL_IS_AFTER (selection.end, pos)))
2701 CLEAR_ALL_SELECTION (); 2698 CLEAR_ALL_SELECTION ();
2702} 2699}
2703 2700
2704/* ------------------------------------------------------------------------- */ 2701/* ------------------------------------------------------------------------- */
2705/* 2702/*
2712 for (unsigned int i = 0; i < len; i++) 2709 for (unsigned int i = 0; i < len; i++)
2713 if (data[i] == C0_LF) 2710 if (data[i] == C0_LF)
2714 data[i] = C0_CR; 2711 data[i] = C0_CR;
2715 2712
2716 if (priv_modes & PrivMode_BracketPaste) 2713 if (priv_modes & PrivMode_BracketPaste)
2717 tt_printf ("\e[200~"); 2714 tt_printf ("\x1b[200~");
2718 2715
2719 tt_write (data, len); 2716 tt_write (data, len);
2720 2717
2721 if (priv_modes & PrivMode_BracketPaste) 2718 if (priv_modes & PrivMode_BracketPaste)
2722 tt_printf ("\e[201~"); 2719 tt_printf ("\x1b[201~");
2723} 2720}
2724 2721
2725void 2722void
2726rxvt_term::paste (char *data, unsigned int len) NOTHROW 2723rxvt_term::paste (char *data, unsigned int len) NOTHROW
2727{ 2724{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines