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 |
|
|
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
44 | #define GRAB_CURSOR THIS->scrollBar.leftptr_cursor |
46 | #else |
|
|
47 | # define GRAB_CURSOR None |
|
|
48 | #endif |
|
|
49 | |
45 | |
50 | #undef LINENO |
46 | #undef LINENO |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
47 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
52 | #undef ROW |
48 | #undef ROW |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
49 | #define ROW(n) THIS->row_buf [LINENO (n)] |
54 | |
50 | |
55 | typedef int CHAINED UNUSED; |
|
|
56 | |
|
|
57 | ///////////////////////////////////////////////////////////////////////////// |
51 | ///////////////////////////////////////////////////////////////////////////// |
58 | |
52 | |
59 | static wchar_t * |
53 | static wchar_t * |
60 | sv2wcs (SV *sv) |
54 | sv2wcs (SV *sv) |
61 | { |
55 | { |
… | |
… | |
75 | |
69 | |
76 | return sv; |
70 | return sv; |
77 | } |
71 | } |
78 | |
72 | |
79 | static SV * |
73 | static SV * |
80 | new_ref (HV *hv, const char *klass) |
|
|
81 | { |
|
|
82 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
83 | } |
|
|
84 | |
|
|
85 | static SV * |
|
|
86 | newSVptr (void *ptr, const char *klass) |
74 | newSVptr (void *ptr, const char *klass) |
87 | { |
75 | { |
88 | HV *hv = newHV (); |
76 | HV *hv = newHV (); |
89 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
77 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
90 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
78 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
… | |
… | |
119 | |
107 | |
120 | ///////////////////////////////////////////////////////////////////////////// |
108 | ///////////////////////////////////////////////////////////////////////////// |
121 | |
109 | |
122 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
110 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
123 | |
111 | |
124 | class overlay { |
112 | class overlay : overlay_base |
|
|
113 | { |
125 | rxvt_term *THIS; |
114 | rxvt_term *THIS; |
126 | AV *overlay_av; |
115 | AV *overlay_av; |
127 | int x, y, w, h; |
|
|
128 | int border; |
116 | int border; |
129 | text_t **text; |
|
|
130 | rend_t **rend; |
|
|
131 | |
117 | |
132 | public: |
118 | public: |
133 | HV *self; |
119 | HV *self; |
134 | |
120 | |
135 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
121 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
… | |
… | |
142 | |
128 | |
143 | void set (int x, int y, SV *str, SV *rend); |
129 | void set (int x, int y, SV *str, SV *rend); |
144 | }; |
130 | }; |
145 | |
131 | |
146 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
132 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
147 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), overlay_av (0) |
133 | : THIS(THIS), border(border == 2), overlay_av (0) |
148 | { |
134 | { |
|
|
135 | x = x_; |
|
|
136 | y = y_; |
|
|
137 | w = w_; |
|
|
138 | h = h_; |
|
|
139 | |
149 | if (w < 0) w = 0; |
140 | if (w < 0) w = 0; |
150 | if (h < 0) h = 0; |
141 | if (h < 0) h = 0; |
151 | |
142 | |
152 | if (border == 2) |
143 | if (border == 2) |
153 | { |
144 | { |
… | |
… | |
222 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
213 | *hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0) |
223 | )); |
214 | )); |
224 | av_push (overlay_av, newSViv ((long)this)); |
215 | av_push (overlay_av, newSViv ((long)this)); |
225 | |
216 | |
226 | THIS->want_refresh = 1; |
217 | THIS->want_refresh = 1; |
|
|
218 | THIS->refresh_check (); |
227 | } |
219 | } |
228 | |
220 | |
229 | void |
221 | void |
230 | overlay::hide () |
222 | overlay::hide () |
231 | { |
223 | { |
… | |
… | |
245 | |
237 | |
246 | SvREFCNT_dec (overlay_av); |
238 | SvREFCNT_dec (overlay_av); |
247 | overlay_av = 0; |
239 | overlay_av = 0; |
248 | |
240 | |
249 | THIS->want_refresh = 1; |
241 | THIS->want_refresh = 1; |
|
|
242 | THIS->refresh_check (); |
250 | } |
243 | } |
251 | |
244 | |
252 | void overlay::swap () |
245 | void overlay::swap () |
253 | { |
246 | { |
254 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
247 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
255 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
248 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
256 | |
249 | |
257 | int ov_w = min (w, THIS->ncol - ov_x); |
250 | int ov_w = min (w, THIS->ncol - ov_x); |
258 | int ov_h = min (h, THIS->nrow - ov_y); |
251 | int ov_h = min (h, THIS->nrow - ov_y); |
|
|
252 | |
|
|
253 | // hide cursor if it is within the overlay area |
|
|
254 | if (IN_RANGE_EXC (THIS->screen.cur.col - ov_x, 0, ov_w) |
|
|
255 | && IN_RANGE_EXC (THIS->screen.cur.row - ov_y, 0, ov_h)) |
|
|
256 | THIS->screen.flags &= ~Screen_VisibleCursor; |
259 | |
257 | |
260 | for (int y = ov_h; y--; ) |
258 | for (int y = ov_h; y--; ) |
261 | { |
259 | { |
262 | text_t *t1 = text [y]; |
260 | text_t *t1 = text [y]; |
263 | rend_t *r1 = rend [y]; |
261 | rend_t *r1 = rend [y]; |
… | |
… | |
299 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
297 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
300 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
298 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
301 | } |
299 | } |
302 | |
300 | |
303 | THIS->want_refresh = 1; |
301 | THIS->want_refresh = 1; |
|
|
302 | THIS->refresh_check (); |
304 | } |
303 | } |
305 | |
304 | |
306 | ///////////////////////////////////////////////////////////////////////////// |
305 | ///////////////////////////////////////////////////////////////////////////// |
307 | |
306 | |
308 | #define IOM_CLASS "urxvt" |
307 | #define IOM_CLASS "urxvt" |
|
|
308 | #define IOM_WARN rxvt_warn |
309 | #include <iom_perl.h> |
309 | #include "iom_perl.h" |
310 | |
310 | |
311 | ///////////////////////////////////////////////////////////////////////////// |
311 | ///////////////////////////////////////////////////////////////////////////// |
312 | |
312 | |
313 | struct rxvt_perl_interp rxvt_perl; |
313 | struct rxvt_perl_interp rxvt_perl; |
314 | |
314 | |
… | |
… | |
318 | { |
318 | { |
319 | if (perl) |
319 | if (perl) |
320 | { |
320 | { |
321 | perl_destruct (perl); |
321 | perl_destruct (perl); |
322 | perl_free (perl); |
322 | perl_free (perl); |
|
|
323 | PERL_SYS_TERM (); |
323 | } |
324 | } |
324 | } |
325 | } |
325 | |
326 | |
326 | void |
327 | void |
327 | rxvt_perl_interp::init (rxvt_term *term) |
328 | rxvt_perl_interp::init (rxvt_term *term) |
… | |
… | |
331 | rxvt_push_locale (""); // perl init destroys current locale |
332 | rxvt_push_locale (""); // perl init destroys current locale |
332 | |
333 | |
333 | perl_environ = rxvt_environ; |
334 | perl_environ = rxvt_environ; |
334 | swap (perl_environ, environ); |
335 | swap (perl_environ, environ); |
335 | |
336 | |
336 | char *argv[] = { |
337 | char *args[] = { |
337 | "", |
338 | "", |
338 | "-e" |
339 | "-e" |
339 | "BEGIN {" |
340 | "BEGIN {" |
340 | " urxvt->bootstrap;" |
341 | " urxvt->bootstrap;" |
341 | " unshift @INC, '" LIBDIR "';" |
342 | " unshift @INC, '" LIBDIR "';" |
342 | "}" |
343 | "}" |
343 | "" |
344 | "" |
344 | "use urxvt;" |
345 | "use urxvt;" |
345 | }; |
346 | }; |
|
|
347 | int argc = sizeof (args) / sizeof (args[0]); |
|
|
348 | char **argv = args; |
346 | |
349 | |
|
|
350 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
347 | perl = perl_alloc (); |
351 | perl = perl_alloc (); |
348 | perl_construct (perl); |
352 | perl_construct (perl); |
349 | |
353 | |
350 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
354 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
351 | || perl_run (perl)) |
355 | || perl_run (perl)) |
352 | { |
356 | { |
353 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
357 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
354 | |
358 | |
355 | perl_destruct (perl); |
359 | perl_destruct (perl); |
… | |
… | |
389 | |
393 | |
390 | // pre-handling of some events |
394 | // pre-handling of some events |
391 | if (htype == HOOK_REFRESH_END) |
395 | if (htype == HOOK_REFRESH_END) |
392 | { |
396 | { |
393 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
394 | |
398 | |
395 | for (int i = 0; i <= AvFILL (av); i++) |
399 | for (int i = 0; i <= AvFILL (av); i++) |
396 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
397 | } |
401 | } |
398 | |
402 | |
399 | swap (perl_environ, environ); |
403 | swap (perl_environ, environ); |
… | |
… | |
598 | |
602 | |
599 | // post-handling of some events |
603 | // post-handling of some events |
600 | if (htype == HOOK_REFRESH_BEGIN) |
604 | if (htype == HOOK_REFRESH_BEGIN) |
601 | { |
605 | { |
602 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
606 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
603 | |
607 | |
604 | for (int i = AvFILL (av); i >= 0; i--) |
608 | for (int i = AvFILL (av); i >= 0; i--) |
605 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
609 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
606 | } |
610 | } |
607 | else if (htype == HOOK_DESTROY) |
611 | else if (htype == HOOK_DESTROY) |
608 | { |
612 | { |
609 | clearSVptr ((SV *)term->perl.self); |
613 | clearSVptr ((SV *)term->perl.self); |
610 | SvREFCNT_dec ((SV *)term->perl.self); |
614 | SvREFCNT_dec ((SV *)term->perl.self); |
611 | |
615 | |
612 | // don't allow further calls |
616 | // don't allow further calls |
613 | term->perl.self = 0; |
617 | term->perl.self = 0; |
614 | } |
618 | } |
615 | |
619 | |
616 | swap (perl_environ, environ); |
620 | swap (perl_environ, environ); |
… | |
… | |
635 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
639 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
636 | # include "hookinc.h" |
640 | # include "hookinc.h" |
637 | # undef def |
641 | # undef def |
638 | |
642 | |
639 | HV *option = get_hv ("urxvt::OPTION", 1); |
643 | HV *option = get_hv ("urxvt::OPTION", 1); |
640 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
644 | # define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
641 | # define nodef(name) |
645 | # define nodef(name) |
642 | # include "optinc.h" |
646 | # include "optinc.h" |
643 | # undef nodef |
647 | # undef nodef |
644 | # undef def |
648 | # undef def |
645 | |
649 | |
… | |
… | |
647 | static const struct { |
651 | static const struct { |
648 | const char *name; |
652 | const char *name; |
649 | IV iv; |
653 | IV iv; |
650 | } *civ, const_iv[] = { |
654 | } *civ, const_iv[] = { |
651 | # define const_iv(name) { # name, (IV)name } |
655 | # define const_iv(name) { # name, (IV)name } |
|
|
656 | const_iv (NUM_RESOURCES), |
652 | const_iv (DEFAULT_RSTYLE), |
657 | const_iv (DEFAULT_RSTYLE), |
653 | const_iv (OVERLAY_RSTYLE), |
658 | const_iv (OVERLAY_RSTYLE), |
|
|
659 | const_iv (Color_Bits), |
|
|
660 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
|
|
661 | const_iv (RS_fgShift), const_iv (RS_fgMask), |
|
|
662 | const_iv (RS_Careful), |
|
|
663 | const_iv (RS_fontCount), |
|
|
664 | const_iv (RS_fontShift), |
|
|
665 | const_iv (RS_fontMask), |
|
|
666 | const_iv (RS_baseattrMask), |
|
|
667 | const_iv (RS_attrMask), |
|
|
668 | const_iv (RS_redraw), |
|
|
669 | const_iv (RS_Sel), |
654 | const_iv (RS_Bold), |
670 | const_iv (RS_Bold), |
655 | const_iv (RS_Italic), |
671 | const_iv (RS_Italic), |
656 | const_iv (RS_Blink), |
672 | const_iv (RS_Blink), |
657 | const_iv (RS_RVid), |
673 | const_iv (RS_RVid), |
658 | const_iv (RS_Uline), |
674 | const_iv (RS_Uline), |
… | |
… | |
674 | const_iv (AnyModifier), |
690 | const_iv (AnyModifier), |
675 | |
691 | |
676 | const_iv (NoSymbol), |
692 | const_iv (NoSymbol), |
677 | const_iv (GrabModeSync), |
693 | const_iv (GrabModeSync), |
678 | const_iv (GrabModeAsync), |
694 | const_iv (GrabModeAsync), |
679 | |
|
|
680 | const_iv (EVENT_NONE), |
|
|
681 | const_iv (EVENT_READ), |
|
|
682 | const_iv (EVENT_WRITE), |
|
|
683 | |
695 | |
684 | const_iv (NoEventMask), |
696 | const_iv (NoEventMask), |
685 | const_iv (KeyPressMask), |
697 | const_iv (KeyPressMask), |
686 | const_iv (KeyReleaseMask), |
698 | const_iv (KeyReleaseMask), |
687 | const_iv (ButtonPressMask), |
699 | const_iv (ButtonPressMask), |
… | |
… | |
786 | _exit (int status) |
798 | _exit (int status) |
787 | |
799 | |
788 | NV |
800 | NV |
789 | NOW () |
801 | NOW () |
790 | CODE: |
802 | CODE: |
791 | RETVAL = NOW; |
803 | RETVAL = ev::now (); |
792 | OUTPUT: |
804 | OUTPUT: |
793 | RETVAL |
805 | RETVAL |
794 | |
806 | |
795 | int |
807 | int |
796 | GET_BASEFG (int rend) |
808 | GET_BASEFG (int rend) |
… | |
… | |
868 | for (int i = AvFILL (env) + 1; i--; ) |
880 | for (int i = AvFILL (env) + 1; i--; ) |
869 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
881 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
870 | |
882 | |
871 | envv->push_back (0); |
883 | envv->push_back (0); |
872 | |
884 | |
873 | bool success; |
|
|
874 | |
|
|
875 | try |
885 | try |
876 | { |
886 | { |
877 | success = term->init (argv, envv); |
887 | term->init (argv, envv); |
878 | } |
888 | } |
879 | catch (const class rxvt_failure_exception &e) |
889 | catch (const class rxvt_failure_exception &e) |
880 | { |
|
|
881 | success = false; |
|
|
882 | } |
|
|
883 | |
|
|
884 | if (!success) |
|
|
885 | { |
890 | { |
886 | term->destroy (); |
891 | term->destroy (); |
887 | croak ("error while initializing new terminal instance"); |
892 | croak ("error while initializing new terminal instance"); |
888 | } |
893 | } |
889 | |
894 | |
… | |
… | |
1061 | OUTPUT: |
1066 | OUTPUT: |
1062 | RETVAL |
1067 | RETVAL |
1063 | |
1068 | |
1064 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1069 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1065 | |
1070 | |
1066 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1071 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1067 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1072 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1068 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1073 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1069 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1074 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1070 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1075 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1071 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1076 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1072 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1077 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1073 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1078 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1074 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1079 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1075 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1080 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1076 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1081 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1077 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
1082 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
|
|
1083 | #define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace) |
1078 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1084 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1079 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1085 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1080 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1086 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1081 | |
1087 | |
1082 | int |
1088 | int |
1083 | rxvt_term::width () |
1089 | rxvt_term::width () |
1084 | ALIAS: |
1090 | ALIAS: |
1085 | width = TERM_OFFSET_width |
1091 | width = TERM_OFFSET_width |
1086 | height = TERM_OFFSET_height |
1092 | height = TERM_OFFSET_height |
1087 | fwidth = TERM_OFFSET_fwidth |
1093 | fwidth = TERM_OFFSET_fwidth |
1088 | fheight = TERM_OFFSET_fheight |
1094 | fheight = TERM_OFFSET_fheight |
1089 | fbase = TERM_OFFSET_fbase |
1095 | fbase = TERM_OFFSET_fbase |
1090 | nrow = TERM_OFFSET_nrow |
1096 | nrow = TERM_OFFSET_nrow |
1091 | ncol = TERM_OFFSET_ncol |
1097 | ncol = TERM_OFFSET_ncol |
1092 | focus = TERM_OFFSET_focus |
1098 | focus = TERM_OFFSET_focus |
1093 | mapped = TERM_OFFSET_mapped |
1099 | mapped = TERM_OFFSET_mapped |
1094 | int_bwidth = TERM_OFFSET_int_bwidth |
1100 | int_bwidth = TERM_OFFSET_int_bwidth |
1095 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1101 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1096 | lineSpace = TERM_OFFSET_lineSpace |
1102 | lineSpace = TERM_OFFSET_lineSpace |
|
|
1103 | letterSpace = TERM_OFFSET_letterSpace |
1097 | saveLines = TERM_OFFSET_saveLines |
1104 | saveLines = TERM_OFFSET_saveLines |
1098 | total_rows = TERM_OFFSET_total_rows |
1105 | total_rows = TERM_OFFSET_total_rows |
1099 | top_row = TERM_OFFSET_top_row |
1106 | top_row = TERM_OFFSET_top_row |
1100 | CODE: |
1107 | CODE: |
1101 | RETVAL = *(int *)((char *)THIS + ix); |
1108 | RETVAL = *(int *)((char *)THIS + ix); |
1102 | OUTPUT: |
1109 | OUTPUT: |
1103 | RETVAL |
1110 | RETVAL |
1104 | |
1111 | |
… | |
… | |
1115 | { |
1122 | { |
1116 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1123 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1117 | case 1: RETVAL = THIS->ModMetaMask; break; |
1124 | case 1: RETVAL = THIS->ModMetaMask; break; |
1118 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1125 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1119 | case 3: RETVAL = THIS->current_screen; break; |
1126 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1127 | #ifdef CURSOR_BLINK |
1120 | case 4: RETVAL = THIS->hidden_cursor; break; |
1128 | case 4: RETVAL = THIS->hidden_cursor; break; |
|
|
1129 | #endif |
1121 | } |
1130 | } |
1122 | OUTPUT: |
1131 | OUTPUT: |
1123 | RETVAL |
1132 | RETVAL |
1124 | |
1133 | |
1125 | char * |
1134 | char * |
… | |
… | |
1150 | if (*i) |
1159 | if (*i) |
1151 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1160 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1152 | } |
1161 | } |
1153 | |
1162 | |
1154 | int |
1163 | int |
1155 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1164 | rxvt_term::pty_ev_events (int events = ev::UNDEF) |
1156 | CODE: |
1165 | CODE: |
1157 | RETVAL = THIS->pty_ev.events; |
1166 | RETVAL = THIS->pty_ev.events; |
1158 | if (events != EVENT_UNDEF) |
1167 | if (events != ev::UNDEF) |
1159 | THIS->pty_ev.set (events); |
1168 | THIS->pty_ev.set (events); |
1160 | OUTPUT: |
1169 | OUTPUT: |
1161 | RETVAL |
1170 | RETVAL |
1162 | |
1171 | |
1163 | int |
1172 | int |
… | |
… | |
1242 | |
1251 | |
1243 | void |
1252 | void |
1244 | rxvt_term::want_refresh () |
1253 | rxvt_term::want_refresh () |
1245 | CODE: |
1254 | CODE: |
1246 | THIS->want_refresh = 1; |
1255 | THIS->want_refresh = 1; |
|
|
1256 | THIS->refresh_check (); |
1247 | |
1257 | |
1248 | void |
1258 | void |
1249 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1259 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1250 | PPCODE: |
1260 | PPCODE: |
1251 | { |
1261 | { |
… | |
… | |
1406 | SV * |
1416 | SV * |
1407 | rxvt_term::special_decode (SV *text) |
1417 | rxvt_term::special_decode (SV *text) |
1408 | CODE: |
1418 | CODE: |
1409 | { |
1419 | { |
1410 | wchar_t *wstr = sv2wcs (text); |
1420 | wchar_t *wstr = sv2wcs (text); |
1411 | int wlen = wcslen (wstr); |
|
|
1412 | int dlen = 0; |
1421 | int dlen = 0; |
1413 | |
1422 | |
1414 | // find length |
1423 | // find length |
1415 | for (wchar_t *s = wstr; *s; s++) |
1424 | for (wchar_t *s = wstr; *s; s++) |
1416 | if (*s == NOCHAR) |
1425 | if (*s == NOCHAR) |
… | |
… | |
1449 | # undef reserve |
1458 | # undef reserve |
1450 | }; |
1459 | }; |
1451 | |
1460 | |
1452 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1461 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1453 | |
1462 | |
|
|
1463 | if (*name) |
1454 | do { |
1464 | { |
|
|
1465 | do { |
1455 | if (rs-- == rslist) |
1466 | if (rs-- == rslist) |
1456 | croak ("no such resource '%s', requested", name); |
1467 | croak ("no such resource '%s', requested", name); |
1457 | } while (strcmp (name, rs->name)); |
1468 | } while (strcmp (name, rs->name)); |
1458 | |
1469 | |
1459 | index += rs->value; |
1470 | index += rs->value; |
|
|
1471 | } |
|
|
1472 | else |
|
|
1473 | { |
|
|
1474 | --rs; |
|
|
1475 | name = ""; |
|
|
1476 | } |
1460 | |
1477 | |
1461 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1478 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1462 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1479 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1463 | |
1480 | |
1464 | if (GIMME_V != G_VOID) |
1481 | if (GIMME_V != G_VOID) |
… | |
… | |
1479 | |
1496 | |
1480 | const char * |
1497 | const char * |
1481 | rxvt_term::x_resource (const char *name) |
1498 | rxvt_term::x_resource (const char *name) |
1482 | |
1499 | |
1483 | bool |
1500 | bool |
1484 | rxvt_term::option (U32 optval, int set = -1) |
1501 | rxvt_term::option (U8 optval, int set = -1) |
1485 | CODE: |
1502 | CODE: |
1486 | { |
1503 | { |
1487 | RETVAL = THIS->options & optval; |
1504 | RETVAL = THIS->option (optval); |
1488 | |
1505 | |
1489 | if (set >= 0) |
1506 | if (set >= 0) |
1490 | { |
1507 | { |
1491 | if (set) |
|
|
1492 | THIS->options |= optval; |
1508 | THIS->set_option (optval, set); |
1493 | else |
|
|
1494 | THIS->options &= ~optval; |
|
|
1495 | |
1509 | |
1496 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1510 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1497 | switch (optval) |
1511 | switch (optval) |
1498 | { |
1512 | { |
1499 | case Opt_skipBuiltinGlyphs: |
1513 | case Opt_skipBuiltinGlyphs: |
1500 | THIS->set_fonts (); |
1514 | THIS->set_fonts (); |
1501 | THIS->scr_remap_chars (); |
1515 | THIS->scr_remap_chars (); |
1502 | THIS->scr_touch (true); |
1516 | THIS->scr_touch (true); |
1503 | THIS->want_refresh = 1; |
1517 | THIS->want_refresh = 1; |
|
|
1518 | THIS->refresh_check (); |
1504 | break; |
1519 | break; |
1505 | |
1520 | |
1506 | case Opt_cursorUnderline: |
1521 | case Opt_cursorUnderline: |
1507 | THIS->want_refresh = 1; |
1522 | THIS->want_refresh = 1; |
|
|
1523 | THIS->refresh_check (); |
1508 | break; |
1524 | break; |
1509 | |
1525 | |
1510 | # case Opt_scrollBar_floating: |
1526 | # case Opt_scrollBar_floating: |
1511 | # case Opt_scrollBar_right: |
1527 | # case Opt_scrollBar_right: |
1512 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1528 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
… | |
… | |
1545 | EXTEND (SP, 2); |
1561 | EXTEND (SP, 2); |
1546 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1562 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1547 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1563 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1548 | } |
1564 | } |
1549 | |
1565 | |
1550 | if (items == 3) |
1566 | if (items >= 3) |
1551 | { |
1567 | { |
1552 | rc.row = SvIV (ST (1)); |
1568 | rc.row = SvIV (ST (1)); |
1553 | rc.col = SvIV (ST (2)); |
1569 | rc.col = SvIV (ST (2)); |
1554 | |
1570 | |
1555 | if (ix == 2) |
1571 | if (ix == 2) |
… | |
… | |
1570 | |
1586 | |
1571 | clamp_it (rc.col, 0, THIS->ncol); |
1587 | clamp_it (rc.col, 0, THIS->ncol); |
1572 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1588 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1573 | |
1589 | |
1574 | if (ix) |
1590 | if (ix) |
|
|
1591 | { |
|
|
1592 | THIS->selection.screen = THIS->current_screen; |
|
|
1593 | |
1575 | THIS->want_refresh = 1; |
1594 | THIS->want_refresh = 1; |
|
|
1595 | THIS->refresh_check (); |
1576 | } |
1596 | } |
|
|
1597 | } |
1577 | } |
1598 | } |
1578 | |
1599 | |
1579 | char |
1600 | int |
1580 | rxvt_term::cur_charset () |
1601 | rxvt_term::selection_screen (int screen = -1) |
1581 | CODE: |
1602 | CODE: |
1582 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1603 | RETVAL = THIS->selection.screen; |
1583 | OUTPUT: |
1604 | if (screen >= 0) |
|
|
1605 | THIS->selection.screen = screen; |
|
|
1606 | OUTPUT: |
1584 | RETVAL |
1607 | RETVAL |
1585 | |
1608 | |
1586 | void |
1609 | void |
1587 | rxvt_term::selection_clear () |
1610 | rxvt_term::selection_clear (bool clipboard = false) |
1588 | |
1611 | |
1589 | void |
1612 | void |
1590 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1613 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1591 | CODE: |
1614 | CODE: |
1592 | THIS->selection.op = SELECTION_CONT; |
1615 | THIS->selection.op = SELECTION_CONT; |
1593 | THIS->selection.rect = rect; |
1616 | THIS->selection.rect = rect; |
1594 | THIS->selection_make (eventtime); |
1617 | THIS->selection_make (eventtime); |
1595 | |
1618 | |
1596 | int |
1619 | int |
1597 | rxvt_term::selection_grab (Time eventtime) |
1620 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1598 | |
1621 | |
1599 | void |
1622 | void |
1600 | rxvt_term::selection (SV *newtext = 0) |
1623 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1601 | PPCODE: |
1624 | PPCODE: |
1602 | { |
1625 | { |
|
|
1626 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1627 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1628 | |
1603 | if (GIMME_V != G_VOID) |
1629 | if (GIMME_V != G_VOID) |
1604 | XPUSHs (THIS->selection.text |
1630 | XPUSHs (text |
1605 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1631 | ? sv_2mortal (wcs2sv (text, len)) |
1606 | : &PL_sv_undef); |
1632 | : &PL_sv_undef); |
1607 | |
1633 | |
1608 | if (newtext) |
1634 | if (newtext) |
1609 | { |
1635 | { |
1610 | free (THIS->selection.text); |
1636 | free (text); |
1611 | |
1637 | |
1612 | THIS->selection.text = sv2wcs (newtext); |
1638 | text = sv2wcs (newtext); |
1613 | THIS->selection.len = wcslen (THIS->selection.text); |
1639 | len = wcslen (text); |
1614 | } |
1640 | } |
1615 | } |
1641 | } |
|
|
1642 | |
|
|
1643 | char |
|
|
1644 | rxvt_term::cur_charset () |
|
|
1645 | CODE: |
|
|
1646 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1647 | OUTPUT: |
|
|
1648 | RETVAL |
1616 | |
1649 | |
1617 | void |
1650 | void |
1618 | rxvt_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) |
1651 | rxvt_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) |
1619 | |
1652 | |
1620 | void |
1653 | void |
… | |
… | |
1642 | char *str = SvPVbyte (octets, len); |
1675 | char *str = SvPVbyte (octets, len); |
1643 | C_ARGS: |
1676 | C_ARGS: |
1644 | str, len |
1677 | str, len |
1645 | |
1678 | |
1646 | void |
1679 | void |
|
|
1680 | rxvt_term::tt_paste (SV *octets) |
|
|
1681 | INIT: |
|
|
1682 | STRLEN len; |
|
|
1683 | char *str = SvPVbyte (octets, len); |
|
|
1684 | C_ARGS: |
|
|
1685 | str, len |
|
|
1686 | |
|
|
1687 | void |
1647 | rxvt_term::cmd_parse (SV *octets) |
1688 | rxvt_term::cmd_parse (SV *octets) |
1648 | CODE: |
1689 | CODE: |
1649 | { |
1690 | { |
1650 | STRLEN len; |
1691 | STRLEN len; |
1651 | char *str = SvPVbyte (octets, len); |
1692 | char *str = SvPVbyte (octets, len); |
… | |
… | |
1687 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1728 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1688 | |
1729 | |
1689 | EXTEND (SP, count); |
1730 | EXTEND (SP, count); |
1690 | while (count--) |
1731 | while (count--) |
1691 | PUSHs (newSVuv ((U32)props [count])); |
1732 | PUSHs (newSVuv ((U32)props [count])); |
1692 | |
1733 | |
1693 | XFree (props); |
1734 | XFree (props); |
1694 | } |
1735 | } |
1695 | |
1736 | |
1696 | void |
1737 | void |
1697 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
1738 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
… | |
… | |
1720 | XFree (prop); |
1761 | XFree (prop); |
1721 | } |
1762 | } |
1722 | } |
1763 | } |
1723 | |
1764 | |
1724 | void |
1765 | void |
1725 | rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) |
1766 | rxvt_term::XChangeProperty (Window window, Atom property, Atom type, int format, SV *data) |
1726 | CODE: |
1767 | CODE: |
1727 | { |
1768 | { |
1728 | STRLEN len; |
1769 | STRLEN len; |
1729 | char *data_ = SvPVbyte (data, len); |
1770 | char *data_ = SvPVbyte (data, len); |
1730 | |
1771 | |