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

Comparing rxvt-unicode/src/rxvtperl.xs (file contents):
Revision 1.194 by root, Thu Jun 14 17:06:57 2012 UTC vs.
Revision 1.240 by root, Thu Jun 22 23:46:38 2017 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: rxvtperl.xs 2 * File: rxvtperl.xs
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) 2005-2008,2011 Marc Lehmann <schmorp@schmorp.de> 6 * Copyright (c) 2005-2014 Marc Lehmann <schmorp@schmorp.de>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
57typedef int render_repeat_mode; 57typedef int render_repeat_mode;
58 58
59#if HAVE_PIXBUF 59#if HAVE_PIXBUF
60typedef GdkPixbuf * urxvt__pixbuf; 60typedef GdkPixbuf * urxvt__pixbuf;
61#endif 61#endif
62#if HAVE_IMG
62typedef rxvt_img * urxvt__img; 63typedef rxvt_img * urxvt__img;
64typedef rxvt_img::nv rxvt_img__nv;
63 65
64///////////////////////////////////////////////////////////////////////////// 66/////////////////////////////////////////////////////////////////////////////
65 67
66static rgba 68static rgba
67parse_rgba (SV *sv, rxvt_screen *s = 0) 69parse_rgba (SV *sv, rxvt_screen *s = 0)
68{ 70{
69 rgba c; 71 rgba c;
70 72
71 if (AV *av = (AV *)SvRV (sv)) 73 if (SvROK (sv))
72 { 74 {
75 AV *av = (AV *)SvRV (sv);
76
73 if (SvTYPE ((SV *)av) != SVt_PVAV) 77 if (SvTYPE ((SV *)av) != SVt_PVAV)
74 croak ("colour must be either a colour string, or an array,"); 78 croak ("colour must be either a colour string, or an array,");
75 79
76 int len = av_len (av) + 1; 80 int len = av_len (av) + 1;
77 81
95 { 99 {
96 rxvt_color rc; 100 rxvt_color rc;
97 rc.set (s, SvPVbyte_nolen (sv)); 101 rc.set (s, SvPVbyte_nolen (sv));
98 rc.get (c); 102 rc.get (c);
99 } 103 }
104 else
105 croak ("unable to parse colour,");
100 106
101 return c; 107 return c;
102} 108}
103 109
104///////////////////////////////////////////////////////////////////////////// 110/////////////////////////////////////////////////////////////////////////////
111#endif
105 112
106static wchar_t * 113static wchar_t *
107sv2wcs (SV *sv) 114sv2wcs (SV *sv)
108{ 115{
109 STRLEN len; 116 STRLEN len;
284 break; 291 break;
285 292
286 for (; i < AvFILL (overlay_av); i++) 293 for (; i < AvFILL (overlay_av); i++)
287 av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0))); 294 av_store (overlay_av, i, SvREFCNT_inc (*av_fetch (overlay_av, i + 1, 0)));
288 295
289 av_pop (overlay_av); 296 SvREFCNT_dec (av_pop (overlay_av));
290 297
291 SvREFCNT_dec (overlay_av); 298 SvREFCNT_dec (overlay_av);
292 overlay_av = 0; 299 overlay_av = 0;
293 300
294 THIS->want_refresh = 1; 301 THIS->want_refresh = 1;
483 490
484 FREETMPS; 491 FREETMPS;
485 LEAVE; 492 LEAVE;
486 493
487 return ret; 494 return ret;
495}
496
497static void
498_keysym_resource_push (rxvt_term *term, const char *k, const char *v)
499{
500 unsigned int state;
501
502 if (term->parse_keysym (k, state) == -1)
503 return;
504
505 dSP;
506 XPUSHs (sv_2mortal (newSVpv (v, 0)));
507 PUTBACK;
508}
509
510static void
511_keysym_resources (rxvt_term *term)
512{
513 term->enumerate_keysym_resources (_keysym_resource_push);
488} 514}
489 515
490static void 516static void
491ungrab (rxvt_term *THIS) 517ungrab (rxvt_term *THIS)
492{ 518{
786 static const struct { 812 static const struct {
787 const char *name; 813 const char *name;
788 IV iv; 814 IV iv;
789 } *civ, const_iv[] = { 815 } *civ, const_iv[] = {
790# define const_iv(name) { # name, (IV)name } 816# define const_iv(name) { # name, (IV)name }
817 const_iv (HOOK_INIT),
818 const_iv (HOOK_DESTROY),
819 const_iv (HOOK_ACTION),
820
791 const_iv (NUM_RESOURCES), 821 const_iv (NUM_RESOURCES),
792 const_iv (DEFAULT_RSTYLE), 822 const_iv (DEFAULT_RSTYLE),
793 const_iv (OVERLAY_RSTYLE), 823 const_iv (OVERLAY_RSTYLE),
794 const_iv (Color_Bits), 824 const_iv (Color_Bits),
795 const_iv (RS_bgShift), const_iv (RS_bgMask), 825 const_iv (RS_bgShift), const_iv (RS_bgMask),
805 const_iv (RS_Bold), 835 const_iv (RS_Bold),
806 const_iv (RS_Italic), 836 const_iv (RS_Italic),
807 const_iv (RS_Blink), 837 const_iv (RS_Blink),
808 const_iv (RS_RVid), 838 const_iv (RS_RVid),
809 const_iv (RS_Uline), 839 const_iv (RS_Uline),
840
841 // TODO: should support all colour constants, create colorinc.h &c
842 const_iv (Color_fg),
843 const_iv (Color_bg),
844#if OFF_FOCUS_FADING
845 const_iv (Color_fade),
846#endif
847 const_iv (Color_pointer_fg),
848 const_iv (Color_pointer_bg),
849 const_iv (Color_border),
850 const_iv (NRS_COLORS),
851 const_iv (TOTAL_COLORS),
810 852
811 const_iv (CurrentTime), 853 const_iv (CurrentTime),
812 const_iv (ShiftMask), 854 const_iv (ShiftMask),
813 const_iv (LockMask), 855 const_iv (LockMask),
814 const_iv (ControlMask), 856 const_iv (ControlMask),
906 const_iv (PictStandardA1), 948 const_iv (PictStandardA1),
907 const_iv (RepeatNone), 949 const_iv (RepeatNone),
908 const_iv (RepeatNormal), 950 const_iv (RepeatNormal),
909 const_iv (RepeatPad), 951 const_iv (RepeatPad),
910 const_iv (RepeatReflect), 952 const_iv (RepeatReflect),
953 // all versions
954 const_iv (PictOpClear),
955 const_iv (PictOpSrc),
956 const_iv (PictOpDst),
957 const_iv (PictOpOver),
958 const_iv (PictOpOverReverse),
959 const_iv (PictOpIn),
960 const_iv (PictOpInReverse),
961 const_iv (PictOpOut),
962 const_iv (PictOpOutReverse),
963 const_iv (PictOpAtop),
964 const_iv (PictOpAtopReverse),
965 const_iv (PictOpXor),
966 const_iv (PictOpAdd),
967 const_iv (PictOpSaturate),
968 // 0.2+
969 const_iv (PictOpDisjointClear),
970 const_iv (PictOpDisjointSrc),
971 const_iv (PictOpDisjointDst),
972 const_iv (PictOpDisjointOver),
973 const_iv (PictOpDisjointOverReverse),
974 const_iv (PictOpDisjointIn),
975 const_iv (PictOpDisjointInReverse),
976 const_iv (PictOpDisjointOut),
977 const_iv (PictOpDisjointOutReverse),
978 const_iv (PictOpDisjointAtop),
979 const_iv (PictOpDisjointAtopReverse),
980 const_iv (PictOpDisjointXor),
981 const_iv (PictOpConjointClear),
982 const_iv (PictOpConjointSrc),
983 const_iv (PictOpConjointDst),
984 const_iv (PictOpConjointOver),
985 const_iv (PictOpConjointOverReverse),
986 const_iv (PictOpConjointIn),
987 const_iv (PictOpConjointInReverse),
988 const_iv (PictOpConjointOut),
989 const_iv (PictOpConjointOutReverse),
990 const_iv (PictOpConjointAtop),
991 const_iv (PictOpConjointAtopReverse),
992 const_iv (PictOpConjointXor),
993 // 0.11+
994 const_iv (PictOpMultiply),
995 const_iv (PictOpScreen),
996 const_iv (PictOpOverlay),
997 const_iv (PictOpDarken),
998 const_iv (PictOpLighten),
999 const_iv (PictOpColorDodge),
1000 const_iv (PictOpColorBurn),
1001 const_iv (PictOpHardLight),
1002 const_iv (PictOpSoftLight),
1003 const_iv (PictOpDifference),
1004 const_iv (PictOpExclusion),
1005 const_iv (PictOpHSLHue),
1006 const_iv (PictOpHSLSaturation),
1007 const_iv (PictOpHSLColor),
1008 const_iv (PictOpHSLLuminosity),
911#endif 1009#endif
912# if 0 1010# if 0
913 const_iv (XIMForwardChar), 1011 const_iv (XIMForwardChar),
914 const_iv (XIMBackwardChar), 1012 const_iv (XIMBackwardChar),
915 const_iv (XIMForwardWord), 1013 const_iv (XIMForwardWord),
929 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) 1027 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
930 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 1028 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
931} 1029}
932 1030
933void 1031void
934log (const char *msg) 1032log (utf8_string msg)
935 CODE: 1033 CODE:
936 rxvt_log ("%s", msg); 1034 rxvt_log ("%s", msg);
937 1035
938void 1036void
939warn (const char *msg) 1037warn (utf8_string msg)
940 CODE: 1038 CODE:
941 rxvt_warn ("%s", msg); 1039 rxvt_warn ("%s", msg);
942 1040
943void 1041void
944fatal (const char *msg) 1042fatal (utf8_string msg)
945 CODE: 1043 CODE:
946 rxvt_fatal ("%s", msg); 1044 rxvt_fatal ("%s", msg);
947 1045
948void 1046void
949_exit (int status) 1047_exit (int status)
1114void 1212void
1115rxvt_term::put_option_db (octet_string specifier, octet_string value) 1213rxvt_term::put_option_db (octet_string specifier, octet_string value)
1116 CODE: 1214 CODE:
1117 XrmPutStringResource (&THIS->option_db, specifier, value); 1215 XrmPutStringResource (&THIS->option_db, specifier, value);
1118 1216
1217void
1218rxvt_term::_keysym_resources ()
1219 PPCODE:
1220 PUTBACK;
1221 _keysym_resources (THIS);
1222 SPAGAIN;
1223
1119int 1224int
1120rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) 1225rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
1121 CODE: 1226 CODE:
1122 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, 1227 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1,
1123 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 1228 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1182rxvt_term::ungrab () 1287rxvt_term::ungrab ()
1183 CODE: 1288 CODE:
1184 ungrab (THIS); 1289 ungrab (THIS);
1185 1290
1186int 1291int
1187rxvt_term::XStringToKeysym (char *string) 1292rxvt_term::XStringToKeysym (octet_string string)
1188 CODE: 1293 CODE:
1189 RETVAL = XStringToKeysym (string); 1294 RETVAL = XStringToKeysym (string);
1190 OUTPUT: RETVAL 1295 OUTPUT: RETVAL
1191 1296
1192char * 1297char *
1202 OUTPUT: RETVAL 1307 OUTPUT: RETVAL
1203 1308
1204int 1309int
1205rxvt_term::XKeycodeToKeysym (int code, int index) 1310rxvt_term::XKeycodeToKeysym (int code, int index)
1206 CODE: 1311 CODE:
1207 RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); 1312 RETVAL = rxvt_XKeycodeToKeysym (THIS->dpy, code, index);
1208 OUTPUT: RETVAL 1313 OUTPUT: RETVAL
1209 1314
1210int 1315int
1211rxvt_term::strwidth (SV *str) 1316rxvt_term::strwidth (SV *str)
1212 CODE: 1317 CODE:
1282#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) 1387#define TERM_OFFSET_saveLines TERM_OFFSET(saveLines)
1283#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) 1388#define TERM_OFFSET_total_rows TERM_OFFSET(total_rows)
1284#define TERM_OFFSET_top_row TERM_OFFSET(top_row) 1389#define TERM_OFFSET_top_row TERM_OFFSET(top_row)
1285 1390
1286int 1391int
1287rxvt_term::width () 1392rxvt_term::width (int new_value = NO_INIT)
1288 ALIAS: 1393 ALIAS:
1289 width = TERM_OFFSET_width 1394 width = TERM_OFFSET_width
1290 height = TERM_OFFSET_height 1395 height = TERM_OFFSET_height
1291 fwidth = TERM_OFFSET_fwidth 1396 fwidth = TERM_OFFSET_fwidth
1292 fheight = TERM_OFFSET_fheight 1397 fheight = TERM_OFFSET_fheight
1302 saveLines = TERM_OFFSET_saveLines 1407 saveLines = TERM_OFFSET_saveLines
1303 total_rows = TERM_OFFSET_total_rows 1408 total_rows = TERM_OFFSET_total_rows
1304 top_row = TERM_OFFSET_top_row 1409 top_row = TERM_OFFSET_top_row
1305 CODE: 1410 CODE:
1306 RETVAL = *(int *)((char *)THIS + ix); 1411 RETVAL = *(int *)((char *)THIS + ix);
1412 if (items > 1)
1413 *(int *)((char *)THIS + ix) = new_value;
1307 OUTPUT: 1414 OUTPUT:
1308 RETVAL 1415 RETVAL
1309 1416
1310unsigned int 1417unsigned int
1311rxvt_term::ModLevel3Mask () 1418rxvt_term::ModLevel3Mask ()
1322 case 1: RETVAL = THIS->ModMetaMask; break; 1429 case 1: RETVAL = THIS->ModMetaMask; break;
1323 case 2: RETVAL = THIS->ModNumLockMask; break; 1430 case 2: RETVAL = THIS->ModNumLockMask; break;
1324 case 3: RETVAL = THIS->current_screen; break; 1431 case 3: RETVAL = THIS->current_screen; break;
1325#ifdef CURSOR_BLINK 1432#ifdef CURSOR_BLINK
1326 case 4: RETVAL = THIS->hidden_cursor; break; 1433 case 4: RETVAL = THIS->hidden_cursor; break;
1434#else
1435 case 4: RETVAL = 0; break;
1327#endif 1436#endif
1328 } 1437 }
1329 OUTPUT: 1438 OUTPUT:
1330 RETVAL 1439 RETVAL
1331 1440
1393 CODE: 1502 CODE:
1394 RETVAL = THIS->parent_y; 1503 RETVAL = THIS->parent_y;
1395 OUTPUT: 1504 OUTPUT:
1396 RETVAL 1505 RETVAL
1397 1506
1507Window
1508rxvt_term::vt ()
1509 CODE:
1510 RETVAL = THIS->vt;
1511 OUTPUT:
1512 RETVAL
1513
1398void 1514void
1399rxvt_term::vt_emask_add (U32 emask) 1515rxvt_term::vt_emask_add (U32 emask)
1400 CODE: 1516 CODE:
1401 THIS->vt_emask_perl |= emask; 1517 THIS->vt_emask_perl |= emask;
1402 THIS->vt_select_input (); 1518 THIS->vt_select_input ();
1460void 1576void
1461rxvt_term::want_refresh () 1577rxvt_term::want_refresh ()
1462 CODE: 1578 CODE:
1463 THIS->want_refresh = 1; 1579 THIS->want_refresh = 1;
1464 THIS->refresh_check (); 1580 THIS->refresh_check ();
1581
1582void
1583rxvt_term::refresh_check ()
1465 1584
1466void 1585void
1467rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1586rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1468 PPCODE: 1587 PPCODE:
1469{ 1588{
1614 *r++ = NOCHAR; 1733 *r++ = NOCHAR;
1615 } 1734 }
1616 1735
1617 rxvt_pop_locale (); 1736 rxvt_pop_locale ();
1618 1737
1738 free (wstr);
1619 RETVAL = wcs2sv (rstr, r - rstr); 1739 RETVAL = wcs2sv (rstr, r - rstr);
1620} 1740}
1621 OUTPUT: 1741 OUTPUT:
1622 RETVAL 1742 RETVAL
1623 1743
1647 else if (IS_COMPOSE (*s)) 1767 else if (IS_COMPOSE (*s))
1648 r += rxvt_composite.expand (*s, r); 1768 r += rxvt_composite.expand (*s, r);
1649 else 1769 else
1650 *r++ = *s; 1770 *r++ = *s;
1651 1771
1772 free (wstr);
1652 RETVAL = wcs2sv (rstr, r - rstr); 1773 RETVAL = wcs2sv (rstr, r - rstr);
1653} 1774}
1654 OUTPUT: 1775 OUTPUT:
1655 RETVAL 1776 RETVAL
1656 1777
1657void 1778void
1658rxvt_term::_resource (char *name, int index, SV *newval = 0) 1779rxvt_term::_resource (octet_string name, int index, SV *newval = 0)
1659 PPCODE: 1780 PPCODE:
1660{ 1781{
1661 static const struct resval { const char *name; int value; } *rs, rslist [] = { 1782 static const struct resval { const char *name; int value; } *rs, rslist [] = {
1662# define def(name) { # name, Rs_ ## name }, 1783# define def(name) { # name, Rs_ ## name },
1663# define reserve(name,count) 1784# define reserve(name,count)
1701 THIS->rs [index] = 0; 1822 THIS->rs [index] = 0;
1702 } 1823 }
1703} 1824}
1704 1825
1705const char * 1826const char *
1706rxvt_term::x_resource (const char *name) 1827rxvt_term::x_resource (octet_string name)
1707 1828
1708bool 1829bool
1709rxvt_term::option (U8 optval, int set = -1) 1830rxvt_term::option (U8 optval, int set = -1)
1710 CODE: 1831 CODE:
1711{ 1832{
1730 THIS->cursor_blink_reset (); 1851 THIS->cursor_blink_reset ();
1731 break; 1852 break;
1732#endif 1853#endif
1733 1854
1734 case Opt_cursorUnderline: 1855 case Opt_cursorUnderline:
1856 THIS->cursor_type = set ? 1 : 0;
1735 THIS->want_refresh = 1; 1857 THIS->want_refresh = 1;
1736 THIS->refresh_check (); 1858 THIS->refresh_check ();
1737 break; 1859 break;
1738 1860
1739# case Opt_scrollBar_floating: 1861# case Opt_scrollBar_floating:
1744 } 1866 }
1745} 1867}
1746 OUTPUT: 1868 OUTPUT:
1747 RETVAL 1869 RETVAL
1748 1870
1871SV *
1872rxvt_term::lookup_keysym (int keysym, unsigned int state)
1873 CODE:
1874{
1875 keysym_t *key = THIS->keyboard->lookup_keysym (THIS, keysym, state);
1876 RETVAL = key ? sv_2mortal (newSVpv (key->str, 0)) : &PL_sv_undef;
1877}
1878 OUTPUT:
1879 RETVAL
1880
1749bool 1881bool
1750rxvt_term::parse_keysym (char *keysym, char *str) 1882rxvt_term::bind_action (octet_string keysym, octet_string action)
1883 ALIAS:
1884 parse_keysym = 1
1751 CODE: 1885 CODE:
1752 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1886 RETVAL = 0 < THIS->bind_action (keysym, action);
1753 THIS->keyboard->register_done (); 1887 THIS->keyboard->register_done ();
1754 OUTPUT: 1888 OUTPUT:
1755 RETVAL 1889 RETVAL
1756 1890
1757void 1891void
1758rxvt_term::register_command (int keysym, unsigned int state, SV *str) 1892rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1759 CODE: 1893 CODE:
1760 wchar_t *wstr = sv2wcs (str); 1894 wchar_t *wstr = sv2wcs (str);
1761 THIS->keyboard->register_user_translation (keysym, state, wstr); 1895 THIS->keyboard->register_action (keysym, state, wstr);
1762 free (wstr); 1896 free (wstr);
1763 1897
1764void 1898void
1765rxvt_term::screen_cur (...) 1899rxvt_term::screen_cur (...)
1766 PROTOTYPE: $;$$ 1900 PROTOTYPE: $;$$
1809 1943
1810 if (ix) 1944 if (ix)
1811 { 1945 {
1812 THIS->selection.screen = THIS->current_screen; 1946 THIS->selection.screen = THIS->current_screen;
1813 1947
1814 THIS->want_refresh = 1; 1948 THIS->selection_changed ();
1815 THIS->refresh_check (); 1949 THIS->refresh_check ();
1816 } 1950 }
1817 } 1951 }
1818} 1952}
1819 1953
1825 THIS->selection.screen = screen; 1959 THIS->selection.screen = screen;
1826 OUTPUT: 1960 OUTPUT:
1827 RETVAL 1961 RETVAL
1828 1962
1829void 1963void
1964rxvt_term::selection_request (Time tm, int selnum)
1965
1966void
1830rxvt_term::selection_clear (bool clipboard = false) 1967rxvt_term::selection_clear (bool clipboard = false)
1831 1968
1832void 1969void
1833rxvt_term::selection_make (Time eventtime, bool rect = false) 1970rxvt_term::selection_make (Time eventtime, bool rect = false)
1834 CODE: 1971 CODE:
1875 2012
1876void 2013void
1877rxvt_term::scr_bell () 2014rxvt_term::scr_bell ()
1878 2015
1879void 2016void
1880rxvt_term::scr_recolour (bool refresh = true); 2017rxvt_term::scr_recolor (bool refresh = true);
1881 2018
1882void 2019void
1883rxvt_term::scr_change_screen (int screen) 2020rxvt_term::scr_change_screen (int screen)
1884 2021
1885void 2022void
1888{ 2025{
1889 wchar_t *wstr = sv2wcs (string); 2026 wchar_t *wstr = sv2wcs (string);
1890 THIS->scr_add_lines (wstr, wcslen (wstr)); 2027 THIS->scr_add_lines (wstr, wcslen (wstr));
1891 free (wstr); 2028 free (wstr);
1892} 2029}
2030
2031void
2032rxvt_term::tt_write_user_input (SV *octets)
2033 INIT:
2034 STRLEN len;
2035 char *str = SvPVbyte (octets, len);
2036 C_ARGS:
2037 str, len
1893 2038
1894void 2039void
1895rxvt_term::tt_write (SV *octets) 2040rxvt_term::tt_write (SV *octets)
1896 INIT: 2041 INIT:
1897 STRLEN len; 2042 STRLEN len;
2094 PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height))); 2239 PUSHs (sv_2mortal (newSViv (border ? THIS->vt_height : THIS->szHint.height)));
2095 2240
2096#if HAVE_IMG 2241#if HAVE_IMG
2097 2242
2098rxvt_img * 2243rxvt_img *
2099rxvt_term::new_img (SV *format, int width = 1, int height = 1) 2244rxvt_term::new_img (SV *format = &PL_sv_undef, int x = 0, int y = 0, int width = 1, int height = 1)
2100 CODE: 2245 CODE:
2101 XRenderPictFormat *f = SvOK (format) 2246 XRenderPictFormat *f = SvOK (format)
2102 ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) 2247 ? XRenderFindStandardFormat (THIS->dpy, SvIV (format))
2103 : XRenderFindVisualFormat (THIS->dpy, THIS->visual); 2248 : XRenderFindVisualFormat (THIS->dpy, THIS->visual);
2104 RETVAL = new rxvt_img (THIS, f, 0, 0, width, height); 2249 RETVAL = new rxvt_img (THIS, f, x, y, width, height);
2105 RETVAL->alloc (); 2250 RETVAL->alloc ();
2106 OUTPUT: 2251 OUTPUT:
2107 RETVAL 2252 RETVAL
2108 2253
2109#if ENABLE_TRANSPARENCY 2254#if ENABLE_TRANSPARENCY
2133 OUTPUT: 2278 OUTPUT:
2134 RETVAL 2279 RETVAL
2135 2280
2136#endif 2281#endif
2137 2282
2138#if HAVE_BG_PIXMAP
2139
2140void 2283void
2141rxvt_term::set_background (rxvt_img *img, bool border = false) 2284rxvt_term::set_background (rxvt_img *img, bool border = false)
2142 CODE: 2285 CODE:
2143 THIS->bg_destroy (); 2286 delete THIS->bg_img;
2144 THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT); 2287 THIS->bg_img = 0;
2288 THIS->bg_flags = 0;
2145 2289
2146 if (img) // TODO: cannot be false 2290 if (img) // TODO: cannot be false
2147 { 2291 {
2148 img = img->clone (); // own the img 2292 img = img->clone (); // own the img
2149 2293
2150 if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap 2294 if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap
2151 img->sub_rect (0, 0, 2295 img->sub_rect (0, 0,
2152 border ? THIS->vt_width : THIS->szHint.width, 2296 border ? THIS->vt_width : THIS->szHint.width,
2153 border ? THIS->vt_height : THIS->szHint.height) 2297 border ? THIS->vt_height : THIS->szHint.height)
2154 ->replace (img); 2298 ->replace (img);
2155 2299
2156 // just in case, should usually be a nop 2300 // just in case, should usually be a nop
2157 img->reify () 2301 img->reify ()
2158 ->replace (img); 2302 ->replace (img);
2159 2303
2160 img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg]) 2304 img->convert_format (XRenderFindVisualFormat (THIS->dpy, THIS->visual), THIS->pix_colors [Color_bg])
2161 ->replace (img); 2305 ->replace (img);
2162 2306
2163 THIS->bg_img = img; 2307 THIS->bg_img = img;
2164 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; 2308 THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH;
2165 2309
2166 if (!border) 2310 if (!border)
2167 THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; 2311 THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT;
2168 } 2312 }
2169
2170#endif
2171 2313
2172#endif 2314#endif
2173 2315
2174############################################################################# 2316#############################################################################
2175# urxvt::overlay 2317# urxvt::overlay
2199 C_ARGS: filename, 0 2341 C_ARGS: filename, 0
2200 2342
2201void 2343void
2202DESTROY (urxvt::pixbuf self) 2344DESTROY (urxvt::pixbuf self)
2203 CODE: 2345 CODE:
2204 gdk_pixbuf_unref (self); 2346 g_object_unref (self);
2205 2347
2206#endif 2348#endif
2207 2349
2208MODULE = urxvt PACKAGE = urxvt::img 2350MODULE = urxvt PACKAGE = urxvt::img
2209 2351
2210#if HAVE_IMG 2352#if HAVE_IMG
2211 2353
2212# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) 2354# rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height)
2213# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); 2355# rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
2214 2356
2357void
2358rxvt_img::geometry ()
2359 PPCODE:
2360 EXTEND (SP, 4);
2361 PUSHs (sv_2mortal (newSViv (THIS->x)));
2362 PUSHs (sv_2mortal (newSViv (THIS->y)));
2363 PUSHs (sv_2mortal (newSViv (THIS->w)));
2364 PUSHs (sv_2mortal (newSViv (THIS->h)));
2365
2215int 2366int
2216rxvt_img::w () 2367rxvt_img::x ()
2368 ALIAS:
2369 x = 0
2370 y = 1
2371 w = 2
2372 h = 3
2217 CODE: 2373 CODE:
2218 RETVAL = THIS->w; 2374 switch (ix)
2219 OUTPUT: 2375 {
2220 RETVAL 2376 case 0: RETVAL = THIS->x; break;
2221 2377 case 1: RETVAL = THIS->y; break;
2222int 2378 case 2: RETVAL = THIS->w; break;
2223rxvt_img::h () 2379 case 3: RETVAL = THIS->h; break;
2224 CODE: 2380 }
2225 RETVAL = THIS->h;
2226 OUTPUT: 2381 OUTPUT:
2227 RETVAL 2382 RETVAL
2228 2383
2229Pixmap 2384Pixmap
2230rxvt_img::pm () 2385rxvt_img::pm ()
2232 RETVAL = THIS->pm; 2387 RETVAL = THIS->pm;
2233 OUTPUT: 2388 OUTPUT:
2234 RETVAL 2389 RETVAL
2235 2390
2236void 2391void
2237rxvt_img::fill (SV *c) 2392rxvt_img::fill (SV *c, int x = 0, int y = 0, int w = THIS->w, int h = THIS->h)
2393 PROTOTYPE: $;$$$$
2238 INIT: 2394 INIT:
2239 rgba cc = parse_rgba (c, THIS->s); 2395 rgba cc = parse_rgba (c, THIS->s);
2240 C_ARGS: cc 2396 C_ARGS: cc, x, y, w, h
2241 2397
2242void 2398void
2243rxvt_img::DESTROY () 2399rxvt_img::DESTROY ()
2244 CODE: 2400 CODE:
2245 delete THIS; 2401 delete THIS;
2246 2402
2247void 2403void
2404rxvt_img::add_alpha ()
2405
2406void
2248rxvt_img::unshare () 2407rxvt_img::unshare ()
2249 2408
2250int 2409void
2251rxvt_img::repeat_mode (render_repeat_mode repeat = 0) 2410rxvt_img::repeat_mode (render_repeat_mode repeat = 0)
2252 CODE: 2411 PPCODE:
2253 if (items >= 2) 2412 if (items >= 2)
2254 THIS->repeat_mode (repeat); 2413 THIS->repeat_mode (repeat);
2255 if (GIMME_V != G_VOID) 2414 if (GIMME_V != G_VOID)
2256 XPUSHs (sv_2mortal (newSViv (THIS->repeat))); 2415 XPUSHs (sv_2mortal (newSViv (THIS->repeat)));
2257 2416
2258void 2417void
2259rxvt_img::move (int dx, int dy) 2418rxvt_img::move (int dx, int dy)
2260 2419
2261void 2420void
2262rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) 2421rxvt_img::brightness (rxvt_img::nv r, rxvt_img::nv g, rxvt_img::nv b, rxvt_img::nv a = 1.)
2263 2422
2264void 2423void
2265rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) 2424rxvt_img::contrast (rxvt_img::nv r, rxvt_img::nv g, rxvt_img::nv b, rxvt_img::nv a = 1.)
2425
2426void
2427rxvt_img::draw (rxvt_img *img, int op = PictOpOver, rxvt_img::nv mask = 1.);
2266 2428
2267rxvt_img * 2429rxvt_img *
2268rxvt_img::clone () 2430rxvt_img::clone ()
2269 2431
2270rxvt_img * 2432rxvt_img *
2275 2437
2276rxvt_img * 2438rxvt_img *
2277rxvt_img::blur (int rh, int rv) 2439rxvt_img::blur (int rh, int rv)
2278 2440
2279rxvt_img * 2441rxvt_img *
2280rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) 2442rxvt_img::muladd (rxvt_img::nv mul, rxvt_img::nv add)
2443
2444rxvt_img *
2445rxvt_img::transform (rxvt_img::nv p11, rxvt_img::nv p12, rxvt_img::nv p13, rxvt_img::nv p21, rxvt_img::nv p22, rxvt_img::nv p23, rxvt_img::nv p31, rxvt_img::nv p32, rxvt_img::nv p33)
2281 INIT: 2446 INIT:
2282 double matrix[3][3] = { 2447 rxvt_img::nv matrix[3][3] = {
2283 { p11, p12, p13 }, 2448 { p11, p12, p13 },
2284 { p21, p22, p23 }, 2449 { p21, p22, p23 },
2285 { p31, p32, p33 } 2450 { p31, p32, p33 }
2286 }; 2451 };
2287 C_ARGS: matrix 2452 C_ARGS: matrix
2288 2453
2289rxvt_img * 2454rxvt_img *
2290rxvt_img::scale (int new_width, int new_height) 2455rxvt_img::scale (int new_width, int new_height)
2291 2456
2292rxvt_img * 2457rxvt_img *
2293rxvt_img::rotate (int x, int y, NV phi) 2458rxvt_img::rotate (int x, int y, rxvt_img::nv phi)
2459
2460rxvt_img *
2461rxvt_img::tint (SV *c)
2462 INIT:
2463 rgba cc = parse_rgba (c, THIS->s);
2464 C_ARGS: cc
2465
2466rxvt_img *
2467rxvt_img::shade (rxvt_img::nv factor)
2468
2469rxvt_img *
2470rxvt_img::filter (octet_string name, SV *params = &PL_sv_undef)
2471 CODE:
2472 rxvt_img::nv *vparams = 0;
2473 int nparams = 0;
2474
2475 if (SvOK (params))
2476 {
2477 if (!SvROK (params) || SvTYPE (SvRV (params)) != SVt_PVAV)
2478 croak ("rxvt_img::filter: params must be an array reference with parameter values");
2479
2480 nparams = av_len ((AV *)SvRV (params)) + 1;
2481 vparams = (rxvt_img::nv *)malloc (nparams * sizeof (rxvt_img::nv));
2482
2483 for (int i = 0; i < nparams; ++i)
2484 vparams [i] = SvNV (*av_fetch ((AV *)SvRV (params), i, 1));
2485 }
2486
2487 RETVAL = THIS->filter (name, nparams, vparams);
2488 free (vparams);
2489 OUTPUT:
2490 RETVAL
2294 2491
2295#endif 2492#endif
2296 2493

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines