/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1997, by Sun Microsystems, Inc.
* All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
/*LINTLIBRARY*/
#include "utility.h"
/* from v through end */
/* _next_char move to next char with wrap to next line at end of line */
int
{
if (++X(f) == Xmax(f)) {
if (++Y(f) == Ymax(f)) {
--X(f);
--Y(f);
return (E_REQUEST_DENIED); /* at last char */
}
X(f) = 0;
}
return (E_OK);
}
/*
* _prev_char - move to previous char with
* wrap to previous line at beginning of line
*/
int
{
if (--X(f) < 0) {
if (--Y(f) < 0) {
++X(f);
++Y(f);
return (E_REQUEST_DENIED); /* at first char */
}
X(f) = Xmax(f) - 1;
}
return (E_OK);
}
/* _next_line - move to beginning of next line */
int
{
if (++Y(f) == Ymax(f)) {
--Y(f);
return (E_REQUEST_DENIED); /* at last line */
}
X(f) = 0;
return (E_OK);
}
/* _prev_line - move to beginning of previous line */
int
{
if (--Y(f) < 0) {
++Y(f);
return (E_REQUEST_DENIED); /* at first line */
}
X(f) = 0;
return (E_OK);
}
/* _next_word - move to beginning of next word */
int
{
FIELD * c = C(f);
char * v = LineBuf(c, Y(f)) + X(f); /* position in buffer */
char * t;
_sync_buffer(f);
if (v == t)
return (E_REQUEST_DENIED); /* at last word */
/* one row and field has grown */
t = v;
while (*t != ' ' && *t != '\0') /* find end of word + 1 */
t++;
if (t - v > c->cols) {
/* word longer than visible field */
B(f) = (int) (v - Buf(c));
} else {
}
X(f) = (int) (v - Buf(c));
return (E_OK);
}
}
_adjust_cursor(f, v);
return (E_OK);
}
/* _prev_word - move to beginning of previous word */
int
{
FIELD * c = C(f);
char * v = LineBuf(c, Y(f)) + X(f); /* position in buffer */
char * t;
_sync_buffer(f);
if (v == t)
return (E_REQUEST_DENIED); /* at first word */
_adjust_cursor(f, v);
return (E_OK);
}
/* _beg_field - move to first non-pad char in field */
int
{
FIELD * c = C(f);
_sync_buffer(f);
return (E_OK);
}
/* _end_field - move after last non-pad char in field */
int
{
FIELD * c = C(f);
char * end;
_sync_buffer(f);
end--;
_adjust_cursor(f, end);
return (E_OK);
}
/* _beg_line - move to first non-pad char on current line */
int
{
FIELD *c = C(f);
_sync_buffer(f);
return (E_OK);
}
/* _end_line - move after last non-pad char on current line */
int
{
FIELD *c = C(f);
char *end;
_sync_buffer(f);
end--;
_adjust_cursor(f, end);
return (E_OK);
}
/* _left_char - move left */
int
{
if (--X(f) < 0) {
++X(f);
return (E_REQUEST_DENIED); /* at left side */
}
return (E_OK);
}
/* _right_char - move right */
int
{
if (++X(f) == Xmax(f)) {
--X(f);
return (E_REQUEST_DENIED); /* at right side */
}
return (E_OK);
}
/* _up_char - move up */
int
{
if (--Y(f) < 0) {
++Y(f);
return (E_REQUEST_DENIED); /* at top */
}
return (E_OK);
}
/* _down_char - move down */
int
{
if (++Y(f) == Ymax(f)) {
--Y(f);
return (E_REQUEST_DENIED); /* at bottom */
}
return (E_OK);
}
/* _scr_fline - scroll forward one line */
int
{
FIELD *c = C(f);
if (++T(f) > OffscreenRows(c)) {
--T(f);
return (E_REQUEST_DENIED); /* at bottom */
}
++Y(f);
return (E_OK);
}
/* _scr_bline - scroll backward one line */
int
{
FIELD *c = C(f);
if (--T(f) < 0) {
++T(f);
return (E_REQUEST_DENIED); /* at top */
}
--Y(f);
return (E_OK);
}
/* _scr_fpage - scroll forward one page(C(f) -> rows) */
int
{
FIELD * c = C(f);
int m = OffscreenRows(c) - T(f);
if (n) {
Y(f) += n;
T(f) += n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at bottom */
}
/* _scr_bpage - scroll backward one page(C(f) -> rows) */
int
{
FIELD * c = C(f);
int m = T(f);
if (n) {
Y(f) -= n;
T(f) -= n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at top */
}
/* _scr_fhpage - scroll forward one half page(C(f)->rows + 1)/2) */
int
{
FIELD * c = C(f);
int m = OffscreenRows(c) - T(f);
int n = h < m ? h : m;
if (n) {
Y(f) += n;
T(f) += n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at bottom */
}
/* _scr_bhpage - scroll backward one half page(C(f)->rows + 1)/2) */
int
{
FIELD * c = C(f);
int m = T(f);
int n = h < m ? h : m;
if (n) {
Y(f) -= n;
T(f) -= n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at top */
}
/* _scr_fchar - horizontal scroll forward one char */
int
{
FIELD *c = C(f);
if (++B(f) > OffscreenCols(c)) {
--B(f);
return (E_REQUEST_DENIED); /* at end */
}
++X(f);
return (E_OK);
}
/* _scr_bchar - horizontal scroll backward one char */
int
{
if (--B(f) < 0) {
++B(f);
return (E_REQUEST_DENIED); /* at beginning */
}
--X(f);
return (E_OK);
}
/* _scr_hfline - horizontal scroll forward one line(C(f)->cols) */
int
{
FIELD *c = C(f);
int m = OffscreenCols(c) - B(f);
if (n) {
X(f) += n;
B(f) += n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at end */
}
/* _scr_hbline - horizontal scroll backward one line(C(f)->cols) */
int
{
FIELD *c = C(f);
int m = B(f);
if (n) {
X(f) -= n;
B(f) -= n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at end */
}
/* _scr_hfhalf - horizontal scroll forward one half line(C(f)->cols/2) */
int
{
FIELD *c = C(f);
int m = OffscreenCols(c) - B(f);
int n = h < m ? h : m;
if (n) {
X(f) += n;
B(f) += n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at end */
}
/* _scr_hbhalf - horizontal scroll backward one half line(C(f)->cols/2) */
int
{
FIELD *c = C(f);
int m = B(f);
int n = h < m ? h : m;
if (n) {
X(f) -= n;
B(f) -= n;
return (E_OK);
}
return (E_REQUEST_DENIED); /* at top */
}