… | |
… | |
60 | |
60 | |
61 | =item digital-clock |
61 | =item digital-clock |
62 | |
62 | |
63 | Displays a digital clock using the built-in overlay. |
63 | Displays a digital clock using the built-in overlay. |
64 | |
64 | |
|
|
65 | =item mark-urls |
|
|
66 | |
|
|
67 | Uses per-line filtering (C<on_line_update>) to underline urls. |
|
|
68 | |
65 | =item example-refresh-hooks |
69 | =item example-refresh-hooks |
66 | |
70 | |
67 | Displays a very simple digital clock in the upper right corner of the |
71 | Displays a very simple digital clock in the upper right corner of the |
68 | window. Illustrates overwriting the refresh callbacks to create your own |
72 | window. Illustrates overwriting the refresh callbacks to create your own |
69 | overlays or changes. |
73 | overlays or changes. |
70 | |
74 | |
71 | =item mark-urls |
75 | =item example-filter-input |
72 | |
76 | |
73 | A not very useful example of filtering all text output to the terminal, by |
77 | 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 |
78 | 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. |
79 | is not very useful because urls that are output in multiple steps (e.g. |
76 | when typing them) do not get marked. |
80 | when typing them) do not get marked. |
… | |
… | |
222 | Called whenever text is about to be output, with the text as argument. You |
226 | 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 |
227 | 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 |
228 | 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 |
229 | might be very slow, however, as your hook is called for B<all> text being |
226 | output. |
230 | output. |
|
|
231 | |
|
|
232 | =item on_line_update $term, $row |
|
|
233 | |
|
|
234 | Called whenever a line was updated or changed. Can be used to filter |
|
|
235 | screen output (e.g. underline urls or other useless stuff). Only lines |
|
|
236 | that are being shown will be filtered, and, due to performance reasons, |
|
|
237 | not always immediately. |
|
|
238 | |
|
|
239 | The row number is always the topmost row of the line if the line spans |
|
|
240 | multiple rows. |
|
|
241 | |
|
|
242 | Please note that, if you change the line, then the hook might get called |
|
|
243 | later with the already-modified line (e.g. if unrelated parts change), so |
|
|
244 | you cannot just toggle rendition bits, but only set them. |
227 | |
245 | |
228 | =item on_refresh_begin $term |
246 | =item on_refresh_begin $term |
229 | |
247 | |
230 | Called just before the screen gets redrawn. Can be used for overlay |
248 | Called just before the screen gets redrawn. Can be used for overlay |
231 | or similar effects by modify terminal contents in refresh_begin, and |
249 | or similar effects by modify terminal contents in refresh_begin, and |
… | |
… | |
735 | about the logical line that row C<$row_number> is part of. It supports the |
753 | about the logical line that row C<$row_number> is part of. It supports the |
736 | following methods: |
754 | following methods: |
737 | |
755 | |
738 | =over 4 |
756 | =over 4 |
739 | |
757 | |
740 | =item $text = $line->t |
758 | =item $text = $line->t ([$new_text]) |
741 | |
759 | |
742 | Returns the full text of the line, similar to C<ROW_t> |
760 | Returns or replaces the full text of the line, similar to C<ROW_t> |
743 | |
761 | |
744 | =item $rend = $line->r |
762 | =item $rend = $line->r ([$new_rend]) |
745 | |
763 | |
746 | Returns the full rendition array of the line, similar to C<ROW_r> |
764 | Returns or replaces the full rendition array of the line, similar to C<ROW_r> |
747 | |
765 | |
748 | =item $length = $line->l |
766 | =item $length = $line->l |
749 | |
767 | |
750 | Returns the length of the line in cells, similar to C<ROW_l>. |
768 | Returns the length of the line in cells, similar to C<ROW_l>. |
751 | |
769 | |
… | |
… | |
780 | |
798 | |
781 | bless { |
799 | bless { |
782 | term => $self, |
800 | term => $self, |
783 | beg => $beg, |
801 | beg => $beg, |
784 | end => $end, |
802 | end => $end, |
|
|
803 | ncol => $self->ncol, |
785 | len => ($end - $beg) * $self->ncol + $self->ROW_l ($end), |
804 | len => ($end - $beg) * $self->ncol + $self->ROW_l ($end), |
786 | }, urxvt::line:: |
805 | }, urxvt::line:: |
787 | } |
806 | } |
788 | |
807 | |
789 | sub urxvt::line::t { |
808 | sub urxvt::line::t { |
790 | my ($self) = @_; |
809 | my ($self) = @_; |
791 | |
810 | |
|
|
811 | if (@_ > 1) |
|
|
812 | { |
|
|
813 | $self->{term}->ROW_t ($_, $_[1], 0, ($_ - $self->{beg}) * $self->{ncol}, $self->{ncol}) |
|
|
814 | for $self->{beg} .. $self->{end}; |
|
|
815 | } |
|
|
816 | |
|
|
817 | defined wantarray && |
792 | substr +(join "", map $self->{term}->ROW_t ($_), $self->{beg} .. $self->{end}), |
818 | substr +(join "", map $self->{term}->ROW_t ($_), $self->{beg} .. $self->{end}), |
793 | 0, $self->{len} |
819 | 0, $self->{len} |
794 | } |
820 | } |
795 | |
821 | |
796 | sub urxvt::line::r { |
822 | sub urxvt::line::r { |
797 | my ($self) = @_; |
823 | my ($self) = @_; |
798 | |
824 | |
|
|
825 | if (@_ > 1) |
|
|
826 | { |
|
|
827 | $self->{term}->ROW_r ($_, $_[1], 0, ($_ - $self->{beg}) * $self->{ncol}, $self->{ncol}) |
|
|
828 | for $self->{beg} .. $self->{end}; |
|
|
829 | } |
|
|
830 | |
|
|
831 | if (defined wantarray) { |
799 | my $rend = [ |
832 | my $rend = [ |
800 | map @{ $self->{term}->ROW_r ($_) }, $self->{beg} .. $self->{end} |
833 | map @{ $self->{term}->ROW_r ($_) }, $self->{beg} .. $self->{end} |
801 | ]; |
834 | ]; |
802 | $#$rend = $self->{len} - 1; |
835 | $#$rend = $self->{len} - 1; |
803 | $rend |
836 | return $rend; |
|
|
837 | } |
|
|
838 | |
|
|
839 | () |
804 | } |
840 | } |
805 | |
841 | |
806 | sub urxvt::line::beg { $_[0]{beg} } |
842 | sub urxvt::line::beg { $_[0]{beg} } |
807 | sub urxvt::line::end { $_[0]{end} } |
843 | sub urxvt::line::end { $_[0]{end} } |
808 | sub urxvt::line::l { $_[0]{len} } |
844 | sub urxvt::line::l { $_[0]{len} } |
809 | |
845 | |
810 | sub urxvt::line::offset_of { |
846 | sub urxvt::line::offset_of { |
811 | my ($self, $row, $col) = @_; |
847 | my ($self, $row, $col) = @_; |
812 | |
848 | |
813 | ($row - $self->{beg}) * $self->{term}->ncol + $col |
849 | ($row - $self->{beg}) * $self->{ncol} + $col |
814 | } |
850 | } |
815 | |
851 | |
816 | sub urxvt::line::coord_of { |
852 | sub urxvt::line::coord_of { |
817 | my ($self, $offset) = @_; |
853 | my ($self, $offset) = @_; |
818 | |
854 | |
819 | use integer; |
855 | use integer; |
820 | |
856 | |
821 | ( |
857 | ( |
822 | $offset / $self->{term}->ncol + $self->{beg}, |
858 | $offset / $self->{ncol} + $self->{beg}, |
823 | $offset % $self->{term}->ncol |
859 | $offset % $self->{ncol} |
824 | ) |
860 | ) |
825 | } |
861 | } |
826 | |
862 | |
827 | =item ($row, $col) = $line->coord_of ($offset) |
863 | =item ($row, $col) = $line->coord_of ($offset) |
828 | =item $text = $term->special_encode $string |
864 | =item $text = $term->special_encode $string |