/* This file contains movement functions which are screen-relative */
/* This moves the cursor to a particular row on the screen */
MARK m
; /* the cursor position */
long cnt
; /* the row we'll move to */
int key
; /* the keystroke of this move - H/L/M */
/* calculate destination line based on key */
cnt
= topline
+ (LINES
- 1) / 2;
/* return the mark of the destination line */
return MARK_AT_LINE(cnt
);
/* This function repositions the current line to show on a given row */
long cnt
; /* the line number we're repositioning */
int key
; /* key struck after the z */
/* Which line are we talking about? */
if (cnt
< 0 || cnt
> nlines
)
/* allow a "window size" number to be entered */
for (i
= 0; key
>= '0' && key
<= '9'; key
= getkey(0))
if (i
> 0 && i
<= LINES
- 1)
/* the number is ignored if -DCRUNCH */
/* figure out which line will have to be at the top of the screen */
/* make the new topline take effect */
redraw(MARK_UNSET
, FALSE
);
redrawrange(0L, INFINITY
, INFINITY
);
/* The cursor doesn't move */
/* This function scrolls the screen. It does this by calling redraw() with
* an off-screen line as the argument. It will move the cursor if necessary
* so that the cursor is on the new screen.
MARK
m_scroll(m
, cnt
, key
)
MARK m
; /* the cursor position */
long cnt
; /* for some keys: the number of lines to scroll */
int key
; /* keystroke that causes this movement */
MARK tmp
; /* a temporary mark, used as arg to redraw() */
/* adjust cnt, and maybe *o_scroll, depending of key */
redrawrange(0L, INFINITY
, INFINITY
); /* force complete redraw */
cnt
= cnt
* (LINES
- 1) - 2; /* keeps two old lines on screen */
if (cnt
== 0) /* default */
/* scroll up or down, depending on key */
tmp
= MARK_AT_LINE(cnt
) + markidx(m
);
if (markline(m
) > botline
)
m
= MARK_AT_LINE(botline
);
tmp
= MARK_AT_LINE(cnt
) + markidx(m
);
if (markline(m
) < topline
)
m
= MARK_AT_LINE(topline
);