/*
* tkConsole.c --
*
* This file implements a Tcl console for systems that may not
* otherwise have access to a console. It uses the Text widget
* and provides special access via a console command.
*
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* SCCS: @(#) tkConsole.c 1.43 96/08/26 19:42:51
*/
#include "tkInt.h"
/*
* A data structure of the following type holds information for each console
* which a handler (i.e. a Tcl command) has been defined for a particular
* top-level window.
*/
typedef struct ConsoleInfo {
} ConsoleInfo;
/*
* Forward declarations for procedures defined later in this file:
*/
Tcl_Interp *interp));
int mask));
int mask));
int direction));
/*
* This structure describes the channel type structure for file based IO:
*/
"console", /* Type name. */
NULL, /* Always non-blocking.*/
ConsoleClose, /* Close proc. */
ConsoleInput, /* Input proc. */
ConsoleOutput, /* Output proc. */
NULL, /* Seek proc. */
NULL, /* Set option proc. */
NULL, /* Get option proc. */
ConsoleWatch, /* Watch for events on console. */
ConsoleReady, /* Are events present? */
ConsoleFile, /* Get a Tcl_File from the device. */
};
/*
*----------------------------------------------------------------------
*
* TkConsoleCreate --
*
* Create the console channels and install them as the standard
* channels. All I/O will be discarded until TkConsoleInit is
* called to attach the console to a text widget.
*
* Results:
* None.
*
* Side effects:
* Creates the console channel and installs it as the standard
* channels.
*
*----------------------------------------------------------------------
*/
void
{
if (consoleChannel != NULL) {
}
if (consoleChannel != NULL) {
}
if (consoleChannel != NULL) {
}
}
/*
*----------------------------------------------------------------------
*
* TkConsoleInit --
*
* Initialize the console. This code actually creates a new
* application and associated interpreter. This effectivly hides
* the implementation from the main application.
*
* Results:
* None.
*
* Side effects:
* A new console it created.
*
*----------------------------------------------------------------------
*/
int
{
#ifdef MAC_TCL
#else
#endif
if (consoleInterp == NULL) {
goto error;
}
/*
* Initialized Tcl and Tk.
*/
goto error;
}
goto error;
}
/*
* Add console commands to the interp
*/
(ClientData) info);
/* goto error; -- no problem for now... */
}
return TCL_OK;
if (consoleInterp != NULL) {
}
return TCL_ERROR;
}
/*
*----------------------------------------------------------------------
*
* ConsoleOutput--
*
* Writes the given output on the IO channel. Returns count of how
* many characters were actually written, and an error indication.
*
* Results:
* A count of how many characters were written is returned and an
* error indication is returned in an output argument.
*
* Side effects:
* Writes output on the actual channel.
*
*----------------------------------------------------------------------
*/
static int
char *buf; /* The data buffer. */
int toWrite; /* How many bytes to write? */
int *errorCode; /* Where to store error code. */
{
*errorCode = 0;
Tcl_SetErrno(0);
if (gStdoutInterp != NULL) {
}
return toWrite;
}
/*
*----------------------------------------------------------------------
*
* ConsoleInput --
*
* Read input from the console. Not currently implemented.
*
* Results:
* Always returns EOF.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
char *buf; /* Where to store data read. */
int bufSize; /* How much space is available
* in the buffer? */
int *errorCode; /* Where to store error code. */
{
return 0; /* Always return EOF. */
}
/*
*----------------------------------------------------------------------
*
* ConsoleClose --
*
* Closes the IO channel.
*
* Results:
* Always returns 0 (success).
*
* Side effects:
* Frees the dummy file associated with the channel.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
{
return 0;
}
/*
*----------------------------------------------------------------------
*
* ConsoleWatch --
*
* Called by the notifier to set up the console device so that
* events will be noticed. Since there are no events on the
* console, this routine just returns without doing anything.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static void
int mask; /* OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION, for the events
* we are interested in. */
{
}
/*
*----------------------------------------------------------------------
*
* ConsoleReady --
*
* Invoked by the notifier to notice whether any events are present
* on the console. Since there are no events on the console, this
* routine always returns zero.
*
* Results:
* Always 0.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static int
int mask; /* OR-ed combination of
* TCL_READABLE, TCL_WRITABLE and
* TCL_EXCEPTION, for the events
* we are interested in. */
{
return 0;
}
/*
*----------------------------------------------------------------------
*
* ConsoleFile --
*
* Invoked by the generic IO layer to get a Tcl_File from a channel.
* Because console channels do not use Tcl_Files, this function always
* returns NULL.
*
* Results:
* Always NULL.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
/* ARGSUSED */
static Tcl_File
int direction; /* TCL_READABLE or TCL_WRITABLE
* to indicate which direction of
* the channel is being requested. */
{
}
/*
*----------------------------------------------------------------------
*
* ConsoleCmd --
*
* The console command implements a Tcl interface to the various console
* options.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
char c;
int length;
int result;
if (argc < 2) {
" option ?arg arg ...?\"", (char *) NULL);
return TCL_ERROR;
}
c = argv[1][0];
} else {
"\": should be hide, show, or title",
(char *) NULL);
}
return result;
}
/*
*----------------------------------------------------------------------
*
* InterpreterCmd --
*
* This command allows the console interp to communicate with the
* main interpreter.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
static int
int argc; /* Number of arguments. */
char **argv; /* Argument strings. */
{
char c;
int length;
int result;
if (argc < 2) {
" option ?arg arg ...?\"", (char *) NULL);
return TCL_ERROR;
}
c = argv[1][0];
} else {
"\": should be eval or record",
(char *) NULL);
}
return result;
}
/*
*----------------------------------------------------------------------
*
* ConsoleDeleteProc --
*
* If the console command is deleted we destroy the console window
* and all associated data structures.
*
* Results:
* None.
*
* Side effects:
* A new console it created.
*
*----------------------------------------------------------------------
*/
static void
{
}
/*
*----------------------------------------------------------------------
*
* ConsoleEventProc --
*
* This event procedure is registered on the main window of the
* slave interpreter. If the user or a running script causes the
* main window to be destroyed, then we need to inform the console
* interpreter by invoking "tkConsoleExit".
*
* Results:
* None.
*
* Side effects:
* Invokes the "tkConsoleExit" procedure in the console interp.
*
*----------------------------------------------------------------------
*/
static void
{
}
}
/*
*----------------------------------------------------------------------
*
* TkConsolePrint --
*
* Prints to the give text to the console. Given the main interp
* this functions find the appropiate console interp and forwards
* the text to be added to that console.
*
* Results:
* None.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
void
int devId; /* TCL_STDOUT for stdout, TCL_STDERR for
* stderr. */
char *buffer; /* Text buffer. */
long size; /* Size of text buffer. */
{
char *cmd;
int result;
return;
}
if (devId == TCL_STDERR) {
cmd = "tkConsoleOutput stderr ";
} else {
cmd = "tkConsoleOutput stdout ";
}
if (result == 0) {
return;
}
}