… | |
… | |
23 | /* |
23 | /* |
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 | #define INTERN_SCREEN |
|
|
29 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
30 | #include "screen.intpro" /* PROTOS for internal routines */ |
|
|
31 | |
29 | |
32 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
30 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
33 | |
31 | |
34 | #include <inttypes.h> |
32 | #include <inttypes.h> |
35 | #include <wchar.h> |
33 | #include <wchar.h> |
… | |
… | |
41 | while (len--) |
39 | while (len--) |
42 | *start++ = value; |
40 | *start++ = value; |
43 | } |
41 | } |
44 | |
42 | |
45 | /* ------------------------------------------------------------------------- */ |
43 | /* ------------------------------------------------------------------------- */ |
46 | #define PROP_SIZE 16384 |
44 | #define PROP_SIZE 256*1024 |
|
|
45 | #define PASTE_SIZE 32768 |
47 | #define TABSIZE 8 /* default tab size */ |
46 | #define TABSIZE 8 /* default tab size */ |
48 | |
47 | |
49 | /* ------------------------------------------------------------------------- * |
48 | /* ------------------------------------------------------------------------- * |
50 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
49 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
51 | * ------------------------------------------------------------------------- */ |
50 | * ------------------------------------------------------------------------- */ |
52 | #define ZERO_SCROLLBACK() \ |
51 | #define ZERO_SCROLLBACK() \ |
53 | if (Options & Opt_scrollTtyOutput) \ |
52 | if (options & Opt_scrollTtyOutput) \ |
54 | TermWin.view_start = 0 |
53 | TermWin.view_start = 0 |
55 | #define CLEAR_SELECTION() \ |
54 | #define CLEAR_SELECTION() \ |
56 | selection.beg.row = selection.beg.col \ |
55 | selection.beg.row = selection.beg.col \ |
57 | = selection.end.row = selection.end.col = 0 |
56 | = selection.end.row = selection.end.col = 0 |
58 | #define CLEAR_ALL_SELECTION() \ |
57 | #define CLEAR_ALL_SELECTION() \ |
… | |
… | |
113 | (unsigned int)Height2Pixel (num)) |
112 | (unsigned int)Height2Pixel (num)) |
114 | |
113 | |
115 | /* ------------------------------------------------------------------------- * |
114 | /* ------------------------------------------------------------------------- * |
116 | * SCREEN `COMMON' ROUTINES * |
115 | * SCREEN `COMMON' ROUTINES * |
117 | * ------------------------------------------------------------------------- */ |
116 | * ------------------------------------------------------------------------- */ |
|
|
117 | |
118 | /* Fill part/all of a line with blanks. */ |
118 | /* Fill part/all of a line with blanks. */ |
119 | void |
119 | void |
120 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
120 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
121 | { |
121 | { |
122 | efs &= ~RS_baseattrMask; |
122 | efs &= ~RS_baseattrMask; |
123 | efs = SET_FONT (efs, TermWin.ascii_map [' ' - 0x20]); |
123 | efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); |
124 | |
124 | |
125 | while (width--) |
125 | while (width--) |
126 | { |
126 | { |
127 | *et++ = ' '; |
127 | *et++ = ' '; |
128 | *er++ = efs; |
128 | *er++ = efs; |
… | |
… | |
155 | unsigned int ncol, nrow, total_rows, prev_total_rows; |
155 | unsigned int ncol, nrow, total_rows, prev_total_rows; |
156 | unsigned int p, q; |
156 | unsigned int p, q; |
157 | int k; |
157 | int k; |
158 | rend_t setrstyle; |
158 | rend_t setrstyle; |
159 | |
159 | |
160 | D_SCREEN ((stderr, "rxvt_scr_reset ()")); |
160 | #if ENABLE_OVERLAY |
|
|
161 | scr_overlay_off (); |
|
|
162 | #endif |
161 | |
163 | |
162 | TermWin.view_start = 0; |
164 | TermWin.view_start = 0; |
163 | num_scr = 0; |
165 | num_scr = 0; |
164 | |
166 | |
165 | if (TermWin.ncol == 0) |
167 | if (TermWin.ncol == 0) |
… | |
… | |
222 | scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE); |
224 | scr_blank_screen_mem (swap.text, swap.rend, p, DEFAULT_RSTYLE); |
223 | screen.tlen[q] = swap.tlen[p] = 0; |
225 | screen.tlen[q] = swap.tlen[p] = 0; |
224 | scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE); |
226 | scr_blank_screen_mem (drawn_text, drawn_rend, p, DEFAULT_RSTYLE); |
225 | } |
227 | } |
226 | |
228 | |
227 | MEMSET (charsets, 'B', sizeof (charsets)); |
229 | memset (charsets, 'B', sizeof (charsets)); |
228 | TermWin.nscrolled = 0; /* no saved lines */ |
230 | TermWin.nscrolled = 0; /* no saved lines */ |
229 | rstyle = DEFAULT_RSTYLE; |
231 | rstyle = DEFAULT_RSTYLE; |
230 | screen.flags = Screen_DefaultFlags; |
232 | screen.flags = Screen_DefaultFlags; |
231 | screen.cur.row = screen.cur.col = 0; |
233 | screen.cur.row = screen.cur.col = 0; |
232 | screen.charset = 0; |
234 | screen.charset = 0; |
… | |
… | |
292 | ralloc->free (drawn_rend[p]); |
294 | ralloc->free (drawn_rend[p]); |
293 | } |
295 | } |
294 | |
296 | |
295 | /* we have fewer rows so fix up cursor position */ |
297 | /* we have fewer rows so fix up cursor position */ |
296 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
298 | MIN_IT (screen.cur.row, (int32_t)nrow - 1); |
297 | MIN_IT (swap.cur.row, (int32_t)nrow - 1); |
|
|
298 | |
299 | |
299 | scr_reset_realloc (); /* realloc _last_ */ |
300 | scr_reset_realloc (); /* realloc _last_ */ |
300 | } |
301 | } |
301 | else if (nrow > prev_nrow) |
302 | else if (nrow > prev_nrow) |
302 | { |
303 | { |
… | |
… | |
333 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
334 | scr_scroll_text (0, (int)nrow - 1, -k, 1); |
334 | screen.cur.row += k; |
335 | screen.cur.row += k; |
335 | screen.s_cur.row += k; |
336 | screen.s_cur.row += k; |
336 | TermWin.nscrolled -= k; |
337 | TermWin.nscrolled -= k; |
337 | } |
338 | } |
|
|
339 | |
338 | #ifdef DEBUG_STRICT |
340 | #ifdef DEBUG_STRICT |
339 | assert (screen.cur.row < TermWin.nrow); |
341 | assert (screen.cur.row < TermWin.nrow); |
340 | assert (swap.cur.row < TermWin.nrow); |
|
|
341 | #else /* drive with your eyes closed */ |
342 | #else /* drive with your eyes closed */ |
342 | |
|
|
343 | MIN_IT (screen.cur.row, nrow - 1); |
343 | MIN_IT (screen.cur.row, nrow - 1); |
344 | MIN_IT (swap.cur.row, nrow - 1); |
|
|
345 | #endif |
344 | #endif |
346 | TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this |
345 | TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this |
347 | } |
346 | } |
348 | |
347 | |
349 | /* resize columns */ |
348 | /* resize columns */ |
… | |
… | |
392 | } |
391 | } |
393 | |
392 | |
394 | } |
393 | } |
395 | |
394 | |
396 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
395 | MIN_IT (screen.cur.col, (int16_t)ncol - 1); |
397 | MIN_IT (swap.cur.col, (int16_t)ncol - 1); |
|
|
398 | |
396 | |
399 | delete talloc; talloc = ta; |
397 | delete talloc; talloc = ta; |
400 | delete ralloc; ralloc = ra; |
398 | delete ralloc; ralloc = ra; |
401 | } |
399 | } |
402 | |
400 | |
… | |
… | |
416 | } |
414 | } |
417 | |
415 | |
418 | void |
416 | void |
419 | rxvt_term::scr_reset_realloc () |
417 | rxvt_term::scr_reset_realloc () |
420 | { |
418 | { |
421 | uint16_t total_rows, nrow; |
419 | unsigned int total_rows, nrow; |
422 | |
420 | |
423 | nrow = TermWin.nrow; |
421 | nrow = TermWin.nrow; |
424 | total_rows = nrow + TermWin.saveLines; |
422 | total_rows = nrow + TermWin.saveLines; |
425 | /* *INDENT-OFF* */ |
423 | /* *INDENT-OFF* */ |
426 | screen.text = (text_t **)rxvt_realloc (screen.text, total_rows * sizeof (text_t *)); |
424 | screen.text = (text_t **)rxvt_realloc (screen.text, total_rows * sizeof (text_t *)); |
… | |
… | |
443 | * Free everything. That way malloc debugging can find leakage. |
441 | * Free everything. That way malloc debugging can find leakage. |
444 | */ |
442 | */ |
445 | void |
443 | void |
446 | rxvt_term::scr_release () |
444 | rxvt_term::scr_release () |
447 | { |
445 | { |
448 | uint16_t total_rows; |
446 | unsigned int total_rows; |
449 | int i; |
447 | int i; |
450 | |
448 | |
451 | total_rows = TermWin.nrow + TermWin.saveLines; |
449 | total_rows = TermWin.nrow + TermWin.saveLines; |
452 | |
450 | |
453 | delete talloc; talloc = 0; |
451 | delete talloc; talloc = 0; |
… | |
… | |
479 | * Hard reset |
477 | * Hard reset |
480 | */ |
478 | */ |
481 | void |
479 | void |
482 | rxvt_term::scr_poweron () |
480 | rxvt_term::scr_poweron () |
483 | { |
481 | { |
484 | D_SCREEN ((stderr, "rxvt_scr_poweron ()")); |
|
|
485 | |
|
|
486 | scr_release (); |
482 | scr_release (); |
487 | prev_nrow = prev_ncol = 0; |
483 | prev_nrow = prev_ncol = 0; |
488 | scr_reset (); |
484 | scr_reset (); |
489 | |
485 | |
490 | scr_clear (true); |
486 | scr_clear (true); |
… | |
… | |
501 | */ |
497 | */ |
502 | void |
498 | void |
503 | rxvt_term::scr_cursor (int mode) |
499 | rxvt_term::scr_cursor (int mode) |
504 | { |
500 | { |
505 | screen_t *s; |
501 | screen_t *s; |
506 | |
|
|
507 | D_SCREEN ((stderr, "rxvt_scr_cursor (%c)", mode)); |
|
|
508 | |
502 | |
509 | #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) |
503 | #if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) |
510 | if (current_screen == SECONDARY) |
504 | if (current_screen == SECONDARY) |
511 | s = &swap; |
505 | s = &swap; |
512 | else |
506 | else |
… | |
… | |
514 | s = &screen; |
508 | s = &screen; |
515 | |
509 | |
516 | switch (mode) |
510 | switch (mode) |
517 | { |
511 | { |
518 | case SAVE: |
512 | case SAVE: |
519 | s->s_cur.row = s->cur.row; |
513 | s->s_cur.row = screen.cur.row; |
520 | s->s_cur.col = s->cur.col; |
514 | s->s_cur.col = screen.cur.col; |
521 | s->s_rstyle = rstyle; |
515 | s->s_rstyle = rstyle; |
522 | s->s_charset = s->charset; |
516 | s->s_charset = screen.charset; |
523 | s->s_charset_char = charsets[s->charset]; |
517 | s->s_charset_char = charsets[screen.charset]; |
524 | break; |
518 | break; |
525 | |
519 | |
526 | case RESTORE: |
520 | case RESTORE: |
527 | want_refresh = 1; |
521 | want_refresh = 1; |
528 | s->cur.row = s->s_cur.row; |
522 | screen.cur.row = s->s_cur.row; |
529 | s->cur.col = s->s_cur.col; |
523 | screen.cur.col = s->s_cur.col; |
530 | s->flags &= ~Screen_WrapNext; |
524 | screen.flags &= ~Screen_WrapNext; |
531 | rstyle = s->s_rstyle; |
525 | rstyle = s->s_rstyle; |
532 | s->charset = s->s_charset; |
526 | screen.charset = s->s_charset; |
533 | charsets[s->charset] = s->s_charset_char; |
527 | charsets[screen.charset] = s->s_charset_char; |
534 | set_font_style (); |
528 | set_font_style (); |
535 | break; |
529 | break; |
536 | } |
530 | } |
537 | |
531 | |
538 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
532 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
… | |
… | |
561 | int offset; |
555 | int offset; |
562 | #endif |
556 | #endif |
563 | |
557 | |
564 | want_refresh = 1; |
558 | want_refresh = 1; |
565 | |
559 | |
566 | D_SCREEN ((stderr, "rxvt_scr_change_screen (%d)", scrn)); |
|
|
567 | |
|
|
568 | TermWin.view_start = 0; |
560 | TermWin.view_start = 0; |
569 | |
561 | |
570 | if (current_screen == scrn) |
562 | if (current_screen == scrn) |
571 | return scrn; |
563 | return scrn; |
572 | |
564 | |
573 | selection_check (2); /* check for boundary cross */ |
565 | selection_check (2); /* check for boundary cross */ |
574 | |
566 | |
575 | SWAP_IT (current_screen, scrn, int); |
567 | i = current_screen; current_screen = scrn; scrn = i; |
|
|
568 | |
|
|
569 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
|
|
570 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
|
|
571 | MAX_IT (screen.cur.row, 0); |
|
|
572 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
|
|
573 | MAX_IT (screen.cur.col, 0); |
|
|
574 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
575 | |
576 | #if NSCREENS |
576 | #if NSCREENS |
577 | if (Options & Opt_secondaryScreen) |
577 | if (options & Opt_secondaryScreen) |
578 | { |
578 | { |
579 | num_scr = 0; |
579 | num_scr = 0; |
580 | offset = TermWin.saveLines; |
580 | offset = TermWin.saveLines; |
|
|
581 | |
581 | for (i = prev_nrow; i--;) |
582 | for (i = prev_nrow; i--;) |
582 | { |
583 | { |
583 | SWAP_IT (screen.text[i + offset], swap.text[i], text_t *); |
584 | SWAP_IT (screen.text[i + offset], swap.text[i], text_t *); |
584 | SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t); |
585 | SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t); |
585 | SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *); |
586 | SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *); |
586 | } |
587 | } |
587 | SWAP_IT (screen.cur.row, swap.cur.row, int16_t); |
588 | |
588 | SWAP_IT (screen.cur.col, swap.cur.col, int16_t); |
|
|
589 | # ifdef DEBUG_STRICT |
|
|
590 | assert ((screen.cur.row >= 0) && (screen.cur.row < prev_nrow)); |
|
|
591 | assert ((screen.cur.col >= 0) && (screen.cur.col < prev_ncol)); |
|
|
592 | # else /* drive with your eyes closed */ |
|
|
593 | MAX_IT (screen.cur.row, 0); |
|
|
594 | MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); |
|
|
595 | MAX_IT (screen.cur.col, 0); |
|
|
596 | MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); |
|
|
597 | # endif |
|
|
598 | SWAP_IT (screen.charset, swap.charset, int16_t); |
589 | SWAP_IT (screen.charset, swap.charset, int16_t); |
599 | SWAP_IT (screen.flags, swap.flags, int); |
590 | SWAP_IT (screen.flags, swap.flags, int); |
600 | screen.flags |= Screen_VisibleCursor; |
591 | screen.flags |= Screen_VisibleCursor; |
601 | swap.flags |= Screen_VisibleCursor; |
592 | swap.flags |= Screen_VisibleCursor; |
602 | } |
593 | } |
603 | else |
594 | else |
604 | #endif |
595 | #endif |
605 | if (Options & Opt_secondaryScroll) |
596 | if (options & Opt_secondaryScroll) |
606 | //if (current_screen == PRIMARY) |
|
|
607 | scr_scroll_text (0, (prev_nrow - 1), prev_nrow, 0); |
597 | scr_scroll_text (0, prev_nrow - 1, prev_nrow, 0); |
|
|
598 | |
608 | return scrn; |
599 | return scrn; |
609 | } |
600 | } |
610 | |
601 | |
|
|
602 | // clear WrapNext indicator, solidifying position on next line |
|
|
603 | void |
|
|
604 | rxvt_term::scr_do_wrap () |
|
|
605 | { |
|
|
606 | if (!(screen.flags & Screen_WrapNext)) |
|
|
607 | return; |
|
|
608 | |
|
|
609 | screen.flags &= ~Screen_WrapNext; |
|
|
610 | |
|
|
611 | screen.cur.col = 0; |
|
|
612 | |
|
|
613 | if (screen.cur.row == screen.bscroll) |
|
|
614 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
|
|
615 | else if (screen.cur.row < TermWin.nrow - 1) |
|
|
616 | screen.cur.row++; |
|
|
617 | } |
|
|
618 | |
611 | /* ------------------------------------------------------------------------- */ |
619 | /* ------------------------------------------------------------------------- */ |
612 | /* |
620 | /* |
613 | * Change the colour for following text |
621 | * Change the colour for following text |
614 | */ |
622 | */ |
615 | void |
623 | void |
616 | rxvt_term::scr_color (unsigned int color, int fgbg) |
624 | rxvt_term::scr_color (unsigned int color, int fgbg) |
617 | { |
625 | { |
618 | color &= RS_fgMask; |
626 | if (color > maxTermCOLOR) |
|
|
627 | color = fgbg; |
|
|
628 | |
619 | if (fgbg == Color_fg) |
629 | if (fgbg == Color_fg) |
620 | rstyle = SET_FGCOLOR (rstyle, color); |
630 | rstyle = SET_FGCOLOR (rstyle, color); |
621 | else |
631 | else |
622 | rstyle = SET_BGCOLOR (rstyle, color); |
632 | rstyle = SET_BGCOLOR (rstyle, color); |
623 | } |
633 | } |
… | |
… | |
652 | |
662 | |
653 | if (count == 0 || (row1 > row2)) |
663 | if (count == 0 || (row1 > row2)) |
654 | return 0; |
664 | return 0; |
655 | |
665 | |
656 | want_refresh = 1; |
666 | want_refresh = 1; |
657 | D_SCREEN ((stderr, "rxvt_scroll_text (%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); |
|
|
658 | |
667 | |
659 | if (row1 == 0 && count > 0 |
668 | if (row1 == 0 && count > 0 |
660 | && (current_screen == PRIMARY || Options & Opt_secondaryScroll)) |
669 | && (current_screen == PRIMARY || options & Opt_secondaryScroll)) |
661 | { |
670 | { |
662 | nscrolled = (long)TermWin.nscrolled + (long)count; |
671 | nscrolled = (long)TermWin.nscrolled + (long)count; |
663 | |
672 | |
664 | if (nscrolled > (long)TermWin.saveLines) |
673 | if (nscrolled > (long)TermWin.saveLines) |
665 | TermWin.nscrolled = TermWin.saveLines; |
674 | TermWin.nscrolled = TermWin.saveLines; |
666 | else |
675 | else |
667 | TermWin.nscrolled = (uint16_t)nscrolled; |
676 | TermWin.nscrolled = (unsigned int)nscrolled; |
668 | |
677 | |
669 | if ((Options & Opt_scrollWithBuffer) |
678 | if ((options & Opt_scrollWithBuffer) |
670 | && TermWin.view_start != 0 |
679 | && TermWin.view_start != 0 |
671 | && TermWin.view_start != TermWin.saveLines) |
680 | && TermWin.view_start != TermWin.saveLines) |
672 | scr_page (UP, count); |
681 | scr_page (UP, count); |
673 | } |
682 | } |
674 | else if (!spec) |
683 | else if (!spec) |
… | |
… | |
765 | * Add text given in <str> of length <len> to screen struct |
774 | * Add text given in <str> of length <len> to screen struct |
766 | */ |
775 | */ |
767 | void |
776 | void |
768 | rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) |
777 | rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) |
769 | { |
778 | { |
770 | unsigned char checksel, clearsel; |
779 | unsigned char checksel; |
771 | unicode_t c; |
780 | unicode_t c; |
772 | int i, row, last_col; |
781 | int i, row, last_col; |
773 | text_t *stp; |
782 | text_t *stp; |
774 | rend_t *srp; |
783 | rend_t *srp; |
775 | |
784 | |
776 | if (len <= 0) /* sanity */ |
785 | if (len <= 0) /* sanity */ |
777 | return; |
786 | return; |
778 | |
787 | |
779 | want_refresh = 1; |
788 | want_refresh = 1; |
|
|
789 | ZERO_SCROLLBACK (); |
780 | last_col = TermWin.ncol; |
790 | last_col = TermWin.ncol; |
781 | |
791 | |
782 | D_SCREEN ((stderr, "rxvt_scr_add_lines (%d,%d)", nlines, len)); |
|
|
783 | ZERO_SCROLLBACK (); |
|
|
784 | if (nlines > 0) |
792 | if (nlines > 0) |
785 | { |
793 | { |
786 | nlines += screen.cur.row - screen.bscroll; |
794 | nlines += screen.cur.row - screen.bscroll; |
787 | if ((nlines > 0) |
795 | if ((nlines > 0) |
788 | && (screen.tscroll == 0) |
796 | && (screen.tscroll == 0) |
… | |
… | |
804 | MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled); |
812 | MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled); |
805 | #endif |
813 | #endif |
806 | row = screen.cur.row + TermWin.saveLines; |
814 | row = screen.cur.row + TermWin.saveLines; |
807 | |
815 | |
808 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
816 | checksel = selection.op && current_screen == selection.screen ? 1 : 0; |
809 | clearsel = 0; |
|
|
810 | |
817 | |
811 | stp = screen.text[row]; |
818 | stp = screen.text[row]; |
812 | srp = screen.rend[row]; |
819 | srp = screen.rend[row]; |
813 | |
820 | |
814 | while (len--) |
821 | while (len--) |
… | |
… | |
817 | |
824 | |
818 | if (c < 0x20) |
825 | if (c < 0x20) |
819 | switch (c) |
826 | switch (c) |
820 | { |
827 | { |
821 | case C0_HT: |
828 | case C0_HT: |
822 | scr_tab (1); |
829 | scr_tab (1, true); |
823 | continue; |
830 | continue; |
824 | |
831 | |
825 | case C0_LF: |
832 | case C0_LF: |
826 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
833 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
827 | MAX_IT (screen.tlen[row], screen.cur.col); |
834 | MAX_IT (screen.tlen[row], screen.cur.col); |
… | |
… | |
849 | if (checksel /* see if we're writing within selection */ |
856 | if (checksel /* see if we're writing within selection */ |
850 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
857 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
851 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
858 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
852 | { |
859 | { |
853 | checksel = 0; |
860 | checksel = 0; |
854 | clearsel = 1; |
861 | /* |
|
|
862 | * If we wrote anywhere in the selected area, kill the selection |
|
|
863 | * XXX: should we kill the mark too? Possibly, but maybe that |
|
|
864 | * should be a similar check. |
|
|
865 | */ |
|
|
866 | CLEAR_SELECTION (); |
855 | } |
867 | } |
856 | |
868 | |
857 | if (screen.flags & Screen_WrapNext) |
869 | if (screen.flags & Screen_WrapNext) |
858 | { |
870 | { |
859 | screen.tlen[row] = -1; |
871 | screen.tlen[row] = -1; |
860 | if (screen.cur.row == screen.bscroll) |
872 | |
861 | scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); |
|
|
862 | else if (screen.cur.row < (TermWin.nrow - 1)) |
|
|
863 | row = (++screen.cur.row) + TermWin.saveLines; |
873 | scr_do_wrap (); row = screen.cur.row + TermWin.saveLines; |
864 | |
874 | |
865 | stp = screen.text[row]; /* _must_ refresh */ |
875 | stp = screen.text[row]; /* _must_ refresh */ |
866 | srp = screen.rend[row]; /* _must_ refresh */ |
876 | srp = screen.rend[row]; /* _must_ refresh */ |
867 | screen.cur.col = 0; |
|
|
868 | screen.flags &= ~Screen_WrapNext; |
|
|
869 | } |
877 | } |
870 | |
|
|
871 | if (screen.flags & Screen_Insert) |
|
|
872 | scr_insdel_chars (1, INSERT); |
|
|
873 | |
878 | |
874 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
879 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
875 | // do wcwidth before further replacements, as wcwidth says that line-drawing |
880 | // do wcwidth before further replacements, as wcwidth says that line-drawing |
876 | // characters have width -1 (DOH!) on GNU/Linux sometimes. |
881 | // characters have width -1 (DOH!) on GNU/Linux sometimes. |
877 | int width = c < 0x100 ? 1 : wcwidth (c); |
882 | int width = c < 0x100 ? 1 : wcwidth (c); |
878 | |
883 | |
879 | if (charsets[screen.charset] == '0') // DEC SPECIAL |
884 | if (charsets[screen.charset] == '0') // DEC SPECIAL |
880 | { |
885 | { |
881 | // vt100 special graphics and line drawing |
886 | // vt100 special graphics and line drawing |
|
|
887 | // 5f-7e standard vt100 |
|
|
888 | // 40-5e rxvt extension for extra curses acs chars |
882 | static uint16_t vt100_0[32] = { // 5f .. 7e |
889 | static uint16_t vt100_0[63] = { // 40 .. 7e |
|
|
890 | 0x0000, 0x2191, 0x2193, 0x2192, 0x2190, 0x2588, 0x259a, 0x2603, // 40-47 hi mr. snowman! |
|
|
891 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 48-4f |
|
|
892 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 50-57 |
|
|
893 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, // 58-5f |
883 | 0x0020, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
894 | 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, // 60-67 |
884 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
895 | 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba, // 68-6f |
885 | 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, |
896 | 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c, // 70-77 |
886 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, |
897 | 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, // 78-7e |
887 | }; |
898 | }; |
888 | |
899 | |
889 | if (c >= 0x5f && c <= 0x7e) |
900 | if (c >= 0x40 && c <= 0x7e && vt100_0[c - 0x40]) |
890 | { |
901 | { |
891 | c = vt100_0[c - 0x5f]; |
902 | c = vt100_0[c - 0x40]; |
892 | width = 1; |
903 | width = 1; |
893 | } |
904 | } |
894 | } |
905 | } |
895 | |
906 | |
|
|
907 | if (screen.flags & Screen_Insert) |
|
|
908 | scr_insdel_chars (width, INSERT); |
|
|
909 | |
896 | if (width != 0) |
910 | if (width != 0) |
897 | { |
911 | { |
898 | #if !UNICODE_3 && ENABLE_COMBINING |
912 | // some utf-8 decoders decode surrogate characters. |
|
|
913 | if (0xd800 <= c && c <= 0xdfff) |
|
|
914 | c = 0xfffd; |
|
|
915 | |
|
|
916 | #if !UNICODE_3 |
899 | // trim characters we can't store directly :( |
917 | // trim characters we can't store directly :( |
900 | if (c >= 0x10000) |
918 | if (c >= 0x10000) |
|
|
919 | # if ENABLE_COMBINING |
901 | c = rxvt_composite.compose (c); // map to lower 16 bits |
920 | c = rxvt_composite.compose (c); // map to lower 16 bits |
|
|
921 | # else |
|
|
922 | c = 0xfffd; |
902 | #endif |
923 | # endif |
903 | bool bold = (Options & Opt_realBold) && ((rstyle & RS_Bold) != 0); |
924 | #endif |
904 | rend_t rend = SET_FONT (rstyle, |
925 | |
905 | c > 0x7f || bold || c < 0x20 |
926 | // nuke the character at this position, if required |
906 | ? TermWin.fontset->find_font (c, bold) |
927 | if (stp[screen.cur.col] == NOCHAR |
907 | : TermWin.ascii_map [c - 0x20]); |
928 | || (screen.cur.col < TermWin.ncol - 1 |
|
|
929 | && stp[screen.cur.col + 1] == NOCHAR)) |
|
|
930 | { |
|
|
931 | int col = screen.cur.col; |
|
|
932 | |
|
|
933 | // find begin |
|
|
934 | while (col > 0 && stp[col] == NOCHAR) |
|
|
935 | col--; |
|
|
936 | |
|
|
937 | rend_t rend = SET_FONT (srp[col], FONTSET (srp[col])->find_font (' ')); |
|
|
938 | |
|
|
939 | // found begin, nuke |
|
|
940 | do { |
|
|
941 | stp[col] = ' '; |
|
|
942 | srp[col] = rend; |
|
|
943 | col++; |
|
|
944 | } while (col < TermWin.ncol && stp[col] == NOCHAR); |
|
|
945 | } |
|
|
946 | |
|
|
947 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
908 | |
948 | |
909 | do |
949 | do |
910 | { |
950 | { |
911 | stp[screen.cur.col] = c; |
951 | stp[screen.cur.col] = c; |
912 | srp[screen.cur.col] = rend; |
952 | srp[screen.cur.col] = rend; |
… | |
… | |
924 | c = NOCHAR; |
964 | c = NOCHAR; |
925 | } |
965 | } |
926 | while (--width > 0); |
966 | while (--width > 0); |
927 | |
967 | |
928 | // pad with spaces when overwriting wide character with smaller one |
968 | // pad with spaces when overwriting wide character with smaller one |
|
|
969 | if (!width) |
929 | for (int c = screen.cur.col; c < last_col && stp[c] == NOCHAR; c++) |
970 | for (int c = screen.cur.col; c < last_col && stp[c] == NOCHAR; c++) |
930 | { |
971 | { |
931 | stp[c] = ' '; |
972 | stp[c] = ' '; |
932 | srp[c] = rend; |
973 | srp[c] = rend; |
933 | } |
974 | } |
934 | } |
975 | } |
935 | else if (width == 0) |
976 | else if (width == 0) |
936 | { |
977 | { |
937 | #if ENABLE_COMBINING |
978 | #if ENABLE_COMBINING |
938 | // handle combining characters |
979 | // handle combining characters |
… | |
… | |
945 | |
986 | |
946 | if (screen.cur.col > 0) |
987 | if (screen.cur.col > 0) |
947 | { |
988 | { |
948 | tp = stp + screen.cur.col - 1; |
989 | tp = stp + screen.cur.col - 1; |
949 | rp = srp + screen.cur.col - 1; |
990 | rp = srp + screen.cur.col - 1; |
|
|
991 | |
|
|
992 | while (*tp == NOCHAR && tp > stp) |
|
|
993 | tp--, rp--; |
950 | } |
994 | } |
951 | else if (screen.cur.row > 0 |
995 | else if (screen.cur.row > 0 |
952 | && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1) |
996 | && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1) |
953 | { |
997 | { |
954 | tp = screen.text[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1; |
998 | int line = screen.cur.row - 1 + TermWin.saveLines; |
955 | rp = screen.rend[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1; |
999 | |
|
|
1000 | tp = screen.text[line] + last_col - 1; |
|
|
1001 | rp = screen.rend[line] + last_col - 1; |
|
|
1002 | |
|
|
1003 | while (*tp == NOCHAR && tp > screen.text[line]) |
|
|
1004 | tp--, rp--; |
956 | } |
1005 | } |
957 | else |
1006 | else |
958 | continue; |
1007 | continue; |
959 | |
|
|
960 | // handle double-width-chars by making them look extremely ugly |
|
|
961 | if (*tp == NOCHAR) |
|
|
962 | *tp = ' '; // hack //D //TODO //--tp, --rp; |
|
|
963 | |
1008 | |
964 | // first try to find a precomposed character |
1009 | // first try to find a precomposed character |
965 | unicode_t n = rxvt_compose (*tp, c); |
1010 | unicode_t n = rxvt_compose (*tp, c); |
966 | if (n == NOCHAR) |
1011 | if (n == NOCHAR) |
967 | n = rxvt_composite.compose (*tp, c); |
1012 | n = rxvt_composite.compose (*tp, c); |
968 | |
1013 | |
969 | *tp = n; |
1014 | *tp = n; |
970 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
1015 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
971 | #endif |
1016 | #endif |
972 | } |
1017 | } |
973 | } |
1018 | } |
974 | |
1019 | |
975 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
1020 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
976 | MAX_IT (screen.tlen[row], screen.cur.col); |
1021 | MAX_IT (screen.tlen[row], screen.cur.col); |
977 | |
|
|
978 | /* |
|
|
979 | * If we wrote anywhere in the selected area, kill the selection |
|
|
980 | * XXX: should we kill the mark too? Possibly, but maybe that |
|
|
981 | * should be a similar check. |
|
|
982 | */ |
|
|
983 | if (clearsel) |
|
|
984 | CLEAR_SELECTION (); |
|
|
985 | |
1022 | |
986 | #ifdef DEBUG_STRICT |
1023 | #ifdef DEBUG_STRICT |
987 | assert (screen.cur.row >= 0); |
1024 | assert (screen.cur.row >= 0); |
988 | #else /* drive with your eyes closed */ |
1025 | #else /* drive with your eyes closed */ |
989 | MAX_IT (screen.cur.row, 0); |
1026 | MAX_IT (screen.cur.row, 0); |
… | |
… | |
1007 | #ifdef TERMCAP_HAS_BW |
1044 | #ifdef TERMCAP_HAS_BW |
1008 | screen.cur.col = TermWin.ncol - 1; |
1045 | screen.cur.col = TermWin.ncol - 1; |
1009 | screen.cur.row--; |
1046 | screen.cur.row--; |
1010 | return; |
1047 | return; |
1011 | #endif |
1048 | #endif |
1012 | |
|
|
1013 | } |
1049 | } |
1014 | } |
1050 | } |
1015 | else if ((screen.flags & Screen_WrapNext) == 0) |
1051 | else if (!(screen.flags & Screen_WrapNext)) |
1016 | scr_gotorc (0, -1, RELATIVE); |
1052 | scr_gotorc (0, -1, RELATIVE); |
1017 | |
1053 | |
1018 | screen.flags &= ~Screen_WrapNext; |
1054 | screen.flags &= ~Screen_WrapNext; |
1019 | } |
1055 | } |
1020 | |
1056 | |
… | |
… | |
1023 | * Process Horizontal Tab |
1059 | * Process Horizontal Tab |
1024 | * count: +ve = forward; -ve = backwards |
1060 | * count: +ve = forward; -ve = backwards |
1025 | * XTERM_SEQ: CTRL-I |
1061 | * XTERM_SEQ: CTRL-I |
1026 | */ |
1062 | */ |
1027 | void |
1063 | void |
1028 | rxvt_term::scr_tab (int count) |
1064 | rxvt_term::scr_tab (int count, bool ht) |
1029 | { |
1065 | { |
1030 | int i, x; |
1066 | int i, x; |
1031 | |
1067 | |
1032 | D_SCREEN ((stderr, "rxvt_scr_tab (%d)", count)); |
|
|
1033 | want_refresh = 1; |
1068 | want_refresh = 1; |
1034 | i = x = screen.cur.col; |
1069 | i = x = screen.cur.col; |
1035 | |
1070 | |
1036 | if (count == 0) |
1071 | if (count == 0) |
1037 | return; |
1072 | return; |
1038 | else if (count > 0) |
1073 | else if (count > 0) |
1039 | { |
1074 | { |
|
|
1075 | int row = TermWin.saveLines + screen.cur.row; |
|
|
1076 | text_t *tp = screen.text[row]; |
|
|
1077 | rend_t *rp = screen.rend[row]; |
|
|
1078 | rend_t base_rend = rp[i]; |
|
|
1079 | ht &= tp[i] == ' '; |
|
|
1080 | |
1040 | for (; ++i < TermWin.ncol; ) |
1081 | for (; ++i < TermWin.ncol; ) |
1041 | if (tabs[i]) |
1082 | if (tabs[i]) |
1042 | { |
1083 | { |
1043 | x = i; |
1084 | x = i; |
1044 | if (!--count) |
1085 | if (!--count) |
1045 | break; |
1086 | break; |
1046 | } |
1087 | } |
|
|
1088 | else |
|
|
1089 | ht &= tp[i] == ' ' |
|
|
1090 | && RS_SAME (rp[i], base_rend); |
1047 | |
1091 | |
1048 | if (count) |
1092 | if (count) |
1049 | x = TermWin.ncol - 1; |
1093 | x = TermWin.ncol - 1; |
|
|
1094 | |
|
|
1095 | // store horizontal tab commands as characters inside the text |
|
|
1096 | // buffer so they can be selected and pasted. |
|
|
1097 | if (ht && options & Opt_pastableTabs) |
|
|
1098 | { |
|
|
1099 | base_rend = SET_FONT (base_rend, 0); |
|
|
1100 | |
|
|
1101 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
|
|
1102 | MAX_IT (screen.tlen[row], x); |
|
|
1103 | |
|
|
1104 | i = screen.cur.col; |
|
|
1105 | |
|
|
1106 | tp[i] = '\t'; |
|
|
1107 | rp[i] = base_rend; |
|
|
1108 | |
|
|
1109 | while (++i < x) |
|
|
1110 | { |
|
|
1111 | tp[i] = NOCHAR; |
|
|
1112 | rp[i] = base_rend; |
|
|
1113 | } |
|
|
1114 | } |
1050 | } |
1115 | } |
1051 | else /* if (count < 0) */ |
1116 | else /* if (count < 0) */ |
1052 | { |
1117 | { |
1053 | for (; --i >= 0; ) |
1118 | for (; --i >= 0; ) |
1054 | if (tabs[i]) |
1119 | if (tabs[i]) |
… | |
… | |
1071 | * Process DEC Back Index |
1136 | * Process DEC Back Index |
1072 | * XTERM_SEQ: ESC 6 |
1137 | * XTERM_SEQ: ESC 6 |
1073 | * Move cursor left in row. If we're at the left boundary, shift everything |
1138 | * Move cursor left in row. If we're at the left boundary, shift everything |
1074 | * in that row right. Clear left column. |
1139 | * in that row right. Clear left column. |
1075 | */ |
1140 | */ |
1076 | #ifndef NO_FRILLS |
1141 | #if ENABLE_FRILLS |
1077 | void |
1142 | void |
1078 | rxvt_term::scr_backindex () |
1143 | rxvt_term::scr_backindex () |
1079 | { |
1144 | { |
1080 | if (screen.cur.col > 0) |
1145 | if (screen.cur.col > 0) |
1081 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
1146 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
1082 | else |
1147 | else |
1083 | { |
1148 | { |
1084 | if (screen.tlen[screen.cur.row + TermWin.saveLines] == 0) |
1149 | if (screen.tlen[screen.cur.row + TermWin.saveLines] == 0) |
1085 | return; /* um, yeah? */ |
1150 | return; /* um, yeah? */ |
|
|
1151 | |
1086 | scr_insdel_chars (1, INSERT); |
1152 | scr_insdel_chars (1, INSERT); |
1087 | } |
1153 | } |
1088 | } |
1154 | } |
1089 | #endif |
1155 | #endif |
1090 | /* ------------------------------------------------------------------------- */ |
1156 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1092 | * Process DEC Forward Index |
1158 | * Process DEC Forward Index |
1093 | * XTERM_SEQ: ESC 9 |
1159 | * XTERM_SEQ: ESC 9 |
1094 | * Move cursor right in row. If we're at the right boundary, shift everything |
1160 | * Move cursor right in row. If we're at the right boundary, shift everything |
1095 | * in that row left. Clear right column. |
1161 | * in that row left. Clear right column. |
1096 | */ |
1162 | */ |
1097 | #ifndef NO_FRILLS |
1163 | #if ENABLE_FRILLS |
1098 | void |
1164 | void |
1099 | rxvt_term::scr_forwardindex () |
1165 | rxvt_term::scr_forwardindex () |
1100 | { |
1166 | { |
1101 | int row; |
1167 | int row; |
1102 | |
1168 | |
1103 | if (screen.cur.col < TermWin.ncol - 1) |
1169 | if (screen.cur.col < TermWin.ncol - 1) |
1104 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1170 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1105 | else |
1171 | else |
1106 | { |
1172 | { |
1107 | row = screen.cur.row + TermWin.saveLines; |
1173 | row = screen.cur.row + TermWin.saveLines; |
|
|
1174 | |
1108 | if (screen.tlen[row] == 0) |
1175 | if (screen.tlen[row] == 0) |
1109 | return; /* um, yeah? */ |
1176 | return; /* um, yeah? */ |
1110 | else if (screen.tlen[row] == -1) |
1177 | else if (screen.tlen[row] == -1) |
1111 | screen.tlen[row] = TermWin.ncol; |
1178 | screen.tlen[row] = TermWin.ncol; |
|
|
1179 | |
1112 | scr_gotorc (0, 0, R_RELATIVE); |
1180 | scr_gotorc (0, 0, R_RELATIVE); |
1113 | scr_insdel_chars (1, DELETE); |
1181 | scr_insdel_chars (1, DELETE); |
1114 | scr_gotorc (0, TermWin.ncol - 1, R_RELATIVE); |
1182 | scr_gotorc (0, TermWin.ncol - 1, R_RELATIVE); |
1115 | } |
1183 | } |
1116 | } |
1184 | } |
… | |
… | |
1124 | rxvt_term::scr_gotorc (int row, int col, int relative) |
1192 | rxvt_term::scr_gotorc (int row, int col, int relative) |
1125 | { |
1193 | { |
1126 | want_refresh = 1; |
1194 | want_refresh = 1; |
1127 | ZERO_SCROLLBACK (); |
1195 | ZERO_SCROLLBACK (); |
1128 | |
1196 | |
1129 | D_SCREEN ((stderr, "rxvt_scr_gotorc (r:%s%d,c:%s%d): from (r:%d,c:%d)", (relative & R_RELATIVE ? "+" : ""), row, (relative & C_RELATIVE ? "+" : ""), col, screen.cur.row, screen.cur.col)); |
|
|
1130 | |
|
|
1131 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1197 | screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; |
1132 | MAX_IT (screen.cur.col, 0); |
1198 | MAX_IT (screen.cur.col, 0); |
1133 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1199 | MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); |
1134 | |
1200 | |
1135 | screen.flags &= ~Screen_WrapNext; |
1201 | screen.flags &= ~Screen_WrapNext; |
|
|
1202 | |
1136 | if (relative & R_RELATIVE) |
1203 | if (relative & R_RELATIVE) |
1137 | { |
1204 | { |
1138 | if (row > 0) |
1205 | if (row > 0) |
1139 | { |
1206 | { |
1140 | if (screen.cur.row <= screen.bscroll |
1207 | if (screen.cur.row <= screen.bscroll |
… | |
… | |
1160 | MIN_IT (screen.cur.row, screen.bscroll); |
1227 | MIN_IT (screen.cur.row, screen.bscroll); |
1161 | } |
1228 | } |
1162 | else |
1229 | else |
1163 | screen.cur.row = row; |
1230 | screen.cur.row = row; |
1164 | } |
1231 | } |
|
|
1232 | |
1165 | MAX_IT (screen.cur.row, 0); |
1233 | MAX_IT (screen.cur.row, 0); |
1166 | MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); |
1234 | MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); |
1167 | |
|
|
1168 | while (screen.cur.col > 0 |
|
|
1169 | && screen.text[screen.cur.row + TermWin.saveLines][screen.cur.col] == NOCHAR) |
|
|
1170 | screen.cur.col--; |
|
|
1171 | } |
1235 | } |
1172 | |
1236 | |
1173 | /* ------------------------------------------------------------------------- */ |
1237 | /* ------------------------------------------------------------------------- */ |
1174 | /* |
1238 | /* |
1175 | * direction should be UP or DN |
1239 | * direction should be UP or DN |
1176 | */ |
1240 | */ |
1177 | void |
1241 | void |
1178 | rxvt_term::scr_index (enum page_dirn direction) |
1242 | rxvt_term::scr_index (enum page_dirn direction) |
1179 | { |
1243 | { |
1180 | int dirn; |
1244 | int dirn; |
1181 | |
1245 | |
1182 | want_refresh = 1; |
1246 | want_refresh = 1; |
|
|
1247 | ZERO_SCROLLBACK (); |
|
|
1248 | |
1183 | dirn = ((direction == UP) ? 1 : -1); |
1249 | dirn = ((direction == UP) ? 1 : -1); |
1184 | D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); |
|
|
1185 | |
|
|
1186 | ZERO_SCROLLBACK (); |
|
|
1187 | |
1250 | |
1188 | screen.flags &= ~Screen_WrapNext; |
1251 | screen.flags &= ~Screen_WrapNext; |
|
|
1252 | |
1189 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1253 | if ((screen.cur.row == screen.bscroll && direction == UP) |
1190 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1254 | || (screen.cur.row == screen.tscroll && direction == DN)) |
1191 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn, 0); |
1255 | scr_scroll_text (screen.tscroll, screen.bscroll, dirn, 0); |
1192 | else |
1256 | else |
1193 | screen.cur.row += dirn; |
1257 | screen.cur.row += dirn; |
|
|
1258 | |
1194 | MAX_IT (screen.cur.row, 0); |
1259 | MAX_IT (screen.cur.row, 0); |
1195 | MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); |
1260 | MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); |
1196 | selection_check (0); |
1261 | selection_check (0); |
1197 | } |
1262 | } |
1198 | |
1263 | |
… | |
… | |
1207 | rxvt_term::scr_erase_line (int mode) |
1272 | rxvt_term::scr_erase_line (int mode) |
1208 | { |
1273 | { |
1209 | unsigned int row, col, num; |
1274 | unsigned int row, col, num; |
1210 | |
1275 | |
1211 | want_refresh = 1; |
1276 | want_refresh = 1; |
1212 | D_SCREEN ((stderr, "rxvt_scr_erase_line (%d) at screen row: %d", mode, screen.cur.row)); |
|
|
1213 | ZERO_SCROLLBACK (); |
1277 | ZERO_SCROLLBACK (); |
1214 | |
1278 | |
1215 | selection_check (1); |
1279 | selection_check (1); |
1216 | |
|
|
1217 | screen.flags &= ~Screen_WrapNext; |
|
|
1218 | |
1280 | |
1219 | row = TermWin.saveLines + screen.cur.row; |
1281 | row = TermWin.saveLines + screen.cur.row; |
1220 | switch (mode) |
1282 | switch (mode) |
1221 | { |
1283 | { |
1222 | case 0: /* erase to end of line */ |
1284 | case 0: /* erase to end of line */ |
… | |
… | |
1266 | int32_t row, row_offset; |
1328 | int32_t row, row_offset; |
1267 | rend_t ren; |
1329 | rend_t ren; |
1268 | XGCValues gcvalue; |
1330 | XGCValues gcvalue; |
1269 | |
1331 | |
1270 | want_refresh = 1; |
1332 | want_refresh = 1; |
1271 | D_SCREEN ((stderr, "rxvt_scr_erase_screen (%d) at screen row: %d", mode, screen.cur.row)); |
|
|
1272 | ZERO_SCROLLBACK (); |
1333 | ZERO_SCROLLBACK (); |
|
|
1334 | |
1273 | row_offset = (int32_t)TermWin.saveLines; |
1335 | row_offset = (int32_t)TermWin.saveLines; |
1274 | |
1336 | |
1275 | switch (mode) |
1337 | switch (mode) |
1276 | { |
1338 | { |
1277 | case 0: /* erase to end of screen */ |
1339 | case 0: /* erase to end of screen */ |
… | |
… | |
1313 | ren = DEFAULT_RSTYLE; |
1375 | ren = DEFAULT_RSTYLE; |
1314 | CLEAR_ROWS (row, num); |
1376 | CLEAR_ROWS (row, num); |
1315 | } |
1377 | } |
1316 | else |
1378 | else |
1317 | { |
1379 | { |
1318 | ren = (rstyle & (RS_fgMask | RS_bgMask)); |
1380 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1319 | gcvalue.foreground = PixColors[GET_BGCOLOR (rstyle)]; |
1381 | gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; |
1320 | XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); |
1382 | XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); |
1321 | ERASE_ROWS (row, num); |
1383 | ERASE_ROWS (row, num); |
1322 | gcvalue.foreground = PixColors[Color_fg]; |
1384 | gcvalue.foreground = pix_colors[Color_fg]; |
1323 | XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); |
1385 | XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); |
1324 | } |
1386 | } |
1325 | |
1387 | |
1326 | for (; num--; row++) |
1388 | for (; num--; row++) |
1327 | { |
1389 | { |
1328 | scr_blank_screen_mem (screen.text, screen.rend, |
1390 | scr_blank_screen_mem (screen.text, screen.rend, (unsigned int) (row + row_offset), rstyle); |
1329 | (unsigned int) (row + row_offset), rstyle); |
|
|
1330 | screen.tlen[row + row_offset] = 0; |
1391 | screen.tlen[row + row_offset] = 0; |
1331 | scr_blank_line (drawn_text[row], drawn_rend[row], |
1392 | scr_blank_line (drawn_text[row], drawn_rend[row], (unsigned int)TermWin.ncol, ren); |
1332 | (unsigned int)TermWin.ncol, ren); |
|
|
1333 | } |
1393 | } |
1334 | } |
1394 | } |
1335 | |
1395 | |
1336 | /* ------------------------------------------------------------------------- */ |
1396 | /* ------------------------------------------------------------------------- */ |
1337 | /* |
1397 | /* |
… | |
… | |
1343 | { |
1403 | { |
1344 | int i, j, k; |
1404 | int i, j, k; |
1345 | rend_t *r1, fs; |
1405 | rend_t *r1, fs; |
1346 | |
1406 | |
1347 | want_refresh = 1; |
1407 | want_refresh = 1; |
|
|
1408 | ZERO_SCROLLBACK (); |
|
|
1409 | |
1348 | num_scr_allow = 0; |
1410 | num_scr_allow = 0; |
1349 | ZERO_SCROLLBACK (); |
|
|
1350 | selection_check (3); |
1411 | selection_check (3); |
1351 | |
1412 | |
1352 | fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E')); |
1413 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1353 | for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) |
1414 | for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) |
1354 | { |
1415 | { |
1355 | screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ |
1416 | screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ |
1356 | fill_text (screen.text[k], 'E', TermWin.ncol); |
1417 | fill_text (screen.text[k], 'E', TermWin.ncol); |
1357 | for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) |
1418 | for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) |
… | |
… | |
1381 | if (insdel == DELETE) |
1442 | if (insdel == DELETE) |
1382 | return; |
1443 | return; |
1383 | else if (insdel == INSERT) |
1444 | else if (insdel == INSERT) |
1384 | count = end; |
1445 | count = end; |
1385 | } |
1446 | } |
1386 | screen.flags &= ~Screen_WrapNext; |
1447 | |
|
|
1448 | scr_do_wrap (); |
1387 | |
1449 | |
1388 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count, 0); |
1450 | scr_scroll_text (screen.cur.row, screen.bscroll, insdel * count, 0); |
1389 | } |
1451 | } |
1390 | |
1452 | |
1391 | /* ------------------------------------------------------------------------- */ |
1453 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1405 | ZERO_SCROLLBACK (); |
1467 | ZERO_SCROLLBACK (); |
1406 | |
1468 | |
1407 | if (count <= 0) |
1469 | if (count <= 0) |
1408 | return; |
1470 | return; |
1409 | |
1471 | |
|
|
1472 | scr_do_wrap (); |
|
|
1473 | |
1410 | selection_check (1); |
1474 | selection_check (1); |
1411 | MIN_IT (count, (TermWin.ncol - screen.cur.col)); |
1475 | MIN_IT (count, (TermWin.ncol - screen.cur.col)); |
1412 | |
1476 | |
1413 | row = screen.cur.row + TermWin.saveLines; |
1477 | row = screen.cur.row + TermWin.saveLines; |
1414 | screen.flags &= ~Screen_WrapNext; |
|
|
1415 | |
1478 | |
1416 | stp = screen.text[row]; |
1479 | stp = screen.text[row]; |
1417 | srp = screen.rend[row]; |
1480 | srp = screen.rend[row]; |
1418 | slp = & (screen.tlen[row]); |
1481 | slp = &screen.tlen[row]; |
1419 | |
1482 | |
1420 | switch (insdel) |
1483 | switch (insdel) |
1421 | { |
1484 | { |
1422 | case INSERT: |
1485 | case INSERT: |
1423 | for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; |
1486 | for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; col--) |
1424 | col--) |
|
|
1425 | { |
1487 | { |
1426 | stp[col] = stp[col - count]; |
1488 | stp[col] = stp[col - count]; |
1427 | srp[col] = srp[col - count]; |
1489 | srp[col] = srp[col - count]; |
1428 | } |
1490 | } |
1429 | |
1491 | |
… | |
… | |
1439 | if (selection.end.row != screen.cur.row |
1501 | if (selection.end.row != screen.cur.row |
1440 | || (selection.end.col + count >= TermWin.ncol)) |
1502 | || (selection.end.col + count >= TermWin.ncol)) |
1441 | CLEAR_SELECTION (); |
1503 | CLEAR_SELECTION (); |
1442 | else |
1504 | else |
1443 | { /* shift selection */ |
1505 | { /* shift selection */ |
1444 | selection.beg.col += count; |
1506 | selection.beg.col += count; |
1445 | selection.mark.col += count; /* XXX: yes? */ |
1507 | selection.mark.col += count; /* XXX: yes? */ |
1446 | selection.end.col += count; |
1508 | selection.end.col += count; |
1447 | } |
1509 | } |
1448 | } |
1510 | } |
1449 | |
1511 | |
1450 | scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), |
1512 | scr_blank_line (&stp[screen.cur.col], &srp[screen.cur.col], |
1451 | (unsigned int)count, rstyle); |
1513 | (unsigned int)count, rstyle); |
1452 | break; |
1514 | break; |
1453 | |
1515 | |
1454 | case ERASE: |
1516 | case ERASE: |
1455 | screen.cur.col += count; /* don't worry if > TermWin.ncol */ |
1517 | screen.cur.col += count; /* don't worry if > TermWin.ncol */ |
1456 | selection_check (1); |
1518 | selection_check (1); |
1457 | screen.cur.col -= count; |
1519 | screen.cur.col -= count; |
1458 | scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), |
1520 | scr_blank_line (&stp[screen.cur.col], &srp[screen.cur.col], |
1459 | (unsigned int)count, rstyle); |
1521 | (unsigned int)count, rstyle); |
1460 | break; |
1522 | break; |
1461 | |
1523 | |
1462 | case DELETE: |
1524 | case DELETE: |
1463 | tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1525 | tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
… | |
… | |
1466 | { |
1528 | { |
1467 | stp[col] = stp[col + count]; |
1529 | stp[col] = stp[col + count]; |
1468 | srp[col] = srp[col + count]; |
1530 | srp[col] = srp[col + count]; |
1469 | } |
1531 | } |
1470 | |
1532 | |
1471 | scr_blank_line (& (stp[TermWin.ncol - count]), |
1533 | scr_blank_line (&stp[TermWin.ncol - count], &srp[TermWin.ncol - count], |
1472 | & (srp[TermWin.ncol - count]), |
|
|
1473 | (unsigned int)count, tr); |
1534 | (unsigned int)count, tr); |
1474 | |
1535 | |
1475 | if (*slp == -1) /* break line continuation */ |
1536 | if (*slp == -1) /* break line continuation */ |
1476 | *slp = TermWin.ncol; |
1537 | *slp = TermWin.ncol; |
1477 | |
1538 | |
… | |
… | |
1486 | || selection.end.col >= TermWin.ncol) |
1547 | || selection.end.col >= TermWin.ncol) |
1487 | CLEAR_SELECTION (); |
1548 | CLEAR_SELECTION (); |
1488 | else |
1549 | else |
1489 | { |
1550 | { |
1490 | /* shift selection */ |
1551 | /* shift selection */ |
1491 | selection.beg.col -= count; |
1552 | selection.beg.col -= count; |
1492 | selection.mark.col -= count; /* XXX: yes? */ |
1553 | selection.mark.col -= count; /* XXX: yes? */ |
1493 | selection.end.col -= count; |
1554 | selection.end.col -= count; |
1494 | } |
1555 | } |
1495 | } |
1556 | } |
1496 | |
1557 | |
1497 | break; |
1558 | break; |
1498 | } |
1559 | } |
… | |
… | |
1544 | rxvt_term::scr_autowrap (int mode) |
1605 | rxvt_term::scr_autowrap (int mode) |
1545 | { |
1606 | { |
1546 | if (mode) |
1607 | if (mode) |
1547 | screen.flags |= Screen_Autowrap; |
1608 | screen.flags |= Screen_Autowrap; |
1548 | else |
1609 | else |
1549 | screen.flags &= ~ (Screen_Autowrap | Screen_WrapNext); |
1610 | screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); |
1550 | } |
1611 | } |
1551 | |
1612 | |
1552 | /* ------------------------------------------------------------------------- */ |
1613 | /* ------------------------------------------------------------------------- */ |
1553 | /* |
1614 | /* |
1554 | * Set/unset margin origin mode |
1615 | * Set/unset margin origin mode |
… | |
… | |
1564 | { |
1625 | { |
1565 | if (mode) |
1626 | if (mode) |
1566 | screen.flags |= Screen_Relative; |
1627 | screen.flags |= Screen_Relative; |
1567 | else |
1628 | else |
1568 | screen.flags &= ~Screen_Relative; |
1629 | screen.flags &= ~Screen_Relative; |
|
|
1630 | |
1569 | scr_gotorc (0, 0, 0); |
1631 | scr_gotorc (0, 0, 0); |
1570 | } |
1632 | } |
1571 | |
1633 | |
1572 | /* ------------------------------------------------------------------------- */ |
1634 | /* ------------------------------------------------------------------------- */ |
1573 | /* |
1635 | /* |
… | |
… | |
1593 | */ |
1655 | */ |
1594 | void |
1656 | void |
1595 | rxvt_term::scr_set_tab (int mode) |
1657 | rxvt_term::scr_set_tab (int mode) |
1596 | { |
1658 | { |
1597 | if (mode < 0) |
1659 | if (mode < 0) |
1598 | MEMSET (tabs, 0, TermWin.ncol * sizeof (char)); |
1660 | memset (tabs, 0, TermWin.ncol * sizeof (char)); |
1599 | else if (screen.cur.col < TermWin.ncol) |
1661 | else if (screen.cur.col < TermWin.ncol) |
1600 | tabs[screen.cur.col] = (mode ? 1 : 0); |
1662 | tabs[screen.cur.col] = (mode ? 1 : 0); |
1601 | } |
1663 | } |
1602 | |
1664 | |
1603 | /* ------------------------------------------------------------------------- */ |
1665 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1607 | * XTERM_SEQ: Normal video : ESC [ ? 5 l |
1669 | * XTERM_SEQ: Normal video : ESC [ ? 5 l |
1608 | */ |
1670 | */ |
1609 | void |
1671 | void |
1610 | rxvt_term::scr_rvideo_mode (int mode) |
1672 | rxvt_term::scr_rvideo_mode (int mode) |
1611 | { |
1673 | { |
1612 | XGCValues gcvalue; |
1674 | XGCValues gcvalue; |
1613 | |
1675 | |
1614 | if (rvideo != mode) |
1676 | if (rvideo != mode) |
1615 | { |
1677 | { |
1616 | rvideo = mode; |
1678 | rvideo = mode; |
1617 | SWAP_IT (PixColors[Color_fg], PixColors[Color_bg], rxvt_color); |
1679 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1618 | #if defined(XPM_BACKGROUND) |
1680 | #if XPM_BACKGROUND |
1619 | if (bgPixmap.pixmap == None) |
1681 | if (bgPixmap.pixmap == None) |
1620 | #endif |
1682 | #endif |
1621 | #if defined(TRANSPARENT) |
1683 | #if TRANSPARENT |
1622 | if (! (Options & Opt_transparent) || am_transparent == 0) |
1684 | if (! (options & Opt_transparent) || am_transparent == 0) |
1623 | #endif |
1685 | #endif |
1624 | XSetWindowBackground (display->display, TermWin.vt, |
1686 | XSetWindowBackground (display->display, TermWin.vt, |
1625 | PixColors[Color_bg]); |
1687 | pix_colors[Color_bg]); |
1626 | |
1688 | |
1627 | gcvalue.foreground = PixColors[Color_fg]; |
1689 | gcvalue.foreground = pix_colors[Color_fg]; |
1628 | gcvalue.background = PixColors[Color_bg]; |
1690 | gcvalue.background = pix_colors[Color_bg]; |
1629 | XChangeGC (display->display, TermWin.gc, GCBackground | GCForeground, |
1691 | XChangeGC (display->display, TermWin.gc, GCBackground | GCForeground, |
1630 | &gcvalue); |
1692 | &gcvalue); |
1631 | scr_clear (); |
1693 | scr_clear (); |
1632 | scr_touch (true); |
1694 | scr_touch (true); |
1633 | } |
1695 | } |
… | |
… | |
1681 | * XTERM_SEQ: Invoke G2 character set: ESC N |
1743 | * XTERM_SEQ: Invoke G2 character set: ESC N |
1682 | * XTERM_SEQ: Invoke G3 character set: ESC O |
1744 | * XTERM_SEQ: Invoke G3 character set: ESC O |
1683 | */ |
1745 | */ |
1684 | void |
1746 | void |
1685 | rxvt_term::scr_charset_choose (int set) |
1747 | rxvt_term::scr_charset_choose (int set) |
1686 | { |
1748 | { |
1687 | screen.charset = set; |
1749 | screen.charset = set; |
1688 | set_font_style (); |
1750 | set_font_style (); |
1689 | } |
1751 | } |
1690 | |
1752 | |
1691 | /* ------------------------------------------------------------------------- */ |
1753 | /* ------------------------------------------------------------------------- */ |
1692 | /* |
1754 | /* |
1693 | * Set a font |
1755 | * Set a font |
1694 | * XTERM_SEQ: Set G0 character set: ESC ( <C> |
1756 | * XTERM_SEQ: Set G0 character set: ESC ( <C> |
… | |
… | |
1697 | * XTERM_SEQ: Set G3 character set: ESC + <C> |
1759 | * XTERM_SEQ: Set G3 character set: ESC + <C> |
1698 | * See set_font_style for possible values for <C> |
1760 | * See set_font_style for possible values for <C> |
1699 | */ |
1761 | */ |
1700 | void |
1762 | void |
1701 | rxvt_term::scr_charset_set (int set, unsigned int ch) |
1763 | rxvt_term::scr_charset_set (int set, unsigned int ch) |
1702 | { |
1764 | { |
1703 | charsets[set] = (unsigned char)ch; |
1765 | charsets[set] = (unsigned char)ch; |
1704 | set_font_style (); |
1766 | set_font_style (); |
1705 | } |
1767 | } |
1706 | |
1768 | |
1707 | |
1769 | |
1708 | /* ------------------------------------------------------------------------- * |
1770 | /* ------------------------------------------------------------------------- * |
1709 | * MAJOR SCREEN MANIPULATION * |
1771 | * MAJOR SCREEN MANIPULATION * |
1710 | * ------------------------------------------------------------------------- */ |
1772 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1778 | { |
1840 | { |
1779 | MIN_IT (rc[i].col, TermWin.ncol - 1); |
1841 | MIN_IT (rc[i].col, TermWin.ncol - 1); |
1780 | MIN_IT (rc[i].row, TermWin.nrow - 1); |
1842 | MIN_IT (rc[i].row, TermWin.nrow - 1); |
1781 | } |
1843 | } |
1782 | |
1844 | |
1783 | D_SCREEN ((stderr, "rxvt_scr_expose (x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)- (c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); |
|
|
1784 | |
|
|
1785 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1845 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1786 | fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1846 | fill_text (&drawn_text[i][rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1787 | |
1847 | |
1788 | if (refresh) |
1848 | if (refresh) |
1789 | scr_refresh (SLOW_REFRESH); |
1849 | scr_refresh (SLOW_REFRESH); |
… | |
… | |
1806 | */ |
1866 | */ |
1807 | int |
1867 | int |
1808 | rxvt_term::scr_move_to (int y, int len) |
1868 | rxvt_term::scr_move_to (int y, int len) |
1809 | { |
1869 | { |
1810 | long p = 0; |
1870 | long p = 0; |
1811 | uint16_t oldviewstart; |
1871 | unsigned int oldviewstart; |
1812 | |
1872 | |
1813 | oldviewstart = TermWin.view_start; |
1873 | oldviewstart = TermWin.view_start; |
|
|
1874 | |
1814 | if (y < len) |
1875 | if (y < len) |
1815 | { |
1876 | { |
1816 | p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; |
1877 | p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; |
1817 | p -= (long) (TermWin.nrow - 1); |
1878 | p -= (long) (TermWin.nrow - 1); |
1818 | p = max (p, 0); |
1879 | p = max (p, 0); |
1819 | } |
1880 | } |
|
|
1881 | |
1820 | TermWin.view_start = (uint16_t)min (p, TermWin.nscrolled); |
1882 | TermWin.view_start = (unsigned int)min (p, TermWin.nscrolled); |
1821 | D_SCREEN ((stderr, "rxvt_scr_move_to (%d, %d) view_start:%d", y, len, TermWin.view_start)); |
|
|
1822 | |
1883 | |
1823 | return scr_changeview (oldviewstart); |
1884 | return scr_changeview (oldviewstart); |
1824 | } |
1885 | } |
1825 | |
1886 | |
1826 | /* ------------------------------------------------------------------------- */ |
1887 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1830 | */ |
1891 | */ |
1831 | int |
1892 | int |
1832 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1893 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1833 | { |
1894 | { |
1834 | int n; |
1895 | int n; |
1835 | uint16_t oldviewstart; |
1896 | unsigned int oldviewstart; |
1836 | |
1897 | |
1837 | D_SCREEN ((stderr, "rxvt_scr_page (%s, %d) view_start:%d", ((direction == UP) ? "UP" : "DN"), nlines, TermWin.view_start)); |
|
|
1838 | #ifdef DEBUG_STRICT |
1898 | #ifdef DEBUG_STRICT |
1839 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1899 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1840 | #endif |
1900 | #endif |
1841 | oldviewstart = TermWin.view_start; |
1901 | oldviewstart = TermWin.view_start; |
1842 | if (direction == UP) |
1902 | if (direction == UP) |
… | |
… | |
1851 | } |
1911 | } |
1852 | return scr_changeview (oldviewstart); |
1912 | return scr_changeview (oldviewstart); |
1853 | } |
1913 | } |
1854 | |
1914 | |
1855 | int |
1915 | int |
1856 | rxvt_term::scr_changeview (uint16_t oldviewstart) |
1916 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1857 | { |
1917 | { |
1858 | if (TermWin.view_start != oldviewstart) |
1918 | if (TermWin.view_start != oldviewstart) |
1859 | { |
1919 | { |
1860 | want_refresh = 1; |
1920 | want_refresh = 1; |
1861 | num_scr -= (TermWin.view_start - oldviewstart); |
1921 | num_scr -= (TermWin.view_start - oldviewstart); |
… | |
… | |
1869 | rxvt_term::scr_bell () |
1929 | rxvt_term::scr_bell () |
1870 | { |
1930 | { |
1871 | #ifndef NO_BELL |
1931 | #ifndef NO_BELL |
1872 | # ifndef NO_MAPALERT |
1932 | # ifndef NO_MAPALERT |
1873 | # ifdef MAPALERT_OPTION |
1933 | # ifdef MAPALERT_OPTION |
1874 | if (Options & Opt_mapAlert) |
1934 | if (options & Opt_mapAlert) |
1875 | # endif |
1935 | # endif |
1876 | XMapWindow (display->display, TermWin.parent[0]); |
1936 | XMapWindow (display->display, TermWin.parent[0]); |
1877 | # endif |
1937 | # endif |
1878 | if (Options & Opt_visualBell) |
1938 | if (options & Opt_visualBell) |
1879 | { |
1939 | { |
1880 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1940 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1881 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1941 | scr_rvideo_mode (!rvideo); /* refresh also done */ |
1882 | } |
1942 | } |
1883 | else |
1943 | else |
… | |
… | |
1889 | /* ARGSUSED */ |
1949 | /* ARGSUSED */ |
1890 | void |
1950 | void |
1891 | rxvt_term::scr_printscreen (int fullhist) |
1951 | rxvt_term::scr_printscreen (int fullhist) |
1892 | { |
1952 | { |
1893 | #ifdef PRINTPIPE |
1953 | #ifdef PRINTPIPE |
1894 | int i, r1, nrows, row_offset; |
1954 | int i, r1, nrows, row_offset; |
1895 | text_t *t; |
1955 | FILE *fd; |
1896 | FILE *fd; |
|
|
1897 | |
1956 | |
1898 | if ((fd = popen_printer ()) == NULL) |
1957 | if ((fd = popen_printer ()) == NULL) |
1899 | return; |
1958 | return; |
|
|
1959 | |
1900 | nrows = TermWin.nrow; |
1960 | nrows = TermWin.nrow; |
1901 | row_offset = TermWin.saveLines; |
1961 | row_offset = TermWin.saveLines; |
|
|
1962 | |
1902 | if (!fullhist) |
1963 | if (!fullhist) |
1903 | row_offset -= TermWin.view_start; |
1964 | row_offset -= TermWin.view_start; |
1904 | else |
1965 | else |
1905 | { |
1966 | { |
1906 | nrows += TermWin.nscrolled; |
1967 | nrows += TermWin.nscrolled; |
1907 | row_offset -= TermWin.nscrolled; |
1968 | row_offset -= TermWin.nscrolled; |
1908 | } |
1969 | } |
1909 | |
1970 | |
|
|
1971 | wctomb (0, 0); |
|
|
1972 | |
1910 | for (r1 = 0; r1 < nrows; r1++) |
1973 | for (r1 = 0; r1 < nrows; r1++) |
1911 | { |
1974 | { |
1912 | t = screen.text[r1 + row_offset]; |
1975 | text_t *tp = screen.text[r1 + row_offset]; |
1913 | for (i = TermWin.ncol - 1; i >= 0; i--) |
1976 | int len = screen.tlen[r1 + row_offset]; |
1914 | if (!isspace (t[i])) |
1977 | |
1915 | break; |
1978 | for (i = len >= 0 ? len : TermWin.ncol - 1; i--; ) |
1916 | fprintf (fd, "%.*s\n", (i + 1), t); |
1979 | { |
|
|
1980 | char mb[MB_LEN_MAX]; |
|
|
1981 | text_t t = *tp++; |
|
|
1982 | if (t == NOCHAR) |
|
|
1983 | continue; |
|
|
1984 | |
|
|
1985 | len = wctomb (mb, t); |
|
|
1986 | |
|
|
1987 | if (len <= 0) |
|
|
1988 | { |
|
|
1989 | mb[0] = ' '; |
|
|
1990 | len = 1; |
|
|
1991 | } |
|
|
1992 | |
|
|
1993 | fwrite (mb, 1, len, fd); |
|
|
1994 | } |
|
|
1995 | |
|
|
1996 | fputc ('\n', fd); |
1917 | } |
1997 | } |
|
|
1998 | |
1918 | pclose_printer (fd); |
1999 | pclose_printer (fd); |
1919 | #endif |
2000 | #endif |
1920 | } |
2001 | } |
1921 | |
2002 | |
1922 | /* ------------------------------------------------------------------------- */ |
2003 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1937 | |
2018 | |
1938 | void |
2019 | void |
1939 | rxvt_term::scr_refresh (unsigned char refresh_type) |
2020 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1940 | { |
2021 | { |
1941 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
2022 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1942 | rvid, /* reverse video this position */ |
|
|
1943 | showcursor; /* show the cursor */ |
2023 | showcursor; /* show the cursor */ |
1944 | int16_t col, row, /* column/row we're processing */ |
2024 | int16_t col, row, /* column/row we're processing */ |
1945 | ocrow; /* old cursor row */ |
2025 | ocrow; /* old cursor row */ |
1946 | int i, /* tmp */ |
2026 | int i, /* tmp */ |
1947 | row_offset; /* basic offset in screen structure */ |
2027 | row_offset; /* basic offset in screen structure */ |
1948 | #ifndef NO_CURSORCOLOR |
2028 | #ifndef NO_CURSORCOLOR |
1949 | rend_t cc1; /* store colours at cursor position (s) */ |
2029 | rend_t cc1; /* store colours at cursor position (s) */ |
1950 | #endif |
2030 | #endif |
1951 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
2031 | rend_t *crp; // cursor rendition pointer |
1952 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
2032 | |
|
|
2033 | want_refresh = 0; /* screen is current */ |
1953 | |
2034 | |
1954 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
2035 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1955 | return; |
2036 | return; |
1956 | |
2037 | |
1957 | /* |
2038 | /* |
1958 | * A: set up vars |
2039 | * A: set up vars |
1959 | */ |
2040 | */ |
1960 | must_clear = 0; |
2041 | must_clear = 0; |
1961 | |
|
|
1962 | refresh_count = 0; |
2042 | refresh_count = 0; |
1963 | |
2043 | |
1964 | row_offset = TermWin.saveLines - TermWin.view_start; |
2044 | row_offset = TermWin.saveLines - TermWin.view_start; |
1965 | |
2045 | |
1966 | #ifdef XPM_BACKGROUND |
2046 | #if XPM_BACKGROUND |
1967 | must_clear |= (bgPixmap.pixmap != None); |
2047 | must_clear |= (bgPixmap.pixmap != None); |
1968 | #endif |
2048 | #endif |
1969 | #ifdef TRANSPARENT |
2049 | #if TRANSPARENT |
1970 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
2050 | must_clear |= ((options & Opt_transparent) && am_transparent); |
1971 | #endif |
2051 | #endif |
1972 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2052 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1973 | |
2053 | |
1974 | /* |
2054 | /* |
1975 | * B: reverse any characters which are selected |
2055 | * B: reverse any characters which are selected |
… | |
… | |
1990 | showcursor = 0; |
2070 | showcursor = 0; |
1991 | #endif |
2071 | #endif |
1992 | |
2072 | |
1993 | if (showcursor) |
2073 | if (showcursor) |
1994 | { |
2074 | { |
|
|
2075 | int col = screen.cur.col; |
|
|
2076 | |
|
|
2077 | while (col && screen.text[screen.cur.row + TermWin.saveLines][col] == NOCHAR) |
|
|
2078 | col--; |
|
|
2079 | |
1995 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines][screen.cur.col]); |
2080 | crp = &screen.rend[screen.cur.row + TermWin.saveLines][col]; |
1996 | |
2081 | |
1997 | if (showcursor && TermWin.focus) |
2082 | if (showcursor && TermWin.focus) |
1998 | { |
2083 | { |
1999 | *srp ^= RS_RVid; |
2084 | *crp ^= RS_RVid; |
2000 | #ifndef NO_CURSORCOLOR |
2085 | #ifndef NO_CURSORCOLOR |
2001 | cc1 = *srp & (RS_fgMask | RS_bgMask); |
2086 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
2002 | if (ISSET_PIXCOLOR (Color_cursor)) |
2087 | if (ISSET_PIXCOLOR (Color_cursor)) |
2003 | ccol1 = Color_cursor; |
2088 | ccol1 = Color_cursor; |
2004 | else |
2089 | else |
2005 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2090 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2006 | ccol1 = GET_FGCOLOR (rstyle); |
2091 | ccol1 = GET_FGCOLOR (rstyle); |
… | |
… | |
2013 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2098 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2014 | ccol2 = GET_BGCOLOR (rstyle); |
2099 | ccol2 = GET_BGCOLOR (rstyle); |
2015 | #else |
2100 | #else |
2016 | ccol2 = Color_bg; |
2101 | ccol2 = Color_bg; |
2017 | #endif |
2102 | #endif |
2018 | *srp = SET_FGCOLOR (*srp, ccol1); |
2103 | *crp = SET_FGCOLOR (*crp, ccol1); |
2019 | *srp = SET_BGCOLOR (*srp, ccol2); |
2104 | *crp = SET_BGCOLOR (*crp, ccol2); |
2020 | #endif |
2105 | #endif |
2021 | } |
2106 | } |
2022 | } |
2107 | } |
2023 | |
2108 | |
2024 | /* make sure no outline cursor is left around */ |
2109 | /* make sure no outline cursor is left around */ |
… | |
… | |
2051 | oldcursor.col = screen.cur.col; |
2136 | oldcursor.col = screen.cur.col; |
2052 | } |
2137 | } |
2053 | } |
2138 | } |
2054 | } |
2139 | } |
2055 | |
2140 | |
|
|
2141 | #if ENABLE_OVERLAY |
|
|
2142 | scr_swap_overlay (); |
|
|
2143 | #endif |
|
|
2144 | |
|
|
2145 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
|
|
2146 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
|
|
2147 | |
2056 | #ifndef NO_SLOW_LINK_SUPPORT |
2148 | #ifndef NO_SLOW_LINK_SUPPORT |
2057 | /* |
2149 | /* |
2058 | * D: CopyArea pass - very useful for slower links |
2150 | * D: CopyArea pass - very useful for slower links |
2059 | * This has been deliberately kept simple. |
2151 | * This has been deliberately kept simple. |
2060 | */ |
2152 | */ |
… | |
… | |
2063 | && refresh_type == FAST_REFRESH && num_scr_allow && i |
2155 | && refresh_type == FAST_REFRESH && num_scr_allow && i |
2064 | && abs (i) < TermWin.nrow && !must_clear) |
2156 | && abs (i) < TermWin.nrow && !must_clear) |
2065 | { |
2157 | { |
2066 | int16_t nits; |
2158 | int16_t nits; |
2067 | int j; |
2159 | int j; |
2068 | rend_t *drp2; |
|
|
2069 | text_t *dtp2; |
|
|
2070 | int len, wlen; |
2160 | int len, wlen; |
2071 | |
2161 | |
2072 | j = TermWin.nrow; |
2162 | j = TermWin.nrow; |
2073 | wlen = len = -1; |
2163 | wlen = len = -1; |
2074 | row = i > 0 ? 0 : j - 1; |
2164 | row = i > 0 ? 0 : j - 1; |
2075 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2165 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2076 | { |
2166 | { |
2077 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
2167 | if (row + i >= 0 && row + i < TermWin.nrow && row + i != ocrow) |
2078 | { |
2168 | { |
2079 | stp = screen.text[row + row_offset]; |
2169 | text_t *stp = screen.text[row + row_offset]; |
2080 | srp = screen.rend[row + row_offset]; |
2170 | rend_t *srp = screen.rend[row + row_offset]; |
2081 | dtp = drawn_text[row]; |
2171 | text_t *dtp = drawn_text[row]; |
2082 | dtp2 = drawn_text[row + i]; |
2172 | text_t *dtp2 = drawn_text[row + i]; |
2083 | drp = drawn_rend[row]; |
2173 | rend_t *drp = drawn_rend[row]; |
2084 | drp2 = drawn_rend[row + i]; |
2174 | rend_t *drp2 = drawn_rend[row + i]; |
2085 | |
2175 | |
2086 | for (nits = 0, col = TermWin.ncol; col--; ) |
2176 | for (nits = 0, col = TermWin.ncol; col--; ) |
2087 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2177 | if (stp[col] != dtp2[col] || srp[col] != drp2[col]) |
2088 | nits--; |
2178 | nits--; |
2089 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
2179 | else if (stp[col] != dtp[col] || srp[col] != drp[col]) |
… | |
… | |
2109 | { |
2199 | { |
2110 | /* also comes here at end if needed because of >= above */ |
2200 | /* also comes here at end if needed because of >= above */ |
2111 | if (wlen < len) |
2201 | if (wlen < len) |
2112 | SWAP_IT (wlen, len, int); |
2202 | SWAP_IT (wlen, len, int); |
2113 | |
2203 | |
2114 | D_SCREEN ((stderr, "rxvt_scr_refresh (): XCopyArea: %d -> %d (height: %d)", len + i, len, wlen - len + 1)); |
|
|
2115 | XCopyArea (display->display, TermWin.vt, TermWin.vt, |
2204 | XCopyArea (display->display, TermWin.vt, TermWin.vt, |
2116 | TermWin.gc, 0, Row2Pixel (len + i), |
2205 | TermWin.gc, 0, Row2Pixel (len + i), |
2117 | (unsigned int)TermWin_TotalWidth (), |
2206 | (unsigned int)TermWin_TotalWidth (), |
2118 | (unsigned int)Height2Pixel (wlen - len + 1), |
2207 | (unsigned int)Height2Pixel (wlen - len + 1), |
2119 | 0, Row2Pixel (len)); |
2208 | 0, Row2Pixel (len)); |
… | |
… | |
2126 | /* |
2215 | /* |
2127 | * E: main pass across every character |
2216 | * E: main pass across every character |
2128 | */ |
2217 | */ |
2129 | for (row = 0; row < TermWin.nrow; row++) |
2218 | for (row = 0; row < TermWin.nrow; row++) |
2130 | { |
2219 | { |
2131 | stp = screen.text[row + row_offset]; |
2220 | text_t *stp = screen.text[row + row_offset]; |
2132 | srp = screen.rend[row + row_offset]; |
2221 | rend_t *srp = screen.rend[row + row_offset]; |
2133 | dtp = drawn_text[row]; |
2222 | text_t *dtp = drawn_text[row]; |
2134 | drp = drawn_rend[row]; |
2223 | rend_t *drp = drawn_rend[row]; |
2135 | |
2224 | |
2136 | /* |
2225 | /* |
2137 | * E2: OK, now the real pass |
2226 | * E2: OK, now the real pass |
2138 | */ |
2227 | */ |
2139 | int ypixel = (int)Row2Pixel (row); |
2228 | int ypixel = (int)Row2Pixel (row); |
2140 | |
2229 | |
2141 | for (col = 0; col < TermWin.ncol; col++) |
2230 | for (col = 0; col < TermWin.ncol; col++) |
2142 | { |
2231 | { |
2143 | /* compare new text with old - if exactly the same then continue */ |
2232 | /* compare new text with old - if exactly the same then continue */ |
2144 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2233 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2145 | && (srp[col] == drp[col] /* Either rendition the same or */ |
2234 | && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ |
2146 | || (stp[col] == ' ' /* space w/ no background change */ |
2235 | || (stp[col] == ' ' /* space w/ no background change */ |
2147 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
2236 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
2148 | continue; |
2237 | continue; |
2149 | |
2238 | |
2150 | // redraw one or more characters |
2239 | // redraw one or more characters |
2151 | |
2240 | |
2152 | // seek to the beginning if wide characters |
2241 | // seek to the beginning of wide characters |
2153 | while (stp[col] == NOCHAR && col > 0) |
2242 | while (stp[col] == NOCHAR && col > 0) |
2154 | --col; |
2243 | --col; |
2155 | |
2244 | |
2156 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2245 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2157 | text_t *text = stp + col; |
2246 | text_t *text = stp + col; |
… | |
… | |
2160 | dtp[col] = stp[col]; |
2249 | dtp[col] = stp[col]; |
2161 | drp[col] = rend; |
2250 | drp[col] = rend; |
2162 | |
2251 | |
2163 | int xpixel = Col2Pixel (col); |
2252 | int xpixel = Col2Pixel (col); |
2164 | |
2253 | |
2165 | // this loop looks very messy, it can probably be optimized |
|
|
2166 | // and cleaned a bit by you? |
|
|
2167 | for (i = 0; ++col < TermWin.ncol; ) |
2254 | for (i = 0; ++col < TermWin.ncol; ) |
2168 | { |
2255 | { |
2169 | if (stp[col] == NOCHAR) |
2256 | if (stp[col] == NOCHAR) |
2170 | { |
2257 | { |
2171 | dtp[col] = stp[col]; |
2258 | dtp[col] = stp[col]; |
2172 | drp[col] = rend; |
2259 | drp[col] = rend; |
2173 | count++; |
2260 | count++; |
2174 | |
|
|
2175 | if (i) // only possible skip if char unchanged |
|
|
2176 | i++; |
2261 | i++; |
2177 | |
2262 | |
2178 | continue; |
2263 | continue; |
2179 | } |
2264 | } |
2180 | |
2265 | |
2181 | if (rend != srp[col]) |
2266 | if (!RS_SAME (rend, srp[col])) |
2182 | break; |
2267 | break; |
2183 | |
2268 | |
2184 | count++; |
2269 | count++; |
2185 | |
2270 | |
2186 | if (stp[col] != dtp[col] |
2271 | if (stp[col] != dtp[col] |
2187 | || srp[col] != drp[col]) |
2272 | || !RS_SAME (srp[col], drp[col])) |
2188 | { |
2273 | { |
2189 | if (must_clear && (i++ > (count / 2))) |
2274 | if (must_clear && (i++ > count / 2)) |
2190 | break; |
2275 | break; |
2191 | |
2276 | |
2192 | dtp[col] = stp[col]; |
2277 | dtp[col] = stp[col]; |
2193 | drp[col] = rend; |
2278 | drp[col] = rend; |
2194 | i = 0; |
2279 | i = 0; |
2195 | } |
2280 | } |
2196 | else if (must_clear || (stp[col] != ' ' && ++i >= 32)) |
2281 | else if (must_clear || (stp[col] != ' ' && ++i >= 16)) |
2197 | break; |
2282 | break; |
2198 | } |
2283 | } |
2199 | |
2284 | |
2200 | col--; /* went one too far. move back */ |
2285 | col--; /* went one too far. move back */ |
2201 | count -= i; /* dump any matching trailing chars */ |
2286 | count -= i; /* dump any matching trailing chars */ |
|
|
2287 | |
|
|
2288 | // sometimes we optimize away the trailing NOCHAR's, add them back |
|
|
2289 | while (i && text[count] == NOCHAR) |
|
|
2290 | count++, i--; |
|
|
2291 | |
|
|
2292 | #if ENABLE_STYLES |
|
|
2293 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2294 | if (srp[col] & RS_Careful && col < TermWin.ncol - 1 && 0) |
|
|
2295 | drp[col + 1] = ~srp[col + 1]; |
|
|
2296 | |
|
|
2297 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2298 | while (text > stp |
|
|
2299 | && srp[text - stp - 1] & RS_Careful |
|
|
2300 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2301 | text--, count++, xpixel -= TermWin.fwidth; |
|
|
2302 | #endif |
2202 | |
2303 | |
2203 | /* |
2304 | /* |
2204 | * Determine the attributes for the string |
2305 | * Determine the attributes for the string |
2205 | */ |
2306 | */ |
2206 | int fid = GET_FONT (rend); |
|
|
2207 | int fore = GET_FGCOLOR (rend); // desired foreground |
2307 | int fore = GET_FGCOLOR (rend); // desired foreground |
2208 | int back = GET_BGCOLOR (rend); // desired background |
2308 | int back = GET_BGCOLOR (rend); // desired background |
2209 | |
2309 | |
2210 | rend = GET_ATTR (rend); |
2310 | // only do special processing if ana attributes are set, which is rare |
2211 | |
2311 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink)) |
2212 | rvid = !!(rend & RS_RVid); |
2312 | { |
|
|
2313 | bool invert = rend & RS_RVid; |
2213 | |
2314 | |
2214 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2315 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2215 | if (rend & RS_Bold && fore == Color_fg && !(Options & Opt_realBold)) |
2316 | if (rend & RS_Bold |
|
|
2317 | && fore == Color_fg) |
2216 | { |
2318 | { |
2217 | if (ISSET_PIXCOLOR (Color_BD)) |
2319 | if (ISSET_PIXCOLOR (Color_BD)) |
2218 | fore = Color_BD; |
2320 | fore = Color_BD; |
|
|
2321 | # if !ENABLE_STYLES |
2219 | else |
2322 | else |
2220 | rvid = !rvid; |
2323 | invert = !invert; |
|
|
2324 | # endif |
|
|
2325 | } |
|
|
2326 | |
|
|
2327 | if (rend & RS_Italic |
|
|
2328 | && fore == Color_fg) |
|
|
2329 | { |
|
|
2330 | if (ISSET_PIXCOLOR (Color_IT)) |
|
|
2331 | fore = Color_IT; |
|
|
2332 | # if !ENABLE_STYLES |
|
|
2333 | else |
|
|
2334 | invert = !invert; |
|
|
2335 | # endif |
|
|
2336 | } |
|
|
2337 | |
|
|
2338 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
|
|
2339 | fore = Color_UL; |
|
|
2340 | #endif |
|
|
2341 | |
|
|
2342 | if (invert) |
|
|
2343 | { |
|
|
2344 | SWAP_IT (fore, back, int); |
|
|
2345 | |
|
|
2346 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2347 | if (ISSET_PIXCOLOR (Color_RV)) |
|
|
2348 | back = Color_RV; |
|
|
2349 | #endif |
|
|
2350 | } |
|
|
2351 | |
|
|
2352 | #ifdef TEXT_BLINK |
|
|
2353 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
|
|
2354 | { |
|
|
2355 | if (!text_blink_ev.active) |
|
|
2356 | { |
|
|
2357 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2358 | hidden_text = 0; |
|
|
2359 | } |
|
|
2360 | else if (hidden_text) |
|
|
2361 | fore = back; |
|
|
2362 | } |
|
|
2363 | #endif |
2221 | } |
2364 | } |
2222 | |
|
|
2223 | if (rend & RS_Uline) |
|
|
2224 | if (ISSET_PIXCOLOR (Color_UL)) |
|
|
2225 | fore = Color_UL; |
|
|
2226 | #endif |
|
|
2227 | |
|
|
2228 | if (rvid) |
|
|
2229 | { |
|
|
2230 | SWAP_IT (fore, back, int); |
|
|
2231 | |
|
|
2232 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2233 | if (ISSET_PIXCOLOR (Color_RV) |
|
|
2234 | # ifndef NO_CURSORCOLOR |
|
|
2235 | && !ISSET_PIXCOLOR (Color_cursor) |
|
|
2236 | # endif |
|
|
2237 | ) |
|
|
2238 | back = Color_RV; |
|
|
2239 | #endif |
|
|
2240 | } |
|
|
2241 | |
|
|
2242 | #ifdef TEXT_BLINK |
|
|
2243 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
|
|
2244 | { |
|
|
2245 | if (!text_blink_ev.active) |
|
|
2246 | { |
|
|
2247 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2248 | hidden_text = 0; |
|
|
2249 | } |
|
|
2250 | else if (hidden_text) |
|
|
2251 | fore = back; |
|
|
2252 | } |
|
|
2253 | #endif |
|
|
2254 | |
2365 | |
2255 | /* |
2366 | /* |
2256 | * Actually do the drawing of the string here |
2367 | * Actually do the drawing of the string here |
2257 | */ |
2368 | */ |
2258 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2369 | rxvt_font *font = (*TermWin.fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2259 | |
2370 | |
2260 | if (back == fore) |
2371 | if (back == fore) |
2261 | font->clear_rect (*TermWin.drawable, xpixel, ypixel, |
2372 | font->clear_rect (*TermWin.drawable, xpixel, ypixel, |
2262 | TermWin.fwidth * count, TermWin.fheight, |
2373 | TermWin.fwidth * count, TermWin.fheight, |
2263 | back); |
2374 | back); |
… | |
… | |
2279 | } |
2390 | } |
2280 | else |
2391 | else |
2281 | font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); |
2392 | font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); |
2282 | |
2393 | |
2283 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2394 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
|
|
2395 | { |
|
|
2396 | #if ENABLE_FRILLS |
|
|
2397 | if (ISSET_PIXCOLOR (Color_underline)) |
|
|
2398 | XSetForeground (display->display, TermWin.gc, pix_colors[Color_underline]); |
|
|
2399 | else |
|
|
2400 | #endif |
|
|
2401 | XSetForeground (display->display, TermWin.gc, pix_colors[fore]); |
|
|
2402 | |
2284 | XDrawLine (display->display, drawBuffer, TermWin.gc, |
2403 | XDrawLine (display->display, drawBuffer, TermWin.gc, |
2285 | xpixel, ypixel + font->ascent + 1, |
2404 | xpixel, ypixel + font->ascent + 1, |
2286 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2405 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
|
|
2406 | } |
2287 | } /* for (col....) */ |
2407 | } /* for (col....) */ |
2288 | } /* for (row....) */ |
2408 | } /* for (row....) */ |
|
|
2409 | |
|
|
2410 | #if ENABLE_OVERLAY |
|
|
2411 | scr_swap_overlay (); |
|
|
2412 | #endif |
2289 | |
2413 | |
2290 | /* |
2414 | /* |
2291 | * G: cleanup cursor and display outline cursor if necessary |
2415 | * G: cleanup cursor and display outline cursor if necessary |
2292 | */ |
2416 | */ |
2293 | if (showcursor) |
2417 | if (showcursor) |
2294 | { |
2418 | { |
2295 | if (TermWin.focus) |
2419 | if (TermWin.focus) |
2296 | { |
2420 | { |
2297 | srp = & (screen.rend[screen.cur.row + TermWin.saveLines] |
|
|
2298 | [screen.cur.col]); |
|
|
2299 | *srp ^= RS_RVid; |
2421 | *crp ^= RS_RVid; |
2300 | #ifndef NO_CURSORCOLOR |
2422 | #ifndef NO_CURSORCOLOR |
2301 | *srp = (*srp & ~ (RS_fgMask | RS_bgMask)) | cc1; |
2423 | *crp = (*crp & ~ (RS_fgMask | RS_bgMask)) | cc1; |
2302 | #endif |
2424 | #endif |
2303 | } |
2425 | } |
2304 | else if (oldcursor.row >= 0) |
2426 | else if (oldcursor.row >= 0) |
2305 | { |
2427 | { |
2306 | #ifndef NO_CURSORCOLOR |
2428 | #ifndef NO_CURSORCOLOR |
2307 | if (ISSET_PIXCOLOR (Color_cursor)) |
2429 | if (ISSET_PIXCOLOR (Color_cursor)) |
2308 | XSetForeground (display->display, TermWin.gc, PixColors[Color_cursor]); |
2430 | XSetForeground (display->display, TermWin.gc, pix_colors[Color_cursor]); |
2309 | #endif |
2431 | #endif |
2310 | int cursorwidth = 1; |
2432 | int cursorwidth = 1; |
2311 | while (oldcursor.col + cursorwidth < TermWin.ncol |
2433 | while (oldcursor.col + cursorwidth < TermWin.ncol |
2312 | && drawn_text[oldcursor.row][oldcursor.col + cursorwidth] == NOCHAR) |
2434 | && drawn_text[oldcursor.row][oldcursor.col + cursorwidth] == NOCHAR) |
2313 | cursorwidth++; |
2435 | cursorwidth++; |
… | |
… | |
2328 | if (refresh_type & SMOOTH_REFRESH) |
2450 | if (refresh_type & SMOOTH_REFRESH) |
2329 | XFlush (display->display); |
2451 | XFlush (display->display); |
2330 | |
2452 | |
2331 | num_scr = 0; |
2453 | num_scr = 0; |
2332 | num_scr_allow = 1; |
2454 | num_scr_allow = 1; |
2333 | want_refresh = 0; /* screen is current */ |
|
|
2334 | } |
2455 | } |
2335 | |
2456 | |
2336 | void |
2457 | void |
2337 | rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp) |
2458 | rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp) |
2338 | { |
2459 | { |
2339 | if (!rp || !tp) |
2460 | if (!rp || !tp) |
2340 | return; |
2461 | return; |
2341 | |
2462 | |
2342 | for (int i = TermWin.ncol; i; i--, rp++, tp++) |
2463 | for (int i = TermWin.ncol; i; i--, rp++, tp++) |
2343 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
2464 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
2344 | } |
2465 | } |
2345 | |
2466 | |
2346 | void |
2467 | void |
2347 | rxvt_term::scr_remap_chars () |
2468 | rxvt_term::scr_remap_chars () |
2348 | { |
2469 | { |
… | |
… | |
2354 | scr_remap_chars (drawn_text[i], drawn_rend[i]); |
2475 | scr_remap_chars (drawn_text[i], drawn_rend[i]); |
2355 | scr_remap_chars (swap.text[i], swap.rend[i]); |
2476 | scr_remap_chars (swap.text[i], swap.rend[i]); |
2356 | } |
2477 | } |
2357 | } |
2478 | } |
2358 | |
2479 | |
|
|
2480 | void |
|
|
2481 | rxvt_term::scr_recolour () |
|
|
2482 | { |
|
|
2483 | if (1 |
|
|
2484 | #if TRANSPARENT |
|
|
2485 | && !am_transparent |
|
|
2486 | #endif |
|
|
2487 | #if XPM_BACKGROUND |
|
|
2488 | && !bgPixmap.pixmap |
|
|
2489 | #endif |
|
|
2490 | ) |
|
|
2491 | { |
|
|
2492 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors[Color_border]); |
|
|
2493 | XClearWindow (display->display, TermWin.parent[0]); |
|
|
2494 | XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); |
|
|
2495 | #if HAVE_SCROLLBARS |
|
|
2496 | if (scrollBar.win) |
|
|
2497 | { |
|
|
2498 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
|
|
2499 | scrollBar.setIdle (); |
|
|
2500 | scrollbar_show (0); |
|
|
2501 | } |
|
|
2502 | #endif |
|
|
2503 | } |
|
|
2504 | |
|
|
2505 | scr_clear (); |
|
|
2506 | scr_touch (true); |
|
|
2507 | want_refresh = 1; |
|
|
2508 | } |
|
|
2509 | |
2359 | /* ------------------------------------------------------------------------- */ |
2510 | /* ------------------------------------------------------------------------- */ |
2360 | void |
2511 | void |
2361 | rxvt_term::scr_clear (bool really) |
2512 | rxvt_term::scr_clear (bool really) |
2362 | { |
2513 | { |
2363 | if (!TermWin.mapped) |
2514 | if (!TermWin.mapped) |
2364 | return; |
2515 | return; |
2365 | |
2516 | |
2366 | num_scr_allow = 0; |
2517 | num_scr_allow = 0; |
2367 | want_refresh = 1; |
2518 | want_refresh = 1; |
2368 | |
2519 | |
2369 | #ifdef TRANSPARENT |
2520 | #if TRANSPARENT |
2370 | if ((Options & Opt_transparent) && (am_pixmap_trans == 0)) |
2521 | if ((options & Opt_transparent) && (am_pixmap_trans == 0)) |
2371 | { |
2522 | { |
2372 | int i; |
2523 | int i; |
2373 | |
2524 | |
2374 | if (! (Options & Opt_transparent_all)) |
2525 | if (!(options & Opt_transparent_all)) |
2375 | i = 0; |
2526 | i = 0; |
2376 | else |
2527 | else |
2377 | i = (int) (sizeof (TermWin.parent) / sizeof (Window)); |
2528 | i = (int) (sizeof (TermWin.parent) / sizeof (Window)); |
2378 | |
2529 | |
2379 | while (i--) |
2530 | while (i--) |
… | |
… | |
2395 | int end_row = TermWin.saveLines - TermWin.view_start; |
2546 | int end_row = TermWin.saveLines - TermWin.view_start; |
2396 | int i = selection.beg.row + TermWin.saveLines; |
2547 | int i = selection.beg.row + TermWin.saveLines; |
2397 | int col, row = selection.end.row + TermWin.saveLines; |
2548 | int col, row = selection.end.row + TermWin.saveLines; |
2398 | rend_t *srp; |
2549 | rend_t *srp; |
2399 | |
2550 | |
2400 | if (i >= end_row) |
2551 | #if ENABLE_FRILLS |
2401 | col = selection.beg.col; |
2552 | if (selection.rect) |
|
|
2553 | { |
|
|
2554 | end_row += TermWin.nrow; |
|
|
2555 | |
|
|
2556 | for (; i <= row && i <= end_row; i++) |
|
|
2557 | for (srp = screen.rend[i], col = selection.beg.col; col < selection.end.col; col++) |
|
|
2558 | srp[col] ^= RS_RVid; |
|
|
2559 | } |
2402 | else |
2560 | else |
|
|
2561 | #endif |
|
|
2562 | { |
|
|
2563 | if (i >= end_row) |
|
|
2564 | col = selection.beg.col; |
|
|
2565 | else |
2403 | { |
2566 | { |
2404 | col = 0; |
2567 | col = 0; |
2405 | i = end_row; |
2568 | i = end_row; |
2406 | } |
2569 | } |
2407 | |
2570 | |
2408 | end_row += TermWin.nrow; |
2571 | end_row += TermWin.nrow; |
|
|
2572 | |
2409 | for (; i < row && i < end_row; i++, col = 0) |
2573 | for (; i < row && i < end_row; i++, col = 0) |
2410 | for (srp = screen.rend[i]; col < TermWin.ncol; col++) |
2574 | for (srp = screen.rend[i]; col < TermWin.ncol; col++) |
2411 | srp[col] ^= RS_RVid; |
2575 | srp[col] ^= RS_RVid; |
2412 | |
2576 | |
2413 | if (i == row && i < end_row) |
2577 | if (i == row && i < end_row) |
2414 | for (srp = screen.rend[i]; col < selection.end.col; col++) |
2578 | for (srp = screen.rend[i]; col < selection.end.col; col++) |
2415 | srp[col] ^= RS_RVid; |
2579 | srp[col] ^= RS_RVid; |
|
|
2580 | } |
2416 | } |
2581 | } |
2417 | } |
2582 | } |
2418 | |
2583 | |
2419 | /* ------------------------------------------------------------------------- */ |
2584 | /* ------------------------------------------------------------------------- */ |
2420 | /* |
2585 | /* |
… | |
… | |
2456 | * -TermWin.nscrolled <= (selection row) <= TermWin.nrow - 1 |
2621 | * -TermWin.nscrolled <= (selection row) <= TermWin.nrow - 1 |
2457 | */ |
2622 | */ |
2458 | void |
2623 | void |
2459 | rxvt_term::selection_check (int check_more) |
2624 | rxvt_term::selection_check (int check_more) |
2460 | { |
2625 | { |
2461 | row_col_t pos; |
2626 | row_col_t pos; |
2462 | |
2627 | |
2463 | if (!selection.op) |
2628 | if (!selection.op) |
2464 | return; |
2629 | return; |
2465 | |
2630 | |
2466 | pos.row = pos.col = 0; |
2631 | pos.row = pos.col = 0; |
… | |
… | |
2488 | /* ------------------------------------------------------------------------- */ |
2653 | /* ------------------------------------------------------------------------- */ |
2489 | /* |
2654 | /* |
2490 | * Paste a selection direct to the command fd |
2655 | * Paste a selection direct to the command fd |
2491 | */ |
2656 | */ |
2492 | void |
2657 | void |
2493 | rxvt_term::paste (const unsigned char *data, unsigned int len) |
2658 | rxvt_term::paste (unsigned char *data, unsigned int len) |
2494 | { |
2659 | { |
2495 | unsigned int i, j, n; |
|
|
2496 | unsigned char *ds = (unsigned char *)rxvt_malloc (PROP_SIZE); |
|
|
2497 | |
|
|
2498 | #if 0 |
|
|
2499 | /* a paste should act like the user is typing, so check scrollTtyKeypress */ |
|
|
2500 | ZERO_SCROLLBACK (r); |
|
|
2501 | #endif |
|
|
2502 | |
|
|
2503 | /* convert normal newline chars into common keyboard Return key sequence */ |
2660 | /* convert normal newline chars into common keyboard Return key sequence */ |
2504 | for (i = 0; i < len; i += PROP_SIZE) |
2661 | for (unsigned int i = 0; i < len; i++) |
2505 | { |
|
|
2506 | n = min (len - i, PROP_SIZE); |
|
|
2507 | MEMCPY (ds, data + i, n); |
|
|
2508 | |
|
|
2509 | for (j = 0; j < n; j++) |
|
|
2510 | if (ds[j] == C0_LF) |
2662 | if (data[i] == C0_LF) |
2511 | ds[j] = C0_CR; |
2663 | data[i] = C0_CR; |
2512 | |
2664 | |
2513 | tt_write (ds, (int)n); |
2665 | tt_write (data, len); |
2514 | } |
|
|
2515 | |
|
|
2516 | free (ds); |
|
|
2517 | } |
2666 | } |
2518 | |
2667 | |
2519 | /* ------------------------------------------------------------------------- */ |
2668 | /* ------------------------------------------------------------------------- */ |
2520 | /* |
2669 | /* |
2521 | * Respond to a notification that a primary selection has been sent |
2670 | * Respond to a notification that a primary selection has been sent |
2522 | * EXT: SelectionNotify |
2671 | * EXT: SelectionNotify |
2523 | */ |
2672 | */ |
2524 | int |
2673 | void |
2525 | rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) |
2674 | rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) |
2526 | { |
2675 | { |
2527 | long nread = 0; |
|
|
2528 | unsigned long bytes_after; |
|
|
2529 | XTextProperty ct; |
|
|
2530 | |
|
|
2531 | D_SELECT ((stderr, "rxvt_selection_paste (%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, selection_wait)); |
|
|
2532 | |
|
|
2533 | if (prop == None) /* check for failed XConvertSelection */ |
2676 | if (prop == None) /* check for failed XConvertSelection */ |
2534 | { |
2677 | { |
2535 | if ((selection_type & Sel_CompoundText)) |
2678 | if ((selection_type & Sel_CompoundText)) |
2536 | { |
2679 | { |
2537 | int selnum = selection_type & Sel_whereMask; |
2680 | int selnum = selection_type & Sel_whereMask; |
… | |
… | |
2550 | selection_request_other (xa[XA_COMPOUND_TEXT], selnum); |
2693 | selection_request_other (xa[XA_COMPOUND_TEXT], selnum); |
2551 | else |
2694 | else |
2552 | selection_type = 0; |
2695 | selection_type = 0; |
2553 | } |
2696 | } |
2554 | |
2697 | |
2555 | return 0; |
2698 | return; |
2556 | } |
|
|
2557 | |
|
|
2558 | for (;;) |
|
|
2559 | { |
2699 | } |
|
|
2700 | |
|
|
2701 | unsigned long bytes_after; |
|
|
2702 | XTextProperty ct; |
|
|
2703 | |
|
|
2704 | if (XGetWindowProperty (display->display, win, prop, |
|
|
2705 | 0, PROP_SIZE / 4, |
|
|
2706 | delete_prop, AnyPropertyType, |
|
|
2707 | &ct.encoding, &ct.format, |
|
|
2708 | &ct.nitems, &bytes_after, |
|
|
2709 | &ct.value) != Success) |
|
|
2710 | { |
|
|
2711 | ct.value = 0; |
|
|
2712 | goto bailout; |
|
|
2713 | } |
|
|
2714 | |
|
|
2715 | if (ct.encoding == None) |
|
|
2716 | goto bailout; |
|
|
2717 | |
|
|
2718 | if (bytes_after) |
|
|
2719 | { |
|
|
2720 | // fetch and append remaining data |
|
|
2721 | XTextProperty ct2; |
|
|
2722 | |
2560 | if (XGetWindowProperty (display->display, win, prop, (long) (nread / 4), |
2723 | if (XGetWindowProperty (display->display, win, prop, |
2561 | (long) (PROP_SIZE / 4), delete_prop, |
2724 | ct.nitems / 4, (bytes_after + 3) / 4, |
|
|
2725 | delete_prop, AnyPropertyType, |
2562 | AnyPropertyType, &ct.encoding, &ct.format, |
2726 | &ct2.encoding, &ct2.format, |
2563 | &ct.nitems, &bytes_after, |
2727 | &ct2.nitems, &bytes_after, |
2564 | &ct.value) != Success) |
2728 | &ct2.value) != Success) |
2565 | break; |
2729 | goto bailout; |
2566 | |
2730 | |
2567 | if (ct.encoding == 0) |
2731 | // realloc should be compatible to XFree, here, and elsewhere, too |
2568 | { |
2732 | ct.value = (unsigned char *)realloc (ct.value, ct.nitems + ct2.nitems + 1); |
2569 | D_SELECT ((stderr, "rxvt_selection_paste: property didn't exist!")); |
2733 | memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems + 1); |
2570 | break; |
2734 | ct.nitems += ct2.nitems; |
2571 | } |
2735 | |
|
|
2736 | XFree (ct2.value); |
|
|
2737 | } |
|
|
2738 | |
|
|
2739 | if (ct.value == 0) |
|
|
2740 | goto bailout; |
|
|
2741 | |
2572 | else if (ct.encoding == xa[XA_INCR]) |
2742 | if (ct.encoding == xa[XA_INCR]) |
2573 | { |
2743 | { |
2574 | // INCR selection, start handshake |
2744 | // INCR selection, start handshake |
|
|
2745 | if (!delete_prop) |
2575 | XDeleteProperty (display->display, win, prop); |
2746 | XDeleteProperty (display->display, win, prop); |
|
|
2747 | |
2576 | selection_wait = Sel_incr; |
2748 | selection_wait = Sel_incr; |
|
|
2749 | incr_buf_fill = 0; |
2577 | incr_ev.start (NOW + 10); |
2750 | incr_ev.start (NOW + 10); |
2578 | break; |
|
|
2579 | } |
|
|
2580 | |
2751 | |
2581 | if (ct.value == NULL) |
2752 | goto bailout; |
2582 | { |
2753 | } |
2583 | D_SELECT ((stderr, "rxvt_selection_paste: property shooting blanks!")); |
|
|
2584 | continue; |
|
|
2585 | } |
|
|
2586 | |
2754 | |
2587 | if (ct.nitems == 0) |
2755 | if (ct.nitems == 0) |
|
|
2756 | { |
|
|
2757 | if (selection_wait == Sel_incr) |
|
|
2758 | { |
|
|
2759 | XFree (ct.value); |
|
|
2760 | |
|
|
2761 | // finally complete, now paste the whole thing |
|
|
2762 | selection_wait = Sel_normal; |
|
|
2763 | ct.value = (unsigned char *)incr_buf; |
|
|
2764 | ct.nitems = incr_buf_fill; |
|
|
2765 | incr_buf = 0; |
|
|
2766 | incr_buf_size = 0; |
|
|
2767 | incr_ev.stop (); |
2588 | { |
2768 | } |
2589 | D_SELECT ((stderr, "rxvt_selection_paste: property empty - also INCR end")); |
2769 | else |
2590 | |
2770 | { |
2591 | if (selection_wait == Sel_normal && nread == 0 |
2771 | if (selection_wait == Sel_normal |
2592 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2772 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2593 | { |
2773 | { |
2594 | /* |
2774 | /* |
2595 | * pass through again trying CUT_BUFFER0 if we've come from |
2775 | * pass through again trying CUT_BUFFER0 if we've come from |
2596 | * XConvertSelection () but nothing was presented |
2776 | * XConvertSelection () but nothing was presented |
2597 | */ |
2777 | */ |
2598 | D_SELECT ((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
|
|
2599 | selection_paste (display->root, XA_CUT_BUFFER0, False); |
2778 | selection_paste (display->root, XA_CUT_BUFFER0, False); |
2600 | } |
2779 | } |
2601 | |
2780 | |
2602 | nread = -1; /* discount any previous stuff */ |
2781 | goto bailout; |
2603 | break; |
2782 | } |
|
|
2783 | } |
|
|
2784 | else if (selection_wait == Sel_incr) |
|
|
2785 | { |
|
|
2786 | incr_ev.start (NOW + 10); |
|
|
2787 | |
|
|
2788 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2604 | } |
2789 | { |
|
|
2790 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
|
|
2791 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
|
|
2792 | } |
2605 | |
2793 | |
|
|
2794 | memcpy (incr_buf + incr_buf_fill, ct.value, ct.nitems); |
2606 | nread += ct.nitems; |
2795 | incr_buf_fill += ct.nitems; |
2607 | |
2796 | |
|
|
2797 | goto bailout; |
|
|
2798 | } |
|
|
2799 | |
2608 | char **cl; |
2800 | char **cl; |
2609 | int cr; |
2801 | int cr; |
|
|
2802 | |
|
|
2803 | #if ENABLE_FRILLS |
|
|
2804 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
|
|
2805 | // so recode it manually |
|
|
2806 | if (ct.encoding == xa[XA_UTF8_STRING]) |
|
|
2807 | { |
|
|
2808 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
|
|
2809 | char *s = rxvt_wcstombs (w); |
|
|
2810 | free (w); |
|
|
2811 | // TODO: strlen == only the first element will be converted. well... |
|
|
2812 | paste ((unsigned char *)s, strlen (s)); |
|
|
2813 | free (s); |
|
|
2814 | } |
|
|
2815 | else |
|
|
2816 | #endif |
2610 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 && cl) |
2817 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2611 | { |
2818 | && cl) |
|
|
2819 | { |
2612 | for (int i = 0; i < cr; i++) |
2820 | for (int i = 0; i < cr; i++) |
2613 | paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
2821 | paste ((unsigned char *)cl[i], strlen (cl[i])); |
2614 | |
2822 | |
2615 | XFreeStringList (cl); |
2823 | XFreeStringList (cl); |
2616 | } |
2824 | } |
2617 | else |
2825 | else |
2618 | paste (ct.value, ct.nitems); |
2826 | paste (ct.value, ct.nitems); // paste raw |
2619 | |
2827 | |
2620 | if (bytes_after == 0) |
2828 | bailout: |
2621 | break; |
|
|
2622 | |
|
|
2623 | XFree (ct.value); |
|
|
2624 | } |
|
|
2625 | |
|
|
2626 | if (ct.value) |
|
|
2627 | XFree (ct.value); |
2829 | XFree (ct.value); |
2628 | |
2830 | |
2629 | if (selection_wait == Sel_normal) |
2831 | if (selection_wait == Sel_normal) |
2630 | selection_wait = Sel_none; |
2832 | selection_wait = Sel_none; |
2631 | |
|
|
2632 | D_SELECT ((stderr, "rxvt_selection_paste: bytes written: %ld", nread)); |
|
|
2633 | return (int)nread; |
|
|
2634 | } |
2833 | } |
2635 | |
2834 | |
2636 | void |
2835 | void |
2637 | rxvt_term::incr_cb (time_watcher &w) |
2836 | rxvt_term::incr_cb (time_watcher &w) |
2638 | { |
2837 | { |
2639 | selection_wait = Sel_none; |
2838 | selection_wait = Sel_none; |
2640 | |
2839 | |
|
|
2840 | incr_buf_size = 0; |
|
|
2841 | free (incr_buf); |
|
|
2842 | |
2641 | rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); |
2843 | rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); |
2642 | } |
2844 | } |
2643 | |
2845 | |
2644 | /* |
|
|
2645 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
|
|
2646 | */ |
|
|
2647 | void |
2846 | void |
2648 | rxvt_term::selection_property (Window win, Atom prop) |
2847 | rxvt_term::selection_property (Window win, Atom prop) |
2649 | { |
2848 | { |
2650 | if (prop == None || selection_wait != Sel_incr) |
2849 | if (prop == None || selection_wait != Sel_incr) |
2651 | return; |
2850 | return; |
2652 | |
2851 | |
2653 | if (selection_paste (win, prop, 1) > 0) |
2852 | selection_paste (win, prop, true); |
2654 | incr_ev.start (NOW + 10); |
|
|
2655 | else |
|
|
2656 | { |
|
|
2657 | selection_wait = Sel_none; |
|
|
2658 | incr_ev.stop (); |
|
|
2659 | } |
|
|
2660 | } |
2853 | } |
2661 | |
2854 | |
2662 | /* ------------------------------------------------------------------------- */ |
2855 | /* ------------------------------------------------------------------------- */ |
2663 | /* |
2856 | /* |
2664 | * Request the current selection: |
2857 | * Request the current selection: |
… | |
… | |
2670 | * EXT: button 2 release |
2863 | * EXT: button 2 release |
2671 | */ |
2864 | */ |
2672 | void |
2865 | void |
2673 | rxvt_term::selection_request (Time tm, int x, int y) |
2866 | rxvt_term::selection_request (Time tm, int x, int y) |
2674 | { |
2867 | { |
2675 | D_SELECT ((stderr, "rxvt_selection_request (%lu, %d, %d)", tm, x, y)); |
|
|
2676 | |
|
|
2677 | if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height) |
2868 | if (x < 0 || x >= TermWin.width || y < 0 || y >= TermWin.height) |
2678 | return; /* outside window */ |
2869 | return; /* outside window */ |
2679 | |
2870 | |
2680 | if (selection.text) |
2871 | if (selection.text) |
2681 | { /* internal selection */ |
2872 | { /* internal selection */ |
2682 | D_SELECT ((stderr, "rxvt_selection_request: pasting internal")); |
|
|
2683 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2873 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2684 | paste ((unsigned char *)str, strlen (str)); |
2874 | paste ((unsigned char *)str, strlen (str)); |
2685 | free (str); |
2875 | free (str); |
2686 | return; |
2876 | return; |
2687 | } |
2877 | } |
… | |
… | |
2701 | #else |
2891 | #else |
2702 | selection_type = Sel_CompoundText; |
2892 | selection_type = Sel_CompoundText; |
2703 | if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) |
2893 | if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) |
2704 | return; |
2894 | return; |
2705 | #endif |
2895 | #endif |
2706 | |
|
|
2707 | } |
2896 | } |
2708 | } |
2897 | } |
2709 | |
2898 | |
2710 | selection_wait = Sel_none; /* don't loop in rxvt_selection_paste () */ |
2899 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2711 | D_SELECT ((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
|
|
2712 | selection_paste (display->root, XA_CUT_BUFFER0, False); |
2900 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
2713 | } |
2901 | } |
2714 | |
2902 | |
2715 | int |
2903 | int |
2716 | rxvt_term::selection_request_other (Atom target, int selnum) |
2904 | rxvt_term::selection_request_other (Atom target, int selnum) |
2717 | { |
2905 | { |
… | |
… | |
2729 | else |
2917 | else |
2730 | sel = xa[XA_CLIPBOARD]; |
2918 | sel = xa[XA_CLIPBOARD]; |
2731 | |
2919 | |
2732 | if (XGetSelectionOwner (display->display, sel) != None) |
2920 | if (XGetSelectionOwner (display->display, sel) != None) |
2733 | { |
2921 | { |
2734 | D_SELECT ((stderr, "rxvt_selection_request_other: pasting %s", debug_xa_names[selnum])); |
|
|
2735 | XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], |
2922 | XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], |
2736 | TermWin.vt, selection_request_time); |
2923 | TermWin.vt, selection_request_time); |
2737 | return 1; |
2924 | return 1; |
2738 | } |
2925 | } |
2739 | |
2926 | |
… | |
… | |
2746 | * EXT: SelectionClear |
2933 | * EXT: SelectionClear |
2747 | */ |
2934 | */ |
2748 | void |
2935 | void |
2749 | rxvt_term::selection_clear () |
2936 | rxvt_term::selection_clear () |
2750 | { |
2937 | { |
2751 | D_SELECT ((stderr, "rxvt_selection_clear ()")); |
|
|
2752 | |
|
|
2753 | want_refresh = 1; |
2938 | want_refresh = 1; |
2754 | free (selection.text); |
2939 | free (selection.text); |
2755 | selection.text = NULL; |
2940 | selection.text = NULL; |
2756 | selection.len = 0; |
2941 | selection.len = 0; |
2757 | CLEAR_SELECTION (); |
2942 | CLEAR_SELECTION (); |
… | |
… | |
2770 | { |
2955 | { |
2771 | int i, col, end_col, row, end_row; |
2956 | int i, col, end_col, row, end_row; |
2772 | wchar_t *new_selection_text; |
2957 | wchar_t *new_selection_text; |
2773 | text_t *t; |
2958 | text_t *t; |
2774 | |
2959 | |
2775 | D_SELECT ((stderr, "rxvt_selection_make (): selection.op=%d, selection.clicks=%d", selection.op, selection.clicks)); |
|
|
2776 | switch (selection.op) |
2960 | switch (selection.op) |
2777 | { |
2961 | { |
2778 | case SELECTION_CONT: |
2962 | case SELECTION_CONT: |
2779 | break; |
2963 | break; |
2780 | case SELECTION_INIT: |
2964 | case SELECTION_INIT: |
… | |
… | |
2794 | |
2978 | |
2795 | i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1); |
2979 | i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1); |
2796 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2980 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2797 | |
2981 | |
2798 | col = selection.beg.col; |
2982 | col = selection.beg.col; |
2799 | MAX_IT (col, 0); |
|
|
2800 | row = selection.beg.row + TermWin.saveLines; |
2983 | row = selection.beg.row + TermWin.saveLines; |
2801 | end_row = selection.end.row + TermWin.saveLines; |
2984 | end_row = selection.end.row + TermWin.saveLines; |
2802 | int ofs = 0; |
2985 | int ofs = 0; |
2803 | int extra = 0; |
2986 | int extra = 0; |
2804 | |
2987 | |
2805 | for (; row <= end_row; row++, col = 0) |
2988 | for (; row <= end_row; row++, col = 0) |
2806 | { |
2989 | { |
2807 | t = &(screen.text[row][col]); |
|
|
2808 | |
|
|
2809 | end_col = screen.tlen[row]; |
2990 | end_col = screen.tlen[row]; |
|
|
2991 | |
|
|
2992 | #if ENABLE_FRILLS |
|
|
2993 | if (selection.rect) |
|
|
2994 | { |
|
|
2995 | col = selection.beg.col; |
|
|
2996 | end_col = TermWin.ncol + 1; |
|
|
2997 | } |
|
|
2998 | #endif |
|
|
2999 | |
|
|
3000 | MAX_IT (col, 0); |
2810 | |
3001 | |
2811 | if (end_col == -1) |
3002 | if (end_col == -1) |
2812 | end_col = TermWin.ncol; |
3003 | end_col = TermWin.ncol; |
2813 | |
3004 | |
2814 | if (row == end_row) |
3005 | if (row == end_row || selection.rect) |
2815 | MIN_IT (end_col, selection.end.col); |
3006 | MIN_IT (end_col, selection.end.col); |
2816 | |
3007 | |
|
|
3008 | t = &screen.text[row][col]; |
2817 | for (; col < end_col; col++) |
3009 | for (; col < end_col; col++) |
2818 | { |
3010 | { |
2819 | if (*t == NOCHAR) |
3011 | if (*t == NOCHAR) |
2820 | t++; |
3012 | t++; |
2821 | #if ENABLE_COMBINING |
3013 | #if ENABLE_COMBINING |
… | |
… | |
2869 | #if 0 |
3061 | #if 0 |
2870 | XTextProperty ct; |
3062 | XTextProperty ct; |
2871 | |
3063 | |
2872 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3064 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
2873 | { |
3065 | { |
2874 | XChangeProperty (display->display, display->root, XA_CUT_BUFFER0, XA_STRING, 8, |
3066 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
2875 | PropModeReplace, ct.value, ct.nitems); |
|
|
2876 | XFree (ct.value); |
3067 | XFree (ct.value); |
2877 | } |
3068 | } |
2878 | #endif |
3069 | #endif |
2879 | |
3070 | |
2880 | selection_time = tm; |
3071 | selection_time = tm; |
2881 | D_SELECT ((stderr, "rxvt_selection_make (): selection.len=%d", selection.len)); |
|
|
2882 | } |
3072 | } |
2883 | |
3073 | |
2884 | /* ------------------------------------------------------------------------- */ |
3074 | /* ------------------------------------------------------------------------- */ |
2885 | /* |
3075 | /* |
2886 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3076 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
2887 | * EXT: button 1 press |
3077 | * EXT: button 1 press |
2888 | */ |
3078 | */ |
2889 | void |
3079 | void |
2890 | rxvt_term::selection_click (int clicks, int x, int y) |
3080 | rxvt_term::selection_click (int clicks, int x, int y) |
2891 | { |
3081 | { |
2892 | D_SELECT ((stderr, "rxvt_selection_click (%d, %d, %d)", clicks, x, y)); |
|
|
2893 | |
|
|
2894 | clicks = ((clicks - 1) % 3) + 1; |
3082 | clicks = ((clicks - 1) % 3) + 1; |
2895 | selection.clicks = clicks; /* save clicks so extend will work */ |
3083 | selection.clicks = clicks; /* save clicks so extend will work */ |
2896 | |
3084 | |
2897 | selection_start_colrow (Pixel2Col (x), Pixel2Row (y)); |
3085 | selection_start_colrow (Pixel2Col (x), Pixel2Row (y)); |
2898 | |
3086 | |
… | |
… | |
2940 | * We now only find out the boundary in one direction |
3128 | * We now only find out the boundary in one direction |
2941 | */ |
3129 | */ |
2942 | |
3130 | |
2943 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
3131 | /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ |
2944 | #define DELIMIT_TEXT(x) \ |
3132 | #define DELIMIT_TEXT(x) \ |
2945 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!STRCHR (rs[Rs_cutchars], (x))) |
3133 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) |
2946 | #define DELIMIT_REND(x) 1 |
3134 | #define DELIMIT_REND(x) 1 |
2947 | |
3135 | |
2948 | void |
3136 | void |
2949 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
3137 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
2950 | { |
3138 | { |
… | |
… | |
2968 | |
3156 | |
2969 | row = mark->row + TermWin.saveLines; |
3157 | row = mark->row + TermWin.saveLines; |
2970 | col = mark->col; |
3158 | col = mark->col; |
2971 | MAX_IT (col, 0); |
3159 | MAX_IT (col, 0); |
2972 | /* find the edge of a word */ |
3160 | /* find the edge of a word */ |
2973 | stp = & (screen.text[row][col]); |
3161 | stp = &screen.text[row][col]; |
2974 | w1 = DELIMIT_TEXT (*stp); |
3162 | w1 = DELIMIT_TEXT (*stp); |
2975 | |
3163 | |
2976 | srp = (&screen.rend[row][col]); |
3164 | srp = &screen.rend[row][col]; |
2977 | w2 = DELIMIT_REND (*srp); |
3165 | w2 = DELIMIT_REND (*srp); |
2978 | |
3166 | |
2979 | for (;;) |
3167 | for (;;) |
2980 | { |
3168 | { |
2981 | for (; col != bound.col; col += dirnadd) |
3169 | for (; col != bound.col; col += dirnadd) |
… | |
… | |
3015 | } |
3203 | } |
3016 | break; |
3204 | break; |
3017 | } |
3205 | } |
3018 | |
3206 | |
3019 | Old_Word_Selection_You_Die: |
3207 | Old_Word_Selection_You_Die: |
3020 | D_SELECT ((stderr, "rxvt_selection_delimit_word (%s,...) @ (r:%3d, c:%3d) has boundary (r:%3d, c:%3d)", (dirn == UP ? "up " : "down"), mark->row, mark->col, row - TermWin.saveLines, col)); |
|
|
3021 | |
|
|
3022 | if (dirn == DN) |
3208 | if (dirn == DN) |
3023 | col++; /* put us on one past the end */ |
3209 | col++; /* put us on one past the end */ |
3024 | |
3210 | |
3025 | /* Poke the values back in */ |
3211 | /* Poke the values back in */ |
3026 | ret->row = row - TermWin.saveLines; |
3212 | ret->row = row - TermWin.saveLines; |
… | |
… | |
3060 | /* select nothing */ |
3246 | /* select nothing */ |
3061 | selection.beg.row = selection.end.row = 0; |
3247 | selection.beg.row = selection.end.row = 0; |
3062 | selection.beg.col = selection.end.col = 0; |
3248 | selection.beg.col = selection.end.col = 0; |
3063 | selection.clicks = 4; |
3249 | selection.clicks = 4; |
3064 | want_refresh = 1; |
3250 | want_refresh = 1; |
3065 | D_SELECT ((stderr, "rxvt_selection_extend () selection.clicks = 4")); |
|
|
3066 | return; |
3251 | return; |
3067 | } |
3252 | } |
3068 | |
3253 | |
3069 | if (selection.clicks == 4) |
3254 | if (selection.clicks == 4) |
3070 | selection.clicks = 1; |
3255 | selection.clicks = 1; |
… | |
… | |
3086 | row_col_t pos; |
3271 | row_col_t pos; |
3087 | enum { |
3272 | enum { |
3088 | LEFT, RIGHT |
3273 | LEFT, RIGHT |
3089 | } closeto = RIGHT; |
3274 | } closeto = RIGHT; |
3090 | |
3275 | |
3091 | D_SELECT ((stderr, "rxvt_selection_extend_colrow (c:%d, r:%d, %d, %d) clicks:%d, op:%d", col, row, button3, buttonpress, selection.clicks, selection.op)); |
|
|
3092 | D_SELECT ((stderr, "rxvt_selection_extend_colrow () ENT b: (r:%d,c:%d) m: (r:%d,c:%d), e: (r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); |
|
|
3093 | |
|
|
3094 | want_refresh = 1; |
3276 | want_refresh = 1; |
|
|
3277 | |
3095 | switch (selection.op) |
3278 | switch (selection.op) |
3096 | { |
3279 | { |
3097 | case SELECTION_INIT: |
3280 | case SELECTION_INIT: |
3098 | CLEAR_SELECTION (); |
3281 | CLEAR_SELECTION (); |
3099 | selection.op = SELECTION_BEGIN; |
3282 | selection.op = SELECTION_BEGIN; |
… | |
… | |
3112 | selection_start_colrow (col, row); |
3295 | selection_start_colrow (col, row); |
3113 | /* FALLTHROUGH */ |
3296 | /* FALLTHROUGH */ |
3114 | default: |
3297 | default: |
3115 | return; |
3298 | return; |
3116 | } |
3299 | } |
|
|
3300 | |
3117 | if (selection.beg.col == selection.end.col |
3301 | if (selection.beg.col == selection.end.col |
3118 | && selection.beg.col != selection.mark.col |
3302 | && selection.beg.col != selection.mark.col |
3119 | && selection.beg.row == selection.end.row |
3303 | && selection.beg.row == selection.end.row |
3120 | && selection.beg.row != selection.mark.row) |
3304 | && selection.beg.row != selection.mark.row) |
3121 | { |
3305 | { |
3122 | selection.beg.col = selection.end.col = selection.mark.col; |
3306 | selection.beg.col = selection.end.col = selection.mark.col; |
3123 | selection.beg.row = selection.end.row = selection.mark.row; |
3307 | selection.beg.row = selection.end.row = selection.mark.row; |
3124 | D_SELECT ((stderr, "rxvt_selection_extend_colrow () ENT2 b: (r:%d,c:%d) m: (r:%d,c:%d), e: (r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); |
|
|
3125 | } |
3308 | } |
3126 | |
3309 | |
3127 | pos.col = col; |
3310 | pos.col = col; |
3128 | pos.row = row; |
3311 | pos.row = row; |
3129 | |
3312 | |
… | |
… | |
3172 | } |
3355 | } |
3173 | else |
3356 | else |
3174 | { /* button1 drag or button3 drag */ |
3357 | { /* button1 drag or button3 drag */ |
3175 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3358 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3176 | { |
3359 | { |
3177 | if ((selection.mark.row == selection.end.row) |
3360 | if (selection.mark.row == selection.end.row |
3178 | && (selection.mark.col == selection.end.col) |
3361 | && selection.mark.col == selection.end.col |
|
|
3362 | && clickchange |
3179 | && clickchange && selection.clicks == 2) |
3363 | && selection.clicks == 2) |
3180 | selection.mark.col--; |
3364 | selection.mark.col--; |
3181 | |
3365 | |
3182 | selection.beg.row = pos.row; |
3366 | selection.beg.row = pos.row; |
3183 | selection.beg.col = pos.col; |
3367 | selection.beg.col = pos.col; |
3184 | selection.end.row = selection.mark.row; |
3368 | selection.end.row = selection.mark.row; |
… | |
… | |
3195 | |
3379 | |
3196 | if (selection.clicks == 1) |
3380 | if (selection.clicks == 1) |
3197 | { |
3381 | { |
3198 | end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; |
3382 | end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; |
3199 | |
3383 | |
3200 | if (end_col != -1 && selection.beg.col > end_col) |
3384 | if (selection.beg.col > end_col |
|
|
3385 | && end_col != -1 |
|
|
3386 | #if ENABLE_FRILLS |
|
|
3387 | && !selection.rect |
|
|
3388 | #endif |
3201 | { |
3389 | ) |
3202 | #if 1 |
|
|
3203 | selection.beg.col = ncol; |
3390 | selection.beg.col = ncol; |
3204 | #else |
|
|
3205 | if (selection.beg.row != selection.end.row) |
|
|
3206 | selection.beg.col = ncol; |
|
|
3207 | else |
|
|
3208 | selection.beg.col = selection.mark.col; |
|
|
3209 | #endif |
|
|
3210 | } |
|
|
3211 | |
3391 | |
3212 | end_col = screen.tlen[selection.end.row + TermWin.saveLines]; |
3392 | end_col = screen.tlen[selection.end.row + TermWin.saveLines]; |
3213 | |
3393 | |
3214 | if (end_col != -1 && selection.end.col > end_col) |
3394 | if ( |
|
|
3395 | selection.end.col > end_col |
|
|
3396 | && end_col != -1 |
|
|
3397 | #if ENABLE_FRILLS |
|
|
3398 | && !selection.rect |
|
|
3399 | #endif |
|
|
3400 | ) |
3215 | selection.end.col = ncol; |
3401 | selection.end.col = ncol; |
3216 | } |
3402 | } |
3217 | else if (selection.clicks == 2) |
3403 | else if (selection.clicks == 2) |
3218 | { |
3404 | { |
3219 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3405 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3220 | selection.end.col--; |
3406 | selection.end.col--; |
3221 | |
3407 | |
3222 | selection_delimit_word (UP, & (selection.beg), & (selection.beg)); |
|
|
3223 | selection_delimit_word (DN, & (selection.end), & (selection.end)); |
3408 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
|
|
3409 | selection_delimit_word (DN, &selection.end, &selection.end); |
3224 | } |
3410 | } |
3225 | else if (selection.clicks == 3) |
3411 | else if (selection.clicks == 3) |
3226 | { |
3412 | { |
3227 | #ifndef NO_FRILLS |
3413 | #if ENABLE_FRILLS |
3228 | if ((Options & Opt_tripleclickwords)) |
3414 | if (options & Opt_tripleclickwords) |
3229 | { |
3415 | { |
3230 | int end_row; |
3416 | int end_row; |
3231 | |
3417 | |
3232 | selection_delimit_word (UP, & (selection.beg), & (selection.beg)); |
3418 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3233 | end_row = screen.tlen[selection.mark.row + TermWin.saveLines]; |
3419 | end_row = screen.tlen[selection.mark.row + TermWin.saveLines]; |
3234 | |
3420 | |
3235 | for (end_row = selection.mark.row; end_row < TermWin.nrow; end_row++) |
3421 | for (end_row = selection.mark.row; end_row < TermWin.nrow; end_row++) |
3236 | { |
3422 | { |
3237 | end_col = screen.tlen[end_row + TermWin.saveLines]; |
3423 | end_col = screen.tlen[end_row + TermWin.saveLines]; |
… | |
… | |
3248 | else |
3434 | else |
3249 | #endif |
3435 | #endif |
3250 | { |
3436 | { |
3251 | if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) |
3437 | if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) |
3252 | selection.mark.col++; |
3438 | selection.mark.col++; |
|
|
3439 | |
3253 | selection.beg.col = 0; |
3440 | selection.beg.col = 0; |
3254 | selection.end.col = ncol; |
3441 | selection.end.col = ncol; |
|
|
3442 | |
|
|
3443 | // select a complete logical line |
|
|
3444 | while (selection.beg.row > -TermWin.saveLines |
|
|
3445 | && screen.tlen[selection.beg.row - 1 + TermWin.saveLines] == -1) |
|
|
3446 | selection.beg.row--; |
|
|
3447 | |
|
|
3448 | while (selection.end.row < TermWin.nrow |
|
|
3449 | && screen.tlen[selection.end.row + TermWin.saveLines] == -1) |
|
|
3450 | selection.end.row++; |
3255 | } |
3451 | } |
3256 | } |
3452 | } |
3257 | |
3453 | |
3258 | if (button3 && buttonpress) |
3454 | if (button3 && buttonpress) |
3259 | { /* mark may need to be changed */ |
3455 | { /* mark may need to be changed */ |
3260 | if (closeto == LEFT) |
3456 | if (closeto == LEFT) |
3261 | { |
3457 | { |
3262 | selection.mark.row = selection.end.row; |
3458 | selection.mark.row = selection.end.row; |
3263 | selection.mark.col = selection.end.col |
3459 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3264 | - (selection.clicks == 2); |
|
|
3265 | } |
3460 | } |
3266 | else |
3461 | else |
3267 | { |
3462 | { |
3268 | selection.mark.row = selection.beg.row; |
3463 | selection.mark.row = selection.beg.row; |
3269 | selection.mark.col = selection.beg.col; |
3464 | selection.mark.col = selection.beg.col; |
3270 | } |
3465 | } |
3271 | } |
3466 | } |
3272 | D_SELECT ((stderr, "rxvt_selection_extend_colrow () EXIT b: (r:%d,c:%d) m: (r:%d,c:%d), e: (r:%d,c:%d)", selection.beg.row, selection.beg.col, selection.mark.row, selection.mark.col, selection.end.row, selection.end.col)); |
|
|
3273 | } |
|
|
3274 | |
3467 | |
3275 | #ifndef NO_FRILLS |
3468 | #if ENABLE_FRILLS |
|
|
3469 | if (selection.rect && selection.beg.col > selection.end.col) |
|
|
3470 | SWAP_IT (selection.beg.col, selection.end.col, int); |
|
|
3471 | #endif |
|
|
3472 | } |
|
|
3473 | |
|
|
3474 | #if ENABLE_FRILLS |
3276 | void |
3475 | void |
3277 | rxvt_term::selection_remove_trailing_spaces () |
3476 | rxvt_term::selection_remove_trailing_spaces () |
3278 | { |
3477 | { |
3279 | int32_t end_col, end_row; |
3478 | int32_t end_col, end_row; |
3280 | text_t *stp; |
3479 | text_t *stp; |
3281 | |
3480 | |
3282 | end_col = selection.end.col; |
3481 | end_col = selection.end.col; |
3283 | end_row = selection.end.row; |
3482 | end_row = selection.end.row; |
|
|
3483 | |
3284 | for ( ; end_row >= selection.beg.row; ) |
3484 | for ( ; end_row >= selection.beg.row; ) |
3285 | { |
3485 | { |
3286 | stp = screen.text[end_row + TermWin.saveLines]; |
3486 | stp = screen.text[end_row + TermWin.saveLines]; |
|
|
3487 | |
3287 | while (--end_col >= 0) |
3488 | while (--end_col >= 0) |
3288 | { |
3489 | { |
3289 | if (stp[end_col] != ' ' && stp[end_col] != '\t') |
3490 | if (stp[end_col] != ' ' |
|
|
3491 | && stp[end_col] != '\t' |
|
|
3492 | && stp[end_col] != NOCHAR) |
3290 | break; |
3493 | break; |
3291 | } |
3494 | } |
|
|
3495 | |
3292 | if (end_col >= 0 |
3496 | if (end_col >= 0 |
3293 | || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) |
3497 | || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) |
3294 | { |
3498 | { |
3295 | selection.end.col = end_col + 1; |
3499 | selection.end.col = end_col + 1; |
3296 | selection.end.row = end_row; |
3500 | selection.end.row = end_row; |
3297 | break; |
3501 | break; |
3298 | } |
3502 | } |
|
|
3503 | |
3299 | end_row--; |
3504 | end_row--; |
3300 | end_col = TermWin.ncol; |
3505 | end_col = TermWin.ncol; |
3301 | } |
3506 | } |
|
|
3507 | |
3302 | if (selection.mark.row > selection.end.row) |
3508 | if (selection.mark.row > selection.end.row) |
3303 | { |
3509 | { |
3304 | selection.mark.row = selection.end.row; |
3510 | selection.mark.row = selection.end.row; |
3305 | selection.mark.col = selection.end.col; |
3511 | selection.mark.col = selection.end.col; |
3306 | } |
3512 | } |
… | |
… | |
3322 | selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); |
3528 | selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); |
3323 | } |
3529 | } |
3324 | |
3530 | |
3325 | /* ------------------------------------------------------------------------- */ |
3531 | /* ------------------------------------------------------------------------- */ |
3326 | /* |
3532 | /* |
3327 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
|
|
3328 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
|
|
3329 | * the X11 protocol. |
|
|
3330 | */ |
|
|
3331 | typedef CARD32 Atom32; |
|
|
3332 | |
|
|
3333 | /* ------------------------------------------------------------------------- */ |
|
|
3334 | /* |
|
|
3335 | * Respond to a request for our current selection |
3533 | * Respond to a request for our current selection |
3336 | * EXT: SelectionRequest |
3534 | * EXT: SelectionRequest |
3337 | */ |
3535 | */ |
3338 | void |
3536 | void |
3339 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) |
3537 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) |
3340 | { |
3538 | { |
3341 | XSelectionEvent ev; |
3539 | XSelectionEvent ev; |
3342 | XTextProperty ct; |
3540 | dDisp; |
3343 | XICCEncodingStyle style; |
|
|
3344 | Atom target; |
|
|
3345 | |
3541 | |
3346 | ev.type = SelectionNotify; |
3542 | ev.type = SelectionNotify; |
3347 | ev.property = None; |
3543 | ev.property = None; |
3348 | ev.display = rq.display; |
3544 | ev.display = rq.display; |
3349 | ev.requestor = rq.requestor; |
3545 | ev.requestor = rq.requestor; |
… | |
… | |
3351 | ev.target = rq.target; |
3547 | ev.target = rq.target; |
3352 | ev.time = rq.time; |
3548 | ev.time = rq.time; |
3353 | |
3549 | |
3354 | if (rq.target == xa[XA_TARGETS]) |
3550 | if (rq.target == xa[XA_TARGETS]) |
3355 | { |
3551 | { |
3356 | Atom32 target_list[6]; |
3552 | Atom target_list[6]; |
3357 | Atom32 *target = target_list; |
3553 | Atom *target = target_list; |
3358 | |
3554 | |
3359 | *target++ = (Atom32) xa[XA_TARGETS]; |
3555 | *target++ = xa[XA_TARGETS]; |
3360 | *target++ = (Atom32) xa[XA_TIMESTAMP]; |
3556 | *target++ = xa[XA_TIMESTAMP]; |
3361 | *target++ = (Atom32) XA_STRING; |
3557 | *target++ = XA_STRING; |
3362 | *target++ = (Atom32) xa[XA_TEXT]; |
3558 | *target++ = xa[XA_TEXT]; |
3363 | *target++ = (Atom32) xa[XA_COMPOUND_TEXT]; |
3559 | *target++ = xa[XA_COMPOUND_TEXT]; |
3364 | #if X_HAVE_UTF8_STRING |
3560 | #if X_HAVE_UTF8_STRING |
3365 | *target++ = (Atom32) xa[XA_UTF8_STRING]; |
3561 | *target++ = xa[XA_UTF8_STRING]; |
3366 | #endif |
3562 | #endif |
3367 | |
3563 | |
3368 | XChangeProperty (display->display, rq.requestor, rq.property, XA_ATOM, |
3564 | XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, |
3369 | (8 * sizeof (target_list[0])), PropModeReplace, |
3565 | 32, PropModeReplace, |
3370 | (unsigned char *)target_list, |
3566 | (unsigned char *)target_list, target - target_list); |
3371 | target - target_list); |
|
|
3372 | ev.property = rq.property; |
3567 | ev.property = rq.property; |
3373 | } |
3568 | } |
3374 | #if TODO // TODO |
3569 | #if TODO // TODO |
3375 | else if (rq.target == xa[XA_MULTIPLE]) |
3570 | else if (rq.target == xa[XA_MULTIPLE]) |
3376 | { |
3571 | { |
3377 | /* TODO: Handle MULTIPLE */ |
3572 | /* TODO: Handle MULTIPLE */ |
3378 | } |
3573 | } |
3379 | #endif |
3574 | #endif |
3380 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3575 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3381 | { |
3576 | { |
3382 | XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, |
3577 | XChangeProperty (disp, rq.requestor, rq.property, rq.target, |
3383 | (8 * sizeof (Time)), PropModeReplace, |
|
|
3384 | (unsigned char *)&selection_time, 1); |
3578 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3385 | ev.property = rq.property; |
3579 | ev.property = rq.property; |
3386 | } |
3580 | } |
3387 | else if (rq.target == XA_STRING |
3581 | else if (rq.target == XA_STRING |
3388 | || rq.target == xa[XA_TEXT] |
3582 | || rq.target == xa[XA_TEXT] |
3389 | || rq.target == xa[XA_COMPOUND_TEXT] |
3583 | || rq.target == xa[XA_COMPOUND_TEXT] |
3390 | || rq.target == xa[XA_UTF8_STRING] |
3584 | || rq.target == xa[XA_UTF8_STRING] |
3391 | ) |
3585 | ) |
3392 | { |
3586 | { |
|
|
3587 | XTextProperty ct; |
|
|
3588 | Atom target = rq.target; |
3393 | short freect = 0; |
3589 | short freect = 0; |
3394 | int selectlen; |
3590 | int selectlen; |
3395 | wchar_t *cl; |
3591 | wchar_t *cl; |
3396 | |
3592 | enum { |
3397 | target = rq.target; |
3593 | enc_string = XStringStyle, |
|
|
3594 | enc_text = XStdICCTextStyle, |
|
|
3595 | enc_compound_text = XCompoundTextStyle, |
|
|
3596 | #ifdef X_HAVE_UTF8_STRING |
|
|
3597 | enc_utf8 = XUTF8StringStyle, |
|
|
3598 | #else |
|
|
3599 | enc_utf8 = -1, |
|
|
3600 | #endif |
|
|
3601 | } style; |
3398 | |
3602 | |
3399 | if (target == XA_STRING) |
3603 | if (target == XA_STRING) |
3400 | // we actually don't do XA_STRING, but who cares, as i18n clients |
3604 | // we actually don't do XA_STRING, but who cares, as i18n clients |
3401 | // will ask for another format anyways. |
3605 | // will ask for another format anyways. |
3402 | style = XStringStyle; |
3606 | style = enc_string; |
3403 | else if (target == xa[XA_TEXT]) |
3607 | else if (target == xa[XA_TEXT]) |
3404 | style = XStdICCTextStyle; |
3608 | style = enc_text; |
3405 | else if (target == xa[XA_COMPOUND_TEXT]) |
3609 | else if (target == xa[XA_COMPOUND_TEXT]) |
3406 | style = XCompoundTextStyle; |
3610 | style = enc_compound_text; |
3407 | #if X_HAVE_UTF8_STRING |
3611 | #if ENABLE_FRILLS |
3408 | else if (target == xa[XA_UTF8_STRING]) |
3612 | else if (target == xa[XA_UTF8_STRING]) |
3409 | style = XUTF8StringStyle; |
3613 | style = enc_utf8; |
3410 | #endif |
3614 | #endif |
3411 | else |
3615 | else |
3412 | { |
3616 | { |
3413 | target = xa[XA_COMPOUND_TEXT]; |
3617 | target = xa[XA_COMPOUND_TEXT]; |
3414 | style = XCompoundTextStyle; |
3618 | style = enc_compound_text; |
3415 | } |
3619 | } |
3416 | |
3620 | |
3417 | if (selection.text) |
3621 | if (selection.text) |
3418 | { |
3622 | { |
3419 | cl = selection.text; |
3623 | cl = selection.text; |
… | |
… | |
3423 | { |
3627 | { |
3424 | cl = L""; |
3628 | cl = L""; |
3425 | selectlen = 0; |
3629 | selectlen = 0; |
3426 | } |
3630 | } |
3427 | |
3631 | |
3428 | // Xwc doesn't handle iso-10646 in wchar_t gracefully, so maybe recode it |
3632 | #if ENABLE_FRILLS |
3429 | // manually for XUTF8StringStyle. |
3633 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
|
|
3634 | // so recode it manually |
|
|
3635 | if (style == enc_utf8) |
|
|
3636 | { |
|
|
3637 | freect = 1; |
|
|
3638 | ct.encoding = target; |
|
|
3639 | ct.format = 8; |
|
|
3640 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
|
|
3641 | ct.nitems = strlen ((char *)ct.value); |
|
|
3642 | } |
|
|
3643 | else |
|
|
3644 | #endif |
3430 | if (XwcTextListToTextProperty (display->display, &cl, 1, style, &ct) >= 0) |
3645 | if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3431 | freect = 1; |
3646 | freect = 1; |
3432 | else |
3647 | else |
3433 | { |
3648 | { |
3434 | /* if we failed to convert then send it raw */ |
3649 | /* if we failed to convert then send it raw */ |
3435 | ct.value = (unsigned char *)cl; |
3650 | ct.value = (unsigned char *)cl; |
3436 | ct.nitems = selectlen; |
3651 | ct.nitems = selectlen; |
|
|
3652 | ct.encoding = target; |
3437 | } |
3653 | } |
3438 | |
3654 | |
3439 | XChangeProperty (display->display, rq.requestor, rq.property, |
3655 | XChangeProperty (disp, rq.requestor, rq.property, |
3440 | target, 8, PropModeReplace, |
3656 | ct.encoding, 8, PropModeReplace, |
3441 | ct.value, (int)ct.nitems); |
3657 | ct.value, (int)ct.nitems); |
3442 | ev.property = rq.property; |
3658 | ev.property = rq.property; |
3443 | |
3659 | |
3444 | if (freect) |
3660 | if (freect) |
3445 | XFree (ct.value); |
3661 | XFree (ct.value); |
3446 | } |
3662 | } |
3447 | |
3663 | |
3448 | XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev); |
3664 | XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); |
3449 | } |
3665 | } |
3450 | |
3666 | |
3451 | /* ------------------------------------------------------------------------- * |
3667 | /* ------------------------------------------------------------------------- * |
3452 | * MOUSE ROUTINES * |
3668 | * MOUSE ROUTINES * |
3453 | * ------------------------------------------------------------------------- */ |
3669 | * ------------------------------------------------------------------------- */ |
… | |
… | |
3465 | } |
3681 | } |
3466 | |
3682 | |
3467 | /* ------------------------------------------------------------------------- */ |
3683 | /* ------------------------------------------------------------------------- */ |
3468 | #ifdef USE_XIM |
3684 | #ifdef USE_XIM |
3469 | void |
3685 | void |
3470 | rxvt_term::im_set_position (XPoint *pos) |
3686 | rxvt_term::im_set_position (XPoint &pos) |
3471 | { |
3687 | { |
3472 | XWindowAttributes xwa; |
3688 | XWindowAttributes xwa; |
3473 | |
3689 | |
3474 | XGetWindowAttributes (display->display, TermWin.vt, &xwa); |
3690 | XGetWindowAttributes (display->display, TermWin.vt, &xwa); |
|
|
3691 | |
3475 | pos->x = Col2Pixel (screen.cur.col) + xwa.x; |
3692 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3476 | pos->y = Height2Pixel ((screen.cur.row + 1)) + xwa.y - TermWin.lineSpace; |
3693 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + TermWin.fbase; |
3477 | } |
3694 | } |
3478 | |
|
|
3479 | #endif |
3695 | #endif |
|
|
3696 | |
|
|
3697 | #if ENABLE_OVERLAY |
|
|
3698 | void |
|
|
3699 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
|
|
3700 | { |
|
|
3701 | if (TermWin.nrow < 3 || TermWin.ncol < 3) |
|
|
3702 | return; |
|
|
3703 | |
|
|
3704 | want_refresh = 1; |
|
|
3705 | |
|
|
3706 | scr_overlay_off (); |
|
|
3707 | |
|
|
3708 | if (x < 0) x = TermWin.ncol - w; |
|
|
3709 | if (y < 0) y = TermWin.nrow - h; |
|
|
3710 | |
|
|
3711 | // make space for border |
|
|
3712 | w += 2; MIN_IT (w, TermWin.ncol); |
|
|
3713 | h += 2; MIN_IT (h, TermWin.nrow); |
|
|
3714 | |
|
|
3715 | x -= 1; MAX_IT (x, 0); |
|
|
3716 | y -= 1; MAX_IT (y, 0); |
|
|
3717 | |
|
|
3718 | MIN_IT (x, TermWin.ncol - w); |
|
|
3719 | MIN_IT (y, TermWin.nrow - h); |
|
|
3720 | |
|
|
3721 | ov_x = x; ov_y = y; |
|
|
3722 | ov_w = w; ov_h = h; |
|
|
3723 | |
|
|
3724 | ov_text = new text_t *[h]; |
|
|
3725 | ov_rend = new rend_t *[h]; |
|
|
3726 | |
|
|
3727 | for (y = 0; y < h; y++) |
|
|
3728 | { |
|
|
3729 | text_t *tp = ov_text[y] = new text_t[w]; |
|
|
3730 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
|
|
3731 | |
|
|
3732 | text_t t0, t1, t2; |
|
|
3733 | rend_t r = OVERLAY_RSTYLE; |
|
|
3734 | |
|
|
3735 | if (y == 0) |
|
|
3736 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
|
|
3737 | else if (y < h - 1) |
|
|
3738 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
|
|
3739 | else |
|
|
3740 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
|
|
3741 | |
|
|
3742 | *tp++ = t0; |
|
|
3743 | *rp++ = r; |
|
|
3744 | |
|
|
3745 | for (x = w - 2; x > 0; --x) |
|
|
3746 | { |
|
|
3747 | *tp++ = t1; |
|
|
3748 | *rp++ = r; |
|
|
3749 | } |
|
|
3750 | |
|
|
3751 | *tp = t2; |
|
|
3752 | *rp = r; |
|
|
3753 | } |
|
|
3754 | } |
|
|
3755 | |
|
|
3756 | void |
|
|
3757 | rxvt_term::scr_overlay_off () |
|
|
3758 | { |
|
|
3759 | if (!ov_text) |
|
|
3760 | return; |
|
|
3761 | |
|
|
3762 | want_refresh = 1; |
|
|
3763 | |
|
|
3764 | for (int y = 0; y < ov_h; y++) |
|
|
3765 | { |
|
|
3766 | delete [] ov_text[y]; |
|
|
3767 | delete [] ov_rend[y]; |
|
|
3768 | } |
|
|
3769 | |
|
|
3770 | delete [] ov_text; ov_text = 0; |
|
|
3771 | delete [] ov_rend; ov_rend = 0; |
|
|
3772 | } |
|
|
3773 | |
|
|
3774 | void |
|
|
3775 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
|
|
3776 | { |
|
|
3777 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
|
|
3778 | return; |
|
|
3779 | |
|
|
3780 | x++, y++; |
|
|
3781 | |
|
|
3782 | ov_text[y][x] = text; |
|
|
3783 | ov_rend[y][x] = rend; |
|
|
3784 | } |
|
|
3785 | |
|
|
3786 | void |
|
|
3787 | rxvt_term::scr_overlay_set (int x, int y, const char *s) |
|
|
3788 | { |
|
|
3789 | while (*s) |
|
|
3790 | scr_overlay_set (x++, y, *s++); |
|
|
3791 | } |
|
|
3792 | |
|
|
3793 | void |
|
|
3794 | rxvt_term::scr_swap_overlay () |
|
|
3795 | { |
|
|
3796 | if (!ov_text) |
|
|
3797 | return; |
|
|
3798 | |
|
|
3799 | int row_offset = ov_y + TermWin.saveLines - TermWin.view_start; |
|
|
3800 | |
|
|
3801 | // swap screen mem with overlay |
|
|
3802 | for (int y = ov_h; y--; ) |
|
|
3803 | { |
|
|
3804 | text_t *t1 = ov_text[y]; |
|
|
3805 | rend_t *r1 = ov_rend[y]; |
|
|
3806 | |
|
|
3807 | text_t *t2 = screen.text[y + row_offset] + ov_x; |
|
|
3808 | rend_t *r2 = screen.rend[y + row_offset] + ov_x; |
|
|
3809 | |
|
|
3810 | for (int x = ov_w; x--; ) |
|
|
3811 | { |
|
|
3812 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
|
|
3813 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
|
|
3814 | } |
|
|
3815 | } |
|
|
3816 | } |
|
|
3817 | |
|
|
3818 | #endif |
3480 | /* ------------------------------------------------------------------------- */ |
3819 | /* ------------------------------------------------------------------------- */ |