summaryrefslogtreecommitdiff
path: root/usr.bin/vi
diff options
context:
space:
mode:
authorAnthony J. Bentley <bentley@cvs.openbsd.org>2014-11-06 10:48:53 +0000
committerAnthony J. Bentley <bentley@cvs.openbsd.org>2014-11-06 10:48:53 +0000
commit0f9a2f18ad6d8206346a757f4df6b2a0cfadfa93 (patch)
treedeb5954e95f1fcdeac00b2902e1b99a61954eeaa /usr.bin/vi
parentd3a0306610faa82579ce41bf389bfc6533919f1a (diff)
Remove old curses support in vi.
ok nicm@ millert@ plus a comment tweak from nicm@
Diffstat (limited to 'usr.bin/vi')
-rw-r--r--usr.bin/vi/build/Makefile9
-rw-r--r--usr.bin/vi/build/config.h43
-rw-r--r--usr.bin/vi/cl/cl_bsd.c345
-rw-r--r--usr.bin/vi/cl/cl_funcs.c23
-rw-r--r--usr.bin/vi/cl/cl_term.c17
-rw-r--r--usr.bin/vi/include/cl_extern.h35
6 files changed, 8 insertions, 464 deletions
diff --git a/usr.bin/vi/build/Makefile b/usr.bin/vi/build/Makefile
index 1c7e3b28bd0..7a7977969b3 100644
--- a/usr.bin/vi/build/Makefile
+++ b/usr.bin/vi/build/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.18 2013/06/22 18:52:52 miod Exp $
+# $OpenBSD: Makefile,v 1.19 2014/11/06 10:48:52 bentley Exp $
# @(#)Makefile.in 8.75 (Berkeley) 10/23/96
PROG= vi
@@ -11,11 +11,6 @@ CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
LDADD+=-lcurses
DPADD+= ${LIBCURSES}
-# Old BSD curses
-#CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include -D_USE_OLD_CURSES_
-#LDADD+= -locurses
-#DPADD+= ${LIBOLDCURSES}
-
LDADD+=-lutil
DPADD+= ${LIBUTIL}
@@ -24,7 +19,7 @@ DPADD+= ${LIBUTIL}
CFLAGS+= -fno-tree-dominator-opts
.endif
-SRCS= cl_bsd.c cl_funcs.c cl_main.c cl_read.c cl_screen.c cl_term.c \
+SRCS= cl_funcs.c cl_main.c cl_read.c cl_screen.c cl_term.c \
cut.c delete.c ex.c ex_abbrev.c ex_append.c ex_args.c ex_argv.c \
ex_at.c ex_bang.c ex_cd.c ex_cmd.c ex_cscope.c ex_delete.c \
ex_display.c ex_edit.c ex_equal.c ex_file.c ex_filter.c \
diff --git a/usr.bin/vi/build/config.h b/usr.bin/vi/build/config.h
index afdfc04d071..12509ac64ae 100644
--- a/usr.bin/vi/build/config.h
+++ b/usr.bin/vi/build/config.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.h,v 1.9 2012/12/20 20:28:12 naddy Exp $ */
+/* $OpenBSD: config.h,v 1.10 2014/11/06 10:48:52 bentley Exp $ */
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
@@ -51,47 +51,6 @@
/* Define if you have a Ultrix-style (broken) vdisable. */
/* #undef HAVE_BROKEN_VDISABLE */
-/* Define if you have a BSD version of curses. */
-#ifdef _USE_OLD_CURSES_
-#define HAVE_BSD_CURSES 1
-#endif
-
-/* Define if you have the curses(3) addnstr function. */
-#define HAVE_CURSES_ADDNSTR 1
-
-/* Define if you have the curses(3) beep function. */
-#ifndef _USE_OLD_CURSES_
-#define HAVE_CURSES_BEEP 1
-#endif
-
-/* Define if you have the curses(3) flash function. */
-#ifndef _USE_OLD_CURSES_
-#define HAVE_CURSES_FLASH 1
-#endif
-
-/* Define if you have the curses(3) idlok function. */
-#define HAVE_CURSES_IDLOK 1
-
-/* Define if you have the curses(3) keypad function. */
-#ifndef _USE_OLD_CURSES_
-#define HAVE_CURSES_KEYPAD 1
-#endif
-
-/* Define if you have the curses(3) newterm function. */
-#ifndef _USE_OLD_CURSES_
-#define HAVE_CURSES_NEWTERM 1
-#endif
-
-/* Define if you have the curses(3) setupterm function. */
-#ifndef _USE_OLD_CURSES_
-#define HAVE_CURSES_SETUPTERM 1
-#endif
-
-/* Define if you have the curses(3) tigetstr/tigetnum functions. */
-#ifndef _USE_OLD_CURSES_
-#define HAVE_CURSES_TIGETSTR 1
-#endif
-
/* Define if you have the chsize(2) system call. */
/* #undef HAVE_FTRUNCATE_CHSIZE */
diff --git a/usr.bin/vi/cl/cl_bsd.c b/usr.bin/vi/cl/cl_bsd.c
index 768e49815e4..e69de29bb2d 100644
--- a/usr.bin/vi/cl/cl_bsd.c
+++ b/usr.bin/vi/cl/cl_bsd.c
@@ -1,345 +0,0 @@
-/* $OpenBSD: cl_bsd.c,v 1.10 2009/10/27 23:59:47 deraadt Exp $ */
-
-/*-
- * Copyright (c) 1995, 1996
- * Keith Bostic. All rights reserved.
- *
- * See the LICENSE file for redistribution information.
- */
-
-#include "config.h"
-
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/time.h>
-
-#include <bitstring.h>
-#include <ctype.h>
-#include <curses.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-
-#include "../common/common.h"
-#include "../vi/vi.h"
-#include "cl.h"
-
-#ifndef HAVE_CURSES_SETUPTERM
-static char *ke; /* Keypad on. */
-static char *ks; /* Keypad off. */
-static char *vb; /* Visible bell string. */
-#endif
-
-/*
- * HP's support the entire System V curses package except for the tigetstr
- * and tigetnum functions. Ultrix supports the BSD curses package except
- * for the idlok function. Cthulu only knows why. Break things up into a
- * minimal set of functions.
- */
-
-#ifndef HAVE_CURSES_ADDNSTR
-/*
- * addnstr --
- *
- * PUBLIC: #ifndef HAVE_CURSES_ADDNSTR
- * PUBLIC: int addnstr(char *, int);
- * PUBLIC: #endif
- */
-int
-addnstr(s, n)
- char *s;
- int n;
-{
- int ch;
-
- while (n-- && (ch = *s++))
- addch(ch);
- return (OK);
-}
-#endif
-
-#ifndef HAVE_CURSES_BEEP
-/*
- * beep --
- *
- * PUBLIC: #ifndef HAVE_CURSES_BEEP
- * PUBLIC: void beep(void);
- * PUBLIC: #endif
- */
-void
-beep()
-{
- (void)write(1, "\007", 1); /* '\a' */
-}
-#endif /* !HAVE_CURSES_BEEP */
-
-#ifndef HAVE_CURSES_FLASH
-/*
- * flash --
- * Flash the screen.
- *
- * PUBLIC: #ifndef HAVE_CURSES_FLASH
- * PUBLIC: void flash(void);
- * PUBLIC: #endif
- */
-void
-flash()
-{
- if (vb != NULL) {
- (void)tputs(vb, 1, cl_putchar);
- (void)fflush(stdout);
- } else
- beep();
-}
-#endif /* !HAVE_CURSES_FLASH */
-
-#ifndef HAVE_CURSES_IDLOK
-/*
- * idlok --
- * Turn on/off hardware line insert/delete.
- *
- * PUBLIC: #ifndef HAVE_CURSES_IDLOK
- * PUBLIC: void idlok(WINDOW *, int);
- * PUBLIC: #endif
- */
-void
-idlok(win, bf)
- WINDOW *win;
- int bf;
-{
- return;
-}
-#endif /* !HAVE_CURSES_IDLOK */
-
-#ifndef HAVE_CURSES_KEYPAD
-/*
- * keypad --
- * Put the keypad/cursor arrows into or out of application mode.
- *
- * PUBLIC: #ifndef HAVE_CURSES_KEYPAD
- * PUBLIC: int keypad(void *, int);
- * PUBLIC: #endif
- */
-int
-keypad(a, on)
- void *a;
- int on;
-{
- char *p;
-
- if ((p = tigetstr(on ? "smkx" : "rmkx")) != (char *)-1) {
- (void)tputs(p, 0, cl_putchar);
- (void)fflush(stdout);
- }
- return (0);
-}
-#endif /* !HAVE_CURSES_KEYPAD */
-
-#ifndef HAVE_CURSES_NEWTERM
-/*
- * newterm --
- * Create a new curses screen.
- *
- * PUBLIC: #ifndef HAVE_CURSES_NEWTERM
- * PUBLIC: void *newterm(const char *, FILE *, FILE *);
- * PUBLIC: #endif
- */
-void *
-newterm(a, b, c)
- const char *a;
- FILE *b, *c;
-{
- return (initscr());
-}
-#endif /* !HAVE_CURSES_NEWTERM */
-
-#ifndef HAVE_CURSES_SETUPTERM
-/*
- * setupterm --
- * Set up terminal.
- *
- * PUBLIC: #ifndef HAVE_CURSES_SETUPTERM
- * PUBLIC: void setupterm(char *, int, int *);
- * PUBLIC: #endif
- */
-void
-setupterm(ttype, fno, errp)
- char *ttype;
- int fno, *errp;
-{
- static char buf[2048];
- char *p;
-
- if ((*errp = tgetent(buf, ttype)) > 0) {
- if (ke != NULL)
- free(ke);
- ke = ((p = tigetstr("rmkx")) == (char *)-1) ?
- NULL : strdup(p);
- if (ks != NULL)
- free(ks);
- ks = ((p = tigetstr("smkx")) == (char *)-1) ?
- NULL : strdup(p);
- if (vb != NULL)
- free(vb);
- vb = ((p = tigetstr("flash")) == (char *)-1) ?
- NULL : strdup(p);
- }
-}
-#endif /* !HAVE_CURSES_SETUPTERM */
-
-#ifndef HAVE_CURSES_TIGETSTR
-/* Terminfo-to-termcap translation table. */
-typedef struct _tl {
- char *terminfo; /* Terminfo name. */
- char *termcap; /* Termcap name. */
-} TL;
-static const TL list[] = {
- "cols", "co", /* Terminal columns. */
- "cup", "cm", /* Cursor up. */
- "cuu1", "up", /* Cursor up. */
- "el", "ce", /* Clear to end-of-line. */
- "flash", "vb", /* Visible bell. */
- "kcub1", "kl", /* Cursor left. */
- "kcud1", "kd", /* Cursor down. */
- "kcuf1", "kr", /* Cursor right. */
- "kcuu1", "ku", /* Cursor up. */
- "kdch1", "kD", /* Delete character. */
- "kdl1", "kL", /* Delete line. */
- "ked", "kS", /* Delete to end of screen. */
- "kel", "kE", /* Delete to eol. */
- "khome", "kh", /* Go to sol. */
- "kich1", "kI", /* Insert at cursor. */
- "kil1", "kA", /* Insert line. */
- "kind", "kF", /* Scroll down. */
- "kll", "kH", /* Go to eol. */
- "knp", "kN", /* Page down. */
- "kpp", "kP", /* Page up. */
- "kri", "kR", /* Scroll up. */
- "lines", "li", /* Terminal lines. */
- "rmcup", "te", /* Terminal end string. */
- "rmkx", "ke", /* Exit "keypad-transmit" mode. */
- "rmso", "se", /* Standout end. */
- "smcup", "ti", /* Terminal initialization string. */
- "smkx", "ks", /* Enter "keypad-transmit" mode. */
- "smso", "so", /* Standout begin. */
-};
-
-#ifdef _AIX
-/*
- * AIX's implementation for function keys greater than 10 is different and
- * only goes as far as 36.
- */
-static const char codes[] = {
-/* 0-10 */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';',
-/* 11-20 */ '<', '>', '!', '@', '#', '$', '%', '^', '&', '*',
-/* 21-30 */ '(', ')', '-', '_', '+', ',', ':', '?', '[', ']',
-/* 31-36 */ '{', '}', '|', '~', '/', '='
-};
-
-#else
-
-/*
- * !!!
- * Historically, the 4BSD termcap code didn't support functions keys greater
- * than 9. This was silently enforced -- asking for key k12 would return the
- * value for k1. We try and get around this by using the tables specified in
- * the terminfo(TI_ENV) man page from the 3rd Edition SVID. This assumes the
- * implementors of any System V compatibility code or an extended termcap used
- * those codes.
- */
-static const char codes[] = {
-/* 0-10 */ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ';',
-/* 11-19 */ '1', '2', '3', '4', '5', '6', '7', '8', '9',
-/* 20-63 */ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
-};
-#endif /* _AIX */
-
-/*
- * lcmp --
- * list comparison routine for bsearch.
- */
-static int
-lcmp(a, b)
- const void *a, *b;
-{
- return (strcmp(a, ((TL *)b)->terminfo));
-}
-
-/*
- * tigetstr --
- *
- * Vendors put the prototype for tigetstr into random include files, including
- * <term.h>, which we can't include because it makes other systems unhappy.
- * Try and work around the problem, since we only care about the return value.
- *
- * PUBLIC: #ifdef HAVE_CURSES_TIGETSTR
- * PUBLIC: char *tigetstr();
- * PUBLIC: #else
- * PUBLIC: char *tigetstr(char *);
- * PUBLIC: #endif
- */
-char *
-tigetstr(name)
- char *name;
-{
- static char sbuf[256];
- TL *tlp;
- int n;
- char *p, keyname[3];
-
- if ((tlp = bsearch(name,
- list, sizeof(list) / sizeof(TL), sizeof(TL), lcmp)) == NULL) {
-#ifdef _AIX
- if (name[0] == 'k' &&
- name[1] == 'f' && (n = atoi(name + 2)) <= 36) {
- keyname[0] = 'k';
- keyname[1] = codes[n];
- keyname[2] = '\0';
-#else
- if (name[0] == 'k' &&
- name[1] == 'f' && (n = atoi(name + 2)) <= 63) {
- keyname[0] = n <= 10 ? 'k' : 'F';
- keyname[1] = codes[n];
- keyname[2] = '\0';
-#endif
- name = keyname;
- }
- } else
- name = tlp->termcap;
-
- p = sbuf;
-#ifdef _AIX
- return ((p = tgetstr(name, &p)) == NULL ? (char *)-1 : (strlcpy(sbuf, p, sizeof(sbuf)), sbuf));
-#else
- return (tgetstr(name, &p) == NULL ? (char *)-1 : sbuf);
-#endif
-}
-
-/*
- * tigetnum --
- *
- * PUBLIC: #ifndef HAVE_CURSES_TIGETSTR
- * PUBLIC: int tigetnum(char *);
- * PUBLIC: #endif
- */
-int
-tigetnum(name)
- char *name;
-{
- TL *tlp;
- int val;
-
- if ((tlp = bsearch(name,
- list, sizeof(list) / sizeof(TL), sizeof(TL), lcmp)) != NULL) {
- name = tlp->termcap;
- }
-
- return ((val = tgetnum(name)) == -1 ? -2 : val);
-}
-#endif /* !HAVE_CURSES_TIGETSTR */
diff --git a/usr.bin/vi/cl/cl_funcs.c b/usr.bin/vi/cl/cl_funcs.c
index ba9bf5918ed..04a6fcfa233 100644
--- a/usr.bin/vi/cl/cl_funcs.c
+++ b/usr.bin/vi/cl/cl_funcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl_funcs.c,v 1.14 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: cl_funcs.c,v 1.15 2014/11/06 10:48:52 bentley Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -604,14 +604,8 @@ cl_suspend(sp, allowedp)
/*
* Temporarily end the screen. System V introduced a semantic where
* endwin() could be restarted. We use it because restarting curses
- * from scratch often fails in System V. 4BSD curses didn't support
- * restarting after endwin(), so we have to do what clean up we can
- * without calling it.
+ * from scratch often fails in System V.
*/
-#ifdef HAVE_BSD_CURSES
- /* Save the terminal settings. */
- (void)tcgetattr(STDIN_FILENO, &t);
-#endif
/* Restore the cursor keys to normal mode. */
(void)keypad(stdscr, FALSE);
@@ -619,11 +613,8 @@ cl_suspend(sp, allowedp)
/* Restore the window name. */
(void)cl_rename(sp, NULL, 0);
-#ifdef HAVE_BSD_CURSES
- (void)cl_attr(sp, SA_ALTERNATE, 0);
-#else
(void)endwin();
-#endif
+
/*
* XXX
* Restore the original terminal settings. This is bad -- the
@@ -648,14 +639,6 @@ cl_suspend(sp, allowedp)
return (0);
}
-#ifdef HAVE_BSD_CURSES
- /* Restore terminal settings. */
- if (F_ISSET(clp, CL_STDIN_TTY))
- (void)tcsetattr(STDIN_FILENO, TCSASOFT | TCSADRAIN, &t);
-
- (void)cl_attr(sp, SA_ALTERNATE, 1);
-#endif
-
/* Set the window name. */
(void)cl_rename(sp, sp->frp->name, 1);
diff --git a/usr.bin/vi/cl/cl_term.c b/usr.bin/vi/cl/cl_term.c
index 69d1cfc6c9b..db64b6b68da 100644
--- a/usr.bin/vi/cl/cl_term.c
+++ b/usr.bin/vi/cl/cl_term.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cl_term.c,v 1.16 2009/10/27 23:59:47 deraadt Exp $ */
+/* $OpenBSD: cl_term.c,v 1.17 2014/11/06 10:48:52 bentley Exp $ */
/*-
* Copyright (c) 1993, 1994
@@ -447,20 +447,6 @@ noterm: if (row == 0)
return (0);
}
-#ifdef _USE_OLD_CURSES_
-/*
- * cl_putchar --
- * Function version of putchar, for tputs.
- *
- * PUBLIC: int cl_putchar(int);
- */
-void
-cl_putchar(ch)
- int ch;
-{
- (void)putchar(ch);
-}
-#else
/*
* cl_putchar --
* Function version of putchar, for tputs.
@@ -473,4 +459,3 @@ cl_putchar(ch)
{
return (putchar(ch));
}
-#endif
diff --git a/usr.bin/vi/include/cl_extern.h b/usr.bin/vi/include/cl_extern.h
index af565eda8b9..9a3f2850672 100644
--- a/usr.bin/vi/include/cl_extern.h
+++ b/usr.bin/vi/include/cl_extern.h
@@ -1,34 +1,5 @@
-/* $OpenBSD: cl_extern.h,v 1.6 2002/02/16 21:27:57 millert Exp $ */
+/* $OpenBSD: cl_extern.h,v 1.7 2014/11/06 10:48:52 bentley Exp $ */
-#ifndef HAVE_CURSES_ADDNSTR
-int addnstr(char *, int);
-#endif
-#ifndef HAVE_CURSES_BEEP
-void beep(void);
-#endif
-#ifndef HAVE_CURSES_FLASH
-void flash(void);
-#endif
-#ifndef HAVE_CURSES_IDLOK
-void idlok(WINDOW *, int);
-#endif
-#ifndef HAVE_CURSES_KEYPAD
-int keypad(void *, int);
-#endif
-#ifndef HAVE_CURSES_NEWTERM
-void *newterm(const char *, FILE *, FILE *);
-#endif
-#ifndef HAVE_CURSES_SETUPTERM
-void setupterm(char *, int, int *);
-#endif
-#ifdef HAVE_CURSES_TIGETSTR
-char *tigetstr();
-#else
-char *tigetstr(char *);
-#endif
-#ifndef HAVE_CURSES_TIGETSTR
-int tigetnum(char *);
-#endif
int cl_addstr(SCR *, const char *, size_t);
int cl_attr(SCR *, scr_attr_t, int);
int cl_baud(SCR *, u_long *);
@@ -55,8 +26,4 @@ int cl_fmap(SCR *, seq_t, CHAR_T *, size_t, CHAR_T *, size_t);
int cl_optchange(SCR *, int, char *, u_long *);
int cl_omesg(SCR *, CL_PRIVATE *, int);
int cl_ssize(SCR *, int, size_t *, size_t *, int *);
-#ifdef USE_OCURSES
-void cl_putchar(int);
-#else
int cl_putchar(int);
-#endif