sub on_init {
my ($self) = @_;
- $self->{digital_clock_overlay} = $self->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
- $self->{digital_clock_timer} = urxvt::timer
+ $self->{overlay} = $self->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
+ $self->{timer} = urxvt::timer
->new
->start (int urxvt::NOW) # make sure we update "on" the second
->interval (1)
->cb (sub {
- $self->{digital_clock_overlay}->set (0, 0,
+ $self->{overlay}->set (0, 0,
sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]);
});
PPCODE:
{
if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
- croak ("row_number number of out range");
+ XSRETURN_EMPTY;
line_t &l = ROW(row_number);
PPCODE:
{
if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
- croak ("row_number number of out range");
+ XSRETURN_EMPTY;
line_t &l = ROW(row_number);
CODE:
{
if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
- croak ("row_number number of out range");
+ XSRETURN_EMPTY;
line_t &l = ROW(row_number);
- RETVAL = l.l;
+ RETVAL = l.l < 0 ? THIS->ncol : l.l;
if (new_length >= -1)
l.l = new_length;
OUTPUT:
RETVAL
+bool
+rxvt_term::ROW_is_longer (int row_number)
+ CODE:
+{
+ if (!IN_RANGE_EXC (row_number, -THIS->nsaved, THIS->nrow))
+ XSRETURN_EMPTY;
+
+ line_t &l = ROW(row_number);
+ RETVAL = l.l < 0;
+}
+ OUTPUT:
+ RETVAL
+
SV *
rxvt_term::special_encode (SV *str)
CODE:
eval qq{
sub $urxvt::term::proxy::AUTOLOAD {
- unshift \@_, shift->{term};
- goto &urxvt::term::$1;
+ my \$proxy = shift;
+ \$proxy->{term}->$1 (\@_)
}
1
} or die "FATAL: unable to compile method forwarder: $@";
Returns the text of the entire row with number C<$row_number>. Row C<0>
is the topmost terminal line, row C<< $term->$ncol-1 >> is the bottommost
terminal line. The scrollback buffer starts at line C<-1> and extends to
-line C<< -$term->nsaved >>.
+line C<< -$term->nsaved >>. Nothing will be returned if a nonexistent line
+is requested.
If C<$new_text> is specified, it will replace characters in the current
line, starting at column C<$start_col> (default C<0>), which is useful
=item $length = $term->ROW_l ($row_number[, $new_length])
-Returns the number of screen cells that are in use ("the line length"). If
-it is C<-1>, then the line is part of a multiple-row logical "line", which
-means all characters are in use and it is continued on the next row.
+Returns the number of screen cells that are in use ("the line
+length"). Unlike the urxvt core, this returns C<< $term->ncol >> if the
+line is joined with the following one.
+=item $bool = $term->is_longer ($row_number)
+
+Returns true if the row is part of a multiple-row logical "line" (i.e.
+joined with the following row), which means all characters are in use
+and it is continued on the next row (and possibly a continuation of the
+previous row(s)).
+
+=item $line = $term->line ($row_number)
+
+Create and return a new C<urxvt::line> object that stores information
+about the logical line that row C<$row_number> is part of. It supports the
+following methods:
+
+=over 4
+
+=item $text = $line->t
+
+Returns the full text of the line, similar to C<ROW_t>
+
+=item $rend = $line->r
+
+Returns the full rendition array of the line, similar to C<ROW_r>
+
+=item $length = $line->l
+
+Returns the length of the line in cells, similar to C<ROW_l>.
+
+=item $rownum = $line->beg
+
+=item $rownum = $line->end
+
+Return the row number of the first/last row of the line, respectively.
+
+=item $offset = $line->offset_of ($row, $col)
+
+Returns the character offset of the given row|col pair within the logical
+line.
+
+=item ($row, $col) = $line->coord_of ($offset)
+
+Translates a string offset into terminal coordinates again.
+
+=back
+
+=cut
+
+sub urxvt::term::line {
+ my ($self, $row) = @_;
+
+ my $maxrow = $self->nrow - 1;
+
+ my ($beg, $end) = ($row, $row);
+
+ --$beg while $self->ROW_is_longer ($beg - 1);
+ ++$end while $self->ROW_is_longer ($end) && $end < $maxrow;
+
+ bless {
+ term => $self,
+ beg => $beg,
+ end => $end,
+ len => ($end - $beg) * $self->ncol + $self->ROW_l ($end),
+ }, urxvt::line::
+}
+
+sub urxvt::line::t {
+ my ($self) = @_;
+
+ substr +(join "", map $self->{term}->ROW_t ($_), $self->{beg} .. $self->{end}),
+ 0, $self->{len}
+}
+
+sub urxvt::line::r {
+ my ($self) = @_;
+
+ my $rend = [
+ map @{ $self->{term}->ROW_r ($_) }, $self->{beg} .. $self->{end}
+ ];
+ $#$rend = $self->{len} - 1;
+ $rend
+}
+
+sub urxvt::line::beg { $_[0]{beg} }
+sub urxvt::line::end { $_[0]{end} }
+sub urxvt::line::l { $_[0]{len} }
+
+sub urxvt::line::offset_of {
+ my ($self, $row, $col) = @_;
+
+ ($row - $self->{beg}) * $self->{term}->ncol + $col
+}
+
+sub urxvt::line::coord_of {
+ my ($self, $offset) = @_;
+
+ use integer;
+
+ (
+ $offset / $self->{term}->ncol + $self->{beg},
+ $offset % $self->{term}->ncol
+ )
+}
+
+=item ($row, $col) = $line->coord_of ($offset)
=item $text = $term->special_encode $string
Converts a perl string into the special encoding used by rxvt-unicode,