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.216 by root, Thu Oct 3 01:11:38 2013 UTC vs.
Revision 1.236 by sf-exg, Tue Mar 17 09:23:08 2015 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
490 490
491 FREETMPS; 491 FREETMPS;
492 LEAVE; 492 LEAVE;
493 493
494 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);
495} 514}
496 515
497static void 516static void
498ungrab (rxvt_term *THIS) 517ungrab (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),
816 const_iv (RS_Uline), 839 const_iv (RS_Uline),
817 840
818 // TODO: should support all colour constants, create colorinc.h &c 841 // TODO: should support all colour constants, create colorinc.h &c
819 const_iv (Color_fg), 842 const_iv (Color_fg),
820 const_iv (Color_bg), 843 const_iv (Color_bg),
844#if OFF_FOCUS_FADING
821 const_iv (Color_fade), 845 const_iv (Color_fade),
846#endif
822 const_iv (Color_pointer_fg), 847 const_iv (Color_pointer_fg),
823 const_iv (Color_pointer_bg), 848 const_iv (Color_pointer_bg),
824 const_iv (Color_border), 849 const_iv (Color_border),
825 const_iv (NRS_COLORS), 850 const_iv (NRS_COLORS),
826 const_iv (TOTAL_COLORS), 851 const_iv (TOTAL_COLORS),
1002 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--)
1003 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); 1028 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
1004} 1029}
1005 1030
1006void 1031void
1007log (const char *msg) 1032log (utf8_string msg)
1008 CODE: 1033 CODE:
1009 rxvt_log ("%s", msg); 1034 rxvt_log ("%s", msg);
1010 1035
1011void 1036void
1012warn (const char *msg) 1037warn (utf8_string msg)
1013 CODE: 1038 CODE:
1014 rxvt_warn ("%s", msg); 1039 rxvt_warn ("%s", msg);
1015 1040
1016void 1041void
1017fatal (const char *msg) 1042fatal (utf8_string msg)
1018 CODE: 1043 CODE:
1019 rxvt_fatal ("%s", msg); 1044 rxvt_fatal ("%s", msg);
1020 1045
1021void 1046void
1022_exit (int status) 1047_exit (int status)
1187void 1212void
1188rxvt_term::put_option_db (octet_string specifier, octet_string value) 1213rxvt_term::put_option_db (octet_string specifier, octet_string value)
1189 CODE: 1214 CODE:
1190 XrmPutStringResource (&THIS->option_db, specifier, value); 1215 XrmPutStringResource (&THIS->option_db, specifier, value);
1191 1216
1217void
1218rxvt_term::_keysym_resources ()
1219 PPCODE:
1220 PUTBACK;
1221 _keysym_resources (THIS);
1222 SPAGAIN;
1223
1192int 1224int
1193rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) 1225rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt)
1194 CODE: 1226 CODE:
1195 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, 1227 RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1,
1196 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, 1228 ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1255rxvt_term::ungrab () 1287rxvt_term::ungrab ()
1256 CODE: 1288 CODE:
1257 ungrab (THIS); 1289 ungrab (THIS);
1258 1290
1259int 1291int
1260rxvt_term::XStringToKeysym (char *string) 1292rxvt_term::XStringToKeysym (octet_string string)
1261 CODE: 1293 CODE:
1262 RETVAL = XStringToKeysym (string); 1294 RETVAL = XStringToKeysym (string);
1263 OUTPUT: RETVAL 1295 OUTPUT: RETVAL
1264 1296
1265char * 1297char *
1275 OUTPUT: RETVAL 1307 OUTPUT: RETVAL
1276 1308
1277int 1309int
1278rxvt_term::XKeycodeToKeysym (int code, int index) 1310rxvt_term::XKeycodeToKeysym (int code, int index)
1279 CODE: 1311 CODE:
1280 RETVAL = XKeycodeToKeysym (THIS->dpy, code, index); 1312 RETVAL = rxvt_XKeycodeToKeysym (THIS->dpy, code, index);
1281 OUTPUT: RETVAL 1313 OUTPUT: RETVAL
1282 1314
1283int 1315int
1284rxvt_term::strwidth (SV *str) 1316rxvt_term::strwidth (SV *str)
1285 CODE: 1317 CODE:
1542 CODE: 1574 CODE:
1543 THIS->want_refresh = 1; 1575 THIS->want_refresh = 1;
1544 THIS->refresh_check (); 1576 THIS->refresh_check ();
1545 1577
1546void 1578void
1579rxvt_term::refresh_check ()
1580
1581void
1547rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) 1582rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS)
1548 PPCODE: 1583 PPCODE:
1549{ 1584{
1550 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) 1585 if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow))
1551 XSRETURN_EMPTY; 1586 XSRETURN_EMPTY;
1694 *r++ = NOCHAR; 1729 *r++ = NOCHAR;
1695 } 1730 }
1696 1731
1697 rxvt_pop_locale (); 1732 rxvt_pop_locale ();
1698 1733
1734 free (wstr);
1699 RETVAL = wcs2sv (rstr, r - rstr); 1735 RETVAL = wcs2sv (rstr, r - rstr);
1700} 1736}
1701 OUTPUT: 1737 OUTPUT:
1702 RETVAL 1738 RETVAL
1703 1739
1727 else if (IS_COMPOSE (*s)) 1763 else if (IS_COMPOSE (*s))
1728 r += rxvt_composite.expand (*s, r); 1764 r += rxvt_composite.expand (*s, r);
1729 else 1765 else
1730 *r++ = *s; 1766 *r++ = *s;
1731 1767
1768 free (wstr);
1732 RETVAL = wcs2sv (rstr, r - rstr); 1769 RETVAL = wcs2sv (rstr, r - rstr);
1733} 1770}
1734 OUTPUT: 1771 OUTPUT:
1735 RETVAL 1772 RETVAL
1736 1773
1737void 1774void
1738rxvt_term::_resource (char *name, int index, SV *newval = 0) 1775rxvt_term::_resource (octet_string name, int index, SV *newval = 0)
1739 PPCODE: 1776 PPCODE:
1740{ 1777{
1741 static const struct resval { const char *name; int value; } *rs, rslist [] = { 1778 static const struct resval { const char *name; int value; } *rs, rslist [] = {
1742# define def(name) { # name, Rs_ ## name }, 1779# define def(name) { # name, Rs_ ## name },
1743# define reserve(name,count) 1780# define reserve(name,count)
1781 THIS->rs [index] = 0; 1818 THIS->rs [index] = 0;
1782 } 1819 }
1783} 1820}
1784 1821
1785const char * 1822const char *
1786rxvt_term::x_resource (const char *name) 1823rxvt_term::x_resource (octet_string name)
1787 1824
1788bool 1825bool
1789rxvt_term::option (U8 optval, int set = -1) 1826rxvt_term::option (U8 optval, int set = -1)
1790 CODE: 1827 CODE:
1791{ 1828{
1810 THIS->cursor_blink_reset (); 1847 THIS->cursor_blink_reset ();
1811 break; 1848 break;
1812#endif 1849#endif
1813 1850
1814 case Opt_cursorUnderline: 1851 case Opt_cursorUnderline:
1852 THIS->cursor_type = set ? 1 : 0;
1815 THIS->want_refresh = 1; 1853 THIS->want_refresh = 1;
1816 THIS->refresh_check (); 1854 THIS->refresh_check ();
1817 break; 1855 break;
1818 1856
1819# case Opt_scrollBar_floating: 1857# case Opt_scrollBar_floating:
1824 } 1862 }
1825} 1863}
1826 OUTPUT: 1864 OUTPUT:
1827 RETVAL 1865 RETVAL
1828 1866
1867SV *
1868rxvt_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
1829bool 1877bool
1830rxvt_term::parse_keysym (char *keysym, char *str) 1878rxvt_term::bind_action (octet_string keysym, octet_string action)
1879 ALIAS:
1880 parse_keysym = 1
1831 CODE: 1881 CODE:
1832 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1882 RETVAL = 0 < THIS->bind_action (keysym, action);
1833 THIS->keyboard->register_done (); 1883 THIS->keyboard->register_done ();
1834 OUTPUT: 1884 OUTPUT:
1835 RETVAL 1885 RETVAL
1836 1886
1837void 1887void
1838rxvt_term::register_command (int keysym, unsigned int state, SV *str) 1888rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1839 CODE: 1889 CODE:
1840 wchar_t *wstr = sv2wcs (str); 1890 wchar_t *wstr = sv2wcs (str);
1841 THIS->keyboard->register_user_translation (keysym, state, wstr); 1891 THIS->keyboard->register_action (keysym, state, wstr);
1842 free (wstr); 1892 free (wstr);
1843 1893
1844void 1894void
1845rxvt_term::screen_cur (...) 1895rxvt_term::screen_cur (...)
1846 PROTOTYPE: $;$$ 1896 PROTOTYPE: $;$$
1958 2008
1959void 2009void
1960rxvt_term::scr_bell () 2010rxvt_term::scr_bell ()
1961 2011
1962void 2012void
1963rxvt_term::scr_recolour (bool refresh = true); 2013rxvt_term::scr_recolor (bool refresh = true);
1964 2014
1965void 2015void
1966rxvt_term::scr_change_screen (int screen) 2016rxvt_term::scr_change_screen (int screen)
1967 2017
1968void 2018void
1971{ 2021{
1972 wchar_t *wstr = sv2wcs (string); 2022 wchar_t *wstr = sv2wcs (string);
1973 THIS->scr_add_lines (wstr, wcslen (wstr)); 2023 THIS->scr_add_lines (wstr, wcslen (wstr));
1974 free (wstr); 2024 free (wstr);
1975} 2025}
2026
2027void
2028rxvt_term::tt_write_user_input (SV *octets)
2029 INIT:
2030 STRLEN len;
2031 char *str = SvPVbyte (octets, len);
2032 C_ARGS:
2033 str, len
1976 2034
1977void 2035void
1978rxvt_term::tt_write (SV *octets) 2036rxvt_term::tt_write (SV *octets)
1979 INIT: 2037 INIT:
1980 STRLEN len; 2038 STRLEN len;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines