NAME

Tk::Stdio - capture standard output and error, accept standard input, display in separate window

SYNOPSIS

    use Tk::Stdio;

    $mw = MainWindow->new->InitStdio;
    print "something\n";    ## goes to standard IO window
    print STDERR 'stuff';   ## likewise
	warn 'eek!';            ## likewise
    my $input = <STDIN>;    ## keyboard entry is in standard IO window
    my $char = getc;        ## likewise

DESCRIPTION

This module captures the standard output or error of a program and redirects it to a read only text widget, which doesn't appear until necessary. When it does appear, the user can close it; it'll appear again when there is more output. Standard input can be entered in the widget, which becomes temporarily writable.

METHODS

These are actually added to the MainWindow class.

$mw->InitStdio;

The first time this method called, it does the following things:

o

Creates a MainWindow holding a read-only scrollable text widget, and withdraws this window until it's actually needed.

o

Ties STDOUT, STDERR and STDIN to a special handle that adds the output to this text widget.

o

Installs a $SIG{__WARN__} handler that redirects the output from warn to this window as well (by printing it to STDERR).

On the remaining calls, it:

o

Increments a reference count of "other" MainWindows.

o

Installs an OnDestroy handler that decrements this reference count, so that it can detect when it's the only MainWindow left and destroy itself.

$iowin = $mw->StdioWindow;

Returns a reference to the main window holding the text. You can use this to configure the window itself or the widgets it contains. The only advertised subwidget is 'text', which is the scrolled read-only text widget.

$old = $mw->RedirectStdio($boolean);

Enables or disables the redirection of standard output and error to the text window. Set $boolean to true to enable redirection, false to disable it. Returns the previous value of the enabled flag.

If InitStdio has never been called, this routine will call it if $boolean is true.

AUTHOR

Alan Stewart <astewart1@cox.net> based on Tk::Stderr by Kevin Michael Vail <kevin@vaildc.net>