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.242 by root, Thu Jan 19 19:51:08 2006 UTC vs.
Revision 1.253 by root, Fri Jan 27 18:36:43 2006 UTC

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 (xdisp, 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 (xdisp, 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 (xdisp, 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;
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 rvideo = 0; 242 rvideo_state = rvideo_mode = false;
240 } 243 }
241 else 244 else
242 { 245 {
243 /* 246 /*
244 * add or delete rows as appropriate 247 * add or delete rows as appropriate
280 int pend = MOD (term_start + top_row , prev_total_rows); 283 int pend = MOD (term_start + top_row , prev_total_rows);
281 int q = total_rows; // rewrapped row 284 int q = total_rows; // rewrapped row
282 285
283 if (top_row) 286 if (top_row)
284 { 287 {
285 // 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
286 // to come up with a lean and mean algorithm. 289 // to come up with a lean and mean algorithm.
287 290
288 row_col_t ocur = screen.cur; 291 row_col_t ocur = screen.cur;
289 ocur.row = MOD (term_start + ocur.row, prev_total_rows); 292 ocur.row = MOD (term_start + ocur.row, prev_total_rows);
290 293
347 350
348 line_t &pline = old_buf [prow]; 351 line_t &pline = old_buf [prow];
349 352
350 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs); 353 int len = min (min (prev_ncol - pcol, ncol - qcol), llen - lofs);
351 354
352#if DEBUG_STRICT
353 assert (len);
354 assert (pline.t);
355#endif
356
357 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t)); 355 memcpy (qline->t + qcol, pline.t + pcol, len * sizeof (text_t));
358 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t)); 356 memcpy (qline->r + qcol, pline.r + pcol, len * sizeof (rend_t));
359 357
360 lofs += len; 358 lofs += len;
361 qcol += len; 359 qcol += len;
401 delete old_ra; 399 delete old_ra;
402 400
403 clamp_it (screen.cur.row, 0, nrow - 1); 401 clamp_it (screen.cur.row, 0, nrow - 1);
404 clamp_it (screen.cur.col, 0, ncol - 1); 402 clamp_it (screen.cur.col, 0, ncol - 1);
405 403
406 if (tabs)
407 free (tabs); 404 free (tabs);
408 } 405 }
409 406
410 CLEAR_ALL_SELECTION (); 407 CLEAR_ALL_SELECTION ();
411 408
412 prev_nrow = nrow; 409 prev_nrow = nrow;
415 tabs = (char *)rxvt_malloc (ncol * sizeof (char)); 412 tabs = (char *)rxvt_malloc (ncol * sizeof (char));
416 413
417 for (int col = ncol; col--; ) 414 for (int col = ncol; col--; )
418 tabs [col] = col % TABSIZE == 0; 415 tabs [col] = col % TABSIZE == 0;
419 416
417 if (current_screen != PRIMARY)
418 scr_swap_screen ();
419
420 tt_winch (); 420 tt_winch ();
421 421
422 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 422 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
423} 423}
424 424
425/* ------------------------------------------------------------------------- */ 425/* ------------------------------------------------------------------------- */
426/* 426/*
427 * Free everything. That way malloc debugging can find leakage. 427 * Free everything. That way malloc debugging can find leakage.
428 */ 428 */
429void 429void
430rxvt_term::scr_release () 430rxvt_term::scr_release () NOTHROW
431{ 431{
432 if (row_buf)
433 {
432 delete talloc; talloc = 0; 434 delete talloc; talloc = 0;
433 delete ralloc; ralloc = 0; 435 delete ralloc; ralloc = 0;
434 436
435 free (row_buf); 437 free (row_buf);
436 free (swap_buf); 438 free (swap_buf);
437 free (drawn_buf); 439 free (drawn_buf);
438 free (tabs); 440 free (tabs);
439 441
440 row_buf = 0; // signal that we freed all the arrays 442 row_buf = 0; // signal that we freed all the arrays
443 }
441} 444}
442 445
443/* ------------------------------------------------------------------------- */ 446/* ------------------------------------------------------------------------- */
444/* 447/*
445 * Hard reset 448 * Hard reset
462 * Save and Restore cursor 465 * Save and Restore cursor
463 * XTERM_SEQ: Save cursor : ESC 7 466 * XTERM_SEQ: Save cursor : ESC 7
464 * XTERM_SEQ: Restore cursor: ESC 8 467 * XTERM_SEQ: Restore cursor: ESC 8
465 */ 468 */
466void 469void
467rxvt_term::scr_cursor (cursor_mode mode) 470rxvt_term::scr_cursor (cursor_mode mode) NOTHROW
468{ 471{
469 screen_t *s; 472 screen_t *s;
470 473
471#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) 474#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR)
472 if (current_screen == SECONDARY) 475 if (current_screen == SECONDARY)
504 assert (s->cur.row >= 0); 507 assert (s->cur.row >= 0);
505 assert (s->cur.col >= 0); 508 assert (s->cur.col >= 0);
506#endif 509#endif
507} 510}
508 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
509/* ------------------------------------------------------------------------- */ 527/* ------------------------------------------------------------------------- */
510/* 528/*
511 * Swap between primary and secondary screens 529 * Swap between primary and secondary screens
512 * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h 530 * XTERM_SEQ: Primary screen : ESC [ ? 4 7 h
513 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l 531 * XTERM_SEQ: Secondary screen: ESC [ ? 4 7 l
514 */ 532 */
515int 533void
516rxvt_term::scr_change_screen (int scrn) 534rxvt_term::scr_change_screen (int scrn)
517{ 535{
536 if (scrn == current_screen)
537 return;
538
518 want_refresh = 1; 539 want_refresh = 1;
519 view_start = 0; 540 view_start = 0;
520 541
521 if (current_screen == scrn)
522 return scrn;
523
524 selection_check (2); /* check for boundary cross */ 542 selection_check (2); /* check for boundary cross */
525 543
526 int i = current_screen; current_screen = scrn; scrn = i; 544 int i = current_screen; current_screen = scrn; scrn = i;
527
528 ::swap (screen.cur.row, swap.cur.row);
529 ::swap (screen.cur.col, swap.cur.col);
530
531 screen.cur.row = clamp (screen.cur.row, 0, prev_nrow - 1);
532 screen.cur.col = clamp (screen.cur.col, 0, prev_ncol - 1);
533 545
534#if NSCREENS 546#if NSCREENS
535 if (OPTION (Opt_secondaryScreen)) 547 if (OPTION (Opt_secondaryScreen))
536 { 548 {
537 num_scr = 0; 549 num_scr = 0;
538 550
539 for (int i = prev_nrow; i--; ) 551 scr_swap_screen ();
540 ::swap (ROW(i), swap_buf [i]);
541 552
542 ::swap (screen.charset, swap.charset); 553 ::swap (screen.charset, swap.charset);
543 ::swap (screen.flags, swap.flags); 554 ::swap (screen.flags, swap.flags);
544 screen.flags |= Screen_VisibleCursor; 555 screen.flags |= Screen_VisibleCursor;
545 swap.flags |= Screen_VisibleCursor; 556 swap.flags |= Screen_VisibleCursor;
546 } 557 }
547 else 558 else
548#endif 559#endif
549 if (OPTION (Opt_secondaryScroll)) 560 if (OPTION (Opt_secondaryScroll))
550 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 561 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
551
552 return scrn;
553} 562}
554 563
555// clear WrapNext indicator, solidifying position on next line 564// clear WrapNext indicator, solidifying position on next line
556void 565void
557rxvt_term::scr_do_wrap () 566rxvt_term::scr_do_wrap () NOTHROW
558{ 567{
559 if (!(screen.flags & Screen_WrapNext)) 568 if (!(screen.flags & Screen_WrapNext))
560 return; 569 return;
561 570
562 screen.flags &= ~Screen_WrapNext; 571 screen.flags &= ~Screen_WrapNext;
572/* ------------------------------------------------------------------------- */ 581/* ------------------------------------------------------------------------- */
573/* 582/*
574 * Change the colour for following text 583 * Change the colour for following text
575 */ 584 */
576void 585void
577rxvt_term::scr_color (unsigned int color, int fgbg) 586rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW
578{ 587{
579 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) 588 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
580 color = fgbg; 589 color = fgbg;
581 590
582 if (fgbg == Color_fg) 591 if (fgbg == Color_fg)
588/* ------------------------------------------------------------------------- */ 597/* ------------------------------------------------------------------------- */
589/* 598/*
590 * Change the rendition style for following text 599 * Change the rendition style for following text
591 */ 600 */
592void 601void
593rxvt_term::scr_rendition (int set, int style) 602rxvt_term::scr_rendition (int set, int style) NOTHROW
594 { 603 {
595 if (set) 604 if (set)
596 rstyle |= style; 605 rstyle |= style;
597 else if (style == ~RS_None) 606 else if (style == ~RS_None)
598 rstyle = DEFAULT_RSTYLE; 607 rstyle = DEFAULT_RSTYLE;
605 * Scroll text between <row1> and <row2> inclusive, by <count> lines 614 * Scroll text between <row1> and <row2> inclusive, by <count> lines
606 * count positive ==> scroll up 615 * count positive ==> scroll up
607 * count negative ==> scroll down 616 * count negative ==> scroll down
608 */ 617 */
609int 618int
610rxvt_term::scr_scroll_text (int row1, int row2, int count) 619rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW
611{ 620{
612 if (count == 0 || (row1 > row2)) 621 if (count == 0 || (row1 > row2))
613 return 0; 622 return 0;
614 623
615 want_refresh = 1; 624 want_refresh = 1;
631 l.touch (); 640 l.touch ();
632 } 641 }
633 642
634 // erase newly scrolled-in lines 643 // erase newly scrolled-in lines
635 for (int i = count; i--; ) 644 for (int i = count; i--; )
636 { 645 scr_blank_screen_mem (ROW(nrow - 1 - i), rstyle);
637 // basically this is a slightly optimized scr_blank_screen_mem
638 // it is worth the effort on slower machines
639 line_t &l = ROW(nrow - 1 - i);
640
641 scr_blank_line (l, 0, l.l, rstyle);
642
643 l.l = 0;
644 l.f = 0;
645 }
646 646
647 // now copy lines below the scroll region bottom to the 647 // now copy lines below the scroll region bottom to the
648 // bottom of the screen again, so they look as if they 648 // bottom of the screen again, so they look as if they
649 // hadn't moved. 649 // hadn't moved.
650 for (int i = nrow; --i > row2; ) 650 for (int i = nrow; --i > row2; )
733/* ------------------------------------------------------------------------- */ 733/* ------------------------------------------------------------------------- */
734/* 734/*
735 * Add text given in <str> of length <len> to screen struct 735 * Add text given in <str> of length <len> to screen struct
736 */ 736 */
737void 737void
738rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) 738rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW
739{ 739{
740 if (len <= 0) /* sanity */ 740 if (len <= 0) /* sanity */
741 return; 741 return;
742 742
743 unsigned char checksel; 743 unsigned char checksel;
749 ZERO_SCROLLBACK (); 749 ZERO_SCROLLBACK ();
750 750
751 if (minlines > 0) 751 if (minlines > 0)
752 { 752 {
753 minlines += screen.cur.row - screen.bscroll; 753 minlines += screen.cur.row - screen.bscroll;
754 min_it (minlines, screen.cur.row - top_row);
754 755
755 if (minlines > 0 756 if (minlines > 0
756 && screen.tscroll == 0 757 && screen.tscroll == 0
757 && screen.bscroll == nrow - 1) 758 && screen.bscroll == nrow - 1)
758 { 759 {
832 833
833 // some utf-8 decoders "decode" surrogate characters: let's fix this. 834 // some utf-8 decoders "decode" surrogate characters: let's fix this.
834 if (IN_RANGE_INC (c, 0xd800, 0xdfff)) 835 if (IN_RANGE_INC (c, 0xd800, 0xdfff))
835 c = 0xfffd; 836 c = 0xfffd;
836 837
837 // rely on wcwidth to tell us the character width, at least for non-latin1 838 // rely on wcwidth to tell us the character width, do wcwidth before
838 // do wcwidth before further replacements, as wcwidth might return -1 839 // further replacements, as wcwidth might return -1 for the line
839 // for the line drawing characters below as they might be invalid in the current 840 // drawing characters below as they might be invalid in the current
840 // locale. 841 // locale.
841 int width = c < 0x100 ? 1 : wcwidth (c); 842 int width = WCWIDTH (c);
842 843
843 if (charsets [screen.charset] == '0') // DEC SPECIAL 844 if (charsets [screen.charset] == '0') // DEC SPECIAL
844 { 845 {
845 // vt100 special graphics and line drawing 846 // vt100 special graphics and line drawing
846 // 5f-7e standard vt100 847 // 5f-7e standard vt100
997/* 998/*
998 * Process Backspace. Move back the cursor back a position, wrap if have to 999 * Process Backspace. Move back the cursor back a position, wrap if have to
999 * XTERM_SEQ: CTRL-H 1000 * XTERM_SEQ: CTRL-H
1000 */ 1001 */
1001void 1002void
1002rxvt_term::scr_backspace () 1003rxvt_term::scr_backspace () NOTHROW
1003{ 1004{
1004 want_refresh = 1; 1005 want_refresh = 1;
1005 1006
1006 if (screen.cur.col == 0) 1007 if (screen.cur.col == 0)
1007 { 1008 {
1025 * Process Horizontal Tab 1026 * Process Horizontal Tab
1026 * count: +ve = forward; -ve = backwards 1027 * count: +ve = forward; -ve = backwards
1027 * XTERM_SEQ: CTRL-I 1028 * XTERM_SEQ: CTRL-I
1028 */ 1029 */
1029void 1030void
1030rxvt_term::scr_tab (int count, bool ht) 1031rxvt_term::scr_tab (int count, bool ht) NOTHROW
1031{ 1032{
1032 int i, x; 1033 int i, x;
1033 1034
1034 want_refresh = 1; 1035 want_refresh = 1;
1035 i = x = screen.cur.col; 1036 i = x = screen.cur.col;
1102 * Move cursor left in row. If we're at the left boundary, shift everything 1103 * Move cursor left in row. If we're at the left boundary, shift everything
1103 * in that row right. Clear left column. 1104 * in that row right. Clear left column.
1104 */ 1105 */
1105#if ENABLE_FRILLS 1106#if ENABLE_FRILLS
1106void 1107void
1107rxvt_term::scr_backindex () 1108rxvt_term::scr_backindex () NOTHROW
1108{ 1109{
1109 if (screen.cur.col > 0) 1110 if (screen.cur.col > 0)
1110 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1111 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1111 else 1112 else
1112 scr_insdel_chars (1, INSERT); 1113 scr_insdel_chars (1, INSERT);
1119 * Move cursor right in row. If we're at the right boundary, shift everything 1120 * Move cursor right in row. If we're at the right boundary, shift everything
1120 * in that row left. Clear right column. 1121 * in that row left. Clear right column.
1121 */ 1122 */
1122#if ENABLE_FRILLS 1123#if ENABLE_FRILLS
1123void 1124void
1124rxvt_term::scr_forwardindex () 1125rxvt_term::scr_forwardindex () NOTHROW
1125{ 1126{
1126 if (screen.cur.col < ncol - 1) 1127 if (screen.cur.col < ncol - 1)
1127 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1128 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1128 else 1129 else
1129 { 1130 {
1142/* ------------------------------------------------------------------------- */ 1143/* ------------------------------------------------------------------------- */
1143/* 1144/*
1144 * Goto Row/Column 1145 * Goto Row/Column
1145 */ 1146 */
1146void 1147void
1147rxvt_term::scr_gotorc (int row, int col, int relative) 1148rxvt_term::scr_gotorc (int row, int col, int relative) NOTHROW
1148{ 1149{
1149 want_refresh = 1; 1150 want_refresh = 1;
1150 ZERO_SCROLLBACK (); 1151 ZERO_SCROLLBACK ();
1151 1152
1152 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; 1153 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1190/* ------------------------------------------------------------------------- */ 1191/* ------------------------------------------------------------------------- */
1191/* 1192/*
1192 * direction should be UP or DN 1193 * direction should be UP or DN
1193 */ 1194 */
1194void 1195void
1195rxvt_term::scr_index (enum page_dirn direction) 1196rxvt_term::scr_index (enum page_dirn direction) NOTHROW
1196{ 1197{
1197 int dirn; 1198 int dirn;
1198 1199
1199 want_refresh = 1; 1200 want_refresh = 1;
1200 ZERO_SCROLLBACK (); 1201 ZERO_SCROLLBACK ();
1219 * XTERM_SEQ: Clear line to right: ESC [ 0 K 1220 * XTERM_SEQ: Clear line to right: ESC [ 0 K
1220 * XTERM_SEQ: Clear line to left : ESC [ 1 K 1221 * XTERM_SEQ: Clear line to left : ESC [ 1 K
1221 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1222 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1222 */ 1223 */
1223void 1224void
1224rxvt_term::scr_erase_line (int mode) 1225rxvt_term::scr_erase_line (int mode) NOTHROW
1225{ 1226{
1226 unsigned int col, num; 1227 unsigned int col, num;
1227 1228
1228 want_refresh = 1; 1229 want_refresh = 1;
1229 ZERO_SCROLLBACK (); 1230 ZERO_SCROLLBACK ();
1273 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J 1274 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J
1274 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J 1275 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J
1275 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1276 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1276 */ 1277 */
1277void 1278void
1278rxvt_term::scr_erase_screen (int mode) 1279rxvt_term::scr_erase_screen (int mode) NOTHROW
1279{ 1280{
1280 int num; 1281 int num;
1281 int32_t row; 1282 int32_t row;
1282 rend_t ren; 1283 rend_t ren;
1283 XGCValues gcvalue; 1284 XGCValues gcvalue;
1328 } 1329 }
1329 else 1330 else
1330 { 1331 {
1331 ren = rstyle & (RS_fgMask | RS_bgMask); 1332 ren = rstyle & (RS_fgMask | RS_bgMask);
1332 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; 1333 gcvalue.foreground = pix_colors[bgcolor_of (rstyle)];
1333 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1334 XChangeGC (xdisp, gc, GCForeground, &gcvalue);
1334 ERASE_ROWS (row, num); 1335 ERASE_ROWS (row, num);
1335 gcvalue.foreground = pix_colors[Color_fg]; 1336 gcvalue.foreground = pix_colors[Color_fg];
1336 XChangeGC (display->display, gc, GCForeground, &gcvalue); 1337 XChangeGC (xdisp, gc, GCForeground, &gcvalue);
1337 } 1338 }
1338 1339
1339 for (; num--; row++) 1340 for (; num--; row++)
1340 { 1341 {
1341 scr_blank_screen_mem (ROW(row), rstyle); 1342 scr_blank_screen_mem (ROW(row), rstyle);
1343 } 1344 }
1344} 1345}
1345 1346
1346#if ENABLE_FRILLS 1347#if ENABLE_FRILLS
1347void 1348void
1348rxvt_term::scr_erase_savelines () 1349rxvt_term::scr_erase_savelines () NOTHROW
1349{ 1350{
1350 want_refresh = 1; 1351 want_refresh = 1;
1351 ZERO_SCROLLBACK (); 1352 ZERO_SCROLLBACK ();
1352 1353
1353 top_row = 0; 1354 top_row = 0;
1358/* 1359/*
1359 * Fill the screen with `E's 1360 * Fill the screen with `E's
1360 * XTERM_SEQ: Screen Alignment Test: ESC # 8 1361 * XTERM_SEQ: Screen Alignment Test: ESC # 8
1361 */ 1362 */
1362void 1363void
1363rxvt_term::scr_E () 1364rxvt_term::scr_E () NOTHROW
1364{ 1365{
1365 rend_t fs; 1366 rend_t fs;
1366 1367
1367 want_refresh = 1; 1368 want_refresh = 1;
1368 ZERO_SCROLLBACK (); 1369 ZERO_SCROLLBACK ();
1389/* ------------------------------------------------------------------------- */ 1390/* ------------------------------------------------------------------------- */
1390/* 1391/*
1391 * Insert/Delete <count> lines 1392 * Insert/Delete <count> lines
1392 */ 1393 */
1393void 1394void
1394rxvt_term::scr_insdel_lines (int count, int insdel) 1395rxvt_term::scr_insdel_lines (int count, int insdel) NOTHROW
1395{ 1396{
1396 int end; 1397 int end;
1397 1398
1398 ZERO_SCROLLBACK (); 1399 ZERO_SCROLLBACK ();
1399 1400
1419/* ------------------------------------------------------------------------- */ 1420/* ------------------------------------------------------------------------- */
1420/* 1421/*
1421 * Insert/Delete <count> characters from the current position 1422 * Insert/Delete <count> characters from the current position
1422 */ 1423 */
1423void 1424void
1424rxvt_term::scr_insdel_chars (int count, int insdel) 1425rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW
1425{ 1426{
1426 int col, row; 1427 int col, row;
1427 rend_t tr; 1428 rend_t tr;
1428 1429
1429 want_refresh = 1; 1430 want_refresh = 1;
1517/* 1518/*
1518 * Set the scrolling region 1519 * Set the scrolling region
1519 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1520 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1520 */ 1521 */
1521void 1522void
1522rxvt_term::scr_scroll_region (int top, int bot) 1523rxvt_term::scr_scroll_region (int top, int bot) NOTHROW
1523{ 1524{
1524 max_it (top, 0); 1525 max_it (top, 0);
1525 min_it (bot, nrow - 1); 1526 min_it (bot, nrow - 1);
1526 1527
1527 if (top > bot) 1528 if (top > bot)
1537 * Make the cursor visible/invisible 1538 * Make the cursor visible/invisible
1538 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h 1539 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h
1539 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l 1540 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l
1540 */ 1541 */
1541void 1542void
1542rxvt_term::scr_cursor_visible (int mode) 1543rxvt_term::scr_cursor_visible (int mode) NOTHROW
1543{ 1544{
1544 want_refresh = 1; 1545 want_refresh = 1;
1545 1546
1546 if (mode) 1547 if (mode)
1547 screen.flags |= Screen_VisibleCursor; 1548 screen.flags |= Screen_VisibleCursor;
1554 * Set/unset automatic wrapping 1555 * Set/unset automatic wrapping
1555 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h 1556 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h
1556 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l 1557 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l
1557 */ 1558 */
1558void 1559void
1559rxvt_term::scr_autowrap (int mode) 1560rxvt_term::scr_autowrap (int mode) NOTHROW
1560{ 1561{
1561 if (mode) 1562 if (mode)
1562 screen.flags |= Screen_Autowrap; 1563 screen.flags |= Screen_Autowrap;
1563 else 1564 else
1564 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); 1565 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);
1573 * and the cursor cannot be moved outside. 1574 * and the cursor cannot be moved outside.
1574 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h 1575 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h
1575 * XTERM_SEQ: Set Relative: ESC [ ? 6 l 1576 * XTERM_SEQ: Set Relative: ESC [ ? 6 l
1576 */ 1577 */
1577void 1578void
1578rxvt_term::scr_relative_origin (int mode) 1579rxvt_term::scr_relative_origin (int mode) NOTHROW
1579{ 1580{
1580 if (mode) 1581 if (mode)
1581 screen.flags |= Screen_Relative; 1582 screen.flags |= Screen_Relative;
1582 else 1583 else
1583 screen.flags &= ~Screen_Relative; 1584 screen.flags &= ~Screen_Relative;
1590 * Set insert/replace mode 1591 * Set insert/replace mode
1591 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h 1592 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h
1592 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l 1593 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l
1593 */ 1594 */
1594void 1595void
1595rxvt_term::scr_insert_mode (int mode) 1596rxvt_term::scr_insert_mode (int mode) NOTHROW
1596{ 1597{
1597 if (mode) 1598 if (mode)
1598 screen.flags |= Screen_Insert; 1599 screen.flags |= Screen_Insert;
1599 else 1600 else
1600 screen.flags &= ~Screen_Insert; 1601 screen.flags &= ~Screen_Insert;
1606 * XTERM_SEQ: Set tab at current column : ESC H 1607 * XTERM_SEQ: Set tab at current column : ESC H
1607 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g 1608 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g
1608 * XTERM_SEQ: Clear all tabs : ESC [ 3 g 1609 * XTERM_SEQ: Clear all tabs : ESC [ 3 g
1609 */ 1610 */
1610void 1611void
1611rxvt_term::scr_set_tab (int mode) 1612rxvt_term::scr_set_tab (int mode) NOTHROW
1612{ 1613{
1613 if (mode < 0) 1614 if (mode < 0)
1614 memset (tabs, 0, ncol * sizeof (char)); 1615 memset (tabs, 0, ncol * sizeof (char));
1615 else if (screen.cur.col < ncol) 1616 else if (screen.cur.col < ncol)
1616 tabs [screen.cur.col] = !!mode; 1617 tabs [screen.cur.col] = !!mode;
1621 * Set reverse/normal video 1622 * Set reverse/normal video
1622 * XTERM_SEQ: Reverse video: ESC [ ? 5 h 1623 * XTERM_SEQ: Reverse video: ESC [ ? 5 h
1623 * XTERM_SEQ: Normal video : ESC [ ? 5 l 1624 * XTERM_SEQ: Normal video : ESC [ ? 5 l
1624 */ 1625 */
1625void 1626void
1626rxvt_term::scr_rvideo_mode (int mode) 1627rxvt_term::scr_rvideo_mode (bool on) NOTHROW
1627{ 1628{
1628 XGCValues gcvalue; 1629 rvideo_mode = on;
1629 1630
1631#ifndef NO_BELL
1632 on ^= rvideo_bell;
1633#endif
1634
1630 if (rvideo != mode) 1635 if (rvideo_state != on)
1631 { 1636 {
1632 rvideo = mode; 1637 rvideo_state = on;
1638
1633 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1639 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1634#if XPM_BACKGROUND 1640#if XPM_BACKGROUND
1635 if (bgPixmap.pixmap == None) 1641 if (bgPixmap.pixmap == None)
1636#endif 1642#endif
1637#if TRANSPARENT 1643#if TRANSPARENT
1638 if (! OPTION (Opt_transparent) || am_transparent == 0) 1644 if (!OPTION (Opt_transparent) || am_transparent == 0)
1639#endif 1645#endif
1640 XSetWindowBackground (display->display, vt, 1646 XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]);
1641 pix_colors[Color_bg]);
1642 1647
1648 XGCValues gcvalue;
1643 gcvalue.foreground = pix_colors[Color_fg]; 1649 gcvalue.foreground = pix_colors[Color_fg];
1644 gcvalue.background = pix_colors[Color_bg]; 1650 gcvalue.background = pix_colors[Color_bg];
1645 XChangeGC (display->display, gc, GCBackground | GCForeground, 1651 XChangeGC (xdisp, gc, GCBackground | GCForeground, &gcvalue);
1646 &gcvalue); 1652
1647 scr_clear (); 1653 scr_clear ();
1648 scr_touch (true); 1654 scr_touch (true);
1649 } 1655 }
1650} 1656}
1651 1657
1653/* 1659/*
1654 * Report current cursor position 1660 * Report current cursor position
1655 * XTERM_SEQ: Report position: ESC [ 6 n 1661 * XTERM_SEQ: Report position: ESC [ 6 n
1656 */ 1662 */
1657void 1663void
1658rxvt_term::scr_report_position () 1664rxvt_term::scr_report_position () NOTHROW
1659{ 1665{
1660 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); 1666 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
1661} 1667}
1662 1668
1663/* ------------------------------------------------------------------------- * 1669/* ------------------------------------------------------------------------- *
1666 1672
1667/* 1673/*
1668 * Set font style 1674 * Set font style
1669 */ 1675 */
1670void 1676void
1671rxvt_term::set_font_style () 1677rxvt_term::set_font_style () NOTHROW
1672{ 1678{
1673#if 0 1679#if 0
1674 switch (charsets [screen.charset]) 1680 switch (charsets [screen.charset])
1675 { 1681 {
1676 case '0': /* DEC Special Character & Line Drawing Set */ 1682 case '0': /* DEC Special Character & Line Drawing Set */
1698 * XTERM_SEQ: Invoke G1 character set: CTRL-N 1704 * XTERM_SEQ: Invoke G1 character set: CTRL-N
1699 * XTERM_SEQ: Invoke G2 character set: ESC N 1705 * XTERM_SEQ: Invoke G2 character set: ESC N
1700 * XTERM_SEQ: Invoke G3 character set: ESC O 1706 * XTERM_SEQ: Invoke G3 character set: ESC O
1701 */ 1707 */
1702void 1708void
1703rxvt_term::scr_charset_choose (int set) 1709rxvt_term::scr_charset_choose (int set) NOTHROW
1704{ 1710{
1705 screen.charset = set; 1711 screen.charset = set;
1706 set_font_style (); 1712 set_font_style ();
1707} 1713}
1708 1714
1714 * XTERM_SEQ: Set G2 character set: ESC * <C> 1720 * XTERM_SEQ: Set G2 character set: ESC * <C>
1715 * XTERM_SEQ: Set G3 character set: ESC + <C> 1721 * XTERM_SEQ: Set G3 character set: ESC + <C>
1716 * See set_font_style for possible values for <C> 1722 * See set_font_style for possible values for <C>
1717 */ 1723 */
1718void 1724void
1719rxvt_term::scr_charset_set (int set, unsigned int ch) 1725rxvt_term::scr_charset_set (int set, unsigned int ch) NOTHROW
1720{ 1726{
1721 charsets[set] = (unsigned char)ch; 1727 charsets[set] = (unsigned char)ch;
1722 set_font_style (); 1728 set_font_style ();
1723} 1729}
1724 1730
1729 1735
1730/* 1736/*
1731 * refresh matching text. 1737 * refresh matching text.
1732 */ 1738 */
1733bool 1739bool
1734rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) 1740rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW
1735{ 1741{
1736 bool found = false; 1742 bool found = false;
1737 1743
1738 for (int i = 0; i < nrow; i++) 1744 for (int i = 0; i < nrow; i++)
1739 { 1745 {
1759 PART_END, 1765 PART_END,
1760 RC_COUNT 1766 RC_COUNT
1761}; 1767};
1762 1768
1763void 1769void
1764rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) 1770rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW
1765{ 1771{
1766 int i; 1772 int i;
1767 row_col_t rc[RC_COUNT]; 1773 row_col_t rc[RC_COUNT];
1768 1774
1769 if (!drawn_buf) /* sanity check */ 1775 if (!drawn_buf) /* sanity check */
1803/* ------------------------------------------------------------------------- */ 1809/* ------------------------------------------------------------------------- */
1804/* 1810/*
1805 * Refresh the entire screen 1811 * Refresh the entire screen
1806 */ 1812 */
1807void 1813void
1808rxvt_term::scr_touch (bool refresh) 1814rxvt_term::scr_touch (bool refresh) NOTHROW
1809{ 1815{
1810 scr_expose (0, 0, width, height, refresh); 1816 scr_expose (0, 0, width, height, refresh);
1811} 1817}
1812 1818
1813/* ------------------------------------------------------------------------- */ 1819/* ------------------------------------------------------------------------- */
1814/* 1820/*
1815 * Move the display so that the line represented by scrollbar value Y is at 1821 * Move the display so that the line represented by scrollbar value Y is at
1816 * the top of the screen 1822 * the top of the screen
1817 */ 1823 */
1818void 1824void
1819rxvt_term::scr_move_to (int y, int len) 1825rxvt_term::scr_move_to (int y, int len) NOTHROW
1820{ 1826{
1821 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1827 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1));
1822} 1828}
1823 1829
1824/* ------------------------------------------------------------------------- */ 1830/* ------------------------------------------------------------------------- */
1825/* 1831/*
1826 * Page the screen up/down nlines 1832 * Page the screen up/down nlines
1827 * direction should be UP or DN 1833 * direction should be UP or DN
1828 */ 1834 */
1829bool 1835bool
1830rxvt_term::scr_page (enum page_dirn direction, int nlines) 1836rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW
1831{ 1837{
1832 int new_view_start = 1838 int new_view_start =
1833 direction == UP ? view_start - nlines 1839 direction == UP ? view_start - nlines
1834 : view_start + nlines; 1840 : view_start + nlines;
1835 1841
1836 return scr_changeview (new_view_start); 1842 return scr_changeview (new_view_start);
1837} 1843}
1838 1844
1839bool 1845bool
1840rxvt_term::scr_changeview (int new_view_start) 1846rxvt_term::scr_changeview (int new_view_start) NOTHROW
1841{ 1847{
1842 clamp_it (new_view_start, top_row, 0); 1848 clamp_it (new_view_start, top_row, 0);
1843 1849
1844 if (new_view_start == view_start) 1850 if (new_view_start == view_start)
1845 return false; 1851 return false;
1851 HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END)); 1857 HOOK_INVOKE ((this, HOOK_VIEW_CHANGE, DT_INT, view_start, DT_END));
1852 1858
1853 return true; 1859 return true;
1854} 1860}
1855 1861
1856/* ------------------------------------------------------------------------- */ 1862#ifndef NO_BELL
1857void 1863void
1864rxvt_term::bell_cb (time_watcher &w)
1865{
1866 rvideo_bell = false;
1867 scr_rvideo_mode (rvideo_mode);
1868}
1869#endif
1870
1871/* ------------------------------------------------------------------------- */
1872void
1858rxvt_term::scr_bell () 1873rxvt_term::scr_bell () NOTHROW
1859{ 1874{
1860#ifndef NO_BELL 1875#ifndef NO_BELL
1861 1876
1862# ifndef NO_MAPALERT 1877# ifndef NO_MAPALERT
1863# ifdef MAPALERT_OPTION 1878# ifdef MAPALERT_OPTION
1864 if (OPTION (Opt_mapAlert)) 1879 if (OPTION (Opt_mapAlert))
1865# endif 1880# endif
1866 XMapWindow (display->display, parent[0]); 1881 XMapWindow (xdisp, parent[0]);
1867# endif 1882# endif
1868 1883
1869 if (OPTION (Opt_visualBell)) 1884 if (OPTION (Opt_visualBell))
1870 { 1885 {
1871 scr_rvideo_mode (!rvideo); /* refresh also done */ 1886 rvideo_bell = true;
1887 scr_rvideo_mode (rvideo_mode);
1872 display->flush (); 1888 display->flush ();
1873 rxvt_usleep (VISUAL_BELL_DURATION); 1889
1874 scr_rvideo_mode (!rvideo); /* refresh also done */ 1890 bell_ev.start (NOW + VISUAL_BELL_DURATION);
1875 } 1891 }
1876 else 1892 else
1877 XBell (display->display, 0); 1893 XBell (xdisp, 0);
1878 1894
1879#endif 1895#endif
1880} 1896}
1881 1897
1882/* ------------------------------------------------------------------------- */ 1898/* ------------------------------------------------------------------------- */
1883/* ARGSUSED */ 1899/* ARGSUSED */
1884void 1900void
1885rxvt_term::scr_printscreen (int fullhist) 1901rxvt_term::scr_printscreen (int fullhist) NOTHROW
1886{ 1902{
1887#ifdef PRINTPIPE 1903#ifdef PRINTPIPE
1888 int nrows, row_start; 1904 int nrows, row_start;
1889 FILE *fd; 1905 FILE *fd;
1890 1906
1939 * Refresh the screen 1955 * Refresh the screen
1940 * drawn_text/drawn_rend contain the screen information before the update. 1956 * drawn_text/drawn_rend contain the screen information before the update.
1941 * screen.text/screen.rend contain what the screen will change to. 1957 * screen.text/screen.rend contain what the screen will change to.
1942 */ 1958 */
1943void 1959void
1944rxvt_term::scr_refresh () 1960rxvt_term::scr_refresh () NOTHROW
1945{ 1961{
1946 unsigned char must_clear, /* use draw_string not draw_image_string */ 1962 unsigned char must_clear, /* use draw_string not draw_image_string */
1947 showcursor; /* show the cursor */ 1963 showcursor; /* show the cursor */
1948 int16_t col, row, /* column/row we're processing */ 1964 int16_t col, row, /* column/row we're processing */
1949 ocrow; /* old cursor row */ 1965 ocrow; /* old cursor row */
2121 { 2137 {
2122 /* also comes here at end if needed because of >= above */ 2138 /* also comes here at end if needed because of >= above */
2123 if (wlen < len) 2139 if (wlen < len)
2124 ::swap (wlen, len); 2140 ::swap (wlen, len);
2125 2141
2126 XCopyArea (display->display, vt, vt, 2142 XCopyArea (xdisp, vt, vt,
2127 gc, 0, Row2Pixel (len + i), 2143 gc, 0, Row2Pixel (len + i),
2128 (unsigned int)this->width, 2144 (unsigned int)this->width,
2129 (unsigned int)Height2Pixel (wlen - len + 1), 2145 (unsigned int)Height2Pixel (wlen - len + 1),
2130 0, Row2Pixel (len)); 2146 0, Row2Pixel (len));
2131 len = -1; 2147 len = -1;
2219 2235
2220 // only do special processing if any attributes are set, which is unlikely 2236 // only do special processing if any attributes are set, which is unlikely
2221 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) 2237 if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))
2222 { 2238 {
2223#if ENABLE_STYLES 2239#if ENABLE_STYLES
2224 // force redraw after "careful" characters to avoid pixel droppings 2240 // "careful" (too wide) character handling
2225 if (srp[col] & RS_Careful && col < ncol - 1 && 0)
2226 drp[col + 1] = ~srp[col + 1];
2227 2241
2228 // include previous careful character(s) if possible, looks nicer (best effort...) 2242 // include previous careful character(s) if possible, looks nicer (best effort...)
2229 while (text > stp 2243 while (text > stp
2230 && srp[text - stp - 1] & RS_Careful 2244 && srp[text - stp - 1] & RS_Careful
2231 && RS_SAME (rend, srp[text - stp - 1])) 2245 && RS_SAME (rend, srp[text - stp - 1]))
2232 text--, count++, xpixel -= fwidth; 2246 text--, count++, xpixel -= fwidth;
2247
2248 // force redraw after "careful" characters to avoid pixel droppings
2249 for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++)
2250 drp[col + i + 1] = ~srp[col + i + 1];
2251
2252 // force redraw before "careful" characters to avoid pixel droppings
2253 for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++)
2254 drp[text - stp - i - 1] = ~srp[text - stp - i - 1];
2233#endif 2255#endif
2234 2256
2235 bool invert = rend & RS_RVid; 2257 bool invert = rend & RS_RVid;
2236 2258
2237#ifndef NO_BOLD_UNDERLINE_REVERSE 2259#ifndef NO_BOLD_UNDERLINE_REVERSE
2321 2343
2322 if (rend & RS_Uline && font->descent > 1 && fore != back) 2344 if (rend & RS_Uline && font->descent > 1 && fore != back)
2323 { 2345 {
2324#if ENABLE_FRILLS 2346#if ENABLE_FRILLS
2325 if (ISSET_PIXCOLOR (Color_underline)) 2347 if (ISSET_PIXCOLOR (Color_underline))
2326 XSetForeground (display->display, gc, pix_colors[Color_underline]); 2348 XSetForeground (xdisp, gc, pix_colors[Color_underline]);
2327 else 2349 else
2328#endif 2350#endif
2329 XSetForeground (display->display, gc, pix_colors[fore]); 2351 XSetForeground (xdisp, gc, pix_colors[fore]);
2330 2352
2331 XDrawLine (display->display, drawBuffer, gc, 2353 XDrawLine (xdisp, drawBuffer, gc,
2332 xpixel, ypixel + font->ascent + 1, 2354 xpixel, ypixel + font->ascent + 1,
2333 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); 2355 xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1);
2334 } 2356 }
2335 } /* for (col....) */ 2357 } /* for (col....) */
2336 } /* for (row....) */ 2358 } /* for (row....) */
2369 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) 2391 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2370 cursorwidth++; 2392 cursorwidth++;
2371 2393
2372#ifndef NO_CURSORCOLOR 2394#ifndef NO_CURSORCOLOR
2373 if (ISSET_PIXCOLOR (Color_cursor)) 2395 if (ISSET_PIXCOLOR (Color_cursor))
2374 XSetForeground (display->display, gc, pix_colors[Color_cursor]); 2396 XSetForeground (xdisp, gc, pix_colors[Color_cursor]);
2375#endif 2397#endif
2376 2398
2377 XDrawRectangle (display->display, drawBuffer, gc, 2399 XDrawRectangle (xdisp, drawBuffer, gc,
2378 Col2Pixel (col), 2400 Col2Pixel (col),
2379 Row2Pixel (oldcursor.row), 2401 Row2Pixel (oldcursor.row),
2380 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2402 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2381 (unsigned int) (Height2Pixel (1) - lineSpace - 1)); 2403 (unsigned int) (Height2Pixel (1) - lineSpace - 1));
2382 } 2404 }
2390 num_scr = 0; 2412 num_scr = 0;
2391 num_scr_allow = 1; 2413 num_scr_allow = 1;
2392} 2414}
2393 2415
2394void 2416void
2395rxvt_term::scr_remap_chars (line_t &l) 2417rxvt_term::scr_remap_chars (line_t &l) NOTHROW
2396{ 2418{
2397 if (!l.t) 2419 if (!l.t)
2398 return; 2420 return;
2399 2421
2400 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant 2422 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant
2402 for (int i = ncol; i--; ) 2424 for (int i = ncol; i--; )
2403 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2425 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2404} 2426}
2405 2427
2406void 2428void
2407rxvt_term::scr_remap_chars () 2429rxvt_term::scr_remap_chars () NOTHROW
2408{ 2430{
2409 for (int i = total_rows; i--; ) 2431 for (int i = total_rows; i--; )
2410 scr_remap_chars (row_buf [i]); 2432 scr_remap_chars (row_buf [i]);
2411 2433
2412 for (int i = nrow; i--; ) 2434 for (int i = nrow; i--; )
2415 scr_remap_chars (swap_buf [i]); 2437 scr_remap_chars (swap_buf [i]);
2416 } 2438 }
2417} 2439}
2418 2440
2419void 2441void
2420rxvt_term::scr_recolour () 2442rxvt_term::scr_recolour () NOTHROW
2421{ 2443{
2422 if (1 2444 if (1
2423#if TRANSPARENT 2445#if TRANSPARENT
2424 && !am_transparent 2446 && !am_transparent
2425#endif 2447#endif
2426#if XPM_BACKGROUND 2448#if XPM_BACKGROUND
2427 && !bgPixmap.pixmap 2449 && !bgPixmap.pixmap
2428#endif 2450#endif
2429 ) 2451 )
2430 { 2452 {
2431 XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); 2453 XSetWindowBackground (xdisp, parent[0], pix_colors[Color_border]);
2432 XClearWindow (display->display, parent[0]); 2454 XClearWindow (xdisp, parent[0]);
2433 XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); 2455 XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]);
2434#if HAVE_SCROLLBARS 2456#if HAVE_SCROLLBARS
2435 if (scrollBar.win) 2457 if (scrollBar.win)
2436 { 2458 {
2437 XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); 2459 XSetWindowBackground (xdisp, scrollBar.win, pix_colors[Color_border]);
2438 scrollBar.setIdle (); 2460 scrollBar.setIdle ();
2439 scrollbar_show (0); 2461 scrollbar_show (0);
2440 } 2462 }
2441#endif 2463#endif
2442 } 2464 }
2446 want_refresh = 1; 2468 want_refresh = 1;
2447} 2469}
2448 2470
2449/* ------------------------------------------------------------------------- */ 2471/* ------------------------------------------------------------------------- */
2450void 2472void
2451rxvt_term::scr_clear (bool really) 2473rxvt_term::scr_clear (bool really) NOTHROW
2452{ 2474{
2453 if (!mapped) 2475 if (!mapped)
2454 return; 2476 return;
2455 2477
2456 num_scr_allow = 0; 2478 num_scr_allow = 0;
2457 want_refresh = 1; 2479 want_refresh = 1;
2458 2480
2459 if (really) 2481 if (really)
2460 XClearWindow (display->display, vt); 2482 XClearWindow (xdisp, vt);
2461} 2483}
2462 2484
2463void 2485void
2464rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) 2486rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW
2465{ 2487{
2466 int view_end = view_start + nrow; 2488 int view_end = view_start + nrow;
2467 int row, col; 2489 int row, col;
2468 2490
2469 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) 2491 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++)
2481 srp[col] ^= rstyle2; 2503 srp[col] ^= rstyle2;
2482 } 2504 }
2483} 2505}
2484 2506
2485void 2507void
2486rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) 2508rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW
2487{ 2509{
2488 int view_end = view_start + nrow; 2510 int view_end = view_start + nrow;
2489 int row, col; 2511 int row, col;
2490 2512
2491 if (beg_row >= view_start) 2513 if (beg_row >= view_start)
2508 srp[col] ^= rstyle; 2530 srp[col] ^= rstyle;
2509} 2531}
2510 2532
2511/* ------------------------------------------------------------------------- */ 2533/* ------------------------------------------------------------------------- */
2512void 2534void
2513rxvt_term::scr_reverse_selection () 2535rxvt_term::scr_reverse_selection () NOTHROW
2514{ 2536{
2515 if (selection.op 2537 if (selection.op
2516 && current_screen == selection.screen 2538 && current_screen == selection.screen
2517 && selection.end.row >= view_start) 2539 && selection.end.row >= view_start)
2518 { 2540 {
2534 * Dump the whole scrollback and screen to the passed filedescriptor. The 2556 * Dump the whole scrollback and screen to the passed filedescriptor. The
2535 * invoking routine must close the fd. 2557 * invoking routine must close the fd.
2536 */ 2558 */
2537#if 0 2559#if 0
2538void 2560void
2539rxvt_term::scr_dump (int fd) 2561rxvt_term::scr_dump (int fd) NOTHROW
2540{ 2562{
2541 int row, wrote; 2563 int row, wrote;
2542 unsigned int width, towrite; 2564 unsigned int width, towrite;
2543 char r1[] = "\n"; 2565 char r1[] = "\n";
2544 2566
2563 2585
2564/* ------------------------------------------------------------------------- * 2586/* ------------------------------------------------------------------------- *
2565 * CHARACTER SELECTION * 2587 * CHARACTER SELECTION *
2566 * ------------------------------------------------------------------------- */ 2588 * ------------------------------------------------------------------------- */
2567void 2589void
2568rxvt_term::selection_check (int check_more) 2590rxvt_term::selection_check (int check_more) NOTHROW
2569{ 2591{
2570 row_col_t pos; 2592 row_col_t pos;
2571 2593
2572 if (!selection.op) 2594 if (!selection.op)
2573 return; 2595 return;
2594/* ------------------------------------------------------------------------- */ 2616/* ------------------------------------------------------------------------- */
2595/* 2617/*
2596 * Paste a selection direct to the command fd 2618 * Paste a selection direct to the command fd
2597 */ 2619 */
2598void 2620void
2599rxvt_term::paste (char *data, unsigned int len) 2621rxvt_term::paste (char *data, unsigned int len) NOTHROW
2600{ 2622{
2601 /* convert normal newline chars into common keyboard Return key sequence */ 2623 /* convert normal newline chars into common keyboard Return key sequence */
2602 for (unsigned int i = 0; i < len; i++) 2624 for (unsigned int i = 0; i < len; i++)
2603 if (data[i] == C0_LF) 2625 if (data[i] == C0_LF)
2604 data[i] = C0_CR; 2626 data[i] = C0_CR;
2610/* 2632/*
2611 * Respond to a notification that a primary selection has been sent 2633 * Respond to a notification that a primary selection has been sent
2612 * EXT: SelectionNotify 2634 * EXT: SelectionNotify
2613 */ 2635 */
2614void 2636void
2615rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) 2637rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) NOTHROW
2616{ 2638{
2617 if (prop == None) /* check for failed XConvertSelection */ 2639 if (prop == None) /* check for failed XConvertSelection */
2618 { 2640 {
2619 if ((selection_type & Sel_CompoundText)) 2641 if ((selection_type & Sel_CompoundText))
2620 { 2642 {
2640 } 2662 }
2641 2663
2642 unsigned long bytes_after; 2664 unsigned long bytes_after;
2643 XTextProperty ct; 2665 XTextProperty ct;
2644 2666
2645 if (XGetWindowProperty (display->display, win, prop, 2667 if (XGetWindowProperty (xdisp, win, prop,
2646 0, PROP_SIZE / 4, 2668 0, PROP_SIZE / 4,
2647 delete_prop, AnyPropertyType, 2669 delete_prop, AnyPropertyType,
2648 &ct.encoding, &ct.format, 2670 &ct.encoding, &ct.format,
2649 &ct.nitems, &bytes_after, 2671 &ct.nitems, &bytes_after,
2650 &ct.value) != Success) 2672 &ct.value) != Success)
2659 if (bytes_after) 2681 if (bytes_after)
2660 { 2682 {
2661 // fetch and append remaining data 2683 // fetch and append remaining data
2662 XTextProperty ct2; 2684 XTextProperty ct2;
2663 2685
2664 if (XGetWindowProperty (display->display, win, prop, 2686 if (XGetWindowProperty (xdisp, win, prop,
2665 ct.nitems / 4, (bytes_after + 3) / 4, 2687 ct.nitems / 4, (bytes_after + 3) / 4,
2666 delete_prop, AnyPropertyType, 2688 delete_prop, AnyPropertyType,
2667 &ct2.encoding, &ct2.format, 2689 &ct2.encoding, &ct2.format,
2668 &ct2.nitems, &bytes_after, 2690 &ct2.nitems, &bytes_after,
2669 &ct2.value) != Success) 2691 &ct2.value) != Success)
2682 2704
2683 if (ct.encoding == xa[XA_INCR]) 2705 if (ct.encoding == xa[XA_INCR])
2684 { 2706 {
2685 // INCR selection, start handshake 2707 // INCR selection, start handshake
2686 if (!delete_prop) 2708 if (!delete_prop)
2687 XDeleteProperty (display->display, win, prop); 2709 XDeleteProperty (xdisp, win, prop);
2688 2710
2689 selection_wait = Sel_incr; 2711 selection_wait = Sel_incr;
2690 incr_buf_fill = 0; 2712 incr_buf_fill = 0;
2691 incr_ev.start (NOW + 10); 2713 incr_ev.start (NOW + 10);
2692 2714
2753 paste (s, strlen (s)); 2775 paste (s, strlen (s));
2754 free (s); 2776 free (s);
2755 } 2777 }
2756 else 2778 else
2757#endif 2779#endif
2758 if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 2780 if (XmbTextPropertyToTextList (xdisp, &ct, &cl, &cr) >= 0
2759 && cl) 2781 && cl)
2760 { 2782 {
2761 for (int i = 0; i < cr; i++) 2783 for (int i = 0; i < cr; i++)
2762 paste (cl[i], strlen (cl[i])); 2784 paste (cl[i], strlen (cl[i]));
2763 2785
2772 if (selection_wait == Sel_normal) 2794 if (selection_wait == Sel_normal)
2773 selection_wait = Sel_none; 2795 selection_wait = Sel_none;
2774} 2796}
2775 2797
2776void 2798void
2777rxvt_term::incr_cb (time_watcher &w) 2799rxvt_term::incr_cb (time_watcher &w) NOTHROW
2778{ 2800{
2779 selection_wait = Sel_none; 2801 selection_wait = Sel_none;
2780 2802
2781 incr_buf_size = 0; 2803 incr_buf_size = 0;
2782 free (incr_buf); 2804 free (incr_buf);
2783 2805
2784 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); 2806 rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n");
2785} 2807}
2786 2808
2787void 2809void
2788rxvt_term::selection_property (Window win, Atom prop) 2810rxvt_term::selection_property (Window win, Atom prop) NOTHROW
2789{ 2811{
2790 if (prop == None || selection_wait != Sel_incr) 2812 if (prop == None || selection_wait != Sel_incr)
2791 return; 2813 return;
2792 2814
2793 selection_paste (win, prop, true); 2815 selection_paste (win, prop, true);
2802 * (+) if ownership is claimed but property is empty, rxvt_selection_paste () 2824 * (+) if ownership is claimed but property is empty, rxvt_selection_paste ()
2803 * will auto fallback to CUT_BUFFER0 2825 * will auto fallback to CUT_BUFFER0
2804 * EXT: button 2 release 2826 * EXT: button 2 release
2805 */ 2827 */
2806void 2828void
2807rxvt_term::selection_request (Time tm) 2829rxvt_term::selection_request (Time tm, int selnum) NOTHROW
2808{ 2830{
2809 if (selection.text) 2831 if (selection.text && selnum == Sel_Primary)
2810 { /* internal selection */ 2832 { /* internal selection */
2811 char *str = rxvt_wcstombs (selection.text, selection.len); 2833 char *str = rxvt_wcstombs (selection.text, selection.len);
2812 paste (str, strlen (str)); 2834 paste (str, strlen (str));
2813 free (str); 2835 free (str);
2814 return; 2836 return;
2815 } 2837 }
2816 else 2838 else
2817 { 2839 {
2818 int i;
2819
2820 selection_request_time = tm; 2840 selection_request_time = tm;
2821 selection_wait = Sel_normal; 2841 selection_wait = Sel_normal;
2822 2842
2823 for (i = Sel_Primary; i <= Sel_Clipboard; i++)
2824 {
2825#if X_HAVE_UTF8_STRING 2843#if X_HAVE_UTF8_STRING
2826 selection_type = Sel_UTF8String; 2844 selection_type = Sel_UTF8String;
2827 if (selection_request_other (xa[XA_UTF8_STRING], i)) 2845 if (selection_request_other (xa[XA_UTF8_STRING], selnum))
2828 return; 2846 return;
2829#else 2847#else
2830 selection_type = Sel_CompoundText; 2848 selection_type = Sel_CompoundText;
2831 if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) 2849 if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum))
2832 return; 2850 return;
2833#endif 2851#endif
2834 }
2835 } 2852 }
2836 2853
2837 selection_wait = Sel_none; /* don't loop in selection_paste () */ 2854 selection_wait = Sel_none; /* don't loop in selection_paste () */
2838 selection_paste (display->root, XA_CUT_BUFFER0, false); 2855 selection_paste (display->root, XA_CUT_BUFFER0, false);
2839} 2856}
2840 2857
2841int 2858int
2842rxvt_term::selection_request_other (Atom target, int selnum) 2859rxvt_term::selection_request_other (Atom target, int selnum) NOTHROW
2843{ 2860{
2844 Atom sel; 2861 Atom sel;
2845 2862
2846 selection_type |= selnum; 2863 selection_type |= selnum;
2847 2864
2850 else if (selnum == Sel_Secondary) 2867 else if (selnum == Sel_Secondary)
2851 sel = XA_SECONDARY; 2868 sel = XA_SECONDARY;
2852 else 2869 else
2853 sel = xa[XA_CLIPBOARD]; 2870 sel = xa[XA_CLIPBOARD];
2854 2871
2855 if (XGetSelectionOwner (display->display, sel) != None) 2872 if (XGetSelectionOwner (xdisp, sel) != None)
2856 { 2873 {
2857 XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], 2874 XConvertSelection (xdisp, sel, target, xa[XA_VT_SELECTION],
2858 vt, selection_request_time); 2875 vt, selection_request_time);
2859 return 1; 2876 return 1;
2860 } 2877 }
2861 2878
2862 return 0; 2879 return 0;
2866/* 2883/*
2867 * Clear all selected text 2884 * Clear all selected text
2868 * EXT: SelectionClear 2885 * EXT: SelectionClear
2869 */ 2886 */
2870void 2887void
2871rxvt_term::selection_clear () 2888rxvt_term::selection_clear () NOTHROW
2872{ 2889{
2873 want_refresh = 1; 2890 want_refresh = 1;
2874 free (selection.text); 2891 free (selection.text);
2875 selection.text = NULL; 2892 selection.text = NULL;
2876 selection.len = 0; 2893 selection.len = 0;
3011 3028
3012 selection_grab (tm); 3029 selection_grab (tm);
3013} 3030}
3014 3031
3015bool 3032bool
3016rxvt_term::selection_grab (Time tm) 3033rxvt_term::selection_grab (Time tm) NOTHROW
3017{ 3034{
3018 selection_time = tm; 3035 selection_time = tm;
3019 3036
3020 XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); 3037 XSetSelectionOwner (xdisp, XA_PRIMARY, vt, tm);
3021 if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) 3038 if (XGetSelectionOwner (xdisp, XA_PRIMARY) == vt)
3022 { 3039 {
3023 display->set_selection_owner (this); 3040 display->set_selection_owner (this);
3024 return true; 3041 return true;
3025 } 3042 }
3026 else 3043 else
3030 } 3047 }
3031 3048
3032#if 0 3049#if 0
3033 XTextProperty ct; 3050 XTextProperty ct;
3034 3051
3035 if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) 3052 if (XwcTextListToTextProperty (xdisp, &selection.text, 1, XStringStyle, &ct) >= 0)
3036 { 3053 {
3037 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); 3054 set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems);
3038 XFree (ct.value); 3055 XFree (ct.value);
3039 } 3056 }
3040#endif 3057#endif
3044/* 3061/*
3045 * Mark or select text based upon number of clicks: 1, 2, or 3 3062 * Mark or select text based upon number of clicks: 1, 2, or 3
3046 * EXT: button 1 press 3063 * EXT: button 1 press
3047 */ 3064 */
3048void 3065void
3049rxvt_term::selection_click (int clicks, int x, int y) 3066rxvt_term::selection_click (int clicks, int x, int y) NOTHROW
3050{ 3067{
3051 clicks = ((clicks - 1) % 3) + 1; 3068 clicks = ((clicks - 1) % 3) + 1;
3052 selection.clicks = clicks; /* save clicks so extend will work */ 3069 selection.clicks = clicks; /* save clicks so extend will work */
3053 3070
3054 if (clicks == 2 && !selection.rect 3071 if (clicks == 2 && !selection.rect
3073/* ------------------------------------------------------------------------- */ 3090/* ------------------------------------------------------------------------- */
3074/* 3091/*
3075 * Mark a selection at the specified col/row 3092 * Mark a selection at the specified col/row
3076 */ 3093 */
3077void 3094void
3078rxvt_term::selection_start_colrow (int col, int row) 3095rxvt_term::selection_start_colrow (int col, int row) NOTHROW
3079{ 3096{
3080 want_refresh = 1; 3097 want_refresh = 1;
3081 3098
3082 selection.mark.row = row + view_start; 3099 selection.mark.row = row + view_start;
3083 selection.mark.col = col; 3100 selection.mark.col = col;
3109#define DELIMIT_TEXT(x) \ 3126#define DELIMIT_TEXT(x) \
3110 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) 3127 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x)))
3111#define DELIMIT_REND(x) 1 3128#define DELIMIT_REND(x) 1
3112 3129
3113void 3130void
3114rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) 3131rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW
3115{ 3132{
3116 int col, row, dirnadd, tcol, trow, w1, w2; 3133 int col, row, dirnadd, tcol, trow, w1, w2;
3117 row_col_t bound; 3134 row_col_t bound;
3118 text_t *stp; 3135 text_t *stp;
3119 rend_t *srp; 3136 rend_t *srp;
3193 * flag == 0 ==> button 1 3210 * flag == 0 ==> button 1
3194 * flag == 1 ==> button 3 press 3211 * flag == 1 ==> button 3 press
3195 * flag == 2 ==> button 3 motion 3212 * flag == 2 ==> button 3 motion
3196 */ 3213 */
3197void 3214void
3198rxvt_term::selection_extend (int x, int y, int flag) 3215rxvt_term::selection_extend (int x, int y, int flag) NOTHROW
3199{ 3216{
3200 int col = clamp (Pixel2Col (x), 0, ncol); 3217 int col = clamp (Pixel2Col (x), 0, ncol);
3201 int row = clamp (Pixel2Row (y), 0, nrow - 1); 3218 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3202 3219
3203 /* 3220 /*
3229/* ------------------------------------------------------------------------- */ 3246/* ------------------------------------------------------------------------- */
3230/* 3247/*
3231 * Extend the selection to the specified col/row 3248 * Extend the selection to the specified col/row
3232 */ 3249 */
3233void 3250void
3234rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) 3251rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW
3235{ 3252{
3236 row_col_t pos; 3253 row_col_t pos;
3237 enum { 3254 enum {
3238 LEFT, RIGHT 3255 LEFT, RIGHT
3239 } closeto = RIGHT; 3256 } closeto = RIGHT;
3425#endif 3442#endif
3426} 3443}
3427 3444
3428#if ENABLE_FRILLS 3445#if ENABLE_FRILLS
3429void 3446void
3430rxvt_term::selection_remove_trailing_spaces () 3447rxvt_term::selection_remove_trailing_spaces () NOTHROW
3431{ 3448{
3432 int32_t end_col, end_row; 3449 int32_t end_col, end_row;
3433 text_t *stp; 3450 text_t *stp;
3434 3451
3435 end_col = selection.end.col; 3452 end_col = selection.end.col;
3473/* 3490/*
3474 * Double click on button 3 when already selected 3491 * Double click on button 3 when already selected
3475 * EXT: button 3 double click 3492 * EXT: button 3 double click
3476 */ 3493 */
3477void 3494void
3478rxvt_term::selection_rotate (int x, int y) 3495rxvt_term::selection_rotate (int x, int y) NOTHROW
3479{ 3496{
3480 selection.clicks = selection.clicks % 3 + 1; 3497 selection.clicks = selection.clicks % 3 + 1;
3481 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); 3498 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1);
3482} 3499}
3483 3500
3485/* 3502/*
3486 * Respond to a request for our current selection 3503 * Respond to a request for our current selection
3487 * EXT: SelectionRequest 3504 * EXT: SelectionRequest
3488 */ 3505 */
3489void 3506void
3490rxvt_term::selection_send (const XSelectionRequestEvent &rq) 3507rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW
3491{ 3508{
3492 XSelectionEvent ev; 3509 XSelectionEvent ev;
3493 dDisp;
3494 3510
3495 ev.type = SelectionNotify; 3511 ev.type = SelectionNotify;
3496 ev.property = None; 3512 ev.property = None;
3497 ev.display = rq.display; 3513 ev.display = rq.display;
3498 ev.requestor = rq.requestor; 3514 ev.requestor = rq.requestor;
3512 *target++ = xa[XA_COMPOUND_TEXT]; 3528 *target++ = xa[XA_COMPOUND_TEXT];
3513#if X_HAVE_UTF8_STRING 3529#if X_HAVE_UTF8_STRING
3514 *target++ = xa[XA_UTF8_STRING]; 3530 *target++ = xa[XA_UTF8_STRING];
3515#endif 3531#endif
3516 3532
3517 XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, 3533 XChangeProperty (xdisp, rq.requestor, rq.property, XA_ATOM,
3518 32, PropModeReplace, 3534 32, PropModeReplace,
3519 (unsigned char *)target_list, target - target_list); 3535 (unsigned char *)target_list, target - target_list);
3520 ev.property = rq.property; 3536 ev.property = rq.property;
3521 } 3537 }
3522#if TODO // TODO 3538#if TODO // TODO
3525 /* TODO: Handle MULTIPLE */ 3541 /* TODO: Handle MULTIPLE */
3526 } 3542 }
3527#endif 3543#endif
3528 else if (rq.target == xa[XA_TIMESTAMP] && selection.text) 3544 else if (rq.target == xa[XA_TIMESTAMP] && selection.text)
3529 { 3545 {
3530 XChangeProperty (disp, rq.requestor, rq.property, rq.target, 3546 XChangeProperty (xdisp, rq.requestor, rq.property, rq.target,
3531 32, PropModeReplace, (unsigned char *)&selection_time, 1); 3547 32, PropModeReplace, (unsigned char *)&selection_time, 1);
3532 ev.property = rq.property; 3548 ev.property = rq.property;
3533 } 3549 }
3534 else if (rq.target == XA_STRING 3550 else if (rq.target == XA_STRING
3535 || rq.target == xa[XA_TEXT] 3551 || rq.target == xa[XA_TEXT]
3593 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); 3609 ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen);
3594 ct.nitems = strlen ((char *)ct.value); 3610 ct.nitems = strlen ((char *)ct.value);
3595 } 3611 }
3596 else 3612 else
3597#endif 3613#endif
3598 if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) 3614 if (XwcTextListToTextProperty (xdisp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0)
3599 freect = 1; 3615 freect = 1;
3600 else 3616 else
3601 { 3617 {
3602 /* if we failed to convert then send it raw */ 3618 /* if we failed to convert then send it raw */
3603 ct.value = (unsigned char *)cl; 3619 ct.value = (unsigned char *)cl;
3604 ct.nitems = selectlen; 3620 ct.nitems = selectlen;
3605 ct.encoding = target; 3621 ct.encoding = target;
3606 } 3622 }
3607 3623
3608 XChangeProperty (disp, rq.requestor, rq.property, 3624 XChangeProperty (xdisp, rq.requestor, rq.property,
3609 ct.encoding, 8, PropModeReplace, 3625 ct.encoding, 8, PropModeReplace,
3610 ct.value, (int)ct.nitems); 3626 ct.value, (int)ct.nitems);
3611 ev.property = rq.property; 3627 ev.property = rq.property;
3612 3628
3613 if (freect) 3629 if (freect)
3614 XFree (ct.value); 3630 XFree (ct.value);
3615 } 3631 }
3616 3632
3617 XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); 3633 XSendEvent (xdisp, rq.requestor, False, 0L, (XEvent *)&ev);
3618} 3634}
3619 3635
3620/* ------------------------------------------------------------------------- * 3636/* ------------------------------------------------------------------------- *
3621 * MOUSE ROUTINES * 3637 * MOUSE ROUTINES *
3622 * ------------------------------------------------------------------------- */ 3638 * ------------------------------------------------------------------------- */
3623 3639
3624/* 3640/*
3625 * return col/row values corresponding to x/y pixel values 3641 * return col/row values corresponding to x/y pixel values
3626 */ 3642 */
3627void 3643void
3628rxvt_term::pixel_position (int *x, int *y) 3644rxvt_term::pixel_position (int *x, int *y) NOTHROW
3629{ 3645{
3630 *x = Pixel2Col (*x); 3646 *x = Pixel2Col (*x);
3631 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ 3647 /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */
3632 *y = Pixel2Row (*y); 3648 *y = Pixel2Row (*y);
3633 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ 3649 /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */
3634} 3650}
3635 3651
3636/* ------------------------------------------------------------------------- */ 3652/* ------------------------------------------------------------------------- */
3637#ifdef USE_XIM 3653#ifdef USE_XIM
3638void 3654void
3639rxvt_term::im_set_position (XPoint &pos) 3655rxvt_term::im_set_position (XPoint &pos) NOTHROW
3640{ 3656{
3641 XWindowAttributes xwa; 3657 XWindowAttributes xwa;
3642 3658
3643 XGetWindowAttributes (display->display, vt, &xwa); 3659 XGetWindowAttributes (xdisp, vt, &xwa);
3644 3660
3645 pos.x = xwa.x + Col2Pixel (screen.cur.col); 3661 pos.x = xwa.x + Col2Pixel (screen.cur.col);
3646 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; 3662 pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase;
3647} 3663}
3648#endif 3664#endif
3649 3665
3650#if ENABLE_OVERLAY 3666#if ENABLE_OVERLAY
3651void 3667void
3652rxvt_term::scr_overlay_new (int x, int y, int w, int h) 3668rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW
3653{ 3669{
3654 if (nrow < 1 || ncol < 1) 3670 if (nrow < 1 || ncol < 1)
3655 return; 3671 return;
3656 3672
3657 want_refresh = 1; 3673 want_refresh = 1;
3702 *rp = r; 3718 *rp = r;
3703 } 3719 }
3704} 3720}
3705 3721
3706void 3722void
3707rxvt_term::scr_overlay_off () 3723rxvt_term::scr_overlay_off () NOTHROW
3708{ 3724{
3709 if (!ov_text) 3725 if (!ov_text)
3710 return; 3726 return;
3711 3727
3712 want_refresh = 1; 3728 want_refresh = 1;
3720 delete [] ov_text; ov_text = 0; 3736 delete [] ov_text; ov_text = 0;
3721 delete [] ov_rend; ov_rend = 0; 3737 delete [] ov_rend; ov_rend = 0;
3722} 3738}
3723 3739
3724void 3740void
3725rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) 3741rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW
3726{ 3742{
3727 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) 3743 if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2)
3728 return; 3744 return;
3729 3745
3730 x++, y++; 3746 x++, y++;
3732 ov_text[y][x] = text; 3748 ov_text[y][x] = text;
3733 ov_rend[y][x] = rend; 3749 ov_rend[y][x] = rend;
3734} 3750}
3735 3751
3736void 3752void
3737rxvt_term::scr_overlay_set (int x, int y, const char *s) 3753rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW
3738{ 3754{
3739 while (*s) 3755 while (*s)
3740 scr_overlay_set (x++, y, *s++); 3756 scr_overlay_set (x++, y, *s++);
3741} 3757}
3742 3758
3743void 3759void
3744rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) 3760rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW
3745{ 3761{
3746 while (*s) 3762 while (*s)
3747 { 3763 {
3748 text_t t = *s++; 3764 text_t t = *s++;
3749 int width = wcwidth (t); 3765 int width = WCWIDTH (t);
3750 3766
3751 while (width--) 3767 while (width--)
3752 { 3768 {
3753 scr_overlay_set (x++, y, t); 3769 scr_overlay_set (x++, y, t);
3754 t = NOCHAR; 3770 t = NOCHAR;
3755 } 3771 }
3756 } 3772 }
3757} 3773}
3758 3774
3759void 3775void
3760rxvt_term::scr_swap_overlay () 3776rxvt_term::scr_swap_overlay () NOTHROW
3761{ 3777{
3762 if (!ov_text) 3778 if (!ov_text)
3763 return; 3779 return;
3764 3780
3765 // swap screen mem with overlay 3781 // swap screen mem with overlay

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines