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";
52 register struct ww *w;
57 wwputs("New window size (lower right corner): ", cmdwin);
58 col = MIN(w->ww_w.r, wwncol) - 1;
59 row = MIN(w->ww_w.b, wwnrow) - 1;
60 wwadd(boxwin, framewin->ww_back);
62 wwbox(boxwin, w->ww_w.t - 1, w->ww_w.l - 1,
63 row - w->ww_w.t + 3, col - w->ww_w.l + 3);
64 wwsetcursor(row, col);
67 switch (getpos(&row, &col, w->ww_w.t, w->ww_w.l,
68 wwnrow - 1, wwncol - 1)) {
87 sizewin(w, row - w->ww_w.t + 1, col - w->ww_w.l + 1);
99 struct yb *yb_head, *yb_tail;
103 struct ww *w = selwin;
109 wwputs("Yank starting position: ", cmdwin);
114 wwsetcursor(row1, col1);
115 while (wwpeekc() < 0)
117 switch (getpos(&row1, &col1, w->ww_i.t, w->ww_i.l,
118 w->ww_i.b - 1, w->ww_i.r - 1)) {
130 wwputs("\nYank ending position: ", cmdwin);
134 wwsetcursor(row2, col2);
135 while (wwpeekc() < 0)
139 switch (getpos(&row2, &col2, w->ww_i.t, w->ww_i.l,
140 w->ww_i.b - 1, w->ww_i.r - 1)) {
142 yank_highlight(row1, col1, r, c);
147 yank_highlight(row1, col1, r, c);
148 yank_highlight(row1, col1, row2, col2);
154 if (row2 < row1 || row2 == row1 && col2 < col1) {
164 for (r = row1; r < row2; r++) {
165 yank_line(r, c, w->ww_b.r);
168 yank_line(r, c, col2);
169 yank_highlight(row1, col1, row2, col2);
171 wwputc('\n', cmdwin);
176 yank_highlight(row1, col1, row2, col2)
178 struct ww *w = selwin;
181 if ((wwavailmodes & WWM_REV) == 0)
183 if (row2 < row1 || row2 == row1 && col2 < col1) {
192 for (r = row1; r < row2; r++) {
193 yank_highlight_line(r, c, w->ww_b.r);
196 yank_highlight_line(r, c, col2);
199 yank_highlight_line(r, c, cend)
201 struct ww *w = selwin;
204 if (r < w->ww_i.t || r >= w->ww_i.b)
208 if (cend >= w->ww_i.r)
210 for (win = w->ww_win[r] + c; c < cend; c++, win++) {
212 if (wwsmap[r][c] == w->ww_index) {
215 else if (*win == WWM_REV)
217 wwns[r][c].c_m ^= WWM_REV;
218 wwtouched[r] |= WWU_TOUCHED;
227 for (yp = yb_head; yp; yp = yq) {
232 yb_head = yb_tail = 0;
235 yank_line(r, c, cend)
245 if ((yp = (struct yb *) malloc(sizeof *yp)) == 0)
248 nl = cend == selwin->ww_b.r;
249 bp = selwin->ww_buf[r];
250 for (cend--; cend >= c; cend--)
251 if (bp[cend].c_c != ' ')
253 yp->length = n = cend - c + 1;
256 yp->line = str_alloc(yp->length + 1);
257 for (bp += c, cp = yp->line; --n >= 0;)
263 yb_tail = yb_tail->link = yp;
265 yb_head = yb_tail = yp;
272 for (yp = yb_head; yp; yp = yp->link)
273 (void) write(selwin->ww_pty, yp->line, yp->length);