| 1 | package Neovim::Ext::Buffer; | ||||||||||||
| 2 | 55 | $Neovim::Ext::Buffer::VERSION = '0.01'; | |||||||||||
| 3 | 55 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 55 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 55 | ▶ | use Tie::Array; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 55 | ▶ | use Neovim::Ext::Remote; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 55 | our @ISA = (qw/Neovim::Ext::Remote Tie::Array/); | |||||||||||
| 9 | |||||||||||||
| 10 | |||||||||||||
| 11 | sub TIEARRAY | ||||||||||||
| 12 | { | ||||||||||||
| 13 | 0 | ▶ | my ($this, $session, $code_data) = @_; | ||||||||||
|
Subroutine
TIEARRAY: not called CC=1 SCAR=6.9
| |||||||||||||
| 14 | |||||||||||||
| 15 | 0 | return $this->SUPER::new ($session, 'nvim_buf_', $code_data); | |||||||||||
| 16 | } | ||||||||||||
| 17 | |||||||||||||
| 18 | |||||||||||||
| 19 | sub new | ||||||||||||
| 20 | { | ||||||||||||
| 21 | 0 | ▶ | my $this = shift; | ||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 22 | |||||||||||||
| 23 | 0 | tie my @array, 'Neovim::Ext::Buffer', @_; | |||||||||||
| 24 | |||||||||||||
| 25 | 0 | return \@array; | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | |||||||||||||
| 29 | |||||||||||||
| 30 | sub FETCHSIZE | ||||||||||||
| 31 | { | ||||||||||||
| 32 | 0 | ▶ | my ($this) = @_; | ||||||||||
|
Subroutine
FETCHSIZE: not called CC=1 SCAR=6.9
| |||||||||||||
| 33 | 0 | return $this->request ('nvim_buf_line_count'); | |||||||||||
| 34 | } | ||||||||||||
| 35 | |||||||||||||
| 36 | |||||||||||||
| 37 | |||||||||||||
| 38 | sub FETCH | ||||||||||||
| 39 | { | ||||||||||||
| 40 | 0 | ▶ | my ($this, $index) = @_; | ||||||||||
|
Subroutine
FETCH: not called CC=2 SCAR=17.9
| |||||||||||||
| 41 | 0 | my $result = $this->request ('nvim_buf_get_lines', $index, $index+1, 0); | |||||||||||
| 42 | 0 | ▶ | return shift @$result // ''; | ||||||||||
|
Condition0%0/2
shift @$result // ""
MC/DC0%0/1
shift @$result // ""
shift @$result
Truth table0%0/2
A
A= shift @$result
| |||||||||||||
| 43 | } | ||||||||||||
| 44 | |||||||||||||
| 45 | |||||||||||||
| 46 | |||||||||||||
| 47 | sub STORE | ||||||||||||
| 48 | { | ||||||||||||
| 49 | 0 | ▶ | my ($this, $index, $value) = @_; | ||||||||||
|
Subroutine
STORE: not called CC=2 SCAR=17.9
| |||||||||||||
| 50 | 0 | ▶ | $this->request ('nvim_buf_set_lines', $index, $index+1, 0, defined ($value) ? [$value] : []); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 51 | } | ||||||||||||
| 52 | |||||||||||||
| 53 | |||||||||||||
| 54 | |||||||||||||
| 55 | sub STORESIZE | ||||||||||||
| 56 | { | ||||||||||||
| 57 | 0 | ▶ | my ($this, $count) = @_; | ||||||||||
|
Subroutine
STORESIZE: not called CC=2 SCAR=17.9
| |||||||||||||
| 58 | |||||||||||||
| 59 | 0 | AGAIN: | |||||||||||
| 60 | my $size = $this->FETCHSIZE(); | ||||||||||||
| 61 | 0 | ▶ | if ($count < $size) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | { | ||||||||||||
| 63 | 0 | $this->STORE ($size-1, undef); | |||||||||||
| 64 | 0 | goto AGAIN; | |||||||||||
| 65 | } | ||||||||||||
| 66 | } | ||||||||||||
| 67 | |||||||||||||
| 68 | |||||||||||||
| 69 | |||||||||||||
| 70 | sub DELETE | ||||||||||||
| 71 | { | ||||||||||||
| 72 | 0 | ▶ | my ($this, $index) = @_; | ||||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||||
| 73 | 0 | $this->STORE ($index, undef); | |||||||||||
| 74 | } | ||||||||||||
| 75 | |||||||||||||
| 76 | |||||||||||||
| 77 | |||||||||||||
| 78 | sub CLEAR | ||||||||||||
| 79 | { | ||||||||||||
| 80 | 0 | ▶ | my ($this) = @_; | ||||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||||
| 81 | |||||||||||||
| 82 | 0 | my $size = $this->FETCHSIZE(); | |||||||||||
| 83 | 0 | $this->request ('nvim_buf_set_lines', 0, $size, 0, []); | |||||||||||
| 84 | } | ||||||||||||
| 85 | |||||||||||||
| 86 | |||||||||||||
| 87 | |||||||||||||
| 88 | sub number | ||||||||||||
| 89 | { | ||||||||||||
| 90 | 0 | ▶ | my $this = shift; | ||||||||||
|
Subroutine
number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 91 | 0 | return $this->handle; | |||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | |||||||||||||
| 95 | |||||||||||||
| 96 | sub name | ||||||||||||
| 97 | { | ||||||||||||
| 98 | 0 | ▶ | my $this = shift; | ||||||||||
|
Subroutine
name: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 99 | |||||||||||||
| 100 | 0 | ▶ | $this->request ('nvim_buf_set_name', shift) if (@_); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 101 | 0 | ▶ | $this->request ('nvim_buf_get_name') // ''; | ||||||||||
|
Condition0%0/2
$this->request("nvim_buf_get_name") // ""
MC/DC0%0/1
$this->request("nvim_buf_get_name") // ""
$this->request("nvim_buf_get_name")
Truth table0%0/2
A
A= $this->request("nvim_buf_get_name")
| |||||||||||||
| 102 | } | ||||||||||||
| 103 | |||||||||||||
| 104 | |||||||||||||
| 105 | |||||||||||||
| 106 | sub valid | ||||||||||||
| 107 | { | ||||||||||||
| 108 | 0 | ▶ | my $this = shift; | ||||||||||
|
Subroutine
valid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 109 | 0 | $this->request ('nvim_buf_is_valid'); | |||||||||||
| 110 | } | ||||||||||||
| 111 | |||||||||||||
| 112 | |||||||||||||
| 113 | |||||||||||||
| 114 | sub mark | ||||||||||||
| 115 | { | ||||||||||||
| 116 | 0 | ▶ | my ($this, $name) = @_; | ||||||||||
|
Subroutine
mark: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 117 | 0 | $this->request ('nvim_buf_get_mark', $name); | |||||||||||
| 118 | } | ||||||||||||
| 119 | |||||||||||||
| 120 | |||||||||||||
| 121 | =head1 NAME | ||||||||||||
| 122 | |||||||||||||
| 123 | Neovim::Ext::Buffer - Neovim Buffer class | ||||||||||||
| 124 | |||||||||||||
| 125 | =head1 VERSION | ||||||||||||
| 126 | |||||||||||||
| 127 | version 0.01 | ||||||||||||
| 128 | |||||||||||||
| 129 | =head1 SYNPOSIS | ||||||||||||
| 130 | |||||||||||||
| 131 | use Neovim::Ext; | ||||||||||||
| 132 | |||||||||||||
| 133 | my $buffer = $nvim->current->buffer; | ||||||||||||
| 134 | |||||||||||||
| 135 | push @$buffer, 'line'; # add a new line to the buffer | ||||||||||||
| 136 | @$buffer = (); # delete all buffer lines | ||||||||||||
| 137 | |||||||||||||
| 138 | # check if the buffer is valid | ||||||||||||
| 139 | if (tied (@{$buffer})->valid) | ||||||||||||
| 140 | { | ||||||||||||
| 141 | ... | ||||||||||||
| 142 | } | ||||||||||||
| 143 | |||||||||||||
| 144 | =head1 DESCRIPTION | ||||||||||||
| 145 | |||||||||||||
| 146 | A remote Nvim buffer. A C<Neovim::Ext::Buffer> instance is a tied array reference. | ||||||||||||
| 147 | |||||||||||||
| 148 | =head1 METHODS | ||||||||||||
| 149 | |||||||||||||
| 150 | =head2 mark( $name ) | ||||||||||||
| 151 | |||||||||||||
| 152 | Return the row and column for a named mark. | ||||||||||||
| 153 | |||||||||||||
| 154 | =head2 name( [$name] ) | ||||||||||||
| 155 | |||||||||||||
| 156 | Get or set buffer name. | ||||||||||||
| 157 | |||||||||||||
| 158 | =head2 number( ) | ||||||||||||
| 159 | |||||||||||||
| 160 | Get the buffer number. | ||||||||||||
| 161 | |||||||||||||
| 162 | =head2 valid( ) | ||||||||||||
| 163 | |||||||||||||
| 164 | Check if the buffer still exists. | ||||||||||||
| 165 | |||||||||||||
| 166 | =cut | ||||||||||||
| 167 | |||||||||||||
| 168 | 55 | 1; | |||||||||||