| 1 | package Vim::X::Buffer; | ||||||||||
| 2 | BEGIN { | ||||||||||
| 3 | 5 | ▶ | $Vim::X::Buffer::AUTHORITY = 'cpan:YANICK'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | } | ||||||||||
| 5 | # ABSTRACT: A buffer in Vim | ||||||||||
| 6 | 5 | $Vim::X::Buffer::VERSION = '1.1.0'; | |||||||||
| 7 | 5 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 5 | has "index" => ( | |||||||||
| 10 | is => 'ro', | ||||||||||
| 11 | required => 1, | ||||||||||
| 12 | ); | ||||||||||
| 13 | |||||||||||
| 14 | 5 | has "_buffer" => ( | |||||||||
| 15 | is => 'ro', | ||||||||||
| 16 | required => 1, | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | |||||||||||
| 20 | sub lines_content { | ||||||||||
| 21 | 0 | ▶ | my( $self, @lines ) = @_; | ||||||||
|
Subroutine
lines_content: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 22 | 0 | @lines = map { $self->_buffer->Get($_) } @lines; | |||||||||
| 23 | 0 | ▶ | return wantarray ? @lines : join "\n", @lines; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | } | ||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | sub append { | ||||||||||
| 28 | 0 | ▶ | my( $self, $index, @lines ) = @_; | ||||||||
|
Subroutine
append: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 29 | 0 | $self->_buffer->Append( $index, map { split "\n" } @lines ); | |||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | sub delete { | ||||||||||
| 34 | 0 | ▶ | my ( $self, @lines ) = @_; | ||||||||
|
Subroutine
delete: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 35 | 0 | my %seen; | |||||||||
| 36 | 0 | @lines = sort { $a <=> $b } grep { !$seen{$_}++ } map { 0+$_ } @lines; | |||||||||
| 37 | |||||||||||
| 38 | 0 | for my $r ( reverse @lines ) { | |||||||||
| 39 | 0 | $self->_buffer->Delete( $r ); | |||||||||
| 40 | } | ||||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | sub line { | ||||||||||
| 45 | 0 | ▶ | my ( $self, $nbr ) = @_; | ||||||||
|
Subroutine
line: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 46 | |||||||||||
| 47 | 0 | return Vim::X::Line->new( buffer => $self, index => $nbr ); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | sub set_line { | ||||||||||
| 52 | 0 | ▶ | my( $self, $i, @content ) = @_; | ||||||||
|
Subroutine
set_line: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 53 | 0 | $self->_buffer->Set($i => shift @content); | |||||||||
| 54 | 0 | ▶ | $self->append( $i => @content ) if @content; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | sub lines { | ||||||||||
| 59 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
lines: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 60 | 0 | my @lines = @_; | |||||||||
| 61 | 0 | ▶ | unless(@lines) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | @lines = 1..$self->size; | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 0 | @lines = map { Vim::X::Line->new( buffer => $self, index => $_ ) } @lines; | |||||||||
| 66 | 0 | return @lines; | |||||||||
| 67 | } | ||||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | sub size { | ||||||||||
| 71 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
size: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 72 | 0 | $self->_buffer->Count; | |||||||||
| 73 | } | ||||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | sub range { | ||||||||||
| 77 | 0 | ▶ | require Vim::X::Range; | ||||||||
|
Subroutine
range: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 78 | 0 | return Vim::X::Range->new( | |||||||||
| 79 | _buffer => $_[0], | ||||||||||
| 80 | from => $_[1], | ||||||||||
| 81 | to => $_[2] | ||||||||||
| 82 | ); | ||||||||||
| 83 | } | ||||||||||
| 84 | |||||||||||
| 85 | 5 | 1; | |||||||||
| 86 | |||||||||||
| 87 | __END__ | ||||||||||