1 /* $NetBSD: v_util.c,v 1.3 2014/01/26 21:43:45 christos Exp $ */
3 * Copyright (c) 1992, 1993, 1994
4 * The Regents of the University of California. All rights reserved.
5 * Copyright (c) 1992, 1993, 1994, 1995, 1996
6 * Keith Bostic. All rights reserved.
8 * See the LICENSE file for redistribution information.
13 #include <sys/cdefs.h>
16 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 ";
19 __RCSID("$NetBSD: v_util.c,v 1.3 2014/01/26 21:43:45 christos Exp $");
22 #include <sys/types.h>
23 #include <sys/queue.h>
26 #include <bitstring.h>
34 #include "../common/common.h"
39 * Vi end-of-file error.
41 * PUBLIC: void v_eof __P((SCR *, MARK *));
44 v_eof(SCR
*sp
, MARK
*mp
)
49 v_emsg(sp
, NULL
, VIM_EOF
);
51 if (db_last(sp
, &lno
))
54 v_emsg(sp
, NULL
, VIM_EOF
);
56 msgq(sp
, M_BERR
, "195|Movement past the end-of-file");
62 * Vi end-of-line error.
64 * PUBLIC: void v_eol __P((SCR *, MARK *));
67 v_eol(SCR
*sp
, MARK
*mp
)
72 v_emsg(sp
, NULL
, VIM_EOL
);
74 if (db_get(sp
, mp
->lno
, DBG_FATAL
, NULL
, &len
))
76 if (mp
->cno
== len
- 1)
77 v_emsg(sp
, NULL
, VIM_EOL
);
79 msgq(sp
, M_BERR
, "196|Movement past the end-of-line");
85 * Vi no cursor movement error.
87 * PUBLIC: void v_nomove __P((SCR *));
92 msgq(sp
, M_BERR
, "197|No cursor movement made");
97 * Vi start-of-file error.
99 * PUBLIC: void v_sof __P((SCR *, MARK *));
102 v_sof(SCR
*sp
, MARK
*mp
)
104 if (mp
== NULL
|| mp
->lno
== 1)
105 msgq(sp
, M_BERR
, "198|Already at the beginning of the file");
107 msgq(sp
, M_BERR
, "199|Movement past the beginning of the file");
112 * Vi start-of-line error.
114 * PUBLIC: void v_sol __P((SCR *));
119 msgq(sp
, M_BERR
, "200|Already in the first column");
124 * Return if the line contains nothing but white-space characters.
126 * PUBLIC: int v_isempty __P((CHAR_T *, size_t));
129 v_isempty(CHAR_T
*p
, size_t len
)
132 if (!ISBLANK((UCHAR_T
)*p
))
139 * Display a few common vi messages.
141 * PUBLIC: void v_emsg __P((SCR *, const char *, vim_t));
144 v_emsg(SCR
*sp
, const char *p
, vim_t which
)
149 "201|Buffers should be specified before the command");
152 msgq(sp
, M_BERR
, "209|The file is empty");
155 msgq(sp
, M_BERR
, "202|Already at end-of-file");
158 msgq(sp
, M_BERR
, "203|Already at end-of-line");
163 which
== VIM_NOCOM_B
? M_BERR
: M_ERR
,
164 "204|%s isn't a vi command", p
);
167 msgq(sp
, M_ERR
, "Window resize interrupted text input mode");
170 msgq(sp
, M_ERR
, "205|Usage: %s", p
);