1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
23*0Sstevel@tonic-gate /* All Rights Reserved */
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate
26*0Sstevel@tonic-gate /*
27*0Sstevel@tonic-gate * Copyright (c) 1997, by Sun Microsystems, Inc.
28*0Sstevel@tonic-gate * All rights reserved.
29*0Sstevel@tonic-gate */
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate /*LINTLIBRARY*/
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate #include <sys/types.h>
36*0Sstevel@tonic-gate #include "utility.h"
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate #define SizePrev(f, v) ((v) - Buf(f)) /* from beginning to v */
39*0Sstevel@tonic-gate #define SizeNext(f, v) (BufSize(f) - SizePrev(f, v))
40*0Sstevel@tonic-gate /* from v through end */
41*0Sstevel@tonic-gate #define OffscreenRows(c) ((c)->drows - (c)->rows)
42*0Sstevel@tonic-gate #define OffscreenCols(c) ((c)->dcols - (c)->cols)
43*0Sstevel@tonic-gate
44*0Sstevel@tonic-gate /* _next_char move to next char with wrap to next line at end of line */
45*0Sstevel@tonic-gate int
_next_char(FORM * f)46*0Sstevel@tonic-gate _next_char(FORM *f)
47*0Sstevel@tonic-gate {
48*0Sstevel@tonic-gate if (++X(f) == Xmax(f)) {
49*0Sstevel@tonic-gate if (++Y(f) == Ymax(f)) {
50*0Sstevel@tonic-gate --X(f);
51*0Sstevel@tonic-gate --Y(f);
52*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at last char */
53*0Sstevel@tonic-gate }
54*0Sstevel@tonic-gate X(f) = 0;
55*0Sstevel@tonic-gate }
56*0Sstevel@tonic-gate return (E_OK);
57*0Sstevel@tonic-gate }
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gate /*
60*0Sstevel@tonic-gate * _prev_char - move to previous char with
61*0Sstevel@tonic-gate * wrap to previous line at beginning of line
62*0Sstevel@tonic-gate */
63*0Sstevel@tonic-gate int
_prev_char(FORM * f)64*0Sstevel@tonic-gate _prev_char(FORM *f)
65*0Sstevel@tonic-gate {
66*0Sstevel@tonic-gate if (--X(f) < 0) {
67*0Sstevel@tonic-gate if (--Y(f) < 0) {
68*0Sstevel@tonic-gate ++X(f);
69*0Sstevel@tonic-gate ++Y(f);
70*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at first char */
71*0Sstevel@tonic-gate }
72*0Sstevel@tonic-gate X(f) = Xmax(f) - 1;
73*0Sstevel@tonic-gate }
74*0Sstevel@tonic-gate return (E_OK);
75*0Sstevel@tonic-gate }
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate /* _next_line - move to beginning of next line */
78*0Sstevel@tonic-gate int
_next_line(FORM * f)79*0Sstevel@tonic-gate _next_line(FORM *f)
80*0Sstevel@tonic-gate {
81*0Sstevel@tonic-gate if (++Y(f) == Ymax(f)) {
82*0Sstevel@tonic-gate --Y(f);
83*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at last line */
84*0Sstevel@tonic-gate }
85*0Sstevel@tonic-gate X(f) = 0;
86*0Sstevel@tonic-gate return (E_OK);
87*0Sstevel@tonic-gate }
88*0Sstevel@tonic-gate
89*0Sstevel@tonic-gate /* _prev_line - move to beginning of previous line */
90*0Sstevel@tonic-gate int
_prev_line(FORM * f)91*0Sstevel@tonic-gate _prev_line(FORM *f)
92*0Sstevel@tonic-gate {
93*0Sstevel@tonic-gate if (--Y(f) < 0) {
94*0Sstevel@tonic-gate ++Y(f);
95*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at first line */
96*0Sstevel@tonic-gate }
97*0Sstevel@tonic-gate X(f) = 0;
98*0Sstevel@tonic-gate return (E_OK);
99*0Sstevel@tonic-gate }
100*0Sstevel@tonic-gate
101*0Sstevel@tonic-gate /* _next_word - move to beginning of next word */
102*0Sstevel@tonic-gate int
_next_word(FORM * f)103*0Sstevel@tonic-gate _next_word(FORM *f)
104*0Sstevel@tonic-gate {
105*0Sstevel@tonic-gate FIELD * c = C(f);
106*0Sstevel@tonic-gate char * v = LineBuf(c, Y(f)) + X(f); /* position in buffer */
107*0Sstevel@tonic-gate char * t;
108*0Sstevel@tonic-gate
109*0Sstevel@tonic-gate _sync_buffer(f);
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate t = _whsp_beg(v, (int) SizeNext(c, v));
112*0Sstevel@tonic-gate v = _data_beg(t, (int) SizeNext(c, t));
113*0Sstevel@tonic-gate
114*0Sstevel@tonic-gate if (v == t)
115*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at last word */
116*0Sstevel@tonic-gate
117*0Sstevel@tonic-gate if (OneRow(c) && c->dcols != c->cols) {
118*0Sstevel@tonic-gate /* one row and field has grown */
119*0Sstevel@tonic-gate t = v;
120*0Sstevel@tonic-gate
121*0Sstevel@tonic-gate while (*t != ' ' && *t != '\0') /* find end of word + 1 */
122*0Sstevel@tonic-gate t++;
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate if (t - (Buf(c) + B(f)) > c->cols) {
125*0Sstevel@tonic-gate if (t - v > c->cols) {
126*0Sstevel@tonic-gate /* word longer than visible field */
127*0Sstevel@tonic-gate B(f) = (int) (v - Buf(c));
128*0Sstevel@tonic-gate } else {
129*0Sstevel@tonic-gate B(f) = (int) (t - (Buf(c) + c->cols));
130*0Sstevel@tonic-gate }
131*0Sstevel@tonic-gate
132*0Sstevel@tonic-gate X(f) = (int) (v - Buf(c));
133*0Sstevel@tonic-gate return (E_OK);
134*0Sstevel@tonic-gate }
135*0Sstevel@tonic-gate }
136*0Sstevel@tonic-gate
137*0Sstevel@tonic-gate _adjust_cursor(f, v);
138*0Sstevel@tonic-gate return (E_OK);
139*0Sstevel@tonic-gate }
140*0Sstevel@tonic-gate
141*0Sstevel@tonic-gate /* _prev_word - move to beginning of previous word */
142*0Sstevel@tonic-gate int
_prev_word(FORM * f)143*0Sstevel@tonic-gate _prev_word(FORM *f)
144*0Sstevel@tonic-gate {
145*0Sstevel@tonic-gate FIELD * c = C(f);
146*0Sstevel@tonic-gate char * v = LineBuf(c, Y(f)) + X(f); /* position in buffer */
147*0Sstevel@tonic-gate char * t;
148*0Sstevel@tonic-gate
149*0Sstevel@tonic-gate _sync_buffer(f);
150*0Sstevel@tonic-gate
151*0Sstevel@tonic-gate t = _data_end(Buf(c), (int) SizePrev(c, v));
152*0Sstevel@tonic-gate v = _whsp_end(Buf(c), (int) SizePrev(c, t));
153*0Sstevel@tonic-gate
154*0Sstevel@tonic-gate if (v == t)
155*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at first word */
156*0Sstevel@tonic-gate
157*0Sstevel@tonic-gate _adjust_cursor(f, v);
158*0Sstevel@tonic-gate return (E_OK);
159*0Sstevel@tonic-gate }
160*0Sstevel@tonic-gate
161*0Sstevel@tonic-gate /* _beg_field - move to first non-pad char in field */
162*0Sstevel@tonic-gate int
_beg_field(FORM * f)163*0Sstevel@tonic-gate _beg_field(FORM *f)
164*0Sstevel@tonic-gate {
165*0Sstevel@tonic-gate FIELD * c = C(f);
166*0Sstevel@tonic-gate
167*0Sstevel@tonic-gate _sync_buffer(f);
168*0Sstevel@tonic-gate _adjust_cursor(f, _data_beg(Buf(c), BufSize(c)));
169*0Sstevel@tonic-gate return (E_OK);
170*0Sstevel@tonic-gate }
171*0Sstevel@tonic-gate
172*0Sstevel@tonic-gate /* _end_field - move after last non-pad char in field */
173*0Sstevel@tonic-gate int
_end_field(FORM * f)174*0Sstevel@tonic-gate _end_field(FORM *f)
175*0Sstevel@tonic-gate {
176*0Sstevel@tonic-gate FIELD * c = C(f);
177*0Sstevel@tonic-gate char * end;
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gate _sync_buffer(f);
180*0Sstevel@tonic-gate end = _data_end(Buf(c), BufSize(c));
181*0Sstevel@tonic-gate
182*0Sstevel@tonic-gate if (end == Buf(c) + BufSize(c))
183*0Sstevel@tonic-gate end--;
184*0Sstevel@tonic-gate
185*0Sstevel@tonic-gate _adjust_cursor(f, end);
186*0Sstevel@tonic-gate return (E_OK);
187*0Sstevel@tonic-gate }
188*0Sstevel@tonic-gate
189*0Sstevel@tonic-gate /* _beg_line - move to first non-pad char on current line */
190*0Sstevel@tonic-gate int
_beg_line(FORM * f)191*0Sstevel@tonic-gate _beg_line(FORM *f)
192*0Sstevel@tonic-gate {
193*0Sstevel@tonic-gate FIELD *c = C(f);
194*0Sstevel@tonic-gate
195*0Sstevel@tonic-gate _sync_buffer(f);
196*0Sstevel@tonic-gate _adjust_cursor(f, _data_beg(LineBuf(c, Y(f)), Xmax(f)));
197*0Sstevel@tonic-gate return (E_OK);
198*0Sstevel@tonic-gate }
199*0Sstevel@tonic-gate
200*0Sstevel@tonic-gate /* _end_line - move after last non-pad char on current line */
201*0Sstevel@tonic-gate int
_end_line(FORM * f)202*0Sstevel@tonic-gate _end_line(FORM *f)
203*0Sstevel@tonic-gate {
204*0Sstevel@tonic-gate FIELD *c = C(f);
205*0Sstevel@tonic-gate char *end;
206*0Sstevel@tonic-gate
207*0Sstevel@tonic-gate _sync_buffer(f);
208*0Sstevel@tonic-gate end = _data_end(LineBuf(c, Y(f)), Xmax(f));
209*0Sstevel@tonic-gate
210*0Sstevel@tonic-gate if (end == LineBuf(c, Y(f)) + Xmax(f))
211*0Sstevel@tonic-gate end--;
212*0Sstevel@tonic-gate
213*0Sstevel@tonic-gate _adjust_cursor(f, end);
214*0Sstevel@tonic-gate return (E_OK);
215*0Sstevel@tonic-gate }
216*0Sstevel@tonic-gate
217*0Sstevel@tonic-gate /* _left_char - move left */
218*0Sstevel@tonic-gate int
_left_char(FORM * f)219*0Sstevel@tonic-gate _left_char(FORM *f)
220*0Sstevel@tonic-gate {
221*0Sstevel@tonic-gate if (--X(f) < 0) {
222*0Sstevel@tonic-gate ++X(f);
223*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at left side */
224*0Sstevel@tonic-gate }
225*0Sstevel@tonic-gate return (E_OK);
226*0Sstevel@tonic-gate }
227*0Sstevel@tonic-gate
228*0Sstevel@tonic-gate /* _right_char - move right */
229*0Sstevel@tonic-gate int
_right_char(FORM * f)230*0Sstevel@tonic-gate _right_char(FORM *f)
231*0Sstevel@tonic-gate {
232*0Sstevel@tonic-gate if (++X(f) == Xmax(f)) {
233*0Sstevel@tonic-gate --X(f);
234*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at right side */
235*0Sstevel@tonic-gate }
236*0Sstevel@tonic-gate return (E_OK);
237*0Sstevel@tonic-gate }
238*0Sstevel@tonic-gate
239*0Sstevel@tonic-gate /* _up_char - move up */
240*0Sstevel@tonic-gate int
_up_char(FORM * f)241*0Sstevel@tonic-gate _up_char(FORM *f)
242*0Sstevel@tonic-gate {
243*0Sstevel@tonic-gate if (--Y(f) < 0) {
244*0Sstevel@tonic-gate ++Y(f);
245*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at top */
246*0Sstevel@tonic-gate }
247*0Sstevel@tonic-gate return (E_OK);
248*0Sstevel@tonic-gate }
249*0Sstevel@tonic-gate
250*0Sstevel@tonic-gate /* _down_char - move down */
251*0Sstevel@tonic-gate int
_down_char(FORM * f)252*0Sstevel@tonic-gate _down_char(FORM *f)
253*0Sstevel@tonic-gate {
254*0Sstevel@tonic-gate if (++Y(f) == Ymax(f)) {
255*0Sstevel@tonic-gate --Y(f);
256*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at bottom */
257*0Sstevel@tonic-gate }
258*0Sstevel@tonic-gate return (E_OK);
259*0Sstevel@tonic-gate }
260*0Sstevel@tonic-gate
261*0Sstevel@tonic-gate /* _scr_fline - scroll forward one line */
262*0Sstevel@tonic-gate int
_scr_fline(FORM * f)263*0Sstevel@tonic-gate _scr_fline(FORM *f)
264*0Sstevel@tonic-gate {
265*0Sstevel@tonic-gate FIELD *c = C(f);
266*0Sstevel@tonic-gate
267*0Sstevel@tonic-gate if (++T(f) > OffscreenRows(c)) {
268*0Sstevel@tonic-gate --T(f);
269*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at bottom */
270*0Sstevel@tonic-gate }
271*0Sstevel@tonic-gate ++Y(f);
272*0Sstevel@tonic-gate Set(c, TOP_CHG);
273*0Sstevel@tonic-gate return (E_OK);
274*0Sstevel@tonic-gate }
275*0Sstevel@tonic-gate
276*0Sstevel@tonic-gate /* _scr_bline - scroll backward one line */
277*0Sstevel@tonic-gate int
_scr_bline(FORM * f)278*0Sstevel@tonic-gate _scr_bline(FORM *f)
279*0Sstevel@tonic-gate {
280*0Sstevel@tonic-gate FIELD *c = C(f);
281*0Sstevel@tonic-gate
282*0Sstevel@tonic-gate if (--T(f) < 0) {
283*0Sstevel@tonic-gate ++T(f);
284*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at top */
285*0Sstevel@tonic-gate }
286*0Sstevel@tonic-gate --Y(f);
287*0Sstevel@tonic-gate Set(c, TOP_CHG);
288*0Sstevel@tonic-gate return (E_OK);
289*0Sstevel@tonic-gate }
290*0Sstevel@tonic-gate
291*0Sstevel@tonic-gate /* _scr_fpage - scroll forward one page(C(f) -> rows) */
292*0Sstevel@tonic-gate int
_scr_fpage(FORM * f)293*0Sstevel@tonic-gate _scr_fpage(FORM *f)
294*0Sstevel@tonic-gate {
295*0Sstevel@tonic-gate FIELD * c = C(f);
296*0Sstevel@tonic-gate int m = OffscreenRows(c) - T(f);
297*0Sstevel@tonic-gate int n = c -> rows < m ? c -> rows : m;
298*0Sstevel@tonic-gate
299*0Sstevel@tonic-gate if (n) {
300*0Sstevel@tonic-gate Y(f) += n;
301*0Sstevel@tonic-gate T(f) += n;
302*0Sstevel@tonic-gate Set(c, TOP_CHG);
303*0Sstevel@tonic-gate return (E_OK);
304*0Sstevel@tonic-gate }
305*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at bottom */
306*0Sstevel@tonic-gate }
307*0Sstevel@tonic-gate
308*0Sstevel@tonic-gate /* _scr_bpage - scroll backward one page(C(f) -> rows) */
309*0Sstevel@tonic-gate int
_scr_bpage(FORM * f)310*0Sstevel@tonic-gate _scr_bpage(FORM *f)
311*0Sstevel@tonic-gate {
312*0Sstevel@tonic-gate FIELD * c = C(f);
313*0Sstevel@tonic-gate int m = T(f);
314*0Sstevel@tonic-gate int n = c -> rows < m ? c -> rows : m;
315*0Sstevel@tonic-gate
316*0Sstevel@tonic-gate if (n) {
317*0Sstevel@tonic-gate Y(f) -= n;
318*0Sstevel@tonic-gate T(f) -= n;
319*0Sstevel@tonic-gate Set(c, TOP_CHG);
320*0Sstevel@tonic-gate return (E_OK);
321*0Sstevel@tonic-gate }
322*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at top */
323*0Sstevel@tonic-gate }
324*0Sstevel@tonic-gate
325*0Sstevel@tonic-gate /* _scr_fhpage - scroll forward one half page(C(f)->rows + 1)/2) */
326*0Sstevel@tonic-gate int
_scr_fhpage(FORM * f)327*0Sstevel@tonic-gate _scr_fhpage(FORM *f)
328*0Sstevel@tonic-gate {
329*0Sstevel@tonic-gate FIELD * c = C(f);
330*0Sstevel@tonic-gate int m = OffscreenRows(c) - T(f);
331*0Sstevel@tonic-gate int h = (c->rows + 1)/2;
332*0Sstevel@tonic-gate int n = h < m ? h : m;
333*0Sstevel@tonic-gate
334*0Sstevel@tonic-gate if (n) {
335*0Sstevel@tonic-gate Y(f) += n;
336*0Sstevel@tonic-gate T(f) += n;
337*0Sstevel@tonic-gate Set(c, TOP_CHG);
338*0Sstevel@tonic-gate return (E_OK);
339*0Sstevel@tonic-gate }
340*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at bottom */
341*0Sstevel@tonic-gate }
342*0Sstevel@tonic-gate
343*0Sstevel@tonic-gate /* _scr_bhpage - scroll backward one half page(C(f)->rows + 1)/2) */
344*0Sstevel@tonic-gate int
_scr_bhpage(FORM * f)345*0Sstevel@tonic-gate _scr_bhpage(FORM *f)
346*0Sstevel@tonic-gate {
347*0Sstevel@tonic-gate FIELD * c = C(f);
348*0Sstevel@tonic-gate int m = T(f);
349*0Sstevel@tonic-gate int h = (c->rows + 1)/2;
350*0Sstevel@tonic-gate int n = h < m ? h : m;
351*0Sstevel@tonic-gate
352*0Sstevel@tonic-gate if (n) {
353*0Sstevel@tonic-gate Y(f) -= n;
354*0Sstevel@tonic-gate T(f) -= n;
355*0Sstevel@tonic-gate Set(c, TOP_CHG);
356*0Sstevel@tonic-gate return (E_OK);
357*0Sstevel@tonic-gate }
358*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at top */
359*0Sstevel@tonic-gate }
360*0Sstevel@tonic-gate
361*0Sstevel@tonic-gate /* _scr_fchar - horizontal scroll forward one char */
362*0Sstevel@tonic-gate int
_scr_fchar(FORM * f)363*0Sstevel@tonic-gate _scr_fchar(FORM *f)
364*0Sstevel@tonic-gate {
365*0Sstevel@tonic-gate FIELD *c = C(f);
366*0Sstevel@tonic-gate
367*0Sstevel@tonic-gate if (++B(f) > OffscreenCols(c)) {
368*0Sstevel@tonic-gate --B(f);
369*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at end */
370*0Sstevel@tonic-gate }
371*0Sstevel@tonic-gate ++X(f);
372*0Sstevel@tonic-gate return (E_OK);
373*0Sstevel@tonic-gate }
374*0Sstevel@tonic-gate
375*0Sstevel@tonic-gate /* _scr_bchar - horizontal scroll backward one char */
376*0Sstevel@tonic-gate int
_scr_bchar(FORM * f)377*0Sstevel@tonic-gate _scr_bchar(FORM *f)
378*0Sstevel@tonic-gate {
379*0Sstevel@tonic-gate
380*0Sstevel@tonic-gate if (--B(f) < 0) {
381*0Sstevel@tonic-gate ++B(f);
382*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at beginning */
383*0Sstevel@tonic-gate }
384*0Sstevel@tonic-gate --X(f);
385*0Sstevel@tonic-gate return (E_OK);
386*0Sstevel@tonic-gate }
387*0Sstevel@tonic-gate
388*0Sstevel@tonic-gate /* _scr_hfline - horizontal scroll forward one line(C(f)->cols) */
389*0Sstevel@tonic-gate int
_scr_hfline(FORM * f)390*0Sstevel@tonic-gate _scr_hfline(FORM *f)
391*0Sstevel@tonic-gate {
392*0Sstevel@tonic-gate FIELD *c = C(f);
393*0Sstevel@tonic-gate int m = OffscreenCols(c) - B(f);
394*0Sstevel@tonic-gate int n = c -> cols < m ? c -> cols : m;
395*0Sstevel@tonic-gate
396*0Sstevel@tonic-gate if (n) {
397*0Sstevel@tonic-gate X(f) += n;
398*0Sstevel@tonic-gate B(f) += n;
399*0Sstevel@tonic-gate return (E_OK);
400*0Sstevel@tonic-gate }
401*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at end */
402*0Sstevel@tonic-gate }
403*0Sstevel@tonic-gate
404*0Sstevel@tonic-gate /* _scr_hbline - horizontal scroll backward one line(C(f)->cols) */
405*0Sstevel@tonic-gate int
_scr_hbline(FORM * f)406*0Sstevel@tonic-gate _scr_hbline(FORM *f)
407*0Sstevel@tonic-gate {
408*0Sstevel@tonic-gate FIELD *c = C(f);
409*0Sstevel@tonic-gate int m = B(f);
410*0Sstevel@tonic-gate int n = c -> cols < m ? c -> cols : m;
411*0Sstevel@tonic-gate
412*0Sstevel@tonic-gate if (n) {
413*0Sstevel@tonic-gate X(f) -= n;
414*0Sstevel@tonic-gate B(f) -= n;
415*0Sstevel@tonic-gate return (E_OK);
416*0Sstevel@tonic-gate }
417*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at end */
418*0Sstevel@tonic-gate }
419*0Sstevel@tonic-gate
420*0Sstevel@tonic-gate /* _scr_hfhalf - horizontal scroll forward one half line(C(f)->cols/2) */
421*0Sstevel@tonic-gate int
_scr_hfhalf(FORM * f)422*0Sstevel@tonic-gate _scr_hfhalf(FORM *f)
423*0Sstevel@tonic-gate {
424*0Sstevel@tonic-gate FIELD *c = C(f);
425*0Sstevel@tonic-gate int m = OffscreenCols(c) - B(f);
426*0Sstevel@tonic-gate int h = (c->cols + 1)/2;
427*0Sstevel@tonic-gate int n = h < m ? h : m;
428*0Sstevel@tonic-gate
429*0Sstevel@tonic-gate if (n) {
430*0Sstevel@tonic-gate X(f) += n;
431*0Sstevel@tonic-gate B(f) += n;
432*0Sstevel@tonic-gate return (E_OK);
433*0Sstevel@tonic-gate }
434*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at end */
435*0Sstevel@tonic-gate }
436*0Sstevel@tonic-gate
437*0Sstevel@tonic-gate /* _scr_hbhalf - horizontal scroll backward one half line(C(f)->cols/2) */
438*0Sstevel@tonic-gate int
_scr_hbhalf(FORM * f)439*0Sstevel@tonic-gate _scr_hbhalf(FORM *f)
440*0Sstevel@tonic-gate {
441*0Sstevel@tonic-gate FIELD *c = C(f);
442*0Sstevel@tonic-gate int m = B(f);
443*0Sstevel@tonic-gate int h = (c->cols + 1)/2;
444*0Sstevel@tonic-gate int n = h < m ? h : m;
445*0Sstevel@tonic-gate
446*0Sstevel@tonic-gate if (n) {
447*0Sstevel@tonic-gate X(f) -= n;
448*0Sstevel@tonic-gate B(f) -= n;
449*0Sstevel@tonic-gate return (E_OK);
450*0Sstevel@tonic-gate }
451*0Sstevel@tonic-gate return (E_REQUEST_DENIED); /* at top */
452*0Sstevel@tonic-gate }
453