Make close/open sequences work in a more rational manner.
[unix-history] / usr / src / usr.bin / tn3270 / sys_curses / termout.c
index e0fdc1e..3350961 100644 (file)
@@ -51,19 +51,19 @@ extern void EmptyTerminal();
                terminalCursorAddress:UnLocked? CursorAddress: HighestScreen())
 
 
                terminalCursorAddress:UnLocked? CursorAddress: HighestScreen())
 
 
-static int terminalCursorAddress = 0;  /* where the cursor is on term */
-static int screenInitd = 0;            /* the screen has been initialized */
-static int screenStopped = 1;          /* the screen has been stopped */
+static int terminalCursorAddress;      /* where the cursor is on term */
+static int screenInitd;                /* the screen has been initialized */
+static int screenStopped;              /* the screen has been stopped */
 #if    defined(SLOWSCREEN)
 static int max_changes_before_poll;    /* how many characters before looking */
                                        /* at terminal and net again */
 #endif /* defined(SLOWSCREEN) */
 
 #if    defined(SLOWSCREEN)
 static int max_changes_before_poll;    /* how many characters before looking */
                                        /* at terminal and net again */
 #endif /* defined(SLOWSCREEN) */
 
-static int needToRing = 0;             /* need to ring terinal bell */
+static int needToRing;                 /* need to ring terinal bell */
 static char *bellSequence = "\07";     /* bell sequence (may be replaced by
                                         * VB during initialization)
                                         */
 static char *bellSequence = "\07";     /* bell sequence (may be replaced by
                                         * VB during initialization)
                                         */
-static WINDOW *bellwin;                        /* The window the bell message is in */
+static WINDOW *bellwin = 0;            /* The window the bell message is in */
 int    bellwinup = 0;                  /* Are we up with it or not */
 
 #if    defined(unix)
 int    bellwinup = 0;                  /* Are we up with it or not */
 
 #if    defined(unix)
@@ -86,6 +86,23 @@ extern int   tin, tout;              /* file descriptors */
 #include "disp_asc.out"
 
 \f
 #include "disp_asc.out"
 
 \f
+
+/*
+ * init_screen()
+ *
+ * Initialize variables used by screen.
+ */
+
+void
+init_screen()
+{
+    bellwinup = 0;
+#if    defined(SLOWSCREEN)
+    inHighlightMode = 0;
+#endif /* defined(SLOWSCREEN) */
+}
+
+
 /* OurExitString - designed to keep us from going through infinite recursion */
 
 static void
 /* OurExitString - designed to keep us from going through infinite recursion */
 
 static void
@@ -572,10 +589,10 @@ void
 #endif /* defined(NOT43) */
        (*TryToSend)() = FastScreen;
 \f
 #endif /* defined(NOT43) */
        (*TryToSend)() = FastScreen;
 \f
-/* StartScreen - called to initialize the screen, etc. */
+/* InitTerminal - called to initialize the screen, etc. */
 
 void
 
 void
-StartScreen()
+InitTerminal()
 {
 #if defined(unix)
     struct sgttyb ourttyb;
 {
 #if defined(unix)
     struct sgttyb ourttyb;
@@ -583,6 +600,7 @@ StartScreen()
                2400, 4800, 9600 };
 #endif
     
                2400, 4800, 9600 };
 #endif
     
+    InitMapping();             /* Go do mapping file (MAP3270) first */
     if (!screenInitd) {        /* not initialized */
 #if    defined(unix)
        char KSEbuffer[2050];
     if (!screenInitd) {        /* not initialized */
 #if    defined(unix)
        char KSEbuffer[2050];
@@ -591,26 +609,10 @@ StartScreen()
        extern char *tgetstr();
 #endif /* defined(unix) */
 
        extern char *tgetstr();
 #endif /* defined(unix) */
 
-       bzero((char *)Host, sizeof Host);
-
-       bzero(Orders, sizeof Orders);
-       Orders[ORDER_SF] = Orders[ORDER_SBA] = Orders[ORDER_IC]
-               = Orders[ORDER_PT] = Orders[ORDER_RA] = Orders[ORDER_EUA]
-               = Orders[ORDER_YALE] = 1;
-
-       DeleteAllFields();
 #if    defined(SLOWSCREEN)
        bzero((char *)Terminal, sizeof Terminal);
 #endif /* defined(SLOWSCREEN) */
 #if    defined(SLOWSCREEN)
        bzero((char *)Terminal, sizeof Terminal);
 #endif /* defined(SLOWSCREEN) */
-       Lowest = HighestScreen()+1;
-       Highest = LowestScreen()-1;
-       terminalCursorAddress =
-               CursorAddress =
-               BufferAddress = SetBufferAddress(0,0);
-       UnLocked = 1;
-       Initialized = 1;
-       OutputClock = 1;
-       TransparentClock = -1;
+       terminalCursorAddress = SetBufferAddress(0,0);
 #if defined(unix)
        signal(SIGHUP, abort);
 #endif
 #if defined(unix)
        signal(SIGHUP, abort);
 #endif
@@ -660,6 +662,7 @@ StartScreen()
        screenInitd = 1;
        screenStopped = 0;              /* Not stopped */
     }
        screenInitd = 1;
        screenStopped = 0;              /* Not stopped */
     }
+    Initialized = 1;
 }
 
 
 }
 
 
@@ -797,15 +800,17 @@ int
 DoTerminalOutput()
 {
        /* called just before a select to conserve IO to terminal */
 DoTerminalOutput()
 {
        /* called just before a select to conserve IO to terminal */
-    if (Initialized &&
-           ((Lowest <= Highest) || needToRing ||
-                       (terminalCursorAddress != CorrectTerminalCursor()))) {
+    if (!Initialized) {
+       return 1;               /* No output if not initialized */
+    }
+    if ((Lowest <= Highest) || needToRing ||
+                       (terminalCursorAddress != CorrectTerminalCursor())) {
        (*TryToSend)();
     }
     if (Lowest > Highest) {
        (*TryToSend)();
     }
     if (Lowest > Highest) {
-       return(1);              /* no more output now */
+       return 1;               /* no more output now */
     } else {
     } else {
-       return(0);              /* more output for future */
+       return 0;               /* more output for future */
     }
 }
 \f
     }
 }
 \f