BSD 3 development
authorBill Joy <wnj@ucbvax.Berkeley.EDU>
Sat, 10 Nov 1979 18:01:48 +0000 (10:01 -0800)
committerBill Joy <wnj@ucbvax.Berkeley.EDU>
Sat, 10 Nov 1979 18:01:48 +0000 (10:01 -0800)
Work on file usr/src/cmd/clear.c

Synthesized-from: 3bsd

usr/src/cmd/clear.c [new file with mode: 0644]

diff --git a/usr/src/cmd/clear.c b/usr/src/cmd/clear.c
new file mode 100644 (file)
index 0000000..dcc7e99
--- /dev/null
@@ -0,0 +1,42 @@
+/* load me with -ltermlib */
+/* #include <retrofit.h> on version 6 */
+/*
+ * clear - clear the screen
+ */
+
+#include <stdio.h>
+#include <sgtty.h>
+
+char   *getenv();
+char   *tgetstr();
+char   PC;
+short  ospeed;
+#undef putchar
+int    putchar();
+
+main()
+{
+       char *cp = getenv("TERM");
+       char clbuf[20];
+       char pcbuf[20];
+       char *clbp = clbuf;
+       char *pcbp = pcbuf;
+       char *clear;
+       char buf[1024];
+       char *pc;
+       struct sgttyb tty;
+
+       gtty(1, &tty);
+       ospeed = tty.sg_ospeed;
+       if (cp == (char *) 0)
+               exit(1);
+       if (tgetent(buf, cp) != 1)
+               exit(1);
+       pc = tgetstr("pc", &pcbp);
+       if (pc)
+               PC = *pc;
+       clear = tgetstr("cl", &clbp);
+       if (clear)
+               tputs(clear, tgetnum("li"), putchar);
+       exit (clear != (char *) 0);
+}