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); |
… | |
… | |
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), |
654 | const_iv (RS_Bold), |
659 | const_iv (RS_Bold), |
655 | const_iv (RS_Italic), |
660 | const_iv (RS_Italic), |
656 | const_iv (RS_Blink), |
661 | const_iv (RS_Blink), |
… | |
… | |
674 | const_iv (AnyModifier), |
679 | const_iv (AnyModifier), |
675 | |
680 | |
676 | const_iv (NoSymbol), |
681 | const_iv (NoSymbol), |
677 | const_iv (GrabModeSync), |
682 | const_iv (GrabModeSync), |
678 | const_iv (GrabModeAsync), |
683 | const_iv (GrabModeAsync), |
679 | |
|
|
680 | const_iv (EVENT_NONE), |
|
|
681 | const_iv (EVENT_READ), |
|
|
682 | const_iv (EVENT_WRITE), |
|
|
683 | |
684 | |
684 | const_iv (NoEventMask), |
685 | const_iv (NoEventMask), |
685 | const_iv (KeyPressMask), |
686 | const_iv (KeyPressMask), |
686 | const_iv (KeyReleaseMask), |
687 | const_iv (KeyReleaseMask), |
687 | const_iv (ButtonPressMask), |
688 | const_iv (ButtonPressMask), |
… | |
… | |
786 | _exit (int status) |
787 | _exit (int status) |
787 | |
788 | |
788 | NV |
789 | NV |
789 | NOW () |
790 | NOW () |
790 | CODE: |
791 | CODE: |
791 | RETVAL = NOW; |
792 | RETVAL = ev::now (); |
792 | OUTPUT: |
793 | OUTPUT: |
793 | RETVAL |
794 | RETVAL |
794 | |
795 | |
795 | int |
796 | int |
796 | GET_BASEFG (int rend) |
797 | GET_BASEFG (int rend) |
… | |
… | |
868 | for (int i = AvFILL (env) + 1; i--; ) |
869 | for (int i = AvFILL (env) + 1; i--; ) |
869 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
870 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
870 | |
871 | |
871 | envv->push_back (0); |
872 | envv->push_back (0); |
872 | |
873 | |
873 | bool success; |
|
|
874 | |
|
|
875 | try |
874 | try |
876 | { |
875 | { |
877 | success = term->init (argv, envv); |
876 | term->init (argv, envv); |
878 | } |
877 | } |
879 | catch (const class rxvt_failure_exception &e) |
878 | catch (const class rxvt_failure_exception &e) |
880 | { |
|
|
881 | success = false; |
|
|
882 | } |
|
|
883 | |
|
|
884 | if (!success) |
|
|
885 | { |
879 | { |
886 | term->destroy (); |
880 | term->destroy (); |
887 | croak ("error while initializing new terminal instance"); |
881 | croak ("error while initializing new terminal instance"); |
888 | } |
882 | } |
889 | |
883 | |
… | |
… | |
1061 | OUTPUT: |
1055 | OUTPUT: |
1062 | RETVAL |
1056 | RETVAL |
1063 | |
1057 | |
1064 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1058 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1065 | |
1059 | |
1066 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1060 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1067 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1061 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1068 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1062 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1069 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1063 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1070 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1064 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
1071 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1065 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
1072 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1066 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1073 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1067 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1074 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1068 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1075 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1069 | #define TERM_OFFSET_int_bwidth TERM_OFFSET(int_bwidth) |
1076 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1070 | #define TERM_OFFSET_ext_bwidth TERM_OFFSET(ext_bwidth) |
1077 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
1071 | #define TERM_OFFSET_lineSpace TERM_OFFSET(lineSpace) |
|
|
1072 | #define TERM_OFFSET_letterSpace TERM_OFFSET(letterSpace) |
1078 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1073 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1079 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1074 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1080 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1075 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
1081 | |
1076 | |
1082 | int |
1077 | int |
1083 | rxvt_term::width () |
1078 | rxvt_term::width () |
1084 | ALIAS: |
1079 | ALIAS: |
1085 | width = TERM_OFFSET_width |
1080 | width = TERM_OFFSET_width |
1086 | height = TERM_OFFSET_height |
1081 | height = TERM_OFFSET_height |
1087 | fwidth = TERM_OFFSET_fwidth |
1082 | fwidth = TERM_OFFSET_fwidth |
1088 | fheight = TERM_OFFSET_fheight |
1083 | fheight = TERM_OFFSET_fheight |
1089 | fbase = TERM_OFFSET_fbase |
1084 | fbase = TERM_OFFSET_fbase |
1090 | nrow = TERM_OFFSET_nrow |
1085 | nrow = TERM_OFFSET_nrow |
1091 | ncol = TERM_OFFSET_ncol |
1086 | ncol = TERM_OFFSET_ncol |
1092 | focus = TERM_OFFSET_focus |
1087 | focus = TERM_OFFSET_focus |
1093 | mapped = TERM_OFFSET_mapped |
1088 | mapped = TERM_OFFSET_mapped |
1094 | int_bwidth = TERM_OFFSET_int_bwidth |
1089 | int_bwidth = TERM_OFFSET_int_bwidth |
1095 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1090 | ext_bwidth = TERM_OFFSET_ext_bwidth |
1096 | lineSpace = TERM_OFFSET_lineSpace |
1091 | lineSpace = TERM_OFFSET_lineSpace |
|
|
1092 | letterSpace = TERM_OFFSET_letterSpace |
1097 | saveLines = TERM_OFFSET_saveLines |
1093 | saveLines = TERM_OFFSET_saveLines |
1098 | total_rows = TERM_OFFSET_total_rows |
1094 | total_rows = TERM_OFFSET_total_rows |
1099 | top_row = TERM_OFFSET_top_row |
1095 | top_row = TERM_OFFSET_top_row |
1100 | CODE: |
1096 | CODE: |
1101 | RETVAL = *(int *)((char *)THIS + ix); |
1097 | RETVAL = *(int *)((char *)THIS + ix); |
1102 | OUTPUT: |
1098 | OUTPUT: |
1103 | RETVAL |
1099 | RETVAL |
1104 | |
1100 | |
… | |
… | |
1115 | { |
1111 | { |
1116 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1112 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
1117 | case 1: RETVAL = THIS->ModMetaMask; break; |
1113 | case 1: RETVAL = THIS->ModMetaMask; break; |
1118 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1114 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1119 | case 3: RETVAL = THIS->current_screen; break; |
1115 | case 3: RETVAL = THIS->current_screen; break; |
|
|
1116 | #ifdef CURSOR_BLINK |
1120 | case 4: RETVAL = THIS->hidden_cursor; break; |
1117 | case 4: RETVAL = THIS->hidden_cursor; break; |
|
|
1118 | #endif |
1121 | } |
1119 | } |
1122 | OUTPUT: |
1120 | OUTPUT: |
1123 | RETVAL |
1121 | RETVAL |
1124 | |
1122 | |
1125 | char * |
1123 | char * |
… | |
… | |
1150 | if (*i) |
1148 | if (*i) |
1151 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1149 | PUSHs (sv_2mortal (newSVpv (*i, 0))); |
1152 | } |
1150 | } |
1153 | |
1151 | |
1154 | int |
1152 | int |
1155 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
1153 | rxvt_term::pty_ev_events (int events = ev::UNDEF) |
1156 | CODE: |
1154 | CODE: |
1157 | RETVAL = THIS->pty_ev.events; |
1155 | RETVAL = THIS->pty_ev.events; |
1158 | if (events != EVENT_UNDEF) |
1156 | if (events != ev::UNDEF) |
1159 | THIS->pty_ev.set (events); |
1157 | THIS->pty_ev.set (events); |
1160 | OUTPUT: |
1158 | OUTPUT: |
1161 | RETVAL |
1159 | RETVAL |
1162 | |
1160 | |
1163 | int |
1161 | int |
… | |
… | |
1242 | |
1240 | |
1243 | void |
1241 | void |
1244 | rxvt_term::want_refresh () |
1242 | rxvt_term::want_refresh () |
1245 | CODE: |
1243 | CODE: |
1246 | THIS->want_refresh = 1; |
1244 | THIS->want_refresh = 1; |
|
|
1245 | THIS->refresh_check (); |
1247 | |
1246 | |
1248 | void |
1247 | 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) |
1248 | 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: |
1249 | PPCODE: |
1251 | { |
1250 | { |
… | |
… | |
1406 | SV * |
1405 | SV * |
1407 | rxvt_term::special_decode (SV *text) |
1406 | rxvt_term::special_decode (SV *text) |
1408 | CODE: |
1407 | CODE: |
1409 | { |
1408 | { |
1410 | wchar_t *wstr = sv2wcs (text); |
1409 | wchar_t *wstr = sv2wcs (text); |
1411 | int wlen = wcslen (wstr); |
|
|
1412 | int dlen = 0; |
1410 | int dlen = 0; |
1413 | |
1411 | |
1414 | // find length |
1412 | // find length |
1415 | for (wchar_t *s = wstr; *s; s++) |
1413 | for (wchar_t *s = wstr; *s; s++) |
1416 | if (*s == NOCHAR) |
1414 | if (*s == NOCHAR) |
… | |
… | |
1449 | # undef reserve |
1447 | # undef reserve |
1450 | }; |
1448 | }; |
1451 | |
1449 | |
1452 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1450 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1453 | |
1451 | |
|
|
1452 | if (*name) |
1454 | do { |
1453 | { |
|
|
1454 | do { |
1455 | if (rs-- == rslist) |
1455 | if (rs-- == rslist) |
1456 | croak ("no such resource '%s', requested", name); |
1456 | croak ("no such resource '%s', requested", name); |
1457 | } while (strcmp (name, rs->name)); |
1457 | } while (strcmp (name, rs->name)); |
1458 | |
1458 | |
1459 | index += rs->value; |
1459 | index += rs->value; |
|
|
1460 | } |
|
|
1461 | else |
|
|
1462 | { |
|
|
1463 | --rs; |
|
|
1464 | name = ""; |
|
|
1465 | } |
1460 | |
1466 | |
1461 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1467 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1462 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1468 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1463 | |
1469 | |
1464 | if (GIMME_V != G_VOID) |
1470 | if (GIMME_V != G_VOID) |
… | |
… | |
1479 | |
1485 | |
1480 | const char * |
1486 | const char * |
1481 | rxvt_term::x_resource (const char *name) |
1487 | rxvt_term::x_resource (const char *name) |
1482 | |
1488 | |
1483 | bool |
1489 | bool |
1484 | rxvt_term::option (U32 optval, int set = -1) |
1490 | rxvt_term::option (U8 optval, int set = -1) |
1485 | CODE: |
1491 | CODE: |
1486 | { |
1492 | { |
1487 | RETVAL = THIS->options & optval; |
1493 | RETVAL = THIS->option (optval); |
1488 | |
1494 | |
1489 | if (set >= 0) |
1495 | if (set >= 0) |
1490 | { |
1496 | { |
1491 | if (set) |
|
|
1492 | THIS->options |= optval; |
1497 | THIS->set_option (optval, set); |
1493 | else |
|
|
1494 | THIS->options &= ~optval; |
|
|
1495 | |
1498 | |
1496 | if (THIS->check_ev.is_active ()) // avoid doing this before START |
1499 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1497 | switch (optval) |
1500 | switch (optval) |
1498 | { |
1501 | { |
1499 | case Opt_skipBuiltinGlyphs: |
1502 | case Opt_skipBuiltinGlyphs: |
1500 | THIS->set_fonts (); |
1503 | THIS->set_fonts (); |
1501 | THIS->scr_remap_chars (); |
1504 | THIS->scr_remap_chars (); |
1502 | THIS->scr_touch (true); |
1505 | THIS->scr_touch (true); |
1503 | THIS->want_refresh = 1; |
1506 | THIS->want_refresh = 1; |
|
|
1507 | THIS->refresh_check (); |
1504 | break; |
1508 | break; |
1505 | |
1509 | |
1506 | case Opt_cursorUnderline: |
1510 | case Opt_cursorUnderline: |
1507 | THIS->want_refresh = 1; |
1511 | THIS->want_refresh = 1; |
|
|
1512 | THIS->refresh_check (); |
1508 | break; |
1513 | break; |
1509 | |
1514 | |
1510 | # case Opt_scrollBar_floating: |
1515 | # case Opt_scrollBar_floating: |
1511 | # case Opt_scrollBar_right: |
1516 | # case Opt_scrollBar_right: |
1512 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
1517 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
… | |
… | |
1545 | EXTEND (SP, 2); |
1550 | EXTEND (SP, 2); |
1546 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1551 | PUSHs (sv_2mortal (newSViv (rc.row))); |
1547 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1552 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1548 | } |
1553 | } |
1549 | |
1554 | |
1550 | if (items == 3) |
1555 | if (items >= 3) |
1551 | { |
1556 | { |
1552 | rc.row = SvIV (ST (1)); |
1557 | rc.row = SvIV (ST (1)); |
1553 | rc.col = SvIV (ST (2)); |
1558 | rc.col = SvIV (ST (2)); |
1554 | |
1559 | |
1555 | if (ix == 2) |
1560 | if (ix == 2) |
… | |
… | |
1570 | |
1575 | |
1571 | clamp_it (rc.col, 0, THIS->ncol); |
1576 | clamp_it (rc.col, 0, THIS->ncol); |
1572 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1577 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1573 | |
1578 | |
1574 | if (ix) |
1579 | if (ix) |
|
|
1580 | { |
|
|
1581 | THIS->selection.screen = THIS->current_screen; |
|
|
1582 | |
1575 | THIS->want_refresh = 1; |
1583 | THIS->want_refresh = 1; |
|
|
1584 | THIS->refresh_check (); |
1576 | } |
1585 | } |
|
|
1586 | } |
1577 | } |
1587 | } |
1578 | |
1588 | |
1579 | char |
1589 | int |
1580 | rxvt_term::cur_charset () |
1590 | rxvt_term::selection_screen (int screen = -1) |
1581 | CODE: |
1591 | CODE: |
1582 | RETVAL = THIS->charsets [THIS->screen.charset]; |
1592 | RETVAL = THIS->selection.screen; |
1583 | OUTPUT: |
1593 | if (screen >= 0) |
|
|
1594 | THIS->selection.screen = screen; |
|
|
1595 | OUTPUT: |
1584 | RETVAL |
1596 | RETVAL |
1585 | |
1597 | |
1586 | void |
1598 | void |
1587 | rxvt_term::selection_clear () |
1599 | rxvt_term::selection_clear (bool clipboard = false) |
1588 | |
1600 | |
1589 | void |
1601 | void |
1590 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1602 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1591 | CODE: |
1603 | CODE: |
1592 | THIS->selection.op = SELECTION_CONT; |
1604 | THIS->selection.op = SELECTION_CONT; |
1593 | THIS->selection.rect = rect; |
1605 | THIS->selection.rect = rect; |
1594 | THIS->selection_make (eventtime); |
1606 | THIS->selection_make (eventtime); |
1595 | |
1607 | |
1596 | int |
1608 | int |
1597 | rxvt_term::selection_grab (Time eventtime) |
1609 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1598 | |
1610 | |
1599 | void |
1611 | void |
1600 | rxvt_term::selection (SV *newtext = 0) |
1612 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1601 | PPCODE: |
1613 | PPCODE: |
1602 | { |
1614 | { |
|
|
1615 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1616 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1617 | |
1603 | if (GIMME_V != G_VOID) |
1618 | if (GIMME_V != G_VOID) |
1604 | XPUSHs (THIS->selection.text |
1619 | XPUSHs (text |
1605 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1620 | ? sv_2mortal (wcs2sv (text, len)) |
1606 | : &PL_sv_undef); |
1621 | : &PL_sv_undef); |
1607 | |
1622 | |
1608 | if (newtext) |
1623 | if (newtext) |
1609 | { |
1624 | { |
1610 | free (THIS->selection.text); |
1625 | free (text); |
1611 | |
1626 | |
1612 | THIS->selection.text = sv2wcs (newtext); |
1627 | text = sv2wcs (newtext); |
1613 | THIS->selection.len = wcslen (THIS->selection.text); |
1628 | len = wcslen (text); |
1614 | } |
1629 | } |
1615 | } |
1630 | } |
|
|
1631 | |
|
|
1632 | char |
|
|
1633 | rxvt_term::cur_charset () |
|
|
1634 | CODE: |
|
|
1635 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1636 | OUTPUT: |
|
|
1637 | RETVAL |
1616 | |
1638 | |
1617 | void |
1639 | 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) |
1640 | 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 | |
1641 | |
1620 | void |
1642 | void |
… | |
… | |
1687 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1709 | Atom *props = XListProperties (THIS->dpy, window, &count); |
1688 | |
1710 | |
1689 | EXTEND (SP, count); |
1711 | EXTEND (SP, count); |
1690 | while (count--) |
1712 | while (count--) |
1691 | PUSHs (newSVuv ((U32)props [count])); |
1713 | PUSHs (newSVuv ((U32)props [count])); |
1692 | |
1714 | |
1693 | XFree (props); |
1715 | XFree (props); |
1694 | } |
1716 | } |
1695 | |
1717 | |
1696 | void |
1718 | void |
1697 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
1719 | rxvt_term::XGetWindowProperty (Window window, Atom property) |
… | |
… | |
1720 | XFree (prop); |
1742 | XFree (prop); |
1721 | } |
1743 | } |
1722 | } |
1744 | } |
1723 | |
1745 | |
1724 | void |
1746 | void |
1725 | rxvt_term::XChangeWindowProperty (Window window, Atom property, Atom type, int format, SV *data) |
1747 | rxvt_term::XChangeProperty (Window window, Atom property, Atom type, int format, SV *data) |
1726 | CODE: |
1748 | CODE: |
1727 | { |
1749 | { |
1728 | STRLEN len; |
1750 | STRLEN len; |
1729 | char *data_ = SvPVbyte (data, len); |
1751 | char *data_ = SvPVbyte (data, len); |
1730 | |
1752 | |