diff options
author | dgp <dgp@users.sourceforge.net> | 2006-03-21 03:01:26 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2006-03-21 03:01:26 (GMT) |
commit | a035d9f0c9008fbb62a43d011474036c0c56ed3c (patch) | |
tree | bca5bb0681c64b92fb5ae76da7d8104a36d8b681 /generic/tkConsole.c | |
parent | 1ed4bd550b5b14493cf7673adfc2657f1e70bbfd (diff) | |
download | tk-a035d9f0c9008fbb62a43d011474036c0c56ed3c.zip tk-a035d9f0c9008fbb62a43d011474036c0c56ed3c.tar.gz tk-a035d9f0c9008fbb62a43d011474036c0c56ed3c.tar.bz2 |
* generic/tkConsole.c: Added exit handler to clean up the interp
where the console window lives. Also added code to handle
multiple calls to Tk_CreateConsoleWindow so that the console
channels connect to the last console window opened, in compatibility
with the previous implementation.
Diffstat (limited to 'generic/tkConsole.c')
-rw-r--r-- | generic/tkConsole.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/generic/tkConsole.c b/generic/tkConsole.c index f43ad31..e9b406c 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkConsole.c,v 1.28 2006/03/20 22:58:46 dgp Exp $ + * RCS: @(#) $Id: tkConsole.c,v 1.29 2006/03/21 03:01:27 dgp Exp $ */ #include "tk.h" @@ -372,13 +372,32 @@ Tk_CreateConsoleWindow( ChannelData *data = (ChannelData *)Tcl_GetChannelInstanceData(chan); info = data->info; if (info->consoleInterp) { - /* - * TODO: The console channels are already connected to a console - * window. Move channels to this new one, but leave the old one - * functioning. - */ - - + /* New ConsoleInfo for a new console window */ + info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); + info->refCount = 0; + + /* Update any console channels to make use of the new console */ + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDIN)) + == &consoleChannelType) { + data = (ChannelData *)Tcl_GetChannelInstanceData(chan); + data->info->refCount--; + data->info = info; + data->info->refCount++; + } + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDOUT)) + == &consoleChannelType) { + data = (ChannelData *)Tcl_GetChannelInstanceData(chan); + data->info->refCount--; + data->info = info; + data->info->refCount++; + } + if (Tcl_GetChannelType(chan = Tcl_GetStdChannel(TCL_STDERR)) + == &consoleChannelType) { + data = (ChannelData *)Tcl_GetChannelInstanceData(chan); + data->info->refCount--; + data->info = info; + data->info->refCount++; + } } } else { info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo)); |