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.129 by root, Wed Aug 25 03:52:09 2004 UTC vs.
Revision 1.136 by root, Tue Sep 7 21:05:41 2004 UTC

989 989
990 if (screen.cur.col > 0) 990 if (screen.cur.col > 0)
991 { 991 {
992 tp = stp + screen.cur.col - 1; 992 tp = stp + screen.cur.col - 1;
993 rp = srp + screen.cur.col - 1; 993 rp = srp + screen.cur.col - 1;
994
995 while (*tp == NOCHAR && tp > stp)
996 tp--, rp--;
994 } 997 }
995 else if (screen.cur.row > 0 998 else if (screen.cur.row > 0
996 && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1) 999 && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1)
997 { 1000 {
998 tp = screen.text[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1; 1001 int line = screen.cur.row - 1 + TermWin.saveLines;
999 rp = screen.rend[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1; 1002
1003 tp = screen.text[line] + last_col - 1;
1004 rp = screen.rend[line] + last_col - 1;
1005
1006 while (*tp == NOCHAR && tp > screen.text[line])
1007 tp--, rp--;
1000 } 1008 }
1001 else 1009 else
1002 continue; 1010 continue;
1003
1004 // handle double-width-chars by making them look extremely ugly
1005 if (*tp == NOCHAR)
1006 {
1007 // hack //D //TODO //--tp, --rp;
1008 *tp = ' ';
1009 *rp &= ~RS_baseattrMask;
1010 *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp));
1011 }
1012 1011
1013 // first try to find a precomposed character 1012 // first try to find a precomposed character
1014 unicode_t n = rxvt_compose (*tp, c); 1013 unicode_t n = rxvt_compose (*tp, c);
1015 if (n == NOCHAR) 1014 if (n == NOCHAR)
1016 n = rxvt_composite.compose (*tp, c); 1015 n = rxvt_composite.compose (*tp, c);
1487 slp = &screen.tlen[row]; 1486 slp = &screen.tlen[row];
1488 1487
1489 switch (insdel) 1488 switch (insdel)
1490 { 1489 {
1491 case INSERT: 1490 case INSERT:
1492 for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; 1491 for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; col--)
1493 col--)
1494 { 1492 {
1495 stp[col] = stp[col - count]; 1493 stp[col] = stp[col - count];
1496 srp[col] = srp[col - count]; 1494 srp[col] = srp[col - count];
1497 } 1495 }
1498 1496
1508 if (selection.end.row != screen.cur.row 1506 if (selection.end.row != screen.cur.row
1509 || (selection.end.col + count >= TermWin.ncol)) 1507 || (selection.end.col + count >= TermWin.ncol))
1510 CLEAR_SELECTION (); 1508 CLEAR_SELECTION ();
1511 else 1509 else
1512 { /* shift selection */ 1510 { /* shift selection */
1513 selection.beg.col += count; 1511 selection.beg.col += count;
1514 selection.mark.col += count; /* XXX: yes? */ 1512 selection.mark.col += count; /* XXX: yes? */
1515 selection.end.col += count; 1513 selection.end.col += count;
1516 } 1514 }
1517 } 1515 }
1518 1516
1519 scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), 1517 scr_blank_line (&stp[screen.cur.col], &srp[screen.cur.col],
1520 (unsigned int)count, rstyle); 1518 (unsigned int)count, rstyle);
1521 break; 1519 break;
1522 1520
1523 case ERASE: 1521 case ERASE:
1524 screen.cur.col += count; /* don't worry if > TermWin.ncol */ 1522 screen.cur.col += count; /* don't worry if > TermWin.ncol */
1525 selection_check (1); 1523 selection_check (1);
1526 screen.cur.col -= count; 1524 screen.cur.col -= count;
1527 scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), 1525 scr_blank_line (&stp[screen.cur.col], &srp[screen.cur.col],
1528 (unsigned int)count, rstyle); 1526 (unsigned int)count, rstyle);
1529 break; 1527 break;
1530 1528
1531 case DELETE: 1529 case DELETE:
1532 tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); 1530 tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask);
1535 { 1533 {
1536 stp[col] = stp[col + count]; 1534 stp[col] = stp[col + count];
1537 srp[col] = srp[col + count]; 1535 srp[col] = srp[col + count];
1538 } 1536 }
1539 1537
1540 scr_blank_line (& (stp[TermWin.ncol - count]), 1538 scr_blank_line (&stp[TermWin.ncol - count], &srp[TermWin.ncol - count],
1541 & (srp[TermWin.ncol - count]),
1542 (unsigned int)count, tr); 1539 (unsigned int)count, tr);
1543 1540
1544 if (*slp == -1) /* break line continuation */ 1541 if (*slp == -1) /* break line continuation */
1545 *slp = TermWin.ncol; 1542 *slp = TermWin.ncol;
1546 1543
1555 || selection.end.col >= TermWin.ncol) 1552 || selection.end.col >= TermWin.ncol)
1556 CLEAR_SELECTION (); 1553 CLEAR_SELECTION ();
1557 else 1554 else
1558 { 1555 {
1559 /* shift selection */ 1556 /* shift selection */
1560 selection.beg.col -= count; 1557 selection.beg.col -= count;
1561 selection.mark.col -= count; /* XXX: yes? */ 1558 selection.mark.col -= count; /* XXX: yes? */
1562 selection.end.col -= count; 1559 selection.end.col -= count;
1563 } 1560 }
1564 } 1561 }
1565 1562
1566 break; 1563 break;
1567 } 1564 }
1751 * XTERM_SEQ: Invoke G2 character set: ESC N 1748 * XTERM_SEQ: Invoke G2 character set: ESC N
1752 * XTERM_SEQ: Invoke G3 character set: ESC O 1749 * XTERM_SEQ: Invoke G3 character set: ESC O
1753 */ 1750 */
1754void 1751void
1755rxvt_term::scr_charset_choose (int set) 1752rxvt_term::scr_charset_choose (int set)
1756 { 1753{
1757 screen.charset = set; 1754 screen.charset = set;
1758 set_font_style (); 1755 set_font_style ();
1759 } 1756}
1760 1757
1761/* ------------------------------------------------------------------------- */ 1758/* ------------------------------------------------------------------------- */
1762/* 1759/*
1763 * Set a font 1760 * Set a font
1764 * XTERM_SEQ: Set G0 character set: ESC ( <C> 1761 * XTERM_SEQ: Set G0 character set: ESC ( <C>
1767 * XTERM_SEQ: Set G3 character set: ESC + <C> 1764 * XTERM_SEQ: Set G3 character set: ESC + <C>
1768 * See set_font_style for possible values for <C> 1765 * See set_font_style for possible values for <C>
1769 */ 1766 */
1770void 1767void
1771rxvt_term::scr_charset_set (int set, unsigned int ch) 1768rxvt_term::scr_charset_set (int set, unsigned int ch)
1772 { 1769{
1773 charsets[set] = (unsigned char)ch; 1770 charsets[set] = (unsigned char)ch;
1774 set_font_style (); 1771 set_font_style ();
1775 } 1772}
1776 1773
1777 1774
1778/* ------------------------------------------------------------------------- * 1775/* ------------------------------------------------------------------------- *
1779 * MAJOR SCREEN MANIPULATION * 1776 * MAJOR SCREEN MANIPULATION *
1780 * ------------------------------------------------------------------------- */ 1777 * ------------------------------------------------------------------------- */
2035 row_offset; /* basic offset in screen structure */ 2032 row_offset; /* basic offset in screen structure */
2036#ifndef NO_CURSORCOLOR 2033#ifndef NO_CURSORCOLOR
2037 rend_t cc1; /* store colours at cursor position (s) */ 2034 rend_t cc1; /* store colours at cursor position (s) */
2038#endif 2035#endif
2039 rend_t *crp; // cursor rendition pointer 2036 rend_t *crp; // cursor rendition pointer
2037
2038 want_refresh = 0; /* screen is current */
2040 2039
2041 if (refresh_type == NO_REFRESH || !TermWin.mapped) 2040 if (refresh_type == NO_REFRESH || !TermWin.mapped)
2042 return; 2041 return;
2043 2042
2044 /* 2043 /*
2447 if (refresh_type & SMOOTH_REFRESH) 2446 if (refresh_type & SMOOTH_REFRESH)
2448 XFlush (display->display); 2447 XFlush (display->display);
2449 2448
2450 num_scr = 0; 2449 num_scr = 0;
2451 num_scr_allow = 1; 2450 num_scr_allow = 1;
2452 want_refresh = 0; /* screen is current */
2453} 2451}
2454 2452
2455void 2453void
2456rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp) 2454rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp)
2457{ 2455{
2544 int end_row = TermWin.saveLines - TermWin.view_start; 2542 int end_row = TermWin.saveLines - TermWin.view_start;
2545 int i = selection.beg.row + TermWin.saveLines; 2543 int i = selection.beg.row + TermWin.saveLines;
2546 int col, row = selection.end.row + TermWin.saveLines; 2544 int col, row = selection.end.row + TermWin.saveLines;
2547 rend_t *srp; 2545 rend_t *srp;
2548 2546
2549 if (i >= end_row) 2547#if ENABLE_FRILLS
2550 col = selection.beg.col; 2548 if (selection.rect)
2549 {
2550 end_row += TermWin.nrow;
2551
2552 for (; i <= row && i <= end_row; i++)
2553 for (srp = screen.rend[i], col = selection.beg.col; col < selection.end.col; col++)
2554 srp[col] ^= RS_RVid;
2555 }
2551 else 2556 else
2557#endif
2558 {
2559 if (i >= end_row)
2560 col = selection.beg.col;
2561 else
2552 { 2562 {
2553 col = 0; 2563 col = 0;
2554 i = end_row; 2564 i = end_row;
2555 } 2565 }
2556 2566
2557 end_row += TermWin.nrow; 2567 end_row += TermWin.nrow;
2568
2558 for (; i < row && i < end_row; i++, col = 0) 2569 for (; i < row && i < end_row; i++, col = 0)
2559 for (srp = screen.rend[i]; col < TermWin.ncol; col++) 2570 for (srp = screen.rend[i]; col < TermWin.ncol; col++)
2560 srp[col] ^= RS_RVid; 2571 srp[col] ^= RS_RVid;
2561 2572
2562 if (i == row && i < end_row) 2573 if (i == row && i < end_row)
2563 for (srp = screen.rend[i]; col < selection.end.col; col++) 2574 for (srp = screen.rend[i]; col < selection.end.col; col++)
2564 srp[col] ^= RS_RVid; 2575 srp[col] ^= RS_RVid;
2576 }
2565 } 2577 }
2566} 2578}
2567 2579
2568/* ------------------------------------------------------------------------- */ 2580/* ------------------------------------------------------------------------- */
2569/* 2581/*
2919 2931
2920 i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1); 2932 i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1);
2921 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); 2933 new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t));
2922 2934
2923 col = selection.beg.col; 2935 col = selection.beg.col;
2924 MAX_IT (col, 0);
2925 row = selection.beg.row + TermWin.saveLines; 2936 row = selection.beg.row + TermWin.saveLines;
2926 end_row = selection.end.row + TermWin.saveLines; 2937 end_row = selection.end.row + TermWin.saveLines;
2927 int ofs = 0; 2938 int ofs = 0;
2928 int extra = 0; 2939 int extra = 0;
2929 2940
2930 for (; row <= end_row; row++, col = 0) 2941 for (; row <= end_row; row++, col = 0)
2931 { 2942 {
2932 t = &screen.text[row][col];
2933
2934 end_col = screen.tlen[row]; 2943 end_col = screen.tlen[row];
2944
2945#if ENABLE_FRILLS
2946 if (selection.rect)
2947 {
2948 col = selection.beg.col;
2949 end_col = TermWin.ncol + 1;
2950 }
2951#endif
2952
2953 MAX_IT (col, 0);
2935 2954
2936 if (end_col == -1) 2955 if (end_col == -1)
2937 end_col = TermWin.ncol; 2956 end_col = TermWin.ncol;
2938 2957
2939 if (row == end_row) 2958 if (row == end_row || selection.rect)
2940 MIN_IT (end_col, selection.end.col); 2959 MIN_IT (end_col, selection.end.col);
2941 2960
2961 t = &screen.text[row][col];
2942 for (; col < end_col; col++) 2962 for (; col < end_col; col++)
2943 { 2963 {
2944 if (*t == NOCHAR) 2964 if (*t == NOCHAR)
2945 t++; 2965 t++;
2946#if ENABLE_COMBINING 2966#if ENABLE_COMBINING
3206 enum { 3226 enum {
3207 LEFT, RIGHT 3227 LEFT, RIGHT
3208 } closeto = RIGHT; 3228 } closeto = RIGHT;
3209 3229
3210 want_refresh = 1; 3230 want_refresh = 1;
3231
3211 switch (selection.op) 3232 switch (selection.op)
3212 { 3233 {
3213 case SELECTION_INIT: 3234 case SELECTION_INIT:
3214 CLEAR_SELECTION (); 3235 CLEAR_SELECTION ();
3215 selection.op = SELECTION_BEGIN; 3236 selection.op = SELECTION_BEGIN;
3228 selection_start_colrow (col, row); 3249 selection_start_colrow (col, row);
3229 /* FALLTHROUGH */ 3250 /* FALLTHROUGH */
3230 default: 3251 default:
3231 return; 3252 return;
3232 } 3253 }
3254
3233 if (selection.beg.col == selection.end.col 3255 if (selection.beg.col == selection.end.col
3234 && selection.beg.col != selection.mark.col 3256 && selection.beg.col != selection.mark.col
3235 && selection.beg.row == selection.end.row 3257 && selection.beg.row == selection.end.row
3236 && selection.beg.row != selection.mark.row) 3258 && selection.beg.row != selection.mark.row)
3237 { 3259 {
3287 } 3309 }
3288 else 3310 else
3289 { /* button1 drag or button3 drag */ 3311 { /* button1 drag or button3 drag */
3290 if (ROWCOL_IS_AFTER (selection.mark, pos)) 3312 if (ROWCOL_IS_AFTER (selection.mark, pos))
3291 { 3313 {
3292 if ((selection.mark.row == selection.end.row) 3314 if (selection.mark.row == selection.end.row
3293 && (selection.mark.col == selection.end.col) 3315 && selection.mark.col == selection.end.col
3316 && clickchange
3294 && clickchange && selection.clicks == 2) 3317 && selection.clicks == 2)
3295 selection.mark.col--; 3318 selection.mark.col--;
3296 3319
3297 selection.beg.row = pos.row; 3320 selection.beg.row = pos.row;
3298 selection.beg.col = pos.col; 3321 selection.beg.col = pos.col;
3299 selection.end.row = selection.mark.row; 3322 selection.end.row = selection.mark.row;
3310 3333
3311 if (selection.clicks == 1) 3334 if (selection.clicks == 1)
3312 { 3335 {
3313 end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; 3336 end_col = screen.tlen[selection.beg.row + TermWin.saveLines];
3314 3337
3315 if (end_col != -1 && selection.beg.col > end_col) 3338 if (selection.beg.col > end_col
3339 && end_col != -1
3340#if ENABLE_FRILLS
3341 && !selection.rect
3342#endif
3316 { 3343 )
3317#if 1
3318 selection.beg.col = ncol; 3344 selection.beg.col = ncol;
3319#else
3320 if (selection.beg.row != selection.end.row)
3321 selection.beg.col = ncol;
3322 else
3323 selection.beg.col = selection.mark.col;
3324#endif
3325 }
3326 3345
3327 end_col = screen.tlen[selection.end.row + TermWin.saveLines]; 3346 end_col = screen.tlen[selection.end.row + TermWin.saveLines];
3328 3347
3329 if (end_col != -1 && selection.end.col > end_col) 3348 if (
3349 selection.end.col > end_col
3350 && end_col != -1
3351#if ENABLE_FRILLS
3352 && !selection.rect
3353#endif
3354 )
3330 selection.end.col = ncol; 3355 selection.end.col = ncol;
3331 } 3356 }
3332 else if (selection.clicks == 2) 3357 else if (selection.clicks == 2)
3333 { 3358 {
3334 if (ROWCOL_IS_AFTER (selection.end, selection.beg)) 3359 if (ROWCOL_IS_AFTER (selection.end, selection.beg))
3335 selection.end.col--; 3360 selection.end.col--;
3336 3361
3337 selection_delimit_word (UP, & (selection.beg), & (selection.beg));
3338 selection_delimit_word (DN, & (selection.end), & (selection.end)); 3362 selection_delimit_word (UP, &selection.beg, &selection.beg);
3363 selection_delimit_word (DN, &selection.end, &selection.end);
3339 } 3364 }
3340 else if (selection.clicks == 3) 3365 else if (selection.clicks == 3)
3341 { 3366 {
3342#if ENABLE_FRILLS 3367#if ENABLE_FRILLS
3343 if ((options & Opt_tripleclickwords)) 3368 if ((options & Opt_tripleclickwords))
3363 else 3388 else
3364#endif 3389#endif
3365 { 3390 {
3366 if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) 3391 if (ROWCOL_IS_AFTER (selection.mark, selection.beg))
3367 selection.mark.col++; 3392 selection.mark.col++;
3393
3368 selection.beg.col = 0; 3394 selection.beg.col = 0;
3369 selection.end.col = ncol; 3395 selection.end.col = ncol;
3370 } 3396 }
3371 } 3397 }
3372 3398
3381 { 3407 {
3382 selection.mark.row = selection.beg.row; 3408 selection.mark.row = selection.beg.row;
3383 selection.mark.col = selection.beg.col; 3409 selection.mark.col = selection.beg.col;
3384 } 3410 }
3385 } 3411 }
3386}
3387 3412
3388#if ENABLE_FRILLS 3413#if ENABLE_FRILLS
3414 if (selection.rect && selection.beg.col > selection.end.col)
3415 SWAP_IT (selection.beg.col, selection.end.col, int);
3416#endif
3417}
3418
3419#if ENABLE_FRILLS
3389void 3420void
3390rxvt_term::selection_remove_trailing_spaces () 3421rxvt_term::selection_remove_trailing_spaces ()
3391{ 3422{
3392 int32_t end_col, end_row; 3423 int32_t end_col, end_row;
3393 text_t *stp; 3424 text_t *stp;
3394 3425
3395 end_col = selection.end.col; 3426 end_col = selection.end.col;
3396 end_row = selection.end.row; 3427 end_row = selection.end.row;
3428
3397 for ( ; end_row >= selection.beg.row; ) 3429 for ( ; end_row >= selection.beg.row; )
3398 { 3430 {
3399 stp = screen.text[end_row + TermWin.saveLines]; 3431 stp = screen.text[end_row + TermWin.saveLines];
3432
3400 while (--end_col >= 0) 3433 while (--end_col >= 0)
3401 { 3434 {
3402 if (stp[end_col] != ' ' && stp[end_col] != '\t') 3435 if (stp[end_col] != ' '
3436 && stp[end_col] != '\t'
3437 && stp[end_col] != NOCHAR)
3403 break; 3438 break;
3404 } 3439 }
3440
3405 if (end_col >= 0 3441 if (end_col >= 0
3406 || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) 3442 || screen.tlen[end_row - 1 + TermWin.saveLines] != -1)
3407 { 3443 {
3408 selection.end.col = end_col + 1; 3444 selection.end.col = end_col + 1;
3409 selection.end.row = end_row; 3445 selection.end.row = end_row;
3410 break; 3446 break;
3411 } 3447 }
3448
3412 end_row--; 3449 end_row--;
3413 end_col = TermWin.ncol; 3450 end_col = TermWin.ncol;
3414 } 3451 }
3452
3415 if (selection.mark.row > selection.end.row) 3453 if (selection.mark.row > selection.end.row)
3416 { 3454 {
3417 selection.mark.row = selection.end.row; 3455 selection.mark.row = selection.end.row;
3418 selection.mark.col = selection.end.col; 3456 selection.mark.col = selection.end.col;
3419 } 3457 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines