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.251 by root, Wed Jan 25 21:03:04 2006 UTC vs.
Revision 1.298 by ayin, Sun Jan 20 14:12:39 2008 UTC

1/*--------------------------------*-C-*--------------------------------------* 1/*---------------------------------------------------------------------------*
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-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
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#include "rxvtperl.h" /* NECESSARY */
30 30
31#include <X11/Xmd.h> /* get the typedef for CARD32 */
32
33#include <inttypes.h> 31#include <inttypes.h>
34 32
35#include "salloc.C" // HACK, should be a seperate compile! 33#include "salloc.C" // HACK, should be a seperate compile!
36 34
37inline void fill_text (text_t *start, text_t value, int len) 35static inline void fill_text (text_t *start, text_t value, int len)
38{ 36{
39 while (len--) 37 while (len--)
40 *start++ = value; 38 *start++ = value;
41} 39}
42 40
47 45
48/* ------------------------------------------------------------------------- * 46/* ------------------------------------------------------------------------- *
49 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * 47 * GENERAL SCREEN AND SELECTION UPDATE ROUTINES *
50 * ------------------------------------------------------------------------- */ 48 * ------------------------------------------------------------------------- */
51#define ZERO_SCROLLBACK() \ 49#define ZERO_SCROLLBACK() \
52 if (OPTION (Opt_scrollTtyOutput)) \ 50 if (option (Opt_scrollTtyOutput)) \
53 view_start = 0 51 view_start = 0
54#define CLEAR_SELECTION() \ 52#define CLEAR_SELECTION() \
55 selection.beg.row = selection.beg.col \ 53 selection.beg.row = selection.beg.col \
56 = selection.end.row = selection.end.col = 0 54 = selection.end.row = selection.end.col = 0
57#define CLEAR_ALL_SELECTION() \ 55#define CLEAR_ALL_SELECTION() \
93 */ 91 */
94#define drawBuffer vt 92#define drawBuffer vt
95 93
96#define CLEAR_ROWS(row, num) \ 94#define CLEAR_ROWS(row, num) \
97 if (mapped) \ 95 if (mapped) \
98 XClearArea (display->display, drawBuffer, 0, \ 96 XClearArea (dpy, drawBuffer, 0, \
99 Row2Pixel (row), (unsigned int)width, \ 97 Row2Pixel (row), (unsigned int)width, \
100 (unsigned int)Height2Pixel (num), False) 98 (unsigned int)Height2Pixel (num), False)
101 99
102#define CLEAR_CHARS(x, y, num) \ 100#define CLEAR_CHARS(x, y, num) \
103 if (mapped) \ 101 if (mapped) \
104 XClearArea (display->display, drawBuffer, x, y, \ 102 XClearArea (dpy, drawBuffer, x, y, \
105 (unsigned int)Width2Pixel (num), \ 103 (unsigned int)Width2Pixel (num), \
106 (unsigned int)Height2Pixel (1), False) 104 (unsigned int)Height2Pixel (1), False)
107 105
108#define ERASE_ROWS(row, num) \ 106#define ERASE_ROWS(row, num) \
109 XFillRectangle (display->display, drawBuffer, gc, \ 107 XFillRectangle (dpy, drawBuffer, gc, \
110 0, Row2Pixel (row), \ 108 0, Row2Pixel (row), \
111 (unsigned int)width, \ 109 (unsigned int)width, \
112 (unsigned int)Height2Pixel (num)) 110 (unsigned int)Height2Pixel (num))
113 111
114/* ------------------------------------------------------------------------- * 112/* ------------------------------------------------------------------------- *
126 width = ncol; 124 width = ncol;
127 } 125 }
128 126
129 l.touch (); 127 l.touch ();
130 128
131 efs &= ~RS_baseattrMask; 129 efs &= ~RS_baseattrMask; // remove italic etc. fontstyles
132 efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); 130 efs = SET_FONT (efs, FONTSET (efs)->find_font (' '));
133 131
134 text_t *et = l.t + col; 132 text_t *et = l.t + col;
135 rend_t *er = l.r + col; 133 rend_t *er = l.r + col;
136 134
161{ 159{
162#if ENABLE_OVERLAY 160#if ENABLE_OVERLAY
163 scr_overlay_off (); 161 scr_overlay_off ();
164#endif 162#endif
165 163
164 rvideo_mode = false;
166 view_start = 0; 165 view_start = 0;
167 num_scr = 0; 166 num_scr = 0;
168 167
169 if (ncol == 0) 168 if (ncol == 0)
170 ncol = 80; 169 ncol = 80;
237 selection.text = NULL; 236 selection.text = NULL;
238 selection.len = 0; 237 selection.len = 0;
239 selection.op = SELECTION_CLEAR; 238 selection.op = SELECTION_CLEAR;
240 selection.screen = PRIMARY; 239 selection.screen = PRIMARY;
241 selection.clicks = 0; 240 selection.clicks = 0;
242 rvideo_state = rvideo_mode = false;
243 } 241 }
244 else 242 else
245 { 243 {
246 /* 244 /*
247 * add or delete rows as appropriate 245 * add or delete rows as appropriate
276 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); 274 drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE);
277 } 275 }
278 276
279 line_t *old_buf = row_buf; 277 line_t *old_buf = row_buf;
280 row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); 278 row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t));
281 279
282 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 280 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
283 int pend = MOD (term_start + top_row , prev_total_rows); 281 int pend = MOD (term_start + top_row , prev_total_rows);
284 int q = total_rows; // rewrapped row 282 int q = total_rows; // rewrapped row
285 283
286 if (top_row) 284 if (top_row)
330 int qcol = 0; 328 int qcol = 0;
331 329
332 // see below for cursor adjustment rationale 330 // see below for cursor adjustment rationale
333 if (p == ocur.row) 331 if (p == ocur.row)
334 screen.cur.row = q - (total_rows - nrow); 332 screen.cur.row = q - (total_rows - nrow);
335 333
336 // fill a single destination line 334 // fill a single destination line
337 while (lofs < llen && qcol < ncol) 335 while (lofs < llen && qcol < ncol)
338 { 336 {
339 int prow = lofs / prev_ncol; 337 int prow = lofs / prev_ncol;
340 int pcol = lofs % prev_ncol; 338 int pcol = lofs % prev_ncol;
366 } 364 }
367 while (p != pend && q > 0); 365 while (p != pend && q > 0);
368 366
369 term_start = total_rows - nrow; 367 term_start = total_rows - nrow;
370 top_row = q - term_start; 368 top_row = q - term_start;
371 369
372 // make sure all terminal lines exist 370 // make sure all terminal lines exist
373 while (top_row > 0) 371 while (top_row > 0)
374 scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); 372 scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE);
375 } 373 }
376 else 374 else
377 { 375 {
378 // if no scrollback exists (yet), wing, instead of wrap 376 // if no scrollback exists (yet), wing, instead of wrap
379 377
380 for (int row = min (nrow, prev_nrow); row--; ) 378 for (int row = min (nrow, prev_nrow); row--; )
381 { 379 {
382 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; 380 line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)];
383 line_t &qline = row_buf [row]; 381 line_t &qline = row_buf [row];
384 382
407 CLEAR_ALL_SELECTION (); 405 CLEAR_ALL_SELECTION ();
408 406
409 prev_nrow = nrow; 407 prev_nrow = nrow;
410 prev_ncol = ncol; 408 prev_ncol = ncol;
411 409
412 tabs = (char *)rxvt_malloc (ncol * sizeof (char)); 410 tabs = (char *)rxvt_malloc (ncol);
413 411
414 for (int col = ncol; col--; ) 412 for (int col = ncol; --col; )
415 tabs [col] = col % TABSIZE == 0; 413 tabs [col] = col % TABSIZE == 0;
416 414
417 if (current_screen != PRIMARY) 415 if (current_screen != PRIMARY)
418 scr_swap_screen (); 416 scr_swap_screen ();
419 417
510} 508}
511 509
512void 510void
513rxvt_term::scr_swap_screen () 511rxvt_term::scr_swap_screen ()
514{ 512{
515 if (!OPTION (Opt_secondaryScreen)) 513 if (!option (Opt_secondaryScreen))
516 return; 514 return;
517 515
518 for (int i = prev_nrow; i--; ) 516 for (int i = prev_nrow; i--; )
519 ::swap (ROW(i), swap_buf [i]); 517 ::swap (ROW(i), swap_buf [i]);
520 518
542 selection_check (2); /* check for boundary cross */ 540 selection_check (2); /* check for boundary cross */
543 541
544 int i = current_screen; current_screen = scrn; scrn = i; 542 int i = current_screen; current_screen = scrn; scrn = i;
545 543
546#if NSCREENS 544#if NSCREENS
547 if (OPTION (Opt_secondaryScreen)) 545 if (option (Opt_secondaryScreen))
548 { 546 {
549 num_scr = 0; 547 num_scr = 0;
550 548
551 scr_swap_screen (); 549 scr_swap_screen ();
552 550
555 screen.flags |= Screen_VisibleCursor; 553 screen.flags |= Screen_VisibleCursor;
556 swap.flags |= Screen_VisibleCursor; 554 swap.flags |= Screen_VisibleCursor;
557 } 555 }
558 else 556 else
559#endif 557#endif
560 if (OPTION (Opt_secondaryScroll)) 558 if (option (Opt_secondaryScroll))
561 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 559 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
562} 560}
563 561
564// clear WrapNext indicator, solidifying position on next line 562// clear WrapNext indicator, solidifying position on next line
565void 563void
598/* 596/*
599 * Change the rendition style for following text 597 * Change the rendition style for following text
600 */ 598 */
601void 599void
602rxvt_term::scr_rendition (int set, int style) NOTHROW 600rxvt_term::scr_rendition (int set, int style) NOTHROW
603 { 601{
604 if (set) 602 if (set)
605 rstyle |= style; 603 rstyle |= style;
606 else if (style == ~RS_None) 604 else if (style == ~RS_None)
607 rstyle = DEFAULT_RSTYLE; 605 rstyle = DEFAULT_RSTYLE;
608 else 606 else
609 rstyle &= ~style; 607 rstyle &= ~style;
610 } 608}
611 609
612/* ------------------------------------------------------------------------- */ 610/* ------------------------------------------------------------------------- */
613/* 611/*
614 * Scroll text between <row1> and <row2> inclusive, by <count> lines 612 * Scroll text between <row1> and <row2> inclusive, by <count> lines
615 * count positive ==> scroll up 613 * count positive ==> scroll up
624 want_refresh = 1; 622 want_refresh = 1;
625 num_scr += count; 623 num_scr += count;
626 624
627 if (count > 0 625 if (count > 0
628 && row1 == 0 626 && row1 == 0
629 && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) 627 && (current_screen == PRIMARY || option (Opt_secondaryScroll)))
630 { 628 {
631 top_row = max (top_row - count, -saveLines); 629 top_row = max (top_row - count, -saveLines);
632 630
633 // scroll everything up 'count' lines 631 // scroll everything up 'count' lines
634 term_start = (term_start + count) % total_rows; 632 term_start = (term_start + count) % total_rows;
641 } 639 }
642 640
643 // erase newly scrolled-in lines 641 // erase newly scrolled-in lines
644 for (int i = count; i--; ) 642 for (int i = count; i--; )
645 { 643 {
646 // basically this is a slightly optimized scr_blank_screen_mem
647 // it is worth the effort on slower machines
648 line_t &l = ROW(nrow - 1 - i); 644 line_t &l = ROW(nrow - 1 - i);
649 645
646 // optimize if already cleared, can be significant on slow machines
647 // could be rolled into scr_blank_screen_mem
648 if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask)))
649 {
650 scr_blank_line (l, 0, l.l, rstyle); 650 scr_blank_line (l, 0, l.l, rstyle);
651
652 l.l = 0; 651 l.l = 0;
653 l.f = 0; 652 l.f = 0;
653 }
654 else
655 scr_blank_screen_mem (l, rstyle);
654 } 656 }
655 657
656 // now copy lines below the scroll region bottom to the 658 // now copy lines below the scroll region bottom to the
657 // bottom of the screen again, so they look as if they 659 // bottom of the screen again, so they look as if they
658 // hadn't moved. 660 // hadn't moved.
662 line_t &l2 = ROW(i); 664 line_t &l2 = ROW(i);
663 665
664 ::swap (l1, l2); 666 ::swap (l1, l2);
665 l2.touch (); 667 l2.touch ();
666 } 668 }
667 669
668 // move and/or clear selection, if any 670 // move and/or clear selection, if any
669 if (selection.op && current_screen == selection.screen) 671 if (selection.op && current_screen == selection.screen)
670 { 672 {
671 selection.beg.row -= count; 673 selection.beg.row -= count;
672 selection.end.row -= count; 674 selection.end.row -= count;
680 selection.op = SELECTION_CLEAR; 682 selection.op = SELECTION_CLEAR;
681 } 683 }
682 } 684 }
683 685
684 // finally move the view window, if desired 686 // finally move the view window, if desired
685 if (OPTION (Opt_scrollWithBuffer) 687 if (option (Opt_scrollWithBuffer)
686 && view_start != 0 688 && view_start != 0
687 && view_start != -saveLines) 689 && view_start != -saveLines)
688 scr_page (UP, count); 690 scr_page (UP, count);
689 691
690 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 692 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
708 { 710 {
709 /* move selected region too */ 711 /* move selected region too */
710 selection.beg.row -= count; 712 selection.beg.row -= count;
711 selection.end.row -= count; 713 selection.end.row -= count;
712 selection.mark.row -= count; 714 selection.mark.row -= count;
713 715
714 selection_check (0); 716 selection_check (0);
715 } 717 }
716 } 718 }
717 719
718 // use a simple and robust scrolling algorithm, this 720 // use a simple and robust scrolling algorithm, this
830 } 832 }
831 833
832 if (screen.flags & Screen_WrapNext) 834 if (screen.flags & Screen_WrapNext)
833 { 835 {
834 scr_do_wrap (); 836 scr_do_wrap ();
835 837
836 line->l = ncol; 838 line->l = ncol;
837 line->is_longer (1); 839 line->is_longer (1);
838 840
839 row = screen.cur.row; 841 row = screen.cur.row;
840 line = &ROW(row); /* _must_ refresh */ 842 line = &ROW(row); /* _must_ refresh */
1009 * XTERM_SEQ: CTRL-H 1011 * XTERM_SEQ: CTRL-H
1010 */ 1012 */
1011void 1013void
1012rxvt_term::scr_backspace () NOTHROW 1014rxvt_term::scr_backspace () NOTHROW
1013{ 1015{
1014 want_refresh = 1;
1015
1016 if (screen.cur.col == 0) 1016 if (screen.cur.col == 0)
1017 { 1017 {
1018 if (screen.cur.row > 0) 1018 if (screen.cur.row > 0)
1019 { 1019 {
1020#ifdef TERMCAP_HAS_BW 1020#ifdef TERMCAP_HAS_BW
1021 screen.cur.col = ncol - 1; 1021 screen.cur.col = ncol - 1;
1022 screen.cur.row--; 1022 --screen.cur.row;
1023 return; 1023
1024 want_refresh = 1;
1024#endif 1025#endif
1025 } 1026 }
1026 } 1027 }
1027 else if (!(screen.flags & Screen_WrapNext)) 1028 else
1028 scr_gotorc (0, -1, RELATIVE); 1029 scr_gotorc (0, -1, RELATIVE);
1029
1030 screen.flags &= ~Screen_WrapNext;
1031} 1030}
1032 1031
1033/* ------------------------------------------------------------------------- */ 1032/* ------------------------------------------------------------------------- */
1034/* 1033/*
1035 * Process Horizontal Tab 1034 * Process Horizontal Tab
1058 x = i; 1057 x = i;
1059 1058
1060 if (!--count) 1059 if (!--count)
1061 break; 1060 break;
1062 } 1061 }
1063 else 1062 else
1064 ht &= l.t[i] == ' ' 1063 ht &= l.t[i] == ' '
1065 && RS_SAME (l.r[i], base_rend); 1064 && RS_SAME (l.r[i], base_rend);
1066 1065
1067 if (count) 1066 if (count)
1068 x = ncol - 1; 1067 x = ncol - 1;
1069 1068
1070 // store horizontal tab commands as characters inside the text 1069 // store horizontal tab commands as characters inside the text
1071 // buffer so they can be selected and pasted. 1070 // buffer so they can be selected and pasted.
1072 if (ht && OPTION (Opt_pastableTabs)) 1071 if (ht && option (Opt_pastableTabs))
1073 { 1072 {
1074 base_rend = SET_FONT (base_rend, 0); 1073 base_rend = SET_FONT (base_rend, 0);
1075 1074
1076 l.touch (x); 1075 l.touch (x);
1077 1076
1110 * Process DEC Back Index 1109 * Process DEC Back Index
1111 * XTERM_SEQ: ESC 6 1110 * XTERM_SEQ: ESC 6
1112 * Move cursor left in row. If we're at the left boundary, shift everything 1111 * Move cursor left in row. If we're at the left boundary, shift everything
1113 * in that row right. Clear left column. 1112 * in that row right. Clear left column.
1114 */ 1113 */
1115#if ENABLE_FRILLS 1114#if !ENABLE_MINIMAL
1116void 1115void
1117rxvt_term::scr_backindex () NOTHROW 1116rxvt_term::scr_backindex () NOTHROW
1118{ 1117{
1119 if (screen.cur.col > 0) 1118 if (screen.cur.col > 0)
1120 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1119 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1127 * Process DEC Forward Index 1126 * Process DEC Forward Index
1128 * XTERM_SEQ: ESC 9 1127 * XTERM_SEQ: ESC 9
1129 * Move cursor right in row. If we're at the right boundary, shift everything 1128 * Move cursor right in row. If we're at the right boundary, shift everything
1130 * in that row left. Clear right column. 1129 * in that row left. Clear right column.
1131 */ 1130 */
1132#if ENABLE_FRILLS 1131#if !ENABLE_MINIMAL
1133void 1132void
1134rxvt_term::scr_forwardindex () NOTHROW 1133rxvt_term::scr_forwardindex () NOTHROW
1135{ 1134{
1136 if (screen.cur.col < ncol - 1) 1135 if (screen.cur.col < ncol - 1)
1137 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1136 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1184 } 1183 }
1185 } 1184 }
1186 else 1185 else
1187 { 1186 {
1188 if (screen.flags & Screen_Relative) 1187 if (screen.flags & Screen_Relative)
1188 {
1189 { /* relative origin mode */ 1189 /* relative origin mode */
1190 screen.cur.row = row + screen.tscroll; 1190 screen.cur.row = row + screen.tscroll;
1191 min_it (screen.cur.row, screen.bscroll); 1191 min_it (screen.cur.row, screen.bscroll);
1192 } 1192 }
1193 else 1193 else
1194 screen.cur.row = row; 1194 screen.cur.row = row;
1338 } 1338 }
1339 else 1339 else
1340 { 1340 {
1341 ren = rstyle & (RS_fgMask | RS_bgMask); 1341 ren = rstyle & (RS_fgMask | RS_bgMask);
1342 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1342 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1343 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1343 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1344 ERASE_ROWS (row, num); 1344 ERASE_ROWS (row, num);
1345 gcvalue.foreground = pix_colors[Color_fg]; 1345 gcvalue.foreground = pix_colors[Color_fg];
1346 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1346 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1347 } 1347 }
1348 1348
1349 for (; num--; row++) 1349 for (; num--; row++)
1350 { 1350 {
1351 scr_blank_screen_mem (ROW(row), rstyle); 1351 scr_blank_screen_mem (ROW(row), rstyle);
1352 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1352 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1353 } 1353 }
1354} 1354}
1355 1355
1356#if ENABLE_FRILLS 1356#if !ENABLE_MINIMAL
1357void 1357void
1358rxvt_term::scr_erase_savelines () NOTHROW 1358rxvt_term::scr_erase_savelines () NOTHROW
1359{ 1359{
1360 want_refresh = 1; 1360 want_refresh = 1;
1361 ZERO_SCROLLBACK (); 1361 ZERO_SCROLLBACK ();
1470 { 1470 {
1471 if (selection.end.row != screen.cur.row 1471 if (selection.end.row != screen.cur.row
1472 || (selection.end.col + count >= ncol)) 1472 || (selection.end.col + count >= ncol))
1473 CLEAR_SELECTION (); 1473 CLEAR_SELECTION ();
1474 else 1474 else
1475 {
1475 { /* shift selection */ 1476 /* shift selection */
1476 selection.beg.col += count; 1477 selection.beg.col += count;
1477 selection.mark.col += count; /* XXX: yes? */ 1478 selection.mark.col += count; /* XXX: yes? */
1478 selection.end.col += count; 1479 selection.end.col += count;
1479 } 1480 }
1480 } 1481 }
1619 */ 1620 */
1620void 1621void
1621rxvt_term::scr_set_tab (int mode) NOTHROW 1622rxvt_term::scr_set_tab (int mode) NOTHROW
1622{ 1623{
1623 if (mode < 0) 1624 if (mode < 0)
1624 memset (tabs, 0, ncol * sizeof (char)); 1625 memset (tabs, 0, ncol);
1625 else if (screen.cur.col < ncol) 1626 else if (screen.cur.col < ncol)
1626 tabs [screen.cur.col] = !!mode; 1627 tabs [screen.cur.col] = !!mode;
1627} 1628}
1628 1629
1629/* ------------------------------------------------------------------------- */ 1630/* ------------------------------------------------------------------------- */
1644 if (rvideo_state != on) 1645 if (rvideo_state != on)
1645 { 1646 {
1646 rvideo_state = on; 1647 rvideo_state = on;
1647 1648
1648 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1649 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1649#if XPM_BACKGROUND 1650#ifdef HAVE_BG_PIXMAP
1650 if (bgPixmap.pixmap == None) 1651 if (bgPixmap.pixmap == None)
1651#endif 1652#endif
1652#if TRANSPARENT
1653 if (!OPTION (Opt_transparent) || am_transparent == 0)
1654#endif
1655 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 1653 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1656 1654
1657 XGCValues gcvalue; 1655 XGCValues gcvalue;
1658 gcvalue.foreground = pix_colors[Color_fg]; 1656 gcvalue.foreground = pix_colors[Color_fg];
1659 gcvalue.background = pix_colors[Color_bg]; 1657 gcvalue.background = pix_colors[Color_bg];
1660 XChangeGC (display->display, gc, GCBackground | GCForeground, &gcvalue); 1658 XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue);
1661 1659
1662 scr_clear (); 1660 scr_clear ();
1663 scr_touch (true); 1661 scr_touch (true);
1664 } 1662 }
1665} 1663}
1750{ 1748{
1751 bool found = false; 1749 bool found = false;
1752 1750
1753 for (int i = 0; i < nrow; i++) 1751 for (int i = 0; i < nrow; i++)
1754 { 1752 {
1755 int col = 0;
1756 rend_t *drp = drawn_buf[i].r; 1753 rend_t *drp = drawn_buf[i].r;
1757 1754
1758 for (; col < ncol; col++, drp++) 1755 for (int col = 0; col < ncol; col++, drp++)
1759 if ((*drp & mask) == value) 1756 if ((*drp & mask) == value)
1760 { 1757 {
1761 found = true; 1758 found = true;
1762 *drp = ~value; 1759 *drp = ~value;
1763 } 1760 }
1803 for (i = PART_BEG; i < RC_COUNT; i++) 1800 for (i = PART_BEG; i < RC_COUNT; i++)
1804 { 1801 {
1805 min_it (rc[i].col, ncol - 1); 1802 min_it (rc[i].col, ncol - 1);
1806 min_it (rc[i].row, nrow - 1); 1803 min_it (rc[i].row, nrow - 1);
1807 } 1804 }
1808 1805// TODO: this line somehow causes segfault if scr_expose() is called just after resize
1809 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) 1806 for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++)
1810 fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); 1807 fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1);
1811 1808
1812 num_scr_allow = 0; 1809 num_scr_allow = 0;
1813 1810
1868 return true; 1865 return true;
1869} 1866}
1870 1867
1871#ifndef NO_BELL 1868#ifndef NO_BELL
1872void 1869void
1873rxvt_term::bell_cb (time_watcher &w) 1870rxvt_term::bell_cb (ev::timer &w, int revents)
1874{ 1871{
1875 rvideo_bell = false; 1872 rvideo_bell = false;
1876 scr_rvideo_mode (rvideo_mode); 1873 scr_rvideo_mode (rvideo_mode);
1874 refresh_check ();
1877} 1875}
1878#endif 1876#endif
1879 1877
1880/* ------------------------------------------------------------------------- */ 1878/* ------------------------------------------------------------------------- */
1881void 1879void
1883{ 1881{
1884#ifndef NO_BELL 1882#ifndef NO_BELL
1885 1883
1886# ifndef NO_MAPALERT 1884# ifndef NO_MAPALERT
1887# ifdef MAPALERT_OPTION 1885# ifdef MAPALERT_OPTION
1888 if (OPTION (Opt_mapAlert)) 1886 if (option (Opt_mapAlert))
1889# endif 1887# endif
1890 XMapWindow (display->display, parent[0]); 1888 XMapWindow (dpy, parent[0]);
1891# endif 1889# endif
1892 1890
1891# if ENABLE_FRILLS
1892 if (option (Opt_urgentOnBell))
1893 {
1894 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1895 {
1896 h->flags |= XUrgencyHint;
1897 XSetWMHints (dpy, parent[0], h);
1898 }
1899 }
1900# endif
1901
1893 if (OPTION (Opt_visualBell)) 1902 if (option (Opt_visualBell))
1894 { 1903 {
1895 rvideo_bell = true; 1904 rvideo_bell = true;
1896 scr_rvideo_mode (rvideo_mode); 1905 scr_rvideo_mode (rvideo_mode);
1897 display->flush (); 1906 flush ();
1898 1907
1899 bell_ev.start (NOW + VISUAL_BELL_DURATION); 1908 bell_ev.start (VISUAL_BELL_DURATION);
1900 } 1909 }
1901 else 1910 else
1902 XBell (display->display, 0); 1911 XBell (dpy, 0);
1903
1904#endif 1912#endif
1905} 1913}
1906 1914
1907/* ------------------------------------------------------------------------- */ 1915/* ------------------------------------------------------------------------- */
1908/* ARGSUSED */ 1916/* ARGSUSED */
1966 * screen.text/screen.rend contain what the screen will change to. 1974 * screen.text/screen.rend contain what the screen will change to.
1967 */ 1975 */
1968void 1976void
1969rxvt_term::scr_refresh () NOTHROW 1977rxvt_term::scr_refresh () NOTHROW
1970{ 1978{
1971 unsigned char must_clear, /* use draw_string not draw_image_string */ 1979 unsigned char have_bg,
1972 showcursor; /* show the cursor */ 1980 showcursor; /* show the cursor */
1973 int16_t col, row, /* column/row we're processing */ 1981 int16_t col, row, /* column/row we're processing */
1974 ocrow; /* old cursor row */ 1982 ocrow; /* old cursor row */
1975 int i; /* tmp */ 1983 int i; /* tmp */
1976#ifndef NO_CURSORCOLOR 1984#ifndef NO_CURSORCOLOR
1977 rend_t cc1; /* store colours at cursor position (s) */ 1985 rend_t cc1; /* store colours at cursor position (s) */
1978#endif 1986#endif
1979 rend_t *crp; // cursor rendition pointer 1987 rend_t *crp; // cursor rendition pointer
1988 rend_t ccol1, /* Cursor colour */
1989 ccol2; /* Cursor colour2 */
1980 1990
1981 want_refresh = 0; /* screen is current */ 1991 want_refresh = 0; /* screen is current */
1982 1992
1983 if (refresh_type == NO_REFRESH || !mapped) 1993 if (refresh_type == NO_REFRESH || !mapped)
1984 return; 1994 return;
1985 1995
1986 /* 1996 /*
1987 * A: set up vars 1997 * A: set up vars
1988 */ 1998 */
1989 must_clear = 0; 1999 have_bg = 0;
1990 refresh_count = 0; 2000 refresh_count = 0;
1991 2001
1992#if XPM_BACKGROUND 2002#ifdef HAVE_BG_PIXMAP
1993 must_clear |= bgPixmap.pixmap != None; 2003 have_bg |= bgPixmap.pixmap != None;
1994#endif
1995#if TRANSPARENT
1996 must_clear |= OPTION (Opt_transparent) && am_transparent;
1997#endif 2004#endif
1998 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2005 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1999 2006
2000 /* 2007 /*
2001 * B: reverse any characters which are selected 2008 * B: reverse any characters which are selected
2005 /* 2012 /*
2006 * C: set the cursor character (s) 2013 * C: set the cursor character (s)
2007 */ 2014 */
2008 { 2015 {
2009 unsigned char setoldcursor; 2016 unsigned char setoldcursor;
2010 rend_t ccol1, /* Cursor colour */
2011 ccol2; /* Cursor colour2 */
2012 2017
2013 showcursor = (screen.flags & Screen_VisibleCursor); 2018 showcursor = (screen.flags & Screen_VisibleCursor);
2014#ifdef CURSOR_BLINK 2019#ifdef CURSOR_BLINK
2015 if (hidden_cursor) 2020 if (hidden_cursor)
2016 showcursor = 0; 2021 showcursor = 0;
2023 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2028 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2024 col--; 2029 col--;
2025 2030
2026 crp = &ROW(screen.cur.row).r[col]; 2031 crp = &ROW(screen.cur.row).r[col];
2027 2032
2033#ifndef NO_CURSORCOLOR
2034 cc1 = *crp & (RS_fgMask | RS_bgMask);
2035 if (ISSET_PIXCOLOR (Color_cursor))
2036 ccol1 = Color_cursor;
2037 else
2038#endif
2039#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2040 ccol1 = fgcolor_of (rstyle);
2041#else
2042 ccol1 = Color_fg;
2043#endif
2044
2045#ifndef NO_CURSORCOLOR
2046 if (ISSET_PIXCOLOR (Color_cursor2))
2047 ccol2 = Color_cursor2;
2048 else
2049#endif
2050#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2051 ccol2 = bgcolor_of (rstyle);
2052#else
2053 ccol2 = Color_bg;
2054#endif
2055
2028 if (showcursor && focus) 2056 if (showcursor && focus)
2029 { 2057 {
2030 if (OPTION (Opt_cursorUnderline)) 2058 if (option (Opt_cursorUnderline))
2031 *crp ^= RS_Uline; 2059 *crp ^= RS_Uline;
2032 else 2060 else
2033 { 2061 {
2034 *crp ^= RS_RVid; 2062 *crp ^= RS_RVid;
2035
2036#ifndef NO_CURSORCOLOR
2037 cc1 = *crp & (RS_fgMask | RS_bgMask);
2038 if (ISSET_PIXCOLOR (Color_cursor))
2039 ccol1 = Color_cursor;
2040 else
2041#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2042 ccol1 = fgcolor_of (rstyle);
2043#else
2044 ccol1 = Color_fg;
2045#endif
2046 if (ISSET_PIXCOLOR (Color_cursor2))
2047 ccol2 = Color_cursor2;
2048 else
2049#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2050 ccol2 = bgcolor_of (rstyle);
2051#else
2052 ccol2 = Color_bg;
2053#endif
2054 *crp = SET_FGCOLOR (*crp, ccol1); 2063 *crp = SET_FGCOLOR (*crp, ccol1);
2055 *crp = SET_BGCOLOR (*crp, ccol2); 2064 *crp = SET_BGCOLOR (*crp, ccol2);
2056#endif
2057 } 2065 }
2058 } 2066 }
2059 } 2067 }
2060 2068
2061 /* make sure no outline cursor is left around */ 2069 /* make sure no outline cursor is left around */
2100 * D: CopyArea pass - very useful for slower links 2108 * D: CopyArea pass - very useful for slower links
2101 * This has been deliberately kept simple. 2109 * This has been deliberately kept simple.
2102 */ 2110 */
2103 if (!display->is_local 2111 if (!display->is_local
2104 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr 2112 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr
2105 && abs (num_scr) < nrow && !must_clear) 2113 && abs (num_scr) < nrow && !have_bg)
2106 { 2114 {
2107 int16_t nits; 2115 int16_t nits;
2116 int i = num_scr;
2108 int j; 2117 int j;
2109 int len, wlen; 2118 int len, wlen;
2110 dLocal (int, num_scr); 2119 dLocal (int, num_scr);
2111 2120
2112 j = nrow; 2121 j = nrow;
2113 wlen = len = -1; 2122 wlen = len = -1;
2114 row = i > 0 ? 0 : j - 1; 2123 row = i > 0 ? 0 : j - 1;
2124
2115 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2125 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
2116 { 2126 {
2117 if (row + i >= 0 && row + i < nrow && row + i != ocrow) 2127 if (row + i >= 0 && row + i < nrow && row + i != ocrow)
2118 { 2128 {
2119 line_t s = ROW(view_start + row); 2129 line_t s = ROW(view_start + row);
2140 wlen = row; 2150 wlen = row;
2141 continue; 2151 continue;
2142 } 2152 }
2143 } 2153 }
2144 2154
2145 if (len != -1) 2155 if (len >= 0)
2146 { 2156 {
2147 /* also comes here at end if needed because of >= above */ 2157 /* also comes here at end if needed because of >= above */
2148 if (wlen < len) 2158 if (wlen < len)
2149 ::swap (wlen, len); 2159 ::swap (wlen, len);
2150 2160
2161 XGCValues gcv;
2162
2163 gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv);
2151 XCopyArea (display->display, vt, vt, 2164 XCopyArea (dpy, vt, vt,
2152 gc, 0, Row2Pixel (len + i), 2165 gc, 0, Row2Pixel (len + i),
2153 (unsigned int)this->width, 2166 (unsigned int)this->width,
2154 (unsigned int)Height2Pixel (wlen - len + 1), 2167 (unsigned int)Height2Pixel (wlen - len + 1),
2155 0, Row2Pixel (len)); 2168 0, Row2Pixel (len));
2169 gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv);
2170
2156 len = -1; 2171 len = -1;
2157 } 2172 }
2158 } 2173 }
2159 } 2174 }
2160#endif 2175#endif
2216 count++; 2231 count++;
2217 2232
2218 if (stp[col] != dtp[col] 2233 if (stp[col] != dtp[col]
2219 || !RS_SAME (srp[col], drp[col])) 2234 || !RS_SAME (srp[col], drp[col]))
2220 { 2235 {
2221 if (must_clear && (i++ > count / 2)) 2236 if (have_bg && (i++ > count / 2))
2222 break; 2237 break;
2223 2238
2224 dtp[col] = stp[col]; 2239 dtp[col] = stp[col];
2225 drp[col] = rend; 2240 drp[col] = rend;
2226 i = 0; 2241 i = 0;
2227 } 2242 }
2228 else if (must_clear || (stp[col] != ' ' && ++i >= 16)) 2243 else if (have_bg || (stp[col] != ' ' && ++i >= 16))
2229 break; 2244 break;
2230 } 2245 }
2231 2246
2232 col--; /* went one too far. move back */ 2247 col--; /* went one too far. move back */
2233 count -= i; /* dump any matching trailing chars */ 2248 count -= i; /* dump any matching trailing chars */
2243 int back = bgcolor_of (rend); // desired background 2258 int back = bgcolor_of (rend); // desired background
2244 2259
2245 // only do special processing if any attributes are set, which is unlikely 2260 // only do special processing if any attributes are set, which is unlikely
2246 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2261 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2247 { 2262 {
2248#if ENABLE_STYLES
2249 // "careful" (too wide) character handling
2250
2251 // include previous careful character(s) if possible, looks nicer (best effort...)
2252 while (text > stp
2253 && srp[text - stp - 1] & RS_Careful
2254 && RS_SAME (rend, srp[text - stp - 1]))
2255 text--, count++, xpixel -= fwidth;
2256
2257 // force redraw after "careful" characters to avoid pixel droppings
2258 for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
2259 drp[col + i + 1] = ~srp[col + i + 1];
2260
2261 // force redraw before "careful" characters to avoid pixel droppings
2262 for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++)
2263 drp[text - stp - i - 1] = ~srp[text - stp - i - 1];
2264#endif
2265
2266 bool invert = rend & RS_RVid; 2263 bool invert = rend & RS_RVid;
2267 2264
2268#ifndef NO_BOLD_UNDERLINE_REVERSE 2265#ifndef NO_BOLD_UNDERLINE_REVERSE
2269 if (rend & RS_Bold
2270 && fore == Color_fg) 2266 if (rend & RS_Bold && fore == Color_fg)
2271 { 2267 {
2272 if (ISSET_PIXCOLOR (Color_BD)) 2268 if (ISSET_PIXCOLOR (Color_BD))
2273 fore = Color_BD; 2269 fore = Color_BD;
2274# if !ENABLE_STYLES 2270# if !ENABLE_STYLES
2275 else 2271 else
2276 invert = !invert; 2272 invert = !invert;
2277# endif 2273# endif
2278 } 2274 }
2279 2275
2280 if (rend & RS_Italic 2276 if (rend & RS_Italic && fore == Color_fg)
2281 && fore == Color_fg)
2282 { 2277 {
2283 if (ISSET_PIXCOLOR (Color_IT)) 2278 if (ISSET_PIXCOLOR (Color_IT))
2284 fore = Color_IT; 2279 fore = Color_IT;
2285# if !ENABLE_STYLES 2280# if !ENABLE_STYLES
2286 else 2281 else
2287 invert = !invert; 2282 invert = !invert;
2288# endif 2283# endif
2289 } 2284 }
2290 2285
2291 if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) 2286 if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL))
2292 fore = Color_UL; 2287 fore = Color_UL;
2293#endif 2288#endif
2294 2289
2295 if (invert) 2290 if (invert)
2296 { 2291 {
2292#ifdef OPTION_HC
2293 if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col)
2294 || !ISSET_PIXCOLOR (Color_HC))
2295#endif
2296 /* invert the column if no highlightColor is set or it is the
2297 * current cursor column */
2297 ::swap (fore, back); 2298 ::swap (fore, back);
2299#ifdef OPTION_HC
2300 else if (ISSET_PIXCOLOR (Color_HC))
2301 back = Color_HC;
2302#endif
2298 2303
2299#ifndef NO_BOLD_UNDERLINE_REVERSE 2304#ifndef NO_BOLD_UNDERLINE_REVERSE
2305# ifndef OPTION_HC
2300 if (ISSET_PIXCOLOR (Color_RV)) 2306 if (ISSET_PIXCOLOR (Color_RV))
2301 back = Color_RV; 2307 back = Color_RV;
2302 2308# endif
2303 if (fore == back) 2309 if (fore == back)
2304 { 2310 {
2305 fore = Color_bg; 2311 fore = Color_bg;
2306 back = Color_fg; 2312 back = Color_fg;
2307 } 2313 }
2309 } 2315 }
2310 2316
2311#ifdef TEXT_BLINK 2317#ifdef TEXT_BLINK
2312 if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) 2318 if (rend & RS_Blink && (back == Color_bg || fore == Color_bg))
2313 { 2319 {
2314 if (!text_blink_ev.active) 2320 if (!text_blink_ev.is_active ())
2315 { 2321 {
2316 text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); 2322 text_blink_ev.again ();
2317 hidden_text = 0; 2323 hidden_text = 0;
2318 } 2324 }
2319 else if (hidden_text) 2325 else if (hidden_text)
2320 fore = back; 2326 fore = back;
2321 } 2327 }
2322#endif 2328#endif
2329
2330#if ENABLE_STYLES
2331 // "careful" (too wide) character handling
2332
2333 // include previous careful character(s) if possible, looks nicer (best effort...)
2334 while (text > stp
2335 && srp[text - stp - 1] & RS_Careful
2336 && RS_SAME (rend, srp[text - stp - 1]))
2337 text--, count++, xpixel -= fwidth;
2338
2339 // force redraw after "careful" characters to avoid pixel droppings
2340 for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
2341 drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw;
2342
2343 // force redraw before "careful" characters to avoid pixel droppings
2344 for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++)
2345 drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw;
2346#endif
2323 } 2347 }
2324 2348
2325 /* 2349 /*
2326 * Actually do the drawing of the string here 2350 * Actually do the drawing of the string here
2327 */ 2351 */
2328 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; 2352 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];
2329 2353
2330 if (back == fore)
2331 font->clear_rect (*drawable, xpixel, ypixel,
2332 fwidth * count, fheight,
2333 back);
2334 else if (back == Color_bg) 2354 if (have_bg && back == Color_bg)
2335 { 2355 {
2336 if (must_clear) 2356 // this is very ugly, maybe push it into ->draw?
2337 {
2338 CLEAR_CHARS (xpixel, ypixel, count);
2339 2357
2340 for (i = 0; i < count; i++) /* don't draw empty strings */ 2358 for (i = 0; i < count; i++) /* don't draw empty strings */
2341 if (text[i] != ' ') 2359 if (text[i] != ' ')
2342 { 2360 {
2343 font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); 2361 font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_transparent);
2344 break; 2362 goto did_clear;
2345 }
2346 } 2363 }
2347 else 2364
2348 font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); 2365 CLEAR_CHARS (xpixel, ypixel, count);
2366 did_clear: ;
2349 } 2367 }
2350 else 2368 else
2351 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2369 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2352 2370
2353 if (rend & RS_Uline && font->descent > 1 && fore != back) 2371 if (rend & RS_Uline && font->descent > 1 && fore != back)
2354 { 2372 {
2355#if ENABLE_FRILLS 2373#if ENABLE_FRILLS
2356 if (ISSET_PIXCOLOR (Color_underline)) 2374 if (ISSET_PIXCOLOR (Color_underline))
2357 XSetForeground (display->display, gc, pix_colors[Color_underline]); 2375 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2358 else 2376 else
2359#endif 2377#endif
2360 XSetForeground (display->display, gc, pix_colors[fore]); 2378 XSetForeground (dpy, gc, pix_colors[fore]);
2361 2379
2362 XDrawLine (display->display, drawBuffer, gc, 2380 XDrawLine (dpy, drawBuffer, gc,
2363 xpixel, ypixel + font->ascent + 1, 2381 xpixel, ypixel + font->ascent + 1,
2364 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2382 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2365 } 2383 }
2366 } /* for (col....) */ 2384 } /* for (col....) */
2367 } /* for (row....) */ 2385 } /* for (row....) */
2376 */ 2394 */
2377 if (showcursor) 2395 if (showcursor)
2378 { 2396 {
2379 if (focus) 2397 if (focus)
2380 { 2398 {
2381 if (OPTION (Opt_cursorUnderline)) 2399 if (option (Opt_cursorUnderline))
2382 *crp ^= RS_Uline; 2400 *crp ^= RS_Uline;
2383 else 2401 else
2384 { 2402 {
2385 *crp ^= RS_RVid; 2403 *crp ^= RS_RVid;
2386#ifndef NO_CURSORCOLOR 2404#ifndef NO_CURSORCOLOR
2400 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) 2418 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2401 cursorwidth++; 2419 cursorwidth++;
2402 2420
2403#ifndef NO_CURSORCOLOR 2421#ifndef NO_CURSORCOLOR
2404 if (ISSET_PIXCOLOR (Color_cursor)) 2422 if (ISSET_PIXCOLOR (Color_cursor))
2405 XSetForeground (display->display, gc, pix_colors[Color_cursor]); 2423 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2424 else
2406#endif 2425#endif
2426 XSetForeground (dpy, gc, pix_colors[ccol1]);
2407 2427
2408 XDrawRectangle (display->display, drawBuffer, gc, 2428 XDrawRectangle (dpy, drawBuffer, gc,
2409 Col2Pixel (col), 2429 Col2Pixel (col),
2410 Row2Pixel (oldcursor.row), 2430 Row2Pixel (oldcursor.row),
2411 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2431 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2412 (unsigned int) (Height2Pixel (1) - lineSpace - 1)); 2432 (unsigned int) (Height2Pixel (1) - lineSpace - 1));
2413 } 2433 }
2448} 2468}
2449 2469
2450void 2470void
2451rxvt_term::scr_recolour () NOTHROW 2471rxvt_term::scr_recolour () NOTHROW
2452{ 2472{
2453 if (1 2473#ifdef HAVE_BG_PIXMAP
2454#if TRANSPARENT 2474 bgPixmap.apply ();
2455 && !am_transparent 2475#else
2456#endif 2476
2457#if XPM_BACKGROUND
2458 && !bgPixmap.pixmap
2459#endif
2460 )
2461 {
2462 XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); 2477 XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]);
2463 XClearWindow (display->display, parent[0]); 2478 XClearWindow (dpy, parent[0]);
2464 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 2479 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2480
2465#if HAVE_SCROLLBARS 2481# if HAVE_SCROLLBARS
2466 if (scrollBar.win) 2482 if (scrollBar.win)
2467 { 2483 {
2468 XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); 2484 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]);
2469 scrollBar.setIdle (); 2485 scrollBar.setIdle ();
2470 scrollbar_show (0); 2486 scrollbar_show (0);
2471 } 2487 }
2472#endif 2488# endif
2473 }
2474 2489
2475 scr_clear (); 2490 scr_clear ();
2476 scr_touch (true); 2491 scr_touch (true);
2477 want_refresh = 1; 2492 want_refresh = 1;
2493
2494#endif
2478} 2495}
2479 2496
2480/* ------------------------------------------------------------------------- */ 2497/* ------------------------------------------------------------------------- */
2481void 2498void
2482rxvt_term::scr_clear (bool really) NOTHROW 2499rxvt_term::scr_clear (bool really) NOTHROW
2486 2503
2487 num_scr_allow = 0; 2504 num_scr_allow = 0;
2488 want_refresh = 1; 2505 want_refresh = 1;
2489 2506
2490 if (really) 2507 if (really)
2491 XClearWindow (display->display, vt); 2508 XClearWindow (dpy, vt);
2492} 2509}
2493 2510
2494void 2511void
2495rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW 2512rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW
2496{ 2513{
2545{ 2562{
2546 if (selection.op 2563 if (selection.op
2547 && current_screen == selection.screen 2564 && current_screen == selection.screen
2548 && selection.end.row >= view_start) 2565 && selection.end.row >= view_start)
2549 { 2566 {
2550#if ENABLE_FRILLS 2567#if !ENABLE_MINIMAL
2551 if (selection.rect) 2568 if (selection.rect)
2552 scr_xor_rect (selection.beg.row, selection.beg.col, 2569 scr_xor_rect (selection.beg.row, selection.beg.col,
2553 selection.end.row, selection.end.col, 2570 selection.end.row, selection.end.col,
2554 RS_RVid, RS_RVid | RS_Uline); 2571 RS_RVid, RS_RVid | RS_Uline);
2555 else 2572 else
2632 /* convert normal newline chars into common keyboard Return key sequence */ 2649 /* convert normal newline chars into common keyboard Return key sequence */
2633 for (unsigned int i = 0; i < len; i++) 2650 for (unsigned int i = 0; i < len; i++)
2634 if (data[i] == C0_LF) 2651 if (data[i] == C0_LF)
2635 data[i] = C0_CR; 2652 data[i] = C0_CR;
2636 2653
2654 if (priv_modes & PrivMode_BracketPaste)
2655 tt_printf ("\e[200~");
2656
2637 tt_write (data, len); 2657 tt_write (data, len);
2658
2659 if (priv_modes & PrivMode_BracketPaste)
2660 tt_printf ("\e[201~");
2638} 2661}
2639 2662
2640/* ------------------------------------------------------------------------- */ 2663/* ------------------------------------------------------------------------- */
2641/* 2664/*
2642 * Respond to a notification that a primary selection has been sent 2665 * Respond to a notification that a primary selection has been sent
2671 } 2694 }
2672 2695
2673 unsigned long bytes_after; 2696 unsigned long bytes_after;
2674 XTextProperty ct; 2697 XTextProperty ct;
2675 2698
2676 if (XGetWindowProperty (display->display, win, prop, 2699 if (XGetWindowProperty (dpy, win, prop,
2677 0, PROP_SIZE / 4, 2700 0, PROP_SIZE / 4,
2678 delete_prop, AnyPropertyType, 2701 delete_prop, AnyPropertyType,
2679 &ct.encoding, &ct.format, 2702 &ct.encoding, &ct.format,
2680 &ct.nitems, &bytes_after, 2703 &ct.nitems, &bytes_after,
2681 &ct.value) != Success) 2704 &ct.value) != Success)
2690 if (bytes_after) 2713 if (bytes_after)
2691 { 2714 {
2692 // fetch and append remaining data 2715 // fetch and append remaining data
2693 XTextProperty ct2; 2716 XTextProperty ct2;
2694 2717
2695 if (XGetWindowProperty (display->display, win, prop, 2718 if (XGetWindowProperty (dpy, win, prop,
2696 ct.nitems / 4, (bytes_after + 3) / 4, 2719 ct.nitems / 4, (bytes_after + 3) / 4,
2697 delete_prop, AnyPropertyType, 2720 delete_prop, AnyPropertyType,
2698 &ct2.encoding, &ct2.format, 2721 &ct2.encoding, &ct2.format,
2699 &ct2.nitems, &bytes_after, 2722 &ct2.nitems, &bytes_after,
2700 &ct2.value) != Success) 2723 &ct2.value) != Success)
2713 2736
2714 if (ct.encoding == xa[XA_INCR]) 2737 if (ct.encoding == xa[XA_INCR])
2715 { 2738 {
2716 // INCR selection, start handshake 2739 // INCR selection, start handshake
2717 if (!delete_prop) 2740 if (!delete_prop)
2718 XDeleteProperty (display->display, win, prop); 2741 XDeleteProperty (dpy, win, prop);
2719 2742
2720 selection_wait = Sel_incr; 2743 selection_wait = Sel_incr;
2721 incr_buf_fill = 0; 2744 incr_buf_fill = 0;
2722 incr_ev.start (NOW + 10); 2745 incr_ev.start (10);
2723 2746
2724 goto bailout; 2747 goto bailout;
2725 } 2748 }
2726 2749
2727 if (ct.nitems == 0) 2750 if (ct.nitems == 0)
2736 ct.nitems = incr_buf_fill; 2759 ct.nitems = incr_buf_fill;
2737 incr_buf = 0; 2760 incr_buf = 0;
2738 incr_buf_size = 0; 2761 incr_buf_size = 0;
2739 incr_ev.stop (); 2762 incr_ev.stop ();
2740 } 2763 }
2741 else 2764 else
2742 { 2765 {
2743 if (selection_wait == Sel_normal 2766 if (selection_wait == Sel_normal
2744 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion 2767 && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion
2745 { 2768 {
2746 /* 2769 /*
2753 goto bailout; 2776 goto bailout;
2754 } 2777 }
2755 } 2778 }
2756 else if (selection_wait == Sel_incr) 2779 else if (selection_wait == Sel_incr)
2757 { 2780 {
2758 incr_ev.start (NOW + 10); 2781 incr_ev.start (10);
2759 2782
2760 while (incr_buf_fill + ct.nitems > incr_buf_size) 2783 while (incr_buf_fill + ct.nitems > incr_buf_size)
2761 { 2784 {
2762 incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; 2785 incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024;
2763 incr_buf = (char *)realloc (incr_buf, incr_buf_size); 2786 incr_buf = (char *)realloc (incr_buf, incr_buf_size);
2770 } 2793 }
2771 2794
2772 char **cl; 2795 char **cl;
2773 int cr; 2796 int cr;
2774 2797
2775#if ENABLE_FRILLS 2798#if !ENABLE_MINIMAL
2776 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 2799 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
2777 // so recode it manually 2800 // so recode it manually
2778 if (ct.encoding == xa[XA_UTF8_STRING]) 2801 if (ct.encoding == xa[XA_UTF8_STRING])
2779 { 2802 {
2780 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2803 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2784 paste (s, strlen (s)); 2807 paste (s, strlen (s));
2785 free (s); 2808 free (s);
2786 } 2809 }
2787 else 2810 else
2788#endif 2811#endif
2789 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2812 if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0
2790 && cl) 2813 && cl)
2791 { 2814 {
2792 for (int i = 0; i < cr; i++) 2815 for (int i = 0; i < cr; i++)
2793 paste (cl[i], strlen (cl[i])); 2816 paste (cl[i], strlen (cl[i]));
2794 2817
2803 if (selection_wait == Sel_normal) 2826 if (selection_wait == Sel_normal)
2804 selection_wait = Sel_none; 2827 selection_wait = Sel_none;
2805} 2828}
2806 2829
2807void 2830void
2808rxvt_term::incr_cb (time_watcher &w) NOTHROW 2831rxvt_term::incr_cb (ev::timer &w, int revents) NOTHROW
2809{ 2832{
2810 selection_wait = Sel_none; 2833 selection_wait = Sel_none;
2811 2834
2812 incr_buf_size = 0; 2835 incr_buf_size = 0;
2813 free (incr_buf); 2836 free (incr_buf);
2824 selection_paste (win, prop, true); 2847 selection_paste (win, prop, true);
2825} 2848}
2826 2849
2827/* ------------------------------------------------------------------------- */ 2850/* ------------------------------------------------------------------------- */
2828/* 2851/*
2829 * Request the current selection: 2852 * Request the current selection:
2830 * Order: > internal selection if available 2853 * Order: > internal selection if available
2831 * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) 2854 * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+)
2832 * > CUT_BUFFER0 2855 * > CUT_BUFFER0
2833 * (+) if ownership is claimed but property is empty, rxvt_selection_paste () 2856 * (+) if ownership is claimed but property is empty, rxvt_selection_paste ()
2834 * will auto fallback to CUT_BUFFER0 2857 * will auto fallback to CUT_BUFFER0
2836 */ 2859 */
2837void 2860void
2838rxvt_term::selection_request (Time tm, int selnum) NOTHROW 2861rxvt_term::selection_request (Time tm, int selnum) NOTHROW
2839{ 2862{
2840 if (selection.text && selnum == Sel_Primary) 2863 if (selection.text && selnum == Sel_Primary)
2864 {
2841 { /* internal selection */ 2865 /* internal selection */
2842 char *str = rxvt_wcstombs (selection.text, selection.len); 2866 char *str = rxvt_wcstombs (selection.text, selection.len);
2843 paste (str, strlen (str)); 2867 paste (str, strlen (str));
2844 free (str); 2868 free (str);
2845 return; 2869 return;
2846 } 2870 }
2876 else if (selnum == Sel_Secondary) 2900 else if (selnum == Sel_Secondary)
2877 sel = XA_SECONDARY; 2901 sel = XA_SECONDARY;
2878 else 2902 else
2879 sel = xa[XA_CLIPBOARD]; 2903 sel = xa[XA_CLIPBOARD];
2880 2904
2881 if (XGetSelectionOwner (display->display, sel) != None) 2905 if (XGetSelectionOwner (dpy, sel) != None)
2882 { 2906 {
2883 XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], 2907 XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION],
2884 vt, selection_request_time); 2908 vt, selection_request_time);
2885 return 1; 2909 return 1;
2886 } 2910 }
2887 2911
2888 return 0; 2912 return 0;
2951 2975
2952 int end_col; 2976 int end_col;
2953 2977
2954 for (; row <= selection.end.row; row++, col = 0) 2978 for (; row <= selection.end.row; row++, col = 0)
2955 { 2979 {
2956#if ENABLE_FRILLS 2980#if !ENABLE_MINIMAL
2957 if (selection.rect) 2981 if (selection.rect)
2958 { 2982 {
2959 col = selection.beg.col; 2983 col = selection.beg.col;
2960 end_col = ncol + 1; 2984 end_col = ncol + 1;
2961 } 2985 }
2964 end_col = ROW(row).l; 2988 end_col = ROW(row).l;
2965 2989
2966 col = max (col, 0); 2990 col = max (col, 0);
2967 2991
2968 if (row == selection.end.row 2992 if (row == selection.end.row
2969#if ENABLE_FRILLS 2993#if !ENABLE_MINIMAL
2970 || selection.rect 2994 || selection.rect
2971#endif 2995#endif
2972 ) 2996 )
2973 min_it (end_col, selection.end.col); 2997 min_it (end_col, selection.end.col);
2974 2998
2997#endif 3021#endif
2998 else 3022 else
2999 new_selection_text[ofs++] = *t++; 3023 new_selection_text[ofs++] = *t++;
3000 } 3024 }
3001 3025
3002#if ENABLE_FRILLS 3026#if !ENABLE_MINIMAL
3003 if (selection.rect) 3027 if (selection.rect)
3004 { 3028 {
3005 while (ofs 3029 while (ofs
3006 && new_selection_text[ofs - 1] != C0_LF 3030 && new_selection_text[ofs - 1] != C0_LF
3007 && unicode::is_space (new_selection_text[ofs - 1])) 3031 && unicode::is_space (new_selection_text[ofs - 1]))
3041bool 3065bool
3042rxvt_term::selection_grab (Time tm) NOTHROW 3066rxvt_term::selection_grab (Time tm) NOTHROW
3043{ 3067{
3044 selection_time = tm; 3068 selection_time = tm;
3045 3069
3046 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 3070 XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm);
3047 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 3071 if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt)
3048 { 3072 {
3049 display->set_selection_owner (this); 3073 display->set_selection_owner (this);
3050 return true; 3074 return true;
3051 } 3075 }
3052 else 3076 else
3056 } 3080 }
3057 3081
3058#if 0 3082#if 0
3059 XTextProperty ct; 3083 XTextProperty ct;
3060 3084
3061 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3085 if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0)
3062 { 3086 {
3063 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3087 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
3064 XFree (ct.value); 3088 XFree (ct.value);
3065 } 3089 }
3066#endif 3090#endif
3112 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); 3136 selection.mark.col = clamp (selection.mark.col, 0, ncol - 1);
3113 3137
3114 while (selection.mark.col > 0 3138 while (selection.mark.col > 0
3115 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) 3139 && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR)
3116 --selection.mark.col; 3140 --selection.mark.col;
3117 3141
3118 if (selection.op) 3142 if (selection.op)
3143 {
3119 { /* clear the old selection */ 3144 /* clear the old selection */
3120 selection.beg.row = selection.end.row = selection.mark.row; 3145 selection.beg.row = selection.end.row = selection.mark.row;
3121 selection.beg.col = selection.end.col = selection.mark.col; 3146 selection.beg.col = selection.end.col = selection.mark.col;
3122 } 3147 }
3123 3148
3124 selection.op = SELECTION_INIT; 3149 selection.op = SELECTION_INIT;
3313 * a point/word/line which is either the start or end of the selection 3338 * a point/word/line which is either the start or end of the selection
3314 * and it was decided by whichever point/word/line was `fixed' at the 3339 * and it was decided by whichever point/word/line was `fixed' at the
3315 * time of the most recent button3 press 3340 * time of the most recent button3 press
3316 */ 3341 */
3317 if (button3 && buttonpress) 3342 if (button3 && buttonpress)
3343 {
3318 { /* button3 press */ 3344 /* button3 press */
3319 /* 3345 /*
3320 * first determine which edge of the selection we are closest to 3346 * first determine which edge of the selection we are closest to
3321 */ 3347 */
3322 if (ROWCOL_IS_BEFORE (pos, selection.beg) 3348 if (ROWCOL_IS_BEFORE (pos, selection.beg)
3323 || (!ROWCOL_IS_AFTER (pos, selection.end) 3349 || (!ROWCOL_IS_AFTER (pos, selection.end)
3341 selection.mark.row = selection.beg.row; 3367 selection.mark.row = selection.beg.row;
3342 selection.mark.col = selection.beg.col; 3368 selection.mark.col = selection.beg.col;
3343 } 3369 }
3344 } 3370 }
3345 else 3371 else
3372 {
3346 { /* button1 drag or button3 drag */ 3373 /* button1 drag or button3 drag */
3347 if (ROWCOL_IS_AFTER (selection.mark, pos)) 3374 if (ROWCOL_IS_AFTER (selection.mark, pos))
3348 { 3375 {
3349 if (selection.mark.row == selection.end.row 3376 if (selection.mark.row == selection.end.row
3350 && selection.mark.col == selection.end.col 3377 && selection.mark.col == selection.end.col
3351 && clickchange 3378 && clickchange
3368 3395
3369 if (selection.clicks == 1) 3396 if (selection.clicks == 1)
3370 { 3397 {
3371 if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN 3398 if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN
3372 && !ROW(selection.beg.row).is_longer () 3399 && !ROW(selection.beg.row).is_longer ()
3373#if ENABLE_FRILLS 3400#if !ENABLE_MINIMAL
3374 && !selection.rect 3401 && !selection.rect
3375#endif 3402#endif
3376 ) 3403 )
3377 selection.beg.col = ncol; 3404 selection.beg.col = ncol;
3378 3405
3379 if ( 3406 if (
3380 selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN 3407 selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN
3381 && !ROW(selection.end.row).is_longer () 3408 && !ROW(selection.end.row).is_longer ()
3382#if ENABLE_FRILLS 3409#if !ENABLE_MINIMAL
3383 && !selection.rect 3410 && !selection.rect
3384#endif 3411#endif
3385 ) 3412 )
3386 selection.end.col = ncol; 3413 selection.end.col = ncol;
3387 } 3414 }
3394 selection_delimit_word (DN, &selection.end, &selection.end); 3421 selection_delimit_word (DN, &selection.end, &selection.end);
3395 } 3422 }
3396 else if (selection.clicks == 3) 3423 else if (selection.clicks == 3)
3397 { 3424 {
3398#if ENABLE_FRILLS 3425#if ENABLE_FRILLS
3399 if (OPTION (Opt_tripleclickwords)) 3426 if (option (Opt_tripleclickwords))
3400 { 3427 {
3401 selection_delimit_word (UP, &selection.beg, &selection.beg); 3428 selection_delimit_word (UP, &selection.beg, &selection.beg);
3402 3429
3403 for (int end_row = selection.mark.row; end_row < nrow; end_row++) 3430 for (int end_row = selection.mark.row; end_row < nrow; end_row++)
3404 { 3431 {
3405 if (!ROW(end_row).is_longer ()) 3432 if (!ROW(end_row).is_longer ())
3406 { 3433 {
3407 selection.end.row = end_row; 3434 selection.end.row = end_row;
3408 selection.end.col = ROW(end_row).l; 3435 selection.end.col = ROW(end_row).l;
3436# if !ENABLE_MINIMAL
3409 selection_remove_trailing_spaces (); 3437 selection_remove_trailing_spaces ();
3438# endif
3410 break; 3439 break;
3411 } 3440 }
3412 } 3441 }
3413 } 3442 }
3414 else 3443 else
3430 selection.end.row++; 3459 selection.end.row++;
3431 } 3460 }
3432 } 3461 }
3433 3462
3434 if (button3 && buttonpress) 3463 if (button3 && buttonpress)
3464 {
3435 { /* mark may need to be changed */ 3465 /* mark may need to be changed */
3436 if (closeto == LEFT) 3466 if (closeto == LEFT)
3437 { 3467 {
3438 selection.mark.row = selection.end.row; 3468 selection.mark.row = selection.end.row;
3439 selection.mark.col = selection.end.col - (selection.clicks == 2); 3469 selection.mark.col = selection.end.col - (selection.clicks == 2);
3440 } 3470 }
3443 selection.mark.row = selection.beg.row; 3473 selection.mark.row = selection.beg.row;
3444 selection.mark.col = selection.beg.col; 3474 selection.mark.col = selection.beg.col;
3445 } 3475 }
3446 } 3476 }
3447 3477
3448#if ENABLE_FRILLS 3478#if !ENABLE_MINIMAL
3449 if (selection.rect && selection.beg.col > selection.end.col) 3479 if (selection.rect && selection.beg.col > selection.end.col)
3450 ::swap (selection.beg.col, selection.end.col); 3480 ::swap (selection.beg.col, selection.end.col);
3451#endif 3481#endif
3452} 3482}
3453 3483
3454#if ENABLE_FRILLS 3484#if !ENABLE_MINIMAL
3455void 3485void
3456rxvt_term::selection_remove_trailing_spaces () NOTHROW 3486rxvt_term::selection_remove_trailing_spaces () NOTHROW
3457{ 3487{
3458 int32_t end_col, end_row; 3488 int32_t end_col, end_row;
3459 text_t *stp; 3489 text_t *stp;
3537 *target++ = xa[XA_COMPOUND_TEXT]; 3567 *target++ = xa[XA_COMPOUND_TEXT];
3538#if X_HAVE_UTF8_STRING 3568#if X_HAVE_UTF8_STRING
3539 *target++ = xa[XA_UTF8_STRING]; 3569 *target++ = xa[XA_UTF8_STRING];
3540#endif 3570#endif
3541 3571
3542 XChangeProperty (xdisp, rq.requestor, rq.property, XA_ATOM, 3572 XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM,
3543 32, PropModeReplace, 3573 32, PropModeReplace,
3544 (unsigned char *)target_list, target - target_list); 3574 (unsigned char *)target_list, target - target_list);
3545 ev.property = rq.property; 3575 ev.property = rq.property;
3546 } 3576 }
3547#if TODO // TODO 3577#if TODO // TODO
3550 /* TODO: Handle MULTIPLE */ 3580 /* TODO: Handle MULTIPLE */
3551 } 3581 }
3552#endif 3582#endif
3553 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3583 else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
3554 { 3584 {
3555 XChangeProperty (xdisp, rq.requestor, rq.property, rq.target, 3585 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3556 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3586 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3557 ev.property = rq.property; 3587 ev.property = rq.property;
3558 } 3588 }
3559 else if (rq.target == XA_STRING 3589 else if (rq.target == XA_STRING
3560 || rq.target == xa[XA_TEXT] 3590 || rq.target == xa[XA_TEXT]
3584 style = enc_string; 3614 style = enc_string;
3585 else if (target == xa[XA_TEXT]) 3615 else if (target == xa[XA_TEXT])
3586 style = enc_text; 3616 style = enc_text;
3587 else if (target == xa[XA_COMPOUND_TEXT]) 3617 else if (target == xa[XA_COMPOUND_TEXT])
3588 style = enc_compound_text; 3618 style = enc_compound_text;
3589#if ENABLE_FRILLS 3619#if !ENABLE_MINIMAL
3590 else if (target == xa[XA_UTF8_STRING]) 3620 else if (target == xa[XA_UTF8_STRING])
3591 style = enc_utf8; 3621 style = enc_utf8;
3592#endif 3622#endif
3593 else 3623 else
3594 { 3624 {
3605 { 3635 {
3606 cl = L""; 3636 cl = L"";
3607 selectlen = 0; 3637 selectlen = 0;
3608 } 3638 }
3609 3639
3610#if ENABLE_FRILLS 3640#if !ENABLE_MINIMAL
3611 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 3641 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
3612 // so recode it manually 3642 // so recode it manually
3613 if (style == enc_utf8) 3643 if (style == enc_utf8)
3614 { 3644 {
3615 freect = 1; 3645 freect = 1;
3618 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); 3648 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen);
3619 ct.nitems = strlen ((char *)ct.value); 3649 ct.nitems = strlen ((char *)ct.value);
3620 } 3650 }
3621 else 3651 else
3622#endif 3652#endif
3623 if (XwcTextListToTextProperty (xdisp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) 3653 if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
3624 freect = 1; 3654 freect = 1;
3625 else 3655 else
3626 { 3656 {
3627 /* if we failed to convert then send it raw */ 3657 /* if we failed to convert then send it raw */
3628 ct.value = (unsigned char *)cl; 3658 ct.value = (unsigned char *)cl;
3629 ct.nitems = selectlen; 3659 ct.nitems = selectlen;
3630 ct.encoding = target; 3660 ct.encoding = target;
3631 } 3661 }
3632 3662
3633 XChangeProperty (xdisp, rq.requestor, rq.property, 3663 XChangeProperty (dpy, rq.requestor, rq.property,
3634 ct.encoding, 8, PropModeReplace, 3664 ct.encoding, 8, PropModeReplace,
3635 ct.value, (int)ct.nitems); 3665 ct.value, (int)ct.nitems);
3636 ev.property = rq.property; 3666 ev.property = rq.property;
3637 3667
3638 if (freect) 3668 if (freect)
3639 XFree (ct.value); 3669 XFree (ct.value);
3640 } 3670 }
3641 3671
3642 XSendEvent (xdisp, rq.requestor, False, 0L, (XEvent *)&ev); 3672 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev);
3643}
3644
3645/* ------------------------------------------------------------------------- *
3646 * MOUSE ROUTINES *
3647 * ------------------------------------------------------------------------- */
3648
3649/*
3650 * return col/row values corresponding to x/y pixel values
3651 */
3652void
3653rxvt_term::pixel_position (int *x, int *y) NOTHROW
3654{
3655 *x = Pixel2Col (*x);
3656 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */
3657 *y = Pixel2Row (*y);
3658 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */
3659} 3673}
3660 3674
3661/* ------------------------------------------------------------------------- */ 3675/* ------------------------------------------------------------------------- */
3662#ifdef USE_XIM 3676#ifdef USE_XIM
3663void 3677void
3664rxvt_term::im_set_position (XPoint &pos) NOTHROW 3678rxvt_term::im_set_position (XPoint &pos) NOTHROW
3665{ 3679{
3666 XWindowAttributes xwa; 3680 XWindowAttributes xwa;
3667 3681
3668 XGetWindowAttributes (display->display, vt, &xwa); 3682 XGetWindowAttributes (dpy, vt, &xwa);
3669 3683
3670 pos.x = xwa.x + Col2Pixel (screen.cur.col); 3684 pos.x = xwa.x + Col2Pixel (screen.cur.col);
3671 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; 3685 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase;
3672} 3686}
3673#endif 3687#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines