… | |
… | |
24 | * This file handles _all_ screen updates and selections |
24 | * This file handles _all_ screen updates and selections |
25 | */ |
25 | */ |
26 | |
26 | |
27 | #include "../config.h" /* NECESSARY */ |
27 | #include "../config.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
|
|
29 | #include "rxvtperl.h" /* NECESSARY */ |
29 | |
30 | |
30 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
31 | |
32 | |
32 | #include <inttypes.h> |
33 | #include <inttypes.h> |
33 | |
34 | |
… | |
… | |
46 | |
47 | |
47 | /* ------------------------------------------------------------------------- * |
48 | /* ------------------------------------------------------------------------- * |
48 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * ------------------------------------------------------------------------- */ |
50 | * ------------------------------------------------------------------------- */ |
50 | #define ZERO_SCROLLBACK() \ |
51 | #define ZERO_SCROLLBACK() \ |
51 | if (options & Opt_scrollTtyOutput) \ |
52 | if (OPTION (Opt_scrollTtyOutput)) \ |
52 | view_start = 0 |
53 | view_start = 0 |
53 | #define CLEAR_SELECTION() \ |
54 | #define CLEAR_SELECTION() \ |
54 | selection.beg.row = selection.beg.col \ |
55 | selection.beg.row = selection.beg.col \ |
55 | = selection.end.row = selection.end.col = 0 |
56 | = selection.end.row = selection.end.col = 0 |
56 | #define CLEAR_ALL_SELECTION() \ |
57 | #define CLEAR_ALL_SELECTION() \ |
… | |
… | |
283 | // to come up with a lean and mean algorithm. |
284 | // to come up with a lean and mean algorithm. |
284 | |
285 | |
285 | row_col_t ocur = screen.cur; |
286 | row_col_t ocur = screen.cur; |
286 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
287 | ocur.row = MOD (term_start + ocur.row, prev_total_rows); |
287 | |
288 | |
288 | while (p != pend && q > 0) |
289 | do |
289 | { |
290 | { |
290 | p = MOD (p - 1, prev_total_rows); |
291 | p = MOD (p - 1, prev_total_rows); |
291 | #ifdef DEBUG_STRICT |
292 | #ifdef DEBUG_STRICT |
292 | assert (old_buf [MOD (p, prev_total_rows)].t); |
293 | assert (old_buf [MOD (p, prev_total_rows)].t); |
293 | #endif |
294 | #endif |
… | |
… | |
329 | int prow = lofs / prev_ncol; |
330 | int prow = lofs / prev_ncol; |
330 | int pcol = lofs % prev_ncol; |
331 | int pcol = lofs % prev_ncol; |
331 | |
332 | |
332 | prow = MOD (p + prow, prev_total_rows); |
333 | prow = MOD (p + prow, prev_total_rows); |
333 | |
334 | |
334 | // we only adjust the cursor _row_, as this seems to upset |
335 | // we only adjust the cursor _row_ and put it into |
|
|
336 | // the topmost line of "long line" it was in, as |
335 | // applications/shells/readline least. |
337 | // this seems to upset applications/shells/readline |
|
|
338 | // least. |
336 | if (prow == ocur.row) |
339 | if (prow == ocur.row) |
337 | screen.cur.row = qrow - (total_rows - nrow); |
340 | screen.cur.row = q - (total_rows - nrow); |
338 | |
341 | |
339 | line_t &pline = old_buf [prow]; |
342 | line_t &pline = old_buf [prow]; |
340 | |
343 | |
341 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
344 | int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); |
342 | |
345 | |
… | |
… | |
349 | lofs += len; |
352 | lofs += len; |
350 | qcol += len; |
353 | qcol += len; |
351 | } |
354 | } |
352 | } |
355 | } |
353 | |
356 | |
354 | qline->l = llen < ncol ? llen : MOD (llen - 1, ncol) + 1; |
357 | qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; |
|
|
358 | #ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY |
|
|
359 | if (qline->l < 0) |
|
|
360 | { |
|
|
361 | 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 |
|
|
362 | qline->l = 0; |
|
|
363 | } |
|
|
364 | #endif |
355 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
365 | scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); |
356 | } |
366 | } |
|
|
367 | while (p != pend && q > 0); |
357 | |
368 | |
358 | term_start = total_rows - nrow; |
369 | term_start = total_rows - nrow; |
359 | view_start = 0; |
|
|
360 | nsaved = term_start - q; |
370 | nsaved = term_start - q; |
361 | |
371 | |
362 | // make sure all terminal lines exist |
372 | // make sure all terminal lines exist |
363 | while (nsaved < 0) |
373 | while (nsaved < 0) |
364 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
374 | scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); |
… | |
… | |
381 | { |
391 | { |
382 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
392 | row_buf [row].clear (); scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
383 | } |
393 | } |
384 | |
394 | |
385 | term_start = 0; |
395 | term_start = 0; |
386 | view_start = 0; |
|
|
387 | } |
396 | } |
388 | |
397 | |
389 | #ifdef DEBUG_STRICT |
398 | #ifdef DEBUG_STRICT //TODO: remove |
390 | for (int i = -nsaved; i < nrow; i++) |
399 | for (int i = -nsaved; i < nrow; i++) |
391 | assert (ROW (i).t); |
400 | assert (ROW (i).t); |
392 | #endif |
401 | #endif |
393 | |
402 | |
394 | free (old_buf); |
403 | free (old_buf); |
… | |
… | |
409 | |
418 | |
410 | for (int col = ncol; col--; ) |
419 | for (int col = ncol; col--; ) |
411 | tabs [col] = col % TABSIZE == 0; |
420 | tabs [col] = col % TABSIZE == 0; |
412 | |
421 | |
413 | tt_winch (); |
422 | tt_winch (); |
|
|
423 | |
|
|
424 | PERL_INVOKE ((this, HOOK_RESET, DT_END)); |
414 | } |
425 | } |
415 | |
426 | |
416 | /* ------------------------------------------------------------------------- */ |
427 | /* ------------------------------------------------------------------------- */ |
417 | /* |
428 | /* |
418 | * Free everything. That way malloc debugging can find leakage. |
429 | * Free everything. That way malloc debugging can find leakage. |
… | |
… | |
522 | |
533 | |
523 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
534 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
524 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
535 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
525 | |
536 | |
526 | #if NSCREENS |
537 | #if NSCREENS |
527 | if (options & Opt_secondaryScreen) |
538 | if (OPTION (Opt_secondaryScreen)) |
528 | { |
539 | { |
529 | num_scr = 0; |
540 | num_scr = 0; |
530 | |
541 | |
531 | for (int i = prev_nrow; i--; ) |
542 | for (int i = prev_nrow; i--; ) |
532 | ::swap (ROW(i), swap_buf [i]); |
543 | ::swap (ROW(i), swap_buf [i]); |
… | |
… | |
536 | screen.flags |= Screen_VisibleCursor; |
547 | screen.flags |= Screen_VisibleCursor; |
537 | swap.flags |= Screen_VisibleCursor; |
548 | swap.flags |= Screen_VisibleCursor; |
538 | } |
549 | } |
539 | else |
550 | else |
540 | #endif |
551 | #endif |
541 | if (options & Opt_secondaryScroll) |
552 | if (OPTION (Opt_secondaryScroll)) |
542 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
553 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
543 | |
554 | |
544 | return scrn; |
555 | return scrn; |
545 | } |
556 | } |
546 | |
557 | |
… | |
… | |
608 | num_scr += count; |
619 | num_scr += count; |
609 | |
620 | |
610 | if (count > 0 |
621 | if (count > 0 |
611 | && row1 == 0 |
622 | && row1 == 0 |
612 | && row2 == nrow - 1 |
623 | && row2 == nrow - 1 |
613 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
624 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
614 | { |
625 | { |
615 | nsaved = min (nsaved + count, saveLines); |
626 | nsaved = min (nsaved + count, saveLines); |
|
|
627 | |
|
|
628 | PERL_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END)); |
|
|
629 | |
616 | term_start = (term_start + count) % total_rows; |
630 | term_start = (term_start + count) % total_rows; |
617 | |
631 | |
618 | if (selection.op && current_screen == selection.screen) |
632 | if (selection.op && current_screen == selection.screen) |
619 | { |
633 | { |
620 | selection.beg.row -= count; |
634 | selection.beg.row -= count; |
621 | selection.end.row -= count; |
635 | selection.end.row -= count; |
622 | selection.mark.row -= count; |
636 | selection.mark.row -= count; |
623 | |
637 | |
624 | selection_check (0); |
638 | if (selection.beg.row < -nsaved |
|
|
639 | || selection.end.row < -nsaved |
|
|
640 | || selection.mark.row < -nsaved) |
|
|
641 | { |
|
|
642 | CLEAR_ALL_SELECTION (); |
|
|
643 | selection.op = SELECTION_CLEAR; |
|
|
644 | } |
625 | } |
645 | } |
626 | |
646 | |
627 | for (int i = count; i--; ) |
647 | for (int i = count; i--; ) |
|
|
648 | { |
|
|
649 | ROW(row2 - i).l = 0; |
628 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
650 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
|
|
651 | } |
629 | |
652 | |
630 | if ((options & Opt_scrollWithBuffer) |
653 | if (OPTION (Opt_scrollWithBuffer) |
631 | && view_start != 0 |
654 | && view_start != 0 |
632 | && view_start != saveLines) |
655 | && view_start != saveLines) |
633 | scr_page (UP, count); |
656 | scr_page (UP, count); |
634 | } |
657 | } |
635 | else |
658 | else |
636 | { |
659 | { |
637 | if (selection.op && current_screen == selection.screen) |
660 | if (selection.op && current_screen == selection.screen) |
638 | { |
661 | { |
639 | int i = selection.beg.row; |
662 | if ((selection.beg.row < row1 && selection.end.row > row1) |
640 | int j = selection.end.row; |
663 | || (selection.beg.row < row2 && selection.end.row > row2) |
641 | |
|
|
642 | if ((i < row1 && j > row1) |
|
|
643 | || (i < row2 && j > row2) |
|
|
644 | || (i - count < row1 && i >= row1) |
664 | || (selection.beg.row - count < row1 && selection.beg.row >= row1) |
645 | || (i - count > row2 && i <= row2) |
665 | || (selection.beg.row - count > row2 && selection.beg.row <= row2) |
646 | || (j - count < row1 && j >= row1) |
666 | || (selection.end.row - count < row1 && selection.end.row >= row1) |
647 | || (j - count > row2 && j <= row2)) |
667 | || (selection.end.row - count > row2 && selection.end.row <= row2)) |
648 | { |
668 | { |
649 | CLEAR_ALL_SELECTION (); |
669 | CLEAR_ALL_SELECTION (); |
650 | selection.op = SELECTION_CLEAR; /* XXX: too aggressive? */ |
670 | selection.op = SELECTION_CLEAR; |
651 | } |
671 | } |
652 | else if (j >= row1 && j <= row2) |
672 | else if (selection.end.row >= row1 && selection.end.row <= row2) |
653 | { |
673 | { |
654 | /* move selected region too */ |
674 | /* move selected region too */ |
655 | selection.beg.row -= count; |
675 | selection.beg.row -= count; |
656 | selection.end.row -= count; |
676 | selection.end.row -= count; |
657 | selection.mark.row -= count; |
677 | selection.mark.row -= count; |
… | |
… | |
692 | if (len <= 0) /* sanity */ |
712 | if (len <= 0) /* sanity */ |
693 | return; |
713 | return; |
694 | |
714 | |
695 | unsigned char checksel; |
715 | unsigned char checksel; |
696 | unicode_t c; |
716 | unicode_t c; |
697 | int row, last_col; |
717 | int last_col; |
698 | const unicode_t *strend = str + len; |
718 | const unicode_t *strend = str + len; |
699 | |
719 | |
700 | want_refresh = 1; |
720 | want_refresh = 1; |
701 | ZERO_SCROLLBACK (); |
721 | ZERO_SCROLLBACK (); |
702 | last_col = ncol; |
722 | last_col = ncol; |
… | |
… | |
717 | #ifdef DEBUG_STRICT |
737 | #ifdef DEBUG_STRICT |
718 | assert (screen.cur.col < last_col); |
738 | assert (screen.cur.col < last_col); |
719 | assert (screen.cur.row < nrow |
739 | assert (screen.cur.row < nrow |
720 | && screen.cur.row >= -nsaved); |
740 | && screen.cur.row >= -nsaved); |
721 | #endif |
741 | #endif |
722 | row = screen.cur.row; |
742 | int row = screen.cur.row; |
723 | |
743 | |
724 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
744 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
725 | |
745 | |
726 | line_t *line = &ROW(row); |
746 | line_t *line = &ROW(row); |
727 | |
747 | |
… | |
… | |
729 | { |
749 | { |
730 | c = *str++; |
750 | c = *str++; |
731 | |
751 | |
732 | if (c < 0x20) |
752 | if (c < 0x20) |
733 | if (c == C0_LF) |
753 | if (c == C0_LF) |
734 | { |
754 | { |
735 | if (!line->is_longer ()) /* XXX: think about this */ |
755 | if (!line->is_longer ()) /* XXX: think about this */ |
736 | max_it (line->l, screen.cur.col); |
756 | max_it (line->l, screen.cur.col); |
737 | |
757 | |
738 | screen.flags &= ~Screen_WrapNext; |
758 | screen.flags &= ~Screen_WrapNext; |
739 | |
759 | |
… | |
… | |
984 | |
1004 | |
985 | if (count == 0) |
1005 | if (count == 0) |
986 | return; |
1006 | return; |
987 | else if (count > 0) |
1007 | else if (count > 0) |
988 | { |
1008 | { |
989 | int row = screen.cur.row; |
|
|
990 | |
|
|
991 | line_t &l = ROW(row); |
1009 | line_t &l = ROW(screen.cur.row); |
992 | rend_t base_rend = l.r[i]; |
1010 | rend_t base_rend = l.r[i]; |
993 | ht &= l.t[i] == ' '; |
1011 | ht &= l.t[i] == ' '; |
994 | |
1012 | |
995 | for (; ++i < ncol; ) |
1013 | for (; ++i < ncol; ) |
996 | if (tabs[i]) |
1014 | if (tabs[i]) |
… | |
… | |
1006 | if (count) |
1024 | if (count) |
1007 | x = ncol - 1; |
1025 | x = ncol - 1; |
1008 | |
1026 | |
1009 | // store horizontal tab commands as characters inside the text |
1027 | // store horizontal tab commands as characters inside the text |
1010 | // buffer so they can be selected and pasted. |
1028 | // buffer so they can be selected and pasted. |
1011 | if (ht && options & Opt_pastableTabs) |
1029 | if (ht && OPTION (Opt_pastableTabs)) |
1012 | { |
1030 | { |
1013 | base_rend = SET_FONT (base_rend, 0); |
1031 | base_rend = SET_FONT (base_rend, 0); |
1014 | |
1032 | |
1015 | if (!l.is_longer ()) /* XXX: think about this */ |
1033 | if (!l.is_longer ()) /* XXX: think about this */ |
1016 | max_it (l.l, x); |
1034 | max_it (l.l, x); |
… | |
… | |
1071 | */ |
1089 | */ |
1072 | #if ENABLE_FRILLS |
1090 | #if ENABLE_FRILLS |
1073 | void |
1091 | void |
1074 | rxvt_term::scr_forwardindex () |
1092 | rxvt_term::scr_forwardindex () |
1075 | { |
1093 | { |
1076 | int row; |
|
|
1077 | |
|
|
1078 | if (screen.cur.col < ncol - 1) |
1094 | if (screen.cur.col < ncol - 1) |
1079 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1095 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1080 | else |
1096 | else |
1081 | { |
1097 | { |
1082 | row = screen.cur.row; |
|
|
1083 | |
|
|
1084 | if (ROW(row).is_longer ()) //TODO//FIXME//LEN |
1098 | if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN |
1085 | ROW(row).l = ncol; |
1099 | ROW(screen.cur.row).l = ncol; |
1086 | |
1100 | |
1087 | scr_gotorc (0, 0, R_RELATIVE); |
1101 | scr_gotorc (0, 0, R_RELATIVE); |
1088 | scr_insdel_chars (1, DELETE); |
1102 | scr_insdel_chars (1, DELETE); |
1089 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1103 | scr_gotorc (0, ncol - 1, R_RELATIVE); |
1090 | } |
1104 | } |
… | |
… | |
1173 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1187 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1174 | */ |
1188 | */ |
1175 | void |
1189 | void |
1176 | rxvt_term::scr_erase_line (int mode) |
1190 | rxvt_term::scr_erase_line (int mode) |
1177 | { |
1191 | { |
1178 | unsigned int row, col, num; |
1192 | unsigned int col, num; |
1179 | |
1193 | |
1180 | want_refresh = 1; |
1194 | want_refresh = 1; |
1181 | ZERO_SCROLLBACK (); |
1195 | ZERO_SCROLLBACK (); |
1182 | |
1196 | |
1183 | selection_check (1); |
1197 | selection_check (1); |
1184 | |
1198 | |
1185 | row = screen.cur.row; |
1199 | line_t &line = ROW(screen.cur.row); |
1186 | |
1200 | |
1187 | switch (mode) |
1201 | switch (mode) |
1188 | { |
1202 | { |
1189 | case 0: /* erase to end of line */ |
1203 | case 0: /* erase to end of line */ |
1190 | col = screen.cur.col; |
1204 | col = screen.cur.col; |
1191 | num = ncol - col; |
1205 | num = ncol - col; |
1192 | min_it (ROW(row).l, col); |
1206 | min_it (line.l, col); |
1193 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1207 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1194 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1208 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1195 | CLEAR_SELECTION (); |
1209 | CLEAR_SELECTION (); |
1196 | break; |
1210 | break; |
1197 | case 1: /* erase to beginning of line */ |
1211 | case 1: /* erase to beginning of line */ |
… | |
… | |
1202 | CLEAR_SELECTION (); |
1216 | CLEAR_SELECTION (); |
1203 | break; |
1217 | break; |
1204 | case 2: /* erase whole line */ |
1218 | case 2: /* erase whole line */ |
1205 | col = 0; |
1219 | col = 0; |
1206 | num = ncol; |
1220 | num = ncol; |
1207 | ROW(row).l = 0; |
1221 | line.l = 0; |
1208 | if (selection.beg.row <= screen.cur.row |
1222 | if (selection.beg.row <= screen.cur.row |
1209 | && selection.end.row >= screen.cur.row) |
1223 | && selection.end.row >= screen.cur.row) |
1210 | CLEAR_SELECTION (); |
1224 | CLEAR_SELECTION (); |
1211 | break; |
1225 | break; |
1212 | default: |
1226 | default: |
1213 | return; |
1227 | return; |
1214 | } |
1228 | } |
1215 | |
1229 | |
1216 | scr_blank_line (ROW(row), col, num, rstyle); |
1230 | scr_blank_line (line, col, num, rstyle); |
1217 | } |
1231 | } |
1218 | |
1232 | |
1219 | /* ------------------------------------------------------------------------- */ |
1233 | /* ------------------------------------------------------------------------- */ |
1220 | /* |
1234 | /* |
1221 | * Erase part of whole of the screen |
1235 | * Erase part of whole of the screen |
… | |
… | |
1276 | CLEAR_ROWS (row, num); |
1290 | CLEAR_ROWS (row, num); |
1277 | } |
1291 | } |
1278 | else |
1292 | else |
1279 | { |
1293 | { |
1280 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1294 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1281 | gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; |
1295 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1282 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1296 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1283 | ERASE_ROWS (row, num); |
1297 | ERASE_ROWS (row, num); |
1284 | gcvalue.foreground = pix_colors[Color_fg]; |
1298 | gcvalue.foreground = pix_colors[Color_fg]; |
1285 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1299 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1286 | } |
1300 | } |
1287 | |
1301 | |
1288 | for (; num--; row++) |
1302 | for (; num--; row++) |
1289 | { |
1303 | { |
|
|
1304 | ROW (row).l = 0; |
1290 | scr_blank_screen_mem (ROW (row), rstyle); |
1305 | scr_blank_screen_mem (ROW (row), rstyle); |
1291 | ROW (row).l = 0; |
|
|
1292 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1306 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1293 | } |
1307 | } |
1294 | } |
1308 | } |
1295 | |
1309 | |
1296 | #if ENABLE_FRILLS |
1310 | #if ENABLE_FRILLS |
… | |
… | |
1585 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1599 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1586 | #if XPM_BACKGROUND |
1600 | #if XPM_BACKGROUND |
1587 | if (bgPixmap.pixmap == None) |
1601 | if (bgPixmap.pixmap == None) |
1588 | #endif |
1602 | #endif |
1589 | #if TRANSPARENT |
1603 | #if TRANSPARENT |
1590 | if (! (options & Opt_transparent) || am_transparent == 0) |
1604 | if (! OPTION (Opt_transparent) || am_transparent == 0) |
1591 | #endif |
1605 | #endif |
1592 | XSetWindowBackground (display->display, vt, |
1606 | XSetWindowBackground (display->display, vt, |
1593 | pix_colors[Color_bg]); |
1607 | pix_colors[Color_bg]); |
1594 | |
1608 | |
1595 | gcvalue.foreground = pix_colors[Color_fg]; |
1609 | gcvalue.foreground = pix_colors[Color_fg]; |
… | |
… | |
1811 | } |
1825 | } |
1812 | |
1826 | |
1813 | int |
1827 | int |
1814 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1828 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1815 | { |
1829 | { |
|
|
1830 | PERL_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); |
|
|
1831 | |
1816 | if (view_start != oldviewstart) |
1832 | if (view_start != oldviewstart) |
1817 | { |
1833 | { |
1818 | want_refresh = 1; |
1834 | want_refresh = 1; |
1819 | num_scr -= (view_start - oldviewstart); |
1835 | num_scr -= (view_start - oldviewstart); |
1820 | } |
1836 | } |
… | |
… | |
1828 | { |
1844 | { |
1829 | #ifndef NO_BELL |
1845 | #ifndef NO_BELL |
1830 | |
1846 | |
1831 | # ifndef NO_MAPALERT |
1847 | # ifndef NO_MAPALERT |
1832 | # ifdef MAPALERT_OPTION |
1848 | # ifdef MAPALERT_OPTION |
1833 | if (options & Opt_mapAlert) |
1849 | if (OPTION (Opt_mapAlert)) |
1834 | # endif |
1850 | # endif |
1835 | XMapWindow (display->display, parent[0]); |
1851 | XMapWindow (display->display, parent[0]); |
1836 | # endif |
1852 | # endif |
1837 | |
1853 | |
1838 | if (options & Opt_visualBell) |
1854 | if (OPTION (Opt_visualBell)) |
1839 | { |
1855 | { |
1840 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1856 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1841 | rxvt_usleep (VISUAL_BELL_DURATION); |
1857 | rxvt_usleep (VISUAL_BELL_DURATION); |
1842 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1858 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1843 | } |
1859 | } |
… | |
… | |
1934 | |
1950 | |
1935 | #if XPM_BACKGROUND |
1951 | #if XPM_BACKGROUND |
1936 | must_clear |= bgPixmap.pixmap != None; |
1952 | must_clear |= bgPixmap.pixmap != None; |
1937 | #endif |
1953 | #endif |
1938 | #if TRANSPARENT |
1954 | #if TRANSPARENT |
1939 | must_clear |= (options & Opt_transparent) && am_transparent; |
1955 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
1940 | #endif |
1956 | #endif |
1941 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1957 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1942 | |
1958 | |
1943 | /* |
1959 | /* |
1944 | * B: reverse any characters which are selected |
1960 | * B: reverse any characters which are selected |
… | |
… | |
1968 | |
1984 | |
1969 | crp = &ROW(screen.cur.row).r[col]; |
1985 | crp = &ROW(screen.cur.row).r[col]; |
1970 | |
1986 | |
1971 | if (showcursor && focus) |
1987 | if (showcursor && focus) |
1972 | { |
1988 | { |
1973 | if (options & Opt_cursorUnderline) |
1989 | if (OPTION (Opt_cursorUnderline)) |
1974 | *crp ^= RS_Uline; |
1990 | *crp ^= RS_Uline; |
1975 | else |
1991 | else |
1976 | { |
1992 | { |
1977 | *crp ^= RS_RVid; |
1993 | *crp ^= RS_RVid; |
1978 | |
1994 | |
… | |
… | |
1980 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1996 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
1981 | if (ISSET_PIXCOLOR (Color_cursor)) |
1997 | if (ISSET_PIXCOLOR (Color_cursor)) |
1982 | ccol1 = Color_cursor; |
1998 | ccol1 = Color_cursor; |
1983 | else |
1999 | else |
1984 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2000 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1985 | ccol1 = GET_FGCOLOR (rstyle); |
2001 | ccol1 = fgcolor_of (rstyle); |
1986 | #else |
2002 | #else |
1987 | ccol1 = Color_fg; |
2003 | ccol1 = Color_fg; |
1988 | #endif |
2004 | #endif |
1989 | if (ISSET_PIXCOLOR (Color_cursor2)) |
2005 | if (ISSET_PIXCOLOR (Color_cursor2)) |
1990 | ccol2 = Color_cursor2; |
2006 | ccol2 = Color_cursor2; |
1991 | else |
2007 | else |
1992 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2008 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
1993 | ccol2 = GET_BGCOLOR (rstyle); |
2009 | ccol2 = bgcolor_of (rstyle); |
1994 | #else |
2010 | #else |
1995 | ccol2 = Color_bg; |
2011 | ccol2 = Color_bg; |
1996 | #endif |
2012 | #endif |
1997 | *crp = SET_FGCOLOR (*crp, ccol1); |
2013 | *crp = SET_FGCOLOR (*crp, ccol1); |
1998 | *crp = SET_BGCOLOR (*crp, ccol2); |
2014 | *crp = SET_BGCOLOR (*crp, ccol2); |
… | |
… | |
2031 | oldcursor.col = screen.cur.col; |
2047 | oldcursor.col = screen.cur.col; |
2032 | } |
2048 | } |
2033 | } |
2049 | } |
2034 | } |
2050 | } |
2035 | |
2051 | |
|
|
2052 | PERL_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END)); |
2036 | #if ENABLE_OVERLAY |
2053 | #if ENABLE_OVERLAY |
2037 | scr_swap_overlay (); |
2054 | scr_swap_overlay (); |
2038 | #endif |
2055 | #endif |
2039 | |
2056 | |
2040 | #ifndef NO_SLOW_LINK_SUPPORT |
2057 | #ifndef NO_SLOW_LINK_SUPPORT |
… | |
… | |
2179 | count++, i--; |
2196 | count++, i--; |
2180 | |
2197 | |
2181 | /* |
2198 | /* |
2182 | * Determine the attributes for the string |
2199 | * Determine the attributes for the string |
2183 | */ |
2200 | */ |
2184 | int fore = GET_FGCOLOR (rend); // desired foreground |
2201 | int fore = fgcolor_of (rend); // desired foreground |
2185 | int back = GET_BGCOLOR (rend); // desired background |
2202 | int back = bgcolor_of (rend); // desired background |
2186 | |
2203 | |
2187 | // only do special processing if any attributes are set, which is rare |
2204 | // only do special processing if any attributes are set, which is unlikely |
2188 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2205 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2189 | { |
2206 | { |
2190 | #if ENABLE_STYLES |
2207 | #if ENABLE_STYLES |
2191 | // force redraw after "careful" characters to avoid pixel droppings |
2208 | // force redraw after "careful" characters to avoid pixel droppings |
2192 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
2209 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
… | |
… | |
2303 | } /* for (row....) */ |
2320 | } /* for (row....) */ |
2304 | |
2321 | |
2305 | #if ENABLE_OVERLAY |
2322 | #if ENABLE_OVERLAY |
2306 | scr_swap_overlay (); |
2323 | scr_swap_overlay (); |
2307 | #endif |
2324 | #endif |
|
|
2325 | PERL_INVOKE ((this, HOOK_REFRESH_END, DT_END)); |
2308 | |
2326 | |
2309 | /* |
2327 | /* |
2310 | * G: cleanup cursor and display outline cursor if necessary |
2328 | * G: cleanup cursor and display outline cursor if necessary |
2311 | */ |
2329 | */ |
2312 | if (showcursor) |
2330 | if (showcursor) |
2313 | { |
2331 | { |
2314 | if (focus) |
2332 | if (focus) |
2315 | { |
2333 | { |
2316 | if (options & Opt_cursorUnderline) |
2334 | if (OPTION (Opt_cursorUnderline)) |
2317 | *crp ^= RS_Uline; |
2335 | *crp ^= RS_Uline; |
2318 | else |
2336 | else |
2319 | { |
2337 | { |
2320 | *crp ^= RS_RVid; |
2338 | *crp ^= RS_RVid; |
2321 | #ifndef NO_CURSORCOLOR |
2339 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2440 | |
2458 | |
2441 | #if ENABLE_FRILLS |
2459 | #if ENABLE_FRILLS |
2442 | if (selection.rect) |
2460 | if (selection.rect) |
2443 | { |
2461 | { |
2444 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
2462 | for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) |
|
|
2463 | { |
|
|
2464 | text_t *stp = ROW(row).t; |
|
|
2465 | rend_t *srp = ROW(row).r; |
|
|
2466 | |
2445 | for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) |
2467 | for (col = selection.beg.col; col < selection.end.col; col++) |
2446 | srp[col] ^= RS_RVid; |
2468 | srp[col] ^= RS_RVid; |
|
|
2469 | |
|
|
2470 | while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) |
|
|
2471 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2472 | |
|
|
2473 | if (++col < selection.end.col) |
|
|
2474 | srp[col] ^= RS_RVid | RS_Uline; |
|
|
2475 | } |
2447 | } |
2476 | } |
2448 | else |
2477 | else |
2449 | #endif |
2478 | #endif |
2450 | { |
2479 | { |
2451 | if (selection.beg.row >= -view_start) |
2480 | if (selection.beg.row >= -view_start) |
… | |
… | |
2454 | row = selection.beg.row; |
2483 | row = selection.beg.row; |
2455 | } |
2484 | } |
2456 | else |
2485 | else |
2457 | { |
2486 | { |
2458 | col = 0; |
2487 | col = 0; |
2459 | row = view_start; |
2488 | row = -view_start; |
2460 | } |
2489 | } |
2461 | |
2490 | |
2462 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2491 | for (; row < min (selection.end.row, view_end); row++, col = 0) |
2463 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2492 | for (rend_t *srp = ROW(row).r; col < ncol; col++) |
2464 | srp[col] ^= RS_RVid; |
2493 | srp[col] ^= RS_RVid; |
… | |
… | |
2853 | selection.op = SELECTION_DONE; |
2882 | selection.op = SELECTION_DONE; |
2854 | |
2883 | |
2855 | if (selection.clicks == 4) |
2884 | if (selection.clicks == 4) |
2856 | return; /* nothing selected, go away */ |
2885 | return; /* nothing selected, go away */ |
2857 | |
2886 | |
|
|
2887 | if (PERL_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END))) |
|
|
2888 | return; |
|
|
2889 | |
2858 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2890 | i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); |
2859 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2891 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2860 | |
2892 | |
2861 | int ofs = 0; |
2893 | int ofs = 0; |
2862 | int extra = 0; |
2894 | int extra = 0; |
… | |
… | |
2878 | #endif |
2910 | #endif |
2879 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2911 | end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN |
2880 | |
2912 | |
2881 | col = max (col, 0); |
2913 | col = max (col, 0); |
2882 | |
2914 | |
2883 | if (row == selection.end.row || selection.rect) |
2915 | if (row == selection.end.row |
|
|
2916 | #if ENABLE_FRILLS |
|
|
2917 | || selection.rect |
|
|
2918 | #endif |
|
|
2919 | ) |
2884 | end_col = min (end_col, selection.end.col); |
2920 | min_it (end_col, selection.end.col); |
2885 | |
2921 | |
2886 | t = ROW(row).t + col; |
2922 | t = ROW(row).t + col; |
2887 | for (; col < end_col; col++) |
2923 | for (; col < end_col; col++) |
2888 | { |
2924 | { |
2889 | if (*t == NOCHAR) |
2925 | if (*t == NOCHAR) |
… | |
… | |
2907 | #endif |
2943 | #endif |
2908 | else |
2944 | else |
2909 | new_selection_text[ofs++] = *t++; |
2945 | new_selection_text[ofs++] = *t++; |
2910 | } |
2946 | } |
2911 | |
2947 | |
|
|
2948 | #if ENABLE_FRILLS |
|
|
2949 | if (selection.rect) |
|
|
2950 | { |
|
|
2951 | while (ofs |
|
|
2952 | && new_selection_text[ofs - 1] != C0_LF |
|
|
2953 | && unicode::is_space (new_selection_text[ofs - 1])) |
|
|
2954 | --ofs; |
|
|
2955 | |
|
|
2956 | new_selection_text[ofs++] = C0_LF; |
|
|
2957 | } |
|
|
2958 | else |
|
|
2959 | #endif |
2912 | if (!ROW(row).is_longer () && row != selection.end.row) |
2960 | if (!ROW(row).is_longer () && row != selection.end.row) |
2913 | new_selection_text[ofs++] = C0_LF; |
2961 | new_selection_text[ofs++] = C0_LF; |
2914 | } |
2962 | } |
2915 | |
2963 | |
2916 | if (end_col != selection.end.col) |
2964 | if (end_col != selection.end.col) |
2917 | new_selection_text[ofs++] = C0_LF; |
2965 | new_selection_text[ofs++] = C0_LF; |
2918 | |
2966 | |
… | |
… | |
2928 | |
2976 | |
2929 | // we usually allocate much more than necessary, so realloc it smaller again |
2977 | // we usually allocate much more than necessary, so realloc it smaller again |
2930 | selection.len = ofs; |
2978 | selection.len = ofs; |
2931 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2979 | selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); |
2932 | |
2980 | |
|
|
2981 | if (PERL_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END))) |
|
|
2982 | return; |
|
|
2983 | |
|
|
2984 | selection_grab (tm); |
|
|
2985 | } |
|
|
2986 | |
|
|
2987 | bool |
|
|
2988 | rxvt_term::selection_grab (Time tm) |
|
|
2989 | { |
|
|
2990 | selection_time = tm; |
|
|
2991 | |
2933 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2992 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
2934 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
2993 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
|
|
2994 | { |
2935 | display->set_selection_owner (this); |
2995 | display->set_selection_owner (this); |
|
|
2996 | return true; |
|
|
2997 | } |
2936 | else |
2998 | else |
2937 | rxvt_warn ("can't get primary selection, ignoring.\n"); |
2999 | return false; |
2938 | |
3000 | |
2939 | #if 0 |
3001 | #if 0 |
2940 | XTextProperty ct; |
3002 | XTextProperty ct; |
2941 | |
3003 | |
2942 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3004 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
2943 | { |
3005 | { |
2944 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3006 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
2945 | XFree (ct.value); |
3007 | XFree (ct.value); |
2946 | } |
3008 | } |
2947 | #endif |
3009 | #endif |
2948 | |
|
|
2949 | selection_time = tm; |
|
|
2950 | } |
3010 | } |
2951 | |
3011 | |
2952 | /* ------------------------------------------------------------------------- */ |
3012 | /* ------------------------------------------------------------------------- */ |
2953 | /* |
3013 | /* |
2954 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3014 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
… | |
… | |
3269 | selection_delimit_word (DN, &selection.end, &selection.end); |
3329 | selection_delimit_word (DN, &selection.end, &selection.end); |
3270 | } |
3330 | } |
3271 | else if (selection.clicks == 3) |
3331 | else if (selection.clicks == 3) |
3272 | { |
3332 | { |
3273 | #if ENABLE_FRILLS |
3333 | #if ENABLE_FRILLS |
3274 | if (options & Opt_tripleclickwords) |
3334 | if (OPTION (Opt_tripleclickwords)) |
3275 | { |
3335 | { |
3276 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3336 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3277 | |
3337 | |
3278 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3338 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3279 | { |
3339 | { |
… | |
… | |
3340 | { |
3400 | { |
3341 | stp = ROW(end_row).t; |
3401 | stp = ROW(end_row).t; |
3342 | |
3402 | |
3343 | while (--end_col >= 0) |
3403 | while (--end_col >= 0) |
3344 | { |
3404 | { |
3345 | if (stp[end_col] != ' ' |
3405 | if (stp[end_col] != NOCHAR |
3346 | && stp[end_col] != '\t' |
3406 | && !unicode::is_space (stp[end_col])) |
3347 | && stp[end_col] != NOCHAR) |
|
|
3348 | break; |
3407 | break; |
3349 | } |
3408 | } |
3350 | |
3409 | |
3351 | if (end_col >= 0 |
3410 | if (end_col >= 0 |
3352 | || !ROW(end_row - 1).is_longer ()) |
3411 | || !ROW(end_row - 1).is_longer ()) |
… | |
… | |
3551 | |
3610 | |
3552 | #if ENABLE_OVERLAY |
3611 | #if ENABLE_OVERLAY |
3553 | void |
3612 | void |
3554 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3613 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3555 | { |
3614 | { |
3556 | if (nrow < 3 || ncol < 3) |
3615 | if (nrow < 1 || ncol < 1) |
3557 | return; |
3616 | return; |
3558 | |
3617 | |
3559 | want_refresh = 1; |
3618 | want_refresh = 1; |
3560 | |
3619 | |
3561 | scr_overlay_off (); |
3620 | scr_overlay_off (); |
… | |
… | |
3668 | for (int y = ov_h; y--; ) |
3727 | for (int y = ov_h; y--; ) |
3669 | { |
3728 | { |
3670 | text_t *t1 = ov_text[y]; |
3729 | text_t *t1 = ov_text[y]; |
3671 | rend_t *r1 = ov_rend[y]; |
3730 | rend_t *r1 = ov_rend[y]; |
3672 | |
3731 | |
3673 | text_t *t2 = ROW(y - view_start).t + ov_x; |
3732 | text_t *t2 = ROW(y + ov_y - view_start).t + ov_x; |
3674 | rend_t *r2 = ROW(y - view_start).r + ov_x; |
3733 | rend_t *r2 = ROW(y + ov_y - view_start).r + ov_x; |
3675 | |
3734 | |
3676 | for (int x = ov_w; x--; ) |
3735 | for (int x = ov_w; x--; ) |
3677 | { |
3736 | { |
3678 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3737 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3679 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3738 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |