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.
12 #include <sys/types.h>
13 #include <sys/queue.h>
16 #include <bitstring.h>
20 #include "../common/common.h"
23 static void inc_buf(SCR *, VICMD *);
27 * Insert the contents of the buffer before the cursor.
29 * PUBLIC: int v_Put(SCR *, VICMD *);
32 v_Put(SCR *sp, VICMD *vp)
36 if (F_ISSET(vp, VC_ISDOT))
41 * Historic vi did not support a count with the 'p' and 'P'
42 * commands. It's useful, so we do.
44 for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
46 F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
47 &vp->m_start, &vp->m_final, 0))
49 vp->m_start = vp->m_final;
58 * Insert the contents of the buffer after the cursor.
60 * PUBLIC: int v_put(SCR *, VICMD *);
63 v_put(SCR *sp, VICMD *vp)
67 if (F_ISSET(vp, VC_ISDOT))
72 * Historic vi did not support a count with the 'p' and 'P'
73 * commands. It's useful, so we do.
75 for (cnt = F_ISSET(vp, VC_C1SET) ? vp->count : 1; cnt--;) {
77 F_ISSET(vp, VC_BUFFER) ? &vp->buffer : NULL,
78 &vp->m_start, &vp->m_final, 1))
80 vp->m_start = vp->m_final;
89 * Historical whackadoo. The dot command `puts' the numbered buffer
90 * after the last one put. For example, `"4p.' would put buffer #4
91 * and buffer #5. If the user continued to enter '.', the #9 buffer
92 * would be repeatedly output. This was not documented, and is a bit
93 * tricky to reconstruct. Historical versions of vi also dropped the
94 * contents of the default buffer after each put, so after `"4p' the
95 * default buffer would be empty. This makes no sense to me, so we
96 * don't bother. Don't assume sequential order of numeric characters.
98 * And, if that weren't exciting enough, failed commands don't normally
99 * set the dot command. Well, boys and girls, an exception is that
100 * the buffer increment gets done regardless of the success of the put.
103 inc_buf(SCR *sp, VICMD *vp)
107 switch (vp->buffer) {
135 VIP(sp)->sdot.buffer = vp->buffer = v;