4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
22 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
27 * Copyright (c) 1997, by Sun Microsystems, Inc.
28 * All rights reserved.
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
35 #include <sys/types.h>
38 #define SizePrev(f, v) ((v) - Buf(f)) /* from beginning to v */
39 #define SizeNext(f, v) (BufSize(f) - SizePrev(f, v))
40 /* from v through end */
41 #define OffscreenRows(c) ((c)->drows - (c)->rows)
42 #define OffscreenCols(c) ((c)->dcols - (c)->cols)
44 /* _next_char move to next char with wrap to next line at end of line */
48 if (++X(f
) == Xmax(f
)) {
49 if (++Y(f
) == Ymax(f
)) {
52 return (E_REQUEST_DENIED
); /* at last char */
60 * _prev_char - move to previous char with
61 * wrap to previous line at beginning of line
70 return (E_REQUEST_DENIED
); /* at first char */
77 /* _next_line - move to beginning of next line */
81 if (++Y(f
) == Ymax(f
)) {
83 return (E_REQUEST_DENIED
); /* at last line */
89 /* _prev_line - move to beginning of previous line */
95 return (E_REQUEST_DENIED
); /* at first line */
101 /* _next_word - move to beginning of next word */
106 char * v
= LineBuf(c
, Y(f
)) + X(f
); /* position in buffer */
111 t
= _whsp_beg(v
, (int) SizeNext(c
, v
));
112 v
= _data_beg(t
, (int) SizeNext(c
, t
));
115 return (E_REQUEST_DENIED
); /* at last word */
117 if (OneRow(c
) && c
->dcols
!= c
->cols
) {
118 /* one row and field has grown */
121 while (*t
!= ' ' && *t
!= '\0') /* find end of word + 1 */
124 if (t
- (Buf(c
) + B(f
)) > c
->cols
) {
125 if (t
- v
> c
->cols
) {
126 /* word longer than visible field */
127 B(f
) = (int) (v
- Buf(c
));
129 B(f
) = (int) (t
- (Buf(c
) + c
->cols
));
132 X(f
) = (int) (v
- Buf(c
));
137 _adjust_cursor(f
, v
);
141 /* _prev_word - move to beginning of previous word */
146 char * v
= LineBuf(c
, Y(f
)) + X(f
); /* position in buffer */
151 t
= _data_end(Buf(c
), (int) SizePrev(c
, v
));
152 v
= _whsp_end(Buf(c
), (int) SizePrev(c
, t
));
155 return (E_REQUEST_DENIED
); /* at first word */
157 _adjust_cursor(f
, v
);
161 /* _beg_field - move to first non-pad char in field */
168 _adjust_cursor(f
, _data_beg(Buf(c
), BufSize(c
)));
172 /* _end_field - move after last non-pad char in field */
180 end
= _data_end(Buf(c
), BufSize(c
));
182 if (end
== Buf(c
) + BufSize(c
))
185 _adjust_cursor(f
, end
);
189 /* _beg_line - move to first non-pad char on current line */
196 _adjust_cursor(f
, _data_beg(LineBuf(c
, Y(f
)), Xmax(f
)));
200 /* _end_line - move after last non-pad char on current line */
208 end
= _data_end(LineBuf(c
, Y(f
)), Xmax(f
));
210 if (end
== LineBuf(c
, Y(f
)) + Xmax(f
))
213 _adjust_cursor(f
, end
);
217 /* _left_char - move left */
223 return (E_REQUEST_DENIED
); /* at left side */
228 /* _right_char - move right */
232 if (++X(f
) == Xmax(f
)) {
234 return (E_REQUEST_DENIED
); /* at right side */
239 /* _up_char - move up */
245 return (E_REQUEST_DENIED
); /* at top */
250 /* _down_char - move down */
254 if (++Y(f
) == Ymax(f
)) {
256 return (E_REQUEST_DENIED
); /* at bottom */
261 /* _scr_fline - scroll forward one line */
267 if (++T(f
) > OffscreenRows(c
)) {
269 return (E_REQUEST_DENIED
); /* at bottom */
276 /* _scr_bline - scroll backward one line */
284 return (E_REQUEST_DENIED
); /* at top */
291 /* _scr_fpage - scroll forward one page(C(f) -> rows) */
296 int m
= OffscreenRows(c
) - T(f
);
297 int n
= c
-> rows
< m
? c
-> rows
: m
;
305 return (E_REQUEST_DENIED
); /* at bottom */
308 /* _scr_bpage - scroll backward one page(C(f) -> rows) */
314 int n
= c
-> rows
< m
? c
-> rows
: m
;
322 return (E_REQUEST_DENIED
); /* at top */
325 /* _scr_fhpage - scroll forward one half page(C(f)->rows + 1)/2) */
330 int m
= OffscreenRows(c
) - T(f
);
331 int h
= (c
->rows
+ 1)/2;
332 int n
= h
< m
? h
: m
;
340 return (E_REQUEST_DENIED
); /* at bottom */
343 /* _scr_bhpage - scroll backward one half page(C(f)->rows + 1)/2) */
349 int h
= (c
->rows
+ 1)/2;
350 int n
= h
< m
? h
: m
;
358 return (E_REQUEST_DENIED
); /* at top */
361 /* _scr_fchar - horizontal scroll forward one char */
367 if (++B(f
) > OffscreenCols(c
)) {
369 return (E_REQUEST_DENIED
); /* at end */
375 /* _scr_bchar - horizontal scroll backward one char */
382 return (E_REQUEST_DENIED
); /* at beginning */
388 /* _scr_hfline - horizontal scroll forward one line(C(f)->cols) */
393 int m
= OffscreenCols(c
) - B(f
);
394 int n
= c
-> cols
< m
? c
-> cols
: m
;
401 return (E_REQUEST_DENIED
); /* at end */
404 /* _scr_hbline - horizontal scroll backward one line(C(f)->cols) */
410 int n
= c
-> cols
< m
? c
-> cols
: m
;
417 return (E_REQUEST_DENIED
); /* at end */
420 /* _scr_hfhalf - horizontal scroll forward one half line(C(f)->cols/2) */
425 int m
= OffscreenCols(c
) - B(f
);
426 int h
= (c
->cols
+ 1)/2;
427 int n
= h
< m
? h
: m
;
434 return (E_REQUEST_DENIED
); /* at end */
437 /* _scr_hbhalf - horizontal scroll backward one half line(C(f)->cols/2) */
443 int h
= (c
->cols
+ 1)/2;
444 int n
= h
< m
? h
: m
;
451 return (E_REQUEST_DENIED
); /* at top */