Comment VT52, ANSI defines out of levee.h so they can be done on the command line.
Remove dead code.
Disambiguate levee code from standard library functions (as the original author has
done in later versions than we are using):
refresh -> lvrefresh
scan -> lvscan
getcontext -> lvgetcontext
getline -> lvgetline
mvcur(int y, int x)
{
static char gt[30];
-
+
if (y == -1)
y = curpos.y;
else
{
char nb[10];
register int size;
-
+
numtoa(nb,num);
size = min(strlen(nb),COLS-curpos.x);
if (size > 0) {
register int size;
char buf[MAXCOLS+1];
register int bi = 0;
-
+
endd = fseekeol(start);
if (start==0 || core[start-1] == EOL)
mvcur(y, 0);
/* redraw && refresh the screen */
PROC
-refresh(int y,int x,int start,int endd, bool rest)
+lvrefresh(int y,int x,int start,int endd, bool rest)
{
int sp;
-
+
#if ST
/* turn the cursor off */
asm(" clr.l -(sp) ");
{
if (flag)
clrprompt();
- refresh(0, 0, ptop, pend, TRUE);
+ lvrefresh(0, 0, ptop, pend, TRUE);
}
-
+
PROC
scrollback(int curr)
{
ok_to_scroll(int top, int bottom)
{
int nl, i;
-
+
nl = dofscroll;
i = top;
do
- i += 1+scan(bufmax-i,'=',EOL, &core[i]);
+ i += 1 + lvscan(bufmax-i,'=',EOL, &core[i]);
while (--nl > 0 && i < bottom);
return(nl>0);
}
else {
yp = setY(curr);
if (endY != setY(newend)) /* shuffled lines */
- refresh(setY(disp), setX(disp), disp, pend, TRUE);
+ lvrefresh(setY(disp), setX(disp), disp, pend, TRUE);
else /* refresh to end position */
- refresh(setY(disp), setX(disp), disp, newend, FALSE);
+ lvrefresh(setY(disp), setX(disp), disp, newend, FALSE);
}
if (curr >= bufmax && bufmax > 0) { /* adjust off end of buffer */
setpos(bufmax-1);
extern
struct undostack undo; /* To undo a command */
/* R A N D O M S T R I N G S */
-
+
extern
char instring[], /* Latest input */
filenm[], /* Filename */
altnm[], /* Alternate filename */
gcb[]; /* Command buffer for mutations of insert */
-
+
extern
char undobuf[],
undotmp[],
extern
char rcb[], *rcp, /* last modification command */
core[]; /* data space */
-
+
extern
struct ybuf yank; /* last deleted/yanked text */
/* STATIC INITIALIZATIONS: */
ED_REVISION, /* Small revisions & corrections */
fismod[], /* File is modified message */
fisro[]; /* permission denied message */
-
+
extern
char *excmds[],
wordset[],
wrapscan,
bell,
magic;
-/*extern
+/*extern
char *suffix; */
/* For movement routines */
extern
/* Where the last diddling left us */
extern
struct coord curpos;
-
+
/* initialize the buffer */
extern
int curr, /* Global cursor pos */
lineonly, /* Dumb terminal? */
zotscreen, /* do more after command in execmode */
diddled; /* force redraw when I enter editcore */
-
+
extern
int macro; /* Index into MCR macro execution stack */
extern
#endif /*GLOBALS_D*/
#ifndef EXTERN_D
#define EXTERN_D
-#define wc(ch) (scan(65,'=',(ch),wordset)<65)
+#define wc(ch) (lvscan(65,'=',(ch),wordset)<65)
#if SYS5
#define fillchar(p,l,c) memset((p),(c),(l))
#endif /*ST*/
#endif /*SYS5*/
/* non int functions to be found elsewhere */
-
+
#if 0
extern findstates findCP();
extern exec_type editcore();
}
return FALSE;
}
-
+
int PROC
amatch(char *pattern, char *start, char *endp)
{
patsize(char **pattern)
{
register int count;
-
+
switch (**pattern) {
case LITCHAR:
*pattern += 2;
{
register char *p = 1+pattern;
register int count;
-
+
if ((count = (*p++)&0xff) == 0)
return FALSE;
while (count--)
RE_start[arg] = RE_size[arg] = (-1);
arg = 0;
p = pattern;
-
+
while ((*string != delim) && (*string != 0)) {
oldcp = cp;
cp = p;
-
+
if (!magic) /* kludge for nonmagical patterns */
goto normal;
if (*string == ANY)
count = 0;
while (*src >= '0' && *src <= '9')
count = (count*10) + *(src++) - '0';
-
+
addr = to_index(count);
break;
case '$':
break;
case '`':
case '\'':
- addr = getcontext(*(src+1), (*src == '\''));
+ addr = lvgetcontext(*(src+1), (*src == '\''));
src += 2;
break;
}
int PROC
fseekeol(int origin)
{
- return(origin + scan(bufmax-origin-1,'=',EOL,&core[origin]));
+ return(origin + lvscan(bufmax-origin-1,'=',EOL,&core[origin]));
}
int PROC
bseekeol(int origin)
{
- return(origin + scan(-origin,'=',EOL,&core[origin-1]));
+ return(origin + lvscan(-origin,'=',EOL,&core[origin-1]));
}
/* get something from the context table */
int PROC
-getcontext(char c, bool begline)
+lvgetcontext(char c, bool begline)
{
int i;
-
+
if (c == '\'')
c = '`';
if (c >= '`' && c <= 'z')
#include "levee.h"
#define GLOBALS
-char lastchar, /* Last character read via peekc */
- ch; /* Global command char */
+char lastchar, /* Last character read via peekc */
+ ch; /* Global command char */
exec_type mode; /* editor init state */
int lastexec = 0; /* last exec command */
adjendp[PARA_BACK+1];
/* A R G U M E N T S */
-char startcmd[80] = ""; /* initial command after read */
-char **argv; /* Arguments */
-int argc=0, /* # arguments */
- pc=0; /* Index into arguments */
+char startcmd[80] = ""; /* initial command after read */
+char **argv; /* Arguments */
+int argc=0, /* # arguments */
+ pc=0; /* Index into arguments */
#if 0
-struct stat thisfile; /* status on current file, for writeout... */
+struct stat thisfile; /* status on current file, for writeout... */
#endif
/* M A C R O S T U F F */
struct macrecord mbuffer[MAXMACROS];
-struct tmacro mcr[NMACROS]; /* A place for executing macros */
+struct tmacro mcr[NMACROS]; /* A place for executing macros */
/* S E A R C H S T U F F */
-char dst[80] = "", /* last replacement pattern */
- lastpatt[80] = "", /* last search pattern */
- pattern[MAXPAT] = ""; /* encoded last pattern */
+char dst[80] = "", /* last replacement pattern */
+ lastpatt[80] = "", /* last search pattern */
+ pattern[MAXPAT] = ""; /* encoded last pattern */
-int RE_start[9], /* start of substitution arguments */
- RE_size [9], /* size of substitution arguments */
- lastp; /* end of last pattern */
+int RE_start[9], /* start of substitution arguments */
+ RE_size [9], /* size of substitution arguments */
+ lastp; /* end of last pattern */
-struct undostack undo; /* To undo a command */
+struct undostack undo; /* To undo a command */
/* R A N D O M S T R I N G S */
-char instring[80], /* Latest input */
- filenm[80] = "", /* Filename */
- altnm[80] = ""; /* Alternate filename */
-char gcb[16]; /* Command buffer for mutations of insert */
+char instring[80], /* Latest input */
+ filenm[80] = "", /* Filename */
+ altnm[80] = ""; /* Alternate filename */
+char gcb[16]; /* Command buffer for mutations of insert */
char undobuf[40];
char undotmp[40];
char yankbuf[40];
-HANDLE uread, /* reading from the undo stack */
- uwrite; /* writing to the undo stack */
+HANDLE uread, /* reading from the undo stack */
+ uwrite; /* writing to the undo stack */
- /* B U F F E R S */
-char rcb[256]; /* last modification command */
-char *rcp; /* this points at the end of the redo */
-char core[SIZE+1]; /* data space */
+ /* B U F F E R S */
+char rcb[256]; /* last modification command */
+char *rcp; /* this points at the end of the redo */
+char core[SIZE+1]; /* data space */
-struct ybuf yank; /* last deleted/yanked text */
+struct ybuf yank; /* last deleted/yanked text */
/* STATIC INITIALIZATIONS: */
char ED_NOTICE[] = "(c)3.4", /* Editor version */
ED_REVISION = 'm', /* Small revisions & corrections */
fismod[] = "File is modified", /* File is modified message */
- fisro[] = "File is readonly"; /* when you can't write the file */
+ fisro[] = "File is readonly"; /* When you can't write the file */
char *excmds[] = {
"print", /* lines to screen */
/* Where the last diddling left us */
struct coord curpos={0, 0};
- /* initialize the buffer */
+/* Initialize the buffer */
int bufmax = 0, /* End of file here */
lstart = 0, lend = 0, /* Start & end of current line */
ptop = 0, pend = 0, /* Top & bottom of CRT window */
int macro = -1; /* Index into MCR */
char nlsearch = 0; /* for N and n'ing... */
-/* movement, command codes */
-
+/* Movement, command codes */
cmdtype movemap[256]={
/*^@*/ BAD_COMMAND,
/*^A*/ DEBUG_C,
/*^]*/ BAD_COMMAND,
/*^^*/ BAD_COMMAND,
/*^_*/ BAD_COMMAND,
- /* */ GO_RIGHT,
+ /* */ GO_RIGHT, /* 0x20 */
/*! */ BAD_COMMAND,
/*" */ BAD_COMMAND,
/*# */ BAD_COMMAND,
/*- */ CR_BACK,
/*. */ REDO_C,
/*/ */ PATT_FWD,
- /*0 */ BAD_COMMAND,
+ /*0 */ BAD_COMMAND, /* 0x30 */
/*1 */ BAD_COMMAND,
/*2 */ BAD_COMMAND,
/*3 */ BAD_COMMAND,
/*= */ BAD_COMMAND,
/*> */ ADJUST_C,
/*? */ PATT_BACK,
- /*@ */ BAD_COMMAND,
+ /*@ */ BAD_COMMAND, /* 0x40 */
/*A */ A_AT_END,
/*B */ BACK_WD,
/*C */ HARDMACRO,
/*M */ PAGE_MIDDLE,
/*N */ BSEARCH,
/*O */ OPENUP_C,
- /*P */ PUT_AFTER,
+ /*P */ PUT_AFTER, /* 0x50 */
/*Q */ EDIT_C,
/*R */ BIG_REPL_C,
/*S */ BAD_COMMAND,
/*] */ BAD_COMMAND,
/*^ */ NOTWHITE,
/*_ */ BAD_COMMAND,
- /*` */ TO_MARK,
+ /*` */ TO_MARK, /* 0x60 */
/*a */ APPEND_C,
/*b */ BACK_WD,
/*c */ CHANGE_C,
/*m */ MARKER_C,
/*n */ FSEARCH,
/*o */ OPEN_C,
- /*p */ PUT_BEFORE,
+ /*p */ PUT_BEFORE, /* 0x70 */
/*q */ BAD_COMMAND,
/*r */ REPLACE_C,
/*s */ HARDMACRO,
/*83*/ BAD_COMMAND,
/*84*/ BAD_COMMAND,
/*85*/ BAD_COMMAND,
+ /*86*/ BAD_COMMAND,
+ /*87*/ BAD_COMMAND,
+ /*88*/ BAD_COMMAND,
+ /*89*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*90*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
+ /*x6*/ BAD_COMMAND,
+ /*x7*/ BAD_COMMAND,
+ /*x8*/ BAD_COMMAND,
+ /*x9*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*A0*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
+ /*x6*/ BAD_COMMAND,
+ /*x7*/ BAD_COMMAND,
+ /*x8*/ BAD_COMMAND,
+ /*x9*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*B0*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
+ /*x6*/ BAD_COMMAND,
+ /*x7*/ BAD_COMMAND,
+ /*x8*/ BAD_COMMAND,
+ /*x9*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*C0*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
+ /*x6*/ BAD_COMMAND,
+ /*x7*/ BAD_COMMAND,
+ /*x8*/ BAD_COMMAND,
+ /*x9*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*D0*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
+ /*x6*/ BAD_COMMAND,
+ /*x7*/ BAD_COMMAND,
+ /*x8*/ BAD_COMMAND,
+ /*x9*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*E0*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
+ /*x6*/ BAD_COMMAND,
+ /*x7*/ BAD_COMMAND,
+ /*x8*/ BAD_COMMAND,
+ /*x9*/ BAD_COMMAND,
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND,
+ /*F0*/ BAD_COMMAND,
+ /*x1*/ BAD_COMMAND,
+ /*x2*/ BAD_COMMAND,
+ /*x3*/ BAD_COMMAND,
+ /*x4*/ BAD_COMMAND,
+ /*x5*/ BAD_COMMAND,
/*x6*/ BAD_COMMAND,
/*x7*/ BAD_COMMAND,
/*x8*/ BAD_COMMAND,
/*x9*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND,
- /*xx*/ BAD_COMMAND
+ /*xA*/ BAD_COMMAND,
+ /*xB*/ BAD_COMMAND,
+ /*xC*/ BAD_COMMAND,
+ /*xD*/ BAD_COMMAND,
+ /*xE*/ BAD_COMMAND,
+ /*xF*/ BAD_COMMAND
};
#define SYS5 1
/* what sort of terminal are you emulating? */
-#define VT52 1 /* this must be nonzero for the Atari ST */
+/* use "-DANSI=1 -DVT52=0" etc. on compile line */
+/*#define VT52 0*/ /* this must be nonzero for the Atari ST */
+/*#define ANSI 0*/
#define TERMCAP 0
#define ZTERM 0
-#define ANSI 0
#if ST
mode=emode;
do {
prompt(FALSE,":");
- if (getline(instring))
+ if (lvgetline(instring))
exec(instring, &mode, &noquit);
indirect = FALSE;
if (mode == E_VISUAL && zotscreen && noquit) { /*ask for more*/
#include "extern.h"
bool PROC
-getline(char *str)
+lvgetline(char *str)
{
int len;
char flag;
-
+
flag = line(str, 0, COLS-curpos.x, &len);
str[len] = 0;
strput(CE);
return (flag == EOL);
-} /* getline */
+} /* lvgetline */
char PROC
setX(int cp)
{
int top, xp;
-
+
top = bseekeol(cp);
xp = 0;
while (top < cp) {
setY(int cp)
{
int yp, ix;
-
+
ix = ptop;
yp = -1;
cp = min(cp,bufmax-1);
}
return(cp);
} /* to_index */
-
+
PROC
void swap(int *a, int *b)
{
int c;
-
+
c = *a;
*a = *b;
*b = c;
int PROC lookup(char c)
{
int ix = MAXMACROS;
-
+
while (--ix >= 0 && mbuffer[ix].token != c)
;
return ix;
void fixmarkers(int base, int offset)
{
char c;
-
+
for (c = 0;c<'z'-'`';c++)
if (contexts[c] > base)
if (contexts[c]+offset < base || contexts[c]+offset >= bufmax)
static int tabptr,
tabstack[20],
ixp;
-
+
PROC
void back_up(char c)
{
int col0,
ip;
char c;
-
+
col0 = ixp = curpos.x;
ip = start;
tabptr = 0;
void setend(void)
{
int bottom, count;
-
+
bottom = ptop;
count = LINES-1;
while (bottom < bufmax && count > 0) {
settop(int lines)
{
int top, yp;
-
+
top = curr;
yp = -1;
do {
*newpos = ERR;
switch (cmd) { /* move around */
-
+
case GO_LEFT:
*newpos = max(lstart, curp-max(count,1));
break;
case TO_MARK:
case TO_MARK_LINE:
- *newpos = getcontext((char)tolower(readchar()), cmd==TO_MARK_LINE);
+ *newpos = lvgetcontext((char)tolower(readchar()), cmd==TO_MARK_LINE);
break;
case CR_FWD:
clrprompt();
if (cmd == PATT_FWD || cmd == PATT_BACK) {
printch(tsearch = instring[0] = chars[cmd-PATT_FWD]);
- if (!getline(&instring[1]))
+ if (!lvgetline(&instring[1]))
return ESCAPED; /* needs to skip later tests */
}
else {
movearound(cmdtype cmd)
{
int cp;
-
+
switch (findCP(curr, &cp, cmd)) {
case LEGALMOVE:
if (cp < bufmax) {
}
mvcur(yp, xp);
}
-
+
int PROC
findcol(int ip, int col)
{
int tcol, endd;
-
+
ip = bseekeol(ip); /* start search here */
endd = fseekeol(ip); /* end search here */
{
char srcchar, dstchar;
int lev, step;
-
- while((lev = scan(6,'=',core[p],srcpatt)) >= 6 && core[p] != EOL)
+
+ while((lev = lvscan(6,'=',core[p],srcpatt)) >= 6 && core[p] != EOL)
p++;
if (lev < 6) {
srcchar = srcpatt[lev];
{
int step;
register char *ccl;
-
+
step = setstep[forwd]; /* set direction to move.. */
if (!toword)
cp += step; /* advance one character */
fchar(int pos, int npos)
{
do
- pos += scan(lend-pos-1,'=',ch, &core[pos+1]) + 1;
+ pos += lvscan(lend-pos-1,'=',ch, &core[pos+1]) + 1;
while (--count>0 && pos<lend);
if (pos<lend)
return(pos);
bchar(int pos, int npos)
{
do
- pos += scan(-pos+lstart+1,'=',ch, &core[pos-1]) - 1;
+ pos += lvscan(-pos+lstart+1,'=',ch, &core[pos-1]) - 1;
while (--count>0 && pos>=lstart);
if (pos>=lstart)
return(pos);
-/*
-** levee function prototypes
-** (generated by cl -Gms -Ox -nologo -I../tools -Zg)
-*/
-#ifndef _PROTO_D
-#define _PROTO_D
+/*
+** levee function prototypes
+** (generated by cl -Gms -Ox -nologo -I../tools -Zg)
+*/
+#ifndef _PROTO_D
+#define _PROTO_D
char *PROC badccl(char *src);
char *PROC class(char c);
char *PROC dodash(char *src);
char *PROC makepat(char *string,char delim);
char *PROC search(char *pat,int *start);
char *basename(char *s);
-char *glob(char *path,struct glob_t *dta);
+//char *glob(char *path,struct glob_t *dta);
char PROC editcore(void);
char PROC esc(char * *s);
char PROC findCP(int curp,int *newpos,char cmd);
int PROC fseekeol(int origin);
int PROC gcount(void);
int PROC getKey(void);
-int PROC getcontext(char c,int begline);
-int PROC getline(char *str);
+int PROC lvgetcontext(char c,int begline);
+int PROC lvgetline(char *str);
void PROC initialize(int count,char * *args);
int PROC inputf(char *fname,int newbuf);
int PROC insert_to_undo(struct undostack *u,int start,int size);
int PROC putin(struct undostack *save_undo,int *curp);
int PROC readfile(void);
int PROC redisplay(int flag);
-int PROC refresh(int y,int x,int start,int endd,int rest);
+int PROC lvrefresh(int y,int x,int start,int endd,int rest);
void PROC resetX(void);
-int PROC scan(int length,char tst,char ch,char *src);
+int PROC lvscan(int length,char tst,char ch,char *src);
int PROC scroll(int down);
int PROC scrollback(int curr);
int PROC scrollforward(int curr);
void main(int argc,char *argv[]);
void PROC initcon(void);
void PROC fixcon(void);
-#endif /*_PROTO_D*/
+#endif /*_PROTO_D*/
#endif
int PROC
-scan(int length, char tst, char ch, char *src)
+lvscan(int length, char tst, char ch, char *src)
{
register int inc,l;
-
+
if (length < 0)
inc = -1;
else
struct termios new;
if (!ioset) {
- tcgetattr(0, &old);
- /*ioctl(0, TCGETS, &old);*/ /* get editing keys */
+ tcgetattr(0, &old); /* preserve current terminal setup */
erasechar = old.c_cc[VERASE];
eraseline = old.c_cc[VKILL];
new.c_lflag &= ~(ICANON|ISIG|ECHO);
new.c_oflag = 0;
- tcsetattr(0, TCSANOW, &new);
- /*ioctl(0, TCSETS, &new);*/
+ tcsetattr(0, TCSANOW, &new); /* terminal setup for editor */
ioset=1;
}
}
void fixcon(void)
{
if (ioset) {
- tcsetattr(0, TCSANOW, &old);
- /*ioctl(0, TCSETS, &old);*/
-/* More or less blind attempt to fix console corruption.
- T. Huld 1998-05-19
- ioctl(0, TCSETA, &old);
-*/
+ tcsetattr(0, TCSANOW, &old); /* restore original terminal setup */
ioset = 0;
}
}