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 |
… | |
… | |
490 | |
490 | |
491 | FREETMPS; |
491 | FREETMPS; |
492 | LEAVE; |
492 | LEAVE; |
493 | |
493 | |
494 | return ret; |
494 | return ret; |
|
|
495 | } |
|
|
496 | |
|
|
497 | static 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 | |
|
|
510 | static void |
|
|
511 | _keysym_resources (rxvt_term *term) |
|
|
512 | { |
|
|
513 | term->enumerate_keysym_resources (_keysym_resource_push); |
495 | } |
514 | } |
496 | |
515 | |
497 | static void |
516 | static void |
498 | ungrab (rxvt_term *THIS) |
517 | ungrab (rxvt_term *THIS) |
499 | { |
518 | { |
… | |
… | |
793 | static const struct { |
812 | static const struct { |
794 | const char *name; |
813 | const char *name; |
795 | IV iv; |
814 | IV iv; |
796 | } *civ, const_iv[] = { |
815 | } *civ, const_iv[] = { |
797 | # 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 | |
798 | const_iv (NUM_RESOURCES), |
821 | const_iv (NUM_RESOURCES), |
799 | const_iv (DEFAULT_RSTYLE), |
822 | const_iv (DEFAULT_RSTYLE), |
800 | const_iv (OVERLAY_RSTYLE), |
823 | const_iv (OVERLAY_RSTYLE), |
801 | const_iv (Color_Bits), |
824 | const_iv (Color_Bits), |
802 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
825 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
… | |
… | |
812 | const_iv (RS_Bold), |
835 | const_iv (RS_Bold), |
813 | const_iv (RS_Italic), |
836 | const_iv (RS_Italic), |
814 | const_iv (RS_Blink), |
837 | const_iv (RS_Blink), |
815 | const_iv (RS_RVid), |
838 | const_iv (RS_RVid), |
816 | 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), |
817 | |
852 | |
818 | const_iv (CurrentTime), |
853 | const_iv (CurrentTime), |
819 | const_iv (ShiftMask), |
854 | const_iv (ShiftMask), |
820 | const_iv (LockMask), |
855 | const_iv (LockMask), |
821 | const_iv (ControlMask), |
856 | const_iv (ControlMask), |
… | |
… | |
992 | 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--) |
993 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
1028 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
994 | } |
1029 | } |
995 | |
1030 | |
996 | void |
1031 | void |
997 | log (const char *msg) |
1032 | log (utf8_string msg) |
998 | CODE: |
1033 | CODE: |
999 | rxvt_log ("%s", msg); |
1034 | rxvt_log ("%s", msg); |
1000 | |
1035 | |
1001 | void |
1036 | void |
1002 | warn (const char *msg) |
1037 | warn (utf8_string msg) |
1003 | CODE: |
1038 | CODE: |
1004 | rxvt_warn ("%s", msg); |
1039 | rxvt_warn ("%s", msg); |
1005 | |
1040 | |
1006 | void |
1041 | void |
1007 | fatal (const char *msg) |
1042 | fatal (utf8_string msg) |
1008 | CODE: |
1043 | CODE: |
1009 | rxvt_fatal ("%s", msg); |
1044 | rxvt_fatal ("%s", msg); |
1010 | |
1045 | |
1011 | void |
1046 | void |
1012 | _exit (int status) |
1047 | _exit (int status) |
… | |
… | |
1177 | void |
1212 | void |
1178 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
1213 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
1179 | CODE: |
1214 | CODE: |
1180 | XrmPutStringResource (&THIS->option_db, specifier, value); |
1215 | XrmPutStringResource (&THIS->option_db, specifier, value); |
1181 | |
1216 | |
|
|
1217 | void |
|
|
1218 | rxvt_term::_keysym_resources () |
|
|
1219 | PPCODE: |
|
|
1220 | PUTBACK; |
|
|
1221 | _keysym_resources (THIS); |
|
|
1222 | SPAGAIN; |
|
|
1223 | |
1182 | int |
1224 | int |
1183 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1225 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1184 | CODE: |
1226 | CODE: |
1185 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1227 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1186 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1228 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
… | |
… | |
1245 | rxvt_term::ungrab () |
1287 | rxvt_term::ungrab () |
1246 | CODE: |
1288 | CODE: |
1247 | ungrab (THIS); |
1289 | ungrab (THIS); |
1248 | |
1290 | |
1249 | int |
1291 | int |
1250 | rxvt_term::XStringToKeysym (char *string) |
1292 | rxvt_term::XStringToKeysym (octet_string string) |
1251 | CODE: |
1293 | CODE: |
1252 | RETVAL = XStringToKeysym (string); |
1294 | RETVAL = XStringToKeysym (string); |
1253 | OUTPUT: RETVAL |
1295 | OUTPUT: RETVAL |
1254 | |
1296 | |
1255 | char * |
1297 | char * |
… | |
… | |
1265 | OUTPUT: RETVAL |
1307 | OUTPUT: RETVAL |
1266 | |
1308 | |
1267 | int |
1309 | int |
1268 | rxvt_term::XKeycodeToKeysym (int code, int index) |
1310 | rxvt_term::XKeycodeToKeysym (int code, int index) |
1269 | CODE: |
1311 | CODE: |
1270 | RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); |
1312 | RETVAL = rxvt_XKeycodeToKeysym (THIS->dpy, code, index); |
1271 | OUTPUT: RETVAL |
1313 | OUTPUT: RETVAL |
1272 | |
1314 | |
1273 | int |
1315 | int |
1274 | rxvt_term::strwidth (SV *str) |
1316 | rxvt_term::strwidth (SV *str) |
1275 | CODE: |
1317 | CODE: |
… | |
… | |
1345 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1387 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1346 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1388 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1347 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1389 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1348 | |
1390 | |
1349 | int |
1391 | int |
1350 | rxvt_term::width () |
1392 | rxvt_term::width (int new_value = NO_INIT) |
1351 | ALIAS: |
1393 | ALIAS: |
1352 | width = TERM_OFFSET_width |
1394 | width = TERM_OFFSET_width |
1353 | height = TERM_OFFSET_height |
1395 | height = TERM_OFFSET_height |
1354 | fwidth = TERM_OFFSET_fwidth |
1396 | fwidth = TERM_OFFSET_fwidth |
1355 | fheight = TERM_OFFSET_fheight |
1397 | fheight = TERM_OFFSET_fheight |
… | |
… | |
1365 | saveLines = TERM_OFFSET_saveLines |
1407 | saveLines = TERM_OFFSET_saveLines |
1366 | total_rows = TERM_OFFSET_total_rows |
1408 | total_rows = TERM_OFFSET_total_rows |
1367 | top_row = TERM_OFFSET_top_row |
1409 | top_row = TERM_OFFSET_top_row |
1368 | CODE: |
1410 | CODE: |
1369 | RETVAL = *(int *)((char *)THIS + ix); |
1411 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
1412 | if (items > 1) |
|
|
1413 | *(int *)((char *)THIS + ix) = new_value; |
1370 | OUTPUT: |
1414 | OUTPUT: |
1371 | RETVAL |
1415 | RETVAL |
1372 | |
1416 | |
1373 | unsigned int |
1417 | unsigned int |
1374 | rxvt_term::ModLevel3Mask () |
1418 | rxvt_term::ModLevel3Mask () |
… | |
… | |
1532 | CODE: |
1576 | CODE: |
1533 | THIS->want_refresh = 1; |
1577 | THIS->want_refresh = 1; |
1534 | THIS->refresh_check (); |
1578 | THIS->refresh_check (); |
1535 | |
1579 | |
1536 | void |
1580 | void |
|
|
1581 | rxvt_term::refresh_check () |
|
|
1582 | |
|
|
1583 | void |
1537 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1584 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1538 | PPCODE: |
1585 | PPCODE: |
1539 | { |
1586 | { |
1540 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1587 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1541 | XSRETURN_EMPTY; |
1588 | XSRETURN_EMPTY; |
… | |
… | |
1684 | *r++ = NOCHAR; |
1731 | *r++ = NOCHAR; |
1685 | } |
1732 | } |
1686 | |
1733 | |
1687 | rxvt_pop_locale (); |
1734 | rxvt_pop_locale (); |
1688 | |
1735 | |
|
|
1736 | free (wstr); |
1689 | RETVAL = wcs2sv (rstr, r - rstr); |
1737 | RETVAL = wcs2sv (rstr, r - rstr); |
1690 | } |
1738 | } |
1691 | OUTPUT: |
1739 | OUTPUT: |
1692 | RETVAL |
1740 | RETVAL |
1693 | |
1741 | |
… | |
… | |
1717 | else if (IS_COMPOSE (*s)) |
1765 | else if (IS_COMPOSE (*s)) |
1718 | r += rxvt_composite.expand (*s, r); |
1766 | r += rxvt_composite.expand (*s, r); |
1719 | else |
1767 | else |
1720 | *r++ = *s; |
1768 | *r++ = *s; |
1721 | |
1769 | |
|
|
1770 | free (wstr); |
1722 | RETVAL = wcs2sv (rstr, r - rstr); |
1771 | RETVAL = wcs2sv (rstr, r - rstr); |
1723 | } |
1772 | } |
1724 | OUTPUT: |
1773 | OUTPUT: |
1725 | RETVAL |
1774 | RETVAL |
1726 | |
1775 | |
1727 | void |
1776 | void |
1728 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1777 | rxvt_term::_resource (octet_string name, int index, SV *newval = 0) |
1729 | PPCODE: |
1778 | PPCODE: |
1730 | { |
1779 | { |
1731 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1780 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1732 | # define def(name) { # name, Rs_ ## name }, |
1781 | # define def(name) { # name, Rs_ ## name }, |
1733 | # define reserve(name,count) |
1782 | # define reserve(name,count) |
… | |
… | |
1771 | THIS->rs [index] = 0; |
1820 | THIS->rs [index] = 0; |
1772 | } |
1821 | } |
1773 | } |
1822 | } |
1774 | |
1823 | |
1775 | const char * |
1824 | const char * |
1776 | rxvt_term::x_resource (const char *name) |
1825 | rxvt_term::x_resource (octet_string name) |
1777 | |
1826 | |
1778 | bool |
1827 | bool |
1779 | rxvt_term::option (U8 optval, int set = -1) |
1828 | rxvt_term::option (U8 optval, int set = -1) |
1780 | CODE: |
1829 | CODE: |
1781 | { |
1830 | { |
… | |
… | |
1800 | THIS->cursor_blink_reset (); |
1849 | THIS->cursor_blink_reset (); |
1801 | break; |
1850 | break; |
1802 | #endif |
1851 | #endif |
1803 | |
1852 | |
1804 | case Opt_cursorUnderline: |
1853 | case Opt_cursorUnderline: |
|
|
1854 | THIS->cursor_type = set ? 1 : 0; |
1805 | THIS->want_refresh = 1; |
1855 | THIS->want_refresh = 1; |
1806 | THIS->refresh_check (); |
1856 | THIS->refresh_check (); |
1807 | break; |
1857 | break; |
1808 | |
1858 | |
1809 | # case Opt_scrollBar_floating: |
1859 | # case Opt_scrollBar_floating: |
… | |
… | |
1814 | } |
1864 | } |
1815 | } |
1865 | } |
1816 | OUTPUT: |
1866 | OUTPUT: |
1817 | RETVAL |
1867 | RETVAL |
1818 | |
1868 | |
|
|
1869 | SV * |
|
|
1870 | rxvt_term::lookup_keysym (int keysym, unsigned int state) |
|
|
1871 | CODE: |
|
|
1872 | { |
|
|
1873 | keysym_t *key = THIS->keyboard->lookup_keysym (THIS, keysym, state); |
|
|
1874 | RETVAL = key ? sv_2mortal (newSVpv (key->str, 0)) : &PL_sv_undef; |
|
|
1875 | } |
|
|
1876 | OUTPUT: |
|
|
1877 | RETVAL |
|
|
1878 | |
1819 | bool |
1879 | bool |
1820 | rxvt_term::parse_keysym (char *keysym, char *str) |
1880 | rxvt_term::bind_action (octet_string keysym, octet_string action) |
|
|
1881 | ALIAS: |
|
|
1882 | parse_keysym = 1 |
1821 | CODE: |
1883 | CODE: |
1822 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1884 | RETVAL = 0 < THIS->bind_action (keysym, action); |
1823 | THIS->keyboard->register_done (); |
1885 | THIS->keyboard->register_done (); |
1824 | OUTPUT: |
1886 | OUTPUT: |
1825 | RETVAL |
1887 | RETVAL |
1826 | |
1888 | |
1827 | void |
1889 | void |
1828 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
1890 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
1829 | CODE: |
1891 | CODE: |
1830 | wchar_t *wstr = sv2wcs (str); |
1892 | wchar_t *wstr = sv2wcs (str); |
1831 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
1893 | THIS->keyboard->register_action (keysym, state, wstr); |
1832 | free (wstr); |
1894 | free (wstr); |
1833 | |
1895 | |
1834 | void |
1896 | void |
1835 | rxvt_term::screen_cur (...) |
1897 | rxvt_term::screen_cur (...) |
1836 | PROTOTYPE: $;$$ |
1898 | PROTOTYPE: $;$$ |
… | |
… | |
1879 | |
1941 | |
1880 | if (ix) |
1942 | if (ix) |
1881 | { |
1943 | { |
1882 | THIS->selection.screen = THIS->current_screen; |
1944 | THIS->selection.screen = THIS->current_screen; |
1883 | |
1945 | |
1884 | THIS->want_refresh = 1; |
1946 | THIS->selection_changed (); |
1885 | THIS->refresh_check (); |
1947 | THIS->refresh_check (); |
1886 | } |
1948 | } |
1887 | } |
1949 | } |
1888 | } |
1950 | } |
1889 | |
1951 | |
… | |
… | |
1895 | THIS->selection.screen = screen; |
1957 | THIS->selection.screen = screen; |
1896 | OUTPUT: |
1958 | OUTPUT: |
1897 | RETVAL |
1959 | RETVAL |
1898 | |
1960 | |
1899 | void |
1961 | void |
|
|
1962 | rxvt_term::selection_request (Time tm, int selnum) |
|
|
1963 | |
|
|
1964 | void |
1900 | rxvt_term::selection_clear (bool clipboard = false) |
1965 | rxvt_term::selection_clear (bool clipboard = false) |
1901 | |
1966 | |
1902 | void |
1967 | void |
1903 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1968 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1904 | CODE: |
1969 | CODE: |
… | |
… | |
1945 | |
2010 | |
1946 | void |
2011 | void |
1947 | rxvt_term::scr_bell () |
2012 | rxvt_term::scr_bell () |
1948 | |
2013 | |
1949 | void |
2014 | void |
1950 | rxvt_term::scr_recolour (bool refresh = true); |
2015 | rxvt_term::scr_recolor (bool refresh = true); |
1951 | |
2016 | |
1952 | void |
2017 | void |
1953 | rxvt_term::scr_change_screen (int screen) |
2018 | rxvt_term::scr_change_screen (int screen) |
1954 | |
2019 | |
1955 | void |
2020 | void |
… | |
… | |
1958 | { |
2023 | { |
1959 | wchar_t *wstr = sv2wcs (string); |
2024 | wchar_t *wstr = sv2wcs (string); |
1960 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
2025 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1961 | free (wstr); |
2026 | free (wstr); |
1962 | } |
2027 | } |
|
|
2028 | |
|
|
2029 | void |
|
|
2030 | rxvt_term::tt_write_user_input (SV *octets) |
|
|
2031 | INIT: |
|
|
2032 | STRLEN len; |
|
|
2033 | char *str = SvPVbyte (octets, len); |
|
|
2034 | C_ARGS: |
|
|
2035 | str, len |
1963 | |
2036 | |
1964 | void |
2037 | void |
1965 | rxvt_term::tt_write (SV *octets) |
2038 | rxvt_term::tt_write (SV *octets) |
1966 | INIT: |
2039 | INIT: |
1967 | STRLEN len; |
2040 | STRLEN len; |
… | |
… | |
2203 | OUTPUT: |
2276 | OUTPUT: |
2204 | RETVAL |
2277 | RETVAL |
2205 | |
2278 | |
2206 | #endif |
2279 | #endif |
2207 | |
2280 | |
2208 | #if HAVE_BG_PIXMAP |
|
|
2209 | |
|
|
2210 | void |
2281 | void |
2211 | rxvt_term::set_background (rxvt_img *img, bool border = false) |
2282 | rxvt_term::set_background (rxvt_img *img, bool border = false) |
2212 | CODE: |
2283 | CODE: |
2213 | THIS->bg_destroy (); |
2284 | delete THIS->bg_img; |
2214 | THIS->bg_flags &= ~(rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER | rxvt_term::BG_IS_TRANSPARENT); |
2285 | THIS->bg_img = 0; |
|
|
2286 | THIS->bg_flags = 0; |
2215 | |
2287 | |
2216 | if (img) // TODO: cannot be false |
2288 | if (img) // TODO: cannot be false |
2217 | { |
2289 | { |
2218 | img = img->clone (); // own the img |
2290 | img = img->clone (); // own the img |
2219 | |
2291 | |
… | |
… | |
2234 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; |
2306 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH | rxvt_term::BG_INHIBIT_RENDER; |
2235 | |
2307 | |
2236 | if (!border) |
2308 | if (!border) |
2237 | THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; |
2309 | THIS->bg_flags |= rxvt_term::BG_IS_TRANSPARENT; |
2238 | } |
2310 | } |
2239 | |
|
|
2240 | #endif |
|
|
2241 | |
2311 | |
2242 | #endif |
2312 | #endif |
2243 | |
2313 | |
2244 | ############################################################################# |
2314 | ############################################################################# |
2245 | # urxvt::overlay |
2315 | # urxvt::overlay |
… | |
… | |
2390 | INIT: |
2460 | INIT: |
2391 | rgba cc = parse_rgba (c, THIS->s); |
2461 | rgba cc = parse_rgba (c, THIS->s); |
2392 | C_ARGS: cc |
2462 | C_ARGS: cc |
2393 | |
2463 | |
2394 | rxvt_img * |
2464 | rxvt_img * |
|
|
2465 | rxvt_img::shade (rxvt_img::nv factor) |
|
|
2466 | |
|
|
2467 | rxvt_img * |
2395 | rxvt_img::filter (octet_string name, SV *params = &PL_sv_undef) |
2468 | rxvt_img::filter (octet_string name, SV *params = &PL_sv_undef) |
2396 | CODE: |
2469 | CODE: |
2397 | rxvt_img::nv *vparams = 0; |
2470 | rxvt_img::nv *vparams = 0; |
2398 | int nparams = 0; |
2471 | int nparams = 0; |
2399 | |
2472 | |
2400 | if (SvOK (params)) |
2473 | if (SvOK (params)) |
2401 | { |
2474 | { |
2402 | // we overlay rxvt_temp_buf, what a hack |
|
|
2403 | assert (sizeof (rxvt_img::nv) >= sizeof (int)); |
|
|
2404 | |
|
|
2405 | if (!SvROK (params) || SvTYPE (SvRV (params)) != SVt_PVAV) |
2475 | if (!SvROK (params) || SvTYPE (SvRV (params)) != SVt_PVAV) |
2406 | croak ("rxvt_img::filter: params must be an array reference with parameter values"); |
2476 | croak ("rxvt_img::filter: params must be an array reference with parameter values"); |
2407 | |
2477 | |
2408 | nparams = av_len ((AV *)SvRV (params)) + 1; |
2478 | nparams = av_len ((AV *)SvRV (params)) + 1; |
2409 | vparams = rxvt_temp_buf<rxvt_img::nv> (nparams); |
2479 | vparams = (rxvt_img::nv *)malloc (nparams * sizeof (rxvt_img::nv)); |
2410 | |
2480 | |
2411 | for (int i = 0; i < nparams; ++i) |
2481 | for (int i = 0; i < nparams; ++i) |
2412 | vparams [i] = SvNV (*av_fetch ((AV *)SvRV (params), i, 1)); |
2482 | vparams [i] = SvNV (*av_fetch ((AV *)SvRV (params), i, 1)); |
2413 | } |
2483 | } |
2414 | |
2484 | |
2415 | RETVAL = THIS->filter (name, nparams, vparams); |
2485 | RETVAL = THIS->filter (name, nparams, vparams); |
|
|
2486 | free (vparams); |
2416 | OUTPUT: |
2487 | OUTPUT: |
2417 | RETVAL |
2488 | RETVAL |
2418 | |
2489 | |
2419 | #endif |
2490 | #endif |
2420 | |
2491 | |