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_xchar.c,v 10.10 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>
26 #include "../common/common.h"
30 * v_xchar -- [buffer] [count]x
31 * Deletes the character(s) on which the cursor sits.
33 * PUBLIC: int v_xchar __P((SCR *, VICMD *));
36 v_xchar(SCR
*sp
, VICMD
*vp
)
41 if (db_eget(sp
, vp
->m_start
.lno
, NULL
, &len
, &isempty
)) {
47 nodel
: msgq(sp
, M_BERR
, "206|No characters to delete");
52 * Delete from the cursor toward the end of line, w/o moving the
56 * Note, "2x" at EOL isn't the same as "xx" because the left movement
57 * of the cursor as part of the 'x' command isn't taken into account.
58 * Historically correct.
60 if (F_ISSET(vp
, VC_C1SET
))
61 vp
->m_stop
.cno
+= vp
->count
- 1;
62 if (vp
->m_stop
.cno
>= len
- 1) {
63 vp
->m_stop
.cno
= len
- 1;
64 vp
->m_final
.cno
= vp
->m_start
.cno
? vp
->m_start
.cno
- 1 : 0;
66 vp
->m_final
.cno
= vp
->m_start
.cno
;
69 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
70 &vp
->m_start
, &vp
->m_stop
, 0))
72 return (del(sp
, &vp
->m_start
, &vp
->m_stop
, 0));
76 * v_Xchar -- [buffer] [count]X
77 * Deletes the character(s) immediately before the current cursor
80 * PUBLIC: int v_Xchar __P((SCR *, VICMD *));
83 v_Xchar(SCR
*sp
, VICMD
*vp
)
87 if (vp
->m_start
.cno
== 0) {
92 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
93 if (cnt
>= vp
->m_start
.cno
)
96 vp
->m_start
.cno
-= cnt
;
98 vp
->m_final
.cno
= vp
->m_start
.cno
;
101 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
102 &vp
->m_start
, &vp
->m_stop
, 0))
104 return (del(sp
, &vp
->m_start
, &vp
->m_stop
, 0));