summaryrefslogtreecommitdiffstats
path: root/macosx/tkMacOSXAppInit.c
diff options
context:
space:
mode:
authordas <das>2002-09-12 17:34:15 (GMT)
committerdas <das>2002-09-12 17:34:15 (GMT)
commit3511aff356300b3c67bb9cdea914d9d0680818f9 (patch)
tree5accee31b778ee9409cf319d46f1fab25dc6353b /macosx/tkMacOSXAppInit.c
parentd4c4c3a8f8edcc54b1e28e0ef3eaade3e5f2adce (diff)
downloadtk-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.c35
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");
+ }
+ }
}
/*