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.153 by sf-exg, Wed Apr 11 10:20:00 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"
341 " unshift @INC, '" LIBDIR "';" 342 " unshift @INC, '" LIBDIR "';"
342 "}" 343 "}"
343 "" 344 ""
344 "use urxvt;" 345 "use urxvt;"
345 }; 346 };
346 int argc = ARRAY_LENGTH(args); 347 int argc = ecb_array_length (args);
347 char **argv = args; 348 char **argv = args;
348 349
349 PERL_SYS_INIT3 (&argc, &argv, &environ); 350 PERL_SYS_INIT3 (&argc, &argv, &environ);
350 perl = perl_alloc (); 351 perl = perl_alloc ();
351 perl_construct (perl); 352 perl_construct (perl);
367 if (perl) 368 if (perl)
368 { 369 {
369 // runs outside of perls ENV 370 // runs outside of perls ENV
370 term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); 371 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); 372 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0);
373 hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0);
372 } 374 }
373} 375}
374 376
375static void 377static void
376ungrab (rxvt_term *THIS) 378ungrab (rxvt_term *THIS)
396 { 398 {
397 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 399 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
398 400
399 for (int i = 0; i <= AvFILL (av); i++) 401 for (int i = 0; i <= AvFILL (av); i++)
400 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); 402 ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap ();
403 }
404 else if (htype == HOOK_DESTROY)
405 {
406 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
407
408 for (int i = AvFILL (av); i >= 0; i--)
409 {
410 rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0));
411 delete req;
412 }
401 } 413 }
402 414
403 bool event_consumed; 415 bool event_consumed;
404 416
405 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always 417 if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always
788 const_iv (XIMDontChange), 800 const_iv (XIMDontChange),
789# endif 801# endif
790# endif 802# endif
791 }; 803 };
792 804
793 for (civ = const_iv + ARRAY_LENGTH(const_iv); civ-- > const_iv; ) 805 for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--)
794 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 806 newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv));
795} 807}
796 808
797void 809void
798warn (const char *msg) 810warn (const char *msg)
799 CODE: 811 CODE:
876IV 888IV
877_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) 889_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
878 CODE: 890 CODE:
879 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); 891 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
880 req->cb_sv = newSVsv (cb); 892 req->cb_sv = newSVsv (cb);
893 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0));
894 av_push (av, newSViv ((IV)req));
881 RETVAL = (IV)req; 895 RETVAL = (IV)req;
882 OUTPUT: 896 OUTPUT:
883 RETVAL 897 RETVAL
884 898
885void 899void
886_delete_selection_request (IV req_) 900_delete_selection_request (IV req_)
887 CODE: 901 CODE:
888 rxvt_selection *req = (rxvt_selection *)req_; 902 rxvt_selection *req = (rxvt_selection *)req_;
903 AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0));
904 int i;
905
906 for (i = AvFILL (av); i >= 0; i--)
907 if (SvIV (*av_fetch (av, i, 1)) == req_)
908 break;
909
910 for (; i < AvFILL (av); i++)
911 av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0)));
912
913 av_pop (av);
914
889 delete req; 915 delete req;
890 916
891MODULE = urxvt PACKAGE = urxvt::term 917MODULE = urxvt PACKAGE = urxvt::term
892 918
893SV * 919SV *
895 CODE: 921 CODE:
896{ 922{
897 rxvt_term *term = new rxvt_term; 923 rxvt_term *term = new rxvt_term;
898 924
899 stringvec *argv = new stringvec; 925 stringvec *argv = new stringvec;
900 stringvec *envv = new stringvec;
901
902 for (int i = 0; i <= AvFILL (arg); i++) 926 for (int i = 0; i <= AvFILL (arg); i++)
903 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 927 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
904 928
929 stringvec *envv = new stringvec;
905 for (int i = AvFILL (env) + 1; i--; ) 930 for (int i = AvFILL (env) + 1; i--; )
906 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 931 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
907
908 envv->push_back (0);
909 932
910 try 933 try
911 { 934 {
912 term->init (argv, envv); 935 term->init (argv, envv);
913 } 936 }
953 976
954void 977void
955rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 978rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
956 CODE: 979 CODE:
957 XUngrabKey (THIS->dpy, keycode, modifiers, window); 980 XUngrabKey (THIS->dpy, keycode, modifiers, window);
958
959void
960rxvt_term::XUngrabKeyboard (Time eventtime)
961 CODE:
962 XUngrabKeyboard (THIS->dpy, eventtime);
963 981
964bool 982bool
965rxvt_term::grab (Time eventtime, int sync = 0) 983rxvt_term::grab (Time eventtime, int sync = 0)
966 CODE: 984 CODE:
967{ 985{
1079 rxvt_pop_locale (); 1097 rxvt_pop_locale ();
1080 1098
1081 RETVAL = wcs2sv (wstr); 1099 RETVAL = wcs2sv (wstr);
1082 free (wstr); 1100 free (wstr);
1083} 1101}
1084 OUTPUT:
1085 RETVAL
1086
1087char *
1088rxvt_term::locale ()
1089 CODE:
1090 RETVAL = THIS->locale;
1091 OUTPUT: 1102 OUTPUT:
1092 RETVAL 1103 RETVAL
1093 1104
1094#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1105#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1095 1106
1241} 1252}
1242 OUTPUT: 1253 OUTPUT:
1243 RETVAL 1254 RETVAL
1244 1255
1245void 1256void
1257rxvt_term::set_urgency (bool enable)
1258
1259void
1246rxvt_term::focus_in () 1260rxvt_term::focus_in ()
1247 1261
1248void 1262void
1249rxvt_term::focus_out () 1263rxvt_term::focus_out ()
1250 1264
1481# include "rsinc.h" 1495# include "rsinc.h"
1482# undef def 1496# undef def
1483# undef reserve 1497# undef reserve
1484 }; 1498 };
1485 1499
1486 rs = rslist + ARRAY_LENGTH(rslist); 1500 rs = rslist + ecb_array_length (rslist);
1487 1501
1488 if (*name) 1502 if (*name)
1489 { 1503 {
1490 do { 1504 do {
1491 if (rs-- == rslist) 1505 if (rs-- == rslist)
1530 1544
1531 if (set >= 0) 1545 if (set >= 0)
1532 { 1546 {
1533 THIS->set_option (optval, set); 1547 THIS->set_option (optval, set);
1534 1548
1535 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1549 if (THIS->init_done) // avoid doing this before START
1536 switch (optval) 1550 switch (optval)
1537 { 1551 {
1538 case Opt_skipBuiltinGlyphs: 1552 case Opt_skipBuiltinGlyphs:
1539 THIS->set_fonts (); 1553 THIS->set_fonts ();
1540 THIS->scr_remap_chars (); 1554 THIS->scr_remap_chars ();
1541 THIS->scr_touch (true); 1555 THIS->scr_touch (true);
1542 THIS->want_refresh = 1; 1556 THIS->want_refresh = 1;
1543 THIS->refresh_check (); 1557 THIS->refresh_check ();
1544 break; 1558 break;
1545 1559
1560#ifdef CURSOR_BLINK
1561 case Opt_cursorBlink:
1562 THIS->cursor_blink_reset ();
1563 break;
1564#endif
1565
1546 case Opt_cursorUnderline: 1566 case Opt_cursorUnderline:
1547 THIS->want_refresh = 1; 1567 THIS->want_refresh = 1;
1548 THIS->refresh_check (); 1568 THIS->refresh_check ();
1549 break; 1569 break;
1550 1570
1563 CODE: 1583 CODE:
1564 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1584 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1565 THIS->keyboard->register_done (); 1585 THIS->keyboard->register_done ();
1566 OUTPUT: 1586 OUTPUT:
1567 RETVAL 1587 RETVAL
1588
1589void
1590rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1591 CODE:
1592 wchar_t *wstr = sv2wcs (str);
1593 THIS->keyboard->register_user_translation (keysym, state, wstr);
1594 free (wstr);
1568 1595
1569void 1596void
1570rxvt_term::screen_cur (...) 1597rxvt_term::screen_cur (...)
1571 PROTOTYPE: $;$$ 1598 PROTOTYPE: $;$$
1572 ALIAS: 1599 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines