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 | { |
… | |
… | |
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 } |
798 | const_iv (HOOK_INIT), |
817 | const_iv (HOOK_INIT), |
799 | const_iv (HOOK_DESTROY), |
818 | const_iv (HOOK_DESTROY), |
800 | const_iv (HOOK_KEYBOARD_DISPATCH), |
819 | const_iv (HOOK_ACTION), |
801 | |
820 | |
802 | const_iv (NUM_RESOURCES), |
821 | const_iv (NUM_RESOURCES), |
803 | const_iv (DEFAULT_RSTYLE), |
822 | const_iv (DEFAULT_RSTYLE), |
804 | const_iv (OVERLAY_RSTYLE), |
823 | const_iv (OVERLAY_RSTYLE), |
805 | const_iv (Color_Bits), |
824 | const_iv (Color_Bits), |
… | |
… | |
1008 | 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--) |
1009 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
1028 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
1010 | } |
1029 | } |
1011 | |
1030 | |
1012 | void |
1031 | void |
1013 | log (const char *msg) |
1032 | log (utf8_string msg) |
1014 | CODE: |
1033 | CODE: |
1015 | rxvt_log ("%s", msg); |
1034 | rxvt_log ("%s", msg); |
1016 | |
1035 | |
1017 | void |
1036 | void |
1018 | warn (const char *msg) |
1037 | warn (utf8_string msg) |
1019 | CODE: |
1038 | CODE: |
1020 | rxvt_warn ("%s", msg); |
1039 | rxvt_warn ("%s", msg); |
1021 | |
1040 | |
1022 | void |
1041 | void |
1023 | fatal (const char *msg) |
1042 | fatal (utf8_string msg) |
1024 | CODE: |
1043 | CODE: |
1025 | rxvt_fatal ("%s", msg); |
1044 | rxvt_fatal ("%s", msg); |
1026 | |
1045 | |
1027 | void |
1046 | void |
1028 | _exit (int status) |
1047 | _exit (int status) |
… | |
… | |
1193 | void |
1212 | void |
1194 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
1213 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
1195 | CODE: |
1214 | CODE: |
1196 | XrmPutStringResource (&THIS->option_db, specifier, value); |
1215 | XrmPutStringResource (&THIS->option_db, specifier, value); |
1197 | |
1216 | |
|
|
1217 | void |
|
|
1218 | rxvt_term::_keysym_resources () |
|
|
1219 | PPCODE: |
|
|
1220 | PUTBACK; |
|
|
1221 | _keysym_resources (THIS); |
|
|
1222 | SPAGAIN; |
|
|
1223 | |
1198 | int |
1224 | int |
1199 | 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) |
1200 | CODE: |
1226 | CODE: |
1201 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1227 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1202 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1228 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
… | |
… | |
1261 | rxvt_term::ungrab () |
1287 | rxvt_term::ungrab () |
1262 | CODE: |
1288 | CODE: |
1263 | ungrab (THIS); |
1289 | ungrab (THIS); |
1264 | |
1290 | |
1265 | int |
1291 | int |
1266 | rxvt_term::XStringToKeysym (char *string) |
1292 | rxvt_term::XStringToKeysym (octet_string string) |
1267 | CODE: |
1293 | CODE: |
1268 | RETVAL = XStringToKeysym (string); |
1294 | RETVAL = XStringToKeysym (string); |
1269 | OUTPUT: RETVAL |
1295 | OUTPUT: RETVAL |
1270 | |
1296 | |
1271 | char * |
1297 | char * |
… | |
… | |
1281 | OUTPUT: RETVAL |
1307 | OUTPUT: RETVAL |
1282 | |
1308 | |
1283 | int |
1309 | int |
1284 | rxvt_term::XKeycodeToKeysym (int code, int index) |
1310 | rxvt_term::XKeycodeToKeysym (int code, int index) |
1285 | CODE: |
1311 | CODE: |
1286 | RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); |
1312 | RETVAL = rxvt_XKeycodeToKeysym (THIS->dpy, code, index); |
1287 | OUTPUT: RETVAL |
1313 | OUTPUT: RETVAL |
1288 | |
1314 | |
1289 | int |
1315 | int |
1290 | rxvt_term::strwidth (SV *str) |
1316 | rxvt_term::strwidth (SV *str) |
1291 | CODE: |
1317 | CODE: |
… | |
… | |
1548 | CODE: |
1574 | CODE: |
1549 | THIS->want_refresh = 1; |
1575 | THIS->want_refresh = 1; |
1550 | THIS->refresh_check (); |
1576 | THIS->refresh_check (); |
1551 | |
1577 | |
1552 | void |
1578 | void |
|
|
1579 | rxvt_term::refresh_check () |
|
|
1580 | |
|
|
1581 | void |
1553 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1582 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1554 | PPCODE: |
1583 | PPCODE: |
1555 | { |
1584 | { |
1556 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1585 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1557 | XSRETURN_EMPTY; |
1586 | XSRETURN_EMPTY; |
… | |
… | |
1700 | *r++ = NOCHAR; |
1729 | *r++ = NOCHAR; |
1701 | } |
1730 | } |
1702 | |
1731 | |
1703 | rxvt_pop_locale (); |
1732 | rxvt_pop_locale (); |
1704 | |
1733 | |
|
|
1734 | free (wstr); |
1705 | RETVAL = wcs2sv (rstr, r - rstr); |
1735 | RETVAL = wcs2sv (rstr, r - rstr); |
1706 | } |
1736 | } |
1707 | OUTPUT: |
1737 | OUTPUT: |
1708 | RETVAL |
1738 | RETVAL |
1709 | |
1739 | |
… | |
… | |
1733 | else if (IS_COMPOSE (*s)) |
1763 | else if (IS_COMPOSE (*s)) |
1734 | r += rxvt_composite.expand (*s, r); |
1764 | r += rxvt_composite.expand (*s, r); |
1735 | else |
1765 | else |
1736 | *r++ = *s; |
1766 | *r++ = *s; |
1737 | |
1767 | |
|
|
1768 | free (wstr); |
1738 | RETVAL = wcs2sv (rstr, r - rstr); |
1769 | RETVAL = wcs2sv (rstr, r - rstr); |
1739 | } |
1770 | } |
1740 | OUTPUT: |
1771 | OUTPUT: |
1741 | RETVAL |
1772 | RETVAL |
1742 | |
1773 | |
1743 | void |
1774 | void |
1744 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1775 | rxvt_term::_resource (octet_string name, int index, SV *newval = 0) |
1745 | PPCODE: |
1776 | PPCODE: |
1746 | { |
1777 | { |
1747 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1778 | static const struct resval { const char *name; int value; } *rs, rslist [] = { |
1748 | # define def(name) { # name, Rs_ ## name }, |
1779 | # define def(name) { # name, Rs_ ## name }, |
1749 | # define reserve(name,count) |
1780 | # define reserve(name,count) |
… | |
… | |
1787 | THIS->rs [index] = 0; |
1818 | THIS->rs [index] = 0; |
1788 | } |
1819 | } |
1789 | } |
1820 | } |
1790 | |
1821 | |
1791 | const char * |
1822 | const char * |
1792 | rxvt_term::x_resource (const char *name) |
1823 | rxvt_term::x_resource (octet_string name) |
1793 | |
1824 | |
1794 | bool |
1825 | bool |
1795 | rxvt_term::option (U8 optval, int set = -1) |
1826 | rxvt_term::option (U8 optval, int set = -1) |
1796 | CODE: |
1827 | CODE: |
1797 | { |
1828 | { |
… | |
… | |
1816 | THIS->cursor_blink_reset (); |
1847 | THIS->cursor_blink_reset (); |
1817 | break; |
1848 | break; |
1818 | #endif |
1849 | #endif |
1819 | |
1850 | |
1820 | case Opt_cursorUnderline: |
1851 | case Opt_cursorUnderline: |
|
|
1852 | THIS->cursor_type = set ? 1 : 0; |
1821 | THIS->want_refresh = 1; |
1853 | THIS->want_refresh = 1; |
1822 | THIS->refresh_check (); |
1854 | THIS->refresh_check (); |
1823 | break; |
1855 | break; |
1824 | |
1856 | |
1825 | # case Opt_scrollBar_floating: |
1857 | # case Opt_scrollBar_floating: |
… | |
… | |
1830 | } |
1862 | } |
1831 | } |
1863 | } |
1832 | OUTPUT: |
1864 | OUTPUT: |
1833 | RETVAL |
1865 | RETVAL |
1834 | |
1866 | |
|
|
1867 | SV * |
|
|
1868 | rxvt_term::lookup_keysym (int keysym, unsigned int state) |
|
|
1869 | CODE: |
|
|
1870 | { |
|
|
1871 | keysym_t *key = THIS->keyboard->lookup_keysym (THIS, keysym, state); |
|
|
1872 | RETVAL = key ? sv_2mortal (newSVpv (key->str, 0)) : &PL_sv_undef; |
|
|
1873 | } |
|
|
1874 | OUTPUT: |
|
|
1875 | RETVAL |
|
|
1876 | |
1835 | bool |
1877 | bool |
1836 | rxvt_term::parse_keysym (char *keysym, char *str) |
1878 | rxvt_term::bind_action (octet_string keysym, octet_string action) |
|
|
1879 | ALIAS: |
|
|
1880 | parse_keysym = 1 |
1837 | CODE: |
1881 | CODE: |
1838 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1882 | RETVAL = 0 < THIS->bind_action (keysym, action); |
1839 | THIS->keyboard->register_done (); |
1883 | THIS->keyboard->register_done (); |
1840 | OUTPUT: |
1884 | OUTPUT: |
1841 | RETVAL |
1885 | RETVAL |
1842 | |
1886 | |
1843 | void |
1887 | void |
1844 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
1888 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
1845 | CODE: |
1889 | CODE: |
1846 | wchar_t *wstr = sv2wcs (str); |
1890 | wchar_t *wstr = sv2wcs (str); |
1847 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
1891 | THIS->keyboard->register_action (keysym, state, wstr); |
1848 | free (wstr); |
1892 | free (wstr); |
1849 | |
1893 | |
1850 | void |
1894 | void |
1851 | rxvt_term::screen_cur (...) |
1895 | rxvt_term::screen_cur (...) |
1852 | PROTOTYPE: $;$$ |
1896 | PROTOTYPE: $;$$ |
… | |
… | |
1964 | |
2008 | |
1965 | void |
2009 | void |
1966 | rxvt_term::scr_bell () |
2010 | rxvt_term::scr_bell () |
1967 | |
2011 | |
1968 | void |
2012 | void |
1969 | rxvt_term::scr_recolour (bool refresh = true); |
2013 | rxvt_term::scr_recolor (bool refresh = true); |
1970 | |
2014 | |
1971 | void |
2015 | void |
1972 | rxvt_term::scr_change_screen (int screen) |
2016 | rxvt_term::scr_change_screen (int screen) |
1973 | |
2017 | |
1974 | void |
2018 | void |
… | |
… | |
1977 | { |
2021 | { |
1978 | wchar_t *wstr = sv2wcs (string); |
2022 | wchar_t *wstr = sv2wcs (string); |
1979 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
2023 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1980 | free (wstr); |
2024 | free (wstr); |
1981 | } |
2025 | } |
|
|
2026 | |
|
|
2027 | void |
|
|
2028 | rxvt_term::tt_write_user_input (SV *octets) |
|
|
2029 | INIT: |
|
|
2030 | STRLEN len; |
|
|
2031 | char *str = SvPVbyte (octets, len); |
|
|
2032 | C_ARGS: |
|
|
2033 | str, len |
1982 | |
2034 | |
1983 | void |
2035 | void |
1984 | rxvt_term::tt_write (SV *octets) |
2036 | rxvt_term::tt_write (SV *octets) |
1985 | INIT: |
2037 | INIT: |
1986 | STRLEN len; |
2038 | STRLEN len; |