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.140 by sf-exg, Thu Apr 7 12:19:41 2011 UTC vs.
Revision 1.157 by root, Sun Jun 3 15:54:15 2012 UTC

23#define line_t perl_line_t 23#define line_t perl_line_t
24#include <EXTERN.h> 24#include <EXTERN.h>
25#include <perl.h> 25#include <perl.h>
26#include <XSUB.h> 26#include <XSUB.h>
27#undef line_t 27#undef line_t
28#undef bool // perl defines it's own bool type, except with g++... what a trap
28 29
29#include "../config.h" 30#include "../config.h"
30 31
31#include <cstddef> 32#include <stddef.h>
32#include <cstdarg> 33#include <stdarg.h>
33 34
34#include "unistd.h" 35#include "unistd.h"
35 36
36#include "ev_cpp.h" 37#include "ev_cpp.h"
37#include "rxvt.h" 38#include "rxvt.h"
45 46
46#undef LINENO 47#undef LINENO
47#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) 48#define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows)
48#undef ROW 49#undef ROW
49#define ROW(n) THIS->row_buf [LINENO (n)] 50#define ROW(n) THIS->row_buf [LINENO (n)]
51
52/////////////////////////////////////////////////////////////////////////////
53
54typedef char * octet_string;
55typedef char * utf8_string;
56
57typedef GdkPixbuf * urxvt__pixbuf;
58typedef rxvt_img * urxvt__img;
59
60/////////////////////////////////////////////////////////////////////////////
61
62static void
63parse_color (rxvt_screen *s, rxvt_color &c, SV *sv)
64{
65 //TODO: support component stuff
66 c.set (s, SvPVbyte_nolen (sv));
67}
50 68
51///////////////////////////////////////////////////////////////////////////// 69/////////////////////////////////////////////////////////////////////////////
52 70
53static wchar_t * 71static wchar_t *
54sv2wcs (SV *sv) 72sv2wcs (SV *sv)
341 " unshift @INC, '" LIBDIR "';" 359 " unshift @INC, '" LIBDIR "';"
342 "}" 360 "}"
343 "" 361 ""
344 "use urxvt;" 362 "use urxvt;"
345 }; 363 };
346 int argc = ARRAY_LENGTH(args); 364 int argc = ecb_array_length (args);
347 char **argv = args; 365 char **argv = args;
348 366
349 PERL_SYS_INIT3 (&argc, &argv, &environ); 367 PERL_SYS_INIT3 (&argc, &argv, &environ);
350 perl = perl_alloc (); 368 perl = perl_alloc ();
351 perl_construct (perl); 369 perl_construct (perl);
367 if (perl) 385 if (perl)
368 { 386 {
369 // runs outside of perls ENV 387 // runs outside of perls ENV
370 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 388 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term");
371 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); 389 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
390 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
372 } 391 }
373} 392}
374 393
375static void 394static void
376ungrab (rxvt_term *THIS) 395ungrab (rxvt_term *THIS)
396 { 415 {
397 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 416 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
398 417
399 for (int i = 0; i <= AvFILL (av); i++) 418 for (int i = 0; i <= AvFILL (av); i++)
400 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 419 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
420 }
421 else if (htype == HOOK_DESTROY)
422 {
423 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
424
425 for (int i = AvFILL (av); i >= 0; i--)
426 {
427 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
428 delete req;
429 }
401 } 430 }
402 431
403 bool event_consumed; 432 bool event_consumed;
404 433
405 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 434 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
788 const_iv (XIMDontChange), 817 const_iv (XIMDontChange),
789# endif 818# endif
790# endif 819# endif
791 }; 820 };
792 821
793 for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) 822 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
794 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 823 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
795} 824}
796 825
797void 826void
798warn (const char *msg) 827warn (const char *msg)
799 CODE: 828 CODE:
876IV 905IV
877_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) 906_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
878 CODE: 907 CODE:
879 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); 908 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
880 req->cb_sv = newSVsv (cb); 909 req->cb_sv = newSVsv (cb);
910 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
911 av_push (av, newSViv ((IV)req));
881 RETVAL = (IV)req; 912 RETVAL = (IV)req;
882 OUTPUT: 913 OUTPUT:
883 RETVAL 914 RETVAL
884 915
885void 916void
886_delete_selection_request (IV req_) 917_delete_selection_request (IV req_)
887 CODE: 918 CODE:
888 rxvt_selection *req = (rxvt_selection *)req_; 919 rxvt_selection *req = (rxvt_selection *)req_;
920 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
921 int i;
922
923 for (i = AvFILL (av); i >= 0; i--)
924 if (SvIV (*av_fetch (av, i, 1)) == req_)
925 break;
926
927 for (; i < AvFILL (av); i++)
928 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
929
930 av_pop (av);
931
889 delete req; 932 delete req;
890 933
891MODULE = urxvt PACKAGE = urxvt::term 934MODULE = urxvt PACKAGE = urxvt::term
892 935
893SV * 936SV *
895 CODE: 938 CODE:
896{ 939{
897 rxvt_term *term = new rxvt_term; 940 rxvt_term *term = new rxvt_term;
898 941
899 stringvec *argv = new stringvec; 942 stringvec *argv = new stringvec;
900 stringvec *envv = new stringvec;
901
902 for (int i = 0; i <= AvFILL (arg); i++) 943 for (int i = 0; i <= AvFILL (arg); i++)
903 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 944 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
904 945
946 stringvec *envv = new stringvec;
905 for (int i = AvFILL (env) + 1; i--; ) 947 for (int i = AvFILL (env) + 1; i--; )
906 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 948 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
907
908 envv->push_back (0);
909 949
910 try 950 try
911 { 951 {
912 term->init (argv, envv); 952 term->init (argv, envv);
913 } 953 }
953 993
954void 994void
955rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 995rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
956 CODE: 996 CODE:
957 XUngrabKey (THIS->dpy, keycode, modifiers, window); 997 XUngrabKey (THIS->dpy, keycode, modifiers, window);
958
959void
960rxvt_term::XUngrabKeyboard (Time eventtime)
961 CODE:
962 XUngrabKeyboard (THIS->dpy, eventtime);
963 998
964bool 999bool
965rxvt_term::grab (Time eventtime, int sync = 0) 1000rxvt_term::grab (Time eventtime, int sync = 0)
966 CODE: 1001 CODE:
967{ 1002{
1079 rxvt_pop_locale (); 1114 rxvt_pop_locale ();
1080 1115
1081 RETVAL = wcs2sv (wstr); 1116 RETVAL = wcs2sv (wstr);
1082 free (wstr); 1117 free (wstr);
1083} 1118}
1084 OUTPUT:
1085 RETVAL
1086
1087char *
1088rxvt_term::locale ()
1089 CODE:
1090 RETVAL = THIS->locale;
1091 OUTPUT: 1119 OUTPUT:
1092 RETVAL 1120 RETVAL
1093 1121
1094#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1122#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1095 1123
1241} 1269}
1242 OUTPUT: 1270 OUTPUT:
1243 RETVAL 1271 RETVAL
1244 1272
1245void 1273void
1274rxvt_term::set_urgency (bool enable)
1275
1276void
1246rxvt_term::focus_in () 1277rxvt_term::focus_in ()
1247 1278
1248void 1279void
1249rxvt_term::focus_out () 1280rxvt_term::focus_out ()
1250 1281
1481# include "rsinc.h" 1512# include "rsinc.h"
1482# undef def 1513# undef def
1483# undef reserve 1514# undef reserve
1484 }; 1515 };
1485 1516
1486 rs = rslist + ARRAY_LENGTH(rslist); 1517 rs = rslist + ecb_array_length (rslist);
1487 1518
1488 if (*name) 1519 if (*name)
1489 { 1520 {
1490 do { 1521 do {
1491 if (rs-- == rslist) 1522 if (rs-- == rslist)
1530 1561
1531 if (set >= 0) 1562 if (set >= 0)
1532 { 1563 {
1533 THIS->set_option (optval, set); 1564 THIS->set_option (optval, set);
1534 1565
1535 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1566 if (THIS->init_done) // avoid doing this before START
1536 switch (optval) 1567 switch (optval)
1537 { 1568 {
1538 case Opt_skipBuiltinGlyphs: 1569 case Opt_skipBuiltinGlyphs:
1539 THIS->set_fonts (); 1570 THIS->set_fonts ();
1540 THIS->scr_remap_chars (); 1571 THIS->scr_remap_chars ();
1541 THIS->scr_touch (true); 1572 THIS->scr_touch (true);
1542 THIS->want_refresh = 1; 1573 THIS->want_refresh = 1;
1543 THIS->refresh_check (); 1574 THIS->refresh_check ();
1544 break; 1575 break;
1576#ifdef CURSOR_BLINK
1577 case Opt_cursorBlink:
1578 THIS->cursor_blink_reset ();
1579 break;
1580#endif
1545 1581
1546 case Opt_cursorUnderline: 1582 case Opt_cursorUnderline:
1547 THIS->want_refresh = 1; 1583 THIS->want_refresh = 1;
1548 THIS->refresh_check (); 1584 THIS->refresh_check ();
1549 break; 1585 break;
1563 CODE: 1599 CODE:
1564 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1600 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1565 THIS->keyboard->register_done (); 1601 THIS->keyboard->register_done ();
1566 OUTPUT: 1602 OUTPUT:
1567 RETVAL 1603 RETVAL
1604
1605void
1606rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1607 CODE:
1608 wchar_t *wstr = sv2wcs (str);
1609 THIS->keyboard->register_user_translation (keysym, state, wstr);
1610 free (wstr);
1568 1611
1569void 1612void
1570rxvt_term::screen_cur (...) 1613rxvt_term::screen_cur (...)
1571 PROTOTYPE: $;$$ 1614 PROTOTYPE: $;$$
1572 ALIAS: 1615 ALIAS:
1894void 1937void
1895overlay::DESTROY () 1938overlay::DESTROY ()
1896 1939
1897INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 1940INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1898 1941
1942MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
1943
1944#if HAVE_PIXBUF
1945
1946urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename)
1947 C_ARGS: filename, 0
1948
1949void
1950DESTROY (urxvt::pixbuf self)
1951 CODE:
1952 gdk_pixbuf_unref (self);
1953
1954#endif
1955
1956MODULE = urxvt PACKAGE = urxvt::img
1957
1958#if HAVE_IMG
1959
1960# rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height);
1961# rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap);
1962
1963void fill (urxvt::img self, SV *c)
1964 CODE:
1965 rxvt_color rc;
1966 parse_color (self->s, rc, c);
1967 self->fill (rc);
1968
1969void blur (urxvt::img self, int rh, int rv)
1970 CODE:
1971 self->blur (rh, rv);
1972
1973void brightness (urxvt::img self, double r, double g, double b, double a = 1.)
1974 CODE:
1975 self->brightness (r, g, b, a);
1976
1977void contrast (urxvt::img self, double r, double g, double b, double a = 1.)
1978 CODE:
1979 self->contrast (r, g, b, a);
1980
1981urxvt::img copy (urxvt::img self)
1982 CODE:
1983 RETVAL = self->copy ();
1984 OUTPUT:
1985 RETVAL
1986
1987urxvt::img scale (urxvt::img self, int new_width, int new_height)
1988 CODE:
1989 RETVAL = self->scale (new_width, new_height);
1990 OUTPUT:
1991 RETVAL
1992
1993# rxvt_img *transform (urxvt::img self, int new_width, int new_height, double matrix[16]);
1994
1995#endif
1996

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines