ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.11 by pcg, Thu Dec 18 13:33:03 2003 UTC vs.
Revision 1.17 by pcg, Mon Jan 19 17:26:43 2004 UTC

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 $
5 * 4 *
6 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
7 * 6 *
8 * This program is free software; you can redistribute it and/or modify 7 * 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 8 * it under the terms of the GNU General Public License as published by
289 else if (nrow > prev_nrow) 288 else if (nrow > prev_nrow)
290 { 289 {
291 /* add rows */ 290 /* add rows */
292 scr_reset_realloc (); /* realloc _first_ */ 291 scr_reset_realloc (); /* realloc _first_ */
293 292
294 TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this 293 TermWin.ncol = prev_ncol; // save b/c scr_blank_screen_mem uses this
295 294
296 k = min (TermWin.nscrolled, nrow - prev_nrow); 295 k = min (TermWin.nscrolled, nrow - prev_nrow);
297 296
298 for (p = prev_total_rows; p < total_rows; p++) 297 for (p = prev_total_rows; p < total_rows; p++)
299 { 298 {
447 /* then so is screen.rend[i] */ 446 /* then so is screen.rend[i] */
448 assert(screen.rend[i]); 447 assert(screen.rend[i]);
449 } 448 }
450#endif 449#endif
451 450
452 delete talloc; 451 delete talloc; talloc = 0;
453 delete ralloc; 452 delete ralloc; ralloc = 0;
454 453
455 free (screen.text); 454 free (screen.text);
456 free (screen.tlen); 455 free (screen.tlen);
457 free (screen.rend); 456 free (screen.rend);
458 free (drawn_text); 457 free (drawn_text);
899 case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break; 898 case 'z': c = 0x2265; break; case '{': c = 0x03c0; break; case '|': c = 0x2260; break;
900 case '}': c = 0x00a3; break; case '~': c = 0x00b7; break; 899 case '}': c = 0x00a3; break; case '~': c = 0x00b7; break;
901 } 900 }
902 901
903 rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c)); 902 rend_t rend = SET_FONT (R->rstyle, R->TermWin.fontset->find_font (c));
904
905 stp[R->screen.cur.col] = c;
906 srp[R->screen.cur.col] = rend;
907
908 if (c > 255)
909 {
910 // rely on wcwidth to tell us the character width, at least for non iso-8859-1 903 // rely on wcwidth to tell us the character width, at least for non-ascii
911 int width = wcwidth (c); 904 int width = c <= 128 ? 1 : wcwidth (c);
905
906 // width -1 characters (e.g. combining chars) are ignored currently.
907 if (width > 0)
908 do
912 909 {
913 if (width > 1) 910 stp[R->screen.cur.col] = c;
914 {
915 while (--width > 0 && R->screen.cur.col < last_col - 1)
916 {
917
918 srp[R->screen.cur.col] |= RS_wide; 911 srp[R->screen.cur.col] = rend;
919 912
913 if (R->screen.cur.col < last_col - 1)
920 R->screen.cur.col++; 914 R->screen.cur.col++;
921 stp[R->screen.cur.col] = NOCHAR; 915 else
922 srp[R->screen.cur.col] = rend;
923 } 916 {
924 }
925 }
926
927 if (R->screen.cur.col < last_col - 1)
928 R->screen.cur.col++;
929 else {
930 R->screen.tlen[row] = last_col; 917 R->screen.tlen[row] = last_col;
931 if (R->screen.flags & Screen_Autowrap) 918 if (R->screen.flags & Screen_Autowrap)
932 R->screen.flags |= Screen_WrapNext; 919 R->screen.flags |= Screen_WrapNext;
920 break;
921 }
922
923 c = NOCHAR;
933 } 924 }
925 while (--width > 0);
926 else
927 1; /* handle combining character etc. here. */
934 } 928 }
929
935 if (R->screen.tlen[row] != -1) /* XXX: think about this */ 930 if (R->screen.tlen[row] != -1) /* XXX: think about this */
936 MAX_IT(R->screen.tlen[row], R->screen.cur.col); 931 MAX_IT(R->screen.tlen[row], R->screen.cur.col);
937 932
938/* 933/*
939 * If we wrote anywhere in the selected area, kill the selection 934 * If we wrote anywhere in the selected area, kill the selection
940 * XXX: should we kill the mark too? Possibly, but maybe that 935 * XXX: should we kill the mark too? Possibly, but maybe that
941 * should be a similar check. 936 * should be a similar check.
1650 rxvt_set_font_style(aR); 1645 rxvt_set_font_style(aR);
1651} 1646}
1652 1647
1653 1648
1654/* ------------------------------------------------------------------------- * 1649/* ------------------------------------------------------------------------- *
1655 * GRAPHICS COLOURS *
1656 * ------------------------------------------------------------------------- */
1657
1658#ifdef RXVT_GRAPHICS
1659/* EXTPROTO */
1660int
1661rxvt_scr_get_fgcolor(pR)
1662{
1663 return GET_FGCOLOR(R->rstyle);
1664}
1665
1666/* ------------------------------------------------------------------------- */
1667/* EXTPROTO */
1668int
1669rxvt_scr_get_bgcolor(pR)
1670{
1671 return GET_BGCOLOR(R->rstyle);
1672}
1673#endif
1674
1675/* ------------------------------------------------------------------------- *
1676 * MAJOR SCREEN MANIPULATION * 1650 * MAJOR SCREEN MANIPULATION *
1677 * ------------------------------------------------------------------------- */ 1651 * ------------------------------------------------------------------------- */
1678 1652
1679/* 1653/*
1680 * Refresh an area 1654 * Refresh an area
1859 * Refresh the screen 1833 * Refresh the screen
1860 * R->drawn_text/R->drawn_rend contain the screen information before the update. 1834 * R->drawn_text/R->drawn_rend contain the screen information before the update.
1861 * R->screen.text/R->screen.rend contain what the screen will change to. 1835 * R->screen.text/R->screen.rend contain what the screen will change to.
1862 */ 1836 */
1863 1837
1864#if defined (NO_BRIGHTCOLOR) || defined (VERYBOLD)
1865# define MONO_BOLD(x) ((x) & (RS_Bold|RS_Blink))
1866# define MONO_BOLD_FG(x, fg) MONO_BOLD(x)
1867#else
1868# define MONO_BOLD(x) \
1869 (((x) & (RS_Bold | RS_fgMask)) == (RS_Bold | Color_fg))
1870# define MONO_BOLD_FG(x, fg) (((x) & RS_Bold) && (fg) == Color_fg)
1871#endif
1872
1873#define FONT_WIDTH(X, Y) \ 1838#define FONT_WIDTH(X, Y) \
1874 (X)->per_char[(Y) - (X)->min_char_or_byte2].width 1839 (X)->per_char[(Y) - (X)->min_char_or_byte2].width
1875#define FONT_RBEAR(X, Y) \ 1840#define FONT_RBEAR(X, Y) \
1876 (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing 1841 (X)->per_char[(Y) - (X)->min_char_or_byte2].rbearing
1877#define FONT_LBEAR(X, Y) \ 1842#define FONT_LBEAR(X, Y) \
1883rxvt_term::scr_refresh (unsigned char refresh_type) 1848rxvt_term::scr_refresh (unsigned char refresh_type)
1884{ 1849{
1885 unsigned char clearfirst, /* first character writes before cell */ 1850 unsigned char clearfirst, /* first character writes before cell */
1886 clearlast, /* last character writes beyond cell */ 1851 clearlast, /* last character writes beyond cell */
1887 must_clear, /* use draw_string not draw_image_string */ 1852 must_clear, /* use draw_string not draw_image_string */
1888#ifndef NO_BOLDFONT
1889 bfont, /* we've changed font to bold font */
1890#endif
1891 rvid, /* reverse video this position */ 1853 rvid, /* reverse video this position */
1892 wbyte, /* we're in multibyte */
1893 showcursor; /* show the cursor */ 1854 showcursor; /* show the cursor */
1894 int fore, back; /* desired foreground/background */
1895 int16_t col, row, /* column/row we're processing */ 1855 int16_t col, row, /* column/row we're processing */
1896 ocrow; /* old cursor row */ 1856 ocrow; /* old cursor row */
1897 int cursorwidth; 1857 int cursorwidth;
1898 int i, /* tmp */ 1858 int i, /* tmp */
1899 row_offset; /* basic offset in screen structure */ 1859 row_offset; /* basic offset in screen structure */
1901 rend_t cc1; /* store colours at cursor position(s) */ 1861 rend_t cc1; /* store colours at cursor position(s) */
1902 rend_t cc2; /* store colours at cursor position(s) */ 1862 rend_t cc2; /* store colours at cursor position(s) */
1903#endif 1863#endif
1904 rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ 1864 rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */
1905 text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ 1865 text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */
1906 char *buffer; /* local copy of buffer */
1907 1866
1908 if (refresh_type == NO_REFRESH || !TermWin.mapped) 1867 if (refresh_type == NO_REFRESH || !TermWin.mapped)
1909 return; 1868 return;
1910 1869
1911 /* 1870 /*
1912 * A: set up vars 1871 * A: set up vars
1913 */ 1872 */
1914 clearfirst = clearlast = must_clear = wbyte = 0; 1873 clearfirst = clearlast = must_clear = 0;
1915#ifndef NO_BOLDFONT
1916 bfont = 0;
1917#endif
1918 1874
1919 if (currmaxcol < TermWin.ncol) 1875 if (currmaxcol < TermWin.ncol)
1920 { 1876 {
1921 currmaxcol = TermWin.ncol; 1877 currmaxcol = TermWin.ncol;
1922 buffer = (char *)rxvt_realloc (buffer, 1878 buffer = (char *)rxvt_realloc (buffer,
1923 sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX); 1879 sizeof(char) * (currmaxcol + 1) * MB_CUR_MAX);
1924 } 1880 }
1925 1881
1926 buffer = buffer;
1927 refresh_count = 0; 1882 refresh_count = 0;
1928 1883
1929 row_offset = TermWin.saveLines - TermWin.view_start; 1884 row_offset = TermWin.saveLines - TermWin.view_start;
1930 1885
1931 if ((refresh_type & REFRESH_BOUNDS)) 1886 if ((refresh_type & REFRESH_BOUNDS))
1940#if defined(TRANSPARENT) 1895#if defined(TRANSPARENT)
1941 must_clear |= ((Options & Opt_transparent) && am_transparent); 1896 must_clear |= ((Options & Opt_transparent) && am_transparent);
1942#endif 1897#endif
1943 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 1898 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
1944 1899
1945/* 1900 /*
1946 * B: reverse any characters which are selected 1901 * B: reverse any characters which are selected
1947 */ 1902 */
1948 rxvt_scr_reverse_selection (this); 1903 rxvt_scr_reverse_selection (this);
1949 1904
1950/* 1905 /*
1951 * C: set the cursor character(s) 1906 * C: set the cursor character(s)
1952 */ 1907 */
1953 { 1908 {
1954 unsigned char setoldcursor; 1909 unsigned char setoldcursor;
1955 rend_t ccol1, /* Cursor colour */ 1910 rend_t ccol1, /* Cursor colour */
1956 ccol2; /* Cursor colour2 */ 1911 ccol2; /* Cursor colour2 */
1957 1912
1994#endif 1949#endif
1995 *srp = SET_FGCOLOR(*srp, ccol1); 1950 *srp = SET_FGCOLOR(*srp, ccol1);
1996 *srp = SET_BGCOLOR(*srp, ccol2); 1951 *srp = SET_BGCOLOR(*srp, ccol2);
1997#endif 1952#endif
1998 } 1953 }
1999
2000 while (IS_WIDE (*srp))
2001 cursorwidth++, srp++;
2002 } 1954 }
2003 1955
2004 /* make sure no outline cursor is left around */ 1956 /* make sure no outline cursor is left around */
2005 setoldcursor = 0; 1957 setoldcursor = 0;
2006 if (ocrow != -1) { 1958 if (ocrow != -1) {
2026 } 1978 }
2027 } 1979 }
2028 } 1980 }
2029 1981
2030#ifndef NO_SLOW_LINK_SUPPORT 1982#ifndef NO_SLOW_LINK_SUPPORT
2031/* 1983 /*
2032 * D: CopyArea pass - very useful for slower links 1984 * D: CopyArea pass - very useful for slower links
2033 * This has been deliberately kept simple. 1985 * This has been deliberately kept simple.
2034 */ 1986 */
2035 i = num_scr; 1987 i = num_scr;
2036 if (refresh_type == FAST_REFRESH && num_scr_allow && i 1988 if (refresh_type == FAST_REFRESH && num_scr_allow && i
2037 && abs(i) < TermWin.nrow && !must_clear) 1989 && abs(i) < TermWin.nrow && !must_clear)
2038 { 1990 {
2039 int16_t nits; 1991 int16_t nits;
2094 } 2046 }
2095 } 2047 }
2096 } 2048 }
2097#endif 2049#endif
2098 2050
2099/* 2051 /*
2100 * E: main pass across every character 2052 * E: main pass across every character
2101 */ 2053 */
2102 for (row = 0; row < TermWin.nrow; row++) 2054 for (row = 0; row < TermWin.nrow; row++)
2103 { 2055 {
2104 stp = screen.text[row + row_offset]; 2056 stp = screen.text[row + row_offset];
2105 srp = screen.rend[row + row_offset]; 2057 srp = screen.rend[row + row_offset];
2106 dtp = drawn_text[row]; 2058 dtp = drawn_text[row];
2107 drp = drawn_rend[row]; 2059 drp = drawn_rend[row];
2108 2060
2109/* 2061 /*
2110 * E2: OK, now the real pass 2062 * E2: OK, now the real pass
2111 */ 2063 */
2112 int ypixel = (int)Row2Pixel(row); 2064 int ypixel = (int)Row2Pixel(row);
2113 2065
2114 for (col = 0; col < TermWin.ncol; col++) 2066 for (col = 0; col < TermWin.ncol; col++)
2115 { 2067 {
2116 /* compare new text with old - if exactly the same then continue */ 2068 /* compare new text with old - if exactly the same then continue */
2149 i++; 2101 i++;
2150 2102
2151 continue; 2103 continue;
2152 } 2104 }
2153 2105
2154 if (((rend ^ srp[col]) & ~RS_wide) != 0) 2106 if (rend != srp[col])
2155 break; 2107 break;
2156 2108
2157 count++; 2109 count++;
2158 2110
2159 if (stp[col] != dtp[col] 2111 if (stp[col] != dtp[col]
2171 } 2123 }
2172 2124
2173 col--; /* went one too far. move back */ 2125 col--; /* went one too far. move back */
2174 count -= i; /* dump any matching trailing chars */ 2126 count -= i; /* dump any matching trailing chars */
2175 2127
2176/* 2128 /*
2177 * Determine the attributes for the string 2129 * Determine the attributes for the string
2178 */ 2130 */
2179 int fid = GET_FONT(rend); 2131 int fid = GET_FONT (rend);
2180 fore = GET_FGCOLOR(rend); 2132 int fore = GET_FGCOLOR (rend); // desired foreground
2181 back = GET_BGCOLOR(rend); 2133 int back = GET_BGCOLOR (rend); // desired background
2134
2182 rend = GET_ATTR(rend); 2135 rend = GET_ATTR (rend);
2183 2136
2184 rvid = (rend & RS_RVid) ? 1 : 0; 2137 rvid = !!(rend & RS_RVid);
2185#ifdef OPTION_HC 2138#ifdef OPTION_HC
2186 if (!rvid && (rend & RS_Blink)) 2139 if (!rvid && (rend & RS_Blink))
2187 { 2140 {
2188 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC)) 2141 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_HC))
2189 back = Color_HC; 2142 back = Color_HC;
2206 } 2159 }
2207#ifndef NO_BOLD_UNDERLINE_REVERSE 2160#ifndef NO_BOLD_UNDERLINE_REVERSE
2208 else if (rend & RS_Bold) 2161 else if (rend & RS_Bold)
2209 { 2162 {
2210 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD)) 2163 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_BD))
2211 {
2212 fore = Color_BD; 2164 fore = Color_BD;
2213# ifndef VERYBOLD
2214 rend &= ~RS_Bold; /* we've taken care of it */
2215# endif
2216 }
2217 } 2165 }
2218 else if (rend & RS_Uline) 2166 else if (rend & RS_Uline)
2219 { 2167 {
2220 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL)) 2168 if (Xdepth > 2 && ISSET_PIXCOLOR (this, Color_UL))
2221 {
2222 fore = Color_UL; 2169 fore = Color_UL;
2223 rend &= ~RS_Uline; /* we've taken care of it */
2224 }
2225 } 2170 }
2226#endif 2171#endif
2227 2172
2228/* 2173 /*
2229 * Actually do the drawing of the string here 2174 * Actually do the drawing of the string here
2230 */ 2175 */
2231 rxvt_font *font = (*TermWin.fontset)[fid]; 2176 rxvt_font *font = (*TermWin.fontset)[fid];
2232 2177
2233 if (back == Color_bg) 2178 if (back == Color_bg)
2234 { 2179 {
2235 if (must_clear) 2180 if (must_clear)
2255 xpixel, ypixel + font->ascent + 1, 2200 xpixel, ypixel + font->ascent + 1,
2256 xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1); 2201 xpixel + Width2Pixel(count) - 1, ypixel + font->ascent + 1);
2257 } /* for (col....) */ 2202 } /* for (col....) */
2258 } /* for (row....) */ 2203 } /* for (row....) */
2259 2204
2260/* 2205 /*
2261 * G: cleanup cursor and display outline cursor if necessary 2206 * G: cleanup cursor and display outline cursor if necessary
2262 */ 2207 */
2263 if (showcursor) { 2208 if (showcursor) {
2264 if (TermWin.focus) { 2209 if (TermWin.focus) {
2265 srp = &(screen.rend[screen.cur.row + TermWin.saveLines] 2210 srp = &(screen.rend[screen.cur.row + TermWin.saveLines]
2266 [screen.cur.col]); 2211 [screen.cur.col]);
2267 *srp ^= RS_RVid; 2212 *srp ^= RS_RVid;
2280 Row2Pixel(oldcursor.row), 2225 Row2Pixel(oldcursor.row),
2281 (unsigned int)(Width2Pixel(cursorwidth) - 1), 2226 (unsigned int)(Width2Pixel(cursorwidth) - 1),
2282 (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1)); 2227 (unsigned int)(Height2Pixel(1) - TermWin.lineSpace - 1));
2283 } 2228 }
2284 } 2229 }
2285/* 2230
2231 /*
2286 * H: cleanup selection 2232 * H: cleanup selection
2287 */ 2233 */
2288 rxvt_scr_reverse_selection (this); 2234 rxvt_scr_reverse_selection (this);
2289 2235
2290/* 2236 /*
2291 * I: other general cleanup 2237 * I: other general cleanup
2292 */ 2238 */
2293 if (clearfirst && TermWin.int_bwidth) 2239 if (clearfirst && TermWin.int_bwidth)
2294 /* 2240 /*
2295 * clear the whole screen height, note that width == 0 is treated 2241 * clear the whole screen height, note that width == 0 is treated
2296 * specially by XClearArea 2242 * specially by XClearArea
2297 */ 2243 */
2575} 2521}
2576 2522
2577void 2523void
2578rxvt_term::incr_cb (time_watcher &w) 2524rxvt_term::incr_cb (time_watcher &w)
2579{ 2525{
2580 w.stop ();
2581 selection_wait = Sel_none; 2526 selection_wait = Sel_none;
2582 2527
2583 rxvt_print_error("data loss: timeout on INCR selection paste"); 2528 rxvt_print_error ("data loss: timeout on INCR selection paste");
2584} 2529}
2585 2530
2586/* 2531/*
2587 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za> 2532 * INCR support originally provided by Paul Sheer <psheer@obsidian.co.za>
2588 */ 2533 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines