1*84d9c625SLionel Sambuc /* $NetBSD: input.c,v 1.3 2013/09/04 19:44:21 tron Exp $ */
2f7cf2976SLionel Sambuc
3f7cf2976SLionel Sambuc /*
4*84d9c625SLionel Sambuc * Copyright (C) 1984-2012 Mark Nudelman
5f7cf2976SLionel Sambuc *
6f7cf2976SLionel Sambuc * You may distribute under the terms of either the GNU General Public
7f7cf2976SLionel Sambuc * License or the Less License, as specified in the README file.
8f7cf2976SLionel Sambuc *
9*84d9c625SLionel Sambuc * For more information, see the README file.
10f7cf2976SLionel Sambuc */
11f7cf2976SLionel Sambuc
12f7cf2976SLionel Sambuc
13f7cf2976SLionel Sambuc /*
14f7cf2976SLionel Sambuc * High level routines dealing with getting lines of input
15f7cf2976SLionel Sambuc * from the file being viewed.
16f7cf2976SLionel Sambuc *
17f7cf2976SLionel Sambuc * When we speak of "lines" here, we mean PRINTABLE lines;
18f7cf2976SLionel Sambuc * lines processed with respect to the screen width.
19f7cf2976SLionel Sambuc * We use the term "raw line" to refer to lines simply
20f7cf2976SLionel Sambuc * delimited by newlines; not processed with respect to screen width.
21f7cf2976SLionel Sambuc */
22f7cf2976SLionel Sambuc
23f7cf2976SLionel Sambuc #include "less.h"
24f7cf2976SLionel Sambuc
25f7cf2976SLionel Sambuc extern int squeeze;
26f7cf2976SLionel Sambuc extern int chopline;
27f7cf2976SLionel Sambuc extern int hshift;
28f7cf2976SLionel Sambuc extern int quit_if_one_screen;
29f7cf2976SLionel Sambuc extern int sigs;
30f7cf2976SLionel Sambuc extern int ignore_eoi;
31f7cf2976SLionel Sambuc extern int status_col;
32f7cf2976SLionel Sambuc extern POSITION start_attnpos;
33f7cf2976SLionel Sambuc extern POSITION end_attnpos;
34f7cf2976SLionel Sambuc #if HILITE_SEARCH
35f7cf2976SLionel Sambuc extern int hilite_search;
36f7cf2976SLionel Sambuc extern int size_linebuf;
37f7cf2976SLionel Sambuc #endif
38f7cf2976SLionel Sambuc
39f7cf2976SLionel Sambuc /*
40f7cf2976SLionel Sambuc * Get the next line.
41f7cf2976SLionel Sambuc * A "current" position is passed and a "new" position is returned.
42f7cf2976SLionel Sambuc * The current position is the position of the first character of
43f7cf2976SLionel Sambuc * a line. The new position is the position of the first character
44f7cf2976SLionel Sambuc * of the NEXT line. The line obtained is the line starting at curr_pos.
45f7cf2976SLionel Sambuc */
46f7cf2976SLionel Sambuc public POSITION
forw_line(curr_pos)47f7cf2976SLionel Sambuc forw_line(curr_pos)
48f7cf2976SLionel Sambuc POSITION curr_pos;
49f7cf2976SLionel Sambuc {
50f7cf2976SLionel Sambuc POSITION base_pos;
51f7cf2976SLionel Sambuc POSITION new_pos;
52f7cf2976SLionel Sambuc register int c;
53f7cf2976SLionel Sambuc int blankline;
54f7cf2976SLionel Sambuc int endline;
55f7cf2976SLionel Sambuc int backchars;
56f7cf2976SLionel Sambuc
57f7cf2976SLionel Sambuc get_forw_line:
58f7cf2976SLionel Sambuc if (curr_pos == NULL_POSITION)
59f7cf2976SLionel Sambuc {
60f7cf2976SLionel Sambuc null_line();
61f7cf2976SLionel Sambuc return (NULL_POSITION);
62f7cf2976SLionel Sambuc }
63f7cf2976SLionel Sambuc #if HILITE_SEARCH
64f7cf2976SLionel Sambuc if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
65f7cf2976SLionel Sambuc /*
66f7cf2976SLionel Sambuc * If we are ignoring EOI (command F), only prepare
67f7cf2976SLionel Sambuc * one line ahead, to avoid getting stuck waiting for
68f7cf2976SLionel Sambuc * slow data without displaying the data we already have.
69f7cf2976SLionel Sambuc * If we're not ignoring EOI, we *could* do the same, but
70f7cf2976SLionel Sambuc * for efficiency we prepare several lines ahead at once.
71f7cf2976SLionel Sambuc */
72f7cf2976SLionel Sambuc prep_hilite(curr_pos, curr_pos + 3*size_linebuf,
73f7cf2976SLionel Sambuc ignore_eoi ? 1 : -1);
74f7cf2976SLionel Sambuc #endif
75f7cf2976SLionel Sambuc if (ch_seek(curr_pos))
76f7cf2976SLionel Sambuc {
77f7cf2976SLionel Sambuc null_line();
78f7cf2976SLionel Sambuc return (NULL_POSITION);
79f7cf2976SLionel Sambuc }
80f7cf2976SLionel Sambuc
81f7cf2976SLionel Sambuc /*
82f7cf2976SLionel Sambuc * Step back to the beginning of the line.
83f7cf2976SLionel Sambuc */
84f7cf2976SLionel Sambuc base_pos = curr_pos;
85f7cf2976SLionel Sambuc for (;;)
86f7cf2976SLionel Sambuc {
87f7cf2976SLionel Sambuc if (ABORT_SIGS())
88f7cf2976SLionel Sambuc {
89f7cf2976SLionel Sambuc null_line();
90f7cf2976SLionel Sambuc return (NULL_POSITION);
91f7cf2976SLionel Sambuc }
92f7cf2976SLionel Sambuc c = ch_back_get();
93f7cf2976SLionel Sambuc if (c == EOI)
94f7cf2976SLionel Sambuc break;
95f7cf2976SLionel Sambuc if (c == '\n')
96f7cf2976SLionel Sambuc {
97f7cf2976SLionel Sambuc (void) ch_forw_get();
98f7cf2976SLionel Sambuc break;
99f7cf2976SLionel Sambuc }
100f7cf2976SLionel Sambuc --base_pos;
101f7cf2976SLionel Sambuc }
102f7cf2976SLionel Sambuc
103f7cf2976SLionel Sambuc /*
104f7cf2976SLionel Sambuc * Read forward again to the position we should start at.
105f7cf2976SLionel Sambuc */
106f7cf2976SLionel Sambuc prewind();
107f7cf2976SLionel Sambuc plinenum(base_pos);
108f7cf2976SLionel Sambuc (void) ch_seek(base_pos);
109f7cf2976SLionel Sambuc new_pos = base_pos;
110f7cf2976SLionel Sambuc while (new_pos < curr_pos)
111f7cf2976SLionel Sambuc {
112f7cf2976SLionel Sambuc if (ABORT_SIGS())
113f7cf2976SLionel Sambuc {
114f7cf2976SLionel Sambuc null_line();
115f7cf2976SLionel Sambuc return (NULL_POSITION);
116f7cf2976SLionel Sambuc }
117f7cf2976SLionel Sambuc c = ch_forw_get();
118f7cf2976SLionel Sambuc backchars = pappend(c, new_pos);
119f7cf2976SLionel Sambuc new_pos++;
120f7cf2976SLionel Sambuc if (backchars > 0)
121f7cf2976SLionel Sambuc {
122f7cf2976SLionel Sambuc pshift_all();
123f7cf2976SLionel Sambuc new_pos -= backchars;
124f7cf2976SLionel Sambuc while (--backchars >= 0)
125f7cf2976SLionel Sambuc (void) ch_back_get();
126f7cf2976SLionel Sambuc }
127f7cf2976SLionel Sambuc }
128f7cf2976SLionel Sambuc (void) pflushmbc();
129f7cf2976SLionel Sambuc pshift_all();
130f7cf2976SLionel Sambuc
131f7cf2976SLionel Sambuc /*
132f7cf2976SLionel Sambuc * Read the first character to display.
133f7cf2976SLionel Sambuc */
134f7cf2976SLionel Sambuc c = ch_forw_get();
135f7cf2976SLionel Sambuc if (c == EOI)
136f7cf2976SLionel Sambuc {
137f7cf2976SLionel Sambuc null_line();
138f7cf2976SLionel Sambuc return (NULL_POSITION);
139f7cf2976SLionel Sambuc }
140f7cf2976SLionel Sambuc blankline = (c == '\n' || c == '\r');
141f7cf2976SLionel Sambuc
142f7cf2976SLionel Sambuc /*
143f7cf2976SLionel Sambuc * Read each character in the line and append to the line buffer.
144f7cf2976SLionel Sambuc */
145f7cf2976SLionel Sambuc for (;;)
146f7cf2976SLionel Sambuc {
147f7cf2976SLionel Sambuc if (ABORT_SIGS())
148f7cf2976SLionel Sambuc {
149f7cf2976SLionel Sambuc null_line();
150f7cf2976SLionel Sambuc return (NULL_POSITION);
151f7cf2976SLionel Sambuc }
152f7cf2976SLionel Sambuc if (c == '\n' || c == EOI)
153f7cf2976SLionel Sambuc {
154f7cf2976SLionel Sambuc /*
155f7cf2976SLionel Sambuc * End of the line.
156f7cf2976SLionel Sambuc */
157f7cf2976SLionel Sambuc backchars = pflushmbc();
158f7cf2976SLionel Sambuc new_pos = ch_tell();
159f7cf2976SLionel Sambuc if (backchars > 0 && !chopline && hshift == 0)
160f7cf2976SLionel Sambuc {
161f7cf2976SLionel Sambuc new_pos -= backchars + 1;
162f7cf2976SLionel Sambuc endline = FALSE;
163f7cf2976SLionel Sambuc } else
164f7cf2976SLionel Sambuc endline = TRUE;
165f7cf2976SLionel Sambuc break;
166f7cf2976SLionel Sambuc }
167f7cf2976SLionel Sambuc if (c != '\r')
168f7cf2976SLionel Sambuc blankline = 0;
169f7cf2976SLionel Sambuc
170f7cf2976SLionel Sambuc /*
171f7cf2976SLionel Sambuc * Append the char to the line and get the next char.
172f7cf2976SLionel Sambuc */
173f7cf2976SLionel Sambuc backchars = pappend(c, ch_tell()-1);
174f7cf2976SLionel Sambuc if (backchars > 0)
175f7cf2976SLionel Sambuc {
176f7cf2976SLionel Sambuc /*
177f7cf2976SLionel Sambuc * The char won't fit in the line; the line
178f7cf2976SLionel Sambuc * is too long to print in the screen width.
179f7cf2976SLionel Sambuc * End the line here.
180f7cf2976SLionel Sambuc */
181f7cf2976SLionel Sambuc if (chopline || hshift > 0)
182f7cf2976SLionel Sambuc {
183f7cf2976SLionel Sambuc do
184f7cf2976SLionel Sambuc {
185f7cf2976SLionel Sambuc if (ABORT_SIGS())
186f7cf2976SLionel Sambuc {
187f7cf2976SLionel Sambuc null_line();
188f7cf2976SLionel Sambuc return (NULL_POSITION);
189f7cf2976SLionel Sambuc }
190f7cf2976SLionel Sambuc c = ch_forw_get();
191f7cf2976SLionel Sambuc } while (c != '\n' && c != EOI);
192f7cf2976SLionel Sambuc new_pos = ch_tell();
193f7cf2976SLionel Sambuc endline = TRUE;
194f7cf2976SLionel Sambuc quit_if_one_screen = FALSE;
195f7cf2976SLionel Sambuc } else
196f7cf2976SLionel Sambuc {
197f7cf2976SLionel Sambuc new_pos = ch_tell() - backchars;
198f7cf2976SLionel Sambuc endline = FALSE;
199f7cf2976SLionel Sambuc }
200f7cf2976SLionel Sambuc break;
201f7cf2976SLionel Sambuc }
202f7cf2976SLionel Sambuc c = ch_forw_get();
203f7cf2976SLionel Sambuc }
204f7cf2976SLionel Sambuc
205f7cf2976SLionel Sambuc pdone(endline, 1);
206f7cf2976SLionel Sambuc
207f7cf2976SLionel Sambuc #if HILITE_SEARCH
208f7cf2976SLionel Sambuc if (is_filtered(base_pos))
209f7cf2976SLionel Sambuc {
210f7cf2976SLionel Sambuc /*
211f7cf2976SLionel Sambuc * We don't want to display this line.
212f7cf2976SLionel Sambuc * Get the next line.
213f7cf2976SLionel Sambuc */
214f7cf2976SLionel Sambuc curr_pos = new_pos;
215f7cf2976SLionel Sambuc goto get_forw_line;
216f7cf2976SLionel Sambuc }
217f7cf2976SLionel Sambuc
218f7cf2976SLionel Sambuc if (status_col && is_hilited(base_pos, ch_tell()-1, 1, NULL))
219f7cf2976SLionel Sambuc set_status_col('*');
220f7cf2976SLionel Sambuc #endif
221f7cf2976SLionel Sambuc
222f7cf2976SLionel Sambuc if (squeeze && blankline)
223f7cf2976SLionel Sambuc {
224f7cf2976SLionel Sambuc /*
225f7cf2976SLionel Sambuc * This line is blank.
226f7cf2976SLionel Sambuc * Skip down to the last contiguous blank line
227f7cf2976SLionel Sambuc * and pretend it is the one which we are returning.
228f7cf2976SLionel Sambuc */
229f7cf2976SLionel Sambuc while ((c = ch_forw_get()) == '\n' || c == '\r')
230f7cf2976SLionel Sambuc if (ABORT_SIGS())
231f7cf2976SLionel Sambuc {
232f7cf2976SLionel Sambuc null_line();
233f7cf2976SLionel Sambuc return (NULL_POSITION);
234f7cf2976SLionel Sambuc }
235f7cf2976SLionel Sambuc if (c != EOI)
236f7cf2976SLionel Sambuc (void) ch_back_get();
237f7cf2976SLionel Sambuc new_pos = ch_tell();
238f7cf2976SLionel Sambuc }
239f7cf2976SLionel Sambuc
240f7cf2976SLionel Sambuc return (new_pos);
241f7cf2976SLionel Sambuc }
242f7cf2976SLionel Sambuc
243f7cf2976SLionel Sambuc /*
244f7cf2976SLionel Sambuc * Get the previous line.
245f7cf2976SLionel Sambuc * A "current" position is passed and a "new" position is returned.
246f7cf2976SLionel Sambuc * The current position is the position of the first character of
247f7cf2976SLionel Sambuc * a line. The new position is the position of the first character
248f7cf2976SLionel Sambuc * of the PREVIOUS line. The line obtained is the one starting at new_pos.
249f7cf2976SLionel Sambuc */
250f7cf2976SLionel Sambuc public POSITION
back_line(curr_pos)251f7cf2976SLionel Sambuc back_line(curr_pos)
252f7cf2976SLionel Sambuc POSITION curr_pos;
253f7cf2976SLionel Sambuc {
254f7cf2976SLionel Sambuc POSITION new_pos, begin_new_pos, base_pos;
255f7cf2976SLionel Sambuc int c;
256f7cf2976SLionel Sambuc int endline;
257f7cf2976SLionel Sambuc int backchars;
258f7cf2976SLionel Sambuc
259f7cf2976SLionel Sambuc get_back_line:
260f7cf2976SLionel Sambuc if (curr_pos == NULL_POSITION || curr_pos <= ch_zero())
261f7cf2976SLionel Sambuc {
262f7cf2976SLionel Sambuc null_line();
263f7cf2976SLionel Sambuc return (NULL_POSITION);
264f7cf2976SLionel Sambuc }
265f7cf2976SLionel Sambuc #if HILITE_SEARCH
266f7cf2976SLionel Sambuc if (hilite_search == OPT_ONPLUS || is_filtering() || status_col)
267f7cf2976SLionel Sambuc prep_hilite((curr_pos < 3*size_linebuf) ?
268f7cf2976SLionel Sambuc 0 : curr_pos - 3*size_linebuf, curr_pos, -1);
269f7cf2976SLionel Sambuc #endif
270f7cf2976SLionel Sambuc if (ch_seek(curr_pos-1))
271f7cf2976SLionel Sambuc {
272f7cf2976SLionel Sambuc null_line();
273f7cf2976SLionel Sambuc return (NULL_POSITION);
274f7cf2976SLionel Sambuc }
275f7cf2976SLionel Sambuc
276f7cf2976SLionel Sambuc if (squeeze)
277f7cf2976SLionel Sambuc {
278f7cf2976SLionel Sambuc /*
279f7cf2976SLionel Sambuc * Find out if the "current" line was blank.
280f7cf2976SLionel Sambuc */
281f7cf2976SLionel Sambuc (void) ch_forw_get(); /* Skip the newline */
282f7cf2976SLionel Sambuc c = ch_forw_get(); /* First char of "current" line */
283f7cf2976SLionel Sambuc (void) ch_back_get(); /* Restore our position */
284f7cf2976SLionel Sambuc (void) ch_back_get();
285f7cf2976SLionel Sambuc
286f7cf2976SLionel Sambuc if (c == '\n' || c == '\r')
287f7cf2976SLionel Sambuc {
288f7cf2976SLionel Sambuc /*
289f7cf2976SLionel Sambuc * The "current" line was blank.
290f7cf2976SLionel Sambuc * Skip over any preceding blank lines,
291f7cf2976SLionel Sambuc * since we skipped them in forw_line().
292f7cf2976SLionel Sambuc */
293f7cf2976SLionel Sambuc while ((c = ch_back_get()) == '\n' || c == '\r')
294f7cf2976SLionel Sambuc if (ABORT_SIGS())
295f7cf2976SLionel Sambuc {
296f7cf2976SLionel Sambuc null_line();
297f7cf2976SLionel Sambuc return (NULL_POSITION);
298f7cf2976SLionel Sambuc }
299f7cf2976SLionel Sambuc if (c == EOI)
300f7cf2976SLionel Sambuc {
301f7cf2976SLionel Sambuc null_line();
302f7cf2976SLionel Sambuc return (NULL_POSITION);
303f7cf2976SLionel Sambuc }
304f7cf2976SLionel Sambuc (void) ch_forw_get();
305f7cf2976SLionel Sambuc }
306f7cf2976SLionel Sambuc }
307f7cf2976SLionel Sambuc
308f7cf2976SLionel Sambuc /*
309f7cf2976SLionel Sambuc * Scan backwards until we hit the beginning of the line.
310f7cf2976SLionel Sambuc */
311f7cf2976SLionel Sambuc for (;;)
312f7cf2976SLionel Sambuc {
313f7cf2976SLionel Sambuc if (ABORT_SIGS())
314f7cf2976SLionel Sambuc {
315f7cf2976SLionel Sambuc null_line();
316f7cf2976SLionel Sambuc return (NULL_POSITION);
317f7cf2976SLionel Sambuc }
318f7cf2976SLionel Sambuc c = ch_back_get();
319f7cf2976SLionel Sambuc if (c == '\n')
320f7cf2976SLionel Sambuc {
321f7cf2976SLionel Sambuc /*
322f7cf2976SLionel Sambuc * This is the newline ending the previous line.
323f7cf2976SLionel Sambuc * We have hit the beginning of the line.
324f7cf2976SLionel Sambuc */
325f7cf2976SLionel Sambuc base_pos = ch_tell() + 1;
326f7cf2976SLionel Sambuc break;
327f7cf2976SLionel Sambuc }
328f7cf2976SLionel Sambuc if (c == EOI)
329f7cf2976SLionel Sambuc {
330f7cf2976SLionel Sambuc /*
331f7cf2976SLionel Sambuc * We have hit the beginning of the file.
332f7cf2976SLionel Sambuc * This must be the first line in the file.
333f7cf2976SLionel Sambuc * This must, of course, be the beginning of the line.
334f7cf2976SLionel Sambuc */
335f7cf2976SLionel Sambuc base_pos = ch_tell();
336f7cf2976SLionel Sambuc break;
337f7cf2976SLionel Sambuc }
338f7cf2976SLionel Sambuc }
339f7cf2976SLionel Sambuc
340f7cf2976SLionel Sambuc /*
341f7cf2976SLionel Sambuc * Now scan forwards from the beginning of this line.
342f7cf2976SLionel Sambuc * We keep discarding "printable lines" (based on screen width)
343f7cf2976SLionel Sambuc * until we reach the curr_pos.
344f7cf2976SLionel Sambuc *
345f7cf2976SLionel Sambuc * {{ This algorithm is pretty inefficient if the lines
346f7cf2976SLionel Sambuc * are much longer than the screen width,
347f7cf2976SLionel Sambuc * but I don't know of any better way. }}
348f7cf2976SLionel Sambuc */
349f7cf2976SLionel Sambuc new_pos = base_pos;
350f7cf2976SLionel Sambuc if (ch_seek(new_pos))
351f7cf2976SLionel Sambuc {
352f7cf2976SLionel Sambuc null_line();
353f7cf2976SLionel Sambuc return (NULL_POSITION);
354f7cf2976SLionel Sambuc }
355f7cf2976SLionel Sambuc endline = FALSE;
356f7cf2976SLionel Sambuc prewind();
357f7cf2976SLionel Sambuc plinenum(new_pos);
358f7cf2976SLionel Sambuc loop:
359f7cf2976SLionel Sambuc begin_new_pos = new_pos;
360f7cf2976SLionel Sambuc (void) ch_seek(new_pos);
361f7cf2976SLionel Sambuc
362f7cf2976SLionel Sambuc do
363f7cf2976SLionel Sambuc {
364f7cf2976SLionel Sambuc c = ch_forw_get();
365f7cf2976SLionel Sambuc if (c == EOI || ABORT_SIGS())
366f7cf2976SLionel Sambuc {
367f7cf2976SLionel Sambuc null_line();
368f7cf2976SLionel Sambuc return (NULL_POSITION);
369f7cf2976SLionel Sambuc }
370f7cf2976SLionel Sambuc new_pos++;
371f7cf2976SLionel Sambuc if (c == '\n')
372f7cf2976SLionel Sambuc {
373f7cf2976SLionel Sambuc backchars = pflushmbc();
374f7cf2976SLionel Sambuc if (backchars > 0 && !chopline && hshift == 0)
375f7cf2976SLionel Sambuc {
376f7cf2976SLionel Sambuc backchars++;
377f7cf2976SLionel Sambuc goto shift;
378f7cf2976SLionel Sambuc }
379f7cf2976SLionel Sambuc endline = TRUE;
380f7cf2976SLionel Sambuc break;
381f7cf2976SLionel Sambuc }
382f7cf2976SLionel Sambuc backchars = pappend(c, ch_tell()-1);
383f7cf2976SLionel Sambuc if (backchars > 0)
384f7cf2976SLionel Sambuc {
385f7cf2976SLionel Sambuc /*
386f7cf2976SLionel Sambuc * Got a full printable line, but we haven't
387f7cf2976SLionel Sambuc * reached our curr_pos yet. Discard the line
388f7cf2976SLionel Sambuc * and start a new one.
389f7cf2976SLionel Sambuc */
390f7cf2976SLionel Sambuc if (chopline || hshift > 0)
391f7cf2976SLionel Sambuc {
392f7cf2976SLionel Sambuc endline = TRUE;
393f7cf2976SLionel Sambuc quit_if_one_screen = FALSE;
394f7cf2976SLionel Sambuc break;
395f7cf2976SLionel Sambuc }
396f7cf2976SLionel Sambuc shift:
397f7cf2976SLionel Sambuc pshift_all();
398f7cf2976SLionel Sambuc while (backchars-- > 0)
399f7cf2976SLionel Sambuc {
400f7cf2976SLionel Sambuc (void) ch_back_get();
401f7cf2976SLionel Sambuc new_pos--;
402f7cf2976SLionel Sambuc }
403f7cf2976SLionel Sambuc goto loop;
404f7cf2976SLionel Sambuc }
405f7cf2976SLionel Sambuc } while (new_pos < curr_pos);
406f7cf2976SLionel Sambuc
407f7cf2976SLionel Sambuc pdone(endline, 0);
408f7cf2976SLionel Sambuc
409f7cf2976SLionel Sambuc #if HILITE_SEARCH
410f7cf2976SLionel Sambuc if (is_filtered(base_pos))
411f7cf2976SLionel Sambuc {
412f7cf2976SLionel Sambuc /*
413f7cf2976SLionel Sambuc * We don't want to display this line.
414f7cf2976SLionel Sambuc * Get the previous line.
415f7cf2976SLionel Sambuc */
416f7cf2976SLionel Sambuc curr_pos = begin_new_pos;
417f7cf2976SLionel Sambuc goto get_back_line;
418f7cf2976SLionel Sambuc }
419f7cf2976SLionel Sambuc
420*84d9c625SLionel Sambuc if (status_col && curr_pos > 0 && is_hilited(base_pos, curr_pos-1, 1, NULL))
421f7cf2976SLionel Sambuc set_status_col('*');
422f7cf2976SLionel Sambuc #endif
423f7cf2976SLionel Sambuc
424f7cf2976SLionel Sambuc return (begin_new_pos);
425f7cf2976SLionel Sambuc }
426f7cf2976SLionel Sambuc
427f7cf2976SLionel Sambuc /*
428f7cf2976SLionel Sambuc * Set attnpos.
429f7cf2976SLionel Sambuc */
430f7cf2976SLionel Sambuc public void
set_attnpos(pos)431f7cf2976SLionel Sambuc set_attnpos(pos)
432f7cf2976SLionel Sambuc POSITION pos;
433f7cf2976SLionel Sambuc {
434f7cf2976SLionel Sambuc int c;
435f7cf2976SLionel Sambuc
436f7cf2976SLionel Sambuc if (pos != NULL_POSITION)
437f7cf2976SLionel Sambuc {
438f7cf2976SLionel Sambuc if (ch_seek(pos))
439f7cf2976SLionel Sambuc return;
440f7cf2976SLionel Sambuc for (;;)
441f7cf2976SLionel Sambuc {
442f7cf2976SLionel Sambuc c = ch_forw_get();
443f7cf2976SLionel Sambuc if (c == EOI)
444f7cf2976SLionel Sambuc return;
445f7cf2976SLionel Sambuc if (c != '\n' && c != '\r')
446f7cf2976SLionel Sambuc break;
447f7cf2976SLionel Sambuc pos++;
448f7cf2976SLionel Sambuc }
449f7cf2976SLionel Sambuc }
450f7cf2976SLionel Sambuc start_attnpos = pos;
451f7cf2976SLionel Sambuc for (;;)
452f7cf2976SLionel Sambuc {
453f7cf2976SLionel Sambuc c = ch_forw_get();
454f7cf2976SLionel Sambuc pos++;
455f7cf2976SLionel Sambuc if (c == EOI || c == '\n' || c == '\r')
456f7cf2976SLionel Sambuc break;
457f7cf2976SLionel Sambuc }
458f7cf2976SLionel Sambuc end_attnpos = pos;
459f7cf2976SLionel Sambuc }
460