VTide/Command/NewWindow.pm

filter: Statementstmt 46.1% 30 / 65 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 66.6% 8 / 12 Podpod 75.0% 3 / 4 totaltotal 35.6% 41 / 115 CC 15 SCAR 36.3
CC
15
Cov
32%
run
90.0
get_panes
20.0
auto_complete
20.0
CRAP 37.7
« VTide.pm ↑ Summary VTide/Command.pm »
1 package App::VTide::Command::NewWindow;
2  
3 # Created on: 2016-03-22 15:42:06
4 # Create by: Ivan Wills
5 # $Id$
6 # $Revision$, $HeadURL$, $Date$
7 # $Revision$, $Source$, $Date$
8  
9 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use English qw/ -no_match_vars /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use YAML::Syck;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use File::chdir;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Data::Dumper qw/Dumper/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 extends 'App::VTide::Command::Run';
19  
20 1 our $VERSION = version->new('1.0.6');
21 1 our $NAME = 'new-window';
22 1 our $OPTIONS = [ 'force|f!', 'number|n=s', 'test|t!', 'verbose|v+', ];
23 1 our $LOCAL = 1;
24 0 ▶sub details_sub { return ( $NAME, $OPTIONS, $LOCAL ) }
Subroutine details_sub: not called CC=1 SCAR=6.9
Pod documented
25  
26 0 ▶sub run {
Subroutine run: not called CC=9 SCAR=45.0
Pod documented
27 0 my ($self) = @_;
28  
29 0 my $terminals = $self->config->get->{terminals};
30 0 my $number = $self->defaults->{number};
31 0 my $term = $terminals->{$number};
32  
33 # list panes in current session
34 # $ tmux list-panes -s
35 # 1.0: [180x96] [history 3781/4096, 2233336 bytes] %213 (active)
36 # 1.1: [180x24] [history 2856/4096, 2107575 bytes] %214
37 # 1.2: [180x71] [history 0/4096, 4236 bytes] %216
38 # 2.0: [361x96] [history 291/4096, 366910 bytes] %217 (active)
39 # 3.0: [361x96] [history 579/4096, 903096 bytes] %218 (active)
40 # 4.0: [361x96] [history 1467/4096, 2054430 bytes] %219 (active)
41 # 5.0: [361x96] [history 0/4096, 6591 bytes] %220 (active)
42 # 6.0: [361x96] [history 0/4096, 6591 bytes] %221 (active)
43 # 7.0: [361x96] [history 0/4096, 6591 bytes] %222 (active)
44 # 8.0: [361x96] [history 0/4096, 6591 bytes] %223 (active)
45 # 9.0: [361x96] [history 0/4096, 6591 bytes] %224 (active)
46 # 10.0: [361x96] [history 0/4096, 6591 bytes] %225 (active)
47  
48 0 my $session = $self->get_panes(1);
49  
50 0 ▶ if ( $session->{$number} && !$self->defaults->{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($session->{$number} and not $self->defaults->{"force"}) 0 0 0
Condition0%0/3
$session->{$number} and not $self->defaults->{"force"}
!ll&&!rl&&r
000
MC/DC0%0/2
$session->{$number} and not $self->defaults->{"force"}
$session->{$number} not $self->defaults->{"force"}
Truth table0%0/3
A and not(B)
A= $session->{$number}B= not $self->defaults->{"force"}
ABresult
0X0
100
111
51 0 system 'tmux', 'select-window', '-t', $number;
52 0 return;
53 }
54  
55 0 ▶ if ( !$session->{ $number - 1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($$session{$number - 1}) 0 0 0
56 0 warn "Sessions will be out of order!\n";
57 0 ▶ return if !$self->defaults->{force};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->defaults->{"force"} 0 0 0
58 }
59  
60 0 ▶ my @verbose = $self->defaults->{verbose} ? ('--verbose') : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->defaults->{'verbose'} ? : 0 0 0
61 0 ▶ my @test = $self->defaults->{test} ? ('--test') : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->defaults->{'test'} ? : 0 0 0
62 0 $ENV{VTIDE_TERM} = $number;
63 0 ▶ if ( $term->{dir} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->{"dir"}) 0 0 0
64 0 $CWD = $term->{dir};
65 }
66 0 system 'tmux', 'new-window', "vtide run @test @verbose $number && sleep 15";
67 0 ▶ if ( $term->{split} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($term->{"split"}) 0 0 0
68 0 system 'vtide', 'split', @test, @verbose, $term->{split};
69 }
70  
71 #my @panes = keys %{ $self->get_panes()->{''} };
72 #for my $pane (@panes) {
73 # next if $pane == 0;
74  
75 # my $letter = 'a' + $pane;
76 # warn "$number$letter";
77 # next if !$terminals->{"$number$letter"};
78 #}
79  
80 0 return;
81 }
82  
83 0 ▶sub get_panes {
Subroutine get_panes: not called CC=4 SCAR=30.0
Pod undocumented
84 0 my ( $self, $all ) = @_;
85  
86 0 my %session;
87 0 ▶ my $session = $all ? ' -s' : '';
Branch: 1 branch
BranchTrueFalseTotal
$all ? : 0 0 0
88 0 for my $pane (`tmux list-panes $session`) {
89 0 my ( $window, $pane ) = $pane =~ /^(?:(\d+).)?(\d+)/;
90 0 ▶ $session{ $window || '' }{$pane}++;
Condition0%0/2
$window || ''
l!l
00
MC/DC0%0/1
$window || ''
$window
Truth table0%0/2
A
A= $window
Aresult
11
00
91 }
92  
93 0 return \%session;
94 }
95  
96 0 ▶sub auto_complete {
Subroutine auto_complete: not called CC=4 SCAR=30.0
Pod documented
97 0 my ( $self, $auto ) = @_;
98  
99 0 ▶ my $env = $self->options->files->[-1] // '';
Condition0%0/2
$self->options->files->[-1] // ""
l!l
00
MC/DC0%0/1
$self->options->files->[-1] // ""
$self->options->files->[-1]
Truth table0%0/2
A
A= $self->options->files->[-1]
Aresult
11
00
100 0 my @files = sort keys %{ $self->config->get->{editor}{files} };
101  
102 # TODO complete terminal numbers
103  
104 print join ' ',
105 0 ▶ grep { $env ne 'vtide' && $env ne 'edit' ? /^$env/xms : 1 } @files;
Branch: 1 branch
BranchTrueFalseTotal
$env ne 'vtide' && $env ne 'edit' ? : 0 0 0
Condition0%0/3
$env ne "vtide" and $env ne "edit"
!ll&&!rl&&r
000
MC/DC0%0/2
$env ne "vtide" and $env ne "edit"
$env ne "vtide" $env ne "edit"
Truth table0%0/3
A and B
A= $env ne "vtide"B= $env ne "edit"
ABresult
0X0
100
111
106  
107 0 return;
108 }
109  
110 1 1;
111  
112 __END__
« VTide.pm ↑ Summary VTide/Command.pm »