… | |
… | |
31 | #include <cstddef> |
31 | #include <cstddef> |
32 | #include <cstdarg> |
32 | #include <cstdarg> |
33 | |
33 | |
34 | #include "unistd.h" |
34 | #include "unistd.h" |
35 | |
35 | |
36 | #include "iom.h" |
36 | #include "ev_cpp.h" |
37 | #include "rxvt.h" |
37 | #include "rxvt.h" |
38 | #include "keyboard.h" |
38 | #include "keyboard.h" |
39 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
40 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
41 | |
41 | |
… | |
… | |
70 | SV *sv = newSVpv (str, 0); |
70 | SV *sv = newSVpv (str, 0); |
71 | SvUTF8_on (sv); |
71 | SvUTF8_on (sv); |
72 | free (str); |
72 | free (str); |
73 | |
73 | |
74 | return sv; |
74 | return sv; |
75 | } |
|
|
76 | |
|
|
77 | static SV * |
|
|
78 | new_ref (HV *hv, const char *klass) |
|
|
79 | { |
|
|
80 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
81 | } |
75 | } |
82 | |
76 | |
83 | static SV * |
77 | static SV * |
84 | newSVptr (void *ptr, const char *klass) |
78 | newSVptr (void *ptr, const char *klass) |
85 | { |
79 | { |
… | |
… | |
388 | |
382 | |
389 | // pre-handling of some events |
383 | // pre-handling of some events |
390 | if (htype == HOOK_REFRESH_END) |
384 | if (htype == HOOK_REFRESH_END) |
391 | { |
385 | { |
392 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
386 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
393 | |
387 | |
394 | for (int i = 0; i <= AvFILL (av); i++) |
388 | for (int i = 0; i <= AvFILL (av); i++) |
395 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
389 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
396 | } |
390 | } |
397 | |
391 | |
398 | swap (perl_environ, environ); |
392 | swap (perl_environ, environ); |
… | |
… | |
597 | |
591 | |
598 | // post-handling of some events |
592 | // post-handling of some events |
599 | if (htype == HOOK_REFRESH_BEGIN) |
593 | if (htype == HOOK_REFRESH_BEGIN) |
600 | { |
594 | { |
601 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
595 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
602 | |
596 | |
603 | for (int i = AvFILL (av); i >= 0; i--) |
597 | for (int i = AvFILL (av); i >= 0; i--) |
604 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
598 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
605 | } |
599 | } |
606 | else if (htype == HOOK_DESTROY) |
600 | else if (htype == HOOK_DESTROY) |
607 | { |
601 | { |
608 | clearSVptr ((SV *)term->perl.self); |
602 | clearSVptr ((SV *)term->perl.self); |
609 | SvREFCNT_dec ((SV *)term->perl.self); |
603 | SvREFCNT_dec ((SV *)term->perl.self); |
610 | |
604 | |
611 | // don't allow further calls |
605 | // don't allow further calls |
612 | term->perl.self = 0; |
606 | term->perl.self = 0; |
613 | } |
607 | } |
614 | |
608 | |
615 | swap (perl_environ, environ); |
609 | swap (perl_environ, environ); |
… | |
… | |
781 | _exit (int status) |
775 | _exit (int status) |
782 | |
776 | |
783 | NV |
777 | NV |
784 | NOW () |
778 | NOW () |
785 | CODE: |
779 | CODE: |
786 | RETVAL = NOW; |
780 | RETVAL = ev::now (); |
787 | OUTPUT: |
781 | OUTPUT: |
788 | RETVAL |
782 | RETVAL |
789 | |
783 | |
790 | int |
784 | int |
791 | GET_BASEFG (int rend) |
785 | GET_BASEFG (int rend) |
… | |
… | |
863 | for (int i = AvFILL (env) + 1; i--; ) |
857 | for (int i = AvFILL (env) + 1; i--; ) |
864 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
858 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
865 | |
859 | |
866 | envv->push_back (0); |
860 | envv->push_back (0); |
867 | |
861 | |
868 | bool success; |
|
|
869 | |
|
|
870 | try |
862 | try |
871 | { |
863 | { |
872 | success = term->init (argv, envv); |
864 | term->init (argv, envv); |
873 | } |
865 | } |
874 | catch (const class rxvt_failure_exception &e) |
866 | catch (const class rxvt_failure_exception &e) |
875 | { |
|
|
876 | success = false; |
|
|
877 | } |
|
|
878 | |
|
|
879 | if (!success) |
|
|
880 | { |
867 | { |
881 | term->destroy (); |
868 | term->destroy (); |
882 | croak ("error while initializing new terminal instance"); |
869 | croak ("error while initializing new terminal instance"); |
883 | } |
870 | } |
884 | |
871 | |
… | |
… | |
1145 | if (*i) |
1132 | if (*i) |
1146 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1133 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1147 | } |
1134 | } |
1148 | |
1135 | |
1149 | int |
1136 | int |
1150 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1137 | rxvt_term::pty_ev_events (int events = ev::UNDEF) |
1151 | CODE: |
1138 | CODE: |
1152 | RETVAL = THIS->pty_ev.events; |
1139 | RETVAL = THIS->pty_ev.events; |
1153 | if (events != EVENT_UNDEF) |
1140 | if (events != ev::UNDEF) |
1154 | THIS->pty_ev.set (events); |
1141 | THIS->pty_ev.set (events); |
1155 | OUTPUT: |
1142 | OUTPUT: |
1156 | RETVAL |
1143 | RETVAL |
1157 | |
1144 | |
1158 | int |
1145 | int |
… | |
… | |
1401 | SV * |
1388 | SV * |
1402 | rxvt_term::special_decode (SV *text) |
1389 | rxvt_term::special_decode (SV *text) |
1403 | CODE: |
1390 | CODE: |
1404 | { |
1391 | { |
1405 | wchar_t *wstr = sv2wcs (text); |
1392 | wchar_t *wstr = sv2wcs (text); |
1406 | int wlen = wcslen (wstr); |
|
|
1407 | int dlen = 0; |
1393 | int dlen = 0; |
1408 | |
1394 | |
1409 | // find length |
1395 | // find length |
1410 | for (wchar_t *s = wstr; *s; s++) |
1396 | for (wchar_t *s = wstr; *s; s++) |
1411 | if (*s == NOCHAR) |
1397 | if (*s == NOCHAR) |
… | |
… | |
1483 | |
1469 | |
1484 | if (set >= 0) |
1470 | if (set >= 0) |
1485 | { |
1471 | { |
1486 | THIS->set_option (optval, set); |
1472 | THIS->set_option (optval, set); |
1487 | |
1473 | |
1488 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1474 | if (THIS->prepare_ev.is_active ()) // avoid doing this before START |
1489 | switch (optval) |
1475 | switch (optval) |
1490 | { |
1476 | { |
1491 | case Opt_skipBuiltinGlyphs: |
1477 | case Opt_skipBuiltinGlyphs: |
1492 | THIS->set_fonts (); |
1478 | THIS->set_fonts (); |
1493 | THIS->scr_remap_chars (); |
1479 | THIS->scr_remap_chars (); |
… | |
… | |
1679 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1665 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1680 | |
1666 | |
1681 | EXTEND (SP, count); |
1667 | EXTEND (SP, count); |
1682 | while (count--) |
1668 | while (count--) |
1683 | PUSHs (newSVuv ((U32)props [count])); |
1669 | PUSHs (newSVuv ((U32)props [count])); |
1684 | |
1670 | |
1685 | XFree (props); |
1671 | XFree (props); |
1686 | } |
1672 | } |
1687 | |
1673 | |
1688 | void |
1674 | void |
1689 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
1675 | rxvt_term::XGetWindowProperty (Window window, Atom property) |