… | |
… | |
83 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
83 | #define ROWCOL_IN_ROW_AT_OR_AFTER(X, Y) \ |
84 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
84 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
85 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
85 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
86 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
86 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
87 | |
87 | |
88 | #define LINENO(n) (((n) + term_start + total_rows) % total_rows) |
|
|
89 | #define ROW(n) (save [LINENO (n)]) |
|
|
90 | |
|
|
91 | /* |
88 | /* |
92 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
89 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
93 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
94 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
91 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
95 | */ |
92 | */ |
… | |
… | |
251 | if (nrow < prev_nrow) |
248 | if (nrow < prev_nrow) |
252 | { |
249 | { |
253 | /* delete rows */ |
250 | /* delete rows */ |
254 | k = min (nsaved, prev_nrow - nrow); |
251 | k = min (nsaved, prev_nrow - nrow); |
255 | // k = max (0, - ( (nrow - 1) - r->screen.cur.row)); // mmc's http://maruska.dyndns.org/wiki/scrolling-bug //make configurable? //D TODO |
252 | // k = max (0, - ( (nrow - 1) - r->screen.cur.row)); // mmc's http://maruska.dyndns.org/wiki/scrolling-bug //make configurable? //D TODO |
256 | scr_scroll_text (0, (int)prev_nrow - 1, k, 1); |
253 | scr_scroll_text (0, (int)prev_nrow - 1, k); |
257 | |
254 | |
258 | for (p = nrow; p < prev_nrow; p++) |
255 | for (p = nrow; p < prev_nrow; p++) |
259 | { |
256 | { |
260 | lfree (ROW(p)); |
257 | lfree (ROW(p)); |
261 | lfree (swap_save[p]); |
258 | lfree (swap_save[p]); |
262 | lfree (drawn[p]); |
259 | lfree (drawn[p]); |
263 | } |
260 | } |
264 | |
261 | |
265 | /* we have fewer rows so fix up cursor position */ |
262 | /* we have fewer rows so fix up cursor position */ |
266 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
263 | min_it (screen.cur.row, (int32_t)nrow - 1); |
267 | |
264 | |
268 | scr_reset_realloc (); /* realloc _last_ */ |
265 | scr_reset_realloc (); /* realloc _last_ */ |
269 | } |
266 | } |
270 | else if (nrow > prev_nrow) |
267 | else if (nrow > prev_nrow) |
271 | { |
268 | { |
… | |
… | |
289 | drawn[p].clear (); scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); |
286 | drawn[p].clear (); scr_blank_screen_mem (drawn[p], DEFAULT_RSTYLE); |
290 | } |
287 | } |
291 | |
288 | |
292 | if (k > 0) |
289 | if (k > 0) |
293 | { |
290 | { |
294 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
291 | scr_scroll_text (0, (int)nrow - 1, -k); |
295 | screen.cur.row += k; |
292 | screen.cur.row += k; |
296 | screen.s_cur.row += k; |
293 | screen.s_cur.row += k; |
297 | nsaved -= k; |
294 | nsaved -= k; |
298 | } |
295 | } |
299 | |
296 | |
300 | #ifdef DEBUG_STRICT |
297 | #ifdef DEBUG_STRICT |
301 | assert (screen.cur.row < nrow); |
298 | assert (screen.cur.row < nrow); |
302 | #else /* drive with your eyes closed */ |
299 | #else /* drive with your eyes closed */ |
303 | MIN_IT (screen.cur.row, nrow - 1); |
300 | min_it (screen.cur.row, nrow - 1); |
304 | #endif |
301 | #endif |
305 | ncol = ocol; // save b/c scr_blank_screen_mem uses this |
302 | ncol = ocol; // save b/c scr_blank_screen_mem uses this |
306 | } |
303 | } |
307 | |
304 | |
308 | /* resize columns */ |
305 | /* resize columns */ |
… | |
… | |
318 | { |
315 | { |
319 | lresize (drawn[p]); |
316 | lresize (drawn[p]); |
320 | lresize (swap_save[p]); |
317 | lresize (swap_save[p]); |
321 | } |
318 | } |
322 | |
319 | |
323 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
320 | min_it (screen.cur.col, (int16_t)ncol - 1); |
324 | |
321 | |
325 | delete old_ta; |
322 | delete old_ta; |
326 | delete old_ra; |
323 | delete old_ra; |
327 | } |
324 | } |
328 | |
325 | |
… | |
… | |
518 | set_font_style (); |
515 | set_font_style (); |
519 | break; |
516 | break; |
520 | } |
517 | } |
521 | |
518 | |
522 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
519 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
523 | MIN_IT (s->cur.row, nrow - 1); |
520 | min_it (s->cur.row, nrow - 1); |
524 | MIN_IT (s->cur.col, ncol - 1); |
521 | min_it (s->cur.col, ncol - 1); |
525 | #ifdef DEBUG_STRICT |
522 | #ifdef DEBUG_STRICT |
526 | assert (s->cur.row >= 0); |
523 | assert (s->cur.row >= 0); |
527 | assert (s->cur.col >= 0); |
524 | assert (s->cur.col >= 0); |
528 | #else /* drive with your eyes closed */ |
525 | #else /* drive with your eyes closed */ |
529 | MAX_IT (s->cur.row, 0); |
526 | max_it (s->cur.row, 0); |
530 | MAX_IT (s->cur.col, 0); |
527 | max_it (s->cur.col, 0); |
531 | #endif |
528 | #endif |
532 | } |
529 | } |
533 | |
530 | |
534 | /* ------------------------------------------------------------------------- */ |
531 | /* ------------------------------------------------------------------------- */ |
535 | /* |
532 | /* |
… | |
… | |
538 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
535 | * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l |
539 | */ |
536 | */ |
540 | int |
537 | int |
541 | rxvt_term::scr_change_screen (int scrn) |
538 | rxvt_term::scr_change_screen (int scrn) |
542 | { |
539 | { |
543 | int i; |
|
|
544 | #if NSCREENS |
|
|
545 | int offset; |
|
|
546 | #endif |
|
|
547 | |
|
|
548 | want_refresh = 1; |
540 | want_refresh = 1; |
549 | |
|
|
550 | view_start = 0; |
541 | view_start = 0; |
551 | |
542 | |
552 | if (current_screen == scrn) |
543 | if (current_screen == scrn) |
553 | return scrn; |
544 | return scrn; |
554 | |
545 | |
555 | selection_check (2); /* check for boundary cross */ |
546 | selection_check (2); /* check for boundary cross */ |
556 | |
547 | |
557 | i = current_screen; current_screen = scrn; scrn = i; |
548 | int i = current_screen; current_screen = scrn; scrn = i; |
558 | |
549 | |
559 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
550 | ::swap (screen.cur.row, swap.cur.row); |
560 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
551 | ::swap (screen.cur.col, swap.cur.col); |
561 | MAX_IT (screen.cur.row, 0); |
552 | |
562 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
553 | screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); |
563 | MAX_IT (screen.cur.col, 0); |
554 | screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); |
564 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
565 | |
555 | |
566 | #if NSCREENS |
556 | #if NSCREENS |
567 | if (options & Opt_secondaryScreen) |
557 | if (options & Opt_secondaryScreen) |
568 | { |
558 | { |
569 | num_scr = 0; |
559 | num_scr = 0; |
570 | offset = saveLines; |
|
|
571 | |
560 | |
572 | for (i = prev_nrow; i--;) |
561 | for (int i = nrow; i--; ) |
573 | SWAP_IT (ROW(i), swap_save[i], line_t); |
562 | ::swap (ROW(i), swap_save[i]); |
574 | |
563 | |
575 | SWAP_IT (screen.charset, swap.charset, int16_t); |
564 | ::swap (screen.charset, swap.charset); |
576 | SWAP_IT (screen.flags, swap.flags, int); |
565 | ::swap (screen.flags, swap.flags); |
577 | screen.flags |= Screen_VisibleCursor; |
566 | screen.flags |= Screen_VisibleCursor; |
578 | swap.flags |= Screen_VisibleCursor; |
567 | swap.flags |= Screen_VisibleCursor; |
579 | } |
568 | } |
580 | else |
569 | else |
581 | #endif |
570 | #endif |
582 | if (options & Opt_secondaryScroll) |
571 | if (options & Opt_secondaryScroll) |
583 | scr_scroll_text (0, prev_nrow - 1, prev_nrow, 0); |
572 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
584 | |
573 | |
585 | return scrn; |
574 | return scrn; |
586 | } |
575 | } |
587 | |
576 | |
588 | // clear WrapNext indicator, solidifying position on next line |
577 | // clear WrapNext indicator, solidifying position on next line |
… | |
… | |
595 | screen.flags &= ~Screen_WrapNext; |
584 | screen.flags &= ~Screen_WrapNext; |
596 | |
585 | |
597 | screen.cur.col = 0; |
586 | screen.cur.col = 0; |
598 | |
587 | |
599 | if (screen.cur.row == screen.bscroll) |
588 | if (screen.cur.row == screen.bscroll) |
600 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
589 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
601 | else if (screen.cur.row < nrow - 1) |
590 | else if (screen.cur.row < nrow - 1) |
602 | screen.cur.row++; |
591 | screen.cur.row++; |
603 | } |
592 | } |
604 | |
593 | |
605 | /* ------------------------------------------------------------------------- */ |
594 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
636 | /* ------------------------------------------------------------------------- */ |
625 | /* ------------------------------------------------------------------------- */ |
637 | /* |
626 | /* |
638 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
627 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
639 | * count positive ==> scroll up |
628 | * count positive ==> scroll up |
640 | * count negative ==> scroll down |
629 | * count negative ==> scroll down |
641 | * spec == 0 for normal routines |
|
|
642 | */ |
630 | */ |
643 | int |
631 | int |
644 | rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) |
632 | rxvt_term::scr_scroll_text (int row1, int row2, int count) |
645 | { |
633 | { |
646 | int i, j; |
|
|
647 | |
|
|
648 | if (count == 0 || (row1 > row2)) |
634 | if (count == 0 || (row1 > row2)) |
649 | return 0; |
635 | return 0; |
650 | |
636 | |
651 | want_refresh = 1; |
637 | want_refresh = 1; |
|
|
638 | num_scr += count; |
652 | |
639 | |
653 | if (row1 == 0 && count > 0 |
640 | if (count > 0 |
|
|
641 | && row1 == 0 |
|
|
642 | && row2 == nrow - 1 |
654 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
643 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
655 | { |
644 | { |
656 | nsaved = min (nsaved + count, saveLines); |
645 | nsaved = min (nsaved + count, saveLines); |
657 | term_start = (term_start + count) % total_rows; |
646 | term_start = (term_start + count) % total_rows; |
658 | |
647 | |
659 | if (selection.op && current_screen == selection.screen) |
648 | if (selection.op && current_screen == selection.screen) |
660 | { |
649 | { |
661 | selection.beg.row -= count; |
650 | selection.beg.row -= count; |
662 | selection.end.row -= count; |
651 | selection.end.row -= count; |
663 | selection.mark.row -= count; |
652 | selection.mark.row -= count; |
|
|
653 | |
|
|
654 | selection_check (0); |
664 | } |
655 | } |
665 | |
656 | |
666 | for (int i = count; i--; ) |
657 | for (int i = count; i--; ) |
667 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
658 | scr_blank_screen_mem (ROW(row2 - i), rstyle); |
668 | |
659 | |
… | |
… | |
671 | && view_start != saveLines) |
662 | && view_start != saveLines) |
672 | scr_page (UP, count); |
663 | scr_page (UP, count); |
673 | } |
664 | } |
674 | else |
665 | else |
675 | { |
666 | { |
676 | if (!spec) |
|
|
677 | row1 += saveLines; |
|
|
678 | |
|
|
679 | row2 += saveLines; |
|
|
680 | |
|
|
681 | if (selection.op && current_screen == selection.screen) |
667 | if (selection.op && current_screen == selection.screen) |
682 | { |
668 | { |
683 | i = selection.beg.row + saveLines; |
669 | int i = selection.beg.row; |
684 | j = selection.end.row + saveLines; |
670 | int j = selection.end.row; |
685 | |
671 | |
686 | if ((i < row1 && j > row1) |
672 | if ((i < row1 && j > row1) |
687 | || (i < row2 && j > row2) |
673 | || (i < row2 && j > row2) |
688 | || (i - count < row1 && i >= row1) |
674 | || (i - count < row1 && i >= row1) |
689 | || (i - count > row2 && i <= row2) |
675 | || (i - count > row2 && i <= row2) |
… | |
… | |
697 | { |
683 | { |
698 | /* move selected region too */ |
684 | /* move selected region too */ |
699 | selection.beg.row -= count; |
685 | selection.beg.row -= count; |
700 | selection.end.row -= count; |
686 | selection.end.row -= count; |
701 | selection.mark.row -= count; |
687 | selection.mark.row -= count; |
|
|
688 | |
|
|
689 | selection_check (0); |
702 | } |
690 | } |
703 | } |
691 | } |
704 | |
692 | |
705 | selection_check (0); /* _after_ nsaved update */ |
693 | // use a simple and robust scrolling algorithm, this |
|
|
694 | // part of scr_scroll_text is not time-critical. |
706 | |
695 | |
707 | num_scr += count; |
|
|
708 | j = count; |
|
|
709 | |
|
|
710 | if (count < 0) |
|
|
711 | count = -count; |
|
|
712 | |
|
|
713 | i = row2 - row1 + 1; |
696 | int rows = row2 - row1 + 1; |
714 | MIN_IT (count, i); |
|
|
715 | |
697 | |
716 | if (j > 0) |
698 | for (int row = 0; row < rows; row++) |
717 | { |
|
|
718 | /* scroll up */ |
|
|
719 | |
|
|
720 | /* Copy lines that will get clobbered by the rotation */ |
|
|
721 | memcpy (buf, save + row1, count * sizeof (line_t)); |
|
|
722 | |
|
|
723 | /* Rotate lines */ |
|
|
724 | i = row2 - row1 - count + 1; |
|
|
725 | memmove (save + row1, save + row1 + count, i * sizeof (line_t)); |
|
|
726 | |
|
|
727 | j = row2 - count + 1, i = count; |
|
|
728 | } |
699 | { |
729 | else /* if (j < 0) */ |
700 | buf [row] = ROW(row1 + (row + count + rows) % rows); |
|
|
701 | |
|
|
702 | if (!IN_RANGE_EXC (row + count, 0, rows)) |
|
|
703 | scr_blank_screen_mem (buf [row], rstyle); |
730 | { |
704 | } |
731 | /* scroll down */ |
|
|
732 | |
705 | |
733 | /* Copy lines that will get clobbered by the rotation */ |
706 | for (int row = 0; row < rows; row++) |
734 | for (i = 0, j = row2; i < count; i++, j--) |
707 | ROW(row1 + row) = buf [row]; |
735 | buf[i] = save[j]; |
|
|
736 | |
|
|
737 | /* Rotate lines */ |
|
|
738 | for (j = row2, i = j - count; i >= row1; i--, j--) |
|
|
739 | save[j] = save[i]; |
|
|
740 | |
|
|
741 | j = row1, i = count; |
|
|
742 | count = -count; |
|
|
743 | } |
|
|
744 | |
|
|
745 | /* Resurrect lines */ |
|
|
746 | memcpy (save + j, buf, i * sizeof (line_t)); |
|
|
747 | |
|
|
748 | if (!spec) /* line length may not equal ncol */ |
|
|
749 | for (; i--; j++) |
|
|
750 | scr_blank_screen_mem (save[j], rstyle); |
|
|
751 | } |
708 | } |
752 | |
709 | |
753 | return count; |
710 | return count; |
754 | } |
711 | } |
755 | |
712 | |
… | |
… | |
778 | if ((nlines > 0) |
735 | if ((nlines > 0) |
779 | && (screen.tscroll == 0) |
736 | && (screen.tscroll == 0) |
780 | && (screen.bscroll == (nrow - 1))) |
737 | && (screen.bscroll == (nrow - 1))) |
781 | { |
738 | { |
782 | /* _at least_ this many lines need to be scrolled */ |
739 | /* _at least_ this many lines need to be scrolled */ |
783 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines, 0); |
740 | scr_scroll_text (screen.tscroll, screen.bscroll, nlines); |
784 | screen.cur.row -= nlines; |
741 | screen.cur.row -= nlines; |
785 | } |
742 | } |
786 | } |
743 | } |
787 | |
744 | |
788 | #ifdef DEBUG_STRICT |
745 | #ifdef DEBUG_STRICT |
789 | assert (screen.cur.col < last_col); |
746 | assert (screen.cur.col < last_col); |
790 | assert ((screen.cur.row < nrow) |
747 | assert ((screen.cur.row < nrow) |
791 | && (screen.cur.row >= - (int32_t)nsaved)); |
748 | && (screen.cur.row >= - (int32_t)nsaved)); |
792 | #else /* drive with your eyes closed */ |
749 | #else /* drive with your eyes closed */ |
793 | MIN_IT (screen.cur.col, last_col - 1); |
750 | min_it (screen.cur.col, last_col - 1); |
794 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
751 | min_it (screen.cur.row, (int32_t)nrow - 1); |
795 | MAX_IT (screen.cur.row, - (int32_t)nsaved); |
752 | max_it (screen.cur.row, - (int32_t)nsaved); |
796 | #endif |
753 | #endif |
797 | row = screen.cur.row; |
754 | row = screen.cur.row; |
798 | |
755 | |
799 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
756 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
800 | |
757 | |
… | |
… | |
806 | |
763 | |
807 | if (c < 0x20) |
764 | if (c < 0x20) |
808 | if (c == C0_LF) |
765 | if (c == C0_LF) |
809 | { |
766 | { |
810 | if (!line->is_longer ()) /* XXX: think about this */ |
767 | if (!line->is_longer ()) /* XXX: think about this */ |
811 | MAX_IT (line->l, screen.cur.col); |
768 | max_it (line->l, screen.cur.col); |
812 | |
769 | |
813 | screen.flags &= ~Screen_WrapNext; |
770 | screen.flags &= ~Screen_WrapNext; |
814 | |
771 | |
815 | if (screen.cur.row == screen.bscroll) |
772 | if (screen.cur.row == screen.bscroll) |
816 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
773 | scr_scroll_text (screen.tscroll, screen.bscroll, 1); |
817 | else if (screen.cur.row < (nrow - 1)) |
774 | else if (screen.cur.row < (nrow - 1)) |
818 | row = ++screen.cur.row; |
775 | row = ++screen.cur.row; |
819 | |
776 | |
820 | line = &ROW(row); /* _must_ refresh */ |
777 | line = &ROW(row); /* _must_ refresh */ |
821 | continue; |
778 | continue; |
822 | } |
779 | } |
823 | else if (c == C0_CR) |
780 | else if (c == C0_CR) |
824 | { |
781 | { |
825 | if (!line->is_longer ()) /* XXX: think about this */ |
782 | if (!line->is_longer ()) /* XXX: think about this */ |
826 | MAX_IT (line->l, screen.cur.col); |
783 | max_it (line->l, screen.cur.col); |
827 | |
784 | |
828 | screen.flags &= ~Screen_WrapNext; |
785 | screen.flags &= ~Screen_WrapNext; |
829 | screen.cur.col = 0; |
786 | screen.cur.col = 0; |
830 | continue; |
787 | continue; |
831 | } |
788 | } |
… | |
… | |
1007 | #endif |
964 | #endif |
1008 | } |
965 | } |
1009 | } |
966 | } |
1010 | |
967 | |
1011 | if (!line->is_longer ()) /* XXX: think about this */ |
968 | if (!line->is_longer ()) /* XXX: think about this */ |
1012 | MAX_IT (line->l, screen.cur.col); |
969 | max_it (line->l, screen.cur.col); |
1013 | |
970 | |
1014 | #ifdef DEBUG_STRICT |
971 | #ifdef DEBUG_STRICT |
1015 | assert (screen.cur.row >= 0); |
972 | assert (screen.cur.row >= 0); |
1016 | #else /* drive with your eyes closed */ |
973 | #else /* drive with your eyes closed */ |
1017 | MAX_IT (screen.cur.row, 0); |
974 | max_it (screen.cur.row, 0); |
1018 | #endif |
975 | #endif |
1019 | } |
976 | } |
1020 | |
977 | |
1021 | /* ------------------------------------------------------------------------- */ |
978 | /* ------------------------------------------------------------------------- */ |
1022 | /* |
979 | /* |
… | |
… | |
1088 | if (ht && options & Opt_pastableTabs) |
1045 | if (ht && options & Opt_pastableTabs) |
1089 | { |
1046 | { |
1090 | base_rend = SET_FONT (base_rend, 0); |
1047 | base_rend = SET_FONT (base_rend, 0); |
1091 | |
1048 | |
1092 | if (!l.is_longer ()) /* XXX: think about this */ |
1049 | if (!l.is_longer ()) /* XXX: think about this */ |
1093 | MAX_IT (l.l, x); |
1050 | max_it (l.l, x); |
1094 | |
1051 | |
1095 | i = screen.cur.col; |
1052 | i = screen.cur.col; |
1096 | |
1053 | |
1097 | l.t[i] = '\t'; |
1054 | l.t[i] = '\t'; |
1098 | l.r[i] = base_rend; |
1055 | l.r[i] = base_rend; |
… | |
… | |
1177 | { |
1134 | { |
1178 | want_refresh = 1; |
1135 | want_refresh = 1; |
1179 | ZERO_SCROLLBACK (); |
1136 | ZERO_SCROLLBACK (); |
1180 | |
1137 | |
1181 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1138 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1182 | MAX_IT (screen.cur.col, 0); |
1139 | max_it (screen.cur.col, 0); |
1183 | MIN_IT (screen.cur.col, (int32_t)ncol - 1); |
1140 | min_it (screen.cur.col, (int32_t)ncol - 1); |
1184 | |
1141 | |
1185 | screen.flags &= ~Screen_WrapNext; |
1142 | screen.flags &= ~Screen_WrapNext; |
1186 | |
1143 | |
1187 | if (relative & R_RELATIVE) |
1144 | if (relative & R_RELATIVE) |
1188 | { |
1145 | { |
… | |
… | |
1206 | else |
1163 | else |
1207 | { |
1164 | { |
1208 | if (screen.flags & Screen_Relative) |
1165 | if (screen.flags & Screen_Relative) |
1209 | { /* relative origin mode */ |
1166 | { /* relative origin mode */ |
1210 | screen.cur.row = row + screen.tscroll; |
1167 | screen.cur.row = row + screen.tscroll; |
1211 | MIN_IT (screen.cur.row, screen.bscroll); |
1168 | min_it (screen.cur.row, screen.bscroll); |
1212 | } |
1169 | } |
1213 | else |
1170 | else |
1214 | screen.cur.row = row; |
1171 | screen.cur.row = row; |
1215 | } |
1172 | } |
1216 | |
1173 | |
1217 | MAX_IT (screen.cur.row, 0); |
1174 | max_it (screen.cur.row, 0); |
1218 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
1175 | min_it (screen.cur.row, (int32_t)nrow - 1); |
1219 | } |
1176 | } |
1220 | |
1177 | |
1221 | /* ------------------------------------------------------------------------- */ |
1178 | /* ------------------------------------------------------------------------- */ |
1222 | /* |
1179 | /* |
1223 | * direction should be UP or DN |
1180 | * direction should be UP or DN |
… | |
… | |
1234 | |
1191 | |
1235 | screen.flags &= ~Screen_WrapNext; |
1192 | screen.flags &= ~Screen_WrapNext; |
1236 | |
1193 | |
1237 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1194 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1238 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1195 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1239 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn, 0); |
1196 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn); |
1240 | else |
1197 | else |
1241 | screen.cur.row += dirn; |
1198 | screen.cur.row += dirn; |
1242 | |
1199 | |
1243 | MAX_IT (screen.cur.row, 0); |
1200 | max_it (screen.cur.row, 0); |
1244 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
1201 | min_it (screen.cur.row, (int32_t)nrow - 1); |
1245 | selection_check (0); |
1202 | selection_check (0); |
1246 | } |
1203 | } |
1247 | |
1204 | |
1248 | /* ------------------------------------------------------------------------- */ |
1205 | /* ------------------------------------------------------------------------- */ |
1249 | /* |
1206 | /* |
… | |
… | |
1267 | switch (mode) |
1224 | switch (mode) |
1268 | { |
1225 | { |
1269 | case 0: /* erase to end of line */ |
1226 | case 0: /* erase to end of line */ |
1270 | col = screen.cur.col; |
1227 | col = screen.cur.col; |
1271 | num = ncol - col; |
1228 | num = ncol - col; |
1272 | MIN_IT (ROW(row).l, (int16_t)col); |
1229 | min_it (ROW(row).l, (int16_t)col); |
1273 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1230 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1274 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1231 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1275 | CLEAR_SELECTION (); |
1232 | CLEAR_SELECTION (); |
1276 | break; |
1233 | break; |
1277 | case 1: /* erase to beginning of line */ |
1234 | case 1: /* erase to beginning of line */ |
… | |
… | |
1305 | */ |
1262 | */ |
1306 | void |
1263 | void |
1307 | rxvt_term::scr_erase_screen (int mode) |
1264 | rxvt_term::scr_erase_screen (int mode) |
1308 | { |
1265 | { |
1309 | int num; |
1266 | int num; |
1310 | int32_t row, row_offset; |
1267 | int32_t row; |
1311 | rend_t ren; |
1268 | rend_t ren; |
1312 | XGCValues gcvalue; |
1269 | XGCValues gcvalue; |
1313 | |
1270 | |
1314 | want_refresh = 1; |
1271 | want_refresh = 1; |
1315 | ZERO_SCROLLBACK (); |
1272 | ZERO_SCROLLBACK (); |
1316 | |
|
|
1317 | row_offset = (int32_t)saveLines; |
|
|
1318 | |
1273 | |
1319 | switch (mode) |
1274 | switch (mode) |
1320 | { |
1275 | { |
1321 | case 0: /* erase to end of screen */ |
1276 | case 0: /* erase to end of screen */ |
1322 | selection_check (1); |
1277 | selection_check (1); |
… | |
… | |
1346 | CLEAR_SELECTION (); |
1301 | CLEAR_SELECTION (); |
1347 | |
1302 | |
1348 | if (row >= nrow) /* Out Of Bounds */ |
1303 | if (row >= nrow) /* Out Of Bounds */ |
1349 | return; |
1304 | return; |
1350 | |
1305 | |
1351 | MIN_IT (num, (nrow - row)); |
1306 | min_it (num, (nrow - row)); |
1352 | |
1307 | |
1353 | if (rstyle & (RS_RVid | RS_Uline)) |
1308 | if (rstyle & (RS_RVid | RS_Uline)) |
1354 | ren = (rend_t) ~RS_None; |
1309 | ren = (rend_t) ~RS_None; |
1355 | else if (GET_BASEBG (rstyle) == Color_bg) |
1310 | else if (GET_BASEBG (rstyle) == Color_bg) |
1356 | { |
1311 | { |
… | |
… | |
1367 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1322 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1368 | } |
1323 | } |
1369 | |
1324 | |
1370 | for (; num--; row++) |
1325 | for (; num--; row++) |
1371 | { |
1326 | { |
1372 | scr_blank_screen_mem (save[row + row_offset], rstyle); |
1327 | scr_blank_screen_mem (ROW (row), rstyle); |
1373 | save[row + row_offset].l = 0; |
1328 | ROW (row).l = 0; |
1374 | scr_blank_line (drawn[row], 0, ncol, ren); |
1329 | scr_blank_line (drawn[row], 0, ncol, ren); |
1375 | } |
1330 | } |
1376 | } |
1331 | } |
1377 | |
1332 | |
1378 | #if ENABLE_FRILLS |
1333 | #if ENABLE_FRILLS |
… | |
… | |
1392 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1347 | * XTERM_SEQ: Screen Alignment Test: ESC # 8 |
1393 | */ |
1348 | */ |
1394 | void |
1349 | void |
1395 | rxvt_term::scr_E () |
1350 | rxvt_term::scr_E () |
1396 | { |
1351 | { |
1397 | int i, j, k; |
|
|
1398 | rend_t *r1, fs; |
1352 | rend_t fs; |
1399 | |
1353 | |
1400 | want_refresh = 1; |
1354 | want_refresh = 1; |
1401 | ZERO_SCROLLBACK (); |
1355 | ZERO_SCROLLBACK (); |
1402 | |
1356 | |
1403 | num_scr_allow = 0; |
1357 | num_scr_allow = 0; |
1404 | selection_check (3); |
1358 | selection_check (3); |
1405 | |
1359 | |
1406 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1360 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1407 | for (k = saveLines, i = nrow; i--; k++) |
1361 | for (int row = nrow; row--; ) |
1408 | { |
1362 | { |
1409 | line_t &line = save[k]; |
1363 | line_t &line = ROW(row); |
1410 | |
1364 | |
1411 | fill_text (line.t, 'E', ncol); |
1365 | fill_text (line.t, 'E', ncol); |
|
|
1366 | rend_t *r1 = line.r; |
1412 | |
1367 | |
1413 | for (r1 = line.r, j = ncol; j--; ) |
1368 | for (int j = ncol; j--; ) |
1414 | *r1++ = fs; |
1369 | *r1++ = fs; |
1415 | |
1370 | |
1416 | line.l = ncol; /* make the `E's selectable */ |
1371 | line.l = ncol; /* make the `E's selectable */ |
1417 | } |
1372 | } |
1418 | } |
1373 | } |
… | |
… | |
1442 | count = end; |
1397 | count = end; |
1443 | } |
1398 | } |
1444 | |
1399 | |
1445 | scr_do_wrap (); |
1400 | scr_do_wrap (); |
1446 | |
1401 | |
1447 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count, 0); |
1402 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count); |
1448 | } |
1403 | } |
1449 | |
1404 | |
1450 | /* ------------------------------------------------------------------------- */ |
1405 | /* ------------------------------------------------------------------------- */ |
1451 | /* |
1406 | /* |
1452 | * Insert/Delete <count> characters from the current position |
1407 | * Insert/Delete <count> characters from the current position |
… | |
… | |
1464 | return; |
1419 | return; |
1465 | |
1420 | |
1466 | scr_do_wrap (); |
1421 | scr_do_wrap (); |
1467 | |
1422 | |
1468 | selection_check (1); |
1423 | selection_check (1); |
1469 | MIN_IT (count, (ncol - screen.cur.col)); |
1424 | min_it (count, (ncol - screen.cur.col)); |
1470 | |
1425 | |
1471 | row = screen.cur.row + saveLines; |
1426 | row = screen.cur.row; |
1472 | |
1427 | |
1473 | line_t *line = save + row; |
1428 | line_t *line = &ROW(row); |
1474 | |
1429 | |
1475 | switch (insdel) |
1430 | switch (insdel) |
1476 | { |
1431 | { |
1477 | case INSERT: |
1432 | case INSERT: |
1478 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1433 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
… | |
… | |
1482 | } |
1437 | } |
1483 | |
1438 | |
1484 | if (!line->is_longer ()) |
1439 | if (!line->is_longer ()) |
1485 | { |
1440 | { |
1486 | line->l += count; |
1441 | line->l += count; |
1487 | MIN_IT (line->l, ncol); |
1442 | min_it (line->l, ncol); |
1488 | } |
1443 | } |
1489 | |
1444 | |
1490 | if (selection.op && current_screen == selection.screen |
1445 | if (selection.op && current_screen == selection.screen |
1491 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1446 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1492 | { |
1447 | { |
… | |
… | |
1499 | selection.mark.col += count; /* XXX: yes? */ |
1454 | selection.mark.col += count; /* XXX: yes? */ |
1500 | selection.end.col += count; |
1455 | selection.end.col += count; |
1501 | } |
1456 | } |
1502 | } |
1457 | } |
1503 | |
1458 | |
1504 | scr_blank_line (save[row], screen.cur.col, count, rstyle); |
1459 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1505 | break; |
1460 | break; |
1506 | |
1461 | |
1507 | case ERASE: |
1462 | case ERASE: |
1508 | screen.cur.col += count; /* don't worry if > ncol */ |
1463 | screen.cur.col += count; /* don't worry if > ncol */ |
1509 | selection_check (1); |
1464 | selection_check (1); |
1510 | screen.cur.col -= count; |
1465 | screen.cur.col -= count; |
1511 | scr_blank_line (save[row], screen.cur.col, count, rstyle); |
1466 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1512 | break; |
1467 | break; |
1513 | |
1468 | |
1514 | case DELETE: |
1469 | case DELETE: |
1515 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1470 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1516 | |
1471 | |
… | |
… | |
1523 | scr_blank_line (*line, ncol - count, count, tr); |
1478 | scr_blank_line (*line, ncol - count, count, tr); |
1524 | |
1479 | |
1525 | if (line->is_longer ()) /* break line continuation */ |
1480 | if (line->is_longer ()) /* break line continuation */ |
1526 | line->l = ncol; |
1481 | line->l = ncol; |
1527 | |
1482 | |
1528 | line->l -= count; |
1483 | max_it (line->l - count, 0); |
1529 | MAX_IT (line->l, 0); |
|
|
1530 | |
1484 | |
1531 | if (selection.op && current_screen == selection.screen |
1485 | if (selection.op && current_screen == selection.screen |
1532 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1486 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1533 | { |
1487 | { |
1534 | if (selection.end.row != screen.cur.row |
1488 | if (selection.end.row != screen.cur.row |
… | |
… | |
1554 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1508 | * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r |
1555 | */ |
1509 | */ |
1556 | void |
1510 | void |
1557 | rxvt_term::scr_scroll_region (int top, int bot) |
1511 | rxvt_term::scr_scroll_region (int top, int bot) |
1558 | { |
1512 | { |
1559 | MAX_IT (top, 0); |
1513 | max_it (top, 0); |
1560 | MIN_IT (bot, (int)nrow - 1); |
1514 | min_it (bot, (int)nrow - 1); |
1561 | |
1515 | |
1562 | if (top > bot) |
1516 | if (top > bot) |
1563 | return; |
1517 | return; |
1564 | |
1518 | |
1565 | screen.tscroll = top; |
1519 | screen.tscroll = top; |
… | |
… | |
1663 | XGCValues gcvalue; |
1617 | XGCValues gcvalue; |
1664 | |
1618 | |
1665 | if (rvideo != mode) |
1619 | if (rvideo != mode) |
1666 | { |
1620 | { |
1667 | rvideo = mode; |
1621 | rvideo = mode; |
1668 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1622 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1669 | #if XPM_BACKGROUND |
1623 | #if XPM_BACKGROUND |
1670 | if (bgPixmap.pixmap == None) |
1624 | if (bgPixmap.pixmap == None) |
1671 | #endif |
1625 | #endif |
1672 | #if TRANSPARENT |
1626 | #if TRANSPARENT |
1673 | if (! (options & Opt_transparent) || am_transparent == 0) |
1627 | if (! (options & Opt_transparent) || am_transparent == 0) |
… | |
… | |
1809 | eheight = height; |
1763 | eheight = height; |
1810 | } |
1764 | } |
1811 | #endif |
1765 | #endif |
1812 | |
1766 | |
1813 | #ifdef DEBUG_STRICT |
1767 | #ifdef DEBUG_STRICT |
1814 | x = max (x, 0); |
1768 | #if 0 |
1815 | x = min (x, (int)width); |
1769 | // that's not debugging //TODO //FIXME |
1816 | y = max (y, 0); |
1770 | clamp_it (x, 0, width); |
1817 | y = min (y, (int)height); |
1771 | clamp_it (y, 0, height); |
|
|
1772 | #endif |
1818 | #endif |
1773 | #endif |
1819 | |
1774 | |
1820 | /* round down */ |
1775 | /* round down */ |
1821 | rc[PART_BEG].col = Pixel2Col (x); |
1776 | rc[PART_BEG].col = Pixel2Col (x); |
1822 | rc[PART_BEG].row = Pixel2Row (y); |
1777 | rc[PART_BEG].row = Pixel2Row (y); |
… | |
… | |
1825 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1780 | rc[PART_END].row = Pixel2Row (y + eheight + fheight - 1); |
1826 | |
1781 | |
1827 | /* sanity checks */ |
1782 | /* sanity checks */ |
1828 | for (i = PART_BEG; i < RC_COUNT; i++) |
1783 | for (i = PART_BEG; i < RC_COUNT; i++) |
1829 | { |
1784 | { |
1830 | MIN_IT (rc[i].col, ncol - 1); |
1785 | min_it (rc[i].col, ncol - 1); |
1831 | MIN_IT (rc[i].row, nrow - 1); |
1786 | min_it (rc[i].row, nrow - 1); |
1832 | } |
1787 | } |
1833 | |
1788 | |
1834 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1789 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1835 | fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1790 | fill_text (&drawn[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1836 | |
1791 | |
… | |
… | |
1941 | /* ARGSUSED */ |
1896 | /* ARGSUSED */ |
1942 | void |
1897 | void |
1943 | rxvt_term::scr_printscreen (int fullhist) |
1898 | rxvt_term::scr_printscreen (int fullhist) |
1944 | { |
1899 | { |
1945 | #ifdef PRINTPIPE |
1900 | #ifdef PRINTPIPE |
1946 | int i, r1, nrows, row_offset; |
1901 | int nrows, row_start; |
1947 | FILE *fd; |
1902 | FILE *fd; |
1948 | |
1903 | |
1949 | if ((fd = popen_printer ()) == NULL) |
1904 | if ((fd = popen_printer ()) == NULL) |
1950 | return; |
1905 | return; |
1951 | |
1906 | |
1952 | nrows = nrow; |
|
|
1953 | row_offset = saveLines; |
|
|
1954 | |
|
|
1955 | if (!fullhist) |
1907 | if (fullhist) |
1956 | row_offset -= view_start; |
1908 | { |
|
|
1909 | nrows = nrow + nsaved; |
|
|
1910 | row_start = -nsaved; |
|
|
1911 | } |
1957 | else |
1912 | else |
1958 | { |
1913 | { |
1959 | nrows += nsaved; |
1914 | nrows = nrow; |
1960 | row_offset -= nsaved; |
1915 | row_start = -view_start; |
1961 | } |
1916 | } |
1962 | |
1917 | |
1963 | wctomb (0, 0); |
1918 | wctomb (0, 0); |
1964 | |
1919 | |
1965 | for (r1 = 0; r1 < nrows; r1++) |
1920 | for (int r1 = 0; r1 < nrows; r1++) |
1966 | { |
1921 | { |
1967 | text_t *tp = save[r1 + row_offset].t; |
1922 | text_t *tp = ROW(r1).t; |
1968 | int len = save[r1 + row_offset].l; |
1923 | int len = ROW(r1).l; |
1969 | |
1924 | |
1970 | for (i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1925 | for (int i = len >= 0 ? len : ncol - 1; i--; ) //TODO//FIXME//LEN |
1971 | { |
1926 | { |
1972 | char mb[MB_LEN_MAX]; |
1927 | char mb[MB_LEN_MAX]; |
1973 | text_t t = *tp++; |
1928 | text_t t = *tp++; |
1974 | if (t == NOCHAR) |
1929 | if (t == NOCHAR) |
1975 | continue; |
1930 | continue; |
… | |
… | |
2003 | { |
1958 | { |
2004 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1959 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
2005 | showcursor; /* show the cursor */ |
1960 | showcursor; /* show the cursor */ |
2006 | int16_t col, row, /* column/row we're processing */ |
1961 | int16_t col, row, /* column/row we're processing */ |
2007 | ocrow; /* old cursor row */ |
1962 | ocrow; /* old cursor row */ |
2008 | int i, /* tmp */ |
1963 | int i; /* tmp */ |
2009 | row_offset; /* basic offset in screen structure */ |
|
|
2010 | #ifndef NO_CURSORCOLOR |
1964 | #ifndef NO_CURSORCOLOR |
2011 | rend_t cc1; /* store colours at cursor position (s) */ |
1965 | rend_t cc1; /* store colours at cursor position (s) */ |
2012 | #endif |
1966 | #endif |
2013 | rend_t *crp; // cursor rendition pointer |
1967 | rend_t *crp; // cursor rendition pointer |
2014 | |
1968 | |
… | |
… | |
2020 | /* |
1974 | /* |
2021 | * A: set up vars |
1975 | * A: set up vars |
2022 | */ |
1976 | */ |
2023 | must_clear = 0; |
1977 | must_clear = 0; |
2024 | refresh_count = 0; |
1978 | refresh_count = 0; |
2025 | |
|
|
2026 | row_offset = term_start - view_start; |
|
|
2027 | |
1979 | |
2028 | #if XPM_BACKGROUND |
1980 | #if XPM_BACKGROUND |
2029 | must_clear |= bgPixmap.pixmap != None; |
1981 | must_clear |= bgPixmap.pixmap != None; |
2030 | #endif |
1982 | #endif |
2031 | #if TRANSPARENT |
1983 | #if TRANSPARENT |
… | |
… | |
2135 | * D: CopyArea pass - very useful for slower links |
2087 | * D: CopyArea pass - very useful for slower links |
2136 | * This has been deliberately kept simple. |
2088 | * This has been deliberately kept simple. |
2137 | */ |
2089 | */ |
2138 | i = num_scr; |
2090 | i = num_scr; |
2139 | if (!display->is_local |
2091 | if (!display->is_local |
2140 | && refresh_type == FAST_REFRESH && num_scr_allow && i |
2092 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2141 | && abs (i) < nrow && !must_clear) |
2093 | && abs (num_scr) < nrow && !must_clear) |
2142 | { |
2094 | { |
2143 | int16_t nits; |
2095 | int16_t nits; |
2144 | int j; |
2096 | int j; |
2145 | int len, wlen; |
2097 | int len, wlen; |
2146 | |
2098 | |
… | |
… | |
2149 | row = i > 0 ? 0 : j - 1; |
2101 | row = i > 0 ? 0 : j - 1; |
2150 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2102 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2151 | { |
2103 | { |
2152 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2104 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2153 | { |
2105 | { |
2154 | line_t s = save[(row + row_offset) % nlines]; |
2106 | line_t s = ROW(row - view_start); |
2155 | line_t d = drawn[row]; |
2107 | line_t d = drawn[row]; |
2156 | line_t d2 = drawn[row + i]; |
2108 | line_t d2 = drawn[row + i]; |
2157 | |
2109 | |
2158 | for (nits = 0, col = ncol; col--; ) |
2110 | for (nits = 0, col = ncol; col--; ) |
2159 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
2111 | if (s.t[col] != d2.t[col] || s.r[col] != d2.r[col]) |
… | |
… | |
2179 | |
2131 | |
2180 | if (len != -1) |
2132 | if (len != -1) |
2181 | { |
2133 | { |
2182 | /* also comes here at end if needed because of >= above */ |
2134 | /* also comes here at end if needed because of >= above */ |
2183 | if (wlen < len) |
2135 | if (wlen < len) |
2184 | SWAP_IT (wlen, len, int); |
2136 | ::swap (wlen, len); |
2185 | |
2137 | |
2186 | XCopyArea (display->display, vt, vt, |
2138 | XCopyArea (display->display, vt, vt, |
2187 | gc, 0, Row2Pixel (len + i), |
2139 | gc, 0, Row2Pixel (len + i), |
2188 | (unsigned int)TermWin_TotalWidth (), |
2140 | (unsigned int)TermWin_TotalWidth (), |
2189 | (unsigned int)Height2Pixel (wlen - len + 1), |
2141 | (unsigned int)Height2Pixel (wlen - len + 1), |
… | |
… | |
2197 | /* |
2149 | /* |
2198 | * E: main pass across every character |
2150 | * E: main pass across every character |
2199 | */ |
2151 | */ |
2200 | for (row = 0; row < nrow; row++) |
2152 | for (row = 0; row < nrow; row++) |
2201 | { |
2153 | { |
2202 | text_t *stp = save[(row + row_offset) % total_rows].t; |
2154 | text_t *stp = ROW(row - view_start).t; |
2203 | rend_t *srp = save[(row + row_offset) % total_rows].r; |
2155 | rend_t *srp = ROW(row - view_start).r; |
2204 | text_t *dtp = drawn[row].t; |
2156 | text_t *dtp = drawn[row].t; |
2205 | rend_t *drp = drawn[row].r; |
2157 | rend_t *drp = drawn[row].r; |
2206 | |
2158 | |
2207 | /* |
2159 | /* |
2208 | * E2: OK, now the real pass |
2160 | * E2: OK, now the real pass |
… | |
… | |
2321 | fore = Color_UL; |
2273 | fore = Color_UL; |
2322 | #endif |
2274 | #endif |
2323 | |
2275 | |
2324 | if (invert) |
2276 | if (invert) |
2325 | { |
2277 | { |
2326 | SWAP_IT (fore, back, int); |
2278 | ::swap (fore, back); |
2327 | |
2279 | |
2328 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2280 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2329 | if (ISSET_PIXCOLOR (Color_RV)) |
2281 | if (ISSET_PIXCOLOR (Color_RV)) |
2330 | back = Color_RV; |
2282 | back = Color_RV; |
2331 | |
2283 | |
… | |
… | |
3073 | want_refresh = 1; |
3025 | want_refresh = 1; |
3074 | |
3026 | |
3075 | selection.mark.row = row - view_start; |
3027 | selection.mark.row = row - view_start; |
3076 | selection.mark.col = col; |
3028 | selection.mark.col = col; |
3077 | |
3029 | |
3078 | selection.mark.row = min (max (selection.mark.row, -nsaved), nrow - 1); |
3030 | selection.mark.row = clamp (selection.mark.row, -nsaved, nrow - 1); |
3079 | selection.mark.col = min (max (selection.mark.col, 0), ncol - 1); |
3031 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3080 | |
3032 | |
3081 | while (selection.mark.col > 0 |
3033 | while (selection.mark.col > 0 |
3082 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3034 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3083 | --selection.mark.col; |
3035 | --selection.mark.col; |
3084 | |
3036 | |
… | |
… | |
3189 | * flag == 2 ==> button 3 motion |
3141 | * flag == 2 ==> button 3 motion |
3190 | */ |
3142 | */ |
3191 | void |
3143 | void |
3192 | rxvt_term::selection_extend (int x, int y, int flag) |
3144 | rxvt_term::selection_extend (int x, int y, int flag) |
3193 | { |
3145 | { |
3194 | int col = min (max (Pixel2Col (x), 0), nrow - 1); |
3146 | int col = clamp (Pixel2Col (x), 0, ncol); |
3195 | int row = min (max (Pixel2Row (y), 0), ncol); |
3147 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3196 | |
3148 | |
3197 | /* |
3149 | /* |
3198 | * If we're selecting characters (single click) then we must check first |
3150 | * If we're selecting characters (single click) then we must check first |
3199 | * if we are at the same place as the original mark. If we are then |
3151 | * if we are at the same place as the original mark. If we are then |
3200 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
3152 | * select nothing. Otherwise, if we're to the right of the mark, you have to |
… | |
… | |
3371 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3323 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3372 | { |
3324 | { |
3373 | if (!ROW(end_row).is_longer ()) |
3325 | if (!ROW(end_row).is_longer ()) |
3374 | { |
3326 | { |
3375 | selection.end.row = end_row; |
3327 | selection.end.row = end_row; |
3376 | selection.end.col = save[end_row + saveLines].l; |
3328 | selection.end.col = ROW(end_row).l; |
3377 | selection_remove_trailing_spaces (); |
3329 | selection_remove_trailing_spaces (); |
3378 | break; |
3330 | break; |
3379 | } |
3331 | } |
3380 | } |
3332 | } |
3381 | } |
3333 | } |
… | |
… | |
3413 | } |
3365 | } |
3414 | } |
3366 | } |
3415 | |
3367 | |
3416 | #if ENABLE_FRILLS |
3368 | #if ENABLE_FRILLS |
3417 | if (selection.rect && selection.beg.col > selection.end.col) |
3369 | if (selection.rect && selection.beg.col > selection.end.col) |
3418 | SWAP_IT (selection.beg.col, selection.end.col, int); |
3370 | ::swap (selection.beg.col, selection.end.col); |
3419 | #endif |
3371 | #endif |
3420 | } |
3372 | } |
3421 | |
3373 | |
3422 | #if ENABLE_FRILLS |
3374 | #if ENABLE_FRILLS |
3423 | void |
3375 | void |
… | |
… | |
3621 | */ |
3573 | */ |
3622 | void |
3574 | void |
3623 | rxvt_term::pixel_position (int *x, int *y) |
3575 | rxvt_term::pixel_position (int *x, int *y) |
3624 | { |
3576 | { |
3625 | *x = Pixel2Col (*x); |
3577 | *x = Pixel2Col (*x); |
3626 | /* MAX_IT (*x, 0); MIN_IT (*x, (int)ncol - 1); */ |
3578 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3627 | *y = Pixel2Row (*y); |
3579 | *y = Pixel2Row (*y); |
3628 | /* MAX_IT (*y, 0); MIN_IT (*y, (int)nrow - 1); */ |
3580 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3629 | } |
3581 | } |
3630 | |
3582 | |
3631 | /* ------------------------------------------------------------------------- */ |
3583 | /* ------------------------------------------------------------------------- */ |
3632 | #ifdef USE_XIM |
3584 | #ifdef USE_XIM |
3633 | void |
3585 | void |
… | |
… | |
3655 | |
3607 | |
3656 | if (x < 0) x = ncol - w; |
3608 | if (x < 0) x = ncol - w; |
3657 | if (y < 0) y = nrow - h; |
3609 | if (y < 0) y = nrow - h; |
3658 | |
3610 | |
3659 | // make space for border |
3611 | // make space for border |
3660 | w += 2; MIN_IT (w, ncol); |
3612 | w += 2; min_it (w, ncol); |
3661 | h += 2; MIN_IT (h, nrow); |
3613 | h += 2; min_it (h, nrow); |
3662 | |
3614 | |
3663 | x -= 1; MAX_IT (x, 0); |
3615 | x -= 1; max_it (x, 0); |
3664 | y -= 1; MAX_IT (y, 0); |
3616 | y -= 1; max_it (y, 0); |
3665 | |
3617 | |
3666 | MIN_IT (x, ncol - w); |
3618 | min_it (x, ncol - w); |
3667 | MIN_IT (y, nrow - h); |
3619 | min_it (y, nrow - h); |
3668 | |
3620 | |
3669 | ov_x = x; ov_y = y; |
3621 | ov_x = x; ov_y = y; |
3670 | ov_w = w; ov_h = h; |
3622 | ov_w = w; ov_h = h; |
3671 | |
3623 | |
3672 | ov_text = new text_t *[h]; |
3624 | ov_text = new text_t *[h]; |