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.313 by root, Tue Nov 4 14:25:10 2008 UTC vs.
Revision 1.360 by sf-exg, Wed Jan 5 22:29:50 2011 UTC

28#include "rxvt.h" /* NECESSARY */ 28#include "rxvt.h" /* NECESSARY */
29#include "rxvtperl.h" /* NECESSARY */ 29#include "rxvtperl.h" /* NECESSARY */
30 30
31#include <inttypes.h> 31#include <inttypes.h>
32 32
33#include "salloc.C" // HACK, should be a seperate compile! 33#include "salloc.C" // HACK, should be a separate compile!
34 34
35static inline void
35static inline void fill_text (text_t *start, text_t value, int len) 36fill_text (text_t *start, text_t value, int len)
36{ 37{
37 while (len--) 38 while (len--)
38 *start++ = value; 39 *start++ = value;
39} 40}
40 41
143 col--; 144 col--;
144 145
145 rend_t rend = l.r[col] & ~RS_baseattrMask; 146 rend_t rend = l.r[col] & ~RS_baseattrMask;
146 rend = SET_FONT (rend, FONTSET (rend)->find_font (' ')); 147 rend = SET_FONT (rend, FONTSET (rend)->find_font (' '));
147 148
149 l.touch ();
150
148 // found begin, nuke 151 // found start, nuke
149 do { 152 do {
150 l.t[col] = ' '; 153 l.t[col] = ' ';
151 l.r[col] = rend; 154 l.r[col] = rend;
152 col++; 155 col++;
153 } while (col < ncol && l.t[col] == NOCHAR); 156 } while (col < ncol && l.t[col] == NOCHAR);
158 * ------------------------------------------------------------------------- */ 161 * ------------------------------------------------------------------------- */
159 162
160void 163void
161rxvt_term::scr_reset () 164rxvt_term::scr_reset ()
162{ 165{
163#if ENABLE_OVERLAY
164 scr_overlay_off ();
165#endif
166
167 rvideo_mode = false;
168 view_start = 0; 166 view_start = 0;
169 num_scr = 0; 167 num_scr = 0;
170 168
171 if (ncol == 0) 169 if (ncol == 0)
172 ncol = 80; 170 ncol = 80;
174 if (nrow == 0) 172 if (nrow == 0)
175 nrow = 24; 173 nrow = 24;
176 174
177 if (ncol == prev_ncol && nrow == prev_nrow) 175 if (ncol == prev_ncol && nrow == prev_nrow)
178 return; 176 return;
179
180 if (current_screen != PRIMARY)
181 scr_swap_screen ();
182 177
183 // we need at least two lines for wrapping to work correctly 178 // we need at least two lines for wrapping to work correctly
184 while (nrow + saveLines < 2) 179 while (nrow + saveLines < 2)
185 { 180 {
186 //TODO//FIXME 181 //TODO//FIXME
239 selection.text = NULL; 234 selection.text = NULL;
240 selection.len = 0; 235 selection.len = 0;
241 selection.op = SELECTION_CLEAR; 236 selection.op = SELECTION_CLEAR;
242 selection.screen = PRIMARY; 237 selection.screen = PRIMARY;
243 selection.clicks = 0; 238 selection.clicks = 0;
239 selection.clip_text = NULL;
240 selection.clip_len = 0;
244 } 241 }
245 else 242 else
246 { 243 {
247 /* 244 /*
248 * add or delete rows as appropriate 245 * add or delete rows as appropriate
286 283
287 if (top_row) 284 if (top_row)
288 { 285 {
289 // Re-wrap lines. This is rather ugly, possibly because I am too dumb 286 // Re-wrap lines. This is rather ugly, possibly because I am too dumb
290 // to come up with a lean and mean algorithm. 287 // to come up with a lean and mean algorithm.
288 // TODO: maybe optimise when width didn't change
291 289
292 row_col_t ocur = screen.cur; 290 row_col_t ocur = screen.cur;
293 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 291 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
294 292
295 do 293 do
296 { 294 {
297 p = MOD (p - 1, prev_total_rows); 295 p = MOD (p - 1, prev_total_rows);
298#ifdef DEBUG_STRICT
299 assert (old_buf [MOD (p, prev_total_rows)].t); 296 assert (old_buf [MOD (p, prev_total_rows)].t);
300#endif
301 int plines = 1; 297 int plines = 1;
302 int llen = old_buf [MOD (p, prev_total_rows)].l; 298 int llen = old_buf [MOD (p, prev_total_rows)].l;
303 299
304 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) 300 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
305 { 301 {
399 delete old_ta; 395 delete old_ta;
400 delete old_ra; 396 delete old_ra;
401 397
402 clamp_it (screen.cur.row, 0, nrow - 1); 398 clamp_it (screen.cur.row, 0, nrow - 1);
403 clamp_it (screen.cur.col, 0, ncol - 1); 399 clamp_it (screen.cur.col, 0, ncol - 1);
400 }
404 401
405 free (tabs); 402 free (tabs);
406 } 403 tabs = (char *)rxvt_malloc (ncol);
404
405 for (int col = ncol; col--; )
406 tabs [col] = col % TABSIZE == 0;
407 407
408 CLEAR_ALL_SELECTION (); 408 CLEAR_ALL_SELECTION ();
409 409
410 prev_nrow = nrow; 410 prev_nrow = nrow;
411 prev_ncol = ncol; 411 prev_ncol = ncol;
412
413 tabs = (char *)rxvt_malloc (ncol);
414
415 for (int col = ncol; --col; )
416 tabs [col] = col % TABSIZE == 0;
417
418 if (current_screen != PRIMARY)
419 scr_swap_screen ();
420 412
421 tt_winch (); 413 tt_winch ();
422 414
423 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 415 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
424} 416}
436 delete ralloc; ralloc = 0; 428 delete ralloc; ralloc = 0;
437 429
438 free (row_buf); 430 free (row_buf);
439 free (swap_buf); 431 free (swap_buf);
440 free (drawn_buf); 432 free (drawn_buf);
433 row_buf = 0; // signal that we freed all the arrays above
434
441 free (tabs); 435 free (tabs);
442 436 tabs = 0;
443 row_buf = 0; // signal that we freed all the arrays
444 } 437 }
445} 438}
446 439
447/* ------------------------------------------------------------------------- */ 440/* ------------------------------------------------------------------------- */
448/* 441/*
449 * Hard reset 442 * Hard/Soft reset
450 */ 443 */
451void 444void
452rxvt_term::scr_poweron () 445rxvt_term::scr_poweron ()
453{ 446{
454 scr_release (); 447 scr_release ();
455 prev_nrow = prev_ncol = 0; 448 prev_nrow = prev_ncol = 0;
449 rvideo_mode = false;
450 scr_soft_reset ();
456 scr_reset (); 451 scr_reset ();
457 452
458 scr_clear (true); 453 scr_clear (true);
459 scr_refresh (); 454 scr_refresh ();
455}
456
457void
458rxvt_term::scr_soft_reset ()
459{
460 /* only affects modes, nothing drastic such as clearing the screen */
461#if ENABLE_OVERLAY
462 scr_overlay_off ();
463#endif
464
465 if (current_screen != PRIMARY)
466 scr_swap_screen ();
467
468 scr_scroll_region (0, MAX_ROWS - 1);
469 scr_rendition (0, ~RS_None);
470 scr_insert_mode (0);
460} 471}
461 472
462/* ------------------------------------------------------------------------- * 473/* ------------------------------------------------------------------------- *
463 * PROCESS SCREEN COMMANDS * 474 * PROCESS SCREEN COMMANDS *
464 * ------------------------------------------------------------------------- */ 475 * ------------------------------------------------------------------------- */
502 } 513 }
503 514
504 /* boundary check in case screen size changed between SAVE and RESTORE */ 515 /* boundary check in case screen size changed between SAVE and RESTORE */
505 min_it (s->cur.row, nrow - 1); 516 min_it (s->cur.row, nrow - 1);
506 min_it (s->cur.col, ncol - 1); 517 min_it (s->cur.col, ncol - 1);
507#ifdef DEBUG_STRICT
508 assert (s->cur.row >= 0); 518 assert (s->cur.row >= 0);
509 assert (s->cur.col >= 0); 519 assert (s->cur.col >= 0);
510#endif
511} 520}
512 521
513void 522void
514rxvt_term::scr_swap_screen () 523rxvt_term::scr_swap_screen ()
515{ 524{
540 want_refresh = 1; 549 want_refresh = 1;
541 view_start = 0; 550 view_start = 0;
542 551
543 selection_check (2); /* check for boundary cross */ 552 selection_check (2); /* check for boundary cross */
544 553
545 int i = current_screen; current_screen = scrn; scrn = i; 554 current_screen = scrn;
546 555
547#if NSCREENS 556#if NSCREENS
548 if (option (Opt_secondaryScreen)) 557 if (option (Opt_secondaryScreen))
549 { 558 {
550 num_scr = 0; 559 num_scr = 0;
775 scr_scroll_text (screen.tscroll, screen.bscroll, minlines); 784 scr_scroll_text (screen.tscroll, screen.bscroll, minlines);
776 screen.cur.row -= minlines; 785 screen.cur.row -= minlines;
777 } 786 }
778 } 787 }
779 788
780#ifdef DEBUG_STRICT
781 assert (screen.cur.col < ncol); 789 assert (screen.cur.col < ncol);
782 assert (screen.cur.row < nrow 790 assert (screen.cur.row < nrow
783 && screen.cur.row >= top_row); 791 && screen.cur.row >= top_row);
784#endif
785 int row = screen.cur.row; 792 int row = screen.cur.row;
786 793
787 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 794 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
788 795
789 line_t *line = &ROW(row); 796 line_t *line = &ROW(row);
893# else 900# else
894 c = 0xfffd; 901 c = 0xfffd;
895# endif 902# endif
896#endif 903#endif
897 904
898 // nuke the character at this position, if required
899 if (expect_false (
900 line->t[screen.cur.col] == NOCHAR
901 || (screen.cur.col < ncol - 1
902 && line->t[screen.cur.col + 1] == NOCHAR)
903 ))
904 scr_kill_char (*line, screen.cur.col);
905
906 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); 905 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
907 906
908 // if the character doesn't fit into the remaining columns... 907 // if the character doesn't fit into the remaining columns...
909 if (expect_false (screen.cur.col > ncol - width && ncol >= width)) 908 if (expect_false (screen.cur.col > ncol - width && ncol >= width))
910 { 909 {
911 // ...output spaces 910 if (screen.flags & Screen_Autowrap)
912 c = ' '; 911 {
912 // ... artificially enlargen the previous one
913 c = NOCHAR;
913 // and try the same character next loop iteration 914 // and try the same character next loop iteration
914 --str; 915 --str;
916 }
917 else
918 screen.cur.col = ncol - width;
915 } 919 }
920
921 // nuke the character at this position, if required
922 // due to wonderful coincidences everywhere else in this loop
923 // we never have to check for overwriting a wide char itself,
924 // only its tail.
925 if (expect_false (line->t[screen.cur.col] == NOCHAR))
926 scr_kill_char (*line, screen.cur.col);
916 927
917 line->touch (); 928 line->touch ();
918 929
919 do 930 do
920 { 931 {
926 else 937 else
927 { 938 {
928 line->l = ncol; 939 line->l = ncol;
929 if (screen.flags & Screen_Autowrap) 940 if (screen.flags & Screen_Autowrap)
930 screen.flags |= Screen_WrapNext; 941 screen.flags |= Screen_WrapNext;
931 break; 942
943 goto end_of_line;
932 } 944 }
933 945
934 c = NOCHAR; 946 c = NOCHAR;
935 } 947 }
936 while (expect_false (--width > 0)); 948 while (expect_false (--width > 0));
937 949
938 // pad with spaces when overwriting wide character with smaller one 950 // pad with spaces when overwriting wide character with smaller one
939 if (expect_false (!width)) 951 for (int c = screen.cur.col; expect_false (c < ncol && line->t[c] == NOCHAR); c++)
940 { 952 {
941 line->touch ();
942
943 for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++)
944 {
945 line->t[c] = ' '; 953 line->t[c] = ' ';
946 line->r[c] = rend; 954 line->r[c] = rend;
947 }
948 } 955 }
956
957end_of_line:
958 ;
949 } 959 }
950#if ENABLE_COMBINING 960#if ENABLE_COMBINING
951 else // width == 0 961 else // width == 0
952 { 962 {
953 if (c != 0xfeff) // ignore BOM 963 if (c != 0xfeff) // ignore BOM
993#endif 1003#endif
994 } 1004 }
995 1005
996 max_it (line->l, screen.cur.col); 1006 max_it (line->l, screen.cur.col);
997 1007
998#ifdef DEBUG_STRICT
999 assert (screen.cur.row >= 0); 1008 assert (screen.cur.row >= 0);
1000#endif
1001} 1009}
1002 1010
1003/* ------------------------------------------------------------------------- */ 1011/* ------------------------------------------------------------------------- */
1004/* 1012/*
1005 * Process Backspace. Move back the cursor back a position, wrap if have to 1013 * Process Backspace. Move back the cursor back a position, wrap if have to
1018 1026
1019 want_refresh = 1; 1027 want_refresh = 1;
1020#endif 1028#endif
1021 } 1029 }
1022 } 1030 }
1031 else if (screen.flags & Screen_WrapNext)
1032 screen.flags &= ~Screen_WrapNext;
1023 else 1033 else
1024 scr_gotorc (0, -1, RELATIVE); 1034 scr_gotorc (0, -1, RELATIVE);
1025} 1035}
1026 1036
1027/* ------------------------------------------------------------------------- */ 1037/* ------------------------------------------------------------------------- */
1333 if (row >= nrow) /* Out Of Bounds */ 1343 if (row >= nrow) /* Out Of Bounds */
1334 return; 1344 return;
1335 1345
1336 min_it (num, nrow - row); 1346 min_it (num, nrow - row);
1337 1347
1338 /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */
1339 if (rstyle & (RS_RVid | RS_Uline)) 1348 if (rstyle & (RS_Blink | RS_RVid | RS_Uline))
1340 ren = (rend_t) ~RS_None; 1349 ren = (rend_t) ~RS_None;
1341 else if (GET_BASEBG (rstyle) == Color_bg) 1350 else if (GET_BASEBG (rstyle) == Color_bg)
1342 { 1351 {
1343 ren = DEFAULT_RSTYLE; 1352 ren = DEFAULT_RSTYLE;
1344 1353
1345 if (mapped) 1354 if (mapped)
1346 XClearArea (dpy, vt, 0, 1355 XClearArea (dpy, vt, 0,
1347 Row2Pixel (row), (unsigned int)width, 1356 Row2Pixel (row - view_start), (unsigned int)width,
1348 (unsigned int)Height2Pixel (num), False); 1357 (unsigned int)Height2Pixel (num), False);
1349 } 1358 }
1350 else 1359 else
1351 { 1360 {
1352 ren = rstyle & (RS_fgMask | RS_bgMask); 1361 ren = rstyle & (RS_fgMask | RS_bgMask);
1353 1362
1363 if (mapped)
1364 {
1354 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1365 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1355 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1366 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1356 XFillRectangle (dpy, vt, gc, 1367 XFillRectangle (dpy, vt, gc,
1357 0, Row2Pixel (row), 1368 0, Row2Pixel (row - view_start),
1358 (unsigned int)width, 1369 (unsigned int)width,
1359 (unsigned int)Height2Pixel (num)); 1370 (unsigned int)Height2Pixel (num));
1360 gcvalue.foreground = pix_colors[Color_fg]; 1371 gcvalue.foreground = pix_colors[Color_fg];
1361 XChangeGC (dpy, gc, GCForeground, &gcvalue); 1372 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1373 }
1362 } 1374 }
1363 1375
1364 for (; num--; row++) 1376 for (; num--; row++)
1365 { 1377 {
1366 scr_blank_screen_mem (ROW(row), rstyle); 1378 scr_blank_screen_mem (ROW(row), rstyle);
1379
1380 if (row - view_start < nrow)
1367 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1381 scr_blank_line (drawn_buf [row - view_start], 0, ncol, ren);
1368 } 1382 }
1369} 1383}
1370 1384
1371#if !ENABLE_MINIMAL 1385#if !ENABLE_MINIMAL
1372void 1386void
1446 * Insert/Delete <count> characters from the current position 1460 * Insert/Delete <count> characters from the current position
1447 */ 1461 */
1448void 1462void
1449rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW 1463rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW
1450{ 1464{
1451 int col, row;
1452 rend_t tr;
1453
1454 want_refresh = 1; 1465 want_refresh = 1;
1455 ZERO_SCROLLBACK (); 1466 ZERO_SCROLLBACK ();
1456 1467
1457 if (count <= 0) 1468 if (count <= 0)
1458 return; 1469 return;
1460 scr_do_wrap (); 1471 scr_do_wrap ();
1461 1472
1462 selection_check (1); 1473 selection_check (1);
1463 min_it (count, ncol - screen.cur.col); 1474 min_it (count, ncol - screen.cur.col);
1464 1475
1465 row = screen.cur.row; 1476 int row = screen.cur.row;
1466 1477
1467 line_t *line = &ROW(row); 1478 line_t *line = &ROW(row);
1468 1479
1469 line->touch (); 1480 line->touch ();
1470 line->is_longer (0); 1481 line->is_longer (0);
1471 1482
1483 // nuke wide spanning the start
1484 if (line->t[screen.cur.col] == NOCHAR)
1485 scr_kill_char (*line, screen.cur.col);
1486
1472 switch (insdel) 1487 switch (insdel)
1473 { 1488 {
1474 case INSERT: 1489 case INSERT:
1475 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1490 line->l = min (line->l + count, ncol);
1491
1492 if (line->t[screen.cur.col] == NOCHAR)
1493 scr_kill_char (*line, screen.cur.col);
1494
1495 for (int col = ncol - 1; (col - count) >= screen.cur.col; col--)
1476 { 1496 {
1477 line->t[col] = line->t[col - count]; 1497 line->t[col] = line->t[col - count];
1478 line->r[col] = line->r[col - count]; 1498 line->r[col] = line->r[col - count];
1479 } 1499 }
1480
1481 line->l = min (line->l + count, ncol);
1482 1500
1483 if (selection.op && current_screen == selection.screen 1501 if (selection.op && current_screen == selection.screen
1484 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1502 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1485 { 1503 {
1486 if (selection.end.row != screen.cur.row 1504 if (selection.end.row != screen.cur.row
1501 case ERASE: 1519 case ERASE:
1502 screen.cur.col += count; /* don't worry if > ncol */ 1520 screen.cur.col += count; /* don't worry if > ncol */
1503 selection_check (1); 1521 selection_check (1);
1504 screen.cur.col -= count; 1522 screen.cur.col -= count;
1505 1523
1524 // nuke wide char after the end
1525 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1526 scr_kill_char (*line, screen.cur.col + count);
1527
1506 scr_blank_line (*line, screen.cur.col, count, rstyle); 1528 scr_blank_line (*line, screen.cur.col, count, rstyle);
1507 break; 1529 break;
1508 1530
1509 case DELETE: 1531 case DELETE:
1510 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1532 line->l = max (line->l - count, 0);
1511 1533
1534 // nuke wide char spanning the end
1535 if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR)
1536 scr_kill_char (*line, screen.cur.col + count);
1537
1512 for (col = screen.cur.col; (col + count) < ncol; col++) 1538 for (int col = screen.cur.col; (col + count) < ncol; col++)
1513 { 1539 {
1514 line->t[col] = line->t[col + count]; 1540 line->t[col] = line->t[col + count];
1515 line->r[col] = line->r[col + count]; 1541 line->r[col] = line->r[col + count];
1516 } 1542 }
1517 1543
1518 line->l = max (line->l - count, 0);
1519 scr_blank_line (*line, ncol - count, count, tr); 1544 scr_blank_line (*line, ncol - count, count, rstyle);
1520 1545
1521 if (selection.op && current_screen == selection.screen 1546 if (selection.op && current_screen == selection.screen
1522 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1547 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1523 { 1548 {
1524 if (selection.end.row != screen.cur.row 1549 if (selection.end.row != screen.cur.row
1814 for (i = PART_BEG; i < RC_COUNT; i++) 1839 for (i = PART_BEG; i < RC_COUNT; i++)
1815 { 1840 {
1816 min_it (rc[i].col, ncol - 1); 1841 min_it (rc[i].col, ncol - 1);
1817 min_it (rc[i].row, nrow - 1); 1842 min_it (rc[i].row, nrow - 1);
1818 } 1843 }
1819// TODO: this line somehow causes segfault if scr_expose() is called just after resize 1844
1820 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1845 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1821 fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); 1846 fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1822 1847
1823 num_scr_allow = 0; 1848 num_scr_allow = 0;
1824 1849
1915 1940
1916 bell_ev.start (VISUAL_BELL_DURATION); 1941 bell_ev.start (VISUAL_BELL_DURATION);
1917 } 1942 }
1918 else 1943 else
1919 XBell (dpy, 0); 1944 XBell (dpy, 0);
1945 HOOK_INVOKE ((this, HOOK_BELL, DT_END));
1920#endif 1946#endif
1921} 1947}
1922 1948
1923/* ------------------------------------------------------------------------- */ 1949/* ------------------------------------------------------------------------- */
1924/* ARGSUSED */ 1950/* ARGSUSED */
1943 row_start = view_start; 1969 row_start = view_start;
1944 } 1970 }
1945 1971
1946 wctomb (0, 0); 1972 wctomb (0, 0);
1947 1973
1948 for (int r1 = 0; r1 < nrows; r1++) 1974 for (int r1 = row_start; r1 < row_start + nrows; r1++)
1949 { 1975 {
1950 text_t *tp = ROW(r1).t; 1976 text_t *tp = ROW(r1).t;
1951 int len = ROW(r1).l; 1977 int len = ROW(r1).l;
1952 1978
1953 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN 1979 for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN
1982 * screen.text/screen.rend contain what the screen will change to. 2008 * screen.text/screen.rend contain what the screen will change to.
1983 */ 2009 */
1984void 2010void
1985rxvt_term::scr_refresh () NOTHROW 2011rxvt_term::scr_refresh () NOTHROW
1986{ 2012{
1987 unsigned char have_bg,
1988 showcursor; /* show the cursor */
1989 int16_t col, row, /* column/row we're processing */ 2013 int16_t col, row, /* column/row we're processing */
1990 ocrow; /* old cursor row */ 2014 ocrow; /* old cursor row */
1991 int i; /* tmp */ 2015 int i; /* tmp */
1992#ifndef NO_CURSORCOLOR 2016#ifndef NO_CURSORCOLOR
1993 rend_t cc1; /* store colours at cursor position (s) */ 2017 rend_t cc1; /* store colours at cursor position (s) */
2004 /* 2028 /*
2005 * A: set up vars 2029 * A: set up vars
2006 */ 2030 */
2007 refresh_count = 0; 2031 refresh_count = 0;
2008 2032
2033 unsigned int old_screen_flags = screen.flags;
2009 have_bg = 0; 2034 char have_bg = 0;
2010#ifdef HAVE_BG_PIXMAP 2035#ifdef HAVE_BG_PIXMAP
2011 have_bg = bgPixmap.pixmap != None; 2036 have_bg = bgPixmap.pixmap != None;
2012#endif 2037#endif
2013 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2038 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2014 2039
2015 /* 2040 /*
2016 * B: reverse any characters which are selected 2041 * B: reverse any characters which are selected
2017 */ 2042 */
2018 scr_reverse_selection (); 2043 scr_reverse_selection ();
2044
2045 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2046#if ENABLE_OVERLAY
2047 scr_swap_overlay ();
2048#endif
2049
2050 char showcursor = screen.flags & Screen_VisibleCursor;
2019 2051
2020 /* 2052 /*
2021 * C: set the cursor character (s) 2053 * C: set the cursor character (s)
2022 */ 2054 */
2023 { 2055 {
2024 unsigned char setoldcursor; 2056 unsigned char setoldcursor;
2025 2057
2026 showcursor = (screen.flags & Screen_VisibleCursor);
2027#ifdef CURSOR_BLINK 2058#ifdef CURSOR_BLINK
2028 if (hidden_cursor) 2059 if (hidden_cursor)
2029 showcursor = 0; 2060 showcursor = 0;
2030#endif 2061#endif
2031 2062
2059 ccol2 = bgcolor_of (rstyle); 2090 ccol2 = bgcolor_of (rstyle);
2060#else 2091#else
2061 ccol2 = Color_bg; 2092 ccol2 = Color_bg;
2062#endif 2093#endif
2063 2094
2064 if (showcursor && focus) 2095 if (focus)
2065 { 2096 {
2066 if (option (Opt_cursorUnderline)) 2097 if (option (Opt_cursorUnderline))
2067 *crp ^= RS_Uline; 2098 *crp ^= RS_Uline;
2068 else 2099 else
2069 { 2100 {
2104 oldcursor.col = screen.cur.col; 2135 oldcursor.col = screen.cur.col;
2105 } 2136 }
2106 } 2137 }
2107 } 2138 }
2108 2139
2109 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2110#if ENABLE_OVERLAY
2111 scr_swap_overlay ();
2112#endif
2113
2114#ifndef NO_SLOW_LINK_SUPPORT 2140#ifndef NO_SLOW_LINK_SUPPORT
2115 /* 2141 /*
2116 * D: CopyArea pass - very useful for slower links 2142 * D: CopyArea pass - very useful for slower links
2117 * This has been deliberately kept simple. 2143 * This has been deliberately kept simple.
2118 */ 2144 */
2210 2236
2211 // seek to the beginning of wide characters 2237 // seek to the beginning of wide characters
2212 while (expect_false (stp[col] == NOCHAR && col > 0)) 2238 while (expect_false (stp[col] == NOCHAR && col > 0))
2213 --col; 2239 --col;
2214 2240
2215 rend_t rend = srp[col]; /* screen rendition (target rendtion) */ 2241 rend_t rend = srp[col]; /* screen rendition (target rendition) */
2216 text_t *text = stp + col; 2242 text_t *text = stp + col;
2217 int count = 1; 2243 int count = 1;
2218 2244
2219 dtp[col] = stp[col]; 2245 dtp[col] = stp[col];
2220 drp[col] = rend; 2246 drp[col] = rend;
2224 for (i = 0; ++col < ncol; ) 2250 for (i = 0; ++col < ncol; )
2225 { 2251 {
2226 if (stp[col] == NOCHAR) 2252 if (stp[col] == NOCHAR)
2227 { 2253 {
2228 dtp[col] = stp[col]; 2254 dtp[col] = stp[col];
2229 drp[col] = rend; 2255 drp[col] = srp[col];
2256
2230 count++; 2257 count++;
2231 i++; 2258 i++;
2232 2259
2233 continue; 2260 continue;
2234 } 2261 }
2264 */ 2291 */
2265 int fore = fgcolor_of (rend); // desired foreground 2292 int fore = fgcolor_of (rend); // desired foreground
2266 int back = bgcolor_of (rend); // desired background 2293 int back = bgcolor_of (rend); // desired background
2267 2294
2268 // only do special processing if any attributes are set, which is unlikely 2295 // only do special processing if any attributes are set, which is unlikely
2269 if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) 2296 if (expect_false (rend & (RS_baseattrMask | RS_Careful | RS_Sel)))
2270 { 2297 {
2271 bool invert = rend & RS_RVid; 2298 bool invert = rend & RS_RVid;
2272 2299
2273#ifndef NO_BOLD_UNDERLINE_REVERSE 2300#ifndef NO_BOLD_UNDERLINE_REVERSE
2274 if (rend & RS_Bold && fore == Color_fg) 2301 if (rend & RS_Bold && fore == Color_fg)
2293 2320
2294 if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) 2321 if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL))
2295 fore = Color_UL; 2322 fore = Color_UL;
2296#endif 2323#endif
2297 2324
2325#ifdef OPTION_HC
2326 if (rend & RS_Sel)
2327 {
2328 /* invert the column if no highlightColor is set or it is the
2329 * current cursor column */
2330 if (!(showcursor && row == screen.cur.row && text - stp == screen.cur.col)
2331 && ISSET_PIXCOLOR (Color_HC))
2332 {
2333 if (ISSET_PIXCOLOR (Color_HTC))
2334 fore = Color_HTC;
2335 // if invert is 0 reverse video is set so we use bg color as fg color
2336 else if (!invert)
2337 fore = back;
2338
2339 back = Color_HC;
2340 invert = 0;
2341 }
2342 }
2343#endif
2344
2298 if (invert) 2345 if (invert)
2299 { 2346 {
2300#ifdef OPTION_HC
2301 if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col)
2302 || !ISSET_PIXCOLOR (Color_HC))
2303#endif
2304 /* invert the column if no highlightColor is set or it is the
2305 * current cursor column */
2306 ::swap (fore, back); 2347 ::swap (fore, back);
2307#ifdef OPTION_HC
2308 else if (ISSET_PIXCOLOR (Color_HC))
2309 back = Color_HC;
2310#endif
2311 2348
2312#ifndef NO_BOLD_UNDERLINE_REVERSE 2349#ifndef NO_BOLD_UNDERLINE_REVERSE
2313# ifndef OPTION_HC
2314 if (ISSET_PIXCOLOR (Color_RV))
2315 back = Color_RV;
2316# endif
2317 if (fore == back) 2350 if (fore == back)
2318 { 2351 {
2319 fore = Color_bg; 2352 fore = Color_bg;
2320 back = Color_fg; 2353 back = Color_fg;
2321 } 2354 }
2390 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2423 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2391 } 2424 }
2392 } /* for (col....) */ 2425 } /* for (col....) */
2393 } /* for (row....) */ 2426 } /* for (row....) */
2394 2427
2395#if ENABLE_OVERLAY
2396 scr_swap_overlay ();
2397#endif
2398 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2399
2400 /* 2428 /*
2401 * G: cleanup cursor and display outline cursor if necessary 2429 * G: cleanup cursor and display outline cursor if necessary
2402 */ 2430 */
2403 if (showcursor) 2431 if (showcursor)
2404 { 2432 {
2442 } 2470 }
2443 2471
2444 /* 2472 /*
2445 * H: cleanup selection 2473 * H: cleanup selection
2446 */ 2474 */
2475#if ENABLE_OVERLAY
2476 scr_swap_overlay ();
2477#endif
2478 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2479
2447 scr_reverse_selection (); 2480 scr_reverse_selection ();
2448 2481
2482 screen.flags = old_screen_flags;
2449 num_scr = 0; 2483 num_scr = 0;
2450 num_scr_allow = 1; 2484 num_scr_allow = 1;
2451} 2485}
2452 2486
2453void 2487void
2573 { 2607 {
2574#if !ENABLE_MINIMAL 2608#if !ENABLE_MINIMAL
2575 if (selection.rect) 2609 if (selection.rect)
2576 scr_xor_rect (selection.beg.row, selection.beg.col, 2610 scr_xor_rect (selection.beg.row, selection.beg.col,
2577 selection.end.row, selection.end.col, 2611 selection.end.row, selection.end.col,
2578 RS_RVid, RS_RVid | RS_Uline); 2612 RS_Sel | RS_RVid, RS_Sel | RS_RVid | RS_Uline);
2579 else 2613 else
2580#endif 2614#endif
2581 scr_xor_span (selection.beg.row, selection.beg.col, 2615 scr_xor_span (selection.beg.row, selection.beg.col,
2582 selection.end.row, selection.end.col, 2616 selection.end.row, selection.end.col,
2583 RS_RVid); 2617 RS_Sel | RS_RVid);
2584 } 2618 }
2585} 2619}
2586 2620
2587/* ------------------------------------------------------------------------- */ 2621/* ------------------------------------------------------------------------- */
2588/* 2622/*
2593void 2627void
2594rxvt_term::scr_dump (int fd) NOTHROW 2628rxvt_term::scr_dump (int fd) NOTHROW
2595{ 2629{
2596 int row, wrote; 2630 int row, wrote;
2597 unsigned int width, towrite; 2631 unsigned int width, towrite;
2598 char r1[] = "\n"; 2632 const char r1[] = "\n";
2599 2633
2600 for (row = saveLines + top_row; 2634 for (row = saveLines + top_row;
2601 row < saveLines + nrow - 1; row++) 2635 row < saveLines + nrow - 1; row++)
2602 { 2636 {
2603 width = row_buf[row].l >= 0 ? row_buf[row].l 2637 width = row_buf[row].l >= 0 ? row_buf[row].l
2649/* ------------------------------------------------------------------------- */ 2683/* ------------------------------------------------------------------------- */
2650/* 2684/*
2651 * Paste a selection direct to the command fd 2685 * Paste a selection direct to the command fd
2652 */ 2686 */
2653void 2687void
2654rxvt_term::paste (char *data, unsigned int len) NOTHROW 2688rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW
2655{ 2689{
2656 /* convert normal newline chars into common keyboard Return key sequence */ 2690 /* convert normal newline chars into common keyboard Return key sequence */
2657 for (unsigned int i = 0; i < len; i++) 2691 for (unsigned int i = 0; i < len; i++)
2658 if (data[i] == C0_LF) 2692 if (data[i] == C0_LF)
2659 data[i] = C0_CR; 2693 data[i] = C0_CR;
2663 2697
2664 tt_write (data, len); 2698 tt_write (data, len);
2665 2699
2666 if (priv_modes & PrivMode_BracketPaste) 2700 if (priv_modes & PrivMode_BracketPaste)
2667 tt_printf ("\e[201~"); 2701 tt_printf ("\e[201~");
2702}
2703
2704void
2705rxvt_term::paste (char *data, unsigned int len) NOTHROW
2706{
2707 if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END)))
2708 return;
2709
2710 tt_paste (data, len);
2668} 2711}
2669 2712
2670/* ------------------------------------------------------------------------- */ 2713/* ------------------------------------------------------------------------- */
2671/* 2714/*
2672 * Respond to a notification that a primary selection has been sent 2715 * Respond to a notification that a primary selection has been sent
2881 selection_wait = Sel_normal; 2924 selection_wait = Sel_normal;
2882 2925
2883#if X_HAVE_UTF8_STRING 2926#if X_HAVE_UTF8_STRING
2884 selection_type = Sel_UTF8String; 2927 selection_type = Sel_UTF8String;
2885 if (selection_request_other (xa[XA_UTF8_STRING], selnum)) 2928 if (selection_request_other (xa[XA_UTF8_STRING], selnum))
2886 return; 2929 return;
2887#else 2930#else
2888 selection_type = Sel_CompoundText; 2931 selection_type = Sel_CompoundText;
2889 if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) 2932 if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum))
2890 return; 2933 return;
2891#endif 2934#endif
2892 } 2935 }
2893 2936
2894 selection_wait = Sel_none; /* don't loop in selection_paste () */ 2937 selection_wait = Sel_none; /* don't loop in selection_paste () */
2895 selection_paste (display->root, XA_CUT_BUFFER0, false); 2938 selection_paste (display->root, XA_CUT_BUFFER0, false);
2923/* 2966/*
2924 * Clear all selected text 2967 * Clear all selected text
2925 * EXT: SelectionClear 2968 * EXT: SelectionClear
2926 */ 2969 */
2927void 2970void
2928rxvt_term::selection_clear () NOTHROW 2971rxvt_term::selection_clear (bool clipboard) NOTHROW
2929{ 2972{
2973 if (!clipboard)
2974 {
2930 want_refresh = 1; 2975 want_refresh = 1;
2931 free (selection.text); 2976 free (selection.text);
2932 selection.text = NULL; 2977 selection.text = NULL;
2933 selection.len = 0; 2978 selection.len = 0;
2934 CLEAR_SELECTION (); 2979 CLEAR_SELECTION ();
2935 2980
2936 if (display->selection_owner == this) 2981 if (display->selection_owner == this)
2937 display->selection_owner = 0; 2982 display->selection_owner = 0;
2983 }
2984 else
2985 {
2986 free (selection.clip_text);
2987 selection.clip_text = NULL;
2988 selection.clip_len = 0;
2989
2990 if (display->clipboard_owner == this)
2991 display->clipboard_owner = 0;
2992 }
2938} 2993}
2939 2994
2940/* ------------------------------------------------------------------------- */ 2995/* ------------------------------------------------------------------------- */
2941/* 2996/*
2942 * Copy a selection into the cut buffer 2997 * Copy a selection into the cut buffer
2943 * EXT: button 1 or 3 release 2998 * EXT: button 1 or 3 release
2944 */ 2999 */
2945void 3000void
2946rxvt_term::selection_make (Time tm) 3001rxvt_term::selection_make (Time tm)
2947{ 3002{
2948 int i; 3003 int size;
2949 wchar_t *new_selection_text; 3004 wchar_t *new_selection_text;
2950 text_t *t; 3005 text_t *t;
2951 3006
2952 switch (selection.op) 3007 switch (selection.op)
2953 { 3008 {
2969 return; /* nothing selected, go away */ 3024 return; /* nothing selected, go away */
2970 3025
2971 if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) 3026 if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2972 return; 3027 return;
2973 3028
2974 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 3029 size = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2975 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 3030 new_selection_text = (wchar_t *)rxvt_malloc ((size + 4) * sizeof (wchar_t));
2976 3031
2977 int ofs = 0; 3032 int ofs = 0;
2978 int extra = 0; 3033 int extra = 0;
2979 3034
2980 int col = selection.beg.col; 3035 int col = selection.beg.col;
2986 { 3041 {
2987#if !ENABLE_MINIMAL 3042#if !ENABLE_MINIMAL
2988 if (selection.rect) 3043 if (selection.rect)
2989 { 3044 {
2990 col = selection.beg.col; 3045 col = selection.beg.col;
2991 end_col = ncol + 1; 3046 end_col = selection.end.col;
2992 } 3047 }
2993 else 3048 else
2994#endif 3049#endif
2995 end_col = ROW(row).l; 3050 end_col = ROW(row).l;
2996 3051
2997 col = max (col, 0); 3052 col = max (col, 0);
2998 3053
2999 if (row == selection.end.row 3054 if (row == selection.end.row)
3000#if !ENABLE_MINIMAL
3001 || selection.rect
3002#endif
3003 )
3004 min_it (end_col, selection.end.col); 3055 min_it (end_col, selection.end.col);
3005 3056
3006 t = ROW(row).t + col; 3057 t = ROW(row).t + col;
3007 3058
3008 for (; col < end_col; col++) 3059 for (; col < end_col; col++)
3016 3067
3017 extra -= (len - 1); 3068 extra -= (len - 1);
3018 3069
3019 if (extra < 0) 3070 if (extra < 0)
3020 { 3071 {
3021 extra += i; 3072 extra += size;
3022 i += i; 3073 size += size;
3023 new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (i + 4) * sizeof (wchar_t)); 3074 new_selection_text = (wchar_t *)rxvt_realloc (new_selection_text, (size + 4) * sizeof (wchar_t));
3024 } 3075 }
3025 3076
3026 ofs += rxvt_composite.expand (*t++, new_selection_text + ofs); 3077 ofs += rxvt_composite.expand (*t++, new_selection_text + ofs);
3027 } 3078 }
3028#endif 3079#endif
3040 3091
3041 new_selection_text[ofs++] = C0_LF; 3092 new_selection_text[ofs++] = C0_LF;
3042 } 3093 }
3043 else 3094 else
3044#endif 3095#endif
3045 if (!ROW(row).is_longer () && row != selection.end.row) 3096 if (!ROW(row).is_longer () && row != selection.end.row
3097 && (row != selection.beg.row || selection.beg.col < ncol))
3046 new_selection_text[ofs++] = C0_LF; 3098 new_selection_text[ofs++] = C0_LF;
3047 } 3099 }
3048 3100
3049 if (end_col != selection.end.col) 3101 if (end_col != selection.end.col)
3050 new_selection_text[ofs++] = C0_LF; 3102 new_selection_text[ofs++] = C0_LF;
3068 3120
3069 selection_grab (tm); 3121 selection_grab (tm);
3070} 3122}
3071 3123
3072bool 3124bool
3073rxvt_term::selection_grab (Time tm) NOTHROW 3125rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW
3074{ 3126{
3127 Atom sel;
3128
3129 if (!clipboard)
3130 {
3075 selection_time = tm; 3131 selection_time = tm;
3132 sel = XA_PRIMARY;
3133 }
3134 else
3135 {
3136 clipboard_time = tm;
3137 sel = xa[XA_CLIPBOARD];
3138 }
3076 3139
3077 XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); 3140 XSetSelectionOwner (dpy, sel, vt, tm);
3078 if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) 3141 if (XGetSelectionOwner (dpy, sel) == vt)
3079 { 3142 {
3080 display->set_selection_owner (this); 3143 display->set_selection_owner (this, clipboard);
3081 return true; 3144 return true;
3082 } 3145 }
3083 else 3146 else
3084 { 3147 {
3085 selection_clear (); 3148 selection_clear (clipboard);
3086 return false; 3149 return false;
3087 } 3150 }
3088 3151
3089#if 0 3152#if 0
3090 XTextProperty ct; 3153 XTextProperty ct;
3585 else if (rq.target == xa[XA_MULTIPLE]) 3648 else if (rq.target == xa[XA_MULTIPLE])
3586 { 3649 {
3587 /* TODO: Handle MULTIPLE */ 3650 /* TODO: Handle MULTIPLE */
3588 } 3651 }
3589#endif 3652#endif
3590 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3653 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == XA_PRIMARY && selection.text)
3591 { 3654 {
3592 XChangeProperty (dpy, rq.requestor, rq.property, rq.target, 3655 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3593 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3656 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3657 ev.property = rq.property;
3658 }
3659 else if (rq.target == xa[XA_TIMESTAMP] && rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
3660 {
3661 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3662 32, PropModeReplace, (unsigned char *)&clipboard_time, 1);
3594 ev.property = rq.property; 3663 ev.property = rq.property;
3595 } 3664 }
3596 else if (rq.target == XA_STRING 3665 else if (rq.target == XA_STRING
3597 || rq.target == xa[XA_TEXT] 3666 || rq.target == xa[XA_TEXT]
3598 || rq.target == xa[XA_COMPOUND_TEXT] 3667 || rq.target == xa[XA_COMPOUND_TEXT]
3631 { 3700 {
3632 target = xa[XA_COMPOUND_TEXT]; 3701 target = xa[XA_COMPOUND_TEXT];
3633 style = enc_compound_text; 3702 style = enc_compound_text;
3634 } 3703 }
3635 3704
3636 if (selection.text) 3705 if (rq.selection == XA_PRIMARY && selection.text)
3637 { 3706 {
3638 cl = selection.text; 3707 cl = selection.text;
3639 selectlen = selection.len; 3708 selectlen = selection.len;
3709 }
3710 else if (rq.selection == xa[XA_CLIPBOARD] && selection.clip_text)
3711 {
3712 cl = selection.clip_text;
3713 selectlen = selection.clip_len;
3640 } 3714 }
3641 else 3715 else
3642 { 3716 {
3643 cl = L""; 3717 cl = L"";
3644 selectlen = 0; 3718 selectlen = 0;
3712 h += 2; min_it (h, nrow); 3786 h += 2; min_it (h, nrow);
3713 3787
3714 x -= 1; clamp_it (x, 0, ncol - w); 3788 x -= 1; clamp_it (x, 0, ncol - w);
3715 y -= 1; clamp_it (y, 0, nrow - h); 3789 y -= 1; clamp_it (y, 0, nrow - h);
3716 3790
3717 ov_x = x; ov_y = y; 3791 ov.x = x; ov.y = y;
3718 ov_w = w; ov_h = h; 3792 ov.w = w; ov.h = h;
3719 3793
3720 ov_text = new text_t *[h]; 3794 ov.text = new text_t *[h];
3721 ov_rend = new rend_t *[h]; 3795 ov.rend = new rend_t *[h];
3722 3796
3723 for (y = 0; y < h; y++) 3797 for (y = 0; y < h; y++)
3724 { 3798 {
3725 text_t *tp = ov_text[y] = new text_t[w]; 3799 text_t *tp = ov.text[y] = new text_t[w];
3726 rend_t *rp = ov_rend[y] = new rend_t[w]; 3800 rend_t *rp = ov.rend[y] = new rend_t[w];
3727 3801
3728 text_t t0, t1, t2; 3802 text_t t0, t1, t2;
3729 rend_t r = OVERLAY_RSTYLE; 3803 rend_t r = OVERLAY_RSTYLE;
3730 3804
3731 if (y == 0) 3805 if (y == 0)
3750} 3824}
3751 3825
3752void 3826void
3753rxvt_term::scr_overlay_off () NOTHROW 3827rxvt_term::scr_overlay_off () NOTHROW
3754{ 3828{
3755 if (!ov_text) 3829 if (!ov.text)
3756 return; 3830 return;
3757 3831
3758 want_refresh = 1; 3832 want_refresh = 1;
3759 3833
3760 for (int y = 0; y < ov_h; y++) 3834 for (int y = 0; y < ov.h; y++)
3761 { 3835 {
3762 delete [] ov_text[y]; 3836 delete [] ov.text[y];
3763 delete [] ov_rend[y]; 3837 delete [] ov.rend[y];
3764 } 3838 }
3765 3839
3766 delete [] ov_text; ov_text = 0; 3840 delete [] ov.text; ov.text = 0;
3767 delete [] ov_rend; ov_rend = 0; 3841 delete [] ov.rend; ov.rend = 0;
3768} 3842}
3769 3843
3770void 3844void
3771rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW 3845rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW
3772{ 3846{
3773 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3847 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3774 return; 3848 return;
3775 3849
3776 x++, y++; 3850 x++, y++;
3777 3851
3778 ov_text[y][x] = text; 3852 ov.text[y][x] = text;
3779 ov_rend[y][x] = rend; 3853 ov.rend[y][x] = rend;
3780} 3854}
3781 3855
3782void 3856void
3783rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW 3857rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW
3784{ 3858{
3803} 3877}
3804 3878
3805void 3879void
3806rxvt_term::scr_swap_overlay () NOTHROW 3880rxvt_term::scr_swap_overlay () NOTHROW
3807{ 3881{
3808 if (!ov_text) 3882 if (!ov.text)
3809 return; 3883 return;
3810 3884
3885 // hide cursor if it is within the overlay area
3886 if (IN_RANGE_EXC (screen.cur.col - ov.x, 0, ov.w)
3887 && IN_RANGE_EXC (screen.cur.row - ov.y, 0, ov.h))
3888 screen.flags &= ~Screen_VisibleCursor;
3889
3811 // swap screen mem with overlay 3890 // swap screen mem with overlay
3812 for (int y = ov_h; y--; ) 3891 for (int y = ov.h; y--; )
3813 { 3892 {
3814 text_t *t1 = ov_text[y]; 3893 text_t *t1 = ov.text[y];
3815 rend_t *r1 = ov_rend[y]; 3894 rend_t *r1 = ov.rend[y];
3816 3895
3817 text_t *t2 = ROW(y + ov_y + view_start).t + ov_x; 3896 text_t *t2 = ROW(y + ov.y + view_start).t + ov.x;
3818 rend_t *r2 = ROW(y + ov_y + view_start).r + ov_x; 3897 rend_t *r2 = ROW(y + ov.y + view_start).r + ov.x;
3819 3898
3820 for (int x = ov_w; x--; ) 3899 for (int x = ov.w; x--; )
3821 { 3900 {
3822 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3901 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3823 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3902 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));
3824 } 3903 }
3825 } 3904 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines