summaryrefslogtreecommitdiffstats
path: root/mac/tkMacAppInit.c
diff options
context:
space:
mode:
Diffstat (limited to 'mac/tkMacAppInit.c')
-rw-r--r--mac/tkMacAppInit.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/mac/tkMacAppInit.c b/mac/tkMacAppInit.c
index c625609..50f6156 100644
--- a/mac/tkMacAppInit.c
+++ b/mac/tkMacAppInit.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacAppInit.c,v 1.13 2002/01/15 20:48:30 dgp Exp $
+ * RCS: @(#) $Id: tkMacAppInit.c,v 1.14 2002/04/08 09:04:34 das Exp $
*/
#include <Gestalt.h>
@@ -25,6 +25,7 @@
#include "tkMacInt.h"
#include "tclInt.h"
#include "tclMac.h"
+#include "tclMacInt.h"
#ifdef TK_TEST
extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp));
@@ -49,6 +50,9 @@ void RemoveConsole _ANSI_ARGS_((void));
long WriteCharsToConsole _ANSI_ARGS_((char *buff, long n));
long ReadCharsFromConsole _ANSI_ARGS_((char *buff, long n));
extern char * __ttyname _ANSI_ARGS_((long fildes));
+int kbhit _ANSI_ARGS_((void));
+int getch _ANSI_ARGS_((void));
+void clrscr _ANSI_ARGS_((void));
short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event));
/*
@@ -57,6 +61,10 @@ short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event));
static int MacintoshInit _ANSI_ARGS_((void));
static int SetupMainInterp _ANSI_ARGS_((Tcl_Interp *interp));
+static void SetupSIOUX _ANSI_ARGS_((void));
+
+static int inMacExit = 0;
+static pascal void NoMoreOutput() { inMacExit = 1; }
/*
*----------------------------------------------------------------------
@@ -319,6 +327,8 @@ SetupMainInterp(
if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
goto error;
}
+ SetupSIOUX();
+ TclMacInstallExitToShellPatch(NoMoreOutput);
}
/*
@@ -368,8 +378,15 @@ RemoveConsole(void)
long
WriteCharsToConsole(char *buffer, long n)
{
- TkConsolePrint(gStdoutInterp, TCL_STDOUT, buffer, n);
- return n;
+ if (!inMacExit) {
+ Tcl_DString ds;
+ Tcl_ExternalToUtfDString(NULL, buffer, n, &ds);
+ TkConsolePrint(gStdoutInterp, TCL_STDOUT, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ Tcl_DStringFree(&ds);
+ return n;
+ } else {
+ return 0;
+ }
}
long
@@ -390,8 +407,37 @@ __ttyname(long fildes)
return (0L);
}
+int kbhit(void)
+{
+ return 0;
+}
+
+int getch(void)
+{
+ return 0;
+}
+
+void clrscr(void)
+{
+ return;
+}
+
short
SIOUXHandleOneEvent(EventRecord *event)
{
return 0;
}
+static void SetupSIOUX(void) {
+#ifndef STATIC_BUILD
+ extern DLLIMPORT void SetupConsolePlugins(void*, void*, void*, void*,
+ void*, void*, void*, void*);
+ SetupConsolePlugins( &InstallConsole,
+ &RemoveConsole,
+ &WriteCharsToConsole,
+ &ReadCharsFromConsole,
+ &__ttyname,
+ &kbhit,
+ &getch,
+ &clrscr);
+#endif
+}