… | |
… | |
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" |
|
|
43 | |
|
|
44 | #ifdef HAVE_SCROLLBARS |
|
|
45 | # define GRAB_CURSOR THIS->leftptr_cursor |
|
|
46 | #else |
|
|
47 | # define GRAB_CURSOR None |
|
|
48 | #endif |
39 | |
49 | |
40 | #undef LINENO |
50 | #undef LINENO |
41 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
51 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
42 | #undef ROW |
52 | #undef ROW |
43 | #define ROW(n) THIS->row_buf [LINENO (n)] |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
44 | |
54 | |
|
|
55 | #define ENABLE_PERL_FRILLS 1 |
|
|
56 | |
45 | ///////////////////////////////////////////////////////////////////////////// |
57 | ///////////////////////////////////////////////////////////////////////////// |
46 | |
58 | |
47 | static wchar_t * |
59 | static wchar_t * |
48 | sv2wcs (SV *sv) |
60 | sv2wcs (SV *sv) |
49 | { |
61 | { |
… | |
… | |
101 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
113 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
102 | |
114 | |
103 | return (long)mg->mg_ptr; |
115 | return (long)mg->mg_ptr; |
104 | } |
116 | } |
105 | |
117 | |
106 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
118 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
107 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
119 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
108 | |
120 | |
109 | ///////////////////////////////////////////////////////////////////////////// |
121 | ///////////////////////////////////////////////////////////////////////////// |
110 | |
122 | |
111 | struct perl_watcher |
123 | struct perl_watcher |
… | |
… | |
199 | |
211 | |
200 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
212 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
201 | |
213 | |
202 | struct overlay { |
214 | struct overlay { |
203 | HV *self; |
215 | HV *self; |
|
|
216 | bool visible; |
204 | rxvt_term *THIS; |
217 | rxvt_term *THIS; |
205 | int x, y, w, h; |
218 | int x, y, w, h; |
206 | int border; |
219 | int border; |
207 | text_t **text; |
220 | text_t **text; |
208 | rend_t **rend; |
221 | rend_t **rend; |
… | |
… | |
217 | |
230 | |
218 | void set (int x, int y, SV *str, SV *rend); |
231 | void set (int x, int y, SV *str, SV *rend); |
219 | }; |
232 | }; |
220 | |
233 | |
221 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
234 | overlay::overlay (rxvt_term *THIS, int x_, int y_, int w_, int h_, rend_t rstyle, int border) |
222 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2) |
235 | : THIS(THIS), x(x_), y(y_), w(w_), h(h_), border(border == 2), visible(false) |
223 | { |
236 | { |
224 | if (border == 2) |
237 | if (border == 2) |
225 | { |
238 | { |
226 | w += 2; |
239 | w += 2; |
227 | h += 2; |
240 | h += 2; |
… | |
… | |
288 | } |
301 | } |
289 | |
302 | |
290 | void |
303 | void |
291 | overlay::show () |
304 | overlay::show () |
292 | { |
305 | { |
293 | char key[33]; sprintf (key, "%32lx", (long)this); |
306 | if (visible) |
|
|
307 | return; |
294 | |
308 | |
|
|
309 | visible = true; |
|
|
310 | |
295 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
311 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
296 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
312 | av_push (av, newSViv ((long)this)); |
297 | } |
313 | } |
298 | |
314 | |
299 | void |
315 | void |
300 | overlay::hide () |
316 | overlay::hide () |
301 | { |
317 | { |
|
|
318 | if (!visible) |
|
|
319 | return; |
|
|
320 | |
|
|
321 | visible = false; |
|
|
322 | |
302 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); |
323 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
303 | |
324 | |
304 | if (ovs) |
325 | int i; |
|
|
326 | |
|
|
327 | for (i = AvFILL (av); i >= 0; i--) |
|
|
328 | if (SvIV (*av_fetch (av, i, 1)) == (long)this) |
305 | { |
329 | { |
306 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
307 | |
|
|
308 | HV *hv = (HV *)SvRV (*ovs); |
|
|
309 | hv_delete (hv, key, 32, G_DISCARD); |
330 | av_delete (av, i, G_DISCARD); |
|
|
331 | break; |
310 | } |
332 | } |
|
|
333 | |
|
|
334 | for (; i < AvFILL (av); i++) |
|
|
335 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
336 | |
|
|
337 | av_pop (av); |
311 | } |
338 | } |
312 | |
339 | |
313 | void overlay::swap () |
340 | void overlay::swap () |
314 | { |
341 | { |
315 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
342 | int ov_x = max (0, min (MOD (x, THIS->ncol), THIS->ncol - w)); |
… | |
… | |
321 | for (int y = ov_h; y--; ) |
348 | for (int y = ov_h; y--; ) |
322 | { |
349 | { |
323 | text_t *t1 = text [y]; |
350 | text_t *t1 = text [y]; |
324 | rend_t *r1 = rend [y]; |
351 | rend_t *r1 = rend [y]; |
325 | |
352 | |
326 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
353 | text_t *t2 = ROW(y + ov_y + THIS->view_start).t + ov_x; |
327 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
354 | rend_t *r2 = ROW(y + ov_y + THIS->view_start).r + ov_x; |
328 | |
355 | |
329 | for (int x = ov_w; x--; ) |
356 | for (int x = ov_w; x--; ) |
330 | { |
357 | { |
331 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
358 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
332 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
359 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
… | |
… | |
355 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
382 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
356 | croak ("rend must be arrayref"); |
383 | croak ("rend must be arrayref"); |
357 | |
384 | |
358 | AV *av = (AV *)SvRV (rend); |
385 | AV *av = (AV *)SvRV (rend); |
359 | |
386 | |
360 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
387 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
361 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
388 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
362 | } |
389 | } |
363 | |
390 | |
364 | THIS->want_refresh = 1; |
391 | THIS->want_refresh = 1; |
365 | } |
392 | } |
… | |
… | |
368 | ///////////////////////////////////////////////////////////////////////////// |
395 | ///////////////////////////////////////////////////////////////////////////// |
369 | |
396 | |
370 | struct rxvt_perl_interp rxvt_perl; |
397 | struct rxvt_perl_interp rxvt_perl; |
371 | |
398 | |
372 | static PerlInterpreter *perl; |
399 | static PerlInterpreter *perl; |
373 | |
|
|
374 | rxvt_perl_interp::rxvt_perl_interp () |
|
|
375 | { |
|
|
376 | } |
|
|
377 | |
400 | |
378 | rxvt_perl_interp::~rxvt_perl_interp () |
401 | rxvt_perl_interp::~rxvt_perl_interp () |
379 | { |
402 | { |
380 | if (perl) |
403 | if (perl) |
381 | { |
404 | { |
… | |
… | |
383 | perl_free (perl); |
406 | perl_free (perl); |
384 | } |
407 | } |
385 | } |
408 | } |
386 | |
409 | |
387 | void |
410 | void |
388 | rxvt_perl_interp::init () |
411 | rxvt_perl_interp::init (rxvt_term *term) |
389 | { |
412 | { |
390 | if (!perl) |
413 | if (!perl) |
391 | { |
414 | { |
|
|
415 | rxvt_push_locale (""); // perl init destroys current locale |
|
|
416 | |
|
|
417 | perl_environ = rxvt_environ; |
|
|
418 | swap (perl_environ, environ); |
|
|
419 | |
392 | char *argv[] = { |
420 | char *argv[] = { |
393 | "", |
421 | "", |
394 | "-edo '" LIBDIR "/urxvt.pm' or ($@ and die $@) or exit 1", |
422 | "-e" |
|
|
423 | "BEGIN {" |
|
|
424 | " urxvt->bootstrap;" |
|
|
425 | " unshift @INC, '" LIBDIR "';" |
|
|
426 | "}" |
|
|
427 | "" |
|
|
428 | "use urxvt;" |
395 | }; |
429 | }; |
396 | |
430 | |
397 | perl = perl_alloc (); |
431 | perl = perl_alloc (); |
398 | perl_construct (perl); |
432 | perl_construct (perl); |
399 | |
433 | |
… | |
… | |
404 | |
438 | |
405 | perl_destruct (perl); |
439 | perl_destruct (perl); |
406 | perl_free (perl); |
440 | perl_free (perl); |
407 | perl = 0; |
441 | perl = 0; |
408 | } |
442 | } |
|
|
443 | |
|
|
444 | swap (perl_environ, environ); |
|
|
445 | |
|
|
446 | rxvt_pop_locale (); |
|
|
447 | } |
|
|
448 | |
|
|
449 | if (perl) |
|
|
450 | { |
|
|
451 | // runs outside of perls ENV |
|
|
452 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
|
|
453 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
454 | } |
|
|
455 | } |
|
|
456 | |
|
|
457 | static void |
|
|
458 | ungrab (rxvt_term *THIS) |
|
|
459 | { |
|
|
460 | if (THIS->perl.grabtime) |
|
|
461 | { |
|
|
462 | XUngrabKeyboard (THIS->display->display, THIS->perl.grabtime); |
|
|
463 | XUngrabPointer (THIS->display->display, THIS->perl.grabtime); |
|
|
464 | THIS->perl.grabtime = 0; |
409 | } |
465 | } |
410 | } |
466 | } |
411 | |
467 | |
412 | bool |
468 | bool |
413 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
469 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
414 | { |
470 | { |
415 | if (!perl) |
471 | if (!perl || !term->perl.self) |
416 | return false; |
472 | return false; |
417 | |
473 | |
418 | if (htype == HOOK_INIT) // first hook ever called |
474 | // pre-handling of some events |
|
|
475 | if (htype == HOOK_REFRESH_END) |
419 | { |
476 | { |
420 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
477 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
421 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
478 | |
|
|
479 | for (int i = 0; i <= AvFILL (av); i++) |
|
|
480 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
422 | } |
481 | } |
423 | else if (!term->self) |
482 | |
424 | return false; // perl not initialized for this instance |
483 | swap (perl_environ, environ); |
|
|
484 | |
|
|
485 | bool event_consumed; |
|
|
486 | |
|
|
487 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
|
|
488 | || term->perl.should_invoke [htype]) |
|
|
489 | try |
|
|
490 | { |
|
|
491 | dSP; |
|
|
492 | va_list ap; |
|
|
493 | |
|
|
494 | va_start (ap, htype); |
|
|
495 | |
|
|
496 | ENTER; |
|
|
497 | SAVETMPS; |
|
|
498 | |
|
|
499 | PUSHMARK (SP); |
|
|
500 | |
|
|
501 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
502 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
503 | |
|
|
504 | for (;;) { |
|
|
505 | data_type dt = (data_type)va_arg (ap, int); |
|
|
506 | |
|
|
507 | switch (dt) |
|
|
508 | { |
|
|
509 | case DT_INT: |
|
|
510 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
511 | break; |
|
|
512 | |
|
|
513 | case DT_LONG: |
|
|
514 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
515 | break; |
|
|
516 | |
|
|
517 | case DT_STR: |
|
|
518 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
519 | break; |
|
|
520 | |
|
|
521 | case DT_STR_LEN: |
|
|
522 | { |
|
|
523 | char *str = va_arg (ap, char *); |
|
|
524 | int len = va_arg (ap, int); |
|
|
525 | |
|
|
526 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
527 | } |
|
|
528 | break; |
|
|
529 | |
|
|
530 | case DT_WCS_LEN: |
|
|
531 | { |
|
|
532 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
533 | int wlen = va_arg (ap, int); |
|
|
534 | |
|
|
535 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
536 | } |
|
|
537 | break; |
|
|
538 | |
|
|
539 | case DT_XEVENT: |
|
|
540 | { |
|
|
541 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
542 | HV *hv = newHV (); |
|
|
543 | |
|
|
544 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
545 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
546 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
|
|
547 | # undef set |
|
|
548 | |
|
|
549 | setiv (type, xe->type); |
|
|
550 | setiv (send_event, xe->xany.send_event); |
|
|
551 | setiv (serial, xe->xany.serial); |
|
|
552 | |
|
|
553 | switch (xe->type) |
|
|
554 | { |
|
|
555 | case KeyPress: |
|
|
556 | case KeyRelease: |
|
|
557 | case ButtonPress: |
|
|
558 | case ButtonRelease: |
|
|
559 | case MotionNotify: |
|
|
560 | setuv (window, xe->xmotion.window); |
|
|
561 | setuv (root, xe->xmotion.root); |
|
|
562 | setuv (subwindow, xe->xmotion.subwindow); |
|
|
563 | setuv (time, xe->xmotion.time); |
|
|
564 | setiv (x, xe->xmotion.x); |
|
|
565 | setiv (y, xe->xmotion.y); |
|
|
566 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
567 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
568 | setiv (x_root, xe->xmotion.x_root); |
|
|
569 | setiv (y_root, xe->xmotion.y_root); |
|
|
570 | setuv (state, xe->xmotion.state); |
|
|
571 | |
|
|
572 | switch (xe->type) |
|
|
573 | { |
|
|
574 | case KeyPress: |
|
|
575 | case KeyRelease: |
|
|
576 | setuv (keycode, xe->xkey.keycode); |
|
|
577 | break; |
|
|
578 | |
|
|
579 | case ButtonPress: |
|
|
580 | case ButtonRelease: |
|
|
581 | setuv (button, xe->xbutton.button); |
|
|
582 | break; |
|
|
583 | |
|
|
584 | case MotionNotify: |
|
|
585 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
586 | break; |
|
|
587 | } |
|
|
588 | |
|
|
589 | break; |
|
|
590 | |
|
|
591 | case MapNotify: |
|
|
592 | case UnmapNotify: |
|
|
593 | case ConfigureNotify: |
|
|
594 | setuv (event, xe->xconfigure.event); |
|
|
595 | setuv (window, xe->xconfigure.window); |
|
|
596 | |
|
|
597 | switch (xe->type) |
|
|
598 | { |
|
|
599 | case ConfigureNotify: |
|
|
600 | setiv (x, xe->xconfigure.x); |
|
|
601 | setiv (y, xe->xconfigure.y); |
|
|
602 | setiv (width, xe->xconfigure.width); |
|
|
603 | setiv (height, xe->xconfigure.height); |
|
|
604 | setuv (above, xe->xconfigure.above); |
|
|
605 | break; |
|
|
606 | } |
|
|
607 | |
|
|
608 | break; |
|
|
609 | } |
|
|
610 | |
|
|
611 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
612 | } |
|
|
613 | break; |
|
|
614 | |
|
|
615 | case DT_END: |
|
|
616 | goto call; |
|
|
617 | |
|
|
618 | default: |
|
|
619 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
620 | } |
|
|
621 | } |
|
|
622 | |
|
|
623 | call: |
|
|
624 | va_end (ap); |
|
|
625 | |
|
|
626 | PUTBACK; |
|
|
627 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
628 | SPAGAIN; |
|
|
629 | |
|
|
630 | if (count) |
|
|
631 | { |
|
|
632 | SV *status = POPs; |
|
|
633 | count = SvTRUE (status); |
|
|
634 | } |
|
|
635 | |
|
|
636 | PUTBACK; |
|
|
637 | FREETMPS; |
|
|
638 | LEAVE; |
|
|
639 | |
|
|
640 | if (SvTRUE (ERRSV)) |
|
|
641 | { |
|
|
642 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
643 | ungrab (term); // better lose the grab than the session |
|
|
644 | } |
|
|
645 | |
|
|
646 | event_consumed = !!count; |
|
|
647 | } |
|
|
648 | catch (...) |
|
|
649 | { |
|
|
650 | swap (perl_environ, environ); |
|
|
651 | throw; |
|
|
652 | } |
|
|
653 | else |
|
|
654 | event_consumed = false; |
|
|
655 | |
|
|
656 | // post-handling of some events |
|
|
657 | if (htype == HOOK_REFRESH_BEGIN) |
|
|
658 | { |
|
|
659 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
660 | |
|
|
661 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
662 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
|
|
663 | } |
425 | else if (htype == HOOK_DESTROY) |
664 | else if (htype == HOOK_DESTROY) |
426 | { |
665 | { |
427 | // handled later |
666 | clearSVptr ((SV *)term->perl.self); |
|
|
667 | SvREFCNT_dec ((SV *)term->perl.self); |
428 | } |
668 | } |
429 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
430 | { |
|
|
431 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
|
|
432 | |
669 | |
433 | if (HvKEYS (hv)) |
670 | swap (perl_environ, environ); |
434 | { |
|
|
435 | hv_iterinit (hv); |
|
|
436 | |
671 | |
437 | while (HE *he = hv_iternext (hv)) |
672 | return event_consumed; |
438 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
439 | } |
|
|
440 | } |
|
|
441 | else if (!should_invoke [htype]) |
|
|
442 | return false; |
|
|
443 | |
|
|
444 | dSP; |
|
|
445 | va_list ap; |
|
|
446 | |
|
|
447 | va_start (ap, htype); |
|
|
448 | |
|
|
449 | ENTER; |
|
|
450 | SAVETMPS; |
|
|
451 | |
|
|
452 | PUSHMARK (SP); |
|
|
453 | |
|
|
454 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
455 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
456 | |
|
|
457 | for (;;) { |
|
|
458 | data_type dt = (data_type)va_arg (ap, int); |
|
|
459 | |
|
|
460 | switch (dt) |
|
|
461 | { |
|
|
462 | case DT_INT: |
|
|
463 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
464 | break; |
|
|
465 | |
|
|
466 | case DT_LONG: |
|
|
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
468 | break; |
|
|
469 | |
|
|
470 | case DT_STR: |
|
|
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
472 | break; |
|
|
473 | |
|
|
474 | case DT_STR_LEN: |
|
|
475 | { |
|
|
476 | char *str = va_arg (ap, char *); |
|
|
477 | int len = va_arg (ap, int); |
|
|
478 | |
|
|
479 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
480 | } |
|
|
481 | break; |
|
|
482 | |
|
|
483 | case DT_WCS_LEN: |
|
|
484 | { |
|
|
485 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
486 | int wlen = va_arg (ap, int); |
|
|
487 | |
|
|
488 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
489 | } |
|
|
490 | break; |
|
|
491 | |
|
|
492 | case DT_XEVENT: |
|
|
493 | { |
|
|
494 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
495 | HV *hv = newHV (); |
|
|
496 | |
|
|
497 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
498 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
499 | # undef set |
|
|
500 | |
|
|
501 | setiv (type, xe->type); |
|
|
502 | setiv (send_event, xe->xany.send_event); |
|
|
503 | setiv (serial, xe->xany.serial); |
|
|
504 | |
|
|
505 | switch (xe->type) |
|
|
506 | { |
|
|
507 | case KeyPress: |
|
|
508 | case KeyRelease: |
|
|
509 | case ButtonPress: |
|
|
510 | case ButtonRelease: |
|
|
511 | case MotionNotify: |
|
|
512 | setiv (time, xe->xmotion.time); |
|
|
513 | setiv (x, xe->xmotion.x); |
|
|
514 | setiv (y, xe->xmotion.y); |
|
|
515 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
516 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
517 | setiv (x_root, xe->xmotion.x_root); |
|
|
518 | setiv (y_root, xe->xmotion.y_root); |
|
|
519 | setiv (state, xe->xmotion.state); |
|
|
520 | break; |
|
|
521 | } |
|
|
522 | |
|
|
523 | switch (xe->type) |
|
|
524 | { |
|
|
525 | case KeyPress: |
|
|
526 | case KeyRelease: |
|
|
527 | setiv (keycode, xe->xkey.keycode); |
|
|
528 | break; |
|
|
529 | |
|
|
530 | case ButtonPress: |
|
|
531 | case ButtonRelease: |
|
|
532 | setiv (button, xe->xbutton.button); |
|
|
533 | break; |
|
|
534 | |
|
|
535 | case MotionNotify: |
|
|
536 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
537 | break; |
|
|
538 | } |
|
|
539 | |
|
|
540 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
541 | } |
|
|
542 | break; |
|
|
543 | |
|
|
544 | case DT_END: |
|
|
545 | { |
|
|
546 | va_end (ap); |
|
|
547 | |
|
|
548 | PUTBACK; |
|
|
549 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
550 | SPAGAIN; |
|
|
551 | |
|
|
552 | if (count) |
|
|
553 | { |
|
|
554 | SV *status = POPs; |
|
|
555 | count = SvTRUE (status); |
|
|
556 | } |
|
|
557 | |
|
|
558 | PUTBACK; |
|
|
559 | FREETMPS; |
|
|
560 | LEAVE; |
|
|
561 | |
|
|
562 | if (SvTRUE (ERRSV)) |
|
|
563 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
564 | |
|
|
565 | if (htype == HOOK_DESTROY) |
|
|
566 | { |
|
|
567 | clearSVptr ((SV *)term->self); |
|
|
568 | SvREFCNT_dec ((SV *)term->self); |
|
|
569 | } |
|
|
570 | |
|
|
571 | return count; |
|
|
572 | } |
|
|
573 | |
|
|
574 | default: |
|
|
575 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
576 | } |
|
|
577 | } |
|
|
578 | } |
673 | } |
579 | |
674 | |
580 | ///////////////////////////////////////////////////////////////////////////// |
675 | ///////////////////////////////////////////////////////////////////////////// |
581 | |
676 | |
582 | MODULE = urxvt PACKAGE = urxvt |
677 | MODULE = urxvt PACKAGE = urxvt |
583 | |
678 | |
584 | PROTOTYPES: ENABLE |
679 | PROTOTYPES: ENABLE |
585 | |
680 | |
586 | BOOT: |
681 | BOOT: |
587 | { |
682 | { |
588 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
683 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
684 | sv_setsv (get_sv ("urxvt::RESNAME", 1), newSVpvn (RESNAME, sizeof (RESNAME) - 1)); |
|
|
685 | sv_setsv (get_sv ("urxvt::RESCLASS", 1), newSVpvn (RESCLASS, sizeof (RESCLASS) - 1)); |
|
|
686 | sv_setsv (get_sv ("urxvt::RXVTNAME", 1), newSVpvn (RXVTNAME, sizeof (RXVTNAME) - 1)); |
|
|
687 | |
589 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
688 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
590 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
689 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
591 | # include "hookinc.h" |
690 | # include "hookinc.h" |
592 | # undef def |
691 | # undef def |
593 | |
692 | |
|
|
693 | HV *option = get_hv ("urxvt::OPTION", 1); |
|
|
694 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
|
|
695 | # define nodef(name) |
|
|
696 | # include "optinc.h" |
|
|
697 | # undef nodef |
|
|
698 | # undef def |
|
|
699 | |
|
|
700 | HV *stash = gv_stashpv ("urxvt", 1); |
|
|
701 | struct { |
|
|
702 | const char *name; |
|
|
703 | IV iv; |
|
|
704 | } *civ, const_iv[] = { |
|
|
705 | # define const_iv(name) { # name, (IV)name } |
594 | export_const (DEFAULT_RSTYLE); |
706 | const_iv (DEFAULT_RSTYLE), |
595 | export_const (OVERLAY_RSTYLE); |
707 | const_iv (OVERLAY_RSTYLE), |
596 | export_const (RS_Bold); |
708 | const_iv (RS_Bold), |
597 | export_const (RS_Italic); |
709 | const_iv (RS_Italic), |
598 | export_const (RS_Blink); |
710 | const_iv (RS_Blink), |
599 | export_const (RS_RVid); |
711 | const_iv (RS_RVid), |
600 | export_const (RS_Uline); |
712 | const_iv (RS_Uline), |
601 | |
713 | |
602 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
714 | const_iv (CurrentTime), |
|
|
715 | const_iv (ShiftMask), |
|
|
716 | const_iv (LockMask), |
|
|
717 | const_iv (ControlMask), |
|
|
718 | const_iv (Mod1Mask), |
|
|
719 | const_iv (Mod2Mask), |
|
|
720 | const_iv (Mod3Mask), |
|
|
721 | const_iv (Mod4Mask), |
|
|
722 | const_iv (Mod5Mask), |
|
|
723 | const_iv (Button1Mask), |
|
|
724 | const_iv (Button2Mask), |
|
|
725 | const_iv (Button3Mask), |
|
|
726 | const_iv (Button4Mask), |
|
|
727 | const_iv (Button5Mask), |
|
|
728 | const_iv (AnyModifier), |
|
|
729 | |
|
|
730 | const_iv (EVENT_NONE), |
|
|
731 | const_iv (EVENT_READ), |
|
|
732 | const_iv (EVENT_WRITE), |
|
|
733 | |
|
|
734 | const_iv (NoEventMask), |
|
|
735 | const_iv (KeyPressMask), |
|
|
736 | const_iv (KeyReleaseMask), |
|
|
737 | const_iv (ButtonPressMask), |
|
|
738 | const_iv (ButtonReleaseMask), |
|
|
739 | const_iv (EnterWindowMask), |
|
|
740 | const_iv (LeaveWindowMask), |
|
|
741 | const_iv (PointerMotionMask), |
|
|
742 | const_iv (PointerMotionHintMask), |
|
|
743 | const_iv (Button1MotionMask), |
|
|
744 | const_iv (Button2MotionMask), |
|
|
745 | const_iv (Button3MotionMask), |
|
|
746 | const_iv (Button4MotionMask), |
|
|
747 | const_iv (Button5MotionMask), |
|
|
748 | const_iv (ButtonMotionMask), |
|
|
749 | const_iv (KeymapStateMask), |
|
|
750 | const_iv (ExposureMask), |
|
|
751 | const_iv (VisibilityChangeMask), |
|
|
752 | const_iv (StructureNotifyMask), |
|
|
753 | const_iv (ResizeRedirectMask), |
|
|
754 | const_iv (SubstructureNotifyMask), |
|
|
755 | const_iv (SubstructureRedirectMask), |
|
|
756 | const_iv (FocusChangeMask), |
|
|
757 | const_iv (PropertyChangeMask), |
|
|
758 | const_iv (ColormapChangeMask), |
|
|
759 | const_iv (OwnerGrabButtonMask), |
|
|
760 | |
|
|
761 | const_iv (KeyPress), |
|
|
762 | const_iv (KeyRelease), |
|
|
763 | const_iv (ButtonPress), |
|
|
764 | const_iv (ButtonRelease), |
|
|
765 | const_iv (MotionNotify), |
|
|
766 | const_iv (EnterNotify), |
|
|
767 | const_iv (LeaveNotify), |
|
|
768 | const_iv (FocusIn), |
|
|
769 | const_iv (FocusOut), |
|
|
770 | const_iv (KeymapNotify), |
|
|
771 | const_iv (Expose), |
|
|
772 | const_iv (GraphicsExpose), |
|
|
773 | const_iv (NoExpose), |
|
|
774 | const_iv (VisibilityNotify), |
|
|
775 | const_iv (CreateNotify), |
|
|
776 | const_iv (DestroyNotify), |
|
|
777 | const_iv (UnmapNotify), |
|
|
778 | const_iv (MapNotify), |
|
|
779 | const_iv (MapRequest), |
|
|
780 | const_iv (ReparentNotify), |
|
|
781 | const_iv (ConfigureNotify), |
|
|
782 | const_iv (ConfigureRequest), |
|
|
783 | const_iv (GravityNotify), |
|
|
784 | const_iv (ResizeRequest), |
|
|
785 | const_iv (CirculateNotify), |
|
|
786 | const_iv (CirculateRequest), |
|
|
787 | const_iv (PropertyNotify), |
|
|
788 | const_iv (SelectionClear), |
|
|
789 | const_iv (SelectionRequest), |
|
|
790 | const_iv (SelectionNotify), |
|
|
791 | const_iv (ColormapNotify), |
|
|
792 | const_iv (ClientMessage), |
|
|
793 | const_iv (MappingNotify), |
|
|
794 | }; |
|
|
795 | |
|
|
796 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); |
|
|
797 | civ-- > const_iv; ) |
|
|
798 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
603 | } |
799 | } |
|
|
800 | |
|
|
801 | void |
|
|
802 | warn (const char *msg) |
|
|
803 | CODE: |
|
|
804 | rxvt_warn ("%s", msg); |
|
|
805 | |
|
|
806 | void |
|
|
807 | fatal (const char *msg) |
|
|
808 | CODE: |
|
|
809 | rxvt_fatal ("%s", msg); |
|
|
810 | |
|
|
811 | void |
|
|
812 | _exit (int status) |
|
|
813 | |
|
|
814 | NV |
|
|
815 | NOW () |
|
|
816 | CODE: |
|
|
817 | RETVAL = NOW; |
|
|
818 | OUTPUT: |
|
|
819 | RETVAL |
|
|
820 | |
|
|
821 | int |
|
|
822 | GET_BASEFG (int rend) |
|
|
823 | CODE: |
|
|
824 | RETVAL = GET_BASEFG (rend); |
|
|
825 | OUTPUT: |
|
|
826 | RETVAL |
|
|
827 | |
|
|
828 | int |
|
|
829 | GET_BASEBG (int rend) |
|
|
830 | CODE: |
|
|
831 | RETVAL = GET_BASEBG (rend); |
|
|
832 | OUTPUT: |
|
|
833 | RETVAL |
|
|
834 | |
|
|
835 | int |
|
|
836 | SET_FGCOLOR (int rend, int new_color) |
|
|
837 | CODE: |
|
|
838 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
839 | OUTPUT: |
|
|
840 | RETVAL |
|
|
841 | |
|
|
842 | int |
|
|
843 | SET_BGCOLOR (int rend, int new_color) |
|
|
844 | CODE: |
|
|
845 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
846 | OUTPUT: |
|
|
847 | RETVAL |
|
|
848 | |
|
|
849 | int |
|
|
850 | GET_CUSTOM (int rend) |
|
|
851 | CODE: |
|
|
852 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
853 | OUTPUT: |
|
|
854 | RETVAL |
|
|
855 | |
|
|
856 | int |
|
|
857 | SET_CUSTOM (int rend, int new_value) |
|
|
858 | CODE: |
|
|
859 | { |
|
|
860 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
861 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
862 | |
|
|
863 | RETVAL = (rend & ~RS_customMask) |
|
|
864 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
865 | } |
|
|
866 | OUTPUT: |
|
|
867 | RETVAL |
|
|
868 | |
|
|
869 | MODULE = urxvt PACKAGE = urxvt::term |
604 | |
870 | |
605 | SV * |
871 | SV * |
606 | new (...) |
872 | _new (...) |
607 | CODE: |
873 | CODE: |
608 | { |
874 | { |
|
|
875 | if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV) |
|
|
876 | croak ("first argument to urxvt::term->_new must be arrayref"); |
|
|
877 | |
|
|
878 | rxvt_term *term = new rxvt_term; |
|
|
879 | |
609 | stringvec *argv = new stringvec; |
880 | term->argv = new stringvec; |
|
|
881 | term->envv = new stringvec; |
|
|
882 | |
|
|
883 | for (int i = 1; i < items; i++) |
|
|
884 | term->argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
885 | |
|
|
886 | AV *envv = (AV *)SvRV (ST (0)); |
|
|
887 | for (int i = AvFILL (envv) + 1; i--; ) |
|
|
888 | term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1)))); |
|
|
889 | |
|
|
890 | term->envv->push_back (0); |
|
|
891 | |
610 | bool success; |
892 | bool success; |
611 | |
|
|
612 | for (int i = 0; i < items ;i++) |
|
|
613 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
614 | |
|
|
615 | rxvt_term *term = new rxvt_term; |
|
|
616 | |
|
|
617 | term->argv = argv; |
|
|
618 | |
893 | |
619 | try |
894 | try |
620 | { |
895 | { |
621 | if (!term->init (argv->size (), argv->begin ())) |
896 | success = term->init (term->argv->size (), term->argv->begin ()); |
622 | term = 0; |
|
|
623 | } |
897 | } |
624 | catch (const class rxvt_failure_exception &e) |
898 | catch (const class rxvt_failure_exception &e) |
625 | { |
899 | { |
|
|
900 | success = false; |
|
|
901 | } |
|
|
902 | |
|
|
903 | if (!success) |
|
|
904 | { |
626 | term->destroy (); |
905 | term->destroy (); |
627 | croak ("exception caught while initializing new terminal instance"); |
906 | croak ("error while initializing new terminal instance"); |
628 | } |
907 | } |
629 | |
908 | |
630 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
909 | RETVAL = term && term->perl.self |
|
|
910 | ? newSVterm (term) : &PL_sv_undef; |
631 | } |
911 | } |
632 | OUTPUT: |
912 | OUTPUT: |
633 | RETVAL |
913 | RETVAL |
634 | |
914 | |
635 | void |
915 | void |
636 | set_should_invoke (int htype, int value) |
916 | rxvt_term::destroy () |
|
|
917 | |
|
|
918 | #if ENABLE_PERL_FRILLS |
|
|
919 | |
|
|
920 | void |
|
|
921 | rxvt_term::XListProperties (U32 window) |
637 | CODE: |
922 | PPCODE: |
638 | rxvt_perl.should_invoke [htype] = value; |
923 | { |
|
|
924 | int count; |
|
|
925 | Atom *props = XListProperties (THIS->display->display, (Window)window, &count); |
639 | |
926 | |
|
|
927 | EXTEND (SP, count); |
|
|
928 | while (count--) |
|
|
929 | PUSHs (newSVuv ((U32)props [count])); |
|
|
930 | |
|
|
931 | XFree (props); |
|
|
932 | } |
|
|
933 | |
640 | void |
934 | void |
641 | warn (const char *msg) |
935 | rxvt_term::XGetWindowProperty (U32 window, U32 property) |
642 | CODE: |
936 | PPCODE: |
643 | rxvt_warn ("%s", msg); |
937 | { |
|
|
938 | Atom type; |
|
|
939 | int format; |
|
|
940 | unsigned long nitems; |
|
|
941 | unsigned long bytes_after; |
|
|
942 | unsigned char *prop; |
|
|
943 | XGetWindowProperty (THIS->display->display, (Window)window, (Atom)property, |
|
|
944 | 0, 1<<30, 0, AnyPropertyType, |
|
|
945 | &type, &format, &nitems, &bytes_after, &prop); |
|
|
946 | if (type != None) |
|
|
947 | { |
|
|
948 | EXTEND (SP, 3); |
|
|
949 | PUSHs (newSVuv ((U32)type)); |
|
|
950 | PUSHs (newSViv (format)); |
|
|
951 | PUSHs (newSVpvn ((char *)prop, nitems * format / 8)); |
|
|
952 | XFree (prop); |
|
|
953 | } |
|
|
954 | } |
644 | |
955 | |
645 | void |
956 | void |
646 | fatal (const char *msg) |
957 | rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data) |
647 | CODE: |
958 | CODE: |
648 | rxvt_fatal ("%s", msg); |
959 | { |
|
|
960 | STRLEN len; |
|
|
961 | char *data_ = SvPVbyte (data, len); |
649 | |
962 | |
650 | NV |
963 | XChangeProperty (THIS->display->display, (Window)window, (Atom)property, |
651 | NOW () |
964 | type, format, PropModeReplace, |
|
|
965 | (unsigned char *)data, len * 8 / format); |
|
|
966 | } |
|
|
967 | |
|
|
968 | void |
|
|
969 | rxvt_term::XDeleteProperty (U32 window, U32 property) |
652 | CODE: |
970 | CODE: |
|
|
971 | XDeleteProperty (THIS->display->display, (Window)window, (Atom)property); |
|
|
972 | |
|
|
973 | U32 |
|
|
974 | rxvt_term::DefaultRootWindow () |
|
|
975 | CODE: |
|
|
976 | RETVAL = (U32)THIS->display->root; |
|
|
977 | OUTPUT: |
653 | RETVAL = NOW; |
978 | RETVAL |
654 | OUTPUT: |
|
|
655 | RETVAL |
|
|
656 | |
979 | |
657 | int |
980 | U32 |
658 | GET_BASEFG (int rend) |
981 | rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height) |
659 | CODE: |
982 | CODE: |
660 | RETVAL = GET_BASEFG (rend); |
983 | RETVAL = XCreateSimpleWindow (THIS->display->display, (Window)parent, |
|
|
984 | x, y, width, height, 0, |
|
|
985 | THIS->pix_colors_focused[Color_border], |
|
|
986 | THIS->pix_colors_focused[Color_border]); |
661 | OUTPUT: |
987 | OUTPUT: |
662 | RETVAL |
988 | RETVAL |
663 | |
989 | |
664 | int |
990 | void |
665 | GET_BASEBG (int rend) |
991 | rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0) |
666 | CODE: |
992 | CODE: |
667 | RETVAL = GET_BASEBG (rend); |
993 | XReparentWindow (THIS->display->display, (Window)window, (Window)parent, x, y); |
|
|
994 | |
|
|
995 | void |
|
|
996 | rxvt_term::XMapWindow (U32 window) |
|
|
997 | CODE: |
|
|
998 | XMapWindow (THIS->display->display, (Window)window); |
|
|
999 | |
|
|
1000 | void |
|
|
1001 | rxvt_term::XUnmapWindow (U32 window) |
|
|
1002 | CODE: |
|
|
1003 | XUnmapWindow (THIS->display->display, (Window)window); |
|
|
1004 | |
|
|
1005 | #endif |
|
|
1006 | |
|
|
1007 | void |
|
|
1008 | rxvt_term::set_should_invoke (int htype, int inc) |
|
|
1009 | CODE: |
|
|
1010 | THIS->perl.should_invoke [htype] += inc; |
|
|
1011 | |
|
|
1012 | void |
|
|
1013 | rxvt_term::grab_button (int button, U32 modifiers) |
|
|
1014 | CODE: |
|
|
1015 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
|
|
1016 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
1017 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
1018 | |
|
|
1019 | bool |
|
|
1020 | rxvt_term::grab (U32 eventtime, int sync = 0) |
|
|
1021 | CODE: |
|
|
1022 | { |
|
|
1023 | int mode = sync ? GrabModeSync : GrabModeAsync; |
|
|
1024 | |
|
|
1025 | THIS->perl.grabtime = 0; |
|
|
1026 | |
|
|
1027 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
1028 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
1029 | mode, mode, None, GRAB_CURSOR, eventtime)) |
|
|
1030 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
|
|
1031 | THIS->perl.grabtime = eventtime; |
|
|
1032 | else |
|
|
1033 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
1034 | |
|
|
1035 | RETVAL = !!THIS->perl.grabtime; |
|
|
1036 | } |
668 | OUTPUT: |
1037 | OUTPUT: |
669 | RETVAL |
1038 | RETVAL |
670 | |
1039 | |
671 | int |
|
|
672 | SET_FGCOLOR (int rend, int new_color) |
|
|
673 | CODE: |
|
|
674 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
675 | OUTPUT: |
|
|
676 | RETVAL |
|
|
677 | |
|
|
678 | int |
|
|
679 | SET_BGCOLOR (int rend, int new_color) |
|
|
680 | CODE: |
|
|
681 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
682 | OUTPUT: |
|
|
683 | RETVAL |
|
|
684 | |
|
|
685 | int |
|
|
686 | GET_CUSTOM (int rend) |
|
|
687 | CODE: |
|
|
688 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
689 | OUTPUT: |
|
|
690 | RETVAL |
|
|
691 | |
|
|
692 | int |
|
|
693 | SET_CUSTOM (int rend, int new_value) |
|
|
694 | CODE: |
|
|
695 | { |
|
|
696 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
697 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
698 | |
|
|
699 | RETVAL = (rend & ~RS_customMask) |
|
|
700 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
701 | } |
|
|
702 | OUTPUT: |
|
|
703 | RETVAL |
|
|
704 | |
|
|
705 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
706 | |
|
|
707 | void |
1040 | void |
708 | rxvt_term::destroy () |
1041 | rxvt_term::allow_events_async () |
|
|
1042 | CODE: |
|
|
1043 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
|
|
1044 | |
|
|
1045 | void |
|
|
1046 | rxvt_term::allow_events_sync () |
|
|
1047 | CODE: |
|
|
1048 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
|
|
1049 | |
|
|
1050 | void |
|
|
1051 | rxvt_term::allow_events_replay () |
|
|
1052 | CODE: |
|
|
1053 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
|
|
1054 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
|
|
1055 | |
|
|
1056 | void |
|
|
1057 | rxvt_term::ungrab () |
|
|
1058 | CODE: |
|
|
1059 | ungrab (THIS); |
709 | |
1060 | |
710 | int |
1061 | int |
711 | rxvt_term::strwidth (SV *str) |
1062 | rxvt_term::strwidth (SV *str) |
712 | CODE: |
1063 | CODE: |
713 | { |
1064 | { |
… | |
… | |
755 | free (wstr); |
1106 | free (wstr); |
756 | } |
1107 | } |
757 | OUTPUT: |
1108 | OUTPUT: |
758 | RETVAL |
1109 | RETVAL |
759 | |
1110 | |
760 | # very portable, especially on objects as opposed to pods |
1111 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
761 | #define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0) |
|
|
762 | |
1112 | |
763 | #define TERM_OFFSET_width TERM_OFFSET(width) |
1113 | #define TERM_OFFSET_width TERM_OFFSET(width) |
764 | #define TERM_OFFSET_height TERM_OFFSET(height) |
1114 | #define TERM_OFFSET_height TERM_OFFSET(height) |
765 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
1115 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
766 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
1116 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
… | |
… | |
769 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1119 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
770 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1120 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
771 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1121 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
772 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1122 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
773 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1123 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
774 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
1124 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
775 | |
1125 | |
776 | int |
1126 | int |
777 | rxvt_term::width () |
1127 | rxvt_term::width () |
778 | ALIAS: |
1128 | ALIAS: |
779 | width = TERM_OFFSET_width |
1129 | width = TERM_OFFSET_width |
… | |
… | |
785 | ncol = TERM_OFFSET_ncol |
1135 | ncol = TERM_OFFSET_ncol |
786 | focus = TERM_OFFSET_focus |
1136 | focus = TERM_OFFSET_focus |
787 | mapped = TERM_OFFSET_mapped |
1137 | mapped = TERM_OFFSET_mapped |
788 | saveLines = TERM_OFFSET_saveLines |
1138 | saveLines = TERM_OFFSET_saveLines |
789 | total_rows = TERM_OFFSET_total_rows |
1139 | total_rows = TERM_OFFSET_total_rows |
790 | nsaved = TERM_OFFSET_nsaved |
1140 | top_row = TERM_OFFSET_top_row |
791 | CODE: |
1141 | CODE: |
792 | RETVAL = *(int *)((char *)THIS + ix); |
1142 | RETVAL = *(int *)((char *)THIS + ix); |
793 | OUTPUT: |
1143 | OUTPUT: |
|
|
1144 | RETVAL |
|
|
1145 | |
|
|
1146 | unsigned int |
|
|
1147 | rxvt_term::ModLevel3Mask () |
|
|
1148 | ALIAS: |
|
|
1149 | ModLevel3Mask = 0 |
|
|
1150 | ModMetaMask = 1 |
|
|
1151 | ModNumLockMask = 2 |
|
|
1152 | CODE: |
|
|
1153 | switch (ix) |
|
|
1154 | { |
|
|
1155 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
|
|
1156 | case 1: RETVAL = THIS->ModMetaMask; break; |
|
|
1157 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
1158 | } |
|
|
1159 | OUTPUT: |
|
|
1160 | RETVAL |
|
|
1161 | |
|
|
1162 | char * |
|
|
1163 | rxvt_term::display_id () |
|
|
1164 | ALIAS: |
|
|
1165 | display_id = 0 |
|
|
1166 | locale = 1 |
|
|
1167 | CODE: |
|
|
1168 | switch (ix) |
|
|
1169 | { |
|
|
1170 | case 0: RETVAL = THIS->display->id; break; |
|
|
1171 | case 1: RETVAL = THIS->locale; break; |
|
|
1172 | } |
|
|
1173 | OUTPUT: |
|
|
1174 | RETVAL |
|
|
1175 | |
|
|
1176 | SV * |
|
|
1177 | rxvt_term::_env () |
|
|
1178 | CODE: |
|
|
1179 | { |
|
|
1180 | if (THIS->envv) |
|
|
1181 | { |
|
|
1182 | AV *av = newAV (); |
|
|
1183 | |
|
|
1184 | for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i) |
|
|
1185 | if (*i) |
|
|
1186 | av_push (av, newSVpv (*i, 0)); |
|
|
1187 | |
|
|
1188 | RETVAL = newRV_noinc ((SV *)av); |
|
|
1189 | } |
|
|
1190 | else |
|
|
1191 | RETVAL = &PL_sv_undef; |
|
|
1192 | } |
|
|
1193 | OUTPUT: |
|
|
1194 | RETVAL |
|
|
1195 | |
|
|
1196 | int |
|
|
1197 | rxvt_term::pty_ev_events (int events = EVENT_UNDEF) |
|
|
1198 | CODE: |
|
|
1199 | RETVAL = THIS->pty_ev.events; |
|
|
1200 | if (events != EVENT_UNDEF) |
|
|
1201 | THIS->pty_ev.set (events); |
|
|
1202 | OUTPUT: |
794 | RETVAL |
1203 | RETVAL |
795 | |
1204 | |
796 | U32 |
1205 | U32 |
797 | rxvt_term::parent () |
1206 | rxvt_term::parent () |
798 | CODE: |
1207 | CODE: |
… | |
… | |
805 | CODE: |
1214 | CODE: |
806 | RETVAL = (U32)THIS->vt; |
1215 | RETVAL = (U32)THIS->vt; |
807 | OUTPUT: |
1216 | OUTPUT: |
808 | RETVAL |
1217 | RETVAL |
809 | |
1218 | |
|
|
1219 | void |
|
|
1220 | rxvt_term::vt_emask_add (U32 emask) |
|
|
1221 | CODE: |
|
|
1222 | THIS->vt_emask_perl |= emask; |
|
|
1223 | THIS->vt_select_input (); |
|
|
1224 | |
810 | U32 |
1225 | U32 |
811 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
1226 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
812 | CODE: |
1227 | CODE: |
813 | { |
|
|
814 | RETVAL = THIS->rstyle; |
1228 | RETVAL = THIS->rstyle; |
815 | THIS->rstyle = new_rstyle; |
1229 | THIS->rstyle = new_rstyle; |
816 | } |
|
|
817 | OUTPUT: |
1230 | OUTPUT: |
818 | RETVAL |
1231 | RETVAL |
819 | |
1232 | |
820 | int |
1233 | int |
821 | rxvt_term::view_start (int newval = -1) |
1234 | rxvt_term::view_start (int newval = 1) |
|
|
1235 | PROTOTYPE: $;$ |
822 | CODE: |
1236 | CODE: |
823 | { |
1237 | { |
824 | RETVAL = THIS->view_start; |
1238 | RETVAL = THIS->view_start; |
825 | |
1239 | |
826 | if (newval >= 0) |
1240 | if (newval <= 0) |
827 | { |
1241 | THIS->scr_changeview (max (newval, THIS->top_row)); |
828 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
829 | THIS->scr_changeview (RETVAL); |
|
|
830 | } |
|
|
831 | } |
1242 | } |
832 | OUTPUT: |
1243 | OUTPUT: |
833 | RETVAL |
1244 | RETVAL |
834 | |
1245 | |
835 | void |
1246 | void |
… | |
… | |
839 | |
1250 | |
840 | void |
1251 | void |
841 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1252 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
842 | PPCODE: |
1253 | PPCODE: |
843 | { |
1254 | { |
844 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1255 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
845 | XSRETURN_EMPTY; |
1256 | XSRETURN_EMPTY; |
846 | |
1257 | |
847 | line_t &l = ROW(row_number); |
1258 | line_t &l = ROW(row_number); |
848 | |
1259 | |
849 | if (GIMME_V != G_VOID) |
1260 | if (GIMME_V != G_VOID) |
… | |
… | |
882 | |
1293 | |
883 | void |
1294 | void |
884 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
1295 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
885 | PPCODE: |
1296 | PPCODE: |
886 | { |
1297 | { |
887 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1298 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
888 | XSRETURN_EMPTY; |
1299 | XSRETURN_EMPTY; |
889 | |
1300 | |
890 | line_t &l = ROW(row_number); |
1301 | line_t &l = ROW(row_number); |
891 | |
1302 | |
892 | if (GIMME_V != G_VOID) |
1303 | if (GIMME_V != G_VOID) |
… | |
… | |
904 | { |
1315 | { |
905 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1316 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
906 | croak ("new_rend must be arrayref"); |
1317 | croak ("new_rend must be arrayref"); |
907 | |
1318 | |
908 | AV *av = (AV *)SvRV (new_rend); |
1319 | AV *av = (AV *)SvRV (new_rend); |
909 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
1320 | int len = min (AvFILL (av) + 1 - start_ofs, max_len); |
910 | |
1321 | |
911 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1322 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
912 | croak ("new_rend array extends beyond horizontal margins"); |
1323 | croak ("new_rend array extends beyond horizontal margins"); |
913 | |
1324 | |
914 | for (int col = start_col; col < start_col + len; col++) |
1325 | for (int col = start_col; col < start_col + len; col++) |
… | |
… | |
922 | |
1333 | |
923 | int |
1334 | int |
924 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1335 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
925 | CODE: |
1336 | CODE: |
926 | { |
1337 | { |
927 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1338 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
928 | XSRETURN_EMPTY; |
1339 | XSRETURN_EMPTY; |
929 | |
1340 | |
930 | line_t &l = ROW(row_number); |
1341 | line_t &l = ROW(row_number); |
931 | RETVAL = l.l; |
1342 | RETVAL = l.l; |
932 | |
1343 | |
… | |
… | |
938 | |
1349 | |
939 | bool |
1350 | bool |
940 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
1351 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
941 | CODE: |
1352 | CODE: |
942 | { |
1353 | { |
943 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1354 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
944 | XSRETURN_EMPTY; |
1355 | XSRETURN_EMPTY; |
945 | |
1356 | |
946 | line_t &l = ROW(row_number); |
1357 | line_t &l = ROW(row_number); |
947 | RETVAL = l.is_longer (); |
1358 | RETVAL = l.is_longer (); |
948 | |
1359 | |
… | |
… | |
1065 | else |
1476 | else |
1066 | THIS->rs [index] = 0; |
1477 | THIS->rs [index] = 0; |
1067 | } |
1478 | } |
1068 | } |
1479 | } |
1069 | |
1480 | |
|
|
1481 | const char * |
|
|
1482 | rxvt_term::x_resource (const char *name) |
|
|
1483 | |
|
|
1484 | bool |
|
|
1485 | rxvt_term::option (U32 optval, int set = -1) |
|
|
1486 | CODE: |
|
|
1487 | { |
|
|
1488 | RETVAL = THIS->options & optval; |
|
|
1489 | |
|
|
1490 | if (set >= 0) |
|
|
1491 | { |
|
|
1492 | if (set) |
|
|
1493 | THIS->options |= optval; |
|
|
1494 | else |
|
|
1495 | THIS->options &= ~optval; |
|
|
1496 | |
|
|
1497 | switch (optval) |
|
|
1498 | { |
|
|
1499 | case Opt_skipBuiltinGlyphs: |
|
|
1500 | THIS->set_fonts (); |
|
|
1501 | THIS->scr_remap_chars (); |
|
|
1502 | THIS->scr_touch (true); |
|
|
1503 | THIS->want_refresh = 1; |
|
|
1504 | break; |
|
|
1505 | |
|
|
1506 | case Opt_cursorUnderline: |
|
|
1507 | THIS->want_refresh = 1; |
|
|
1508 | break; |
|
|
1509 | |
|
|
1510 | # case Opt_scrollBar_floating: |
|
|
1511 | # case Opt_scrollBar_right: |
|
|
1512 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
|
|
1513 | # break; |
|
|
1514 | } |
|
|
1515 | } |
|
|
1516 | } |
|
|
1517 | OUTPUT: |
|
|
1518 | RETVAL |
|
|
1519 | |
|
|
1520 | bool |
|
|
1521 | rxvt_term::parse_keysym (char *keysym, char *str) |
|
|
1522 | CODE: |
|
|
1523 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
|
|
1524 | THIS->keyboard->register_done (); |
|
|
1525 | OUTPUT: |
|
|
1526 | RETVAL |
|
|
1527 | |
1070 | void |
1528 | void |
1071 | rxvt_term::cur (...) |
1529 | rxvt_term::screen_cur (...) |
1072 | PROTOTYPE: $;$$ |
1530 | PROTOTYPE: $;$$ |
1073 | ALIAS: |
1531 | ALIAS: |
1074 | screen_cur = 0 |
1532 | screen_cur = 0 |
1075 | selection_beg = 1 |
1533 | selection_beg = 1 |
1076 | selection_end = 2 |
1534 | selection_end = 2 |
… | |
… | |
1089 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1547 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1090 | } |
1548 | } |
1091 | |
1549 | |
1092 | if (items == 3) |
1550 | if (items == 3) |
1093 | { |
1551 | { |
1094 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1552 | rc.row = SvIV (ST (1)); |
1095 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1553 | rc.col = SvIV (ST (2)); |
|
|
1554 | |
|
|
1555 | if (ix == 2 && rc.col == 0) |
|
|
1556 | { |
|
|
1557 | rc.row--; |
|
|
1558 | rc.col = THIS->ncol; |
|
|
1559 | } |
|
|
1560 | |
|
|
1561 | clamp_it (rc.col, 0, THIS->ncol); |
|
|
1562 | clamp_it (rc.row, THIS->top_row, THIS->nrow - 1); |
1096 | |
1563 | |
1097 | if (ix) |
1564 | if (ix) |
1098 | THIS->want_refresh = 1; |
1565 | THIS->want_refresh = 1; |
1099 | } |
1566 | } |
1100 | } |
1567 | } |
1101 | |
1568 | |
|
|
1569 | char |
|
|
1570 | rxvt_term::cur_charset () |
|
|
1571 | CODE: |
|
|
1572 | RETVAL = THIS->charsets [THIS->screen.charset]; |
|
|
1573 | OUTPUT: |
|
|
1574 | RETVAL |
|
|
1575 | |
|
|
1576 | #void |
|
|
1577 | #rxvt_term::selection_clear () |
|
|
1578 | |
|
|
1579 | void |
|
|
1580 | rxvt_term::selection_make (U32 eventtime, bool rect = false) |
|
|
1581 | CODE: |
|
|
1582 | THIS->selection.op = SELECTION_CONT; |
|
|
1583 | THIS->selection.rect = rect; |
|
|
1584 | THIS->selection_make (eventtime); |
|
|
1585 | |
1102 | int |
1586 | int |
1103 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
1587 | rxvt_term::selection_grab (U32 eventtime) |
1104 | |
1588 | |
1105 | void |
1589 | void |
1106 | rxvt_term::selection (SV *newtext = 0) |
1590 | rxvt_term::selection (SV *newtext = 0) |
1107 | PPCODE: |
1591 | PPCODE: |
1108 | { |
1592 | { |
1109 | if (GIMME_V != G_VOID) |
1593 | if (GIMME_V != G_VOID) |
|
|
1594 | XPUSHs (THIS->selection.text |
1110 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
1595 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
|
|
1596 | : &PL_sv_undef); |
1111 | |
1597 | |
1112 | if (newtext) |
1598 | if (newtext) |
1113 | { |
1599 | { |
1114 | free (THIS->selection.text); |
1600 | free (THIS->selection.text); |
1115 | |
1601 | |
1116 | THIS->selection.text = sv2wcs (newtext); |
1602 | THIS->selection.text = sv2wcs (newtext); |
1117 | THIS->selection.len = wcslen (THIS->selection.text); |
1603 | THIS->selection.len = wcslen (THIS->selection.text); |
1118 | } |
1604 | } |
1119 | } |
1605 | } |
|
|
1606 | |
|
|
1607 | void |
|
|
1608 | 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) |
|
|
1609 | |
|
|
1610 | void |
|
|
1611 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
|
|
1612 | |
|
|
1613 | void |
|
|
1614 | rxvt_term::scr_bell () |
1120 | |
1615 | |
1121 | void |
1616 | void |
1122 | rxvt_term::scr_add_lines (SV *string) |
1617 | rxvt_term::scr_add_lines (SV *string) |
1123 | CODE: |
1618 | CODE: |
1124 | { |
1619 | { |
… | |
… | |
1146 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1641 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1147 | |
1642 | |
1148 | THIS->cmdbuf_ptr = str; |
1643 | THIS->cmdbuf_ptr = str; |
1149 | THIS->cmdbuf_endp = str + len; |
1644 | THIS->cmdbuf_endp = str + len; |
1150 | |
1645 | |
|
|
1646 | rxvt_push_locale (THIS->locale); |
1151 | THIS->cmd_parse (); |
1647 | THIS->cmd_parse (); |
|
|
1648 | rxvt_pop_locale (); |
1152 | |
1649 | |
1153 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1650 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1154 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1651 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1155 | } |
1652 | } |
1156 | |
1653 | |
… | |
… | |
1229 | RETVAL = THIS; |
1726 | RETVAL = THIS; |
1230 | OUTPUT: |
1727 | OUTPUT: |
1231 | RETVAL |
1728 | RETVAL |
1232 | |
1729 | |
1233 | timer * |
1730 | timer * |
|
|
1731 | timer::after (NV delay) |
|
|
1732 | CODE: |
|
|
1733 | THIS->start (NOW + delay); |
|
|
1734 | RETVAL = THIS; |
|
|
1735 | OUTPUT: |
|
|
1736 | RETVAL |
|
|
1737 | |
|
|
1738 | timer * |
1234 | timer::stop () |
1739 | timer::stop () |
1235 | CODE: |
1740 | CODE: |
1236 | THIS->stop (); |
1741 | THIS->stop (); |
1237 | RETVAL = THIS; |
1742 | RETVAL = THIS; |
1238 | OUTPUT: |
1743 | OUTPUT: |