… | |
… | |
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. */ |
119 | void |
119 | void |
120 | rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const |
120 | rxvt_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 */ |
146 | void |
146 | void |
147 | rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const |
147 | rxvt_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 | */ |
428 | void |
429 | void |
429 | rxvt_term::scr_release () |
430 | rxvt_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 | */ |
465 | void |
469 | void |
466 | rxvt_term::scr_cursor (int mode) |
470 | rxvt_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 | |
|
|
512 | void |
|
|
513 | rxvt_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 | */ |
514 | int |
533 | void |
515 | rxvt_term::scr_change_screen (int scrn) |
534 | rxvt_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 |
555 | void |
565 | void |
556 | rxvt_term::scr_do_wrap () |
566 | rxvt_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 | */ |
575 | void |
585 | void |
576 | rxvt_term::scr_color (unsigned int color, int fgbg) |
586 | rxvt_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 | */ |
591 | void |
601 | void |
592 | rxvt_term::scr_rendition (int set, int style) |
602 | rxvt_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 | */ |
608 | int |
618 | int |
609 | rxvt_term::scr_scroll_text (int row1, int row2, int count) |
619 | rxvt_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_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 | */ |
736 | void |
750 | void |
737 | rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) |
751 | rxvt_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 | */ |
1000 | void |
1015 | void |
1001 | rxvt_term::scr_backspace () |
1016 | rxvt_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 | */ |
1028 | void |
1043 | void |
1029 | rxvt_term::scr_tab (int count, bool ht) |
1044 | rxvt_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; |
… | |
… | |
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_FRILLS |
1105 | void |
1120 | void |
1106 | rxvt_term::scr_backindex () |
1121 | rxvt_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); |
… | |
… | |
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_FRILLS |
1122 | void |
1137 | void |
1123 | rxvt_term::scr_forwardindex () |
1138 | rxvt_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 | */ |
1145 | void |
1160 | void |
1146 | rxvt_term::scr_gotorc (int row, int col, int relative) |
1161 | rxvt_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 | */ |
1193 | void |
1208 | void |
1194 | rxvt_term::scr_index (enum page_dirn direction) |
1209 | rxvt_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 | */ |
1222 | void |
1237 | void |
1223 | rxvt_term::scr_erase_line (int mode) |
1238 | rxvt_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 | */ |
1276 | void |
1291 | void |
1277 | rxvt_term::scr_erase_screen (int mode) |
1292 | rxvt_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 (xdisp, 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 (xdisp, 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); |
… | |
… | |
1342 | } |
1357 | } |
1343 | } |
1358 | } |
1344 | |
1359 | |
1345 | #if ENABLE_FRILLS |
1360 | #if ENABLE_FRILLS |
1346 | void |
1361 | void |
1347 | rxvt_term::scr_erase_savelines () |
1362 | rxvt_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 | */ |
1361 | void |
1376 | void |
1362 | rxvt_term::scr_E () |
1377 | rxvt_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 | */ |
1392 | void |
1407 | void |
1393 | rxvt_term::scr_insdel_lines (int count, int insdel) |
1408 | rxvt_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 | */ |
1422 | void |
1437 | void |
1423 | rxvt_term::scr_insdel_chars (int count, int insdel) |
1438 | rxvt_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 | */ |
1520 | void |
1535 | void |
1521 | rxvt_term::scr_scroll_region (int top, int bot) |
1536 | rxvt_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 | */ |
1540 | void |
1555 | void |
1541 | rxvt_term::scr_cursor_visible (int mode) |
1556 | rxvt_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 | */ |
1557 | void |
1572 | void |
1558 | rxvt_term::scr_autowrap (int mode) |
1573 | rxvt_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 | */ |
1576 | void |
1591 | void |
1577 | rxvt_term::scr_relative_origin (int mode) |
1592 | rxvt_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 | */ |
1593 | void |
1608 | void |
1594 | rxvt_term::scr_insert_mode (int mode) |
1609 | rxvt_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 | */ |
1609 | void |
1624 | void |
1610 | rxvt_term::scr_set_tab (int mode) |
1625 | rxvt_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 | */ |
1624 | void |
1639 | void |
1625 | rxvt_term::scr_rvideo_mode (int mode) |
1640 | rxvt_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 (xdisp, 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 (xdisp, 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 | */ |
1656 | void |
1676 | void |
1657 | rxvt_term::scr_report_position () |
1677 | rxvt_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 | */ |
1669 | void |
1689 | void |
1670 | rxvt_term::set_font_style () |
1690 | rxvt_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 | */ |
1701 | void |
1721 | void |
1702 | rxvt_term::scr_charset_choose (int set) |
1722 | rxvt_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 | */ |
1717 | void |
1737 | void |
1718 | rxvt_term::scr_charset_set (int set, unsigned int ch) |
1738 | rxvt_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 | */ |
1732 | bool |
1752 | bool |
1733 | rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) |
1753 | rxvt_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 | |
1762 | void |
1781 | void |
1763 | rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) |
1782 | rxvt_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 | */ |
1806 | void |
1825 | void |
1807 | rxvt_term::scr_touch (bool refresh) |
1826 | rxvt_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 | */ |
1817 | void |
1836 | void |
1818 | rxvt_term::scr_move_to (int y, int len) |
1837 | rxvt_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 | */ |
1828 | bool |
1847 | bool |
1829 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1848 | rxvt_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 | |
1838 | bool |
1857 | bool |
1839 | rxvt_term::scr_changeview (int new_view_start) |
1858 | rxvt_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 |
1856 | void |
1875 | void |
|
|
1876 | rxvt_term::bell_cb (time_watcher &w) |
|
|
1877 | { |
|
|
1878 | rvideo_bell = false; |
|
|
1879 | scr_rvideo_mode (rvideo_mode); |
|
|
1880 | } |
|
|
1881 | #endif |
|
|
1882 | |
|
|
1883 | /* ------------------------------------------------------------------------- */ |
|
|
1884 | void |
1857 | rxvt_term::scr_bell () |
1885 | rxvt_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 (xdisp, 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 (xdisp, 0); |
1877 | |
1906 | |
1878 | #endif |
1907 | #endif |
1879 | } |
1908 | } |
1880 | |
1909 | |
1881 | /* ------------------------------------------------------------------------- */ |
1910 | /* ------------------------------------------------------------------------- */ |
1882 | /* ARGSUSED */ |
1911 | /* ARGSUSED */ |
1883 | void |
1912 | void |
1884 | rxvt_term::scr_printscreen (int fullhist) |
1913 | rxvt_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 | */ |
1942 | void |
1971 | void |
1943 | rxvt_term::scr_refresh () |
1972 | rxvt_term::scr_refresh () NOTHROW |
1944 | { |
1973 | { |
1945 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1974 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
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 */ |
… | |
… | |
2120 | { |
2149 | { |
2121 | /* also comes here at end if needed because of >= above */ |
2150 | /* also comes here at end if needed because of >= above */ |
2122 | if (wlen < len) |
2151 | if (wlen < len) |
2123 | ::swap (wlen, len); |
2152 | ::swap (wlen, len); |
2124 | |
2153 | |
2125 | XCopyArea (display->display, vt, vt, |
2154 | XCopyArea (xdisp, vt, vt, |
2126 | gc, 0, Row2Pixel (len + i), |
2155 | gc, 0, Row2Pixel (len + i), |
2127 | (unsigned int)this->width, |
2156 | (unsigned int)this->width, |
2128 | (unsigned int)Height2Pixel (wlen - len + 1), |
2157 | (unsigned int)Height2Pixel (wlen - len + 1), |
2129 | 0, Row2Pixel (len)); |
2158 | 0, Row2Pixel (len)); |
2130 | len = -1; |
2159 | len = -1; |
… | |
… | |
2218 | |
2247 | |
2219 | // only do special processing if any attributes are set, which is unlikely |
2248 | // 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)) |
2249 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2221 | { |
2250 | { |
2222 | #if ENABLE_STYLES |
2251 | #if ENABLE_STYLES |
2223 | // force redraw after "careful" characters to avoid pixel droppings |
2252 | // "careful" (too wide) character handling |
2224 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
|
|
2225 | drp[col + 1] = ~srp[col + 1]; |
|
|
2226 | |
2253 | |
2227 | // include previous careful character(s) if possible, looks nicer (best effort...) |
2254 | // include previous careful character(s) if possible, looks nicer (best effort...) |
2228 | while (text > stp |
2255 | while (text > stp |
2229 | && srp[text - stp - 1] & RS_Careful |
2256 | && srp[text - stp - 1] & RS_Careful |
2230 | && RS_SAME (rend, srp[text - stp - 1])) |
2257 | && RS_SAME (rend, srp[text - stp - 1])) |
2231 | text--, count++, xpixel -= fwidth; |
2258 | text--, count++, xpixel -= fwidth; |
|
|
2259 | |
|
|
2260 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2261 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2262 | drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; |
|
|
2263 | |
|
|
2264 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2265 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2266 | drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; |
2232 | #endif |
2267 | #endif |
2233 | |
2268 | |
2234 | bool invert = rend & RS_RVid; |
2269 | bool invert = rend & RS_RVid; |
2235 | |
2270 | |
2236 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2271 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
… | |
… | |
2320 | |
2355 | |
2321 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2356 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2322 | { |
2357 | { |
2323 | #if ENABLE_FRILLS |
2358 | #if ENABLE_FRILLS |
2324 | if (ISSET_PIXCOLOR (Color_underline)) |
2359 | if (ISSET_PIXCOLOR (Color_underline)) |
2325 | XSetForeground (display->display, gc, pix_colors[Color_underline]); |
2360 | XSetForeground (xdisp, gc, pix_colors[Color_underline]); |
2326 | else |
2361 | else |
2327 | #endif |
2362 | #endif |
2328 | XSetForeground (display->display, gc, pix_colors[fore]); |
2363 | XSetForeground (xdisp, gc, pix_colors[fore]); |
2329 | |
2364 | |
2330 | XDrawLine (display->display, drawBuffer, gc, |
2365 | XDrawLine (xdisp, drawBuffer, gc, |
2331 | xpixel, ypixel + font->ascent + 1, |
2366 | xpixel, ypixel + font->ascent + 1, |
2332 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2367 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2333 | } |
2368 | } |
2334 | } /* for (col....) */ |
2369 | } /* for (col....) */ |
2335 | } /* for (row....) */ |
2370 | } /* for (row....) */ |
… | |
… | |
2368 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2403 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2369 | cursorwidth++; |
2404 | cursorwidth++; |
2370 | |
2405 | |
2371 | #ifndef NO_CURSORCOLOR |
2406 | #ifndef NO_CURSORCOLOR |
2372 | if (ISSET_PIXCOLOR (Color_cursor)) |
2407 | if (ISSET_PIXCOLOR (Color_cursor)) |
2373 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2408 | XSetForeground (xdisp, gc, pix_colors[Color_cursor]); |
2374 | #endif |
2409 | #endif |
2375 | |
2410 | |
2376 | XDrawRectangle (display->display, drawBuffer, gc, |
2411 | XDrawRectangle (xdisp, drawBuffer, gc, |
2377 | Col2Pixel (col), |
2412 | Col2Pixel (col), |
2378 | Row2Pixel (oldcursor.row), |
2413 | Row2Pixel (oldcursor.row), |
2379 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2414 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2380 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2415 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2381 | } |
2416 | } |
… | |
… | |
2389 | num_scr = 0; |
2424 | num_scr = 0; |
2390 | num_scr_allow = 1; |
2425 | num_scr_allow = 1; |
2391 | } |
2426 | } |
2392 | |
2427 | |
2393 | void |
2428 | void |
2394 | rxvt_term::scr_remap_chars (line_t &l) |
2429 | rxvt_term::scr_remap_chars (line_t &l) NOTHROW |
2395 | { |
2430 | { |
2396 | if (!l.t) |
2431 | if (!l.t) |
2397 | return; |
2432 | return; |
2398 | |
2433 | |
2399 | l.touch (); // maybe a bit of an overkill, but it's not performance-relevant |
2434 | l.touch (); // maybe a bit of an overkill, but it's not performance-relevant |
… | |
… | |
2401 | for (int i = ncol; i--; ) |
2436 | for (int i = ncol; i--; ) |
2402 | l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); |
2437 | l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); |
2403 | } |
2438 | } |
2404 | |
2439 | |
2405 | void |
2440 | void |
2406 | rxvt_term::scr_remap_chars () |
2441 | rxvt_term::scr_remap_chars () NOTHROW |
2407 | { |
2442 | { |
2408 | for (int i = total_rows; i--; ) |
2443 | for (int i = total_rows; i--; ) |
2409 | scr_remap_chars (row_buf [i]); |
2444 | scr_remap_chars (row_buf [i]); |
2410 | |
2445 | |
2411 | for (int i = nrow; i--; ) |
2446 | for (int i = nrow; i--; ) |
… | |
… | |
2414 | scr_remap_chars (swap_buf [i]); |
2449 | scr_remap_chars (swap_buf [i]); |
2415 | } |
2450 | } |
2416 | } |
2451 | } |
2417 | |
2452 | |
2418 | void |
2453 | void |
2419 | rxvt_term::scr_recolour () |
2454 | rxvt_term::scr_recolour () NOTHROW |
2420 | { |
2455 | { |
2421 | if (1 |
2456 | if (1 |
2422 | #if TRANSPARENT |
2457 | #if TRANSPARENT |
2423 | && !am_transparent |
2458 | && !am_transparent |
2424 | #endif |
2459 | #endif |
2425 | #if XPM_BACKGROUND |
2460 | #if XPM_BACKGROUND |
2426 | && !bgPixmap.pixmap |
2461 | && !bgPixmap.pixmap |
2427 | #endif |
2462 | #endif |
2428 | ) |
2463 | ) |
2429 | { |
2464 | { |
2430 | XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); |
2465 | XSetWindowBackground (xdisp, parent[0], pix_colors[Color_border]); |
2431 | XClearWindow (display->display, parent[0]); |
2466 | XClearWindow (xdisp, parent[0]); |
2432 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
2467 | XSetWindowBackground (xdisp, vt, pix_colors[Color_bg]); |
2433 | #if HAVE_SCROLLBARS |
2468 | #if HAVE_SCROLLBARS |
2434 | if (scrollBar.win) |
2469 | if (scrollBar.win) |
2435 | { |
2470 | { |
2436 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
2471 | XSetWindowBackground (xdisp, scrollBar.win, pix_colors[Color_border]); |
2437 | scrollBar.setIdle (); |
2472 | scrollBar.setIdle (); |
2438 | scrollbar_show (0); |
2473 | scrollbar_show (0); |
2439 | } |
2474 | } |
2440 | #endif |
2475 | #endif |
2441 | } |
2476 | } |
… | |
… | |
2445 | want_refresh = 1; |
2480 | want_refresh = 1; |
2446 | } |
2481 | } |
2447 | |
2482 | |
2448 | /* ------------------------------------------------------------------------- */ |
2483 | /* ------------------------------------------------------------------------- */ |
2449 | void |
2484 | void |
2450 | rxvt_term::scr_clear (bool really) |
2485 | rxvt_term::scr_clear (bool really) NOTHROW |
2451 | { |
2486 | { |
2452 | if (!mapped) |
2487 | if (!mapped) |
2453 | return; |
2488 | return; |
2454 | |
2489 | |
2455 | num_scr_allow = 0; |
2490 | num_scr_allow = 0; |
2456 | want_refresh = 1; |
2491 | want_refresh = 1; |
2457 | |
2492 | |
2458 | if (really) |
2493 | if (really) |
2459 | XClearWindow (display->display, vt); |
2494 | XClearWindow (xdisp, vt); |
2460 | } |
2495 | } |
2461 | |
2496 | |
2462 | void |
2497 | void |
2463 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) |
2498 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW |
2464 | { |
2499 | { |
2465 | int view_end = view_start + nrow; |
2500 | int view_end = view_start + nrow; |
2466 | int row, col; |
2501 | int row, col; |
2467 | |
2502 | |
2468 | for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) |
2503 | for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) |
… | |
… | |
2480 | srp[col] ^= rstyle2; |
2515 | srp[col] ^= rstyle2; |
2481 | } |
2516 | } |
2482 | } |
2517 | } |
2483 | |
2518 | |
2484 | void |
2519 | void |
2485 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) |
2520 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW |
2486 | { |
2521 | { |
2487 | int view_end = view_start + nrow; |
2522 | int view_end = view_start + nrow; |
2488 | int row, col; |
2523 | int row, col; |
2489 | |
2524 | |
2490 | if (beg_row >= view_start) |
2525 | if (beg_row >= view_start) |
… | |
… | |
2507 | srp[col] ^= rstyle; |
2542 | srp[col] ^= rstyle; |
2508 | } |
2543 | } |
2509 | |
2544 | |
2510 | /* ------------------------------------------------------------------------- */ |
2545 | /* ------------------------------------------------------------------------- */ |
2511 | void |
2546 | void |
2512 | rxvt_term::scr_reverse_selection () |
2547 | rxvt_term::scr_reverse_selection () NOTHROW |
2513 | { |
2548 | { |
2514 | if (selection.op |
2549 | if (selection.op |
2515 | && current_screen == selection.screen |
2550 | && current_screen == selection.screen |
2516 | && selection.end.row >= view_start) |
2551 | && selection.end.row >= view_start) |
2517 | { |
2552 | { |
… | |
… | |
2533 | * Dump the whole scrollback and screen to the passed filedescriptor. The |
2568 | * Dump the whole scrollback and screen to the passed filedescriptor. The |
2534 | * invoking routine must close the fd. |
2569 | * invoking routine must close the fd. |
2535 | */ |
2570 | */ |
2536 | #if 0 |
2571 | #if 0 |
2537 | void |
2572 | void |
2538 | rxvt_term::scr_dump (int fd) |
2573 | rxvt_term::scr_dump (int fd) NOTHROW |
2539 | { |
2574 | { |
2540 | int row, wrote; |
2575 | int row, wrote; |
2541 | unsigned int width, towrite; |
2576 | unsigned int width, towrite; |
2542 | char r1[] = "\n"; |
2577 | char r1[] = "\n"; |
2543 | |
2578 | |
… | |
… | |
2562 | |
2597 | |
2563 | /* ------------------------------------------------------------------------- * |
2598 | /* ------------------------------------------------------------------------- * |
2564 | * CHARACTER SELECTION * |
2599 | * CHARACTER SELECTION * |
2565 | * ------------------------------------------------------------------------- */ |
2600 | * ------------------------------------------------------------------------- */ |
2566 | void |
2601 | void |
2567 | rxvt_term::selection_check (int check_more) |
2602 | rxvt_term::selection_check (int check_more) NOTHROW |
2568 | { |
2603 | { |
2569 | row_col_t pos; |
2604 | row_col_t pos; |
2570 | |
2605 | |
2571 | if (!selection.op) |
2606 | if (!selection.op) |
2572 | return; |
2607 | return; |
… | |
… | |
2593 | /* ------------------------------------------------------------------------- */ |
2628 | /* ------------------------------------------------------------------------- */ |
2594 | /* |
2629 | /* |
2595 | * Paste a selection direct to the command fd |
2630 | * Paste a selection direct to the command fd |
2596 | */ |
2631 | */ |
2597 | void |
2632 | void |
2598 | rxvt_term::paste (char *data, unsigned int len) |
2633 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2599 | { |
2634 | { |
2600 | /* convert normal newline chars into common keyboard Return key sequence */ |
2635 | /* convert normal newline chars into common keyboard Return key sequence */ |
2601 | for (unsigned int i = 0; i < len; i++) |
2636 | for (unsigned int i = 0; i < len; i++) |
2602 | if (data[i] == C0_LF) |
2637 | if (data[i] == C0_LF) |
2603 | data[i] = C0_CR; |
2638 | data[i] = C0_CR; |
… | |
… | |
2609 | /* |
2644 | /* |
2610 | * Respond to a notification that a primary selection has been sent |
2645 | * Respond to a notification that a primary selection has been sent |
2611 | * EXT: SelectionNotify |
2646 | * EXT: SelectionNotify |
2612 | */ |
2647 | */ |
2613 | void |
2648 | void |
2614 | rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) |
2649 | rxvt_term::selection_paste (Window win, Atom prop, bool delete_prop) NOTHROW |
2615 | { |
2650 | { |
2616 | if (prop == None) /* check for failed XConvertSelection */ |
2651 | if (prop == None) /* check for failed XConvertSelection */ |
2617 | { |
2652 | { |
2618 | if ((selection_type & Sel_CompoundText)) |
2653 | if ((selection_type & Sel_CompoundText)) |
2619 | { |
2654 | { |
… | |
… | |
2639 | } |
2674 | } |
2640 | |
2675 | |
2641 | unsigned long bytes_after; |
2676 | unsigned long bytes_after; |
2642 | XTextProperty ct; |
2677 | XTextProperty ct; |
2643 | |
2678 | |
2644 | if (XGetWindowProperty (display->display, win, prop, |
2679 | if (XGetWindowProperty (xdisp, win, prop, |
2645 | 0, PROP_SIZE / 4, |
2680 | 0, PROP_SIZE / 4, |
2646 | delete_prop, AnyPropertyType, |
2681 | delete_prop, AnyPropertyType, |
2647 | &ct.encoding, &ct.format, |
2682 | &ct.encoding, &ct.format, |
2648 | &ct.nitems, &bytes_after, |
2683 | &ct.nitems, &bytes_after, |
2649 | &ct.value) != Success) |
2684 | &ct.value) != Success) |
… | |
… | |
2658 | if (bytes_after) |
2693 | if (bytes_after) |
2659 | { |
2694 | { |
2660 | // fetch and append remaining data |
2695 | // fetch and append remaining data |
2661 | XTextProperty ct2; |
2696 | XTextProperty ct2; |
2662 | |
2697 | |
2663 | if (XGetWindowProperty (display->display, win, prop, |
2698 | if (XGetWindowProperty (xdisp, win, prop, |
2664 | ct.nitems / 4, (bytes_after + 3) / 4, |
2699 | ct.nitems / 4, (bytes_after + 3) / 4, |
2665 | delete_prop, AnyPropertyType, |
2700 | delete_prop, AnyPropertyType, |
2666 | &ct2.encoding, &ct2.format, |
2701 | &ct2.encoding, &ct2.format, |
2667 | &ct2.nitems, &bytes_after, |
2702 | &ct2.nitems, &bytes_after, |
2668 | &ct2.value) != Success) |
2703 | &ct2.value) != Success) |
… | |
… | |
2681 | |
2716 | |
2682 | if (ct.encoding == xa[XA_INCR]) |
2717 | if (ct.encoding == xa[XA_INCR]) |
2683 | { |
2718 | { |
2684 | // INCR selection, start handshake |
2719 | // INCR selection, start handshake |
2685 | if (!delete_prop) |
2720 | if (!delete_prop) |
2686 | XDeleteProperty (display->display, win, prop); |
2721 | XDeleteProperty (xdisp, win, prop); |
2687 | |
2722 | |
2688 | selection_wait = Sel_incr; |
2723 | selection_wait = Sel_incr; |
2689 | incr_buf_fill = 0; |
2724 | incr_buf_fill = 0; |
2690 | incr_ev.start (NOW + 10); |
2725 | incr_ev.start (NOW + 10); |
2691 | |
2726 | |
… | |
… | |
2752 | paste (s, strlen (s)); |
2787 | paste (s, strlen (s)); |
2753 | free (s); |
2788 | free (s); |
2754 | } |
2789 | } |
2755 | else |
2790 | else |
2756 | #endif |
2791 | #endif |
2757 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2792 | if (XmbTextPropertyToTextList (xdisp, &ct, &cl, &cr) >= 0 |
2758 | && cl) |
2793 | && cl) |
2759 | { |
2794 | { |
2760 | for (int i = 0; i < cr; i++) |
2795 | for (int i = 0; i < cr; i++) |
2761 | paste (cl[i], strlen (cl[i])); |
2796 | paste (cl[i], strlen (cl[i])); |
2762 | |
2797 | |
… | |
… | |
2771 | if (selection_wait == Sel_normal) |
2806 | if (selection_wait == Sel_normal) |
2772 | selection_wait = Sel_none; |
2807 | selection_wait = Sel_none; |
2773 | } |
2808 | } |
2774 | |
2809 | |
2775 | void |
2810 | void |
2776 | rxvt_term::incr_cb (time_watcher &w) |
2811 | rxvt_term::incr_cb (time_watcher &w) NOTHROW |
2777 | { |
2812 | { |
2778 | selection_wait = Sel_none; |
2813 | selection_wait = Sel_none; |
2779 | |
2814 | |
2780 | incr_buf_size = 0; |
2815 | incr_buf_size = 0; |
2781 | free (incr_buf); |
2816 | free (incr_buf); |
2782 | |
2817 | |
2783 | rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); |
2818 | rxvt_warn ("data loss: timeout on INCR selection paste, ignoring.\n"); |
2784 | } |
2819 | } |
2785 | |
2820 | |
2786 | void |
2821 | void |
2787 | rxvt_term::selection_property (Window win, Atom prop) |
2822 | rxvt_term::selection_property (Window win, Atom prop) NOTHROW |
2788 | { |
2823 | { |
2789 | if (prop == None || selection_wait != Sel_incr) |
2824 | if (prop == None || selection_wait != Sel_incr) |
2790 | return; |
2825 | return; |
2791 | |
2826 | |
2792 | selection_paste (win, prop, true); |
2827 | selection_paste (win, prop, true); |
… | |
… | |
2801 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2836 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2802 | * will auto fallback to CUT_BUFFER0 |
2837 | * will auto fallback to CUT_BUFFER0 |
2803 | * EXT: button 2 release |
2838 | * EXT: button 2 release |
2804 | */ |
2839 | */ |
2805 | void |
2840 | void |
2806 | rxvt_term::selection_request (Time tm) |
2841 | rxvt_term::selection_request (Time tm, int selnum) NOTHROW |
2807 | { |
2842 | { |
2808 | if (selection.text) |
2843 | if (selection.text && selnum == Sel_Primary) |
2809 | { /* internal selection */ |
2844 | { /* internal selection */ |
2810 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2845 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2811 | paste (str, strlen (str)); |
2846 | paste (str, strlen (str)); |
2812 | free (str); |
2847 | free (str); |
2813 | return; |
2848 | return; |
2814 | } |
2849 | } |
2815 | else |
2850 | else |
2816 | { |
2851 | { |
2817 | int i; |
|
|
2818 | |
|
|
2819 | selection_request_time = tm; |
2852 | selection_request_time = tm; |
2820 | selection_wait = Sel_normal; |
2853 | selection_wait = Sel_normal; |
2821 | |
2854 | |
2822 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) |
|
|
2823 | { |
|
|
2824 | #if X_HAVE_UTF8_STRING |
2855 | #if X_HAVE_UTF8_STRING |
2825 | selection_type = Sel_UTF8String; |
2856 | selection_type = Sel_UTF8String; |
2826 | if (selection_request_other (xa[XA_UTF8_STRING], i)) |
2857 | if (selection_request_other (xa[XA_UTF8_STRING], selnum)) |
2827 | return; |
2858 | return; |
2828 | #else |
2859 | #else |
2829 | selection_type = Sel_CompoundText; |
2860 | selection_type = Sel_CompoundText; |
2830 | if (selection_request_other (xa[XA_COMPOUND_TEXT], i)) |
2861 | if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) |
2831 | return; |
2862 | return; |
2832 | #endif |
2863 | #endif |
2833 | } |
|
|
2834 | } |
2864 | } |
2835 | |
2865 | |
2836 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2866 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2837 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
2867 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
2838 | } |
2868 | } |
2839 | |
2869 | |
2840 | int |
2870 | int |
2841 | rxvt_term::selection_request_other (Atom target, int selnum) |
2871 | rxvt_term::selection_request_other (Atom target, int selnum) NOTHROW |
2842 | { |
2872 | { |
2843 | Atom sel; |
2873 | Atom sel; |
2844 | |
2874 | |
2845 | selection_type |= selnum; |
2875 | selection_type |= selnum; |
2846 | |
2876 | |
… | |
… | |
2849 | else if (selnum == Sel_Secondary) |
2879 | else if (selnum == Sel_Secondary) |
2850 | sel = XA_SECONDARY; |
2880 | sel = XA_SECONDARY; |
2851 | else |
2881 | else |
2852 | sel = xa[XA_CLIPBOARD]; |
2882 | sel = xa[XA_CLIPBOARD]; |
2853 | |
2883 | |
2854 | if (XGetSelectionOwner (display->display, sel) != None) |
2884 | if (XGetSelectionOwner (xdisp, sel) != None) |
2855 | { |
2885 | { |
2856 | XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], |
2886 | XConvertSelection (xdisp, sel, target, xa[XA_VT_SELECTION], |
2857 | vt, selection_request_time); |
2887 | vt, selection_request_time); |
2858 | return 1; |
2888 | return 1; |
2859 | } |
2889 | } |
2860 | |
2890 | |
2861 | return 0; |
2891 | return 0; |
… | |
… | |
2865 | /* |
2895 | /* |
2866 | * Clear all selected text |
2896 | * Clear all selected text |
2867 | * EXT: SelectionClear |
2897 | * EXT: SelectionClear |
2868 | */ |
2898 | */ |
2869 | void |
2899 | void |
2870 | rxvt_term::selection_clear () |
2900 | rxvt_term::selection_clear () NOTHROW |
2871 | { |
2901 | { |
2872 | want_refresh = 1; |
2902 | want_refresh = 1; |
2873 | free (selection.text); |
2903 | free (selection.text); |
2874 | selection.text = NULL; |
2904 | selection.text = NULL; |
2875 | selection.len = 0; |
2905 | selection.len = 0; |
… | |
… | |
3010 | |
3040 | |
3011 | selection_grab (tm); |
3041 | selection_grab (tm); |
3012 | } |
3042 | } |
3013 | |
3043 | |
3014 | bool |
3044 | bool |
3015 | rxvt_term::selection_grab (Time tm) |
3045 | rxvt_term::selection_grab (Time tm) NOTHROW |
3016 | { |
3046 | { |
3017 | selection_time = tm; |
3047 | selection_time = tm; |
3018 | |
3048 | |
3019 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
3049 | XSetSelectionOwner (xdisp, XA_PRIMARY, vt, tm); |
3020 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
3050 | if (XGetSelectionOwner (xdisp, XA_PRIMARY) == vt) |
3021 | { |
3051 | { |
3022 | display->set_selection_owner (this); |
3052 | display->set_selection_owner (this); |
3023 | return true; |
3053 | return true; |
3024 | } |
3054 | } |
3025 | else |
3055 | else |
… | |
… | |
3029 | } |
3059 | } |
3030 | |
3060 | |
3031 | #if 0 |
3061 | #if 0 |
3032 | XTextProperty ct; |
3062 | XTextProperty ct; |
3033 | |
3063 | |
3034 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3064 | if (XwcTextListToTextProperty (xdisp, &selection.text, 1, XStringStyle, &ct) >= 0) |
3035 | { |
3065 | { |
3036 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3066 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3037 | XFree (ct.value); |
3067 | XFree (ct.value); |
3038 | } |
3068 | } |
3039 | #endif |
3069 | #endif |
… | |
… | |
3043 | /* |
3073 | /* |
3044 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3074 | * Mark or select text based upon number of clicks: 1, 2, or 3 |
3045 | * EXT: button 1 press |
3075 | * EXT: button 1 press |
3046 | */ |
3076 | */ |
3047 | void |
3077 | void |
3048 | rxvt_term::selection_click (int clicks, int x, int y) |
3078 | rxvt_term::selection_click (int clicks, int x, int y) NOTHROW |
3049 | { |
3079 | { |
3050 | clicks = ((clicks - 1) % 3) + 1; |
3080 | clicks = ((clicks - 1) % 3) + 1; |
3051 | selection.clicks = clicks; /* save clicks so extend will work */ |
3081 | selection.clicks = clicks; /* save clicks so extend will work */ |
3052 | |
3082 | |
3053 | if (clicks == 2 && !selection.rect |
3083 | if (clicks == 2 && !selection.rect |
… | |
… | |
3072 | /* ------------------------------------------------------------------------- */ |
3102 | /* ------------------------------------------------------------------------- */ |
3073 | /* |
3103 | /* |
3074 | * Mark a selection at the specified col/row |
3104 | * Mark a selection at the specified col/row |
3075 | */ |
3105 | */ |
3076 | void |
3106 | void |
3077 | rxvt_term::selection_start_colrow (int col, int row) |
3107 | rxvt_term::selection_start_colrow (int col, int row) NOTHROW |
3078 | { |
3108 | { |
3079 | want_refresh = 1; |
3109 | want_refresh = 1; |
3080 | |
3110 | |
3081 | selection.mark.row = row + view_start; |
3111 | selection.mark.row = row + view_start; |
3082 | selection.mark.col = col; |
3112 | selection.mark.col = col; |
… | |
… | |
3108 | #define DELIMIT_TEXT(x) \ |
3138 | #define DELIMIT_TEXT(x) \ |
3109 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) |
3139 | (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) |
3110 | #define DELIMIT_REND(x) 1 |
3140 | #define DELIMIT_REND(x) 1 |
3111 | |
3141 | |
3112 | void |
3142 | void |
3113 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) |
3143 | rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW |
3114 | { |
3144 | { |
3115 | int col, row, dirnadd, tcol, trow, w1, w2; |
3145 | int col, row, dirnadd, tcol, trow, w1, w2; |
3116 | row_col_t bound; |
3146 | row_col_t bound; |
3117 | text_t *stp; |
3147 | text_t *stp; |
3118 | rend_t *srp; |
3148 | rend_t *srp; |
… | |
… | |
3192 | * flag == 0 ==> button 1 |
3222 | * flag == 0 ==> button 1 |
3193 | * flag == 1 ==> button 3 press |
3223 | * flag == 1 ==> button 3 press |
3194 | * flag == 2 ==> button 3 motion |
3224 | * flag == 2 ==> button 3 motion |
3195 | */ |
3225 | */ |
3196 | void |
3226 | void |
3197 | rxvt_term::selection_extend (int x, int y, int flag) |
3227 | rxvt_term::selection_extend (int x, int y, int flag) NOTHROW |
3198 | { |
3228 | { |
3199 | int col = clamp (Pixel2Col (x), 0, ncol); |
3229 | int col = clamp (Pixel2Col (x), 0, ncol); |
3200 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3230 | int row = clamp (Pixel2Row (y), 0, nrow - 1); |
3201 | |
3231 | |
3202 | /* |
3232 | /* |
… | |
… | |
3228 | /* ------------------------------------------------------------------------- */ |
3258 | /* ------------------------------------------------------------------------- */ |
3229 | /* |
3259 | /* |
3230 | * Extend the selection to the specified col/row |
3260 | * Extend the selection to the specified col/row |
3231 | */ |
3261 | */ |
3232 | void |
3262 | void |
3233 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) |
3263 | rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW |
3234 | { |
3264 | { |
3235 | row_col_t pos; |
3265 | row_col_t pos; |
3236 | enum { |
3266 | enum { |
3237 | LEFT, RIGHT |
3267 | LEFT, RIGHT |
3238 | } closeto = RIGHT; |
3268 | } closeto = RIGHT; |
… | |
… | |
3424 | #endif |
3454 | #endif |
3425 | } |
3455 | } |
3426 | |
3456 | |
3427 | #if ENABLE_FRILLS |
3457 | #if ENABLE_FRILLS |
3428 | void |
3458 | void |
3429 | rxvt_term::selection_remove_trailing_spaces () |
3459 | rxvt_term::selection_remove_trailing_spaces () NOTHROW |
3430 | { |
3460 | { |
3431 | int32_t end_col, end_row; |
3461 | int32_t end_col, end_row; |
3432 | text_t *stp; |
3462 | text_t *stp; |
3433 | |
3463 | |
3434 | end_col = selection.end.col; |
3464 | end_col = selection.end.col; |
… | |
… | |
3472 | /* |
3502 | /* |
3473 | * Double click on button 3 when already selected |
3503 | * Double click on button 3 when already selected |
3474 | * EXT: button 3 double click |
3504 | * EXT: button 3 double click |
3475 | */ |
3505 | */ |
3476 | void |
3506 | void |
3477 | rxvt_term::selection_rotate (int x, int y) |
3507 | rxvt_term::selection_rotate (int x, int y) NOTHROW |
3478 | { |
3508 | { |
3479 | selection.clicks = selection.clicks % 3 + 1; |
3509 | selection.clicks = selection.clicks % 3 + 1; |
3480 | selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); |
3510 | selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); |
3481 | } |
3511 | } |
3482 | |
3512 | |
… | |
… | |
3484 | /* |
3514 | /* |
3485 | * Respond to a request for our current selection |
3515 | * Respond to a request for our current selection |
3486 | * EXT: SelectionRequest |
3516 | * EXT: SelectionRequest |
3487 | */ |
3517 | */ |
3488 | void |
3518 | void |
3489 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) |
3519 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW |
3490 | { |
3520 | { |
3491 | XSelectionEvent ev; |
3521 | XSelectionEvent ev; |
3492 | dDisp; |
|
|
3493 | |
3522 | |
3494 | ev.type = SelectionNotify; |
3523 | ev.type = SelectionNotify; |
3495 | ev.property = None; |
3524 | ev.property = None; |
3496 | ev.display = rq.display; |
3525 | ev.display = rq.display; |
3497 | ev.requestor = rq.requestor; |
3526 | ev.requestor = rq.requestor; |
… | |
… | |
3511 | *target++ = xa[XA_COMPOUND_TEXT]; |
3540 | *target++ = xa[XA_COMPOUND_TEXT]; |
3512 | #if X_HAVE_UTF8_STRING |
3541 | #if X_HAVE_UTF8_STRING |
3513 | *target++ = xa[XA_UTF8_STRING]; |
3542 | *target++ = xa[XA_UTF8_STRING]; |
3514 | #endif |
3543 | #endif |
3515 | |
3544 | |
3516 | XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, |
3545 | XChangeProperty (xdisp, rq.requestor, rq.property, XA_ATOM, |
3517 | 32, PropModeReplace, |
3546 | 32, PropModeReplace, |
3518 | (unsigned char *)target_list, target - target_list); |
3547 | (unsigned char *)target_list, target - target_list); |
3519 | ev.property = rq.property; |
3548 | ev.property = rq.property; |
3520 | } |
3549 | } |
3521 | #if TODO // TODO |
3550 | #if TODO // TODO |
… | |
… | |
3524 | /* TODO: Handle MULTIPLE */ |
3553 | /* TODO: Handle MULTIPLE */ |
3525 | } |
3554 | } |
3526 | #endif |
3555 | #endif |
3527 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3556 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3528 | { |
3557 | { |
3529 | XChangeProperty (disp, rq.requestor, rq.property, rq.target, |
3558 | XChangeProperty (xdisp, rq.requestor, rq.property, rq.target, |
3530 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3559 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3531 | ev.property = rq.property; |
3560 | ev.property = rq.property; |
3532 | } |
3561 | } |
3533 | else if (rq.target == XA_STRING |
3562 | else if (rq.target == XA_STRING |
3534 | || rq.target == xa[XA_TEXT] |
3563 | || rq.target == xa[XA_TEXT] |
… | |
… | |
3592 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3621 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3593 | ct.nitems = strlen ((char *)ct.value); |
3622 | ct.nitems = strlen ((char *)ct.value); |
3594 | } |
3623 | } |
3595 | else |
3624 | else |
3596 | #endif |
3625 | #endif |
3597 | if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3626 | if (XwcTextListToTextProperty (xdisp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3598 | freect = 1; |
3627 | freect = 1; |
3599 | else |
3628 | else |
3600 | { |
3629 | { |
3601 | /* if we failed to convert then send it raw */ |
3630 | /* if we failed to convert then send it raw */ |
3602 | ct.value = (unsigned char *)cl; |
3631 | ct.value = (unsigned char *)cl; |
3603 | ct.nitems = selectlen; |
3632 | ct.nitems = selectlen; |
3604 | ct.encoding = target; |
3633 | ct.encoding = target; |
3605 | } |
3634 | } |
3606 | |
3635 | |
3607 | XChangeProperty (disp, rq.requestor, rq.property, |
3636 | XChangeProperty (xdisp, rq.requestor, rq.property, |
3608 | ct.encoding, 8, PropModeReplace, |
3637 | ct.encoding, 8, PropModeReplace, |
3609 | ct.value, (int)ct.nitems); |
3638 | ct.value, (int)ct.nitems); |
3610 | ev.property = rq.property; |
3639 | ev.property = rq.property; |
3611 | |
3640 | |
3612 | if (freect) |
3641 | if (freect) |
3613 | XFree (ct.value); |
3642 | XFree (ct.value); |
3614 | } |
3643 | } |
3615 | |
3644 | |
3616 | XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); |
3645 | XSendEvent (xdisp, rq.requestor, False, 0L, (XEvent *)&ev); |
3617 | } |
3646 | } |
3618 | |
3647 | |
3619 | /* ------------------------------------------------------------------------- * |
3648 | /* ------------------------------------------------------------------------- * |
3620 | * MOUSE ROUTINES * |
3649 | * MOUSE ROUTINES * |
3621 | * ------------------------------------------------------------------------- */ |
3650 | * ------------------------------------------------------------------------- */ |
3622 | |
3651 | |
3623 | /* |
3652 | /* |
3624 | * return col/row values corresponding to x/y pixel values |
3653 | * return col/row values corresponding to x/y pixel values |
3625 | */ |
3654 | */ |
3626 | void |
3655 | void |
3627 | rxvt_term::pixel_position (int *x, int *y) |
3656 | rxvt_term::pixel_position (int *x, int *y) NOTHROW |
3628 | { |
3657 | { |
3629 | *x = Pixel2Col (*x); |
3658 | *x = Pixel2Col (*x); |
3630 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3659 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
3631 | *y = Pixel2Row (*y); |
3660 | *y = Pixel2Row (*y); |
3632 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3661 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
3633 | } |
3662 | } |
3634 | |
3663 | |
3635 | /* ------------------------------------------------------------------------- */ |
3664 | /* ------------------------------------------------------------------------- */ |
3636 | #ifdef USE_XIM |
3665 | #ifdef USE_XIM |
3637 | void |
3666 | void |
3638 | rxvt_term::im_set_position (XPoint &pos) |
3667 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3639 | { |
3668 | { |
3640 | XWindowAttributes xwa; |
3669 | XWindowAttributes xwa; |
3641 | |
3670 | |
3642 | XGetWindowAttributes (display->display, vt, &xwa); |
3671 | XGetWindowAttributes (xdisp, vt, &xwa); |
3643 | |
3672 | |
3644 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3673 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3645 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3674 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3646 | } |
3675 | } |
3647 | #endif |
3676 | #endif |
3648 | |
3677 | |
3649 | #if ENABLE_OVERLAY |
3678 | #if ENABLE_OVERLAY |
3650 | void |
3679 | void |
3651 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
3680 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW |
3652 | { |
3681 | { |
3653 | if (nrow < 1 || ncol < 1) |
3682 | if (nrow < 1 || ncol < 1) |
3654 | return; |
3683 | return; |
3655 | |
3684 | |
3656 | want_refresh = 1; |
3685 | want_refresh = 1; |
… | |
… | |
3701 | *rp = r; |
3730 | *rp = r; |
3702 | } |
3731 | } |
3703 | } |
3732 | } |
3704 | |
3733 | |
3705 | void |
3734 | void |
3706 | rxvt_term::scr_overlay_off () |
3735 | rxvt_term::scr_overlay_off () NOTHROW |
3707 | { |
3736 | { |
3708 | if (!ov_text) |
3737 | if (!ov_text) |
3709 | return; |
3738 | return; |
3710 | |
3739 | |
3711 | want_refresh = 1; |
3740 | want_refresh = 1; |
… | |
… | |
3719 | delete [] ov_text; ov_text = 0; |
3748 | delete [] ov_text; ov_text = 0; |
3720 | delete [] ov_rend; ov_rend = 0; |
3749 | delete [] ov_rend; ov_rend = 0; |
3721 | } |
3750 | } |
3722 | |
3751 | |
3723 | void |
3752 | void |
3724 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
3753 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW |
3725 | { |
3754 | { |
3726 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3755 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3727 | return; |
3756 | return; |
3728 | |
3757 | |
3729 | x++, y++; |
3758 | x++, y++; |
… | |
… | |
3731 | ov_text[y][x] = text; |
3760 | ov_text[y][x] = text; |
3732 | ov_rend[y][x] = rend; |
3761 | ov_rend[y][x] = rend; |
3733 | } |
3762 | } |
3734 | |
3763 | |
3735 | void |
3764 | void |
3736 | rxvt_term::scr_overlay_set (int x, int y, const char *s) |
3765 | rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW |
3737 | { |
3766 | { |
3738 | while (*s) |
3767 | while (*s) |
3739 | scr_overlay_set (x++, y, *s++); |
3768 | scr_overlay_set (x++, y, *s++); |
3740 | } |
3769 | } |
3741 | |
3770 | |
3742 | void |
3771 | void |
3743 | rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) |
3772 | rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW |
3744 | { |
3773 | { |
3745 | while (*s) |
3774 | while (*s) |
3746 | { |
3775 | { |
3747 | text_t t = *s++; |
3776 | text_t t = *s++; |
3748 | int width = wcwidth (t); |
3777 | int width = WCWIDTH (t); |
3749 | |
3778 | |
3750 | while (width--) |
3779 | while (width--) |
3751 | { |
3780 | { |
3752 | scr_overlay_set (x++, y, t); |
3781 | scr_overlay_set (x++, y, t); |
3753 | t = NOCHAR; |
3782 | t = NOCHAR; |
3754 | } |
3783 | } |
3755 | } |
3784 | } |
3756 | } |
3785 | } |
3757 | |
3786 | |
3758 | void |
3787 | void |
3759 | rxvt_term::scr_swap_overlay () |
3788 | rxvt_term::scr_swap_overlay () NOTHROW |
3760 | { |
3789 | { |
3761 | if (!ov_text) |
3790 | if (!ov_text) |
3762 | return; |
3791 | return; |
3763 | |
3792 | |
3764 | // swap screen mem with overlay |
3793 | // swap screen mem with overlay |