diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-06-11 18:55:32 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-06-11 18:55:32 (GMT) |
commit | 57e25a04aef40def9f523ec04b6fd04a60d2147b (patch) | |
tree | cfe623294ef7fc33d630552701c1b56b5ab42bdf /generic/tkMain.c | |
parent | d9ac48147c4cc07f47d581b94c2fd05cfff767a7 (diff) | |
parent | 94bf2a20e147c3a37f07c2a51348e3a072c4c248 (diff) | |
download | tk-57e25a04aef40def9f523ec04b6fd04a60d2147b.zip tk-57e25a04aef40def9f523ec04b6fd04a60d2147b.tar.gz tk-57e25a04aef40def9f523ec04b6fd04a60d2147b.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/tkMain.c')
-rw-r--r-- | generic/tkMain.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/generic/tkMain.c b/generic/tkMain.c index a48ddd4..9fd2f69 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -39,6 +39,8 @@ # include <stdlib.h> #endif +extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *); + /* * The default prompt used when the user has not overridden it. */ @@ -53,6 +55,7 @@ * to strcmp here. */ #ifdef __WIN32__ +# include "tclInt.h" # include "tkWinInt.h" #else # define TCHAR char @@ -92,16 +95,24 @@ * it will conflict with a declaration elsewhere on some systems. */ -#if defined(_WIN32) +#if defined(__WIN32__) || defined(_WIN32) #define isatty WinIsTty static int WinIsTty(int fd) { HANDLE handle; + /* * For now, under Windows, we assume we are not running as a console mode * app, so we need to use the GUI console. In order to enable this, we * always claim to be running on a tty. This probably isn't the right way * to do it. */ + +#if !defined(STATIC_BUILD) + if (tclStubsPtr->reserved9 && TclpIsAtty) { + /* We are running on Cygwin */ + return TclpIsAtty(fd); + } +#endif handle = GetStdHandle(STD_INPUT_HANDLE + fd); /* * If it's a bad or closed handle, then it's been connected to a wish @@ -181,6 +192,31 @@ Tk_MainEx( abort(); } +#if defined(__WIN32__) && !defined(__WIN64__) && !defined(UNICODE) && !defined(STATIC_BUILD) + + if (tclStubsPtr->reserved9) { + /* We are running win32 Tk under Cygwin, so let's check + * whether the env("DISPLAY") variable or the -display + * argument is set. If so, we really want to run the + * Tk_MainEx function of libtk8.?.dll, not this one. */ + if (Tcl_GetVar2(interp, "env", "DISPLAY", TCL_GLOBAL_ONLY)) { + loadCygwinTk: + if (TkCygwinMainEx(argc, argv, appInitProc, interp)) { + /* Should never reach here. */ + return; + } + } else { + int i; + + for (i = 1; i < argc; ++i) { + if (!_tcscmp(argv[i], TEXT("-display"))) { + goto loadCygwinTk; + } + } + } + } +#endif + Tcl_InitMemory(interp); is.interp = interp; |