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-2005 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2006 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. |
… | |
… | |
26 | #include <XSUB.h> |
26 | #include <XSUB.h> |
27 | #undef line_t |
27 | #undef line_t |
28 | |
28 | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
|
|
31 | #include <cstddef> |
31 | #include <cstdarg> |
32 | #include <cstdarg> |
32 | |
33 | |
|
|
34 | #include "unistd.h" |
|
|
35 | |
|
|
36 | #include "iom.h" |
33 | #include "rxvt.h" |
37 | #include "rxvt.h" |
34 | #include "iom.h" |
38 | #include "keyboard.h" |
35 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
36 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
37 | |
41 | |
38 | #include "perlxsi.c" |
42 | #include "perlxsi.c" |
39 | |
43 | |
|
|
44 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
|
|
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
|
|
46 | #else |
|
|
47 | # define GRAB_CURSOR None |
|
|
48 | #endif |
|
|
49 | |
|
|
50 | #undef LINENO |
|
|
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
|
|
52 | #undef ROW |
|
|
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
54 | |
|
|
55 | #define ENABLE_PERL_FRILLS 1 |
|
|
56 | |
40 | ///////////////////////////////////////////////////////////////////////////// |
57 | ///////////////////////////////////////////////////////////////////////////// |
|
|
58 | |
|
|
59 | static SV * |
|
|
60 | taint (SV *sv) |
|
|
61 | { |
|
|
62 | SvTAINT (sv); |
|
|
63 | return sv; |
|
|
64 | } |
|
|
65 | |
|
|
66 | static SV * |
|
|
67 | taint_if (SV *sv, SV *src) |
|
|
68 | { |
|
|
69 | if (SvTAINTED (src)) |
|
|
70 | SvTAINT (sv); |
|
|
71 | |
|
|
72 | return sv; |
|
|
73 | } |
41 | |
74 | |
42 | static wchar_t * |
75 | static wchar_t * |
43 | sv2wcs (SV *sv) |
76 | sv2wcs (SV *sv) |
44 | { |
77 | { |
45 | STRLEN len; |
78 | STRLEN len; |
46 | char *str = SvPVutf8 (sv, len); |
79 | char *str = SvPVutf8 (sv, len); |
47 | return rxvt_utf8towcs (str, len); |
80 | return rxvt_utf8towcs (str, len); |
48 | } |
81 | } |
49 | |
82 | |
50 | static SV * |
83 | static SV * |
|
|
84 | wcs2sv (wchar_t *wstr, int len = -1) |
|
|
85 | { |
|
|
86 | char *str = rxvt_wcstoutf8 (wstr, len); |
|
|
87 | |
|
|
88 | SV *sv = newSVpv (str, 0); |
|
|
89 | SvUTF8_on (sv); |
|
|
90 | free (str); |
|
|
91 | |
|
|
92 | return sv; |
|
|
93 | } |
|
|
94 | |
|
|
95 | static SV * |
51 | new_ref (HV *hv, const char *klass) |
96 | new_ref (HV *hv, const char *klass) |
52 | { |
97 | { |
53 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
98 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
54 | } |
99 | } |
55 | |
100 | |
56 | //TODO: use magic |
101 | //TODO: use magic |
57 | static SV * |
102 | static SV * |
58 | newSVptr (void *ptr, const char *klass) |
103 | newSVptr (void *ptr, const char *klass) |
59 | { |
104 | { |
60 | HV *hv = newHV (); |
105 | HV *hv = newHV (); |
61 | hv_store (hv, "_ptr", 4, newSViv ((long)ptr), 0); |
106 | sv_magic ((SV *)hv, 0, PERL_MAGIC_ext, (char *)ptr, 0); |
62 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
107 | return sv_bless (newRV_noinc ((SV *)hv), gv_stashpv (klass, 1)); |
|
|
108 | } |
|
|
109 | |
|
|
110 | static void |
|
|
111 | clearSVptr (SV *sv) |
|
|
112 | { |
|
|
113 | if (SvROK (sv)) |
|
|
114 | sv = SvRV (sv); |
|
|
115 | |
|
|
116 | hv_clear ((HV *)sv); |
|
|
117 | sv_unmagic (sv, PERL_MAGIC_ext); |
63 | } |
118 | } |
64 | |
119 | |
65 | static long |
120 | static long |
66 | SvPTR (SV *sv, const char *klass) |
121 | SvPTR (SV *sv, const char *klass) |
67 | { |
122 | { |
68 | if (!sv_derived_from (sv, klass)) |
123 | if (!sv_derived_from (sv, klass)) |
69 | croak ("object of type %s expected", klass); |
124 | croak ("object of type %s expected", klass); |
70 | |
125 | |
71 | IV iv = SvIV (*hv_fetch ((HV *)SvRV (sv), "_ptr", 4, 1)); |
126 | MAGIC *mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
72 | |
127 | |
73 | if (!iv) |
128 | if (!mg) |
74 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
129 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
75 | |
130 | |
76 | return (long)iv; |
131 | return (long)mg->mg_ptr; |
77 | } |
132 | } |
78 | |
133 | |
79 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
134 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
80 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
135 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
81 | |
136 | |
82 | ///////////////////////////////////////////////////////////////////////////// |
137 | ///////////////////////////////////////////////////////////////////////////// |
83 | |
138 | |
84 | struct perl_watcher |
139 | struct perl_watcher |
… | |
… | |
134 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
189 | #define newSVtimer(timer) new_ref (timer->self, "urxvt::timer") |
135 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
190 | #define SvTIMER(sv) (timer *)SvPTR (sv, "urxvt::timer") |
136 | |
191 | |
137 | struct timer : time_watcher, perl_watcher |
192 | struct timer : time_watcher, perl_watcher |
138 | { |
193 | { |
|
|
194 | tstamp interval; |
|
|
195 | |
139 | timer () |
196 | timer () |
140 | : time_watcher (this, &timer::execute) |
197 | : time_watcher (this, &timer::execute) |
141 | { |
198 | { |
142 | } |
199 | } |
143 | |
200 | |
144 | void execute (time_watcher &w) |
201 | void execute (time_watcher &w) |
145 | { |
202 | { |
|
|
203 | if (interval) |
|
|
204 | start (at + interval); |
|
|
205 | |
146 | invoke ("urxvt::timer", newSVtimer (this)); |
206 | invoke ("urxvt::timer", newSVtimer (this)); |
147 | } |
207 | } |
148 | }; |
208 | }; |
149 | |
209 | |
150 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
210 | #define newSViow(iow) new_ref (iow->self, "urxvt::iow") |
… | |
… | |
163 | } |
223 | } |
164 | }; |
224 | }; |
165 | |
225 | |
166 | ///////////////////////////////////////////////////////////////////////////// |
226 | ///////////////////////////////////////////////////////////////////////////// |
167 | |
227 | |
|
|
228 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
|
|
229 | |
|
|
230 | struct overlay { |
|
|
231 | HV *self; |
|
|
232 | rxvt_term *THIS; |
|
|
233 | int x, y, w, h; |
|
|
234 | int border; |
|
|
235 | text_t **text; |
|
|
236 | rend_t **rend; |
|
|
237 | |
|
|
238 | overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border); |
|
|
239 | ~overlay (); |
|
|
240 | |
|
|
241 | void show (); |
|
|
242 | void hide (); |
|
|
243 | |
|
|
244 | void swap (); |
|
|
245 | |
|
|
246 | void set (int x, int y, SV *str, SV *rend); |
|
|
247 | }; |
|
|
248 | |
|
|
249 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
|
|
250 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) |
|
|
251 | { |
|
|
252 | if (border == 2) |
|
|
253 | { |
|
|
254 | w += 2; |
|
|
255 | h += 2; |
|
|
256 | } |
|
|
257 | |
|
|
258 | text = new text_t *[h]; |
|
|
259 | rend = new rend_t *[h]; |
|
|
260 | |
|
|
261 | for (int y = 0; y < h; y++) |
|
|
262 | { |
|
|
263 | text_t *tp = text[y] = new text_t[w]; |
|
|
264 | rend_t *rp = rend[y] = new rend_t[w]; |
|
|
265 | |
|
|
266 | text_t t0, t1, t2; |
|
|
267 | rend_t r = rstyle; |
|
|
268 | |
|
|
269 | if (border == 2) |
|
|
270 | { |
|
|
271 | if (y == 0) |
|
|
272 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
|
|
273 | else if (y < h - 1) |
|
|
274 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
|
|
275 | else |
|
|
276 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
|
|
277 | |
|
|
278 | *tp++ = t0; |
|
|
279 | *rp++ = r; |
|
|
280 | |
|
|
281 | for (int x = w - 2; x-- > 0; ) |
|
|
282 | { |
|
|
283 | *tp++ = t1; |
|
|
284 | *rp++ = r; |
|
|
285 | } |
|
|
286 | |
|
|
287 | *tp = t2; |
|
|
288 | *rp = r; |
|
|
289 | } |
|
|
290 | else |
|
|
291 | for (int x = w; x-- > 0; ) |
|
|
292 | { |
|
|
293 | *tp++ = 0x0020; |
|
|
294 | *rp++ = r; |
|
|
295 | } |
|
|
296 | } |
|
|
297 | |
|
|
298 | show (); |
|
|
299 | THIS->want_refresh = 1; |
|
|
300 | } |
|
|
301 | |
|
|
302 | overlay::~overlay () |
|
|
303 | { |
|
|
304 | hide (); |
|
|
305 | |
|
|
306 | for (int y = h; y--; ) |
|
|
307 | { |
|
|
308 | delete [] text[y]; |
|
|
309 | delete [] rend[y]; |
|
|
310 | } |
|
|
311 | |
|
|
312 | delete [] text; |
|
|
313 | delete [] rend; |
|
|
314 | |
|
|
315 | THIS->want_refresh = 1; |
|
|
316 | } |
|
|
317 | |
|
|
318 | void |
|
|
319 | overlay::show () |
|
|
320 | { |
|
|
321 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
322 | |
|
|
323 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
|
|
324 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
|
|
325 | } |
|
|
326 | |
|
|
327 | void |
|
|
328 | overlay::hide () |
|
|
329 | { |
|
|
330 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
|
|
331 | |
|
|
332 | if (ovs) |
|
|
333 | { |
|
|
334 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
335 | |
|
|
336 | HV *hv = (HV *)SvRV (*ovs); |
|
|
337 | hv_delete (hv, key, 32, G_DISCARD); |
|
|
338 | } |
|
|
339 | } |
|
|
340 | |
|
|
341 | void overlay::swap () |
|
|
342 | { |
|
|
343 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
|
|
344 | int ov_y = max (0, min (MOD (y, THIS->nrow), THIS->nrow - h)); |
|
|
345 | |
|
|
346 | int ov_w = min (w, THIS->ncol - ov_x); |
|
|
347 | int ov_h = min (h, THIS->nrow - ov_y); |
|
|
348 | |
|
|
349 | for (int y = ov_h; y--; ) |
|
|
350 | { |
|
|
351 | text_t *t1 = text [y]; |
|
|
352 | rend_t *r1 = rend [y]; |
|
|
353 | |
|
|
354 | text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x; |
|
|
355 | rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x; |
|
|
356 | |
|
|
357 | for (int x = ov_w; x--; ) |
|
|
358 | { |
|
|
359 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
|
|
360 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
|
|
361 | } |
|
|
362 | } |
|
|
363 | |
|
|
364 | } |
|
|
365 | |
|
|
366 | void overlay::set (int x, int y, SV *text, SV *rend) |
|
|
367 | { |
|
|
368 | x += border; |
|
|
369 | y += border; |
|
|
370 | |
|
|
371 | if (!IN_RANGE_EXC (y, 0, h - border)) |
|
|
372 | return; |
|
|
373 | |
|
|
374 | wchar_t *wtext = sv2wcs (text); |
|
|
375 | |
|
|
376 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
|
|
377 | this->text [y][x + col] = wtext [col]; |
|
|
378 | |
|
|
379 | free (wtext); |
|
|
380 | |
|
|
381 | if (rend) |
|
|
382 | { |
|
|
383 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
|
|
384 | croak ("rend must be arrayref"); |
|
|
385 | |
|
|
386 | AV *av = (AV *)SvRV (rend); |
|
|
387 | |
|
|
388 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
|
|
389 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
|
|
390 | } |
|
|
391 | |
|
|
392 | THIS->want_refresh = 1; |
|
|
393 | } |
|
|
394 | |
|
|
395 | |
|
|
396 | ///////////////////////////////////////////////////////////////////////////// |
|
|
397 | |
168 | struct rxvt_perl_interp rxvt_perl; |
398 | struct rxvt_perl_interp rxvt_perl; |
169 | |
399 | |
170 | static PerlInterpreter *perl; |
400 | static PerlInterpreter *perl; |
171 | |
|
|
172 | rxvt_perl_interp::rxvt_perl_interp () |
|
|
173 | { |
|
|
174 | } |
|
|
175 | |
401 | |
176 | rxvt_perl_interp::~rxvt_perl_interp () |
402 | rxvt_perl_interp::~rxvt_perl_interp () |
177 | { |
403 | { |
178 | if (perl) |
404 | if (perl) |
179 | { |
405 | { |
… | |
… | |
185 | void |
411 | void |
186 | rxvt_perl_interp::init () |
412 | rxvt_perl_interp::init () |
187 | { |
413 | { |
188 | if (!perl) |
414 | if (!perl) |
189 | { |
415 | { |
|
|
416 | perl_environ = rxvt_environ; |
|
|
417 | swap (perl_environ, environ); |
|
|
418 | |
190 | char *argv[] = { |
419 | char *argv[] = { |
191 | "", |
420 | "", |
|
|
421 | "-T", |
192 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
422 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
193 | }; |
423 | }; |
194 | |
424 | |
195 | perl = perl_alloc (); |
425 | perl = perl_alloc (); |
196 | perl_construct (perl); |
426 | perl_construct (perl); |
197 | |
427 | |
198 | if (perl_parse (perl, xs_init, 2, argv, (char **)NULL) |
428 | if (perl_parse (perl, xs_init, 3, argv, (char **)NULL) |
199 | || perl_run (perl)) |
429 | || perl_run (perl)) |
200 | { |
430 | { |
201 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
431 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
202 | |
432 | |
203 | perl_destruct (perl); |
433 | perl_destruct (perl); |
204 | perl_free (perl); |
434 | perl_free (perl); |
205 | perl = 0; |
435 | perl = 0; |
206 | } |
436 | } |
|
|
437 | |
|
|
438 | swap (perl_environ, environ); |
|
|
439 | } |
|
|
440 | } |
|
|
441 | |
|
|
442 | static void |
|
|
443 | ungrab (rxvt_term *THIS) |
|
|
444 | { |
|
|
445 | if (THIS->perl.grabtime) |
|
|
446 | { |
|
|
447 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
|
|
448 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
|
|
449 | THIS->perl.grabtime = 0; |
|
|
450 | } |
|
|
451 | } |
|
|
452 | |
|
|
453 | static void |
|
|
454 | swap_overlays (rxvt_term *term) |
|
|
455 | { |
|
|
456 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
457 | |
|
|
458 | if (HvKEYS (hv)) |
|
|
459 | { |
|
|
460 | hv_iterinit (hv); |
|
|
461 | |
|
|
462 | while (HE *he = hv_iternext (hv)) |
|
|
463 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
207 | } |
464 | } |
208 | } |
465 | } |
209 | |
466 | |
210 | bool |
467 | bool |
211 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
468 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
212 | { |
469 | { |
213 | if (!perl |
470 | if (!perl) |
214 | || (!should_invoke [htype] && htype != HOOK_INIT && htype != HOOK_DESTROY)) |
|
|
215 | return false; |
471 | return false; |
216 | |
472 | |
217 | if (htype == HOOK_INIT) // first hook ever called |
473 | if (htype == HOOK_INIT) // first hook ever called |
|
|
474 | { |
218 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
475 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
476 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
|
|
477 | } |
|
|
478 | else if (!term->perl.self) |
|
|
479 | return false; // perl not initialized for this instance |
|
|
480 | else if (htype == HOOK_DESTROY) |
|
|
481 | { |
|
|
482 | // handled later |
|
|
483 | } |
|
|
484 | else |
|
|
485 | { |
|
|
486 | if (htype == HOOK_REFRESH_END) |
|
|
487 | swap_overlays (term); |
219 | |
488 | |
|
|
489 | if (!term->perl.should_invoke [htype]) |
|
|
490 | { |
|
|
491 | if (htype == HOOK_REFRESH_BEGIN) |
|
|
492 | swap_overlays (term); |
|
|
493 | |
|
|
494 | return false; |
|
|
495 | } |
|
|
496 | } |
|
|
497 | |
|
|
498 | swap (perl_environ, environ); |
|
|
499 | |
|
|
500 | try |
|
|
501 | { |
220 | dSP; |
502 | dSP; |
221 | va_list ap; |
503 | va_list ap; |
222 | |
504 | |
223 | va_start (ap, htype); |
505 | va_start (ap, htype); |
224 | |
506 | |
225 | ENTER; |
507 | ENTER; |
226 | SAVETMPS; |
508 | SAVETMPS; |
227 | |
509 | |
228 | PUSHMARK (SP); |
510 | PUSHMARK (SP); |
229 | |
511 | |
230 | XPUSHs (sv_2mortal (newSVterm (term))); |
512 | XPUSHs (sv_2mortal (newSVterm (term))); |
231 | XPUSHs (sv_2mortal (newSViv (htype))); |
513 | XPUSHs (sv_2mortal (newSViv (htype))); |
232 | |
514 | |
233 | for (;;) { |
515 | for (;;) { |
234 | data_type dt = (data_type)va_arg (ap, int); |
516 | data_type dt = (data_type)va_arg (ap, int); |
235 | |
517 | |
236 | switch (dt) |
518 | switch (dt) |
237 | { |
|
|
238 | case DT_INT: |
|
|
239 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
240 | break; |
|
|
241 | |
|
|
242 | case DT_LONG: |
|
|
243 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
244 | break; |
|
|
245 | |
|
|
246 | case DT_STRING: |
|
|
247 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
248 | break; |
|
|
249 | |
|
|
250 | case DT_END: |
|
|
251 | { |
519 | { |
252 | va_end (ap); |
520 | case DT_INT: |
|
|
521 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
522 | break; |
253 | |
523 | |
254 | PUTBACK; |
524 | case DT_LONG: |
255 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
525 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
256 | SPAGAIN; |
526 | break; |
257 | |
527 | |
258 | if (count) |
528 | case DT_STR: |
|
|
529 | XPUSHs (taint (sv_2mortal (newSVpv (va_arg (ap, char *), 0)))); |
|
|
530 | break; |
|
|
531 | |
|
|
532 | case DT_STR_LEN: |
259 | { |
533 | { |
260 | SV *status = POPs; |
534 | char *str = va_arg (ap, char *); |
261 | count = SvTRUE (status); |
535 | int len = va_arg (ap, int); |
|
|
536 | |
|
|
537 | XPUSHs (taint (sv_2mortal (newSVpvn (str, len)))); |
262 | } |
538 | } |
|
|
539 | break; |
263 | |
540 | |
264 | PUTBACK; |
541 | case DT_WCS_LEN: |
265 | FREETMPS; |
|
|
266 | LEAVE; |
|
|
267 | |
|
|
268 | if (SvTRUE (ERRSV)) |
|
|
269 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
270 | |
|
|
271 | if (htype == HOOK_DESTROY) |
|
|
272 | { |
542 | { |
273 | // TODO: clear magic |
543 | wchar_t *wstr = va_arg (ap, wchar_t *); |
274 | hv_clear ((HV *)SvRV ((SV *)term->self)); |
544 | int wlen = va_arg (ap, int); |
275 | SvREFCNT_dec ((SV *)term->self); |
545 | |
|
|
546 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, wlen)))); |
276 | } |
547 | } |
|
|
548 | break; |
277 | |
549 | |
|
|
550 | case DT_XEVENT: |
|
|
551 | { |
|
|
552 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
553 | HV *hv = newHV (); |
|
|
554 | |
|
|
555 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
556 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
557 | # undef set |
|
|
558 | |
|
|
559 | setiv (type, xe->type); |
|
|
560 | setiv (send_event, xe->xany.send_event); |
|
|
561 | setiv (serial, xe->xany.serial); |
|
|
562 | |
|
|
563 | switch (xe->type) |
|
|
564 | { |
|
|
565 | case KeyPress: |
|
|
566 | case KeyRelease: |
|
|
567 | case ButtonPress: |
|
|
568 | case ButtonRelease: |
|
|
569 | case MotionNotify: |
|
|
570 | setiv (time, xe->xmotion.time); |
|
|
571 | setiv (x, xe->xmotion.x); |
|
|
572 | setiv (y, xe->xmotion.y); |
|
|
573 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
574 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
575 | setiv (x_root, xe->xmotion.x_root); |
|
|
576 | setiv (y_root, xe->xmotion.y_root); |
|
|
577 | setiv (state, xe->xmotion.state); |
|
|
578 | break; |
|
|
579 | } |
|
|
580 | |
|
|
581 | switch (xe->type) |
|
|
582 | { |
|
|
583 | case KeyPress: |
|
|
584 | case KeyRelease: |
|
|
585 | setiv (keycode, xe->xkey.keycode); |
|
|
586 | break; |
|
|
587 | |
|
|
588 | case ButtonPress: |
|
|
589 | case ButtonRelease: |
|
|
590 | setiv (button, xe->xbutton.button); |
|
|
591 | break; |
|
|
592 | |
|
|
593 | case MotionNotify: |
|
|
594 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
595 | break; |
|
|
596 | } |
|
|
597 | |
|
|
598 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
599 | } |
|
|
600 | break; |
|
|
601 | |
|
|
602 | case DT_END: |
|
|
603 | { |
|
|
604 | va_end (ap); |
|
|
605 | |
|
|
606 | PUTBACK; |
|
|
607 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
608 | SPAGAIN; |
|
|
609 | |
|
|
610 | if (count) |
|
|
611 | { |
|
|
612 | SV *status = POPs; |
|
|
613 | count = SvTRUE (status); |
|
|
614 | } |
|
|
615 | |
|
|
616 | PUTBACK; |
|
|
617 | FREETMPS; |
|
|
618 | LEAVE; |
|
|
619 | |
|
|
620 | if (SvTRUE (ERRSV)) |
|
|
621 | { |
|
|
622 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
623 | ungrab (term); // better lose the grab than the session |
|
|
624 | } |
|
|
625 | |
|
|
626 | if (htype == HOOK_REFRESH_BEGIN) |
|
|
627 | swap_overlays (term); |
|
|
628 | else if (htype == HOOK_DESTROY) |
|
|
629 | { |
|
|
630 | clearSVptr ((SV *)term->perl.self); |
|
|
631 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
632 | } |
|
|
633 | |
|
|
634 | swap (perl_environ, environ); |
278 | return count; |
635 | return count; |
|
|
636 | } |
|
|
637 | |
|
|
638 | default: |
|
|
639 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
279 | } |
640 | } |
280 | |
|
|
281 | default: |
|
|
282 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
283 | } |
641 | } |
284 | } |
642 | } |
|
|
643 | catch (...) |
|
|
644 | { |
|
|
645 | swap (perl_environ, environ); |
|
|
646 | throw; |
|
|
647 | } |
285 | } |
648 | } |
286 | |
649 | |
287 | ///////////////////////////////////////////////////////////////////////////// |
650 | ///////////////////////////////////////////////////////////////////////////// |
288 | |
651 | |
289 | MODULE = urxvt PACKAGE = urxvt |
652 | MODULE = urxvt PACKAGE = urxvt |
290 | |
653 | |
291 | PROTOTYPES: ENABLE |
654 | PROTOTYPES: ENABLE |
292 | |
655 | |
293 | BOOT: |
656 | BOOT: |
294 | { |
657 | { |
295 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
658 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
659 | sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1)); |
|
|
660 | sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1)); |
|
|
661 | sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1)); |
|
|
662 | |
296 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
663 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
297 | set_hookname (INIT); |
664 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
298 | set_hookname (RESET); |
665 | # include "hookinc.h" |
299 | set_hookname (START); |
666 | # undef def |
300 | set_hookname (DESTROY); |
|
|
301 | set_hookname (SEL_BEGIN); |
|
|
302 | set_hookname (SEL_EXTEND); |
|
|
303 | set_hookname (SEL_MAKE); |
|
|
304 | set_hookname (SEL_GRAB); |
|
|
305 | set_hookname (FOCUS_IN); |
|
|
306 | set_hookname (FOCUS_OUT); |
|
|
307 | set_hookname (VIEW_CHANGE); |
|
|
308 | set_hookname (SCROLL_BACK); |
|
|
309 | set_hookname (TTY_ACTIVITY); |
|
|
310 | set_hookname (REFRESH_BEGIN); |
|
|
311 | set_hookname (REFRESH_END); |
|
|
312 | set_hookname (KEYBOARD_COMMAND); |
|
|
313 | |
667 | |
314 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
668 | HV *option = get_hv ("urxvt::OPTION", 1); |
315 | } |
669 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
|
|
670 | # define nodef(name) |
|
|
671 | # include "optinc.h" |
|
|
672 | # undef nodef |
|
|
673 | # undef def |
316 | |
674 | |
317 | void |
675 | HV *stash = gv_stashpv ("urxvt", 1); |
318 | set_should_invoke (int htype, int value) |
676 | struct { |
319 | CODE: |
677 | const char *name; |
320 | rxvt_perl.should_invoke [htype] = value; |
678 | IV iv; |
|
|
679 | } *civ, const_iv[] = { |
|
|
680 | # define const_iv(name) { # name, (IV)name } |
|
|
681 | const_iv (DEFAULT_RSTYLE), |
|
|
682 | const_iv (OVERLAY_RSTYLE), |
|
|
683 | const_iv (RS_Bold), |
|
|
684 | const_iv (RS_Italic), |
|
|
685 | const_iv (RS_Blink), |
|
|
686 | const_iv (RS_RVid), |
|
|
687 | const_iv (RS_Uline), |
|
|
688 | |
|
|
689 | const_iv (CurrentTime), |
|
|
690 | const_iv (ShiftMask), |
|
|
691 | const_iv (LockMask), |
|
|
692 | const_iv (ControlMask), |
|
|
693 | const_iv (Mod1Mask), |
|
|
694 | const_iv (Mod2Mask), |
|
|
695 | const_iv (Mod3Mask), |
|
|
696 | const_iv (Mod4Mask), |
|
|
697 | const_iv (Mod5Mask), |
|
|
698 | const_iv (Button1Mask), |
|
|
699 | const_iv (Button2Mask), |
|
|
700 | const_iv (Button3Mask), |
|
|
701 | const_iv (Button4Mask), |
|
|
702 | const_iv (Button5Mask), |
|
|
703 | const_iv (AnyModifier), |
|
|
704 | |
|
|
705 | const_iv (EVENT_NONE), |
|
|
706 | const_iv (EVENT_READ), |
|
|
707 | const_iv (EVENT_WRITE), |
|
|
708 | |
|
|
709 | const_iv (NoEventMask), |
|
|
710 | const_iv (KeyPressMask), |
|
|
711 | const_iv (KeyReleaseMask), |
|
|
712 | const_iv (ButtonPressMask), |
|
|
713 | const_iv (ButtonReleaseMask), |
|
|
714 | const_iv (EnterWindowMask), |
|
|
715 | const_iv (LeaveWindowMask), |
|
|
716 | const_iv (PointerMotionMask), |
|
|
717 | const_iv (PointerMotionHintMask), |
|
|
718 | const_iv (Button1MotionMask), |
|
|
719 | const_iv (Button2MotionMask), |
|
|
720 | const_iv (Button3MotionMask), |
|
|
721 | const_iv (Button4MotionMask), |
|
|
722 | const_iv (Button5MotionMask), |
|
|
723 | const_iv (ButtonMotionMask), |
|
|
724 | const_iv (KeymapStateMask), |
|
|
725 | const_iv (ExposureMask), |
|
|
726 | const_iv (VisibilityChangeMask), |
|
|
727 | const_iv (StructureNotifyMask), |
|
|
728 | const_iv (ResizeRedirectMask), |
|
|
729 | const_iv (SubstructureNotifyMask), |
|
|
730 | const_iv (SubstructureRedirectMask), |
|
|
731 | const_iv (FocusChangeMask), |
|
|
732 | const_iv (PropertyChangeMask), |
|
|
733 | const_iv (ColormapChangeMask), |
|
|
734 | const_iv (OwnerGrabButtonMask), |
|
|
735 | |
|
|
736 | const_iv (KeyPress), |
|
|
737 | const_iv (KeyRelease), |
|
|
738 | const_iv (ButtonPress), |
|
|
739 | const_iv (ButtonRelease), |
|
|
740 | const_iv (MotionNotify), |
|
|
741 | const_iv (EnterNotify), |
|
|
742 | const_iv (LeaveNotify), |
|
|
743 | const_iv (FocusIn), |
|
|
744 | const_iv (FocusOut), |
|
|
745 | const_iv (KeymapNotify), |
|
|
746 | const_iv (Expose), |
|
|
747 | const_iv (GraphicsExpose), |
|
|
748 | const_iv (NoExpose), |
|
|
749 | const_iv (VisibilityNotify), |
|
|
750 | const_iv (CreateNotify), |
|
|
751 | const_iv (DestroyNotify), |
|
|
752 | const_iv (UnmapNotify), |
|
|
753 | const_iv (MapNotify), |
|
|
754 | const_iv (MapRequest), |
|
|
755 | const_iv (ReparentNotify), |
|
|
756 | const_iv (ConfigureNotify), |
|
|
757 | const_iv (ConfigureRequest), |
|
|
758 | const_iv (GravityNotify), |
|
|
759 | const_iv (ResizeRequest), |
|
|
760 | const_iv (CirculateNotify), |
|
|
761 | const_iv (CirculateRequest), |
|
|
762 | const_iv (PropertyNotify), |
|
|
763 | const_iv (SelectionClear), |
|
|
764 | const_iv (SelectionRequest), |
|
|
765 | const_iv (SelectionNotify), |
|
|
766 | const_iv (ColormapNotify), |
|
|
767 | const_iv (ClientMessage), |
|
|
768 | const_iv (MappingNotify), |
|
|
769 | }; |
|
|
770 | |
|
|
771 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
|
|
772 | civ-- > const_iv; ) |
|
|
773 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
774 | } |
321 | |
775 | |
322 | void |
776 | void |
323 | warn (const char *msg) |
777 | warn (const char *msg) |
324 | CODE: |
778 | CODE: |
325 | rxvt_warn ("%s", msg); |
779 | rxvt_warn ("%s", msg); |
326 | |
780 | |
327 | void |
781 | void |
328 | fatal (const char *msg) |
782 | fatal (const char *msg) |
329 | CODE: |
783 | CODE: |
330 | rxvt_fatal ("%s", msg); |
784 | rxvt_fatal ("%s", msg); |
|
|
785 | |
|
|
786 | SV * |
|
|
787 | untaint (SV *sv) |
|
|
788 | CODE: |
|
|
789 | RETVAL = newSVsv (sv); |
|
|
790 | SvTAINTED_off (RETVAL); |
|
|
791 | OUTPUT: |
|
|
792 | RETVAL |
|
|
793 | |
|
|
794 | void |
|
|
795 | _exit (int status) |
|
|
796 | |
|
|
797 | bool |
|
|
798 | safe () |
|
|
799 | CODE: |
|
|
800 | RETVAL = !rxvt_tainted (); |
|
|
801 | OUTPUT: |
|
|
802 | RETVAL |
331 | |
803 | |
332 | NV |
804 | NV |
333 | NOW () |
805 | NOW () |
334 | CODE: |
806 | CODE: |
335 | RETVAL = NOW; |
807 | RETVAL = NOW; |
336 | OUTPUT: |
808 | OUTPUT: |
337 | RETVAL |
809 | RETVAL |
338 | |
810 | |
|
|
811 | int |
|
|
812 | GET_BASEFG (int rend) |
|
|
813 | CODE: |
|
|
814 | RETVAL = GET_BASEFG (rend); |
|
|
815 | OUTPUT: |
|
|
816 | RETVAL |
|
|
817 | |
|
|
818 | int |
|
|
819 | GET_BASEBG (int rend) |
|
|
820 | CODE: |
|
|
821 | RETVAL = GET_BASEBG (rend); |
|
|
822 | OUTPUT: |
|
|
823 | RETVAL |
|
|
824 | |
|
|
825 | int |
|
|
826 | SET_FGCOLOR (int rend, int new_color) |
|
|
827 | CODE: |
|
|
828 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
829 | OUTPUT: |
|
|
830 | RETVAL |
|
|
831 | |
|
|
832 | int |
|
|
833 | SET_BGCOLOR (int rend, int new_color) |
|
|
834 | CODE: |
|
|
835 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
836 | OUTPUT: |
|
|
837 | RETVAL |
|
|
838 | |
|
|
839 | int |
|
|
840 | GET_CUSTOM (int rend) |
|
|
841 | CODE: |
|
|
842 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
843 | OUTPUT: |
|
|
844 | RETVAL |
|
|
845 | |
|
|
846 | int |
|
|
847 | SET_CUSTOM (int rend, int new_value) |
|
|
848 | CODE: |
|
|
849 | { |
|
|
850 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
851 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
852 | |
|
|
853 | RETVAL = (rend & ~RS_customMask) |
|
|
854 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
855 | } |
|
|
856 | OUTPUT: |
|
|
857 | RETVAL |
|
|
858 | |
339 | MODULE = urxvt PACKAGE = urxvt::term |
859 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
860 | |
|
|
861 | SV * |
|
|
862 | _new (...) |
|
|
863 | CODE: |
|
|
864 | { |
|
|
865 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
866 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
867 | |
|
|
868 | rxvt_term *term = new rxvt_term; |
|
|
869 | |
|
|
870 | term->argv = new stringvec; |
|
|
871 | term->envv = new stringvec; |
|
|
872 | |
|
|
873 | for (int i = 1; i < items; i++) |
|
|
874 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
875 | |
|
|
876 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
877 | for (int i = av_len (envv) + 1; i--; ) |
|
|
878 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
|
|
879 | |
|
|
880 | term->envv->push_back (0); |
|
|
881 | |
|
|
882 | bool success; |
|
|
883 | |
|
|
884 | try |
|
|
885 | { |
|
|
886 | success = term->init (term->argv->size (), term->argv->begin ()); |
|
|
887 | } |
|
|
888 | catch (const class rxvt_failure_exception &e) |
|
|
889 | { |
|
|
890 | success = false; |
|
|
891 | } |
|
|
892 | |
|
|
893 | if (!success) |
|
|
894 | { |
|
|
895 | term->destroy (); |
|
|
896 | croak ("error while initializing new terminal instance"); |
|
|
897 | } |
|
|
898 | |
|
|
899 | RETVAL = term && term->perl.self |
|
|
900 | ? newSVterm (term) : &PL_sv_undef; |
|
|
901 | } |
|
|
902 | OUTPUT: |
|
|
903 | RETVAL |
|
|
904 | |
|
|
905 | void |
|
|
906 | rxvt_term::destroy () |
|
|
907 | |
|
|
908 | #if ENABLE_PERL_FRILLS |
|
|
909 | |
|
|
910 | void |
|
|
911 | rxvt_term::XListProperties (U32 window) |
|
|
912 | PPCODE: |
|
|
913 | { |
|
|
914 | int count; |
|
|
915 | Atom *props = XListProperties (THIS->display->display, (Window)window, &count); |
|
|
916 | |
|
|
917 | EXTEND (SP, count); |
|
|
918 | while (count--) |
|
|
919 | PUSHs (newSVuv ((U32)props [count])); |
|
|
920 | |
|
|
921 | XFree (props); |
|
|
922 | } |
|
|
923 | |
|
|
924 | void |
|
|
925 | rxvt_term::XGetWindowProperty (U32 window, U32 property) |
|
|
926 | PPCODE: |
|
|
927 | { |
|
|
928 | Atom type; |
|
|
929 | int format; |
|
|
930 | unsigned long nitems; |
|
|
931 | unsigned long bytes_after; |
|
|
932 | unsigned char *prop; |
|
|
933 | XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
934 | 0, 1<<30, 0, AnyPropertyType, |
|
|
935 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
936 | if (type != None) |
|
|
937 | { |
|
|
938 | EXTEND (SP, 3); |
|
|
939 | PUSHs (newSVuv ((U32)type)); |
|
|
940 | PUSHs (newSViv (format)); |
|
|
941 | PUSHs (newSVpvn ((char *)prop, nitems * format / 8)); |
|
|
942 | XFree (prop); |
|
|
943 | } |
|
|
944 | } |
|
|
945 | |
|
|
946 | void |
|
|
947 | rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data) |
|
|
948 | CODE: |
|
|
949 | { |
|
|
950 | STRLEN len; |
|
|
951 | char *data_ = SvPVbyte (data, len); |
|
|
952 | |
|
|
953 | XChangeProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
954 | type, format, PropModeReplace, |
|
|
955 | (unsigned char *)data, len * 8 / format); |
|
|
956 | } |
|
|
957 | |
|
|
958 | void |
|
|
959 | rxvt_term::XDeleteProperty (U32 window, U32 property) |
|
|
960 | CODE: |
|
|
961 | XDeleteProperty (THIS->display->display, (Window)window, (Atom)property); |
|
|
962 | |
|
|
963 | U32 |
|
|
964 | rxvt_term::DefaultRootWindow () |
|
|
965 | CODE: |
|
|
966 | RETVAL = (U32)THIS->display->root; |
|
|
967 | OUTPUT: |
|
|
968 | RETVAL |
|
|
969 | |
|
|
970 | U32 |
|
|
971 | rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height) |
|
|
972 | CODE: |
|
|
973 | RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent, |
|
|
974 | x, y, width, height, 0, |
|
|
975 | THIS->pix_colors_focused[Color_border], |
|
|
976 | THIS->pix_colors_focused[Color_border]); |
|
|
977 | OUTPUT: |
|
|
978 | RETVAL |
|
|
979 | |
|
|
980 | void |
|
|
981 | rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0) |
|
|
982 | CODE: |
|
|
983 | XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y); |
|
|
984 | |
|
|
985 | void |
|
|
986 | rxvt_term::XMapWindow (U32 window) |
|
|
987 | CODE: |
|
|
988 | XMapWindow (THIS->display->display, (Window)window); |
|
|
989 | |
|
|
990 | void |
|
|
991 | rxvt_term::XUnmapWindow (U32 window) |
|
|
992 | CODE: |
|
|
993 | XUnmapWindow (THIS->display->display, (Window)window); |
|
|
994 | |
|
|
995 | #endif |
|
|
996 | |
|
|
997 | void |
|
|
998 | rxvt_term::set_should_invoke (int htype, int inc) |
|
|
999 | CODE: |
|
|
1000 | THIS->perl.should_invoke [htype] += inc; |
|
|
1001 | |
|
|
1002 | void |
|
|
1003 | rxvt_term::grab_button (int button, U32 modifiers) |
|
|
1004 | CODE: |
|
|
1005 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
|
|
1006 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
1007 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
1008 | |
|
|
1009 | bool |
|
|
1010 | rxvt_term::grab (U32 eventtime, int sync = 0) |
|
|
1011 | CODE: |
|
|
1012 | { |
|
|
1013 | int mode = sync ? GrabModeSync : GrabModeAsync; |
|
|
1014 | |
|
|
1015 | THIS->perl.grabtime = 0; |
|
|
1016 | |
|
|
1017 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
1018 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
1019 | mode, mode, None, GRAB_CURSOR, eventtime)) |
|
|
1020 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
|
|
1021 | THIS->perl.grabtime = eventtime; |
|
|
1022 | else |
|
|
1023 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
1024 | |
|
|
1025 | RETVAL = !!THIS->perl.grabtime; |
|
|
1026 | } |
|
|
1027 | OUTPUT: |
|
|
1028 | RETVAL |
|
|
1029 | |
|
|
1030 | void |
|
|
1031 | rxvt_term::allow_events_async () |
|
|
1032 | CODE: |
|
|
1033 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
|
|
1034 | |
|
|
1035 | void |
|
|
1036 | rxvt_term::allow_events_sync () |
|
|
1037 | CODE: |
|
|
1038 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
|
|
1039 | |
|
|
1040 | void |
|
|
1041 | rxvt_term::allow_events_replay () |
|
|
1042 | CODE: |
|
|
1043 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
|
|
1044 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
|
|
1045 | |
|
|
1046 | void |
|
|
1047 | rxvt_term::ungrab () |
|
|
1048 | CODE: |
|
|
1049 | ungrab (THIS); |
340 | |
1050 | |
341 | int |
1051 | int |
342 | rxvt_term::strwidth (SV *str) |
1052 | rxvt_term::strwidth (SV *str) |
343 | CODE: |
1053 | CODE: |
344 | { |
1054 | { |
… | |
… | |
363 | char *mbstr = rxvt_wcstombs (wstr); |
1073 | char *mbstr = rxvt_wcstombs (wstr); |
364 | rxvt_pop_locale (); |
1074 | rxvt_pop_locale (); |
365 | |
1075 | |
366 | free (wstr); |
1076 | free (wstr); |
367 | |
1077 | |
368 | RETVAL = newSVpv (mbstr, 0); |
1078 | RETVAL = taint_if (newSVpv (mbstr, 0), str); |
369 | free (mbstr); |
1079 | free (mbstr); |
370 | } |
1080 | } |
371 | OUTPUT: |
1081 | OUTPUT: |
372 | RETVAL |
1082 | RETVAL |
373 | |
1083 | |
… | |
… | |
380 | |
1090 | |
381 | rxvt_push_locale (THIS->locale); |
1091 | rxvt_push_locale (THIS->locale); |
382 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
1092 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
383 | rxvt_pop_locale (); |
1093 | rxvt_pop_locale (); |
384 | |
1094 | |
385 | char *str = rxvt_wcstoutf8 (wstr); |
1095 | RETVAL = taint_if (wcs2sv (wstr), octets); |
386 | free (wstr); |
1096 | free (wstr); |
|
|
1097 | } |
|
|
1098 | OUTPUT: |
|
|
1099 | RETVAL |
387 | |
1100 | |
388 | RETVAL = newSVpv (str, 0); |
1101 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
389 | SvUTF8_on (RETVAL); |
1102 | |
|
|
1103 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
1104 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
1105 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
1106 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
1107 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
1108 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
1109 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
1110 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
1111 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
1112 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
1113 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
1114 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
|
|
1115 | |
|
|
1116 | int |
|
|
1117 | rxvt_term::width () |
|
|
1118 | ALIAS: |
|
|
1119 | width = TERM_OFFSET_width |
|
|
1120 | height = TERM_OFFSET_height |
|
|
1121 | fwidth = TERM_OFFSET_fwidth |
|
|
1122 | fheight = TERM_OFFSET_fheight |
|
|
1123 | fbase = TERM_OFFSET_fbase |
|
|
1124 | nrow = TERM_OFFSET_nrow |
|
|
1125 | ncol = TERM_OFFSET_ncol |
|
|
1126 | focus = TERM_OFFSET_focus |
|
|
1127 | mapped = TERM_OFFSET_mapped |
|
|
1128 | saveLines = TERM_OFFSET_saveLines |
|
|
1129 | total_rows = TERM_OFFSET_total_rows |
|
|
1130 | top_row = TERM_OFFSET_top_row |
|
|
1131 | CODE: |
|
|
1132 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
1133 | OUTPUT: |
|
|
1134 | RETVAL |
|
|
1135 | |
|
|
1136 | unsigned int |
|
|
1137 | rxvt_term::ModLevel3Mask () |
|
|
1138 | ALIAS: |
|
|
1139 | ModLevel3Mask = 0 |
|
|
1140 | ModMetaMask = 1 |
|
|
1141 | ModNumLockMask = 2 |
|
|
1142 | CODE: |
|
|
1143 | switch (ix) |
|
|
1144 | { |
|
|
1145 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
|
|
1146 | case 1: RETVAL = THIS->ModMetaMask; break; |
|
|
1147 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
1148 | } |
|
|
1149 | OUTPUT: |
|
|
1150 | RETVAL |
|
|
1151 | |
|
|
1152 | char * |
|
|
1153 | rxvt_term::display_id () |
|
|
1154 | ALIAS: |
|
|
1155 | display_id = 0 |
|
|
1156 | locale = 1 |
|
|
1157 | CODE: |
|
|
1158 | switch (ix) |
|
|
1159 | { |
|
|
1160 | case 0: RETVAL = THIS->display->id; break; |
|
|
1161 | case 1: RETVAL = THIS->locale; break; |
|
|
1162 | } |
|
|
1163 | OUTPUT: |
|
|
1164 | RETVAL |
|
|
1165 | |
|
|
1166 | SV * |
|
|
1167 | rxvt_term::_env () |
|
|
1168 | CODE: |
|
|
1169 | { |
|
|
1170 | if (THIS->envv) |
|
|
1171 | { |
|
|
1172 | AV *av = newAV (); |
|
|
1173 | |
|
|
1174 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
|
|
1175 | if (*i) |
|
|
1176 | av_push (av, newSVpv (*i, 0)); |
|
|
1177 | |
|
|
1178 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1179 | } |
|
|
1180 | else |
|
|
1181 | RETVAL = &PL_sv_undef; |
|
|
1182 | } |
|
|
1183 | OUTPUT: |
|
|
1184 | RETVAL |
|
|
1185 | |
|
|
1186 | int |
|
|
1187 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
|
|
1188 | CODE: |
|
|
1189 | RETVAL = THIS->pty_ev.events; |
|
|
1190 | if (events != EVENT_UNDEF) |
|
|
1191 | THIS->pty_ev.set (events); |
|
|
1192 | OUTPUT: |
|
|
1193 | RETVAL |
|
|
1194 | |
|
|
1195 | U32 |
|
|
1196 | rxvt_term::parent () |
|
|
1197 | CODE: |
|
|
1198 | RETVAL = (U32)THIS->parent [0]; |
|
|
1199 | OUTPUT: |
|
|
1200 | RETVAL |
|
|
1201 | |
|
|
1202 | U32 |
|
|
1203 | rxvt_term::vt () |
|
|
1204 | CODE: |
|
|
1205 | RETVAL = (U32)THIS->vt; |
|
|
1206 | OUTPUT: |
|
|
1207 | RETVAL |
|
|
1208 | |
|
|
1209 | void |
|
|
1210 | rxvt_term::vt_emask_add (U32 emask) |
|
|
1211 | CODE: |
|
|
1212 | THIS->vt_emask_perl |= emask; |
|
|
1213 | THIS->vt_select_input (); |
|
|
1214 | |
|
|
1215 | U32 |
|
|
1216 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
1217 | CODE: |
|
|
1218 | RETVAL = THIS->rstyle; |
|
|
1219 | THIS->rstyle = new_rstyle; |
|
|
1220 | OUTPUT: |
|
|
1221 | RETVAL |
|
|
1222 | |
|
|
1223 | int |
|
|
1224 | rxvt_term::view_start (int newval = 1) |
|
|
1225 | PROTOTYPE: $;$ |
|
|
1226 | CODE: |
|
|
1227 | { |
|
|
1228 | RETVAL = THIS->view_start; |
|
|
1229 | |
|
|
1230 | if (newval <= 0) |
|
|
1231 | THIS->scr_changeview (max (newval, THIS->top_row)); |
|
|
1232 | } |
|
|
1233 | OUTPUT: |
|
|
1234 | RETVAL |
|
|
1235 | |
|
|
1236 | void |
|
|
1237 | rxvt_term::want_refresh () |
|
|
1238 | CODE: |
|
|
1239 | THIS->want_refresh = 1; |
|
|
1240 | |
|
|
1241 | void |
|
|
1242 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
|
|
1243 | PPCODE: |
|
|
1244 | { |
|
|
1245 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
|
|
1246 | XSRETURN_EMPTY; |
|
|
1247 | |
|
|
1248 | line_t &l = ROW(row_number); |
|
|
1249 | |
|
|
1250 | if (GIMME_V != G_VOID) |
|
|
1251 | { |
|
|
1252 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
|
|
1253 | |
|
|
1254 | for (int col = 0; col < THIS->ncol; col++) |
|
|
1255 | wstr [col] = l.t [col]; |
|
|
1256 | |
|
|
1257 | XPUSHs (taint (sv_2mortal (wcs2sv (wstr, THIS->ncol)))); |
|
|
1258 | |
|
|
1259 | delete [] wstr; |
|
|
1260 | } |
|
|
1261 | |
|
|
1262 | if (new_text) |
|
|
1263 | { |
|
|
1264 | wchar_t *wstr = sv2wcs (new_text); |
|
|
1265 | |
|
|
1266 | int len = min (wcslen (wstr) - start_ofs, max_len); |
|
|
1267 | |
|
|
1268 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
1269 | { |
|
|
1270 | free (wstr); |
|
|
1271 | croak ("new_text extends beyond horizontal margins"); |
|
|
1272 | } |
|
|
1273 | |
|
|
1274 | for (int col = start_col; col < start_col + len; col++) |
|
|
1275 | { |
|
|
1276 | l.t [col] = wstr [start_ofs + col - start_col]; |
|
|
1277 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
|
|
1278 | } |
|
|
1279 | |
390 | free (str); |
1280 | free (wstr); |
|
|
1281 | } |
|
|
1282 | } |
|
|
1283 | |
|
|
1284 | void |
|
|
1285 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
|
|
1286 | PPCODE: |
|
|
1287 | { |
|
|
1288 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
|
|
1289 | XSRETURN_EMPTY; |
|
|
1290 | |
|
|
1291 | line_t &l = ROW(row_number); |
|
|
1292 | |
|
|
1293 | if (GIMME_V != G_VOID) |
|
|
1294 | { |
|
|
1295 | AV *av = newAV (); |
|
|
1296 | |
|
|
1297 | av_extend (av, THIS->ncol - 1); |
|
|
1298 | for (int col = 0; col < THIS->ncol; col++) |
|
|
1299 | av_store (av, col, newSViv (l.r [col])); |
|
|
1300 | |
|
|
1301 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
1302 | } |
|
|
1303 | |
|
|
1304 | if (new_rend) |
|
|
1305 | { |
|
|
1306 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
|
|
1307 | croak ("new_rend must be arrayref"); |
|
|
1308 | |
|
|
1309 | AV *av = (AV *)SvRV (new_rend); |
|
|
1310 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
|
|
1311 | |
|
|
1312 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
1313 | croak ("new_rend array extends beyond horizontal margins"); |
|
|
1314 | |
|
|
1315 | for (int col = start_col; col < start_col + len; col++) |
|
|
1316 | { |
|
|
1317 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
|
|
1318 | |
|
|
1319 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
|
|
1320 | } |
|
|
1321 | } |
|
|
1322 | } |
|
|
1323 | |
|
|
1324 | int |
|
|
1325 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
|
|
1326 | CODE: |
|
|
1327 | { |
|
|
1328 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
|
|
1329 | XSRETURN_EMPTY; |
|
|
1330 | |
|
|
1331 | line_t &l = ROW(row_number); |
|
|
1332 | RETVAL = l.l; |
|
|
1333 | |
|
|
1334 | if (new_length >= 0) |
|
|
1335 | l.l = new_length; |
|
|
1336 | } |
|
|
1337 | OUTPUT: |
|
|
1338 | RETVAL |
|
|
1339 | |
|
|
1340 | bool |
|
|
1341 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
|
|
1342 | CODE: |
|
|
1343 | { |
|
|
1344 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
|
|
1345 | XSRETURN_EMPTY; |
|
|
1346 | |
|
|
1347 | line_t &l = ROW(row_number); |
|
|
1348 | RETVAL = l.is_longer (); |
|
|
1349 | |
|
|
1350 | if (new_is_longer >= 0) |
|
|
1351 | l.is_longer (new_is_longer); |
|
|
1352 | } |
|
|
1353 | OUTPUT: |
|
|
1354 | RETVAL |
|
|
1355 | |
|
|
1356 | SV * |
|
|
1357 | rxvt_term::special_encode (SV *string) |
|
|
1358 | CODE: |
|
|
1359 | { |
|
|
1360 | wchar_t *wstr = sv2wcs (string); |
|
|
1361 | int wlen = wcslen (wstr); |
|
|
1362 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
1363 | |
|
|
1364 | rxvt_push_locale (THIS->locale); |
|
|
1365 | |
|
|
1366 | wchar_t *r = rstr; |
|
|
1367 | for (wchar_t *s = wstr; *s; s++) |
|
|
1368 | if (wcwidth (*s) == 0) |
|
|
1369 | { |
|
|
1370 | if (r == rstr) |
|
|
1371 | croak ("leading combining character unencodable"); |
|
|
1372 | |
|
|
1373 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
1374 | if (n == NOCHAR) |
|
|
1375 | n = rxvt_composite.compose (r[-1], *s); |
|
|
1376 | |
|
|
1377 | r[-1] = n; |
|
|
1378 | } |
|
|
1379 | #if !UNICODE_3 |
|
|
1380 | else if (*s >= 0x10000) |
|
|
1381 | *r++ = rxvt_composite.compose (*s); |
|
|
1382 | #endif |
|
|
1383 | else |
|
|
1384 | *r++ = *s; |
|
|
1385 | |
|
|
1386 | rxvt_pop_locale (); |
|
|
1387 | |
|
|
1388 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), string); |
|
|
1389 | |
|
|
1390 | delete [] rstr; |
|
|
1391 | } |
|
|
1392 | OUTPUT: |
|
|
1393 | RETVAL |
|
|
1394 | |
|
|
1395 | SV * |
|
|
1396 | rxvt_term::special_decode (SV *text) |
|
|
1397 | CODE: |
|
|
1398 | { |
|
|
1399 | wchar_t *wstr = sv2wcs (text); |
|
|
1400 | int wlen = wcslen (wstr); |
|
|
1401 | int dlen = 0; |
|
|
1402 | |
|
|
1403 | // find length |
|
|
1404 | for (wchar_t *s = wstr; *s; s++) |
|
|
1405 | if (*s == NOCHAR) |
|
|
1406 | ; |
|
|
1407 | else if (IS_COMPOSE (*s)) |
|
|
1408 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1409 | else |
|
|
1410 | dlen++; |
|
|
1411 | |
|
|
1412 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1413 | |
|
|
1414 | // decode |
|
|
1415 | wchar_t *r = rstr; |
|
|
1416 | for (wchar_t *s = wstr; *s; s++) |
|
|
1417 | if (*s == NOCHAR) |
|
|
1418 | ; |
|
|
1419 | else if (IS_COMPOSE (*s)) |
|
|
1420 | r += rxvt_composite.expand (*s, r); |
|
|
1421 | else |
|
|
1422 | *r++ = *s; |
|
|
1423 | |
|
|
1424 | RETVAL = taint_if (wcs2sv (rstr, r - rstr), text); |
|
|
1425 | |
|
|
1426 | delete [] rstr; |
391 | } |
1427 | } |
392 | OUTPUT: |
1428 | OUTPUT: |
393 | RETVAL |
1429 | RETVAL |
394 | |
1430 | |
395 | void |
1431 | void |
396 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1432 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
397 | PPCODE: |
1433 | PPCODE: |
398 | { |
1434 | { |
399 | struct resval { const char *name; int value; } rslist [] = { |
1435 | struct resval { const char *name; int value; } rslist [] = { |
400 | # define Rs_def(name) { # name, Rs_ ## name }, |
1436 | # define def(name) { # name, Rs_ ## name }, |
401 | # define Rs_reserve(name,count) |
1437 | # define reserve(name,count) |
402 | # include "rsinc.h" |
1438 | # include "rsinc.h" |
403 | # undef Rs_def |
1439 | # undef def |
404 | # undef Rs_reserve |
1440 | # undef reserve |
405 | }; |
1441 | }; |
406 | |
1442 | |
407 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1443 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
408 | |
1444 | |
409 | do { |
1445 | do { |
… | |
… | |
415 | |
1451 | |
416 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
1452 | if (!IN_RANGE_EXC (index, 0, NUM_RESOURCES)) |
417 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
1453 | croak ("requested out-of-bound resource %s+%d,", name, index - rs->value); |
418 | |
1454 | |
419 | if (GIMME_V != G_VOID) |
1455 | if (GIMME_V != G_VOID) |
420 | XPUSHs (THIS->rs [index] ? sv_2mortal (newSVpv (THIS->rs [index], 0)) : &PL_sv_undef); |
1456 | XPUSHs (THIS->rs [index] ? sv_2mortal (taint (newSVpv (THIS->rs [index], 0))) : &PL_sv_undef); |
421 | |
1457 | |
422 | if (newval) |
1458 | if (newval) |
423 | { |
1459 | { |
424 | if (SvOK (newval)) |
1460 | if (SvOK (newval)) |
425 | { |
1461 | { |
… | |
… | |
430 | else |
1466 | else |
431 | THIS->rs [index] = 0; |
1467 | THIS->rs [index] = 0; |
432 | } |
1468 | } |
433 | } |
1469 | } |
434 | |
1470 | |
|
|
1471 | const char * |
|
|
1472 | rxvt_term::x_resource (const char *name) |
|
|
1473 | CLEANUP: |
|
|
1474 | SvTAINTED_on (ST (0)); |
|
|
1475 | |
|
|
1476 | bool |
|
|
1477 | rxvt_term::option (U32 optval, int set = -1) |
|
|
1478 | CODE: |
|
|
1479 | { |
|
|
1480 | RETVAL = THIS->options & optval; |
|
|
1481 | |
|
|
1482 | if (set >= 0) |
|
|
1483 | { |
|
|
1484 | if (set) |
|
|
1485 | THIS->options |= optval; |
|
|
1486 | else |
|
|
1487 | THIS->options &= ~optval; |
|
|
1488 | |
|
|
1489 | switch (optval) |
|
|
1490 | { |
|
|
1491 | case Opt_skipBuiltinGlyphs: |
|
|
1492 | THIS->set_fonts (); |
|
|
1493 | THIS->scr_remap_chars (); |
|
|
1494 | THIS->scr_touch (true); |
|
|
1495 | THIS->want_refresh = 1; |
|
|
1496 | break; |
|
|
1497 | |
|
|
1498 | case Opt_cursorUnderline: |
|
|
1499 | THIS->want_refresh = 1; |
|
|
1500 | break; |
|
|
1501 | |
|
|
1502 | # case Opt_scrollBar_floating: |
|
|
1503 | # case Opt_scrollBar_right: |
|
|
1504 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
|
|
1505 | # break; |
|
|
1506 | } |
|
|
1507 | } |
|
|
1508 | } |
|
|
1509 | OUTPUT: |
|
|
1510 | RETVAL |
|
|
1511 | |
|
|
1512 | bool |
|
|
1513 | rxvt_term::parse_keysym (char *keysym, char *str) |
|
|
1514 | CODE: |
|
|
1515 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
|
|
1516 | THIS->keyboard->register_done (); |
|
|
1517 | OUTPUT: |
|
|
1518 | RETVAL |
|
|
1519 | |
435 | void |
1520 | void |
436 | rxvt_term::selection_mark (...) |
1521 | rxvt_term::screen_cur (...) |
437 | PROTOTYPE: $;$$ |
1522 | PROTOTYPE: $;$$ |
438 | ALIAS: |
1523 | ALIAS: |
|
|
1524 | screen_cur = 0 |
439 | selection_beg = 1 |
1525 | selection_beg = 1 |
440 | selection_end = 2 |
1526 | selection_end = 2 |
|
|
1527 | selection_mark = 3 |
441 | PPCODE: |
1528 | PPCODE: |
442 | { |
1529 | { |
443 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1530 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1531 | : ix == 1 ? THIS->selection.beg |
444 | : ix == 2 ? THIS->selection.end |
1532 | : ix == 2 ? THIS->selection.end |
445 | : THIS->selection.mark; |
1533 | : THIS->selection.mark; |
446 | |
1534 | |
447 | if (GIMME_V != G_VOID) |
1535 | if (GIMME_V != G_VOID) |
448 | { |
1536 | { |
449 | EXTEND (SP, 2); |
1537 | EXTEND (SP, 2); |
450 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1538 | PUSHs (sv_2mortal (newSViv (rc.row))); |
451 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1539 | PUSHs (sv_2mortal (newSViv (rc.col))); |
452 | } |
1540 | } |
453 | |
1541 | |
454 | if (items == 3) |
1542 | if (items == 3) |
455 | { |
1543 | { |
456 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1544 | rc.row = clamp (SvIV (ST (1)), THIS->top_row, THIS->nrow - 1); |
457 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1545 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
458 | |
1546 | |
459 | if (ix) |
1547 | if (ix) |
460 | THIS->want_refresh = 1; |
1548 | THIS->want_refresh = 1; |
461 | } |
1549 | } |
462 | } |
1550 | } |
463 | |
1551 | |
|
|
1552 | char |
|
|
1553 | rxvt_term::cur_charset () |
|
|
1554 | CODE: |
|
|
1555 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1556 | OUTPUT: |
|
|
1557 | RETVAL |
|
|
1558 | |
|
|
1559 | #void |
|
|
1560 | #rxvt_term::selection_clear () |
|
|
1561 | |
|
|
1562 | void |
|
|
1563 | rxvt_term::selection_make (U32 eventtime, bool rect = false) |
|
|
1564 | CODE: |
|
|
1565 | THIS->selection.op = SELECTION_CONT; |
|
|
1566 | THIS->selection.rect = rect; |
|
|
1567 | THIS->selection_make (eventtime); |
|
|
1568 | |
464 | int |
1569 | int |
465 | rxvt_term::selection_grab (int eventtime) |
1570 | rxvt_term::selection_grab (U32 eventtime) |
466 | |
1571 | |
467 | void |
1572 | void |
468 | rxvt_term::selection (SV *newtext = 0) |
1573 | rxvt_term::selection (SV *newtext = 0) |
469 | PPCODE: |
1574 | PPCODE: |
470 | { |
1575 | { |
471 | if (GIMME_V != G_VOID) |
1576 | if (GIMME_V != G_VOID) |
472 | { |
1577 | XPUSHs (THIS->selection.text |
473 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
1578 | ? taint (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))) |
474 | SV *sv = newSVpv (sel, 0); |
1579 | : &PL_sv_undef); |
475 | SvUTF8_on (sv); |
|
|
476 | free (sel); |
|
|
477 | XPUSHs (sv_2mortal (sv)); |
|
|
478 | } |
|
|
479 | |
1580 | |
480 | if (newtext) |
1581 | if (newtext) |
481 | { |
1582 | { |
482 | free (THIS->selection.text); |
1583 | free (THIS->selection.text); |
483 | |
1584 | |
484 | THIS->selection.text = sv2wcs (newtext); |
1585 | THIS->selection.text = sv2wcs (newtext); |
485 | THIS->selection.len = wcslen (THIS->selection.text); |
1586 | THIS->selection.len = wcslen (THIS->selection.text); |
486 | } |
1587 | } |
487 | } |
1588 | } |
488 | |
|
|
489 | void |
|
|
490 | rxvt_term::scr_overlay_new (int x, int y, int w, int h) |
|
|
491 | |
1589 | |
492 | void |
1590 | void |
|
|
1591 | 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) |
|
|
1592 | |
|
|
1593 | void |
|
|
1594 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
|
|
1595 | |
|
|
1596 | void |
493 | rxvt_term::scr_overlay_off () |
1597 | rxvt_term::scr_bell () |
494 | |
1598 | |
495 | void |
1599 | void |
496 | rxvt_term::scr_overlay_set_char (int x, int y, U32 text, U32 rend = OVERLAY_RSTYLE) |
1600 | rxvt_term::scr_add_lines (SV *string) |
497 | CODE: |
1601 | CODE: |
498 | THIS->scr_overlay_set (x, y, text, rend); |
|
|
499 | |
|
|
500 | void |
|
|
501 | rxvt_term::scr_overlay_set (int x, int y, SV *text) |
|
|
502 | CODE: |
|
|
503 | { |
1602 | { |
504 | wchar_t *wtext = sv2wcs (text); |
1603 | wchar_t *wstr = sv2wcs (string); |
505 | THIS->scr_overlay_set (x, y, wtext); |
1604 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
506 | free (wtext); |
1605 | free (wstr); |
507 | } |
1606 | } |
508 | |
1607 | |
509 | void |
1608 | void |
510 | rxvt_term::tt_write (SV *octets) |
1609 | rxvt_term::tt_write (SV *octets) |
511 | INIT: |
1610 | INIT: |
512 | STRLEN len; |
1611 | STRLEN len; |
513 | char *str = SvPVbyte (octets, len); |
1612 | char *str = SvPVbyte (octets, len); |
514 | C_ARGS: |
1613 | C_ARGS: |
515 | (unsigned char *)str, len |
1614 | str, len |
|
|
1615 | |
|
|
1616 | void |
|
|
1617 | rxvt_term::cmd_parse (SV *octets) |
|
|
1618 | CODE: |
|
|
1619 | { |
|
|
1620 | STRLEN len; |
|
|
1621 | char *str = SvPVbyte (octets, len); |
|
|
1622 | |
|
|
1623 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1624 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1625 | |
|
|
1626 | THIS->cmdbuf_ptr = str; |
|
|
1627 | THIS->cmdbuf_endp = str + len; |
|
|
1628 | |
|
|
1629 | rxvt_push_locale (THIS->locale); |
|
|
1630 | THIS->cmd_parse (); |
|
|
1631 | rxvt_pop_locale (); |
|
|
1632 | |
|
|
1633 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1634 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1635 | } |
|
|
1636 | |
|
|
1637 | SV * |
|
|
1638 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
|
|
1639 | CODE: |
|
|
1640 | { |
|
|
1641 | overlay *o = new overlay (THIS, x, y, w, h, rstyle, border); |
|
|
1642 | RETVAL = newSVptr ((void *)o, "urxvt::overlay"); |
|
|
1643 | o->self = (HV *)SvRV (RETVAL); |
|
|
1644 | } |
|
|
1645 | OUTPUT: |
|
|
1646 | RETVAL |
|
|
1647 | |
|
|
1648 | MODULE = urxvt PACKAGE = urxvt::overlay |
|
|
1649 | |
|
|
1650 | void |
|
|
1651 | overlay::set (int x, int y, SV *text, SV *rend = 0) |
|
|
1652 | |
|
|
1653 | void |
|
|
1654 | overlay::show () |
|
|
1655 | |
|
|
1656 | void |
|
|
1657 | overlay::hide () |
|
|
1658 | |
|
|
1659 | void |
|
|
1660 | overlay::DESTROY () |
516 | |
1661 | |
517 | MODULE = urxvt PACKAGE = urxvt::timer |
1662 | MODULE = urxvt PACKAGE = urxvt::timer |
518 | |
1663 | |
519 | SV * |
1664 | SV * |
520 | timer::new () |
1665 | timer::new () |
521 | CODE: |
1666 | CODE: |
522 | timer *w = new timer; |
1667 | timer *w = new timer; |
|
|
1668 | w->start (NOW); |
523 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
1669 | RETVAL = newSVptr ((void *)w, "urxvt::timer"); |
524 | w->self = (HV *)SvRV (RETVAL); |
1670 | w->self = (HV *)SvRV (RETVAL); |
525 | OUTPUT: |
1671 | OUTPUT: |
526 | RETVAL |
1672 | RETVAL |
527 | |
1673 | |
… | |
… | |
535 | |
1681 | |
536 | NV |
1682 | NV |
537 | timer::at () |
1683 | timer::at () |
538 | CODE: |
1684 | CODE: |
539 | RETVAL = THIS->at; |
1685 | RETVAL = THIS->at; |
|
|
1686 | OUTPUT: |
|
|
1687 | RETVAL |
|
|
1688 | |
|
|
1689 | timer * |
|
|
1690 | timer::interval (NV interval) |
|
|
1691 | CODE: |
|
|
1692 | THIS->interval = interval; |
|
|
1693 | RETVAL = THIS; |
540 | OUTPUT: |
1694 | OUTPUT: |
541 | RETVAL |
1695 | RETVAL |
542 | |
1696 | |
543 | timer * |
1697 | timer * |
544 | timer::set (NV tstamp) |
1698 | timer::set (NV tstamp) |