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.93 by pcg, Thu Apr 8 20:31:45 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: command.c 2 * File: command.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> 6 * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk>
7 * - original version 7 * - original version
672 scr_refresh (refresh_type); 672 scr_refresh (refresh_type);
673 scrollbar_show (1); 673 scrollbar_show (1);
674#ifdef USE_XIM 674#ifdef USE_XIM
675 IMSendSpot (); 675 IMSendSpot ();
676#endif 676#endif
677
678 } 677 }
679 678
680 display->flush (); 679 display->flush ();
681} 680}
682 681
715 714
716bool 715bool
717rxvt_term::pty_fill () 716rxvt_term::pty_fill ()
718{ 717{
719 ssize_t n = cmdbuf_endp - cmdbuf_ptr; 718 ssize_t n = cmdbuf_endp - cmdbuf_ptr;
719
720 if (CBUFSIZ == n)
721 {
722 rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n");
723 n = 0;
724 }
720 725
721 memmove (cmdbuf_base, cmdbuf_ptr, n); 726 memmove (cmdbuf_base, cmdbuf_ptr, n);
722 cmdbuf_ptr = cmdbuf_base; 727 cmdbuf_ptr = cmdbuf_base;
723 cmdbuf_endp = cmdbuf_ptr + n; 728 cmdbuf_endp = cmdbuf_ptr + n;
724 729
742 SET_LOCALE (locale); 747 SET_LOCALE (locale);
743 748
744 if (revents & EVENT_WRITE) 749 if (revents & EVENT_WRITE)
745 tt_write (0, 0); 750 tt_write (0, 0);
746 else if (revents & EVENT_READ) 751 else if (revents & EVENT_READ)
747 {
748 // loop, but don't allow a single term to monopolize us 752 // loop, but don't allow a single term to monopolize us
749 // the number of loops is fully arbitrary, and thus wrong
750 while (pty_fill ()) 753 while (pty_fill ())
751 {
752 if (!seen_input)
753 {
754 seen_input = 1;
755 /* once we know the shell is running, send the screen size. Again! */
756 // I don't know why, btw.
757 tt_winch ();
758 }
759
760 if (cmd_parse ()) 754 if (cmd_parse ())
761 break; 755 break;
762 }
763 }
764} 756}
765 757
766#ifdef POINTER_BLANK 758#ifdef POINTER_BLANK
767void 759void
768rxvt_term::pointer_unblank () 760rxvt_term::pointer_unblank ()
1013 && (ev.xclient.data.l[0] == DndFile 1005 && (ev.xclient.data.l[0] == DndFile
1014 || ev.xclient.data.l[0] == DndDir 1006 || ev.xclient.data.l[0] == DndDir
1015 || ev.xclient.data.l[0] == DndLink)) 1007 || ev.xclient.data.l[0] == DndLink))
1016 { 1008 {
1017 /* Get Dnd data */ 1009 /* Get Dnd data */
1018 Atom ActualType; 1010 Atom ActualType;
1019 int ActualFormat; 1011 int ActualFormat;
1020 unsigned char *data; 1012 unsigned char *data;
1021 unsigned long Size, RemainingBytes; 1013 unsigned long Size, RemainingBytes;
1022 1014
1023 XGetWindowProperty (display->display, display->root, 1015 XGetWindowProperty (display->display, display->root,
1024 xa[XA_DNDSELECTION], 1016 xa[XA_DNDSELECTION],
1025 0L, 1000000L, 1017 0L, 1000000L,
1026 False, AnyPropertyType, 1018 False, AnyPropertyType,
1029 &data); 1021 &data);
1030 XChangeProperty (display->display, display->root, 1022 XChangeProperty (display->display, display->root,
1031 XA_CUT_BUFFER0, XA_STRING, 1023 XA_CUT_BUFFER0, XA_STRING,
1032 8, PropModeReplace, 1024 8, PropModeReplace,
1033 data, STRLEN (data)); 1025 data, STRLEN (data));
1026 XFree (data);
1034 selection_paste (display->root, XA_CUT_BUFFER0, True); 1027 selection_paste (display->root, XA_CUT_BUFFER0, True);
1035 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); 1028 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime);
1036 } 1029 }
1037#endif /* OFFIX_DND */ 1030#endif /* OFFIX_DND */
1038 break; 1031 break;
1131 check_our_parents (); 1124 check_our_parents ();
1132 if (am_transparent) 1125 if (am_transparent)
1133 want_full_refresh = 1; 1126 want_full_refresh = 1;
1134 } 1127 }
1135#endif 1128#endif
1136
1137 } 1129 }
1138 break; 1130 break;
1139 1131
1140 case SelectionClear: 1132 case SelectionClear:
1141 selection_clear (); 1133 selection_clear ();
1345 return; 1337 return;
1346 } 1338 }
1347 1339
1348 /* FALLTHROUGH */ 1340 /* FALLTHROUGH */
1349 case ReparentNotify: 1341 case ReparentNotify:
1350 if ((Options & Opt_transparent) && check_our_parents ()) 1342 if ((Options & Opt_transparent) && check_our_parents () && am_transparent)
1351 if (am_transparent)
1352 want_full_refresh = 1; 1343 want_full_refresh = 1;
1353 break; 1344 break;
1354#endif 1345#endif
1355 } 1346 }
1356} 1347}
1357 1348
1701 else if (isMenuBarWindow (ev.window)) 1692 else if (isMenuBarWindow (ev.window))
1702 menubar_control (ev); 1693 menubar_control (ev);
1703#endif 1694#endif
1704} 1695}
1705 1696
1706
1707#ifdef TRANSPARENT 1697#ifdef TRANSPARENT
1698#if TINTING
1699/* shading taken from eterm-0.9.2 */
1700/* RGB 15 */
1701
1702static void
1703shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1704{
1705 unsigned char *ptr;
1706 int x, y;
1707
1708 ptr = (unsigned char *)data + (w * sizeof(uint16_t));
1709 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1710 /* No saturation */
1711 for (y = h; --y >= 0;) {
1712 for (x = -w; x < 0; x++) {
1713 int r, g, b;
1714
1715 b = ((uint16_t *) ptr)[x];
1716 r = (b & 0x7c00) * rm;
1717 g = (b & 0x3e0) * gm;
1718 b = (b & 0x1f) * bm;
1719 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00)
1720 | ((g >> 8) & 0x3e0)
1721 | ((b >> 8) & 0x1f);
1722 }
1723 ptr += bpl;
1724 }
1725 } else {
1726 for (y = h; --y >= 0;) {
1727 for (x = -w; x < 0; x++) {
1728 int r, g, b;
1729
1730 b = ((uint16_t *) ptr)[x];
1731 r = (b & 0x7c00) * rm;
1732 g = (b & 0x3e0) * gm;
1733 b = (b & 0x1f) * bm;
1734 r |= (!(r >> 15) - 1);
1735 g |= (!(g >> 10) - 1);
1736 b |= (!(b >> 5) - 1);
1737 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00)
1738 | ((g >> 8) & 0x3e0)
1739 | ((b >> 8) & 0x1f);
1740 }
1741 ptr += bpl;
1742 }
1743 }
1744}
1745
1746/* RGB 16 */
1747static void
1748shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1749{
1750 unsigned char *ptr;
1751 int x, y;
1752
1753 ptr = (unsigned char *)data + (w * sizeof(uint16_t));
1754 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1755 /* No saturation */
1756 for (y = h; --y >= 0;) {
1757 for (x = -w; x < 0; x++) {
1758 int r, g, b;
1759
1760 b = ((uint16_t *) ptr)[x];
1761 r = (b & 0xf800) * rm;
1762 g = (b & 0x7e0) * gm;
1763 b = (b & 0x1f) * bm;
1764 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1765 | ((g >> 8) & 0x7e0)
1766 | ((b >> 8) & 0x1f);
1767 }
1768 ptr += bpl;
1769 }
1770 } else {
1771 for (y = h; --y >= 0;) {
1772 for (x = -w; x < 0; x++) {
1773 int r, g, b;
1774
1775 b = ((uint16_t *) ptr)[x];
1776 r = (b & 0xf800) * rm;
1777 g = (b & 0x7e0) * gm;
1778 b = (b & 0x1f) * bm;
1779 r |= (!(r >> 16) - 1);
1780 g |= (!(g >> 11) - 1);
1781 b |= (!(b >> 5) - 1);
1782 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1783 | ((g >> 8) & 0x7e0)
1784 | ((b >> 8) & 0x1f);
1785 }
1786 ptr += bpl;
1787 }
1788 }
1789}
1790
1791/* RGB 24 */
1792static void
1793shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1794{
1795 unsigned char *ptr;
1796 int x, y;
1797
1798 ptr = (unsigned char *)data + (w * 3);
1799 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1800 /* No saturation */
1801 for (y = h; --y >= 0;) {
1802 for (x = -(w * 3); x < 0; x += 3) {
1803 int r, g, b;
1804
1805 if (byteorder.big_endian()) {
1806 r = (ptr[x + 0] * rm) >> 8;
1807 g = (ptr[x + 1] * gm) >> 8;
1808 b = (ptr[x + 2] * bm) >> 8;
1809 ptr[x + 0] = r;
1810 ptr[x + 1] = g;
1811 ptr[x + 2] = b;
1812 } else {
1813 r = (ptr[x + 2] * rm) >> 8;
1814 g = (ptr[x + 1] * gm) >> 8;
1815 b = (ptr[x + 0] * bm) >> 8;
1816 ptr[x + 2] = r;
1817 ptr[x + 1] = g;
1818 ptr[x + 0] = b;
1819 }
1820 }
1821 ptr += bpl;
1822 }
1823 } else {
1824 for (y = h; --y >= 0;) {
1825 for (x = -(w * 3); x < 0; x += 3) {
1826 int r, g, b;
1827
1828 if (byteorder.big_endian()) {
1829 r = (ptr[x + 0] * rm) >> 8;
1830 g = (ptr[x + 1] * gm) >> 8;
1831 b = (ptr[x + 2] * bm) >> 8;
1832
1833 r |= (!(r >> 8) - 1);
1834 g |= (!(g >> 8) - 1);
1835 b |= (!(b >> 8) - 1);
1836
1837 ptr[x + 0] = r;
1838 ptr[x + 1] = g;
1839 ptr[x + 2] = b;
1840 } else {
1841 r = (ptr[x + 2] * rm) >> 8;
1842 g = (ptr[x + 1] * gm) >> 8;
1843 b = (ptr[x + 0] * bm) >> 8;
1844
1845 r |= (!(r >> 8) - 1);
1846 g |= (!(g >> 8) - 1);
1847 b |= (!(b >> 8) - 1);
1848
1849 ptr[x + 2] = r;
1850 ptr[x + 1] = g;
1851 ptr[x + 0] = b;
1852 }
1853 }
1854 ptr += bpl;
1855 }
1856 }
1857}
1858
1859/* RGB 32 */
1860static void
1861shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1862{
1863 unsigned char *ptr;
1864 int x, y;
1865
1866 ptr = (unsigned char *)data + (w * 4);
1867 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1868 /* No saturation */
1869 for (y = h; --y >= 0;) {
1870 if (byteorder.big_endian()) {
1871 for (x = -(w * 4); x < 0; x += 4) {
1872 int r, g, b;
1873
1874 r = (ptr[x + 1] * rm) >> 8;
1875 g = (ptr[x + 2] * gm) >> 8;
1876 b = (ptr[x + 3] * bm) >> 8;
1877 ptr[x + 1] = r;
1878 ptr[x + 2] = g;
1879 ptr[x + 3] = b;
1880 }
1881 } else {
1882 for (x = -(w * 4); x < 0; x += 4) {
1883 int r, g, b;
1884
1885 r = (ptr[x + 2] * rm) >> 8;
1886 g = (ptr[x + 1] * gm) >> 8;
1887 b = (ptr[x + 0] * bm) >> 8;
1888 ptr[x + 2] = r;
1889 ptr[x + 1] = g;
1890 ptr[x + 0] = b;
1891 }
1892 }
1893 ptr += bpl;
1894 }
1895 } else {
1896 for (y = h; --y >= 0;) {
1897 for (x = -(w * 4); x < 0; x += 4) {
1898 int r, g, b;
1899
1900 if (byteorder.big_endian()) {
1901 r = (ptr[x + 1] * rm) >> 8;
1902 g = (ptr[x + 2] * gm) >> 8;
1903 b = (ptr[x + 3] * bm) >> 8;
1904
1905 r |= (!(r >> 8) - 1);
1906 g |= (!(g >> 8) - 1);
1907 b |= (!(b >> 8) - 1);
1908
1909 ptr[x + 1] = r;
1910 ptr[x + 2] = g;
1911 ptr[x + 3] = b;
1912 } else {
1913 r = (ptr[x + 2] * rm) >> 8;
1914 g = (ptr[x + 1] * gm) >> 8;
1915 b = (ptr[x + 0] * bm) >> 8;
1916
1917 r |= (!(r >> 8) - 1);
1918 g |= (!(g >> 8) - 1);
1919 b |= (!(b >> 8) - 1);
1920
1921 ptr[x + 2] = r;
1922 ptr[x + 1] = g;
1923 ptr[x + 0] = b;
1924 }
1925 }
1926 ptr += bpl;
1927 }
1928 }
1929}
1930
1931#endif
1932
1708/* 1933/*
1709 * Check our parents are still who we think they are. 1934 * Check our parents are still who we think they are.
1710 * Do transparency updates if required 1935 * Do transparency updates if required
1711 */ 1936 */
1712int 1937int
1713rxvt_term::check_our_parents () 1938rxvt_term::check_our_parents ()
1714{ 1939{
1715 int i, pchanged, aformat, have_pixmap, rootdepth; 1940 int i, pchanged, aformat, have_pixmap, rootdepth;
1716 unsigned long nitems, bytes_after; 1941 unsigned long nitems, bytes_after;
1717 Atom atype; 1942 Atom atype;
1718 unsigned char *prop = NULL; 1943 unsigned char *prop = NULL;
1719 Window root, oldp, *list; 1944 Window root, oldp, *list;
1720 Pixmap rootpixmap = None; 1945 Pixmap rootpixmap = None;
1721 XWindowAttributes wattr, wrootattr; 1946 XWindowAttributes wattr, wrootattr;
1722 1947
1723 pchanged = 0; 1948 pchanged = 0;
1724 1949
1725 if (! (Options & Opt_transparent)) 1950 if (!(Options & Opt_transparent))
1726 return pchanged; /* Don't try any more */ 1951 return pchanged; /* Don't try any more */
1727 1952
1728 XGetWindowAttributes (display->display, display->root, &wrootattr); 1953 XGetWindowAttributes (display->display, display->root, &wrootattr);
1729 rootdepth = wrootattr.depth; 1954 rootdepth = wrootattr.depth;
1730 1955
1731 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 1956 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
1957
1732 if (rootdepth != wattr.depth) 1958 if (rootdepth != wattr.depth)
1733 { 1959 {
1734 if (am_transparent) 1960 if (am_transparent)
1735 { 1961 {
1736 pchanged = 1; 1962 pchanged = 1;
1737 XSetWindowBackground (display->display, TermWin.vt, 1963 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
1738 PixColors[Color_bg]);
1739 am_transparent = am_pixmap_trans = 0; 1964 am_transparent = am_pixmap_trans = 0;
1740 } 1965 }
1966
1741 return pchanged; /* Don't try any more */ 1967 return pchanged; /* Don't try any more */
1742 } 1968 }
1743 1969
1744 /* Get all X ops out of the queue so that our information is up-to-date. */ 1970 /* Get all X ops out of the queue so that our information is up-to-date. */
1745 XSync (display->display, False); 1971 XSync (display->display, False);
1747 /* 1973 /*
1748 * Make the frame window set by the window manager have 1974 * Make the frame window set by the window manager have
1749 * the root background. Some window managers put multiple nested frame 1975 * the root background. Some window managers put multiple nested frame
1750 * windows for each client, so we have to take care about that. 1976 * windows for each client, so we have to take care about that.
1751 */ 1977 */
1752 i = (xa[XA_XROOTPMAPID] != 0 1978 i = (xa[XA_XROOTPMAPID]
1753 && (XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], 1979 && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID],
1754 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 1980 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1755 &nitems, &bytes_after, &prop) == Success)); 1981 &nitems, &bytes_after, &prop) == Success);
1982
1983 if (!i || prop == NULL)
1984 i = (xa[XA_XSETROOTID]
1985 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID],
1986 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
1987 &nitems, &bytes_after, &prop) == Success);
1988
1756 if (!i || prop == NULL) 1989 if (!i || prop == NULL)
1757 have_pixmap = 0; 1990 have_pixmap = 0;
1758 else 1991 else
1759 { 1992 {
1760 have_pixmap = 1; 1993 have_pixmap = 1;
1761 rootpixmap = * ((Pixmap *)prop); 1994 rootpixmap = *(Pixmap *)prop;
1762 XFree (prop); 1995 XFree (prop);
1763 } 1996 }
1997
1764 if (have_pixmap) 1998 if (have_pixmap)
1765 { 1999 {
1766 /* 2000 /*
1767 * Copy display->root pixmap transparency 2001 * Copy display->root pixmap transparency
1768 */ 2002 */
1772 XImage *image; 2006 XImage *image;
1773 GC gc; 2007 GC gc;
1774 XGCValues gcvalue; 2008 XGCValues gcvalue;
1775 2009
1776 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 2010 XTranslateCoordinates (display->display, TermWin.parent[0], display->root,
1777 0, 0, &sx, &sy, &cr); 2011 0, 0, &sx, &sy, &cr);
1778 nw = (unsigned int)szHint.width; 2012 nw = (unsigned int)szHint.width;
1779 nh = (unsigned int)szHint.height; 2013 nh = (unsigned int)szHint.height;
1780 nx = ny = 0; 2014 nx = ny = 0;
1781 2015
1782 if (sx < 0) 2016 if (sx < 0)
1794 } 2028 }
1795 2029
1796 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2030 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
1797 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2031 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
1798 allowedxerror = -1; 2032 allowedxerror = -1;
1799 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, 2033 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
1800 ZPixmap); 2034
1801 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2035 /* XXX: handle BadMatch - usually because we're outside the pixmap */
1802 /* XXX: may need a delay here? */ 2036 /* XXX: may need a delay here? */
1803 allowedxerror = 0; 2037 allowedxerror = 0;
2038
1804 if (image == NULL) 2039 if (image == NULL)
1805 { 2040 {
1806 if (am_transparent && am_pixmap_trans) 2041 if (am_transparent && am_pixmap_trans)
1807 { 2042 {
1808 pchanged = 1; 2043 pchanged = 1;
1810 { 2045 {
1811 XFreePixmap (display->display, TermWin.pixmap); 2046 XFreePixmap (display->display, TermWin.pixmap);
1812 TermWin.pixmap = None; 2047 TermWin.pixmap = None;
1813 } 2048 }
1814 } 2049 }
2050
1815 am_pixmap_trans = 0; 2051 am_pixmap_trans = 0;
1816 } 2052 }
1817 else 2053 else
1818 { 2054 {
1819 if (TermWin.pixmap != None) 2055 if (TermWin.pixmap != None)
1820 XFreePixmap (display->display, TermWin.pixmap); 2056 XFreePixmap (display->display, TermWin.pixmap);
2057
2058#if TINTING
2059 if (ISSET_PIXCOLOR (Color_tint))
2060 {
2061 unsigned short shade, rm, gm, bm;
2062
2063 PixColors[Color_tint].get (display, rm, gm, bm);
2064
2065 rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but...
2066
2067 /* Determine bitshift and bitmask values */
2068 switch (image->bits_per_pixel)
2069 {
2070 case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2071 case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2072 case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2073 case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2074 }
2075 }
2076#endif
2077
1821 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 2078 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
1822 (unsigned int)szHint.width,
1823 (unsigned int)szHint.height, 2079 szHint.width, szHint.height, image->depth);
1824 (unsigned int)image->depth);
1825 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); 2080 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue);
1826 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, 2081 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0,
1827 nx, ny, (unsigned int)image->width,
1828 (unsigned int)image->height); 2082 nx, ny, image->width, image->height);
1829 XFreeGC (display->display, gc); 2083 XFreeGC (display->display, gc);
1830 XDestroyImage (image); 2084 XDestroyImage (image);
1831 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2085 XSetWindowBackgroundPixmap (display->display, TermWin.vt,
1832 TermWin.pixmap); 2086 TermWin.pixmap);
2087
1833 if (!am_transparent || !am_pixmap_trans) 2088 if (!am_transparent || !am_pixmap_trans)
1834 pchanged = 1; 2089 pchanged = 1;
2090
1835 am_transparent = am_pixmap_trans = 1; 2091 am_transparent = am_pixmap_trans = 1;
1836 } 2092 }
1837 } 2093 }
1838 2094
1839 if (!am_pixmap_trans) 2095 if (!am_pixmap_trans)
1840 { 2096 {
1841 unsigned int n; 2097 unsigned int n;
1842 /* 2098 /*
1843 * InheritPixmap transparency 2099 * InheritPixmap transparency
1844 */ 2100 */
1845 D_X ((stderr, "InheritPixmap Seeking to %08lx", display->root)); 2101 D_X ((stderr, "InheritPixmap Seeking to %08lx", display->root));
1846 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); 2102 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
1847 i++)
1848 { 2103 {
1849 oldp = TermWin.parent[i]; 2104 oldp = TermWin.parent[i];
1850 XQueryTree (display->display, TermWin.parent[i - 1], &root, 2105 XQueryTree (display->display, TermWin.parent[i - 1], &root,
1851 &TermWin.parent[i], &list, &n); 2106 &TermWin.parent[i], &list, &n);
1852 XFree (list); 2107 XFree (list);
1853 D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i])); 2108 D_X ((stderr, "InheritPixmap Parent[%d] = %08lx", i, TermWin.parent[i]));
2109
1854 if (TermWin.parent[i] == display->root) 2110 if (TermWin.parent[i] == display->root)
1855 { 2111 {
1856 if (oldp != None) 2112 if (oldp != None)
1857 pchanged = 1; 2113 pchanged = 1;
2114
1858 break; 2115 break;
1859 } 2116 }
2117
1860 if (oldp != TermWin.parent[i]) 2118 if (oldp != TermWin.parent[i])
1861 pchanged = 1; 2119 pchanged = 1;
1862 } 2120 }
1863 2121
1864 n = 0; 2122 n = 0;
1875 break; 2133 break;
1876 } 2134 }
1877 } 2135 }
1878 } 2136 }
1879 2137
1880 if (n > (int) (sizeof (TermWin.parent) 2138 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
1881 / sizeof (TermWin.parent[0])))
1882 { 2139 {
1883 D_X ((stderr, "InheritPixmap Turning off")); 2140 D_X ((stderr, "InheritPixmap Turning off"));
1884 XSetWindowBackground (display->display, TermWin.parent[0], 2141 XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]);
1885 PixColors[Color_fg]);
1886 XSetWindowBackground (display->display, TermWin.vt, 2142 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]);
1887 PixColors[Color_bg]);
1888 am_transparent = 0; 2143 am_transparent = 0;
1889 /* XXX: also turn off Opt_transparent? */ 2144 /* XXX: also turn off Opt_transparent? */
1890 } 2145 }
1891 else 2146 else
1892 { 2147 {
2148#if WAIT_FOR_WM
1893 /* wait (an arbitrary period) for the WM to do its thing 2149 /* wait (an arbitrary period) for the WM to do its thing
1894 * needed for fvwm2.2.2 (and before?) */ 2150 * 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); 2151 sleep (1);
1903# endif 2152#endif
1904 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); 2153 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
1905 for (n = 0; n < (unsigned int)i; n++) 2154 for (n = 0; n < (unsigned int)i; n++)
1906 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], 2155 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
1907 ParentRelative); 2156
1908 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2157 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
1909 ParentRelative);
1910 am_transparent = 1; 2158 am_transparent = 1;
1911 } 2159 }
1912 2160
1913 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2161 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
1914 TermWin.parent[i] = None; 2162 TermWin.parent[i] = None;
1915 } 2163 }
2164
1916 return pchanged; 2165 return pchanged;
1917} 2166}
1918#endif 2167#endif
1919 2168
1920/*}}} */ 2169/*}}} */
1935 } 2184 }
1936 2185
1937 if (ch == NOCHAR) // TODO: improve 2186 if (ch == NOCHAR) // TODO: improve
1938 break; 2187 break;
1939 2188
1940 if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') 2189 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)
1941 { 2190 {
1942 /* Read a text string from the input buffer */ 2191 /* Read a text string from the input buffer */
1943 unicode_t buf[UBUFSIZ]; 2192 unicode_t buf[UBUFSIZ];
1944 bool refreshnow = false; 2193 bool refreshnow = false;
1945 int nlines = 0; 2194 int nlines = 0;
1950 for (;;) 2199 for (;;)
1951 { 2200 {
1952 seq_begin = cmdbuf_ptr; 2201 seq_begin = cmdbuf_ptr;
1953 ch = next_char (); 2202 ch = next_char ();
1954 2203
1955 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) 2204 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
1956 break; 2205 break;
1957 2206
1958 *str++ = ch; 2207 *str++ = ch;
1959 2208
1960 if (ch == '\n') 2209 if (ch == C0_LF)
1961 { 2210 {
1962 nlines++; 2211 nlines++;
1963 refresh_count++; 2212 refresh_count++;
1964 2213
1965 if (! (Options & Opt_jumpScroll) 2214 if (! (Options & Opt_jumpScroll)
2000 */ 2249 */
2001 if (refreshnow) 2250 if (refreshnow)
2002 { 2251 {
2003 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2252 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2004 refresh_limit++; 2253 refresh_limit++;
2005 2254 else
2006 scr_refresh (refresh_type); 2255 scr_refresh (refresh_type);
2007 } 2256 }
2008 2257
2009 } 2258 }
2010 else 2259 else
2011 { 2260 {
2156/*}}} */ 2405/*}}} */
2157 2406
2158/* *INDENT-OFF* */ 2407/* *INDENT-OFF* */
2159enum { 2408enum {
2160 C1_40 = 0x40, 2409 C1_40 = 0x40,
2161 C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA, 2410 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, 2411 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, 2412 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 2413 C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC,
2165}; 2414};
2166/* *INDENT-ON* */ 2415/* *INDENT-ON* */
2167 2416
2168/*{{{ process non-printing single characters */ 2417/*{{{ process non-printing single characters */
2169void 2418void
2174 case C0_ESC: 2423 case C0_ESC:
2175 process_escape_seq (); 2424 process_escape_seq ();
2176 break; 2425 break;
2177 case C0_ENQ: /* terminal Status */ 2426 case C0_ENQ: /* terminal Status */
2178 if (rs[Rs_answerbackstring]) 2427 if (rs[Rs_answerbackstring])
2179 tt_write (
2180 (const unsigned char *)rs[Rs_answerbackstring], 2428 tt_write ((const unsigned char *)rs[Rs_answerbackstring],
2181 (unsigned int)STRLEN (rs[Rs_answerbackstring])); 2429 (unsigned int)STRLEN (rs[Rs_answerbackstring]));
2182 else 2430 else
2183 tt_write ((unsigned char *)VT100_ANS, 2431 tt_write ((unsigned char *)VT100_ANS,
2184 (unsigned int)STRLEN (VT100_ANS)); 2432 (unsigned int)STRLEN (VT100_ANS));
2185 break; 2433 break;
2186 case C0_BEL: /* bell */ 2434 case C0_BEL: /* bell */
2187 scr_bell (); 2435 scr_bell ();
2188 break; 2436 break;
2189 case C0_BS: /* backspace */ 2437 case C0_BS: /* backspace */
2342 break; 2590 break;
2343 2591
2344 /* 8.3.87: NEXT LINE */ 2592 /* 8.3.87: NEXT LINE */
2345 case C1_NEL: /* ESC E */ 2593 case C1_NEL: /* ESC E */
2346 { 2594 {
2347 unicode_t nlcr[] = { L'\n', L'\r' }; 2595 unicode_t nlcr[] = { C0_LF, C0_CR };
2348 scr_add_lines (nlcr, 1, 2); 2596 scr_add_lines (nlcr, 1, 2);
2349 } 2597 }
2350 break; 2598 break;
2351 2599
2352 /* kidnapped escape sequence: Should be 8.3.48 */ 2600 /* kidnapped escape sequence: Should be 8.3.48 */
2363 case C1_RI: /* ESC M */ 2611 case C1_RI: /* ESC M */
2364 scr_index (DN); 2612 scr_index (DN);
2365 break; 2613 break;
2366 2614
2367 /* 8.3.142: SINGLE-SHIFT TWO */ 2615 /* 8.3.142: SINGLE-SHIFT TWO */
2368 /*case C1_SS2: scr_single_shift (2); break; */ 2616 /*case C1_SS2: scr_single_shift (2); break; */
2369 2617
2370 /* 8.3.143: SINGLE-SHIFT THREE */ 2618 /* 8.3.143: SINGLE-SHIFT THREE */
2371 /*case C1_SS3: scr_single_shift (3); break; */ 2619 /*case C1_SS3: scr_single_shift (3); break; */
2372 2620
2373 /* 8.3.27: DEVICE CONTROL STRING */ 2621 /* 8.3.27: DEVICE CONTROL STRING */
2374 case C1_DCS: /* ESC P */ 2622 case C1_DCS: /* ESC P */
2375 process_dcs_seq (); 2623 process_dcs_seq ();
2376 break; 2624 break;
2391 process_osc_seq (); 2639 process_osc_seq ();
2392 break; 2640 break;
2393 2641
2394 /* 8.3.106: RESET TO INITIAL STATE */ 2642 /* 8.3.106: RESET TO INITIAL STATE */
2395 case 'c': 2643 case 'c':
2644 mbstate.reset ();
2396 scr_poweron (); 2645 scr_poweron ();
2397 scrollbar_show (1); 2646 scrollbar_show (1);
2398 break; 2647 break;
2399 2648
2400 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ 2649 /* 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, */ 2686 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, [, \, ], ^, _, */ 2687 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, */ 2688 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, */ 2689 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, */ 2690 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, {, |, }, ~, */ 2691 make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */
2443 }; 2692 };
2444/* *INDENT-ON* */ 2693/* *INDENT-ON* */
2445 2694
2446void 2695void
2447rxvt_term::process_csi_seq () 2696rxvt_term::process_csi_seq ()
2646 tt_printf ("\033[0n"); 2895 tt_printf ("\033[0n");
2647 break; 2896 break;
2648 case 6: /* CPR requested */ 2897 case 6: /* CPR requested */
2649 scr_report_position (); 2898 scr_report_position ();
2650 break; 2899 break;
2651#if defined (ENABLE_DISPLAY_ANSWER)
2652 case 7: /* unofficial extension */ 2900 case 7: /* unofficial extension */
2901 if (Options & Opt_insecure)
2653 tt_printf ("%-.250s\n", rs[Rs_display_name]); 2902 tt_printf ("%-.250s\n", rs[Rs_display_name]);
2654 break; 2903 break;
2655#endif
2656 case 8: /* unofficial extension */ 2904 case 8: /* unofficial extension */
2657 xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); 2905 process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST);
2658 break; 2906 break;
2659 } 2907 }
2660 break; 2908 break;
2661 2909
2662 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */ 2910 case CSI_TBC: /* 8.3.155: (0) TABULATION CLEAR */
2800 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3048 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
2801 break; 3049 break;
2802 case 13: /* report window position */ 3050 case 13: /* report window position */
2803 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3051 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2804 XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, 3052 XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root,
2805 -wattr.border_width, -wattr.border_width, 3053 -wattr.border_width, -wattr.border_width,
2806 &x, &y, &wdummy); 3054 &x, &y, &wdummy);
2807 tt_printf ("\033[3;%d;%dt", x, y); 3055 tt_printf ("\033[3;%d;%dt", x, y);
2808 break; 3056 break;
2809 case 14: /* report window size (pixels) */ 3057 case 14: /* report window size (pixels) */
2810 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3058 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr);
2811 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3059 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
2814 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); 3062 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol);
2815 break; 3063 break;
2816 case 19: /* report window size (chars) */ 3064 case 19: /* report window size (chars) */
2817 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); 3065 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol);
2818 break; 3066 break;
2819#if 0 /* XXX: currently disabled due to security concerns */
2820 case 20: /* report icon label */ 3067 case 20: /* report icon label */
3068 if (Options & Opt_insecure)
3069 {
3070 char *s;
2821 XGetIconName (display->display, TermWin.parent[0], &s); 3071 XGetIconName (display->display, TermWin.parent[0], &s);
2822 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ 3072 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */
3073 }
2823 break; 3074 break;
2824 case 21: /* report window title */ 3075 case 21: /* report window title */
3076 if (Options & Opt_insecure)
3077 {
3078 char *s;
2825 XFetchName (display->display, TermWin.parent[0], &s); 3079 XFetchName (display->display, TermWin.parent[0], &s);
2826 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ 3080 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */
3081 }
2827 break; 3082 break;
2828#endif
2829 } 3083 }
2830} 3084}
2831#endif 3085#endif
2832 3086
2833/*----------------------------------------------------------------------*/ 3087/*----------------------------------------------------------------------*/
2834/* 3088/*
2835 * get input up until STRING TERMINATOR (or BEL) 3089 * get input up until STRING TERMINATOR (or BEL)
2836 * ends_how is terminator used. returned input must be free ()d 3090 * ends_how is terminator used. returned input must be free()'d
2837 */ 3091 */
2838unsigned char * 3092unsigned char *
2839rxvt_term::get_to_st (unicode_t &ends_how) 3093rxvt_term::get_to_st (unicode_t &ends_how)
2840{ 3094{
2841 int seen_esc = 0; /* seen escape? */ 3095 int seen_esc = 0; /* seen escape? */
2844 unicode_t ch; 3098 unicode_t ch;
2845 unsigned char string[STRING_MAX]; 3099 unsigned char string[STRING_MAX];
2846 3100
2847 while ((ch = cmd_getc ())) 3101 while ((ch = cmd_getc ()))
2848 { 3102 {
2849 if (ch == C0_BEL 3103 if (ch == C0_BEL || ch == CHAR_ST)
2850 || ch == CHAR_ST 3104 break;
3105
3106 if (seen_esc)
2851 || (ch == 0x5c && seen_esc)) /* 7bit ST */ 3107 if (ch == 0x5c) /* 7bit ST */
2852 break; 3108 break;
3109 else
3110 return NULL;
2853 3111
2854 if (ch == C0_ESC) 3112 if (ch == C0_ESC)
2855 { 3113 {
2856 seen_esc = 1; 3114 seen_esc = 1;
2857 continue; 3115 continue;
2858 } 3116 }
2859 else if (ch == '\t') 3117 else if (ch == C0_HT)
2860 ch = ' '; /* translate '\t' to space */ 3118 ch = ' '; /* translate '\t' to space */
2861 else if (ch < 0x08 || (ch > 0x0d && ch < 0x20)) 3119 else if (ch < 0x20 && (ch != C0_LF && ch != C0_CR))
2862 return NULL; /* other control character - exit */ 3120 return NULL; /* other control character - exit */
2863 3121
2864 if (n < sizeof (string) - 1) 3122 if (n >= sizeof (string) - 1)
3123 // stop at some sane length
3124 return NULL;
3125
2865 string[n++] = ch; 3126 string[n++] = ch;
2866
2867 seen_esc = 0; 3127 seen_esc = 0;
2868 } 3128 }
2869 3129
2870 string[n++] = '\0'; 3130 string[n++] = '\0';
2871 3131
2915 { 3175 {
2916 unsigned char *s = get_to_st (eh); 3176 unsigned char *s = get_to_st (eh);
2917 3177
2918 if (s) 3178 if (s)
2919 { 3179 {
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); 3180 process_xterm_seq (arg, (char *)s, eh);
2932
2933 free (s); 3181 free (s);
2934 } 3182 }
2935 } 3183 }
2936} 3184}
3185
3186void
3187rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp)
3188{
3189 if (str[0] == '?' && !str[1])
3190 {
3191 if (Options & Opt_insecure)
3192 {
3193 unsigned short r, g, b;
3194 PixColors[color].get (display, r, g, b);
3195 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp);
3196 }
3197 }
3198 else
3199 set_window_color (color, str);
3200}
3201
2937/* 3202/*
2938 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3203 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
2939 * 0 = change iconName/title 3204 * 0 = change iconName/title
2940 * 1 = change iconName 3205 * 1 = change iconName
2941 * 2 = change title 3206 * 2 = change title
2942 * 4 = change color 3207 * 4 = change color
3208 * 10 = change fg color
3209 * 11 = change bg color
2943 * 12 = change text color 3210 * 12 = change text color
2944 * 13 = change mouse foreground color 3211 * 13 = change mouse foreground color
2945 * 17 = change highlight character colour 3212 * 17 = change highlight character colour
2946 * 18 = change bold character color 3213 * 18 = change bold character color
2947 * 19 = change underlined character color 3214 * 19 = change underlined character color
2948 * 46 = change logfile (not implemented) 3215 * 46 = change logfile (not implemented)
2949 * 50 = change font 3216 * 50 = change font
2950 * 3217 *
2951 * rxvt extensions: 3218 * rxvt extensions:
2952 * 10 = menu (may change in future)
2953 * 20 = bg pixmap 3219 * 20 = bg pixmap
2954 * 39 = change default fg color 3220 * 39 = change default fg color
2955 * 49 = change default bg color 3221 * 49 = change default bg color
2956 * 55 = dump scrollback buffer and all of screen 3222 * 55 = dump scrollback buffer and all of screen
2957 * 701 = change locale 3223 * 701 = change locale
2958 * 702 = find font 3224 * 702 = find font
3225 * 703 = menu
2959 */ 3226 */
2960void 3227void
2961rxvt_term::xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused))) 3228rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
2962{ 3229{
2963 int changed = 0; 3230 int changed = 0;
2964 int color; 3231 int color;
2965 char *buf, *name; 3232 char *buf, *name;
3233 bool query = str[0] == '?' && !str[1];
2966 3234
2967 assert (str != NULL); 3235 assert (str != NULL);
2968 switch (op) 3236 switch (op)
2969 { 3237 {
2970 case XTerm_name: 3238 case XTerm_name:
2974 set_icon_name (str); 3242 set_icon_name (str);
2975 break; 3243 break;
2976 case XTerm_title: 3244 case XTerm_title:
2977 set_title (str); 3245 set_title (str);
2978 break; 3246 break;
3247 case XTerm_property:
3248 if (str[0] == '?')
3249 {
3250 Atom prop = XInternAtom (display->display, str + 1, True);
3251 Atom actual_type;
3252 int actual_format;
3253 unsigned long nitems;
3254 unsigned long bytes_after;
3255 unsigned char *value = 0;
3256 const char *str = "";
3257
3258 if (prop
3259 && XGetWindowProperty (display->display, TermWin.parent[0],
3260 prop, 0, 1<<16, 0, AnyPropertyType,
3261 &actual_type, &actual_format,
3262 &nitems, &bytes_after, &value) == Success
3263 && actual_type != None
3264 && actual_format == 8)
3265 str = (const char *)(value);
3266
3267 tt_printf ("\033]%d;%s%c", XTerm_property, str, resp);
3268
3269 XFree (value);
3270 }
3271 else
3272 {
3273 char *eq = strchr (str, '='); // constness lost, but verified to be ok
3274
3275 if (eq)
3276 {
3277 *eq = 0;
3278 XChangeProperty (display->display, TermWin.parent[0],
3279 display->atom (str), XA_STRING, 8,
3280 PropModeReplace, (unsigned char *)eq + 1,
3281 strlen (eq + 1));
3282 }
3283 else
3284 XDeleteProperty (display->display, TermWin.parent[0],
3285 display->atom (str));
3286 }
3287 break;
3288
2979 case XTerm_Color: 3289 case XTerm_Color:
2980 for (buf = (char *)str; buf && *buf;) 3290 for (buf = (char *)str; buf && *buf;)
2981 { 3291 {
2982 if ((name = STRCHR (buf, ';')) == NULL) 3292 if ((name = STRCHR (buf, ';')) == NULL)
2983 break; 3293 break;
2989 break; 3299 break;
2990 3300
2991 if ((buf = STRCHR (name, ';')) != NULL) 3301 if ((buf = STRCHR (name, ';')) != NULL)
2992 *buf++ = '\0'; 3302 *buf++ = '\0';
2993 3303
3304 if (name[0] == '?' && !name[1])
3305 {
3306 if (Options & Opt_insecure)
3307 {
3308 unsigned short r, g, b;
3309 PixColors[color + minCOLOR].get (display, r, g, b);
3310 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3311 }
3312 }
3313 else
2994 set_window_color (color + minCOLOR, name); 3314 set_window_color (color + minCOLOR, name);
2995 } 3315 }
3316 break;
3317 case XTerm_Color00:
3318 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3319 break;
3320 case XTerm_Color01:
3321 process_color_seq (XTerm_Color00, Color_bg, str, resp);
2996 break; 3322 break;
2997#ifndef NO_CURSORCOLOR 3323#ifndef NO_CURSORCOLOR
2998 case XTerm_Color_cursor: 3324 case XTerm_Color_cursor:
2999 set_window_color (Color_cursor, str); 3325 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3000 break; 3326 break;
3001#endif 3327#endif
3002 case XTerm_Color_pointer: 3328 case XTerm_Color_pointer_fg:
3003 set_window_color (Color_pointer, str); 3329 process_color_seq (XTerm_Color_pointer_fg, Color_pointer_fg, str, resp);
3330 break;
3331 case XTerm_Color_pointer_bg:
3332 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3004 break; 3333 break;
3005#ifndef NO_BOLD_UNDERLINE_REVERSE 3334#ifndef NO_BOLD_UNDERLINE_REVERSE
3006 case XTerm_Color_BD: 3335 case XTerm_Color_BD:
3007 set_window_color (Color_BD, str); 3336 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3008 break; 3337 break;
3009 case XTerm_Color_UL: 3338 case XTerm_Color_UL:
3010 set_window_color (Color_UL, str); 3339 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3011 break; 3340 break;
3012 case XTerm_Color_RV: 3341 case XTerm_Color_RV:
3013 set_window_color (Color_RV, str); 3342 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3014 break; 3343 break;
3015#endif 3344#endif
3016 3345
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: 3346 case XTerm_Pixmap:
3024 if (*str != ';') 3347 if (*str != ';')
3025 { 3348 {
3026#if XPM_BACKGROUND 3349#if XPM_BACKGROUND
3027 scale_pixmap (""); /* reset to default scaling */ 3350 scale_pixmap (""); /* reset to default scaling */
3050 set_window_color (Color_fg, str); 3373 set_window_color (Color_fg, str);
3051 break; 3374 break;
3052 case XTerm_restoreBG: 3375 case XTerm_restoreBG:
3053 set_window_color (Color_bg, str); 3376 set_window_color (Color_bg, str);
3054 break; 3377 break;
3378
3055 case XTerm_logfile: 3379 case XTerm_logfile:
3056 // TODO, when secure mode? 3380 // TODO, when secure mode?
3057 break; 3381 break;
3382
3058 case XTerm_font: 3383 case XTerm_font:
3384 if (query)
3385 {
3386 if (Options & Opt_insecure)
3387 tt_printf ("\33]%d;%-.250s%c", XTerm_font,
3388 TermWin.fontset->fontdesc
3389 ? TermWin.fontset->fontdesc
3390 : "",
3391 resp);
3392 }
3393 else
3059 change_font (str); 3394 change_font (str);
3060 break; 3395 break;
3396
3061#ifndef NO_FRILLS 3397#ifndef NO_FRILLS
3062 case XTerm_locale: 3398 case XTerm_locale:
3063 if (str[0] == '?' && !str[1]) 3399 if (query)
3064 tt_printf ("%-.250s\n", locale); 3400 {
3401 if (Options & Opt_insecure)
3402 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, locale, resp);
3403 }
3065 else 3404 else
3066 { 3405 {
3067 set_locale (str); 3406 set_locale (str);
3068# ifdef USE_XIM 3407# ifdef USE_XIM
3069 im_cb (); 3408 im_cb ();
3070# endif 3409# endif
3071 } 3410 }
3072 break; 3411 break;
3412
3073 case XTerm_findfont: 3413 case XTerm_findfont:
3414 if (Options & Opt_insecure)
3074 { 3415 {
3075 int fid = TermWin.fontset->find_font (atoi (str)); 3416 int fid = TermWin.fontset->find_font (atoi (str));
3076 tt_printf ("%d %-.250s\n", fid, (*TermWin.fontset)[fid]->name); 3417 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont,
3418 fid, (*TermWin.fontset)[fid]->name, resp);
3077 } 3419 }
3420 break;
3421#endif
3422
3423#ifdef MENUBAR
3424 case XTerm_Menu:
3425 if (Options & Opt_insecure)
3426 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3078 break; 3427 break;
3079#endif 3428#endif
3080#if 0 3429#if 0
3081 case XTerm_dumpscreen: /* no error notices */ 3430 case XTerm_dumpscreen: /* no error notices */
3082 { 3431 {
3083 int fd; 3432 int fd;
3084 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3433 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3085 { 3434 {
3086 scr_dump (fd); 3435 scr_dump (fd);
3087 close (fd); 3436 close (fd);
3088 } 3437 }
3175 // 1035 enable modifiers for alt, numlock NYI 3524 // 1035 enable modifiers for alt, numlock NYI
3176 // 1036 send ESC for meta keys NYI 3525 // 1036 send ESC for meta keys NYI
3177 // 1037 send DEL for keypad delete NYI 3526 // 1037 send DEL for keypad delete NYI
3178 { 1047, PrivMode_Screen }, 3527 { 1047, PrivMode_Screen },
3179 // 1048 save and restore cursor 3528 // 1048 save and restore cursor
3180 { 1049, PrivMode_Screen }, /* xterm extension, not fully implemented */ 3529 { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */
3181 // 1051, 1052, 1060, 1061 keyboard emulation NYI 3530 // 1051, 1052, 1060, 1061 keyboard emulation NYI
3182 }; 3531 };
3183 3532
3184 if (nargs == 0) 3533 if (nargs == 0)
3185 return; 3534 return;
3204 3553
3205 /* extra handling for values with state unkept */ 3554 /* extra handling for values with state unkept */
3206 switch (arg[i]) 3555 switch (arg[i])
3207 { 3556 {
3208 case 1048: /* alternative cursor save */ 3557 case 1048: /* alternative cursor save */
3209 case 1049: 3558 if (Options & Opt_secondaryScreen)
3210 if (mode == 0) 3559 if (mode == 0)
3211 scr_cursor (RESTORE); 3560 scr_cursor (RESTORE);
3212 else if (mode == 1) 3561 else if (mode == 1)
3213 scr_cursor (SAVE); 3562 scr_cursor (SAVE);
3214 /* FALLTHROUGH */ 3563 break;
3215 } 3564 }
3216 3565
3217 if (state >= 0) 3566 if (state >= 0)
3218 /* extra handling for values with valid 0 or 1 state */ 3567 /* extra handling for values with valid 0 or 1 state */
3219 switch (arg[i]) 3568 switch (arg[i])
3243 scr_relative_origin (state); 3592 scr_relative_origin (state);
3244 break; 3593 break;
3245 case 7: /* autowrap */ 3594 case 7: /* autowrap */
3246 scr_autowrap (state); 3595 scr_autowrap (state);
3247 break; 3596 break;
3248 /* case 8: - auto repeat, can't do on a per window basis */ 3597 /* case 8: - auto repeat, can't do on a per window basis */
3249 case 9: /* X10 mouse reporting */ 3598 case 9: /* X10 mouse reporting */
3250 if (state) /* orthogonal */ 3599 if (state) /* orthogonal */
3251 PrivateModes &= ~PrivMode_MouseX11; 3600 PrivateModes &= ~PrivMode_MouseX11;
3252 break; 3601 break;
3253#ifdef menuBar_esc 3602#ifdef menuBar_esc
3267 break; 3616 break;
3268#endif 3617#endif
3269 case 25: /* visible/invisible cursor */ 3618 case 25: /* visible/invisible cursor */
3270 scr_cursor_visible (state); 3619 scr_cursor_visible (state);
3271 break; 3620 break;
3272 /* case 35: - shift keys */ 3621 /* case 35: - shift keys */
3273 /* case 40: - 80 <--> 132 mode */ 3622 /* case 40: - 80 <--> 132 mode */
3274 case 47: /* secondary screen */ 3623 case 47: /* secondary screen */
3275 scr_change_screen (state); 3624 scr_change_screen (state);
3276 break; 3625 break;
3277 /* case 66: - application key pad */ 3626 /* case 66: - application key pad */
3278 /* case 67: - backspace key */ 3627 /* case 67: - backspace key */
3279 case 1000: /* X11 mouse reporting */ 3628 case 1000: /* X11 mouse reporting */
3280 if (state) /* orthogonal */ 3629 if (state) /* orthogonal */
3281 PrivateModes &= ~PrivMode_MouseX10; 3630 PrivateModes &= ~PrivMode_MouseX10;
3282 break; 3631 break;
3283#if 0 3632#if 0
3294 if (state) 3643 if (state)
3295 Options |= Opt_scrollTtyKeypress; 3644 Options |= Opt_scrollTtyKeypress;
3296 else 3645 else
3297 Options &= ~Opt_scrollTtyKeypress; 3646 Options &= ~Opt_scrollTtyKeypress;
3298 break; 3647 break;
3299 case 1047: /* secondary screen w/ clearing */ 3648 case 1047: /* secondary screen w/ clearing last */
3300 case 1049: /* better secondary screen w/ clearing, but not fully implemented */ 3649 if (Options & Opt_secondaryScreen)
3301 if (current_screen != PRIMARY) 3650 if (current_screen != PRIMARY)
3302 scr_erase_screen (2); 3651 scr_erase_screen (2);
3303
3304 scr_change_screen (state); 3652 scr_change_screen (state);
3305 /* FALLTHROUGH */ 3653 break;
3654 case 1049: /* secondary screen w/ clearing first */
3655 scr_change_screen (state);
3656 if (Options & Opt_secondaryScreen)
3657 if (current_screen != PRIMARY)
3658 scr_erase_screen (2);
3659 break;
3306 default: 3660 default:
3307 break; 3661 break;
3308 } 3662 }
3309 } 3663 }
3310} 3664}
3339 rendset = 1, rendstyle = RS_Uline; 3693 rendset = 1, rendstyle = RS_Uline;
3340 break; 3694 break;
3341 case 5: 3695 case 5:
3342 rendset = 1, rendstyle = RS_Blink; 3696 rendset = 1, rendstyle = RS_Blink;
3343 break; 3697 break;
3698 //case 6: // scoansi light background
3344 case 7: 3699 case 7:
3345 rendset = 1, rendstyle = RS_RVid; 3700 rendset = 1, rendstyle = RS_RVid;
3346 break; 3701 break;
3347 case 8: 3702 case 8:
3348 // invisible. NYI 3703 // invisible. NYI
3704 break;
3705 //case 10: // scoansi acs off
3706 //case 11: // scoansi acs on
3707 //case 12: // scoansi acs on, |0x80
3708 case 21: // disable bold, blink and invis (some terminals use this)
3709 rendset = 0, rendstyle = RS_Bold | RS_Blink;
3349 break; 3710 break;
3350 case 22: 3711 case 22:
3351 rendset = 0, rendstyle = RS_Bold; 3712 rendset = 0, rendstyle = RS_Bold;
3352 break; 3713 break;
3353 case 24: 3714 case 24:
3446 } 3807 }
3447 } 3808 }
3448} 3809}
3449/*}}} */ 3810/*}}} */
3450 3811
3451/*{{{ process Rob Nation's own graphics mode sequences */ 3812/*{{{ (do not) process Rob Nation's own graphics mode sequences */
3452void 3813void
3453rxvt_term::process_graphics () 3814rxvt_term::process_graphics ()
3454{ 3815{
3455 unicode_t ch, cmd = cmd_getc (); 3816 unicode_t ch, cmd = cmd_getc ();
3456 3817

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines