App-Codit
view release on metacpan or search on metacpan
lib/App/Codit/Plugins/Exporter.pm view on Meta::CPAN
=item B<Export to PNG>
A form will pop up. All your changes except
for Output file are saved. You can set:
=over 4
=item B<Output file>
A default file is suggested. Change it if you like.
=item B<Background>
Background color of your image. By default the background
color of the Tk::CodeText widget is set.
=item B<Foreground>
Default color of the text in your image. By default the foreground
color of the Tk::CodeText widget is set.
=item B<Theme file>
Select the Tk::CodeText theme file (extension '.ctt') to use for syntax highlighting.
By default the theme file used in the Tk::CodeText widget is set. You can create your
custom theme file through Menu->Codit->Settings and select the highlighting panel.
=item B<Font>
Set the font used to draw text in your image. By default the font
of the Tk::CodeText widget is set.
=item B<Line numbers>
Tick this if you want line numbers displayed in the left column.
=item B<Tab size>
Set the size of tabs in characters.
=item B<Max width>
If set to 0 the image will grow in width whenever needed.
Otherwise it will wrap text when the max width (in pixels) has been reached.
=item B<Margins>
Set the top, left, bottom and right margins around your image.
=back
Beware! Exporting to PNG is painstakingly slow.
=back
=cut
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
return undef unless defined $self;
$self->{BACKGROUND} = undef;
$self->{IMAGE} = undef;
$self->{IHEIGHT} = 0;
$self->{IWIDTH} = 0;
$self->{MAXWIDTH} = 0;
$self->{XPOS} = 0;
$self->{TABSTRING} = '';
$self->{YPOS} = 0;
$self->cmdConfig(
'export_html' => ['export2html', $self],
'export_png' => ['export2png', $self],
);
return $self;
}
sub background {
my $self = shift;
$self->{BACKGROUND} = shift if @_;
return $self->{BACKGROUND}
}
sub export2html {
my $self = shift;
my $mdi = $self->mdi;
#setting initial values
my %iv = ();
my $name = $mdi->docSelected;
return unless defined $name;
$iv{'outfile'} = "$name.html";
$iv{'theme'} = 'White';
$iv{'scrolled'} = '';
$iv{'lineoffset'} = 1;
$iv{'foldmarkers'} = '';
#popping the form
my %options = $self->popForm(
-acceptempty => 1,
-initialvalues => \%iv,
-oktext => 'Export',
-structure => [
'*section' => 'Output',
outfile => ['file', 'File'],
'*end',
'*section' => 'Theme',
theme => ['radio', 'Color', -values => [qw/White LightGray Gray DarkGray Black/]],
'*end',
'*section' => 'Features',
scrolled => ['boolean', 'Scrolled'],
foldmarkers => ['boolean', 'Fold markers'],
'*column',
lineoffset => ['boolean', 'Line numbers'],
'*end',
],
-title => 'Export to HTML',
);
return unless %options;
lib/App/Codit/Plugins/Exporter.pm view on Meta::CPAN
$self->image->polygon(
points => [[$x1, $y1], [$x2, $y1], [$x2, $y2], [$x1, $y2]],
color => $bg,
);
}
$self->image->string(
x => $self->xpos,
y => $self->ypos,
font => $ifont,
string => $string,
color => $fg,
aa => 1,
);
$self->xpos($self->xpos + $partsize);
}
sub iwidth {
my $self = shift;
$self->{IWIDTH} = shift if @_;
return $self->{IWIDTH}
}
sub linecolumn {
my $self = shift;
$self->{LINECOLUMN} = shift if @_;
return $self->{LINECOLUMN}
}
sub linenumbers {
my $self = shift;
$self->{LINENUMBERS} = shift if @_;
return $self->{LINENUMBERS}
}
sub maxwidth {
my $self = shift;
$self->{MAXWIDTH} = shift if @_;
return $self->{MAXWIDTH}
}
sub MenuItems {
my $self = shift;
return (
[ 'menu_normal', 'File::Close', 'Export to ~HTML', 'export_html', 'text-html'],
[ 'menu_normal', 'File::Close', 'Export to P~NG', 'export_png', 'image-x-generic'],
[ 'menu_separator', 'File::Close', 'F3'],
)
}
sub tabstring {
my $self = shift;
$self->{TABSTRING} = shift if @_;
return $self->{TABSTRING}
}
sub Unload {
my $self = shift;
$self->cmdRemove('export_html');
$self->cmdRemove('export_png');
return $self->SUPER::Unload;
}
sub xpos {
my $self = shift;
$self->{XPOS} = shift if @_;
return $self->{XPOS}
}
sub ypos {
my $self = shift;
$self->{YPOS} = shift if @_;
return $self->{YPOS}
}
=head1 LICENSE
Same as Perl.
=head1 AUTHOR
Hans Jeuken (hanje at cpan dot org)
=head1 TODO
=over 4
=back
=head1 BUGS AND CAVEATS
If you find any bugs, please report them here L<https://github.com/haje61/App-Codit/issues>.
=head1 SEE ALSO
=over 4
=back
=cut
1;
( run in 0.772 second using v1.01-cache-2.11-cpan-99c4e6809bf )