… | |
… | |
1649 | /* ------------------------------------------------------------------------- * |
1649 | /* ------------------------------------------------------------------------- * |
1650 | * MAJOR SCREEN MANIPULATION * |
1650 | * MAJOR SCREEN MANIPULATION * |
1651 | * ------------------------------------------------------------------------- */ |
1651 | * ------------------------------------------------------------------------- */ |
1652 | |
1652 | |
1653 | /* |
1653 | /* |
|
|
1654 | * refresh matching text. |
|
|
1655 | */ |
|
|
1656 | bool |
|
|
1657 | rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) |
|
|
1658 | { |
|
|
1659 | bool found = false; |
|
|
1660 | |
|
|
1661 | for (int i = 0; i < TermWin.nrow; i++) |
|
|
1662 | { |
|
|
1663 | int col = 0; |
|
|
1664 | rend_t *drp = drawn_rend [i]; |
|
|
1665 | |
|
|
1666 | for (; col < TermWin.ncol; col++, drp++) |
|
|
1667 | if ((*drp & mask) == value) |
|
|
1668 | { |
|
|
1669 | found = true; |
|
|
1670 | *drp = ~value; |
|
|
1671 | } |
|
|
1672 | } |
|
|
1673 | |
|
|
1674 | return found; |
|
|
1675 | } |
|
|
1676 | |
|
|
1677 | /* |
1654 | * Refresh an area |
1678 | * Refresh an area |
1655 | */ |
1679 | */ |
1656 | enum { |
1680 | enum { |
1657 | PART_BEG = 0, |
1681 | PART_BEG = 0, |
1658 | PART_END, |
1682 | PART_END, |
… | |
… | |
2133 | int back = GET_BGCOLOR (rend); // desired background |
2157 | int back = GET_BGCOLOR (rend); // desired background |
2134 | |
2158 | |
2135 | rend = GET_ATTR (rend); |
2159 | rend = GET_ATTR (rend); |
2136 | |
2160 | |
2137 | rvid = !!(rend & RS_RVid); |
2161 | rvid = !!(rend & RS_RVid); |
|
|
2162 | #ifdef TEXT_BLINK |
|
|
2163 | if (rend & RS_Blink) |
|
|
2164 | { |
|
|
2165 | if (!text_blink_ev.active) |
|
|
2166 | { |
|
|
2167 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2168 | hidden_text = 0; |
|
|
2169 | } |
|
|
2170 | else if (hidden_text) |
|
|
2171 | fore = back; |
|
|
2172 | } |
2138 | #ifdef OPTION_HC |
2173 | #elif OPTION_HC |
2139 | if (!rvid && (rend & RS_Blink)) |
2174 | if (!rvid && (rend & RS_Blink)) |
2140 | { |
2175 | { |
2141 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2176 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) |
2142 | back = Color_HC; |
2177 | back = Color_HC; |
2143 | else |
2178 | else |
… | |
… | |
2158 | #endif |
2193 | #endif |
2159 | } |
2194 | } |
2160 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2195 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2161 | else if (rend & RS_Bold) |
2196 | else if (rend & RS_Bold) |
2162 | { |
2197 | { |
|
|
2198 | if (Xdepth > 2) |
2163 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) |
2199 | if (ISSET_PIXCOLOR (this, Color_BD)) |
2164 | fore = Color_BD; |
2200 | fore = Color_BD; |
|
|
2201 | else |
|
|
2202 | fore = Color_White; |
2165 | } |
2203 | } |
2166 | else if (rend & RS_Uline) |
2204 | else if (rend & RS_Uline) |
2167 | { |
2205 | { |
2168 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2206 | if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) |
2169 | fore = Color_UL; |
2207 | fore = Color_UL; |
… | |
… | |
2435 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2473 | rxvt_selection_paste(pR_ Window win, Atom prop, Bool delete_prop) |
2436 | { |
2474 | { |
2437 | long nread = 0; |
2475 | long nread = 0; |
2438 | unsigned long bytes_after; |
2476 | unsigned long bytes_after; |
2439 | XTextProperty ct; |
2477 | XTextProperty ct; |
2440 | int dummy_count; |
|
|
2441 | char **cl; |
|
|
2442 | |
2478 | |
2443 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2479 | D_SELECT((stderr, "rxvt_selection_paste(%08lx, %lu, %d), wait=%2x", win, (unsigned long)prop, (int)delete_prop, R->selection_wait)); |
2444 | |
2480 | |
2445 | if (prop == None) /* check for failed XConvertSelection */ |
2481 | if (prop == None) /* check for failed XConvertSelection */ |
2446 | { |
2482 | { |
… | |
… | |
2449 | int selnum = R->selection_type & Sel_whereMask; |
2485 | int selnum = R->selection_type & Sel_whereMask; |
2450 | |
2486 | |
2451 | R->selection_type = 0; |
2487 | R->selection_type = 0; |
2452 | if (selnum != Sel_direct) |
2488 | if (selnum != Sel_direct) |
2453 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
2489 | rxvt_selection_request_other(aR_ XA_STRING, selnum); |
|
|
2490 | } |
|
|
2491 | |
|
|
2492 | if ((R->selection_type & Sel_UTF8String)) |
|
|
2493 | { |
|
|
2494 | int selnum = R->selection_type & Sel_whereMask; |
|
|
2495 | |
|
|
2496 | R->selection_type = Sel_CompoundText; |
|
|
2497 | if (selnum != Sel_direct) |
|
|
2498 | rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], selnum); |
|
|
2499 | else |
|
|
2500 | R->selection_type = 0; |
2454 | } |
2501 | } |
2455 | |
2502 | |
2456 | return 0; |
2503 | return 0; |
2457 | } |
2504 | } |
2458 | |
2505 | |
… | |
… | |
2493 | nread = -1; /* discount any previous stuff */ |
2540 | nread = -1; /* discount any previous stuff */ |
2494 | break; |
2541 | break; |
2495 | } |
2542 | } |
2496 | |
2543 | |
2497 | nread += ct.nitems; |
2544 | nread += ct.nitems; |
|
|
2545 | |
|
|
2546 | char **cl; |
|
|
2547 | int cr; |
2498 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2548 | if (XmbTextPropertyToTextList (R->Xdisplay, &ct, &cl, |
2499 | &dummy_count) == Success && cl) |
2549 | &cr) >= 0 && cl) |
2500 | { |
2550 | { |
|
|
2551 | for (int i = 0; i < cr; i++) |
2501 | R->paste ((unsigned char *)cl[0], STRLEN (cl[0])); |
2552 | R->paste ((unsigned char *)cl[i], STRLEN (cl[i])); |
|
|
2553 | |
2502 | XFreeStringList (cl); |
2554 | XFreeStringList (cl); |
2503 | } |
2555 | } |
2504 | else |
2556 | else |
2505 | R->paste (ct.value, ct.nitems); |
2557 | R->paste (ct.value, ct.nitems); |
2506 | |
2558 | |
… | |
… | |
2599 | int i; |
2651 | int i; |
2600 | |
2652 | |
2601 | R->selection_request_time = tm; |
2653 | R->selection_request_time = tm; |
2602 | R->selection_wait = Sel_normal; |
2654 | R->selection_wait = Sel_normal; |
2603 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
2655 | for (i = Sel_Primary; i <= Sel_Clipboard; i++) { |
|
|
2656 | #if X_HAVE_UTF8_STRING |
|
|
2657 | R->selection_type = Sel_UTF8String; |
|
|
2658 | if (rxvt_selection_request_other(aR_ R->xa[XA_UTF8_STRING], i)) |
|
|
2659 | return; |
|
|
2660 | #else |
2604 | R->selection_type = Sel_CompoundText; |
2661 | R->selection_type = Sel_CompoundText; |
2605 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2662 | if (rxvt_selection_request_other(aR_ R->xa[XA_COMPOUND_TEXT], i)) |
2606 | return; |
2663 | return; |
|
|
2664 | #endif |
2607 | } |
2665 | } |
2608 | } |
2666 | } |
2609 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2667 | R->selection_wait = Sel_none; /* don't loop in rxvt_selection_paste() */ |
2610 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2668 | D_SELECT((stderr, "rxvt_selection_request: pasting CUT_BUFFER0")); |
2611 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
2669 | rxvt_selection_paste(aR_ Xroot, XA_CUT_BUFFER0, False); |
… | |
… | |
2743 | { |
2801 | { |
2744 | free (new_selection_text); |
2802 | free (new_selection_text); |
2745 | return; |
2803 | return; |
2746 | } |
2804 | } |
2747 | |
2805 | |
2748 | // due to MB_MAX_CUR, selection wastage is usually high |
2806 | // due to MB_MAX_CUR, selection wastage is usually high, so realloc |
2749 | if (str - (char *)new_selection_text > 1024) |
2807 | if (str - (char *)new_selection_text > 1024) |
2750 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2808 | new_selection_text = (unsigned char *)rxvt_realloc (new_selection_text, i + 1); |
2751 | |
2809 | |
2752 | R->selection.len = i; |
2810 | R->selection.len = i; |
|
|
2811 | |
2753 | if (R->selection.text) |
2812 | if (R->selection.text) |
2754 | free (R->selection.text); |
2813 | free (R->selection.text); |
2755 | |
2814 | |
2756 | R->selection.text = new_selection_text; |
2815 | R->selection.text = new_selection_text; |
2757 | |
2816 | |
2758 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2817 | XSetSelectionOwner(R->Xdisplay, XA_PRIMARY, R->TermWin.vt, tm); |
2759 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2818 | if (XGetSelectionOwner(R->Xdisplay, XA_PRIMARY) != R->TermWin.vt) |
2760 | rxvt_print_error("can't get primary selection"); |
2819 | rxvt_print_error("can't get primary selection"); |
|
|
2820 | |
|
|
2821 | |
|
|
2822 | { |
|
|
2823 | XTextProperty ct; |
|
|
2824 | char *cl = (char *)R->selection.text; |
|
|
2825 | |
|
|
2826 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, XStringStyle, &ct) >= 0) |
|
|
2827 | { |
|
|
2828 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
|
|
2829 | PropModeReplace, ct.value, ct.nitems); |
|
|
2830 | XFree (ct.value); |
|
|
2831 | } |
|
|
2832 | else |
2761 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2833 | XChangeProperty(R->Xdisplay, Xroot, XA_CUT_BUFFER0, XA_STRING, 8, |
2762 | PropModeReplace, R->selection.text, (int)R->selection.len); |
2834 | PropModeReplace, R->selection.text, (int)R->selection.len); |
|
|
2835 | } |
|
|
2836 | |
2763 | R->selection_time = tm; |
2837 | R->selection_time = tm; |
2764 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2838 | D_SELECT((stderr, "rxvt_selection_make(): R->selection.len=%d", R->selection.len)); |
2765 | } |
2839 | } |
2766 | |
2840 | |
2767 | /* ------------------------------------------------------------------------- */ |
2841 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
3219 | /* |
3293 | /* |
3220 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3294 | * On some systems, the Atom typedef is 64 bits wide. We need to have a type |
3221 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3295 | * that is exactly 32 bits wide, because a format of 64 is not allowed by |
3222 | * the X11 protocol. |
3296 | * the X11 protocol. |
3223 | */ |
3297 | */ |
3224 | typedef CARD32 Atom32; |
3298 | typedef CARD32 Atom32; |
3225 | |
3299 | |
3226 | /* ------------------------------------------------------------------------- */ |
3300 | /* ------------------------------------------------------------------------- */ |
3227 | /* |
3301 | /* |
3228 | * Respond to a request for our current selection |
3302 | * Respond to a request for our current selection |
3229 | * EXT: SelectionRequest |
3303 | * EXT: SelectionRequest |
… | |
… | |
3231 | /* EXTPROTO */ |
3305 | /* EXTPROTO */ |
3232 | void |
3306 | void |
3233 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3307 | rxvt_selection_send(pR_ const XSelectionRequestEvent *rq) |
3234 | { |
3308 | { |
3235 | XSelectionEvent ev; |
3309 | XSelectionEvent ev; |
3236 | #ifdef USE_XIM |
|
|
3237 | Atom32 target_list[4]; |
|
|
3238 | #else |
|
|
3239 | Atom32 target_list[3]; |
|
|
3240 | #endif |
|
|
3241 | Atom target; |
|
|
3242 | XTextProperty ct; |
3310 | XTextProperty ct; |
3243 | XICCEncodingStyle style; |
3311 | XICCEncodingStyle style; |
3244 | char *cl[2], dummy[1]; |
3312 | Atom target; |
3245 | |
3313 | |
3246 | ev.type = SelectionNotify; |
3314 | ev.type = SelectionNotify; |
3247 | ev.property = None; |
3315 | ev.property = None; |
3248 | ev.display = rq->display; |
3316 | ev.display = rq->display; |
3249 | ev.requestor = rq->requestor; |
3317 | ev.requestor = rq->requestor; |
3250 | ev.selection = rq->selection; |
3318 | ev.selection = rq->selection; |
3251 | ev.target = rq->target; |
3319 | ev.target = rq->target; |
3252 | ev.time = rq->time; |
3320 | ev.time = rq->time; |
3253 | |
3321 | |
3254 | if (rq->target == R->xa[XA_TARGETS]) { |
3322 | if (rq->target == R->xa[XA_TARGETS]) { |
|
|
3323 | Atom32 target_list[5]; |
|
|
3324 | Atom32 *target = target_list; |
|
|
3325 | |
3255 | target_list[0] = (Atom32) R->xa[XA_TARGETS]; |
3326 | *target++ = (Atom32) R->xa[XA_TARGETS]; |
3256 | target_list[1] = (Atom32) XA_STRING; |
3327 | *target++ = (Atom32) XA_STRING; |
3257 | target_list[2] = (Atom32) R->xa[XA_TEXT]; |
3328 | *target++ = (Atom32) R->xa[XA_TEXT]; |
3258 | #ifdef USE_XIM |
|
|
3259 | target_list[3] = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
3329 | *target++ = (Atom32) R->xa[XA_COMPOUND_TEXT]; |
|
|
3330 | #if X_HAVE_UTF8_STRING |
|
|
3331 | *target++ = (Atom32) R->xa[XA_UTF8_STRING]; |
3260 | #endif |
3332 | #endif |
3261 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3333 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_ATOM, |
3262 | (8 * sizeof(target_list[0])), PropModeReplace, |
3334 | (8 * sizeof(target_list[0])), PropModeReplace, |
3263 | (unsigned char *)target_list, |
3335 | (unsigned char *)target_list, |
3264 | (sizeof(target_list) / sizeof(target_list[0]))); |
3336 | target - target_list); |
3265 | ev.property = rq->property; |
3337 | ev.property = rq->property; |
3266 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3338 | } else if (rq->target == R->xa[XA_MULTIPLE]) { |
3267 | /* TODO: Handle MULTIPLE */ |
3339 | /* TODO: Handle MULTIPLE */ |
3268 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3340 | } else if (rq->target == R->xa[XA_TIMESTAMP] && R->selection.text) { |
3269 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3341 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, XA_INTEGER, |
3270 | (8 * sizeof(Time)), PropModeReplace, |
3342 | (8 * sizeof(Time)), PropModeReplace, |
3271 | (unsigned char *)&R->selection_time, 1); |
3343 | (unsigned char *)&R->selection_time, 1); |
3272 | ev.property = rq->property; |
3344 | ev.property = rq->property; |
3273 | } else if (rq->target == XA_STRING |
3345 | } else if (rq->target == XA_STRING |
|
|
3346 | || rq->target == R->xa[XA_TEXT] |
3274 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3347 | || rq->target == R->xa[XA_COMPOUND_TEXT] |
3275 | || rq->target == R->xa[XA_TEXT]) { |
3348 | || rq->target == R->xa[XA_UTF8_STRING] |
3276 | #ifdef USE_XIM |
3349 | ) { |
3277 | short freect = 0; |
3350 | short freect = 0; |
3278 | #endif |
|
|
3279 | int selectlen; |
3351 | int selectlen; |
|
|
3352 | char *cl; |
3280 | |
3353 | |
3281 | #ifdef USE_XIM |
3354 | target = rq->target; |
|
|
3355 | |
3282 | if (rq->target != XA_STRING) { |
3356 | if (target == XA_STRING) |
|
|
3357 | // we actually don't do XA_STRING, but who cares, as i18n clients |
|
|
3358 | // will ask for another format anyways. |
|
|
3359 | style = XStringStyle; |
|
|
3360 | else if (target == R->xa[XA_TEXT]) |
|
|
3361 | style = XTextStyle; |
|
|
3362 | else if (target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3363 | style = XCompoundTextStyle; |
|
|
3364 | #if X_HAVE_UTF8_STRING |
|
|
3365 | else if (target == R->xa[XA_UTF8_STRING]) |
|
|
3366 | style = XUTF8StringStyle; |
|
|
3367 | #endif |
|
|
3368 | else |
|
|
3369 | { |
3283 | target = R->xa[XA_COMPOUND_TEXT]; |
3370 | target = R->xa[XA_COMPOUND_TEXT]; |
3284 | style = (rq->target == R->xa[XA_COMPOUND_TEXT]) |
|
|
3285 | ? XCompoundTextStyle : XStdICCTextStyle; |
|
|
3286 | } else |
|
|
3287 | #endif |
|
|
3288 | { |
|
|
3289 | target = XA_STRING; |
|
|
3290 | style = XStringStyle; |
3371 | style = XCompoundTextStyle; |
3291 | } |
3372 | } |
|
|
3373 | |
3292 | if (R->selection.text) { |
3374 | if (R->selection.text) { |
3293 | cl[0] = (char *)R->selection.text; |
3375 | cl = (char *)R->selection.text; |
3294 | selectlen = R->selection.len; |
3376 | selectlen = R->selection.len; |
3295 | } else { |
3377 | } else { |
3296 | cl[0] = dummy; |
3378 | cl = ""; |
3297 | *dummy = '\0'; |
|
|
3298 | selectlen = 0; |
3379 | selectlen = 0; |
3299 | } |
3380 | } |
3300 | #ifdef USE_XIM |
3381 | |
3301 | if (XmbTextListToTextProperty(R->Xdisplay, cl, 1, style, &ct) |
3382 | if (XmbTextListToTextProperty(R->Xdisplay, &cl, 1, style, &ct) >= 0) |
3302 | == Success) /* if we failed to convert then send it raw */ |
|
|
3303 | freect = 1; |
3383 | freect = 1; |
3304 | else |
3384 | else |
3305 | #endif |
|
|
3306 | { |
3385 | { |
|
|
3386 | /* if we failed to convert then send it raw */ |
3307 | ct.value = (unsigned char *)cl[0]; |
3387 | ct.value = (unsigned char *)cl; |
3308 | ct.nitems = selectlen; |
3388 | ct.nitems = selectlen; |
3309 | } |
3389 | } |
|
|
3390 | |
3310 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3391 | XChangeProperty(R->Xdisplay, rq->requestor, rq->property, |
3311 | target, 8, PropModeReplace, |
3392 | target, 8, PropModeReplace, |
3312 | ct.value, (int)ct.nitems); |
3393 | ct.value, (int)ct.nitems); |
3313 | ev.property = rq->property; |
3394 | ev.property = rq->property; |
3314 | #ifdef USE_XIM |
3395 | |
3315 | if (freect) |
3396 | if (freect) |
3316 | XFree(ct.value); |
3397 | XFree (ct.value); |
3317 | #endif |
|
|
3318 | } |
3398 | } |
3319 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3399 | XSendEvent(R->Xdisplay, rq->requestor, False, 0L, (XEvent *)&ev); |
3320 | } |
3400 | } |
3321 | |
3401 | |
3322 | /* ------------------------------------------------------------------------- * |
3402 | /* ------------------------------------------------------------------------- * |