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.240 by root, Thu Jan 19 17:21:20 2006 UTC vs.
Revision 1.264 by root, Thu Jul 6 18:56:10 2006 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-2006 Marc Lehmann <pcg@goof.com>
93 */ 93 */
94#define drawBuffer vt 94#define drawBuffer vt
95 95
96#define CLEAR_ROWS(row, num) \ 96#define CLEAR_ROWS(row, num) \
97 if (mapped) \ 97 if (mapped) \
98 XClearArea (display->display, drawBuffer, 0, \ 98 XClearArea (dpy, drawBuffer, 0, \
99 Row2Pixel (row), (unsigned int)width, \ 99 Row2Pixel (row), (unsigned int)width, \
100 (unsigned int)Height2Pixel (num), False) 100 (unsigned int)Height2Pixel (num), False)
101 101
102#define CLEAR_CHARS(x, y, num) \ 102#define CLEAR_CHARS(x, y, num) \
103 if (mapped) \ 103 if (mapped) \
104 XClearArea (display->display, drawBuffer, x, y, \ 104 XClearArea (dpy, drawBuffer, x, y, \
105 (unsigned int)Width2Pixel (num), \ 105 (unsigned int)Width2Pixel (num), \
106 (unsigned int)Height2Pixel (1), False) 106 (unsigned int)Height2Pixel (1), False)
107 107
108#define ERASE_ROWS(row, num) \ 108#define ERASE_ROWS(row, num) \
109 XFillRectangle (display->display, drawBuffer, gc, \ 109 XFillRectangle (dpy, drawBuffer, gc, \
110 0, Row2Pixel (row), \ 110 0, Row2Pixel (row), \
111 (unsigned int)width, \ 111 (unsigned int)width, \
112 (unsigned int)Height2Pixel (num)) 112 (unsigned int)Height2Pixel (num))
113 113
114/* ------------------------------------------------------------------------- * 114/* ------------------------------------------------------------------------- *
115 * SCREEN `COMMON' ROUTINES * 115 * SCREEN `COMMON' ROUTINES *
116 * ------------------------------------------------------------------------- */ 116 * ------------------------------------------------------------------------- */
117 117
118/* Fill part/all of a line with blanks. */ 118/* Fill part/all of a line with blanks. */
119void 119void
120rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const 120rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW
121{ 121{
122 if (!l.t) 122 if (!l.t)
123 { 123 {
124 lalloc (l); 124 lalloc (l);
125 col = 0; 125 col = 0;
126 width = ncol; 126 width = ncol;
127 } 127 }
128 128
129 l.touch (); 129 l.touch ();
130 130
131 efs &= ~RS_baseattrMask; 131 efs &= ~RS_baseattrMask; // remove italic etc. fontstyles
132 efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); 132 efs = SET_FONT (efs, FONTSET (efs)->find_font (' '));
133 133
134 text_t *et = l.t + col; 134 text_t *et = l.t + col;
135 rend_t *er = l.r + col; 135 rend_t *er = l.r + col;
136 136
142} 142}
143 143
144/* ------------------------------------------------------------------------- */ 144/* ------------------------------------------------------------------------- */
145/* Fill a full line with blanks - make sure it is allocated first */ 145/* Fill a full line with blanks - make sure it is allocated first */
146void 146void
147rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const 147rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW
148{ 148{
149 scr_blank_line (l, 0, ncol, efs); 149 scr_blank_line (l, 0, ncol, efs);
150 150
151 l.l = 0; 151 l.l = 0;
152 l.f = 0; 152 l.f = 0;
173 nrow = 24; 173 nrow = 24;
174 174
175 if (ncol == prev_ncol && nrow == prev_nrow) 175 if (ncol == prev_ncol && nrow == prev_nrow)
176 return; 176 return;
177 177
178 if (current_screen != PRIMARY)
179 scr_swap_screen ();
180
178 // we need at least two lines for wrapping to work correctly 181 // we need at least two lines for wrapping to work correctly
179 if (nrow + saveLines < 2) 182 while (nrow + saveLines < 2)
180 { 183 {
181 //TODO//FIXME 184 //TODO//FIXME
182 saveLines++; 185 saveLines++;
183 prev_nrow--; 186 prev_nrow--;
184 top_row--; 187 top_row--;
195 if (!row_buf) 198 if (!row_buf)
196 { 199 {
197 /* 200 /*
198 * first time called so just malloc everything: don't rely on realloc 201 * first time called so just malloc everything: don't rely on realloc
199 */ 202 */
200 top_row = 0; /* no saved lines */ 203 top_row = 0;
201 term_start = 0; 204 term_start = 0;
202 205
203 talloc = new rxvt_salloc (ncol * sizeof (text_t)); 206 talloc = new rxvt_salloc (ncol * sizeof (text_t));
204 ralloc = new rxvt_salloc (ncol * sizeof (rend_t)); 207 ralloc = new rxvt_salloc (ncol * sizeof (rend_t));
205 208
234 selection.text = NULL; 237 selection.text = NULL;
235 selection.len = 0; 238 selection.len = 0;
236 selection.op = SELECTION_CLEAR; 239 selection.op = SELECTION_CLEAR;
237 selection.screen = PRIMARY; 240 selection.screen = PRIMARY;
238 selection.clicks = 0; 241 selection.clicks = 0;
239 CLEAR_ALL_SELECTION (); 242 rvideo_state = rvideo_mode = false;
240 rvideo = 0;
241 } 243 }
242 else 244 else
243 { 245 {
244 CLEAR_ALL_SELECTION ();
245
246 /* 246 /*
247 * add or delete rows as appropriate 247 * add or delete rows as appropriate
248 */ 248 */
249 249
250 rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t)); 250 rxvt_salloc *old_ta = talloc; talloc = new rxvt_salloc (ncol * sizeof (text_t));
283 int pend = MOD (term_start + top_row , prev_total_rows); 283 int pend = MOD (term_start + top_row , prev_total_rows);
284 int q = total_rows; // rewrapped row 284 int q = total_rows; // rewrapped row
285 285
286 if (top_row) 286 if (top_row)
287 { 287 {
288 // re-wrap lines, this is rather ugly, possibly because I am too dumb 288 // Re-wrap lines. This is rather ugly, possibly because I am too dumb
289 // to come up with a lean and mean algorithm. 289 // to come up with a lean and mean algorithm.
290 290
291 row_col_t ocur = screen.cur; 291 row_col_t ocur = screen.cur;
292 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 292 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
293 293
350 350
351 line_t &pline = old_buf [prow]; 351 line_t &pline = old_buf [prow];
352 352
353 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); 353 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
354 354
355 assert (len);
356 assert (pline.t);
357
358 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); 355 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
359 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); 356 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
360 357
361 lofs += len; 358 lofs += len;
362 qcol += len; 359 qcol += len;
402 delete old_ra; 399 delete old_ra;
403 400
404 clamp_it (screen.cur.row, 0, nrow - 1); 401 clamp_it (screen.cur.row, 0, nrow - 1);
405 clamp_it (screen.cur.col, 0, ncol - 1); 402 clamp_it (screen.cur.col, 0, ncol - 1);
406 403
407 if (tabs)
408 free (tabs); 404 free (tabs);
409 } 405 }
406
407 CLEAR_ALL_SELECTION ();
410 408
411 prev_nrow = nrow; 409 prev_nrow = nrow;
412 prev_ncol = ncol; 410 prev_ncol = ncol;
413 411
414 tabs = (char *)rxvt_malloc (ncol * sizeof (char)); 412 tabs = (char *)rxvt_malloc (ncol * sizeof (char));
415 413
416 for (int col = ncol; col--; ) 414 for (int col = ncol; col--; )
417 tabs [col] = col % TABSIZE == 0; 415 tabs [col] = col % TABSIZE == 0;
418 416
417 if (current_screen != PRIMARY)
418 scr_swap_screen ();
419
419 tt_winch (); 420 tt_winch ();
420 421
421 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 422 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
422} 423}
423 424
424/* ------------------------------------------------------------------------- */ 425/* ------------------------------------------------------------------------- */
425/* 426/*
426 * Free everything. That way malloc debugging can find leakage. 427 * Free everything. That way malloc debugging can find leakage.
427 */ 428 */
428void 429void
429rxvt_term::scr_release () 430rxvt_term::scr_release () NOTHROW
430{ 431{
432 if (row_buf)
433 {
431 delete talloc; talloc = 0; 434 delete talloc; talloc = 0;
432 delete ralloc; ralloc = 0; 435 delete ralloc; ralloc = 0;
433 436
434 free (row_buf); 437 free (row_buf);
435 free (swap_buf); 438 free (swap_buf);
436 free (drawn_buf); 439 free (drawn_buf);
437 free (tabs); 440 free (tabs);
438 441
439 row_buf = 0; // signal that we freed all the arrays 442 row_buf = 0; // signal that we freed all the arrays
443 }
440} 444}
441 445
442/* ------------------------------------------------------------------------- */ 446/* ------------------------------------------------------------------------- */
443/* 447/*
444 * Hard reset 448 * Hard reset
461 * Save and Restore cursor 465 * Save and Restore cursor
462 * XTERM_SEQ: Save cursor : ESC 7 466 * XTERM_SEQ: Save cursor : ESC 7
463 * XTERM_SEQ: Restore cursor: ESC 8 467 * XTERM_SEQ: Restore cursor: ESC 8
464 */ 468 */
465void 469void
466rxvt_term::scr_cursor (int mode) 470rxvt_term::scr_cursor (cursor_mode mode) NOTHROW
467{ 471{
468 screen_t *s; 472 screen_t *s;
469 473
470#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) 474#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR)
471 if (current_screen == SECONDARY) 475 if (current_screen == SECONDARY)
503 assert (s->cur.row >= 0); 507 assert (s->cur.row >= 0);
504 assert (s->cur.col >= 0); 508 assert (s->cur.col >= 0);
505#endif 509#endif
506} 510}
507 511
512void
513rxvt_term::scr_swap_screen ()
514{
515 if (!OPTION (Opt_secondaryScreen))
516 return;
517
518 for (int i = prev_nrow; i--; )
519 ::swap (ROW(i), swap_buf [i]);
520
521 ::swap (screen.cur, swap.cur);
522
523 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
524 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
525}
526
508/* ------------------------------------------------------------------------- */ 527/* ------------------------------------------------------------------------- */
509/* 528/*
510 * Swap between primary and secondary screens 529 * Swap between primary and secondary screens
511 * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h 530 * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h
512 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l 531 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l
513 */ 532 */
514int 533void
515rxvt_term::scr_change_screen (int scrn) 534rxvt_term::scr_change_screen (int scrn)
516{ 535{
536 if (scrn == current_screen)
537 return;
538
517 want_refresh = 1; 539 want_refresh = 1;
518 view_start = 0; 540 view_start = 0;
519 541
520 if (current_screen == scrn)
521 return scrn;
522
523 selection_check (2); /* check for boundary cross */ 542 selection_check (2); /* check for boundary cross */
524 543
525 int i = current_screen; current_screen = scrn; scrn = i; 544 int i = current_screen; current_screen = scrn; scrn = i;
526
527 ::swap (screen.cur.row, swap.cur.row);
528 ::swap (screen.cur.col, swap.cur.col);
529
530 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
531 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
532 545
533#if NSCREENS 546#if NSCREENS
534 if (OPTION (Opt_secondaryScreen)) 547 if (OPTION (Opt_secondaryScreen))
535 { 548 {
536 num_scr = 0; 549 num_scr = 0;
537 550
538 for (int i = prev_nrow; i--; ) 551 scr_swap_screen ();
539 ::swap (ROW(i), swap_buf [i]);
540 552
541 ::swap (screen.charset, swap.charset); 553 ::swap (screen.charset, swap.charset);
542 ::swap (screen.flags, swap.flags); 554 ::swap (screen.flags, swap.flags);
543 screen.flags |= Screen_VisibleCursor; 555 screen.flags |= Screen_VisibleCursor;
544 swap.flags |= Screen_VisibleCursor; 556 swap.flags |= Screen_VisibleCursor;
545 } 557 }
546 else 558 else
547#endif 559#endif
548 if (OPTION (Opt_secondaryScroll)) 560 if (OPTION (Opt_secondaryScroll))
549 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 561 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
550
551 return scrn;
552} 562}
553 563
554// clear WrapNext indicator, solidifying position on next line 564// clear WrapNext indicator, solidifying position on next line
555void 565void
556rxvt_term::scr_do_wrap () 566rxvt_term::scr_do_wrap () NOTHROW
557{ 567{
558 if (!(screen.flags & Screen_WrapNext)) 568 if (!(screen.flags & Screen_WrapNext))
559 return; 569 return;
560 570
561 screen.flags &= ~Screen_WrapNext; 571 screen.flags &= ~Screen_WrapNext;
571/* ------------------------------------------------------------------------- */ 581/* ------------------------------------------------------------------------- */
572/* 582/*
573 * Change the colour for following text 583 * Change the colour for following text
574 */ 584 */
575void 585void
576rxvt_term::scr_color (unsigned int color, int fgbg) 586rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW
577{ 587{
578 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) 588 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
579 color = fgbg; 589 color = fgbg;
580 590
581 if (fgbg == Color_fg) 591 if (fgbg == Color_fg)
587/* ------------------------------------------------------------------------- */ 597/* ------------------------------------------------------------------------- */
588/* 598/*
589 * Change the rendition style for following text 599 * Change the rendition style for following text
590 */ 600 */
591void 601void
592rxvt_term::scr_rendition (int set, int style) 602rxvt_term::scr_rendition (int set, int style) NOTHROW
593 { 603 {
594 if (set) 604 if (set)
595 rstyle |= style; 605 rstyle |= style;
596 else if (style == ~RS_None) 606 else if (style == ~RS_None)
597 rstyle = DEFAULT_RSTYLE; 607 rstyle = DEFAULT_RSTYLE;
604 * Scroll text between <row1> and <row2> inclusive, by <count> lines 614 * Scroll text between <row1> and <row2> inclusive, by <count> lines
605 * count positive ==> scroll up 615 * count positive ==> scroll up
606 * count negative ==> scroll down 616 * count negative ==> scroll down
607 */ 617 */
608int 618int
609rxvt_term::scr_scroll_text (int row1, int row2, int count) 619rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW
610{ 620{
611 if (count == 0 || (row1 > row2)) 621 if (count == 0 || (row1 > row2))
612 return 0; 622 return 0;
613 623
614 want_refresh = 1; 624 want_refresh = 1;
631 } 641 }
632 642
633 // erase newly scrolled-in lines 643 // erase newly scrolled-in lines
634 for (int i = count; i--; ) 644 for (int i = count; i--; )
635 { 645 {
636 // basically this is a slightly optimized scr_blank_screen_mem
637 // it is worth the effort on slower machines
638 line_t &l = ROW(nrow - 1 - i); 646 line_t &l = ROW(nrow - 1 - i);
639 647
648 // optimize if already cleared, can be significant on slow machines
649 // could be rolled into scr_blank_screen_mem
650 if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask)))
651 {
640 scr_blank_line (l, 0, l.l, rstyle); 652 scr_blank_line (l, 0, l.l, rstyle);
641
642 l.l = 0; 653 l.l = 0;
643 l.f = 0; 654 l.f = 0;
655 }
656 else
657 scr_blank_screen_mem (l, rstyle);
644 } 658 }
645 659
646 // now copy lines below the scroll region bottom to the 660 // now copy lines below the scroll region bottom to the
647 // bottom of the screen again, so they look as if they 661 // bottom of the screen again, so they look as if they
648 // hadn't moved. 662 // hadn't moved.
732/* ------------------------------------------------------------------------- */ 746/* ------------------------------------------------------------------------- */
733/* 747/*
734 * Add text given in <str> of length <len> to screen struct 748 * Add text given in <str> of length <len> to screen struct
735 */ 749 */
736void 750void
737rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) 751rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
738{ 752{
739 if (len <= 0) /* sanity */ 753 if (len <= 0) /* sanity */
740 return; 754 return;
741 755
742 unsigned char checksel; 756 unsigned char checksel;
748 ZERO_SCROLLBACK (); 762 ZERO_SCROLLBACK ();
749 763
750 if (minlines > 0) 764 if (minlines > 0)
751 { 765 {
752 minlines += screen.cur.row - screen.bscroll; 766 minlines += screen.cur.row - screen.bscroll;
767 min_it (minlines, screen.cur.row - top_row);
753 768
754 if (minlines > 0 769 if (minlines > 0
755 && screen.tscroll == 0 770 && screen.tscroll == 0
756 && screen.bscroll == nrow - 1) 771 && screen.bscroll == nrow - 1)
757 { 772 {
831 846
832 // some utf-8 decoders "decode" surrogate characters: let's fix this. 847 // some utf-8 decoders "decode" surrogate characters: let's fix this.
833 if (IN_RANGE_INC (c, 0xd800, 0xdfff)) 848 if (IN_RANGE_INC (c, 0xd800, 0xdfff))
834 c = 0xfffd; 849 c = 0xfffd;
835 850
836 // rely on wcwidth to tell us the character width, at least for non-latin1 851 // rely on wcwidth to tell us the character width, do wcwidth before
837 // do wcwidth before further replacements, as wcwidth might return -1 852 // further replacements, as wcwidth might return -1 for the line
838 // for the line drawing characters below as they might be invalid in the current 853 // drawing characters below as they might be invalid in the current
839 // locale. 854 // locale.
840 int width = c < 0x100 ? 1 : wcwidth (c); 855 int width = WCWIDTH (c);
841 856
842 if (charsets [screen.charset] == '0') // DEC SPECIAL 857 if (charsets [screen.charset] == '0') // DEC SPECIAL
843 { 858 {
844 // vt100 special graphics and line drawing 859 // vt100 special graphics and line drawing
845 // 5f-7e standard vt100 860 // 5f-7e standard vt100
996/* 1011/*
997 * Process Backspace. Move back the cursor back a position, wrap if have to 1012 * Process Backspace. Move back the cursor back a position, wrap if have to
998 * XTERM_SEQ: CTRL-H 1013 * XTERM_SEQ: CTRL-H
999 */ 1014 */
1000void 1015void
1001rxvt_term::scr_backspace () 1016rxvt_term::scr_backspace () NOTHROW
1002{ 1017{
1003 want_refresh = 1; 1018 want_refresh = 1;
1004 1019
1005 if (screen.cur.col == 0) 1020 if (screen.cur.col == 0)
1006 { 1021 {
1024 * Process Horizontal Tab 1039 * Process Horizontal Tab
1025 * count: +ve = forward; -ve = backwards 1040 * count: +ve = forward; -ve = backwards
1026 * XTERM_SEQ: CTRL-I 1041 * XTERM_SEQ: CTRL-I
1027 */ 1042 */
1028void 1043void
1029rxvt_term::scr_tab (int count, bool ht) 1044rxvt_term::scr_tab (int count, bool ht) NOTHROW
1030{ 1045{
1031 int i, x; 1046 int i, x;
1032 1047
1033 want_refresh = 1; 1048 want_refresh = 1;
1034 i = x = screen.cur.col; 1049 i = x = screen.cur.col;
1099 * Process DEC Back Index 1114 * Process DEC Back Index
1100 * XTERM_SEQ: ESC 6 1115 * XTERM_SEQ: ESC 6
1101 * Move cursor left in row. If we're at the left boundary, shift everything 1116 * Move cursor left in row. If we're at the left boundary, shift everything
1102 * in that row right. Clear left column. 1117 * in that row right. Clear left column.
1103 */ 1118 */
1104#if ENABLE_FRILLS 1119#if !ENABLE_MINIMAL
1105void 1120void
1106rxvt_term::scr_backindex () 1121rxvt_term::scr_backindex () NOTHROW
1107{ 1122{
1108 if (screen.cur.col > 0) 1123 if (screen.cur.col > 0)
1109 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1124 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1110 else 1125 else
1111 scr_insdel_chars (1, INSERT); 1126 scr_insdel_chars (1, INSERT);
1116 * Process DEC Forward Index 1131 * Process DEC Forward Index
1117 * XTERM_SEQ: ESC 9 1132 * XTERM_SEQ: ESC 9
1118 * Move cursor right in row. If we're at the right boundary, shift everything 1133 * Move cursor right in row. If we're at the right boundary, shift everything
1119 * in that row left. Clear right column. 1134 * in that row left. Clear right column.
1120 */ 1135 */
1121#if ENABLE_FRILLS 1136#if !ENABLE_MINIMAL
1122void 1137void
1123rxvt_term::scr_forwardindex () 1138rxvt_term::scr_forwardindex () NOTHROW
1124{ 1139{
1125 if (screen.cur.col < ncol - 1) 1140 if (screen.cur.col < ncol - 1)
1126 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1141 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1127 else 1142 else
1128 { 1143 {
1141/* ------------------------------------------------------------------------- */ 1156/* ------------------------------------------------------------------------- */
1142/* 1157/*
1143 * Goto Row/Column 1158 * Goto Row/Column
1144 */ 1159 */
1145void 1160void
1146rxvt_term::scr_gotorc (int row, int col, int relative) 1161rxvt_term::scr_gotorc (int row, int col, int relative) NOTHROW
1147{ 1162{
1148 want_refresh = 1; 1163 want_refresh = 1;
1149 ZERO_SCROLLBACK (); 1164 ZERO_SCROLLBACK ();
1150 1165
1151 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; 1166 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1189/* ------------------------------------------------------------------------- */ 1204/* ------------------------------------------------------------------------- */
1190/* 1205/*
1191 * direction should be UP or DN 1206 * direction should be UP or DN
1192 */ 1207 */
1193void 1208void
1194rxvt_term::scr_index (enum page_dirn direction) 1209rxvt_term::scr_index (enum page_dirn direction) NOTHROW
1195{ 1210{
1196 int dirn; 1211 int dirn;
1197 1212
1198 want_refresh = 1; 1213 want_refresh = 1;
1199 ZERO_SCROLLBACK (); 1214 ZERO_SCROLLBACK ();
1218 * XTERM_SEQ: Clear line to right: ESC [ 0 K 1233 * XTERM_SEQ: Clear line to right: ESC [ 0 K
1219 * XTERM_SEQ: Clear line to left : ESC [ 1 K 1234 * XTERM_SEQ: Clear line to left : ESC [ 1 K
1220 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1235 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1221 */ 1236 */
1222void 1237void
1223rxvt_term::scr_erase_line (int mode) 1238rxvt_term::scr_erase_line (int mode) NOTHROW
1224{ 1239{
1225 unsigned int col, num; 1240 unsigned int col, num;
1226 1241
1227 want_refresh = 1; 1242 want_refresh = 1;
1228 ZERO_SCROLLBACK (); 1243 ZERO_SCROLLBACK ();
1272 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J 1287 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J
1273 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J 1288 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J
1274 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1289 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1275 */ 1290 */
1276void 1291void
1277rxvt_term::scr_erase_screen (int mode) 1292rxvt_term::scr_erase_screen (int mode) NOTHROW
1278{ 1293{
1279 int num; 1294 int num;
1280 int32_t row; 1295 int32_t row;
1281 rend_t ren; 1296 rend_t ren;
1282 XGCValues gcvalue; 1297 XGCValues gcvalue;
1327 } 1342 }
1328 else 1343 else
1329 { 1344 {
1330 ren = rstyle & (RS_fgMask | RS_bgMask); 1345 ren = rstyle & (RS_fgMask | RS_bgMask);
1331 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1346 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1332 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1347 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1333 ERASE_ROWS (row, num); 1348 ERASE_ROWS (row, num);
1334 gcvalue.foreground = pix_colors[Color_fg]; 1349 gcvalue.foreground = pix_colors[Color_fg];
1335 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1350 XChangeGC (dpy, gc, GCForeground, &gcvalue);
1336 } 1351 }
1337 1352
1338 for (; num--; row++) 1353 for (; num--; row++)
1339 { 1354 {
1340 scr_blank_screen_mem (ROW(row), rstyle); 1355 scr_blank_screen_mem (ROW(row), rstyle);
1341 scr_blank_line (drawn_buf [row], 0, ncol, ren); 1356 scr_blank_line (drawn_buf [row], 0, ncol, ren);
1342 } 1357 }
1343} 1358}
1344 1359
1345#if ENABLE_FRILLS 1360#if !ENABLE_MINIMAL
1346void 1361void
1347rxvt_term::scr_erase_savelines () 1362rxvt_term::scr_erase_savelines () NOTHROW
1348{ 1363{
1349 want_refresh = 1; 1364 want_refresh = 1;
1350 ZERO_SCROLLBACK (); 1365 ZERO_SCROLLBACK ();
1351 1366
1352 top_row = 0; 1367 top_row = 0;
1357/* 1372/*
1358 * Fill the screen with `E's 1373 * Fill the screen with `E's
1359 * XTERM_SEQ: Screen Alignment Test: ESC # 8 1374 * XTERM_SEQ: Screen Alignment Test: ESC # 8
1360 */ 1375 */
1361void 1376void
1362rxvt_term::scr_E () 1377rxvt_term::scr_E () NOTHROW
1363{ 1378{
1364 rend_t fs; 1379 rend_t fs;
1365 1380
1366 want_refresh = 1; 1381 want_refresh = 1;
1367 ZERO_SCROLLBACK (); 1382 ZERO_SCROLLBACK ();
1388/* ------------------------------------------------------------------------- */ 1403/* ------------------------------------------------------------------------- */
1389/* 1404/*
1390 * Insert/Delete <count> lines 1405 * Insert/Delete <count> lines
1391 */ 1406 */
1392void 1407void
1393rxvt_term::scr_insdel_lines (int count, int insdel) 1408rxvt_term::scr_insdel_lines (int count, int insdel) NOTHROW
1394{ 1409{
1395 int end; 1410 int end;
1396 1411
1397 ZERO_SCROLLBACK (); 1412 ZERO_SCROLLBACK ();
1398 1413
1418/* ------------------------------------------------------------------------- */ 1433/* ------------------------------------------------------------------------- */
1419/* 1434/*
1420 * Insert/Delete <count> characters from the current position 1435 * Insert/Delete <count> characters from the current position
1421 */ 1436 */
1422void 1437void
1423rxvt_term::scr_insdel_chars (int count, int insdel) 1438rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW
1424{ 1439{
1425 int col, row; 1440 int col, row;
1426 rend_t tr; 1441 rend_t tr;
1427 1442
1428 want_refresh = 1; 1443 want_refresh = 1;
1516/* 1531/*
1517 * Set the scrolling region 1532 * Set the scrolling region
1518 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1533 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1519 */ 1534 */
1520void 1535void
1521rxvt_term::scr_scroll_region (int top, int bot) 1536rxvt_term::scr_scroll_region (int top, int bot) NOTHROW
1522{ 1537{
1523 max_it (top, 0); 1538 max_it (top, 0);
1524 min_it (bot, nrow - 1); 1539 min_it (bot, nrow - 1);
1525 1540
1526 if (top > bot) 1541 if (top > bot)
1536 * Make the cursor visible/invisible 1551 * Make the cursor visible/invisible
1537 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h 1552 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h
1538 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l 1553 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l
1539 */ 1554 */
1540void 1555void
1541rxvt_term::scr_cursor_visible (int mode) 1556rxvt_term::scr_cursor_visible (int mode) NOTHROW
1542{ 1557{
1543 want_refresh = 1; 1558 want_refresh = 1;
1544 1559
1545 if (mode) 1560 if (mode)
1546 screen.flags |= Screen_VisibleCursor; 1561 screen.flags |= Screen_VisibleCursor;
1553 * Set/unset automatic wrapping 1568 * Set/unset automatic wrapping
1554 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h 1569 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h
1555 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l 1570 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l
1556 */ 1571 */
1557void 1572void
1558rxvt_term::scr_autowrap (int mode) 1573rxvt_term::scr_autowrap (int mode) NOTHROW
1559{ 1574{
1560 if (mode) 1575 if (mode)
1561 screen.flags |= Screen_Autowrap; 1576 screen.flags |= Screen_Autowrap;
1562 else 1577 else
1563 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); 1578 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);
1572 * and the cursor cannot be moved outside. 1587 * and the cursor cannot be moved outside.
1573 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h 1588 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h
1574 * XTERM_SEQ: Set Relative: ESC [ ? 6 l 1589 * XTERM_SEQ: Set Relative: ESC [ ? 6 l
1575 */ 1590 */
1576void 1591void
1577rxvt_term::scr_relative_origin (int mode) 1592rxvt_term::scr_relative_origin (int mode) NOTHROW
1578{ 1593{
1579 if (mode) 1594 if (mode)
1580 screen.flags |= Screen_Relative; 1595 screen.flags |= Screen_Relative;
1581 else 1596 else
1582 screen.flags &= ~Screen_Relative; 1597 screen.flags &= ~Screen_Relative;
1589 * Set insert/replace mode 1604 * Set insert/replace mode
1590 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h 1605 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h
1591 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l 1606 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l
1592 */ 1607 */
1593void 1608void
1594rxvt_term::scr_insert_mode (int mode) 1609rxvt_term::scr_insert_mode (int mode) NOTHROW
1595{ 1610{
1596 if (mode) 1611 if (mode)
1597 screen.flags |= Screen_Insert; 1612 screen.flags |= Screen_Insert;
1598 else 1613 else
1599 screen.flags &= ~Screen_Insert; 1614 screen.flags &= ~Screen_Insert;
1605 * XTERM_SEQ: Set tab at current column : ESC H 1620 * XTERM_SEQ: Set tab at current column : ESC H
1606 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g 1621 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g
1607 * XTERM_SEQ: Clear all tabs : ESC [ 3 g 1622 * XTERM_SEQ: Clear all tabs : ESC [ 3 g
1608 */ 1623 */
1609void 1624void
1610rxvt_term::scr_set_tab (int mode) 1625rxvt_term::scr_set_tab (int mode) NOTHROW
1611{ 1626{
1612 if (mode < 0) 1627 if (mode < 0)
1613 memset (tabs, 0, ncol * sizeof (char)); 1628 memset (tabs, 0, ncol * sizeof (char));
1614 else if (screen.cur.col < ncol) 1629 else if (screen.cur.col < ncol)
1615 tabs [screen.cur.col] = !!mode; 1630 tabs [screen.cur.col] = !!mode;
1620 * Set reverse/normal video 1635 * Set reverse/normal video
1621 * XTERM_SEQ: Reverse video: ESC [ ? 5 h 1636 * XTERM_SEQ: Reverse video: ESC [ ? 5 h
1622 * XTERM_SEQ: Normal video : ESC [ ? 5 l 1637 * XTERM_SEQ: Normal video : ESC [ ? 5 l
1623 */ 1638 */
1624void 1639void
1625rxvt_term::scr_rvideo_mode (int mode) 1640rxvt_term::scr_rvideo_mode (bool on) NOTHROW
1626{ 1641{
1627 XGCValues gcvalue; 1642 rvideo_mode = on;
1628 1643
1644#ifndef NO_BELL
1645 on ^= rvideo_bell;
1646#endif
1647
1629 if (rvideo != mode) 1648 if (rvideo_state != on)
1630 { 1649 {
1631 rvideo = mode; 1650 rvideo_state = on;
1651
1632 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1652 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1633#if XPM_BACKGROUND 1653#if XPM_BACKGROUND
1634 if (bgPixmap.pixmap == None) 1654 if (bgPixmap.pixmap == None)
1635#endif 1655#endif
1636#if TRANSPARENT 1656#if TRANSPARENT
1637 if (! OPTION (Opt_transparent) || am_transparent == 0) 1657 if (!OPTION (Opt_transparent) || am_transparent == 0)
1638#endif 1658#endif
1639 XSetWindowBackground (display->display, vt, 1659 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1640 pix_colors[Color_bg]);
1641 1660
1661 XGCValues gcvalue;
1642 gcvalue.foreground = pix_colors[Color_fg]; 1662 gcvalue.foreground = pix_colors[Color_fg];
1643 gcvalue.background = pix_colors[Color_bg]; 1663 gcvalue.background = pix_colors[Color_bg];
1644 XChangeGC (display->display, gc, GCBackground | GCForeground, 1664 XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue);
1645 &gcvalue); 1665
1646 scr_clear (); 1666 scr_clear ();
1647 scr_touch (true); 1667 scr_touch (true);
1648 } 1668 }
1649} 1669}
1650 1670
1652/* 1672/*
1653 * Report current cursor position 1673 * Report current cursor position
1654 * XTERM_SEQ: Report position: ESC [ 6 n 1674 * XTERM_SEQ: Report position: ESC [ 6 n
1655 */ 1675 */
1656void 1676void
1657rxvt_term::scr_report_position () 1677rxvt_term::scr_report_position () NOTHROW
1658{ 1678{
1659 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); 1679 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
1660} 1680}
1661 1681
1662/* ------------------------------------------------------------------------- * 1682/* ------------------------------------------------------------------------- *
1665 1685
1666/* 1686/*
1667 * Set font style 1687 * Set font style
1668 */ 1688 */
1669void 1689void
1670rxvt_term::set_font_style () 1690rxvt_term::set_font_style () NOTHROW
1671{ 1691{
1672#if 0 1692#if 0
1673 switch (charsets [screen.charset]) 1693 switch (charsets [screen.charset])
1674 { 1694 {
1675 case '0': /* DEC Special Character & Line Drawing Set */ 1695 case '0': /* DEC Special Character & Line Drawing Set */
1697 * XTERM_SEQ: Invoke G1 character set: CTRL-N 1717 * XTERM_SEQ: Invoke G1 character set: CTRL-N
1698 * XTERM_SEQ: Invoke G2 character set: ESC N 1718 * XTERM_SEQ: Invoke G2 character set: ESC N
1699 * XTERM_SEQ: Invoke G3 character set: ESC O 1719 * XTERM_SEQ: Invoke G3 character set: ESC O
1700 */ 1720 */
1701void 1721void
1702rxvt_term::scr_charset_choose (int set) 1722rxvt_term::scr_charset_choose (int set) NOTHROW
1703{ 1723{
1704 screen.charset = set; 1724 screen.charset = set;
1705 set_font_style (); 1725 set_font_style ();
1706} 1726}
1707 1727
1713 * XTERM_SEQ: Set G2 character set: ESC * <C> 1733 * XTERM_SEQ: Set G2 character set: ESC * <C>
1714 * XTERM_SEQ: Set G3 character set: ESC + <C> 1734 * XTERM_SEQ: Set G3 character set: ESC + <C>
1715 * See set_font_style for possible values for <C> 1735 * See set_font_style for possible values for <C>
1716 */ 1736 */
1717void 1737void
1718rxvt_term::scr_charset_set (int set, unsigned int ch) 1738rxvt_term::scr_charset_set (int set, unsigned int ch) NOTHROW
1719{ 1739{
1720 charsets[set] = (unsigned char)ch; 1740 charsets[set] = (unsigned char)ch;
1721 set_font_style (); 1741 set_font_style ();
1722} 1742}
1723 1743
1728 1748
1729/* 1749/*
1730 * refresh matching text. 1750 * refresh matching text.
1731 */ 1751 */
1732bool 1752bool
1733rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) 1753rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW
1734{ 1754{
1735 bool found = false; 1755 bool found = false;
1736 1756
1737 for (int i = 0; i < nrow; i++) 1757 for (int i = 0; i < nrow; i++)
1738 { 1758 {
1739 int col = 0;
1740 rend_t *drp = drawn_buf[i].r; 1759 rend_t *drp = drawn_buf[i].r;
1741 1760
1742 for (; col < ncol; col++, drp++) 1761 for (int col = 0; col < ncol; col++, drp++)
1743 if ((*drp & mask) == value) 1762 if ((*drp & mask) == value)
1744 { 1763 {
1745 found = true; 1764 found = true;
1746 *drp = ~value; 1765 *drp = ~value;
1747 } 1766 }
1758 PART_END, 1777 PART_END,
1759 RC_COUNT 1778 RC_COUNT
1760}; 1779};
1761 1780
1762void 1781void
1763rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) 1782rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW
1764{ 1783{
1765 int i; 1784 int i;
1766 row_col_t rc[RC_COUNT]; 1785 row_col_t rc[RC_COUNT];
1767 1786
1768 if (!drawn_buf) /* sanity check */ 1787 if (!drawn_buf) /* sanity check */
1802/* ------------------------------------------------------------------------- */ 1821/* ------------------------------------------------------------------------- */
1803/* 1822/*
1804 * Refresh the entire screen 1823 * Refresh the entire screen
1805 */ 1824 */
1806void 1825void
1807rxvt_term::scr_touch (bool refresh) 1826rxvt_term::scr_touch (bool refresh) NOTHROW
1808{ 1827{
1809 scr_expose (0, 0, width, height, refresh); 1828 scr_expose (0, 0, width, height, refresh);
1810} 1829}
1811 1830
1812/* ------------------------------------------------------------------------- */ 1831/* ------------------------------------------------------------------------- */
1813/* 1832/*
1814 * Move the display so that the line represented by scrollbar value Y is at 1833 * Move the display so that the line represented by scrollbar value Y is at
1815 * the top of the screen 1834 * the top of the screen
1816 */ 1835 */
1817void 1836void
1818rxvt_term::scr_move_to (int y, int len) 1837rxvt_term::scr_move_to (int y, int len) NOTHROW
1819{ 1838{
1820 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1839 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1));
1821} 1840}
1822 1841
1823/* ------------------------------------------------------------------------- */ 1842/* ------------------------------------------------------------------------- */
1824/* 1843/*
1825 * Page the screen up/down nlines 1844 * Page the screen up/down nlines
1826 * direction should be UP or DN 1845 * direction should be UP or DN
1827 */ 1846 */
1828bool 1847bool
1829rxvt_term::scr_page (enum page_dirn direction, int nlines) 1848rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW
1830{ 1849{
1831 int new_view_start = 1850 int new_view_start =
1832 direction == UP ? view_start - nlines 1851 direction == UP ? view_start - nlines
1833 : view_start + nlines; 1852 : view_start + nlines;
1834 1853
1835 return scr_changeview (new_view_start); 1854 return scr_changeview (new_view_start);
1836} 1855}
1837 1856
1838bool 1857bool
1839rxvt_term::scr_changeview (int new_view_start) 1858rxvt_term::scr_changeview (int new_view_start) NOTHROW
1840{ 1859{
1841 clamp_it (new_view_start, top_row, 0); 1860 clamp_it (new_view_start, top_row, 0);
1842 1861
1843 if (new_view_start == view_start) 1862 if (new_view_start == view_start)
1844 return false; 1863 return false;
1850 HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); 1869 HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1851 1870
1852 return true; 1871 return true;
1853} 1872}
1854 1873
1855/* ------------------------------------------------------------------------- */ 1874#ifndef NO_BELL
1856void 1875void
1876rxvt_term::bell_cb (time_watcher &w)
1877{
1878 rvideo_bell = false;
1879 scr_rvideo_mode (rvideo_mode);
1880}
1881#endif
1882
1883/* ------------------------------------------------------------------------- */
1884void
1857rxvt_term::scr_bell () 1885rxvt_term::scr_bell () NOTHROW
1858{ 1886{
1859#ifndef NO_BELL 1887#ifndef NO_BELL
1860 1888
1861# ifndef NO_MAPALERT 1889# ifndef NO_MAPALERT
1862# ifdef MAPALERT_OPTION 1890# ifdef MAPALERT_OPTION
1863 if (OPTION (Opt_mapAlert)) 1891 if (OPTION (Opt_mapAlert))
1864# endif 1892# endif
1865 XMapWindow (display->display, parent[0]); 1893 XMapWindow (dpy, parent[0]);
1866# endif 1894# endif
1867 1895
1868 if (OPTION (Opt_visualBell)) 1896 if (OPTION (Opt_visualBell))
1869 { 1897 {
1870 scr_rvideo_mode (!rvideo); /* refresh also done */ 1898 rvideo_bell = true;
1899 scr_rvideo_mode (rvideo_mode);
1871 display->flush (); 1900 display->flush ();
1872 rxvt_usleep (VISUAL_BELL_DURATION); 1901
1873 scr_rvideo_mode (!rvideo); /* refresh also done */ 1902 bell_ev.start (NOW + VISUAL_BELL_DURATION);
1874 } 1903 }
1875 else 1904 else
1876 XBell (display->display, 0); 1905 XBell (dpy, 0);
1877 1906
1878#endif 1907#endif
1879} 1908}
1880 1909
1881/* ------------------------------------------------------------------------- */ 1910/* ------------------------------------------------------------------------- */
1882/* ARGSUSED */ 1911/* ARGSUSED */
1883void 1912void
1884rxvt_term::scr_printscreen (int fullhist) 1913rxvt_term::scr_printscreen (int fullhist) NOTHROW
1885{ 1914{
1886#ifdef PRINTPIPE 1915#ifdef PRINTPIPE
1887 int nrows, row_start; 1916 int nrows, row_start;
1888 FILE *fd; 1917 FILE *fd;
1889 1918
1938 * Refresh the screen 1967 * Refresh the screen
1939 * drawn_text/drawn_rend contain the screen information before the update. 1968 * drawn_text/drawn_rend contain the screen information before the update.
1940 * screen.text/screen.rend contain what the screen will change to. 1969 * screen.text/screen.rend contain what the screen will change to.
1941 */ 1970 */
1942void 1971void
1943rxvt_term::scr_refresh () 1972rxvt_term::scr_refresh () NOTHROW
1944{ 1973{
1945 unsigned char must_clear, /* use draw_string not draw_image_string */ 1974 unsigned char have_bg,
1946 showcursor; /* show the cursor */ 1975 showcursor; /* show the cursor */
1947 int16_t col, row, /* column/row we're processing */ 1976 int16_t col, row, /* column/row we're processing */
1948 ocrow; /* old cursor row */ 1977 ocrow; /* old cursor row */
1949 int i; /* tmp */ 1978 int i; /* tmp */
1950#ifndef NO_CURSORCOLOR 1979#ifndef NO_CURSORCOLOR
1958 return; 1987 return;
1959 1988
1960 /* 1989 /*
1961 * A: set up vars 1990 * A: set up vars
1962 */ 1991 */
1963 must_clear = 0; 1992 have_bg = 0;
1964 refresh_count = 0; 1993 refresh_count = 0;
1965 1994
1966#if XPM_BACKGROUND 1995#if XPM_BACKGROUND
1967 must_clear |= bgPixmap.pixmap != None; 1996 have_bg |= bgPixmap.pixmap != None;
1968#endif 1997#endif
1969#if TRANSPARENT 1998#if TRANSPARENT
1970 must_clear |= OPTION (Opt_transparent) && am_transparent; 1999 have_bg |= OPTION (Opt_transparent) && am_transparent;
1971#endif 2000#endif
1972 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2001 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1973 2002
1974 /* 2003 /*
1975 * B: reverse any characters which are selected 2004 * B: reverse any characters which are selected
2074 * D: CopyArea pass - very useful for slower links 2103 * D: CopyArea pass - very useful for slower links
2075 * This has been deliberately kept simple. 2104 * This has been deliberately kept simple.
2076 */ 2105 */
2077 if (!display->is_local 2106 if (!display->is_local
2078 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr 2107 && refresh_type == FAST_REFRESH && num_scr_allow && num_scr
2079 && abs (num_scr) < nrow && !must_clear) 2108 && abs (num_scr) < nrow && !have_bg)
2080 { 2109 {
2081 int16_t nits; 2110 int16_t nits;
2111 int i = num_scr;
2082 int j; 2112 int j;
2083 int len, wlen; 2113 int len, wlen;
2084 dLocal (int, num_scr); 2114 dLocal (int, num_scr);
2085 2115
2086 j = nrow; 2116 j = nrow;
2087 wlen = len = -1; 2117 wlen = len = -1;
2088 row = i > 0 ? 0 : j - 1; 2118 row = i > 0 ? 0 : j - 1;
2119
2089 for (; j-- >= 0; row += (i > 0 ? 1 : -1)) 2120 for (; j-- >= 0; row += (i > 0 ? 1 : -1))
2090 { 2121 {
2091 if (row + i >= 0 && row + i < nrow && row + i != ocrow) 2122 if (row + i >= 0 && row + i < nrow && row + i != ocrow)
2092 { 2123 {
2093 line_t s = ROW(view_start + row); 2124 line_t s = ROW(view_start + row);
2114 wlen = row; 2145 wlen = row;
2115 continue; 2146 continue;
2116 } 2147 }
2117 } 2148 }
2118 2149
2119 if (len != -1) 2150 if (len >= 0)
2120 { 2151 {
2121 /* also comes here at end if needed because of >= above */ 2152 /* also comes here at end if needed because of >= above */
2122 if (wlen < len) 2153 if (wlen < len)
2123 ::swap (wlen, len); 2154 ::swap (wlen, len);
2124 2155
2156 XGCValues gcv;
2157
2158 gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv);
2125 XCopyArea (display->display, vt, vt, 2159 XCopyArea (dpy, vt, vt,
2126 gc, 0, Row2Pixel (len + i), 2160 gc, 0, Row2Pixel (len + i),
2127 (unsigned int)this->width, 2161 (unsigned int)this->width,
2128 (unsigned int)Height2Pixel (wlen - len + 1), 2162 (unsigned int)Height2Pixel (wlen - len + 1),
2129 0, Row2Pixel (len)); 2163 0, Row2Pixel (len));
2164 gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv);
2165
2130 len = -1; 2166 len = -1;
2131 } 2167 }
2132 } 2168 }
2133 } 2169 }
2134#endif 2170#endif
2190 count++; 2226 count++;
2191 2227
2192 if (stp[col] != dtp[col] 2228 if (stp[col] != dtp[col]
2193 || !RS_SAME (srp[col], drp[col])) 2229 || !RS_SAME (srp[col], drp[col]))
2194 { 2230 {
2195 if (must_clear && (i++ > count / 2)) 2231 if (have_bg && (i++ > count / 2))
2196 break; 2232 break;
2197 2233
2198 dtp[col] = stp[col]; 2234 dtp[col] = stp[col];
2199 drp[col] = rend; 2235 drp[col] = rend;
2200 i = 0; 2236 i = 0;
2201 } 2237 }
2202 else if (must_clear || (stp[col] != ' ' && ++i >= 16)) 2238 else if (have_bg || (stp[col] != ' ' && ++i >= 16))
2203 break; 2239 break;
2204 } 2240 }
2205 2241
2206 col--; /* went one too far. move back */ 2242 col--; /* went one too far. move back */
2207 count -= i; /* dump any matching trailing chars */ 2243 count -= i; /* dump any matching trailing chars */
2217 int back = bgcolor_of (rend); // desired background 2253 int back = bgcolor_of (rend); // desired background
2218 2254
2219 // only do special processing if any attributes are set, which is unlikely 2255 // only do special processing if any attributes are set, which is unlikely
2220 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2256 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2221 { 2257 {
2222#if ENABLE_STYLES
2223 // force redraw after "careful" characters to avoid pixel droppings
2224 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2225 drp[col + 1] = ~srp[col + 1];
2226
2227 // include previous careful character(s) if possible, looks nicer (best effort...)
2228 while (text > stp
2229 && srp[text - stp - 1] & RS_Careful
2230 && RS_SAME (rend, srp[text - stp - 1]))
2231 text--, count++, xpixel -= fwidth;
2232#endif
2233
2234 bool invert = rend & RS_RVid; 2258 bool invert = rend & RS_RVid;
2235 2259
2236#ifndef NO_BOLD_UNDERLINE_REVERSE 2260#ifndef NO_BOLD_UNDERLINE_REVERSE
2237 if (rend & RS_Bold 2261 if (rend & RS_Bold
2238 && fore == Color_fg) 2262 && fore == Color_fg)
2254 else 2278 else
2255 invert = !invert; 2279 invert = !invert;
2256# endif 2280# endif
2257 } 2281 }
2258 2282
2259 if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) 2283 if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL))
2260 fore = Color_UL; 2284 fore = Color_UL;
2261#endif 2285#endif
2262 2286
2263 if (invert) 2287 if (invert)
2264 { 2288 {
2289#ifdef OPTION_HC
2290 if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col)
2291 || !ISSET_PIXCOLOR (Color_HC))
2292#endif
2293 /* invert the column if no highlightColor is set or it is the
2294 * current cursor column */
2265 ::swap (fore, back); 2295 ::swap (fore, back);
2296#ifdef OPTION_HC
2297 else if (ISSET_PIXCOLOR (Color_HC))
2298 back = Color_HC;
2299#endif
2266 2300
2267#ifndef NO_BOLD_UNDERLINE_REVERSE 2301#ifndef NO_BOLD_UNDERLINE_REVERSE
2302# ifndef OPTION_HC
2268 if (ISSET_PIXCOLOR (Color_RV)) 2303 if (ISSET_PIXCOLOR (Color_RV))
2269 back = Color_RV; 2304 back = Color_RV;
2270 2305# endif
2271 if (fore == back) 2306 if (fore == back)
2272 { 2307 {
2273 fore = Color_bg; 2308 fore = Color_bg;
2274 back = Color_fg; 2309 back = Color_fg;
2275 } 2310 }
2286 } 2321 }
2287 else if (hidden_text) 2322 else if (hidden_text)
2288 fore = back; 2323 fore = back;
2289 } 2324 }
2290#endif 2325#endif
2326
2327#if ENABLE_STYLES
2328 // "careful" (too wide) character handling
2329
2330 // include previous careful character(s) if possible, looks nicer (best effort...)
2331 while (text > stp
2332 && srp[text - stp - 1] & RS_Careful
2333 && RS_SAME (rend, srp[text - stp - 1]))
2334 text--, count++, xpixel -= fwidth;
2335
2336 // force redraw after "careful" characters to avoid pixel droppings
2337 for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
2338 drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw;
2339
2340 // force redraw before "careful" characters to avoid pixel droppings
2341 for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++)
2342 drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw;
2343#endif
2291 } 2344 }
2292 2345
2293 /* 2346 /*
2294 * Actually do the drawing of the string here 2347 * Actually do the drawing of the string here
2295 */ 2348 */
2296 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; 2349 rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)];
2297 2350
2298 if (back == fore) 2351 if (back == fore)
2299 font->clear_rect (*drawable, xpixel, ypixel, 2352 font->clear_rect (*drawable, xpixel, ypixel, fwidth * count, fheight, back);
2300 fwidth * count, fheight,
2301 back);
2302 else if (back == Color_bg) 2353 else if (back == Color_bg && have_bg)
2303 { 2354 {
2304 if (must_clear) 2355 // this is very ugly, maybe push it into ->draw?
2305 {
2306 CLEAR_CHARS (xpixel, ypixel, count);
2307 2356
2308 for (i = 0; i < count; i++) /* don't draw empty strings */ 2357 for (i = 0; i < count; i++) /* don't draw empty strings */
2309 if (text[i] != ' ') 2358 if (text[i] != ' ')
2310 { 2359 {
2311 font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); 2360 font->draw (*drawable, xpixel, ypixel, text, count, fore, -1);
2312 break; 2361 goto did_clear;
2313 }
2314 } 2362 }
2315 else 2363
2316 font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); 2364 CLEAR_CHARS (xpixel, ypixel, count);
2365 did_clear: ;
2317 } 2366 }
2318 else 2367 else
2319 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2368 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2320 2369
2321 if (rend & RS_Uline && font->descent > 1 && fore != back) 2370 if (rend & RS_Uline && font->descent > 1 && fore != back)
2322 { 2371 {
2323#if ENABLE_FRILLS 2372#if ENABLE_FRILLS
2324 if (ISSET_PIXCOLOR (Color_underline)) 2373 if (ISSET_PIXCOLOR (Color_underline))
2325 XSetForeground (display->display, gc, pix_colors[Color_underline]); 2374 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2326 else 2375 else
2327#endif 2376#endif
2328 XSetForeground (display->display, gc, pix_colors[fore]); 2377 XSetForeground (dpy, gc, pix_colors[fore]);
2329 2378
2330 XDrawLine (display->display, drawBuffer, gc, 2379 XDrawLine (dpy, drawBuffer, gc,
2331 xpixel, ypixel + font->ascent + 1, 2380 xpixel, ypixel + font->ascent + 1,
2332 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2381 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2333 } 2382 }
2334 } /* for (col....) */ 2383 } /* for (col....) */
2335 } /* for (row....) */ 2384 } /* for (row....) */
2368 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) 2417 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2369 cursorwidth++; 2418 cursorwidth++;
2370 2419
2371#ifndef NO_CURSORCOLOR 2420#ifndef NO_CURSORCOLOR
2372 if (ISSET_PIXCOLOR (Color_cursor)) 2421 if (ISSET_PIXCOLOR (Color_cursor))
2373 XSetForeground (display->display, gc, pix_colors[Color_cursor]); 2422 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2374#endif 2423#endif
2375 2424
2376 XDrawRectangle (display->display, drawBuffer, gc, 2425 XDrawRectangle (dpy, drawBuffer, gc,
2377 Col2Pixel (col), 2426 Col2Pixel (col),
2378 Row2Pixel (oldcursor.row), 2427 Row2Pixel (oldcursor.row),
2379 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2428 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2380 (unsigned int) (Height2Pixel (1) - lineSpace - 1)); 2429 (unsigned int) (Height2Pixel (1) - lineSpace - 1));
2381 } 2430 }
2389 num_scr = 0; 2438 num_scr = 0;
2390 num_scr_allow = 1; 2439 num_scr_allow = 1;
2391} 2440}
2392 2441
2393void 2442void
2394rxvt_term::scr_remap_chars (line_t &l) 2443rxvt_term::scr_remap_chars (line_t &l) NOTHROW
2395{ 2444{
2396 if (!l.t) 2445 if (!l.t)
2397 return; 2446 return;
2398 2447
2399 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant 2448 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant
2401 for (int i = ncol; i--; ) 2450 for (int i = ncol; i--; )
2402 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2451 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2403} 2452}
2404 2453
2405void 2454void
2406rxvt_term::scr_remap_chars () 2455rxvt_term::scr_remap_chars () NOTHROW
2407{ 2456{
2408 for (int i = total_rows; i--; ) 2457 for (int i = total_rows; i--; )
2409 scr_remap_chars (row_buf [i]); 2458 scr_remap_chars (row_buf [i]);
2410 2459
2411 for (int i = nrow; i--; ) 2460 for (int i = nrow; i--; )
2414 scr_remap_chars (swap_buf [i]); 2463 scr_remap_chars (swap_buf [i]);
2415 } 2464 }
2416} 2465}
2417 2466
2418void 2467void
2419rxvt_term::scr_recolour () 2468rxvt_term::scr_recolour () NOTHROW
2420{ 2469{
2421 if (1 2470 if (1
2422#if TRANSPARENT 2471#if TRANSPARENT
2423 && !am_transparent 2472 && !am_transparent
2424#endif 2473#endif
2425#if XPM_BACKGROUND 2474#if XPM_BACKGROUND
2426 && !bgPixmap.pixmap 2475 && !bgPixmap.pixmap
2427#endif 2476#endif
2428 ) 2477 )
2429 { 2478 {
2430 XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); 2479 XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]);
2431 XClearWindow (display->display, parent[0]); 2480 XClearWindow (dpy, parent[0]);
2432 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 2481 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2433#if HAVE_SCROLLBARS 2482#if HAVE_SCROLLBARS
2434 if (scrollBar.win) 2483 if (scrollBar.win)
2435 { 2484 {
2436 XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); 2485 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]);
2437 scrollBar.setIdle (); 2486 scrollBar.setIdle ();
2438 scrollbar_show (0); 2487 scrollbar_show (0);
2439 } 2488 }
2440#endif 2489#endif
2441 } 2490 }
2445 want_refresh = 1; 2494 want_refresh = 1;
2446} 2495}
2447 2496
2448/* ------------------------------------------------------------------------- */ 2497/* ------------------------------------------------------------------------- */
2449void 2498void
2450rxvt_term::scr_clear (bool really) 2499rxvt_term::scr_clear (bool really) NOTHROW
2451{ 2500{
2452 if (!mapped) 2501 if (!mapped)
2453 return; 2502 return;
2454 2503
2455 num_scr_allow = 0; 2504 num_scr_allow = 0;
2456 want_refresh = 1; 2505 want_refresh = 1;
2457 2506
2458 if (really) 2507 if (really)
2459 XClearWindow (display->display, vt); 2508 XClearWindow (dpy, vt);
2460} 2509}
2461 2510
2462void 2511void
2463rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) 2512rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW
2464{ 2513{
2465 int view_end = view_start + nrow; 2514 int view_end = view_start + nrow;
2466 int row, col; 2515 int row, col;
2467 2516
2468 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) 2517 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++)
2480 srp[col] ^= rstyle2; 2529 srp[col] ^= rstyle2;
2481 } 2530 }
2482} 2531}
2483 2532
2484void 2533void
2485rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) 2534rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW
2486{ 2535{
2487 int view_end = view_start + nrow; 2536 int view_end = view_start + nrow;
2488 int row, col; 2537 int row, col;
2489 2538
2490 if (beg_row >= view_start) 2539 if (beg_row >= view_start)
2507 srp[col] ^= rstyle; 2556 srp[col] ^= rstyle;
2508} 2557}
2509 2558
2510/* ------------------------------------------------------------------------- */ 2559/* ------------------------------------------------------------------------- */
2511void 2560void
2512rxvt_term::scr_reverse_selection () 2561rxvt_term::scr_reverse_selection () NOTHROW
2513{ 2562{
2514 if (selection.op 2563 if (selection.op
2515 && current_screen == selection.screen 2564 && current_screen == selection.screen
2516 && selection.end.row >= view_start) 2565 && selection.end.row >= view_start)
2517 { 2566 {
2518#if ENABLE_FRILLS 2567#if !ENABLE_MINIMAL
2519 if (selection.rect) 2568 if (selection.rect)
2520 scr_xor_rect (selection.beg.row, selection.beg.col, 2569 scr_xor_rect (selection.beg.row, selection.beg.col,
2521 selection.end.row, selection.end.col, 2570 selection.end.row, selection.end.col,
2522 RS_RVid, RS_RVid | RS_Uline); 2571 RS_RVid, RS_RVid | RS_Uline);
2523 else 2572 else
2533 * Dump the whole scrollback and screen to the passed filedescriptor. The 2582 * Dump the whole scrollback and screen to the passed filedescriptor. The
2534 * invoking routine must close the fd. 2583 * invoking routine must close the fd.
2535 */ 2584 */
2536#if 0 2585#if 0
2537void 2586void
2538rxvt_term::scr_dump (int fd) 2587rxvt_term::scr_dump (int fd) NOTHROW
2539{ 2588{
2540 int row, wrote; 2589 int row, wrote;
2541 unsigned int width, towrite; 2590 unsigned int width, towrite;
2542 char r1[] = "\n"; 2591 char r1[] = "\n";
2543 2592
2562 2611
2563/* ------------------------------------------------------------------------- * 2612/* ------------------------------------------------------------------------- *
2564 * CHARACTER SELECTION * 2613 * CHARACTER SELECTION *
2565 * ------------------------------------------------------------------------- */ 2614 * ------------------------------------------------------------------------- */
2566void 2615void
2567rxvt_term::selection_check (int check_more) 2616rxvt_term::selection_check (int check_more) NOTHROW
2568{ 2617{
2569 row_col_t pos; 2618 row_col_t pos;
2570 2619
2571 if (!selection.op) 2620 if (!selection.op)
2572 return; 2621 return;
2593/* ------------------------------------------------------------------------- */ 2642/* ------------------------------------------------------------------------- */
2594/* 2643/*
2595 * Paste a selection direct to the command fd 2644 * Paste a selection direct to the command fd
2596 */ 2645 */
2597void 2646void
2598rxvt_term::paste (char *data, unsigned int len) 2647rxvt_term::paste (char *data, unsigned int len) NOTHROW
2599{ 2648{
2600 /* convert normal newline chars into common keyboard Return key sequence */ 2649 /* convert normal newline chars into common keyboard Return key sequence */
2601 for (unsigned int i = 0; i < len; i++) 2650 for (unsigned int i = 0; i < len; i++)
2602 if (data[i] == C0_LF) 2651 if (data[i] == C0_LF)
2603 data[i] = C0_CR; 2652 data[i] = C0_CR;
2609/* 2658/*
2610 * Respond to a notification that a primary selection has been sent 2659 * Respond to a notification that a primary selection has been sent
2611 * EXT: SelectionNotify 2660 * EXT: SelectionNotify
2612 */ 2661 */
2613void 2662void
2614rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) 2663rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) NOTHROW
2615{ 2664{
2616 if (prop == None) /* check for failed XConvertSelection */ 2665 if (prop == None) /* check for failed XConvertSelection */
2617 { 2666 {
2618 if ((selection_type & Sel_CompoundText)) 2667 if ((selection_type & Sel_CompoundText))
2619 { 2668 {
2639 } 2688 }
2640 2689
2641 unsigned long bytes_after; 2690 unsigned long bytes_after;
2642 XTextProperty ct; 2691 XTextProperty ct;
2643 2692
2644 if (XGetWindowProperty (display->display, win, prop, 2693 if (XGetWindowProperty (dpy, win, prop,
2645 0, PROP_SIZE / 4, 2694 0, PROP_SIZE / 4,
2646 delete_prop, AnyPropertyType, 2695 delete_prop, AnyPropertyType,
2647 &ct.encoding, &ct.format, 2696 &ct.encoding, &ct.format,
2648 &ct.nitems, &bytes_after, 2697 &ct.nitems, &bytes_after,
2649 &ct.value) != Success) 2698 &ct.value) != Success)
2658 if (bytes_after) 2707 if (bytes_after)
2659 { 2708 {
2660 // fetch and append remaining data 2709 // fetch and append remaining data
2661 XTextProperty ct2; 2710 XTextProperty ct2;
2662 2711
2663 if (XGetWindowProperty (display->display, win, prop, 2712 if (XGetWindowProperty (dpy, win, prop,
2664 ct.nitems / 4, (bytes_after + 3) / 4, 2713 ct.nitems / 4, (bytes_after + 3) / 4,
2665 delete_prop, AnyPropertyType, 2714 delete_prop, AnyPropertyType,
2666 &ct2.encoding, &ct2.format, 2715 &ct2.encoding, &ct2.format,
2667 &ct2.nitems, &bytes_after, 2716 &ct2.nitems, &bytes_after,
2668 &ct2.value) != Success) 2717 &ct2.value) != Success)
2681 2730
2682 if (ct.encoding == xa[XA_INCR]) 2731 if (ct.encoding == xa[XA_INCR])
2683 { 2732 {
2684 // INCR selection, start handshake 2733 // INCR selection, start handshake
2685 if (!delete_prop) 2734 if (!delete_prop)
2686 XDeleteProperty (display->display, win, prop); 2735 XDeleteProperty (dpy, win, prop);
2687 2736
2688 selection_wait = Sel_incr; 2737 selection_wait = Sel_incr;
2689 incr_buf_fill = 0; 2738 incr_buf_fill = 0;
2690 incr_ev.start (NOW + 10); 2739 incr_ev.start (NOW + 10);
2691 2740
2738 } 2787 }
2739 2788
2740 char **cl; 2789 char **cl;
2741 int cr; 2790 int cr;
2742 2791
2743#if ENABLE_FRILLS 2792#if !ENABLE_MINIMAL
2744 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 2793 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
2745 // so recode it manually 2794 // so recode it manually
2746 if (ct.encoding == xa[XA_UTF8_STRING]) 2795 if (ct.encoding == xa[XA_UTF8_STRING])
2747 { 2796 {
2748 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); 2797 wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems);
2752 paste (s, strlen (s)); 2801 paste (s, strlen (s));
2753 free (s); 2802 free (s);
2754 } 2803 }
2755 else 2804 else
2756#endif 2805#endif
2757 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2806 if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0
2758 && cl) 2807 && cl)
2759 { 2808 {
2760 for (int i = 0; i < cr; i++) 2809 for (int i = 0; i < cr; i++)
2761 paste (cl[i], strlen (cl[i])); 2810 paste (cl[i], strlen (cl[i]));
2762 2811
2771 if (selection_wait == Sel_normal) 2820 if (selection_wait == Sel_normal)
2772 selection_wait = Sel_none; 2821 selection_wait = Sel_none;
2773} 2822}
2774 2823
2775void 2824void
2776rxvt_term::incr_cb (time_watcher &w) 2825rxvt_term::incr_cb (time_watcher &w) NOTHROW
2777{ 2826{
2778 selection_wait = Sel_none; 2827 selection_wait = Sel_none;
2779 2828
2780 incr_buf_size = 0; 2829 incr_buf_size = 0;
2781 free (incr_buf); 2830 free (incr_buf);
2782 2831
2783 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); 2832 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n");
2784} 2833}
2785 2834
2786void 2835void
2787rxvt_term::selection_property (Window win, Atom prop) 2836rxvt_term::selection_property (Window win, Atom prop) NOTHROW
2788{ 2837{
2789 if (prop == None || selection_wait != Sel_incr) 2838 if (prop == None || selection_wait != Sel_incr)
2790 return; 2839 return;
2791 2840
2792 selection_paste (win, prop, true); 2841 selection_paste (win, prop, true);
2801 * (+) if ownership is claimed but property is empty, rxvt_selection_paste () 2850 * (+) if ownership is claimed but property is empty, rxvt_selection_paste ()
2802 * will auto fallback to CUT_BUFFER0 2851 * will auto fallback to CUT_BUFFER0
2803 * EXT: button 2 release 2852 * EXT: button 2 release
2804 */ 2853 */
2805void 2854void
2806rxvt_term::selection_request (Time tm) 2855rxvt_term::selection_request (Time tm, int selnum) NOTHROW
2807{ 2856{
2808 if (selection.text) 2857 if (selection.text && selnum == Sel_Primary)
2809 { /* internal selection */ 2858 { /* internal selection */
2810 char *str = rxvt_wcstombs (selection.text, selection.len); 2859 char *str = rxvt_wcstombs (selection.text, selection.len);
2811 paste (str, strlen (str)); 2860 paste (str, strlen (str));
2812 free (str); 2861 free (str);
2813 return; 2862 return;
2814 } 2863 }
2815 else 2864 else
2816 { 2865 {
2817 int i;
2818
2819 selection_request_time = tm; 2866 selection_request_time = tm;
2820 selection_wait = Sel_normal; 2867 selection_wait = Sel_normal;
2821 2868
2822 for (i = Sel_Primary; i <= Sel_Clipboard; i++)
2823 {
2824#if X_HAVE_UTF8_STRING 2869#if X_HAVE_UTF8_STRING
2825 selection_type = Sel_UTF8String; 2870 selection_type = Sel_UTF8String;
2826 if (selection_request_other (xa[XA_UTF8_STRING], i)) 2871 if (selection_request_other (xa[XA_UTF8_STRING], selnum))
2827 return; 2872 return;
2828#else 2873#else
2829 selection_type = Sel_CompoundText; 2874 selection_type = Sel_CompoundText;
2830 if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) 2875 if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum))
2831 return; 2876 return;
2832#endif 2877#endif
2833 }
2834 } 2878 }
2835 2879
2836 selection_wait = Sel_none; /* don't loop in selection_paste () */ 2880 selection_wait = Sel_none; /* don't loop in selection_paste () */
2837 selection_paste (display->root, XA_CUT_BUFFER0, false); 2881 selection_paste (display->root, XA_CUT_BUFFER0, false);
2838} 2882}
2839 2883
2840int 2884int
2841rxvt_term::selection_request_other (Atom target, int selnum) 2885rxvt_term::selection_request_other (Atom target, int selnum) NOTHROW
2842{ 2886{
2843 Atom sel; 2887 Atom sel;
2844 2888
2845 selection_type |= selnum; 2889 selection_type |= selnum;
2846 2890
2849 else if (selnum == Sel_Secondary) 2893 else if (selnum == Sel_Secondary)
2850 sel = XA_SECONDARY; 2894 sel = XA_SECONDARY;
2851 else 2895 else
2852 sel = xa[XA_CLIPBOARD]; 2896 sel = xa[XA_CLIPBOARD];
2853 2897
2854 if (XGetSelectionOwner (display->display, sel) != None) 2898 if (XGetSelectionOwner (dpy, sel) != None)
2855 { 2899 {
2856 XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], 2900 XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION],
2857 vt, selection_request_time); 2901 vt, selection_request_time);
2858 return 1; 2902 return 1;
2859 } 2903 }
2860 2904
2861 return 0; 2905 return 0;
2865/* 2909/*
2866 * Clear all selected text 2910 * Clear all selected text
2867 * EXT: SelectionClear 2911 * EXT: SelectionClear
2868 */ 2912 */
2869void 2913void
2870rxvt_term::selection_clear () 2914rxvt_term::selection_clear () NOTHROW
2871{ 2915{
2872 want_refresh = 1; 2916 want_refresh = 1;
2873 free (selection.text); 2917 free (selection.text);
2874 selection.text = NULL; 2918 selection.text = NULL;
2875 selection.len = 0; 2919 selection.len = 0;
2924 2968
2925 int end_col; 2969 int end_col;
2926 2970
2927 for (; row <= selection.end.row; row++, col = 0) 2971 for (; row <= selection.end.row; row++, col = 0)
2928 { 2972 {
2929#if ENABLE_FRILLS 2973#if !ENABLE_MINIMAL
2930 if (selection.rect) 2974 if (selection.rect)
2931 { 2975 {
2932 col = selection.beg.col; 2976 col = selection.beg.col;
2933 end_col = ncol + 1; 2977 end_col = ncol + 1;
2934 } 2978 }
2937 end_col = ROW(row).l; 2981 end_col = ROW(row).l;
2938 2982
2939 col = max (col, 0); 2983 col = max (col, 0);
2940 2984
2941 if (row == selection.end.row 2985 if (row == selection.end.row
2942#if ENABLE_FRILLS 2986#if !ENABLE_MINIMAL
2943 || selection.rect 2987 || selection.rect
2944#endif 2988#endif
2945 ) 2989 )
2946 min_it (end_col, selection.end.col); 2990 min_it (end_col, selection.end.col);
2947 2991
2970#endif 3014#endif
2971 else 3015 else
2972 new_selection_text[ofs++] = *t++; 3016 new_selection_text[ofs++] = *t++;
2973 } 3017 }
2974 3018
2975#if ENABLE_FRILLS 3019#if !ENABLE_MINIMAL
2976 if (selection.rect) 3020 if (selection.rect)
2977 { 3021 {
2978 while (ofs 3022 while (ofs
2979 && new_selection_text[ofs - 1] != C0_LF 3023 && new_selection_text[ofs - 1] != C0_LF
2980 && unicode::is_space (new_selection_text[ofs - 1])) 3024 && unicode::is_space (new_selection_text[ofs - 1]))
3010 3054
3011 selection_grab (tm); 3055 selection_grab (tm);
3012} 3056}
3013 3057
3014bool 3058bool
3015rxvt_term::selection_grab (Time tm) 3059rxvt_term::selection_grab (Time tm) NOTHROW
3016{ 3060{
3017 selection_time = tm; 3061 selection_time = tm;
3018 3062
3019 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 3063 XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm);
3020 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 3064 if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt)
3021 { 3065 {
3022 display->set_selection_owner (this); 3066 display->set_selection_owner (this);
3023 return true; 3067 return true;
3024 } 3068 }
3025 else 3069 else
3029 } 3073 }
3030 3074
3031#if 0 3075#if 0
3032 XTextProperty ct; 3076 XTextProperty ct;
3033 3077
3034 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3078 if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0)
3035 { 3079 {
3036 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3080 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
3037 XFree (ct.value); 3081 XFree (ct.value);
3038 } 3082 }
3039#endif 3083#endif
3043/* 3087/*
3044 * Mark or select text based upon number of clicks: 1, 2, or 3 3088 * Mark or select text based upon number of clicks: 1, 2, or 3
3045 * EXT: button 1 press 3089 * EXT: button 1 press
3046 */ 3090 */
3047void 3091void
3048rxvt_term::selection_click (int clicks, int x, int y) 3092rxvt_term::selection_click (int clicks, int x, int y) NOTHROW
3049{ 3093{
3050 clicks = ((clicks - 1) % 3) + 1; 3094 clicks = ((clicks - 1) % 3) + 1;
3051 selection.clicks = clicks; /* save clicks so extend will work */ 3095 selection.clicks = clicks; /* save clicks so extend will work */
3052 3096
3053 if (clicks == 2 && !selection.rect 3097 if (clicks == 2 && !selection.rect
3072/* ------------------------------------------------------------------------- */ 3116/* ------------------------------------------------------------------------- */
3073/* 3117/*
3074 * Mark a selection at the specified col/row 3118 * Mark a selection at the specified col/row
3075 */ 3119 */
3076void 3120void
3077rxvt_term::selection_start_colrow (int col, int row) 3121rxvt_term::selection_start_colrow (int col, int row) NOTHROW
3078{ 3122{
3079 want_refresh = 1; 3123 want_refresh = 1;
3080 3124
3081 selection.mark.row = row + view_start; 3125 selection.mark.row = row + view_start;
3082 selection.mark.col = col; 3126 selection.mark.col = col;
3108#define DELIMIT_TEXT(x) \ 3152#define DELIMIT_TEXT(x) \
3109 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) 3153 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x)))
3110#define DELIMIT_REND(x) 1 3154#define DELIMIT_REND(x) 1
3111 3155
3112void 3156void
3113rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) 3157rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW
3114{ 3158{
3115 int col, row, dirnadd, tcol, trow, w1, w2; 3159 int col, row, dirnadd, tcol, trow, w1, w2;
3116 row_col_t bound; 3160 row_col_t bound;
3117 text_t *stp; 3161 text_t *stp;
3118 rend_t *srp; 3162 rend_t *srp;
3192 * flag == 0 ==> button 1 3236 * flag == 0 ==> button 1
3193 * flag == 1 ==> button 3 press 3237 * flag == 1 ==> button 3 press
3194 * flag == 2 ==> button 3 motion 3238 * flag == 2 ==> button 3 motion
3195 */ 3239 */
3196void 3240void
3197rxvt_term::selection_extend (int x, int y, int flag) 3241rxvt_term::selection_extend (int x, int y, int flag) NOTHROW
3198{ 3242{
3199 int col = clamp (Pixel2Col (x), 0, ncol); 3243 int col = clamp (Pixel2Col (x), 0, ncol);
3200 int row = clamp (Pixel2Row (y), 0, nrow - 1); 3244 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3201 3245
3202 /* 3246 /*
3228/* ------------------------------------------------------------------------- */ 3272/* ------------------------------------------------------------------------- */
3229/* 3273/*
3230 * Extend the selection to the specified col/row 3274 * Extend the selection to the specified col/row
3231 */ 3275 */
3232void 3276void
3233rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) 3277rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW
3234{ 3278{
3235 row_col_t pos; 3279 row_col_t pos;
3236 enum { 3280 enum {
3237 LEFT, RIGHT 3281 LEFT, RIGHT
3238 } closeto = RIGHT; 3282 } closeto = RIGHT;
3341 3385
3342 if (selection.clicks == 1) 3386 if (selection.clicks == 1)
3343 { 3387 {
3344 if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN 3388 if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN
3345 && !ROW(selection.beg.row).is_longer () 3389 && !ROW(selection.beg.row).is_longer ()
3346#if ENABLE_FRILLS 3390#if !ENABLE_MINIMAL
3347 && !selection.rect 3391 && !selection.rect
3348#endif 3392#endif
3349 ) 3393 )
3350 selection.beg.col = ncol; 3394 selection.beg.col = ncol;
3351 3395
3352 if ( 3396 if (
3353 selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN 3397 selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN
3354 && !ROW(selection.end.row).is_longer () 3398 && !ROW(selection.end.row).is_longer ()
3355#if ENABLE_FRILLS 3399#if !ENABLE_MINIMAL
3356 && !selection.rect 3400 && !selection.rect
3357#endif 3401#endif
3358 ) 3402 )
3359 selection.end.col = ncol; 3403 selection.end.col = ncol;
3360 } 3404 }
3377 { 3421 {
3378 if (!ROW(end_row).is_longer ()) 3422 if (!ROW(end_row).is_longer ())
3379 { 3423 {
3380 selection.end.row = end_row; 3424 selection.end.row = end_row;
3381 selection.end.col = ROW(end_row).l; 3425 selection.end.col = ROW(end_row).l;
3426# if !ENABLE_MINIMAL
3382 selection_remove_trailing_spaces (); 3427 selection_remove_trailing_spaces ();
3428# endif
3383 break; 3429 break;
3384 } 3430 }
3385 } 3431 }
3386 } 3432 }
3387 else 3433 else
3416 selection.mark.row = selection.beg.row; 3462 selection.mark.row = selection.beg.row;
3417 selection.mark.col = selection.beg.col; 3463 selection.mark.col = selection.beg.col;
3418 } 3464 }
3419 } 3465 }
3420 3466
3421#if ENABLE_FRILLS 3467#if !ENABLE_MINIMAL
3422 if (selection.rect && selection.beg.col > selection.end.col) 3468 if (selection.rect && selection.beg.col > selection.end.col)
3423 ::swap (selection.beg.col, selection.end.col); 3469 ::swap (selection.beg.col, selection.end.col);
3424#endif 3470#endif
3425} 3471}
3426 3472
3427#if ENABLE_FRILLS 3473#if !ENABLE_MINIMAL
3428void 3474void
3429rxvt_term::selection_remove_trailing_spaces () 3475rxvt_term::selection_remove_trailing_spaces () NOTHROW
3430{ 3476{
3431 int32_t end_col, end_row; 3477 int32_t end_col, end_row;
3432 text_t *stp; 3478 text_t *stp;
3433 3479
3434 end_col = selection.end.col; 3480 end_col = selection.end.col;
3472/* 3518/*
3473 * Double click on button 3 when already selected 3519 * Double click on button 3 when already selected
3474 * EXT: button 3 double click 3520 * EXT: button 3 double click
3475 */ 3521 */
3476void 3522void
3477rxvt_term::selection_rotate (int x, int y) 3523rxvt_term::selection_rotate (int x, int y) NOTHROW
3478{ 3524{
3479 selection.clicks = selection.clicks % 3 + 1; 3525 selection.clicks = selection.clicks % 3 + 1;
3480 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); 3526 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1);
3481} 3527}
3482 3528
3484/* 3530/*
3485 * Respond to a request for our current selection 3531 * Respond to a request for our current selection
3486 * EXT: SelectionRequest 3532 * EXT: SelectionRequest
3487 */ 3533 */
3488void 3534void
3489rxvt_term::selection_send (const XSelectionRequestEvent &rq) 3535rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW
3490{ 3536{
3491 XSelectionEvent ev; 3537 XSelectionEvent ev;
3492 dDisp;
3493 3538
3494 ev.type = SelectionNotify; 3539 ev.type = SelectionNotify;
3495 ev.property = None; 3540 ev.property = None;
3496 ev.display = rq.display; 3541 ev.display = rq.display;
3497 ev.requestor = rq.requestor; 3542 ev.requestor = rq.requestor;
3511 *target++ = xa[XA_COMPOUND_TEXT]; 3556 *target++ = xa[XA_COMPOUND_TEXT];
3512#if X_HAVE_UTF8_STRING 3557#if X_HAVE_UTF8_STRING
3513 *target++ = xa[XA_UTF8_STRING]; 3558 *target++ = xa[XA_UTF8_STRING];
3514#endif 3559#endif
3515 3560
3516 XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, 3561 XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM,
3517 32, PropModeReplace, 3562 32, PropModeReplace,
3518 (unsigned char *)target_list, target - target_list); 3563 (unsigned char *)target_list, target - target_list);
3519 ev.property = rq.property; 3564 ev.property = rq.property;
3520 } 3565 }
3521#if TODO // TODO 3566#if TODO // TODO
3524 /* TODO: Handle MULTIPLE */ 3569 /* TODO: Handle MULTIPLE */
3525 } 3570 }
3526#endif 3571#endif
3527 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3572 else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
3528 { 3573 {
3529 XChangeProperty (disp, rq.requestor, rq.property, rq.target, 3574 XChangeProperty (dpy, rq.requestor, rq.property, rq.target,
3530 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3575 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3531 ev.property = rq.property; 3576 ev.property = rq.property;
3532 } 3577 }
3533 else if (rq.target == XA_STRING 3578 else if (rq.target == XA_STRING
3534 || rq.target == xa[XA_TEXT] 3579 || rq.target == xa[XA_TEXT]
3558 style = enc_string; 3603 style = enc_string;
3559 else if (target == xa[XA_TEXT]) 3604 else if (target == xa[XA_TEXT])
3560 style = enc_text; 3605 style = enc_text;
3561 else if (target == xa[XA_COMPOUND_TEXT]) 3606 else if (target == xa[XA_COMPOUND_TEXT])
3562 style = enc_compound_text; 3607 style = enc_compound_text;
3563#if ENABLE_FRILLS 3608#if !ENABLE_MINIMAL
3564 else if (target == xa[XA_UTF8_STRING]) 3609 else if (target == xa[XA_UTF8_STRING])
3565 style = enc_utf8; 3610 style = enc_utf8;
3566#endif 3611#endif
3567 else 3612 else
3568 { 3613 {
3579 { 3624 {
3580 cl = L""; 3625 cl = L"";
3581 selectlen = 0; 3626 selectlen = 0;
3582 } 3627 }
3583 3628
3584#if ENABLE_FRILLS 3629#if !ENABLE_MINIMAL
3585 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 3630 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
3586 // so recode it manually 3631 // so recode it manually
3587 if (style == enc_utf8) 3632 if (style == enc_utf8)
3588 { 3633 {
3589 freect = 1; 3634 freect = 1;
3592 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); 3637 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen);
3593 ct.nitems = strlen ((char *)ct.value); 3638 ct.nitems = strlen ((char *)ct.value);
3594 } 3639 }
3595 else 3640 else
3596#endif 3641#endif
3597 if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) 3642 if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
3598 freect = 1; 3643 freect = 1;
3599 else 3644 else
3600 { 3645 {
3601 /* if we failed to convert then send it raw */ 3646 /* if we failed to convert then send it raw */
3602 ct.value = (unsigned char *)cl; 3647 ct.value = (unsigned char *)cl;
3603 ct.nitems = selectlen; 3648 ct.nitems = selectlen;
3604 ct.encoding = target; 3649 ct.encoding = target;
3605 } 3650 }
3606 3651
3607 XChangeProperty (disp, rq.requestor, rq.property, 3652 XChangeProperty (dpy, rq.requestor, rq.property,
3608 ct.encoding, 8, PropModeReplace, 3653 ct.encoding, 8, PropModeReplace,
3609 ct.value, (int)ct.nitems); 3654 ct.value, (int)ct.nitems);
3610 ev.property = rq.property; 3655 ev.property = rq.property;
3611 3656
3612 if (freect) 3657 if (freect)
3613 XFree (ct.value); 3658 XFree (ct.value);
3614 } 3659 }
3615 3660
3616 XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); 3661 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev);
3617} 3662}
3618 3663
3619/* ------------------------------------------------------------------------- * 3664/* ------------------------------------------------------------------------- *
3620 * MOUSE ROUTINES * 3665 * MOUSE ROUTINES *
3621 * ------------------------------------------------------------------------- */ 3666 * ------------------------------------------------------------------------- */
3622 3667
3623/* 3668/*
3624 * return col/row values corresponding to x/y pixel values 3669 * return col/row values corresponding to x/y pixel values
3625 */ 3670 */
3626void 3671void
3627rxvt_term::pixel_position (int *x, int *y) 3672rxvt_term::pixel_position (int *x, int *y) NOTHROW
3628{ 3673{
3629 *x = Pixel2Col (*x); 3674 *x = Pixel2Col (*x);
3630 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ 3675 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */
3631 *y = Pixel2Row (*y); 3676 *y = Pixel2Row (*y);
3632 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ 3677 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */
3633} 3678}
3634 3679
3635/* ------------------------------------------------------------------------- */ 3680/* ------------------------------------------------------------------------- */
3636#ifdef USE_XIM 3681#ifdef USE_XIM
3637void 3682void
3638rxvt_term::im_set_position (XPoint &pos) 3683rxvt_term::im_set_position (XPoint &pos) NOTHROW
3639{ 3684{
3640 XWindowAttributes xwa; 3685 XWindowAttributes xwa;
3641 3686
3642 XGetWindowAttributes (display->display, vt, &xwa); 3687 XGetWindowAttributes (dpy, vt, &xwa);
3643 3688
3644 pos.x = xwa.x + Col2Pixel (screen.cur.col); 3689 pos.x = xwa.x + Col2Pixel (screen.cur.col);
3645 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; 3690 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase;
3646} 3691}
3647#endif 3692#endif
3648 3693
3649#if ENABLE_OVERLAY 3694#if ENABLE_OVERLAY
3650void 3695void
3651rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3696rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW
3652{ 3697{
3653 if (nrow < 1 || ncol < 1) 3698 if (nrow < 1 || ncol < 1)
3654 return; 3699 return;
3655 3700
3656 want_refresh = 1; 3701 want_refresh = 1;
3701 *rp = r; 3746 *rp = r;
3702 } 3747 }
3703} 3748}
3704 3749
3705void 3750void
3706rxvt_term::scr_overlay_off () 3751rxvt_term::scr_overlay_off () NOTHROW
3707{ 3752{
3708 if (!ov_text) 3753 if (!ov_text)
3709 return; 3754 return;
3710 3755
3711 want_refresh = 1; 3756 want_refresh = 1;
3719 delete [] ov_text; ov_text = 0; 3764 delete [] ov_text; ov_text = 0;
3720 delete [] ov_rend; ov_rend = 0; 3765 delete [] ov_rend; ov_rend = 0;
3721} 3766}
3722 3767
3723void 3768void
3724rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) 3769rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW
3725{ 3770{
3726 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3771 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2)
3727 return; 3772 return;
3728 3773
3729 x++, y++; 3774 x++, y++;
3731 ov_text[y][x] = text; 3776 ov_text[y][x] = text;
3732 ov_rend[y][x] = rend; 3777 ov_rend[y][x] = rend;
3733} 3778}
3734 3779
3735void 3780void
3736rxvt_term::scr_overlay_set (int x, int y, const char *s) 3781rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW
3737{ 3782{
3738 while (*s) 3783 while (*s)
3739 scr_overlay_set (x++, y, *s++); 3784 scr_overlay_set (x++, y, *s++);
3740} 3785}
3741 3786
3742void 3787void
3743rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) 3788rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW
3744{ 3789{
3745 while (*s) 3790 while (*s)
3746 { 3791 {
3747 text_t t = *s++; 3792 text_t t = *s++;
3748 int width = wcwidth (t); 3793 int width = WCWIDTH (t);
3749 3794
3750 while (width--) 3795 while (width--)
3751 { 3796 {
3752 scr_overlay_set (x++, y, t); 3797 scr_overlay_set (x++, y, t);
3753 t = NOCHAR; 3798 t = NOCHAR;
3754 } 3799 }
3755 } 3800 }
3756} 3801}
3757 3802
3758void 3803void
3759rxvt_term::scr_swap_overlay () 3804rxvt_term::scr_swap_overlay () NOTHROW
3760{ 3805{
3761 if (!ov_text) 3806 if (!ov_text)
3762 return; 3807 return;
3763 3808
3764 // swap screen mem with overlay 3809 // swap screen mem with overlay

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines