… | |
… | |
28 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
29 | #include "rxvtperl.h" /* NECESSARY */ |
29 | #include "rxvtperl.h" /* NECESSARY */ |
30 | |
30 | |
31 | #include <inttypes.h> |
31 | #include <inttypes.h> |
32 | |
32 | |
33 | #include "salloc.C" // HACK, should be a seperate compile! |
33 | #include "salloc.C" // HACK, should be a separate compile! |
34 | |
34 | |
|
|
35 | static inline void |
35 | static inline void fill_text (text_t *start, text_t value, int len) |
36 | fill_text (text_t *start, text_t value, int len) |
36 | { |
37 | { |
37 | while (len--) |
38 | while (len--) |
38 | *start++ = value; |
39 | *start++ = value; |
39 | } |
40 | } |
40 | |
41 | |
… | |
… | |
1338 | min_it (num, nrow - row); |
1339 | min_it (num, nrow - row); |
1339 | |
1340 | |
1340 | // TODO: the code below does not work when view_start != 0 |
1341 | // TODO: the code below does not work when view_start != 0 |
1341 | // the workaround is to disable the clear and use a normal refresh |
1342 | // the workaround is to disable the clear and use a normal refresh |
1342 | // when view_start != 0. mysterious. |
1343 | // when view_start != 0. mysterious. |
1343 | if (rstyle & (RS_RVid | RS_Uline)) |
1344 | if (rstyle & (RS_Blink | RS_RVid | RS_Uline)) |
1344 | ren = (rend_t) ~RS_None; |
1345 | ren = (rend_t) ~RS_None; |
1345 | else if (GET_BASEBG (rstyle) == Color_bg) |
1346 | else if (GET_BASEBG (rstyle) == Color_bg) |
1346 | { |
1347 | { |
1347 | ren = DEFAULT_RSTYLE; |
1348 | ren = DEFAULT_RSTYLE; |
1348 | |
1349 | |
… | |
… | |
1834 | for (i = PART_BEG; i < RC_COUNT; i++) |
1835 | for (i = PART_BEG; i < RC_COUNT; i++) |
1835 | { |
1836 | { |
1836 | min_it (rc[i].col, ncol - 1); |
1837 | min_it (rc[i].col, ncol - 1); |
1837 | min_it (rc[i].row, nrow - 1); |
1838 | min_it (rc[i].row, nrow - 1); |
1838 | } |
1839 | } |
1839 | // TODO: this line somehow causes segfault if scr_expose() is called just after resize |
1840 | |
1840 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1841 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1841 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1842 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1842 | |
1843 | |
1843 | num_scr_allow = 0; |
1844 | num_scr_allow = 0; |
1844 | |
1845 | |
… | |
… | |
2085 | ccol2 = bgcolor_of (rstyle); |
2086 | ccol2 = bgcolor_of (rstyle); |
2086 | #else |
2087 | #else |
2087 | ccol2 = Color_bg; |
2088 | ccol2 = Color_bg; |
2088 | #endif |
2089 | #endif |
2089 | |
2090 | |
2090 | if (showcursor && focus) |
2091 | if (focus) |
2091 | { |
2092 | { |
2092 | if (option (Opt_cursorUnderline)) |
2093 | if (option (Opt_cursorUnderline)) |
2093 | *crp ^= RS_Uline; |
2094 | *crp ^= RS_Uline; |
2094 | else |
2095 | else |
2095 | { |
2096 | { |
… | |
… | |
2231 | |
2232 | |
2232 | // seek to the beginning of wide characters |
2233 | // seek to the beginning of wide characters |
2233 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2234 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2234 | --col; |
2235 | --col; |
2235 | |
2236 | |
2236 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2237 | rend_t rend = srp[col]; /* screen rendition (target rendition) */ |
2237 | text_t *text = stp + col; |
2238 | text_t *text = stp + col; |
2238 | int count = 1; |
2239 | int count = 1; |
2239 | |
2240 | |
2240 | dtp[col] = stp[col]; |
2241 | dtp[col] = stp[col]; |
2241 | drp[col] = rend; |
2242 | drp[col] = rend; |
… | |
… | |
2286 | */ |
2287 | */ |
2287 | int fore = fgcolor_of (rend); // desired foreground |
2288 | int fore = fgcolor_of (rend); // desired foreground |
2288 | int back = bgcolor_of (rend); // desired background |
2289 | int back = bgcolor_of (rend); // desired background |
2289 | |
2290 | |
2290 | // only do special processing if any attributes are set, which is unlikely |
2291 | // only do special processing if any attributes are set, which is unlikely |
2291 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2292 | if (expect_false (rend & (RS_baseattrMask | RS_Careful | RS_Sel))) |
2292 | { |
2293 | { |
2293 | bool invert = rend & RS_RVid; |
2294 | bool invert = rend & RS_RVid; |
2294 | |
2295 | |
2295 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2296 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2296 | if (rend & RS_Bold && fore == Color_fg) |
2297 | if (rend & RS_Bold && fore == Color_fg) |
… | |
… | |
2315 | |
2316 | |
2316 | if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) |
2317 | if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) |
2317 | fore = Color_UL; |
2318 | fore = Color_UL; |
2318 | #endif |
2319 | #endif |
2319 | |
2320 | |
|
|
2321 | #ifdef OPTION_HC |
|
|
2322 | if (rend & RS_Sel) |
|
|
2323 | { |
|
|
2324 | /* invert the column if no highlightColor is set or it is the |
|
|
2325 | * current cursor column */ |
|
|
2326 | if (!(showcursor && row == screen.cur.row && text - stp == screen.cur.col) |
|
|
2327 | && ISSET_PIXCOLOR (Color_HC)) |
|
|
2328 | { |
|
|
2329 | if (ISSET_PIXCOLOR (Color_HTC)) |
|
|
2330 | fore = Color_HTC; |
|
|
2331 | // if invert is 0 reverse video is set so we use bg color as fg color |
|
|
2332 | else if (!invert) |
|
|
2333 | fore = back; |
|
|
2334 | |
|
|
2335 | back = Color_HC; |
|
|
2336 | invert = 0; |
|
|
2337 | } |
|
|
2338 | } |
|
|
2339 | #endif |
|
|
2340 | |
2320 | if (invert) |
2341 | if (invert) |
2321 | { |
2342 | { |
2322 | #ifdef OPTION_HC |
|
|
2323 | if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) |
|
|
2324 | || !ISSET_PIXCOLOR (Color_HC)) |
|
|
2325 | #endif |
|
|
2326 | /* invert the column if no highlightColor is set or it is the |
|
|
2327 | * current cursor column */ |
|
|
2328 | ::swap (fore, back); |
2343 | ::swap (fore, back); |
2329 | #ifdef OPTION_HC |
|
|
2330 | else if (ISSET_PIXCOLOR (Color_HC)) |
|
|
2331 | back = Color_HC; |
|
|
2332 | #endif |
|
|
2333 | |
2344 | |
2334 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2345 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2335 | # ifndef OPTION_HC |
|
|
2336 | if (ISSET_PIXCOLOR (Color_RV)) |
|
|
2337 | back = Color_RV; |
|
|
2338 | # endif |
|
|
2339 | if (fore == back) |
2346 | if (fore == back) |
2340 | { |
2347 | { |
2341 | fore = Color_bg; |
2348 | fore = Color_bg; |
2342 | back = Color_fg; |
2349 | back = Color_fg; |
2343 | } |
2350 | } |
… | |
… | |
2596 | { |
2603 | { |
2597 | #if !ENABLE_MINIMAL |
2604 | #if !ENABLE_MINIMAL |
2598 | if (selection.rect) |
2605 | if (selection.rect) |
2599 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2606 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2600 | selection.end.row, selection.end.col, |
2607 | selection.end.row, selection.end.col, |
2601 | RS_RVid, RS_RVid | RS_Uline); |
2608 | RS_Sel | RS_RVid, RS_Sel | RS_RVid | RS_Uline); |
2602 | else |
2609 | else |
2603 | #endif |
2610 | #endif |
2604 | scr_xor_span (selection.beg.row, selection.beg.col, |
2611 | scr_xor_span (selection.beg.row, selection.beg.col, |
2605 | selection.end.row, selection.end.col, |
2612 | selection.end.row, selection.end.col, |
2606 | RS_RVid); |
2613 | RS_Sel | RS_RVid); |
2607 | } |
2614 | } |
2608 | } |
2615 | } |
2609 | |
2616 | |
2610 | /* ------------------------------------------------------------------------- */ |
2617 | /* ------------------------------------------------------------------------- */ |
2611 | /* |
2618 | /* |
… | |
… | |
2672 | /* ------------------------------------------------------------------------- */ |
2679 | /* ------------------------------------------------------------------------- */ |
2673 | /* |
2680 | /* |
2674 | * Paste a selection direct to the command fd |
2681 | * Paste a selection direct to the command fd |
2675 | */ |
2682 | */ |
2676 | void |
2683 | void |
2677 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
2684 | rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW |
2678 | { |
2685 | { |
2679 | /* convert normal newline chars into common keyboard Return key sequence */ |
2686 | /* convert normal newline chars into common keyboard Return key sequence */ |
2680 | for (unsigned int i = 0; i < len; i++) |
2687 | for (unsigned int i = 0; i < len; i++) |
2681 | if (data[i] == C0_LF) |
2688 | if (data[i] == C0_LF) |
2682 | data[i] = C0_CR; |
2689 | data[i] = C0_CR; |
… | |
… | |
2686 | |
2693 | |
2687 | tt_write (data, len); |
2694 | tt_write (data, len); |
2688 | |
2695 | |
2689 | if (priv_modes & PrivMode_BracketPaste) |
2696 | if (priv_modes & PrivMode_BracketPaste) |
2690 | tt_printf ("\e[201~"); |
2697 | tt_printf ("\e[201~"); |
|
|
2698 | } |
|
|
2699 | |
|
|
2700 | void |
|
|
2701 | rxvt_term::paste (char *data, unsigned int len) NOTHROW |
|
|
2702 | { |
|
|
2703 | if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END))) |
|
|
2704 | return; |
|
|
2705 | |
|
|
2706 | tt_paste (data, len); |
2691 | } |
2707 | } |
2692 | |
2708 | |
2693 | /* ------------------------------------------------------------------------- */ |
2709 | /* ------------------------------------------------------------------------- */ |
2694 | /* |
2710 | /* |
2695 | * Respond to a notification that a primary selection has been sent |
2711 | * Respond to a notification that a primary selection has been sent |
… | |
… | |
2904 | selection_wait = Sel_normal; |
2920 | selection_wait = Sel_normal; |
2905 | |
2921 | |
2906 | #if X_HAVE_UTF8_STRING |
2922 | #if X_HAVE_UTF8_STRING |
2907 | selection_type = Sel_UTF8String; |
2923 | selection_type = Sel_UTF8String; |
2908 | if (selection_request_other (xa[XA_UTF8_STRING], selnum)) |
2924 | if (selection_request_other (xa[XA_UTF8_STRING], selnum)) |
2909 | return; |
2925 | return; |
2910 | #else |
2926 | #else |
2911 | selection_type = Sel_CompoundText; |
2927 | selection_type = Sel_CompoundText; |
2912 | if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) |
2928 | if (selection_request_other (xa[XA_COMPOUND_TEXT], selnum)) |
2913 | return; |
2929 | return; |
2914 | #endif |
2930 | #endif |
2915 | } |
2931 | } |
2916 | |
2932 | |
2917 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2933 | selection_wait = Sel_none; /* don't loop in selection_paste () */ |
2918 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
2934 | selection_paste (display->root, XA_CUT_BUFFER0, false); |
… | |
… | |
2967 | selection.clip_text = NULL; |
2983 | selection.clip_text = NULL; |
2968 | selection.clip_len = 0; |
2984 | selection.clip_len = 0; |
2969 | |
2985 | |
2970 | if (display->clipboard_owner == this) |
2986 | if (display->clipboard_owner == this) |
2971 | display->clipboard_owner = 0; |
2987 | display->clipboard_owner = 0; |
2972 | } |
|
|
2973 | } |
|
|
2974 | |
|
|
2975 | void |
|
|
2976 | rxvt_term::clipboard_copy (Time tm) |
|
|
2977 | { |
|
|
2978 | if (selection.len > 0) |
|
|
2979 | { |
|
|
2980 | free (selection.clip_text); |
|
|
2981 | selection.clip_len = selection.len; |
|
|
2982 | selection.clip_text = (wchar_t *) malloc (sizeof (wchar_t) * selection.clip_len); |
|
|
2983 | memcpy (selection.clip_text, selection.text, |
|
|
2984 | sizeof (wchar_t) * selection.clip_len); |
|
|
2985 | selection_grab (tm, true); |
|
|
2986 | } |
2988 | } |
2987 | } |
2989 | } |
2988 | |
2990 | |
2989 | /* ------------------------------------------------------------------------- */ |
2991 | /* ------------------------------------------------------------------------- */ |
2990 | /* |
2992 | /* |