5 * 14407 SW Teal Blvd. #C
11 /* This file contains movement functions which are screen-relative */
16 /* This moves the cursor to a particular row on the screen */
18 MARK
m_row(m
, cnt
, key
)
19 MARK m
; /* the cursor position */
20 long cnt
; /* the row we'll move to */
21 int key
; /* the keystroke of this move - H/L/M */
25 /* calculate destination line based on key */
34 cnt
= topline
+ (LINES
- 1) / 2;
42 /* return the mark of the destination line */
43 return MARK_AT_LINE(cnt
);
47 /* This function repositions the current line to show on a given row */
49 MARK m
; /* the cursor */
50 long cnt
; /* the line number we're repositioning */
51 int key
; /* key struck after the z */
56 /* Which line are we talking about? */
57 if (cnt
< 0 || cnt
> nlines
)
63 m
= MARK_AT_LINE(cnt
);
71 /* allow a "window size" number to be entered */
72 for (i
= 0; key
>= '0' && key
<= '9'; key
= getkey(0))
74 i
= i
* 10 + key
- '0';
77 if (i
> 0 && i
<= LINES
- 1)
83 /* the number is ignored if -DCRUNCH */
86 /* figure out which line will have to be at the top of the screen */
111 /* make the new topline take effect */
112 redraw(MARK_UNSET
, FALSE
);
121 redrawrange(0L, INFINITY
, INFINITY
);
123 /* The cursor doesn't move */
128 /* This function scrolls the screen. It does this by calling redraw() with
129 * an off-screen line as the argument. It will move the cursor if necessary
130 * so that the cursor is on the new screen.
133 MARK
m_scroll(m
, cnt
, key
)
134 MARK m
; /* the cursor position */
135 long cnt
; /* for some keys: the number of lines to scroll */
136 int key
; /* keystroke that causes this movement */
138 MARK tmp
; /* a temporary mark, used as arg to redraw() */
140 /* adjust cnt, and maybe *o_scroll, depending of key */
146 redrawrange(0L, INFINITY
, INFINITY
); /* force complete redraw */
147 cnt
= cnt
* (LINES
- 1) - 2; /* keeps two old lines on screen */
157 if (cnt
== 0) /* default */
172 /* scroll up or down, depending on key */
184 tmp
= MARK_AT_LINE(cnt
) + markidx(m
);
186 if (markline(m
) > botline
)
188 m
= MARK_AT_LINE(botline
);
201 tmp
= MARK_AT_LINE(cnt
) + markidx(m
);
203 if (markline(m
) < topline
)
205 m
= MARK_AT_LINE(topline
);