diff options
author | das <das> | 2002-09-12 17:34:15 (GMT) |
---|---|---|
committer | das <das> | 2002-09-12 17:34:15 (GMT) |
commit | 3511aff356300b3c67bb9cdea914d9d0680818f9 (patch) | |
tree | 5accee31b778ee9409cf319d46f1fab25dc6353b /macosx/tkMacOSXAppInit.c | |
parent | d4c4c3a8f8edcc54b1e28e0ef3eaade3e5f2adce (diff) | |
download | tk-3511aff356300b3c67bb9cdea914d9d0680818f9.zip tk-3511aff356300b3c67bb9cdea914d9d0680818f9.tar.gz tk-3511aff356300b3c67bb9cdea914d9d0680818f9.tar.bz2 |
* generic/tk.h:
* mac/tkMacApplication.r:
* mac/tkMacLibrary.r:
* mac/tkMacResource.r:
* macosx/tkAboutDlg.r:
* macosx/tkMacOSXApplication.r:
* macosx/tkMacOSXLibrary.r:
* macosx/tkMacOSXResource.r: unified use of the two equivalent
resource compiler header inclusion defines RC_INVOKED and
RESOURCE_INCLUDED, now use RC_INVOKED throughout.
* macosx/tkMacOSXAppInit.c: improved detection of Wish startup
by the finder (by checking if stdin is /dev/null), in which
case we want to bring up the Tk console window.
* macosx/tkMacOSXHLEvents.c: added 'rapp' apple event handler.
Diffstat (limited to 'macosx/tkMacOSXAppInit.c')
-rw-r--r-- | macosx/tkMacOSXAppInit.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/macosx/tkMacOSXAppInit.c b/macosx/tkMacOSXAppInit.c index 422546b..55863a1 100644 --- a/macosx/tkMacOSXAppInit.c +++ b/macosx/tkMacOSXAppInit.c @@ -11,9 +11,10 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXAppInit.c,v 1.2 2002/08/31 06:12:29 das Exp $ + * RCS: @(#) $Id: tkMacOSXAppInit.c,v 1.3 2002/09/12 17:34:16 das Exp $ */ #include <pthread.h> +#include <sys/stat.h> #include "tk.h" #include "tclInt.h" #include "locale.h" @@ -190,22 +191,26 @@ Tcl_AppInit(interp) #endif /* TK_TEST */ /* - * If we don't have a TTY, then use the Tk based console - * interpreter instead. + * If we don't have a TTY and stdin is a special character file of length 0, + * (e.g. /dev/null, which is what Finder sets when double clicking Wish) + * then use the Tk based console interpreter. */ - if (ttyname(0) == NULL) { - Tk_InitConsoleChannels(interp); - Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); - Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); - Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); - if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { - goto error; - } - /* Only show the console if we don't have a startup script */ - if (TclGetStartupScriptPath() == NULL) { - Tcl_Eval(interp, "console show"); - } + if (!isatty(0)) { + struct stat st; + if (fstat(0, &st) || (S_ISCHR(st.st_mode) && st.st_blocks == 0)) { + Tk_InitConsoleChannels(interp); + Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDIN)); + Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDOUT)); + Tcl_RegisterChannel(interp, Tcl_GetStdChannel(TCL_STDERR)); + if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) { + goto error; + } + /* Only show the console if we don't have a startup script */ + if (TclGetStartupScriptPath() == NULL) { + Tcl_Eval(interp, "console show"); + } + } } /* |