… | |
… | |
150 | l.r[col] = rend; |
150 | l.r[col] = rend; |
151 | col++; |
151 | col++; |
152 | } while (col < ncol && l.t[col] == NOCHAR); |
152 | } while (col < ncol && l.t[col] == NOCHAR); |
153 | } |
153 | } |
154 | |
154 | |
|
|
155 | // set the rendition of a single wide character beginning at the given column |
|
|
156 | void |
|
|
157 | rxvt_term::scr_set_char_rend (line_t &l, int col, rend_t rend) |
|
|
158 | { |
|
|
159 | do { |
|
|
160 | l.r[col] = rend; |
|
|
161 | col++; |
|
|
162 | } while (col < ncol && l.t[col] == NOCHAR); |
|
|
163 | } |
|
|
164 | |
155 | /* ------------------------------------------------------------------------- * |
165 | /* ------------------------------------------------------------------------- * |
156 | * SCREEN INITIALISATION * |
166 | * SCREEN INITIALISATION * |
157 | * ------------------------------------------------------------------------- */ |
167 | * ------------------------------------------------------------------------- */ |
158 | |
168 | |
159 | void |
169 | void |
… | |
… | |
169 | tsize -= tsize % sizeof (rend_t); |
179 | tsize -= tsize % sizeof (rend_t); |
170 | |
180 | |
171 | int all_rows = total_rows + nrow + nrow; |
181 | int all_rows = total_rows + nrow + nrow; |
172 | |
182 | |
173 | chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows; |
183 | chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows; |
174 | chunk = rxvt_malloc (chunk_size); |
184 | chunk = chunk_alloc (chunk_size, 0); |
175 | |
185 | |
176 | char *base = (char *)chunk + sizeof (line_t) * all_rows; |
186 | char *base = (char *)chunk + sizeof (line_t) * all_rows; |
177 | |
187 | |
178 | for (int row = 0; row < all_rows; ++row) |
188 | for (int row = 0; row < all_rows; ++row) |
179 | { |
189 | { |
… | |
… | |
188 | drawn_buf = (line_t *)chunk; |
198 | drawn_buf = (line_t *)chunk; |
189 | swap_buf = drawn_buf + nrow; |
199 | swap_buf = drawn_buf + nrow; |
190 | row_buf = swap_buf + nrow; |
200 | row_buf = swap_buf + nrow; |
191 | } |
201 | } |
192 | |
202 | |
|
|
203 | void |
|
|
204 | rxvt_term::copy_line (line_t &dst, line_t &src) |
|
|
205 | { |
|
|
206 | scr_blank_screen_mem (dst, DEFAULT_RSTYLE); |
|
|
207 | dst.l = min (src.l, ncol); |
|
|
208 | memcpy (dst.t, src.t, sizeof (text_t) * dst.l); |
|
|
209 | memcpy (dst.r, src.r, sizeof (rend_t) * dst.l); |
|
|
210 | dst.f = src.f; |
|
|
211 | } |
|
|
212 | |
193 | void ecb_cold |
213 | void ecb_cold |
194 | rxvt_term::scr_reset () |
214 | rxvt_term::scr_reset () |
195 | { |
215 | { |
196 | #if ENABLE_OVERLAY |
216 | #if ENABLE_OVERLAY |
197 | scr_overlay_off (); |
217 | scr_overlay_off (); |
… | |
… | |
225 | |
245 | |
226 | screen.tscroll = 0; |
246 | screen.tscroll = 0; |
227 | screen.bscroll = nrow - 1; |
247 | screen.bscroll = nrow - 1; |
228 | |
248 | |
229 | void *prev_chunk = chunk; |
249 | void *prev_chunk = chunk; |
|
|
250 | size_t prev_chunk_size = chunk_size; |
230 | line_t *prev_drawn_buf = drawn_buf; |
251 | line_t *prev_drawn_buf = drawn_buf; |
231 | line_t *prev_swap_buf = swap_buf; |
252 | line_t *prev_swap_buf = swap_buf; |
232 | line_t *prev_row_buf = row_buf; |
253 | line_t *prev_row_buf = row_buf; |
233 | |
|
|
234 | int common_col = min (prev_ncol, ncol); |
|
|
235 | |
254 | |
236 | scr_alloc (); |
255 | scr_alloc (); |
237 | |
256 | |
238 | if (!prev_row_buf) |
257 | if (!prev_row_buf) |
239 | { |
258 | { |
… | |
… | |
274 | * add or delete rows as appropriate |
293 | * add or delete rows as appropriate |
275 | */ |
294 | */ |
276 | |
295 | |
277 | for (int row = min (nrow, prev_nrow); row--; ) |
296 | for (int row = min (nrow, prev_nrow); row--; ) |
278 | { |
297 | { |
279 | scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
298 | copy_line (drawn_buf [row], prev_drawn_buf [row]); |
280 | scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
299 | copy_line (swap_buf [row], prev_swap_buf [row]); |
281 | |
|
|
282 | memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); |
|
|
283 | memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); |
|
|
284 | memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col); |
|
|
285 | memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col); |
|
|
286 | } |
300 | } |
287 | |
301 | |
288 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
302 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
289 | int pend = MOD (term_start + top_row , prev_total_rows); |
303 | int pend = MOD (term_start + top_row , prev_total_rows); |
290 | int q = total_rows; // rewrapped row |
304 | int q = total_rows; // rewrapped row |
… | |
… | |
385 | for (int row = min (nrow, prev_nrow); row--; ) |
399 | for (int row = min (nrow, prev_nrow); row--; ) |
386 | { |
400 | { |
387 | line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; |
401 | line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; |
388 | line_t &dst = row_buf [row]; |
402 | line_t &dst = row_buf [row]; |
389 | |
403 | |
390 | scr_blank_screen_mem (dst, DEFAULT_RSTYLE); |
404 | copy_line (dst, src); |
391 | |
|
|
392 | memcpy (dst.t, src.t, sizeof (text_t) * common_col); |
|
|
393 | memcpy (dst.r, src.r, sizeof (rend_t) * common_col); |
|
|
394 | } |
405 | } |
395 | |
406 | |
396 | for (int row = prev_nrow; row < nrow; row++) |
407 | for (int row = prev_nrow; row < nrow; row++) |
397 | scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
408 | scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); |
398 | |
409 | |
… | |
… | |
408 | if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
419 | if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); |
409 | if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
420 | if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); |
410 | if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
421 | if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); |
411 | } |
422 | } |
412 | |
423 | |
413 | free (prev_chunk); |
424 | chunk_free (prev_chunk, prev_chunk_size); |
414 | |
425 | |
415 | free (tabs); |
426 | free (tabs); |
416 | tabs = (char *)rxvt_malloc (ncol); |
427 | tabs = (char *)rxvt_malloc (ncol); |
417 | |
428 | |
418 | for (int col = ncol; col--; ) |
429 | for (int col = ncol; col--; ) |
… | |
… | |
429 | } |
440 | } |
430 | |
441 | |
431 | void ecb_cold |
442 | void ecb_cold |
432 | rxvt_term::scr_release () NOTHROW |
443 | rxvt_term::scr_release () NOTHROW |
433 | { |
444 | { |
434 | free (chunk); chunk = 0; row_buf = 0; |
445 | chunk_free (chunk, chunk_size); |
435 | free (tabs); tabs = 0; |
446 | chunk = 0; |
|
|
447 | row_buf = 0; |
|
|
448 | |
|
|
449 | free (tabs); |
|
|
450 | tabs = 0; |
436 | } |
451 | } |
437 | |
452 | |
438 | /* ------------------------------------------------------------------------- */ |
453 | /* ------------------------------------------------------------------------- */ |
439 | /* |
454 | /* |
440 | * Hard/Soft reset |
455 | * Hard/Soft reset |
… | |
… | |
1701 | if (rvideo_state != on) |
1716 | if (rvideo_state != on) |
1702 | { |
1717 | { |
1703 | rvideo_state = on; |
1718 | rvideo_state = on; |
1704 | |
1719 | |
1705 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1720 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1706 | #ifdef HAVE_BG_PIXMAP |
1721 | #ifdef HAVE_IMG |
1707 | if (bg_pixmap == None) |
1722 | if (bg_img == 0) |
1708 | #endif |
1723 | #endif |
1709 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1724 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1710 | |
1725 | |
1711 | XGCValues gcvalue; |
1726 | XGCValues gcvalue; |
1712 | gcvalue.foreground = pix_colors[Color_fg]; |
1727 | gcvalue.foreground = pix_colors[Color_fg]; |
… | |
… | |
2027 | rxvt_term::scr_refresh () NOTHROW |
2042 | rxvt_term::scr_refresh () NOTHROW |
2028 | { |
2043 | { |
2029 | int16_t col, row, /* column/row we're processing */ |
2044 | int16_t col, row, /* column/row we're processing */ |
2030 | ocrow; /* old cursor row */ |
2045 | ocrow; /* old cursor row */ |
2031 | int i; /* tmp */ |
2046 | int i; /* tmp */ |
2032 | #ifndef NO_CURSORCOLOR |
|
|
2033 | rend_t cc1; /* store colours at cursor position (s) */ |
|
|
2034 | #endif |
|
|
2035 | rend_t *crp; // cursor rendition pointer |
|
|
2036 | rend_t ccol1, /* Cursor colour */ |
2047 | rend_t ccol1, /* Cursor colour */ |
2037 | ccol2; /* Cursor colour2 */ |
2048 | ccol2; /* Cursor colour2 */ |
|
|
2049 | rend_t cur_rend; |
|
|
2050 | int cur_col; |
2038 | |
2051 | |
2039 | want_refresh = 0; /* screen is current */ |
2052 | want_refresh = 0; /* screen is current */ |
2040 | |
2053 | |
2041 | if (refresh_type == NO_REFRESH || !mapped) |
2054 | if (refresh_type == NO_REFRESH || !mapped) |
2042 | return; |
2055 | return; |
… | |
… | |
2046 | */ |
2059 | */ |
2047 | refresh_count = 0; |
2060 | refresh_count = 0; |
2048 | |
2061 | |
2049 | unsigned int old_screen_flags = screen.flags; |
2062 | unsigned int old_screen_flags = screen.flags; |
2050 | bool have_bg = 0; |
2063 | bool have_bg = 0; |
2051 | #ifdef HAVE_BG_PIXMAP |
2064 | #ifdef HAVE_IMG |
2052 | have_bg = bg_pixmap != None; |
2065 | have_bg = bg_img != 0; |
2053 | #endif |
2066 | #endif |
2054 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2067 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2055 | |
2068 | |
2056 | /* |
2069 | /* |
2057 | * B: reverse any characters which are selected |
2070 | * B: reverse any characters which are selected |
… | |
… | |
2081 | int col = screen.cur.col; |
2094 | int col = screen.cur.col; |
2082 | |
2095 | |
2083 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2096 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2084 | col--; |
2097 | col--; |
2085 | |
2098 | |
2086 | crp = &ROW(screen.cur.row).r[col]; |
2099 | cur_rend = ROW(screen.cur.row).r[col]; |
|
|
2100 | cur_col = col; |
2087 | |
2101 | |
2088 | #ifndef NO_CURSORCOLOR |
2102 | #ifndef NO_CURSORCOLOR |
2089 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
|
|
2090 | if (ISSET_PIXCOLOR (Color_cursor)) |
2103 | if (ISSET_PIXCOLOR (Color_cursor)) |
2091 | ccol1 = Color_cursor; |
2104 | ccol1 = Color_cursor; |
2092 | else |
2105 | else |
2093 | #endif |
2106 | #endif |
2094 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
2107 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
… | |
… | |
2108 | ccol2 = Color_bg; |
2121 | ccol2 = Color_bg; |
2109 | #endif |
2122 | #endif |
2110 | |
2123 | |
2111 | if (focus) |
2124 | if (focus) |
2112 | { |
2125 | { |
|
|
2126 | rend_t rend = cur_rend; |
|
|
2127 | |
2113 | if (option (Opt_cursorUnderline)) |
2128 | if (option (Opt_cursorUnderline)) |
2114 | *crp ^= RS_Uline; |
2129 | rend ^= RS_Uline; |
2115 | else |
2130 | else |
2116 | { |
2131 | { |
2117 | *crp ^= RS_RVid; |
2132 | rend ^= RS_RVid; |
2118 | *crp = SET_FGCOLOR (*crp, ccol1); |
2133 | rend = SET_FGCOLOR (rend, ccol1); |
2119 | *crp = SET_BGCOLOR (*crp, ccol2); |
2134 | rend = SET_BGCOLOR (rend, ccol2); |
2120 | } |
2135 | } |
|
|
2136 | |
|
|
2137 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2121 | } |
2138 | } |
2122 | } |
2139 | } |
2123 | |
2140 | |
2124 | /* make sure no outline cursor is left around */ |
2141 | /* make sure no outline cursor is left around */ |
2125 | setoldcursor = 0; |
2142 | setoldcursor = 0; |
… | |
… | |
2444 | * G: cleanup cursor and display outline cursor if necessary |
2461 | * G: cleanup cursor and display outline cursor if necessary |
2445 | */ |
2462 | */ |
2446 | if (showcursor) |
2463 | if (showcursor) |
2447 | { |
2464 | { |
2448 | if (focus) |
2465 | if (focus) |
2449 | { |
2466 | scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); |
2450 | if (option (Opt_cursorUnderline)) |
|
|
2451 | *crp ^= RS_Uline; |
|
|
2452 | else |
|
|
2453 | { |
|
|
2454 | *crp ^= RS_RVid; |
|
|
2455 | #ifndef NO_CURSORCOLOR |
|
|
2456 | *crp = (*crp & ~ (RS_fgMask | RS_bgMask)) | cc1; |
|
|
2457 | #endif |
|
|
2458 | } |
|
|
2459 | } |
|
|
2460 | else if (oldcursor.row >= 0) |
2467 | else if (oldcursor.row >= 0) |
2461 | { |
2468 | { |
2462 | int cursorwidth = 1; |
2469 | int cursorwidth = 1; |
2463 | int col = oldcursor.col; |
2470 | int col = oldcursor.col; |
2464 | |
2471 | |
… | |
… | |
2527 | void ecb_cold |
2534 | void ecb_cold |
2528 | rxvt_term::scr_recolour (bool refresh) NOTHROW |
2535 | rxvt_term::scr_recolour (bool refresh) NOTHROW |
2529 | { |
2536 | { |
2530 | bool transparent = false; |
2537 | bool transparent = false; |
2531 | |
2538 | |
2532 | #ifdef HAVE_BG_PIXMAP |
2539 | #ifdef HAVE_IMG |
2533 | if (bg_pixmap != None) |
2540 | if (bg_img != 0) |
2534 | { |
2541 | { |
2535 | # ifdef ENABLE_TRANSPARENCY |
2542 | # if ENABLE_TRANSPARENCY |
2536 | if (bg_flags & BG_IS_TRANSPARENT) |
2543 | if (bg_flags & BG_IS_TRANSPARENT) |
2537 | { |
2544 | { |
2538 | XSetWindowBackgroundPixmap (dpy, parent, bg_pixmap); |
2545 | XSetWindowBackgroundPixmap (dpy, parent, bg_img->pm); |
2539 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2546 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2540 | |
2547 | |
2541 | transparent = true; |
2548 | transparent = true; |
2542 | } |
2549 | } |
2543 | else |
2550 | else |
2544 | # endif |
2551 | # endif |
2545 | { |
2552 | { |
2546 | XSetWindowBackground (dpy, parent, pix_colors[Color_border]); |
2553 | XSetWindowBackground (dpy, parent, pix_colors[Color_border]); |
2547 | XSetWindowBackgroundPixmap (dpy, vt, bg_pixmap); |
2554 | XSetWindowBackgroundPixmap (dpy, vt, bg_img->pm); |
2548 | } |
2555 | } |
2549 | } |
2556 | } |
2550 | else |
2557 | else |
2551 | #endif |
2558 | #endif |
2552 | { |
2559 | { |
… | |
… | |
2559 | if (scrollBar.win) |
2566 | if (scrollBar.win) |
2560 | { |
2567 | { |
2561 | if (transparent) |
2568 | if (transparent) |
2562 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2569 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2563 | else |
2570 | else |
2564 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2571 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); |
2565 | scrollBar.state = SB_STATE_IDLE; |
2572 | scrollBar.state = SB_STATE_IDLE; |
2566 | scrollBar.show (0); |
2573 | scrollBar.show (0); |
2567 | } |
2574 | } |
2568 | |
2575 | |
2569 | if (refresh) |
2576 | if (refresh) |
… | |
… | |
3526 | |
3533 | |
3527 | XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); |
3534 | XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); |
3528 | } |
3535 | } |
3529 | |
3536 | |
3530 | /* ------------------------------------------------------------------------- */ |
3537 | /* ------------------------------------------------------------------------- */ |
3531 | #ifdef USE_XIM |
3538 | #if USE_XIM |
3532 | void ecb_cold |
3539 | void ecb_cold |
3533 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3540 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3534 | { |
3541 | { |
3535 | XWindowAttributes xwa; |
3542 | XWindowAttributes xwa; |
3536 | |
3543 | |