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