… | |
… | |
65 | =item example-refresh-hooks |
65 | =item example-refresh-hooks |
66 | |
66 | |
67 | Displays a very simple digital clock in the upper right corner of the |
67 | Displays a very simple digital clock in the upper right corner of the |
68 | window. Illustrates overwriting the refresh callbacks to create your own |
68 | window. Illustrates overwriting the refresh callbacks to create your own |
69 | overlays or changes. |
69 | overlays or changes. |
|
|
70 | |
|
|
71 | =item mark-urls |
|
|
72 | |
|
|
73 | A not very useful example of filtering all text output to the terminal, by |
|
|
74 | underlining all urls that matches a certain regex (i.e. some urls :). It |
|
|
75 | is not very useful because urls that are output in multiple steps (e.g. |
|
|
76 | when typing them) do not get marked. |
70 | |
77 | |
71 | =back |
78 | =back |
72 | |
79 | |
73 | =head2 General API Considerations |
80 | =head2 General API Considerations |
74 | |
81 | |
… | |
… | |
80 | |
87 | |
81 | When objects are destroyed on the C++ side, the perl object hashes are |
88 | When objects are destroyed on the C++ side, the perl object hashes are |
82 | emptied, so its best to store related objects such as time watchers and |
89 | emptied, so its best to store related objects such as time watchers and |
83 | the like inside the terminal object so they get destroyed as soon as the |
90 | the like inside the terminal object so they get destroyed as soon as the |
84 | terminal is destroyed. |
91 | terminal is destroyed. |
|
|
92 | |
|
|
93 | Argument names also often indicate the type of a parameter. Here are some |
|
|
94 | hints on what they mean: |
|
|
95 | |
|
|
96 | =over 4 |
|
|
97 | |
|
|
98 | =item $text |
|
|
99 | |
|
|
100 | Rxvt-unicodes special way of encoding text, where one "unicode" character |
|
|
101 | always represents one screen cell. See L<row_t> for a discussion of this format. |
|
|
102 | |
|
|
103 | =item $string |
|
|
104 | |
|
|
105 | A perl text string, with an emphasis on I<text>. It can store all unicode |
|
|
106 | characters and is to be distinguished with text encoded in a specific |
|
|
107 | encoding (often locale-specific) and binary data. |
|
|
108 | |
|
|
109 | =item $octets |
|
|
110 | |
|
|
111 | Either binary data or - more common - a text string encoded in a |
|
|
112 | locale-specific way. |
|
|
113 | |
|
|
114 | =back |
85 | |
115 | |
86 | =head2 Hooks |
116 | =head2 Hooks |
87 | |
117 | |
88 | The following subroutines can be declared in loaded scripts, and will be |
118 | The following subroutines can be declared in loaded scripts, and will be |
89 | called whenever the relevant event happens. |
119 | called whenever the relevant event happens. |
… | |
… | |
184 | future. |
214 | future. |
185 | |
215 | |
186 | Be careful not ever to trust (in a security sense) the data you receive, |
216 | Be careful not ever to trust (in a security sense) the data you receive, |
187 | as its source can not easily be controleld (e-mail content, messages from |
217 | as its source can not easily be controleld (e-mail content, messages from |
188 | other users on the same system etc.). |
218 | other users on the same system etc.). |
|
|
219 | |
|
|
220 | =item on_add_lines $term, $string |
|
|
221 | |
|
|
222 | Called whenever text is about to be output, with the text as argument. You |
|
|
223 | can filter/change and output the text yourself by returning a true value |
|
|
224 | and calling C<< $term->scr_add_lines >> yourself. Please note that this |
|
|
225 | might be very slow, however, as your hook is called for B<all> text being |
|
|
226 | output. |
189 | |
227 | |
190 | =item on_refresh_begin $term |
228 | =item on_refresh_begin $term |
191 | |
229 | |
192 | Called just before the screen gets redrawn. Can be used for overlay |
230 | Called just before the screen gets redrawn. Can be used for overlay |
193 | or similar effects by modify terminal contents in refresh_begin, and |
231 | or similar effects by modify terminal contents in refresh_begin, and |
… | |
… | |
487 | my ($self, $name) = (shift, shift); |
525 | my ($self, $name) = (shift, shift); |
488 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
526 | unshift @_, $self, $name, ($name =~ s/\s*\+\s*(\d+)$// ? $1 : 0); |
489 | goto &urxvt::term::_resource; |
527 | goto &urxvt::term::_resource; |
490 | } |
528 | } |
491 | |
529 | |
|
|
530 | =item $rend = $term->rstyle ([$new_rstyle]) |
|
|
531 | |
|
|
532 | Return and optionally change the current rendition. Text that is output by |
|
|
533 | the terminal application will use this style. |
|
|
534 | |
|
|
535 | =item ($row, $col) = $term->screen_cur ([$row, $col]) |
|
|
536 | |
|
|
537 | Return the current coordinates of the text cursor position and optionally |
|
|
538 | set it (which is usually bad as applications don't expect that). |
|
|
539 | |
492 | =item ($row, $col) = $term->selection_mark ([$row, $col]) |
540 | =item ($row, $col) = $term->selection_mark ([$row, $col]) |
493 | |
541 | |
494 | =item ($row, $col) = $term->selection_beg ([$row, $col]) |
542 | =item ($row, $col) = $term->selection_beg ([$row, $col]) |
495 | |
543 | |
496 | =item ($row, $col) = $term->selection_end ([$row, $col]) |
544 | =item ($row, $col) = $term->selection_end ([$row, $col]) |
… | |
… | |
510 | #=item $term->overlay ($x, $y, $text) |
558 | #=item $term->overlay ($x, $y, $text) |
511 | # |
559 | # |
512 | #Create a simple multi-line overlay box. See the next method for details. |
560 | #Create a simple multi-line overlay box. See the next method for details. |
513 | # |
561 | # |
514 | #=cut |
562 | #=cut |
515 | |
563 | # |
516 | sub urxvt::term::scr_overlay { |
564 | #sub urxvt::term::scr_overlay { |
517 | die; |
|
|
518 | my ($self, $x, $y, $text) = @_; |
565 | # my ($self, $x, $y, $text) = @_; |
519 | |
566 | # |
520 | my @lines = split /\n/, $text; |
567 | # my @lines = split /\n/, $text; |
521 | |
568 | # |
522 | my $w = 0; |
569 | # my $w = 0; |
523 | for (map $self->strwidth ($_), @lines) { |
570 | # for (map $self->strwidth ($_), @lines) { |
524 | $w = $_ if $w < $_; |
571 | # $w = $_ if $w < $_; |
525 | } |
572 | # } |
526 | |
573 | # |
527 | $self->scr_overlay_new ($x, $y, $w, scalar @lines); |
574 | # $self->scr_overlay_new ($x, $y, $w, scalar @lines); |
528 | $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines; |
575 | # $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines; |
529 | } |
576 | #} |
530 | |
577 | |
531 | =item $term->overlay ($x, $y, $width, $height[, $rstyle[, $border]]) |
578 | =item $term->overlay ($x, $y, $width, $height[, $rstyle[, $border]]) |
532 | |
579 | |
533 | Create a new (empty) overlay at the given position with the given |
580 | Create a new (empty) overlay at the given position with the given |
534 | width/height. C<$rstyle> defines the initial rendition style |
581 | width/height. C<$rstyle> defines the initial rendition style |
… | |
… | |
574 | |
621 | |
575 | =item $string = $term->locale_decode $octets |
622 | =item $string = $term->locale_decode $octets |
576 | |
623 | |
577 | Convert the given locale-encoded octets into a perl string. |
624 | Convert the given locale-encoded octets into a perl string. |
578 | |
625 | |
|
|
626 | =item $term->scr_add_lines ($string) |
|
|
627 | |
|
|
628 | Write the given text string to the screen, as if output by the application |
|
|
629 | running inside the terminal. It may not contain command sequences (escape |
|
|
630 | codes), but is free to use line feeds, carriage returns and tabs. The |
|
|
631 | string is a normal text string, not in locale-dependent encoding. |
|
|
632 | |
|
|
633 | Normally its not a good idea to use this function, as programs might be |
|
|
634 | confused by changes in cursor position or scrolling. Its useful inside a |
|
|
635 | C<on_add_lines> hook, though. |
|
|
636 | |
579 | =item $term->tt_write ($octets) |
637 | =item $term->tt_write ($octets) |
580 | |
638 | |
581 | Write the octets given in C<$data> to the tty (i.e. as program input). To |
639 | Write the octets given in C<$data> to the tty (i.e. as program input). To |
582 | pass characters instead of octets, you should convert your strings first |
640 | pass characters instead of octets, you should convert your strings first |
583 | to the locale-specific encoding using C<< $term->locale_encode >>. |
641 | to the locale-specific encoding using C<< $term->locale_encode >>. |
584 | |
642 | |
|
|
643 | =item $window_width = $term->width |
|
|
644 | |
|
|
645 | =item $window_height = $term->height |
|
|
646 | |
|
|
647 | =item $font_width = $term->fwidth |
|
|
648 | |
|
|
649 | =item $font_height = $term->fheight |
|
|
650 | |
|
|
651 | =item $font_ascent = $term->fbase |
|
|
652 | |
585 | =item $nrow = $term->nrow |
653 | =item $terminal_rows = $term->nrow |
586 | |
654 | |
587 | =item $ncol = $term->ncol |
655 | =item $terminal_columns = $term->ncol |
588 | |
656 | |
589 | Return the number of rows/columns of the terminal window (i.e. as |
657 | =item $has_focus = $term->focus |
590 | specified by C<-geometry>, excluding any scrollback). |
|
|
591 | |
658 | |
592 | =item $nsaved = $term->nsaved |
659 | =item $is_mapped = $term->mapped |
593 | |
660 | |
594 | Returns the number of lines in the scrollback buffer. |
661 | =item $max_scrollback = $term->saveLines |
|
|
662 | |
|
|
663 | =item $nrow_plus_saveLines = $term->total_rows |
|
|
664 | |
|
|
665 | =item $lines_in_scrollback = $term->nsaved |
|
|
666 | |
|
|
667 | Return various integers describing terminal characteristics. |
595 | |
668 | |
596 | =item $view_start = $term->view_start ([$newvalue]) |
669 | =item $view_start = $term->view_start ([$newvalue]) |
597 | |
670 | |
598 | Returns the negative row number of the topmost line. Minimum value is |
671 | Returns the negative row number of the topmost line. Minimum value is |
599 | C<0>, which displays the normal terminal contents. Larger values scroll |
672 | C<0>, which displays the normal terminal contents. Larger values scroll |