home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d01xx
/
d0197.lha
/
Stevie
/
linefunc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-03-28
|
2KB
|
94 lines
/*
* STEVIE - Simply Try this Editor for VI Enthusiasts
*
* Code Contributions By : Tim Thompson twitch!tjt
* Tony Andrews onecom!wldrdg!tony
* G. R. (Fred) Walter watmath!watcgl!grwalter
*/
#include "stevie.h"
/*
* nextline(curr)
*
* Return a pointer to the beginning of the next line after the one referenced
* by 'curr'. Return NULL if there is no next line (at EOF).
*/
LPtr *
nextline(curr)
LPtr *curr;
{
static LPtr next;
if (curr != NULL) {
if (curr->linep->next != Fileend->linep) {
next.index = 0;
next.linep = curr->linep->next;
return &next;
}
}
return (LPtr *) NULL;
}
/*
* prevline(curr)
*
* Return a pointer to the beginning of the line before the one referenced by
* 'curr'. Return NULL if there is no prior line.
*/
LPtr *
prevline(curr)
LPtr *curr;
{
static LPtr prev;
if (curr != NULL) {
if (curr->linep->prev != Filetop->linep) {
prev.index = 0;
prev.linep = curr->linep->prev;
return &prev;
}
}
return (LPtr *) NULL;
}
/*
* coladvance(p,col)
*
* Try to advance to the specified column, starting at p.
*/
LPtr *
coladvance(p, col)
LPtr *p;
int col;
{
static LPtr lp;
int c, in;
lp.linep = p->linep;
lp.index = p->index;
/* If we're on a blank ('\n' only) line, we can't do anything */
if (lp.linep->s[lp.index] == '\0')
return &lp;
/* try to advance to the specified column */
for (c = 0; col-- > 0; c++) {
/* Count a tab for what it's worth (if list mode not on) */
if (gchar(&lp) == TAB && !P(P_LS)) {
in = ((P(P_TS) - 1) - c % P(P_TS));
col -= in;
c += in;
}
/* Don't go past the end of */
/* the file or the line. */
if (inc(&lp)) {
dec(&lp);
break;
}
}
return &lp;
}