summaryrefslogtreecommitdiff
path: root/bin/pdksh/vi.c
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-08-19 20:09:10 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-08-19 20:09:10 +0000
commite7e852656e3beb5f62f8c146ba24004cfda2cf88 (patch)
treeb312bc3e985b3f1cf19691c779e7870219573b6e /bin/pdksh/vi.c
parent1e9e82f84b5de8bcd110c41c780f476397c385d9 (diff)
update to pdksh-5.2.8
Diffstat (limited to 'bin/pdksh/vi.c')
-rw-r--r--bin/pdksh/vi.c59
1 files changed, 12 insertions, 47 deletions
diff --git a/bin/pdksh/vi.c b/bin/pdksh/vi.c
index c4b2aeeee33..4fc7b75c511 100644
--- a/bin/pdksh/vi.c
+++ b/bin/pdksh/vi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vi.c,v 1.1 1996/08/14 06:19:12 downsj Exp $ */
+/* $OpenBSD: vi.c,v 1.2 1996/08/19 20:09:04 downsj Exp $ */
/*
* vi command editing
@@ -57,7 +57,6 @@ static void rewindow ARGS((void));
static int newcol ARGS((int ch, int col));
static void display ARGS((char *wb1, char *wb2, int leftside));
static void ed_mov_opt ARGS((int col, char *wb));
-static int do_comment ARGS((void));
static int expand_word ARGS((int command));
static int complete_word ARGS((int command, int count));
static int print_expansions ARGS((struct edstate *e, int command));
@@ -94,7 +93,7 @@ const unsigned char classify[128] = {
/* 02 ^P ^Q ^R ^S ^T ^U ^V ^W */
C_, 0, C_|U_, 0, 0, 0, C_, 0,
/* 03 ^X ^Y ^Z ^[ ^\ ^] ^^ ^_ */
- C_, 0, 0, 0, 0, 0, 0, 0,
+ C_, 0, 0, C_|Z_, 0, 0, 0, 0,
/* 04 <space> ! " # $ % & ' */
M_, 0, 0, C_, M_, M_, 0, 0,
/* 05 ( ) * + , - . / */
@@ -1121,7 +1120,13 @@ vi_cmd(argcnt, cmd)
}
case '#':
- return do_comment();
+ {
+ int ret = x_do_comment(es->cbuf, es->cbufsize,
+ &es->linelen);
+ if (ret >= 0)
+ es->cursor = 0;
+ return ret;
+ }
case '=': /* at&t ksh */
case Ctrl('e'): /* Nonstandard vi/ksh */
@@ -1135,6 +1140,8 @@ vi_cmd(argcnt, cmd)
/* FALLTHROUGH */
case Ctrl('['): /* some annoying at&t ksh's */
+ if (!Flag(FVIESCCOMPLETE))
+ return -1;
case '\\': /* at&t ksh */
case Ctrl('f'): /* Nonstandard vi/ksh */
complete_word(1, argcnt);
@@ -1887,7 +1894,7 @@ display(wb1, wb2, leftside)
else
mc = ' ';
if (mc != morec) {
- ed_mov_opt(x_cols - 2, wb1);
+ ed_mov_opt(pwidth + winwidth + 1, wb1);
x_putc(mc);
cur_col++;
morec = mc;
@@ -1920,48 +1927,6 @@ ed_mov_opt(col, wb)
cur_col = col;
}
-/* Handle the commenting/uncommenting of a line */
-static int
-do_comment()
-{
- int i, j;
-
- if (es->linelen == 0)
- return 1; /* somewhat arbitrary - it's what at&t ksh does */
-
- /* Already commented? */
- if (es->cbuf[0] == '#') {
- int saw_nl = 0;
-
- for (j = 0, i = 1; i < es->linelen; i++) {
- if (!saw_nl || es->cbuf[i] != '#')
- es->cbuf[j++] = es->cbuf[i];
- saw_nl = es->cbuf[i] == '\n';
- }
- es->linelen = j;
- es->cursor = 0;
- return 0;
- } else {
- int n = 1;
-
- /* See if there's room for the #'s - 1 per \n */
- for (i = 0; i < es->linelen; i++)
- if (es->cbuf[i] == '\n')
- n++;
- if (es->linelen + n >= es->cbufsize)
- return -1;
- /* Now add them... */
- for (i = es->linelen, j = es->linelen + n; --i >= 0; ) {
- if (es->cbuf[i] == '\n')
- es->cbuf[--j] = '#';
- es->cbuf[--j] = es->cbuf[i];
- }
- es->cbuf[0] = '#';
- es->linelen += n;
- es->cursor = 0;
- return 1;
- }
-}
/* replace word with all expansions (ie, expand word*) */
static int