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
36 * @(#)cmd7.c 8.1 (Berkeley) 6/6/93
37 * $FreeBSD: src/usr.bin/window/cmd7.c,v 1.2.6.2 2001/05/17 09:45:00 obrien Exp $
38 * $DragonFly: src/usr.bin/window/cmd7.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $
55 wwputs("New window size (lower right corner): ", cmdwin);
56 col = MIN(w->ww_w.r, wwncol) - 1;
57 row = MIN(w->ww_w.b, wwnrow) - 1;
58 wwadd(boxwin, framewin->ww_back);
60 wwbox(boxwin, w->ww_w.t - 1, w->ww_w.l - 1,
61 row - w->ww_w.t + 3, col - w->ww_w.l + 3);
62 wwsetcursor(row, col);
65 switch (getpos(&row, &col, w->ww_w.t, w->ww_w.l,
66 wwnrow - 1, wwncol - 1)) {
85 sizewin(w, row - w->ww_w.t + 1, col - w->ww_w.l + 1);
97 struct yb *yb_head, *yb_tail;
101 struct ww *w = selwin;
107 wwputs("Yank starting position: ", cmdwin);
112 wwsetcursor(row1, col1);
113 while (wwpeekc() < 0)
115 switch (getpos(&row1, &col1, w->ww_i.t, w->ww_i.l,
116 w->ww_i.b - 1, w->ww_i.r - 1)) {
128 wwputs("\nYank ending position: ", cmdwin);
132 wwsetcursor(row2, col2);
133 while (wwpeekc() < 0)
137 switch (getpos(&row2, &col2, w->ww_i.t, w->ww_i.l,
138 w->ww_i.b - 1, w->ww_i.r - 1)) {
140 yank_highlight(row1, col1, r, c);
145 yank_highlight(row1, col1, r, c);
146 yank_highlight(row1, col1, row2, col2);
152 if (row2 < row1 || row2 == row1 && col2 < col1) {
162 for (r = row1; r < row2; r++) {
163 yank_line(r, c, w->ww_b.r);
166 yank_line(r, c, col2);
167 yank_highlight(row1, col1, row2, col2);
169 wwputc('\n', cmdwin);
174 yank_highlight(row1, col1, row2, col2)
176 struct ww *w = selwin;
179 if ((wwavailmodes & WWM_REV) == 0)
181 if (row2 < row1 || row2 == row1 && col2 < col1) {
190 for (r = row1; r < row2; r++) {
191 yank_highlight_line(r, c, w->ww_b.r);
194 yank_highlight_line(r, c, col2);
197 yank_highlight_line(r, c, cend)
199 struct ww *w = selwin;
202 if (r < w->ww_i.t || r >= w->ww_i.b)
206 if (cend >= w->ww_i.r)
208 for (win = w->ww_win[r] + c; c < cend; c++, win++) {
210 if (wwsmap[r][c] == w->ww_index) {
213 else if (*win == WWM_REV)
215 wwns[r][c].c_m ^= WWM_REV;
216 wwtouched[r] |= WWU_TOUCHED;
225 for (yp = yb_head; yp; yp = yq) {
230 yb_head = yb_tail = 0;
233 yank_line(r, c, cend)
243 if ((yp = (struct yb *) malloc(sizeof *yp)) == 0)
246 nl = cend == selwin->ww_b.r;
247 bp = selwin->ww_buf[r];
248 for (cend--; cend >= c; cend--)
249 if (bp[cend].c_c != ' ')
251 yp->length = n = cend - c + 1;
254 yp->line = str_alloc(yp->length + 1);
255 for (bp += c, cp = yp->line; --n >= 0;)
261 yb_tail = yb_tail->link = yp;
263 yb_head = yb_tail = yp;
270 for (yp = yb_head; yp; yp = yp->link)
271 (void) write(selwin->ww_pty, yp->line, yp->length);