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-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
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. |
… | |
… | |
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 | |
42 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
43 | |
43 | |
44 | #ifdef HAVE_SCROLLBARS |
44 | #ifdef HAVE_SCROLLBARS |
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
45 | # define GRAB_CURSOR THIS->scrollBar.leftptr_cursor |
46 | #else |
46 | #else |
47 | # define GRAB_CURSOR None |
47 | # define GRAB_CURSOR None |
48 | #endif |
48 | #endif |
49 | |
49 | |
50 | #undef LINENO |
50 | #undef LINENO |
… | |
… | |
214 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
214 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
215 | )); |
215 | )); |
216 | av_push (overlay_av, newSViv ((long)this)); |
216 | av_push (overlay_av, newSViv ((long)this)); |
217 | |
217 | |
218 | THIS->want_refresh = 1; |
218 | THIS->want_refresh = 1; |
|
|
219 | THIS->refresh_check (); |
219 | } |
220 | } |
220 | |
221 | |
221 | void |
222 | void |
222 | overlay::hide () |
223 | overlay::hide () |
223 | { |
224 | { |
… | |
… | |
237 | |
238 | |
238 | SvREFCNT_dec (overlay_av); |
239 | SvREFCNT_dec (overlay_av); |
239 | overlay_av = 0; |
240 | overlay_av = 0; |
240 | |
241 | |
241 | THIS->want_refresh = 1; |
242 | THIS->want_refresh = 1; |
|
|
243 | THIS->refresh_check (); |
242 | } |
244 | } |
243 | |
245 | |
244 | void overlay::swap () |
246 | void overlay::swap () |
245 | { |
247 | { |
246 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
248 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
… | |
… | |
291 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
293 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
292 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
294 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
293 | } |
295 | } |
294 | |
296 | |
295 | THIS->want_refresh = 1; |
297 | THIS->want_refresh = 1; |
|
|
298 | THIS->refresh_check (); |
296 | } |
299 | } |
297 | |
300 | |
298 | ///////////////////////////////////////////////////////////////////////////// |
301 | ///////////////////////////////////////////////////////////////////////////// |
299 | |
302 | |
300 | #define IOM_CLASS "urxvt" |
303 | #define IOM_CLASS "urxvt" |
301 | #define IOM_WARN rxvt_warn |
304 | #define IOM_WARN rxvt_warn |
302 | #include <iom_perl.h> |
305 | #include "iom_perl.h" |
303 | |
306 | |
304 | ///////////////////////////////////////////////////////////////////////////// |
307 | ///////////////////////////////////////////////////////////////////////////// |
305 | |
308 | |
306 | struct rxvt_perl_interp rxvt_perl; |
309 | struct rxvt_perl_interp rxvt_perl; |
307 | |
310 | |
… | |
… | |
382 | |
385 | |
383 | // pre-handling of some events |
386 | // pre-handling of some events |
384 | if (htype == HOOK_REFRESH_END) |
387 | if (htype == HOOK_REFRESH_END) |
385 | { |
388 | { |
386 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
389 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
387 | |
390 | |
388 | for (int i = 0; i <= AvFILL (av); i++) |
391 | for (int i = 0; i <= AvFILL (av); i++) |
389 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
392 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
390 | } |
393 | } |
391 | |
394 | |
392 | swap (perl_environ, environ); |
395 | swap (perl_environ, environ); |
… | |
… | |
591 | |
594 | |
592 | // post-handling of some events |
595 | // post-handling of some events |
593 | if (htype == HOOK_REFRESH_BEGIN) |
596 | if (htype == HOOK_REFRESH_BEGIN) |
594 | { |
597 | { |
595 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
598 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
596 | |
599 | |
597 | for (int i = AvFILL (av); i >= 0; i--) |
600 | for (int i = AvFILL (av); i >= 0; i--) |
598 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
601 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
599 | } |
602 | } |
600 | else if (htype == HOOK_DESTROY) |
603 | else if (htype == HOOK_DESTROY) |
601 | { |
604 | { |
602 | clearSVptr ((SV *)term->perl.self); |
605 | clearSVptr ((SV *)term->perl.self); |
603 | SvREFCNT_dec ((SV *)term->perl.self); |
606 | SvREFCNT_dec ((SV *)term->perl.self); |
604 | |
607 | |
605 | // don't allow further calls |
608 | // don't allow further calls |
606 | term->perl.self = 0; |
609 | term->perl.self = 0; |
607 | } |
610 | } |
608 | |
611 | |
609 | swap (perl_environ, environ); |
612 | swap (perl_environ, environ); |
… | |
… | |
775 | _exit (int status) |
778 | _exit (int status) |
776 | |
779 | |
777 | NV |
780 | NV |
778 | NOW () |
781 | NOW () |
779 | CODE: |
782 | CODE: |
780 | RETVAL = NOW; |
783 | RETVAL = ev::now (); |
781 | OUTPUT: |
784 | OUTPUT: |
782 | RETVAL |
785 | RETVAL |
783 | |
786 | |
784 | int |
787 | int |
785 | GET_BASEFG (int rend) |
788 | GET_BASEFG (int rend) |
… | |
… | |
857 | for (int i = AvFILL (env) + 1; i--; ) |
860 | for (int i = AvFILL (env) + 1; i--; ) |
858 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
861 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
859 | |
862 | |
860 | envv->push_back (0); |
863 | envv->push_back (0); |
861 | |
864 | |
862 | bool success; |
|
|
863 | |
|
|
864 | try |
865 | try |
865 | { |
866 | { |
866 | success = term->init (argv, envv); |
867 | term->init (argv, envv); |
867 | } |
868 | } |
868 | catch (const class rxvt_failure_exception &e) |
869 | catch (const class rxvt_failure_exception &e) |
869 | { |
|
|
870 | success = false; |
|
|
871 | } |
|
|
872 | |
|
|
873 | if (!success) |
|
|
874 | { |
870 | { |
875 | term->destroy (); |
871 | term->destroy (); |
876 | croak ("error while initializing new terminal instance"); |
872 | croak ("error while initializing new terminal instance"); |
877 | } |
873 | } |
878 | |
874 | |
… | |
… | |
1139 | if (*i) |
1135 | if (*i) |
1140 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1136 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1141 | } |
1137 | } |
1142 | |
1138 | |
1143 | int |
1139 | int |
1144 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1140 | rxvt_term::pty_ev_events (int events = ev::UNDEF) |
1145 | CODE: |
1141 | CODE: |
1146 | RETVAL = THIS->pty_ev.events; |
1142 | RETVAL = THIS->pty_ev.events; |
1147 | if (events != EVENT_UNDEF) |
1143 | if (events != ev::UNDEF) |
1148 | THIS->pty_ev.set (events); |
1144 | THIS->pty_ev.set (events); |
1149 | OUTPUT: |
1145 | OUTPUT: |
1150 | RETVAL |
1146 | RETVAL |
1151 | |
1147 | |
1152 | int |
1148 | int |
… | |
… | |
1231 | |
1227 | |
1232 | void |
1228 | void |
1233 | rxvt_term::want_refresh () |
1229 | rxvt_term::want_refresh () |
1234 | CODE: |
1230 | CODE: |
1235 | THIS->want_refresh = 1; |
1231 | THIS->want_refresh = 1; |
|
|
1232 | THIS->refresh_check (); |
1236 | |
1233 | |
1237 | void |
1234 | void |
1238 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1235 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1239 | PPCODE: |
1236 | PPCODE: |
1240 | { |
1237 | { |
… | |
… | |
1476 | |
1473 | |
1477 | if (set >= 0) |
1474 | if (set >= 0) |
1478 | { |
1475 | { |
1479 | THIS->set_option (optval, set); |
1476 | THIS->set_option (optval, set); |
1480 | |
1477 | |
1481 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1478 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1482 | switch (optval) |
1479 | switch (optval) |
1483 | { |
1480 | { |
1484 | case Opt_skipBuiltinGlyphs: |
1481 | case Opt_skipBuiltinGlyphs: |
1485 | THIS->set_fonts (); |
1482 | THIS->set_fonts (); |
1486 | THIS->scr_remap_chars (); |
1483 | THIS->scr_remap_chars (); |
1487 | THIS->scr_touch (true); |
1484 | THIS->scr_touch (true); |
1488 | THIS->want_refresh = 1; |
1485 | THIS->want_refresh = 1; |
|
|
1486 | THIS->refresh_check (); |
1489 | break; |
1487 | break; |
1490 | |
1488 | |
1491 | case Opt_cursorUnderline: |
1489 | case Opt_cursorUnderline: |
1492 | THIS->want_refresh = 1; |
1490 | THIS->want_refresh = 1; |
|
|
1491 | THIS->refresh_check (); |
1493 | break; |
1492 | break; |
1494 | |
1493 | |
1495 | # case Opt_scrollBar_floating: |
1494 | # case Opt_scrollBar_floating: |
1496 | # case Opt_scrollBar_right: |
1495 | # case Opt_scrollBar_right: |
1497 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1496 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
… | |
… | |
1555 | |
1554 | |
1556 | clamp_it (rc.col, 0, THIS->ncol); |
1555 | clamp_it (rc.col, 0, THIS->ncol); |
1557 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1556 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1558 | |
1557 | |
1559 | if (ix) |
1558 | if (ix) |
|
|
1559 | { |
1560 | THIS->want_refresh = 1; |
1560 | THIS->want_refresh = 1; |
|
|
1561 | THIS->refresh_check (); |
|
|
1562 | } |
1561 | } |
1563 | } |
1562 | } |
1564 | } |
1563 | |
1565 | |
1564 | char |
1566 | char |
1565 | rxvt_term::cur_charset () |
1567 | rxvt_term::cur_charset () |
… | |
… | |
1672 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1674 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1673 | |
1675 | |
1674 | EXTEND (SP, count); |
1676 | EXTEND (SP, count); |
1675 | while (count--) |
1677 | while (count--) |
1676 | PUSHs (newSVuv ((U32)props [count])); |
1678 | PUSHs (newSVuv ((U32)props [count])); |
1677 | |
1679 | |
1678 | XFree (props); |
1680 | XFree (props); |
1679 | } |
1681 | } |
1680 | |
1682 | |
1681 | void |
1683 | void |
1682 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
1684 | rxvt_term::XGetWindowProperty (Window window, Atom property) |