Drag into the 21st century.
[sw-tools] / src / pres_curses.c
index f0a14d0..a4f3b3f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: pres_curses.c,v 1.5 1999/07/27 12:49:16 mdw Exp $
+ * $Id$
  *
  * Curses-based output presentation
  *
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: pres_curses.c,v $
- * Revision 1.5  1999/07/27 12:49:16  mdw
- * Slight tidying of resizing terminal handling.
- *
- * Revision 1.4  1999/07/16  16:52:28  mdw
- * `wbkdset' doesn't work so well.  Use `wbkgd' instead.
- *
- * Revision 1.3  1999/07/16 12:49:58  mdw
- * Improve exit status display.  New interface from `doto' project.
- *
- * Revision 1.2  1999/06/24 15:51:16  mdw
- * Fix signal handlers so they don't corrupt `errno'.
- *
- * Revision 1.1.1.1  1999/06/02 16:53:35  mdw
- * Initial import.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include "config.h"
@@ -250,7 +230,7 @@ int curses_init(archcons *a)
   }
   doupdate();
 
-#ifdef HAVE_WRESIZE
+#ifdef SIGWINCH
   signal(SIGWINCH, sig_winch);
 #endif
 #ifdef SIGTSTP
@@ -279,8 +259,25 @@ fail_0:
 void curses_output(archent *e, const char *p, size_t sz)
 {
   cwin *c = e->pres;
+  int y, x;
   while (sz) {
-    waddch(c->w, *p);
+    switch (*p) {
+      case '\r':
+       getyx(c->w, y, x);
+       wmove(c->w, y, 0);
+       break;
+      case '\n':
+       getyx(c->w, y, x);
+       if (y < c->height - 1)
+         y++;
+       else
+         scroll(c->w);
+       wmove(c->w, y, 0);
+       break;
+      default:
+       waddch(c->w, *p);
+       break;
+    }
     p++;
     sz--;
   }