… | |
… | |
254 | |
254 | |
255 | scr_alloc (); |
255 | scr_alloc (); |
256 | |
256 | |
257 | if (!prev_row_buf) |
257 | if (!prev_row_buf) |
258 | { |
258 | { |
259 | /* |
|
|
260 | * first time called (or after scr_release) so just malloc everything: don't rely on realloc |
|
|
261 | */ |
|
|
262 | top_row = 0; |
259 | top_row = 0; |
263 | term_start = 0; |
260 | term_start = 0; |
264 | |
261 | |
265 | memset (charsets, 'B', sizeof (charsets)); |
262 | memset (charsets, 'B', sizeof (charsets)); |
266 | rstyle = DEFAULT_RSTYLE; |
263 | rstyle = DEFAULT_RSTYLE; |
… | |
… | |
2051 | int i; /* tmp */ |
2048 | int i; /* tmp */ |
2052 | rend_t ccol1, /* Cursor colour */ |
2049 | rend_t ccol1, /* Cursor colour */ |
2053 | ccol2; /* Cursor colour2 */ |
2050 | ccol2; /* Cursor colour2 */ |
2054 | rend_t cur_rend; |
2051 | rend_t cur_rend; |
2055 | int cur_col; |
2052 | int cur_col; |
|
|
2053 | int cursorwidth; |
2056 | |
2054 | |
2057 | want_refresh = 0; /* screen is current */ |
2055 | want_refresh = 0; /* screen is current */ |
2058 | |
2056 | |
2059 | if (refresh_type == NO_REFRESH || !mapped) |
2057 | if (refresh_type == NO_REFRESH || !mapped) |
2060 | return; |
2058 | return; |
… | |
… | |
2085 | |
2083 | |
2086 | /* |
2084 | /* |
2087 | * C: set the cursor character (s) |
2085 | * C: set the cursor character (s) |
2088 | */ |
2086 | */ |
2089 | { |
2087 | { |
2090 | bool setoldcursor; |
|
|
2091 | |
|
|
2092 | #ifdef CURSOR_BLINK |
2088 | #ifdef CURSOR_BLINK |
2093 | if (hidden_cursor) |
2089 | if (hidden_cursor) |
2094 | showcursor = 0; |
2090 | showcursor = 0; |
2095 | #endif |
2091 | #endif |
2096 | |
2092 | |
… | |
… | |
2098 | { |
2094 | { |
2099 | int col = screen.cur.col; |
2095 | int col = screen.cur.col; |
2100 | |
2096 | |
2101 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2097 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2102 | col--; |
2098 | col--; |
|
|
2099 | |
|
|
2100 | cursorwidth = 1; |
|
|
2101 | while (col + cursorwidth < ncol |
|
|
2102 | && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR) |
|
|
2103 | cursorwidth++; |
2103 | |
2104 | |
2104 | cur_rend = ROW(screen.cur.row).r[col]; |
2105 | cur_rend = ROW(screen.cur.row).r[col]; |
2105 | cur_col = col; |
2106 | cur_col = col; |
2106 | |
2107 | |
2107 | #ifndef NO_CURSORCOLOR |
2108 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2142 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2143 | scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); |
2143 | } |
2144 | } |
2144 | } |
2145 | } |
2145 | |
2146 | |
2146 | /* make sure no outline cursor is left around */ |
2147 | /* make sure no outline cursor is left around */ |
2147 | setoldcursor = 0; |
|
|
2148 | if (ocrow != -1) |
2148 | if (ocrow != -1) |
2149 | { |
2149 | { |
2150 | if (screen.cur.row - view_start != ocrow |
2150 | if (screen.cur.row - view_start != ocrow |
2151 | || screen.cur.col != oldcursor.col) |
2151 | || screen.cur.col != oldcursor.col) |
2152 | { |
2152 | { |
2153 | if (ocrow < nrow |
2153 | if (ocrow < nrow |
2154 | && oldcursor.col < ncol) |
2154 | && oldcursor.col < ncol) |
2155 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2155 | drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); |
2156 | |
|
|
2157 | if (focus || !showcursor) |
|
|
2158 | oldcursor.row = -1; |
|
|
2159 | else |
|
|
2160 | setoldcursor = 1; |
|
|
2161 | } |
2156 | } |
2162 | } |
2157 | } |
2163 | else if (!focus) |
|
|
2164 | setoldcursor = 1; |
|
|
2165 | |
2158 | |
2166 | if (setoldcursor) |
2159 | // save the current cursor coordinates if the cursor is visible |
|
|
2160 | // and the window is unfocused, so as to clear the outline cursor |
|
|
2161 | // in the next refresh if the cursor moves |
|
|
2162 | if (showcursor && !focus && screen.cur.row - view_start < nrow) |
2167 | { |
2163 | { |
2168 | if (screen.cur.row - view_start >= nrow) |
|
|
2169 | oldcursor.row = -1; |
|
|
2170 | else |
|
|
2171 | { |
|
|
2172 | oldcursor.row = screen.cur.row - view_start; |
2164 | oldcursor.row = screen.cur.row - view_start; |
2173 | oldcursor.col = screen.cur.col; |
2165 | oldcursor.col = screen.cur.col; |
2174 | } |
|
|
2175 | } |
2166 | } |
|
|
2167 | else |
|
|
2168 | oldcursor.row = -1; |
2176 | } |
2169 | } |
2177 | |
2170 | |
2178 | #ifndef NO_SLOW_LINK_SUPPORT |
2171 | #ifndef NO_SLOW_LINK_SUPPORT |
2179 | /* |
2172 | /* |
2180 | * D: CopyArea pass - very useful for slower links |
2173 | * D: CopyArea pass - very useful for slower links |
… | |
… | |
2446 | else |
2439 | else |
2447 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2440 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2448 | |
2441 | |
2449 | if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) |
2442 | if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) |
2450 | { |
2443 | { |
|
|
2444 | if (showcursor && focus && row == screen.cur.row |
|
|
2445 | && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth)) |
|
|
2446 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
|
|
2447 | else |
2451 | #if ENABLE_FRILLS |
2448 | #if ENABLE_FRILLS |
2452 | if (ISSET_PIXCOLOR (Color_underline)) |
2449 | if (ISSET_PIXCOLOR (Color_underline)) |
2453 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2450 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2454 | else |
2451 | else |
2455 | #endif |
2452 | #endif |
… | |
… | |
2469 | { |
2466 | { |
2470 | if (focus) |
2467 | if (focus) |
2471 | scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); |
2468 | scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); |
2472 | else if (oldcursor.row >= 0) |
2469 | else if (oldcursor.row >= 0) |
2473 | { |
2470 | { |
2474 | int cursorwidth = 1; |
|
|
2475 | int col = oldcursor.col; |
|
|
2476 | |
|
|
2477 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
|
|
2478 | col--; |
|
|
2479 | |
|
|
2480 | while (col + cursorwidth < ncol |
|
|
2481 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
|
|
2482 | cursorwidth++; |
|
|
2483 | |
|
|
2484 | #ifndef NO_CURSORCOLOR |
|
|
2485 | if (ISSET_PIXCOLOR (Color_cursor)) |
|
|
2486 | XSetForeground (dpy, gc, pix_colors[Color_cursor]); |
|
|
2487 | else |
|
|
2488 | #endif |
|
|
2489 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2471 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2490 | |
2472 | |
2491 | XDrawRectangle (dpy, vt, gc, |
2473 | XDrawRectangle (dpy, vt, gc, |
2492 | Col2Pixel (col), |
2474 | Col2Pixel (cur_col), |
2493 | Row2Pixel (oldcursor.row), |
2475 | Row2Pixel (oldcursor.row), |
2494 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2476 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2495 | (unsigned int) (Height2Pixel (1) - 1)); |
2477 | (unsigned int) (Height2Pixel (1) - 1)); |
2496 | } |
2478 | } |
2497 | } |
2479 | } |