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.5 1996/03/06 19:54:29 bostic Exp $ (Berkeley) $Date: 1996/03/06 19:54:29 $";
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 *));
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 *));
75 if (F_ISSET(vp
, VC_ISDOT
))
80 * Historic vi did not support a count with the 'p' and 'P'
81 * commands. It's useful, so we do.
83 for (cnt
= F_ISSET(vp
, VC_C1SET
) ? vp
->count
: 1; cnt
--;) {
85 F_ISSET(vp
, VC_BUFFER
) ? &vp
->buffer
: NULL
,
86 &vp
->m_start
, &vp
->m_final
, 1))
88 vp
->m_start
= vp
->m_final
;
97 * Historical whackadoo. The dot command `puts' the numbered buffer
98 * after the last one put. For example, `"4p.' would put buffer #4
99 * and buffer #5. If the user continued to enter '.', the #9 buffer
100 * would be repeatedly output. This was not documented, and is a bit
101 * tricky to reconstruct. Historical versions of vi also dropped the
102 * contents of the default buffer after each put, so after `"4p' the
103 * default buffer would be empty. This makes no sense to me, so we
104 * don't bother. Don't assume sequential order of numeric characters.
106 * And, if that weren't exciting enough, failed commands don't normally
107 * set the dot command. Well, boys and girls, an exception is that
108 * the buffer increment gets done regardless of the success of the put.
117 switch (vp
->buffer
) {
145 VIP(sp
)->sdot
.buffer
= vp
->buffer
= v
;