/*
* 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 1997 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include "curses_inc.h"
/*
* Cursor motion optimization routine. This routine takes as parameters
* the screen positions that the cursor is currently at, and the position
* you want it to be at, and it will move the cursor there very
* efficiently. It isn't really optimal, since several approximations
* are taken in the interests of efficiency and simplicity. The code
* here considers directly addressing the cursor, and also considers
* local motions using left, right, up, down, tabs, backtabs, vertical
* and horizontal addressing, and parameterized motions. It does not
* consider using home down, or taking advantage of automatic margins on
* any of the four directions. (Two of these directions, left and right,
* are well defined by the am and bw capabilities, but up and down are
* not defined, nor are tab or backtab off the ends.)
*
* General strategies considered:
* CA Direct Cursor Addressing
* LM Local Motions from the old position
* HR Home + Local Motions from upper left corner
* HDR Home Down + Local Motions from lower left corner
* CR CR + Local Motions from left margin
*
* Local Motions can include
* Up cuu, cuu1, vpa
* Down cud, cud1, vpa
* Left cul, cul1, hpa, bs, cbt
* Right cuf, cuf1, hpa, tab, char moved over
*/
/* This is called _ISMARK2 so it doesn't conflict with _ISMARK1 in wrefresh.c */
static int Newy;
static int _homefirst(int, int, int, int),
_mvrel(int, int, int, int, int),
int
{
/* obvious case */
return (OK);
/* not in the right mode for cursor movement */
return (ERR);
_OFFINSERT();
/* cost of using cm */
/* baudrate optimization */
goto done;
}
/* fast horizontal move */
else
else
goto done;
}
}
}
/* cost using relative movements */
/* cost of homing to upper-left corner first */
if (cursor_home)
/* cost of homing to lower-left corner first */
if (cursor_to_ll)
/* can't do any one of them */
return (ERR);
/* do the best one */
else
else
done:
/* update cursor position */
/*LINTED*/
/*LINTED*/
return (OK);
}
/* Move by homing first. */
static int
{
char *home;
home = cursor_home;
cy = 0;
} else {
home = cursor_to_ll;
}
if (!home)
return (LARGECOST);
if (!doit)
}
/* Move relatively */
static int
{
/* do in this order since _mvhor may need the curscr image */
}
/* Move vertically */
static int
{
char *ve;
goto out;
/* cost of stepwise movement */
} else {
}
/* cost of using vertical move */
/* if calculating cost only */
if (!doit)
/* do it */
else
else
} else {
ve = cursor_down;
else
}
out:
return (0);
}
/* Move horizontally */
static int
{
goto out;
/* cost using horizontal move */
/* cost doing stepwise */
/* cost homeleft first */
if (!doit)
else
} else {
else
}
out:
return (0);
}
/* Move right. */
static int
{
char *mks;
if (!cursor_right && !parm_right_cursor)
return (LARGECOST);
if (cursor_right) {
/* number of tabs used in stepwise movement */
/* calculate stepwise cost */
iscont = 0;
iscont = 1;
if ((!ceol_standout_glitch && !mks &&
stcost += 1;
stcost += 1;
else
} else
}
} else
if (!doit)
/* actually move */
else {
_OFFINSERT();
iscont = 0;
iscont = 1;
if ((!ceol_standout_glitch && !mks &&
else
} else
}
}
return (0);
}
/* Move left */
static int
{
if (!cursor_left && !parm_left_cursor)
return (LARGECOST);
if (cursor_left) {
/* stepwise cost */
nt = 0;
if (back_tab) {
/* the TAB position >= nx */
/* # of tabs used and position after using them */
if (x < cx) {
tx = x;
}
}
} else
/* get cost only */
if (!doit)
/* doit */
else {
}
return (0);
}