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

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.81 by pcg, Sun Mar 28 02:07:08 2004 UTC vs.
Revision 1.90 by pcg, Fri Apr 2 19:09:52 2004 UTC

1131 check_our_parents (); 1131 check_our_parents ();
1132 if (am_transparent) 1132 if (am_transparent)
1133 want_full_refresh = 1; 1133 want_full_refresh = 1;
1134 } 1134 }
1135#endif 1135#endif
1136
1137 } 1136 }
1138 break; 1137 break;
1139 1138
1140 case SelectionClear: 1139 case SelectionClear:
1141 selection_clear (); 1140 selection_clear ();
1345 return; 1344 return;
1346 } 1345 }
1347 1346
1348 /* FALLTHROUGH */ 1347 /* FALLTHROUGH */
1349 case ReparentNotify: 1348 case ReparentNotify:
1350 if ((Options & Opt_transparent) && check_our_parents ()) 1349 if ((Options & Opt_transparent) && check_our_parents () && am_transparent)
1351 if (am_transparent)
1352 want_full_refresh = 1; 1350 want_full_refresh = 1;
1353 break; 1351 break;
1354#endif 1352#endif
1355 } 1353 }
1356} 1354}
1357 1355
1701 else if (isMenuBarWindow (ev.window)) 1699 else if (isMenuBarWindow (ev.window))
1702 menubar_control (ev); 1700 menubar_control (ev);
1703#endif 1701#endif
1704} 1702}
1705 1703
1706
1707#ifdef TRANSPARENT 1704#ifdef TRANSPARENT
1705#if TINTING
1706/* shading taken from eterm-0.9.2 */
1707/* RGB 15 */
1708
1709static void
1710shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1711{
1712 unsigned char *ptr;
1713 int x, y;
1714
1715 ptr = (unsigned char *)data + (w * sizeof(uint16_t));
1716 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1717 /* No saturation */
1718 for (y = h; --y >= 0;) {
1719 for (x = -w; x < 0; x++) {
1720 int r, g, b;
1721
1722 b = ((uint16_t *) ptr)[x];
1723 r = (b & 0x7c00) * rm;
1724 g = (b & 0x3e0) * gm;
1725 b = (b & 0x1f) * bm;
1726 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00)
1727 | ((g >> 8) & 0x3e0)
1728 | ((b >> 8) & 0x1f);
1729 }
1730 ptr += bpl;
1731 }
1732 } else {
1733 for (y = h; --y >= 0;) {
1734 for (x = -w; x < 0; x++) {
1735 int r, g, b;
1736
1737 b = ((uint16_t *) ptr)[x];
1738 r = (b & 0x7c00) * rm;
1739 g = (b & 0x3e0) * gm;
1740 b = (b & 0x1f) * bm;
1741 r |= (!(r >> 15) - 1);
1742 g |= (!(g >> 10) - 1);
1743 b |= (!(b >> 5) - 1);
1744 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00)
1745 | ((g >> 8) & 0x3e0)
1746 | ((b >> 8) & 0x1f);
1747 }
1748 ptr += bpl;
1749 }
1750 }
1751}
1752
1753/* RGB 16 */
1754static void
1755shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1756{
1757 unsigned char *ptr;
1758 int x, y;
1759
1760 ptr = (unsigned char *)data + (w * sizeof(uint16_t));
1761 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1762 /* No saturation */
1763 for (y = h; --y >= 0;) {
1764 for (x = -w; x < 0; x++) {
1765 int r, g, b;
1766
1767 b = ((uint16_t *) ptr)[x];
1768 r = (b & 0xf800) * rm;
1769 g = (b & 0x7e0) * gm;
1770 b = (b & 0x1f) * bm;
1771 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1772 | ((g >> 8) & 0x7e0)
1773 | ((b >> 8) & 0x1f);
1774 }
1775 ptr += bpl;
1776 }
1777 } else {
1778 for (y = h; --y >= 0;) {
1779 for (x = -w; x < 0; x++) {
1780 int r, g, b;
1781
1782 b = ((uint16_t *) ptr)[x];
1783 r = (b & 0xf800) * rm;
1784 g = (b & 0x7e0) * gm;
1785 b = (b & 0x1f) * bm;
1786 r |= (!(r >> 16) - 1);
1787 g |= (!(g >> 11) - 1);
1788 b |= (!(b >> 5) - 1);
1789 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1790 | ((g >> 8) & 0x7e0)
1791 | ((b >> 8) & 0x1f);
1792 }
1793 ptr += bpl;
1794 }
1795 }
1796}
1797
1798/* RGB 24 */
1799static void
1800shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1801{
1802 unsigned char *ptr;
1803 int x, y;
1804
1805 ptr = (unsigned char *)data + (w * 3);
1806 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1807 /* No saturation */
1808 for (y = h; --y >= 0;) {
1809 for (x = -(w * 3); x < 0; x += 3) {
1810 int r, g, b;
1811
1812 if (byteorder.big_endian()) {
1813 r = (ptr[x + 0] * rm) >> 8;
1814 g = (ptr[x + 1] * gm) >> 8;
1815 b = (ptr[x + 2] * bm) >> 8;
1816 ptr[x + 0] = r;
1817 ptr[x + 1] = g;
1818 ptr[x + 2] = b;
1819 } else {
1820 r = (ptr[x + 2] * rm) >> 8;
1821 g = (ptr[x + 1] * gm) >> 8;
1822 b = (ptr[x + 0] * bm) >> 8;
1823 ptr[x + 2] = r;
1824 ptr[x + 1] = g;
1825 ptr[x + 0] = b;
1826 }
1827 }
1828 ptr += bpl;
1829 }
1830 } else {
1831 for (y = h; --y >= 0;) {
1832 for (x = -(w * 3); x < 0; x += 3) {
1833 int r, g, b;
1834
1835 if (byteorder.big_endian()) {
1836 r = (ptr[x + 0] * rm) >> 8;
1837 g = (ptr[x + 1] * gm) >> 8;
1838 b = (ptr[x + 2] * bm) >> 8;
1839
1840 r |= (!(r >> 8) - 1);
1841 g |= (!(g >> 8) - 1);
1842 b |= (!(b >> 8) - 1);
1843
1844 ptr[x + 0] = r;
1845 ptr[x + 1] = g;
1846 ptr[x + 2] = b;
1847 } else {
1848 r = (ptr[x + 2] * rm) >> 8;
1849 g = (ptr[x + 1] * gm) >> 8;
1850 b = (ptr[x + 0] * bm) >> 8;
1851
1852 r |= (!(r >> 8) - 1);
1853 g |= (!(g >> 8) - 1);
1854 b |= (!(b >> 8) - 1);
1855
1856 ptr[x + 2] = r;
1857 ptr[x + 1] = g;
1858 ptr[x + 0] = b;
1859 }
1860 }
1861 ptr += bpl;
1862 }
1863 }
1864}
1865
1866/* RGB 32 */
1867static void
1868shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1869{
1870 unsigned char *ptr;
1871 int x, y;
1872
1873 ptr = (unsigned char *)data + (w * 4);
1874 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1875 /* No saturation */
1876 for (y = h; --y >= 0;) {
1877 if (byteorder.big_endian()) {
1878 for (x = -(w * 4); x < 0; x += 4) {
1879 int r, g, b;
1880
1881 r = (ptr[x + 1] * rm) >> 8;
1882 g = (ptr[x + 2] * gm) >> 8;
1883 b = (ptr[x + 3] * bm) >> 8;
1884 ptr[x + 1] = r;
1885 ptr[x + 2] = g;
1886 ptr[x + 3] = b;
1887 }
1888 } else {
1889 for (x = -(w * 4); x < 0; x += 4) {
1890 int r, g, b;
1891
1892 r = (ptr[x + 2] * rm) >> 8;
1893 g = (ptr[x + 1] * gm) >> 8;
1894 b = (ptr[x + 0] * bm) >> 8;
1895 ptr[x + 2] = r;
1896 ptr[x + 1] = g;
1897 ptr[x + 0] = b;
1898 }
1899 }
1900 ptr += bpl;
1901 }
1902 } else {
1903 for (y = h; --y >= 0;) {
1904 for (x = -(w * 4); x < 0; x += 4) {
1905 int r, g, b;
1906
1907 if (byteorder.big_endian()) {
1908 r = (ptr[x + 1] * rm) >> 8;
1909 g = (ptr[x + 2] * gm) >> 8;
1910 b = (ptr[x + 3] * bm) >> 8;
1911
1912 r |= (!(r >> 8) - 1);
1913 g |= (!(g >> 8) - 1);
1914 b |= (!(b >> 8) - 1);
1915
1916 ptr[x + 1] = r;
1917 ptr[x + 2] = g;
1918 ptr[x + 3] = b;
1919 } else {
1920 r = (ptr[x + 2] * rm) >> 8;
1921 g = (ptr[x + 1] * gm) >> 8;
1922 b = (ptr[x + 0] * bm) >> 8;
1923
1924 r |= (!(r >> 8) - 1);
1925 g |= (!(g >> 8) - 1);
1926 b |= (!(b >> 8) - 1);
1927
1928 ptr[x + 2] = r;
1929 ptr[x + 1] = g;
1930 ptr[x + 0] = b;
1931 }
1932 }
1933 ptr += bpl;
1934 }
1935 }
1936}
1937
1938#endif
1939
1708/* 1940/*
1709 * Check our parents are still who we think they are. 1941 * Check our parents are still who we think they are.
1710 * Do transparency updates if required 1942 * Do transparency updates if required
1711 */ 1943 */
1712int 1944int
1713rxvt_term::check_our_parents () 1945rxvt_term::check_our_parents ()
1714{ 1946{
1715 int i, pchanged, aformat, have_pixmap, rootdepth; 1947 int i, pchanged, aformat, have_pixmap, rootdepth;
1716 unsigned long nitems, bytes_after; 1948 unsigned long nitems, bytes_after;
1717 Atom atype; 1949 Atom atype;
1718 unsigned char *prop = NULL; 1950 unsigned char *prop = NULL;
1719 Window root, oldp, *list; 1951 Window root, oldp, *list;
1720 Pixmap rootpixmap = None; 1952 Pixmap rootpixmap = None;
1721 XWindowAttributes wattr, wrootattr; 1953 XWindowAttributes wattr, wrootattr;
1722 1954
1723 pchanged = 0; 1955 pchanged = 0;
1724 1956
1725 if (! (Options & Opt_transparent)) 1957 if (!(Options & Opt_transparent))
1726 return pchanged; /* Don't try any more */ 1958 return pchanged; /* Don't try any more */
1727 1959
1728 XGetWindowAttributes (display->display, display->root, &wrootattr); 1960 XGetWindowAttributes (display->display, display->root, &wrootattr);
1729 rootdepth = wrootattr.depth; 1961 rootdepth = wrootattr.depth;
1730 1962
1731 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 1963 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
1964
1732 if (rootdepth != wattr.depth) 1965 if (rootdepth != wattr.depth)
1733 { 1966 {
1734 if (am_transparent) 1967 if (am_transparent)
1735 { 1968 {
1736 pchanged = 1; 1969 pchanged = 1;
1737 XSetWindowBackground (display->display, TermWin.vt, 1970 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
1738 PixColors[Color_bg]);
1739 am_transparent = am_pixmap_trans = 0; 1971 am_transparent = am_pixmap_trans = 0;
1740 } 1972 }
1973
1741 return pchanged; /* Don't try any more */ 1974 return pchanged; /* Don't try any more */
1742 } 1975 }
1743 1976
1744 /* Get all X ops out of the queue so that our information is up-to-date. */ 1977 /* Get all X ops out of the queue so that our information is up-to-date. */
1745 XSync (display->display, False); 1978 XSync (display->display, False);
1747 /* 1980 /*
1748 * Make the frame window set by the window manager have 1981 * Make the frame window set by the window manager have
1749 * the root background. Some window managers put multiple nested frame 1982 * the root background. Some window managers put multiple nested frame
1750 * windows for each client, so we have to take care about that. 1983 * windows for each client, so we have to take care about that.
1751 */ 1984 */
1752 i = (xa[XA_XROOTPMAPID] != 0 1985 i = (xa[XA_XROOTPMAPID]
1753 && (XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], 1986 && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID],
1754 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 1987 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1755 &nitems, &bytes_after, &prop) == Success)); 1988 &nitems, &bytes_after, &prop) == Success);
1989
1990 if (!i || prop == NULL)
1991 i = (xa[XA_XSETROOTID]
1992 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID],
1993 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1994 &nitems, &bytes_after, &prop) == Success);
1995
1756 if (!i || prop == NULL) 1996 if (!i || prop == NULL)
1757 have_pixmap = 0; 1997 have_pixmap = 0;
1758 else 1998 else
1759 { 1999 {
1760 have_pixmap = 1; 2000 have_pixmap = 1;
1761 rootpixmap = * ((Pixmap *)prop); 2001 rootpixmap = * ((Pixmap *)prop);
1762 XFree (prop); 2002 XFree (prop);
1763 } 2003 }
2004
1764 if (have_pixmap) 2005 if (have_pixmap)
1765 { 2006 {
1766 /* 2007 /*
1767 * Copy display->root pixmap transparency 2008 * Copy display->root pixmap transparency
1768 */ 2009 */
1772 XImage *image; 2013 XImage *image;
1773 GC gc; 2014 GC gc;
1774 XGCValues gcvalue; 2015 XGCValues gcvalue;
1775 2016
1776 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 2017 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
1777 0, 0, &sx, &sy, &cr); 2018 0, 0, &sx, &sy, &cr);
1778 nw = (unsigned int)szHint.width; 2019 nw = (unsigned int)szHint.width;
1779 nh = (unsigned int)szHint.height; 2020 nh = (unsigned int)szHint.height;
1780 nx = ny = 0; 2021 nx = ny = 0;
1781 2022
1782 if (sx < 0) 2023 if (sx < 0)
1794 } 2035 }
1795 2036
1796 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2037 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
1797 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2038 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
1798 allowedxerror = -1; 2039 allowedxerror = -1;
1799 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 2040 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
1800 ZPixmap); 2041
1801 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2042 /* XXX: handle BadMatch - usually because we're outside the pixmap */
1802 /* XXX: may need a delay here? */ 2043 /* XXX: may need a delay here? */
1803 allowedxerror = 0; 2044 allowedxerror = 0;
2045
1804 if (image == NULL) 2046 if (image == NULL)
1805 { 2047 {
1806 if (am_transparent && am_pixmap_trans) 2048 if (am_transparent && am_pixmap_trans)
1807 { 2049 {
1808 pchanged = 1; 2050 pchanged = 1;
1810 { 2052 {
1811 XFreePixmap (display->display, TermWin.pixmap); 2053 XFreePixmap (display->display, TermWin.pixmap);
1812 TermWin.pixmap = None; 2054 TermWin.pixmap = None;
1813 } 2055 }
1814 } 2056 }
2057
1815 am_pixmap_trans = 0; 2058 am_pixmap_trans = 0;
1816 } 2059 }
1817 else 2060 else
1818 { 2061 {
1819 if (TermWin.pixmap != None) 2062 if (TermWin.pixmap != None)
1820 XFreePixmap (display->display, TermWin.pixmap); 2063 XFreePixmap (display->display, TermWin.pixmap);
2064
2065#if TINTING
2066 if (ISSET_PIXCOLOR (Color_tint))
2067 {
2068 unsigned short shade, rm, gm, bm;
2069
2070 PixColors[Color_tint].get (display, rm, gm, bm);
2071
2072 rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but...
2073
2074 /* Determine bitshift and bitmask values */
2075 switch (image->bits_per_pixel)
2076 {
2077 case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2078 case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2079 case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2080 case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2081 }
2082 }
2083#endif
2084
1821 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 2085 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
1822 (unsigned int)szHint.width,
1823 (unsigned int)szHint.height, 2086 szHint.width, szHint.height, image->depth);
1824 (unsigned int)image->depth);
1825 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); 2087 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue);
1826 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, 2088 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0,
1827 nx, ny, (unsigned int)image->width,
1828 (unsigned int)image->height); 2089 nx, ny, image->width, image->height);
1829 XFreeGC (display->display, gc); 2090 XFreeGC (display->display, gc);
1830 XDestroyImage (image); 2091 XDestroyImage (image);
1831 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2092 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
1832 TermWin.pixmap); 2093 TermWin.pixmap);
2094
1833 if (!am_transparent || !am_pixmap_trans) 2095 if (!am_transparent || !am_pixmap_trans)
1834 pchanged = 1; 2096 pchanged = 1;
2097
1835 am_transparent = am_pixmap_trans = 1; 2098 am_transparent = am_pixmap_trans = 1;
1836 } 2099 }
1837 } 2100 }
1838 2101
1839 if (!am_pixmap_trans) 2102 if (!am_pixmap_trans)
1840 { 2103 {
1841 unsigned int n; 2104 unsigned int n;
1842 /* 2105 /*
1843 * InheritPixmap transparency 2106 * InheritPixmap transparency
1844 */ 2107 */
1845 D_X ((stderr, "InheritPixmap Seeking to %08lx", display->root)); 2108 D_X ((stderr, "InheritPixmap Seeking to %08lx", display->root));
1846 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); 2109 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
1847 i++)
1848 { 2110 {
1849 oldp = TermWin.parent[i]; 2111 oldp = TermWin.parent[i];
1850 XQueryTree (display->display, TermWin.parent[i - 1], &root, 2112 XQueryTree (display->display, TermWin.parent[i - 1], &root,
1851 &TermWin.parent[i], &list, &n); 2113 &TermWin.parent[i], &list, &n);
1852 XFree (list); 2114 XFree (list);
1853 D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i])); 2115 D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i]));
2116
1854 if (TermWin.parent[i] == display->root) 2117 if (TermWin.parent[i] == display->root)
1855 { 2118 {
1856 if (oldp != None) 2119 if (oldp != None)
1857 pchanged = 1; 2120 pchanged = 1;
2121
1858 break; 2122 break;
1859 } 2123 }
2124
1860 if (oldp != TermWin.parent[i]) 2125 if (oldp != TermWin.parent[i])
1861 pchanged = 1; 2126 pchanged = 1;
1862 } 2127 }
1863 2128
1864 n = 0; 2129 n = 0;
1875 break; 2140 break;
1876 } 2141 }
1877 } 2142 }
1878 } 2143 }
1879 2144
1880 if (n > (int) (sizeof (TermWin.parent) 2145 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
1881 / sizeof (TermWin.parent[0])))
1882 { 2146 {
1883 D_X ((stderr, "InheritPixmap Turning off")); 2147 D_X ((stderr, "InheritPixmap Turning off"));
1884 XSetWindowBackground (display->display, TermWin.parent[0], 2148 XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]);
1885 PixColors[Color_fg]);
1886 XSetWindowBackground (display->display, TermWin.vt, 2149 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
1887 PixColors[Color_bg]);
1888 am_transparent = 0; 2150 am_transparent = 0;
1889 /* XXX: also turn off Opt_transparent? */ 2151 /* XXX: also turn off Opt_transparent? */
1890 } 2152 }
1891 else 2153 else
1892 { 2154 {
2155#if WAIT_FOR_WM
1893 /* wait (an arbitrary period) for the WM to do its thing 2156 /* wait (an arbitrary period) for the WM to do its thing
1894 * needed for fvwm2.2.2 (and before?) */ 2157 * needed for fvwm2.2.2 (and before?) */
1895# ifdef HAVE_NANOSLEEP
1896 struct timespec rqt;
1897
1898 rqt.tv_sec = 1;
1899 rqt.tv_nsec = 0;
1900 nanosleep (&rqt, NULL);
1901# else
1902 sleep (1); 2158 sleep (1);
1903# endif 2159#endif
1904 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); 2160 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
1905 for (n = 0; n < (unsigned int)i; n++) 2161 for (n = 0; n < (unsigned int)i; n++)
1906 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], 2162 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
1907 ParentRelative); 2163
1908 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2164 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
1909 ParentRelative);
1910 am_transparent = 1; 2165 am_transparent = 1;
1911 } 2166 }
1912 2167
1913 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2168 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
1914 TermWin.parent[i] = None; 2169 TermWin.parent[i] = None;
1915 } 2170 }
2171
1916 return pchanged; 2172 return pchanged;
1917} 2173}
1918#endif 2174#endif
1919 2175
1920/*}}} */ 2176/*}}} */
2156/*}}} */ 2412/*}}} */
2157 2413
2158/* *INDENT-OFF* */ 2414/* *INDENT-OFF* */
2159enum { 2415enum {
2160 C1_40 = 0x40, 2416 C1_40 = 0x40,
2161 C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, 2417 C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA,
2162 C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3, 2418 C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3,
2163 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA, 2419 C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,
2164 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC 2420 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC,
2165}; 2421};
2166/* *INDENT-ON* */ 2422/* *INDENT-ON* */
2167 2423
2168/*{{{ process non-printing single characters */ 2424/*{{{ process non-printing single characters */
2169void 2425void
2174 case C0_ESC: 2430 case C0_ESC:
2175 process_escape_seq (); 2431 process_escape_seq ();
2176 break; 2432 break;
2177 case C0_ENQ: /* terminal Status */ 2433 case C0_ENQ: /* terminal Status */
2178 if (rs[Rs_answerbackstring]) 2434 if (rs[Rs_answerbackstring])
2179 tt_write (
2180 (const unsigned char *)rs[Rs_answerbackstring], 2435 tt_write ((const unsigned char *)rs[Rs_answerbackstring],
2181 (unsigned int)STRLEN (rs[Rs_answerbackstring])); 2436 (unsigned int)STRLEN (rs[Rs_answerbackstring]));
2182 else 2437 else
2183 tt_write ((unsigned char *)VT100_ANS, 2438 tt_write ((unsigned char *)VT100_ANS,
2184 (unsigned int)STRLEN (VT100_ANS)); 2439 (unsigned int)STRLEN (VT100_ANS));
2185 break; 2440 break;
2186 case C0_BEL: /* bell */ 2441 case C0_BEL: /* bell */
2187 scr_bell (); 2442 scr_bell ();
2188 break; 2443 break;
2189 case C0_BS: /* backspace */ 2444 case C0_BS: /* backspace */
2363 case C1_RI: /* ESC M */ 2618 case C1_RI: /* ESC M */
2364 scr_index (DN); 2619 scr_index (DN);
2365 break; 2620 break;
2366 2621
2367 /* 8.3.142: SINGLE-SHIFT TWO */ 2622 /* 8.3.142: SINGLE-SHIFT TWO */
2368 /*case C1_SS2: scr_single_shift (2); break; */ 2623 /*case C1_SS2: scr_single_shift (2); break; */
2369 2624
2370 /* 8.3.143: SINGLE-SHIFT THREE */ 2625 /* 8.3.143: SINGLE-SHIFT THREE */
2371 /*case C1_SS3: scr_single_shift (3); break; */ 2626 /*case C1_SS3: scr_single_shift (3); break; */
2372 2627
2373 /* 8.3.27: DEVICE CONTROL STRING */ 2628 /* 8.3.27: DEVICE CONTROL STRING */
2374 case C1_DCS: /* ESC P */ 2629 case C1_DCS: /* ESC P */
2375 process_dcs_seq (); 2630 process_dcs_seq ();
2376 break; 2631 break;
2391 process_osc_seq (); 2646 process_osc_seq ();
2392 break; 2647 break;
2393 2648
2394 /* 8.3.106: RESET TO INITIAL STATE */ 2649 /* 8.3.106: RESET TO INITIAL STATE */
2395 case 'c': 2650 case 'c':
2651 mbstate.reset ();
2396 scr_poweron (); 2652 scr_poweron ();
2397 scrollbar_show (1); 2653 scrollbar_show (1);
2398 break; 2654 break;
2399 2655
2400 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ 2656 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */
2437 make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */ 2693 make_byte (1,0,1,1,1,1,1,0), /* P, Q, R, S, T, U, V, W, */
2438 make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */ 2694 make_byte (1,1,1,0,0,0,1,0), /* X, Y, Z, [, \, ], ^, _, */
2439 make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */ 2695 make_byte (1,1,1,0,1,1,1,0), /* `, a, b, c, d, e, f, g, */
2440 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */ 2696 make_byte (0,0,1,1,0,0,0,0), /* h, i, j, k, l, m, n, o, */
2441 make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */ 2697 make_byte (0,0,0,0,0,0,0,0), /* p, q, r, s, t, u, v, w, */
2442 make_byte (0,0,0,0,0,0,0,0) /* x, y, z, {, |, }, ~, */ 2698 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */
2443 }; 2699 };
2444/* *INDENT-ON* */ 2700/* *INDENT-ON* */
2445 2701
2446void 2702void
2447rxvt_term::process_csi_seq () 2703rxvt_term::process_csi_seq ()
2646 tt_printf ("\033[0n"); 2902 tt_printf ("\033[0n");
2647 break; 2903 break;
2648 case 6: /* CPR requested */ 2904 case 6: /* CPR requested */
2649 scr_report_position (); 2905 scr_report_position ();
2650 break; 2906 break;
2651#if defined (ENABLE_DISPLAY_ANSWER)
2652 case 7: /* unofficial extension */ 2907 case 7: /* unofficial extension */
2908 if (Options & Opt_insecure)
2653 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2909 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2654 break; 2910 break;
2655#endif
2656 case 8: /* unofficial extension */ 2911 case 8: /* unofficial extension */
2657 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 2912 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2658 break; 2913 break;
2659 } 2914 }
2660 break; 2915 break;
2661 2916
2662 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2917 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
2800 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3055 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
2801 break; 3056 break;
2802 case 13: /* report window position */ 3057 case 13: /* report window position */
2803 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3058 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2804 XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, 3059 XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root,
2805 -wattr.border_width, -wattr.border_width, 3060 -wattr.border_width, -wattr.border_width,
2806 &x, &y, &wdummy); 3061 &x, &y, &wdummy);
2807 tt_printf ("\033[3;%d;%dt", x, y); 3062 tt_printf ("\033[3;%d;%dt", x, y);
2808 break; 3063 break;
2809 case 14: /* report window size (pixels) */ 3064 case 14: /* report window size (pixels) */
2810 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3065 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2811 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3066 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
2814 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); 3069 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol);
2815 break; 3070 break;
2816 case 19: /* report window size (chars) */ 3071 case 19: /* report window size (chars) */
2817 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); 3072 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol);
2818 break; 3073 break;
2819#if 0 /* XXX: currently disabled due to security concerns */
2820 case 20: /* report icon label */ 3074 case 20: /* report icon label */
3075 if (Options & Opt_insecure)
3076 {
3077 char *s;
2821 XGetIconName (display->display, TermWin.parent[0], &s); 3078 XGetIconName (display->display, TermWin.parent[0], &s);
2822 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ 3079 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */
3080 }
2823 break; 3081 break;
2824 case 21: /* report window title */ 3082 case 21: /* report window title */
3083 if (Options & Opt_insecure)
3084 {
3085 char *s;
2825 XFetchName (display->display, TermWin.parent[0], &s); 3086 XFetchName (display->display, TermWin.parent[0], &s);
2826 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ 3087 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */
3088 }
2827 break; 3089 break;
2828#endif
2829 } 3090 }
2830} 3091}
2831#endif 3092#endif
2832 3093
2833/*----------------------------------------------------------------------*/ 3094/*----------------------------------------------------------------------*/
2844 unicode_t ch; 3105 unicode_t ch;
2845 unsigned char string[STRING_MAX]; 3106 unsigned char string[STRING_MAX];
2846 3107
2847 while ((ch = cmd_getc ())) 3108 while ((ch = cmd_getc ()))
2848 { 3109 {
2849 if (ch == C0_BEL 3110 if (ch == C0_BEL || ch == CHAR_ST)
2850 || ch == CHAR_ST 3111 break;
3112
3113 if (seen_esc)
2851 || (ch == 0x5c && seen_esc)) /* 7bit ST */ 3114 if (ch == 0x5c) /* 7bit ST */
2852 break; 3115 break;
3116 else
3117 return NULL;
2853 3118
2854 if (ch == C0_ESC) 3119 if (ch == C0_ESC)
2855 { 3120 {
2856 seen_esc = 1; 3121 seen_esc = 1;
2857 continue; 3122 continue;
2858 } 3123 }
2859 else if (ch == '\t') 3124 else if (ch == '\t')
2860 ch = ' '; /* translate '\t' to space */ 3125 ch = ' '; /* translate '\t' to space */
2861 else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) 3126 else if (ch < 0x20 && (ch != 0x0a && ch != 0x0d))
2862 return NULL; /* other control character - exit */ 3127 return NULL; /* other control character - exit */
2863 3128
2864 if (n < sizeof (string) - 1) 3129 if (n >= sizeof (string) - 1)
3130 // stop at some sane length
3131 return NULL;
3132
2865 string[n++] = ch; 3133 string[n++] = ch;
2866
2867 seen_esc = 0; 3134 seen_esc = 0;
2868 } 3135 }
2869 3136
2870 string[n++] = '\0'; 3137 string[n++] = '\0';
2871 3138
2915 { 3182 {
2916 unsigned char *s = get_to_st (eh); 3183 unsigned char *s = get_to_st (eh);
2917 3184
2918 if (s) 3185 if (s)
2919 { 3186 {
2920 /*
2921 * rxvt_menubar_dispatch () violates the constness of the string,
2922 * so do it here
2923 */
2924 if (arg == XTerm_Menu)
2925#if 0 /* XXX: currently disabled due to security concerns */
2926 menubar_dispatch ((char *)s);
2927#else
2928 (void)0;
2929#endif
2930 else
2931 xterm_seq (arg, (char *)s, eh); 3187 process_xterm_seq (arg, (char *)s, eh);
2932
2933 free (s); 3188 free (s);
2934 } 3189 }
2935 } 3190 }
2936} 3191}
3192
3193void
3194rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp)
3195{
3196 if (str[0] == '?' && !str[1])
3197 {
3198 if (Options & Opt_insecure)
3199 {
3200 unsigned short r, g, b;
3201 PixColors[color].get (display, r, g, b);
3202 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp);
3203 }
3204 }
3205 else
3206 set_window_color (color, str);
3207}
3208
2937/* 3209/*
2938 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3210 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
2939 * 0 = change iconName/title 3211 * 0 = change iconName/title
2940 * 1 = change iconName 3212 * 1 = change iconName
2941 * 2 = change title 3213 * 2 = change title
2942 * 4 = change color 3214 * 4 = change color
3215 * 10 = change fg color
3216 * 11 = change bg color
2943 * 12 = change text color 3217 * 12 = change text color
2944 * 13 = change mouse foreground color 3218 * 13 = change mouse foreground color
2945 * 17 = change highlight character colour 3219 * 17 = change highlight character colour
2946 * 18 = change bold character color 3220 * 18 = change bold character color
2947 * 19 = change underlined character color 3221 * 19 = change underlined character color
2948 * 46 = change logfile (not implemented) 3222 * 46 = change logfile (not implemented)
2949 * 50 = change font 3223 * 50 = change font
2950 * 3224 *
2951 * rxvt extensions: 3225 * rxvt extensions:
2952 * 10 = menu (may change in future)
2953 * 20 = bg pixmap 3226 * 20 = bg pixmap
2954 * 39 = change default fg color 3227 * 39 = change default fg color
2955 * 49 = change default bg color 3228 * 49 = change default bg color
2956 * 55 = dump scrollback buffer and all of screen 3229 * 55 = dump scrollback buffer and all of screen
2957 * 701 = change locale 3230 * 701 = change locale
2958 * 702 = find font 3231 * 702 = find font
3232 * 703 = menu
2959 */ 3233 */
2960void 3234void
2961rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) 3235rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
2962{ 3236{
2963 int changed = 0; 3237 int changed = 0;
2964 int color; 3238 int color;
2965 char *buf, *name; 3239 char *buf, *name;
3240 bool query = str[0] == '?' && !str[1];
2966 3241
2967 assert (str != NULL); 3242 assert (str != NULL);
2968 switch (op) 3243 switch (op)
2969 { 3244 {
2970 case XTerm_name: 3245 case XTerm_name:
2974 set_icon_name (str); 3249 set_icon_name (str);
2975 break; 3250 break;
2976 case XTerm_title: 3251 case XTerm_title:
2977 set_title (str); 3252 set_title (str);
2978 break; 3253 break;
3254 case XTerm_property:
3255 if (str[0] == '?')
3256 {
3257 Atom prop = XInternAtom (display->display, str + 1, True);
3258 Atom actual_type;
3259 int actual_format;
3260 unsigned long nitems;
3261 unsigned long bytes_after;
3262 unsigned char *value = 0;
3263 const char *str = "";
3264
3265 if (prop
3266 && XGetWindowProperty (display->display, TermWin.parent[0],
3267 prop, 0, 1<<16, 0, AnyPropertyType,
3268 &actual_type, &actual_format,
3269 &nitems, &bytes_after, &value) == Success
3270 && actual_type != None
3271 && actual_format == 8)
3272 str = (const char *)(value);
3273
3274 tt_printf ("\033]%d;%s%c", XTerm_property, str, resp);
3275
3276 XFree (value);
3277 }
3278 else
3279 {
3280 char *eq = strchr (str, '='); // constness lost, but verified to be ok
3281
3282 if (eq)
3283 {
3284 *eq = 0;
3285 XChangeProperty (display->display, TermWin.parent[0],
3286 display->atom (str), XA_STRING, 8,
3287 PropModeReplace, (unsigned char *)eq + 1,
3288 strlen (eq + 1));
3289 }
3290 else
3291 XDeleteProperty (display->display, TermWin.parent[0],
3292 display->atom (str));
3293 }
3294 break;
3295
2979 case XTerm_Color: 3296 case XTerm_Color:
2980 for (buf = (char *)str; buf && *buf;) 3297 for (buf = (char *)str; buf && *buf;)
2981 { 3298 {
2982 if ((name = STRCHR (buf, ';')) == NULL) 3299 if ((name = STRCHR (buf, ';')) == NULL)
2983 break; 3300 break;
2989 break; 3306 break;
2990 3307
2991 if ((buf = STRCHR (name, ';')) != NULL) 3308 if ((buf = STRCHR (name, ';')) != NULL)
2992 *buf++ = '\0'; 3309 *buf++ = '\0';
2993 3310
3311 if (name[0] == '?' && !name[1])
3312 {
3313 if (Options & Opt_insecure)
3314 {
3315 unsigned short r, g, b;
3316 PixColors[color + minCOLOR].get (display, r, g, b);
3317 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3318 }
3319 }
3320 else
2994 set_window_color (color + minCOLOR, name); 3321 set_window_color (color + minCOLOR, name);
2995 } 3322 }
3323 break;
3324 case XTerm_Color00:
3325 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3326 break;
3327 case XTerm_Color01:
3328 process_color_seq (XTerm_Color00, Color_bg, str, resp);
2996 break; 3329 break;
2997#ifndef NO_CURSORCOLOR 3330#ifndef NO_CURSORCOLOR
2998 case XTerm_Color_cursor: 3331 case XTerm_Color_cursor:
2999 set_window_color (Color_cursor, str); 3332 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3000 break; 3333 break;
3001#endif 3334#endif
3002 case XTerm_Color_pointer: 3335 case XTerm_Color_pointer_fg:
3003 set_window_color (Color_pointer, str); 3336 process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp);
3337 break;
3338 case XTerm_Color_pointer_bg:
3339 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3004 break; 3340 break;
3005#ifndef NO_BOLD_UNDERLINE_REVERSE 3341#ifndef NO_BOLD_UNDERLINE_REVERSE
3006 case XTerm_Color_BD: 3342 case XTerm_Color_BD:
3007 set_window_color (Color_BD, str); 3343 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3008 break; 3344 break;
3009 case XTerm_Color_UL: 3345 case XTerm_Color_UL:
3010 set_window_color (Color_UL, str); 3346 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3011 break; 3347 break;
3012 case XTerm_Color_RV: 3348 case XTerm_Color_RV:
3013 set_window_color (Color_RV, str); 3349 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3014 break; 3350 break;
3015#endif 3351#endif
3016 3352
3017 case XTerm_Menu:
3018 /*
3019 * rxvt_menubar_dispatch () violates the constness of the string,
3020 * so DON'T do it here
3021 */
3022 break;
3023 case XTerm_Pixmap: 3353 case XTerm_Pixmap:
3024 if (*str != ';') 3354 if (*str != ';')
3025 { 3355 {
3026#if XPM_BACKGROUND 3356#if XPM_BACKGROUND
3027 scale_pixmap (""); /* reset to default scaling */ 3357 scale_pixmap (""); /* reset to default scaling */
3050 set_window_color (Color_fg, str); 3380 set_window_color (Color_fg, str);
3051 break; 3381 break;
3052 case XTerm_restoreBG: 3382 case XTerm_restoreBG:
3053 set_window_color (Color_bg, str); 3383 set_window_color (Color_bg, str);
3054 break; 3384 break;
3385
3055 case XTerm_logfile: 3386 case XTerm_logfile:
3056 // TODO, when secure mode? 3387 // TODO, when secure mode?
3057 break; 3388 break;
3389
3058 case XTerm_font: 3390 case XTerm_font:
3391 if (query)
3392 {
3393 if (Options & Opt_insecure)
3394 tt_printf ("\33]%d;%-.250s%c", XTerm_font,
3395 TermWin.fontset->fontdesc
3396 ? TermWin.fontset->fontdesc
3397 : "",
3398 resp);
3399 }
3400 else
3059 change_font (str); 3401 change_font (str);
3060 break; 3402 break;
3403
3061#ifndef NO_FRILLS 3404#ifndef NO_FRILLS
3062 case XTerm_locale: 3405 case XTerm_locale:
3063 if (str[0] == '?' && !str[1]) 3406 if (query)
3064 tt_printf ("%-.250s\n", locale); 3407 {
3408 if (Options & Opt_insecure)
3409 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, locale, resp);
3410 }
3065 else 3411 else
3066 { 3412 {
3067 set_locale (str); 3413 set_locale (str);
3068# ifdef USE_XIM 3414# ifdef USE_XIM
3069 im_cb (); 3415 im_cb ();
3070# endif 3416# endif
3071 } 3417 }
3072 break; 3418 break;
3419
3073 case XTerm_findfont: 3420 case XTerm_findfont:
3421 if (Options & Opt_insecure)
3074 { 3422 {
3075 int fid = TermWin.fontset->find_font (atoi (str)); 3423 int fid = TermWin.fontset->find_font (atoi (str));
3076 tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); 3424 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont,
3425 fid, (*TermWin.fontset)[fid]->name, resp);
3077 } 3426 }
3427 break;
3428#endif
3429
3430#ifdef MENUBAR
3431 case XTerm_Menu:
3432 if (Options & Opt_insecure)
3433 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3078 break; 3434 break;
3079#endif 3435#endif
3080#if 0 3436#if 0
3081 case XTerm_dumpscreen: /* no error notices */ 3437 case XTerm_dumpscreen: /* no error notices */
3082 { 3438 {
3083 int fd; 3439 int fd;
3084 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3440 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3085 { 3441 {
3086 scr_dump (fd); 3442 scr_dump (fd);
3087 close (fd); 3443 close (fd);
3088 } 3444 }
3175 // 1035 enable modifiers for alt, numlock NYI 3531 // 1035 enable modifiers for alt, numlock NYI
3176 // 1036 send ESC for meta keys NYI 3532 // 1036 send ESC for meta keys NYI
3177 // 1037 send DEL for keypad delete NYI 3533 // 1037 send DEL for keypad delete NYI
3178 { 1047, PrivMode_Screen }, 3534 { 1047, PrivMode_Screen },
3179 // 1048 save and restore cursor 3535 // 1048 save and restore cursor
3180 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ 3536 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
3181 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3537 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3182 }; 3538 };
3183 3539
3184 if (nargs == 0) 3540 if (nargs == 0)
3185 return; 3541 return;
3204 3560
3205 /* extra handling for values with state unkept */ 3561 /* extra handling for values with state unkept */
3206 switch (arg[i]) 3562 switch (arg[i])
3207 { 3563 {
3208 case 1048: /* alternative cursor save */ 3564 case 1048: /* alternative cursor save */
3209 case 1049: 3565 if (Options & Opt_secondaryScreen)
3210 if (mode == 0) 3566 if (mode == 0)
3211 scr_cursor (RESTORE); 3567 scr_cursor (RESTORE);
3212 else if (mode == 1) 3568 else if (mode == 1)
3213 scr_cursor (SAVE); 3569 scr_cursor (SAVE);
3214 /* FALLTHROUGH */ 3570 break;
3215 } 3571 }
3216 3572
3217 if (state >= 0) 3573 if (state >= 0)
3218 /* extra handling for values with valid 0 or 1 state */ 3574 /* extra handling for values with valid 0 or 1 state */
3219 switch (arg[i]) 3575 switch (arg[i])
3243 scr_relative_origin (state); 3599 scr_relative_origin (state);
3244 break; 3600 break;
3245 case 7: /* autowrap */ 3601 case 7: /* autowrap */
3246 scr_autowrap (state); 3602 scr_autowrap (state);
3247 break; 3603 break;
3248 /* case 8: - auto repeat, can't do on a per window basis */ 3604 /* case 8: - auto repeat, can't do on a per window basis */
3249 case 9: /* X10 mouse reporting */ 3605 case 9: /* X10 mouse reporting */
3250 if (state) /* orthogonal */ 3606 if (state) /* orthogonal */
3251 PrivateModes &= ~PrivMode_MouseX11; 3607 PrivateModes &= ~PrivMode_MouseX11;
3252 break; 3608 break;
3253#ifdef menuBar_esc 3609#ifdef menuBar_esc
3267 break; 3623 break;
3268#endif 3624#endif
3269 case 25: /* visible/invisible cursor */ 3625 case 25: /* visible/invisible cursor */
3270 scr_cursor_visible (state); 3626 scr_cursor_visible (state);
3271 break; 3627 break;
3272 /* case 35: - shift keys */ 3628 /* case 35: - shift keys */
3273 /* case 40: - 80 <--> 132 mode */ 3629 /* case 40: - 80 <--> 132 mode */
3274 case 47: /* secondary screen */ 3630 case 47: /* secondary screen */
3275 scr_change_screen (state); 3631 scr_change_screen (state);
3276 break; 3632 break;
3277 /* case 66: - application key pad */ 3633 /* case 66: - application key pad */
3278 /* case 67: - backspace key */ 3634 /* case 67: - backspace key */
3279 case 1000: /* X11 mouse reporting */ 3635 case 1000: /* X11 mouse reporting */
3280 if (state) /* orthogonal */ 3636 if (state) /* orthogonal */
3281 PrivateModes &= ~PrivMode_MouseX10; 3637 PrivateModes &= ~PrivMode_MouseX10;
3282 break; 3638 break;
3283#if 0 3639#if 0
3294 if (state) 3650 if (state)
3295 Options |= Opt_scrollTtyKeypress; 3651 Options |= Opt_scrollTtyKeypress;
3296 else 3652 else
3297 Options &= ~Opt_scrollTtyKeypress; 3653 Options &= ~Opt_scrollTtyKeypress;
3298 break; 3654 break;
3299 case 1047: /* secondary screen w/ clearing */ 3655 case 1047: /* secondary screen w/ clearing last */
3300 case 1049: /* better secondary screen w/ clearing, but not fully implemented */ 3656 if (Options & Opt_secondaryScreen)
3301 if (current_screen != PRIMARY) 3657 if (current_screen != PRIMARY)
3302 scr_erase_screen (2); 3658 scr_erase_screen (2);
3303
3304 scr_change_screen (state); 3659 scr_change_screen (state);
3305 /* FALLTHROUGH */ 3660 break;
3661 case 1049: /* secondary screen w/ clearing first */
3662 scr_change_screen (state);
3663 if (Options & Opt_secondaryScreen)
3664 if (current_screen != PRIMARY)
3665 scr_erase_screen (2);
3666 break;
3306 default: 3667 default:
3307 break; 3668 break;
3308 } 3669 }
3309 } 3670 }
3310} 3671}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines