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.148 by root, Mon Dec 13 01:29:03 2004 UTC vs.
Revision 1.156 by root, Fri Feb 4 11:41:23 2005 UTC

294 ralloc->free (drawn_rend[p]); 294 ralloc->free (drawn_rend[p]);
295 } 295 }
296 296
297 /* we have fewer rows so fix up cursor position */ 297 /* we have fewer rows so fix up cursor position */
298 MIN_IT (screen.cur.row, (int32_t)nrow - 1); 298 MIN_IT (screen.cur.row, (int32_t)nrow - 1);
299 MIN_IT (swap.cur.row, (int32_t)nrow - 1);
300 299
301 scr_reset_realloc (); /* realloc _last_ */ 300 scr_reset_realloc (); /* realloc _last_ */
302 } 301 }
303 else if (nrow > prev_nrow) 302 else if (nrow > prev_nrow)
304 { 303 {
335 scr_scroll_text (0, (int)nrow - 1, -k, 1); 334 scr_scroll_text (0, (int)nrow - 1, -k, 1);
336 screen.cur.row += k; 335 screen.cur.row += k;
337 screen.s_cur.row += k; 336 screen.s_cur.row += k;
338 TermWin.nscrolled -= k; 337 TermWin.nscrolled -= k;
339 } 338 }
339
340#ifdef DEBUG_STRICT 340#ifdef DEBUG_STRICT
341 assert (screen.cur.row < TermWin.nrow); 341 assert (screen.cur.row < TermWin.nrow);
342 assert (swap.cur.row < TermWin.nrow);
343#else /* drive with your eyes closed */ 342#else /* drive with your eyes closed */
344
345 MIN_IT (screen.cur.row, nrow - 1); 343 MIN_IT (screen.cur.row, nrow - 1);
346 MIN_IT (swap.cur.row, nrow - 1);
347#endif 344#endif
348 TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this 345 TermWin.ncol = ncol; // save b/c scr_blank_screen_mem uses this
349 } 346 }
350 347
351 /* resize columns */ 348 /* resize columns */
394 } 391 }
395 392
396 } 393 }
397 394
398 MIN_IT (screen.cur.col, (int16_t)ncol - 1); 395 MIN_IT (screen.cur.col, (int16_t)ncol - 1);
399 MIN_IT (swap.cur.col, (int16_t)ncol - 1);
400 396
401 delete talloc; talloc = ta; 397 delete talloc; talloc = ta;
402 delete ralloc; ralloc = ra; 398 delete ralloc; ralloc = ra;
403 } 399 }
404 400
566 if (current_screen == scrn) 562 if (current_screen == scrn)
567 return scrn; 563 return scrn;
568 564
569 selection_check (2); /* check for boundary cross */ 565 selection_check (2); /* check for boundary cross */
570 566
571 SWAP_IT (current_screen, scrn, int); 567 i = current_screen; current_screen = scrn; scrn = i;
572 568
573 SWAP_IT (screen.cur.row, swap.cur.row, int16_t); 569 SWAP_IT (screen.cur.row, swap.cur.row, int16_t);
574 SWAP_IT (screen.cur.col, swap.cur.col, int16_t); 570 SWAP_IT (screen.cur.col, swap.cur.col, int16_t);
575# ifdef DEBUG_STRICT
576 assert (screen.cur.row >= 0 && screen.cur.row < prev_nrow);
577 assert (screen.cur.col >= 0 && screen.cur.col < prev_ncol);
578# else /* drive with your eyes closed */
579 MAX_IT (screen.cur.row, 0); 571 MAX_IT (screen.cur.row, 0);
580 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1); 572 MIN_IT (screen.cur.row, (int32_t)prev_nrow - 1);
581 MAX_IT (screen.cur.col, 0); 573 MAX_IT (screen.cur.col, 0);
582 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1); 574 MIN_IT (screen.cur.col, (int32_t)prev_ncol - 1);
583# endif
584 575
585#if NSCREENS 576#if NSCREENS
586 if (options & Opt_secondaryScreen) 577 if (options & Opt_secondaryScreen)
587 { 578 {
588 num_scr = 0; 579 num_scr = 0;
2400 else 2391 else
2401 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back); 2392 font->draw (*TermWin.drawable, xpixel, ypixel, text, count, fore, back);
2402 2393
2403 if (rend & RS_Uline && font->descent > 1 && fore != back) 2394 if (rend & RS_Uline && font->descent > 1 && fore != back)
2404 { 2395 {
2396#if ENABLE_FRILLS
2397 if (ISSET_PIXCOLOR (Color_underline))
2398 XSetForeground (display->display, TermWin.gc, pix_colors[Color_underline]);
2399 else
2400#endif
2405 XSetForeground (display->display, TermWin.gc, pix_colors[fore]); 2401 XSetForeground (display->display, TermWin.gc, pix_colors[fore]);
2402
2406 XDrawLine (display->display, drawBuffer, TermWin.gc, 2403 XDrawLine (display->display, drawBuffer, TermWin.gc,
2407 xpixel, ypixel + font->ascent + 1, 2404 xpixel, ypixel + font->ascent + 1,
2408 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2405 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2409 } 2406 }
2410 } /* for (col....) */ 2407 } /* for (col....) */
2656/* ------------------------------------------------------------------------- */ 2653/* ------------------------------------------------------------------------- */
2657/* 2654/*
2658 * Paste a selection direct to the command fd 2655 * Paste a selection direct to the command fd
2659 */ 2656 */
2660void 2657void
2661rxvt_term::paste (const unsigned char *data, unsigned int len) 2658rxvt_term::paste (unsigned char *data, unsigned int len)
2662{ 2659{
2663 unsigned int i, j, n;
2664 unsigned char *ds = (unsigned char *)rxvt_malloc (PASTE_SIZE);
2665
2666 /* convert normal newline chars into common keyboard Return key sequence */ 2660 /* convert normal newline chars into common keyboard Return key sequence */
2667 for (i = 0; i < len; i += PASTE_SIZE) 2661 for (unsigned int i = 0; i < len; i++)
2668 {
2669 n = min (len - i, PASTE_SIZE);
2670 memcpy (ds, data + i, n);
2671
2672 for (j = 0; j < n; j++)
2673 if (ds[j] == C0_LF) 2662 if (data[i] == C0_LF)
2674 ds[j] = C0_CR; 2663 data[i] = C0_CR;
2675 2664
2676 tt_write (ds, (int)n); 2665 tt_write (data, len);
2677 }
2678
2679 free (ds);
2680} 2666}
2681 2667
2682/* ------------------------------------------------------------------------- */ 2668/* ------------------------------------------------------------------------- */
2683/* 2669/*
2684 * Respond to a notification that a primary selection has been sent 2670 * Respond to a notification that a primary selection has been sent
2714 2700
2715 unsigned long bytes_after; 2701 unsigned long bytes_after;
2716 XTextProperty ct; 2702 XTextProperty ct;
2717 2703
2718 if (XGetWindowProperty (display->display, win, prop, 2704 if (XGetWindowProperty (display->display, win, prop,
2719 0, (long)(PROP_SIZE / 4), 2705 0, PROP_SIZE / 4,
2720 delete_prop, AnyPropertyType, 2706 delete_prop, AnyPropertyType,
2721 &ct.encoding, &ct.format, 2707 &ct.encoding, &ct.format,
2722 &ct.nitems, &bytes_after, 2708 &ct.nitems, &bytes_after,
2723 &ct.value) != Success) 2709 &ct.value) != Success)
2724 { 2710 {
2731 2717
2732 if (bytes_after) 2718 if (bytes_after)
2733 { 2719 {
2734 // fetch and append remaining data 2720 // fetch and append remaining data
2735 XTextProperty ct2; 2721 XTextProperty ct2;
2736 unsigned long bytes_after2;
2737 2722
2738 if (XGetWindowProperty (display->display, win, prop, 2723 if (XGetWindowProperty (display->display, win, prop,
2739 ct.nitems / 4, (long) (bytes_after + 3) / 4, 2724 ct.nitems / 4, (bytes_after + 3) / 4,
2740 delete_prop, AnyPropertyType, 2725 delete_prop, AnyPropertyType,
2741 &ct2.encoding, &ct2.format, 2726 &ct2.encoding, &ct2.format,
2742 &ct2.nitems, &bytes_after2, 2727 &ct2.nitems, &bytes_after,
2743 &ct2.value) != Success) 2728 &ct2.value) != Success)
2744 goto bailout; 2729 goto bailout;
2745 2730
2746 // realloc should be compatible to XFree, here, and elsewhere, too 2731 // realloc should be compatible to XFree, here, and elsewhere, too
2747 ct.value = (unsigned char *)realloc (ct.value, ct.nitems + bytes_after); 2732 ct.value = (unsigned char *)realloc (ct.value, ct.nitems + ct2.nitems + 1);
2748 memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems); 2733 memcpy (ct.value + ct.nitems, ct2.value, ct2.nitems + 1);
2749 ct.nitems += ct2.nitems; 2734 ct.nitems += ct2.nitems;
2750 2735
2751 XFree (ct2.value); 2736 XFree (ct2.value);
2752 } 2737 }
2753 else if (delete_prop)
2754 XDeleteProperty (display->display, win, prop);
2755 2738
2756 if (ct.value == 0) 2739 if (ct.value == 0)
2757 goto bailout; 2740 goto bailout;
2758 2741
2759 if (ct.encoding == xa[XA_INCR]) 2742 if (ct.encoding == xa[XA_INCR])
3426 selection_delimit_word (DN, &selection.end, &selection.end); 3409 selection_delimit_word (DN, &selection.end, &selection.end);
3427 } 3410 }
3428 else if (selection.clicks == 3) 3411 else if (selection.clicks == 3)
3429 { 3412 {
3430#if ENABLE_FRILLS 3413#if ENABLE_FRILLS
3431 if ((options & Opt_tripleclickwords)) 3414 if (options & Opt_tripleclickwords)
3432 { 3415 {
3433 int end_row; 3416 int end_row;
3434 3417
3435 selection_delimit_word (UP, &selection.beg, &selection.beg); 3418 selection_delimit_word (UP, &selection.beg, &selection.beg);
3436 end_row = screen.tlen[selection.mark.row + TermWin.saveLines]; 3419 end_row = screen.tlen[selection.mark.row + TermWin.saveLines];
3454 if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) 3437 if (ROWCOL_IS_AFTER (selection.mark, selection.beg))
3455 selection.mark.col++; 3438 selection.mark.col++;
3456 3439
3457 selection.beg.col = 0; 3440 selection.beg.col = 0;
3458 selection.end.col = ncol; 3441 selection.end.col = ncol;
3442
3443 // select a complete logical line
3444 while (selection.beg.row > -TermWin.saveLines
3445 && screen.tlen[selection.beg.row - 1 + TermWin.saveLines] == -1)
3446 selection.beg.row--;
3447
3448 while (selection.end.row < TermWin.nrow
3449 && screen.tlen[selection.end.row + TermWin.saveLines] == -1)
3450 selection.end.row++;
3459 } 3451 }
3460 } 3452 }
3461 3453
3462 if (button3 && buttonpress) 3454 if (button3 && buttonpress)
3463 { /* mark may need to be changed */ 3455 { /* mark may need to be changed */
3543 */ 3535 */
3544void 3536void
3545rxvt_term::selection_send (const XSelectionRequestEvent &rq) 3537rxvt_term::selection_send (const XSelectionRequestEvent &rq)
3546{ 3538{
3547 XSelectionEvent ev; 3539 XSelectionEvent ev;
3540 dDisp;
3548 3541
3549 ev.type = SelectionNotify; 3542 ev.type = SelectionNotify;
3550 ev.property = None; 3543 ev.property = None;
3551 ev.display = rq.display; 3544 ev.display = rq.display;
3552 ev.requestor = rq.requestor; 3545 ev.requestor = rq.requestor;
3566 *target++ = xa[XA_COMPOUND_TEXT]; 3559 *target++ = xa[XA_COMPOUND_TEXT];
3567#if X_HAVE_UTF8_STRING 3560#if X_HAVE_UTF8_STRING
3568 *target++ = xa[XA_UTF8_STRING]; 3561 *target++ = xa[XA_UTF8_STRING];
3569#endif 3562#endif
3570 3563
3571 XChangeProperty (display->display, rq.requestor, rq.property, XA_ATOM, 3564 XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM,
3572 32, PropModeReplace, 3565 32, PropModeReplace,
3573 (unsigned char *)target_list, target - target_list); 3566 (unsigned char *)target_list, target - target_list);
3574 ev.property = rq.property; 3567 ev.property = rq.property;
3575 } 3568 }
3576#if TODO // TODO 3569#if TODO // TODO
3579 /* TODO: Handle MULTIPLE */ 3572 /* TODO: Handle MULTIPLE */
3580 } 3573 }
3581#endif 3574#endif
3582 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3575 else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
3583 { 3576 {
3584 XChangeProperty (display->display, rq.requestor, rq.property, rq.target, 3577 XChangeProperty (disp, rq.requestor, rq.property, rq.target,
3585 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3578 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3586 ev.property = rq.property; 3579 ev.property = rq.property;
3587 } 3580 }
3588 else if (rq.target == XA_STRING 3581 else if (rq.target == XA_STRING
3589 || rq.target == xa[XA_TEXT] 3582 || rq.target == xa[XA_TEXT]
3647 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); 3640 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen);
3648 ct.nitems = strlen ((char *)ct.value); 3641 ct.nitems = strlen ((char *)ct.value);
3649 } 3642 }
3650 else 3643 else
3651#endif 3644#endif
3652 if (XwcTextListToTextProperty (display->display, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) 3645 if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
3653 freect = 1; 3646 freect = 1;
3654 else 3647 else
3655 { 3648 {
3656 /* if we failed to convert then send it raw */ 3649 /* if we failed to convert then send it raw */
3657 ct.value = (unsigned char *)cl; 3650 ct.value = (unsigned char *)cl;
3658 ct.nitems = selectlen; 3651 ct.nitems = selectlen;
3659 ct.encoding = target; 3652 ct.encoding = target;
3660 } 3653 }
3661 3654
3662 XChangeProperty (display->display, rq.requestor, rq.property, 3655 XChangeProperty (disp, rq.requestor, rq.property,
3663 ct.encoding, 8, PropModeReplace, 3656 ct.encoding, 8, PropModeReplace,
3664 ct.value, (int)ct.nitems); 3657 ct.value, (int)ct.nitems);
3665 ev.property = rq.property; 3658 ev.property = rq.property;
3666 3659
3667 if (freect) 3660 if (freect)
3668 XFree (ct.value); 3661 XFree (ct.value);
3669 } 3662 }
3670 3663
3671 XSendEvent (display->display, rq.requestor, False, 0L, (XEvent *)&ev); 3664 XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev);
3672} 3665}
3673 3666
3674/* ------------------------------------------------------------------------- * 3667/* ------------------------------------------------------------------------- *
3675 * MOUSE ROUTINES * 3668 * MOUSE ROUTINES *
3676 * ------------------------------------------------------------------------- */ 3669 * ------------------------------------------------------------------------- */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines