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 | |
… | |
… | |
51 | char *str = SvPVutf8 (sv, len); |
58 | char *str = SvPVutf8 (sv, len); |
52 | return rxvt_utf8towcs (str, len); |
59 | return rxvt_utf8towcs (str, len); |
53 | } |
60 | } |
54 | |
61 | |
55 | static SV * |
62 | static SV * |
|
|
63 | wcs2sv (wchar_t *wstr, int len = -1) |
|
|
64 | { |
|
|
65 | char *str = rxvt_wcstoutf8 (wstr, len); |
|
|
66 | |
|
|
67 | SV *sv = newSVpv (str, 0); |
|
|
68 | SvUTF8_on (sv); |
|
|
69 | free (str); |
|
|
70 | |
|
|
71 | return sv; |
|
|
72 | } |
|
|
73 | |
|
|
74 | static SV * |
56 | new_ref (HV *hv, const char *klass) |
75 | new_ref (HV *hv, const char *klass) |
57 | { |
76 | { |
58 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
77 | return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1)); |
59 | } |
78 | } |
60 | |
79 | |
… | |
… | |
89 | 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); |
90 | |
109 | |
91 | return (long)mg->mg_ptr; |
110 | return (long)mg->mg_ptr; |
92 | } |
111 | } |
93 | |
112 | |
94 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->self) |
113 | #define newSVterm(term) SvREFCNT_inc ((SV *)term->perl.self) |
95 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
114 | #define SvTERM(sv) (rxvt_term *)SvPTR (sv, "urxvt::term") |
96 | |
115 | |
97 | ///////////////////////////////////////////////////////////////////////////// |
116 | ///////////////////////////////////////////////////////////////////////////// |
98 | |
117 | |
99 | struct perl_watcher |
118 | struct perl_watcher |
… | |
… | |
215 | h += 2; |
234 | h += 2; |
216 | } |
235 | } |
217 | |
236 | |
218 | text = new text_t *[h]; |
237 | text = new text_t *[h]; |
219 | rend = new rend_t *[h]; |
238 | rend = new rend_t *[h]; |
220 | |
239 | |
221 | for (int y = 0; y < h; y++) |
240 | for (int y = 0; y < h; y++) |
222 | { |
241 | { |
223 | text_t *tp = text[y] = new text_t[w]; |
242 | text_t *tp = text[y] = new text_t[w]; |
224 | rend_t *rp = rend[y] = new rend_t[w]; |
243 | rend_t *rp = rend[y] = new rend_t[w]; |
225 | |
244 | |
226 | text_t t0, t1, t2; |
245 | text_t t0, t1, t2; |
227 | rend_t r = rstyle; |
246 | rend_t r = rstyle; |
228 | |
247 | |
229 | if (border == 2) |
248 | if (border == 2) |
230 | { |
249 | { |
231 | if (y == 0) |
250 | if (y == 0) |
232 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
251 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
233 | else if (y < h - 1) |
252 | else if (y < h - 1) |
234 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
253 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
235 | else |
254 | else |
236 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
255 | t0 = 0x255a, t1 = 0x2550, t2 = 0x255d; |
237 | |
256 | |
238 | *tp++ = t0; |
257 | *tp++ = t0; |
239 | *rp++ = r; |
258 | *rp++ = r; |
240 | |
259 | |
241 | for (int x = w - 2; x-- > 0; ) |
260 | for (int x = w - 2; x-- > 0; ) |
242 | { |
261 | { |
243 | *tp++ = t1; |
262 | *tp++ = t1; |
244 | *rp++ = r; |
263 | *rp++ = r; |
245 | } |
264 | } |
246 | |
265 | |
247 | *tp = t2; |
266 | *tp = t2; |
248 | *rp = r; |
267 | *rp = r; |
249 | } |
268 | } |
250 | else |
269 | else |
251 | for (int x = w; x-- > 0; ) |
270 | for (int x = w; x-- > 0; ) |
252 | { |
271 | { |
253 | *tp++ = 0x0020; |
272 | *tp++ = 0x0020; |
254 | *rp++ = r; |
273 | *rp++ = r; |
255 | } |
274 | } |
256 | } |
275 | } |
257 | |
276 | |
258 | show (); |
277 | show (); |
259 | THIS->want_refresh = 1; |
278 | THIS->want_refresh = 1; |
260 | } |
279 | } |
261 | |
280 | |
… | |
… | |
278 | void |
297 | void |
279 | overlay::show () |
298 | overlay::show () |
280 | { |
299 | { |
281 | char key[33]; sprintf (key, "%32lx", (long)this); |
300 | char key[33]; sprintf (key, "%32lx", (long)this); |
282 | |
301 | |
283 | 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)); |
284 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
303 | hv_store (hv, key, 32, newSViv ((long)this), 0); |
285 | } |
304 | } |
286 | |
305 | |
287 | void |
306 | void |
288 | overlay::hide () |
307 | overlay::hide () |
289 | { |
308 | { |
290 | 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); |
291 | |
310 | |
292 | if (ovs) |
311 | if (ovs) |
293 | { |
312 | { |
294 | char key[33]; sprintf (key, "%32lx", (long)this); |
313 | char key[33]; sprintf (key, "%32lx", (long)this); |
295 | |
314 | |
… | |
… | |
308 | |
327 | |
309 | for (int y = ov_h; y--; ) |
328 | for (int y = ov_h; y--; ) |
310 | { |
329 | { |
311 | text_t *t1 = text [y]; |
330 | text_t *t1 = text [y]; |
312 | rend_t *r1 = rend [y]; |
331 | rend_t *r1 = rend [y]; |
313 | |
332 | |
314 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
333 | text_t *t2 = ROW(y + ov_y - THIS->view_start).t + ov_x; |
315 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
334 | rend_t *r2 = ROW(y + ov_y - THIS->view_start).r + ov_x; |
316 | |
335 | |
317 | for (int x = ov_w; x--; ) |
336 | for (int x = ov_w; x--; ) |
318 | { |
337 | { |
319 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
338 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
320 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
339 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (t)); |
321 | } |
340 | } |
322 | } |
341 | } |
323 | |
342 | |
… | |
… | |
333 | |
352 | |
334 | wchar_t *wtext = sv2wcs (text); |
353 | wchar_t *wtext = sv2wcs (text); |
335 | |
354 | |
336 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
355 | for (int col = min (wcslen (wtext), w - x - border); col--; ) |
337 | this->text [y][x + col] = wtext [col]; |
356 | this->text [y][x + col] = wtext [col]; |
338 | |
357 | |
339 | free (wtext); |
358 | free (wtext); |
340 | |
359 | |
341 | if (rend) |
360 | if (rend) |
342 | { |
361 | { |
343 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
362 | if (!SvROK (rend) || SvTYPE (SvRV (rend)) != SVt_PVAV) |
… | |
… | |
400 | bool |
419 | bool |
401 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
420 | rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...) |
402 | { |
421 | { |
403 | if (!perl) |
422 | if (!perl) |
404 | return false; |
423 | return false; |
405 | |
424 | |
406 | if (htype == HOOK_INIT) // first hook ever called |
425 | if (htype == HOOK_INIT) // first hook ever called |
407 | { |
426 | { |
408 | term->self = (void *)newSVptr ((void *)term, "urxvt::term"); |
427 | term->perl.self = (void *)newSVptr ((void *)term, "urxvt::term"); |
409 | 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); |
410 | } |
429 | } |
411 | else if (!term->self) |
430 | else if (!term->perl.self) |
412 | return false; // perl not initialized for this instance |
431 | return false; // perl not initialized for this instance |
413 | else if (htype == HOOK_DESTROY) |
432 | else if (htype == HOOK_DESTROY) |
414 | { |
433 | { |
415 | // handled later |
434 | // handled later |
416 | } |
435 | } |
417 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
436 | else if (htype == HOOK_REFRESH_BEGIN || htype == HOOK_REFRESH_END) |
418 | { |
437 | { |
419 | 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)); |
420 | |
439 | |
421 | if (HvKEYS (hv)) |
440 | if (HvKEYS (hv)) |
422 | { |
441 | { |
423 | hv_iterinit (hv); |
442 | hv_iterinit (hv); |
424 | |
443 | |
… | |
… | |
453 | |
472 | |
454 | case DT_LONG: |
473 | case DT_LONG: |
455 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
474 | XPUSHs (sv_2mortal (newSViv (va_arg (ap, long)))); |
456 | break; |
475 | break; |
457 | |
476 | |
458 | case DT_STRING: |
477 | case DT_STR: |
459 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
478 | XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0))); |
|
|
479 | break; |
|
|
480 | |
|
|
481 | case DT_STR_LEN: |
|
|
482 | { |
|
|
483 | char *str = va_arg (ap, char *); |
|
|
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 | { |
|
|
492 | wchar_t *wstr = va_arg (ap, wchar_t *); |
|
|
493 | int wlen = va_arg (ap, int); |
|
|
494 | |
|
|
495 | XPUSHs (sv_2mortal (wcs2sv (wstr, wlen))); |
|
|
496 | } |
|
|
497 | break; |
|
|
498 | |
|
|
499 | case DT_XEVENT: |
|
|
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 | } |
460 | break; |
549 | break; |
461 | |
550 | |
462 | case DT_END: |
551 | case DT_END: |
463 | { |
552 | { |
464 | va_end (ap); |
553 | va_end (ap); |
… | |
… | |
480 | if (SvTRUE (ERRSV)) |
569 | if (SvTRUE (ERRSV)) |
481 | 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)); |
482 | |
571 | |
483 | if (htype == HOOK_DESTROY) |
572 | if (htype == HOOK_DESTROY) |
484 | { |
573 | { |
485 | clearSVptr ((SV *)term->self); |
574 | clearSVptr ((SV *)term->perl.self); |
486 | SvREFCNT_dec ((SV *)term->self); |
575 | SvREFCNT_dec ((SV *)term->perl.self); |
487 | } |
576 | } |
488 | |
577 | |
489 | return count; |
578 | return count; |
490 | } |
579 | } |
491 | |
580 | |
… | |
… | |
501 | |
590 | |
502 | PROTOTYPES: ENABLE |
591 | PROTOTYPES: ENABLE |
503 | |
592 | |
504 | BOOT: |
593 | BOOT: |
505 | { |
594 | { |
506 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
595 | sv_setsv (get_sv ("urxvt::LIBDIR", 1), newSVpvn (LIBDIR, sizeof (LIBDIR) - 1)); |
507 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); |
596 | |
508 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
597 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
509 | set_hookname (INIT); |
598 | # define def(sym) av_store (hookname, HOOK_ ## sym, newSVpv (# sym, 0)); |
510 | set_hookname (RESET); |
599 | # include "hookinc.h" |
511 | set_hookname (START); |
600 | # undef def |
512 | set_hookname (DESTROY); |
|
|
513 | set_hookname (SEL_BEGIN); |
|
|
514 | set_hookname (SEL_EXTEND); |
|
|
515 | set_hookname (SEL_MAKE); |
|
|
516 | set_hookname (SEL_GRAB); |
|
|
517 | set_hookname (FOCUS_IN); |
|
|
518 | set_hookname (FOCUS_OUT); |
|
|
519 | set_hookname (VIEW_CHANGE); |
|
|
520 | set_hookname (SCROLL_BACK); |
|
|
521 | set_hookname (TTY_ACTIVITY); |
|
|
522 | set_hookname (REFRESH_BEGIN); |
|
|
523 | set_hookname (REFRESH_END); |
|
|
524 | set_hookname (KEYBOARD_COMMAND); |
|
|
525 | |
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)); |
526 | export_const (DEFAULT_RSTYLE); |
611 | export_const_iv (DEFAULT_RSTYLE); |
527 | export_const (OVERLAY_RSTYLE); |
612 | export_const_iv (OVERLAY_RSTYLE); |
528 | export_const (RS_Bold); |
613 | export_const_iv (RS_Bold); |
529 | export_const (RS_Italic); |
614 | export_const_iv (RS_Italic); |
530 | export_const (RS_Blink); |
615 | export_const_iv (RS_Blink); |
531 | export_const (RS_RVid); |
616 | export_const_iv (RS_RVid); |
532 | export_const (RS_Uline); |
617 | export_const_iv (RS_Uline); |
533 | |
618 | |
534 | 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); |
535 | } |
634 | } |
|
|
635 | |
|
|
636 | SV * |
|
|
637 | new (...) |
|
|
638 | CODE: |
|
|
639 | { |
|
|
640 | stringvec *argv = new stringvec; |
|
|
641 | bool success; |
|
|
642 | |
|
|
643 | for (int i = 0; i < items ;i++) |
|
|
644 | argv->push_back (strdup (SvPVbyte_nolen (ST (i)))); |
|
|
645 | |
|
|
646 | rxvt_term *term = new rxvt_term; |
|
|
647 | |
|
|
648 | term->argv = argv; |
|
|
649 | |
|
|
650 | try |
|
|
651 | { |
|
|
652 | if (!term->init (argv->size (), argv->begin ())) |
|
|
653 | term = 0; |
|
|
654 | } |
|
|
655 | catch (const class rxvt_failure_exception &e) |
|
|
656 | { |
|
|
657 | term->destroy (); |
|
|
658 | croak ("exception caught while initializing new terminal instance"); |
|
|
659 | } |
|
|
660 | |
|
|
661 | RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef; |
|
|
662 | } |
|
|
663 | OUTPUT: |
|
|
664 | RETVAL |
536 | |
665 | |
537 | void |
666 | void |
538 | set_should_invoke (int htype, int value) |
667 | set_should_invoke (int htype, int value) |
539 | CODE: |
668 | CODE: |
540 | rxvt_perl.should_invoke [htype] = value; |
669 | rxvt_perl.should_invoke [htype] = value; |
… | |
… | |
603 | } |
732 | } |
604 | OUTPUT: |
733 | OUTPUT: |
605 | RETVAL |
734 | RETVAL |
606 | |
735 | |
607 | MODULE = urxvt PACKAGE = urxvt::term |
736 | MODULE = urxvt PACKAGE = urxvt::term |
|
|
737 | |
|
|
738 | void |
|
|
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); |
608 | |
791 | |
609 | int |
792 | int |
610 | rxvt_term::strwidth (SV *str) |
793 | rxvt_term::strwidth (SV *str) |
611 | CODE: |
794 | CODE: |
612 | { |
795 | { |
… | |
… | |
648 | |
831 | |
649 | rxvt_push_locale (THIS->locale); |
832 | rxvt_push_locale (THIS->locale); |
650 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
833 | wchar_t *wstr = rxvt_mbstowcs (data, len); |
651 | rxvt_pop_locale (); |
834 | rxvt_pop_locale (); |
652 | |
835 | |
653 | char *str = rxvt_wcstoutf8 (wstr); |
836 | RETVAL = wcs2sv (wstr); |
654 | free (wstr); |
837 | free (wstr); |
655 | |
|
|
656 | RETVAL = newSVpv (str, 0); |
|
|
657 | SvUTF8_on (RETVAL); |
|
|
658 | free (str); |
|
|
659 | } |
838 | } |
660 | OUTPUT: |
839 | OUTPUT: |
661 | RETVAL |
840 | RETVAL |
662 | |
841 | |
|
|
842 | #define TERM_OFFSET(sym) offsetof (TermWin_t, sym) |
|
|
843 | |
|
|
844 | #define TERM_OFFSET_width TERM_OFFSET(width) |
|
|
845 | #define TERM_OFFSET_height TERM_OFFSET(height) |
|
|
846 | #define TERM_OFFSET_fwidth TERM_OFFSET(fwidth) |
|
|
847 | #define TERM_OFFSET_fheight TERM_OFFSET(fheight) |
|
|
848 | #define TERM_OFFSET_fbase TERM_OFFSET(fbase) |
|
|
849 | #define TERM_OFFSET_nrow TERM_OFFSET(nrow) |
|
|
850 | #define TERM_OFFSET_ncol TERM_OFFSET(ncol) |
|
|
851 | #define TERM_OFFSET_focus TERM_OFFSET(focus) |
|
|
852 | #define TERM_OFFSET_mapped TERM_OFFSET(mapped) |
|
|
853 | #define TERM_OFFSET_saveLines TERM_OFFSET(saveLines) |
|
|
854 | #define TERM_OFFSET_total_rows TERM_OFFSET(total_rows) |
|
|
855 | #define TERM_OFFSET_nsaved TERM_OFFSET(nsaved) |
|
|
856 | |
663 | int |
857 | int |
|
|
858 | rxvt_term::width () |
|
|
859 | ALIAS: |
|
|
860 | width = TERM_OFFSET_width |
|
|
861 | height = TERM_OFFSET_height |
|
|
862 | fwidth = TERM_OFFSET_fwidth |
|
|
863 | fheight = TERM_OFFSET_fheight |
|
|
864 | fbase = TERM_OFFSET_fbase |
|
|
865 | nrow = TERM_OFFSET_nrow |
|
|
866 | ncol = TERM_OFFSET_ncol |
|
|
867 | focus = TERM_OFFSET_focus |
|
|
868 | mapped = TERM_OFFSET_mapped |
|
|
869 | saveLines = TERM_OFFSET_saveLines |
|
|
870 | total_rows = TERM_OFFSET_total_rows |
|
|
871 | nsaved = TERM_OFFSET_nsaved |
|
|
872 | CODE: |
|
|
873 | RETVAL = *(int *)((char *)THIS + ix); |
|
|
874 | OUTPUT: |
|
|
875 | RETVAL |
|
|
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 |
664 | rxvt_term::nsaved () |
901 | rxvt_term::vt () |
665 | CODE: |
902 | CODE: |
|
|
903 | RETVAL = (U32)THIS->vt; |
|
|
904 | OUTPUT: |
|
|
905 | RETVAL |
|
|
906 | |
|
|
907 | U32 |
|
|
908 | rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle) |
|
|
909 | CODE: |
|
|
910 | { |
666 | RETVAL = THIS->nsaved; |
911 | RETVAL = THIS->rstyle; |
|
|
912 | THIS->rstyle = new_rstyle; |
|
|
913 | } |
667 | OUTPUT: |
914 | OUTPUT: |
668 | RETVAL |
915 | RETVAL |
669 | |
916 | |
670 | int |
917 | int |
671 | rxvt_term::view_start (int newval = -1) |
918 | rxvt_term::view_start (int newval = -1) |
672 | CODE: |
919 | CODE: |
673 | { |
920 | { |
… | |
… | |
680 | } |
927 | } |
681 | } |
928 | } |
682 | OUTPUT: |
929 | OUTPUT: |
683 | RETVAL |
930 | RETVAL |
684 | |
931 | |
685 | int |
|
|
686 | rxvt_term::nrow () |
|
|
687 | CODE: |
|
|
688 | RETVAL = THIS->nrow; |
|
|
689 | OUTPUT: |
|
|
690 | RETVAL |
|
|
691 | |
|
|
692 | int |
|
|
693 | rxvt_term::ncol () |
|
|
694 | CODE: |
|
|
695 | RETVAL = THIS->ncol; |
|
|
696 | OUTPUT: |
|
|
697 | RETVAL |
|
|
698 | |
|
|
699 | void |
932 | void |
700 | rxvt_term::want_refresh () |
933 | rxvt_term::want_refresh () |
701 | CODE: |
934 | CODE: |
702 | THIS->want_refresh = 1; |
935 | THIS->want_refresh = 1; |
703 | |
936 | |
704 | void |
937 | void |
705 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
938 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
706 | PPCODE: |
939 | PPCODE: |
707 | { |
940 | { |
708 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
941 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
709 | croak ("row_number number of out range"); |
942 | XSRETURN_EMPTY; |
710 | |
943 | |
711 | line_t &l = ROW(row_number); |
944 | line_t &l = ROW(row_number); |
712 | |
945 | |
713 | if (GIMME_V != G_VOID) |
946 | if (GIMME_V != G_VOID) |
714 | { |
947 | { |
715 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
948 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
716 | |
949 | |
717 | for (int col = 0; col <THIS->ncol; col++) |
950 | for (int col = 0; col < THIS->ncol; col++) |
718 | wstr [col] = l.t [col]; |
951 | wstr [col] = l.t [col]; |
719 | |
952 | |
720 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
|
|
721 | free (wstr); |
|
|
722 | |
|
|
723 | SV *sv = newSVpv (str, 0); |
|
|
724 | SvUTF8_on (sv); |
|
|
725 | XPUSHs (sv_2mortal (sv)); |
953 | XPUSHs (sv_2mortal (wcs2sv (wstr, THIS->ncol))); |
726 | free (str); |
954 | |
|
|
955 | delete [] wstr; |
727 | } |
956 | } |
728 | |
957 | |
729 | if (new_text) |
958 | if (new_text) |
730 | { |
959 | { |
731 | wchar_t *wstr = sv2wcs (new_text); |
960 | wchar_t *wstr = sv2wcs (new_text); |
732 | |
961 | |
733 | int len = wcslen (wstr); |
962 | int len = min (wcslen (wstr) - start_ofs, max_len); |
734 | |
963 | |
735 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
964 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
736 | { |
965 | { |
737 | free (wstr); |
966 | free (wstr); |
738 | croak ("new_text extends beyond horizontal margins"); |
967 | croak ("new_text extends beyond horizontal margins"); |
739 | } |
968 | } |
740 | |
969 | |
741 | for (int col = start_col; col < start_col + len; col++) |
970 | for (int col = start_col; col < start_col + len; col++) |
742 | { |
971 | { |
743 | l.t [col] = wstr [col - start_col]; |
972 | l.t [col] = wstr [start_ofs + col - start_col]; |
744 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
973 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
745 | } |
974 | } |
746 | |
975 | |
747 | free (wstr); |
976 | free (wstr); |
748 | } |
977 | } |
749 | } |
978 | } |
750 | |
979 | |
751 | void |
980 | void |
752 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
981 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0, int start_ofs = 0, int max_len = MAX_COLS) |
753 | PPCODE: |
982 | PPCODE: |
754 | { |
983 | { |
755 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
984 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
756 | croak ("row_number number of out range"); |
985 | XSRETURN_EMPTY; |
757 | |
986 | |
758 | line_t &l = ROW(row_number); |
987 | line_t &l = ROW(row_number); |
759 | |
988 | |
760 | if (GIMME_V != G_VOID) |
989 | if (GIMME_V != G_VOID) |
761 | { |
990 | { |
… | |
… | |
772 | { |
1001 | { |
773 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
1002 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
774 | croak ("new_rend must be arrayref"); |
1003 | croak ("new_rend must be arrayref"); |
775 | |
1004 | |
776 | AV *av = (AV *)SvRV (new_rend); |
1005 | AV *av = (AV *)SvRV (new_rend); |
777 | int len = av_len (av) + 1; |
1006 | int len = min (av_len (av) + 1 - start_ofs, max_len); |
778 | |
1007 | |
779 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
1008 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
780 | croak ("new_rend array extends beyond horizontal margins"); |
1009 | croak ("new_rend array extends beyond horizontal margins"); |
781 | |
1010 | |
782 | for (int col = start_col; col < start_col + len; col++) |
1011 | for (int col = start_col; col < start_col + len; col++) |
783 | { |
1012 | { |
784 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
1013 | rend_t r = SvIV (*av_fetch (av, start_ofs + col - start_col, 1)) & ~RS_fontMask; |
785 | |
1014 | |
786 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
1015 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
787 | } |
1016 | } |
788 | } |
1017 | } |
789 | } |
1018 | } |
790 | |
1019 | |
791 | int |
1020 | int |
792 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
1021 | rxvt_term::ROW_l (int row_number, int new_length = -1) |
793 | CODE: |
1022 | CODE: |
794 | { |
1023 | { |
795 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
1024 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
796 | croak ("row_number number of out range"); |
1025 | XSRETURN_EMPTY; |
797 | |
1026 | |
798 | line_t &l = ROW(row_number); |
1027 | line_t &l = ROW(row_number); |
799 | RETVAL = l.l; |
1028 | RETVAL = l.l; |
800 | |
1029 | |
801 | if (new_length >= -1) |
1030 | if (new_length >= 0) |
802 | l.l = new_length; |
1031 | l.l = new_length; |
803 | } |
1032 | } |
804 | OUTPUT: |
1033 | OUTPUT: |
805 | RETVAL |
1034 | RETVAL |
806 | |
1035 | |
|
|
1036 | bool |
|
|
1037 | rxvt_term::ROW_is_longer (int row_number, int new_is_longer = -1) |
|
|
1038 | CODE: |
|
|
1039 | { |
|
|
1040 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
1041 | XSRETURN_EMPTY; |
|
|
1042 | |
|
|
1043 | line_t &l = ROW(row_number); |
|
|
1044 | RETVAL = l.is_longer (); |
|
|
1045 | |
|
|
1046 | if (new_is_longer >= 0) |
|
|
1047 | l.is_longer (new_is_longer); |
|
|
1048 | } |
|
|
1049 | OUTPUT: |
|
|
1050 | RETVAL |
|
|
1051 | |
807 | SV * |
1052 | SV * |
808 | rxvt_term::special_encode (SV *str) |
1053 | rxvt_term::special_encode (SV *string) |
809 | CODE: |
1054 | CODE: |
810 | 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 |
811 | |
1090 | |
812 | SV * |
1091 | SV * |
813 | rxvt_term::special_decode (SV *str) |
1092 | rxvt_term::special_decode (SV *text) |
814 | CODE: |
1093 | CODE: |
815 | 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 |
816 | |
1126 | |
817 | void |
1127 | void |
818 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
1128 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
819 | PPCODE: |
1129 | PPCODE: |
820 | { |
1130 | { |
821 | struct resval { const char *name; int value; } rslist [] = { |
1131 | struct resval { const char *name; int value; } rslist [] = { |
822 | # define Rs_def(name) { # name, Rs_ ## name }, |
1132 | # define def(name) { # name, Rs_ ## name }, |
823 | # define Rs_reserve(name,count) |
1133 | # define reserve(name,count) |
824 | # include "rsinc.h" |
1134 | # include "rsinc.h" |
825 | # undef Rs_def |
1135 | # undef def |
826 | # undef Rs_reserve |
1136 | # undef reserve |
827 | }; |
1137 | }; |
828 | |
1138 | |
829 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
1139 | struct resval *rs = rslist + sizeof (rslist) / sizeof (rslist [0]); |
830 | |
1140 | |
831 | do { |
1141 | do { |
… | |
… | |
852 | else |
1162 | else |
853 | THIS->rs [index] = 0; |
1163 | THIS->rs [index] = 0; |
854 | } |
1164 | } |
855 | } |
1165 | } |
856 | |
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 | |
857 | void |
1203 | void |
858 | rxvt_term::selection_mark (...) |
1204 | rxvt_term::cur (...) |
859 | PROTOTYPE: $;$$ |
1205 | PROTOTYPE: $;$$ |
860 | ALIAS: |
1206 | ALIAS: |
|
|
1207 | screen_cur = 0 |
861 | selection_beg = 1 |
1208 | selection_beg = 1 |
862 | selection_end = 2 |
1209 | selection_end = 2 |
|
|
1210 | selection_mark = 3 |
863 | PPCODE: |
1211 | PPCODE: |
864 | { |
1212 | { |
865 | row_col_t &sel = ix == 1 ? THIS->selection.beg |
1213 | row_col_t &rc = ix == 0 ? THIS->screen.cur |
|
|
1214 | : ix == 1 ? THIS->selection.beg |
866 | : ix == 2 ? THIS->selection.end |
1215 | : ix == 2 ? THIS->selection.end |
867 | : THIS->selection.mark; |
1216 | : THIS->selection.mark; |
868 | |
1217 | |
869 | if (GIMME_V != G_VOID) |
1218 | if (GIMME_V != G_VOID) |
870 | { |
1219 | { |
871 | EXTEND (SP, 2); |
1220 | EXTEND (SP, 2); |
872 | PUSHs (sv_2mortal (newSViv (sel.row))); |
1221 | PUSHs (sv_2mortal (newSViv (rc.row))); |
873 | PUSHs (sv_2mortal (newSViv (sel.col))); |
1222 | PUSHs (sv_2mortal (newSViv (rc.col))); |
874 | } |
1223 | } |
875 | |
1224 | |
876 | if (items == 3) |
1225 | if (items == 3) |
877 | { |
1226 | { |
878 | sel.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
1227 | rc.row = clamp (SvIV (ST (1)), -THIS->nsaved, THIS->nrow - 1); |
879 | sel.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
1228 | rc.col = clamp (SvIV (ST (2)), 0, THIS->ncol - 1); |
880 | |
1229 | |
881 | if (ix) |
1230 | if (ix) |
882 | THIS->want_refresh = 1; |
1231 | THIS->want_refresh = 1; |
883 | } |
1232 | } |
884 | } |
1233 | } |
885 | |
1234 | |
886 | int |
1235 | int |
887 | rxvt_term::selection_grab (int eventtime = CurrentTime) |
1236 | rxvt_term::selection_grab (U32 eventtime) |
888 | |
1237 | |
889 | void |
1238 | void |
890 | rxvt_term::selection (SV *newtext = 0) |
1239 | rxvt_term::selection (SV *newtext = 0) |
891 | PPCODE: |
1240 | PPCODE: |
892 | { |
1241 | { |
893 | if (GIMME_V != G_VOID) |
1242 | if (GIMME_V != G_VOID) |
894 | { |
1243 | XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len))); |
895 | char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len); |
|
|
896 | SV *sv = newSVpv (sel, 0); |
|
|
897 | SvUTF8_on (sv); |
|
|
898 | free (sel); |
|
|
899 | XPUSHs (sv_2mortal (sv)); |
|
|
900 | } |
|
|
901 | |
1244 | |
902 | if (newtext) |
1245 | if (newtext) |
903 | { |
1246 | { |
904 | free (THIS->selection.text); |
1247 | free (THIS->selection.text); |
905 | |
1248 | |
906 | THIS->selection.text = sv2wcs (newtext); |
1249 | THIS->selection.text = sv2wcs (newtext); |
907 | THIS->selection.len = wcslen (THIS->selection.text); |
1250 | THIS->selection.len = wcslen (THIS->selection.text); |
908 | } |
1251 | } |
909 | } |
1252 | } |
910 | |
1253 | |
|
|
1254 | void |
|
|
1255 | rxvt_term::scr_add_lines (SV *string) |
|
|
1256 | CODE: |
|
|
1257 | { |
|
|
1258 | wchar_t *wstr = sv2wcs (string); |
|
|
1259 | THIS->scr_add_lines (wstr, wcslen (wstr)); |
|
|
1260 | free (wstr); |
|
|
1261 | } |
|
|
1262 | |
911 | void |
1263 | void |
912 | rxvt_term::tt_write (SV *octets) |
1264 | rxvt_term::tt_write (SV *octets) |
913 | INIT: |
1265 | INIT: |
914 | STRLEN len; |
1266 | STRLEN len; |
915 | char *str = SvPVbyte (octets, len); |
1267 | char *str = SvPVbyte (octets, len); |
916 | C_ARGS: |
1268 | C_ARGS: |
917 | (unsigned char *)str, len |
1269 | str, len |
|
|
1270 | |
|
|
1271 | void |
|
|
1272 | rxvt_term::cmd_parse (SV *octets) |
|
|
1273 | CODE: |
|
|
1274 | { |
|
|
1275 | STRLEN len; |
|
|
1276 | char *str = SvPVbyte (octets, len); |
|
|
1277 | |
|
|
1278 | char *old_cmdbuf_ptr = THIS->cmdbuf_ptr; |
|
|
1279 | char *old_cmdbuf_endp = THIS->cmdbuf_endp; |
|
|
1280 | |
|
|
1281 | THIS->cmdbuf_ptr = str; |
|
|
1282 | THIS->cmdbuf_endp = str + len; |
|
|
1283 | |
|
|
1284 | rxvt_push_locale (THIS->locale); |
|
|
1285 | THIS->cmd_parse (); |
|
|
1286 | rxvt_pop_locale (); |
|
|
1287 | |
|
|
1288 | THIS->cmdbuf_ptr = old_cmdbuf_ptr; |
|
|
1289 | THIS->cmdbuf_endp = old_cmdbuf_endp; |
|
|
1290 | } |
918 | |
1291 | |
919 | SV * |
1292 | SV * |
920 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
1293 | rxvt_term::overlay (int x, int y, int w, int h, int rstyle = OVERLAY_RSTYLE, int border = 2) |
921 | CODE: |
1294 | CODE: |
922 | { |
1295 | { |