App-Codit
view release on metacpan or search on metacpan
lib/App/Codit/Plugins/Exporter.pm view on Meta::CPAN
to HTML or PNG. You will find two entries for this in the File menu:
=over 4
=item B<Export to HTML>
Exporting to html is done using the standard facilities available in
<LSyntax::Kamelon>. We are looking to extend that in future versions.
A form will pop up where you can set:
=over 4
=item B<Output file>
A default file is suggested. Change it if you like.
=item B<Theme>
Pick one of the available themes.
=item B<Line numbers>
Tick this if you want line numbers displayed in the left column.
=item B<Fold markers>
Tick this if you want fold markers displayed in the left column.
=item B<Scrolled pane>
Tick this if you want the content to appear in a scrollable pane.
=back
=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;
lib/App/Codit/Plugins/Exporter.pm view on Meta::CPAN
sub iprints {
my ($self, $string, $font, $fg, $bg) = @_;
my $ifont = $self->extGet('Art')->imagerFont($font);
my $partsize = $self->fontMeasure($font, $string);
my $linesize = $self->xpos + $partsize + $self->imargin;
if ($linesize > $self->iwidth) { #need to enlarge in x direction?
my $new = $self->inew($linesize, $self->iheight);
$new->paste(src => $self->image);
$self->image($new);
$self->iwidth($linesize);
}
if (defined $bg) { #paint background
my $linespace = $self->fontMetrics($font, '-linespace');
my $descent = $self->fontMetrics($font, '-descent');
my $x1 = $self->xpos;
my $x2 = $x1 + $partsize;
my $y2 = $self->ypos + $descent;
my $y1 = $y2 - $linespace;
$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
( run in 1.093 second using v1.01-cache-2.11-cpan-d7f47b0818f )