2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
5 * This code is derived from software contributed to Berkeley by
6 * Edward Wang at The University of California, Berkeley.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 static char sccsid[] = "@(#)cmd7.c 8.1 (Berkeley) 6/6/93";
39 static char rcsid[] = "@(#)$FreeBSD$";
51 register struct ww *w;
56 wwputs("New window size (lower right corner): ", cmdwin);
57 col = MIN(w->ww_w.r, wwncol) - 1;
58 row = MIN(w->ww_w.b, wwnrow) - 1;
59 wwadd(boxwin, framewin->ww_back);
61 wwbox(boxwin, w->ww_w.t - 1, w->ww_w.l - 1,
62 row - w->ww_w.t + 3, col - w->ww_w.l + 3);
63 wwsetcursor(row, col);
66 switch (getpos(&row, &col, w->ww_w.t, w->ww_w.l,
67 wwnrow - 1, wwncol - 1)) {
86 sizewin(w, row - w->ww_w.t + 1, col - w->ww_w.l + 1);
98 struct yb *yb_head, *yb_tail;
102 struct ww *w = selwin;
108 wwputs("Yank starting position: ", cmdwin);
113 wwsetcursor(row1, col1);
114 while (wwpeekc() < 0)
116 switch (getpos(&row1, &col1, w->ww_i.t, w->ww_i.l,
117 w->ww_i.b - 1, w->ww_i.r - 1)) {
129 wwputs("\nYank ending position: ", cmdwin);
133 wwsetcursor(row2, col2);
134 while (wwpeekc() < 0)
138 switch (getpos(&row2, &col2, w->ww_i.t, w->ww_i.l,
139 w->ww_i.b - 1, w->ww_i.r - 1)) {
141 yank_highlight(row1, col1, r, c);
146 yank_highlight(row1, col1, r, c);
147 yank_highlight(row1, col1, row2, col2);
153 if (row2 < row1 || row2 == row1 && col2 < col1) {
163 for (r = row1; r < row2; r++) {
164 yank_line(r, c, w->ww_b.r);
167 yank_line(r, c, col2);
168 yank_highlight(row1, col1, row2, col2);
170 wwputc('\n', cmdwin);
175 yank_highlight(row1, col1, row2, col2)
177 struct ww *w = selwin;
180 if ((wwavailmodes & WWM_REV) == 0)
182 if (row2 < row1 || row2 == row1 && col2 < col1) {
191 for (r = row1; r < row2; r++) {
192 yank_highlight_line(r, c, w->ww_b.r);
195 yank_highlight_line(r, c, col2);
198 yank_highlight_line(r, c, cend)
200 struct ww *w = selwin;
203 if (r < w->ww_i.t || r >= w->ww_i.b)
207 if (cend >= w->ww_i.r)
209 for (win = w->ww_win[r] + c; c < cend; c++, win++) {
211 if (wwsmap[r][c] == w->ww_index) {
214 else if (*win == WWM_REV)
216 wwns[r][c].c_m ^= WWM_REV;
217 wwtouched[r] |= WWU_TOUCHED;
226 for (yp = yb_head; yp; yp = yq) {
231 yb_head = yb_tail = 0;
234 yank_line(r, c, cend)
244 if ((yp = (struct yb *) malloc(sizeof *yp)) == 0)
247 nl = cend == selwin->ww_b.r;
248 bp = selwin->ww_buf[r];
249 for (cend--; cend >= c; cend--)
250 if (bp[cend].c_c != ' ')
252 yp->length = n = cend - c + 1;
255 yp->line = str_alloc(yp->length + 1);
256 for (bp += c, cp = yp->line; --n >= 0;)
262 yb_tail = yb_tail->link = yp;
264 yb_head = yb_tail = yp;
271 for (yp = yb_head; yp; yp = yp->link)
272 (void) write(selwin->ww_pty, yp->line, yp->length);