line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
Term::ReadLine::Simple::Linux; |
3
|
|
|
|
|
|
|
|
4
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
111
|
|
5
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
69
|
|
6
|
4
|
|
|
4
|
|
60
|
use 5.008003; |
|
4
|
|
|
|
|
13
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.307'; |
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
3472
|
use Term::ReadKey qw( GetTerminalSize ReadKey ReadMode ); |
|
4
|
|
|
|
|
18708
|
|
|
4
|
|
|
|
|
310
|
|
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
28
|
use Term::ReadLine::Simple::Constants qw( :linux ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
3579
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
3
|
|
|
3
|
0
|
13
|
return bless {}, $_[0]; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub __set_mode { |
21
|
|
|
|
|
|
|
#my ( $self ) = @_; |
22
|
0
|
|
|
0
|
|
0
|
ReadMode( 'cbreak' ); |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub __reset_mode { |
27
|
|
|
|
|
|
|
#my ( $self ) = @_; |
28
|
3
|
|
|
3
|
|
15
|
ReadMode( 'restore' ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub __term_buff_size { |
33
|
|
|
|
|
|
|
#my ( $self ) = @_; |
34
|
0
|
|
|
0
|
|
|
my ( $term_width, $term_height ) = GetTerminalSize(); |
35
|
0
|
|
|
|
|
|
return $term_width, $term_height; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub __get_key { |
40
|
|
|
|
|
|
|
#my ( $self ) = @_; |
41
|
0
|
|
|
0
|
|
|
my $c1 = ReadKey( 0 ); |
42
|
0
|
0
|
|
|
|
|
return if ! defined $c1; |
43
|
0
|
0
|
|
|
|
|
if ( $c1 eq "\e" ) { |
44
|
0
|
|
|
|
|
|
my $c2 = ReadKey( 0.10 ); |
45
|
0
|
0
|
|
|
|
|
if ( ! defined $c2 ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return NEXT_get_key; # KEY_ESC |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
elsif ( $c2 eq 'O' ) { |
49
|
0
|
|
|
|
|
|
my $c3 = ReadKey( 0 ); |
50
|
0
|
0
|
|
|
|
|
if ( $c3 eq 'A' ) { return VK_UP; } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'B' ) { return VK_DOWN; } |
52
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'C' ) { return VK_RIGHT; } |
53
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'D' ) { return VK_LEFT; } |
54
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'F' ) { return VK_END; } |
55
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'H' ) { return VK_HOME; } |
56
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'Z' ) { return KEY_BTAB; } |
57
|
|
|
|
|
|
|
else { |
58
|
0
|
|
|
|
|
|
return NEXT_get_key; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
elsif ( $c2 eq '[' ) { |
62
|
0
|
|
|
|
|
|
my $c3 = ReadKey( 0 ); |
63
|
0
|
0
|
|
|
|
|
if ( $c3 eq 'A' ) { return VK_UP; } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'B' ) { return VK_DOWN; } |
65
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'C' ) { return VK_RIGHT; } |
66
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'D' ) { return VK_LEFT; } |
67
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'F' ) { return VK_END; } |
68
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'H' ) { return VK_HOME; } |
69
|
0
|
|
|
|
|
|
elsif ( $c3 eq 'Z' ) { return KEY_BTAB; } |
70
|
|
|
|
|
|
|
elsif ( $c3 =~ /^[0-9]$/ ) { |
71
|
0
|
|
|
|
|
|
my $c4 = ReadKey( 0 ); |
72
|
0
|
0
|
|
|
|
|
if ( $c4 eq '~' ) { |
73
|
0
|
0
|
|
|
|
|
if ( $c3 eq '3' ) { return VK_DELETE; } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
elsif ( $c3 eq '5' ) { return VK_PAGE_UP; } |
75
|
0
|
|
|
|
|
|
elsif ( $c3 eq '6' ) { return VK_PAGE_DOWN; } |
76
|
|
|
|
|
|
|
else { |
77
|
0
|
|
|
|
|
|
return NEXT_get_key; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
|
return NEXT_get_key; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
0
|
|
|
|
|
|
return NEXT_get_key; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else { |
89
|
0
|
|
|
|
|
|
return NEXT_get_key; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else { |
93
|
0
|
|
|
|
|
|
return ord $c1; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub __up { |
99
|
0
|
0
|
|
0
|
|
|
return if ! $_[1]; |
100
|
0
|
|
|
|
|
|
print "\e[${_[1]}A"; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub __down { |
104
|
0
|
0
|
|
0
|
|
|
return if ! $_[1]; |
105
|
0
|
|
|
|
|
|
print "\e[${_[1]}B"; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub __left { |
109
|
0
|
0
|
|
0
|
|
|
return if ! $_[1]; |
110
|
0
|
|
|
|
|
|
print "\e[${_[1]}D"; } |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub __right { |
113
|
0
|
0
|
|
0
|
|
|
return if ! $_[1]; |
114
|
0
|
|
|
|
|
|
print "\e[${_[1]}C"; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
0
|
|
|
sub __reverse { print "\e[7m"; } |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
0
|
|
|
sub __reset { print "\e[0m"; } |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
0
|
|
|
sub __mark_current { print "\e[4m"; } # "\e[1m\e[4m"; |
122
|
|
|
|
|
|
|
|
123
|
0
|
|
|
0
|
|
|
sub __clear_screen { print "\e[H\e[J"; } |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
0
|
|
|
sub __clear_lines_to_end_of_screen { print "\r\e[0J"; } |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
0
|
|
|
sub __clear_line { print "\r\e[K"; } |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
0
|
|
|
sub __beep { |
130
|
|
|
|
|
|
|
# print "\a"; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |