1898184e3Ssthenpackage Pod::Perldoc::ToTk; 2898184e3Ssthenuse strict; 3898184e3Ssthenuse warnings; 4898184e3Ssthen 5898184e3Ssthenuse vars qw($VERSION); 6*9f11ffb7Safresh1$VERSION = '3.28'; 7898184e3Ssthen 8898184e3Ssthenuse parent qw(Pod::Perldoc::BaseTo); 9898184e3Ssthen 10898184e3Ssthensub is_pageable { 1 } 11898184e3Ssthensub write_with_binmode { 0 } 12898184e3Ssthensub output_extension { 'txt' } # doesn't matter 13898184e3Ssthensub if_zero_length { } # because it will be 0-length! 14898184e3Ssthensub new { return bless {}, ref($_[0]) || $_[0] } 15898184e3Ssthen 16898184e3Ssthen# TODO: document these and their meanings... 17898184e3Ssthensub tree { shift->_perldoc_elem('tree' , @_) } 18898184e3Ssthensub tk_opt { shift->_perldoc_elem('tk_opt' , @_) } 19898184e3Ssthensub forky { shift->_perldoc_elem('forky' , @_) } 20898184e3Ssthen 21898184e3Ssthenuse Pod::Perldoc (); 22898184e3Ssthenuse File::Spec::Functions qw(catfile); 23898184e3Ssthen 24898184e3SsthenBEGIN{ # Tk is not core, but this is 25898184e3Ssthen eval { require Tk } || 26898184e3Ssthen __PACKAGE__->die( <<"HERE" ); 27898184e3SsthenYou must have the Tk module to use Pod::Perldoc::ToTk. 28898184e3SsthenIf you have it installed, ensure it's in your Perl library 29898184e3Ssthenpath. 30898184e3SsthenHERE 31898184e3Ssthen 32898184e3Ssthen __PACKAGE__->die( 33898184e3Ssthen __PACKAGE__, 34898184e3Ssthen " doesn't work nice with Tk.pm version $Tk::VERSION" 35898184e3Ssthen ) if $Tk::VERSION eq '800.003'; 36898184e3Ssthen } 37898184e3Ssthen 38898184e3Ssthen 39898184e3SsthenBEGIN { eval { require Tk::FcyEntry; }; }; 40898184e3SsthenBEGIN{ # Tk::Pod is not core, but this is 41898184e3Ssthen eval { require Tk::Pod } || 42898184e3Ssthen __PACKAGE__->die( <<"HERE" ); 43898184e3SsthenYou must have the Tk::Pod module to use Pod::Perldoc::ToTk. 44898184e3SsthenIf you have it installed, ensure it's in your Perl library 45898184e3Ssthenpath. 46898184e3SsthenHERE 47898184e3Ssthen } 48898184e3Ssthen 49898184e3Ssthen# The following was adapted from "tkpod" in the Tk-Pod dist. 50898184e3Ssthen 51898184e3Ssthensub parse_from_file { 52898184e3Ssthen 53898184e3Ssthen my($self, $Input_File) = @_; 54898184e3Ssthen if($self->{'forky'}) { 55898184e3Ssthen return if fork; # i.e., parent process returns 56898184e3Ssthen } 57898184e3Ssthen 58898184e3Ssthen $Input_File =~ s{\\}{/}g 59898184e3Ssthen if $self->is_mswin32 or $self->is_dos 60898184e3Ssthen # and maybe OS/2 61898184e3Ssthen ; 62898184e3Ssthen 63898184e3Ssthen my($tk_opt, $tree); 64898184e3Ssthen $tree = $self->{'tree' }; 65898184e3Ssthen $tk_opt = $self->{'tk_opt'}; 66898184e3Ssthen 67898184e3Ssthen #require Tk::ErrorDialog; 68898184e3Ssthen 69898184e3Ssthen # Add 'Tk' subdirectories to search path so, e.g., 70898184e3Ssthen # 'Scrolled' will find doc in 'Tk/Scrolled' 71898184e3Ssthen 72898184e3Ssthen if( $tk_opt ) { 73898184e3Ssthen push @INC, grep -d $_, map catfile($_,'Tk'), @INC; 74898184e3Ssthen } 75898184e3Ssthen 76898184e3Ssthen my $mw = MainWindow->new(); 77898184e3Ssthen #eval 'use blib "/home/e/eserte/src/perl/Tk-App";require Tk::App::Debug'; 78898184e3Ssthen $mw->withdraw; 79898184e3Ssthen 80898184e3Ssthen # CDE use Font Settings if available 81898184e3Ssthen my $ufont = $mw->optionGet('userFont','UserFont'); # fixed width 82898184e3Ssthen my $sfont = $mw->optionGet('systemFont','SystemFont'); # proportional 83898184e3Ssthen if (defined($ufont) and defined($sfont)) { 84898184e3Ssthen foreach ($ufont, $sfont) { s/:$//; }; 85898184e3Ssthen $mw->optionAdd('*Font', $sfont); 86898184e3Ssthen $mw->optionAdd('*Entry.Font', $ufont); 87898184e3Ssthen $mw->optionAdd('*Text.Font', $ufont); 88898184e3Ssthen } 89898184e3Ssthen 90898184e3Ssthen $mw->optionAdd('*Menu.tearOff', $Tk::platform ne 'MSWin32' ? 1 : 0); 91898184e3Ssthen 92898184e3Ssthen $mw->Pod( 93898184e3Ssthen '-file' => $Input_File, 94898184e3Ssthen (($Tk::Pod::VERSION >= 4) ? ('-tree' => $tree) : ()) 95898184e3Ssthen )->focusNext; 96898184e3Ssthen 97898184e3Ssthen # xxx dirty but it works. A simple $mw->destroy if $mw->children 98898184e3Ssthen # does not work because Tk::ErrorDialogs could be created. 99898184e3Ssthen # (they are withdrawn after Ok instead of destory'ed I guess) 100898184e3Ssthen 101898184e3Ssthen if ($mw->children) { 102898184e3Ssthen $mw->repeat(1000, sub { 103898184e3Ssthen # ErrorDialog is withdrawn not deleted :-( 104898184e3Ssthen foreach ($mw->children) { 105898184e3Ssthen return if "$_" =~ /^Tk::Pod/ # ->isa('Tk::Pod') 106898184e3Ssthen } 107898184e3Ssthen $mw->destroy; 108898184e3Ssthen }); 109898184e3Ssthen } else { 110898184e3Ssthen $mw->destroy; 111898184e3Ssthen } 112898184e3Ssthen #$mw->WidgetDump; 113898184e3Ssthen MainLoop(); 114898184e3Ssthen 115898184e3Ssthen exit if $self->{'forky'}; # we were the child! so exit now! 116898184e3Ssthen return; 117898184e3Ssthen} 118898184e3Ssthen 119898184e3Ssthen1; 120898184e3Ssthen__END__ 121898184e3Ssthen 122898184e3Ssthen 123898184e3Ssthen=head1 NAME 124898184e3Ssthen 125898184e3SsthenPod::Perldoc::ToTk - let Perldoc use Tk::Pod to render Pod 126898184e3Ssthen 127898184e3Ssthen=head1 SYNOPSIS 128898184e3Ssthen 129898184e3Ssthen perldoc -o tk Some::Modulename & 130898184e3Ssthen 131898184e3Ssthen=head1 DESCRIPTION 132898184e3Ssthen 133898184e3SsthenThis is a "plug-in" class that allows Perldoc to use 134898184e3SsthenTk::Pod as a formatter class. 135898184e3Ssthen 136898184e3SsthenYou have to have installed Tk::Pod first, or this class won't load. 137898184e3Ssthen 138898184e3Ssthen=head1 SEE ALSO 139898184e3Ssthen 140898184e3SsthenL<Tk::Pod>, L<Pod::Perldoc> 141898184e3Ssthen 142898184e3Ssthen=head1 AUTHOR 143898184e3Ssthen 144898184e3SsthenCurrent maintainer: Mark Allen C<< <mallen@cpan.org> >> 145898184e3Ssthen 146898184e3SsthenPast contributions from: 147898184e3Ssthenbrian d foy C<< <bdfoy@cpan.org> >> 148898184e3SsthenAdriano R. Ferreira C<< <ferreira@cpan.org> >>; 149898184e3SsthenSean M. Burke C<< <sburke@cpan.org> >>; 150898184e3Ssthensignificant portions copied from 151898184e3SsthenF<tkpod> in the Tk::Pod dist, by Nick Ing-Simmons, Slaven Rezic, et al. 152898184e3Ssthen 153898184e3Ssthen=cut 154898184e3Ssthen 155