summaryrefslogtreecommitdiff
path: root/usr.bin/mg/ttyio.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2000-02-26 22:53:17 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2000-02-26 22:53:17 +0000
commitac2dd1683fd459fc832d940eea325eb1725424bb (patch)
tree1a5cdc9d6300b1a29ff65c02960159db2bdfb9ad /usr.bin/mg/ttyio.c
parentc198e5bf8d551492a685ce1c4ab327ceac70a790 (diff)
change WINDOW -> MGWIN to avoid curses type conflict
convert to terminfo in tty*.c add support for some keypad function keys (arrows, pgup, pgdown)
Diffstat (limited to 'usr.bin/mg/ttyio.c')
-rw-r--r--usr.bin/mg/ttyio.c53
1 files changed, 10 insertions, 43 deletions
diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c
index 58f84eb4dfa..d13caf3e69f 100644
--- a/usr.bin/mg/ttyio.c
+++ b/usr.bin/mg/ttyio.c
@@ -1,6 +1,6 @@
/*
* Name: MicroEMACS
- * System V terminal I/O.
+ * POSIX terminal I/O.
* Version: 0
* Last edit: Tue Aug 26 23:57:57 PDT 1986
* By: gonzo!daveb
@@ -11,15 +11,14 @@
* keyboard characters, and write characters to
* the display in a barely buffered fashion.
*
- * This version goes along with tty/termcap/tty.c.
- * Terminal size is determined there, rather than here, and
- * this does not open the termcap file
+ * This version goes along with the terminfo tty.c.
*/
#include "def.h"
#include <sys/types.h>
#include <fcntl.h>
#include <termios.h>
+#include <term.h>
#define NOBUF 512 /* Output buffer size. */
@@ -77,45 +76,12 @@ ttopen()
if (tcsetattr(0, TCSAFLUSH, &nt) < 0)
abort();
- /* This really belongs in tty/termcap... */
-
- if ((cp=getenv("TERMCAP")) == NULL
- || (nrow=getvalue(cp, "li")) <= 0
- || (ncol=getvalue(cp, "co")) <= 0) {
- nrow = 24;
- ncol = 80;
- }
- if (nrow > NROW) /* Don't crash if the */
- nrow = NROW; /* termcap entry is */
- if (ncol > NCOL) /* too big. */
- ncol = NCOL;
+ setttysize();
ttyactivep = TRUE;
}
/*
- * This routine scans a string, which is
- * actually the return value of a getenv call for the TERMCAP
- * variable, looking for numeric parameter "name". Return the value
- * if found. Return -1 if not there. Assume that "name" is 2
- * characters long. This limited use of the TERMCAP lets us find
- * out the size of a window on the X display.
- */
-getvalue(cp, name)
-register char *cp;
-register char *name;
-{
- for (;;) {
- while (*cp!=0 && *cp!=':')
- ++cp;
- if (*cp++ == 0) /* Not found. */
- return (-1);
- if (cp[0]==name[0] && cp[1]==name[1] && cp[2]=='#')
- return (atoi(cp+3)); /* Stops on ":". */
- }
-}
-
-/*
* This function gets called just
* before we go back home to the shell. Put all of
* the terminal parameters back.
@@ -223,14 +189,15 @@ setttysize()
ncol = winsize . ws_col;
} else
#endif
- if ((nrow=tgetnum ("li")) <= 0
- || (ncol=tgetnum ("co")) <= 0) {
+ if ((nrow = lines) <= 0 || (ncol = columns) <= 0) {
nrow = 24;
ncol = 80;
}
- if (nrow > NROW) /* Don't crash if the */
- nrow = NROW; /* termcap entry is */
- if (ncol > NCOL) /* too big. */
+
+ /* Enforce maximum screen size. */
+ if (nrow > NROW)
+ nrow = NROW;
+ if (ncol > NCOL)
ncol = NCOL;
}