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