Show more information in screen status.
[profile.git] / .urxvt / vimselection
1 #!/usr/bin/perl
2
3 # Hide Vim stuff like marks and numbers from the selection.
4 sub on_sel_grab {
5   my ($self) = @_;
6
7   # Assume that the terminal will have been resized.
8   return unless $self->{term}->ncol > 80;
9
10   my $selection = $self->{term}->selection;
11   my @lines = split /\n/, $selection;
12   my @new;
13   my $n = 0;
14
15   foreach my $line (@lines) {
16     # If this is the first line only do the replacement at the beginning.
17     # Subsequent lines are necessarily captured from the first column.
18     unless ($n++) {
19       if (($self->{term}->selection_beg)[1] > 1) {
20         push @new, $line;
21         next;
22       }
23     }
24
25     # Strip signs, numbers (five or eight columns) and non-line squiggles.
26     if ($line =~ /^(. )?(~|[ \d]{5}|[ \d]{8})?/) { $line =~ s/// }
27
28     push @new, $line;
29   }
30
31   # Save the new selection.
32   $selection = join "\n", @new;
33   $self->{term}->selection($selection);
34 }