1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtperl.xs |
2 | * File: rxvtperl.xs |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008,2011 Marc Lehmann <schmorp@schmorp.de> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
23 | #define line_t perl_line_t |
23 | #define line_t perl_line_t |
24 | #include <EXTERN.h> |
24 | #include <EXTERN.h> |
25 | #include <perl.h> |
25 | #include <perl.h> |
26 | #include <XSUB.h> |
26 | #include <XSUB.h> |
27 | #undef line_t |
27 | #undef line_t |
|
|
28 | #undef bool // perl defines it's own bool type, except with g++... what a trap |
28 | |
29 | |
29 | #include "../config.h" |
30 | #include "../config.h" |
30 | |
31 | |
31 | #include <cstddef> |
32 | #include <stddef.h> |
32 | #include <cstdarg> |
33 | #include <stdarg.h> |
33 | |
34 | |
34 | #include "unistd.h" |
35 | #include "unistd.h" |
35 | |
36 | |
36 | #include "ev_cpp.h" |
37 | #include "ev_cpp.h" |
37 | #include "rxvt.h" |
38 | #include "rxvt.h" |
… | |
… | |
45 | |
46 | |
46 | #undef LINENO |
47 | #undef LINENO |
47 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
48 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
48 | #undef ROW |
49 | #undef ROW |
49 | #define ROW(n) THIS->row_buf [LINENO (n)] |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
51 | |
|
|
52 | ///////////////////////////////////////////////////////////////////////////// |
|
|
53 | |
|
|
54 | typedef char * octet_string; |
|
|
55 | typedef char * utf8_string; |
|
|
56 | |
|
|
57 | typedef int render_repeat_mode; |
|
|
58 | |
|
|
59 | typedef GdkPixbuf * urxvt__pixbuf; |
|
|
60 | typedef rxvt_img * urxvt__img; |
|
|
61 | |
|
|
62 | ///////////////////////////////////////////////////////////////////////////// |
|
|
63 | |
|
|
64 | static void |
|
|
65 | parse_color (rxvt_screen *s, rxvt_color &c, SV *sv) |
|
|
66 | { |
|
|
67 | //TODO: support component stuff |
|
|
68 | c.set (s, SvPVbyte_nolen (sv)); |
|
|
69 | } |
50 | |
70 | |
51 | ///////////////////////////////////////////////////////////////////////////// |
71 | ///////////////////////////////////////////////////////////////////////////// |
52 | |
72 | |
53 | static wchar_t * |
73 | static wchar_t * |
54 | sv2wcs (SV *sv) |
74 | sv2wcs (SV *sv) |
… | |
… | |
302 | THIS->refresh_check (); |
322 | THIS->refresh_check (); |
303 | } |
323 | } |
304 | |
324 | |
305 | ///////////////////////////////////////////////////////////////////////////// |
325 | ///////////////////////////////////////////////////////////////////////////// |
306 | |
326 | |
307 | #define IOM_CLASS "urxvt" |
|
|
308 | #define IOM_WARN rxvt_warn |
|
|
309 | #include "iom_perl.h" |
327 | #include "iom_perl.h" |
310 | |
328 | |
311 | ///////////////////////////////////////////////////////////////////////////// |
329 | ///////////////////////////////////////////////////////////////////////////// |
312 | |
330 | |
313 | struct rxvt_perl_interp rxvt_perl; |
331 | struct rxvt_perl_interp rxvt_perl; |
… | |
… | |
329 | { |
347 | { |
330 | if (!perl) |
348 | if (!perl) |
331 | { |
349 | { |
332 | rxvt_push_locale (""); // perl init destroys current locale |
350 | rxvt_push_locale (""); // perl init destroys current locale |
333 | |
351 | |
|
|
352 | { |
334 | perl_environ = rxvt_environ; |
353 | perl_environ = rxvt_environ; |
335 | swap (perl_environ, environ); |
354 | localise_env set_environ (perl_environ); |
336 | |
355 | |
337 | char *args[] = { |
356 | char *args[] = { |
338 | "", |
357 | "", |
339 | "-e" |
358 | "-e" |
340 | "BEGIN {" |
359 | "BEGIN {" |
341 | " urxvt->bootstrap;" |
360 | " urxvt->bootstrap;" |
342 | " unshift @INC, '" LIBDIR "';" |
361 | " unshift @INC, '" LIBDIR "';" |
343 | "}" |
362 | "}" |
344 | "" |
363 | "" |
345 | "use urxvt;" |
364 | "use urxvt;" |
346 | }; |
365 | }; |
347 | int argc = sizeof (args) / sizeof (args[0]); |
366 | int argc = ecb_array_length (args); |
348 | char **argv = args; |
367 | char **argv = args; |
349 | |
368 | |
350 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
369 | PERL_SYS_INIT3 (&argc, &argv, &environ); |
351 | perl = perl_alloc (); |
370 | perl = perl_alloc (); |
352 | perl_construct (perl); |
371 | perl_construct (perl); |
353 | |
372 | |
354 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
373 | if (perl_parse (perl, xs_init, argc, argv, (char **)NULL) |
355 | || perl_run (perl)) |
374 | || perl_run (perl)) |
356 | { |
375 | { |
357 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
376 | rxvt_warn ("unable to initialize perl-interpreter, continuing without.\n"); |
358 | |
377 | |
359 | perl_destruct (perl); |
378 | perl_destruct (perl); |
360 | perl_free (perl); |
379 | perl_free (perl); |
361 | perl = 0; |
380 | perl = 0; |
362 | } |
381 | } |
363 | |
382 | } |
364 | swap (perl_environ, environ); |
|
|
365 | |
383 | |
366 | rxvt_pop_locale (); |
384 | rxvt_pop_locale (); |
367 | } |
385 | } |
368 | |
386 | |
369 | if (perl) |
387 | if (perl) |
370 | { |
388 | { |
371 | // runs outside of perls ENV |
389 | // runs outside of perls ENV |
372 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
390 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
373 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
391 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newAV ()), 0); |
|
|
392 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, newRV_noinc ((SV *)newAV ()), 0); |
374 | } |
393 | } |
|
|
394 | } |
|
|
395 | |
|
|
396 | void |
|
|
397 | rxvt_perl_interp::usage (int type) |
|
|
398 | { |
|
|
399 | localise_env set_environ (perl_environ); |
|
|
400 | |
|
|
401 | ENTER; |
|
|
402 | SAVETMPS; |
|
|
403 | |
|
|
404 | dSP; |
|
|
405 | XPUSHs (sv_2mortal (newSViv (type))); |
|
|
406 | PUTBACK; |
|
|
407 | call_pv ("urxvt::usage", G_VOID | G_DISCARD | G_EVAL); |
|
|
408 | |
|
|
409 | FREETMPS; |
|
|
410 | LEAVE; |
|
|
411 | } |
|
|
412 | |
|
|
413 | uint8_t |
|
|
414 | rxvt_perl_interp::resource (rxvt_term *term, const char *name, bool arg, bool longopt, bool flag, const char *value) |
|
|
415 | { |
|
|
416 | localise_env set_environ (perl_environ); |
|
|
417 | |
|
|
418 | ENTER; |
|
|
419 | SAVETMPS; |
|
|
420 | |
|
|
421 | dSP; |
|
|
422 | EXTEND (SP, 6); |
|
|
423 | PUSHs (sv_2mortal (newSVterm (term))); |
|
|
424 | PUSHs (sv_2mortal (newSVpv (name, 0))); |
|
|
425 | PUSHs (arg ? &PL_sv_yes : &PL_sv_no); |
|
|
426 | PUSHs (longopt ? &PL_sv_yes : &PL_sv_no); |
|
|
427 | PUSHs (flag ? &PL_sv_yes : &PL_sv_no); |
|
|
428 | PUSHs (value ? sv_2mortal (newSVpv (value, 0)) : &PL_sv_undef); |
|
|
429 | PUTBACK; |
|
|
430 | call_pv ("urxvt::resource", G_SCALAR | G_EVAL); |
|
|
431 | |
|
|
432 | uint8_t ret = POPi; |
|
|
433 | |
|
|
434 | FREETMPS; |
|
|
435 | LEAVE; |
|
|
436 | |
|
|
437 | return ret; |
375 | } |
438 | } |
376 | |
439 | |
377 | static void |
440 | static void |
378 | ungrab (rxvt_term *THIS) |
441 | ungrab (rxvt_term *THIS) |
379 | { |
442 | { |
… | |
… | |
389 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
452 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
390 | { |
453 | { |
391 | if (!perl || !term->perl.self) |
454 | if (!perl || !term->perl.self) |
392 | return false; |
455 | return false; |
393 | |
456 | |
|
|
457 | localise_env set_environ (perl_environ); |
|
|
458 | |
394 | // pre-handling of some events |
459 | // pre-handling of some events |
395 | if (htype == HOOK_REFRESH_END) |
460 | if (htype == HOOK_REFRESH_END) |
396 | { |
461 | { |
397 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
462 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
398 | |
463 | |
399 | for (int i = 0; i <= AvFILL (av); i++) |
464 | for (int i = 0; i <= AvFILL (av); i++) |
400 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
465 | ((overlay *)SvIV (*av_fetch (av, i, 0)))->swap (); |
401 | } |
466 | } |
|
|
467 | else if (htype == HOOK_DESTROY) |
|
|
468 | { |
|
|
469 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
402 | |
470 | |
403 | swap (perl_environ, environ); |
471 | for (int i = AvFILL (av); i >= 0; i--) |
|
|
472 | { |
|
|
473 | rxvt_selection *req = (rxvt_selection *)SvIV (*av_fetch (av, i, 0)); |
|
|
474 | delete req; |
|
|
475 | } |
|
|
476 | } |
404 | |
477 | |
405 | bool event_consumed; |
478 | bool event_consumed; |
406 | |
479 | |
407 | if (htype == HOOK_INIT || htype == HOOK_DESTROY // must be called always |
|
|
408 | || term->perl.should_invoke [htype]) |
480 | if (term->perl.should_invoke [htype]) |
409 | try |
|
|
410 | { |
481 | { |
411 | dSP; |
482 | dSP; |
412 | va_list ap; |
483 | va_list ap; |
413 | |
484 | |
414 | va_start (ap, htype); |
485 | va_start (ap, htype); |
415 | |
486 | |
416 | ENTER; |
487 | ENTER; |
417 | SAVETMPS; |
488 | SAVETMPS; |
418 | |
489 | |
419 | PUSHMARK (SP); |
490 | PUSHMARK (SP); |
420 | |
491 | |
|
|
492 | EXTEND (SP, 2); |
421 | XPUSHs (sv_2mortal (newSVterm (term))); |
493 | PUSHs (sv_2mortal (newSVterm (term))); |
422 | XPUSHs (sv_2mortal (newSViv (htype))); |
494 | PUSHs (sv_2mortal (newSViv (htype))); |
423 | |
495 | |
424 | for (;;) { |
496 | for (;;) { |
425 | data_type dt = (data_type)va_arg (ap, int); |
497 | data_type dt = (data_type)va_arg (ap, int); |
426 | |
498 | |
427 | switch (dt) |
499 | switch (dt) |
428 | { |
500 | { |
429 | case DT_INT: |
501 | case DT_INT: |
430 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
502 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, int)))); |
431 | break; |
503 | break; |
432 | |
504 | |
433 | case DT_LONG: |
505 | case DT_LONG: |
434 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
506 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
435 | break; |
507 | break; |
436 | |
508 | |
437 | case DT_STR: |
509 | case DT_STR: |
438 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
510 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
439 | break; |
511 | break; |
440 | |
512 | |
441 | case DT_STR_LEN: |
513 | case DT_STR_LEN: |
442 | { |
514 | { |
443 | char *str = va_arg (ap, char *); |
515 | char *str = va_arg (ap, char *); |
444 | int len = va_arg (ap, int); |
516 | int len = va_arg (ap, int); |
445 | |
517 | |
446 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
518 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
447 | } |
519 | } |
448 | break; |
520 | break; |
449 | |
521 | |
450 | case DT_WCS_LEN: |
522 | case DT_WCS_LEN: |
451 | { |
523 | { |
452 | wchar_t *wstr = va_arg (ap, wchar_t *); |
524 | wchar_t *wstr = va_arg (ap, wchar_t *); |
453 | int wlen = va_arg (ap, int); |
525 | int wlen = va_arg (ap, int); |
454 | |
526 | |
455 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
527 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
456 | } |
528 | } |
457 | break; |
529 | break; |
458 | |
530 | |
459 | case DT_LCS_LEN: |
531 | case DT_LCS_LEN: |
460 | { |
532 | { |
461 | long *lstr = va_arg (ap, long *); |
533 | long *lstr = va_arg (ap, long *); |
462 | int llen = va_arg (ap, int); |
534 | int llen = va_arg (ap, int); |
463 | |
535 | |
464 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
536 | XPUSHs (sv_2mortal (newSVpvn ((char *)lstr, llen * sizeof (long)))); |
465 | } |
537 | } |
466 | break; |
538 | break; |
467 | |
539 | |
468 | case DT_XEVENT: |
540 | case DT_XEVENT: |
469 | { |
541 | { |
470 | XEvent *xe = va_arg (ap, XEvent *); |
542 | XEvent *xe = va_arg (ap, XEvent *); |
471 | HV *hv = newHV (); |
543 | HV *hv = newHV (); |
472 | |
544 | |
473 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
545 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
474 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
546 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
475 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
547 | # define setuv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSVuv (val), 0) |
476 | # undef set |
548 | # undef set |
477 | |
549 | |
478 | setiv (type, xe->type); |
550 | setiv (type, xe->type); |
479 | setiv (send_event, xe->xany.send_event); |
551 | setiv (send_event, xe->xany.send_event); |
480 | setiv (serial, xe->xany.serial); |
552 | setiv (serial, xe->xany.serial); |
481 | |
553 | |
482 | switch (xe->type) |
554 | switch (xe->type) |
483 | { |
555 | { |
484 | case KeyPress: |
556 | case KeyPress: |
485 | case KeyRelease: |
557 | case KeyRelease: |
486 | case ButtonPress: |
558 | case ButtonPress: |
487 | case ButtonRelease: |
559 | case ButtonRelease: |
488 | case MotionNotify: |
560 | case MotionNotify: |
489 | setuv (window, xe->xmotion.window); |
561 | setuv (window, xe->xmotion.window); |
490 | setuv (root, xe->xmotion.root); |
562 | setuv (root, xe->xmotion.root); |
491 | setuv (subwindow, xe->xmotion.subwindow); |
563 | setuv (subwindow, xe->xmotion.subwindow); |
492 | setuv (time, xe->xmotion.time); |
564 | setuv (time, xe->xmotion.time); |
493 | setiv (x, xe->xmotion.x); |
565 | setiv (x, xe->xmotion.x); |
494 | setiv (y, xe->xmotion.y); |
566 | setiv (y, xe->xmotion.y); |
495 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
567 | setiv (row, xe->xmotion.y / term->fheight + term->view_start); |
496 | setiv (col, xe->xmotion.x / term->fwidth); |
568 | setiv (col, xe->xmotion.x / term->fwidth); |
497 | setiv (x_root, xe->xmotion.x_root); |
569 | setiv (x_root, xe->xmotion.x_root); |
498 | setiv (y_root, xe->xmotion.y_root); |
570 | setiv (y_root, xe->xmotion.y_root); |
499 | setuv (state, xe->xmotion.state); |
571 | setuv (state, xe->xmotion.state); |
500 | |
572 | |
501 | switch (xe->type) |
573 | switch (xe->type) |
502 | { |
574 | { |
503 | case KeyPress: |
575 | case KeyPress: |
504 | case KeyRelease: |
576 | case KeyRelease: |
505 | setuv (keycode, xe->xkey.keycode); |
577 | setuv (keycode, xe->xkey.keycode); |
506 | break; |
578 | break; |
507 | |
579 | |
508 | case ButtonPress: |
580 | case ButtonPress: |
509 | case ButtonRelease: |
581 | case ButtonRelease: |
510 | setuv (button, xe->xbutton.button); |
582 | setuv (button, xe->xbutton.button); |
511 | break; |
583 | break; |
512 | |
584 | |
513 | case MotionNotify: |
585 | case MotionNotify: |
514 | setiv (is_hint, xe->xmotion.is_hint); |
586 | setiv (is_hint, xe->xmotion.is_hint); |
515 | break; |
587 | break; |
516 | } |
588 | } |
517 | |
589 | |
518 | break; |
590 | break; |
519 | |
591 | |
520 | case MapNotify: |
592 | case MapNotify: |
521 | case UnmapNotify: |
593 | case UnmapNotify: |
522 | case ConfigureNotify: |
594 | case ConfigureNotify: |
523 | setuv (event, xe->xconfigure.event); |
595 | setuv (event, xe->xconfigure.event); |
524 | setuv (window, xe->xconfigure.window); |
596 | setuv (window, xe->xconfigure.window); |
525 | |
597 | |
526 | switch (xe->type) |
598 | switch (xe->type) |
527 | { |
599 | { |
528 | case ConfigureNotify: |
600 | case ConfigureNotify: |
529 | setiv (x, xe->xconfigure.x); |
601 | setiv (x, xe->xconfigure.x); |
530 | setiv (y, xe->xconfigure.y); |
602 | setiv (y, xe->xconfigure.y); |
531 | setiv (width, xe->xconfigure.width); |
603 | setiv (width, xe->xconfigure.width); |
532 | setiv (height, xe->xconfigure.height); |
604 | setiv (height, xe->xconfigure.height); |
533 | setuv (above, xe->xconfigure.above); |
605 | setuv (above, xe->xconfigure.above); |
534 | break; |
606 | break; |
535 | } |
607 | } |
536 | |
608 | |
537 | break; |
609 | break; |
538 | |
610 | |
539 | case PropertyNotify: |
611 | case PropertyNotify: |
540 | setuv (window, xe->xproperty.window); |
612 | setuv (window, xe->xproperty.window); |
541 | setuv (atom, xe->xproperty.atom); |
613 | setuv (atom, xe->xproperty.atom); |
542 | setuv (time, xe->xproperty.time); |
614 | setuv (time, xe->xproperty.time); |
543 | setiv (state, xe->xproperty.state); |
615 | setiv (state, xe->xproperty.state); |
544 | break; |
616 | break; |
545 | |
617 | |
546 | case ClientMessage: |
618 | case ClientMessage: |
547 | setuv (window, xe->xclient.window); |
619 | setuv (window, xe->xclient.window); |
548 | setuv (message_type, xe->xclient.message_type); |
620 | setuv (message_type, xe->xclient.message_type); |
549 | setuv (format, xe->xclient.format); |
621 | setuv (format, xe->xclient.format); |
550 | setuv (l0, xe->xclient.data.l[0]); |
622 | setuv (l0, xe->xclient.data.l[0]); |
551 | setuv (l1, xe->xclient.data.l[1]); |
623 | setuv (l1, xe->xclient.data.l[1]); |
552 | setuv (l2, xe->xclient.data.l[2]); |
624 | setuv (l2, xe->xclient.data.l[2]); |
553 | setuv (l3, xe->xclient.data.l[3]); |
625 | setuv (l3, xe->xclient.data.l[3]); |
554 | setuv (l4, xe->xclient.data.l[4]); |
626 | setuv (l4, xe->xclient.data.l[4]); |
555 | break; |
627 | break; |
556 | } |
628 | } |
557 | |
629 | |
558 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
630 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
559 | } |
631 | } |
560 | break; |
632 | break; |
561 | |
633 | |
562 | case DT_END: |
634 | case DT_END: |
563 | goto call; |
635 | goto call; |
564 | |
636 | |
565 | default: |
637 | default: |
566 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
638 | rxvt_fatal ("FATAL: unable to pass data type %d\n", dt); |
567 | } |
639 | } |
|
|
640 | } |
|
|
641 | |
|
|
642 | call: |
|
|
643 | va_end (ap); |
|
|
644 | |
|
|
645 | PUTBACK; |
|
|
646 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
647 | SPAGAIN; |
|
|
648 | |
|
|
649 | if (count) |
|
|
650 | { |
|
|
651 | SV *status = POPs; |
|
|
652 | count = SvTRUE (status); |
568 | } |
653 | } |
569 | |
654 | |
570 | call: |
|
|
571 | va_end (ap); |
|
|
572 | |
|
|
573 | PUTBACK; |
655 | PUTBACK; |
574 | int count = call_pv ("urxvt::invoke", G_ARRAY | G_EVAL); |
|
|
575 | SPAGAIN; |
|
|
576 | |
|
|
577 | if (count) |
|
|
578 | { |
|
|
579 | SV *status = POPs; |
|
|
580 | count = SvTRUE (status); |
|
|
581 | } |
|
|
582 | |
|
|
583 | PUTBACK; |
|
|
584 | FREETMPS; |
656 | FREETMPS; |
585 | LEAVE; |
657 | LEAVE; |
586 | |
658 | |
587 | if (SvTRUE (ERRSV)) |
659 | if (SvTRUE (ERRSV)) |
588 | { |
660 | { |
589 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
661 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPVbyte_nolen (ERRSV)); |
590 | ungrab (term); // better lose the grab than the session |
662 | ungrab (term); // better lose the grab than the session |
591 | } |
663 | } |
592 | |
664 | |
593 | event_consumed = !!count; |
665 | event_consumed = !!count; |
594 | } |
666 | } |
595 | catch (...) |
|
|
596 | { |
|
|
597 | swap (perl_environ, environ); |
|
|
598 | throw; |
|
|
599 | } |
|
|
600 | else |
667 | else |
601 | event_consumed = false; |
668 | event_consumed = false; |
602 | |
669 | |
603 | // post-handling of some events |
670 | // post-handling of some events |
604 | if (htype == HOOK_REFRESH_BEGIN) |
671 | if (htype == HOOK_REFRESH_BEGIN) |
… | |
… | |
615 | |
682 | |
616 | // don't allow further calls |
683 | // don't allow further calls |
617 | term->perl.self = 0; |
684 | term->perl.self = 0; |
618 | } |
685 | } |
619 | |
686 | |
620 | swap (perl_environ, environ); |
|
|
621 | |
|
|
622 | return event_consumed; |
687 | return event_consumed; |
|
|
688 | } |
|
|
689 | |
|
|
690 | void |
|
|
691 | rxvt_perl_interp::selection_finish (rxvt_selection *sel, char *data, unsigned int len) |
|
|
692 | { |
|
|
693 | localise_env set_environ (perl_environ); |
|
|
694 | |
|
|
695 | ENTER; |
|
|
696 | SAVETMPS; |
|
|
697 | |
|
|
698 | dSP; |
|
|
699 | XPUSHs (sv_2mortal (newSVpvn (data, len))); |
|
|
700 | PUTBACK; |
|
|
701 | call_sv ((SV *)sel->cb_sv, G_VOID | G_DISCARD | G_EVAL); |
|
|
702 | |
|
|
703 | if (SvTRUE (ERRSV)) |
|
|
704 | rxvt_warn ("perl selection callback evaluation error: %s", SvPVbyte_nolen (ERRSV)); |
|
|
705 | |
|
|
706 | FREETMPS; |
|
|
707 | LEAVE; |
623 | } |
708 | } |
624 | |
709 | |
625 | ///////////////////////////////////////////////////////////////////////////// |
710 | ///////////////////////////////////////////////////////////////////////////// |
626 | |
711 | |
627 | MODULE = urxvt PACKAGE = urxvt |
712 | MODULE = urxvt PACKAGE = urxvt |
… | |
… | |
639 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
724 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
640 | # include "hookinc.h" |
725 | # include "hookinc.h" |
641 | # undef def |
726 | # undef def |
642 | |
727 | |
643 | HV *option = get_hv ("urxvt::OPTION", 1); |
728 | HV *option = get_hv ("urxvt::OPTION", 1); |
644 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
729 | # define def(name) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
645 | # define nodef(name) |
730 | # define nodef(name) |
646 | # include "optinc.h" |
731 | # include "optinc.h" |
647 | # undef nodef |
732 | # undef nodef |
648 | # undef def |
733 | # undef def |
649 | |
734 | |
… | |
… | |
654 | } *civ, const_iv[] = { |
739 | } *civ, const_iv[] = { |
655 | # define const_iv(name) { # name, (IV)name } |
740 | # define const_iv(name) { # name, (IV)name } |
656 | const_iv (NUM_RESOURCES), |
741 | const_iv (NUM_RESOURCES), |
657 | const_iv (DEFAULT_RSTYLE), |
742 | const_iv (DEFAULT_RSTYLE), |
658 | const_iv (OVERLAY_RSTYLE), |
743 | const_iv (OVERLAY_RSTYLE), |
|
|
744 | const_iv (Color_Bits), |
|
|
745 | const_iv (RS_bgShift), const_iv (RS_bgMask), |
|
|
746 | const_iv (RS_fgShift), const_iv (RS_fgMask), |
|
|
747 | const_iv (RS_Careful), |
|
|
748 | const_iv (RS_fontCount), |
|
|
749 | const_iv (RS_fontShift), |
|
|
750 | const_iv (RS_fontMask), |
|
|
751 | const_iv (RS_baseattrMask), |
|
|
752 | const_iv (RS_attrMask), |
|
|
753 | const_iv (RS_redraw), |
|
|
754 | const_iv (RS_Sel), |
659 | const_iv (RS_Bold), |
755 | const_iv (RS_Bold), |
660 | const_iv (RS_Italic), |
756 | const_iv (RS_Italic), |
661 | const_iv (RS_Blink), |
757 | const_iv (RS_Blink), |
662 | const_iv (RS_RVid), |
758 | const_iv (RS_RVid), |
663 | const_iv (RS_Uline), |
759 | const_iv (RS_Uline), |
… | |
… | |
750 | const_iv (XIMSecondary), |
846 | const_iv (XIMSecondary), |
751 | const_iv (XIMTertiary), |
847 | const_iv (XIMTertiary), |
752 | const_iv (XIMVisibleToForward), |
848 | const_iv (XIMVisibleToForward), |
753 | const_iv (XIMVisibleToBackword), |
849 | const_iv (XIMVisibleToBackword), |
754 | const_iv (XIMVisibleToCenter), |
850 | const_iv (XIMVisibleToCenter), |
|
|
851 | #if XRENDER |
|
|
852 | const_iv (PictStandardARGB32), |
|
|
853 | const_iv (PictStandardRGB24), |
|
|
854 | const_iv (PictStandardA8), |
|
|
855 | const_iv (PictStandardA4), |
|
|
856 | const_iv (PictStandardA1), |
|
|
857 | const_iv (RepeatNone), |
|
|
858 | const_iv (RepeatNormal), |
|
|
859 | const_iv (RepeatPad), |
|
|
860 | const_iv (RepeatReflect), |
|
|
861 | #endif |
755 | # if 0 |
862 | # if 0 |
756 | const_iv (XIMForwardChar), |
863 | const_iv (XIMForwardChar), |
757 | const_iv (XIMBackwardChar), |
864 | const_iv (XIMBackwardChar), |
758 | const_iv (XIMForwardWord), |
865 | const_iv (XIMForwardWord), |
759 | const_iv (XIMBackwardWord), |
866 | const_iv (XIMBackwardWord), |
… | |
… | |
767 | const_iv (XIMDontChange), |
874 | const_iv (XIMDontChange), |
768 | # endif |
875 | # endif |
769 | # endif |
876 | # endif |
770 | }; |
877 | }; |
771 | |
878 | |
772 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
879 | for (civ = const_iv + ecb_array_length (const_iv); civ > const_iv; civ--) |
773 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
880 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
774 | } |
881 | } |
775 | |
882 | |
776 | void |
883 | void |
777 | warn (const char *msg) |
884 | warn (const char *msg) |
778 | CODE: |
885 | CODE: |
… | |
… | |
783 | CODE: |
890 | CODE: |
784 | rxvt_fatal ("%s", msg); |
891 | rxvt_fatal ("%s", msg); |
785 | |
892 | |
786 | void |
893 | void |
787 | _exit (int status) |
894 | _exit (int status) |
|
|
895 | |
|
|
896 | void |
|
|
897 | catch_fatal (SV *block) |
|
|
898 | PROTOTYPE: & |
|
|
899 | CODE: |
|
|
900 | try |
|
|
901 | { |
|
|
902 | PUSHMARK (SP); |
|
|
903 | PUTBACK; |
|
|
904 | call_sv (block, G_VOID | G_DISCARD); |
|
|
905 | SPAGAIN; |
|
|
906 | } |
|
|
907 | catch (const rxvt_failure_exception &e) |
|
|
908 | { |
|
|
909 | croak ("rxvt_fatal exception caught, trying to continue."); |
|
|
910 | } |
788 | |
911 | |
789 | NV |
912 | NV |
790 | NOW () |
913 | NOW () |
791 | CODE: |
914 | CODE: |
792 | RETVAL = ev::now (); |
915 | RETVAL = ev::now (); |
… | |
… | |
850 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
973 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
851 | if ((*t)->perl.self) |
974 | if ((*t)->perl.self) |
852 | PUSHs (sv_2mortal (newSVterm (*t))); |
975 | PUSHs (sv_2mortal (newSVterm (*t))); |
853 | } |
976 | } |
854 | |
977 | |
|
|
978 | IV |
|
|
979 | _new_selection_request (rxvt_term *term, int selnum, Time tm, Window win, Atom prop, SV *cb) |
|
|
980 | CODE: |
|
|
981 | rxvt_selection *req = new rxvt_selection (term->display, selnum, tm, win, prop, term); |
|
|
982 | req->cb_sv = newSVsv (cb); |
|
|
983 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_selection", 10, 0)); |
|
|
984 | av_push (av, newSViv ((IV)req)); |
|
|
985 | RETVAL = (IV)req; |
|
|
986 | OUTPUT: |
|
|
987 | RETVAL |
|
|
988 | |
|
|
989 | void |
|
|
990 | _delete_selection_request (IV req_) |
|
|
991 | CODE: |
|
|
992 | rxvt_selection *req = (rxvt_selection *)req_; |
|
|
993 | AV *av = (AV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)req->term->perl.self), "_selection", 10, 0)); |
|
|
994 | int i; |
|
|
995 | |
|
|
996 | for (i = AvFILL (av); i >= 0; i--) |
|
|
997 | if (SvIV (*av_fetch (av, i, 1)) == req_) |
|
|
998 | break; |
|
|
999 | |
|
|
1000 | for (; i < AvFILL (av); i++) |
|
|
1001 | av_store (av, i, SvREFCNT_inc (*av_fetch (av, i + 1, 0))); |
|
|
1002 | |
|
|
1003 | av_pop (av); |
|
|
1004 | |
|
|
1005 | delete req; |
|
|
1006 | |
855 | MODULE = urxvt PACKAGE = urxvt::term |
1007 | MODULE = urxvt PACKAGE = urxvt::term |
856 | |
1008 | |
857 | SV * |
1009 | SV * |
858 | _new (AV *env, AV *arg) |
1010 | _new (AV *env, AV *arg) |
859 | CODE: |
1011 | CODE: |
860 | { |
1012 | { |
861 | rxvt_term *term = new rxvt_term; |
1013 | rxvt_term *term = new rxvt_term; |
862 | |
1014 | |
863 | stringvec *argv = new stringvec; |
1015 | stringvec *argv = new stringvec; |
864 | stringvec *envv = new stringvec; |
|
|
865 | |
|
|
866 | for (int i = 0; i <= AvFILL (arg); i++) |
1016 | for (int i = 0; i <= AvFILL (arg); i++) |
867 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
1017 | argv->push_back (strdup (SvPVbyte_nolen (*av_fetch (arg, i, 1)))); |
868 | |
1018 | |
|
|
1019 | stringvec *envv = new stringvec; |
869 | for (int i = AvFILL (env) + 1; i--; ) |
1020 | for (int i = AvFILL (env) + 1; i--; ) |
870 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
1021 | envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (env, i, 1)))); |
871 | |
1022 | |
872 | envv->push_back (0); |
|
|
873 | |
|
|
874 | try |
1023 | try |
875 | { |
1024 | { |
876 | term->init (argv, envv); |
1025 | term->init (argv, envv); |
877 | } |
1026 | } |
878 | catch (const class rxvt_failure_exception &e) |
1027 | catch (const class rxvt_failure_exception &e) |
… | |
… | |
891 | rxvt_term::destroy () |
1040 | rxvt_term::destroy () |
892 | |
1041 | |
893 | void |
1042 | void |
894 | rxvt_term::set_should_invoke (int htype, int inc) |
1043 | rxvt_term::set_should_invoke (int htype, int inc) |
895 | CODE: |
1044 | CODE: |
896 | THIS->perl.should_invoke [htype] += inc; |
1045 | uint8_t &count = THIS->perl.should_invoke [htype]; |
|
|
1046 | uint8_t prev = count; |
|
|
1047 | count += inc; |
|
|
1048 | if (!prev != !count) |
|
|
1049 | { |
|
|
1050 | // hook status changed, react |
|
|
1051 | switch (htype) |
|
|
1052 | { |
|
|
1053 | case HOOK_POSITION_CHANGE: |
|
|
1054 | if (count) |
|
|
1055 | THIS->get_window_origin (THIS->parent_x, THIS->parent_y); |
|
|
1056 | } |
|
|
1057 | } |
897 | |
1058 | |
898 | int |
1059 | int |
899 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
1060 | rxvt_term::grab_button (int button, U32 modifiers, Window window = THIS->vt) |
900 | CODE: |
1061 | CODE: |
901 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
1062 | RETVAL = XGrabButton (THIS->dpy, button, modifiers, window, 1, |
… | |
… | |
917 | |
1078 | |
918 | void |
1079 | void |
919 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
1080 | rxvt_term::XUngrabKey (int keycode, U32 modifiers, Window window = THIS->vt) |
920 | CODE: |
1081 | CODE: |
921 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
1082 | XUngrabKey (THIS->dpy, keycode, modifiers, window); |
922 | |
|
|
923 | void |
|
|
924 | rxvt_term::XUngrabKeyboard (Time eventtime) |
|
|
925 | CODE: |
|
|
926 | XUngrabKeyboard (THIS->dpy, eventtime); |
|
|
927 | |
1083 | |
928 | bool |
1084 | bool |
929 | rxvt_term::grab (Time eventtime, int sync = 0) |
1085 | rxvt_term::grab (Time eventtime, int sync = 0) |
930 | CODE: |
1086 | CODE: |
931 | { |
1087 | { |
… | |
… | |
1043 | rxvt_pop_locale (); |
1199 | rxvt_pop_locale (); |
1044 | |
1200 | |
1045 | RETVAL = wcs2sv (wstr); |
1201 | RETVAL = wcs2sv (wstr); |
1046 | free (wstr); |
1202 | free (wstr); |
1047 | } |
1203 | } |
1048 | OUTPUT: |
|
|
1049 | RETVAL |
|
|
1050 | |
|
|
1051 | char * |
|
|
1052 | rxvt_term::locale () |
|
|
1053 | CODE: |
|
|
1054 | RETVAL = THIS->locale; |
|
|
1055 | OUTPUT: |
1204 | OUTPUT: |
1056 | RETVAL |
1205 | RETVAL |
1057 | |
1206 | |
1058 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1207 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
1059 | |
1208 | |
… | |
… | |
1166 | RETVAL |
1315 | RETVAL |
1167 | |
1316 | |
1168 | Window |
1317 | Window |
1169 | rxvt_term::parent () |
1318 | rxvt_term::parent () |
1170 | CODE: |
1319 | CODE: |
1171 | RETVAL = THIS->parent [0]; |
1320 | RETVAL = THIS->parent; |
1172 | OUTPUT: |
1321 | OUTPUT: |
1173 | RETVAL |
1322 | RETVAL |
1174 | |
1323 | |
1175 | Window |
1324 | int |
1176 | rxvt_term::vt () |
1325 | rxvt_term::parent_x () |
1177 | CODE: |
1326 | CODE: |
1178 | RETVAL = THIS->vt; |
1327 | RETVAL = THIS->parent_x; |
|
|
1328 | OUTPUT: |
|
|
1329 | RETVAL |
|
|
1330 | |
|
|
1331 | int |
|
|
1332 | rxvt_term::parent_y () |
|
|
1333 | CODE: |
|
|
1334 | RETVAL = THIS->parent_y; |
1179 | OUTPUT: |
1335 | OUTPUT: |
1180 | RETVAL |
1336 | RETVAL |
1181 | |
1337 | |
1182 | void |
1338 | void |
1183 | rxvt_term::vt_emask_add (U32 emask) |
1339 | rxvt_term::vt_emask_add (U32 emask) |
… | |
… | |
1203 | if (newval <= 0) |
1359 | if (newval <= 0) |
1204 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1360 | THIS->scr_changeview (max (newval, THIS->top_row)); |
1205 | } |
1361 | } |
1206 | OUTPUT: |
1362 | OUTPUT: |
1207 | RETVAL |
1363 | RETVAL |
|
|
1364 | |
|
|
1365 | void |
|
|
1366 | rxvt_term::set_urgency (bool enable) |
1208 | |
1367 | |
1209 | void |
1368 | void |
1210 | rxvt_term::focus_in () |
1369 | rxvt_term::focus_in () |
1211 | |
1370 | |
1212 | void |
1371 | void |
… | |
… | |
1445 | # include "rsinc.h" |
1604 | # include "rsinc.h" |
1446 | # undef def |
1605 | # undef def |
1447 | # undef reserve |
1606 | # undef reserve |
1448 | }; |
1607 | }; |
1449 | |
1608 | |
1450 | rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1609 | rs = rslist + ecb_array_length (rslist); |
1451 | |
1610 | |
1452 | if (*name) |
1611 | if (*name) |
1453 | { |
1612 | { |
1454 | do { |
1613 | do { |
1455 | if (rs-- == rslist) |
1614 | if (rs-- == rslist) |
… | |
… | |
1494 | |
1653 | |
1495 | if (set >= 0) |
1654 | if (set >= 0) |
1496 | { |
1655 | { |
1497 | THIS->set_option (optval, set); |
1656 | THIS->set_option (optval, set); |
1498 | |
1657 | |
1499 | if (THIS->env_colorfgbg [0]) // avoid doing this before START |
1658 | if (THIS->init_done) // avoid doing this before START |
1500 | switch (optval) |
1659 | switch (optval) |
1501 | { |
1660 | { |
1502 | case Opt_skipBuiltinGlyphs: |
1661 | case Opt_skipBuiltinGlyphs: |
1503 | THIS->set_fonts (); |
1662 | THIS->set_fonts (); |
1504 | THIS->scr_remap_chars (); |
1663 | THIS->scr_remap_chars (); |
1505 | THIS->scr_touch (true); |
1664 | THIS->scr_touch (true); |
1506 | THIS->want_refresh = 1; |
1665 | THIS->want_refresh = 1; |
1507 | THIS->refresh_check (); |
1666 | THIS->refresh_check (); |
1508 | break; |
1667 | break; |
|
|
1668 | #ifdef CURSOR_BLINK |
|
|
1669 | case Opt_cursorBlink: |
|
|
1670 | THIS->cursor_blink_reset (); |
|
|
1671 | break; |
|
|
1672 | #endif |
1509 | |
1673 | |
1510 | case Opt_cursorUnderline: |
1674 | case Opt_cursorUnderline: |
1511 | THIS->want_refresh = 1; |
1675 | THIS->want_refresh = 1; |
1512 | THIS->refresh_check (); |
1676 | THIS->refresh_check (); |
1513 | break; |
1677 | break; |
… | |
… | |
1527 | CODE: |
1691 | CODE: |
1528 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1692 | RETVAL = 0 < THIS->parse_keysym (keysym, str); |
1529 | THIS->keyboard->register_done (); |
1693 | THIS->keyboard->register_done (); |
1530 | OUTPUT: |
1694 | OUTPUT: |
1531 | RETVAL |
1695 | RETVAL |
|
|
1696 | |
|
|
1697 | void |
|
|
1698 | rxvt_term::register_command (int keysym, unsigned int state, SV *str) |
|
|
1699 | CODE: |
|
|
1700 | wchar_t *wstr = sv2wcs (str); |
|
|
1701 | THIS->keyboard->register_user_translation (keysym, state, wstr); |
|
|
1702 | free (wstr); |
1532 | |
1703 | |
1533 | void |
1704 | void |
1534 | rxvt_term::screen_cur (...) |
1705 | rxvt_term::screen_cur (...) |
1535 | PROTOTYPE: $;$$ |
1706 | PROTOTYPE: $;$$ |
1536 | ALIAS: |
1707 | ALIAS: |
… | |
… | |
1597 | |
1768 | |
1598 | void |
1769 | void |
1599 | rxvt_term::selection_clear (bool clipboard = false) |
1770 | rxvt_term::selection_clear (bool clipboard = false) |
1600 | |
1771 | |
1601 | void |
1772 | void |
1602 | rxvt_term::clipboard_copy (Time eventtime) |
|
|
1603 | |
|
|
1604 | void |
|
|
1605 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1773 | rxvt_term::selection_make (Time eventtime, bool rect = false) |
1606 | CODE: |
1774 | CODE: |
1607 | THIS->selection.op = SELECTION_CONT; |
1775 | THIS->selection.op = SELECTION_CONT; |
1608 | THIS->selection.rect = rect; |
1776 | THIS->selection.rect = rect; |
1609 | THIS->selection_make (eventtime); |
1777 | THIS->selection_make (eventtime); |
1610 | |
1778 | |
1611 | int |
1779 | int |
1612 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1780 | rxvt_term::selection_grab (Time eventtime, bool clipboard = false) |
1613 | |
1781 | |
1614 | void |
1782 | void |
1615 | rxvt_term::selection (SV *newtext = 0) |
1783 | rxvt_term::selection (SV *newtext = 0, bool clipboard = false) |
1616 | PPCODE: |
1784 | PPCODE: |
1617 | { |
1785 | { |
|
|
1786 | wchar_t * &text = clipboard ? THIS->selection.clip_text : THIS->selection.text; |
|
|
1787 | unsigned int &len = clipboard ? THIS->selection.clip_len : THIS->selection.len; |
|
|
1788 | |
1618 | if (GIMME_V != G_VOID) |
1789 | if (GIMME_V != G_VOID) |
1619 | XPUSHs (THIS->selection.text |
1790 | XPUSHs (text |
1620 | ? sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)) |
1791 | ? sv_2mortal (wcs2sv (text, len)) |
1621 | : &PL_sv_undef); |
1792 | : &PL_sv_undef); |
1622 | |
1793 | |
1623 | if (newtext) |
1794 | if (newtext) |
1624 | { |
1795 | { |
1625 | free (THIS->selection.text); |
1796 | free (text); |
1626 | |
1797 | |
1627 | THIS->selection.text = sv2wcs (newtext); |
1798 | text = sv2wcs (newtext); |
1628 | THIS->selection.len = wcslen (THIS->selection.text); |
1799 | len = wcslen (text); |
1629 | } |
1800 | } |
1630 | } |
1801 | } |
1631 | |
1802 | |
1632 | char |
1803 | char |
1633 | rxvt_term::cur_charset () |
1804 | rxvt_term::cur_charset () |
… | |
… | |
1642 | void |
1813 | void |
1643 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1814 | rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, U32 rstyle = RS_RVid) |
1644 | |
1815 | |
1645 | void |
1816 | void |
1646 | rxvt_term::scr_bell () |
1817 | rxvt_term::scr_bell () |
|
|
1818 | |
|
|
1819 | void |
|
|
1820 | rxvt_term::scr_recolour (bool refresh = true); |
1647 | |
1821 | |
1648 | void |
1822 | void |
1649 | rxvt_term::scr_change_screen (int screen) |
1823 | rxvt_term::scr_change_screen (int screen) |
1650 | |
1824 | |
1651 | void |
1825 | void |
… | |
… | |
1664 | char *str = SvPVbyte (octets, len); |
1838 | char *str = SvPVbyte (octets, len); |
1665 | C_ARGS: |
1839 | C_ARGS: |
1666 | str, len |
1840 | str, len |
1667 | |
1841 | |
1668 | void |
1842 | void |
|
|
1843 | rxvt_term::tt_paste (SV *octets) |
|
|
1844 | INIT: |
|
|
1845 | STRLEN len; |
|
|
1846 | char *str = SvPVbyte (octets, len); |
|
|
1847 | C_ARGS: |
|
|
1848 | str, len |
|
|
1849 | |
|
|
1850 | void |
1669 | rxvt_term::cmd_parse (SV *octets) |
1851 | rxvt_term::cmd_parse (SV *octets) |
1670 | CODE: |
1852 | CODE: |
1671 | { |
1853 | { |
1672 | STRLEN len; |
1854 | STRLEN len; |
1673 | char *str = SvPVbyte (octets, len); |
1855 | char *str = SvPVbyte (octets, len); |
… | |
… | |
1758 | type, format, PropModeReplace, |
1940 | type, format, PropModeReplace, |
1759 | (unsigned char *)data_, len / elemsize); |
1941 | (unsigned char *)data_, len / elemsize); |
1760 | } |
1942 | } |
1761 | |
1943 | |
1762 | Atom |
1944 | Atom |
1763 | XInternAtom (rxvt_term *term, char *atom_name, int only_if_exists = FALSE) |
1945 | XInternAtom (rxvt_term *term, octet_string atom_name, int only_if_exists = FALSE) |
1764 | C_ARGS: term->dpy, atom_name, only_if_exists |
1946 | C_ARGS: term->dpy, atom_name, only_if_exists |
1765 | |
1947 | |
1766 | char * |
1948 | char * |
1767 | XGetAtomName (rxvt_term *term, Atom atom) |
1949 | XGetAtomName (rxvt_term *term, Atom atom) |
1768 | C_ARGS: term->dpy, atom |
1950 | C_ARGS: term->dpy, atom |
1769 | CLEANUP: |
1951 | CLEANUP: |
1770 | XFree (RETVAL); |
1952 | XFree (RETVAL); |
1771 | |
1953 | |
1772 | void |
1954 | void |
1773 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1955 | XDeleteProperty (rxvt_term *term, Window window, Atom property) |
1774 | C_ARGS: term->dpy, window, property |
1956 | C_ARGS: term->dpy, window, property |
1775 | |
1957 | |
1776 | Window |
1958 | Window |
1777 | rxvt_term::DefaultRootWindow () |
1959 | rxvt_term::DefaultRootWindow () |
1778 | CODE: |
1960 | CODE: |
1779 | RETVAL = THIS->display->root; |
1961 | RETVAL = THIS->display->root; |
… | |
… | |
1831 | PUSHs (newSVuv (child)); |
2013 | PUSHs (newSVuv (child)); |
1832 | } |
2014 | } |
1833 | } |
2015 | } |
1834 | |
2016 | |
1835 | ############################################################################# |
2017 | ############################################################################# |
|
|
2018 | # fancy bg bloatstuff (TODO: should be moved up somewhere) |
|
|
2019 | |
|
|
2020 | # TODO: ugly |
|
|
2021 | void |
|
|
2022 | rxvt_term::get_geometry () |
|
|
2023 | PPCODE: |
|
|
2024 | EXTEND (SP, 4); |
|
|
2025 | PUSHs (sv_2mortal (newSViv (THIS->parent_x))); |
|
|
2026 | PUSHs (sv_2mortal (newSViv (THIS->parent_y))); |
|
|
2027 | PUSHs (sv_2mortal (newSViv (THIS->szHint.width))); |
|
|
2028 | PUSHs (sv_2mortal (newSViv (THIS->szHint.height))); |
|
|
2029 | |
|
|
2030 | #if HAVE_IMG |
|
|
2031 | |
|
|
2032 | rxvt_img * |
|
|
2033 | rxvt_term::new_img (SV *format, int width, int height) |
|
|
2034 | CODE: |
|
|
2035 | XRenderPictFormat *f = SvOK (format) |
|
|
2036 | ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) |
|
|
2037 | : XRenderFindVisualFormat (THIS->dpy, THIS->visual); |
|
|
2038 | RETVAL = new rxvt_img (THIS, f, width, height); |
|
|
2039 | OUTPUT: |
|
|
2040 | RETVAL |
|
|
2041 | |
|
|
2042 | #if ENABLE_TRANSPARENCY |
|
|
2043 | |
|
|
2044 | #if 0 |
|
|
2045 | |
|
|
2046 | rxvt_img * |
|
|
2047 | rxvt_term::new_img_from_root () |
|
|
2048 | CODE: |
|
|
2049 | RETVAL = rxvt_img::new_from_root (THIS); |
|
|
2050 | OUTPUT: |
|
|
2051 | RETVAL |
|
|
2052 | |
|
|
2053 | #endif |
|
|
2054 | |
|
|
2055 | #endif |
|
|
2056 | |
|
|
2057 | #if HAVE_PIXBUF |
|
|
2058 | |
|
|
2059 | rxvt_img * |
|
|
2060 | rxvt_term::new_img_from_file (octet_string filename) |
|
|
2061 | CODE: |
|
|
2062 | try |
|
|
2063 | { |
|
|
2064 | RETVAL = rxvt_img::new_from_file (THIS, filename); |
|
|
2065 | } |
|
|
2066 | catch (const class rxvt_failure_exception &e) |
|
|
2067 | { |
|
|
2068 | croak ("new_img_from_file failed"); |
|
|
2069 | } |
|
|
2070 | OUTPUT: |
|
|
2071 | RETVAL |
|
|
2072 | |
|
|
2073 | #endif |
|
|
2074 | |
|
|
2075 | #if HAVE_BG_PIXMAP |
|
|
2076 | |
|
|
2077 | void |
|
|
2078 | rxvt_term::set_background (rxvt_img *img) |
|
|
2079 | CODE: |
|
|
2080 | THIS->bg_destroy (); |
|
|
2081 | THIS->bg_pixmap = None; |
|
|
2082 | THIS->bg_flags &= ~rxvt_term::BG_NEEDS_REFRESH; |
|
|
2083 | |
|
|
2084 | if (img) // TODO: cannot be false |
|
|
2085 | { |
|
|
2086 | img->unshare (); |
|
|
2087 | THIS->bg_pixmap = img->steal (); |
|
|
2088 | THIS->bg_flags |= rxvt_term::BG_NEEDS_REFRESH; |
|
|
2089 | THIS->bg_valid_since = ev::now (); // TODO: extra bloat |
|
|
2090 | } |
|
|
2091 | |
|
|
2092 | #endif |
|
|
2093 | |
|
|
2094 | #endif |
|
|
2095 | |
|
|
2096 | ############################################################################# |
1836 | # urxvt::overlay |
2097 | # urxvt::overlay |
1837 | ############################################################################# |
2098 | ############################################################################# |
1838 | |
2099 | |
1839 | MODULE = urxvt PACKAGE = urxvt::overlay |
2100 | MODULE = urxvt PACKAGE = urxvt::overlay |
1840 | |
2101 | |
… | |
… | |
1850 | void |
2111 | void |
1851 | overlay::DESTROY () |
2112 | overlay::DESTROY () |
1852 | |
2113 | |
1853 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
2114 | INCLUDE: $PERL <iom_perl.xs -pe s/IOM_MODULE/urxvt/g,s/IOM_CLASS/urxvt/g | |
1854 | |
2115 | |
|
|
2116 | MODULE = urxvt PACKAGE = urxvt::pixbuf PREFIX = gdk_pixbuf_ |
|
|
2117 | |
|
|
2118 | #if HAVE_PIXBUF |
|
|
2119 | |
|
|
2120 | urxvt::pixbuf gdk_pixbuf_new_from_file (SV *klass, octet_string filename) |
|
|
2121 | C_ARGS: filename, 0 |
|
|
2122 | |
|
|
2123 | void |
|
|
2124 | DESTROY (urxvt::pixbuf self) |
|
|
2125 | CODE: |
|
|
2126 | gdk_pixbuf_unref (self); |
|
|
2127 | |
|
|
2128 | #endif |
|
|
2129 | |
|
|
2130 | MODULE = urxvt PACKAGE = urxvt::img |
|
|
2131 | |
|
|
2132 | #if HAVE_IMG |
|
|
2133 | |
|
|
2134 | # rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) |
|
|
2135 | # rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); |
|
|
2136 | |
|
|
2137 | int |
|
|
2138 | rxvt_img::w () |
|
|
2139 | CODE: |
|
|
2140 | RETVAL = THIS->w; |
|
|
2141 | OUTPUT: |
|
|
2142 | RETVAL |
|
|
2143 | |
|
|
2144 | int |
|
|
2145 | rxvt_img::h () |
|
|
2146 | CODE: |
|
|
2147 | RETVAL = THIS->h; |
|
|
2148 | OUTPUT: |
|
|
2149 | RETVAL |
|
|
2150 | |
|
|
2151 | bool |
|
|
2152 | rxvt_img::shared () |
|
|
2153 | CODE: |
|
|
2154 | RETVAL = THIS->shared; |
|
|
2155 | OUTPUT: |
|
|
2156 | RETVAL |
|
|
2157 | |
|
|
2158 | Pixmap |
|
|
2159 | rxvt_img::pm () |
|
|
2160 | CODE: |
|
|
2161 | RETVAL = THIS->pm; |
|
|
2162 | OUTPUT: |
|
|
2163 | RETVAL |
|
|
2164 | |
|
|
2165 | void |
|
|
2166 | rxvt_img::fill (SV *c) |
|
|
2167 | INIT: |
|
|
2168 | rxvt_color rc; |
|
|
2169 | parse_color (THIS->s, rc, c); |
|
|
2170 | C_ARGS: rc |
|
|
2171 | |
|
|
2172 | void |
|
|
2173 | rxvt_img::DESTROY () |
|
|
2174 | CODE: |
|
|
2175 | delete THIS; |
|
|
2176 | |
|
|
2177 | rxvt_img * |
|
|
2178 | rxvt_img::blur (int rh, int rv) |
|
|
2179 | |
|
|
2180 | void |
|
|
2181 | rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) |
|
|
2182 | |
|
|
2183 | void |
|
|
2184 | rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) |
|
|
2185 | |
|
|
2186 | void |
|
|
2187 | rxvt_img::unshare () |
|
|
2188 | |
|
|
2189 | rxvt_img * |
|
|
2190 | rxvt_img::clone () |
|
|
2191 | |
|
|
2192 | rxvt_img * |
|
|
2193 | rxvt_img::sub_rect (int x, int y, int width, int height, render_repeat_mode repeat = RepeatNormal) |
|
|
2194 | |
|
|
2195 | rxvt_img * |
|
|
2196 | rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33, render_repeat_mode repeat = RepeatNormal) |
|
|
2197 | INIT: |
|
|
2198 | double matrix[9] = { |
|
|
2199 | p11, p12, p13, |
|
|
2200 | p21, p22, p23, |
|
|
2201 | p31, p32, p33 |
|
|
2202 | }; |
|
|
2203 | C_ARGS: new_width, new_height, matrix, repeat |
|
|
2204 | |
|
|
2205 | rxvt_img * |
|
|
2206 | rxvt_img::scale (int new_width, int new_height) |
|
|
2207 | |
|
|
2208 | rxvt_img * |
|
|
2209 | rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi, render_repeat_mode repeat = RepeatNormal) |
|
|
2210 | |
|
|
2211 | #endif |
|
|
2212 | |