use strict;
use warnings;

use Irssi;

my $content = '';

sub update_preview {
    if (my $win = Irssi::window_find_name('preview')) {
	my $new_content = Irssi::parse_special('$L');
	if ($new_content ne $content) {
	    $content = $new_content;
	    $win->command('scrollback clear');
	    my $to_print = $content;
	    $to_print =~ s/%/%%/g;
	    $win->print("> $to_print", MSGLEVEL_NEVER);
	}
    }
}

Irssi::timeout_add(1000, 'update_preview', undef);
