1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtperl.xs |
2 | * File: rxvtperl.xs |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008,2011 Marc Lehmann <schmorp@schmorp.de> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
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 | |
|
|
54 | typedef char * octet_string; |
|
|
55 | typedef char * utf8_string; |
|
|
56 | |
|
|
57 | typedef int render_repeat_mode; |
|
|
58 | |
|
|
59 | typedef GdkPixbuf * urxvt__pixbuf; |
|
|
60 | typedef rxvt_img * urxvt__img; |
|
|
61 | |
|
|
62 | ///////////////////////////////////////////////////////////////////////////// |
|
|
63 | |
|
|
64 | static void |
|
|
65 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
|
|
66 | { |
|
|
67 | //TODO: support component stuff |
|
|
68 | c.set (s, SvPVbyte_nolen (sv)); |
|
|
69 | } |
50 | |
70 | |
51 | ///////////////////////////////////////////////////////////////////////////// |
71 | ///////////////////////////////////////////////////////////////////////////// |
52 | |
72 | |
53 | static wchar_t * |
73 | static wchar_t * |
54 | sv2wcs (SV *sv) |
74 | sv2wcs (SV *sv) |
… | |
… | |
302 | THIS->refresh_check (); |
322 | THIS->refresh_check (); |
303 | } |
323 | } |
304 | |
324 | |
305 | ///////////////////////////////////////////////////////////////////////////// |
325 | ///////////////////////////////////////////////////////////////////////////// |
306 | |
326 | |
307 | #define IOM_CLASS "urxvt" |
|
|
308 | #define IOM_WARN rxvt_warn |
|
|
309 | #include "iom_perl.h" |
327 | #include "iom_perl.h" |
310 | |
328 | |
311 | ///////////////////////////////////////////////////////////////////////////// |
329 | ///////////////////////////////////////////////////////////////////////////// |
312 | |
330 | |
313 | struct rxvt_perl_interp rxvt_perl; |
331 | struct rxvt_perl_interp rxvt_perl; |
… | |
… | |
343 | " unshift @INC, '" LIBDIR "';" |
361 | " unshift @INC, '" LIBDIR "';" |
344 | "}" |
362 | "}" |
345 | "" |
363 | "" |
346 | "use urxvt;" |
364 | "use urxvt;" |
347 | }; |
365 | }; |
348 | int argc = sizeof (args) / sizeof (args[0]); |
366 | int argc = ecb_array_length (args); |
349 | char **argv = args; |
367 | char **argv = args; |
350 | |
368 | |
351 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
369 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
352 | perl = perl_alloc (); |
370 | perl = perl_alloc (); |
353 | perl_construct (perl); |
371 | perl_construct (perl); |
… | |
… | |
369 | if (perl) |
387 | if (perl) |
370 | { |
388 | { |
371 | // runs outside of perls ENV |
389 | // runs outside of perls ENV |
372 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
390 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
373 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
391 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
392 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
374 | } |
393 | } |
|
|
394 | } |
|
|
395 | |
|
|
396 | void |
|
|
397 | rxvt_perl_interp::usage (rxvt_term *term, int type) |
|
|
398 | { |
|
|
399 | localise_env set_environ (perl_environ); |
|
|
400 | |
|
|
401 | ENTER; |
|
|
402 | SAVETMPS; |
|
|
403 | |
|
|
404 | dSP; |
|
|
405 | EXTEND (SP, 2); |
|
|
406 | PUSHs (sv_2mortal (newSVterm (term))); |
|
|
407 | PUSHs (sv_2mortal (newSViv (type))); |
|
|
408 | PUTBACK; |
|
|
409 | call_pv ("urxvt::usage", G_VOID | G_DISCARD); |
|
|
410 | |
|
|
411 | FREETMPS; |
|
|
412 | LEAVE; |
|
|
413 | } |
|
|
414 | |
|
|
415 | uint8_t |
|
|
416 | rxvt_perl_interp::parse_resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
|
|
417 | { |
|
|
418 | localise_env set_environ (perl_environ); |
|
|
419 | |
|
|
420 | ENTER; |
|
|
421 | SAVETMPS; |
|
|
422 | |
|
|
423 | dSP; |
|
|
424 | EXTEND (SP, 6); |
|
|
425 | PUSHs (sv_2mortal (newSVterm (term))); |
|
|
426 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
|
|
427 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
|
|
428 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
|
|
429 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
|
|
430 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
|
|
431 | PUTBACK; |
|
|
432 | call_pv ("urxvt::parse_resource", G_SCALAR); |
|
|
433 | SPAGAIN; |
|
|
434 | |
|
|
435 | uint8_t ret = POPi; |
|
|
436 | |
|
|
437 | FREETMPS; |
|
|
438 | LEAVE; |
|
|
439 | |
|
|
440 | return ret; |
375 | } |
441 | } |
376 | |
442 | |
377 | static void |
443 | static void |
378 | ungrab (rxvt_term *THIS) |
444 | ungrab (rxvt_term *THIS) |
379 | { |
445 | { |
… | |
… | |
399 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
465 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
400 | |
466 | |
401 | for (int i = 0; i <= AvFILL (av); i++) |
467 | for (int i = 0; i <= AvFILL (av); i++) |
402 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
468 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
403 | } |
469 | } |
|
|
470 | else if (htype == HOOK_DESTROY) |
|
|
471 | { |
|
|
472 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
473 | |
|
|
474 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
475 | { |
|
|
476 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
477 | delete req; |
|
|
478 | } |
|
|
479 | } |
404 | |
480 | |
405 | bool event_consumed; |
481 | bool event_consumed; |
406 | |
482 | |
407 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
|
|
408 | || term->perl.should_invoke [htype]) |
483 | if (term->perl.should_invoke [htype]) |
409 | { |
484 | { |
410 | dSP; |
485 | dSP; |
411 | va_list ap; |
486 | va_list ap; |
412 | |
487 | |
413 | va_start (ap, htype); |
488 | va_start (ap, htype); |
… | |
… | |
415 | ENTER; |
490 | ENTER; |
416 | SAVETMPS; |
491 | SAVETMPS; |
417 | |
492 | |
418 | PUSHMARK (SP); |
493 | PUSHMARK (SP); |
419 | |
494 | |
|
|
495 | EXTEND (SP, 2); |
420 | XPUSHs (sv_2mortal (newSVterm (term))); |
496 | PUSHs (sv_2mortal (newSVterm (term))); |
421 | XPUSHs (sv_2mortal (newSViv (htype))); |
497 | PUSHs (sv_2mortal (newSViv (htype))); |
422 | |
498 | |
423 | for (;;) { |
499 | for (;;) { |
424 | data_type dt = (data_type)va_arg (ap, int); |
500 | data_type dt = (data_type)va_arg (ap, int); |
425 | |
501 | |
426 | switch (dt) |
502 | switch (dt) |
… | |
… | |
583 | FREETMPS; |
659 | FREETMPS; |
584 | LEAVE; |
660 | LEAVE; |
585 | |
661 | |
586 | if (SvTRUE (ERRSV)) |
662 | if (SvTRUE (ERRSV)) |
587 | { |
663 | { |
588 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
664 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
589 | ungrab (term); // better lose the grab than the session |
665 | ungrab (term); // better lose the grab than the session |
590 | } |
666 | } |
591 | |
667 | |
592 | event_consumed = !!count; |
668 | event_consumed = !!count; |
593 | } |
669 | } |
… | |
… | |
610 | // don't allow further calls |
686 | // don't allow further calls |
611 | term->perl.self = 0; |
687 | term->perl.self = 0; |
612 | } |
688 | } |
613 | |
689 | |
614 | return event_consumed; |
690 | return event_consumed; |
|
|
691 | } |
|
|
692 | |
|
|
693 | void |
|
|
694 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
695 | { |
|
|
696 | localise_env set_environ (perl_environ); |
|
|
697 | |
|
|
698 | ENTER; |
|
|
699 | SAVETMPS; |
|
|
700 | |
|
|
701 | dSP; |
|
|
702 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
703 | PUTBACK; |
|
|
704 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
705 | |
|
|
706 | if (SvTRUE (ERRSV)) |
|
|
707 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
708 | |
|
|
709 | FREETMPS; |
|
|
710 | LEAVE; |
615 | } |
711 | } |
616 | |
712 | |
617 | ///////////////////////////////////////////////////////////////////////////// |
713 | ///////////////////////////////////////////////////////////////////////////// |
618 | |
714 | |
619 | MODULE = urxvt PACKAGE = urxvt |
715 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
753 | const_iv (XIMSecondary), |
849 | const_iv (XIMSecondary), |
754 | const_iv (XIMTertiary), |
850 | const_iv (XIMTertiary), |
755 | const_iv (XIMVisibleToForward), |
851 | const_iv (XIMVisibleToForward), |
756 | const_iv (XIMVisibleToBackword), |
852 | const_iv (XIMVisibleToBackword), |
757 | const_iv (XIMVisibleToCenter), |
853 | const_iv (XIMVisibleToCenter), |
|
|
854 | #if XRENDER |
|
|
855 | const_iv (PictStandardARGB32), |
|
|
856 | const_iv (PictStandardRGB24), |
|
|
857 | const_iv (PictStandardA8), |
|
|
858 | const_iv (PictStandardA4), |
|
|
859 | const_iv (PictStandardA1), |
|
|
860 | const_iv (RepeatNone), |
|
|
861 | const_iv (RepeatNormal), |
|
|
862 | const_iv (RepeatPad), |
|
|
863 | const_iv (RepeatReflect), |
|
|
864 | #endif |
758 | # if 0 |
865 | # if 0 |
759 | const_iv (XIMForwardChar), |
866 | const_iv (XIMForwardChar), |
760 | const_iv (XIMBackwardChar), |
867 | const_iv (XIMBackwardChar), |
761 | const_iv (XIMForwardWord), |
868 | const_iv (XIMForwardWord), |
762 | const_iv (XIMBackwardWord), |
869 | const_iv (XIMBackwardWord), |
… | |
… | |
770 | const_iv (XIMDontChange), |
877 | const_iv (XIMDontChange), |
771 | # endif |
878 | # endif |
772 | # endif |
879 | # endif |
773 | }; |
880 | }; |
774 | |
881 | |
775 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
882 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
776 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
883 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
777 | } |
884 | } |
|
|
885 | |
|
|
886 | void |
|
|
887 | log (const char *msg) |
|
|
888 | CODE: |
|
|
889 | rxvt_log ("%s", msg); |
778 | |
890 | |
779 | void |
891 | void |
780 | warn (const char *msg) |
892 | warn (const char *msg) |
781 | CODE: |
893 | CODE: |
782 | rxvt_warn ("%s", msg); |
894 | rxvt_warn ("%s", msg); |
… | |
… | |
786 | CODE: |
898 | CODE: |
787 | rxvt_fatal ("%s", msg); |
899 | rxvt_fatal ("%s", msg); |
788 | |
900 | |
789 | void |
901 | void |
790 | _exit (int status) |
902 | _exit (int status) |
|
|
903 | |
|
|
904 | void |
|
|
905 | catch_fatal (SV *block) |
|
|
906 | PROTOTYPE: & |
|
|
907 | CODE: |
|
|
908 | try |
|
|
909 | { |
|
|
910 | PUSHMARK (SP); |
|
|
911 | PUTBACK; |
|
|
912 | call_sv (block, G_VOID | G_DISCARD); |
|
|
913 | SPAGAIN; |
|
|
914 | } |
|
|
915 | catch (const rxvt_failure_exception &e) |
|
|
916 | { |
|
|
917 | croak ("rxvt_fatal exception caught, trying to continue."); |
|
|
918 | } |
791 | |
919 | |
792 | NV |
920 | NV |
793 | NOW () |
921 | NOW () |
794 | CODE: |
922 | CODE: |
795 | RETVAL = ev::now (); |
923 | RETVAL = ev::now (); |
… | |
… | |
853 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
981 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
854 | if ((*t)->perl.self) |
982 | if ((*t)->perl.self) |
855 | PUSHs (sv_2mortal (newSVterm (*t))); |
983 | PUSHs (sv_2mortal (newSVterm (*t))); |
856 | } |
984 | } |
857 | |
985 | |
|
|
986 | IV |
|
|
987 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
988 | CODE: |
|
|
989 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
990 | req->cb_sv = newSVsv (cb); |
|
|
991 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
992 | av_push (av, newSViv ((IV)req)); |
|
|
993 | RETVAL = (IV)req; |
|
|
994 | OUTPUT: |
|
|
995 | RETVAL |
|
|
996 | |
|
|
997 | void |
|
|
998 | _delete_selection_request (IV req_) |
|
|
999 | CODE: |
|
|
1000 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
1001 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
1002 | int i; |
|
|
1003 | |
|
|
1004 | for (i = AvFILL (av); i >= 0; i--) |
|
|
1005 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
1006 | break; |
|
|
1007 | |
|
|
1008 | for (; i < AvFILL (av); i++) |
|
|
1009 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
1010 | |
|
|
1011 | av_pop (av); |
|
|
1012 | |
|
|
1013 | delete req; |
|
|
1014 | |
858 | MODULE = urxvt PACKAGE = urxvt::term |
1015 | MODULE = urxvt PACKAGE = urxvt::term |
859 | |
1016 | |
860 | SV * |
1017 | SV * |
861 | _new (AV *env, AV *arg) |
1018 | _new (AV *env, AV *arg) |
862 | CODE: |
1019 | CODE: |
863 | { |
1020 | { |
864 | rxvt_term *term = new rxvt_term; |
1021 | rxvt_term *term = new rxvt_term; |
865 | |
1022 | |
866 | stringvec *argv = new stringvec; |
1023 | stringvec *argv = new stringvec; |
867 | stringvec *envv = new stringvec; |
|
|
868 | |
|
|
869 | for (int i = 0; i <= AvFILL (arg); i++) |
1024 | for (int i = 0; i <= AvFILL (arg); i++) |
870 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
1025 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
871 | |
1026 | |
|
|
1027 | stringvec *envv = new stringvec; |
872 | for (int i = AvFILL (env) + 1; i--; ) |
1028 | for (int i = AvFILL (env) + 1; i--; ) |
873 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
1029 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
874 | |
1030 | |
875 | envv->push_back (0); |
|
|
876 | |
|
|
877 | try |
1031 | try |
878 | { |
1032 | { |
879 | term->init (argv, envv); |
1033 | term->init (argv, envv); |
880 | } |
1034 | } |
881 | catch (const class rxvt_failure_exception &e) |
1035 | catch (const class rxvt_failure_exception &e) |
… | |
… | |
894 | rxvt_term::destroy () |
1048 | rxvt_term::destroy () |
895 | |
1049 | |
896 | void |
1050 | void |
897 | rxvt_term::set_should_invoke (int htype, int inc) |
1051 | rxvt_term::set_should_invoke (int htype, int inc) |
898 | CODE: |
1052 | CODE: |
899 | THIS->perl.should_invoke [htype] += inc; |
1053 | uint8_t &count = THIS->perl.should_invoke [htype]; |
|
|
1054 | uint8_t prev = count; |
|
|
1055 | count += inc; |
|
|
1056 | if (!prev != !count) |
|
|
1057 | { |
|
|
1058 | // hook status changed, react |
|
|
1059 | switch (htype) |
|
|
1060 | { |
|
|
1061 | case HOOK_POSITION_CHANGE: |
|
|
1062 | if (count) |
|
|
1063 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
|
|
1064 | } |
|
|
1065 | } |
|
|
1066 | |
|
|
1067 | void |
|
|
1068 | rxvt_term::put_option_db (octet_string specifier, octet_string value) |
|
|
1069 | CODE: |
|
|
1070 | XrmPutStringResource (&THIS->option_db, specifier, value); |
900 | |
1071 | |
901 | int |
1072 | int |
902 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1073 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
903 | CODE: |
1074 | CODE: |
904 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1075 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
… | |
… | |
920 | |
1091 | |
921 | void |
1092 | void |
922 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
1093 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
923 | CODE: |
1094 | CODE: |
924 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
1095 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
925 | |
|
|
926 | void |
|
|
927 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
928 | CODE: |
|
|
929 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
930 | |
1096 | |
931 | bool |
1097 | bool |
932 | rxvt_term::grab (Time eventtime, int sync = 0) |
1098 | rxvt_term::grab (Time eventtime, int sync = 0) |
933 | CODE: |
1099 | CODE: |
934 | { |
1100 | { |
… | |
… | |
1046 | rxvt_pop_locale (); |
1212 | rxvt_pop_locale (); |
1047 | |
1213 | |
1048 | RETVAL = wcs2sv (wstr); |
1214 | RETVAL = wcs2sv (wstr); |
1049 | free (wstr); |
1215 | free (wstr); |
1050 | } |
1216 | } |
1051 | OUTPUT: |
|
|
1052 | RETVAL |
|
|
1053 | |
|
|
1054 | char * |
|
|
1055 | rxvt_term::locale () |
|
|
1056 | CODE: |
|
|
1057 | RETVAL = THIS->locale; |
|
|
1058 | OUTPUT: |
1217 | OUTPUT: |
1059 | RETVAL |
1218 | RETVAL |
1060 | |
1219 | |
1061 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1220 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1062 | |
1221 | |
… | |
… | |
1169 | RETVAL |
1328 | RETVAL |
1170 | |
1329 | |
1171 | Window |
1330 | Window |
1172 | rxvt_term::parent () |
1331 | rxvt_term::parent () |
1173 | CODE: |
1332 | CODE: |
1174 | RETVAL = THIS->parent [0]; |
1333 | RETVAL = THIS->parent; |
1175 | OUTPUT: |
1334 | OUTPUT: |
1176 | RETVAL |
1335 | RETVAL |
1177 | |
1336 | |
1178 | Window |
1337 | int |
1179 | rxvt_term::vt () |
1338 | rxvt_term::parent_x () |
1180 | CODE: |
1339 | CODE: |
1181 | RETVAL = THIS->vt; |
1340 | RETVAL = THIS->parent_x; |
|
|
1341 | OUTPUT: |
|
|
1342 | RETVAL |
|
|
1343 | |
|
|
1344 | int |
|
|
1345 | rxvt_term::parent_y () |
|
|
1346 | CODE: |
|
|
1347 | RETVAL = THIS->parent_y; |
1182 | OUTPUT: |
1348 | OUTPUT: |
1183 | RETVAL |
1349 | RETVAL |
1184 | |
1350 | |
1185 | void |
1351 | void |
1186 | rxvt_term::vt_emask_add (U32 emask) |
1352 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1206 | if (newval <= 0) |
1372 | if (newval <= 0) |
1207 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1373 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1208 | } |
1374 | } |
1209 | OUTPUT: |
1375 | OUTPUT: |
1210 | RETVAL |
1376 | RETVAL |
|
|
1377 | |
|
|
1378 | void |
|
|
1379 | rxvt_term::set_urgency (bool enable) |
1211 | |
1380 | |
1212 | void |
1381 | void |
1213 | rxvt_term::focus_in () |
1382 | rxvt_term::focus_in () |
1214 | |
1383 | |
1215 | void |
1384 | void |
… | |
… | |
1448 | # include "rsinc.h" |
1617 | # include "rsinc.h" |
1449 | # undef def |
1618 | # undef def |
1450 | # undef reserve |
1619 | # undef reserve |
1451 | }; |
1620 | }; |
1452 | |
1621 | |
1453 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1622 | rs = rslist + ecb_array_length (rslist); |
1454 | |
1623 | |
1455 | if (*name) |
1624 | if (*name) |
1456 | { |
1625 | { |
1457 | do { |
1626 | do { |
1458 | if (rs-- == rslist) |
1627 | if (rs-- == rslist) |
… | |
… | |
1497 | |
1666 | |
1498 | if (set >= 0) |
1667 | if (set >= 0) |
1499 | { |
1668 | { |
1500 | THIS->set_option (optval, set); |
1669 | THIS->set_option (optval, set); |
1501 | |
1670 | |
1502 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1671 | if (THIS->init_done) // avoid doing this before START |
1503 | switch (optval) |
1672 | switch (optval) |
1504 | { |
1673 | { |
1505 | case Opt_skipBuiltinGlyphs: |
1674 | case Opt_skipBuiltinGlyphs: |
1506 | THIS->set_fonts (); |
1675 | THIS->set_fonts (); |
1507 | THIS->scr_remap_chars (); |
1676 | THIS->scr_remap_chars (); |
1508 | THIS->scr_touch (true); |
1677 | THIS->scr_touch (true); |
1509 | THIS->want_refresh = 1; |
1678 | THIS->want_refresh = 1; |
1510 | THIS->refresh_check (); |
1679 | THIS->refresh_check (); |
1511 | break; |
1680 | break; |
|
|
1681 | #ifdef CURSOR_BLINK |
|
|
1682 | case Opt_cursorBlink: |
|
|
1683 | THIS->cursor_blink_reset (); |
|
|
1684 | break; |
|
|
1685 | #endif |
1512 | |
1686 | |
1513 | case Opt_cursorUnderline: |
1687 | case Opt_cursorUnderline: |
1514 | THIS->want_refresh = 1; |
1688 | THIS->want_refresh = 1; |
1515 | THIS->refresh_check (); |
1689 | THIS->refresh_check (); |
1516 | break; |
1690 | break; |
… | |
… | |
1530 | CODE: |
1704 | CODE: |
1531 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1705 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1532 | THIS->keyboard->register_done (); |
1706 | THIS->keyboard->register_done (); |
1533 | OUTPUT: |
1707 | OUTPUT: |
1534 | RETVAL |
1708 | RETVAL |
|
|
1709 | |
|
|
1710 | void |
|
|
1711 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1712 | CODE: |
|
|
1713 | wchar_t *wstr = sv2wcs (str); |
|
|
1714 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1715 | free (wstr); |
1535 | |
1716 | |
1536 | void |
1717 | void |
1537 | rxvt_term::screen_cur (...) |
1718 | rxvt_term::screen_cur (...) |
1538 | PROTOTYPE: $;$$ |
1719 | PROTOTYPE: $;$$ |
1539 | ALIAS: |
1720 | ALIAS: |
… | |
… | |
1647 | |
1828 | |
1648 | void |
1829 | void |
1649 | rxvt_term::scr_bell () |
1830 | rxvt_term::scr_bell () |
1650 | |
1831 | |
1651 | void |
1832 | void |
|
|
1833 | rxvt_term::scr_recolour (bool refresh = true); |
|
|
1834 | |
|
|
1835 | void |
1652 | rxvt_term::scr_change_screen (int screen) |
1836 | rxvt_term::scr_change_screen (int screen) |
1653 | |
1837 | |
1654 | void |
1838 | void |
1655 | rxvt_term::scr_add_lines (SV *string) |
1839 | rxvt_term::scr_add_lines (SV *string) |
1656 | CODE: |
1840 | CODE: |
… | |
… | |
1769 | type, format, PropModeReplace, |
1953 | type, format, PropModeReplace, |
1770 | (unsigned char *)data_, len / elemsize); |
1954 | (unsigned char *)data_, len / elemsize); |
1771 | } |
1955 | } |
1772 | |
1956 | |
1773 | Atom |
1957 | Atom |
1774 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1958 | XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE) |
1775 | C_ARGS: term->dpy, atom_name, only_if_exists |
1959 | C_ARGS: term->dpy, atom_name, only_if_exists |
1776 | |
1960 | |
1777 | char * |
1961 | char * |
1778 | XGetAtomName (rxvt_term *term, Atom atom) |
1962 | XGetAtomName (rxvt_term *term, Atom atom) |
1779 | C_ARGS: term->dpy, atom |
1963 | C_ARGS: term->dpy, atom |
1780 | CLEANUP: |
1964 | CLEANUP: |
1781 | XFree (RETVAL); |
1965 | XFree (RETVAL); |
1782 | |
1966 | |
1783 | void |
1967 | void |
1784 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1968 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1785 | C_ARGS: term->dpy, window, property |
1969 | C_ARGS: term->dpy, window, property |
1786 | |
1970 | |
1787 | Window |
1971 | Window |
1788 | rxvt_term::DefaultRootWindow () |
1972 | rxvt_term::DefaultRootWindow () |
1789 | CODE: |
1973 | CODE: |
1790 | RETVAL = THIS->display->root; |
1974 | RETVAL = THIS->display->root; |
… | |
… | |
1842 | PUSHs (newSVuv (child)); |
2026 | PUSHs (newSVuv (child)); |
1843 | } |
2027 | } |
1844 | } |
2028 | } |
1845 | |
2029 | |
1846 | ############################################################################# |
2030 | ############################################################################# |
|
|
2031 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
|
|
2032 | |
|
|
2033 | # TODO: ugly |
|
|
2034 | void |
|
|
2035 | rxvt_term::get_geometry () |
|
|
2036 | PPCODE: |
|
|
2037 | EXTEND (SP, 4); |
|
|
2038 | PUSHs (sv_2mortal (newSViv (THIS->parent_x))); |
|
|
2039 | PUSHs (sv_2mortal (newSViv (THIS->parent_y))); |
|
|
2040 | PUSHs (sv_2mortal (newSViv (THIS->szHint.width))); |
|
|
2041 | PUSHs (sv_2mortal (newSViv (THIS->szHint.height))); |
|
|
2042 | |
|
|
2043 | #if HAVE_IMG |
|
|
2044 | |
|
|
2045 | rxvt_img * |
|
|
2046 | rxvt_term::new_img (SV *format, int width, int height) |
|
|
2047 | CODE: |
|
|
2048 | XRenderPictFormat *f = SvOK (format) |
|
|
2049 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
|
|
2050 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
|
|
2051 | RETVAL = new rxvt_img (THIS, f, width, height); |
|
|
2052 | OUTPUT: |
|
|
2053 | RETVAL |
|
|
2054 | |
|
|
2055 | #if ENABLE_TRANSPARENCY |
|
|
2056 | |
|
|
2057 | rxvt_img * |
|
|
2058 | rxvt_term::new_img_from_root () |
|
|
2059 | CODE: |
|
|
2060 | RETVAL = rxvt_img::new_from_root (THIS); |
|
|
2061 | OUTPUT: |
|
|
2062 | RETVAL |
|
|
2063 | |
|
|
2064 | #endif |
|
|
2065 | |
|
|
2066 | #if HAVE_PIXBUF |
|
|
2067 | |
|
|
2068 | rxvt_img * |
|
|
2069 | rxvt_term::new_img_from_file (octet_string filename) |
|
|
2070 | CODE: |
|
|
2071 | try |
|
|
2072 | { |
|
|
2073 | RETVAL = rxvt_img::new_from_file (THIS, filename); |
|
|
2074 | } |
|
|
2075 | catch (const class rxvt_failure_exception &e) |
|
|
2076 | { |
|
|
2077 | croak ("new_img_from_file failed"); |
|
|
2078 | } |
|
|
2079 | OUTPUT: |
|
|
2080 | RETVAL |
|
|
2081 | |
|
|
2082 | #endif |
|
|
2083 | |
|
|
2084 | #if HAVE_BG_PIXMAP |
|
|
2085 | |
|
|
2086 | void |
|
|
2087 | rxvt_term::set_background (rxvt_img *img) |
|
|
2088 | CODE: |
|
|
2089 | THIS->bg_destroy (); |
|
|
2090 | THIS->bg_pixmap = None; |
|
|
2091 | THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH; |
|
|
2092 | |
|
|
2093 | if (img) // TODO: cannot be false |
|
|
2094 | { |
|
|
2095 | img->unshare (); |
|
|
2096 | //TODO: convetr to visual, possibly precompose with colour |
|
|
2097 | THIS->bg_pixmap = img->steal (); |
|
|
2098 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; |
|
|
2099 | THIS->bg_valid_since = ev::now (); // TODO: extra bloat |
|
|
2100 | } |
|
|
2101 | |
|
|
2102 | #endif |
|
|
2103 | |
|
|
2104 | #endif |
|
|
2105 | |
|
|
2106 | ############################################################################# |
1847 | # urxvt::overlay |
2107 | # urxvt::overlay |
1848 | ############################################################################# |
2108 | ############################################################################# |
1849 | |
2109 | |
1850 | MODULE = urxvt PACKAGE = urxvt::overlay |
2110 | MODULE = urxvt PACKAGE = urxvt::overlay |
1851 | |
2111 | |
… | |
… | |
1861 | void |
2121 | void |
1862 | overlay::DESTROY () |
2122 | overlay::DESTROY () |
1863 | |
2123 | |
1864 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
2124 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1865 | |
2125 | |
|
|
2126 | MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_ |
|
|
2127 | |
|
|
2128 | #if HAVE_PIXBUF |
|
|
2129 | |
|
|
2130 | urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename) |
|
|
2131 | C_ARGS: filename, 0 |
|
|
2132 | |
|
|
2133 | void |
|
|
2134 | DESTROY (urxvt::pixbuf self) |
|
|
2135 | CODE: |
|
|
2136 | gdk_pixbuf_unref (self); |
|
|
2137 | |
|
|
2138 | #endif |
|
|
2139 | |
|
|
2140 | MODULE = urxvt PACKAGE = urxvt::img |
|
|
2141 | |
|
|
2142 | #if HAVE_IMG |
|
|
2143 | |
|
|
2144 | # rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
|
|
2145 | # rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
|
|
2146 | |
|
|
2147 | int |
|
|
2148 | rxvt_img::w () |
|
|
2149 | CODE: |
|
|
2150 | RETVAL = THIS->w; |
|
|
2151 | OUTPUT: |
|
|
2152 | RETVAL |
|
|
2153 | |
|
|
2154 | int |
|
|
2155 | rxvt_img::h () |
|
|
2156 | CODE: |
|
|
2157 | RETVAL = THIS->h; |
|
|
2158 | OUTPUT: |
|
|
2159 | RETVAL |
|
|
2160 | |
|
|
2161 | bool |
|
|
2162 | rxvt_img::shared () |
|
|
2163 | CODE: |
|
|
2164 | RETVAL = THIS->shared; |
|
|
2165 | OUTPUT: |
|
|
2166 | RETVAL |
|
|
2167 | |
|
|
2168 | Pixmap |
|
|
2169 | rxvt_img::pm () |
|
|
2170 | CODE: |
|
|
2171 | RETVAL = THIS->pm; |
|
|
2172 | OUTPUT: |
|
|
2173 | RETVAL |
|
|
2174 | |
|
|
2175 | void |
|
|
2176 | rxvt_img::fill (SV *c) |
|
|
2177 | INIT: |
|
|
2178 | rxvt_color rc; |
|
|
2179 | parse_color (THIS->s, rc, c); |
|
|
2180 | C_ARGS: rc |
|
|
2181 | |
|
|
2182 | void |
|
|
2183 | rxvt_img::DESTROY () |
|
|
2184 | CODE: |
|
|
2185 | delete THIS; |
|
|
2186 | |
|
|
2187 | rxvt_img * |
|
|
2188 | rxvt_img::blur (int rh, int rv) |
|
|
2189 | |
|
|
2190 | void |
|
|
2191 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2192 | |
|
|
2193 | void |
|
|
2194 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2195 | |
|
|
2196 | void |
|
|
2197 | rxvt_img::unshare () |
|
|
2198 | |
|
|
2199 | rxvt_img * |
|
|
2200 | rxvt_img::clone () |
|
|
2201 | |
|
|
2202 | rxvt_img * |
|
|
2203 | rxvt_img::sub_rect (int x, int y, int width, int height, render_repeat_mode repeat = RepeatNormal) |
|
|
2204 | |
|
|
2205 | rxvt_img * |
|
|
2206 | rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33, render_repeat_mode repeat = RepeatNormal) |
|
|
2207 | INIT: |
|
|
2208 | double matrix[9] = { |
|
|
2209 | p11, p12, p13, |
|
|
2210 | p21, p22, p23, |
|
|
2211 | p31, p32, p33 |
|
|
2212 | }; |
|
|
2213 | C_ARGS: new_width, new_height, matrix, repeat |
|
|
2214 | |
|
|
2215 | rxvt_img * |
|
|
2216 | rxvt_img::scale (int new_width, int new_height) |
|
|
2217 | |
|
|
2218 | rxvt_img * |
|
|
2219 | rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi, render_repeat_mode repeat = RepeatNormal) |
|
|
2220 | |
|
|
2221 | #endif |
|
|
2222 | |