]>
git.saurik.com Git - apple/shell_cmds.git/blob - window/cmd7.c
5d176234bfd47da34ee0a8cfaf2d19f54bc34764
1 /* $NetBSD: cmd7.c,v 1.4 1997/11/21 08:35:54 lukem Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
8 * Edward Wang at The University of California, Berkeley.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #include <sys/cdefs.h>
42 static char sccsid
[] = "@(#)cmd7.c 8.1 (Berkeley) 6/6/93";
44 __RCSID("$NetBSD: cmd7.c,v 1.4 1997/11/21 08:35:54 lukem Exp $");
51 #include "window_string.h"
53 void unyank
__P((void));
54 void yank_highlight
__P((int, int, int, int));
55 void yank_highlight_line
__P((int, int, int));
56 void yank_line
__P((int, int, int));
68 wwputs("New window size (lower right corner): ", cmdwin
);
69 col
= MIN(w
->ww_w
.r
, wwncol
) - 1;
70 row
= MIN(w
->ww_w
.b
, wwnrow
) - 1;
71 wwadd(boxwin
, framewin
->ww_back
);
73 wwbox(boxwin
, w
->ww_w
.t
- 1, w
->ww_w
.l
- 1,
74 row
- w
->ww_w
.t
+ 3, col
- w
->ww_w
.l
+ 3);
75 wwsetcursor(row
, col
);
78 switch (getpos(&row
, &col
, w
->ww_w
.t
, w
->ww_w
.l
,
79 wwnrow
- 1, wwncol
- 1)) {
98 sizewin(w
, row
- w
->ww_w
.t
+ 1, col
- w
->ww_w
.l
+ 1);
110 struct yb
*yb_head
, *yb_tail
;
115 struct ww
*w
= selwin
;
121 wwputs("Yank starting position: ", cmdwin
);
126 wwsetcursor(row1
, col1
);
127 while (wwpeekc() < 0)
129 switch (getpos(&row1
, &col1
, w
->ww_i
.t
, w
->ww_i
.l
,
130 w
->ww_i
.b
- 1, w
->ww_i
.r
- 1)) {
142 wwputs("\nYank ending position: ", cmdwin
);
146 wwsetcursor(row2
, col2
);
147 while (wwpeekc() < 0)
151 switch (getpos(&row2
, &col2
, w
->ww_i
.t
, w
->ww_i
.l
,
152 w
->ww_i
.b
- 1, w
->ww_i
.r
- 1)) {
154 yank_highlight(row1
, col1
, r
, c
);
159 yank_highlight(row1
, col1
, r
, c
);
160 yank_highlight(row1
, col1
, row2
, col2
);
166 if (row2
< row1
|| (row2
== row1
&& col2
< col1
)) {
176 for (r
= row1
; r
< row2
; r
++) {
177 yank_line(r
, c
, w
->ww_b
.r
);
180 yank_line(r
, c
, col2
);
181 yank_highlight(row1
, col1
, row2
, col2
);
183 wwputc('\n', cmdwin
);
189 yank_highlight(row1
, col1
, row2
, col2
)
190 int row1
, col1
, row2
, col2
;
192 struct ww
*w
= selwin
;
195 if ((wwavailmodes
& WWM_REV
) == 0)
197 if (row2
< row1
|| (row2
== row1
&& col2
< col1
)) {
206 for (r
= row1
; r
< row2
; r
++) {
207 yank_highlight_line(r
, c
, w
->ww_b
.r
);
210 yank_highlight_line(r
, c
, col2
);
214 yank_highlight_line(r
, c
, cend
)
217 struct ww
*w
= selwin
;
220 if (r
< w
->ww_i
.t
|| r
>= w
->ww_i
.b
)
224 if (cend
>= w
->ww_i
.r
)
226 for (win
= w
->ww_win
[r
] + c
; c
< cend
; c
++, win
++) {
228 if (wwsmap
[r
][c
] == w
->ww_index
) {
231 else if (*win
== WWM_REV
)
233 wwns
[r
][c
].c_m
^= WWM_REV
;
234 wwtouched
[r
] |= WWU_TOUCHED
;
244 for (yp
= yb_head
; yp
; yp
= yq
) {
249 yb_head
= yb_tail
= 0;
253 yank_line(r
, c
, cend
)
264 if ((yp
= (struct yb
*) malloc(sizeof *yp
)) == 0)
267 nl
= cend
== selwin
->ww_b
.r
;
268 bp
= selwin
->ww_buf
[r
];
269 for (cend
--; cend
>= c
; cend
--)
270 if (bp
[cend
].c_c
!= ' ')
272 yp
->length
= n
= cend
- c
+ 1;
275 yp
->line
= str_alloc(yp
->length
+ 1);
276 for (bp
+= c
, cp
= yp
->line
; --n
>= 0;)
282 yb_tail
= yb_tail
->link
= yp
;
284 yb_head
= yb_tail
= yp
;
292 for (yp
= yb_head
; yp
; yp
= yp
->link
)
293 (void) write(selwin
->ww_pty
, yp
->line
, yp
->length
);