line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Term::GnuScreen::WindowArrayLike; |
2
|
1
|
|
|
1
|
|
859
|
use 5.008005; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
22
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
789
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.01"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
10
|
0
|
0
|
|
|
|
|
my $windows = qx{ screen -Q windows } or die "Your screen doesn't support -Q"; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
bless { |
13
|
|
|
|
|
|
|
windows => [split "\x20\x20", $windows], |
14
|
|
|
|
|
|
|
} => $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
|
sub windows { $_[0]->{windows} } |
18
|
|
|
|
|
|
|
sub start_number { |
19
|
0
|
|
|
0
|
0
|
|
my $self = $_[0]; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if ($_[1]) { |
|
|
0
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$self->{start_number} = $_[1]; |
23
|
|
|
|
|
|
|
}elsif ( !defined $self->{start_number} ) { |
24
|
0
|
|
|
|
|
|
$self->{start_number} = _current_window_number(); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $self->{start_number}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _current_window_number { |
31
|
0
|
|
|
0
|
|
|
my $win = qx{ screen -Q number }; |
32
|
0
|
0
|
|
|
|
|
$win =~ /^(\d+)/ or die 'current window number not found'; |
33
|
0
|
|
|
|
|
|
return $1; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub window_numbers_more_than_start { |
37
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
38
|
0
|
|
|
|
|
|
my @window_numbers_more_than_start; |
39
|
0
|
|
|
|
|
|
my @windows = @{$self->windows}; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
for my $i (0 .. @windows - 1) { |
42
|
0
|
|
|
|
|
|
my ($num) = $windows[$i] =~ /^(\d+)/; |
43
|
0
|
0
|
|
|
|
|
if ($self->start_number < $num) { |
44
|
0
|
|
|
|
|
|
push @window_numbers_more_than_start,$num; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
\@window_numbers_more_than_start; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub push { |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
0
|
|
|
|
|
$self->windows->[-1] =~ /^(\d+)/ or die 'last window number not found'; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $pushed_number = $1 + 1; |
55
|
0
|
|
|
|
|
|
qx{ screen -X screen $pushed_number }; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub insert { |
59
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $target_number = shift; |
61
|
0
|
|
|
|
|
|
my $start_number; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if (defined $target_number) { |
64
|
0
|
|
|
|
|
|
$start_number = $target_number - 1; |
65
|
0
|
|
|
|
|
|
$self->start_number($start_number); |
66
|
|
|
|
|
|
|
}else{ |
67
|
0
|
|
|
|
|
|
$target_number = ($self->start_number + 1); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
for my $win_number (reverse @{$self->window_numbers_more_than_start} ) { |
|
0
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
qx{ screen -X eval 'select $win_number' 'number +1' }; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
qx{ screen -X screen $target_number }; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub compact { |
78
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
79
|
0
|
|
|
|
|
|
my @windows = @{$self->windows}; |
|
0
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
for my $i (0 .. @windows - 1) { |
82
|
0
|
|
|
|
|
|
my ($number) = $windows[$i] =~ /^(\d+)/; |
83
|
0
|
|
|
|
|
|
qx{ screen -X eval 'select $number' 'number $i' }; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $start_number = $self->start_number; |
87
|
0
|
|
|
|
|
|
qx{ screen -X select $start_number }; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
__END__ |