I am trying to write a rxvt-unicode perl extension to do what [mrxvt PrintScreen](https://code.google.com/p/mrxvt/wiki/Tips#Can_I_search_the_scroll_back_buffer) does. I.e., the extension should pipe urxvt's contents to user-defined commands. The main purpose would be viewing urxvt's contents unwrapped in
less -S
.
Here are my first attempts. (The command is still hardcoded cat -n
, and including color escape codes and joining of wrapped lines is still missing.)
#! perl -w
use strict;
sub on_user_command {
my ($self, $cmd) = @_;
open PIPE, "|cat -n" or die "urxvt-pipe: error opening pipe: $^E\n";
for (my $i = $self->top_row; $i nrow; $i++) {
print PIPE $self->ROW_t($i), "\n";
}
close PIPE or warn "urxvt-pipe: error closing pipe: $^E\n";
()
}
Replacing the pipe with exec_async
does not help:
#! perl -w
use strict;
sub on_user_command {
my ($self, $cmd) = @_;
open FH, ">/tmp/urxvt.txt" or die "urxvt-pipe: error opening file: $^E\n";
for (my $i = $self->top_row; $i nrow; $i++) {
print FH $self->ROW_t($i), "\n";
}
close FH or warn "urxvt-pipe: error closing file: $^E\n";
$self->exec_async("cat", "-n", "/tmp/urxvt.txt");
()
}
The problem with both is that the cat
runs inside urxvt's parent (e.g. another urxvt or an emacs buffer if I call urxvt as the "compile" command during extension development). I would like it to run in the instance whose contents I'm piping, or a new tab thereof. Is that possible?
Obviously as a workaround, the exec_async
could be modified to open a new window: $self->exec_async("urxvt", "-title", "less urxvt scrollback", "-e", "less", "-S", "/tmp/urxvt.txt");
But I'd prefer the same window, and also rather avoid creating a temporary file.
Asked by EndlosSchleife
(173 rep)
Sep 10, 2015, 11:01 PM
Last activity: Dec 10, 2022, 03:08 PM
Last activity: Dec 10, 2022, 03:08 PM