| 1 | package Vim::X::Range; | ||||||||||
| 2 | BEGIN { | ||||||||||
| 3 | 1 | ▶ | $Vim::X::Range::AUTHORITY = 'cpan:YANICK'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | } | ||||||||||
| 5 | # ABSTRACT: A range of lines in a Vim buffer | ||||||||||
| 6 | 1 | $Vim::X::Range::VERSION = '1.1.0'; | |||||||||
| 7 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | use overload | ||||||||||
| 10 | '@{}' => sub { | ||||||||||
| 11 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 12 | 0 | return $self->lines; | |||||||||
| 13 | }, | ||||||||||
| 14 | 1 | ▶ | '""' => \&as_string; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | |||||||||||
| 17 | |||||||||||
| 18 | 1 | has [ qw/ from to / ] => ( | |||||||||
| 19 | is => 'rw', | ||||||||||
| 20 | required => 1, | ||||||||||
| 21 | ); | ||||||||||
| 22 | |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 1 | has "_buffer" => ( | |||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | required => 1, | ||||||||||
| 28 | ); | ||||||||||
| 29 | |||||||||||
| 30 | sub lines { | ||||||||||
| 31 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
lines: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | 0 | return $self->_buffer->lines( $self->from..$self->to ); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | sub replace { | ||||||||||
| 37 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
replace: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | |||||||||||
| 39 | # strinfigy if needed | ||||||||||
| 40 | 0 | my @new = map { split "\n", "$_" } @_; | |||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | 0 | $self->_buffer->delete( ($self->from+1)..$self->to ); | |||||||||
| 44 | |||||||||||
| 45 | 0 | $self->to( $self->from + @new -1 ); | |||||||||
| 46 | |||||||||||
| 47 | 0 | $self->_buffer->line($self->from)->content( @new ); | |||||||||
| 48 | |||||||||||
| 49 | 0 | return $self; | |||||||||
| 50 | } | ||||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | sub as_string { | ||||||||||
| 54 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
as_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | 0 | return join "\n", $self->lines; | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | sub from_rewind { | ||||||||||
| 60 | 0 | ▶ | my( $self, $condition ) = @_; | ||||||||
|
Subroutine
from_rewind: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 61 | 0 | my( $from ) = $self->lines; | |||||||||
| 62 | 0 | ▶ | $from->rewind($condition) or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 63 | 0 | $self->from( 0 + $from ); | |||||||||
| 64 | 0 | return $self->from; | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | sub from_ff { | ||||||||||
| 68 | 0 | ▶ | my( $self, $condition ) = @_; | ||||||||
|
Subroutine
from_ff: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 69 | 0 | my( $from ) = $self->lines; | |||||||||
| 70 | 0 | ▶ | $from->ff($condition) or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 71 | 0 | ▶ | return if $from + 0 > $self->to; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | $self->from( 0 + $from ); | |||||||||
| 73 | 0 | return $self->from; | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | sub to_rewind { | ||||||||||
| 77 | 0 | ▶ | my( $self, $condition ) = @_; | ||||||||
|
Subroutine
to_rewind: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||
| 78 | 0 | my $to = ( $self->lines )[-1]; | |||||||||
| 79 | 0 | ▶ | $to->rewind($condition) or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 0 | ▶ | return if $to + 0 < $self->from; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 81 | 0 | $self->to( 0 + $to ); | |||||||||
| 82 | 0 | return $self->to; | |||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | sub to_ff { | ||||||||||
| 86 | 0 | ▶ | my( $self, $condition ) = @_; | ||||||||
|
Subroutine
to_ff: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 87 | 0 | my $to = ( $self->lines )[-1]; | |||||||||
| 88 | 0 | ▶ | $to->ff($condition) or return; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 89 | 0 | $self->to( 0 + $to ); | |||||||||
| 90 | 0 | return $self->to; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 1 | 1; | |||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | 1 | 1; | |||||||||
| 97 | |||||||||||
| 98 | __END__ | ||||||||||