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_put.c,v 10.6 2001/06/25 15:19:34 skimo Exp $ (Berkeley) $Date: 2001/06/25 15:19:34 $";
16 #include <sys/types.h>
17 #include <sys/queue.h>
20 #include <bitstring.h>
24 #include "../common/common.h"
27 static void inc_buf
__P((SCR
*, VICMD
*));
31 * Insert the contents of the buffer before the cursor.
33 * PUBLIC: int v_Put __P((SCR *, VICMD *));
36 v_Put(SCR
*sp
, VICMD
*vp
)
40 if (F_ISSET(vp
, VC_ISDOT
))
45 * Historic vi did not support a count with the 'p' and 'P'
46 * commands. It's useful, so we do.
48 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
50 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
51 &vp
->m_start
, &vp
->m_final
, 0))
53 vp
->m_start
= vp
->m_final
;
62 * Insert the contents of the buffer after the cursor.
64 * PUBLIC: int v_put __P((SCR *, VICMD *));
67 v_put(SCR
*sp
, VICMD
*vp
)
71 if (F_ISSET(vp
, VC_ISDOT
))
76 * Historic vi did not support a count with the 'p' and 'P'
77 * commands. It's useful, so we do.
79 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
81 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
82 &vp
->m_start
, &vp
->m_final
, 1))
84 vp
->m_start
= vp
->m_final
;
93 * Historical whackadoo. The dot command `puts' the numbered buffer
94 * after the last one put. For example, `"4p.' would put buffer #4
95 * and buffer #5. If the user continued to enter '.', the #9 buffer
96 * would be repeatedly output. This was not documented, and is a bit
97 * tricky to reconstruct. Historical versions of vi also dropped the
98 * contents of the default buffer after each put, so after `"4p' the
99 * default buffer would be empty. This makes no sense to me, so we
100 * don't bother. Don't assume sequential order of numeric characters.
102 * And, if that weren't exciting enough, failed commands don't normally
103 * set the dot command. Well, boys and girls, an exception is that
104 * the buffer increment gets done regardless of the success of the put.
107 inc_buf(SCR
*sp
, VICMD
*vp
)
111 switch (vp
->buffer
) {
139 VIP(sp
)->sdot
.buffer
= vp
->buffer
= v
;