1 /* $NetBSD: v_util.c,v 1.2 2013/11/22 15:52:06 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.
14 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 ";
17 #include <sys/types.h>
18 #include <sys/queue.h>
21 #include <bitstring.h>
29 #include "../common/common.h"
34 * Vi end-of-file error.
36 * PUBLIC: void v_eof __P((SCR *, MARK *));
39 v_eof(SCR
*sp
, MARK
*mp
)
44 v_emsg(sp
, NULL
, VIM_EOF
);
46 if (db_last(sp
, &lno
))
49 v_emsg(sp
, NULL
, VIM_EOF
);
51 msgq(sp
, M_BERR
, "195|Movement past the end-of-file");
57 * Vi end-of-line error.
59 * PUBLIC: void v_eol __P((SCR *, MARK *));
62 v_eol(SCR
*sp
, MARK
*mp
)
67 v_emsg(sp
, NULL
, VIM_EOL
);
69 if (db_get(sp
, mp
->lno
, DBG_FATAL
, NULL
, &len
))
71 if (mp
->cno
== len
- 1)
72 v_emsg(sp
, NULL
, VIM_EOL
);
74 msgq(sp
, M_BERR
, "196|Movement past the end-of-line");
80 * Vi no cursor movement error.
82 * PUBLIC: void v_nomove __P((SCR *));
87 msgq(sp
, M_BERR
, "197|No cursor movement made");
92 * Vi start-of-file error.
94 * PUBLIC: void v_sof __P((SCR *, MARK *));
97 v_sof(SCR
*sp
, MARK
*mp
)
99 if (mp
== NULL
|| mp
->lno
== 1)
100 msgq(sp
, M_BERR
, "198|Already at the beginning of the file");
102 msgq(sp
, M_BERR
, "199|Movement past the beginning of the file");
107 * Vi start-of-line error.
109 * PUBLIC: void v_sol __P((SCR *));
114 msgq(sp
, M_BERR
, "200|Already in the first column");
119 * Return if the line contains nothing but white-space characters.
121 * PUBLIC: int v_isempty __P((CHAR_T *, size_t));
124 v_isempty(CHAR_T
*p
, size_t len
)
127 if (!ISBLANK((UCHAR_T
)*p
))
134 * Display a few common vi messages.
136 * PUBLIC: void v_emsg __P((SCR *, const char *, vim_t));
139 v_emsg(SCR
*sp
, const char *p
, vim_t which
)
144 "201|Buffers should be specified before the command");
147 msgq(sp
, M_BERR
, "209|The file is empty");
150 msgq(sp
, M_BERR
, "202|Already at end-of-file");
153 msgq(sp
, M_BERR
, "203|Already at end-of-line");
158 which
== VIM_NOCOM_B
? M_BERR
: M_ERR
,
159 "204|%s isn't a vi command", p
);
162 msgq(sp
, M_ERR
, "Window resize interrupted text input mode");
165 msgq(sp
, M_ERR
, "205|Usage: %s", p
);