… | |
… | |
35 | #include "rxvtutil.h" |
35 | #include "rxvtutil.h" |
36 | #include "rxvtperl.h" |
36 | #include "rxvtperl.h" |
37 | |
37 | |
38 | #include "perlxsi.c" |
38 | #include "perlxsi.c" |
39 | |
39 | |
|
|
40 | #undef LINENO |
|
|
41 | #define LINENO(n) MOD (THIS->term_start + int(n), THIS->total_rows) |
|
|
42 | #undef ROW |
|
|
43 | #define ROW(n) THIS->row_buf [LINENO (n)] |
|
|
44 | |
40 | ///////////////////////////////////////////////////////////////////////////// |
45 | ///////////////////////////////////////////////////////////////////////////// |
41 | |
46 | |
42 | static wchar_t * |
47 | static wchar_t * |
43 | sv2wcs (SV *sv) |
48 | sv2wcs (SV *sv) |
44 | { |
49 | { |
… | |
… | |
291 | PROTOTYPES: ENABLE |
296 | PROTOTYPES: ENABLE |
292 | |
297 | |
293 | BOOT: |
298 | BOOT: |
294 | { |
299 | { |
295 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
300 | # define set_hookname(sym) av_store (hookname, PP_CONCAT(HOOK_, sym), newSVpv (PP_STRINGIFY(sym), 0)) |
|
|
301 | # define export_const(name) newCONSTSUB (gv_stashpv ("urxvt", 1), #name, newSViv (name)); |
296 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
302 | AV *hookname = get_av ("urxvt::HOOKNAME", 1); |
297 | set_hookname (INIT); |
303 | set_hookname (INIT); |
298 | set_hookname (RESET); |
304 | set_hookname (RESET); |
299 | set_hookname (START); |
305 | set_hookname (START); |
300 | set_hookname (DESTROY); |
306 | set_hookname (DESTROY); |
… | |
… | |
309 | set_hookname (TTY_ACTIVITY); |
315 | set_hookname (TTY_ACTIVITY); |
310 | set_hookname (REFRESH_BEGIN); |
316 | set_hookname (REFRESH_BEGIN); |
311 | set_hookname (REFRESH_END); |
317 | set_hookname (REFRESH_END); |
312 | set_hookname (KEYBOARD_COMMAND); |
318 | set_hookname (KEYBOARD_COMMAND); |
313 | |
319 | |
|
|
320 | export_const (DEFAULT_RSTYLE); |
|
|
321 | export_const (OVERLAY_RSTYLE); |
|
|
322 | export_const (RS_Bold); |
|
|
323 | export_const (RS_Italic); |
|
|
324 | export_const (RS_Blink); |
|
|
325 | export_const (RS_RVid); |
|
|
326 | export_const (RS_Uline); |
|
|
327 | |
314 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
328 | sv_setpv (get_sv ("urxvt::LIBDIR", 1), LIBDIR); |
315 | } |
329 | } |
316 | |
330 | |
317 | void |
331 | void |
318 | set_should_invoke (int htype, int value) |
332 | set_should_invoke (int htype, int value) |
… | |
… | |
332 | NV |
346 | NV |
333 | NOW () |
347 | NOW () |
334 | CODE: |
348 | CODE: |
335 | RETVAL = NOW; |
349 | RETVAL = NOW; |
336 | OUTPUT: |
350 | OUTPUT: |
|
|
351 | RETVAL |
|
|
352 | |
|
|
353 | int |
|
|
354 | GET_BASEFG (int rend) |
|
|
355 | CODE: |
|
|
356 | RETVAL = GET_BASEFG (rend); |
|
|
357 | OUTPUT: |
|
|
358 | RETVAL |
|
|
359 | |
|
|
360 | int |
|
|
361 | GET_BASEBG (int rend) |
|
|
362 | CODE: |
|
|
363 | RETVAL = GET_BASEBG (rend); |
|
|
364 | OUTPUT: |
|
|
365 | RETVAL |
|
|
366 | |
|
|
367 | int |
|
|
368 | SET_FGCOLOR (int rend, int new_color) |
|
|
369 | CODE: |
|
|
370 | RETVAL = SET_FGCOLOR (rend, new_color); |
|
|
371 | OUTPUT: |
|
|
372 | RETVAL |
|
|
373 | |
|
|
374 | int |
|
|
375 | SET_BGCOLOR (int rend, int new_color) |
|
|
376 | CODE: |
|
|
377 | RETVAL = SET_BGCOLOR (rend, new_color); |
|
|
378 | OUTPUT: |
|
|
379 | RETVAL |
|
|
380 | |
|
|
381 | int |
|
|
382 | GET_CUSTOM (int rend) |
|
|
383 | CODE: |
|
|
384 | RETVAL = (rend && RS_customMask) >> RS_customShift; |
|
|
385 | OUTPUT: |
|
|
386 | RETVAL |
|
|
387 | |
|
|
388 | int |
|
|
389 | SET_CUSTOM (int rend, int new_value) |
|
|
390 | CODE: |
|
|
391 | { |
|
|
392 | if (!IN_RANGE_EXC (new_value, 0, RS_customCount)) |
|
|
393 | croak ("custom value out of range, must be 0..%d", RS_customCount - 1); |
|
|
394 | |
|
|
395 | RETVAL = (rend & ~RS_customMask) |
|
|
396 | | ((new_value << RS_customShift) & RS_customMask); |
|
|
397 | } |
|
|
398 | OUTPUT: |
337 | RETVAL |
399 | RETVAL |
338 | |
400 | |
339 | MODULE = urxvt PACKAGE = urxvt::term |
401 | MODULE = urxvt PACKAGE = urxvt::term |
340 | |
402 | |
341 | int |
403 | int |
… | |
… | |
389 | SvUTF8_on (RETVAL); |
451 | SvUTF8_on (RETVAL); |
390 | free (str); |
452 | free (str); |
391 | } |
453 | } |
392 | OUTPUT: |
454 | OUTPUT: |
393 | RETVAL |
455 | RETVAL |
|
|
456 | |
|
|
457 | int |
|
|
458 | rxvt_term::nsaved () |
|
|
459 | CODE: |
|
|
460 | RETVAL = THIS->nsaved; |
|
|
461 | OUTPUT: |
|
|
462 | RETVAL |
|
|
463 | |
|
|
464 | int |
|
|
465 | rxvt_term::view_start (int newval = -1) |
|
|
466 | CODE: |
|
|
467 | { |
|
|
468 | RETVAL = THIS->view_start; |
|
|
469 | |
|
|
470 | if (newval >= 0) |
|
|
471 | { |
|
|
472 | THIS->view_start = min (newval, THIS->nsaved); |
|
|
473 | THIS->scr_changeview (RETVAL); |
|
|
474 | } |
|
|
475 | } |
|
|
476 | OUTPUT: |
|
|
477 | RETVAL |
|
|
478 | |
|
|
479 | int |
|
|
480 | rxvt_term::nrow () |
|
|
481 | CODE: |
|
|
482 | RETVAL = THIS->nrow; |
|
|
483 | OUTPUT: |
|
|
484 | RETVAL |
|
|
485 | |
|
|
486 | int |
|
|
487 | rxvt_term::ncol () |
|
|
488 | CODE: |
|
|
489 | RETVAL = THIS->ncol; |
|
|
490 | OUTPUT: |
|
|
491 | RETVAL |
|
|
492 | |
|
|
493 | void |
|
|
494 | rxvt_term::want_refresh () |
|
|
495 | CODE: |
|
|
496 | THIS->want_refresh = 1; |
|
|
497 | |
|
|
498 | void |
|
|
499 | rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0) |
|
|
500 | PPCODE: |
|
|
501 | { |
|
|
502 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
503 | croak ("row_number number of out range"); |
|
|
504 | |
|
|
505 | line_t &l = ROW(row_number); |
|
|
506 | |
|
|
507 | if (GIMME_V != G_VOID) |
|
|
508 | { |
|
|
509 | wchar_t *wstr = new wchar_t [THIS->ncol]; |
|
|
510 | |
|
|
511 | for (int col = 0; col <THIS->ncol; col++) |
|
|
512 | wstr [col] = l.t [col]; |
|
|
513 | |
|
|
514 | char *str = rxvt_wcstoutf8 (wstr, THIS->ncol); |
|
|
515 | free (wstr); |
|
|
516 | |
|
|
517 | SV *sv = newSVpv (str, 0); |
|
|
518 | SvUTF8_on (sv); |
|
|
519 | XPUSHs (sv_2mortal (sv)); |
|
|
520 | free (str); |
|
|
521 | } |
|
|
522 | |
|
|
523 | if (new_text) |
|
|
524 | { |
|
|
525 | STRLEN slen; |
|
|
526 | char *str = SvPVutf8 (new_text, slen); |
|
|
527 | wchar_t *wstr = rxvt_utf8towcs (str, slen); |
|
|
528 | |
|
|
529 | int len = wcslen (wstr); |
|
|
530 | |
|
|
531 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
532 | { |
|
|
533 | free (wstr); |
|
|
534 | croak ("new_text extends beyond horizontal margins"); |
|
|
535 | } |
|
|
536 | |
|
|
537 | for (int col = start_col; col < start_col + len; col++) |
|
|
538 | { |
|
|
539 | l.t [col] = wstr [col - start_col]; |
|
|
540 | l.r [col] = SET_FONT (l.r [col], THIS->fontset [GET_STYLE (l.r [col])]->find_font (l.t [col])); |
|
|
541 | } |
|
|
542 | |
|
|
543 | free (wstr); |
|
|
544 | } |
|
|
545 | } |
|
|
546 | |
|
|
547 | void |
|
|
548 | rxvt_term::ROW_r (int row_number, SV *new_rend = 0, int start_col = 0) |
|
|
549 | PPCODE: |
|
|
550 | { |
|
|
551 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
552 | croak ("row_number number of out range"); |
|
|
553 | |
|
|
554 | line_t &l = ROW(row_number); |
|
|
555 | |
|
|
556 | if (GIMME_V != G_VOID) |
|
|
557 | { |
|
|
558 | AV *av = newAV (); |
|
|
559 | |
|
|
560 | av_extend (av, THIS->ncol - 1); |
|
|
561 | for (int col = 0; col < THIS->ncol; col++) |
|
|
562 | av_store (av, col, newSViv (l.r [col])); |
|
|
563 | |
|
|
564 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)av))); |
|
|
565 | } |
|
|
566 | |
|
|
567 | if (new_rend) |
|
|
568 | { |
|
|
569 | if (!SvROK (new_rend) || SvTYPE (SvRV (new_rend)) != SVt_PVAV) |
|
|
570 | croak ("new_rend must be arrayref"); |
|
|
571 | |
|
|
572 | AV *av = (AV *)SvRV (new_rend); |
|
|
573 | int len = av_len (av) + 1; |
|
|
574 | |
|
|
575 | if (!IN_RANGE_INC (start_col, 0, THIS->ncol - len)) |
|
|
576 | croak ("new_rend array extends beyond horizontal margins"); |
|
|
577 | |
|
|
578 | for (int col = start_col; col < start_col + len; col++) |
|
|
579 | { |
|
|
580 | rend_t r = SvIV (*av_fetch (av, col - start_col, 1)) & ~RS_fontMask; |
|
|
581 | |
|
|
582 | l.r [col] = SET_FONT (r, THIS->fontset [GET_STYLE (r)]->find_font (l.t [col])); |
|
|
583 | } |
|
|
584 | } |
|
|
585 | } |
|
|
586 | |
|
|
587 | int |
|
|
588 | rxvt_term::ROW_l (int row_number, int new_length = -2) |
|
|
589 | CODE: |
|
|
590 | { |
|
|
591 | if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow)) |
|
|
592 | croak ("row_number number of out range"); |
|
|
593 | |
|
|
594 | line_t &l = ROW(row_number); |
|
|
595 | RETVAL = l.l; |
|
|
596 | |
|
|
597 | if (new_length >= -1) |
|
|
598 | l.l = new_length; |
|
|
599 | } |
|
|
600 | OUTPUT: |
|
|
601 | RETVAL |
|
|
602 | |
|
|
603 | SV * |
|
|
604 | rxvt_term::special_encode (SV *str) |
|
|
605 | CODE: |
|
|
606 | abort ();//TODO |
|
|
607 | |
|
|
608 | SV * |
|
|
609 | rxvt_term::special_decode (SV *str) |
|
|
610 | CODE: |
|
|
611 | abort ();//TODO |
394 | |
612 | |
395 | void |
613 | void |
396 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
614 | rxvt_term::_resource (char *name, int index, SV *newval = 0) |
397 | PPCODE: |
615 | PPCODE: |
398 | { |
616 | { |