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.47 by root, Mon Jan 9 02:06:43 2006 UTC vs.
Revision 1.56 by root, Thu Jan 12 00:35:39 2006 UTC

29#include "../config.h" 29#include "../config.h"
30 30
31#include <cstddef> 31#include <cstddef>
32#include <cstdarg> 32#include <cstdarg>
33 33
34#include "iom.h"
34#include "rxvt.h" 35#include "rxvt.h"
35#include "iom.h" 36#include "keyboard.h"
36#include "rxvtutil.h" 37#include "rxvtutil.h"
37#include "rxvtperl.h" 38#include "rxvtperl.h"
38 39
39#include "perlxsi.c" 40#include "perlxsi.c"
40 41
410void 411void
411rxvt_perl_interp::init () 412rxvt_perl_interp::init ()
412{ 413{
413 if (!perl) 414 if (!perl)
414 { 415 {
416 temp_environ temp_environ(rxvt_environ);
417
415 char *argv[] = { 418 char *argv[] = {
416 "", 419 "",
417 "-T", 420 "-T",
418 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", 421 "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1",
419 }; 422 };
459 return false; // perl not initialized for this instance 462 return false; // perl not initialized for this instance
460 else if (htype == HOOK_DESTROY) 463 else if (htype == HOOK_DESTROY)
461 { 464 {
462 // handled later 465 // handled later
463 } 466 }
464 else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) 467 else
465 { 468 {
466 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); 469 if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END)
467
468 if (HvKEYS (hv))
469 { 470 {
471 HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0));
472
473 if (HvKEYS (hv))
474 {
470 hv_iterinit (hv); 475 hv_iterinit (hv);
471 476
472 while (HE *he = hv_iternext (hv)) 477 while (HE *he = hv_iternext (hv))
473 ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); 478 ((overlay *)SvIV (hv_iterval (hv, he)))->swap ();
479 }
480
474 } 481 }
482
483 if (!should_invoke [htype])
484 return false;
475 } 485 }
476 else if (!should_invoke [htype]) 486
477 return false; 487 temp_environ temp_environ(rxvt_environ);
478 488
479 dSP; 489 dSP;
480 va_list ap; 490 va_list ap;
481 491
482 va_start (ap, htype); 492 va_start (ap, htype);
621 631
622PROTOTYPES: ENABLE 632PROTOTYPES: ENABLE
623 633
624BOOT: 634BOOT:
625{ 635{
626 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); 636 sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1));
637 sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1));
638 sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1));
639 sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1));
627 640
628 AV *hookname = get_av ("urxvt::HOOKNAME", 1); 641 AV *hookname = get_av ("urxvt::HOOKNAME", 1);
629# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); 642# define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0));
630# include "hookinc.h" 643# include "hookinc.h"
631# undef def 644# undef def
660 export_const_iv (Button2Mask); 673 export_const_iv (Button2Mask);
661 export_const_iv (Button3Mask); 674 export_const_iv (Button3Mask);
662 export_const_iv (Button4Mask); 675 export_const_iv (Button4Mask);
663 export_const_iv (Button5Mask); 676 export_const_iv (Button5Mask);
664 export_const_iv (AnyModifier); 677 export_const_iv (AnyModifier);
665}
666 678
667SV * 679 export_const_iv (EVENT_NONE);
668new (...) 680 export_const_iv (EVENT_READ);
669 CODE: 681 export_const_iv (EVENT_WRITE);
670{
671 stringvec *argv = new stringvec;
672 bool success;
673
674 for (int i = 0; i < items ;i++)
675 argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
676
677 rxvt_term *term = new rxvt_term;
678
679 term->argv = argv;
680
681 try
682 {
683 if (!term->init (argv->size (), argv->begin ()))
684 term = 0;
685 }
686 catch (const class rxvt_failure_exception &e)
687 {
688 term->destroy ();
689 croak ("exception caught while initializing new terminal instance");
690 }
691
692 RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
693} 682}
694 OUTPUT:
695 RETVAL
696 683
697void 684void
698set_should_invoke (int htype, int value) 685set_should_invoke (int htype, int value)
699 CODE: 686 CODE:
700 rxvt_perl.should_invoke [htype] = value; 687 rxvt_perl.should_invoke [htype] = value;
778} 765}
779 OUTPUT: 766 OUTPUT:
780 RETVAL 767 RETVAL
781 768
782MODULE = urxvt PACKAGE = urxvt::term 769MODULE = urxvt PACKAGE = urxvt::term
770
771SV *
772_new (...)
773 CODE:
774{
775 if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
776 croak ("first argument to urxvt::term->_new must be arrayref");
777
778 rxvt_term *term = new rxvt_term;
779
780 term->argv = new stringvec;
781 term->envv = new stringvec;
782
783 for (int i = 1; i < items; i++)
784 term->argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
785
786 AV *envv = (AV *)SvRV (ST (0));
787 for (int i = av_len (envv) + 1; i--; )
788 term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1))));
789
790 term->envv->push_back (0);
791
792 bool success;
793
794 try
795 {
796 success = term->init (term->argv->size (), term->argv->begin ());
797 }
798 catch (const class rxvt_failure_exception &e)
799 {
800 success = false;
801 }
802
803 if (!success)
804 {
805 term->destroy ();
806 croak ("error while initializing new terminal instance");
807 }
808
809 RETVAL = term && term->perl.self
810 ? newSVterm (term) : &PL_sv_undef;
811}
812 OUTPUT:
813 RETVAL
783 814
784void 815void
785rxvt_term::destroy () 816rxvt_term::destroy ()
786 817
787void 818void
932 case 2: RETVAL = THIS->ModNumLockMask; break; 963 case 2: RETVAL = THIS->ModNumLockMask; break;
933 } 964 }
934 OUTPUT: 965 OUTPUT:
935 RETVAL 966 RETVAL
936 967
968char *
969rxvt_term::display_id ()
970 ALIAS:
971 display_id = 0
972 locale = 1
973 CODE:
974 switch (ix)
975 {
976 case 0: RETVAL = THIS->display->id; break;
977 case 1: RETVAL = THIS->locale; break;
978 }
979 OUTPUT:
980 RETVAL
981
982SV *
983rxvt_term::_env ()
984 CODE:
985{
986 if (THIS->envv)
987 {
988 AV *av = newAV ();
989
990 for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i)
991 if (*i)
992 av_push (av, newSVpv (*i, 0));
993
994 RETVAL = newRV_noinc ((SV *)av);
995 }
996 else
997 RETVAL = &PL_sv_undef;
998}
999 OUTPUT:
1000 RETVAL
1001
1002int
1003rxvt_term::pty_ev_events (int events = EVENT_UNDEF)
1004 CODE:
1005 RETVAL = THIS->pty_ev.events;
1006 if (events != EVENT_UNDEF)
1007 THIS->pty_ev.set (events);
1008 OUTPUT:
1009 RETVAL
1010
937U32 1011U32
938rxvt_term::parent () 1012rxvt_term::parent ()
939 CODE: 1013 CODE:
940 RETVAL = (U32)THIS->parent [0]; 1014 RETVAL = (U32)THIS->parent [0];
941 OUTPUT: 1015 OUTPUT:
1206 else 1280 else
1207 THIS->rs [index] = 0; 1281 THIS->rs [index] = 0;
1208 } 1282 }
1209} 1283}
1210 1284
1285const char *
1286rxvt_term::x_resource (const char *name)
1287 CLEANUP:
1288 SvTAINTED_on (ST (0));
1289
1211bool 1290bool
1212rxvt_term::option (U32 optval, int set = -1) 1291rxvt_term::option (U32 optval, int set = -1)
1213 CODE: 1292 CODE:
1214{ 1293{
1215 RETVAL = THIS->options & optval; 1294 RETVAL = THIS->options & optval;
1242 } 1321 }
1243} 1322}
1244 OUTPUT: 1323 OUTPUT:
1245 RETVAL 1324 RETVAL
1246 1325
1326bool
1327rxvt_term::parse_keysym (char *keysym, char *str)
1328 CODE:
1329 RETVAL = 0 < THIS->parse_keysym (keysym, str);
1330 THIS->keyboard->register_done ();
1331 OUTPUT:
1332 RETVAL
1333
1247void 1334void
1248rxvt_term::screen_cur (...) 1335rxvt_term::screen_cur (...)
1249 PROTOTYPE: $;$$ 1336 PROTOTYPE: $;$$
1250 ALIAS: 1337 ALIAS:
1251 screen_cur = 0 1338 screen_cur = 0
1274 if (ix) 1361 if (ix)
1275 THIS->want_refresh = 1; 1362 THIS->want_refresh = 1;
1276 } 1363 }
1277} 1364}
1278 1365
1366char
1367rxvt_term::cur_charset ()
1368 CODE:
1369 RETVAL = THIS->charsets [THIS->screen.charset];
1370 OUTPUT:
1371 RETVAL
1372
1279int 1373int
1280rxvt_term::selection_grab (U32 eventtime) 1374rxvt_term::selection_grab (U32 eventtime)
1281 1375
1282void 1376void
1283rxvt_term::selection (SV *newtext = 0) 1377rxvt_term::selection (SV *newtext = 0)
1294 1388
1295 THIS->selection.text = sv2wcs (newtext); 1389 THIS->selection.text = sv2wcs (newtext);
1296 THIS->selection.len = wcslen (THIS->selection.text); 1390 THIS->selection.len = wcslen (THIS->selection.text);
1297 } 1391 }
1298} 1392}
1393
1394void
1395rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle1 = RS_RVid, U32 rstyle2 = RS_RVid | RS_Uline)
1396
1397void
1398rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid)
1399
1400void
1401rxvt_term::scr_bell ()
1299 1402
1300void 1403void
1301rxvt_term::scr_add_lines (SV *string) 1404rxvt_term::scr_add_lines (SV *string)
1302 CODE: 1405 CODE:
1303{ 1406{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines