1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*--------------------------------*-C-*--------------------------------------* |
2 | * File: screen.c |
2 | * File: screen.c |
3 | *---------------------------------------------------------------------------* |
3 | *---------------------------------------------------------------------------* |
4 | * $Id: screen.C,v 1.11 2003/12/18 13:33:03 pcg Exp $ |
4 | * $Id: screen.C,v 1.16 2004/01/16 22:11:09 pcg Exp $ |
5 | * |
5 | * |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
6 | * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
… | |
… | |
289 | else if (nrow > prev_nrow) |
289 | else if (nrow > prev_nrow) |
290 | { |
290 | { |
291 | /* add rows */ |
291 | /* add rows */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
292 | scr_reset_realloc (); /* realloc _first_ */ |
293 | |
293 | |
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
294 | TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this |
295 | |
295 | |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
296 | k = min (TermWin.nscrolled, nrow - prev_nrow); |
297 | |
297 | |
298 | for (p = prev_total_rows; p < total_rows; p++) |
298 | for (p = prev_total_rows; p < total_rows; p++) |
299 | { |
299 | { |
… | |
… | |
447 | /* then so is screen.rend[i] */ |
447 | /* then so is screen.rend[i] */ |
448 | assert(screen.rend[i]); |
448 | assert(screen.rend[i]); |
449 | } |
449 | } |
450 | #endif |
450 | #endif |
451 | |
451 | |
452 | delete talloc; |
452 | delete talloc; talloc = 0; |
453 | delete ralloc; |
453 | delete ralloc; ralloc = 0; |
454 | |
454 | |
455 | free (screen.text); |
455 | free (screen.text); |
456 | free (screen.tlen); |
456 | free (screen.tlen); |
457 | free (screen.rend); |
457 | free (screen.rend); |
458 | free (drawn_text); |
458 | free (drawn_text); |
… | |
… | |
899 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
899 | case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; |
900 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
900 | case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; |
901 | } |
901 | } |
902 | |
902 | |
903 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
903 | rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); |
|
|
904 | // rely on wcwidth to tell us the character width, at least for non-ascii |
|
|
905 | int width = c <= 128 ? 1 : wcwidth (c); |
904 | |
906 | |
905 | stp[R->screen.cur.col] = c; |
907 | // width 0 characters (e.g. combining chars) are ignored. your problem, really |
906 | srp[R->screen.cur.col] = rend; |
908 | while (width-- > 0) |
907 | |
|
|
908 | if (c > 255) |
|
|
909 | { |
909 | { |
910 | // rely on wcwidth to tell us the character width, at least for non iso-8859-1 |
910 | stp[R->screen.cur.col] = c; |
911 | int width = wcwidth (c); |
911 | srp[R->screen.cur.col] = rend; |
|
|
912 | |
|
|
913 | if (R->screen.cur.col < last_col - 1) |
|
|
914 | R->screen.cur.col++; |
912 | |
915 | else |
913 | if (width > 1) |
|
|
914 | { |
916 | { |
915 | while (--width > 0 && R->screen.cur.col < last_col - 1) |
917 | R->screen.tlen[row] = last_col; |
|
|
918 | if (R->screen.flags & Screen_Autowrap) |
|
|
919 | R->screen.flags |= Screen_WrapNext; |
916 | { |
920 | break; |
917 | |
|
|
918 | srp[R->screen.cur.col] |= RS_wide; |
|
|
919 | |
|
|
920 | R->screen.cur.col++; |
|
|
921 | stp[R->screen.cur.col] = NOCHAR; |
|
|
922 | srp[R->screen.cur.col] = rend; |
|
|
923 | } |
|
|
924 | } |
921 | } |
|
|
922 | |
|
|
923 | c = NOCHAR; |
925 | } |
924 | } |
926 | |
|
|
927 | if (R->screen.cur.col < last_col - 1) |
|
|
928 | R->screen.cur.col++; |
|
|
929 | else { |
|
|
930 | R->screen.tlen[row] = last_col; |
|
|
931 | if (R->screen.flags & Screen_Autowrap) |
|
|
932 | R->screen.flags |= Screen_WrapNext; |
|
|
933 | } |
|
|
934 | } |
925 | } |
935 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
926 | if (R->screen.tlen[row] != -1) /* XXX: think about this */ |
936 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
927 | MAX_IT(R->screen.tlen[row], R->screen.cur.col); |
937 | |
928 | |
938 | /* |
929 | /* |
… | |
… | |
1901 | rend_t cc1; /* store colours at cursor position(s) */ |
1892 | rend_t cc1; /* store colours at cursor position(s) */ |
1902 | rend_t cc2; /* store colours at cursor position(s) */ |
1893 | rend_t cc2; /* store colours at cursor position(s) */ |
1903 | #endif |
1894 | #endif |
1904 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1895 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
1905 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1896 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
1906 | char *buffer; /* local copy of buffer */ |
|
|
1907 | |
1897 | |
1908 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1898 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1909 | return; |
1899 | return; |
1910 | |
1900 | |
1911 | /* |
1901 | /* |
… | |
… | |
1921 | currmaxcol = TermWin.ncol; |
1911 | currmaxcol = TermWin.ncol; |
1922 | buffer = (char *)rxvt_realloc (buffer, |
1912 | buffer = (char *)rxvt_realloc (buffer, |
1923 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1913 | sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); |
1924 | } |
1914 | } |
1925 | |
1915 | |
1926 | buffer = buffer; |
|
|
1927 | refresh_count = 0; |
1916 | refresh_count = 0; |
1928 | |
1917 | |
1929 | row_offset = TermWin.saveLines - TermWin.view_start; |
1918 | row_offset = TermWin.saveLines - TermWin.view_start; |
1930 | |
1919 | |
1931 | if ((refresh_type & REFRESH_BOUNDS)) |
1920 | if ((refresh_type & REFRESH_BOUNDS)) |
… | |
… | |
1940 | #if defined(TRANSPARENT) |
1929 | #if defined(TRANSPARENT) |
1941 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1930 | must_clear |= ((Options & Opt_transparent) && am_transparent); |
1942 | #endif |
1931 | #endif |
1943 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1932 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1944 | |
1933 | |
1945 | /* |
1934 | /* |
1946 | * B: reverse any characters which are selected |
1935 | * B: reverse any characters which are selected |
1947 | */ |
1936 | */ |
1948 | rxvt_scr_reverse_selection (this); |
1937 | rxvt_scr_reverse_selection (this); |
1949 | |
1938 | |
1950 | /* |
1939 | /* |
1951 | * C: set the cursor character(s) |
1940 | * C: set the cursor character(s) |
1952 | */ |
1941 | */ |
1953 | { |
1942 | { |
1954 | unsigned char setoldcursor; |
1943 | unsigned char setoldcursor; |
1955 | rend_t ccol1, /* Cursor colour */ |
1944 | rend_t ccol1, /* Cursor colour */ |
1956 | ccol2; /* Cursor colour2 */ |
1945 | ccol2; /* Cursor colour2 */ |
1957 | |
1946 | |
… | |
… | |
2026 | } |
2015 | } |
2027 | } |
2016 | } |
2028 | } |
2017 | } |
2029 | |
2018 | |
2030 | #ifndef NO_SLOW_LINK_SUPPORT |
2019 | #ifndef NO_SLOW_LINK_SUPPORT |
2031 | /* |
2020 | /* |
2032 | * D: CopyArea pass - very useful for slower links |
2021 | * D: CopyArea pass - very useful for slower links |
2033 | * This has been deliberately kept simple. |
2022 | * This has been deliberately kept simple. |
2034 | */ |
2023 | */ |
2035 | i = num_scr; |
2024 | i = num_scr; |
2036 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
2025 | if (refresh_type == FAST_REFRESH && num_scr_allow && i |
2037 | && abs(i) < TermWin.nrow && !must_clear) |
2026 | && abs(i) < TermWin.nrow && !must_clear) |
2038 | { |
2027 | { |
2039 | int16_t nits; |
2028 | int16_t nits; |
… | |
… | |
2094 | } |
2083 | } |
2095 | } |
2084 | } |
2096 | } |
2085 | } |
2097 | #endif |
2086 | #endif |
2098 | |
2087 | |
2099 | /* |
2088 | /* |
2100 | * E: main pass across every character |
2089 | * E: main pass across every character |
2101 | */ |
2090 | */ |
2102 | for (row = 0; row < TermWin.nrow; row++) |
2091 | for (row = 0; row < TermWin.nrow; row++) |
2103 | { |
2092 | { |
2104 | stp = screen.text[row + row_offset]; |
2093 | stp = screen.text[row + row_offset]; |
2105 | srp = screen.rend[row + row_offset]; |
2094 | srp = screen.rend[row + row_offset]; |
2106 | dtp = drawn_text[row]; |
2095 | dtp = drawn_text[row]; |
2107 | drp = drawn_rend[row]; |
2096 | drp = drawn_rend[row]; |
2108 | |
2097 | |
2109 | /* |
2098 | /* |
2110 | * E2: OK, now the real pass |
2099 | * E2: OK, now the real pass |
2111 | */ |
2100 | */ |
2112 | int ypixel = (int)Row2Pixel(row); |
2101 | int ypixel = (int)Row2Pixel(row); |
2113 | |
2102 | |
2114 | for (col = 0; col < TermWin.ncol; col++) |
2103 | for (col = 0; col < TermWin.ncol; col++) |
2115 | { |
2104 | { |
2116 | /* compare new text with old - if exactly the same then continue */ |
2105 | /* compare new text with old - if exactly the same then continue */ |
… | |
… | |
2171 | } |
2160 | } |
2172 | |
2161 | |
2173 | col--; /* went one too far. move back */ |
2162 | col--; /* went one too far. move back */ |
2174 | count -= i; /* dump any matching trailing chars */ |
2163 | count -= i; /* dump any matching trailing chars */ |
2175 | |
2164 | |
2176 | /* |
2165 | /* |
2177 | * Determine the attributes for the string |
2166 | * Determine the attributes for the string |
2178 | */ |
2167 | */ |
2179 | int fid = GET_FONT(rend); |
2168 | int fid = GET_FONT(rend); |
2180 | fore = GET_FGCOLOR(rend); |
2169 | fore = GET_FGCOLOR(rend); |
2181 | back = GET_BGCOLOR(rend); |
2170 | back = GET_BGCOLOR(rend); |
2182 | rend = GET_ATTR(rend); |
2171 | rend = GET_ATTR(rend); |
2183 | |
2172 | |
… | |
… | |
2223 | rend &= ~RS_Uline; /* we've taken care of it */ |
2212 | rend &= ~RS_Uline; /* we've taken care of it */ |
2224 | } |
2213 | } |
2225 | } |
2214 | } |
2226 | #endif |
2215 | #endif |
2227 | |
2216 | |
2228 | /* |
2217 | /* |
2229 | * Actually do the drawing of the string here |
2218 | * Actually do the drawing of the string here |
2230 | */ |
2219 | */ |
2231 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2220 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2232 | |
2221 | |
2233 | if (back == Color_bg) |
2222 | if (back == Color_bg) |
2234 | { |
2223 | { |
2235 | if (must_clear) |
2224 | if (must_clear) |
… | |
… | |
2255 | xpixel, ypixel + font->ascent + 1, |
2244 | xpixel, ypixel + font->ascent + 1, |
2256 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2245 | xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); |
2257 | } /* for (col....) */ |
2246 | } /* for (col....) */ |
2258 | } /* for (row....) */ |
2247 | } /* for (row....) */ |
2259 | |
2248 | |
2260 | /* |
2249 | /* |
2261 | * G: cleanup cursor and display outline cursor if necessary |
2250 | * G: cleanup cursor and display outline cursor if necessary |
2262 | */ |
2251 | */ |
2263 | if (showcursor) { |
2252 | if (showcursor) { |
2264 | if (TermWin.focus) { |
2253 | if (TermWin.focus) { |
2265 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2254 | srp = &(screen.rend[screen.cur.row + TermWin.saveLines] |
2266 | [screen.cur.col]); |
2255 | [screen.cur.col]); |
2267 | *srp ^= RS_RVid; |
2256 | *srp ^= RS_RVid; |
… | |
… | |
2280 | Row2Pixel(oldcursor.row), |
2269 | Row2Pixel(oldcursor.row), |
2281 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2270 | (unsigned int)(Width2Pixel(cursorwidth) - 1), |
2282 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2271 | (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); |
2283 | } |
2272 | } |
2284 | } |
2273 | } |
2285 | /* |
2274 | |
|
|
2275 | /* |
2286 | * H: cleanup selection |
2276 | * H: cleanup selection |
2287 | */ |
2277 | */ |
2288 | rxvt_scr_reverse_selection (this); |
2278 | rxvt_scr_reverse_selection (this); |
2289 | |
2279 | |
2290 | /* |
2280 | /* |
2291 | * I: other general cleanup |
2281 | * I: other general cleanup |
2292 | */ |
2282 | */ |
2293 | if (clearfirst && TermWin.int_bwidth) |
2283 | if (clearfirst && TermWin.int_bwidth) |
2294 | /* |
2284 | /* |
2295 | * clear the whole screen height, note that width == 0 is treated |
2285 | * clear the whole screen height, note that width == 0 is treated |
2296 | * specially by XClearArea |
2286 | * specially by XClearArea |
2297 | */ |
2287 | */ |
… | |
… | |
2575 | } |
2565 | } |
2576 | |
2566 | |
2577 | void |
2567 | void |
2578 | rxvt_term::incr_cb (time_watcher &w) |
2568 | rxvt_term::incr_cb (time_watcher &w) |
2579 | { |
2569 | { |
2580 | w.stop (); |
|
|
2581 | selection_wait = Sel_none; |
2570 | selection_wait = Sel_none; |
2582 | |
2571 | |
2583 | rxvt_print_error("data loss: timeout on INCR selection paste"); |
2572 | rxvt_print_error ("data loss: timeout on INCR selection paste"); |
2584 | } |
2573 | } |
2585 | |
2574 | |
2586 | /* |
2575 | /* |
2587 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2576 | * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> |
2588 | */ |
2577 | */ |