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.187 by root, Wed Dec 21 23:57:12 2005 UTC vs.
Revision 1.203 by root, Sat Dec 31 19:30:25 2005 UTC

46 46
47/* ------------------------------------------------------------------------- * 47/* ------------------------------------------------------------------------- *
48 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * 48 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES *
49 * ------------------------------------------------------------------------- */ 49 * ------------------------------------------------------------------------- */
50#define ZERO_SCROLLBACK() \ 50#define ZERO_SCROLLBACK() \
51 if (options & Opt_scrollTtyOutput) \ 51 if (OPTION (Opt_scrollTtyOutput)) \
52 view_start = 0 52 view_start = 0
53#define CLEAR_SELECTION() \ 53#define CLEAR_SELECTION() \
54 selection.beg.row = selection.beg.col \ 54 selection.beg.row = selection.beg.col \
55 = selection.end.row = selection.end.col = 0 55 = selection.end.row = selection.end.col = 0
56#define CLEAR_ALL_SELECTION() \ 56#define CLEAR_ALL_SELECTION() \
271 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); 271 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE);
272 } 272 }
273 273
274 line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t)); 274 line_t *old_buf = row_buf; row_buf = (line_t *)rxvt_calloc (total_rows, sizeof (line_t));
275 275
276 // re-wrap lines, this is rather ugly, possibly because I am too dumb
277 // to come up with a lean and mean algorithm.
278
279 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 276 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
280 int pend = MOD (term_start - nsaved , prev_total_rows); 277 int pend = MOD (term_start - nsaved , prev_total_rows);
281 int q = total_rows; // rewrapped row 278 int q = total_rows; // rewrapped row
282 279
283 while (p != pend && q > 0) 280 if (nsaved)
281 {
282 // re-wrap lines, this is rather ugly, possibly because I am too dumb
283 // to come up with a lean and mean algorithm.
284
285 row_col_t ocur = screen.cur;
286 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
287
284 { 288 do
285 p = MOD (p - 1, prev_total_rows);
286#ifdef DEBUG_STRICT
287 assert (old_buf [MOD (p, prev_total_rows)].t);
288#endif
289
290 int llen = old_buf [MOD (p, prev_total_rows)].l;
291
292 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
293 { 289 {
294 p = MOD (p - 1, prev_total_rows); 290 p = MOD (p - 1, prev_total_rows);
291#ifdef DEBUG_STRICT
292 assert (old_buf [MOD (p, prev_total_rows)].t);
293#endif
295 294
295 int plines = 1;
296 int llen = old_buf [MOD (p, prev_total_rows)].l;
297
298 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
299 {
300 p = MOD (p - 1, prev_total_rows);
301
302 plines++;
296 llen += prev_ncol; 303 llen += prev_ncol;
304 }
305
306 int qlines = max (0, (llen - 1) / ncol) + 1;
307
308 // drop partial lines completely
309 if (q < qlines)
310 break;
311
312 q -= qlines;
313
314 int lofs = 0;
315 line_t *qline;
316
317 // re-assemble the full line by destination lines
318 for (int qrow = q; qlines--; qrow++)
319 {
320 qline = row_buf + qrow;
321 lalloc (*qline);
322 qline->set_is_longer ();
323
324 int qcol = 0;
325
326 // fill a single destination line
327 while (lofs < llen && qcol < ncol)
328 {
329 int prow = lofs / prev_ncol;
330 int pcol = lofs % prev_ncol;
331
332 prow = MOD (p + prow, prev_total_rows);
333
334 // we only adjust the cursor _row_ and put it into
335 // the topmost line of "long line" it was in, as
336 // this seems to upset applications/shells/readline
337 // least.
338 if (prow == ocur.row)
339 screen.cur.row = q - (total_rows - nrow);
340
341 line_t &pline = old_buf [prow];
342
343 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
344
345 assert (len);
346 assert (pline.t);
347
348 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
349 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
350
351 lofs += len;
352 qcol += len;
353 }
354 }
355
356 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0;
357#ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY
358 if (qline->l < 0)
359 {
360 fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D
361 qline->l = 0;
362 }
363#endif
364 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
297 } 365 }
366 while (p != pend && q > 0);
298 367
299 int qlines = max (0, (llen - 1) / ncol) + 1; 368 term_start = total_rows - nrow;
369 nsaved = term_start - q;
370
371 // make sure all terminal lines exist
372 while (nsaved < 0)
373 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
300 374
301 // drop partial lines completely 375 }
302 if (q < qlines) 376 else
303 break; 377 {
304 378 // if no scrollback exists (yet), wing, instead of wrap
305 q -= qlines; 379
306 380 for (int row = min (nrow, prev_nrow); row--; )
307 int lofs = 0;
308 line_t *qline;
309
310 // re-assemble the full line by destination lines
311 for (int qrow = q; qlines--; qrow++)
312 { 381 {
313 qline = row_buf + qrow;
314 lalloc (*qline);
315 qline->set_is_longer ();
316
317 int qcol = 0;
318
319 // fill a single destination line
320 while (lofs < llen && qcol < ncol)
321 {
322 int prow = lofs / prev_ncol;
323 int pcol = lofs % prev_ncol;
324
325 line_t &pline = old_buf [MOD (p + prow, prev_total_rows)]; 382 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)];
383 line_t &qline = row_buf [row];
326 384
327 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); 385 qline = pline;
328 386 lresize (qline);
329 assert (len);
330 assert (pline.t);
331
332 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
333 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
334
335 lofs += len;
336 qcol += len;
337 }
338 } 387 }
339 388
340 qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; 389 for (int row = prev_nrow; row < nrow; row++)
341 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 390 {
391 row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
342 } 392 }
343 393
344 term_start = total_rows - nrow;
345 view_start = 0; 394 term_start = 0;
346 nsaved = term_start - q; 395 }
347 396
348 // make sure all terminal lines exist 397#ifdef DEBUG_STRICT //TODO: remove
349 while (nsaved < 0)
350 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
351
352 for (int i = -nsaved; i < nrow; i++) 398 for (int i = -nsaved; i < nrow; i++)
353 assert (ROW (i).t);//D 399 assert (ROW (i).t);
400#endif
354 401
355 free (old_buf); 402 free (old_buf);
356 delete old_ta; 403 delete old_ta;
357 delete old_ra; 404 delete old_ra;
358 405
359 min_it (screen.cur.row, nrow - 1); 406 clamp_it (screen.cur.row, 0, nrow - 1);
360 min_it (screen.cur.col, ncol - 1); 407 clamp_it (screen.cur.col, 0, ncol - 1);
361 408
362 if (tabs) 409 if (tabs)
363 free (tabs); 410 free (tabs);
364 } 411 }
365 412
483 530
484 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); 531 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
485 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); 532 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
486 533
487#if NSCREENS 534#if NSCREENS
488 if (options & Opt_secondaryScreen) 535 if (OPTION (Opt_secondaryScreen))
489 { 536 {
490 num_scr = 0; 537 num_scr = 0;
491 538
492 for (int i = nrow; i--; ) 539 for (int i = prev_nrow; i--; )
493 ::swap (ROW(i), swap_buf [i]); 540 ::swap (ROW(i), swap_buf [i]);
494 541
495 ::swap (screen.charset, swap.charset); 542 ::swap (screen.charset, swap.charset);
496 ::swap (screen.flags, swap.flags); 543 ::swap (screen.flags, swap.flags);
497 screen.flags |= Screen_VisibleCursor; 544 screen.flags |= Screen_VisibleCursor;
498 swap.flags |= Screen_VisibleCursor; 545 swap.flags |= Screen_VisibleCursor;
499 } 546 }
500 else 547 else
501#endif 548#endif
502 if (options & Opt_secondaryScroll) 549 if (OPTION (Opt_secondaryScroll))
503 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 550 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
504 551
505 return scrn; 552 return scrn;
506} 553}
507 554
569 num_scr += count; 616 num_scr += count;
570 617
571 if (count > 0 618 if (count > 0
572 && row1 == 0 619 && row1 == 0
573 && row2 == nrow - 1 620 && row2 == nrow - 1
574 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 621 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
575 { 622 {
576 nsaved = min (nsaved + count, saveLines); 623 nsaved = min (nsaved + count, saveLines);
577 term_start = (term_start + count) % total_rows; 624 term_start = (term_start + count) % total_rows;
578 625
579 if (selection.op && current_screen == selection.screen) 626 if (selection.op && current_screen == selection.screen)
580 { 627 {
581 selection.beg.row -= count; 628 selection.beg.row -= count;
582 selection.end.row -= count; 629 selection.end.row -= count;
583 selection.mark.row -= count; 630 selection.mark.row -= count;
584 631
585 selection_check (0); 632 if (selection.beg.row < -nsaved
633 || selection.end.row < -nsaved
634 || selection.mark.row < -nsaved)
635 {
636 CLEAR_ALL_SELECTION ();
637 selection.op = SELECTION_CLEAR;
638 }
586 } 639 }
587 640
588 for (int i = count; i--; ) 641 for (int i = count; i--; )
642 {
643 ROW(row2 - i).l = 0;
589 scr_blank_screen_mem (ROW(row2 - i), rstyle); 644 scr_blank_screen_mem (ROW(row2 - i), rstyle);
645 }
590 646
591 if ((options & Opt_scrollWithBuffer) 647 if (OPTION (Opt_scrollWithBuffer)
592 && view_start != 0 648 && view_start != 0
593 && view_start != saveLines) 649 && view_start != saveLines)
594 scr_page (UP, count); 650 scr_page (UP, count);
595 } 651 }
596 else 652 else
597 { 653 {
598 if (selection.op && current_screen == selection.screen) 654 if (selection.op && current_screen == selection.screen)
599 { 655 {
600 int i = selection.beg.row; 656 if ((selection.beg.row < row1 && selection.end.row > row1)
601 int j = selection.end.row; 657 || (selection.beg.row < row2 && selection.end.row > row2)
602
603 if ((i < row1 && j > row1)
604 || (i < row2 && j > row2)
605 || (i - count < row1 && i >= row1) 658 || (selection.beg.row - count < row1 && selection.beg.row >= row1)
606 || (i - count > row2 && i <= row2) 659 || (selection.beg.row - count > row2 && selection.beg.row <= row2)
607 || (j - count < row1 && j >= row1) 660 || (selection.end.row - count < row1 && selection.end.row >= row1)
608 || (j - count > row2 && j <= row2)) 661 || (selection.end.row - count > row2 && selection.end.row <= row2))
609 { 662 {
610 CLEAR_ALL_SELECTION (); 663 CLEAR_ALL_SELECTION ();
611 selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ 664 selection.op = SELECTION_CLEAR;
612 } 665 }
613 else if (j >= row1 && j <= row2) 666 else if (selection.end.row >= row1 && selection.end.row <= row2)
614 { 667 {
615 /* move selected region too */ 668 /* move selected region too */
616 selection.beg.row -= count; 669 selection.beg.row -= count;
617 selection.end.row -= count; 670 selection.end.row -= count;
618 selection.mark.row -= count; 671 selection.mark.row -= count;
653 if (len <= 0) /* sanity */ 706 if (len <= 0) /* sanity */
654 return; 707 return;
655 708
656 unsigned char checksel; 709 unsigned char checksel;
657 unicode_t c; 710 unicode_t c;
658 int row, last_col; 711 int last_col;
659 const unicode_t *strend = str + len; 712 const unicode_t *strend = str + len;
660 713
661 want_refresh = 1; 714 want_refresh = 1;
662 ZERO_SCROLLBACK (); 715 ZERO_SCROLLBACK ();
663 last_col = ncol; 716 last_col = ncol;
678#ifdef DEBUG_STRICT 731#ifdef DEBUG_STRICT
679 assert (screen.cur.col < last_col); 732 assert (screen.cur.col < last_col);
680 assert (screen.cur.row < nrow 733 assert (screen.cur.row < nrow
681 && screen.cur.row >= -nsaved); 734 && screen.cur.row >= -nsaved);
682#endif 735#endif
683 row = screen.cur.row; 736 int row = screen.cur.row;
684 737
685 checksel = selection.op && current_screen == selection.screen ? 1 : 0; 738 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
686 739
687 line_t *line = &ROW(row); 740 line_t *line = &ROW(row);
688 741
690 { 743 {
691 c = *str++; 744 c = *str++;
692 745
693 if (c < 0x20) 746 if (c < 0x20)
694 if (c == C0_LF) 747 if (c == C0_LF)
695 { 748 {
696 if (!line->is_longer ()) /* XXX: think about this */ 749 if (!line->is_longer ()) /* XXX: think about this */
697 max_it (line->l, screen.cur.col); 750 max_it (line->l, screen.cur.col);
698 751
699 screen.flags &= ~Screen_WrapNext; 752 screen.flags &= ~Screen_WrapNext;
700 753
945 998
946 if (count == 0) 999 if (count == 0)
947 return; 1000 return;
948 else if (count > 0) 1001 else if (count > 0)
949 { 1002 {
950 int row = screen.cur.row;
951
952 line_t &l = ROW(row); 1003 line_t &l = ROW(screen.cur.row);
953 rend_t base_rend = l.r[i]; 1004 rend_t base_rend = l.r[i];
954 ht &= l.t[i] == ' '; 1005 ht &= l.t[i] == ' ';
955 1006
956 for (; ++i < ncol; ) 1007 for (; ++i < ncol; )
957 if (tabs[i]) 1008 if (tabs[i])
967 if (count) 1018 if (count)
968 x = ncol - 1; 1019 x = ncol - 1;
969 1020
970 // store horizontal tab commands as characters inside the text 1021 // store horizontal tab commands as characters inside the text
971 // buffer so they can be selected and pasted. 1022 // buffer so they can be selected and pasted.
972 if (ht && options & Opt_pastableTabs) 1023 if (ht && OPTION (Opt_pastableTabs))
973 { 1024 {
974 base_rend = SET_FONT (base_rend, 0); 1025 base_rend = SET_FONT (base_rend, 0);
975 1026
976 if (!l.is_longer ()) /* XXX: think about this */ 1027 if (!l.is_longer ()) /* XXX: think about this */
977 max_it (l.l, x); 1028 max_it (l.l, x);
1032 */ 1083 */
1033#if ENABLE_FRILLS 1084#if ENABLE_FRILLS
1034void 1085void
1035rxvt_term::scr_forwardindex () 1086rxvt_term::scr_forwardindex ()
1036{ 1087{
1037 int row;
1038
1039 if (screen.cur.col < ncol - 1) 1088 if (screen.cur.col < ncol - 1)
1040 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1089 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1041 else 1090 else
1042 { 1091 {
1043 row = screen.cur.row;
1044
1045 if (ROW(row).is_longer ()) //TODO//FIXME//LEN 1092 if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN
1046 ROW(row).l = ncol; 1093 ROW(screen.cur.row).l = ncol;
1047 1094
1048 scr_gotorc (0, 0, R_RELATIVE); 1095 scr_gotorc (0, 0, R_RELATIVE);
1049 scr_insdel_chars (1, DELETE); 1096 scr_insdel_chars (1, DELETE);
1050 scr_gotorc (0, ncol - 1, R_RELATIVE); 1097 scr_gotorc (0, ncol - 1, R_RELATIVE);
1051 } 1098 }
1134 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1181 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1135 */ 1182 */
1136void 1183void
1137rxvt_term::scr_erase_line (int mode) 1184rxvt_term::scr_erase_line (int mode)
1138{ 1185{
1139 unsigned int row, col, num; 1186 unsigned int col, num;
1140 1187
1141 want_refresh = 1; 1188 want_refresh = 1;
1142 ZERO_SCROLLBACK (); 1189 ZERO_SCROLLBACK ();
1143 1190
1144 selection_check (1); 1191 selection_check (1);
1145 1192
1146 row = screen.cur.row; 1193 line_t &line = ROW(screen.cur.row);
1147 1194
1148 switch (mode) 1195 switch (mode)
1149 { 1196 {
1150 case 0: /* erase to end of line */ 1197 case 0: /* erase to end of line */
1151 col = screen.cur.col; 1198 col = screen.cur.col;
1152 num = ncol - col; 1199 num = ncol - col;
1153 min_it (ROW(row).l, col); 1200 min_it (line.l, col);
1154 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) 1201 if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)
1155 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) 1202 || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur))
1156 CLEAR_SELECTION (); 1203 CLEAR_SELECTION ();
1157 break; 1204 break;
1158 case 1: /* erase to beginning of line */ 1205 case 1: /* erase to beginning of line */
1163 CLEAR_SELECTION (); 1210 CLEAR_SELECTION ();
1164 break; 1211 break;
1165 case 2: /* erase whole line */ 1212 case 2: /* erase whole line */
1166 col = 0; 1213 col = 0;
1167 num = ncol; 1214 num = ncol;
1168 ROW(row).l = 0; 1215 line.l = 0;
1169 if (selection.beg.row <= screen.cur.row 1216 if (selection.beg.row <= screen.cur.row
1170 && selection.end.row >= screen.cur.row) 1217 && selection.end.row >= screen.cur.row)
1171 CLEAR_SELECTION (); 1218 CLEAR_SELECTION ();
1172 break; 1219 break;
1173 default: 1220 default:
1174 return; 1221 return;
1175 } 1222 }
1176 1223
1177 scr_blank_line (ROW(row), col, num, rstyle); 1224 scr_blank_line (line, col, num, rstyle);
1178} 1225}
1179 1226
1180/* ------------------------------------------------------------------------- */ 1227/* ------------------------------------------------------------------------- */
1181/* 1228/*
1182 * Erase part of whole of the screen 1229 * Erase part of whole of the screen
1237 CLEAR_ROWS (row, num); 1284 CLEAR_ROWS (row, num);
1238 } 1285 }
1239 else 1286 else
1240 { 1287 {
1241 ren = rstyle & (RS_fgMask | RS_bgMask); 1288 ren = rstyle & (RS_fgMask | RS_bgMask);
1242 gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; 1289 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1243 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1290 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1244 ERASE_ROWS (row, num); 1291 ERASE_ROWS (row, num);
1245 gcvalue.foreground = pix_colors[Color_fg]; 1292 gcvalue.foreground = pix_colors[Color_fg];
1246 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1293 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1247 } 1294 }
1248 1295
1249 for (; num--; row++) 1296 for (; num--; row++)
1250 { 1297 {
1298 ROW (row).l = 0;
1251 scr_blank_screen_mem (ROW (row), rstyle); 1299 scr_blank_screen_mem (ROW (row), rstyle);
1252 ROW (row).l = 0;
1253 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1300 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1254 } 1301 }
1255} 1302}
1256 1303
1257#if ENABLE_FRILLS 1304#if ENABLE_FRILLS
1546 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1593 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1547#if XPM_BACKGROUND 1594#if XPM_BACKGROUND
1548 if (bgPixmap.pixmap == None) 1595 if (bgPixmap.pixmap == None)
1549#endif 1596#endif
1550#if TRANSPARENT 1597#if TRANSPARENT
1551 if (! (options & Opt_transparent) || am_transparent == 0) 1598 if (! OPTION (Opt_transparent) || am_transparent == 0)
1552#endif 1599#endif
1553 XSetWindowBackground (display->display, vt, 1600 XSetWindowBackground (display->display, vt,
1554 pix_colors[Color_bg]); 1601 pix_colors[Color_bg]);
1555 1602
1556 gcvalue.foreground = pix_colors[Color_fg]; 1603 gcvalue.foreground = pix_colors[Color_fg];
1789{ 1836{
1790#ifndef NO_BELL 1837#ifndef NO_BELL
1791 1838
1792# ifndef NO_MAPALERT 1839# ifndef NO_MAPALERT
1793# ifdef MAPALERT_OPTION 1840# ifdef MAPALERT_OPTION
1794 if (options & Opt_mapAlert) 1841 if (OPTION (Opt_mapAlert))
1795# endif 1842# endif
1796 XMapWindow (display->display, parent[0]); 1843 XMapWindow (display->display, parent[0]);
1797# endif 1844# endif
1798 1845
1799 if (options & Opt_visualBell) 1846 if (OPTION (Opt_visualBell))
1800 { 1847 {
1801 scr_rvideo_mode (!rvideo); /* refresh also done */ 1848 scr_rvideo_mode (!rvideo); /* refresh also done */
1802 rxvt_usleep (VISUAL_BELL_DURATION); 1849 rxvt_usleep (VISUAL_BELL_DURATION);
1803 scr_rvideo_mode (!rvideo); /* refresh also done */ 1850 scr_rvideo_mode (!rvideo); /* refresh also done */
1804 } 1851 }
1895 1942
1896#if XPM_BACKGROUND 1943#if XPM_BACKGROUND
1897 must_clear |= bgPixmap.pixmap != None; 1944 must_clear |= bgPixmap.pixmap != None;
1898#endif 1945#endif
1899#if TRANSPARENT 1946#if TRANSPARENT
1900 must_clear |= (options & Opt_transparent) && am_transparent; 1947 must_clear |= OPTION (Opt_transparent) && am_transparent;
1901#endif 1948#endif
1902 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1949 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1903 1950
1904 /* 1951 /*
1905 * B: reverse any characters which are selected 1952 * B: reverse any characters which are selected
1929 1976
1930 crp = &ROW(screen.cur.row).r[col]; 1977 crp = &ROW(screen.cur.row).r[col];
1931 1978
1932 if (showcursor && focus) 1979 if (showcursor && focus)
1933 { 1980 {
1934 if (options & Opt_cursorUnderline) 1981 if (OPTION (Opt_cursorUnderline))
1935 *crp ^= RS_Uline; 1982 *crp ^= RS_Uline;
1936 else 1983 else
1937 { 1984 {
1938 *crp ^= RS_RVid; 1985 *crp ^= RS_RVid;
1939 1986
1941 cc1 = *crp & (RS_fgMask | RS_bgMask); 1988 cc1 = *crp & (RS_fgMask | RS_bgMask);
1942 if (ISSET_PIXCOLOR (Color_cursor)) 1989 if (ISSET_PIXCOLOR (Color_cursor))
1943 ccol1 = Color_cursor; 1990 ccol1 = Color_cursor;
1944 else 1991 else
1945#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 1992#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1946 ccol1 = GET_FGCOLOR (rstyle); 1993 ccol1 = fgcolor_of (rstyle);
1947#else 1994#else
1948 ccol1 = Color_fg; 1995 ccol1 = Color_fg;
1949#endif 1996#endif
1950 if (ISSET_PIXCOLOR (Color_cursor2)) 1997 if (ISSET_PIXCOLOR (Color_cursor2))
1951 ccol2 = Color_cursor2; 1998 ccol2 = Color_cursor2;
1952 else 1999 else
1953#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2000#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1954 ccol2 = GET_BGCOLOR (rstyle); 2001 ccol2 = bgcolor_of (rstyle);
1955#else 2002#else
1956 ccol2 = Color_bg; 2003 ccol2 = Color_bg;
1957#endif 2004#endif
1958 *crp = SET_FGCOLOR (*crp, ccol1); 2005 *crp = SET_FGCOLOR (*crp, ccol1);
1959 *crp = SET_BGCOLOR (*crp, ccol2); 2006 *crp = SET_BGCOLOR (*crp, ccol2);
2140 count++, i--; 2187 count++, i--;
2141 2188
2142 /* 2189 /*
2143 * Determine the attributes for the string 2190 * Determine the attributes for the string
2144 */ 2191 */
2145 int fore = GET_FGCOLOR (rend); // desired foreground 2192 int fore = fgcolor_of (rend); // desired foreground
2146 int back = GET_BGCOLOR (rend); // desired background 2193 int back = bgcolor_of (rend); // desired background
2147 2194
2148 // only do special processing if any attributes are set, which is rare 2195 // only do special processing if any attributes are set, which is unlikely
2149 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2196 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2150 { 2197 {
2151#if ENABLE_STYLES 2198#if ENABLE_STYLES
2152 // force redraw after "careful" characters to avoid pixel droppings 2199 // force redraw after "careful" characters to avoid pixel droppings
2153 if (srp[col] & RS_Careful && col < ncol - 1 && 0) 2200 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2272 */ 2319 */
2273 if (showcursor) 2320 if (showcursor)
2274 { 2321 {
2275 if (focus) 2322 if (focus)
2276 { 2323 {
2277 if (options & Opt_cursorUnderline) 2324 if (OPTION (Opt_cursorUnderline))
2278 *crp ^= RS_Uline; 2325 *crp ^= RS_Uline;
2279 else 2326 else
2280 { 2327 {
2281 *crp ^= RS_RVid; 2328 *crp ^= RS_RVid;
2282#ifndef NO_CURSORCOLOR 2329#ifndef NO_CURSORCOLOR
2401 2448
2402#if ENABLE_FRILLS 2449#if ENABLE_FRILLS
2403 if (selection.rect) 2450 if (selection.rect)
2404 { 2451 {
2405 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) 2452 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++)
2453 {
2454 text_t *stp = ROW(row).t;
2455 rend_t *srp = ROW(row).r;
2456
2406 for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) 2457 for (col = selection.beg.col; col < selection.end.col; col++)
2407 srp[col] ^= RS_RVid; 2458 srp[col] ^= RS_RVid;
2459
2460 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2461 srp[col] ^= RS_RVid | RS_Uline;
2462
2463 if (++col < selection.end.col)
2464 srp[col] ^= RS_RVid | RS_Uline;
2465 }
2408 } 2466 }
2409 else 2467 else
2410#endif 2468#endif
2411 { 2469 {
2412 if (selection.beg.row >= -view_start) 2470 if (selection.beg.row >= -view_start)
2415 row = selection.beg.row; 2473 row = selection.beg.row;
2416 } 2474 }
2417 else 2475 else
2418 { 2476 {
2419 col = 0; 2477 col = 0;
2420 row = view_start; 2478 row = -view_start;
2421 } 2479 }
2422 2480
2423 for (; row < min (selection.end.row, view_end); row++, col = 0) 2481 for (; row < min (selection.end.row, view_end); row++, col = 0)
2424 for (rend_t *srp = ROW(row).r; col < ncol; col++) 2482 for (rend_t *srp = ROW(row).r; col < ncol; col++)
2425 srp[col] ^= RS_RVid; 2483 srp[col] ^= RS_RVid;
2839#endif 2897#endif
2840 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2898 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN
2841 2899
2842 col = max (col, 0); 2900 col = max (col, 0);
2843 2901
2844 if (row == selection.end.row || selection.rect) 2902 if (row == selection.end.row
2903#if ENABLE_FRILLS
2904 || selection.rect
2905#endif
2906 )
2845 end_col = min (end_col, selection.end.col); 2907 min_it (end_col, selection.end.col);
2846 2908
2847 t = ROW(row).t + col; 2909 t = ROW(row).t + col;
2848 for (; col < end_col; col++) 2910 for (; col < end_col; col++)
2849 { 2911 {
2850 if (*t == NOCHAR) 2912 if (*t == NOCHAR)
2868#endif 2930#endif
2869 else 2931 else
2870 new_selection_text[ofs++] = *t++; 2932 new_selection_text[ofs++] = *t++;
2871 } 2933 }
2872 2934
2935#if ENABLE_FRILLS
2936 if (selection.rect)
2937 {
2938 while (ofs
2939 && new_selection_text[ofs - 1] != C0_LF
2940 && unicode::is_space (new_selection_text[ofs - 1]))
2941 --ofs;
2942
2943 new_selection_text[ofs++] = C0_LF;
2944 }
2945 else
2946#endif
2873 if (!ROW(row).is_longer () && row != selection.end.row) 2947 if (!ROW(row).is_longer () && row != selection.end.row)
2874 new_selection_text[ofs++] = C0_LF; 2948 new_selection_text[ofs++] = C0_LF;
2875 } 2949 }
2876 2950
2877 if (end_col != selection.end.col) 2951 if (end_col != selection.end.col)
2878 new_selection_text[ofs++] = C0_LF; 2952 new_selection_text[ofs++] = C0_LF;
2879 2953
3230 selection_delimit_word (DN, &selection.end, &selection.end); 3304 selection_delimit_word (DN, &selection.end, &selection.end);
3231 } 3305 }
3232 else if (selection.clicks == 3) 3306 else if (selection.clicks == 3)
3233 { 3307 {
3234#if ENABLE_FRILLS 3308#if ENABLE_FRILLS
3235 if (options & Opt_tripleclickwords) 3309 if (OPTION (Opt_tripleclickwords))
3236 { 3310 {
3237 selection_delimit_word (UP, &selection.beg, &selection.beg); 3311 selection_delimit_word (UP, &selection.beg, &selection.beg);
3238 3312
3239 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3313 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3240 { 3314 {
3301 { 3375 {
3302 stp = ROW(end_row).t; 3376 stp = ROW(end_row).t;
3303 3377
3304 while (--end_col >= 0) 3378 while (--end_col >= 0)
3305 { 3379 {
3306 if (stp[end_col] != ' ' 3380 if (stp[end_col] != NOCHAR
3307 && stp[end_col] != '\t' 3381 && !unicode::is_space (stp[end_col]))
3308 && stp[end_col] != NOCHAR)
3309 break; 3382 break;
3310 } 3383 }
3311 3384
3312 if (end_col >= 0 3385 if (end_col >= 0
3313 || !ROW(end_row - 1).is_longer ()) 3386 || !ROW(end_row - 1).is_longer ())
3629 for (int y = ov_h; y--; ) 3702 for (int y = ov_h; y--; )
3630 { 3703 {
3631 text_t *t1 = ov_text[y]; 3704 text_t *t1 = ov_text[y];
3632 rend_t *r1 = ov_rend[y]; 3705 rend_t *r1 = ov_rend[y];
3633 3706
3634 text_t *t2 = ROW(y - view_start).t + ov_x; 3707 text_t *t2 = ROW(y + ov_y - view_start).t + ov_x;
3635 rend_t *r2 = ROW(y - view_start).r + ov_x; 3708 rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x;
3636 3709
3637 for (int x = ov_w; x--; ) 3710 for (int x = ov_w; x--; )
3638 { 3711 {
3639 text_t t = *t1; *t1++ = *t2; *t2++ = t; 3712 text_t t = *t1; *t1++ = *t2; *t2++ = t;
3640 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); 3713 rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines