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.155 by root, Sun Jun 3 10:38:22 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;
50 59
51///////////////////////////////////////////////////////////////////////////// 60/////////////////////////////////////////////////////////////////////////////
52 61
53static wchar_t * 62static wchar_t *
54sv2wcs (SV *sv) 63sv2wcs (SV *sv)
341 " unshift @INC, '" LIBDIR "';" 350 " unshift @INC, '" LIBDIR "';"
342 "}" 351 "}"
343 "" 352 ""
344 "use urxvt;" 353 "use urxvt;"
345 }; 354 };
346 int argc = ARRAY_LENGTH(args); 355 int argc = ecb_array_length (args);
347 char **argv = args; 356 char **argv = args;
348 357
349 PERL_SYS_INIT3 (&argc, &argv, &environ); 358 PERL_SYS_INIT3 (&argc, &argv, &environ);
350 perl = perl_alloc (); 359 perl = perl_alloc ();
351 perl_construct (perl); 360 perl_construct (perl);
367 if (perl) 376 if (perl)
368 { 377 {
369 // runs outside of perls ENV 378 // runs outside of perls ENV
370 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 379 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); 380 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
381 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
372 } 382 }
373} 383}
374 384
375static void 385static void
376ungrab (rxvt_term *THIS) 386ungrab (rxvt_term *THIS)
396 { 406 {
397 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 407 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
398 408
399 for (int i = 0; i <= AvFILL (av); i++) 409 for (int i = 0; i <= AvFILL (av); i++)
400 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 410 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
411 }
412 else if (htype == HOOK_DESTROY)
413 {
414 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
415
416 for (int i = AvFILL (av); i >= 0; i--)
417 {
418 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
419 delete req;
420 }
401 } 421 }
402 422
403 bool event_consumed; 423 bool event_consumed;
404 424
405 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 425 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
788 const_iv (XIMDontChange), 808 const_iv (XIMDontChange),
789# endif 809# endif
790# endif 810# endif
791 }; 811 };
792 812
793 for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) 813 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
794 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 814 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
795} 815}
796 816
797void 817void
798warn (const char *msg) 818warn (const char *msg)
799 CODE: 819 CODE:
876IV 896IV
877_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) 897_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
878 CODE: 898 CODE:
879 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); 899 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
880 req->cb_sv = newSVsv (cb); 900 req->cb_sv = newSVsv (cb);
901 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
902 av_push (av, newSViv ((IV)req));
881 RETVAL = (IV)req; 903 RETVAL = (IV)req;
882 OUTPUT: 904 OUTPUT:
883 RETVAL 905 RETVAL
884 906
885void 907void
886_delete_selection_request (IV req_) 908_delete_selection_request (IV req_)
887 CODE: 909 CODE:
888 rxvt_selection *req = (rxvt_selection *)req_; 910 rxvt_selection *req = (rxvt_selection *)req_;
911 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
912 int i;
913
914 for (i = AvFILL (av); i >= 0; i--)
915 if (SvIV (*av_fetch (av, i, 1)) == req_)
916 break;
917
918 for (; i < AvFILL (av); i++)
919 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
920
921 av_pop (av);
922
889 delete req; 923 delete req;
890 924
891MODULE = urxvt PACKAGE = urxvt::term 925MODULE = urxvt PACKAGE = urxvt::term
892 926
893SV * 927SV *
895 CODE: 929 CODE:
896{ 930{
897 rxvt_term *term = new rxvt_term; 931 rxvt_term *term = new rxvt_term;
898 932
899 stringvec *argv = new stringvec; 933 stringvec *argv = new stringvec;
900 stringvec *envv = new stringvec;
901
902 for (int i = 0; i <= AvFILL (arg); i++) 934 for (int i = 0; i <= AvFILL (arg); i++)
903 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 935 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
904 936
937 stringvec *envv = new stringvec;
905 for (int i = AvFILL (env) + 1; i--; ) 938 for (int i = AvFILL (env) + 1; i--; )
906 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 939 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
907
908 envv->push_back (0);
909 940
910 try 941 try
911 { 942 {
912 term->init (argv, envv); 943 term->init (argv, envv);
913 } 944 }
953 984
954void 985void
955rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 986rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
956 CODE: 987 CODE:
957 XUngrabKey (THIS->dpy, keycode, modifiers, window); 988 XUngrabKey (THIS->dpy, keycode, modifiers, window);
958
959void
960rxvt_term::XUngrabKeyboard (Time eventtime)
961 CODE:
962 XUngrabKeyboard (THIS->dpy, eventtime);
963 989
964bool 990bool
965rxvt_term::grab (Time eventtime, int sync = 0) 991rxvt_term::grab (Time eventtime, int sync = 0)
966 CODE: 992 CODE:
967{ 993{
1079 rxvt_pop_locale (); 1105 rxvt_pop_locale ();
1080 1106
1081 RETVAL = wcs2sv (wstr); 1107 RETVAL = wcs2sv (wstr);
1082 free (wstr); 1108 free (wstr);
1083} 1109}
1084 OUTPUT:
1085 RETVAL
1086
1087char *
1088rxvt_term::locale ()
1089 CODE:
1090 RETVAL = THIS->locale;
1091 OUTPUT: 1110 OUTPUT:
1092 RETVAL 1111 RETVAL
1093 1112
1094#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1113#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1095 1114
1241} 1260}
1242 OUTPUT: 1261 OUTPUT:
1243 RETVAL 1262 RETVAL
1244 1263
1245void 1264void
1265rxvt_term::set_urgency (bool enable)
1266
1267void
1246rxvt_term::focus_in () 1268rxvt_term::focus_in ()
1247 1269
1248void 1270void
1249rxvt_term::focus_out () 1271rxvt_term::focus_out ()
1250 1272
1481# include "rsinc.h" 1503# include "rsinc.h"
1482# undef def 1504# undef def
1483# undef reserve 1505# undef reserve
1484 }; 1506 };
1485 1507
1486 rs = rslist + ARRAY_LENGTH(rslist); 1508 rs = rslist + ecb_array_length (rslist);
1487 1509
1488 if (*name) 1510 if (*name)
1489 { 1511 {
1490 do { 1512 do {
1491 if (rs-- == rslist) 1513 if (rs-- == rslist)
1530 1552
1531 if (set >= 0) 1553 if (set >= 0)
1532 { 1554 {
1533 THIS->set_option (optval, set); 1555 THIS->set_option (optval, set);
1534 1556
1535 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1557 if (THIS->init_done) // avoid doing this before START
1536 switch (optval) 1558 switch (optval)
1537 { 1559 {
1538 case Opt_skipBuiltinGlyphs: 1560 case Opt_skipBuiltinGlyphs:
1539 THIS->set_fonts (); 1561 THIS->set_fonts ();
1540 THIS->scr_remap_chars (); 1562 THIS->scr_remap_chars ();
1541 THIS->scr_touch (true); 1563 THIS->scr_touch (true);
1542 THIS->want_refresh = 1; 1564 THIS->want_refresh = 1;
1543 THIS->refresh_check (); 1565 THIS->refresh_check ();
1544 break; 1566 break;
1567#ifdef CURSOR_BLINK
1568 case Opt_cursorBlink:
1569 THIS->cursor_blink_reset ();
1570 break;
1571#endif
1545 1572
1546 case Opt_cursorUnderline: 1573 case Opt_cursorUnderline:
1547 THIS->want_refresh = 1; 1574 THIS->want_refresh = 1;
1548 THIS->refresh_check (); 1575 THIS->refresh_check ();
1549 break; 1576 break;
1563 CODE: 1590 CODE:
1564 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1591 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1565 THIS->keyboard->register_done (); 1592 THIS->keyboard->register_done ();
1566 OUTPUT: 1593 OUTPUT:
1567 RETVAL 1594 RETVAL
1595
1596void
1597rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1598 CODE:
1599 wchar_t *wstr = sv2wcs (str);
1600 THIS->keyboard->register_user_translation (keysym, state, wstr);
1601 free (wstr);
1568 1602
1569void 1603void
1570rxvt_term::screen_cur (...) 1604rxvt_term::screen_cur (...)
1571 PROTOTYPE: $;$$ 1605 PROTOTYPE: $;$$
1572 ALIAS: 1606 ALIAS:
1894void 1928void
1895overlay::DESTROY () 1929overlay::DESTROY ()
1896 1930
1897INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | 1931INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g |
1898 1932
1933MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_
1934
1935urxvt::pixbuf gdk_pixbuf_new_from_file (octet_string filename, GError **error = 0)
1936
1937void
1938DESTROY (urxvt::pixbuf self)
1939 CODE:
1940 gdk_pixbuf_unref (self);
1941

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines