1 /* $NetBSD: v_xchar.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_xchar.c,v 10.10 2001/06/25 15:19:36 skimo Exp (Berkeley) Date: 2001/06/25 15:19:36 ";
19 __RCSID("$NetBSD: v_xchar.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>
30 #include "../common/common.h"
34 * v_xchar -- [buffer] [count]x
35 * Deletes the character(s) on which the cursor sits.
37 * PUBLIC: int v_xchar __P((SCR *, VICMD *));
40 v_xchar(SCR
*sp
, VICMD
*vp
)
45 if (db_eget(sp
, vp
->m_start
.lno
, NULL
, &len
, &isempty
)) {
51 nodel
: msgq(sp
, M_BERR
, "206|No characters to delete");
56 * Delete from the cursor toward the end of line, w/o moving the
60 * Note, "2x" at EOL isn't the same as "xx" because the left movement
61 * of the cursor as part of the 'x' command isn't taken into account.
62 * Historically correct.
64 if (F_ISSET(vp
, VC_C1SET
))
65 vp
->m_stop
.cno
+= vp
->count
- 1;
66 if (vp
->m_stop
.cno
>= len
- 1) {
67 vp
->m_stop
.cno
= len
- 1;
68 vp
->m_final
.cno
= vp
->m_start
.cno
? vp
->m_start
.cno
- 1 : 0;
70 vp
->m_final
.cno
= vp
->m_start
.cno
;
73 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
74 &vp
->m_start
, &vp
->m_stop
, 0))
76 return (del(sp
, &vp
->m_start
, &vp
->m_stop
, 0));
80 * v_Xchar -- [buffer] [count]X
81 * Deletes the character(s) immediately before the current cursor
84 * PUBLIC: int v_Xchar __P((SCR *, VICMD *));
87 v_Xchar(SCR
*sp
, VICMD
*vp
)
91 if (vp
->m_start
.cno
== 0) {
96 cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1;
97 if (cnt
>= vp
->m_start
.cno
)
100 vp
->m_start
.cno
-= cnt
;
102 vp
->m_final
.cno
= vp
->m_start
.cno
;
105 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
106 &vp
->m_start
, &vp
->m_stop
, 0))
108 return (del(sp
, &vp
->m_start
, &vp
->m_stop
, 0));