2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1992, 1993, 1994, 1995, 1996
5 * Keith Bostic. All rights reserved.
7 * See the LICENSE file for redistribution information.
13 static const char sccsid
[] = "$Id: v_xchar.c,v 10.10 2001/06/25 15:19:36 skimo Exp $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
24 #include "../common/common.h"
28 * v_xchar -- [buffer] [count]x
29 * Deletes the character(s) on which the cursor sits.
31 * PUBLIC: int v_xchar(SCR *, VICMD *);
34 v_xchar(SCR
*sp
, VICMD
*vp
)
39 if (db_eget(sp
, vp
->m_start
.lno
, NULL
, &len
, &isempty
)) {
45 nodel
: msgq(sp
, M_BERR
, "206|No characters to delete");
50 * Delete from the cursor toward the end of line, w/o moving the
54 * Note, "2x" at EOL isn't the same as "xx" because the left movement
55 * of the cursor as part of the 'x' command isn't taken into account.
56 * Historically correct.
58 if (F_ISSET(vp
, VC_C1SET
))
59 vp
->m_stop
.cno
+= vp
->count
- 1;
60 if (vp
->m_stop
.cno
>= len
- 1) {
61 vp
->m_stop
.cno
= len
- 1;
62 vp
->m_final
.cno
= vp
->m_start
.cno
? vp
->m_start
.cno
- 1 : 0;
64 vp
->m_final
.cno
= vp
->m_start
.cno
;
67 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
68 &vp
->m_start
, &vp
->m_stop
, 0))
70 return (del(sp
, &vp
->m_start
, &vp
->m_stop
, 0));
74 * v_Xchar -- [buffer] [count]X
75 * Deletes the character(s) immediately before the current cursor
78 * PUBLIC: int v_Xchar(SCR *, VICMD *);
81 v_Xchar(SCR
*sp
, VICMD
*vp
)
85 if (vp
->m_start
.cno
== 0) {
90 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
91 if (cnt
>= vp
->m_start
.cno
)
94 vp
->m_start
.cno
-= cnt
;
96 vp
->m_final
.cno
= vp
->m_start
.cno
;
99 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
100 &vp
->m_start
, &vp
->m_stop
, 0))
102 return (del(sp
, &vp
->m_start
, &vp
->m_stop
, 0));