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.59 by pcg, Mon Mar 15 00:08:11 2004 UTC vs.
Revision 1.71 by pcg, Thu Apr 8 20:31:45 2004 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-2004 Marc Lehmann <pcg@goof.com>
7 * 7 *
439 uint16_t total_rows; 439 uint16_t total_rows;
440 int i; 440 int i;
441 441
442 total_rows = TermWin.nrow + TermWin.saveLines; 442 total_rows = TermWin.nrow + TermWin.saveLines;
443 443
444#ifdef DEBUG_STRICT
445 for (i = 0; i < total_rows; i++)
446 {
447 if (screen.text[i])
448 /* then so is screen.rend[i] */
449 assert (screen.rend[i]);
450 }
451#endif
452
453 delete talloc; talloc = 0; 444 delete talloc; talloc = 0;
454 delete ralloc; ralloc = 0; 445 delete ralloc; ralloc = 0;
455 446
456 free (screen.text); 447 free (screen.text);
457 free (screen.tlen); 448 free (screen.tlen);
500 * XTERM_SEQ: Restore cursor: ESC 8 491 * XTERM_SEQ: Restore cursor: ESC 8
501 */ 492 */
502void 493void
503rxvt_term::scr_cursor (int mode) 494rxvt_term::scr_cursor (int mode)
504{ 495{
505 screen_t *s; 496 screen_t *s;
506 497
507 D_SCREEN ((stderr, "rxvt_scr_cursor (%c)", mode)); 498 D_SCREEN ((stderr, "rxvt_scr_cursor (%c)", mode));
508 499
509#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) 500#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR)
510 if (current_screen == SECONDARY) 501 if (current_screen == SECONDARY)
511 s = & (swap); 502 s = &swap;
512 else 503 else
513#endif 504#endif
514 s = & (screen); 505 s = &screen;
506
515 switch (mode) 507 switch (mode)
516 { 508 {
517 case SAVE: 509 case SAVE:
518 s->s_cur.row = s->cur.row; 510 s->s_cur.row = s->cur.row;
519 s->s_cur.col = s->cur.col; 511 s->s_cur.col = s->cur.col;
520 s->s_rstyle = rstyle; 512 s->s_rstyle = rstyle;
521 s->s_charset = s->charset; 513 s->s_charset = s->charset;
522 s->s_charset_char = charsets[s->charset]; 514 s->s_charset_char = charsets[s->charset];
523 break; 515 break;
516
524 case RESTORE: 517 case RESTORE:
525 want_refresh = 1; 518 want_refresh = 1;
526 s->cur.row = s->s_cur.row; 519 s->cur.row = s->s_cur.row;
527 s->cur.col = s->s_cur.col; 520 s->cur.col = s->s_cur.col;
528 s->flags &= ~Screen_WrapNext; 521 s->flags &= ~Screen_WrapNext;
530 s->charset = s->s_charset; 523 s->charset = s->s_charset;
531 charsets[s->charset] = s->s_charset_char; 524 charsets[s->charset] = s->s_charset_char;
532 set_font_style (); 525 set_font_style ();
533 break; 526 break;
534 } 527 }
528
535 /* boundary check in case screen size changed between SAVE and RESTORE */ 529 /* boundary check in case screen size changed between SAVE and RESTORE */
536 MIN_IT (s->cur.row, TermWin.nrow - 1); 530 MIN_IT (s->cur.row, TermWin.nrow - 1);
537 MIN_IT (s->cur.col, TermWin.ncol - 1); 531 MIN_IT (s->cur.col, TermWin.ncol - 1);
538#ifdef DEBUG_STRICT 532#ifdef DEBUG_STRICT
539 assert (s->cur.row >= 0); 533 assert (s->cur.row >= 0);
551 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l 545 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l
552 */ 546 */
553int 547int
554rxvt_term::scr_change_screen (int scrn) 548rxvt_term::scr_change_screen (int scrn)
555{ 549{
556 int i; 550 int i;
557#if NSCREENS 551#if NSCREENS
558 int offset; 552 int offset;
559#endif 553#endif
560 554
561 want_refresh = 1; 555 want_refresh = 1;
562 556
563 D_SCREEN ((stderr, "rxvt_scr_change_screen (%d)", scrn)); 557 D_SCREEN ((stderr, "rxvt_scr_change_screen (%d)", scrn));
564 558
565 TermWin.view_start = 0; 559 TermWin.view_start = 0;
566 560
567 if (current_screen == scrn) 561 if (current_screen == scrn)
568 return current_screen; 562 return scrn;
569 563
570 selection_check (2); /* check for boundary cross */ 564 selection_check (2); /* check for boundary cross */
571 565
572 SWAP_IT (current_screen, scrn, int); 566 SWAP_IT (current_screen, scrn, int);
573#if NSCREENS 567#if NSCREENS
568 if (Options & Opt_secondaryScreen)
569 {
574 num_scr = 0; 570 num_scr = 0;
575 offset = TermWin.saveLines; 571 offset = TermWin.saveLines;
576 for (i = prev_nrow; i--;) 572 for (i = prev_nrow; i--;)
577 { 573 {
578 SWAP_IT (screen.text[i + offset], swap.text[i], text_t *); 574 SWAP_IT (screen.text[i + offset], swap.text[i], text_t *);
579 SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t); 575 SWAP_IT (screen.tlen[i + offset], swap.tlen[i], int16_t);
580 SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *); 576 SWAP_IT (screen.rend[i + offset], swap.rend[i], rend_t *);
581 } 577 }
582 SWAP_IT (screen.cur.row, swap.cur.row, int16_t); 578 SWAP_IT (screen.cur.row, swap.cur.row, int16_t);
583 SWAP_IT (screen.cur.col, swap.cur.col, int16_t); 579 SWAP_IT (screen.cur.col, swap.cur.col, int16_t);
584# ifdef DEBUG_STRICT 580# ifdef DEBUG_STRICT
585 assert ((screen.cur.row >= 0) && (screen.cur.row < prev_nrow)); 581 assert ((screen.cur.row >= 0) && (screen.cur.row < prev_nrow));
586 assert ((screen.cur.col >= 0) && (screen.cur.col < prev_ncol)); 582 assert ((screen.cur.col >= 0) && (screen.cur.col < prev_ncol));
587# else /* drive with your eyes closed */ 583# else /* drive with your eyes closed */
588 MAX_IT (screen.cur.row, 0); 584 MAX_IT (screen.cur.row, 0);
589 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); 585 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1);
590 MAX_IT (screen.cur.col, 0); 586 MAX_IT (screen.cur.col, 0);
591 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); 587 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1);
592# endif 588# endif
593 SWAP_IT (screen.charset, swap.charset, int16_t); 589 SWAP_IT (screen.charset, swap.charset, int16_t);
594 SWAP_IT (screen.flags, swap.flags, int); 590 SWAP_IT (screen.flags, swap.flags, int);
595 screen.flags |= Screen_VisibleCursor; 591 screen.flags |= Screen_VisibleCursor;
596 swap.flags |= Screen_VisibleCursor; 592 swap.flags |= Screen_VisibleCursor;
597#else 593 }
598# ifdef SCROLL_ON_NO_SECONDARY 594 else
595#endif
596 if (Options & Opt_secondaryScroll)
599 if (current_screen == PRIMARY) 597 //if (current_screen == PRIMARY)
600 scr_scroll_text (0, (prev_nrow - 1), prev_nrow, 0); 598 scr_scroll_text (0, (prev_nrow - 1), prev_nrow, 0);
601# endif
602#endif
603 return scrn; 599 return scrn;
604} 600}
605 601
606/* ------------------------------------------------------------------------- */ 602/* ------------------------------------------------------------------------- */
607/* 603/*
649 return 0; 645 return 0;
650 646
651 want_refresh = 1; 647 want_refresh = 1;
652 D_SCREEN ((stderr, "rxvt_scroll_text (%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary")); 648 D_SCREEN ((stderr, "rxvt_scroll_text (%d,%d,%d,%d): %s", row1, row2, count, spec, (current_screen == PRIMARY) ? "Primary" : "Secondary"));
653 649
654 if ((count > 0) && (row1 == 0) && (current_screen == PRIMARY)) 650 if (row1 == 0 && count > 0
651 && (current_screen == PRIMARY || Options & Opt_secondaryScroll))
655 { 652 {
656 nscrolled = (long)TermWin.nscrolled + (long)count; 653 nscrolled = (long)TermWin.nscrolled + (long)count;
657 654
658 if (nscrolled > (long)TermWin.saveLines) 655 if (nscrolled > (long)TermWin.saveLines)
659 TermWin.nscrolled = TermWin.saveLines; 656 TermWin.nscrolled = TermWin.saveLines;
801 MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1); 798 MIN_IT (screen.cur.row, (int32_t)TermWin.nrow - 1);
802 MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled); 799 MAX_IT (screen.cur.row, - (int32_t)TermWin.nscrolled);
803#endif 800#endif
804 row = screen.cur.row + TermWin.saveLines; 801 row = screen.cur.row + TermWin.saveLines;
805 802
806 checksel = (selection.op 803 checksel = selection.op && current_screen == selection.screen ? 1 : 0;
807 && current_screen == selection.screen) ? 1 : 0;
808 clearsel = 0; 804 clearsel = 0;
809 805
810 stp = screen.text[row]; 806 stp = screen.text[row];
811 srp = screen.rend[row]; 807 srp = screen.rend[row];
812 808
813 for (i = 0; i < len;) 809 while (len--)
814 { 810 {
815 c = str[i++]; 811 c = *str++;
812
813 if (c < 0x20)
816 switch (c) 814 switch (c)
817 { 815 {
818 case '\t': 816 case C0_HT:
819 scr_tab (1); 817 scr_tab (1);
820 continue; 818 continue;
821 case '\n': 819
820 case C0_LF:
822 if (screen.tlen[row] != -1) /* XXX: think about this */ 821 if (screen.tlen[row] != -1) /* XXX: think about this */
823 MAX_IT (screen.tlen[row], screen.cur.col); 822 MAX_IT (screen.tlen[row], screen.cur.col);
823
824 screen.flags &= ~Screen_WrapNext; 824 screen.flags &= ~Screen_WrapNext;
825
825 if (screen.cur.row == screen.bscroll) 826 if (screen.cur.row == screen.bscroll)
826 scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0); 827 scr_scroll_text (screen.tscroll, screen.bscroll, 1, 0);
827 else if (screen.cur.row < (TermWin.nrow - 1)) 828 else if (screen.cur.row < (TermWin.nrow - 1))
828 row = (++screen.cur.row) + TermWin.saveLines; 829 row = (++screen.cur.row) + TermWin.saveLines;
830
829 stp = screen.text[row]; /* _must_ refresh */ 831 stp = screen.text[row]; /* _must_ refresh */
830 srp = screen.rend[row]; /* _must_ refresh */ 832 srp = screen.rend[row]; /* _must_ refresh */
831 continue; 833 continue;
832 case '\r': 834
835 case C0_CR:
833 if (screen.tlen[row] != -1) /* XXX: think about this */ 836 if (screen.tlen[row] != -1) /* XXX: think about this */
834 MAX_IT (screen.tlen[row], screen.cur.col); 837 MAX_IT (screen.tlen[row], screen.cur.col);
838
835 screen.flags &= ~Screen_WrapNext; 839 screen.flags &= ~Screen_WrapNext;
836 screen.cur.col = 0; 840 screen.cur.col = 0;
837 continue; 841 continue;
838 default:
839 if (c == 127)
840 continue; /* yummmm..... */
841 break;
842 } 842 }
843 843
844 if (checksel /* see if we're writing within selection */ 844 if (checksel /* see if we're writing within selection */
845 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 845 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
846 && ROWCOL_IS_BEFORE (screen.cur, selection.end)) 846 && ROWCOL_IS_BEFORE (screen.cur, selection.end))
847 { 847 {
866 if (screen.flags & Screen_Insert) 866 if (screen.flags & Screen_Insert)
867 scr_insdel_chars (1, INSERT); 867 scr_insdel_chars (1, INSERT);
868 868
869 // rely on wcwidth to tell us the character width, at least for non-latin1 869 // rely on wcwidth to tell us the character width, at least for non-latin1
870 // do wcwidth before further replacements, as wcwidth says that line-drawing 870 // do wcwidth before further replacements, as wcwidth says that line-drawing
871 // characters have width -1 (DOH!) on gnu/linux sometimes. 871 // characters have width -1 (DOH!) on GNU/Linux sometimes.
872 int width = c < 256 ? 1 : wcwidth (c); 872 int width = c < 256 ? 1 : wcwidth (c);
873 873
874 if (charsets[screen.charset] == '0') // DEC SPECIAL 874 if (charsets[screen.charset] == '0') // DEC SPECIAL
875 switch (c)
876 { 875 {
877 // vt100 special graphics and line drawing 876 // vt100 special graphics and line drawing
878 case '`': c = 0x25c6; break; case '_': c = 0x0020; break; 877 static uint16_t vt100_0[32] = { // 5f .. 7e
879 case 'a': c = 0x2592; break; case 'b': c = 0x2409; break; case 'c': c = 0x240c; break; 878 0x0020, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0,
880 case 'd': c = 0x240d; break; case 'e': c = 0x240a; break; case 'f': c = 0x00b0; break; 879 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c,
881 case 'g': c = 0x00b1; break; case 'h': c = 0x2424; break; case 'i': c = 0x240b; break; 880 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534,
882 case 'j': c = 0x2518; break; case 'k': c = 0x2510; break; case 'l': c = 0x250c; break; 881 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7,
883 case 'm': c = 0x2514; break; case 'n': c = 0x253c; break; case 'o': c = 0x23ba; break;
884 case 'p': c = 0x23bb; break; case 'q': c = 0x2500; break; case 'r': c = 0x23bc; break;
885 case 's': c = 0x23bd; break; case 't': c = 0x251c; break; case 'u': c = 0x2524; break;
886 case 'v': c = 0x2534; break; case 'w': c = 0x252c; break; case 'x': c = 0x2502; break;
887 case 'y': c = 0x2264; break; case 'z': c = 0x2265; break; case '{': c = 0x03c0; break;
888 case '|': c = 0x2260; break; case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
889 } 882 };
883
884 if (c >= 0x5f && c <= 0x7e)
885 {
886 c = vt100_0[c - 0x5f];
887 width = 1;
888 }
889 }
890 890
891 if (width > 0) 891 if (width > 0)
892 { 892 {
893#if !UNICODE_3 && ENABLE_COMBINING 893#if !UNICODE_3 && ENABLE_COMBINING
894 // trim characters we can't store directly :( 894 // trim characters we can't store directly :(
988 */ 988 */
989void 989void
990rxvt_term::scr_backspace () 990rxvt_term::scr_backspace ()
991{ 991{
992 want_refresh = 1; 992 want_refresh = 1;
993
993 if (screen.cur.col == 0) 994 if (screen.cur.col == 0)
994 { 995 {
995 if (screen.cur.row > 0) 996 if (screen.cur.row > 0)
996 { 997 {
997#ifdef TERMCAP_HAS_BW 998#ifdef TERMCAP_HAS_BW
1002 1003
1003 } 1004 }
1004 } 1005 }
1005 else if ((screen.flags & Screen_WrapNext) == 0) 1006 else if ((screen.flags & Screen_WrapNext) == 0)
1006 scr_gotorc (0, -1, RELATIVE); 1007 scr_gotorc (0, -1, RELATIVE);
1008
1007 screen.flags &= ~Screen_WrapNext; 1009 screen.flags &= ~Screen_WrapNext;
1008} 1010}
1009 1011
1010/* ------------------------------------------------------------------------- */ 1012/* ------------------------------------------------------------------------- */
1011/* 1013/*
1014 * XTERM_SEQ: CTRL-I 1016 * XTERM_SEQ: CTRL-I
1015 */ 1017 */
1016void 1018void
1017rxvt_term::scr_tab (int count) 1019rxvt_term::scr_tab (int count)
1018{ 1020{
1019 int i, x; 1021 int i, x;
1020 1022
1021 D_SCREEN ((stderr, "rxvt_scr_tab (%d)", count)); 1023 D_SCREEN ((stderr, "rxvt_scr_tab (%d)", count));
1022 want_refresh = 1; 1024 want_refresh = 1;
1023 i = x = screen.cur.col; 1025 i = x = screen.cur.col;
1026
1024 if (count == 0) 1027 if (count == 0)
1025 return; 1028 return;
1026 else if (count > 0) 1029 else if (count > 0)
1027 { 1030 {
1028 for (; ++i < TermWin.ncol; ) 1031 for (; ++i < TermWin.ncol; )
1030 { 1033 {
1031 x = i; 1034 x = i;
1032 if (!--count) 1035 if (!--count)
1033 break; 1036 break;
1034 } 1037 }
1038
1035 if (count) 1039 if (count)
1036 x = TermWin.ncol - 1; 1040 x = TermWin.ncol - 1;
1037 } 1041 }
1038 else /* if (count < 0) */ 1042 else /* if (count < 0) */
1039 { 1043 {
1042 { 1046 {
1043 x = i; 1047 x = i;
1044 if (!++count) 1048 if (!++count)
1045 break; 1049 break;
1046 } 1050 }
1051
1047 if (count) 1052 if (count)
1048 x = 0; 1053 x = 0;
1049 } 1054 }
1055
1050 if (x != screen.cur.col) 1056 if (x != screen.cur.col)
1051 scr_gotorc (0, x, R_RELATIVE); 1057 scr_gotorc (0, x, R_RELATIVE);
1052} 1058}
1053 1059
1054/* ------------------------------------------------------------------------- */ 1060/* ------------------------------------------------------------------------- */
1111 want_refresh = 1; 1117 want_refresh = 1;
1112 ZERO_SCROLLBACK (); 1118 ZERO_SCROLLBACK ();
1113 1119
1114 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)); 1120 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));
1115 1121
1116 screen.cur.col = ((relative & C_RELATIVE) ? (screen.cur.col + col) 1122 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1117 : col);
1118 MAX_IT (screen.cur.col, 0); 1123 MAX_IT (screen.cur.col, 0);
1119 MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1); 1124 MIN_IT (screen.cur.col, (int32_t)TermWin.ncol - 1);
1120 1125
1121 screen.flags &= ~Screen_WrapNext; 1126 screen.flags &= ~Screen_WrapNext;
1122 if (relative & R_RELATIVE) 1127 if (relative & R_RELATIVE)
1161 * direction should be UP or DN 1166 * direction should be UP or DN
1162 */ 1167 */
1163void 1168void
1164rxvt_term::scr_index (enum page_dirn direction) 1169rxvt_term::scr_index (enum page_dirn direction)
1165{ 1170{
1166 int dirn; 1171 int dirn;
1167 1172
1168 want_refresh = 1; 1173 want_refresh = 1;
1169 dirn = ((direction == UP) ? 1 : -1); 1174 dirn = ((direction == UP) ? 1 : -1);
1170 D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn)); 1175 D_SCREEN ((stderr, "rxvt_scr_index (%d)", dirn));
1171 1176
1247 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1252 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1248 */ 1253 */
1249void 1254void
1250rxvt_term::scr_erase_screen (int mode) 1255rxvt_term::scr_erase_screen (int mode)
1251{ 1256{
1252 int num; 1257 int num;
1253 int32_t row, row_offset; 1258 int32_t row, row_offset;
1254 rend_t ren; 1259 rend_t ren;
1255 XGCValues gcvalue; 1260 XGCValues gcvalue;
1256 1261
1257 want_refresh = 1; 1262 want_refresh = 1;
1258 D_SCREEN ((stderr, "rxvt_scr_erase_screen (%d) at screen row: %d", mode, screen.cur.row)); 1263 D_SCREEN ((stderr, "rxvt_scr_erase_screen (%d) at screen row: %d", mode, screen.cur.row));
1259 ZERO_SCROLLBACK (); 1264 ZERO_SCROLLBACK ();
1260 row_offset = (int32_t)TermWin.saveLines; 1265 row_offset = (int32_t)TermWin.saveLines;
1279 num = TermWin.nrow; 1284 num = TermWin.nrow;
1280 break; 1285 break;
1281 default: 1286 default:
1282 return; 1287 return;
1283 } 1288 }
1289
1284 refresh_type |= REFRESH_BOUNDS; 1290 refresh_type |= REFRESH_BOUNDS;
1291
1285 if (selection.op && current_screen == selection.screen 1292 if (selection.op && current_screen == selection.screen
1286 && ((selection.beg.row >= row && selection.beg.row <= row + num) 1293 && ((selection.beg.row >= row && selection.beg.row <= row + num)
1287 || (selection.end.row >= row 1294 || (selection.end.row >= row
1288 && selection.end.row <= row + num))) 1295 && selection.end.row <= row + num)))
1289 CLEAR_SELECTION (); 1296 CLEAR_SELECTION ();
1297
1290 if (row >= TermWin.nrow) /* Out Of Bounds */ 1298 if (row >= TermWin.nrow) /* Out Of Bounds */
1291 return; 1299 return;
1300
1292 MIN_IT (num, (TermWin.nrow - row)); 1301 MIN_IT (num, (TermWin.nrow - row));
1302
1293 if (rstyle & (RS_RVid | RS_Uline)) 1303 if (rstyle & (RS_RVid | RS_Uline))
1294 ren = (rend_t) ~RS_None; 1304 ren = (rend_t) ~RS_None;
1295 else if (GET_BASEBG (rstyle) == Color_bg) 1305 else if (GET_BASEBG (rstyle) == Color_bg)
1296 { 1306 {
1297 ren = DEFAULT_RSTYLE; 1307 ren = DEFAULT_RSTYLE;
1304 XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); 1314 XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue);
1305 ERASE_ROWS (row, num); 1315 ERASE_ROWS (row, num);
1306 gcvalue.foreground = PixColors[Color_fg]; 1316 gcvalue.foreground = PixColors[Color_fg];
1307 XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue); 1317 XChangeGC (display->display, TermWin.gc, GCForeground, &gcvalue);
1308 } 1318 }
1319
1309 for (; num--; row++) 1320 for (; num--; row++)
1310 { 1321 {
1311 scr_blank_screen_mem (screen.text, screen.rend, 1322 scr_blank_screen_mem (screen.text, screen.rend,
1312 (unsigned int) (row + row_offset), rstyle); 1323 (unsigned int) (row + row_offset), rstyle);
1313 screen.tlen[row + row_offset] = 0; 1324 screen.tlen[row + row_offset] = 0;
1347 * Insert/Delete <count> lines 1358 * Insert/Delete <count> lines
1348 */ 1359 */
1349void 1360void
1350rxvt_term::scr_insdel_lines (int count, int insdel) 1361rxvt_term::scr_insdel_lines (int count, int insdel)
1351{ 1362{
1352 int end; 1363 int end;
1353 1364
1354 ZERO_SCROLLBACK (); 1365 ZERO_SCROLLBACK ();
1355 1366
1356 selection_check (1); 1367 selection_check (1);
1357 1368
1376 * Insert/Delete <count> characters from the current position 1387 * Insert/Delete <count> characters from the current position
1377 */ 1388 */
1378void 1389void
1379rxvt_term::scr_insdel_chars (int count, int insdel) 1390rxvt_term::scr_insdel_chars (int count, int insdel)
1380{ 1391{
1381 int col, row; 1392 int col, row;
1382 rend_t tr; 1393 rend_t tr;
1383 text_t *stp; 1394 text_t *stp;
1384 rend_t *srp; 1395 rend_t *srp;
1385 int16_t *slp; 1396 int16_t *slp;
1386 1397
1387 want_refresh = 1; 1398 want_refresh = 1;
1388 ZERO_SCROLLBACK (); 1399 ZERO_SCROLLBACK ();
1389 1400
1390 if (count <= 0) 1401 if (count <= 0)
1397 screen.flags &= ~Screen_WrapNext; 1408 screen.flags &= ~Screen_WrapNext;
1398 1409
1399 stp = screen.text[row]; 1410 stp = screen.text[row];
1400 srp = screen.rend[row]; 1411 srp = screen.rend[row];
1401 slp = & (screen.tlen[row]); 1412 slp = & (screen.tlen[row]);
1413
1402 switch (insdel) 1414 switch (insdel)
1403 { 1415 {
1404 case INSERT: 1416 case INSERT:
1405 for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; 1417 for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col;
1406 col--) 1418 col--)
1407 { 1419 {
1408 stp[col] = stp[col - count]; 1420 stp[col] = stp[col - count];
1409 srp[col] = srp[col - count]; 1421 srp[col] = srp[col - count];
1410 } 1422 }
1423
1411 if (*slp != -1) 1424 if (*slp != -1)
1412 { 1425 {
1413 *slp += count; 1426 *slp += count;
1414 MIN_IT (*slp, TermWin.ncol); 1427 MIN_IT (*slp, TermWin.ncol);
1415 } 1428 }
1429
1416 if (selection.op && current_screen == selection.screen 1430 if (selection.op && current_screen == selection.screen
1417 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1431 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1418 { 1432 {
1419 if (selection.end.row != screen.cur.row 1433 if (selection.end.row != screen.cur.row
1420 || (selection.end.col + count >= TermWin.ncol)) 1434 || (selection.end.col + count >= TermWin.ncol))
1424 selection.beg.col += count; 1438 selection.beg.col += count;
1425 selection.mark.col += count; /* XXX: yes? */ 1439 selection.mark.col += count; /* XXX: yes? */
1426 selection.end.col += count; 1440 selection.end.col += count;
1427 } 1441 }
1428 } 1442 }
1443
1429 scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), 1444 scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]),
1430 (unsigned int)count, rstyle); 1445 (unsigned int)count, rstyle);
1431 break; 1446 break;
1447
1432 case ERASE: 1448 case ERASE:
1433 screen.cur.col += count; /* don't worry if > TermWin.ncol */ 1449 screen.cur.col += count; /* don't worry if > TermWin.ncol */
1434 selection_check (1); 1450 selection_check (1);
1435 screen.cur.col -= count; 1451 screen.cur.col -= count;
1436 scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), 1452 scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]),
1437 (unsigned int)count, rstyle); 1453 (unsigned int)count, rstyle);
1438 break; 1454 break;
1455
1439 case DELETE: 1456 case DELETE:
1440 tr = srp[TermWin.ncol - 1]
1441 & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1457 tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask);
1458
1442 for (col = screen.cur.col; (col + count) < TermWin.ncol; col++) 1459 for (col = screen.cur.col; (col + count) < TermWin.ncol; col++)
1443 { 1460 {
1444 stp[col] = stp[col + count]; 1461 stp[col] = stp[col + count];
1445 srp[col] = srp[col + count]; 1462 srp[col] = srp[col + count];
1446 } 1463 }
1464
1447 scr_blank_line (& (stp[TermWin.ncol - count]), 1465 scr_blank_line (& (stp[TermWin.ncol - count]),
1448 & (srp[TermWin.ncol - count]), 1466 & (srp[TermWin.ncol - count]),
1449 (unsigned int)count, tr); 1467 (unsigned int)count, tr);
1468
1450 if (*slp == -1) /* break line continuation */ 1469 if (*slp == -1) /* break line continuation */
1451 *slp = TermWin.ncol; 1470 *slp = TermWin.ncol;
1471
1452 *slp -= count; 1472 *slp -= count;
1453 MAX_IT (*slp, 0); 1473 MAX_IT (*slp, 0);
1474
1454 if (selection.op && current_screen == selection.screen 1475 if (selection.op && current_screen == selection.screen
1455 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) 1476 && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur))
1456 { 1477 {
1457 if (selection.end.row != screen.cur.row 1478 if (selection.end.row != screen.cur.row
1458 || (screen.cur.col >= selection.beg.col - count) 1479 || (screen.cur.col >= selection.beg.col - count)
1464 selection.beg.col -= count; 1485 selection.beg.col -= count;
1465 selection.mark.col -= count; /* XXX: yes? */ 1486 selection.mark.col -= count; /* XXX: yes? */
1466 selection.end.col -= count; 1487 selection.end.col -= count;
1467 } 1488 }
1468 } 1489 }
1490
1469 break; 1491 break;
1470 } 1492 }
1471} 1493}
1472 1494
1473/* ------------------------------------------------------------------------- */ 1495/* ------------------------------------------------------------------------- */
1478void 1500void
1479rxvt_term::scr_scroll_region (int top, int bot) 1501rxvt_term::scr_scroll_region (int top, int bot)
1480{ 1502{
1481 MAX_IT (top, 0); 1503 MAX_IT (top, 0);
1482 MIN_IT (bot, (int)TermWin.nrow - 1); 1504 MIN_IT (bot, (int)TermWin.nrow - 1);
1505
1483 if (top > bot) 1506 if (top > bot)
1484 return; 1507 return;
1508
1485 screen.tscroll = top; 1509 screen.tscroll = top;
1486 screen.bscroll = bot; 1510 screen.bscroll = bot;
1487 scr_gotorc (0, 0, 0); 1511 scr_gotorc (0, 0, 0);
1488} 1512}
1489 1513
1495 */ 1519 */
1496void 1520void
1497rxvt_term::scr_cursor_visible (int mode) 1521rxvt_term::scr_cursor_visible (int mode)
1498{ 1522{
1499 want_refresh = 1; 1523 want_refresh = 1;
1524
1500 if (mode) 1525 if (mode)
1501 screen.flags |= Screen_VisibleCursor; 1526 screen.flags |= Screen_VisibleCursor;
1502 else 1527 else
1503 screen.flags &= ~Screen_VisibleCursor; 1528 screen.flags &= ~Screen_VisibleCursor;
1504} 1529}
1820 if (TermWin.view_start != oldviewstart) 1845 if (TermWin.view_start != oldviewstart)
1821 { 1846 {
1822 want_refresh = 1; 1847 want_refresh = 1;
1823 num_scr -= (TermWin.view_start - oldviewstart); 1848 num_scr -= (TermWin.view_start - oldviewstart);
1824 } 1849 }
1850
1825 return (int) (TermWin.view_start - oldviewstart); 1851 return (int) (TermWin.view_start - oldviewstart);
1826} 1852}
1827 1853
1828/* ------------------------------------------------------------------------- */ 1854/* ------------------------------------------------------------------------- */
1829void 1855void
1947 1973
1948 /* 1974 /*
1949 * C: set the cursor character (s) 1975 * C: set the cursor character (s)
1950 */ 1976 */
1951 { 1977 {
1952 unsigned char setoldcursor; 1978 unsigned char setoldcursor;
1953 rend_t ccol1, /* Cursor colour */ 1979 rend_t ccol1, /* Cursor colour */
1954 ccol2; /* Cursor colour2 */ 1980 ccol2; /* Cursor colour2 */
1955 1981
1956 showcursor = (screen.flags & Screen_VisibleCursor); 1982 showcursor = (screen.flags & Screen_VisibleCursor);
1957#ifdef CURSOR_BLINK 1983#ifdef CURSOR_BLINK
1958 if (hidden_cursor) 1984 if (hidden_cursor)
1959 showcursor = 0; 1985 showcursor = 0;
1960#endif 1986#endif
1961 1987
1962 if (showcursor) 1988 if (showcursor)
1963 { 1989 {
1964 srp = & (screen.rend[screen.cur.row + TermWin.saveLines] 1990 srp = &(screen.rend[screen.cur.row + TermWin.saveLines][screen.cur.col]);
1965 [screen.cur.col]);
1966 1991
1967 if (showcursor && TermWin.focus) 1992 if (showcursor && TermWin.focus)
1968 { 1993 {
1969 *srp ^= RS_RVid; 1994 *srp ^= RS_RVid;
1970#ifndef NO_CURSORCOLOR 1995#ifndef NO_CURSORCOLOR
1998 if (screen.cur.row + TermWin.view_start != ocrow 2023 if (screen.cur.row + TermWin.view_start != ocrow
1999 || screen.cur.col != oldcursor.col) 2024 || screen.cur.col != oldcursor.col)
2000 { 2025 {
2001 if (ocrow < TermWin.nrow 2026 if (ocrow < TermWin.nrow
2002 && oldcursor.col < TermWin.ncol) 2027 && oldcursor.col < TermWin.ncol)
2003 {
2004 drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline); 2028 drawn_rend[ocrow][oldcursor.col] ^= (RS_RVid | RS_Uline);
2005 } 2029
2006 if (TermWin.focus || !showcursor) 2030 if (TermWin.focus || !showcursor)
2007 oldcursor.row = -1; 2031 oldcursor.row = -1;
2008 else 2032 else
2009 setoldcursor = 1; 2033 setoldcursor = 1;
2010 } 2034 }
2011 } 2035 }
2012 else if (!TermWin.focus) 2036 else if (!TermWin.focus)
2013 setoldcursor = 1; 2037 setoldcursor = 1;
2038
2014 if (setoldcursor) 2039 if (setoldcursor)
2015 { 2040 {
2016 if (screen.cur.row + TermWin.view_start >= TermWin.nrow) 2041 if (screen.cur.row + TermWin.view_start >= TermWin.nrow)
2017 oldcursor.row = -1; 2042 oldcursor.row = -1;
2018 else 2043 else
2030 */ 2055 */
2031 i = num_scr; 2056 i = num_scr;
2032 if (refresh_type == FAST_REFRESH && num_scr_allow && i 2057 if (refresh_type == FAST_REFRESH && num_scr_allow && i
2033 && abs (i) < TermWin.nrow && !must_clear) 2058 && abs (i) < TermWin.nrow && !must_clear)
2034 { 2059 {
2035 int16_t nits; 2060 int16_t nits;
2036 int j; 2061 int j;
2037 rend_t *drp2; 2062 rend_t *drp2;
2038 text_t *dtp2; 2063 text_t *dtp2;
2039 int len, wlen; 2064 int len, wlen;
2040 2065
2041 j = TermWin.nrow; 2066 j = TermWin.nrow;
2042 wlen = len = -1; 2067 wlen = len = -1;
2043 row = i > 0 ? 0 : j - 1; 2068 row = i > 0 ? 0 : j - 1;
2044 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2069 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
2496 { 2521 {
2497 n = min (len - i, PROP_SIZE); 2522 n = min (len - i, PROP_SIZE);
2498 MEMCPY (ds, data + i, n); 2523 MEMCPY (ds, data + i, n);
2499 2524
2500 for (j = 0; j < n; j++) 2525 for (j = 0; j < n; j++)
2501 if (ds[j] == '\n') 2526 if (ds[j] == C0_LF)
2502 ds[j] = '\r'; 2527 ds[j] = C0_CR;
2503 2528
2504 tt_write (ds, (int)n); 2529 tt_write (ds, (int)n);
2505 } 2530 }
2506 2531
2507 free (ds); 2532 free (ds);
2620void 2645void
2621rxvt_term::incr_cb (time_watcher &w) 2646rxvt_term::incr_cb (time_watcher &w)
2622{ 2647{
2623 selection_wait = Sel_none; 2648 selection_wait = Sel_none;
2624 2649
2625 rxvt_print_error ("data loss: timeout on INCR selection paste"); 2650 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n");
2626} 2651}
2627 2652
2628/* 2653/*
2629 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> 2654 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za>
2630 */ 2655 */
2709 { 2734 {
2710 int i; 2735 int i;
2711 2736
2712 selection_request_time = tm; 2737 selection_request_time = tm;
2713 selection_wait = Sel_normal; 2738 selection_wait = Sel_normal;
2739
2714 for (i = Sel_Primary; i <= Sel_Clipboard; i++) 2740 for (i = Sel_Primary; i <= Sel_Clipboard; i++)
2715 { 2741 {
2716#if X_HAVE_UTF8_STRING 2742#if X_HAVE_UTF8_STRING
2717 selection_type = Sel_UTF8String; 2743 selection_type = Sel_UTF8String;
2718 if (selection_request_other (xa[XA_UTF8_STRING], i)) 2744 if (selection_request_other (xa[XA_UTF8_STRING], i))
2772 want_refresh = 1; 2798 want_refresh = 1;
2773 free (selection.text); 2799 free (selection.text);
2774 selection.text = NULL; 2800 selection.text = NULL;
2775 selection.len = 0; 2801 selection.len = 0;
2776 CLEAR_SELECTION (); 2802 CLEAR_SELECTION ();
2803
2804 if (display->selection_owner == this)
2805 display->selection_owner = 0;
2777} 2806}
2778 2807
2779/* ------------------------------------------------------------------------- */ 2808/* ------------------------------------------------------------------------- */
2780/* 2809/*
2781 * Copy a selection into the cut buffer 2810 * Copy a selection into the cut buffer
2854 else 2883 else
2855 new_selection_text[ofs++] = *t++; 2884 new_selection_text[ofs++] = *t++;
2856 } 2885 }
2857 2886
2858 if (screen.tlen[row] != -1 && row != end_row) 2887 if (screen.tlen[row] != -1 && row != end_row)
2859 new_selection_text[ofs++] = L'\n'; 2888 new_selection_text[ofs++] = C0_LF;
2860 } 2889 }
2861 2890
2862 if (end_col != selection.end.col) 2891 if (end_col != selection.end.col)
2863 new_selection_text[ofs++] = L'\n'; 2892 new_selection_text[ofs++] = C0_LF;
2864 2893
2865 new_selection_text[ofs] = 0; 2894 new_selection_text[ofs] = 0;
2866 2895
2867 if (ofs == 0) 2896 if (ofs == 0)
2868 { 2897 {
2878 2907
2879 XSetSelectionOwner (display->display, XA_PRIMARY, TermWin.vt, tm); 2908 XSetSelectionOwner (display->display, XA_PRIMARY, TermWin.vt, tm);
2880 if (XGetSelectionOwner (display->display, XA_PRIMARY) == TermWin.vt) 2909 if (XGetSelectionOwner (display->display, XA_PRIMARY) == TermWin.vt)
2881 display->set_selection_owner (this); 2910 display->set_selection_owner (this);
2882 else 2911 else
2883 rxvt_print_error ("can't get primary selection"); 2912 rxvt_warn ("can't get primary selection, ignoring.\n");
2884 2913
2885#if 0 2914#if 0
2886 XTextProperty ct; 2915 XTextProperty ct;
2887 2916
2888 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 2917 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0)
3095 * Extend the selection to the specified col/row 3124 * Extend the selection to the specified col/row
3096 */ 3125 */
3097void 3126void
3098rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) 3127rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange)
3099{ 3128{
3100 int16_t ncol = TermWin.ncol; 3129 int16_t ncol = TermWin.ncol;
3101 int end_col; 3130 int end_col;
3102 row_col_t pos; 3131 row_col_t pos;
3103 enum { 3132 enum {
3104 LEFT, RIGHT 3133 LEFT, RIGHT
3105 } closeto = RIGHT; 3134 } closeto = RIGHT;
3106 3135
3107 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)); 3136 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));
3392 /* TODO: Handle MULTIPLE */ 3421 /* TODO: Handle MULTIPLE */
3393 } 3422 }
3394 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3423 else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
3395 { 3424 {
3396 XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER, 3425 XChangeProperty (display->display, rq.requestor, rq.property, XA_INTEGER,
3397 (8 * sizeof (Time)), PropModeReplace, 3426 (8 * sizeof (Time)), PropModeReplace,
3398 (unsigned char *)&selection_time, 1); 3427 (unsigned char *)&selection_time, 1);
3399 ev.property = rq.property; 3428 ev.property = rq.property;
3400 } 3429 }
3401 else if (rq.target == XA_STRING 3430 else if (rq.target == XA_STRING
3402 || rq.target == xa[XA_TEXT] 3431 || rq.target == xa[XA_TEXT]
3403 || rq.target == xa[XA_COMPOUND_TEXT] 3432 || rq.target == xa[XA_COMPOUND_TEXT]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines