pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / elvis / move4.c
bloba31ef881f347845eb0d4e19bcd63e2777dfd6d61
1 /* move4.c */
3 /* Author:
4 * Steve Kirkendall
5 * 14407 SW Teal Blvd. #C
6 * Beaverton, OR 97005
7 * kirkenda@cs.pdx.edu
8 */
11 /* This file contains movement functions which are screen-relative */
13 #include "config.h"
14 #include "vi.h"
16 /* This moves the cursor to a particular row on the screen */
17 /*ARGSUSED*/
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 */
23 DEFAULT(1);
25 /* calculate destination line based on key */
26 cnt--;
27 switch (key)
29 case 'H':
30 cnt = topline + cnt;
31 break;
33 case 'M':
34 cnt = topline + (LINES - 1) / 2;
35 break;
37 case 'L':
38 cnt = botline - cnt;
39 break;
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 */
48 MARK m_z(m, cnt, key)
49 MARK m; /* the cursor */
50 long cnt; /* the line number we're repositioning */
51 int key; /* key struck after the z */
53 long newtop;
54 int i;
56 /* Which line are we talking about? */
57 if (cnt < 0 || cnt > nlines)
59 return MARK_UNSET;
61 if (cnt)
63 m = MARK_AT_LINE(cnt);
64 newtop = cnt;
66 else
68 newtop = markline(m);
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';
76 #ifndef CRUNCH
77 if (i > 0 && i <= LINES - 1)
79 *o_window = i;
80 wset = TRUE;
82 #else
83 /* the number is ignored if -DCRUNCH */
84 #endif
86 /* figure out which line will have to be at the top of the screen */
87 switch (key)
89 case '\n':
90 #if OSK
91 case '\l':
92 #else
93 case '\r':
94 #endif
95 case '+':
96 break;
98 case '.':
99 case 'z':
100 newtop -= LINES / 2;
101 break;
103 case '-':
104 newtop -= LINES - 1;
105 break;
107 default:
108 return MARK_UNSET;
111 /* make the new topline take effect */
112 redraw(MARK_UNSET, FALSE);
113 if (newtop >= 1)
115 topline = newtop;
117 else
119 topline = 1L;
121 redrawrange(0L, INFINITY, INFINITY);
123 /* The cursor doesn't move */
124 return m;
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.
132 /*ARGSUSED*/
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 */
141 switch (key)
143 case ctrl('F'):
144 case ctrl('B'):
145 DEFAULT(1);
146 redrawrange(0L, INFINITY, INFINITY); /* force complete redraw */
147 cnt = cnt * (LINES - 1) - 2; /* keeps two old lines on screen */
148 break;
150 case ctrl('E'):
151 case ctrl('Y'):
152 DEFAULT(1);
153 break;
155 case ctrl('U'):
156 case ctrl('D'):
157 if (cnt == 0) /* default */
159 cnt = *o_scroll;
161 else
163 if (cnt > LINES - 1)
165 cnt = LINES - 1;
167 *o_scroll = cnt;
169 break;
172 /* scroll up or down, depending on key */
173 switch (key)
175 case ctrl('B'):
176 case ctrl('Y'):
177 case ctrl('U'):
178 cnt = topline - cnt;
179 if (cnt < 1L)
181 cnt = 1L;
182 m = MARK_FIRST;
184 tmp = MARK_AT_LINE(cnt) + markidx(m);
185 redraw(tmp, FALSE);
186 if (markline(m) > botline)
188 m = MARK_AT_LINE(botline);
190 break;
192 case ctrl('F'):
193 case ctrl('E'):
194 case ctrl('D'):
195 cnt = botline + cnt;
196 if (cnt > nlines)
198 cnt = nlines;
199 m = MARK_LAST;
201 tmp = MARK_AT_LINE(cnt) + markidx(m);
202 redraw(tmp, FALSE);
203 if (markline(m) < topline)
205 m = MARK_AT_LINE(topline);
207 break;
210 return m;