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.138 by root, Mon Feb 21 08:10:10 2011 UTC vs.
Revision 1.152 by sf-exg, Thu Jan 19 13:33:43 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:
871 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 883 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
872 if ((*t)->perl.self) 884 if ((*t)->perl.self)
873 PUSHs (sv_2mortal (newSVterm (*t))); 885 PUSHs (sv_2mortal (newSVterm (*t)));
874} 886}
875 887
888IV
889_new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb)
890 CODE:
891 rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term);
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));
895 RETVAL = (IV)req;
896 OUTPUT:
897 RETVAL
898
899void
900_delete_selection_request (IV req_)
901 CODE:
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
915 delete req;
916
876MODULE = urxvt PACKAGE = urxvt::term 917MODULE = urxvt PACKAGE = urxvt::term
877 918
878SV * 919SV *
879_new (AV *env, AV *arg) 920_new (AV *env, AV *arg)
880 CODE: 921 CODE:
881{ 922{
882 rxvt_term *term = new rxvt_term; 923 rxvt_term *term = new rxvt_term;
883 924
884 stringvec *argv = new stringvec; 925 stringvec *argv = new stringvec;
885 stringvec *envv = new stringvec;
886
887 for (int i = 0; i <= AvFILL (arg); i++) 926 for (int i = 0; i <= AvFILL (arg); i++)
888 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); 927 argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1))));
889 928
929 stringvec *envv = new stringvec;
890 for (int i = AvFILL (env) + 1; i--; ) 930 for (int i = AvFILL (env) + 1; i--; )
891 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); 931 envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1))));
892
893 envv->push_back (0);
894 932
895 try 933 try
896 { 934 {
897 term->init (argv, envv); 935 term->init (argv, envv);
898 } 936 }
938 976
939void 977void
940rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) 978rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt)
941 CODE: 979 CODE:
942 XUngrabKey (THIS->dpy, keycode, modifiers, window); 980 XUngrabKey (THIS->dpy, keycode, modifiers, window);
943
944void
945rxvt_term::XUngrabKeyboard (Time eventtime)
946 CODE:
947 XUngrabKeyboard (THIS->dpy, eventtime);
948 981
949bool 982bool
950rxvt_term::grab (Time eventtime, int sync = 0) 983rxvt_term::grab (Time eventtime, int sync = 0)
951 CODE: 984 CODE:
952{ 985{
1064 rxvt_pop_locale (); 1097 rxvt_pop_locale ();
1065 1098
1066 RETVAL = wcs2sv (wstr); 1099 RETVAL = wcs2sv (wstr);
1067 free (wstr); 1100 free (wstr);
1068} 1101}
1069 OUTPUT:
1070 RETVAL
1071
1072char *
1073rxvt_term::locale ()
1074 CODE:
1075 RETVAL = THIS->locale;
1076 OUTPUT: 1102 OUTPUT:
1077 RETVAL 1103 RETVAL
1078 1104
1079#define TERM_OFFSET(sym) offsetof (TermWin_t, sym) 1105#define TERM_OFFSET(sym) offsetof (TermWin_t, sym)
1080 1106
1187 RETVAL 1213 RETVAL
1188 1214
1189Window 1215Window
1190rxvt_term::parent () 1216rxvt_term::parent ()
1191 CODE: 1217 CODE:
1192 RETVAL = THIS->parent [0]; 1218 RETVAL = THIS->parent;
1193 OUTPUT: 1219 OUTPUT:
1194 RETVAL 1220 RETVAL
1195 1221
1196Window 1222Window
1197rxvt_term::vt () 1223rxvt_term::vt ()
1224 if (newval <= 0) 1250 if (newval <= 0)
1225 THIS->scr_changeview (max (newval, THIS->top_row)); 1251 THIS->scr_changeview (max (newval, THIS->top_row));
1226} 1252}
1227 OUTPUT: 1253 OUTPUT:
1228 RETVAL 1254 RETVAL
1255
1256void
1257rxvt_term::set_urgency (bool enable)
1229 1258
1230void 1259void
1231rxvt_term::focus_in () 1260rxvt_term::focus_in ()
1232 1261
1233void 1262void
1466# include "rsinc.h" 1495# include "rsinc.h"
1467# undef def 1496# undef def
1468# undef reserve 1497# undef reserve
1469 }; 1498 };
1470 1499
1471 rs = rslist + ARRAY_LENGTH(rslist); 1500 rs = rslist + ecb_array_length (rslist);
1472 1501
1473 if (*name) 1502 if (*name)
1474 { 1503 {
1475 do { 1504 do {
1476 if (rs-- == rslist) 1505 if (rs-- == rslist)
1515 1544
1516 if (set >= 0) 1545 if (set >= 0)
1517 { 1546 {
1518 THIS->set_option (optval, set); 1547 THIS->set_option (optval, set);
1519 1548
1520 if (THIS->env_colorfgbg [0]) // avoid doing this before START 1549 if (THIS->init_done) // avoid doing this before START
1521 switch (optval) 1550 switch (optval)
1522 { 1551 {
1523 case Opt_skipBuiltinGlyphs: 1552 case Opt_skipBuiltinGlyphs:
1524 THIS->set_fonts (); 1553 THIS->set_fonts ();
1525 THIS->scr_remap_chars (); 1554 THIS->scr_remap_chars ();
1548 CODE: 1577 CODE:
1549 RETVAL = 0 < THIS->parse_keysym (keysym, str); 1578 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1550 THIS->keyboard->register_done (); 1579 THIS->keyboard->register_done ();
1551 OUTPUT: 1580 OUTPUT:
1552 RETVAL 1581 RETVAL
1582
1583void
1584rxvt_term::register_command (int keysym, unsigned int state, SV *str)
1585 CODE:
1586 wchar_t *wstr = sv2wcs (str);
1587 THIS->keyboard->register_user_translation (keysym, state, wstr);
1588 free (wstr);
1553 1589
1554void 1590void
1555rxvt_term::screen_cur (...) 1591rxvt_term::screen_cur (...)
1556 PROTOTYPE: $;$$ 1592 PROTOTYPE: $;$$
1557 ALIAS: 1593 ALIAS:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines