Upgrade to 1.11b.
[unix-history] / usr.bin / vi / svi / svi_confirm.c
CommitLineData
1e64b3ba 1/*-
395c4480 2 * Copyright (c) 1992, 1993, 1994
1e64b3ba
JH
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
395c4480 35static char sccsid[] = "@(#)svi_confirm.c 8.6 (Berkeley) 3/8/94";
1e64b3ba
JH
36#endif /* not lint */
37
38#include <sys/types.h>
395c4480
AM
39#include <queue.h>
40#include <sys/time.h>
1e64b3ba 41
395c4480 42#include <bitstring.h>
1e64b3ba 43#include <curses.h>
395c4480
AM
44#include <limits.h>
45#include <signal.h>
46#include <stdio.h>
47#include <termios.h>
48
49#include <db.h>
50#include <regex.h>
1e64b3ba
JH
51
52#include "vi.h"
53#include "svi_screen.h"
54
55enum confirm
56svi_confirm(sp, ep, fp, tp)
57 SCR *sp;
58 EXF *ep;
59 MARK *fp, *tp;
60{
61 CH ikey;
62 size_t oldy, oldx;
63
64 /*
65 * Refresh the cursor first -- this means that we won't have to
66 * set S_UPDATE_MODE to keep refresh from erasing the mode line
67 * or SVI_CUR_INVALID because we sneaked the cursor off somewhere
68 * else.
69 */
70 sp->lno = fp->lno;
71 sp->cno = fp->cno;
72 if (svi_paint(sp, ep))
73 return (CONF_QUIT);
74
75 getyx(stdscr, oldy, oldx);
76 MOVE(sp, INFOLINE(sp), 0);
77 clrtoeol();
78 ADDNSTR(CONFSTRING, sizeof(CONFSTRING) - 1);
79 MOVEA(sp, oldy, oldx);
80 refresh();
81
82 if (term_key(sp, &ikey, 0) != INP_OK)
83 return (CONF_QUIT);
84 switch (ikey.ch) {
85 case YES_CH:
86 return (CONF_YES);
87 case QUIT_CH:
88 return (CONF_QUIT);
89 default:
90 case NO_CH:
91 return (CONF_NO);
92 }
93 /* NOTREACHED */
94}