1 /* $NetBSD: v_util.c,v 1.1.1.2 2008/05/18 14:31:47 aymeric Exp $ */
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1992, 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
9 * See the LICENSE file for redistribution information.
15 static const char sccsid
[] = "Id: v_util.c,v 10.14 2001/06/25 15:19:36 skimo Exp (Berkeley) Date: 2001/06/25 15:19:36";
18 #include <sys/types.h>
19 #include <sys/queue.h>
22 #include <bitstring.h>
30 #include "../common/common.h"
35 * Vi end-of-file error.
37 * PUBLIC: void v_eof __P((SCR *, MARK *));
40 v_eof(SCR
*sp
, MARK
*mp
)
45 v_emsg(sp
, NULL
, VIM_EOF
);
47 if (db_last(sp
, &lno
))
50 v_emsg(sp
, NULL
, VIM_EOF
);
52 msgq(sp
, M_BERR
, "195|Movement past the end-of-file");
58 * Vi end-of-line error.
60 * PUBLIC: void v_eol __P((SCR *, MARK *));
63 v_eol(SCR
*sp
, MARK
*mp
)
68 v_emsg(sp
, NULL
, VIM_EOL
);
70 if (db_get(sp
, mp
->lno
, DBG_FATAL
, NULL
, &len
))
72 if (mp
->cno
== len
- 1)
73 v_emsg(sp
, NULL
, VIM_EOL
);
75 msgq(sp
, M_BERR
, "196|Movement past the end-of-line");
81 * Vi no cursor movement error.
83 * PUBLIC: void v_nomove __P((SCR *));
88 msgq(sp
, M_BERR
, "197|No cursor movement made");
93 * Vi start-of-file error.
95 * PUBLIC: void v_sof __P((SCR *, MARK *));
98 v_sof(SCR
*sp
, MARK
*mp
)
100 if (mp
== NULL
|| mp
->lno
== 1)
101 msgq(sp
, M_BERR
, "198|Already at the beginning of the file");
103 msgq(sp
, M_BERR
, "199|Movement past the beginning of the file");
108 * Vi start-of-line error.
110 * PUBLIC: void v_sol __P((SCR *));
115 msgq(sp
, M_BERR
, "200|Already in the first column");
120 * Return if the line contains nothing but white-space characters.
122 * PUBLIC: int v_isempty __P((CHAR_T *, size_t));
125 v_isempty(CHAR_T
*p
, size_t len
)
135 * Display a few common vi messages.
137 * PUBLIC: void v_emsg __P((SCR *, const char *, vim_t));
140 v_emsg(SCR
*sp
, const char *p
, vim_t which
)
145 "201|Buffers should be specified before the command");
148 msgq(sp
, M_BERR
, "209|The file is empty");
151 msgq(sp
, M_BERR
, "202|Already at end-of-file");
154 msgq(sp
, M_BERR
, "203|Already at end-of-line");
159 which
== VIM_NOCOM_B
? M_BERR
: M_ERR
,
160 "204|%s isn't a vi command", p
);
163 msgq(sp
, M_ERR
, "Window resize interrupted text input mode");
166 msgq(sp
, M_ERR
, "205|Usage: %s", p
);