date and time created 87/02/15 16:03:30 by lepreau
[unix-history] / usr / src / games / cribbage / io.c
index 6fd82cc..708dbd2 100644 (file)
@@ -1,6 +1,16 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)io.c       5.1 (Berkeley) %G%";
+#endif not lint
+
 # include      <curses.h>
 # include      <ctype.h>
 # include      <curses.h>
 # include      <ctype.h>
-# include      <unctrl.h>
+# include      <signal.h>
 # include      "deck.h"
 # include      "cribbage.h"
 # include      "cribcur.h"
 # include      "deck.h"
 # include      "cribbage.h"
 # include      "cribcur.h"
@@ -377,8 +387,13 @@ endmsg()
        Msgbuf[0] = toupper(Msgbuf[0]);
     mp = Msgbuf;
     len = strlen(mp);
        Msgbuf[0] = toupper(Msgbuf[0]);
     mp = Msgbuf;
     len = strlen(mp);
-    if (len / MSG_X + Lineno >= MSG_Y)
+    if (len / MSG_X + Lineno >= MSG_Y) {
+       while (Lineno < MSG_Y) {
+           wmove(Msgwin, Lineno++, 0);
+           wclrtoeol(Msgwin);
+       }
        Lineno = 0;
        Lineno = 0;
+    }
     mvaddch(Lineno + Y_MSG_START, SCORE_X, '*');
     lastline = Lineno;
     do {
     mvaddch(Lineno + Y_MSG_START, SCORE_X, '*');
     lastline = Lineno;
     do {
@@ -397,7 +412,7 @@ endmsg()
            Lineno = 0;
     } while (len > MSG_X);
     wclrtoeol(Msgwin);
            Lineno = 0;
     } while (len > MSG_X);
     wclrtoeol(Msgwin);
-    Mpos = Newpos % MSG_X;
+    Mpos = len;
     Newpos = 0;
     wrefresh(Msgwin);
     refresh();
     Newpos = 0;
     wrefresh(Msgwin);
     refresh();
@@ -541,3 +556,17 @@ getline()
     stdscr = oscr;
     return linebuf;
 }
     stdscr = oscr;
     return linebuf;
 }
+
+/*
+ * bye:
+ *     Leave the program, cleaning things up as we go.
+ */
+bye()
+{
+       signal(SIGINT, SIG_IGN);
+       mvcur(0, COLS - 1, LINES - 1, 0);
+       fflush(stdout);
+       endwin();
+       putchar('\n');
+       exit(1);
+}