ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.198 by root, Tue Dec 27 01:25:42 2005 UTC vs.
Revision 1.215 by root, Sun Jan 8 06:35:23 2006 UTC

1/*--------------------------------*-C-*--------------------------------------* 1/*--------------------------------*-C-*--------------------------------------*
2 * File: screen.C 2 * File: screen.C
3 *---------------------------------------------------------------------------* 3 *---------------------------------------------------------------------------*
4 * 4 *
5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2006 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
24 * This file handles _all_ screen updates and selections 24 * This file handles _all_ screen updates and selections
25 */ 25 */
26 26
27#include "../config.h" /* NECESSARY */ 27#include "../config.h" /* NECESSARY */
28#include "rxvt.h" /* NECESSARY */ 28#include "rxvt.h" /* NECESSARY */
29#include "rxvtperl.h" /* NECESSARY */
29 30
30#include <X11/Xmd.h> /* get the typedef for CARD32 */ 31#include <X11/Xmd.h> /* get the typedef for CARD32 */
31 32
32#include <inttypes.h> 33#include <inttypes.h>
33 34
46 47
47/* ------------------------------------------------------------------------- * 48/* ------------------------------------------------------------------------- *
48 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * 49 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES *
49 * ------------------------------------------------------------------------- */ 50 * ------------------------------------------------------------------------- */
50#define ZERO_SCROLLBACK() \ 51#define ZERO_SCROLLBACK() \
51 if (options & Opt_scrollTtyOutput) \ 52 if (OPTION (Opt_scrollTtyOutput)) \
52 view_start = 0 53 view_start = 0
53#define CLEAR_SELECTION() \ 54#define CLEAR_SELECTION() \
54 selection.beg.row = selection.beg.col \ 55 selection.beg.row = selection.beg.col \
55 = selection.end.row = selection.end.col = 0 56 = selection.end.row = selection.end.col = 0
56#define CLEAR_ALL_SELECTION() \ 57#define CLEAR_ALL_SELECTION() \
123 lalloc (l); 124 lalloc (l);
124 col = 0; 125 col = 0;
125 width = ncol; 126 width = ncol;
126 } 127 }
127 128
129 l.touch ();
130
128 efs &= ~RS_baseattrMask; 131 efs &= ~RS_baseattrMask;
129 efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); 132 efs = SET_FONT (efs, FONTSET (efs)->find_font (' '));
130 133
131 text_t *et = l.t + col; 134 text_t *et = l.t + col;
132 rend_t *er = l.r + col; 135 rend_t *er = l.r + col;
142/* Fill a full line with blanks - make sure it is allocated first */ 145/* Fill a full line with blanks - make sure it is allocated first */
143void 146void
144rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) 147rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs)
145{ 148{
146 scr_blank_line (l, 0, ncol, efs); 149 scr_blank_line (l, 0, ncol, efs);
150
151 l.l = 0;
152 l.f = 0;
147} 153}
148 154
149/* ------------------------------------------------------------------------- * 155/* ------------------------------------------------------------------------- *
150 * SCREEN INITIALISATION * 156 * SCREEN INITIALISATION *
151 * ------------------------------------------------------------------------- */ 157 * ------------------------------------------------------------------------- */
289 { 295 {
290 p = MOD (p - 1, prev_total_rows); 296 p = MOD (p - 1, prev_total_rows);
291#ifdef DEBUG_STRICT 297#ifdef DEBUG_STRICT
292 assert (old_buf [MOD (p, prev_total_rows)].t); 298 assert (old_buf [MOD (p, prev_total_rows)].t);
293#endif 299#endif
294
295 int plines = 1; 300 int plines = 1;
296 int llen = old_buf [MOD (p, prev_total_rows)].l; 301 int llen = old_buf [MOD (p, prev_total_rows)].l;
297 302
298 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) 303 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
299 { 304 {
317 // re-assemble the full line by destination lines 322 // re-assemble the full line by destination lines
318 for (int qrow = q; qlines--; qrow++) 323 for (int qrow = q; qlines--; qrow++)
319 { 324 {
320 qline = row_buf + qrow; 325 qline = row_buf + qrow;
321 lalloc (*qline); 326 lalloc (*qline);
327 qline->l = ncol;
322 qline->set_is_longer (); 328 qline->is_longer (1);
323 329
324 int qcol = 0; 330 int qcol = 0;
325 331
326 // fill a single destination line 332 // fill a single destination line
327 while (lofs < llen && qcol < ncol) 333 while (lofs < llen && qcol < ncol)
352 qcol += len; 358 qcol += len;
353 } 359 }
354 } 360 }
355 361
356 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; 362 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0;
357#ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY 363 qline->is_longer (0);
358 if (qline->l < 0)
359 {
360 fprintf (stderr, "ERROR, PLEASE REPORT to rxvt-unicode@plan9.de: qline->l %d = llen %d < ncol %d ? %d : MOD %d\n", qline->l,llen,ncol,llen,MOD (llen - 1, ncol) + 1);//D
361 qline->l = 0;
362 }
363#endif
364 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 364 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
365 } 365 }
366 while (p != pend && q > 0); 366 while (p != pend && q > 0);
367 367
368 term_start = total_rows - nrow; 368 term_start = total_rows - nrow;
369 nsaved = term_start - q; 369 nsaved = term_start - q;
370 370
371 // make sure all terminal lines exist 371 // make sure all terminal lines exist
372 while (nsaved < 0) 372 while (nsaved < 0)
373 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); 373 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
374
375 } 374 }
376 else 375 else
377 { 376 {
378 // if no scrollback exists (yet), wing, instead of wrap 377 // if no scrollback exists (yet), wing, instead of wrap
379 378
417 416
418 for (int col = ncol; col--; ) 417 for (int col = ncol; col--; )
419 tabs [col] = col % TABSIZE == 0; 418 tabs [col] = col % TABSIZE == 0;
420 419
421 tt_winch (); 420 tt_winch ();
421
422 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
422} 423}
423 424
424/* ------------------------------------------------------------------------- */ 425/* ------------------------------------------------------------------------- */
425/* 426/*
426 * Free everything. That way malloc debugging can find leakage. 427 * Free everything. That way malloc debugging can find leakage.
530 531
531 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1); 532 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
532 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1); 533 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
533 534
534#if NSCREENS 535#if NSCREENS
535 if (options & Opt_secondaryScreen) 536 if (OPTION (Opt_secondaryScreen))
536 { 537 {
537 num_scr = 0; 538 num_scr = 0;
538 539
539 for (int i = prev_nrow; i--; ) 540 for (int i = prev_nrow; i--; )
540 ::swap (ROW(i), swap_buf [i]); 541 ::swap (ROW(i), swap_buf [i]);
544 screen.flags |= Screen_VisibleCursor; 545 screen.flags |= Screen_VisibleCursor;
545 swap.flags |= Screen_VisibleCursor; 546 swap.flags |= Screen_VisibleCursor;
546 } 547 }
547 else 548 else
548#endif 549#endif
549 if (options & Opt_secondaryScroll) 550 if (OPTION (Opt_secondaryScroll))
550 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 551 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
551 552
552 return scrn; 553 return scrn;
553} 554}
554 555
616 num_scr += count; 617 num_scr += count;
617 618
618 if (count > 0 619 if (count > 0
619 && row1 == 0 620 && row1 == 0
620 && row2 == nrow - 1 621 && row2 == nrow - 1
621 && (current_screen == PRIMARY || options & Opt_secondaryScroll)) 622 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
622 { 623 {
623 nsaved = min (nsaved + count, saveLines); 624 nsaved = min (nsaved + count, saveLines);
625
626 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END));
627
624 term_start = (term_start + count) % total_rows; 628 term_start = (term_start + count) % total_rows;
625 629
626 if (selection.op && current_screen == selection.screen) 630 if (selection.op && current_screen == selection.screen)
627 { 631 {
628 selection.beg.row -= count; 632 selection.beg.row -= count;
637 selection.op = SELECTION_CLEAR; 641 selection.op = SELECTION_CLEAR;
638 } 642 }
639 } 643 }
640 644
641 for (int i = count; i--; ) 645 for (int i = count; i--; )
642 {
643 ROW(row2 - i).l = 0;
644 scr_blank_screen_mem (ROW(row2 - i), rstyle); 646 scr_blank_screen_mem (ROW(row2 - i), rstyle);
645 }
646 647
647 if ((options & Opt_scrollWithBuffer) 648 if (OPTION (Opt_scrollWithBuffer)
648 && view_start != 0 649 && view_start != 0
649 && view_start != saveLines) 650 && view_start != saveLines)
650 scr_page (UP, count); 651 scr_page (UP, count);
651 } 652 }
652 else 653 else
699/* ------------------------------------------------------------------------- */ 700/* ------------------------------------------------------------------------- */
700/* 701/*
701 * Add text given in <str> of length <len> to screen struct 702 * Add text given in <str> of length <len> to screen struct
702 */ 703 */
703void 704void
704rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) 705rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines)
705{ 706{
706 if (len <= 0) /* sanity */ 707 if (len <= 0) /* sanity */
707 return; 708 return;
708 709
709 unsigned char checksel; 710 unsigned char checksel;
710 unicode_t c; 711 unicode_t c;
711 int last_col; 712 int ncol = this->ncol;
712 const unicode_t *strend = str + len; 713 const wchar_t *strend = str + len;
713 714
714 want_refresh = 1; 715 want_refresh = 1;
715 ZERO_SCROLLBACK (); 716 ZERO_SCROLLBACK ();
716 last_col = ncol;
717 717
718 if (nlines > 0) 718 if (minlines > 0)
719 { 719 {
720 nlines += screen.cur.row - screen.bscroll; 720 minlines += screen.cur.row - screen.bscroll;
721
721 if (nlines > 0 722 if (minlines > 0
722 && screen.tscroll == 0 723 && screen.tscroll == 0
723 && screen.bscroll == (nrow - 1)) 724 && screen.bscroll == nrow - 1)
724 { 725 {
725 /* _at least_ this many lines need to be scrolled */ 726 /* _at least_ this many lines need to be scrolled */
726 scr_scroll_text (screen.tscroll, screen.bscroll, nlines); 727 scr_scroll_text (screen.tscroll, screen.bscroll, minlines);
727 screen.cur.row -= nlines; 728 screen.cur.row -= minlines;
728 } 729 }
729 } 730 }
730 731
731#ifdef DEBUG_STRICT 732#ifdef DEBUG_STRICT
732 assert (screen.cur.col < last_col); 733 assert (screen.cur.col < ncol);
733 assert (screen.cur.row < nrow 734 assert (screen.cur.row < nrow
734 && screen.cur.row >= -nsaved); 735 && screen.cur.row >= -nsaved);
735#endif 736#endif
736 int row = screen.cur.row; 737 int row = screen.cur.row;
737 738
739 740
740 line_t *line = &ROW(row); 741 line_t *line = &ROW(row);
741 742
742 while (str < strend) 743 while (str < strend)
743 { 744 {
744 c = *str++; 745 c = (unicode_t)*str++; // convert to rxvt-unicodes representation
745 746
746 if (c < 0x20) 747 if (c < 0x20)
747 if (c == C0_LF) 748 if (c == C0_LF)
748 { 749 {
749 if (!line->is_longer ()) /* XXX: think about this */
750 max_it (line->l, screen.cur.col); 750 max_it (line->l, screen.cur.col);
751 751
752 screen.flags &= ~Screen_WrapNext; 752 screen.flags &= ~Screen_WrapNext;
753 753
754 if (screen.cur.row == screen.bscroll) 754 if (screen.cur.row == screen.bscroll)
755 scr_scroll_text (screen.tscroll, screen.bscroll, 1); 755 scr_scroll_text (screen.tscroll, screen.bscroll, 1);
759 line = &ROW(row); /* _must_ refresh */ 759 line = &ROW(row); /* _must_ refresh */
760 continue; 760 continue;
761 } 761 }
762 else if (c == C0_CR) 762 else if (c == C0_CR)
763 { 763 {
764 if (!line->is_longer ()) /* XXX: think about this */
765 max_it (line->l, screen.cur.col); 764 max_it (line->l, screen.cur.col);
766 765
767 screen.flags &= ~Screen_WrapNext; 766 screen.flags &= ~Screen_WrapNext;
768 screen.cur.col = 0; 767 screen.cur.col = 0;
769 continue; 768 continue;
770 } 769 }
787 CLEAR_SELECTION (); 786 CLEAR_SELECTION ();
788 } 787 }
789 788
790 if (screen.flags & Screen_WrapNext) 789 if (screen.flags & Screen_WrapNext)
791 { 790 {
791 max_it (line->l, ncol);
792 line->set_is_longer (); 792 line->is_longer (1);
793 793
794 scr_do_wrap (); 794 scr_do_wrap ();
795 795
796 row = screen.cur.row; 796 row = screen.cur.row;
797 line = &ROW(row); /* _must_ refresh */ 797 line = &ROW(row); /* _must_ refresh */
805 // do wcwidth before further replacements, as wcwidth might return -1 805 // do wcwidth before further replacements, as wcwidth might return -1
806 // for the line drawing characters below as they might be invalid in the current 806 // for the line drawing characters below as they might be invalid in the current
807 // locale. 807 // locale.
808 int width = c < 0x100 ? 1 : wcwidth (c); 808 int width = c < 0x100 ? 1 : wcwidth (c);
809 809
810 if (charsets[screen.charset] == '0') // DEC SPECIAL 810 if (charsets [screen.charset] == '0') // DEC SPECIAL
811 { 811 {
812 // vt100 special graphics and line drawing 812 // vt100 special graphics and line drawing
813 // 5f-7e standard vt100 813 // 5f-7e standard vt100
814 // 40-5e rxvt extension for extra curses acs chars 814 // 40-5e rxvt extension for extra curses acs chars
815 static uint16_t vt100_0[62] = { // 41 .. 7e 815 static uint16_t vt100_0[62] = { // 41 .. 7e
867 } 867 }
868 868
869 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); 869 rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c));
870 870
871 // if the character doesn't fit into the remaining columns... 871 // if the character doesn't fit into the remaining columns...
872 if (screen.cur.col > last_col - width && last_col >= width) 872 if (screen.cur.col > ncol - width && ncol >= width)
873 { 873 {
874 // ...output spaces 874 // ...output spaces
875 c = ' '; 875 c = ' ';
876 // and try the same character next loop iteration 876 // and try the same character next loop iteration
877 --str; 877 --str;
878 } 878 }
879 879
880 line->touch ();
881
880 do 882 do
881 { 883 {
882 line->t[screen.cur.col] = c; 884 line->t[screen.cur.col] = c;
883 line->r[screen.cur.col] = rend; 885 line->r[screen.cur.col] = rend;
884 886
885 if (screen.cur.col < last_col - 1) 887 if (screen.cur.col < ncol - 1)
886 screen.cur.col++; 888 screen.cur.col++;
887 else 889 else
888 { 890 {
889 line->l = last_col; 891 line->l = ncol;
890 if (screen.flags & Screen_Autowrap) 892 if (screen.flags & Screen_Autowrap)
891 screen.flags |= Screen_WrapNext; 893 screen.flags |= Screen_WrapNext;
892 break; 894 break;
893 } 895 }
894 896
896 } 898 }
897 while (--width > 0); 899 while (--width > 0);
898 900
899 // pad with spaces when overwriting wide character with smaller one 901 // pad with spaces when overwriting wide character with smaller one
900 if (!width) 902 if (!width)
903 {
904 line->touch ();
905
901 for (int c = screen.cur.col; c < last_col && line->t[c] == NOCHAR; c++) 906 for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++)
902 { 907 {
903 line->t[c] = ' '; 908 line->t[c] = ' ';
904 line->r[c] = rend; 909 line->r[c] = rend;
905 } 910 }
911 }
906 } 912 }
907 else // width == 0 913 else // width == 0
908 { 914 {
909#if ENABLE_COMBINING 915#if ENABLE_COMBINING
910 // handle combining characters 916 // handle combining characters
911 // we just tag the accent on the previous on-screen character. 917 // we just tag the accent on the previous on-screen character.
912 // this is arguably not correct, but also arguably not wrong. 918 // this is arguably not correct, but also arguably not wrong.
913 // we don't handle double-width characters nicely yet. 919 // we don't handle double-width characters nicely yet.
920 line_t *linep;
914 text_t *tp; 921 text_t *tp;
915 rend_t *rp; 922 rend_t *rp;
916 923
917 if (screen.cur.col > 0) 924 if (screen.cur.col > 0)
918 { 925 {
926 linep = line;
919 tp = line->t + screen.cur.col - 1; 927 tp = line->t + screen.cur.col - 1;
920 rp = line->r + screen.cur.col - 1; 928 rp = line->r + screen.cur.col - 1;
921
922 while (*tp == NOCHAR && tp > line->t)
923 tp--, rp--;
924 } 929 }
925 else if (screen.cur.row > 0 930 else if (screen.cur.row > 0
926 && ROW(screen.cur.row - 1).is_longer ()) 931 && ROW(screen.cur.row - 1).is_longer ())
927 { 932 {
928 line_t *line = &ROW(screen.cur.row - 1); 933 linep = &ROW(screen.cur.row - 1);
929
930 tp = line->t + last_col - 1; 934 tp = line->t + ncol - 1;
931 rp = line->r + last_col - 1; 935 rp = line->r + ncol - 1;
932
933 while (*tp == NOCHAR && tp > line->t)
934 tp--, rp--;
935 } 936 }
936 else 937 else
937 continue; 938 continue;
939
940 linep->touch ();
941
942 while (*tp == NOCHAR && tp > linep->t)
943 tp--, rp--;
938 944
939 // first try to find a precomposed character 945 // first try to find a precomposed character
940 unicode_t n = rxvt_compose (*tp, c); 946 unicode_t n = rxvt_compose (*tp, c);
941 if (n == NOCHAR) 947 if (n == NOCHAR)
942 n = rxvt_composite.compose (*tp, c); 948 n = rxvt_composite.compose (*tp, c);
945 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); 951 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
946#endif 952#endif
947 } 953 }
948 } 954 }
949 955
950 if (!line->is_longer ()) /* XXX: think about this */
951 max_it (line->l, screen.cur.col); 956 max_it (line->l, screen.cur.col);
952 957
953#ifdef DEBUG_STRICT 958#ifdef DEBUG_STRICT
954 assert (screen.cur.row >= 0); 959 assert (screen.cur.row >= 0);
955#endif 960#endif
956} 961}
1006 1011
1007 for (; ++i < ncol; ) 1012 for (; ++i < ncol; )
1008 if (tabs[i]) 1013 if (tabs[i])
1009 { 1014 {
1010 x = i; 1015 x = i;
1016
1011 if (!--count) 1017 if (!--count)
1012 break; 1018 break;
1013 } 1019 }
1014 else 1020 else
1015 ht &= l.t[i] == ' ' 1021 ht &= l.t[i] == ' '
1018 if (count) 1024 if (count)
1019 x = ncol - 1; 1025 x = ncol - 1;
1020 1026
1021 // store horizontal tab commands as characters inside the text 1027 // store horizontal tab commands as characters inside the text
1022 // buffer so they can be selected and pasted. 1028 // buffer so they can be selected and pasted.
1023 if (ht && options & Opt_pastableTabs) 1029 if (ht && OPTION (Opt_pastableTabs))
1024 { 1030 {
1025 base_rend = SET_FONT (base_rend, 0); 1031 base_rend = SET_FONT (base_rend, 0);
1026 1032
1027 if (!l.is_longer ()) /* XXX: think about this */ 1033 l.touch (x);
1028 max_it (l.l, x);
1029 1034
1030 i = screen.cur.col; 1035 i = screen.cur.col;
1031 1036
1032 l.t[i] = '\t'; 1037 l.t[i] = '\t';
1033 l.r[i] = base_rend; 1038 l.r[i] = base_rend;
1087{ 1092{
1088 if (screen.cur.col < ncol - 1) 1093 if (screen.cur.col < ncol - 1)
1089 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1094 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1090 else 1095 else
1091 { 1096 {
1092 if (ROW(screen.cur.row).is_longer ()) //TODO//FIXME//LEN 1097 line_t &l = ROW(screen.cur.row);
1093 ROW(screen.cur.row).l = ncol; 1098
1099 l.touch ();
1100 l.is_longer (0);
1094 1101
1095 scr_gotorc (0, 0, R_RELATIVE); 1102 scr_gotorc (0, 0, R_RELATIVE);
1096 scr_insdel_chars (1, DELETE); 1103 scr_insdel_chars (1, DELETE);
1097 scr_gotorc (0, ncol - 1, R_RELATIVE); 1104 scr_gotorc (0, ncol - 1, R_RELATIVE);
1098 } 1105 }
1189 ZERO_SCROLLBACK (); 1196 ZERO_SCROLLBACK ();
1190 1197
1191 selection_check (1); 1198 selection_check (1);
1192 1199
1193 line_t &line = ROW(screen.cur.row); 1200 line_t &line = ROW(screen.cur.row);
1201
1202 line.touch ();
1203 line.is_longer (0);
1194 1204
1195 switch (mode) 1205 switch (mode)
1196 { 1206 {
1197 case 0: /* erase to end of line */ 1207 case 0: /* erase to end of line */
1198 col = screen.cur.col; 1208 col = screen.cur.col;
1284 CLEAR_ROWS (row, num); 1294 CLEAR_ROWS (row, num);
1285 } 1295 }
1286 else 1296 else
1287 { 1297 {
1288 ren = rstyle & (RS_fgMask | RS_bgMask); 1298 ren = rstyle & (RS_fgMask | RS_bgMask);
1289 gcvalue.foreground = pix_colors[GET_BGCOLOR (rstyle)]; 1299 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1290 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1300 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1291 ERASE_ROWS (row, num); 1301 ERASE_ROWS (row, num);
1292 gcvalue.foreground = pix_colors[Color_fg]; 1302 gcvalue.foreground = pix_colors[Color_fg];
1293 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1303 XChangeGC (display->display, gc, GCForeground, &gcvalue);
1294 } 1304 }
1295 1305
1296 for (; num--; row++) 1306 for (; num--; row++)
1297 { 1307 {
1298 ROW (row).l = 0;
1299 scr_blank_screen_mem (ROW (row), rstyle); 1308 scr_blank_screen_mem (ROW(row), rstyle);
1300 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1309 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1301 } 1310 }
1302} 1311}
1303 1312
1304#if ENABLE_FRILLS 1313#if ENABLE_FRILLS
1337 rend_t *r1 = line.r; 1346 rend_t *r1 = line.r;
1338 1347
1339 for (int j = ncol; j--; ) 1348 for (int j = ncol; j--; )
1340 *r1++ = fs; 1349 *r1++ = fs;
1341 1350
1342 line.l = ncol; /* make the `E's selectable */ 1351 line.is_longer (0);
1352 line.touch (ncol);
1343 } 1353 }
1344} 1354}
1345 1355
1346/* ------------------------------------------------------------------------- */ 1356/* ------------------------------------------------------------------------- */
1347/* 1357/*
1395 min_it (count, ncol - screen.cur.col); 1405 min_it (count, ncol - screen.cur.col);
1396 1406
1397 row = screen.cur.row; 1407 row = screen.cur.row;
1398 1408
1399 line_t *line = &ROW(row); 1409 line_t *line = &ROW(row);
1410
1411 line->touch ();
1412 line->is_longer (0);
1400 1413
1401 switch (insdel) 1414 switch (insdel)
1402 { 1415 {
1403 case INSERT: 1416 case INSERT:
1404 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1417 for (col = ncol - 1; (col - count) >= screen.cur.col; col--)
1405 { 1418 {
1406 line->t[col] = line->t[col - count]; 1419 line->t[col] = line->t[col - count];
1407 line->r[col] = line->r[col - count]; 1420 line->r[col] = line->r[col - count];
1408 } 1421 }
1409 1422
1410 if (!line->is_longer ()) 1423 line->l = min (line->l + count, ncol);
1411 {
1412 line->l += count;
1413 min_it (line->l, ncol);
1414 }
1415 1424
1416 if (selection.op && current_screen == selection.screen 1425 if (selection.op && current_screen == selection.screen
1417 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1426 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1418 { 1427 {
1419 if (selection.end.row != screen.cur.row 1428 if (selection.end.row != screen.cur.row
1432 1441
1433 case ERASE: 1442 case ERASE:
1434 screen.cur.col += count; /* don't worry if > ncol */ 1443 screen.cur.col += count; /* don't worry if > ncol */
1435 selection_check (1); 1444 selection_check (1);
1436 screen.cur.col -= count; 1445 screen.cur.col -= count;
1446
1447 line->l = max (line->l - count, 0);
1437 scr_blank_line (*line, screen.cur.col, count, rstyle); 1448 scr_blank_line (*line, screen.cur.col, count, rstyle);
1438 break; 1449 break;
1439 1450
1440 case DELETE: 1451 case DELETE:
1441 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1452 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask);
1444 { 1455 {
1445 line->t[col] = line->t[col + count]; 1456 line->t[col] = line->t[col + count];
1446 line->r[col] = line->r[col + count]; 1457 line->r[col] = line->r[col + count];
1447 } 1458 }
1448 1459
1460 line->l = max (line->l - count, 0);
1449 scr_blank_line (*line, ncol - count, count, tr); 1461 scr_blank_line (*line, ncol - count, count, tr);
1450
1451 if (line->is_longer ()) /* break line continuation */
1452 line->l = ncol;
1453
1454 line->l = max (line->l - count, 0);
1455 1462
1456 if (selection.op && current_screen == selection.screen 1463 if (selection.op && current_screen == selection.screen
1457 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1464 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1458 { 1465 {
1459 if (selection.end.row != screen.cur.row 1466 if (selection.end.row != screen.cur.row
1571rxvt_term::scr_set_tab (int mode) 1578rxvt_term::scr_set_tab (int mode)
1572{ 1579{
1573 if (mode < 0) 1580 if (mode < 0)
1574 memset (tabs, 0, ncol * sizeof (char)); 1581 memset (tabs, 0, ncol * sizeof (char));
1575 else if (screen.cur.col < ncol) 1582 else if (screen.cur.col < ncol)
1576 tabs[screen.cur.col] = (mode ? 1 : 0); 1583 tabs [screen.cur.col] = !!mode;
1577} 1584}
1578 1585
1579/* ------------------------------------------------------------------------- */ 1586/* ------------------------------------------------------------------------- */
1580/* 1587/*
1581 * Set reverse/normal video 1588 * Set reverse/normal video
1593 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1600 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1594#if XPM_BACKGROUND 1601#if XPM_BACKGROUND
1595 if (bgPixmap.pixmap == None) 1602 if (bgPixmap.pixmap == None)
1596#endif 1603#endif
1597#if TRANSPARENT 1604#if TRANSPARENT
1598 if (! (options & Opt_transparent) || am_transparent == 0) 1605 if (! OPTION (Opt_transparent) || am_transparent == 0)
1599#endif 1606#endif
1600 XSetWindowBackground (display->display, vt, 1607 XSetWindowBackground (display->display, vt,
1601 pix_colors[Color_bg]); 1608 pix_colors[Color_bg]);
1602 1609
1603 gcvalue.foreground = pix_colors[Color_fg]; 1610 gcvalue.foreground = pix_colors[Color_fg];
1628 * Set font style 1635 * Set font style
1629 */ 1636 */
1630void 1637void
1631rxvt_term::set_font_style () 1638rxvt_term::set_font_style ()
1632{ 1639{
1640#if 0
1633 switch (charsets[screen.charset]) 1641 switch (charsets [screen.charset])
1634 { 1642 {
1635 case '0': /* DEC Special Character & Line Drawing Set */ 1643 case '0': /* DEC Special Character & Line Drawing Set */
1636 break; 1644 break;
1637 case 'A': /* United Kingdom (UK) */ 1645 case 'A': /* United Kingdom (UK) */
1638 break; 1646 break;
1645 case 'C': /* Finnish character set */ 1653 case 'C': /* Finnish character set */
1646 break; 1654 break;
1647 case 'K': /* German character set */ 1655 case 'K': /* German character set */
1648 break; 1656 break;
1649 } 1657 }
1658#endif
1650} 1659}
1651 1660
1652/* ------------------------------------------------------------------------- */ 1661/* ------------------------------------------------------------------------- */
1653/* 1662/*
1654 * Choose a font 1663 * Choose a font
1821int 1830int
1822rxvt_term::scr_changeview (unsigned int oldviewstart) 1831rxvt_term::scr_changeview (unsigned int oldviewstart)
1823{ 1832{
1824 if (view_start != oldviewstart) 1833 if (view_start != oldviewstart)
1825 { 1834 {
1835 HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1836
1826 want_refresh = 1; 1837 want_refresh = 1;
1827 num_scr -= (view_start - oldviewstart); 1838 num_scr -= (view_start - oldviewstart);
1828 } 1839 }
1829 1840
1830 return (int) (view_start - oldviewstart); 1841 return (int)view_start - (int)oldviewstart;
1831} 1842}
1832 1843
1833/* ------------------------------------------------------------------------- */ 1844/* ------------------------------------------------------------------------- */
1834void 1845void
1835rxvt_term::scr_bell () 1846rxvt_term::scr_bell ()
1836{ 1847{
1837#ifndef NO_BELL 1848#ifndef NO_BELL
1838 1849
1839# ifndef NO_MAPALERT 1850# ifndef NO_MAPALERT
1840# ifdef MAPALERT_OPTION 1851# ifdef MAPALERT_OPTION
1841 if (options & Opt_mapAlert) 1852 if (OPTION (Opt_mapAlert))
1842# endif 1853# endif
1843 XMapWindow (display->display, parent[0]); 1854 XMapWindow (display->display, parent[0]);
1844# endif 1855# endif
1845 1856
1846 if (options & Opt_visualBell) 1857 if (OPTION (Opt_visualBell))
1847 { 1858 {
1848 scr_rvideo_mode (!rvideo); /* refresh also done */ 1859 scr_rvideo_mode (!rvideo); /* refresh also done */
1849 rxvt_usleep (VISUAL_BELL_DURATION); 1860 rxvt_usleep (VISUAL_BELL_DURATION);
1850 scr_rvideo_mode (!rvideo); /* refresh also done */ 1861 scr_rvideo_mode (!rvideo); /* refresh also done */
1851 } 1862 }
1942 1953
1943#if XPM_BACKGROUND 1954#if XPM_BACKGROUND
1944 must_clear |= bgPixmap.pixmap != None; 1955 must_clear |= bgPixmap.pixmap != None;
1945#endif 1956#endif
1946#if TRANSPARENT 1957#if TRANSPARENT
1947 must_clear |= (options & Opt_transparent) && am_transparent; 1958 must_clear |= OPTION (Opt_transparent) && am_transparent;
1948#endif 1959#endif
1949 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1960 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1950 1961
1951 /* 1962 /*
1952 * B: reverse any characters which are selected 1963 * B: reverse any characters which are selected
1976 1987
1977 crp = &ROW(screen.cur.row).r[col]; 1988 crp = &ROW(screen.cur.row).r[col];
1978 1989
1979 if (showcursor && focus) 1990 if (showcursor && focus)
1980 { 1991 {
1981 if (options & Opt_cursorUnderline) 1992 if (OPTION (Opt_cursorUnderline))
1982 *crp ^= RS_Uline; 1993 *crp ^= RS_Uline;
1983 else 1994 else
1984 { 1995 {
1985 *crp ^= RS_RVid; 1996 *crp ^= RS_RVid;
1986 1997
1988 cc1 = *crp & (RS_fgMask | RS_bgMask); 1999 cc1 = *crp & (RS_fgMask | RS_bgMask);
1989 if (ISSET_PIXCOLOR (Color_cursor)) 2000 if (ISSET_PIXCOLOR (Color_cursor))
1990 ccol1 = Color_cursor; 2001 ccol1 = Color_cursor;
1991 else 2002 else
1992#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2003#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
1993 ccol1 = GET_FGCOLOR (rstyle); 2004 ccol1 = fgcolor_of (rstyle);
1994#else 2005#else
1995 ccol1 = Color_fg; 2006 ccol1 = Color_fg;
1996#endif 2007#endif
1997 if (ISSET_PIXCOLOR (Color_cursor2)) 2008 if (ISSET_PIXCOLOR (Color_cursor2))
1998 ccol2 = Color_cursor2; 2009 ccol2 = Color_cursor2;
1999 else 2010 else
2000#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2011#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2001 ccol2 = GET_BGCOLOR (rstyle); 2012 ccol2 = bgcolor_of (rstyle);
2002#else 2013#else
2003 ccol2 = Color_bg; 2014 ccol2 = Color_bg;
2004#endif 2015#endif
2005 *crp = SET_FGCOLOR (*crp, ccol1); 2016 *crp = SET_FGCOLOR (*crp, ccol1);
2006 *crp = SET_BGCOLOR (*crp, ccol2); 2017 *crp = SET_BGCOLOR (*crp, ccol2);
2039 oldcursor.col = screen.cur.col; 2050 oldcursor.col = screen.cur.col;
2040 } 2051 }
2041 } 2052 }
2042 } 2053 }
2043 2054
2055 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2044#if ENABLE_OVERLAY 2056#if ENABLE_OVERLAY
2045 scr_swap_overlay (); 2057 scr_swap_overlay ();
2046#endif 2058#endif
2047 2059
2048#ifndef NO_SLOW_LINK_SUPPORT 2060#ifndef NO_SLOW_LINK_SUPPORT
2098 if (wlen < len) 2110 if (wlen < len)
2099 ::swap (wlen, len); 2111 ::swap (wlen, len);
2100 2112
2101 XCopyArea (display->display, vt, vt, 2113 XCopyArea (display->display, vt, vt,
2102 gc, 0, Row2Pixel (len + i), 2114 gc, 0, Row2Pixel (len + i),
2103 (unsigned int)TermWin_TotalWidth (), 2115 (unsigned int)this->width,
2104 (unsigned int)Height2Pixel (wlen - len + 1), 2116 (unsigned int)Height2Pixel (wlen - len + 1),
2105 0, Row2Pixel (len)); 2117 0, Row2Pixel (len));
2106 len = -1; 2118 len = -1;
2107 } 2119 }
2108 } 2120 }
2187 count++, i--; 2199 count++, i--;
2188 2200
2189 /* 2201 /*
2190 * Determine the attributes for the string 2202 * Determine the attributes for the string
2191 */ 2203 */
2192 int fore = GET_FGCOLOR (rend); // desired foreground 2204 int fore = fgcolor_of (rend); // desired foreground
2193 int back = GET_BGCOLOR (rend); // desired background 2205 int back = bgcolor_of (rend); // desired background
2194 2206
2195 // only do special processing if any attributes are set, which is unlikely 2207 // only do special processing if any attributes are set, which is unlikely
2196 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2208 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2197 { 2209 {
2198#if ENABLE_STYLES 2210#if ENABLE_STYLES
2311 } /* for (row....) */ 2323 } /* for (row....) */
2312 2324
2313#if ENABLE_OVERLAY 2325#if ENABLE_OVERLAY
2314 scr_swap_overlay (); 2326 scr_swap_overlay ();
2315#endif 2327#endif
2328 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2316 2329
2317 /* 2330 /*
2318 * G: cleanup cursor and display outline cursor if necessary 2331 * G: cleanup cursor and display outline cursor if necessary
2319 */ 2332 */
2320 if (showcursor) 2333 if (showcursor)
2321 { 2334 {
2322 if (focus) 2335 if (focus)
2323 { 2336 {
2324 if (options & Opt_cursorUnderline) 2337 if (OPTION (Opt_cursorUnderline))
2325 *crp ^= RS_Uline; 2338 *crp ^= RS_Uline;
2326 else 2339 else
2327 { 2340 {
2328 *crp ^= RS_RVid; 2341 *crp ^= RS_RVid;
2329#ifndef NO_CURSORCOLOR 2342#ifndef NO_CURSORCOLOR
2367 num_scr = 0; 2380 num_scr = 0;
2368 num_scr_allow = 1; 2381 num_scr_allow = 1;
2369} 2382}
2370 2383
2371void 2384void
2372rxvt_term::scr_remap_chars (const line_t &l) 2385rxvt_term::scr_remap_chars (line_t &l)
2373{ 2386{
2374 if (!l.t) 2387 if (!l.t)
2375 return; 2388 return;
2389
2390 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant
2376 2391
2377 for (int i = ncol; i--; ) 2392 for (int i = ncol; i--; )
2378 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2393 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2379} 2394}
2380 2395
2448 2463
2449#if ENABLE_FRILLS 2464#if ENABLE_FRILLS
2450 if (selection.rect) 2465 if (selection.rect)
2451 { 2466 {
2452 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++) 2467 for (row = max (selection.beg.row, -view_start); row <= min (selection.end.row, view_end); row++)
2468 {
2469 text_t *stp = ROW(row).t;
2470 rend_t *srp = ROW(row).r;
2471
2453 for (rend_t *srp = ROW(row).r, col = selection.beg.col; col < selection.end.col; col++) 2472 for (col = selection.beg.col; col < selection.end.col; col++)
2454 srp[col] ^= RS_RVid; 2473 srp[col] ^= RS_RVid;
2474
2475 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2476 srp[col] ^= RS_RVid | RS_Uline;
2477
2478 if (++col < selection.end.col)
2479 srp[col] ^= RS_RVid | RS_Uline;
2480 }
2455 } 2481 }
2456 else 2482 else
2457#endif 2483#endif
2458 { 2484 {
2459 if (selection.beg.row >= -view_start) 2485 if (selection.beg.row >= -view_start)
2543/* ------------------------------------------------------------------------- */ 2569/* ------------------------------------------------------------------------- */
2544/* 2570/*
2545 * Paste a selection direct to the command fd 2571 * Paste a selection direct to the command fd
2546 */ 2572 */
2547void 2573void
2548rxvt_term::paste (unsigned char *data, unsigned int len) 2574rxvt_term::paste (char *data, unsigned int len)
2549{ 2575{
2550 /* convert normal newline chars into common keyboard Return key sequence */ 2576 /* convert normal newline chars into common keyboard Return key sequence */
2551 for (unsigned int i = 0; i < len; i++) 2577 for (unsigned int i = 0; i < len; i++)
2552 if (data[i] == C0_LF) 2578 if (data[i] == C0_LF)
2553 data[i] = C0_CR; 2579 data[i] = C0_CR;
2697 { 2723 {
2698 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2724 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2699 char *s = rxvt_wcstombs (w); 2725 char *s = rxvt_wcstombs (w);
2700 free (w); 2726 free (w);
2701 // TODO: strlen == only the first element will be converted. well... 2727 // TODO: strlen == only the first element will be converted. well...
2702 paste ((unsigned char *)s, strlen (s)); 2728 paste (s, strlen (s));
2703 free (s); 2729 free (s);
2704 } 2730 }
2705 else 2731 else
2706#endif 2732#endif
2707 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2733 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0
2708 && cl) 2734 && cl)
2709 { 2735 {
2710 for (int i = 0; i < cr; i++) 2736 for (int i = 0; i < cr; i++)
2711 paste ((unsigned char *)cl[i], strlen (cl[i])); 2737 paste (cl[i], strlen (cl[i]));
2712 2738
2713 XFreeStringList (cl); 2739 XFreeStringList (cl);
2714 } 2740 }
2715 else 2741 else
2716 paste (ct.value, ct.nitems); // paste raw 2742 paste ((char *)ct.value, ct.nitems); // paste raw
2717 2743
2718bailout: 2744bailout:
2719 XFree (ct.value); 2745 XFree (ct.value);
2720 2746
2721 if (selection_wait == Sel_normal) 2747 if (selection_wait == Sel_normal)
2759 return; /* outside window */ 2785 return; /* outside window */
2760 2786
2761 if (selection.text) 2787 if (selection.text)
2762 { /* internal selection */ 2788 { /* internal selection */
2763 char *str = rxvt_wcstombs (selection.text, selection.len); 2789 char *str = rxvt_wcstombs (selection.text, selection.len);
2764 paste ((unsigned char *)str, strlen (str)); 2790 paste (str, strlen (str));
2765 free (str); 2791 free (str);
2766 return; 2792 return;
2767 } 2793 }
2768 else 2794 else
2769 { 2795 {
2861 selection.op = SELECTION_DONE; 2887 selection.op = SELECTION_DONE;
2862 2888
2863 if (selection.clicks == 4) 2889 if (selection.clicks == 4)
2864 return; /* nothing selected, go away */ 2890 return; /* nothing selected, go away */
2865 2891
2892 if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2893 return;
2894
2866 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2895 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2867 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 2896 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2868 2897
2869 int ofs = 0; 2898 int ofs = 0;
2870 int extra = 0; 2899 int extra = 0;
2882 col = selection.beg.col; 2911 col = selection.beg.col;
2883 end_col = ncol + 1; 2912 end_col = ncol + 1;
2884 } 2913 }
2885 else 2914 else
2886#endif 2915#endif
2887 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2916 end_col = ROW(row).l;
2888 2917
2889 col = max (col, 0); 2918 col = max (col, 0);
2890 2919
2891 if (row == selection.end.row || selection.rect) 2920 if (row == selection.end.row
2921#if ENABLE_FRILLS
2922 || selection.rect
2923#endif
2924 )
2892 end_col = min (end_col, selection.end.col); 2925 min_it (end_col, selection.end.col);
2893 2926
2894 t = ROW(row).t + col; 2927 t = ROW(row).t + col;
2928
2895 for (; col < end_col; col++) 2929 for (; col < end_col; col++)
2896 { 2930 {
2897 if (*t == NOCHAR) 2931 if (*t == NOCHAR)
2898 t++; 2932 t++;
2899#if ENABLE_COMBINING 2933#if ENABLE_COMBINING
2915#endif 2949#endif
2916 else 2950 else
2917 new_selection_text[ofs++] = *t++; 2951 new_selection_text[ofs++] = *t++;
2918 } 2952 }
2919 2953
2954#if ENABLE_FRILLS
2955 if (selection.rect)
2956 {
2957 while (ofs
2958 && new_selection_text[ofs - 1] != C0_LF
2959 && unicode::is_space (new_selection_text[ofs - 1]))
2960 --ofs;
2961
2962 new_selection_text[ofs++] = C0_LF;
2963 }
2964 else
2965#endif
2920 if (!ROW(row).is_longer () && row != selection.end.row) 2966 if (!ROW(row).is_longer () && row != selection.end.row)
2921 new_selection_text[ofs++] = C0_LF; 2967 new_selection_text[ofs++] = C0_LF;
2922 } 2968 }
2923 2969
2924 if (end_col != selection.end.col) 2970 if (end_col != selection.end.col)
2925 new_selection_text[ofs++] = C0_LF; 2971 new_selection_text[ofs++] = C0_LF;
2926 2972
2936 2982
2937 // we usually allocate much more than necessary, so realloc it smaller again 2983 // we usually allocate much more than necessary, so realloc it smaller again
2938 selection.len = ofs; 2984 selection.len = ofs;
2939 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); 2985 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t));
2940 2986
2987 if (HOOK_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END)))
2988 return;
2989
2990 selection_grab (tm);
2991}
2992
2993bool
2994rxvt_term::selection_grab (Time tm)
2995{
2996 selection_time = tm;
2997
2941 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 2998 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2942 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 2999 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
3000 {
2943 display->set_selection_owner (this); 3001 display->set_selection_owner (this);
3002 return true;
3003 }
2944 else 3004 else
2945 rxvt_warn ("can't get primary selection, ignoring.\n"); 3005 return false;
2946 3006
2947#if 0 3007#if 0
2948 XTextProperty ct; 3008 XTextProperty ct;
2949 3009
2950 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3010 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2951 { 3011 {
2952 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3012 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2953 XFree (ct.value); 3013 XFree (ct.value);
2954 } 3014 }
2955#endif 3015#endif
2956
2957 selection_time = tm;
2958} 3016}
2959 3017
2960/* ------------------------------------------------------------------------- */ 3018/* ------------------------------------------------------------------------- */
2961/* 3019/*
2962 * Mark or select text based upon number of clicks: 1, 2, or 3 3020 * Mark or select text based upon number of clicks: 1, 2, or 3
3084 } 3142 }
3085 } 3143 }
3086 break; 3144 break;
3087 } 3145 }
3088 3146
3089Old_Word_Selection_You_Die:
3090 if (dirn == DN) 3147 if (dirn == DN)
3091 col++; /* put us on one past the end */ 3148 col++; /* put us on one past the end */
3092 3149
3093 /* Poke the values back in */ 3150 /* Poke the values back in */
3094 ret->row = row; 3151 ret->row = row;
3271 else if (selection.clicks == 2) 3328 else if (selection.clicks == 2)
3272 { 3329 {
3273 if (ROWCOL_IS_AFTER (selection.end, selection.beg)) 3330 if (ROWCOL_IS_AFTER (selection.end, selection.beg))
3274 selection.end.col--; 3331 selection.end.col--;
3275 3332
3333 if (!HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
3334 {
3276 selection_delimit_word (UP, &selection.beg, &selection.beg); 3335 selection_delimit_word (UP, &selection.beg, &selection.beg);
3277 selection_delimit_word (DN, &selection.end, &selection.end); 3336 selection_delimit_word (DN, &selection.end, &selection.end);
3337 }
3278 } 3338 }
3279 else if (selection.clicks == 3) 3339 else if (selection.clicks == 3)
3280 { 3340 {
3281#if ENABLE_FRILLS 3341#if ENABLE_FRILLS
3282 if (options & Opt_tripleclickwords) 3342 if (OPTION (Opt_tripleclickwords))
3283 { 3343 {
3284 selection_delimit_word (UP, &selection.beg, &selection.beg); 3344 selection_delimit_word (UP, &selection.beg, &selection.beg);
3285 3345
3286 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3346 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3287 { 3347 {
3348 { 3408 {
3349 stp = ROW(end_row).t; 3409 stp = ROW(end_row).t;
3350 3410
3351 while (--end_col >= 0) 3411 while (--end_col >= 0)
3352 { 3412 {
3353 if (stp[end_col] != ' ' 3413 if (stp[end_col] != NOCHAR
3354 && stp[end_col] != '\t' 3414 && !unicode::is_space (stp[end_col]))
3355 && stp[end_col] != NOCHAR)
3356 break; 3415 break;
3357 } 3416 }
3358 3417
3359 if (end_col >= 0 3418 if (end_col >= 0
3360 || !ROW(end_row - 1).is_longer ()) 3419 || !ROW(end_row - 1).is_longer ())
3559 3618
3560#if ENABLE_OVERLAY 3619#if ENABLE_OVERLAY
3561void 3620void
3562rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3621rxvt_term::scr_overlay_new (int x, int y, int w, int h)
3563{ 3622{
3564 if (nrow < 3 || ncol < 3) 3623 if (nrow < 1 || ncol < 1)
3565 return; 3624 return;
3566 3625
3567 want_refresh = 1; 3626 want_refresh = 1;
3568 3627
3569 scr_overlay_off (); 3628 scr_overlay_off ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines