… | |
… | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
31 | #include <cstddef> |
31 | #include <cstddef> |
32 | #include <cstdarg> |
32 | #include <cstdarg> |
33 | |
33 | |
|
|
34 | #include "unistd.h" |
|
|
35 | |
|
|
36 | #include "iom.h" |
34 | #include "rxvt.h" |
37 | #include "rxvt.h" |
35 | #include "iom.h" |
38 | #include "keyboard.h" |
36 | #include "rxvtutil.h" |
39 | #include "rxvtutil.h" |
37 | #include "rxvtperl.h" |
40 | #include "rxvtperl.h" |
38 | |
41 | |
39 | #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 |
40 | |
49 | |
41 | #undef LINENO |
50 | #undef LINENO |
42 | #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) |
43 | #undef ROW |
52 | #undef ROW |
44 | #define ROW(n) THIS->row_buf [LINENO (n)] |
53 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
54 | |
|
|
55 | #define ENABLE_PERL_FRILLS 1 |
45 | |
56 | |
46 | ///////////////////////////////////////////////////////////////////////////// |
57 | ///////////////////////////////////////////////////////////////////////////// |
47 | |
58 | |
48 | static wchar_t * |
59 | static wchar_t * |
49 | sv2wcs (SV *sv) |
60 | sv2wcs (SV *sv) |
… | |
… | |
200 | |
211 | |
201 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
212 | #define SvOVERLAY(sv) (overlay *)SvPTR (sv, "urxvt::overlay") |
202 | |
213 | |
203 | struct overlay { |
214 | struct overlay { |
204 | HV *self; |
215 | HV *self; |
|
|
216 | bool visible; |
205 | rxvt_term *THIS; |
217 | rxvt_term *THIS; |
206 | int x, y, w, h; |
218 | int x, y, w, h; |
207 | int border; |
219 | int border; |
208 | text_t **text; |
220 | text_t **text; |
209 | rend_t **rend; |
221 | rend_t **rend; |
… | |
… | |
218 | |
230 | |
219 | void set (int x, int y, SV *str, SV *rend); |
231 | void set (int x, int y, SV *str, SV *rend); |
220 | }; |
232 | }; |
221 | |
233 | |
222 | 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) |
223 | : 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) |
224 | { |
236 | { |
225 | if (border == 2) |
237 | if (border == 2) |
226 | { |
238 | { |
227 | w += 2; |
239 | w += 2; |
228 | h += 2; |
240 | h += 2; |
… | |
… | |
289 | } |
301 | } |
290 | |
302 | |
291 | void |
303 | void |
292 | overlay::show () |
304 | overlay::show () |
293 | { |
305 | { |
294 | char key[33]; sprintf (key, "%32lx", (long)this); |
306 | if (visible) |
|
|
307 | return; |
295 | |
308 | |
|
|
309 | visible = true; |
|
|
310 | |
296 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
311 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
297 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
312 | av_push (av, newSViv ((long)this)); |
298 | } |
313 | } |
299 | |
314 | |
300 | void |
315 | void |
301 | overlay::hide () |
316 | overlay::hide () |
302 | { |
317 | { |
|
|
318 | if (!visible) |
|
|
319 | return; |
|
|
320 | |
|
|
321 | visible = false; |
|
|
322 | |
303 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
323 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
304 | |
324 | |
305 | if (ovs) |
325 | int i; |
|
|
326 | |
|
|
327 | for (i = AvFILL (av); i >= 0; i--) |
|
|
328 | if (SvIV (*av_fetch (av, i, 1)) == (long)this) |
306 | { |
329 | { |
307 | char key[33]; sprintf (key, "%32lx", (long)this); |
|
|
308 | |
|
|
309 | HV *hv = (HV *)SvRV (*ovs); |
|
|
310 | hv_delete (hv, key, 32, G_DISCARD); |
330 | av_delete (av, i, G_DISCARD); |
|
|
331 | break; |
311 | } |
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); |
312 | } |
338 | } |
313 | |
339 | |
314 | void overlay::swap () |
340 | void overlay::swap () |
315 | { |
341 | { |
316 | 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)); |
… | |
… | |
322 | for (int y = ov_h; y--; ) |
348 | for (int y = ov_h; y--; ) |
323 | { |
349 | { |
324 | text_t *t1 = text [y]; |
350 | text_t *t1 = text [y]; |
325 | rend_t *r1 = rend [y]; |
351 | rend_t *r1 = rend [y]; |
326 | |
352 | |
327 | 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; |
328 | 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; |
329 | |
355 | |
330 | for (int x = ov_w; x--; ) |
356 | for (int x = ov_w; x--; ) |
331 | { |
357 | { |
332 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
358 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
333 | 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)); |
… | |
… | |
356 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
382 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
357 | croak ("rend must be arrayref"); |
383 | croak ("rend must be arrayref"); |
358 | |
384 | |
359 | AV *av = (AV *)SvRV (rend); |
385 | AV *av = (AV *)SvRV (rend); |
360 | |
386 | |
361 | for (int col = min (av_len (av) + 1, w - x - border); col--; ) |
387 | for (int col = min (AvFILL (av) + 1, w - x - border); col--; ) |
362 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
388 | this->rend [y][x + col] = SvIV (*av_fetch (av, col, 1)); |
363 | } |
389 | } |
364 | |
390 | |
365 | THIS->want_refresh = 1; |
391 | THIS->want_refresh = 1; |
366 | } |
392 | } |
… | |
… | |
369 | ///////////////////////////////////////////////////////////////////////////// |
395 | ///////////////////////////////////////////////////////////////////////////// |
370 | |
396 | |
371 | struct rxvt_perl_interp rxvt_perl; |
397 | struct rxvt_perl_interp rxvt_perl; |
372 | |
398 | |
373 | static PerlInterpreter *perl; |
399 | static PerlInterpreter *perl; |
374 | |
|
|
375 | rxvt_perl_interp::rxvt_perl_interp () |
|
|
376 | { |
|
|
377 | } |
|
|
378 | |
400 | |
379 | rxvt_perl_interp::~rxvt_perl_interp () |
401 | rxvt_perl_interp::~rxvt_perl_interp () |
380 | { |
402 | { |
381 | if (perl) |
403 | if (perl) |
382 | { |
404 | { |
… | |
… | |
384 | perl_free (perl); |
406 | perl_free (perl); |
385 | } |
407 | } |
386 | } |
408 | } |
387 | |
409 | |
388 | void |
410 | void |
389 | rxvt_perl_interp::init () |
411 | rxvt_perl_interp::init (rxvt_term *term) |
390 | { |
412 | { |
391 | if (!perl) |
413 | if (!perl) |
392 | { |
414 | { |
|
|
415 | rxvt_push_locale (""); // perl init destroys current locale |
|
|
416 | |
|
|
417 | perl_environ = rxvt_environ; |
|
|
418 | swap (perl_environ, environ); |
|
|
419 | |
393 | char *argv[] = { |
420 | char *argv[] = { |
394 | "", |
421 | "", |
395 | "-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;" |
396 | }; |
429 | }; |
397 | |
430 | |
398 | perl = perl_alloc (); |
431 | perl = perl_alloc (); |
399 | perl_construct (perl); |
432 | perl_construct (perl); |
400 | |
433 | |
… | |
… | |
405 | |
438 | |
406 | perl_destruct (perl); |
439 | perl_destruct (perl); |
407 | perl_free (perl); |
440 | perl_free (perl); |
408 | perl = 0; |
441 | perl = 0; |
409 | } |
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; |
410 | } |
465 | } |
411 | } |
466 | } |
412 | |
467 | |
413 | bool |
468 | bool |
414 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
469 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
415 | { |
470 | { |
416 | if (!perl) |
471 | if (!perl || !term->perl.self) |
417 | return false; |
472 | return false; |
418 | |
473 | |
419 | if (htype == HOOK_INIT) // first hook ever called |
474 | // pre-handling of some events |
|
|
475 | if (htype == HOOK_REFRESH_END) |
420 | { |
476 | { |
421 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
477 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
422 | hv_store ((HV *)SvRV ((SV *)term->perl.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 (); |
423 | } |
481 | } |
424 | else if (!term->perl.self) |
482 | |
425 | 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 | } |
426 | else if (htype == HOOK_DESTROY) |
664 | else if (htype == HOOK_DESTROY) |
427 | { |
665 | { |
428 | // handled later |
666 | clearSVptr ((SV *)term->perl.self); |
|
|
667 | SvREFCNT_dec ((SV *)term->perl.self); |
429 | } |
668 | } |
430 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
|
|
431 | { |
|
|
432 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
|
|
433 | |
669 | |
434 | if (HvKEYS (hv)) |
670 | swap (perl_environ, environ); |
435 | { |
|
|
436 | hv_iterinit (hv); |
|
|
437 | |
671 | |
438 | while (HE *he = hv_iternext (hv)) |
672 | return event_consumed; |
439 | ((overlay *)SvIV (hv_iterval (hv, he)))->swap (); |
|
|
440 | } |
|
|
441 | } |
|
|
442 | else if (!should_invoke [htype]) |
|
|
443 | return false; |
|
|
444 | |
|
|
445 | dSP; |
|
|
446 | va_list ap; |
|
|
447 | |
|
|
448 | va_start (ap, htype); |
|
|
449 | |
|
|
450 | ENTER; |
|
|
451 | SAVETMPS; |
|
|
452 | |
|
|
453 | PUSHMARK (SP); |
|
|
454 | |
|
|
455 | XPUSHs (sv_2mortal (newSVterm (term))); |
|
|
456 | XPUSHs (sv_2mortal (newSViv (htype))); |
|
|
457 | |
|
|
458 | for (;;) { |
|
|
459 | data_type dt = (data_type)va_arg (ap, int); |
|
|
460 | |
|
|
461 | switch (dt) |
|
|
462 | { |
|
|
463 | case DT_INT: |
|
|
464 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
|
|
465 | break; |
|
|
466 | |
|
|
467 | case DT_LONG: |
|
|
468 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
|
|
469 | break; |
|
|
470 | |
|
|
471 | case DT_STR: |
|
|
472 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
473 | break; |
|
|
474 | |
|
|
475 | case DT_STR_LEN: |
|
|
476 | { |
|
|
477 | char *str = va_arg (ap, char *); |
|
|
478 | int len = va_arg (ap, int); |
|
|
479 | |
|
|
480 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
481 | } |
|
|
482 | break; |
|
|
483 | |
|
|
484 | case DT_WCS_LEN: |
|
|
485 | { |
|
|
486 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
487 | int wlen = va_arg (ap, int); |
|
|
488 | |
|
|
489 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
490 | } |
|
|
491 | break; |
|
|
492 | |
|
|
493 | case DT_XEVENT: |
|
|
494 | { |
|
|
495 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
496 | HV *hv = newHV (); |
|
|
497 | |
|
|
498 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
499 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
500 | # undef set |
|
|
501 | |
|
|
502 | setiv (type, xe->type); |
|
|
503 | setiv (send_event, xe->xany.send_event); |
|
|
504 | setiv (serial, xe->xany.serial); |
|
|
505 | |
|
|
506 | switch (xe->type) |
|
|
507 | { |
|
|
508 | case KeyPress: |
|
|
509 | case KeyRelease: |
|
|
510 | case ButtonPress: |
|
|
511 | case ButtonRelease: |
|
|
512 | case MotionNotify: |
|
|
513 | setiv (time, xe->xmotion.time); |
|
|
514 | setiv (x, xe->xmotion.x); |
|
|
515 | setiv (y, xe->xmotion.y); |
|
|
516 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
517 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
518 | setiv (x_root, xe->xmotion.x_root); |
|
|
519 | setiv (y_root, xe->xmotion.y_root); |
|
|
520 | setiv (state, xe->xmotion.state); |
|
|
521 | break; |
|
|
522 | } |
|
|
523 | |
|
|
524 | switch (xe->type) |
|
|
525 | { |
|
|
526 | case KeyPress: |
|
|
527 | case KeyRelease: |
|
|
528 | setiv (keycode, xe->xkey.keycode); |
|
|
529 | break; |
|
|
530 | |
|
|
531 | case ButtonPress: |
|
|
532 | case ButtonRelease: |
|
|
533 | setiv (button, xe->xbutton.button); |
|
|
534 | break; |
|
|
535 | |
|
|
536 | case MotionNotify: |
|
|
537 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
538 | break; |
|
|
539 | } |
|
|
540 | |
|
|
541 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
542 | } |
|
|
543 | break; |
|
|
544 | |
|
|
545 | case DT_END: |
|
|
546 | { |
|
|
547 | va_end (ap); |
|
|
548 | |
|
|
549 | PUTBACK; |
|
|
550 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
551 | SPAGAIN; |
|
|
552 | |
|
|
553 | if (count) |
|
|
554 | { |
|
|
555 | SV *status = POPs; |
|
|
556 | count = SvTRUE (status); |
|
|
557 | } |
|
|
558 | |
|
|
559 | PUTBACK; |
|
|
560 | FREETMPS; |
|
|
561 | LEAVE; |
|
|
562 | |
|
|
563 | if (SvTRUE (ERRSV)) |
|
|
564 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
|
|
565 | |
|
|
566 | if (htype == HOOK_DESTROY) |
|
|
567 | { |
|
|
568 | clearSVptr ((SV *)term->perl.self); |
|
|
569 | SvREFCNT_dec ((SV *)term->perl.self); |
|
|
570 | } |
|
|
571 | |
|
|
572 | return count; |
|
|
573 | } |
|
|
574 | |
|
|
575 | default: |
|
|
576 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
|
|
577 | } |
|
|
578 | } |
|
|
579 | } |
673 | } |
580 | |
674 | |
581 | ///////////////////////////////////////////////////////////////////////////// |
675 | ///////////////////////////////////////////////////////////////////////////// |
582 | |
676 | |
583 | MODULE = urxvt PACKAGE = urxvt |
677 | MODULE = urxvt PACKAGE = urxvt |
584 | |
678 | |
585 | PROTOTYPES: ENABLE |
679 | PROTOTYPES: ENABLE |
586 | |
680 | |
587 | BOOT: |
681 | BOOT: |
588 | { |
682 | { |
589 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
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)); |
590 | |
687 | |
591 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
688 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
592 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
689 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
593 | # include "hookinc.h" |
690 | # include "hookinc.h" |
594 | # undef def |
691 | # undef def |
… | |
… | |
599 | # include "optinc.h" |
696 | # include "optinc.h" |
600 | # undef nodef |
697 | # undef nodef |
601 | # undef def |
698 | # undef def |
602 | |
699 | |
603 | HV *stash = gv_stashpv ("urxvt", 1); |
700 | HV *stash = gv_stashpv ("urxvt", 1); |
604 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
701 | struct { |
|
|
702 | const char *name; |
|
|
703 | IV iv; |
|
|
704 | } *civ, const_iv[] = { |
|
|
705 | # define const_iv(name) { # name, (IV)name } |
605 | export_const_iv (DEFAULT_RSTYLE); |
706 | const_iv (DEFAULT_RSTYLE), |
606 | export_const_iv (OVERLAY_RSTYLE); |
707 | const_iv (OVERLAY_RSTYLE), |
607 | export_const_iv (RS_Bold); |
708 | const_iv (RS_Bold), |
608 | export_const_iv (RS_Italic); |
709 | const_iv (RS_Italic), |
609 | export_const_iv (RS_Blink); |
710 | const_iv (RS_Blink), |
610 | export_const_iv (RS_RVid); |
711 | const_iv (RS_RVid), |
611 | export_const_iv (RS_Uline); |
712 | const_iv (RS_Uline), |
612 | |
713 | |
613 | export_const_iv (CurrentTime); |
714 | const_iv (CurrentTime), |
614 | export_const_iv (ShiftMask); |
715 | const_iv (ShiftMask), |
615 | export_const_iv (LockMask); |
716 | const_iv (LockMask), |
616 | export_const_iv (ControlMask); |
717 | const_iv (ControlMask), |
617 | export_const_iv (Mod1Mask); |
718 | const_iv (Mod1Mask), |
618 | export_const_iv (Mod2Mask); |
719 | const_iv (Mod2Mask), |
619 | export_const_iv (Mod3Mask); |
720 | const_iv (Mod3Mask), |
620 | export_const_iv (Mod4Mask); |
721 | const_iv (Mod4Mask), |
621 | export_const_iv (Mod5Mask); |
722 | const_iv (Mod5Mask), |
622 | export_const_iv (Button1Mask); |
723 | const_iv (Button1Mask), |
623 | export_const_iv (Button2Mask); |
724 | const_iv (Button2Mask), |
624 | export_const_iv (Button3Mask); |
725 | const_iv (Button3Mask), |
625 | export_const_iv (Button4Mask); |
726 | const_iv (Button4Mask), |
626 | export_const_iv (Button5Mask); |
727 | const_iv (Button5Mask), |
627 | export_const_iv (AnyModifier); |
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)); |
628 | } |
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 |
629 | |
870 | |
630 | SV * |
871 | SV * |
631 | new (...) |
872 | _new (...) |
632 | CODE: |
873 | CODE: |
633 | { |
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 | |
634 | 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 | |
635 | bool success; |
892 | bool success; |
636 | |
|
|
637 | for (int i = 0; i < items ;i++) |
|
|
638 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
639 | |
|
|
640 | rxvt_term *term = new rxvt_term; |
|
|
641 | |
|
|
642 | term->argv = argv; |
|
|
643 | |
893 | |
644 | try |
894 | try |
645 | { |
895 | { |
646 | if (!term->init (argv->size (), argv->begin ())) |
896 | success = term->init (term->argv->size (), term->argv->begin ()); |
647 | term = 0; |
|
|
648 | } |
897 | } |
649 | catch (const class rxvt_failure_exception &e) |
898 | catch (const class rxvt_failure_exception &e) |
650 | { |
899 | { |
|
|
900 | success = false; |
|
|
901 | } |
|
|
902 | |
|
|
903 | if (!success) |
|
|
904 | { |
651 | term->destroy (); |
905 | term->destroy (); |
652 | croak ("exception caught while initializing new terminal instance"); |
906 | croak ("error while initializing new terminal instance"); |
653 | } |
907 | } |
654 | |
908 | |
655 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
909 | RETVAL = term && term->perl.self |
|
|
910 | ? newSVterm (term) : &PL_sv_undef; |
656 | } |
911 | } |
657 | OUTPUT: |
912 | OUTPUT: |
658 | RETVAL |
913 | RETVAL |
659 | |
914 | |
660 | void |
915 | void |
661 | 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) |
662 | CODE: |
922 | PPCODE: |
663 | rxvt_perl.should_invoke [htype] = value; |
923 | { |
|
|
924 | int count; |
|
|
925 | Atom *props = XListProperties (THIS->display->display, (Window)window, &count); |
664 | |
926 | |
|
|
927 | EXTEND (SP, count); |
|
|
928 | while (count--) |
|
|
929 | PUSHs (newSVuv ((U32)props [count])); |
|
|
930 | |
|
|
931 | XFree (props); |
|
|
932 | } |
|
|
933 | |
665 | void |
934 | void |
666 | warn (const char *msg) |
935 | rxvt_term::XGetWindowProperty (U32 window, U32 property) |
667 | CODE: |
936 | PPCODE: |
668 | 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 | } |
669 | |
955 | |
670 | void |
956 | void |
671 | fatal (const char *msg) |
957 | rxvt_term::XChangeWindowProperty (U32 window, U32 property, U32 type, int format, SV *data) |
672 | CODE: |
958 | CODE: |
673 | rxvt_fatal ("%s", msg); |
959 | { |
|
|
960 | STRLEN len; |
|
|
961 | char *data_ = SvPVbyte (data, len); |
674 | |
962 | |
675 | NV |
963 | XChangeProperty (THIS->display->display, (Window)window, (Atom)property, |
676 | NOW () |
964 | type, format, PropModeReplace, |
|
|
965 | (unsigned char *)data, len * 8 / format); |
|
|
966 | } |
|
|
967 | |
|
|
968 | void |
|
|
969 | rxvt_term::XDeleteProperty (U32 window, U32 property) |
677 | 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: |
678 | RETVAL = NOW; |
978 | RETVAL |
679 | OUTPUT: |
|
|
680 | RETVAL |
|
|
681 | |
979 | |
682 | int |
980 | U32 |
683 | GET_BASEFG (int rend) |
981 | rxvt_term::XCreateSimpleWindow (U32 parent, int x, int y, unsigned int width, unsigned int height) |
684 | CODE: |
982 | CODE: |
685 | 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]); |
686 | OUTPUT: |
987 | OUTPUT: |
687 | RETVAL |
988 | RETVAL |
688 | |
989 | |
689 | int |
|
|
690 | GET_BASEBG (int rend) |
|
|
691 | CODE: |
|
|
692 | RETVAL = GET_BASEBG (rend); |
|
|
693 | OUTPUT: |
|
|
694 | RETVAL |
|
|
695 | |
|
|
696 | int |
|
|
697 | SET_FGCOLOR (int rend, int new_color) |
|
|
698 | CODE: |
|
|
699 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
700 | OUTPUT: |
|
|
701 | RETVAL |
|
|
702 | |
|
|
703 | int |
|
|
704 | SET_BGCOLOR (int rend, int new_color) |
|
|
705 | CODE: |
|
|
706 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
707 | OUTPUT: |
|
|
708 | RETVAL |
|
|
709 | |
|
|
710 | int |
|
|
711 | GET_CUSTOM (int rend) |
|
|
712 | CODE: |
|
|
713 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
714 | OUTPUT: |
|
|
715 | RETVAL |
|
|
716 | |
|
|
717 | int |
|
|
718 | SET_CUSTOM (int rend, int new_value) |
|
|
719 | CODE: |
|
|
720 | { |
|
|
721 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
722 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
723 | |
|
|
724 | RETVAL = (rend & ~RS_customMask) |
|
|
725 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
726 | } |
|
|
727 | OUTPUT: |
|
|
728 | RETVAL |
|
|
729 | |
|
|
730 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
731 | |
|
|
732 | void |
990 | void |
733 | rxvt_term::destroy () |
991 | rxvt_term::XReparentWindow (U32 window, U32 parent, int x = 0, int y = 0) |
|
|
992 | CODE: |
|
|
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; |
734 | |
1011 | |
735 | void |
1012 | void |
736 | rxvt_term::grab_button (int button, U32 modifiers) |
1013 | rxvt_term::grab_button (int button, U32 modifiers) |
737 | CODE: |
1014 | CODE: |
738 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
1015 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
739 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1016 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
740 | GrabModeSync, GrabModeSync, None, None); |
1017 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
741 | |
1018 | |
742 | bool |
1019 | bool |
743 | rxvt_term::grab (U32 eventtime, int sync = 0) |
1020 | rxvt_term::grab (U32 eventtime, int sync = 0) |
744 | CODE: |
1021 | CODE: |
745 | { |
1022 | { |
… | |
… | |
747 | |
1024 | |
748 | THIS->perl.grabtime = 0; |
1025 | THIS->perl.grabtime = 0; |
749 | |
1026 | |
750 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
1027 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
751 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
1028 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
752 | mode, mode, None, None, eventtime)) |
1029 | mode, mode, None, GRAB_CURSOR, eventtime)) |
753 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
1030 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
754 | THIS->perl.grabtime = eventtime; |
1031 | THIS->perl.grabtime = eventtime; |
755 | else |
1032 | else |
756 | XUngrabPointer (THIS->display->display, eventtime); |
1033 | XUngrabPointer (THIS->display->display, eventtime); |
757 | |
1034 | |
… | |
… | |
759 | } |
1036 | } |
760 | OUTPUT: |
1037 | OUTPUT: |
761 | RETVAL |
1038 | RETVAL |
762 | |
1039 | |
763 | void |
1040 | void |
764 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
1041 | rxvt_term::allow_events_async () |
765 | CODE: |
1042 | CODE: |
766 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
1043 | XAllowEvents (THIS->display->display, AsyncBoth, THIS->perl.grabtime); |
767 | |
1044 | |
768 | void |
1045 | void |
769 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
1046 | rxvt_term::allow_events_sync () |
770 | CODE: |
1047 | CODE: |
771 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
1048 | XAllowEvents (THIS->display->display, SyncBoth, THIS->perl.grabtime); |
772 | |
1049 | |
773 | void |
1050 | void |
774 | rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) |
1051 | rxvt_term::allow_events_replay () |
775 | CODE: |
1052 | CODE: |
776 | XAllowEvents (THIS->display->display, ReplayPointer, eventtime); |
1053 | XAllowEvents (THIS->display->display, ReplayPointer, THIS->perl.grabtime); |
777 | XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); |
1054 | XAllowEvents (THIS->display->display, ReplayKeyboard, THIS->perl.grabtime); |
778 | |
1055 | |
779 | void |
1056 | void |
780 | rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) |
1057 | rxvt_term::ungrab () |
781 | CODE: |
1058 | CODE: |
782 | THIS->perl.grabtime = 0; |
1059 | ungrab (THIS); |
783 | XUngrabKeyboard (THIS->display->display, eventtime); |
|
|
784 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
785 | |
1060 | |
786 | int |
1061 | int |
787 | rxvt_term::strwidth (SV *str) |
1062 | rxvt_term::strwidth (SV *str) |
788 | CODE: |
1063 | CODE: |
789 | { |
1064 | { |
… | |
… | |
844 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
1119 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
845 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
1120 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
846 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
1121 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
847 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
1122 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
848 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
1123 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
849 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
1124 | #define TERM_OFFSET_top_row TERM_OFFSET(top_row) |
850 | |
1125 | |
851 | int |
1126 | int |
852 | rxvt_term::width () |
1127 | rxvt_term::width () |
853 | ALIAS: |
1128 | ALIAS: |
854 | width = TERM_OFFSET_width |
1129 | width = TERM_OFFSET_width |
… | |
… | |
860 | ncol = TERM_OFFSET_ncol |
1135 | ncol = TERM_OFFSET_ncol |
861 | focus = TERM_OFFSET_focus |
1136 | focus = TERM_OFFSET_focus |
862 | mapped = TERM_OFFSET_mapped |
1137 | mapped = TERM_OFFSET_mapped |
863 | saveLines = TERM_OFFSET_saveLines |
1138 | saveLines = TERM_OFFSET_saveLines |
864 | total_rows = TERM_OFFSET_total_rows |
1139 | total_rows = TERM_OFFSET_total_rows |
865 | nsaved = TERM_OFFSET_nsaved |
1140 | top_row = TERM_OFFSET_top_row |
866 | CODE: |
1141 | CODE: |
867 | RETVAL = *(int *)((char *)THIS + ix); |
1142 | RETVAL = *(int *)((char *)THIS + ix); |
868 | OUTPUT: |
1143 | OUTPUT: |
869 | RETVAL |
1144 | RETVAL |
870 | |
1145 | |
… | |
… | |
882 | case 2: RETVAL = THIS->ModNumLockMask; break; |
1157 | case 2: RETVAL = THIS->ModNumLockMask; break; |
883 | } |
1158 | } |
884 | OUTPUT: |
1159 | OUTPUT: |
885 | RETVAL |
1160 | RETVAL |
886 | |
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: |
|
|
1203 | RETVAL |
|
|
1204 | |
887 | U32 |
1205 | U32 |
888 | rxvt_term::parent () |
1206 | rxvt_term::parent () |
889 | CODE: |
1207 | CODE: |
890 | RETVAL = (U32)THIS->parent [0]; |
1208 | RETVAL = (U32)THIS->parent [0]; |
891 | OUTPUT: |
1209 | OUTPUT: |
… | |
… | |
896 | CODE: |
1214 | CODE: |
897 | RETVAL = (U32)THIS->vt; |
1215 | RETVAL = (U32)THIS->vt; |
898 | OUTPUT: |
1216 | OUTPUT: |
899 | RETVAL |
1217 | RETVAL |
900 | |
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 | |
901 | U32 |
1225 | U32 |
902 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
1226 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
903 | CODE: |
1227 | CODE: |
904 | { |
|
|
905 | RETVAL = THIS->rstyle; |
1228 | RETVAL = THIS->rstyle; |
906 | THIS->rstyle = new_rstyle; |
1229 | THIS->rstyle = new_rstyle; |
907 | } |
|
|
908 | OUTPUT: |
1230 | OUTPUT: |
909 | RETVAL |
1231 | RETVAL |
910 | |
1232 | |
911 | int |
1233 | int |
912 | rxvt_term::view_start (int newval = -1) |
1234 | rxvt_term::view_start (int newval = 1) |
|
|
1235 | PROTOTYPE: $;$ |
913 | CODE: |
1236 | CODE: |
914 | { |
1237 | { |
915 | RETVAL = THIS->view_start; |
1238 | RETVAL = THIS->view_start; |
916 | |
1239 | |
917 | if (newval >= 0) |
1240 | if (newval <= 0) |
918 | { |
1241 | THIS->scr_changeview (max (newval, THIS->top_row)); |
919 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
920 | THIS->scr_changeview (RETVAL); |
|
|
921 | } |
|
|
922 | } |
1242 | } |
923 | OUTPUT: |
1243 | OUTPUT: |
924 | RETVAL |
1244 | RETVAL |
925 | |
1245 | |
926 | void |
1246 | void |
… | |
… | |
930 | |
1250 | |
931 | void |
1251 | void |
932 | 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) |
933 | PPCODE: |
1253 | PPCODE: |
934 | { |
1254 | { |
935 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1255 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
936 | XSRETURN_EMPTY; |
1256 | XSRETURN_EMPTY; |
937 | |
1257 | |
938 | line_t &l = ROW(row_number); |
1258 | line_t &l = ROW(row_number); |
939 | |
1259 | |
940 | if (GIMME_V != G_VOID) |
1260 | if (GIMME_V != G_VOID) |
… | |
… | |
973 | |
1293 | |
974 | void |
1294 | void |
975 | 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) |
976 | PPCODE: |
1296 | PPCODE: |
977 | { |
1297 | { |
978 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1298 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
979 | XSRETURN_EMPTY; |
1299 | XSRETURN_EMPTY; |
980 | |
1300 | |
981 | line_t &l = ROW(row_number); |
1301 | line_t &l = ROW(row_number); |
982 | |
1302 | |
983 | if (GIMME_V != G_VOID) |
1303 | if (GIMME_V != G_VOID) |
… | |
… | |
995 | { |
1315 | { |
996 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1316 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
997 | croak ("new_rend must be arrayref"); |
1317 | croak ("new_rend must be arrayref"); |
998 | |
1318 | |
999 | AV *av = (AV *)SvRV (new_rend); |
1319 | AV *av = (AV *)SvRV (new_rend); |
1000 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
1320 | int len = min (AvFILL (av) + 1 - start_ofs, max_len); |
1001 | |
1321 | |
1002 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1322 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1003 | croak ("new_rend array extends beyond horizontal margins"); |
1323 | croak ("new_rend array extends beyond horizontal margins"); |
1004 | |
1324 | |
1005 | for (int col = start_col; col < start_col + len; col++) |
1325 | for (int col = start_col; col < start_col + len; col++) |
… | |
… | |
1013 | |
1333 | |
1014 | int |
1334 | int |
1015 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1335 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
1016 | CODE: |
1336 | CODE: |
1017 | { |
1337 | { |
1018 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1338 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1019 | XSRETURN_EMPTY; |
1339 | XSRETURN_EMPTY; |
1020 | |
1340 | |
1021 | line_t &l = ROW(row_number); |
1341 | line_t &l = ROW(row_number); |
1022 | RETVAL = l.l; |
1342 | RETVAL = l.l; |
1023 | |
1343 | |
… | |
… | |
1029 | |
1349 | |
1030 | bool |
1350 | bool |
1031 | 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) |
1032 | CODE: |
1352 | CODE: |
1033 | { |
1353 | { |
1034 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1354 | if (!IN_RANGE_EXC (row_number, THIS->top_row, THIS->nrow)) |
1035 | XSRETURN_EMPTY; |
1355 | XSRETURN_EMPTY; |
1036 | |
1356 | |
1037 | line_t &l = ROW(row_number); |
1357 | line_t &l = ROW(row_number); |
1038 | RETVAL = l.is_longer (); |
1358 | RETVAL = l.is_longer (); |
1039 | |
1359 | |
… | |
… | |
1156 | else |
1476 | else |
1157 | THIS->rs [index] = 0; |
1477 | THIS->rs [index] = 0; |
1158 | } |
1478 | } |
1159 | } |
1479 | } |
1160 | |
1480 | |
|
|
1481 | const char * |
|
|
1482 | rxvt_term::x_resource (const char *name) |
|
|
1483 | |
1161 | bool |
1484 | bool |
1162 | rxvt_term::option (U32 optval, int set = -1) |
1485 | rxvt_term::option (U32 optval, int set = -1) |
1163 | CODE: |
1486 | CODE: |
1164 | { |
1487 | { |
1165 | RETVAL = THIS->options & optval; |
1488 | RETVAL = THIS->options & optval; |
… | |
… | |
1192 | } |
1515 | } |
1193 | } |
1516 | } |
1194 | OUTPUT: |
1517 | OUTPUT: |
1195 | RETVAL |
1518 | RETVAL |
1196 | |
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 | |
1197 | void |
1528 | void |
1198 | rxvt_term::cur (...) |
1529 | rxvt_term::screen_cur (...) |
1199 | PROTOTYPE: $;$$ |
1530 | PROTOTYPE: $;$$ |
1200 | ALIAS: |
1531 | ALIAS: |
1201 | screen_cur = 0 |
1532 | screen_cur = 0 |
1202 | selection_beg = 1 |
1533 | selection_beg = 1 |
1203 | selection_end = 2 |
1534 | selection_end = 2 |
… | |
… | |
1216 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1547 | PUSHs (sv_2mortal (newSViv (rc.col))); |
1217 | } |
1548 | } |
1218 | |
1549 | |
1219 | if (items == 3) |
1550 | if (items == 3) |
1220 | { |
1551 | { |
1221 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1552 | rc.row = SvIV (ST (1)); |
1222 | 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); |
1223 | |
1563 | |
1224 | if (ix) |
1564 | if (ix) |
1225 | THIS->want_refresh = 1; |
1565 | THIS->want_refresh = 1; |
1226 | } |
1566 | } |
1227 | } |
1567 | } |
1228 | |
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 | |
1229 | int |
1586 | int |
1230 | rxvt_term::selection_grab (U32 eventtime) |
1587 | rxvt_term::selection_grab (U32 eventtime) |
1231 | |
1588 | |
1232 | void |
1589 | void |
1233 | rxvt_term::selection (SV *newtext = 0) |
1590 | rxvt_term::selection (SV *newtext = 0) |
1234 | PPCODE: |
1591 | PPCODE: |
1235 | { |
1592 | { |
1236 | if (GIMME_V != G_VOID) |
1593 | if (GIMME_V != G_VOID) |
|
|
1594 | XPUSHs (THIS->selection.text |
1237 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
1595 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
|
|
1596 | : &PL_sv_undef); |
1238 | |
1597 | |
1239 | if (newtext) |
1598 | if (newtext) |
1240 | { |
1599 | { |
1241 | free (THIS->selection.text); |
1600 | free (THIS->selection.text); |
1242 | |
1601 | |
1243 | THIS->selection.text = sv2wcs (newtext); |
1602 | THIS->selection.text = sv2wcs (newtext); |
1244 | THIS->selection.len = wcslen (THIS->selection.text); |
1603 | THIS->selection.len = wcslen (THIS->selection.text); |
1245 | } |
1604 | } |
1246 | } |
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 () |
1247 | |
1615 | |
1248 | void |
1616 | void |
1249 | rxvt_term::scr_add_lines (SV *string) |
1617 | rxvt_term::scr_add_lines (SV *string) |
1250 | CODE: |
1618 | CODE: |
1251 | { |
1619 | { |
… | |
… | |
1358 | RETVAL = THIS; |
1726 | RETVAL = THIS; |
1359 | OUTPUT: |
1727 | OUTPUT: |
1360 | RETVAL |
1728 | RETVAL |
1361 | |
1729 | |
1362 | timer * |
1730 | timer * |
|
|
1731 | timer::after (NV delay) |
|
|
1732 | CODE: |
|
|
1733 | THIS->start (NOW + delay); |
|
|
1734 | OUTPUT: |
|
|
1735 | RETVAL |
|
|
1736 | |
|
|
1737 | timer * |
1363 | timer::stop () |
1738 | timer::stop () |
1364 | CODE: |
1739 | CODE: |
1365 | THIS->stop (); |
1740 | THIS->stop (); |
1366 | RETVAL = THIS; |
1741 | RETVAL = THIS; |
1367 | OUTPUT: |
1742 | OUTPUT: |