… | |
… | |
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 | typedef SV * urxvt_color; |
|
|
57 | |
|
|
58 | typedef GdkPixbuf * urxvt__pixbuf; |
|
|
59 | typedef rxvt_img * urxvt__img; |
|
|
60 | |
|
|
61 | ///////////////////////////////////////////////////////////////////////////// |
|
|
62 | |
|
|
63 | static void |
|
|
64 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
|
|
65 | { |
|
|
66 | //TODO: support component stuff |
|
|
67 | c.set (s, SvPVbyte_nolen (sv)); |
|
|
68 | } |
50 | |
69 | |
51 | ///////////////////////////////////////////////////////////////////////////// |
70 | ///////////////////////////////////////////////////////////////////////////// |
52 | |
71 | |
53 | static wchar_t * |
72 | static wchar_t * |
54 | sv2wcs (SV *sv) |
73 | sv2wcs (SV *sv) |
… | |
… | |
367 | if (perl) |
386 | if (perl) |
368 | { |
387 | { |
369 | // runs outside of perls ENV |
388 | // runs outside of perls ENV |
370 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
389 | 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); |
390 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
391 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
372 | } |
392 | } |
373 | } |
393 | } |
374 | |
394 | |
375 | static void |
395 | static void |
376 | ungrab (rxvt_term *THIS) |
396 | ungrab (rxvt_term *THIS) |
… | |
… | |
396 | { |
416 | { |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
417 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | |
418 | |
399 | for (int i = 0; i <= AvFILL (av); i++) |
419 | for (int i = 0; i <= AvFILL (av); i++) |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
420 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
|
|
421 | } |
|
|
422 | else if (htype == HOOK_DESTROY) |
|
|
423 | { |
|
|
424 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
425 | |
|
|
426 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
427 | { |
|
|
428 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
429 | delete req; |
|
|
430 | } |
401 | } |
431 | } |
402 | |
432 | |
403 | bool event_consumed; |
433 | bool event_consumed; |
404 | |
434 | |
405 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
435 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
… | |
… | |
788 | const_iv (XIMDontChange), |
818 | const_iv (XIMDontChange), |
789 | # endif |
819 | # endif |
790 | # endif |
820 | # endif |
791 | }; |
821 | }; |
792 | |
822 | |
793 | for (civ = const_iv + ecb_array_length (const_iv); civ-- > const_iv; ) |
823 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
794 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
824 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
795 | } |
825 | } |
796 | |
826 | |
797 | void |
827 | void |
798 | warn (const char *msg) |
828 | warn (const char *msg) |
799 | CODE: |
829 | CODE: |
… | |
… | |
876 | IV |
906 | IV |
877 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
907 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
878 | CODE: |
908 | CODE: |
879 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
909 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
880 | req->cb_sv = newSVsv (cb); |
910 | req->cb_sv = newSVsv (cb); |
|
|
911 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
912 | av_push (av, newSViv ((IV)req)); |
881 | RETVAL = (IV)req; |
913 | RETVAL = (IV)req; |
882 | OUTPUT: |
914 | OUTPUT: |
883 | RETVAL |
915 | RETVAL |
884 | |
916 | |
885 | void |
917 | void |
886 | _delete_selection_request (IV req_) |
918 | _delete_selection_request (IV req_) |
887 | CODE: |
919 | CODE: |
888 | rxvt_selection *req = (rxvt_selection *)req_; |
920 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
921 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
922 | int i; |
|
|
923 | |
|
|
924 | for (i = AvFILL (av); i >= 0; i--) |
|
|
925 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
926 | break; |
|
|
927 | |
|
|
928 | for (; i < AvFILL (av); i++) |
|
|
929 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
930 | |
|
|
931 | av_pop (av); |
|
|
932 | |
889 | delete req; |
933 | delete req; |
890 | |
934 | |
891 | MODULE = urxvt PACKAGE = urxvt::term |
935 | MODULE = urxvt PACKAGE = urxvt::term |
892 | |
936 | |
893 | SV * |
937 | SV * |
… | |
… | |
895 | CODE: |
939 | CODE: |
896 | { |
940 | { |
897 | rxvt_term *term = new rxvt_term; |
941 | rxvt_term *term = new rxvt_term; |
898 | |
942 | |
899 | stringvec *argv = new stringvec; |
943 | stringvec *argv = new stringvec; |
900 | stringvec *envv = new stringvec; |
|
|
901 | |
|
|
902 | for (int i = 0; i <= AvFILL (arg); i++) |
944 | for (int i = 0; i <= AvFILL (arg); i++) |
903 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
945 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
904 | |
946 | |
|
|
947 | stringvec *envv = new stringvec; |
905 | for (int i = AvFILL (env) + 1; i--; ) |
948 | for (int i = AvFILL (env) + 1; i--; ) |
906 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
949 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
907 | |
|
|
908 | envv->push_back (0); |
|
|
909 | |
950 | |
910 | try |
951 | try |
911 | { |
952 | { |
912 | term->init (argv, envv); |
953 | term->init (argv, envv); |
913 | } |
954 | } |
… | |
… | |
953 | |
994 | |
954 | void |
995 | void |
955 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
996 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
956 | CODE: |
997 | CODE: |
957 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
998 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
958 | |
|
|
959 | void |
|
|
960 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
961 | CODE: |
|
|
962 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
963 | |
999 | |
964 | bool |
1000 | bool |
965 | rxvt_term::grab (Time eventtime, int sync = 0) |
1001 | rxvt_term::grab (Time eventtime, int sync = 0) |
966 | CODE: |
1002 | CODE: |
967 | { |
1003 | { |
… | |
… | |
1079 | rxvt_pop_locale (); |
1115 | rxvt_pop_locale (); |
1080 | |
1116 | |
1081 | RETVAL = wcs2sv (wstr); |
1117 | RETVAL = wcs2sv (wstr); |
1082 | free (wstr); |
1118 | free (wstr); |
1083 | } |
1119 | } |
1084 | OUTPUT: |
|
|
1085 | RETVAL |
|
|
1086 | |
|
|
1087 | char * |
|
|
1088 | rxvt_term::locale () |
|
|
1089 | CODE: |
|
|
1090 | RETVAL = THIS->locale; |
|
|
1091 | OUTPUT: |
1120 | OUTPUT: |
1092 | RETVAL |
1121 | RETVAL |
1093 | |
1122 | |
1094 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1123 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1095 | |
1124 | |
… | |
… | |
1241 | } |
1270 | } |
1242 | OUTPUT: |
1271 | OUTPUT: |
1243 | RETVAL |
1272 | RETVAL |
1244 | |
1273 | |
1245 | void |
1274 | void |
|
|
1275 | rxvt_term::set_urgency (bool enable) |
|
|
1276 | |
|
|
1277 | void |
1246 | rxvt_term::focus_in () |
1278 | rxvt_term::focus_in () |
1247 | |
1279 | |
1248 | void |
1280 | void |
1249 | rxvt_term::focus_out () |
1281 | rxvt_term::focus_out () |
1250 | |
1282 | |
… | |
… | |
1530 | |
1562 | |
1531 | if (set >= 0) |
1563 | if (set >= 0) |
1532 | { |
1564 | { |
1533 | THIS->set_option (optval, set); |
1565 | THIS->set_option (optval, set); |
1534 | |
1566 | |
1535 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1567 | if (THIS->init_done) // avoid doing this before START |
1536 | switch (optval) |
1568 | switch (optval) |
1537 | { |
1569 | { |
1538 | case Opt_skipBuiltinGlyphs: |
1570 | case Opt_skipBuiltinGlyphs: |
1539 | THIS->set_fonts (); |
1571 | THIS->set_fonts (); |
1540 | THIS->scr_remap_chars (); |
1572 | THIS->scr_remap_chars (); |
1541 | THIS->scr_touch (true); |
1573 | THIS->scr_touch (true); |
1542 | THIS->want_refresh = 1; |
1574 | THIS->want_refresh = 1; |
1543 | THIS->refresh_check (); |
1575 | THIS->refresh_check (); |
1544 | break; |
1576 | break; |
|
|
1577 | #ifdef CURSOR_BLINK |
|
|
1578 | case Opt_cursorBlink: |
|
|
1579 | THIS->cursor_blink_reset (); |
|
|
1580 | break; |
|
|
1581 | #endif |
1545 | |
1582 | |
1546 | case Opt_cursorUnderline: |
1583 | case Opt_cursorUnderline: |
1547 | THIS->want_refresh = 1; |
1584 | THIS->want_refresh = 1; |
1548 | THIS->refresh_check (); |
1585 | THIS->refresh_check (); |
1549 | break; |
1586 | break; |
… | |
… | |
1563 | CODE: |
1600 | CODE: |
1564 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1601 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1565 | THIS->keyboard->register_done (); |
1602 | THIS->keyboard->register_done (); |
1566 | OUTPUT: |
1603 | OUTPUT: |
1567 | RETVAL |
1604 | RETVAL |
|
|
1605 | |
|
|
1606 | void |
|
|
1607 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1608 | CODE: |
|
|
1609 | wchar_t *wstr = sv2wcs (str); |
|
|
1610 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1611 | free (wstr); |
1568 | |
1612 | |
1569 | void |
1613 | void |
1570 | rxvt_term::screen_cur (...) |
1614 | rxvt_term::screen_cur (...) |
1571 | PROTOTYPE: $;$$ |
1615 | PROTOTYPE: $;$$ |
1572 | ALIAS: |
1616 | ALIAS: |
… | |
… | |
1894 | void |
1938 | void |
1895 | overlay::DESTROY () |
1939 | overlay::DESTROY () |
1896 | |
1940 | |
1897 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1941 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1898 | |
1942 | |
|
|
1943 | MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_ |
|
|
1944 | |
|
|
1945 | #if HAVE_PIXBUF |
|
|
1946 | |
|
|
1947 | urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename) |
|
|
1948 | C_ARGS: filename, 0 |
|
|
1949 | |
|
|
1950 | void |
|
|
1951 | DESTROY (urxvt::pixbuf self) |
|
|
1952 | CODE: |
|
|
1953 | gdk_pixbuf_unref (self); |
|
|
1954 | |
|
|
1955 | #endif |
|
|
1956 | |
|
|
1957 | MODULE = urxvt PACKAGE = urxvt::img |
|
|
1958 | |
|
|
1959 | #if HAVE_IMG |
|
|
1960 | |
|
|
1961 | # rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height); |
|
|
1962 | # rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
|
|
1963 | |
|
|
1964 | void fill (urxvt::img self, SV *c) |
|
|
1965 | CODE: |
|
|
1966 | rxvt_color rc; |
|
|
1967 | parse_color (self->s, rc, c); |
|
|
1968 | self->fill (rc); |
|
|
1969 | |
|
|
1970 | void blur (urxvt::img self, int rh, int rv) |
|
|
1971 | CODE: |
|
|
1972 | self->blur (rh, rv); |
|
|
1973 | |
|
|
1974 | void brightness (urxvt::img self, double r, double g, double b, double a = 1.) |
|
|
1975 | CODE: |
|
|
1976 | self->brightness (r, g, b, a); |
|
|
1977 | |
|
|
1978 | void contrast (urxvt::img self, double r, double g, double b, double a = 1.) |
|
|
1979 | CODE: |
|
|
1980 | self->contrast (r, g, b, a); |
|
|
1981 | |
|
|
1982 | urxvt::img copy (urxvt::img self) |
|
|
1983 | CODE: |
|
|
1984 | RETVAL = self->copy (); |
|
|
1985 | OUTPUT: |
|
|
1986 | RETVAL |
|
|
1987 | |
|
|
1988 | urxvt::img scale (urxvt::img self, int new_width, int new_height) |
|
|
1989 | CODE: |
|
|
1990 | RETVAL = self->scale (new_width, new_height); |
|
|
1991 | OUTPUT: |
|
|
1992 | RETVAL |
|
|
1993 | |
|
|
1994 | # rxvt_img *transform (urxvt::img self, int new_width, int new_height, double matrix[16]); |
|
|
1995 | |
|
|
1996 | #endif |
|
|
1997 | |