$|=1;
local $/ = undef;
$_ = <STDIN>;

print "#plugin norepaint\n";
print "#plugin save_edited\n";
print "#plugin save_cursor\n";
if (isdirty ($_)) { print bleach($_); } else { print unbleach($_) };
print "#plugin repaint\n";
print "#plugin restore_cursor\n";
print "#plugin restore_edited\n";

sub bleach
{
  local $_ = unpack "b*", $_[0];
  tr/01/ \t/;
  #s/(.{1023})/$1\n/g;
  s/(.{76})/$1\n/g;
  "$_\n";
}

sub unbleach
{ 
  local $_ = $_[0];
  s/\n//g;
  tr/ \t/01/;
  pack "b*", $_;
}

sub isdirty { $_[0] =~ /[^\n \t]/ }

=comment
