1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: rxvtperl.xs |
2 | * File: rxvtperl.xs |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2005 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
26 | #include <XSUB.h> |
26 | #include <XSUB.h> |
27 | #undef line_t |
27 | #undef line_t |
28 | |
28 | |
29 | #include "../config.h" |
29 | #include "../config.h" |
30 | |
30 | |
|
|
31 | #include <cstddef> |
31 | #include <cstdarg> |
32 | #include <cstdarg> |
32 | |
33 | |
33 | #include "rxvt.h" |
34 | #include "rxvt.h" |
34 | #include "iom.h" |
35 | #include "iom.h" |
35 | #include "rxvtutil.h" |
36 | #include "rxvtutil.h" |
36 | #include "rxvtperl.h" |
37 | #include "rxvtperl.h" |
37 | |
38 | |
38 | #include "perlxsi.c" |
39 | #include "perlxsi.c" |
39 | |
40 | |
|
|
41 | #if defined(HAVE_SCROLLBARS) || defined(MENUBAR) |
|
|
42 | # define GRAB_CURSOR THIS->leftptr_cursor |
|
|
43 | #else |
|
|
44 | # define GRAB_CURSOR None |
|
|
45 | #endif |
|
|
46 | |
40 | #undef LINENO |
47 | #undef LINENO |
41 | #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) |
42 | #undef ROW |
49 | #undef ROW |
43 | #define ROW(n) THIS->row_buf [LINENO (n)] |
50 | #define ROW(n) THIS->row_buf [LINENO (n)] |
44 | |
51 | |
… | |
… | |
101 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
108 | croak ("perl code used %s object, but C++ object is already destroyed, caught", klass); |
102 | |
109 | |
103 | return (long)mg->mg_ptr; |
110 | return (long)mg->mg_ptr; |
104 | } |
111 | } |
105 | |
112 | |
106 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
113 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
107 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
114 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
108 | |
115 | |
109 | ///////////////////////////////////////////////////////////////////////////// |
116 | ///////////////////////////////////////////////////////////////////////////// |
110 | |
117 | |
111 | struct perl_watcher |
118 | struct perl_watcher |
… | |
… | |
290 | void |
297 | void |
291 | overlay::show () |
298 | overlay::show () |
292 | { |
299 | { |
293 | char key[33]; sprintf (key, "%32lx", (long)this); |
300 | char key[33]; sprintf (key, "%32lx", (long)this); |
294 | |
301 | |
295 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0)); |
302 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0)); |
296 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
303 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
297 | } |
304 | } |
298 | |
305 | |
299 | void |
306 | void |
300 | overlay::hide () |
307 | overlay::hide () |
301 | { |
308 | { |
302 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->self), "_overlay", 8, 0); |
309 | SV **ovs = hv_fetch ((HV *)SvRV ((SV *)THIS->perl.self), "_overlay", 8, 0); |
303 | |
310 | |
304 | if (ovs) |
311 | if (ovs) |
305 | { |
312 | { |
306 | char key[33]; sprintf (key, "%32lx", (long)this); |
313 | char key[33]; sprintf (key, "%32lx", (long)this); |
307 | |
314 | |
… | |
… | |
415 | if (!perl) |
422 | if (!perl) |
416 | return false; |
423 | return false; |
417 | |
424 | |
418 | if (htype == HOOK_INIT) // first hook ever called |
425 | if (htype == HOOK_INIT) // first hook ever called |
419 | { |
426 | { |
420 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
427 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
421 | hv_store ((HV *)SvRV ((SV *)term->self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
428 | hv_store ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, newRV_noinc ((SV *)newHV ()), 0); |
422 | } |
429 | } |
423 | else if (!term->self) |
430 | else if (!term->perl.self) |
424 | return false; // perl not initialized for this instance |
431 | return false; // perl not initialized for this instance |
425 | else if (htype == HOOK_DESTROY) |
432 | else if (htype == HOOK_DESTROY) |
426 | { |
433 | { |
427 | // handled later |
434 | // handled later |
428 | } |
435 | } |
429 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
436 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
430 | { |
437 | { |
431 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->self), "_overlay", 8, 0)); |
438 | HV *hv = (HV *)SvRV (*hv_fetch ((HV *)SvRV ((SV *)term->perl.self), "_overlay", 8, 0)); |
432 | |
439 | |
433 | if (HvKEYS (hv)) |
440 | if (HvKEYS (hv)) |
434 | { |
441 | { |
435 | hv_iterinit (hv); |
442 | hv_iterinit (hv); |
436 | |
443 | |
… | |
… | |
465 | |
472 | |
466 | case DT_LONG: |
473 | case DT_LONG: |
467 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
474 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
468 | break; |
475 | break; |
469 | |
476 | |
470 | case DT_STRING: |
477 | case DT_STR: |
471 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
478 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
472 | break; |
479 | break; |
473 | |
480 | |
474 | case DT_USTRING_LEN: |
481 | case DT_STR_LEN: |
475 | { |
482 | { |
476 | unicode_t *ustr = va_arg (ap, unicode_t *); |
483 | char *str = va_arg (ap, char *); |
477 | int ulen = va_arg (ap, int); |
484 | int len = va_arg (ap, int); |
|
|
485 | |
|
|
486 | XPUSHs (sv_2mortal (newSVpvn (str, len))); |
|
|
487 | } |
|
|
488 | break; |
|
|
489 | |
|
|
490 | case DT_WCS_LEN: |
|
|
491 | { |
478 | wchar_t *wstr = new wchar_t [ulen]; |
492 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
493 | int wlen = va_arg (ap, int); |
479 | |
494 | |
480 | for (int i = ulen; i--; ) |
|
|
481 | wstr [i] = ustr [i]; |
|
|
482 | |
|
|
483 | XPUSHs (sv_2mortal (wcs2sv (wstr, ulen))); |
495 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
496 | } |
|
|
497 | break; |
484 | |
498 | |
485 | delete [] wstr; |
499 | case DT_XEVENT: |
486 | } |
500 | { |
|
|
501 | XEvent *xe = va_arg (ap, XEvent *); |
|
|
502 | HV *hv = newHV (); |
|
|
503 | |
|
|
504 | # define set(name, sv) hv_store (hv, # name, sizeof (# name) - 1, sv, 0) |
|
|
505 | # define setiv(name, val) hv_store (hv, # name, sizeof (# name) - 1, newSViv (val), 0) |
|
|
506 | # undef set |
|
|
507 | |
|
|
508 | setiv (type, xe->type); |
|
|
509 | setiv (send_event, xe->xany.send_event); |
|
|
510 | setiv (serial, xe->xany.serial); |
|
|
511 | |
|
|
512 | switch (xe->type) |
|
|
513 | { |
|
|
514 | case KeyPress: |
|
|
515 | case KeyRelease: |
|
|
516 | case ButtonPress: |
|
|
517 | case ButtonRelease: |
|
|
518 | case MotionNotify: |
|
|
519 | setiv (time, xe->xmotion.time); |
|
|
520 | setiv (x, xe->xmotion.x); |
|
|
521 | setiv (y, xe->xmotion.y); |
|
|
522 | setiv (row, xe->xmotion.y / term->fheight); |
|
|
523 | setiv (col, xe->xmotion.x / term->fwidth); |
|
|
524 | setiv (x_root, xe->xmotion.x_root); |
|
|
525 | setiv (y_root, xe->xmotion.y_root); |
|
|
526 | setiv (state, xe->xmotion.state); |
|
|
527 | break; |
|
|
528 | } |
|
|
529 | |
|
|
530 | switch (xe->type) |
|
|
531 | { |
|
|
532 | case KeyPress: |
|
|
533 | case KeyRelease: |
|
|
534 | setiv (keycode, xe->xkey.keycode); |
|
|
535 | break; |
|
|
536 | |
|
|
537 | case ButtonPress: |
|
|
538 | case ButtonRelease: |
|
|
539 | setiv (button, xe->xbutton.button); |
|
|
540 | break; |
|
|
541 | |
|
|
542 | case MotionNotify: |
|
|
543 | setiv (is_hint, xe->xmotion.is_hint); |
|
|
544 | break; |
|
|
545 | } |
|
|
546 | |
|
|
547 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)hv))); |
|
|
548 | } |
|
|
549 | break; |
487 | |
550 | |
488 | case DT_END: |
551 | case DT_END: |
489 | { |
552 | { |
490 | va_end (ap); |
553 | va_end (ap); |
491 | |
554 | |
… | |
… | |
506 | if (SvTRUE (ERRSV)) |
569 | if (SvTRUE (ERRSV)) |
507 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
570 | rxvt_warn ("perl hook %d evaluation error: %s", htype, SvPV_nolen (ERRSV)); |
508 | |
571 | |
509 | if (htype == HOOK_DESTROY) |
572 | if (htype == HOOK_DESTROY) |
510 | { |
573 | { |
511 | clearSVptr ((SV *)term->self); |
574 | clearSVptr ((SV *)term->perl.self); |
512 | SvREFCNT_dec ((SV *)term->self); |
575 | SvREFCNT_dec ((SV *)term->perl.self); |
513 | } |
576 | } |
514 | |
577 | |
515 | return count; |
578 | return count; |
516 | } |
579 | } |
517 | |
580 | |
… | |
… | |
527 | |
590 | |
528 | PROTOTYPES: ENABLE |
591 | PROTOTYPES: ENABLE |
529 | |
592 | |
530 | BOOT: |
593 | BOOT: |
531 | { |
594 | { |
532 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), # name, newSViv (name)); |
595 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
|
|
596 | |
533 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
597 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
534 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
598 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
535 | # include "hookinc.h" |
599 | # include "hookinc.h" |
536 | # undef def |
600 | # undef def |
537 | |
601 | |
|
|
602 | HV *option = get_hv ("urxvt::OPTION", 1); |
|
|
603 | # define def(name,val) hv_store (option, # name, sizeof (# name) - 1, newSVuv (Opt_ ## name), 0); |
|
|
604 | # define nodef(name) |
|
|
605 | # include "optinc.h" |
|
|
606 | # undef nodef |
|
|
607 | # undef def |
|
|
608 | |
|
|
609 | HV *stash = gv_stashpv ("urxvt", 1); |
|
|
610 | # define export_const_iv(name) newCONSTSUB (stash, # name, newSViv (name)); |
538 | export_const (DEFAULT_RSTYLE); |
611 | export_const_iv (DEFAULT_RSTYLE); |
539 | export_const (OVERLAY_RSTYLE); |
612 | export_const_iv (OVERLAY_RSTYLE); |
540 | export_const (RS_Bold); |
613 | export_const_iv (RS_Bold); |
541 | export_const (RS_Italic); |
614 | export_const_iv (RS_Italic); |
542 | export_const (RS_Blink); |
615 | export_const_iv (RS_Blink); |
543 | export_const (RS_RVid); |
616 | export_const_iv (RS_RVid); |
544 | export_const (RS_Uline); |
617 | export_const_iv (RS_Uline); |
545 | |
618 | |
546 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
619 | export_const_iv (CurrentTime); |
|
|
620 | export_const_iv (ShiftMask); |
|
|
621 | export_const_iv (LockMask); |
|
|
622 | export_const_iv (ControlMask); |
|
|
623 | export_const_iv (Mod1Mask); |
|
|
624 | export_const_iv (Mod2Mask); |
|
|
625 | export_const_iv (Mod3Mask); |
|
|
626 | export_const_iv (Mod4Mask); |
|
|
627 | export_const_iv (Mod5Mask); |
|
|
628 | export_const_iv (Button1Mask); |
|
|
629 | export_const_iv (Button2Mask); |
|
|
630 | export_const_iv (Button3Mask); |
|
|
631 | export_const_iv (Button4Mask); |
|
|
632 | export_const_iv (Button5Mask); |
|
|
633 | export_const_iv (AnyModifier); |
547 | } |
634 | } |
548 | |
635 | |
549 | SV * |
636 | SV * |
550 | new (...) |
637 | new (...) |
551 | CODE: |
638 | CODE: |
… | |
… | |
569 | { |
656 | { |
570 | term->destroy (); |
657 | term->destroy (); |
571 | croak ("exception caught while initializing new terminal instance"); |
658 | croak ("exception caught while initializing new terminal instance"); |
572 | } |
659 | } |
573 | |
660 | |
574 | RETVAL = term && term->self ? newSVterm (term) : &PL_sv_undef; |
661 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
575 | } |
662 | } |
576 | OUTPUT: |
663 | OUTPUT: |
577 | RETVAL |
664 | RETVAL |
578 | |
665 | |
579 | void |
666 | void |
… | |
… | |
648 | |
735 | |
649 | MODULE = urxvt PACKAGE = urxvt::term |
736 | MODULE = urxvt PACKAGE = urxvt::term |
650 | |
737 | |
651 | void |
738 | void |
652 | rxvt_term::destroy () |
739 | rxvt_term::destroy () |
|
|
740 | |
|
|
741 | void |
|
|
742 | rxvt_term::grab_button (int button, U32 modifiers) |
|
|
743 | CODE: |
|
|
744 | XGrabButton (THIS->display->display, button, modifiers, THIS->vt, 1, |
|
|
745 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
746 | GrabModeSync, GrabModeSync, None, GRAB_CURSOR); |
|
|
747 | |
|
|
748 | bool |
|
|
749 | rxvt_term::grab (U32 eventtime, int sync = 0) |
|
|
750 | CODE: |
|
|
751 | { |
|
|
752 | int mode = sync ? GrabModeSync : GrabModeAsync; |
|
|
753 | |
|
|
754 | THIS->perl.grabtime = 0; |
|
|
755 | |
|
|
756 | if (!XGrabPointer (THIS->display->display, THIS->vt, 0, |
|
|
757 | ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask, |
|
|
758 | mode, mode, None, GRAB_CURSOR, eventtime)) |
|
|
759 | if (!XGrabKeyboard (THIS->display->display, THIS->vt, 0, mode, mode, eventtime)) |
|
|
760 | THIS->perl.grabtime = eventtime; |
|
|
761 | else |
|
|
762 | XUngrabPointer (THIS->display->display, eventtime); |
|
|
763 | |
|
|
764 | RETVAL = !!THIS->perl.grabtime; |
|
|
765 | } |
|
|
766 | OUTPUT: |
|
|
767 | RETVAL |
|
|
768 | |
|
|
769 | void |
|
|
770 | rxvt_term::allow_events_async (U32 eventtime = THIS->perl.grabtime) |
|
|
771 | CODE: |
|
|
772 | XAllowEvents (THIS->display->display, AsyncBoth, eventtime); |
|
|
773 | |
|
|
774 | void |
|
|
775 | rxvt_term::allow_events_sync (U32 eventtime = THIS->perl.grabtime) |
|
|
776 | CODE: |
|
|
777 | XAllowEvents (THIS->display->display, SyncBoth, eventtime); |
|
|
778 | |
|
|
779 | void |
|
|
780 | rxvt_term::allow_events_replay (U32 eventtime = THIS->perl.grabtime) |
|
|
781 | CODE: |
|
|
782 | XAllowEvents (THIS->display->display, ReplayPointer, eventtime); |
|
|
783 | XAllowEvents (THIS->display->display, ReplayKeyboard, eventtime); |
|
|
784 | |
|
|
785 | void |
|
|
786 | rxvt_term::ungrab (U32 eventtime = THIS->perl.grabtime) |
|
|
787 | CODE: |
|
|
788 | THIS->perl.grabtime = 0; |
|
|
789 | XUngrabKeyboard (THIS->display->display, eventtime); |
|
|
790 | XUngrabPointer (THIS->display->display, eventtime); |
653 | |
791 | |
654 | int |
792 | int |
655 | rxvt_term::strwidth (SV *str) |
793 | rxvt_term::strwidth (SV *str) |
656 | CODE: |
794 | CODE: |
657 | { |
795 | { |
… | |
… | |
699 | free (wstr); |
837 | free (wstr); |
700 | } |
838 | } |
701 | OUTPUT: |
839 | OUTPUT: |
702 | RETVAL |
840 | RETVAL |
703 | |
841 | |
704 | # very portable, especially on objects as opposed to pods |
842 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
705 | #define TERM_OFFSET(sym) (((char *)&((TermWin_t *)0)->sym) - (char *)(TermWin_t *)0) |
|
|
706 | |
843 | |
707 | #define TERM_OFFSET_width TERM_OFFSET(width) |
844 | #define TERM_OFFSET_width TERM_OFFSET(width) |
708 | #define TERM_OFFSET_height TERM_OFFSET(height) |
845 | #define TERM_OFFSET_height TERM_OFFSET(height) |
709 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
846 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
710 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
847 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
… | |
… | |
735 | CODE: |
872 | CODE: |
736 | RETVAL = *(int *)((char *)THIS + ix); |
873 | RETVAL = *(int *)((char *)THIS + ix); |
737 | OUTPUT: |
874 | OUTPUT: |
738 | RETVAL |
875 | RETVAL |
739 | |
876 | |
|
|
877 | unsigned int |
|
|
878 | rxvt_term::ModLevel3Mask () |
|
|
879 | ALIAS: |
|
|
880 | ModLevel3Mask = 0 |
|
|
881 | ModMetaMask = 1 |
|
|
882 | ModNumLockMask = 2 |
|
|
883 | CODE: |
|
|
884 | switch (ix) |
|
|
885 | { |
|
|
886 | case 0: RETVAL = THIS->ModLevel3Mask; break; |
|
|
887 | case 1: RETVAL = THIS->ModMetaMask; break; |
|
|
888 | case 2: RETVAL = THIS->ModNumLockMask; break; |
|
|
889 | } |
|
|
890 | OUTPUT: |
|
|
891 | RETVAL |
|
|
892 | |
|
|
893 | U32 |
|
|
894 | rxvt_term::parent () |
|
|
895 | CODE: |
|
|
896 | RETVAL = (U32)THIS->parent [0]; |
|
|
897 | OUTPUT: |
|
|
898 | RETVAL |
|
|
899 | |
|
|
900 | U32 |
|
|
901 | rxvt_term::vt () |
|
|
902 | CODE: |
|
|
903 | RETVAL = (U32)THIS->vt; |
|
|
904 | OUTPUT: |
|
|
905 | RETVAL |
|
|
906 | |
740 | U32 |
907 | U32 |
741 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
908 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
742 | CODE: |
909 | CODE: |
743 | { |
910 | { |
744 | RETVAL = THIS->rstyle; |
911 | RETVAL = THIS->rstyle; |
… | |
… | |
778 | |
945 | |
779 | if (GIMME_V != G_VOID) |
946 | if (GIMME_V != G_VOID) |
780 | { |
947 | { |
781 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
948 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
782 | |
949 | |
783 | for (int col = 0; col <THIS->ncol; col++) |
950 | for (int col = 0; col < THIS->ncol; col++) |
784 | wstr [col] = l.t [col]; |
951 | wstr [col] = l.t [col]; |
785 | |
952 | |
786 | XPUSHs (sv_2mortal (wcs2sv (wstr))); |
953 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
787 | |
954 | |
788 | delete [] wstr; |
955 | delete [] wstr; |
789 | } |
956 | } |
790 | |
957 | |
791 | if (new_text) |
958 | if (new_text) |
… | |
… | |
881 | } |
1048 | } |
882 | OUTPUT: |
1049 | OUTPUT: |
883 | RETVAL |
1050 | RETVAL |
884 | |
1051 | |
885 | SV * |
1052 | SV * |
886 | rxvt_term::special_encode (SV *str) |
1053 | rxvt_term::special_encode (SV *string) |
887 | CODE: |
1054 | CODE: |
888 | abort ();//TODO |
1055 | { |
|
|
1056 | wchar_t *wstr = sv2wcs (string); |
|
|
1057 | int wlen = wcslen (wstr); |
|
|
1058 | wchar_t *rstr = new wchar_t [wlen]; // cannot become longer |
|
|
1059 | |
|
|
1060 | rxvt_push_locale (THIS->locale); |
|
|
1061 | |
|
|
1062 | wchar_t *r = rstr; |
|
|
1063 | for (wchar_t *s = wstr; *s; s++) |
|
|
1064 | if (wcwidth (*s) == 0) |
|
|
1065 | { |
|
|
1066 | if (r == rstr) |
|
|
1067 | croak ("leading combining character unencodable"); |
|
|
1068 | |
|
|
1069 | unicode_t n = rxvt_compose (r[-1], *s); |
|
|
1070 | if (n == NOCHAR) |
|
|
1071 | n = rxvt_composite.compose (r[-1], *s); |
|
|
1072 | |
|
|
1073 | r[-1] = n; |
|
|
1074 | } |
|
|
1075 | #if !UNICODE_3 |
|
|
1076 | else if (*s >= 0x10000) |
|
|
1077 | *r++ = rxvt_composite.compose (*s); |
|
|
1078 | #endif |
|
|
1079 | else |
|
|
1080 | *r++ = *s; |
|
|
1081 | |
|
|
1082 | rxvt_pop_locale (); |
|
|
1083 | |
|
|
1084 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1085 | |
|
|
1086 | delete [] rstr; |
|
|
1087 | } |
|
|
1088 | OUTPUT: |
|
|
1089 | RETVAL |
889 | |
1090 | |
890 | SV * |
1091 | SV * |
891 | rxvt_term::special_decode (SV *str) |
1092 | rxvt_term::special_decode (SV *text) |
892 | CODE: |
1093 | CODE: |
893 | abort ();//TODO |
1094 | { |
|
|
1095 | wchar_t *wstr = sv2wcs (text); |
|
|
1096 | int wlen = wcslen (wstr); |
|
|
1097 | int dlen = 0; |
|
|
1098 | |
|
|
1099 | // find length |
|
|
1100 | for (wchar_t *s = wstr; *s; s++) |
|
|
1101 | if (*s == NOCHAR) |
|
|
1102 | ; |
|
|
1103 | else if (IS_COMPOSE (*s)) |
|
|
1104 | dlen += rxvt_composite.expand (*s, 0); |
|
|
1105 | else |
|
|
1106 | dlen++; |
|
|
1107 | |
|
|
1108 | wchar_t *rstr = new wchar_t [dlen]; |
|
|
1109 | |
|
|
1110 | // decode |
|
|
1111 | wchar_t *r = rstr; |
|
|
1112 | for (wchar_t *s = wstr; *s; s++) |
|
|
1113 | if (*s == NOCHAR) |
|
|
1114 | ; |
|
|
1115 | else if (IS_COMPOSE (*s)) |
|
|
1116 | r += rxvt_composite.expand (*s, r); |
|
|
1117 | else |
|
|
1118 | *r++ = *s; |
|
|
1119 | |
|
|
1120 | RETVAL = wcs2sv (rstr, r - rstr); |
|
|
1121 | |
|
|
1122 | delete [] rstr; |
|
|
1123 | } |
|
|
1124 | OUTPUT: |
|
|
1125 | RETVAL |
894 | |
1126 | |
895 | void |
1127 | void |
896 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1128 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
897 | PPCODE: |
1129 | PPCODE: |
898 | { |
1130 | { |
… | |
… | |
930 | else |
1162 | else |
931 | THIS->rs [index] = 0; |
1163 | THIS->rs [index] = 0; |
932 | } |
1164 | } |
933 | } |
1165 | } |
934 | |
1166 | |
|
|
1167 | bool |
|
|
1168 | rxvt_term::option (U32 optval, int set = -1) |
|
|
1169 | CODE: |
|
|
1170 | { |
|
|
1171 | RETVAL = THIS->options & optval; |
|
|
1172 | |
|
|
1173 | if (set >= 0) |
|
|
1174 | { |
|
|
1175 | if (set) |
|
|
1176 | THIS->options |= optval; |
|
|
1177 | else |
|
|
1178 | THIS->options &= ~optval; |
|
|
1179 | |
|
|
1180 | switch (optval) |
|
|
1181 | { |
|
|
1182 | case Opt_skipBuiltinGlyphs: |
|
|
1183 | THIS->set_fonts (); |
|
|
1184 | THIS->scr_remap_chars (); |
|
|
1185 | THIS->scr_touch (true); |
|
|
1186 | THIS->want_refresh = 1; |
|
|
1187 | break; |
|
|
1188 | |
|
|
1189 | case Opt_cursorUnderline: |
|
|
1190 | THIS->want_refresh = 1; |
|
|
1191 | break; |
|
|
1192 | |
|
|
1193 | # case Opt_scrollBar_floating: |
|
|
1194 | # case Opt_scrollBar_right: |
|
|
1195 | # THIS->resize_all_windows (THIS->width, THIS->height, 1); |
|
|
1196 | # break; |
|
|
1197 | } |
|
|
1198 | } |
|
|
1199 | } |
|
|
1200 | OUTPUT: |
|
|
1201 | RETVAL |
|
|
1202 | |
935 | void |
1203 | void |
936 | rxvt_term::cur (...) |
1204 | rxvt_term::cur (...) |
937 | PROTOTYPE: $;$$ |
1205 | PROTOTYPE: $;$$ |
938 | ALIAS: |
1206 | ALIAS: |
939 | screen_cur = 0 |
1207 | screen_cur = 0 |
… | |
… | |
963 | THIS->want_refresh = 1; |
1231 | THIS->want_refresh = 1; |
964 | } |
1232 | } |
965 | } |
1233 | } |
966 | |
1234 | |
967 | int |
1235 | int |
968 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
1236 | rxvt_term::selection_grab (U32 eventtime) |
969 | |
1237 | |
970 | void |
1238 | void |
971 | rxvt_term::selection (SV *newtext = 0) |
1239 | rxvt_term::selection (SV *newtext = 0) |
972 | PPCODE: |
1240 | PPCODE: |
973 | { |
1241 | { |
… | |
… | |
986 | void |
1254 | void |
987 | rxvt_term::scr_add_lines (SV *string) |
1255 | rxvt_term::scr_add_lines (SV *string) |
988 | CODE: |
1256 | CODE: |
989 | { |
1257 | { |
990 | wchar_t *wstr = sv2wcs (string); |
1258 | wchar_t *wstr = sv2wcs (string); |
991 | int wlen = wcslen (wstr); |
|
|
992 | unicode_t *ustr = new unicode_t [wlen]; |
|
|
993 | int nlines = 0; |
|
|
994 | |
|
|
995 | for (int i = wlen; i--; ) |
|
|
996 | { |
|
|
997 | ustr [i] = wstr [i]; |
|
|
998 | nlines += ustr [i] == '\012'; |
|
|
999 | } |
|
|
1000 | |
|
|
1001 | THIS->scr_add_lines (ustr, nlines, wlen); |
1259 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
1002 | |
|
|
1003 | free (wstr); |
1260 | free (wstr); |
1004 | delete [] ustr; |
|
|
1005 | } |
1261 | } |
1006 | |
1262 | |
1007 | void |
1263 | void |
1008 | rxvt_term::tt_write (SV *octets) |
1264 | rxvt_term::tt_write (SV *octets) |
1009 | INIT: |
1265 | INIT: |
… | |
… | |
1023 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1279 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
1024 | |
1280 | |
1025 | THIS->cmdbuf_ptr = str; |
1281 | THIS->cmdbuf_ptr = str; |
1026 | THIS->cmdbuf_endp = str + len; |
1282 | THIS->cmdbuf_endp = str + len; |
1027 | |
1283 | |
|
|
1284 | rxvt_push_locale (THIS->locale); |
1028 | THIS->cmd_parse (); |
1285 | THIS->cmd_parse (); |
|
|
1286 | rxvt_pop_locale (); |
1029 | |
1287 | |
1030 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1288 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
1031 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1289 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
1032 | } |
1290 | } |
1033 | |
1291 | |