line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::SpellChecker::GUI; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21047
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
1037
|
use ZConf::GUI; |
|
1
|
|
|
|
|
162182
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
12
|
use ZConf; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
442
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Text::SpellChecker::GUI - Implements a user interface to Text::SpellChecker |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.0.2 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.0.2'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Text::SpellChecker::GUI; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $sg = Text::SpellChecker::GUI->new(); |
25
|
|
|
|
|
|
|
... |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 METHODS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This initilizes the object. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head3 args hash |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head4 zconf |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
This is the ZConf object to use. If it is not specified the one in the |
38
|
|
|
|
|
|
|
object for zcrunner will be used. If neither zconf or zcrunner is specified, |
39
|
|
|
|
|
|
|
a new one is created. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head4 zcgui |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This is the ZConf::GUI to use. If one is not specified, |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub new { |
49
|
0
|
|
|
0
|
1
|
|
my %args; |
50
|
0
|
0
|
|
|
|
|
if(defined($_[1])){ |
51
|
0
|
|
|
|
|
|
%args= %{$_[1]}; |
|
0
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $self={error=>undef, errorString=>''}; |
55
|
0
|
|
|
|
|
|
bless $self; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#initilize the ZConf::GUI object if needed |
58
|
0
|
0
|
|
|
|
|
if (!defined($args{zcgui})) { |
59
|
0
|
0
|
|
|
|
|
if (!defined($args{zconf})) { |
60
|
0
|
|
|
|
|
|
$self->{zg}=ZConf::GUI->new(); |
61
|
|
|
|
|
|
|
}else { |
62
|
0
|
|
|
|
|
|
$self->{zg}=ZConf::GUI->new({zconf=>$args{zconf}}); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if ($self->{zg}->{error}) { |
66
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to initilize the ZConf::GUI object. error="'. |
67
|
|
|
|
|
|
|
$self->{zg}->{error}.'" errorString="' |
68
|
|
|
|
|
|
|
.$self->{zg}->{errorString}.'"'; |
69
|
0
|
|
|
|
|
|
$self->{error}=1; |
70
|
0
|
|
|
|
|
|
warn('Text-SpellChecker-GUI new:1: '.$self->{errorString}); |
71
|
0
|
|
|
|
|
|
return $self; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
}else { |
74
|
0
|
|
|
|
|
|
$self->{zg}=$args{zcgui}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#initilize the ZConf object if needed |
78
|
0
|
0
|
|
|
|
|
if (!defined($args{zconf})) { |
79
|
0
|
|
|
|
|
|
$self->{zconf}=$args{zconf}; |
80
|
|
|
|
|
|
|
}else { |
81
|
0
|
|
|
|
|
|
$self->{zconf}=$self->{zg}->{zconf}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#as the GUI stuff is right below this module, use the module above this one |
85
|
0
|
|
|
|
|
|
$self->{useX}=$self->{zg}->useX('Text::SpellChecker'); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my @preferred=$self->{zg}->which('Text::SpellChecker'); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $toeval='use Text::SpellChecker::GUI::'.$preferred[0].';'."\n". |
90
|
|
|
|
|
|
|
'$self->{be}=Text::SpellChecker::GUI::'.$preferred[0]. |
91
|
|
|
|
|
|
|
'->new({zconf=>$self->{zconf}, useX=>$self->{useX}, '. |
92
|
|
|
|
|
|
|
'zcgui=>$self->{zg} }); return 1'; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $er=eval($toeval); |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
return $self; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 check |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This checks the specified the specified text for spelling errors. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Only one option is taken and that is the text to be checked. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
The returned value is a hash. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head3 returned hash |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head4 text |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This is the the resulting text. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head4 cancel |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
If this is defined and true, then the user canceled the check and any changes. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
my %returned=$sg->check($text); |
118
|
|
|
|
|
|
|
if($sg->{error}){ |
119
|
|
|
|
|
|
|
print "Error!\n"; |
120
|
|
|
|
|
|
|
}else{ |
121
|
|
|
|
|
|
|
if($returned{cancel}){ |
122
|
|
|
|
|
|
|
print "The check was canceled."; |
123
|
|
|
|
|
|
|
}else{ |
124
|
|
|
|
|
|
|
$text=$returned{text}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub check{ |
131
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
132
|
0
|
|
|
|
|
|
my $text=$_[1]; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$self->errorblank; |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my %toreturn; |
137
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
if (!defined($self->{be})) { |
139
|
0
|
|
|
|
|
|
$self->{errorString}='Backend is not initilized'; |
140
|
0
|
|
|
|
|
|
$self->{error}=2; |
141
|
0
|
|
|
|
|
|
warn('Text-SpellChecker-GUI check:2: '.$self->{errorString}); |
142
|
0
|
|
|
|
|
|
return undef; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
0
|
|
|
|
|
|
%toreturn=$self->{be}->check($text); |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return %toreturn; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 errorblank |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
It does the following. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
$self->{error}=undef; |
157
|
|
|
|
|
|
|
$self->{errorString}=""; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
#blanks the error flags |
162
|
|
|
|
|
|
|
sub errorblank{ |
163
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$self->{error}=undef; |
166
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
return 1; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 ERROR CODES |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 1 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Failed to initiate the object. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 2 |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Backend is not initilized. |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 AUTHOR |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 BUGS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
188
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
189
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 SUPPORT |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
perldoc Text::SpellChecker::GUI |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
You can also look for information at: |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=over 4 |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
L |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
L |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * CPAN Ratings |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
L |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item * Search CPAN |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
L |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
232
|
|
|
|
|
|
|
under the same terms as Perl itself. |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=cut |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
1; # End of Text::SpellChecker::GUI |