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.202 by root, Sat Dec 31 17:16:17 2005 UTC vs.
Revision 1.211 by root, Fri Jan 6 01:16:58 2006 UTC

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
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;
289 { 292 {
290 p = MOD (p - 1, prev_total_rows); 293 p = MOD (p - 1, prev_total_rows);
291#ifdef DEBUG_STRICT 294#ifdef DEBUG_STRICT
292 assert (old_buf [MOD (p, prev_total_rows)].t); 295 assert (old_buf [MOD (p, prev_total_rows)].t);
293#endif 296#endif
294
295 int plines = 1; 297 int plines = 1;
296 int llen = old_buf [MOD (p, prev_total_rows)].l; 298 int llen = old_buf [MOD (p, prev_total_rows)].l;
297 299
298 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ()) 300 while (p != pend && old_buf [MOD (p - 1, prev_total_rows)].is_longer ())
299 { 301 {
317 // re-assemble the full line by destination lines 319 // re-assemble the full line by destination lines
318 for (int qrow = q; qlines--; qrow++) 320 for (int qrow = q; qlines--; qrow++)
319 { 321 {
320 qline = row_buf + qrow; 322 qline = row_buf + qrow;
321 lalloc (*qline); 323 lalloc (*qline);
324 qline->l = ncol;
322 qline->set_is_longer (); 325 qline->is_longer (1);
323 326
324 int qcol = 0; 327 int qcol = 0;
325 328
326 // fill a single destination line 329 // fill a single destination line
327 while (lofs < llen && qcol < ncol) 330 while (lofs < llen && qcol < ncol)
352 qcol += len; 355 qcol += len;
353 } 356 }
354 } 357 }
355 358
356 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0; 359 qline->l = llen ? MOD (llen - 1, ncol) + 1 : 0;
357#ifdef DEBUG_STRICT //TODO//FIXME//TEMPORARY 360 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); 361 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
365 } 362 }
366 while (p != pend && q > 0); 363 while (p != pend && q > 0);
367 364
368 term_start = total_rows - nrow; 365 term_start = total_rows - nrow;
369 nsaved = term_start - q; 366 nsaved = term_start - q;
370 367
371 // make sure all terminal lines exist 368 // make sure all terminal lines exist
372 while (nsaved < 0) 369 while (nsaved < 0)
373 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE); 370 scr_blank_screen_mem (ROW (-++nsaved), DEFAULT_RSTYLE);
374
375 } 371 }
376 else 372 else
377 { 373 {
378 // if no scrollback exists (yet), wing, instead of wrap 374 // if no scrollback exists (yet), wing, instead of wrap
379 375
417 413
418 for (int col = ncol; col--; ) 414 for (int col = ncol; col--; )
419 tabs [col] = col % TABSIZE == 0; 415 tabs [col] = col % TABSIZE == 0;
420 416
421 tt_winch (); 417 tt_winch ();
418
419 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
422} 420}
423 421
424/* ------------------------------------------------------------------------- */ 422/* ------------------------------------------------------------------------- */
425/* 423/*
426 * Free everything. That way malloc debugging can find leakage. 424 * Free everything. That way malloc debugging can find leakage.
619 && row1 == 0 617 && row1 == 0
620 && row2 == nrow - 1 618 && row2 == nrow - 1
621 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) 619 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll)))
622 { 620 {
623 nsaved = min (nsaved + count, saveLines); 621 nsaved = min (nsaved + count, saveLines);
622
623 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, nsaved, DT_END));
624
624 term_start = (term_start + count) % total_rows; 625 term_start = (term_start + count) % total_rows;
625 626
626 if (selection.op && current_screen == selection.screen) 627 if (selection.op && current_screen == selection.screen)
627 { 628 {
628 selection.beg.row -= count; 629 selection.beg.row -= count;
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 unicode_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 (nlines > 0)
719 { 719 {
720 nlines += screen.cur.row - screen.bscroll; 720 nlines += screen.cur.row - screen.bscroll;
721
721 if (nlines > 0 722 if (nlines > 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, nlines);
727 screen.cur.row -= nlines; 728 screen.cur.row -= nlines;
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
744 c = *str++; 745 c = *str++;
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] == ' '
1022 // buffer so they can be selected and pasted. 1028 // buffer so they can be selected and pasted.
1023 if (ht && OPTION (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;
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; 1308 line_t &l = ROW(row);
1309 l.l = 0;
1310 l.is_longer (0);
1299 scr_blank_screen_mem (ROW (row), rstyle); 1311 scr_blank_screen_mem (l, rstyle);
1300 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1312 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1301 } 1313 }
1302} 1314}
1303 1315
1304#if ENABLE_FRILLS 1316#if ENABLE_FRILLS
1337 rend_t *r1 = line.r; 1349 rend_t *r1 = line.r;
1338 1350
1339 for (int j = ncol; j--; ) 1351 for (int j = ncol; j--; )
1340 *r1++ = fs; 1352 *r1++ = fs;
1341 1353
1342 line.l = ncol; /* make the `E's selectable */ 1354 line.is_longer (0);
1355 line.touch (ncol);
1343 } 1356 }
1344} 1357}
1345 1358
1346/* ------------------------------------------------------------------------- */ 1359/* ------------------------------------------------------------------------- */
1347/* 1360/*
1395 min_it (count, ncol - screen.cur.col); 1408 min_it (count, ncol - screen.cur.col);
1396 1409
1397 row = screen.cur.row; 1410 row = screen.cur.row;
1398 1411
1399 line_t *line = &ROW(row); 1412 line_t *line = &ROW(row);
1413
1414 line->touch ();
1415 line->is_longer (0);
1400 1416
1401 switch (insdel) 1417 switch (insdel)
1402 { 1418 {
1403 case INSERT: 1419 case INSERT:
1404 for (col = ncol - 1; (col - count) >= screen.cur.col; col--) 1420 for (col = ncol - 1; (col - count) >= screen.cur.col; col--)
1405 { 1421 {
1406 line->t[col] = line->t[col - count]; 1422 line->t[col] = line->t[col - count];
1407 line->r[col] = line->r[col - count]; 1423 line->r[col] = line->r[col - count];
1408 } 1424 }
1409 1425
1410 if (!line->is_longer ()) 1426 line->l = min (line->l + count, ncol);
1411 {
1412 line->l += count;
1413 min_it (line->l, ncol);
1414 }
1415 1427
1416 if (selection.op && current_screen == selection.screen 1428 if (selection.op && current_screen == selection.screen
1417 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1429 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1418 { 1430 {
1419 if (selection.end.row != screen.cur.row 1431 if (selection.end.row != screen.cur.row
1432 1444
1433 case ERASE: 1445 case ERASE:
1434 screen.cur.col += count; /* don't worry if > ncol */ 1446 screen.cur.col += count; /* don't worry if > ncol */
1435 selection_check (1); 1447 selection_check (1);
1436 screen.cur.col -= count; 1448 screen.cur.col -= count;
1449
1450 line->l = max (line->l - count, 0);
1437 scr_blank_line (*line, screen.cur.col, count, rstyle); 1451 scr_blank_line (*line, screen.cur.col, count, rstyle);
1438 break; 1452 break;
1439 1453
1440 case DELETE: 1454 case DELETE:
1441 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1455 tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask);
1444 { 1458 {
1445 line->t[col] = line->t[col + count]; 1459 line->t[col] = line->t[col + count];
1446 line->r[col] = line->r[col + count]; 1460 line->r[col] = line->r[col + count];
1447 } 1461 }
1448 1462
1463 line->l = max (line->l - count, 0);
1449 scr_blank_line (*line, ncol - count, count, tr); 1464 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 1465
1456 if (selection.op && current_screen == selection.screen 1466 if (selection.op && current_screen == selection.screen
1457 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1467 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1458 { 1468 {
1459 if (selection.end.row != screen.cur.row 1469 if (selection.end.row != screen.cur.row
1571rxvt_term::scr_set_tab (int mode) 1581rxvt_term::scr_set_tab (int mode)
1572{ 1582{
1573 if (mode < 0) 1583 if (mode < 0)
1574 memset (tabs, 0, ncol * sizeof (char)); 1584 memset (tabs, 0, ncol * sizeof (char));
1575 else if (screen.cur.col < ncol) 1585 else if (screen.cur.col < ncol)
1576 tabs[screen.cur.col] = (mode ? 1 : 0); 1586 tabs [screen.cur.col] = !!mode;
1577} 1587}
1578 1588
1579/* ------------------------------------------------------------------------- */ 1589/* ------------------------------------------------------------------------- */
1580/* 1590/*
1581 * Set reverse/normal video 1591 * Set reverse/normal video
1628 * Set font style 1638 * Set font style
1629 */ 1639 */
1630void 1640void
1631rxvt_term::set_font_style () 1641rxvt_term::set_font_style ()
1632{ 1642{
1643#if 0
1633 switch (charsets[screen.charset]) 1644 switch (charsets [screen.charset])
1634 { 1645 {
1635 case '0': /* DEC Special Character & Line Drawing Set */ 1646 case '0': /* DEC Special Character & Line Drawing Set */
1636 break; 1647 break;
1637 case 'A': /* United Kingdom (UK) */ 1648 case 'A': /* United Kingdom (UK) */
1638 break; 1649 break;
1645 case 'C': /* Finnish character set */ 1656 case 'C': /* Finnish character set */
1646 break; 1657 break;
1647 case 'K': /* German character set */ 1658 case 'K': /* German character set */
1648 break; 1659 break;
1649 } 1660 }
1661#endif
1650} 1662}
1651 1663
1652/* ------------------------------------------------------------------------- */ 1664/* ------------------------------------------------------------------------- */
1653/* 1665/*
1654 * Choose a font 1666 * Choose a font
1821int 1833int
1822rxvt_term::scr_changeview (unsigned int oldviewstart) 1834rxvt_term::scr_changeview (unsigned int oldviewstart)
1823{ 1835{
1824 if (view_start != oldviewstart) 1836 if (view_start != oldviewstart)
1825 { 1837 {
1838 HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1839
1826 want_refresh = 1; 1840 want_refresh = 1;
1827 num_scr -= (view_start - oldviewstart); 1841 num_scr -= (view_start - oldviewstart);
1828 } 1842 }
1829 1843
1830 return (int) (view_start - oldviewstart); 1844 return (int)view_start - (int)oldviewstart;
1831} 1845}
1832 1846
1833/* ------------------------------------------------------------------------- */ 1847/* ------------------------------------------------------------------------- */
1834void 1848void
1835rxvt_term::scr_bell () 1849rxvt_term::scr_bell ()
2039 oldcursor.col = screen.cur.col; 2053 oldcursor.col = screen.cur.col;
2040 } 2054 }
2041 } 2055 }
2042 } 2056 }
2043 2057
2058 HOOK_INVOKE ((this, HOOK_REFRESH_BEGIN, DT_END));
2044#if ENABLE_OVERLAY 2059#if ENABLE_OVERLAY
2045 scr_swap_overlay (); 2060 scr_swap_overlay ();
2046#endif 2061#endif
2047 2062
2048#ifndef NO_SLOW_LINK_SUPPORT 2063#ifndef NO_SLOW_LINK_SUPPORT
2098 if (wlen < len) 2113 if (wlen < len)
2099 ::swap (wlen, len); 2114 ::swap (wlen, len);
2100 2115
2101 XCopyArea (display->display, vt, vt, 2116 XCopyArea (display->display, vt, vt,
2102 gc, 0, Row2Pixel (len + i), 2117 gc, 0, Row2Pixel (len + i),
2103 (unsigned int)TermWin_TotalWidth (), 2118 (unsigned int)this->width,
2104 (unsigned int)Height2Pixel (wlen - len + 1), 2119 (unsigned int)Height2Pixel (wlen - len + 1),
2105 0, Row2Pixel (len)); 2120 0, Row2Pixel (len));
2106 len = -1; 2121 len = -1;
2107 } 2122 }
2108 } 2123 }
2311 } /* for (row....) */ 2326 } /* for (row....) */
2312 2327
2313#if ENABLE_OVERLAY 2328#if ENABLE_OVERLAY
2314 scr_swap_overlay (); 2329 scr_swap_overlay ();
2315#endif 2330#endif
2331 HOOK_INVOKE ((this, HOOK_REFRESH_END, DT_END));
2316 2332
2317 /* 2333 /*
2318 * G: cleanup cursor and display outline cursor if necessary 2334 * G: cleanup cursor and display outline cursor if necessary
2319 */ 2335 */
2320 if (showcursor) 2336 if (showcursor)
2367 num_scr = 0; 2383 num_scr = 0;
2368 num_scr_allow = 1; 2384 num_scr_allow = 1;
2369} 2385}
2370 2386
2371void 2387void
2372rxvt_term::scr_remap_chars (const line_t &l) 2388rxvt_term::scr_remap_chars (line_t &l)
2373{ 2389{
2374 if (!l.t) 2390 if (!l.t)
2375 return; 2391 return;
2392
2393 l.touch (); // maybe a bit of an overkill, but its not performance-relevant
2376 2394
2377 for (int i = ncol; i--; ) 2395 for (int i = ncol; i--; )
2378 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2396 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2379} 2397}
2380 2398
2456 2474
2457 for (col = selection.beg.col; col < selection.end.col; col++) 2475 for (col = selection.beg.col; col < selection.end.col; col++)
2458 srp[col] ^= RS_RVid; 2476 srp[col] ^= RS_RVid;
2459 2477
2460 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col]))) 2478 while (col-- > selection.beg.col && (stp[col] == NOCHAR || unicode::is_space (stp[col])))
2479 srp[col] ^= RS_RVid | RS_Uline;
2480
2481 if (++col < selection.end.col)
2461 srp[col] ^= RS_RVid | RS_Uline; 2482 srp[col] ^= RS_RVid | RS_Uline;
2462 } 2483 }
2463 } 2484 }
2464 else 2485 else
2465#endif 2486#endif
2551/* ------------------------------------------------------------------------- */ 2572/* ------------------------------------------------------------------------- */
2552/* 2573/*
2553 * Paste a selection direct to the command fd 2574 * Paste a selection direct to the command fd
2554 */ 2575 */
2555void 2576void
2556rxvt_term::paste (unsigned char *data, unsigned int len) 2577rxvt_term::paste (char *data, unsigned int len)
2557{ 2578{
2558 /* convert normal newline chars into common keyboard Return key sequence */ 2579 /* convert normal newline chars into common keyboard Return key sequence */
2559 for (unsigned int i = 0; i < len; i++) 2580 for (unsigned int i = 0; i < len; i++)
2560 if (data[i] == C0_LF) 2581 if (data[i] == C0_LF)
2561 data[i] = C0_CR; 2582 data[i] = C0_CR;
2705 { 2726 {
2706 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2727 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2707 char *s = rxvt_wcstombs (w); 2728 char *s = rxvt_wcstombs (w);
2708 free (w); 2729 free (w);
2709 // TODO: strlen == only the first element will be converted. well... 2730 // TODO: strlen == only the first element will be converted. well...
2710 paste ((unsigned char *)s, strlen (s)); 2731 paste (s, strlen (s));
2711 free (s); 2732 free (s);
2712 } 2733 }
2713 else 2734 else
2714#endif 2735#endif
2715 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2736 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0
2716 && cl) 2737 && cl)
2717 { 2738 {
2718 for (int i = 0; i < cr; i++) 2739 for (int i = 0; i < cr; i++)
2719 paste ((unsigned char *)cl[i], strlen (cl[i])); 2740 paste (cl[i], strlen (cl[i]));
2720 2741
2721 XFreeStringList (cl); 2742 XFreeStringList (cl);
2722 } 2743 }
2723 else 2744 else
2724 paste (ct.value, ct.nitems); // paste raw 2745 paste ((char *)ct.value, ct.nitems); // paste raw
2725 2746
2726bailout: 2747bailout:
2727 XFree (ct.value); 2748 XFree (ct.value);
2728 2749
2729 if (selection_wait == Sel_normal) 2750 if (selection_wait == Sel_normal)
2767 return; /* outside window */ 2788 return; /* outside window */
2768 2789
2769 if (selection.text) 2790 if (selection.text)
2770 { /* internal selection */ 2791 { /* internal selection */
2771 char *str = rxvt_wcstombs (selection.text, selection.len); 2792 char *str = rxvt_wcstombs (selection.text, selection.len);
2772 paste ((unsigned char *)str, strlen (str)); 2793 paste (str, strlen (str));
2773 free (str); 2794 free (str);
2774 return; 2795 return;
2775 } 2796 }
2776 else 2797 else
2777 { 2798 {
2869 selection.op = SELECTION_DONE; 2890 selection.op = SELECTION_DONE;
2870 2891
2871 if (selection.clicks == 4) 2892 if (selection.clicks == 4)
2872 return; /* nothing selected, go away */ 2893 return; /* nothing selected, go away */
2873 2894
2895 if (HOOK_INVOKE ((this, HOOK_SEL_MAKE, DT_LONG, (long)tm, DT_END)))
2896 return;
2897
2874 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1); 2898 i = (selection.end.row - selection.beg.row + 1) * (ncol + 1);
2875 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 2899 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2876 2900
2877 int ofs = 0; 2901 int ofs = 0;
2878 int extra = 0; 2902 int extra = 0;
2890 col = selection.beg.col; 2914 col = selection.beg.col;
2891 end_col = ncol + 1; 2915 end_col = ncol + 1;
2892 } 2916 }
2893 else 2917 else
2894#endif 2918#endif
2895 end_col = ROW(row).is_longer () ? ncol : ROW(row).l; //TODO//FIXME//LEN 2919 end_col = ROW(row).l;
2896 2920
2897 col = max (col, 0); 2921 col = max (col, 0);
2898 2922
2899 if (row == selection.end.row 2923 if (row == selection.end.row
2900#if ENABLE_FRILLS 2924#if ENABLE_FRILLS
2902#endif 2926#endif
2903 ) 2927 )
2904 min_it (end_col, selection.end.col); 2928 min_it (end_col, selection.end.col);
2905 2929
2906 t = ROW(row).t + col; 2930 t = ROW(row).t + col;
2931
2907 for (; col < end_col; col++) 2932 for (; col < end_col; col++)
2908 { 2933 {
2909 if (*t == NOCHAR) 2934 if (*t == NOCHAR)
2910 t++; 2935 t++;
2911#if ENABLE_COMBINING 2936#if ENABLE_COMBINING
2960 2985
2961 // we usually allocate much more than necessary, so realloc it smaller again 2986 // we usually allocate much more than necessary, so realloc it smaller again
2962 selection.len = ofs; 2987 selection.len = ofs;
2963 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t)); 2988 selection.text = (wchar_t *)rxvt_realloc (new_selection_text, (ofs + 1) * sizeof (wchar_t));
2964 2989
2990 if (HOOK_INVOKE ((this, HOOK_SEL_GRAB, DT_LONG, (long)tm, DT_END)))
2991 return;
2992
2993 selection_grab (tm);
2994}
2995
2996bool
2997rxvt_term::selection_grab (Time tm)
2998{
2999 selection_time = tm;
3000
2965 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 3001 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm);
2966 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 3002 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt)
3003 {
2967 display->set_selection_owner (this); 3004 display->set_selection_owner (this);
3005 return true;
3006 }
2968 else 3007 else
2969 rxvt_warn ("can't get primary selection, ignoring.\n"); 3008 return false;
2970 3009
2971#if 0 3010#if 0
2972 XTextProperty ct; 3011 XTextProperty ct;
2973 3012
2974 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3013 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
2975 { 3014 {
2976 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3015 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
2977 XFree (ct.value); 3016 XFree (ct.value);
2978 } 3017 }
2979#endif 3018#endif
2980
2981 selection_time = tm;
2982} 3019}
2983 3020
2984/* ------------------------------------------------------------------------- */ 3021/* ------------------------------------------------------------------------- */
2985/* 3022/*
2986 * Mark or select text based upon number of clicks: 1, 2, or 3 3023 * Mark or select text based upon number of clicks: 1, 2, or 3
3108 } 3145 }
3109 } 3146 }
3110 break; 3147 break;
3111 } 3148 }
3112 3149
3113Old_Word_Selection_You_Die:
3114 if (dirn == DN) 3150 if (dirn == DN)
3115 col++; /* put us on one past the end */ 3151 col++; /* put us on one past the end */
3116 3152
3117 /* Poke the values back in */ 3153 /* Poke the values back in */
3118 ret->row = row; 3154 ret->row = row;
3295 else if (selection.clicks == 2) 3331 else if (selection.clicks == 2)
3296 { 3332 {
3297 if (ROWCOL_IS_AFTER (selection.end, selection.beg)) 3333 if (ROWCOL_IS_AFTER (selection.end, selection.beg))
3298 selection.end.col--; 3334 selection.end.col--;
3299 3335
3336 if (!HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
3337 {
3300 selection_delimit_word (UP, &selection.beg, &selection.beg); 3338 selection_delimit_word (UP, &selection.beg, &selection.beg);
3301 selection_delimit_word (DN, &selection.end, &selection.end); 3339 selection_delimit_word (DN, &selection.end, &selection.end);
3340 }
3302 } 3341 }
3303 else if (selection.clicks == 3) 3342 else if (selection.clicks == 3)
3304 { 3343 {
3305#if ENABLE_FRILLS 3344#if ENABLE_FRILLS
3306 if (OPTION (Opt_tripleclickwords)) 3345 if (OPTION (Opt_tripleclickwords))
3582 3621
3583#if ENABLE_OVERLAY 3622#if ENABLE_OVERLAY
3584void 3623void
3585rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3624rxvt_term::scr_overlay_new (int x, int y, int w, int h)
3586{ 3625{
3587 if (nrow < 3 || ncol < 3) 3626 if (nrow < 1 || ncol < 1)
3588 return; 3627 return;
3589 3628
3590 want_refresh = 1; 3629 want_refresh = 1;
3591 3630
3592 scr_overlay_off (); 3631 scr_overlay_off ();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines