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_put.c,v 10.6 2001/06/25 15:19:34 skimo Exp (Berkeley) Date: 2001/06/25 15:19:34";
18 #include <sys/types.h>
19 #include <sys/queue.h>
22 #include <bitstring.h>
26 #include "../common/common.h"
29 static void inc_buf
__P((SCR
*, VICMD
*));
33 * Insert the contents of the buffer before the cursor.
35 * PUBLIC: int v_Put __P((SCR *, VICMD *));
38 v_Put(SCR
*sp
, VICMD
*vp
)
42 if (F_ISSET(vp
, VC_ISDOT
))
47 * Historic vi did not support a count with the 'p' and 'P'
48 * commands. It's useful, so we do.
50 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
52 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
53 &vp
->m_start
, &vp
->m_final
, 0))
55 vp
->m_start
= vp
->m_final
;
64 * Insert the contents of the buffer after the cursor.
66 * PUBLIC: int v_put __P((SCR *, VICMD *));
69 v_put(SCR
*sp
, VICMD
*vp
)
73 if (F_ISSET(vp
, VC_ISDOT
))
78 * Historic vi did not support a count with the 'p' and 'P'
79 * commands. It's useful, so we do.
81 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
83 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
84 &vp
->m_start
, &vp
->m_final
, 1))
86 vp
->m_start
= vp
->m_final
;
95 * Historical whackadoo. The dot command `puts' the numbered buffer
96 * after the last one put. For example, `"4p.' would put buffer #4
97 * and buffer #5. If the user continued to enter '.', the #9 buffer
98 * would be repeatedly output. This was not documented, and is a bit
99 * tricky to reconstruct. Historical versions of vi also dropped the
100 * contents of the default buffer after each put, so after `"4p' the
101 * default buffer would be empty. This makes no sense to me, so we
102 * don't bother. Don't assume sequential order of numeric characters.
104 * And, if that weren't exciting enough, failed commands don't normally
105 * set the dot command. Well, boys and girls, an exception is that
106 * the buffer increment gets done regardless of the success of the put.
109 inc_buf(SCR
*sp
, VICMD
*vp
)
113 switch (vp
->buffer
) {
141 VIP(sp
)->sdot
.buffer
= vp
->buffer
= v
;