mirror of
https://github.com/rfivet/uemacs.git
synced 2025-02-20 23:17:13 -05:00
Run "indent -kr -i8" on the sources
Let's see how nasty it is to clean things up. For real.
This commit is contained in:
parent
1f6239bfeb
commit
435dd32ae2
71
ansi.c
71
ansi.c
@ -58,11 +58,11 @@ int cbcolor = -1; /* current background color */
|
||||
*/
|
||||
TERM term = {
|
||||
#if PKCODE
|
||||
MROW-1,
|
||||
MROW - 1,
|
||||
#else
|
||||
NROW-1,
|
||||
NROW - 1,
|
||||
#endif
|
||||
NROW-1,
|
||||
NROW - 1,
|
||||
NCOL,
|
||||
NCOL,
|
||||
MARGIN,
|
||||
@ -91,8 +91,8 @@ TERM term = {
|
||||
};
|
||||
|
||||
#if COLOR
|
||||
ansifcol(color) /* set the current output color */
|
||||
|
||||
ansifcol(color)
|
||||
/* set the current output color */
|
||||
int color; /* color to set */
|
||||
|
||||
{
|
||||
@ -100,13 +100,13 @@ int color; /* color to set */
|
||||
return;
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ansiparm(color+30);
|
||||
ansiparm(color + 30);
|
||||
ttputc('m');
|
||||
cfcolor = color;
|
||||
}
|
||||
|
||||
ansibcol(color) /* set the current background color */
|
||||
|
||||
ansibcol(color)
|
||||
/* set the current background color */
|
||||
int color; /* color to set */
|
||||
|
||||
{
|
||||
@ -114,7 +114,7 @@ int color; /* color to set */
|
||||
return;
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ansiparm(color+40);
|
||||
ansiparm(color + 40);
|
||||
ttputc('m');
|
||||
cbcolor = color;
|
||||
}
|
||||
@ -124,9 +124,9 @@ ansimove(row, col)
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ansiparm(row+1);
|
||||
ansiparm(row + 1);
|
||||
ttputc(';');
|
||||
ansiparm(col+1);
|
||||
ansiparm(col + 1);
|
||||
ttputc('H');
|
||||
}
|
||||
|
||||
@ -148,8 +148,8 @@ ansieeop()
|
||||
ttputc('J');
|
||||
}
|
||||
|
||||
ansirev(state) /* change reverse video state */
|
||||
|
||||
ansirev(state)
|
||||
/* change reverse video state */
|
||||
int state; /* TRUE = reverse, FALSE = normal */
|
||||
|
||||
{
|
||||
@ -159,7 +159,7 @@ int state; /* TRUE = reverse, FALSE = normal */
|
||||
|
||||
ttputc(ESC);
|
||||
ttputc('[');
|
||||
ttputc(state ? '7': '0');
|
||||
ttputc(state ? '7' : '0');
|
||||
ttputc('m');
|
||||
#if COLOR
|
||||
if (state == FALSE) {
|
||||
@ -173,15 +173,13 @@ int state; /* TRUE = reverse, FALSE = normal */
|
||||
#endif
|
||||
}
|
||||
|
||||
ansicres() /* change screen resolution */
|
||||
|
||||
{
|
||||
return(TRUE);
|
||||
ansicres()
|
||||
{ /* change screen resolution */
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
spal(dummy) /* change pallette settings */
|
||||
|
||||
{
|
||||
spal(dummy)
|
||||
{ /* change pallette settings */
|
||||
/* none for now */
|
||||
}
|
||||
|
||||
@ -194,17 +192,17 @@ ansibeep()
|
||||
ansiparm(n)
|
||||
register int n;
|
||||
{
|
||||
register int q,r;
|
||||
register int q, r;
|
||||
|
||||
q = n/10;
|
||||
q = n / 10;
|
||||
if (q != 0) {
|
||||
r = q/10;
|
||||
r = q / 10;
|
||||
if (r != 0) {
|
||||
ttputc((r%10)+'0');
|
||||
ttputc((r % 10) + '0');
|
||||
}
|
||||
ttputc((q%10) + '0');
|
||||
ttputc((q % 10) + '0');
|
||||
}
|
||||
ttputc((n%10) + '0');
|
||||
ttputc((n % 10) + '0');
|
||||
}
|
||||
|
||||
ansiopen()
|
||||
@ -228,7 +226,6 @@ ansiopen()
|
||||
}
|
||||
|
||||
ansiclose()
|
||||
|
||||
{
|
||||
#if COLOR
|
||||
ansifcol(7);
|
||||
@ -237,24 +234,22 @@ ansiclose()
|
||||
ttclose();
|
||||
}
|
||||
|
||||
ansikopen() /* open the keyboard (a noop here) */
|
||||
|
||||
{
|
||||
ansikopen()
|
||||
{ /* open the keyboard (a noop here) */
|
||||
}
|
||||
|
||||
ansikclose() /* close the keyboard (a noop here) */
|
||||
|
||||
{
|
||||
ansikclose()
|
||||
{ /* close the keyboard (a noop here) */
|
||||
}
|
||||
|
||||
#if FNLABEL
|
||||
fnclabel(f, n) /* label a function key */
|
||||
|
||||
int f,n; /* default flag, numeric argument [unused] */
|
||||
fnclabel(f, n)
|
||||
/* label a function key */
|
||||
int f, n; /* default flag, numeric argument [unused] */
|
||||
|
||||
{
|
||||
/* on machines with no function keys...don't bother */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
58
basic.c
58
basic.c
@ -39,7 +39,7 @@ register int n;
|
||||
return (forwchar(f, -n));
|
||||
while (n--) {
|
||||
if (curwp->w_doto == 0) {
|
||||
if ((lp=lback(curwp->w_dotp)) == curbp->b_linep)
|
||||
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep)
|
||||
return (FALSE);
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = llength(lp);
|
||||
@ -83,30 +83,30 @@ register int n;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
gotoline(f, n) /* move to a particular line.
|
||||
gotoline(f, n)
|
||||
{ /* move to a particular line.
|
||||
argument (n) must be a positive integer for
|
||||
this to actually do anything */
|
||||
|
||||
{
|
||||
register int status; /* status return */
|
||||
char arg[NSTRING]; /* buffer to hold argument */
|
||||
|
||||
/* get an argument if one doesnt exist */
|
||||
if (f == FALSE) {
|
||||
if ((status = mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
|
||||
if ((status =
|
||||
mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
|
||||
mlwrite("(Aborted)");
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
n = atoi(arg);
|
||||
}
|
||||
|
||||
if (n < 1) /* if a bogus argument...then leave */
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* first, we go to the start of the buffer */
|
||||
curwp->w_dotp = lforw(curbp->b_linep);
|
||||
curwp->w_doto = 0;
|
||||
return(forwline(f, n-1));
|
||||
return (forwline(f, n - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -150,11 +150,11 @@ forwline(f, n)
|
||||
|
||||
/* if we are on the last line as we start....fail the command */
|
||||
if (curwp->w_dotp == curbp->b_linep)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* if the last command was not note a line move,
|
||||
reset the goal column */
|
||||
if ((lastflag&CFCPCN) == 0)
|
||||
if ((lastflag & CFCPCN) == 0)
|
||||
curgoal = getccol(FALSE);
|
||||
|
||||
/* flag this command as a line move */
|
||||
@ -162,7 +162,7 @@ forwline(f, n)
|
||||
|
||||
/* and move the point down */
|
||||
dlp = curwp->w_dotp;
|
||||
while (n-- && dlp!=curbp->b_linep)
|
||||
while (n-- && dlp != curbp->b_linep)
|
||||
dlp = lforw(dlp);
|
||||
|
||||
/* reseting the current position */
|
||||
@ -188,11 +188,11 @@ backline(f, n)
|
||||
|
||||
/* if we are on the last line as we start....fail the command */
|
||||
if (lback(curwp->w_dotp) == curbp->b_linep)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* if the last command was not note a line move,
|
||||
reset the goal column */
|
||||
if ((lastflag&CFCPCN) == 0)
|
||||
if ((lastflag & CFCPCN) == 0)
|
||||
curgoal = getccol(FALSE);
|
||||
|
||||
/* flag this command as a line move */
|
||||
@ -200,7 +200,7 @@ backline(f, n)
|
||||
|
||||
/* and move the point up */
|
||||
dlp = curwp->w_dotp;
|
||||
while (n-- && lback(dlp)!=curbp->b_linep)
|
||||
while (n-- && lback(dlp) != curbp->b_linep)
|
||||
dlp = lback(dlp);
|
||||
|
||||
/* reseting the current position */
|
||||
@ -211,17 +211,17 @@ backline(f, n)
|
||||
}
|
||||
|
||||
#if WORDPRO
|
||||
gotobop(f, n) /* go back to the beginning of the current paragraph
|
||||
gotobop(f, n)
|
||||
/* go back to the beginning of the current paragraph
|
||||
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
|
||||
combination to delimit the beginning of a paragraph */
|
||||
|
||||
int f, n; /* default Flag & Numeric argument */
|
||||
|
||||
{
|
||||
register int suc; /* success of last backchar */
|
||||
|
||||
if (n < 0) /* the other way...*/
|
||||
return(gotoeop(f, -n));
|
||||
if (n < 0) /* the other way... */
|
||||
return (gotoeop(f, -n));
|
||||
|
||||
while (n-- > 0) { /* for each one asked for */
|
||||
|
||||
@ -253,20 +253,20 @@ int f, n; /* default Flag & Numeric argument */
|
||||
suc = forwchar(FALSE, 1);
|
||||
}
|
||||
curwp->w_flag |= WFMOVE; /* force screen update */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
gotoeop(f, n) /* go forword to the end of the current paragraph
|
||||
gotoeop(f, n)
|
||||
/* go forword to the end of the current paragraph
|
||||
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
|
||||
combination to delimit the beginning of a paragraph */
|
||||
|
||||
int f, n; /* default Flag & Numeric argument */
|
||||
|
||||
{
|
||||
register int suc; /* success of last backchar */
|
||||
|
||||
if (n < 0) /* the other way...*/
|
||||
return(gotobop(f, -n));
|
||||
if (n < 0) /* the other way... */
|
||||
return (gotobop(f, -n));
|
||||
|
||||
while (n-- > 0) { /* for each one asked for */
|
||||
|
||||
@ -303,7 +303,7 @@ int f, n; /* default Flag & Numeric argument */
|
||||
curwp->w_doto = llength(curwp->w_dotp); /* and to the EOL */
|
||||
}
|
||||
curwp->w_flag |= WFMOVE; /* force screen update */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -327,7 +327,7 @@ register LINE *dlp;
|
||||
newcol = col;
|
||||
if (c == '\t')
|
||||
newcol |= tabmask;
|
||||
else if (c<0x20 || c==0x7F)
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
++newcol;
|
||||
++newcol;
|
||||
if (newcol > curgoal)
|
||||
@ -368,13 +368,13 @@ register int n;
|
||||
n *= curwp->w_ntrows; /* to lines. */
|
||||
#endif
|
||||
lp = curwp->w_linep;
|
||||
while (n-- && lp!=curbp->b_linep)
|
||||
while (n-- && lp != curbp->b_linep)
|
||||
lp = lforw(lp);
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = 0;
|
||||
#if SCROLLCODE
|
||||
curwp->w_flag |= WFHARD|WFKILLS;
|
||||
curwp->w_flag |= WFHARD | WFKILLS;
|
||||
#else
|
||||
curwp->w_flag |= WFHARD;
|
||||
#endif
|
||||
@ -411,13 +411,13 @@ register int n;
|
||||
n *= curwp->w_ntrows; /* to lines. */
|
||||
#endif
|
||||
lp = curwp->w_linep;
|
||||
while (n-- && lback(lp)!=curbp->b_linep)
|
||||
while (n-- && lback(lp) != curbp->b_linep)
|
||||
lp = lback(lp);
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = 0;
|
||||
#if SCROLLCODE
|
||||
curwp->w_flag |= WFHARD|WFINS;
|
||||
curwp->w_flag |= WFHARD | WFINS;
|
||||
#else
|
||||
curwp->w_flag |= WFHARD;
|
||||
#endif
|
||||
|
147
bind.c
147
bind.c
@ -14,10 +14,10 @@
|
||||
|
||||
extern int meta(), cex(), unarg(), ctrlg(); /* dummy prefix binding functions */
|
||||
|
||||
help(f, n) /* give me some help!!!!
|
||||
help(f, n)
|
||||
{ /* give me some help!!!!
|
||||
bring up a fake buffer and read the help file
|
||||
into it with view mode */
|
||||
{
|
||||
register WINDOW *wp; /* scaning pointer to windows */
|
||||
register BUFFER *bp; /* buffer pointer to help */
|
||||
char *fname; /* ptr to file returned by flook() */
|
||||
@ -29,18 +29,18 @@ help(f, n) /* give me some help!!!!
|
||||
fname = flook(pathname[1], FALSE);
|
||||
if (fname == NULL) {
|
||||
mlwrite("(Help file is not online)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* split the current window to make room for the help stuff */
|
||||
if (splitwind(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
if (bp == NULL) {
|
||||
/* and read the stuff in */
|
||||
if (getfile(fname, FALSE) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
} else
|
||||
swbuffer(bp);
|
||||
|
||||
@ -52,16 +52,15 @@ help(f, n) /* give me some help!!!!
|
||||
wp->w_flag |= WFMODE;
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
deskey(f, n) /* describe the command for a certain key */
|
||||
|
||||
{
|
||||
deskey(f, n)
|
||||
{ /* describe the command for a certain key */
|
||||
register int c; /* key to describe */
|
||||
register char *ptr; /* string pointer to scan output strings */
|
||||
char outseq[NSTRING]; /* output buffer for command sequence */
|
||||
int (*getbind())();
|
||||
int (*getbind()) ();
|
||||
|
||||
/* prompt the user to type us a key to describe */
|
||||
mlwrite(": describe-key ");
|
||||
@ -89,12 +88,12 @@ bindtokey(f, n)
|
||||
int f, n; /* command arguments [IGNORED] */
|
||||
|
||||
{
|
||||
register unsigned int c;/* command key to bind */
|
||||
register int (*kfunc)();/* ptr to the requested function to bind to */
|
||||
register unsigned int c; /* command key to bind */
|
||||
register int (*kfunc) (); /* ptr to the requested function to bind to */
|
||||
register KEYTAB *ktp; /* pointer into the command table */
|
||||
register int found; /* matched command flag */
|
||||
char outseq[80]; /* output buffer for keystroke sequence */
|
||||
int (*getname())();
|
||||
int (*getname()) ();
|
||||
|
||||
/* prompt the user to type in a key to bind */
|
||||
mlwrite(": bind-to-key ");
|
||||
@ -103,7 +102,7 @@ int f, n; /* command arguments [IGNORED] */
|
||||
kfunc = getname();
|
||||
if (kfunc == NULL) {
|
||||
mlwrite("(No such function)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
ostring(" ");
|
||||
|
||||
@ -158,7 +157,7 @@ int f, n; /* command arguments [IGNORED] */
|
||||
/* if we run out of binding room, bitch */
|
||||
if (ktp >= &keytab[NBINDS]) {
|
||||
mlwrite("Binding table FULL!");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
ktp->k_code = c; /* add keycode */
|
||||
@ -167,7 +166,7 @@ int f, n; /* command arguments [IGNORED] */
|
||||
ktp->k_code = 0;
|
||||
ktp->k_fp = NULL;
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* unbindkey: delete a key from the key binding table */
|
||||
@ -195,9 +194,9 @@ int f, n; /* command arguments [IGNORED] */
|
||||
/* if it isn't bound, bitch */
|
||||
if (unbindchar(c) == FALSE) {
|
||||
mlwrite("(Key not bound)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
unbindchar(c)
|
||||
@ -222,7 +221,7 @@ int c; /* command key to unbind */
|
||||
|
||||
/* if it isn't bound, bitch */
|
||||
if (!found)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* save the pointer and scan to the end of the table */
|
||||
sktp = ktp;
|
||||
@ -237,33 +236,32 @@ int c; /* command key to unbind */
|
||||
/* null out the last one */
|
||||
ktp->k_code = 0;
|
||||
ktp->k_fp = NULL;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
desbind(f, n) /* describe bindings
|
||||
desbind(f, n)
|
||||
/* describe bindings
|
||||
bring up a fake buffer and list the key bindings
|
||||
into it with view mode */
|
||||
|
||||
#if APROP
|
||||
{
|
||||
buildlist(TRUE, "");
|
||||
}
|
||||
|
||||
apro(f, n) /* Apropos (List functions that match a substring) */
|
||||
|
||||
{
|
||||
apro(f, n)
|
||||
{ /* Apropos (List functions that match a substring) */
|
||||
char mstring[NSTRING]; /* string to match cmd names to */
|
||||
int status; /* status return */
|
||||
|
||||
status = mlreply("Apropos string: ", mstring, NSTRING - 1);
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
return(buildlist(FALSE, mstring));
|
||||
return (buildlist(FALSE, mstring));
|
||||
}
|
||||
|
||||
buildlist(type, mstring) /* build a binding list (limited or full) */
|
||||
|
||||
buildlist(type, mstring)
|
||||
/* build a binding list (limited or full) */
|
||||
int type; /* true = full list, false = partial list */
|
||||
char *mstring; /* match string if a partial list */
|
||||
|
||||
@ -279,13 +277,13 @@ char *mstring; /* match string if a partial list */
|
||||
|
||||
/* split the current window to make room for the binding list */
|
||||
if (splitwind(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* and get a buffer for it */
|
||||
bp = bfind("*Binding list*", TRUE, 0);
|
||||
if (bp == NULL || bclear(bp) == FALSE) {
|
||||
mlwrite("Can not display binding list");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* let us know this is in progress */
|
||||
@ -306,7 +304,7 @@ char *mstring; /* match string if a partial list */
|
||||
wp = curwp;
|
||||
wp->w_bufp = bp;
|
||||
wp->w_linep = bp->b_linep;
|
||||
wp->w_flag = WFHARD|WFFORCE;
|
||||
wp->w_flag = WFHARD | WFFORCE;
|
||||
wp->w_dotp = bp->b_dotp;
|
||||
wp->w_doto = bp->b_doto;
|
||||
wp->w_markp = NULL;
|
||||
@ -341,7 +339,7 @@ char *mstring; /* match string if a partial list */
|
||||
|
||||
/* and add it as a line into the buffer */
|
||||
if (linstr(outseq) != TRUE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
cpos = 0; /* and clear the line */
|
||||
}
|
||||
@ -353,16 +351,16 @@ char *mstring; /* match string if a partial list */
|
||||
outseq[cpos++] = '\n';
|
||||
outseq[cpos] = 0;
|
||||
if (linstr(outseq) != TRUE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
fail: /* and on to the next name */
|
||||
fail: /* and on to the next name */
|
||||
++nptr;
|
||||
}
|
||||
|
||||
curwp->w_bufp->b_mode |= MDVIEW;/* put this buffer view mode */
|
||||
curwp->w_bufp->b_mode |= MDVIEW; /* put this buffer view mode */
|
||||
curbp->b_flag &= ~BFCHG; /* don't flag this as a change */
|
||||
wp->w_dotp = lforw(bp->b_linep);/* back to the beginning */
|
||||
wp->w_dotp = lforw(bp->b_linep); /* back to the beginning */
|
||||
wp->w_doto = 0;
|
||||
wp = wheadp; /* and update ALL mode lines */
|
||||
while (wp != NULL) {
|
||||
@ -370,12 +368,12 @@ fail: /* and on to the next name */
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
mlwrite(""); /* clear the mode line */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if APROP
|
||||
strinc(source, sub) /* does source include sub? */
|
||||
|
||||
strinc(source, sub)
|
||||
/* does source include sub? */
|
||||
char *source; /* string to search in */
|
||||
char *sub; /* substring to look for */
|
||||
|
||||
@ -400,12 +398,12 @@ char *sub; /* substring to look for */
|
||||
|
||||
/* yes, return a success */
|
||||
if (*tp == 0)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* no, onward */
|
||||
sp++;
|
||||
}
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -422,7 +420,7 @@ int mflag; /* going for a meta sequence? */
|
||||
/* check to see if we are executing a command line */
|
||||
if (clexec) {
|
||||
macarg(tok); /* get the next token */
|
||||
return(stock(tok));
|
||||
return (stock(tok));
|
||||
}
|
||||
|
||||
/* or the normal way */
|
||||
@ -430,7 +428,7 @@ int mflag; /* going for a meta sequence? */
|
||||
c = get1key();
|
||||
else
|
||||
c = getcmd();
|
||||
return(c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* execute the startup file */
|
||||
@ -450,10 +448,10 @@ char *sfname; /* name of startup file (null if default) */
|
||||
|
||||
/* if it isn't around, don't sweat it */
|
||||
if (fname == NULL)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* otherwise, execute the sucker */
|
||||
return(dofile(fname));
|
||||
return (dofile(fname));
|
||||
}
|
||||
|
||||
/* Look up the existance of a file along the normal or PATH
|
||||
@ -487,7 +485,7 @@ int hflag; /* Look in the HOME environment variable first? */
|
||||
/* and try it out */
|
||||
if (ffropen(fspec) == FIOSUC) {
|
||||
ffclose();
|
||||
return(fspec);
|
||||
return (fspec);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -496,9 +494,8 @@ int hflag; /* Look in the HOME environment variable first? */
|
||||
/* always try the current directory first */
|
||||
if (ffropen(fname) == FIOSUC) {
|
||||
ffclose();
|
||||
return(fname);
|
||||
return (fname);
|
||||
}
|
||||
|
||||
#if ENVFUNC
|
||||
/* get the PATH variable */
|
||||
path = getenv("PATH");
|
||||
@ -519,7 +516,7 @@ int hflag; /* Look in the HOME environment variable first? */
|
||||
/* and try it out */
|
||||
if (ffropen(fspec) == FIOSUC) {
|
||||
ffclose();
|
||||
return(fspec);
|
||||
return (fspec);
|
||||
}
|
||||
|
||||
if (*path == PATHCHR)
|
||||
@ -528,22 +525,22 @@ int hflag; /* Look in the HOME environment variable first? */
|
||||
#endif
|
||||
|
||||
/* look it up via the old table method */
|
||||
for (i=2; i < NPNAMES; i++) {
|
||||
for (i = 2; i < NPNAMES; i++) {
|
||||
strcpy(fspec, pathname[i]);
|
||||
strcat(fspec, fname);
|
||||
|
||||
/* and try it out */
|
||||
if (ffropen(fspec) == FIOSUC) {
|
||||
ffclose();
|
||||
return(fspec);
|
||||
return (fspec);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL); /* no such luck */
|
||||
return (NULL); /* no such luck */
|
||||
}
|
||||
|
||||
cmdstr(c, seq) /* change a key command to a string we can print out */
|
||||
|
||||
cmdstr(c, seq)
|
||||
/* change a key command to a string we can print out */
|
||||
int c; /* sequence to translate */
|
||||
char *seq; /* destination string for sequence */
|
||||
|
||||
@ -584,7 +581,7 @@ char *seq; /* destination string for sequence */
|
||||
|
||||
/* This function looks a key binding up in the binding table */
|
||||
|
||||
int (*getbind(c))()
|
||||
int (*getbind(c)) ()
|
||||
|
||||
int c; /* key to find what is bound to it */
|
||||
|
||||
@ -594,12 +591,12 @@ int c; /* key to find what is bound to it */
|
||||
ktp = &keytab[0]; /* Look in key table. */
|
||||
while (ktp->k_fp != NULL) {
|
||||
if (ktp->k_code == c)
|
||||
return(ktp->k_fp);
|
||||
return (ktp->k_fp);
|
||||
++ktp;
|
||||
}
|
||||
|
||||
/* no such binding */
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* getfname: This function takes a ptr to function and gets the name
|
||||
@ -608,7 +605,7 @@ int c; /* key to find what is bound to it */
|
||||
|
||||
char *getfname(func)
|
||||
|
||||
int (*func)(); /* ptr to the requested function to bind to */
|
||||
int (*func) (); /* ptr to the requested function to bind to */
|
||||
|
||||
{
|
||||
register NBIND *nptr; /* pointer into the name binding table */
|
||||
@ -617,15 +614,15 @@ int (*func)(); /* ptr to the requested function to bind to */
|
||||
nptr = &names[0];
|
||||
while (nptr->n_func != NULL) {
|
||||
if (nptr->n_func == func)
|
||||
return(nptr->n_name);
|
||||
return (nptr->n_name);
|
||||
++nptr;
|
||||
}
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int (*fncmatch(fname))() /* match fname to a function in the names table
|
||||
int (*fncmatch(fname)) ()
|
||||
/* match fname to a function in the names table
|
||||
and return any match or NULL if none */
|
||||
|
||||
char *fname; /* name to attempt to match */
|
||||
|
||||
{
|
||||
@ -635,10 +632,10 @@ char *fname; /* name to attempt to match */
|
||||
ffp = &names[0];
|
||||
while (ffp->n_func != NULL) {
|
||||
if (strcmp(fname, ffp->n_name) == 0)
|
||||
return(ffp->n_func);
|
||||
return (ffp->n_func);
|
||||
++ffp;
|
||||
}
|
||||
return(NULL);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* stock: String key name TO Command Key */
|
||||
@ -654,25 +651,25 @@ char *keyname; /* name of key to translate to Command key form */
|
||||
c = 0;
|
||||
|
||||
/* first, the META prefix */
|
||||
if (*keyname == 'M' && *(keyname+1) == '-') {
|
||||
if (*keyname == 'M' && *(keyname + 1) == '-') {
|
||||
c = META;
|
||||
keyname += 2;
|
||||
}
|
||||
|
||||
/* next the function prefix */
|
||||
if (*keyname == 'F' && *(keyname+1) == 'N') {
|
||||
if (*keyname == 'F' && *(keyname + 1) == 'N') {
|
||||
c |= SPEC;
|
||||
keyname += 2;
|
||||
}
|
||||
|
||||
/* control-x as well... (but not with FN) */
|
||||
if (*keyname == '^' && *(keyname+1) == 'X'&& !(c & SPEC)) {
|
||||
if (*keyname == '^' && *(keyname + 1) == 'X' && !(c & SPEC)) {
|
||||
c |= CTLX;
|
||||
keyname += 2;
|
||||
}
|
||||
|
||||
/* a control char? */
|
||||
if (*keyname == '^' && *(keyname+1) != 0) {
|
||||
if (*keyname == '^' && *(keyname + 1) != 0) {
|
||||
c |= CONTROL;
|
||||
++keyname;
|
||||
}
|
||||
@ -682,27 +679,27 @@ char *keyname; /* name of key to translate to Command key form */
|
||||
}
|
||||
|
||||
|
||||
/* make sure we are not lower case (not with function keys)*/
|
||||
/* make sure we are not lower case (not with function keys) */
|
||||
if (*keyname >= 'a' && *keyname <= 'z' && !(c & SPEC))
|
||||
*keyname -= 32;
|
||||
|
||||
/* the final sequence... */
|
||||
c |= *keyname;
|
||||
return(c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
char *transbind(skey) /* string key name to binding name.... */
|
||||
|
||||
char *transbind(skey)
|
||||
/* string key name to binding name.... */
|
||||
char *skey; /* name of keey to get binding for */
|
||||
|
||||
{
|
||||
char *bindname;
|
||||
unsigned int stock();
|
||||
int (*getbind())();
|
||||
int (*getbind()) ();
|
||||
|
||||
bindname = getfname(getbind(stock(skey)));
|
||||
if (bindname == NULL)
|
||||
bindname = "ERROR";
|
||||
|
||||
return(bindname);
|
||||
return (bindname);
|
||||
}
|
||||
|
117
buffer.c
117
buffer.c
@ -25,25 +25,25 @@ usebuffer(f, n)
|
||||
register int s;
|
||||
char bufn[NBUFN];
|
||||
|
||||
if ((s=mlreply("Use buffer: ", bufn, NBUFN)) != TRUE)
|
||||
if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE)
|
||||
return (s);
|
||||
if ((bp=bfind(bufn, TRUE, 0)) == NULL)
|
||||
if ((bp = bfind(bufn, TRUE, 0)) == NULL)
|
||||
return (FALSE);
|
||||
return(swbuffer(bp));
|
||||
return (swbuffer(bp));
|
||||
}
|
||||
|
||||
nextbuffer(f, n) /* switch to the next buffer in the buffer list */
|
||||
|
||||
nextbuffer(f, n)
|
||||
/* switch to the next buffer in the buffer list */
|
||||
int f, n; /* default flag, numeric argument */
|
||||
{
|
||||
register BUFFER *bp; /* eligable buffer to switch to*/
|
||||
register BUFFER *bbp; /* eligable buffer to switch to*/
|
||||
register BUFFER *bp; /* eligable buffer to switch to */
|
||||
register BUFFER *bbp; /* eligable buffer to switch to */
|
||||
|
||||
/* make sure the arg is legit */
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
if (n < 1)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
bbp = curbp;
|
||||
while (n-- > 0) {
|
||||
@ -59,18 +59,18 @@ int f, n; /* default flag, numeric argument */
|
||||
|
||||
/* don't get caught in an infinite loop! */
|
||||
if (bp == bbp)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
}
|
||||
|
||||
bbp = bp;
|
||||
}
|
||||
|
||||
return(swbuffer(bp));
|
||||
return (swbuffer(bp));
|
||||
}
|
||||
|
||||
swbuffer(bp) /* make buffer BP current */
|
||||
|
||||
swbuffer(bp)
|
||||
/* make buffer BP current */
|
||||
BUFFER *bp;
|
||||
|
||||
{
|
||||
@ -83,7 +83,7 @@ BUFFER *bp;
|
||||
curbp->b_marko = curwp->w_marko;
|
||||
}
|
||||
curbp = bp; /* Switch. */
|
||||
if (curbp->b_active != TRUE) { /* buffer not active yet*/
|
||||
if (curbp->b_active != TRUE) { /* buffer not active yet */
|
||||
/* read it in and activate it */
|
||||
readin(curbp->b_fname, TRUE);
|
||||
curbp->b_dotp = lforw(curbp->b_linep);
|
||||
@ -93,7 +93,7 @@ BUFFER *bp;
|
||||
}
|
||||
curwp->w_bufp = bp;
|
||||
curwp->w_linep = bp->b_linep; /* For macros, ignored. */
|
||||
curwp->w_flag |= WFMODE|WFFORCE|WFHARD; /* Quite nasty. */
|
||||
curwp->w_flag |= WFMODE | WFFORCE | WFHARD; /* Quite nasty. */
|
||||
if (bp->b_nwnd++ == 0) { /* First use. */
|
||||
curwp->w_dotp = bp->b_dotp;
|
||||
curwp->w_doto = bp->b_doto;
|
||||
@ -104,7 +104,7 @@ BUFFER *bp;
|
||||
}
|
||||
wp = wheadp; /* Look for old. */
|
||||
while (wp != NULL) {
|
||||
if (wp!=curwp && wp->w_bufp==bp) {
|
||||
if (wp != curwp && wp->w_bufp == bp) {
|
||||
curwp->w_dotp = wp->w_dotp;
|
||||
curwp->w_doto = wp->w_doto;
|
||||
curwp->w_markp = wp->w_markp;
|
||||
@ -126,23 +126,22 @@ BUFFER *bp;
|
||||
* line and the buffer header. Bound to "C-X K".
|
||||
*/
|
||||
killbuffer(f, n)
|
||||
|
||||
{
|
||||
register BUFFER *bp;
|
||||
register int s;
|
||||
char bufn[NBUFN];
|
||||
|
||||
if ((s=mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
|
||||
return(s);
|
||||
if ((bp=bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
|
||||
if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
|
||||
return (s);
|
||||
if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
|
||||
return (TRUE);
|
||||
if(bp->b_flag & BFINVS) /* Deal with special buffers */
|
||||
if (bp->b_flag & BFINVS) /* Deal with special buffers */
|
||||
return (TRUE); /* by doing nothing. */
|
||||
return(zotbuf(bp));
|
||||
return (zotbuf(bp));
|
||||
}
|
||||
|
||||
zotbuf(bp) /* kill the buffer pointed to by bp */
|
||||
|
||||
zotbuf(bp)
|
||||
/* kill the buffer pointed to by bp */
|
||||
register BUFFER *bp;
|
||||
|
||||
{
|
||||
@ -154,7 +153,7 @@ register BUFFER *bp;
|
||||
mlwrite("Buffer is being displayed");
|
||||
return (FALSE);
|
||||
}
|
||||
if ((s=bclear(bp)) != TRUE) /* Blow text away. */
|
||||
if ((s = bclear(bp)) != TRUE) /* Blow text away. */
|
||||
return (s);
|
||||
free((char *) bp->b_linep); /* Release header line. */
|
||||
bp1 = NULL; /* Find the header. */
|
||||
@ -172,8 +171,8 @@ register BUFFER *bp;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
namebuffer(f,n) /* Rename the current buffer */
|
||||
|
||||
namebuffer(f, n)
|
||||
/* Rename the current buffer */
|
||||
int f, n; /* default Flag & Numeric arg */
|
||||
|
||||
{
|
||||
@ -181,8 +180,9 @@ int f, n; /* default Flag & Numeric arg */
|
||||
char bufn[NBUFN]; /* buffer to hold buffer name */
|
||||
|
||||
/* prompt for and get the new buffer name */
|
||||
ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE)
|
||||
return(FALSE);
|
||||
ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) !=
|
||||
TRUE)
|
||||
return (FALSE);
|
||||
|
||||
/* and check for duplicates */
|
||||
bp = bheadp;
|
||||
@ -198,7 +198,7 @@ ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE)
|
||||
strcpy(curbp->b_bname, bufn); /* copy buffer name to structure */
|
||||
curwp->w_flag |= WFMODE; /* make mode line replot */
|
||||
mlerase();
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -217,10 +217,10 @@ listbuffers(f, n)
|
||||
register BUFFER *bp;
|
||||
register int s;
|
||||
|
||||
if ((s=makelist(f)) != TRUE)
|
||||
if ((s = makelist(f)) != TRUE)
|
||||
return (s);
|
||||
if (blistp->b_nwnd == 0) { /* Not on screen yet. */
|
||||
if ((wp=wpopup()) == NULL)
|
||||
if ((wp = wpopup()) == NULL)
|
||||
return (FALSE);
|
||||
bp = wp->w_bufp;
|
||||
if (--bp->b_nwnd == 0) {
|
||||
@ -240,7 +240,7 @@ listbuffers(f, n)
|
||||
wp->w_doto = 0;
|
||||
wp->w_markp = NULL;
|
||||
wp->w_marko = 0;
|
||||
wp->w_flag |= WFMODE|WFHARD;
|
||||
wp->w_flag |= WFMODE | WFHARD;
|
||||
}
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
@ -270,15 +270,16 @@ int iflag; /* list hidden buffer flag */
|
||||
register int s;
|
||||
register int i;
|
||||
long nbytes; /* # of bytes in current buffer */
|
||||
char b[7+1];
|
||||
char b[7 + 1];
|
||||
char line[MAXLINE];
|
||||
|
||||
blistp->b_flag &= ~BFCHG; /* Don't complain! */
|
||||
if ((s=bclear(blistp)) != TRUE) /* Blow old text away */
|
||||
if ((s = bclear(blistp)) != TRUE) /* Blow old text away */
|
||||
return (s);
|
||||
strcpy(blistp->b_fname, "");
|
||||
if (addline("ACT MODES Size Buffer File") == FALSE
|
||||
|| addline("--- ----- ---- ------ ----") == FALSE)
|
||||
|| addline("--- ----- ---- ------ ----") ==
|
||||
FALSE)
|
||||
return (FALSE);
|
||||
bp = bheadp; /* For all buffers */
|
||||
|
||||
@ -297,12 +298,12 @@ int iflag; /* list hidden buffer flag */
|
||||
*cp1++ = '.';
|
||||
strcpy(cp1, " Global Modes");
|
||||
if (addline(line) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* output the list of buffers */
|
||||
while (bp != NULL) {
|
||||
/* skip invisable buffers if iflag is false */
|
||||
if (((bp->b_flag&BFINVS) != 0) && (iflag != TRUE)) {
|
||||
if (((bp->b_flag & BFINVS) != 0) && (iflag != TRUE)) {
|
||||
bp = bp->b_bufp;
|
||||
continue;
|
||||
}
|
||||
@ -315,13 +316,13 @@ int iflag; /* list hidden buffer flag */
|
||||
*cp1++ = ' ';
|
||||
|
||||
/* output status of changed flag */
|
||||
if ((bp->b_flag&BFCHG) != 0) /* "*" if changed */
|
||||
if ((bp->b_flag & BFCHG) != 0) /* "*" if changed */
|
||||
*cp1++ = '*';
|
||||
else
|
||||
*cp1++ = ' ';
|
||||
|
||||
/* report if the file is truncated */
|
||||
if ((bp->b_flag&BFTRUNC) != 0)
|
||||
if ((bp->b_flag & BFTRUNC) != 0)
|
||||
*cp1++ = '#';
|
||||
else
|
||||
*cp1++ = ' ';
|
||||
@ -339,7 +340,7 @@ int iflag; /* list hidden buffer flag */
|
||||
nbytes = 0L; /* Count bytes in buf. */
|
||||
lp = lforw(bp->b_linep);
|
||||
while (lp != bp->b_linep) {
|
||||
nbytes += (long)llength(lp)+1L;
|
||||
nbytes += (long) llength(lp) + 1L;
|
||||
lp = lforw(lp);
|
||||
}
|
||||
ltoa(b, 7, nbytes); /* 6 digit buffer size. */
|
||||
@ -352,10 +353,10 @@ int iflag; /* list hidden buffer flag */
|
||||
*cp1++ = c;
|
||||
cp2 = &bp->b_fname[0]; /* File name */
|
||||
if (*cp2 != 0) {
|
||||
while (cp1 < &line[3+1+5+1+6+4+NBUFN])
|
||||
while (cp1 < &line[3 + 1 + 5 + 1 + 6 + 4 + NBUFN])
|
||||
*cp1++ = ' ';
|
||||
while ((c = *cp2++) != 0) {
|
||||
if (cp1 < &line[MAXLINE-1])
|
||||
if (cp1 < &line[MAXLINE - 1])
|
||||
*cp1++ = c;
|
||||
}
|
||||
}
|
||||
@ -376,10 +377,10 @@ long num;
|
||||
{
|
||||
buf[width] = 0; /* End of string. */
|
||||
while (num >= 10) { /* Conditional digits. */
|
||||
buf[--width] = (int)(num%10L) + '0';
|
||||
buf[--width] = (int) (num % 10L) + '0';
|
||||
num /= 10L;
|
||||
}
|
||||
buf[--width] = (int)num + '0'; /* Always 1 digit. */
|
||||
buf[--width] = (int) num + '0'; /* Always 1 digit. */
|
||||
while (width != 0) /* Pad with blanks. */
|
||||
buf[--width] = ' ';
|
||||
}
|
||||
@ -399,9 +400,9 @@ char *text;
|
||||
register int ntext;
|
||||
|
||||
ntext = strlen(text);
|
||||
if ((lp=lalloc(ntext)) == NULL)
|
||||
if ((lp = lalloc(ntext)) == NULL)
|
||||
return (FALSE);
|
||||
for (i=0; i<ntext; ++i)
|
||||
for (i = 0; i < ntext; ++i)
|
||||
lputc(lp, i, text[i]);
|
||||
blistp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */
|
||||
lp->l_bp = blistp->b_linep->l_bp;
|
||||
@ -428,7 +429,8 @@ anycb()
|
||||
|
||||
bp = bheadp;
|
||||
while (bp != NULL) {
|
||||
if ((bp->b_flag&BFINVS)==0 && (bp->b_flag&BFCHG)!=0)
|
||||
if ((bp->b_flag & BFINVS) == 0
|
||||
&& (bp->b_flag & BFCHG) != 0)
|
||||
return (TRUE);
|
||||
bp = bp->b_bufp;
|
||||
}
|
||||
@ -442,8 +444,7 @@ anycb()
|
||||
* and the "cflag" is TRUE, create it. The "bflag" is
|
||||
* the settings for the flags in in buffer.
|
||||
*/
|
||||
BUFFER *
|
||||
bfind(bname, cflag, bflag)
|
||||
BUFFER *bfind(bname, cflag, bflag)
|
||||
register char *bname;
|
||||
{
|
||||
register BUFFER *bp;
|
||||
@ -458,9 +459,9 @@ register char *bname;
|
||||
bp = bp->b_bufp;
|
||||
}
|
||||
if (cflag != FALSE) {
|
||||
if ((bp=(BUFFER *)malloc(sizeof(BUFFER))) == NULL)
|
||||
if ((bp = (BUFFER *) malloc(sizeof(BUFFER))) == NULL)
|
||||
return (NULL);
|
||||
if ((lp=lalloc(0)) == NULL) {
|
||||
if ((lp = lalloc(0)) == NULL) {
|
||||
free((char *) bp);
|
||||
return (NULL);
|
||||
}
|
||||
@ -519,12 +520,12 @@ register BUFFER *bp;
|
||||
register LINE *lp;
|
||||
register int s;
|
||||
|
||||
if ((bp->b_flag&BFINVS) == 0 /* Not scratch buffer. */
|
||||
&& (bp->b_flag&BFCHG) != 0 /* Something changed */
|
||||
&& (s=mlyesno("Discard changes")) != TRUE)
|
||||
if ((bp->b_flag & BFINVS) == 0 /* Not scratch buffer. */
|
||||
&& (bp->b_flag & BFCHG) != 0 /* Something changed */
|
||||
&& (s = mlyesno("Discard changes")) != TRUE)
|
||||
return (s);
|
||||
bp->b_flag &= ~BFCHG; /* Not changed */
|
||||
while ((lp=lforw(bp->b_linep)) != bp->b_linep)
|
||||
while ((lp = lforw(bp->b_linep)) != bp->b_linep)
|
||||
lfree(lp);
|
||||
bp->b_dotp = bp->b_linep; /* Fix "." */
|
||||
bp->b_doto = 0;
|
||||
@ -533,12 +534,12 @@ register BUFFER *bp;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
unmark(f, n) /* unmark the current buffers change flag */
|
||||
|
||||
unmark(f, n)
|
||||
/* unmark the current buffers change flag */
|
||||
int f, n; /* unused command arguments */
|
||||
|
||||
{
|
||||
curbp->b_flag &= ~BFCHG;
|
||||
curwp->w_flag |= WFMODE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
12
crypt.c
12
crypt.c
@ -13,8 +13,8 @@
|
||||
|
||||
static int mod95();
|
||||
|
||||
setkey(f, n) /* reset encryption key of current buffer */
|
||||
|
||||
setkey(f, n)
|
||||
/* reset encryption key of current buffer */
|
||||
int f; /* default flag */
|
||||
int n; /* numeric argument */
|
||||
|
||||
@ -31,16 +31,16 @@ int n; /* numeric argument */
|
||||
status = mlreply("Encryption String: ", key, NPAT - 1);
|
||||
disinp = odisinp;
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
/* and encrypt it */
|
||||
crypt((char *)NULL, 0);
|
||||
crypt((char *) NULL, 0);
|
||||
crypt(key, strlen(key));
|
||||
|
||||
/* and save it off */
|
||||
strcpy(curbp->b_key, key);
|
||||
mlwrite(" "); /* clear it off the bottom line */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/**********
|
||||
@ -170,7 +170,7 @@ register unsigned len; /* number of characters in the buffer */
|
||||
so that the left shift here will be more portable and the
|
||||
mod95() faster **/
|
||||
|
||||
cc = mod95((int)(key % 95) - (cc - ' ')) + ' ';
|
||||
cc = mod95((int) (key % 95) - (cc - ' ')) + ' ';
|
||||
|
||||
/** the salt will spice up the key a little bit, helping to obscure
|
||||
any patterns in the clear text, particularly when all the
|
||||
|
360
display.c
360
display.c
@ -61,21 +61,20 @@ vtinit()
|
||||
TTopen(); /* open the screen */
|
||||
TTkopen(); /* open the keyboard */
|
||||
TTrev(FALSE);
|
||||
vscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
|
||||
vscreen = (VIDEO **) malloc(term.t_mrow * sizeof(VIDEO *));
|
||||
|
||||
if (vscreen == NULL)
|
||||
exit(1);
|
||||
|
||||
#if MEMMAP == 0 || SCROLLCODE
|
||||
pscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
|
||||
pscreen = (VIDEO **) malloc(term.t_mrow * sizeof(VIDEO *));
|
||||
|
||||
if (pscreen == NULL)
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < term.t_mrow; ++i)
|
||||
{
|
||||
vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
|
||||
for (i = 0; i < term.t_mrow; ++i) {
|
||||
vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol);
|
||||
|
||||
if (vp == NULL)
|
||||
exit(1);
|
||||
@ -87,7 +86,7 @@ vtinit()
|
||||
#endif
|
||||
vscreen[i] = vp;
|
||||
#if MEMMAP == 0 || SCROLLCODE
|
||||
vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
|
||||
vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol);
|
||||
|
||||
if (vp == NULL)
|
||||
exit(1);
|
||||
@ -169,7 +168,7 @@ int c;
|
||||
if (c == '\t') {
|
||||
do {
|
||||
vtputc(' ');
|
||||
} while (((vtcol + taboff)&tabmask) != 0);
|
||||
} while (((vtcol + taboff) & tabmask) != 0);
|
||||
} else {
|
||||
vtputc('^');
|
||||
vtputc(c ^ 0x40);
|
||||
@ -200,10 +199,9 @@ vteeol()
|
||||
always finishes complete update */
|
||||
|
||||
upscreen(f, n)
|
||||
|
||||
{
|
||||
update(TRUE);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
@ -226,11 +224,11 @@ int force; /* force update past type ahead? */
|
||||
|
||||
#if TYPEAH && ! PKCODE
|
||||
if (force == FALSE && typahead())
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
#if VISMAC == 0
|
||||
if (force == FALSE && kbdmode == PLAY)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
|
||||
displaying = TRUE;
|
||||
@ -265,9 +263,10 @@ int force; /* force update past type ahead? */
|
||||
/* if the window has changed, service it */
|
||||
reframe(wp); /* check the framing */
|
||||
#if SCROLLCODE
|
||||
if (wp->w_flag & (WFKILLS|WFINS)) {
|
||||
scrflags |= (wp->w_flag & (WFINS|WFKILLS));
|
||||
wp->w_flag &= ~(WFKILLS|WFINS);
|
||||
if (wp->w_flag & (WFKILLS | WFINS)) {
|
||||
scrflags |=
|
||||
(wp->w_flag & (WFINS | WFKILLS));
|
||||
wp->w_flag &= ~(WFKILLS | WFINS);
|
||||
}
|
||||
#endif
|
||||
if ((wp->w_flag & ~WFMODE) == WFEDIT)
|
||||
@ -311,9 +310,9 @@ int force; /* force update past type ahead? */
|
||||
displaying = FALSE;
|
||||
#if SIGWINCH
|
||||
while (chg_width || chg_height)
|
||||
newscreensize(chg_height,chg_width);
|
||||
newscreensize(chg_height, chg_width);
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* reframe: check to see if the cursor is on in the window
|
||||
@ -339,7 +338,7 @@ WINDOW *wp;
|
||||
i = -1;
|
||||
lp = lp0;
|
||||
}
|
||||
for (; i <= (int)(wp->w_ntrows); i++)
|
||||
for (; i <= (int) (wp->w_ntrows); i++)
|
||||
#else
|
||||
lp = wp->w_linep;
|
||||
for (i = 0; i < wp->w_ntrows; i++)
|
||||
@ -349,7 +348,7 @@ WINDOW *wp;
|
||||
if (lp == wp->w_dotp) {
|
||||
#if SCROLLCODE
|
||||
/* if not _quite_ in, we'll reframe gently */
|
||||
if ( i < 0 || i == wp->w_ntrows) {
|
||||
if (i < 0 || i == wp->w_ntrows) {
|
||||
/* if the terminal can't help, then
|
||||
we're simply outside */
|
||||
if (term.t_scroll == NULL)
|
||||
@ -357,7 +356,7 @@ WINDOW *wp;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* if we are at the end of the file, reframe */
|
||||
@ -368,7 +367,6 @@ WINDOW *wp;
|
||||
lp = lforw(lp);
|
||||
}
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
if (i == -1) { /* we're just above the window */
|
||||
i = scrollcount; /* put dot at first line */
|
||||
@ -404,7 +402,7 @@ WINDOW *wp;
|
||||
wp->w_linep = lp;
|
||||
wp->w_flag |= WFHARD;
|
||||
wp->w_flag &= ~WFFORCE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* updone: update the current line to the virtual screen */
|
||||
@ -430,7 +428,7 @@ WINDOW *wp; /* window to update current line in */
|
||||
vscreen[sline]->v_flag |= VFCHG;
|
||||
vscreen[sline]->v_flag &= ~VFREQ;
|
||||
vtmove(sline, 0);
|
||||
for (i=0; i < llength(lp); ++i)
|
||||
for (i = 0; i < llength(lp); ++i)
|
||||
vtputc(lgetc(lp, i));
|
||||
#if COLOR
|
||||
vscreen[sline]->v_rfcolor = wp->w_fcolor;
|
||||
@ -461,7 +459,7 @@ WINDOW *wp; /* window to update lines in */
|
||||
vtmove(sline, 0);
|
||||
if (lp != wp->w_bufp->b_linep) {
|
||||
/* if we are not at the end */
|
||||
for (i=0; i < llength(lp); ++i)
|
||||
for (i = 0; i < llength(lp); ++i)
|
||||
vtputc(lgetc(lp, i));
|
||||
lp = lforw(lp);
|
||||
}
|
||||
@ -481,7 +479,6 @@ WINDOW *wp; /* window to update lines in */
|
||||
lines. This is the only update for simple moves. */
|
||||
|
||||
updpos()
|
||||
|
||||
{
|
||||
register LINE *lp;
|
||||
register int c;
|
||||
@ -502,8 +499,7 @@ updpos()
|
||||
c = lgetc(lp, i++);
|
||||
if (c == '\t')
|
||||
curcol |= tabmask;
|
||||
else
|
||||
if (c < 0x20 || c == 0x7f)
|
||||
else if (c < 0x20 || c == 0x7f)
|
||||
++curcol;
|
||||
|
||||
++curcol;
|
||||
@ -520,11 +516,10 @@ updpos()
|
||||
/* upddex: de-extend any line that derserves it */
|
||||
|
||||
upddex()
|
||||
|
||||
{
|
||||
register WINDOW *wp;
|
||||
register LINE *lp;
|
||||
register int i,j;
|
||||
register int i, j;
|
||||
|
||||
wp = wheadp;
|
||||
|
||||
@ -558,10 +553,9 @@ upddex()
|
||||
the virtual screen and force a full update */
|
||||
|
||||
updgar()
|
||||
|
||||
{
|
||||
register char *txt;
|
||||
register int i,j;
|
||||
register int i, j;
|
||||
|
||||
for (i = 0; i < term.t_nrow; ++i) {
|
||||
vscreen[i]->v_flag |= VFCHG;
|
||||
@ -580,7 +574,7 @@ updgar()
|
||||
}
|
||||
|
||||
movecursor(0, 0); /* Erase the screen. */
|
||||
(*term.t_eeop)();
|
||||
(*term.t_eeop) ();
|
||||
sgarbf = FALSE; /* Erase-page clears */
|
||||
mpresf = FALSE; /* the message area. */
|
||||
#if COLOR
|
||||
@ -609,11 +603,11 @@ int force; /* forced update flag */
|
||||
for (i = 0; i < term.t_nrow; ++i) {
|
||||
vp1 = vscreen[i];
|
||||
|
||||
/* for each line that needs to be updated*/
|
||||
/* for each line that needs to be updated */
|
||||
if ((vp1->v_flag & VFCHG) != 0) {
|
||||
#if TYPEAH && ! PKCODE
|
||||
if (force == FALSE && typahead())
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
#if MEMMAP && ! SCROLLCODE
|
||||
updateline(i, vp1);
|
||||
@ -622,33 +616,32 @@ int force; /* forced update flag */
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
|
||||
/* optimize out scrolls (line breaks, and newlines) */
|
||||
/* arg. chooses between looking for inserts or deletes */
|
||||
int
|
||||
scrolls(inserts) /* returns true if it does something */
|
||||
{
|
||||
struct VIDEO *vpv ; /* virtual screen image */
|
||||
struct VIDEO *vpp ; /* physical screen image */
|
||||
int i, j, k ;
|
||||
int rows, cols ;
|
||||
int first, match, count, ptarget, vtarget, end ;
|
||||
int scrolls(inserts)
|
||||
{ /* returns true if it does something */
|
||||
struct VIDEO *vpv; /* virtual screen image */
|
||||
struct VIDEO *vpp; /* physical screen image */
|
||||
int i, j, k;
|
||||
int rows, cols;
|
||||
int first, match, count, ptarget, vtarget, end;
|
||||
int longmatch, longcount;
|
||||
int from, to;
|
||||
|
||||
if (!term.t_scroll) /* no way to scroll */
|
||||
return FALSE;
|
||||
|
||||
rows = term.t_nrow ;
|
||||
cols = term.t_ncol ;
|
||||
rows = term.t_nrow;
|
||||
cols = term.t_ncol;
|
||||
|
||||
first = -1 ;
|
||||
first = -1;
|
||||
for (i = 0; i < rows; i++) { /* find first wrong line */
|
||||
if (!texttest(i,i)) {
|
||||
if (!texttest(i, i)) {
|
||||
first = i;
|
||||
break;
|
||||
}
|
||||
@ -657,36 +650,38 @@ scrolls(inserts) /* returns true if it does something */
|
||||
if (first < 0)
|
||||
return FALSE; /* no text changes */
|
||||
|
||||
vpv = vscreen[first] ;
|
||||
vpp = pscreen[first] ;
|
||||
vpv = vscreen[first];
|
||||
vpp = pscreen[first];
|
||||
|
||||
if (inserts) {
|
||||
/* determine types of potential scrolls */
|
||||
end = endofline(vpv->v_text,cols) ;
|
||||
if ( end == 0 )
|
||||
ptarget = first ; /* newlines */
|
||||
else if ( strncmp(vpp->v_text, vpv->v_text, end) == 0 )
|
||||
ptarget = first + 1 ; /* broken line newlines */
|
||||
end = endofline(vpv->v_text, cols);
|
||||
if (end == 0)
|
||||
ptarget = first; /* newlines */
|
||||
else if (strncmp(vpp->v_text, vpv->v_text, end) == 0)
|
||||
ptarget = first + 1; /* broken line newlines */
|
||||
else
|
||||
ptarget = first ;
|
||||
ptarget = first;
|
||||
} else {
|
||||
vtarget = first + 1 ;
|
||||
vtarget = first + 1;
|
||||
}
|
||||
|
||||
/* find the matching shifted area */
|
||||
match = -1 ;
|
||||
match = -1;
|
||||
longmatch = -1;
|
||||
longcount = 0;
|
||||
from = inserts ? ptarget : vtarget;
|
||||
for (i = from+1; i < rows-longcount /* P.K. */; i++) {
|
||||
if (inserts ? texttest(i,from) : texttest(from,i) ) {
|
||||
match = i ;
|
||||
count = 1 ;
|
||||
for (j=match+1, k=from+1; j<rows && k<rows; j++, k++) {
|
||||
if (inserts ? texttest(j,k) : texttest(k,j))
|
||||
count++ ;
|
||||
for (i = from + 1; i < rows - longcount /* P.K. */ ; i++) {
|
||||
if (inserts ? texttest(i, from) : texttest(from, i)) {
|
||||
match = i;
|
||||
count = 1;
|
||||
for (j = match + 1, k = from + 1;
|
||||
j < rows && k < rows; j++, k++) {
|
||||
if (inserts ? texttest(j, k) :
|
||||
texttest(k, j))
|
||||
count++;
|
||||
else
|
||||
break ;
|
||||
break;
|
||||
}
|
||||
if (longcount < count) {
|
||||
longcount = count;
|
||||
@ -699,15 +694,15 @@ scrolls(inserts) /* returns true if it does something */
|
||||
|
||||
if (!inserts) {
|
||||
/* full kill case? */
|
||||
if (match > 0 && texttest(first, match-1)) {
|
||||
vtarget-- ;
|
||||
match-- ;
|
||||
count++ ;
|
||||
if (match > 0 && texttest(first, match - 1)) {
|
||||
vtarget--;
|
||||
match--;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
/* do the scroll */
|
||||
if (match>0 && count>2) { /* got a scroll */
|
||||
if (match > 0 && count > 2) { /* got a scroll */
|
||||
/* move the count lines starting at ptarget to match */
|
||||
if (inserts) {
|
||||
from = ptarget;
|
||||
@ -721,32 +716,33 @@ scrolls(inserts) /* returns true if it does something */
|
||||
char line[NLINE];
|
||||
sprintf(line,
|
||||
"scrolls: move the %d lines starting at %d to %d, first %d, scrolls %d",
|
||||
count,from,to,first, 2*count >= abs(from-to));
|
||||
count, from, to, first,
|
||||
2 * count >= abs(from - to));
|
||||
mlwrite(line);
|
||||
}
|
||||
#endif
|
||||
if (2*count < abs(from-to))
|
||||
return(FALSE);
|
||||
scrscroll(from, to, count) ;
|
||||
if (2 * count < abs(from - to))
|
||||
return (FALSE);
|
||||
scrscroll(from, to, count);
|
||||
for (i = 0; i < count; i++) {
|
||||
vpp = pscreen[to+i] ;
|
||||
vpv = vscreen[to+i];
|
||||
strncpy(vpp->v_text, vpv->v_text, cols) ;
|
||||
vpp = pscreen[to + i];
|
||||
vpv = vscreen[to + i];
|
||||
strncpy(vpp->v_text, vpv->v_text, cols);
|
||||
vpp->v_flag = vpv->v_flag; /* XXX */
|
||||
if (vpp->v_flag & VFREV) {
|
||||
vpp->v_flag &= ~VFREV;
|
||||
vpp->v_flag |= ~VFREQ;
|
||||
}
|
||||
#if MEMMAP
|
||||
vscreen[to+i]->v_flag &= ~VFCHG;
|
||||
vscreen[to + i]->v_flag &= ~VFCHG;
|
||||
#endif
|
||||
}
|
||||
if (inserts) {
|
||||
from = ptarget;
|
||||
to = match;
|
||||
} else {
|
||||
from = vtarget+count;
|
||||
to = match+count;
|
||||
from = vtarget + count;
|
||||
to = match + count;
|
||||
}
|
||||
#if MEMMAP == 0
|
||||
for (i = from; i < to; i++) {
|
||||
@ -757,36 +753,36 @@ scrolls(inserts) /* returns true if it does something */
|
||||
vscreen[i]->v_flag |= VFCHG;
|
||||
}
|
||||
#endif
|
||||
return(TRUE) ;
|
||||
return (TRUE);
|
||||
}
|
||||
return(FALSE) ;
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* move the "count" lines starting at "from" to "to" */
|
||||
scrscroll(from, to, count)
|
||||
{
|
||||
ttrow = ttcol = -1;
|
||||
(*term.t_scroll)(from,to,count);
|
||||
(*term.t_scroll) (from, to, count);
|
||||
}
|
||||
|
||||
texttest(vrow,prow) /* return TRUE on text match */
|
||||
int vrow, prow ; /* virtual, physical rows */
|
||||
texttest(vrow, prow) /* return TRUE on text match */
|
||||
int vrow, prow; /* virtual, physical rows */
|
||||
{
|
||||
struct VIDEO *vpv = vscreen[vrow] ; /* virtual screen image */
|
||||
struct VIDEO *vpp = pscreen[prow] ; /* physical screen image */
|
||||
struct VIDEO *vpv = vscreen[vrow]; /* virtual screen image */
|
||||
struct VIDEO *vpp = pscreen[prow]; /* physical screen image */
|
||||
|
||||
return (!memcmp(vpv->v_text, vpp->v_text, term.t_ncol)) ;
|
||||
return (!memcmp(vpv->v_text, vpp->v_text, term.t_ncol));
|
||||
}
|
||||
|
||||
/* return the index of the first blank of trailing whitespace */
|
||||
int
|
||||
endofline(s,n)
|
||||
char *s ;
|
||||
int endofline(s, n)
|
||||
char *s;
|
||||
{
|
||||
int i ;
|
||||
int i;
|
||||
for (i = n - 1; i >= 0; i--)
|
||||
if (s[i] != ' ') return(i+1) ;
|
||||
return(0) ;
|
||||
if (s[i] != ' ')
|
||||
return (i + 1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endif /* SCROLLCODE */
|
||||
@ -798,7 +794,6 @@ int i ;
|
||||
*/
|
||||
|
||||
updext()
|
||||
|
||||
{
|
||||
register int rcursor; /* real cursor location */
|
||||
register LINE *lp; /* pointer to current line */
|
||||
@ -812,7 +807,7 @@ updext()
|
||||
/* once we reach the left edge */
|
||||
vtmove(currow, -lbound); /* start scanning offscreen */
|
||||
lp = curwp->w_dotp; /* line to output */
|
||||
for (j=0; j<llength(lp); ++j) /* until the end-of-line */
|
||||
for (j = 0; j < llength(lp); ++j) /* until the end-of-line */
|
||||
vtputc(lgetc(lp, j));
|
||||
|
||||
/* truncate the virtual line, restore tab offset */
|
||||
@ -836,7 +831,7 @@ updateline(row, vp1
|
||||
#if SCROLLCODE
|
||||
, vp2
|
||||
#endif
|
||||
)
|
||||
)
|
||||
|
||||
int row; /* row of screen to update */
|
||||
struct VIDEO *vp1; /* virtual screen image */
|
||||
@ -853,8 +848,7 @@ struct VIDEO *vp2;
|
||||
cp1 = &vp1->v_text[0];
|
||||
cp2 = &vp2->v_text[0];
|
||||
nch = term.t_ncol;
|
||||
do
|
||||
{
|
||||
do {
|
||||
*cp2 = *cp1;
|
||||
++cp2;
|
||||
++cp1;
|
||||
@ -896,11 +890,10 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
|
||||
cp1 = &vp1->v_text[0]; /* Use fast video. */
|
||||
cp2 = &vp2->v_text[0];
|
||||
putline(row+1, 1, cp1);
|
||||
putline(row + 1, 1, cp1);
|
||||
nch = term.t_ncol;
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
*cp2 = *cp1;
|
||||
++cp2;
|
||||
++cp1;
|
||||
@ -936,13 +929,14 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
req = (vp1->v_flag & VFREQ) == VFREQ;
|
||||
if ((rev != req)
|
||||
#if COLOR
|
||||
|| (vp1->v_fcolor != vp1->v_rfcolor) || (vp1->v_bcolor != vp1->v_rbcolor)
|
||||
|| (vp1->v_fcolor != vp1->v_rfcolor)
|
||||
|| (vp1->v_bcolor != vp1->v_rbcolor)
|
||||
#endif
|
||||
) {
|
||||
movecursor(row, 0); /* Go to start of line. */
|
||||
/* set rev video if needed */
|
||||
if (rev != req)
|
||||
(*term.t_rev)(req);
|
||||
(*term.t_rev) (req);
|
||||
|
||||
/* scan through the line and dump it to the screen and
|
||||
the virtual screen array */
|
||||
@ -954,7 +948,7 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
}
|
||||
/* turn rev video off */
|
||||
if (rev != req)
|
||||
(*term.t_rev)(FALSE);
|
||||
(*term.t_rev) (FALSE);
|
||||
|
||||
/* update the needed flags */
|
||||
vp1->v_flag &= ~VFCHG;
|
||||
@ -966,7 +960,7 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
vp1->v_fcolor = vp1->v_rfcolor;
|
||||
vp1->v_bcolor = vp1->v_rbcolor;
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -985,7 +979,7 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
/* if both lines are the same, no update needs to be done */
|
||||
if (cp1 == &vp1->v_text[term.t_ncol]) {
|
||||
vp1->v_flag &= ~VFCHG; /* flag this line is changed */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* find out if there is a match on the right */
|
||||
@ -1004,10 +998,10 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
|
||||
/* Erase to EOL ? */
|
||||
if (nbflag == FALSE && eolexist == TRUE && (req != TRUE)) {
|
||||
while (cp5!=cp1 && cp5[-1]==' ')
|
||||
while (cp5 != cp1 && cp5[-1] == ' ')
|
||||
--cp5;
|
||||
|
||||
if (cp3-cp5 <= 3) /* Use only if erase is */
|
||||
if (cp3 - cp5 <= 3) /* Use only if erase is */
|
||||
cp5 = cp3; /* fewer characters. */
|
||||
}
|
||||
|
||||
@ -1031,7 +1025,7 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
TTrev(FALSE);
|
||||
#endif
|
||||
vp1->v_flag &= ~VFCHG; /* flag this line as updated */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -1043,7 +1037,7 @@ struct VIDEO *vp2; /* physical screen image */
|
||||
* any time there is a dirty window.
|
||||
*/
|
||||
modeline(wp)
|
||||
WINDOW *wp;
|
||||
WINDOW *wp;
|
||||
{
|
||||
register char *cp;
|
||||
register int c;
|
||||
@ -1054,11 +1048,11 @@ modeline(wp)
|
||||
register int firstm; /* is this the first mode? */
|
||||
char tline[NLINE]; /* buffer for part of mode line */
|
||||
|
||||
n = wp->w_toprow+wp->w_ntrows; /* Location. */
|
||||
vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL;/* Redraw next time. */
|
||||
n = wp->w_toprow + wp->w_ntrows; /* Location. */
|
||||
vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL; /* Redraw next time. */
|
||||
#if COLOR
|
||||
vscreen[n]->v_rfcolor = 0; /* black on */
|
||||
vscreen[n]->v_rbcolor = 7; /* white.....*/
|
||||
vscreen[n]->v_rbcolor = 7; /* white..... */
|
||||
#endif
|
||||
vtmove(n, 0); /* Seek to right line. */
|
||||
if (wp == curwp) /* mark the current buffer */
|
||||
@ -1077,13 +1071,13 @@ modeline(wp)
|
||||
|
||||
bp = wp->w_bufp;
|
||||
#if PKCODE == 0
|
||||
if ((bp->b_flag&BFTRUNC) != 0)
|
||||
if ((bp->b_flag & BFTRUNC) != 0)
|
||||
vtputc('#');
|
||||
else
|
||||
#endif
|
||||
vtputc(lchar);
|
||||
|
||||
if ((bp->b_flag&BFCHG) != 0) /* "*" if changed. */
|
||||
if ((bp->b_flag & BFCHG) != 0) /* "*" if changed. */
|
||||
vtputc('*');
|
||||
else
|
||||
vtputc(lchar);
|
||||
@ -1096,15 +1090,13 @@ modeline(wp)
|
||||
strcat(tline, VERSION);
|
||||
strcat(tline, ": ");
|
||||
cp = &tline[0];
|
||||
while ((c = *cp++) != 0)
|
||||
{
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
|
||||
cp = &bp->b_bname[0];
|
||||
while ((c = *cp++) != 0)
|
||||
{
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
@ -1114,8 +1106,7 @@ modeline(wp)
|
||||
/* display the modes */
|
||||
|
||||
firstm = TRUE;
|
||||
if ((bp->b_flag&BFTRUNC) != 0)
|
||||
{
|
||||
if ((bp->b_flag & BFTRUNC) != 0) {
|
||||
firstm = FALSE;
|
||||
strcat(tline, "Truncated");
|
||||
}
|
||||
@ -1126,30 +1117,28 @@ modeline(wp)
|
||||
firstm = FALSE;
|
||||
strcat(tline, mode2name[i]);
|
||||
}
|
||||
strcat(tline,") ");
|
||||
strcat(tline, ") ");
|
||||
|
||||
cp = &tline[0];
|
||||
while ((c = *cp++) != 0)
|
||||
{
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
|
||||
#if 0
|
||||
vtputc(lchar);
|
||||
vtputc((wp->w_flag&WFCOLR) != 0 ? 'C' : lchar);
|
||||
vtputc((wp->w_flag&WFMODE) != 0 ? 'M' : lchar);
|
||||
vtputc((wp->w_flag&WFHARD) != 0 ? 'H' : lchar);
|
||||
vtputc((wp->w_flag&WFEDIT) != 0 ? 'E' : lchar);
|
||||
vtputc((wp->w_flag&WFMOVE) != 0 ? 'V' : lchar);
|
||||
vtputc((wp->w_flag&WFFORCE) != 0 ? 'F' : lchar);
|
||||
vtputc((wp->w_flag & WFCOLR) != 0 ? 'C' : lchar);
|
||||
vtputc((wp->w_flag & WFMODE) != 0 ? 'M' : lchar);
|
||||
vtputc((wp->w_flag & WFHARD) != 0 ? 'H' : lchar);
|
||||
vtputc((wp->w_flag & WFEDIT) != 0 ? 'E' : lchar);
|
||||
vtputc((wp->w_flag & WFMOVE) != 0 ? 'V' : lchar);
|
||||
vtputc((wp->w_flag & WFFORCE) != 0 ? 'F' : lchar);
|
||||
vtputc(lchar);
|
||||
n += 8;
|
||||
#endif
|
||||
|
||||
#if PKCODE
|
||||
if (bp->b_fname[0] != 0 &&
|
||||
strcmp(bp->b_bname, bp->b_fname) != 0)
|
||||
if (bp->b_fname[0] != 0 && strcmp(bp->b_bname, bp->b_fname) != 0)
|
||||
#else
|
||||
if (bp->b_fname[0] != 0) /* File name. */
|
||||
#endif
|
||||
@ -1157,8 +1146,7 @@ modeline(wp)
|
||||
#if PKCODE == 0
|
||||
cp = "File: ";
|
||||
|
||||
while ((c = *cp++) != 0)
|
||||
{
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
@ -1166,8 +1154,7 @@ modeline(wp)
|
||||
|
||||
cp = &bp->b_fname[0];
|
||||
|
||||
while ((c = *cp++) != 0)
|
||||
{
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
@ -1176,8 +1163,7 @@ modeline(wp)
|
||||
++n;
|
||||
}
|
||||
|
||||
while (n < term.t_ncol) /* Pad to full width. */
|
||||
{
|
||||
while (n < term.t_ncol) { /* Pad to full width. */
|
||||
vtputc(lchar);
|
||||
++n;
|
||||
}
|
||||
@ -1205,8 +1191,7 @@ modeline(wp)
|
||||
msg = " Top ";
|
||||
}
|
||||
}
|
||||
if (!msg)
|
||||
{
|
||||
if (!msg) {
|
||||
LINE *lp;
|
||||
int numlines, predlines, ratio;
|
||||
|
||||
@ -1224,7 +1209,8 @@ modeline(wp)
|
||||
} else {
|
||||
ratio = 0;
|
||||
if (numlines != 0)
|
||||
ratio = (100L*predlines) / numlines;
|
||||
ratio =
|
||||
(100L * predlines) / numlines;
|
||||
if (ratio > 99)
|
||||
ratio = 99;
|
||||
sprintf(tline, " %2d%% ", ratio);
|
||||
@ -1233,17 +1219,15 @@ modeline(wp)
|
||||
}
|
||||
|
||||
cp = msg;
|
||||
while ((c = *cp++) != 0)
|
||||
{
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
upmode() /* update all the mode lines */
|
||||
|
||||
{
|
||||
upmode()
|
||||
{ /* update all the mode lines */
|
||||
register WINDOW *wp;
|
||||
|
||||
wp = wheadp;
|
||||
@ -1259,14 +1243,13 @@ upmode() /* update all the mode lines */
|
||||
* random calls. Update "ttrow" and "ttcol".
|
||||
*/
|
||||
movecursor(row, col)
|
||||
{
|
||||
if (row!=ttrow || col!=ttcol)
|
||||
{
|
||||
{
|
||||
if (row != ttrow || col != ttcol) {
|
||||
ttrow = row;
|
||||
ttcol = col;
|
||||
TTmove(row, col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Erase the message line. This is a special routine because the message line
|
||||
@ -1274,7 +1257,7 @@ movecursor(row, col)
|
||||
* immediately; the terminal buffer is flushed via a call to the flusher.
|
||||
*/
|
||||
mlerase()
|
||||
{
|
||||
{
|
||||
int i;
|
||||
|
||||
movecursor(term.t_nrow, 0);
|
||||
@ -1295,7 +1278,7 @@ mlerase()
|
||||
}
|
||||
TTflush();
|
||||
mpresf = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a message into the message line. Keep track of the physical cursor
|
||||
@ -1318,7 +1301,6 @@ char *arg; /* pointer to first argument to print */
|
||||
movecursor(term.t_nrow, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
#if COLOR
|
||||
/* set up the proper colors for the command line */
|
||||
TTforg(7);
|
||||
@ -1342,36 +1324,36 @@ char *arg; /* pointer to first argument to print */
|
||||
switch (c) {
|
||||
#if PKCODE
|
||||
case '*':
|
||||
ap = *(char **)ap;
|
||||
ap = *(char **) ap;
|
||||
break;
|
||||
#endif
|
||||
case 'd':
|
||||
mlputi(*(int *)ap, 10);
|
||||
mlputi(*(int *) ap, 10);
|
||||
ap += sizeof(int);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
mlputi(*(int *)ap, 8);
|
||||
mlputi(*(int *) ap, 8);
|
||||
ap += sizeof(int);
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
mlputi(*(int *)ap, 16);
|
||||
mlputi(*(int *) ap, 16);
|
||||
ap += sizeof(int);
|
||||
break;
|
||||
|
||||
case 'D':
|
||||
mlputli(*(long *)ap, 10);
|
||||
mlputli(*(long *) ap, 10);
|
||||
ap += sizeof(long);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
mlputs(*(char **)ap);
|
||||
mlputs(*(char **) ap);
|
||||
ap += sizeof(char *);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
mlputf(*(int *)ap);
|
||||
mlputf(*(int *) ap);
|
||||
ap += sizeof(int);
|
||||
break;
|
||||
|
||||
@ -1413,63 +1395,60 @@ char *s; /* string to force out */
|
||||
* things will get screwed up a little.
|
||||
*/
|
||||
mlputs(s)
|
||||
char *s;
|
||||
{
|
||||
char *s;
|
||||
{
|
||||
register int c;
|
||||
|
||||
while ((c = *s++) != 0)
|
||||
{
|
||||
while ((c = *s++) != 0) {
|
||||
TTputc(c);
|
||||
++ttcol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Write out an integer, in the specified radix. Update the physical cursor
|
||||
* position.
|
||||
*/
|
||||
mlputi(i, r)
|
||||
{
|
||||
{
|
||||
register int q;
|
||||
static char hexdigits[] = "0123456789ABCDEF";
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
if (i < 0) {
|
||||
i = -i;
|
||||
TTputc('-');
|
||||
}
|
||||
|
||||
q = i/r;
|
||||
q = i / r;
|
||||
|
||||
if (q != 0)
|
||||
mlputi(q, r);
|
||||
|
||||
TTputc(hexdigits[i%r]);
|
||||
TTputc(hexdigits[i % r]);
|
||||
++ttcol;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* do the same except as a long integer.
|
||||
*/
|
||||
mlputli(l, r)
|
||||
long l;
|
||||
{
|
||||
long l;
|
||||
{
|
||||
register long q;
|
||||
|
||||
if (l < 0)
|
||||
{
|
||||
if (l < 0) {
|
||||
l = -l;
|
||||
TTputc('-');
|
||||
}
|
||||
|
||||
q = l/r;
|
||||
q = l / r;
|
||||
|
||||
if (q != 0)
|
||||
mlputli(q, r);
|
||||
|
||||
TTputc((int)(l%r)+'0');
|
||||
TTputc((int) (l % r) + '0');
|
||||
++ttcol;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* write out a scaled integer with two decimal places
|
||||
@ -1498,30 +1477,30 @@ int s; /* scaled integer to output */
|
||||
#if RAINBOW
|
||||
|
||||
putline(row, col, buf)
|
||||
int row, col;
|
||||
char buf[];
|
||||
{
|
||||
int row, col;
|
||||
char buf[];
|
||||
{
|
||||
int n;
|
||||
|
||||
n = strlen(buf);
|
||||
if (col + n - 1 > term.t_ncol)
|
||||
n = term.t_ncol - col + 1;
|
||||
Put_Data(row, col, n, buf);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get terminal size from system.
|
||||
Store number of lines into *heightp and width into *widthp.
|
||||
If zero or a negative number is stored, the value is not valid. */
|
||||
|
||||
getscreensize (widthp, heightp)
|
||||
getscreensize(widthp, heightp)
|
||||
int *widthp, *heightp;
|
||||
{
|
||||
#ifdef TIOCGWINSZ
|
||||
struct winsize size;
|
||||
*widthp = 0;
|
||||
*heightp = 0;
|
||||
if (ioctl (0, TIOCGWINSZ, &size) < 0)
|
||||
if (ioctl(0, TIOCGWINSZ, &size) < 0)
|
||||
return;
|
||||
*widthp = size.ws_col;
|
||||
*heightp = size.ws_row;
|
||||
@ -1539,16 +1518,16 @@ int signr;
|
||||
extern int errno;
|
||||
int old_errno = errno;
|
||||
|
||||
getscreensize (&w, &h);
|
||||
getscreensize(&w, &h);
|
||||
|
||||
if (h && w && (h-1 != term.t_nrow || w != term.t_ncol))
|
||||
if (h && w && (h - 1 != term.t_nrow || w != term.t_ncol))
|
||||
newscreensize(h, w);
|
||||
|
||||
signal (SIGWINCH, sizesignal);
|
||||
signal(SIGWINCH, sizesignal);
|
||||
errno = old_errno;
|
||||
}
|
||||
|
||||
newscreensize (h, w)
|
||||
newscreensize(h, w)
|
||||
int h, w;
|
||||
{
|
||||
/* do the change later */
|
||||
@ -1559,13 +1538,12 @@ int h, w;
|
||||
}
|
||||
chg_width = chg_height = 0;
|
||||
if (h - 1 < term.t_mrow)
|
||||
newsize(TRUE,h);
|
||||
newsize(TRUE, h);
|
||||
if (w < term.t_mcol)
|
||||
newwidth(TRUE,w);
|
||||
newwidth(TRUE, w);
|
||||
|
||||
update(TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
523
ebind.h
523
ebind.h
@ -12,238 +12,407 @@
|
||||
* control-X commands.
|
||||
*/
|
||||
KEYTAB keytab[NBINDS] = {
|
||||
{CONTROL|'A', gotobol},
|
||||
{CONTROL|'B', backchar},
|
||||
{CONTROL|'C', insspace},
|
||||
{CONTROL|'D', forwdel},
|
||||
{CONTROL|'E', gotoeol},
|
||||
{CONTROL|'F', forwchar},
|
||||
{CONTROL|'G', ctrlg},
|
||||
{CONTROL|'H', backdel},
|
||||
{CONTROL|'I', tab},
|
||||
{CONTROL|'J', indent},
|
||||
{CONTROL|'K', killtext},
|
||||
{CONTROL|'L', refresh},
|
||||
{CONTROL|'M', newline},
|
||||
{CONTROL|'N', forwline},
|
||||
{CONTROL|'O', openline},
|
||||
{CONTROL|'P', backline},
|
||||
{CONTROL|'Q', quote},
|
||||
{CONTROL|'R', backsearch},
|
||||
{CONTROL|'S', forwsearch},
|
||||
{CONTROL|'T', twiddle},
|
||||
{CONTROL|'U', unarg},
|
||||
{CONTROL|'V', forwpage},
|
||||
{CONTROL|'W', killregion},
|
||||
{CONTROL|'X', cex},
|
||||
{CONTROL|'Y', yank},
|
||||
{CONTROL|'Z', backpage},
|
||||
{CONTROL|']', meta},
|
||||
{CTLX|CONTROL|'B', listbuffers},
|
||||
{CTLX|CONTROL|'C', quit}, /* Hard quit. */
|
||||
{CONTROL | 'A', gotobol}
|
||||
,
|
||||
{CONTROL | 'B', backchar}
|
||||
,
|
||||
{CONTROL | 'C', insspace}
|
||||
,
|
||||
{CONTROL | 'D', forwdel}
|
||||
,
|
||||
{CONTROL | 'E', gotoeol}
|
||||
,
|
||||
{CONTROL | 'F', forwchar}
|
||||
,
|
||||
{CONTROL | 'G', ctrlg}
|
||||
,
|
||||
{CONTROL | 'H', backdel}
|
||||
,
|
||||
{CONTROL | 'I', tab}
|
||||
,
|
||||
{CONTROL | 'J', indent}
|
||||
,
|
||||
{CONTROL | 'K', killtext}
|
||||
,
|
||||
{CONTROL | 'L', refresh}
|
||||
,
|
||||
{CONTROL | 'M', newline}
|
||||
,
|
||||
{CONTROL | 'N', forwline}
|
||||
,
|
||||
{CONTROL | 'O', openline}
|
||||
,
|
||||
{CONTROL | 'P', backline}
|
||||
,
|
||||
{CONTROL | 'Q', quote}
|
||||
,
|
||||
{CONTROL | 'R', backsearch}
|
||||
,
|
||||
{CONTROL | 'S', forwsearch}
|
||||
,
|
||||
{CONTROL | 'T', twiddle}
|
||||
,
|
||||
{CONTROL | 'U', unarg}
|
||||
,
|
||||
{CONTROL | 'V', forwpage}
|
||||
,
|
||||
{CONTROL | 'W', killregion}
|
||||
,
|
||||
{CONTROL | 'X', cex}
|
||||
,
|
||||
{CONTROL | 'Y', yank}
|
||||
,
|
||||
{CONTROL | 'Z', backpage}
|
||||
,
|
||||
{CONTROL | ']', meta}
|
||||
,
|
||||
{CTLX | CONTROL | 'B', listbuffers}
|
||||
,
|
||||
{CTLX | CONTROL | 'C', quit}
|
||||
, /* Hard quit. */
|
||||
#if PKCODE & AEDIT
|
||||
{CTLX|CONTROL|'A', detab},
|
||||
{CTLX | CONTROL | 'A', detab}
|
||||
,
|
||||
#endif
|
||||
#if PKCODE
|
||||
{CTLX|CONTROL|'D', filesave}, /* alternative */
|
||||
{CTLX | CONTROL | 'D', filesave}
|
||||
, /* alternative */
|
||||
#else
|
||||
#if AEDIT
|
||||
{CTLX|CONTROL|'D', detab},
|
||||
{CTLX | CONTROL | 'D', detab}
|
||||
,
|
||||
#endif
|
||||
#endif
|
||||
#if AEDIT
|
||||
{CTLX|CONTROL|'E', entab},
|
||||
{CTLX | CONTROL | 'E', entab}
|
||||
,
|
||||
#endif
|
||||
{CTLX|CONTROL|'F', filefind},
|
||||
{CTLX|CONTROL|'I', insfile},
|
||||
{CTLX|CONTROL|'L', lowerregion},
|
||||
{CTLX|CONTROL|'M', delmode},
|
||||
{CTLX|CONTROL|'N', mvdnwind},
|
||||
{CTLX|CONTROL|'O', deblank},
|
||||
{CTLX|CONTROL|'P', mvupwind},
|
||||
{CTLX|CONTROL|'R', fileread},
|
||||
{CTLX|CONTROL|'S', filesave},
|
||||
{CTLX | CONTROL | 'F', filefind}
|
||||
,
|
||||
{CTLX | CONTROL | 'I', insfile}
|
||||
,
|
||||
{CTLX | CONTROL | 'L', lowerregion}
|
||||
,
|
||||
{CTLX | CONTROL | 'M', delmode}
|
||||
,
|
||||
{CTLX | CONTROL | 'N', mvdnwind}
|
||||
,
|
||||
{CTLX | CONTROL | 'O', deblank}
|
||||
,
|
||||
{CTLX | CONTROL | 'P', mvupwind}
|
||||
,
|
||||
{CTLX | CONTROL | 'R', fileread}
|
||||
,
|
||||
{CTLX | CONTROL | 'S', filesave}
|
||||
,
|
||||
#if AEDIT
|
||||
{CTLX|CONTROL|'T', trim},
|
||||
{CTLX | CONTROL | 'T', trim}
|
||||
,
|
||||
#endif
|
||||
{CTLX|CONTROL|'U', upperregion},
|
||||
{CTLX|CONTROL|'V', viewfile},
|
||||
{CTLX|CONTROL|'W', filewrite},
|
||||
{CTLX|CONTROL|'X', swapmark},
|
||||
{CTLX|CONTROL|'Z', shrinkwind},
|
||||
{CTLX|'?', deskey},
|
||||
{CTLX|'!', spawn},
|
||||
{CTLX|'@', pipecmd},
|
||||
{CTLX|'#', filter},
|
||||
{CTLX|'$', execprg},
|
||||
{CTLX|'=', showcpos},
|
||||
{CTLX|'(', ctlxlp},
|
||||
{CTLX|')', ctlxrp},
|
||||
{CTLX|'^', enlargewind},
|
||||
{CTLX|'0', delwind},
|
||||
{CTLX|'1', onlywind},
|
||||
{CTLX|'2', splitwind},
|
||||
{CTLX|'A', setvar},
|
||||
{CTLX|'B', usebuffer},
|
||||
{CTLX|'C', spawncli},
|
||||
{CTLX | CONTROL | 'U', upperregion}
|
||||
,
|
||||
{CTLX | CONTROL | 'V', viewfile}
|
||||
,
|
||||
{CTLX | CONTROL | 'W', filewrite}
|
||||
,
|
||||
{CTLX | CONTROL | 'X', swapmark}
|
||||
,
|
||||
{CTLX | CONTROL | 'Z', shrinkwind}
|
||||
,
|
||||
{CTLX | '?', deskey}
|
||||
,
|
||||
{CTLX | '!', spawn}
|
||||
,
|
||||
{CTLX | '@', pipecmd}
|
||||
,
|
||||
{CTLX | '#', filter}
|
||||
,
|
||||
{CTLX | '$', execprg}
|
||||
,
|
||||
{CTLX | '=', showcpos}
|
||||
,
|
||||
{CTLX | '(', ctlxlp}
|
||||
,
|
||||
{CTLX | ')', ctlxrp}
|
||||
,
|
||||
{CTLX | '^', enlargewind}
|
||||
,
|
||||
{CTLX | '0', delwind}
|
||||
,
|
||||
{CTLX | '1', onlywind}
|
||||
,
|
||||
{CTLX | '2', splitwind}
|
||||
,
|
||||
{CTLX | 'A', setvar}
|
||||
,
|
||||
{CTLX | 'B', usebuffer}
|
||||
,
|
||||
{CTLX | 'C', spawncli}
|
||||
,
|
||||
#if BSD | __hpux | SVR4
|
||||
{CTLX|'D', bktoshell},
|
||||
{CTLX | 'D', bktoshell}
|
||||
,
|
||||
#endif
|
||||
{CTLX|'E', ctlxe},
|
||||
{CTLX|'F', setfillcol},
|
||||
{CTLX|'K', killbuffer},
|
||||
{CTLX|'M', setmode},
|
||||
{CTLX|'N', filename},
|
||||
{CTLX|'O', nextwind},
|
||||
{CTLX|'P', prevwind},
|
||||
{CTLX | 'E', ctlxe}
|
||||
,
|
||||
{CTLX | 'F', setfillcol}
|
||||
,
|
||||
{CTLX | 'K', killbuffer}
|
||||
,
|
||||
{CTLX | 'M', setmode}
|
||||
,
|
||||
{CTLX | 'N', filename}
|
||||
,
|
||||
{CTLX | 'O', nextwind}
|
||||
,
|
||||
{CTLX | 'P', prevwind}
|
||||
,
|
||||
#if PKCODE
|
||||
{CTLX|'Q', quote}, /* alternative */
|
||||
{CTLX | 'Q', quote}
|
||||
, /* alternative */
|
||||
#endif
|
||||
#if ISRCH
|
||||
{CTLX|'R', risearch},
|
||||
{CTLX|'S', fisearch},
|
||||
{CTLX | 'R', risearch}
|
||||
,
|
||||
{CTLX | 'S', fisearch}
|
||||
,
|
||||
#endif
|
||||
{CTLX|'W', resize},
|
||||
{CTLX|'X', nextbuffer},
|
||||
{CTLX|'Z', enlargewind},
|
||||
{CTLX | 'W', resize}
|
||||
,
|
||||
{CTLX | 'X', nextbuffer}
|
||||
,
|
||||
{CTLX | 'Z', enlargewind}
|
||||
,
|
||||
#if WORDPRO
|
||||
{META|CONTROL|'C', wordcount},
|
||||
{META | CONTROL | 'C', wordcount}
|
||||
,
|
||||
#endif
|
||||
#if PKCODE
|
||||
{META|CONTROL|'D', newsize},
|
||||
{META | CONTROL | 'D', newsize}
|
||||
,
|
||||
#endif
|
||||
#if PROC
|
||||
{META|CONTROL|'E', execproc},
|
||||
{META | CONTROL | 'E', execproc}
|
||||
,
|
||||
#endif
|
||||
#if CFENCE
|
||||
{META|CONTROL|'F', getfence},
|
||||
{META | CONTROL | 'F', getfence}
|
||||
,
|
||||
#endif
|
||||
{META|CONTROL|'H', delbword},
|
||||
{META|CONTROL|'K', unbindkey},
|
||||
{META|CONTROL|'L', reposition},
|
||||
{META|CONTROL|'M', delgmode},
|
||||
{META|CONTROL|'N', namebuffer},
|
||||
{META|CONTROL|'R', qreplace},
|
||||
{META|CONTROL|'S', newsize},
|
||||
{META|CONTROL|'T', newwidth},
|
||||
{META|CONTROL|'V', scrnextdw},
|
||||
{META | CONTROL | 'H', delbword}
|
||||
,
|
||||
{META | CONTROL | 'K', unbindkey}
|
||||
,
|
||||
{META | CONTROL | 'L', reposition}
|
||||
,
|
||||
{META | CONTROL | 'M', delgmode}
|
||||
,
|
||||
{META | CONTROL | 'N', namebuffer}
|
||||
,
|
||||
{META | CONTROL | 'R', qreplace}
|
||||
,
|
||||
{META | CONTROL | 'S', newsize}
|
||||
,
|
||||
{META | CONTROL | 'T', newwidth}
|
||||
,
|
||||
{META | CONTROL | 'V', scrnextdw}
|
||||
,
|
||||
#if WORDPRO
|
||||
{META|CONTROL|'W', killpara},
|
||||
{META | CONTROL | 'W', killpara}
|
||||
,
|
||||
#endif
|
||||
{META|CONTROL|'Z', scrnextup},
|
||||
{META|' ', setmark},
|
||||
{META|'?', help},
|
||||
{META|'!', reposition},
|
||||
{META|'.', setmark},
|
||||
{META|'>', gotoeob},
|
||||
{META|'<', gotobob},
|
||||
{META|'~', unmark},
|
||||
{META | CONTROL | 'Z', scrnextup}
|
||||
,
|
||||
{META | ' ', setmark}
|
||||
,
|
||||
{META | '?', help}
|
||||
,
|
||||
{META | '!', reposition}
|
||||
,
|
||||
{META | '.', setmark}
|
||||
,
|
||||
{META | '>', gotoeob}
|
||||
,
|
||||
{META | '<', gotobob}
|
||||
,
|
||||
{META | '~', unmark}
|
||||
,
|
||||
#if APROP
|
||||
{META|'A', apro},
|
||||
{META | 'A', apro}
|
||||
,
|
||||
#endif
|
||||
{META|'B', backword},
|
||||
{META|'C', capword},
|
||||
{META|'D', delfword},
|
||||
{META | 'B', backword}
|
||||
,
|
||||
{META | 'C', capword}
|
||||
,
|
||||
{META | 'D', delfword}
|
||||
,
|
||||
#if CRYPT
|
||||
{META|'E', setkey},
|
||||
{META | 'E', setkey}
|
||||
,
|
||||
#endif
|
||||
{META|'F', forwword},
|
||||
{META|'G', gotoline},
|
||||
{META | 'F', forwword}
|
||||
,
|
||||
{META | 'G', gotoline}
|
||||
,
|
||||
#if PKCODE
|
||||
#if WORDPRO
|
||||
{META|'J', justpara},
|
||||
{META | 'J', justpara}
|
||||
,
|
||||
#endif
|
||||
#endif
|
||||
{META|'K', bindtokey},
|
||||
{META|'L', lowerword},
|
||||
{META|'M', setgmode},
|
||||
{META | 'K', bindtokey}
|
||||
,
|
||||
{META | 'L', lowerword}
|
||||
,
|
||||
{META | 'M', setgmode}
|
||||
,
|
||||
#if WORDPRO
|
||||
{META|'N', gotoeop},
|
||||
{META|'P', gotobop},
|
||||
{META|'Q', fillpara},
|
||||
{META | 'N', gotoeop}
|
||||
,
|
||||
{META | 'P', gotobop}
|
||||
,
|
||||
{META | 'Q', fillpara}
|
||||
,
|
||||
#endif
|
||||
{META|'R', sreplace},
|
||||
{META | 'R', sreplace}
|
||||
,
|
||||
#if PKCODE
|
||||
{META|'S', forwsearch}, /* alternative P.K. */
|
||||
{META | 'S', forwsearch}
|
||||
, /* alternative P.K. */
|
||||
#else
|
||||
#if BSD
|
||||
{META|'S', bktoshell},
|
||||
{META | 'S', bktoshell}
|
||||
,
|
||||
#endif
|
||||
#endif
|
||||
{META|'U', upperword},
|
||||
{META|'V', backpage},
|
||||
{META|'W', copyregion},
|
||||
{META|'X', namedcmd},
|
||||
{META|'Z', quickexit},
|
||||
{META|0x7F, delbword},
|
||||
{META | 'U', upperword}
|
||||
,
|
||||
{META | 'V', backpage}
|
||||
,
|
||||
{META | 'W', copyregion}
|
||||
,
|
||||
{META | 'X', namedcmd}
|
||||
,
|
||||
{META | 'Z', quickexit}
|
||||
,
|
||||
{META | 0x7F, delbword}
|
||||
,
|
||||
|
||||
#if MSDOS
|
||||
{SPEC|CONTROL|'_', forwhunt},
|
||||
{SPEC|CONTROL|'S', backhunt},
|
||||
{SPEC|71, gotobol},
|
||||
{SPEC|72, backline},
|
||||
{SPEC|73, backpage},
|
||||
{SPEC|75, backchar},
|
||||
{SPEC|77, forwchar},
|
||||
{SPEC|79, gotoeol},
|
||||
{SPEC|80, forwline},
|
||||
{SPEC|81, forwpage},
|
||||
{SPEC|82, insspace},
|
||||
{SPEC|83, forwdel},
|
||||
{SPEC|115, backword},
|
||||
{SPEC|116, forwword},
|
||||
{SPEC | CONTROL | '_', forwhunt}
|
||||
,
|
||||
{SPEC | CONTROL | 'S', backhunt}
|
||||
,
|
||||
{SPEC | 71, gotobol}
|
||||
,
|
||||
{SPEC | 72, backline}
|
||||
,
|
||||
{SPEC | 73, backpage}
|
||||
,
|
||||
{SPEC | 75, backchar}
|
||||
,
|
||||
{SPEC | 77, forwchar}
|
||||
,
|
||||
{SPEC | 79, gotoeol}
|
||||
,
|
||||
{SPEC | 80, forwline}
|
||||
,
|
||||
{SPEC | 81, forwpage}
|
||||
,
|
||||
{SPEC | 82, insspace}
|
||||
,
|
||||
{SPEC | 83, forwdel}
|
||||
,
|
||||
{SPEC | 115, backword}
|
||||
,
|
||||
{SPEC | 116, forwword}
|
||||
,
|
||||
#if WORDPRO
|
||||
{SPEC|132, gotobop},
|
||||
{SPEC|118, gotoeop},
|
||||
{SPEC | 132, gotobop}
|
||||
,
|
||||
{SPEC | 118, gotoeop}
|
||||
,
|
||||
#endif
|
||||
{SPEC|84, cbuf1},
|
||||
{SPEC|85, cbuf2},
|
||||
{SPEC|86, cbuf3},
|
||||
{SPEC|87, cbuf4},
|
||||
{SPEC|88, cbuf5},
|
||||
{SPEC|89, cbuf6},
|
||||
{SPEC|90, cbuf7},
|
||||
{SPEC|91, cbuf8},
|
||||
{SPEC|92, cbuf9},
|
||||
{SPEC|93, cbuf10},
|
||||
{SPEC | 84, cbuf1}
|
||||
,
|
||||
{SPEC | 85, cbuf2}
|
||||
,
|
||||
{SPEC | 86, cbuf3}
|
||||
,
|
||||
{SPEC | 87, cbuf4}
|
||||
,
|
||||
{SPEC | 88, cbuf5}
|
||||
,
|
||||
{SPEC | 89, cbuf6}
|
||||
,
|
||||
{SPEC | 90, cbuf7}
|
||||
,
|
||||
{SPEC | 91, cbuf8}
|
||||
,
|
||||
{SPEC | 92, cbuf9}
|
||||
,
|
||||
{SPEC | 93, cbuf10}
|
||||
,
|
||||
#if PKCODE
|
||||
{SPEC|117, gotoeob},
|
||||
{SPEC|119, gotobob},
|
||||
{SPEC|141, gotobop},
|
||||
{SPEC|145, gotoeop},
|
||||
{SPEC|146, yank},
|
||||
{SPEC|147, killregion},
|
||||
{SPEC | 117, gotoeob}
|
||||
,
|
||||
{SPEC | 119, gotobob}
|
||||
,
|
||||
{SPEC | 141, gotobop}
|
||||
,
|
||||
{SPEC | 145, gotoeop}
|
||||
,
|
||||
{SPEC | 146, yank}
|
||||
,
|
||||
{SPEC | 147, killregion}
|
||||
,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if VT220
|
||||
{SPEC|'1', fisearch}, /* VT220 keys */
|
||||
{SPEC|'2', yank},
|
||||
{SPEC|'3', killregion},
|
||||
{SPEC|'4', setmark},
|
||||
{SPEC|'5', backpage},
|
||||
{SPEC|'6', forwpage},
|
||||
{SPEC|'A', backline},
|
||||
{SPEC|'B', forwline},
|
||||
{SPEC|'C', forwchar},
|
||||
{SPEC|'D', backchar},
|
||||
{SPEC|'c', meta},
|
||||
{SPEC|'d', backchar},
|
||||
{SPEC|'e', forwline},
|
||||
{SPEC|'f', gotobob},
|
||||
{SPEC|'h', help},
|
||||
{SPEC|'i', cex},
|
||||
{SPEC | '1', fisearch}
|
||||
, /* VT220 keys */
|
||||
{SPEC | '2', yank}
|
||||
,
|
||||
{SPEC | '3', killregion}
|
||||
,
|
||||
{SPEC | '4', setmark}
|
||||
,
|
||||
{SPEC | '5', backpage}
|
||||
,
|
||||
{SPEC | '6', forwpage}
|
||||
,
|
||||
{SPEC | 'A', backline}
|
||||
,
|
||||
{SPEC | 'B', forwline}
|
||||
,
|
||||
{SPEC | 'C', forwchar}
|
||||
,
|
||||
{SPEC | 'D', backchar}
|
||||
,
|
||||
{SPEC | 'c', meta}
|
||||
,
|
||||
{SPEC | 'd', backchar}
|
||||
,
|
||||
{SPEC | 'e', forwline}
|
||||
,
|
||||
{SPEC | 'f', gotobob}
|
||||
,
|
||||
{SPEC | 'h', help}
|
||||
,
|
||||
{SPEC | 'i', cex}
|
||||
,
|
||||
#endif
|
||||
|
||||
{0x7F, backdel},
|
||||
{0x7F, backdel}
|
||||
,
|
||||
|
||||
/* special internal bindings */
|
||||
SPEC|META|'W', wrapword, /* called on word wrap */
|
||||
SPEC|META|'C', nullproc, /* every command input */
|
||||
SPEC|META|'R', nullproc, /* on file read */
|
||||
SPEC|META|'X', nullproc, /* on window change P.K. */
|
||||
SPEC | META | 'W', wrapword, /* called on word wrap */
|
||||
SPEC | META | 'C', nullproc, /* every command input */
|
||||
SPEC | META | 'R', nullproc, /* on file read */
|
||||
SPEC | META | 'X', nullproc, /* on window change P.K. */
|
||||
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
|
||||
|
20
edef.h
20
edef.h
@ -46,10 +46,12 @@ int revexist = FALSE; /* does reverse video exist? */
|
||||
int flickcode = FALSE; /* do flicker supression? */
|
||||
char *modename[] = { /* name of modes */
|
||||
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
|
||||
"MAGIC", "CRYPT", "ASAVE"};
|
||||
"MAGIC", "CRYPT", "ASAVE"
|
||||
};
|
||||
char *mode2name[] = { /* name of modes */
|
||||
"Wrap", "Cmode", "Spell", "Exact", "View", "Over",
|
||||
"Magic", "Crypt", "Asave"};
|
||||
"Magic", "Crypt", "Asave"
|
||||
};
|
||||
char modecode[] = "WCSEVOMYA"; /* letters to represent modes */
|
||||
int gmode = 0; /* global editor mode */
|
||||
int gflags = GFREAD; /* global control flag */
|
||||
@ -58,7 +60,7 @@ int gfcolor = 8; /* global forgrnd color (white) */
|
||||
#else
|
||||
int gfcolor = 7; /* global forgrnd color (white) */
|
||||
#endif
|
||||
int gbcolor = 0; /* global backgrnd color (black)*/
|
||||
int gbcolor = 0; /* global backgrnd color (black) */
|
||||
int gasave = 256; /* global ASAVE size */
|
||||
int gacount = 256; /* count until next ASAVE */
|
||||
int sgarbf = TRUE; /* TRUE if screen is garbage */
|
||||
@ -67,7 +69,7 @@ int clexec = FALSE; /* command line execution flag */
|
||||
int mstore = FALSE; /* storing text to macro flag */
|
||||
int discmd = TRUE; /* display command flag */
|
||||
int disinp = TRUE; /* display input characters */
|
||||
struct BUFFER *bstore = NULL; /* buffer to store macro text to*/
|
||||
struct BUFFER *bstore = NULL; /* buffer to store macro text to */
|
||||
int vtrow = 0; /* Row location of SW cursor */
|
||||
int vtcol = 0; /* Column location of SW cursor */
|
||||
int ttrow = HUGE; /* Row location of HW cursor */
|
||||
@ -86,9 +88,9 @@ char *cname[] = { /* names of colors */
|
||||
"BLACK", "RED", "GREEN", "YELLOW", "BLUE",
|
||||
"MAGENTA", "CYAN", "WHITE"
|
||||
#if PKCODE & IBMPC
|
||||
,"HIGH"
|
||||
, "HIGH"
|
||||
#endif
|
||||
};
|
||||
};
|
||||
KILL *kbufp = NULL; /* current kill buffer chunk pointer */
|
||||
KILL *kbufh = NULL; /* kill buffer header pointer */
|
||||
int kused = KBLOCK; /* # of bytes used in kill buffer */
|
||||
@ -212,7 +214,7 @@ extern NBIND names[]; /* name to function table */
|
||||
extern int gmode; /* global editor mode */
|
||||
extern int gflags; /* global control flag */
|
||||
extern int gfcolor; /* global forgrnd color (white) */
|
||||
extern int gbcolor; /* global backgrnd color (black)*/
|
||||
extern int gbcolor; /* global backgrnd color (black) */
|
||||
extern int gasave; /* global ASAVE size */
|
||||
extern int gacount; /* count until next ASAVE */
|
||||
extern int sgarbf; /* State of screen unknown */
|
||||
@ -221,7 +223,7 @@ extern int clexec; /* command line execution flag */
|
||||
extern int mstore; /* storing text to macro flag */
|
||||
extern int discmd; /* display command flag */
|
||||
extern int disinp; /* display input characters */
|
||||
extern struct BUFFER *bstore; /* buffer to store macro text to*/
|
||||
extern struct BUFFER *bstore; /* buffer to store macro text to */
|
||||
extern int vtrow; /* Row location of SW cursor */
|
||||
extern int vtcol; /* Column location of SW cursor */
|
||||
extern int ttrow; /* Row location of HW cursor */
|
||||
@ -319,5 +321,3 @@ extern char outline[]; /* global string to hold debug line text */
|
||||
#ifndef termdef
|
||||
extern TERM term; /* Terminal information. */
|
||||
#endif
|
||||
|
||||
|
||||
|
6
efunc.h
6
efunc.h
@ -79,8 +79,8 @@ extern int copyregion(); /* Copy region to kill buffer. */
|
||||
extern int spawncli(); /* Run CLI in a subjob. */
|
||||
extern int spawn(); /* Run a command in a subjob. */
|
||||
#if BSD | __hpux | SVR4
|
||||
extern int bktoshell(); /* suspend emacs to parent shell*/
|
||||
extern int rtfrmshell(); /* return from a suspended state*/
|
||||
extern int bktoshell(); /* suspend emacs to parent shell */
|
||||
extern int rtfrmshell(); /* return from a suspended state */
|
||||
#endif
|
||||
extern int quickexit(); /* low keystroke style exit. */
|
||||
extern int setmode(); /* set an editor mode */
|
||||
@ -116,7 +116,7 @@ extern int setgmode(); /* set a global mode */
|
||||
extern int delgmode(); /* delete a global mode */
|
||||
extern int insspace(); /* insert a space forword */
|
||||
extern int forwhunt(); /* hunt forward for next match */
|
||||
extern int backhunt(); /* hunt backwards for next match*/
|
||||
extern int backhunt(); /* hunt backwards for next match */
|
||||
extern int pipecmd(); /* pipe command into buffer */
|
||||
extern int filter(); /* filter buffer through dos */
|
||||
extern int delwind(); /* delete the current window */
|
||||
|
23
epath.h
23
epath.h
@ -9,7 +9,6 @@
|
||||
/* possible names and paths of help files under different OSs */
|
||||
|
||||
char *pathname[] =
|
||||
|
||||
#if MSDOS
|
||||
{
|
||||
"emacs.rc",
|
||||
@ -24,30 +23,20 @@ char *pathname[] =
|
||||
|
||||
#if V7 | BSD | USG
|
||||
{
|
||||
".emacsrc",
|
||||
"emacs.hlp",
|
||||
".emacsrc", "emacs.hlp",
|
||||
#if PKCODE
|
||||
"/usr/global/lib/",
|
||||
"/usr/local/bin/",
|
||||
"/usr/local/lib/",
|
||||
"/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/",
|
||||
#endif
|
||||
"/usr/local/",
|
||||
"/usr/lib/",
|
||||
""
|
||||
};
|
||||
"/usr/local/", "/usr/lib/", ""};
|
||||
#endif
|
||||
|
||||
#if VMS
|
||||
{
|
||||
"emacs.rc",
|
||||
"emacs.hlp",
|
||||
"",
|
||||
"emacs.rc", "emacs.hlp", "",
|
||||
#if PKCODE
|
||||
"sys$login:",
|
||||
"emacs_dir:",
|
||||
"sys$login:", "emacs_dir:",
|
||||
#endif
|
||||
"sys$sysdevice:[vmstools]"
|
||||
};
|
||||
"sys$sysdevice:[vmstools]"};
|
||||
#endif
|
||||
|
||||
#define NPNAMES (sizeof(pathname)/sizeof(char *))
|
||||
|
77
estruct.h
77
estruct.h
@ -77,7 +77,7 @@
|
||||
#else
|
||||
|
||||
#define MSDOS 1 /* MS-DOS */
|
||||
#define V7 0 /* V7 UNIX or Coherent or BSD4.2*/
|
||||
#define V7 0 /* V7 UNIX or Coherent or BSD4.2 */
|
||||
#define BSD 0 /* UNIX BSD 4.2 and ULTRIX */
|
||||
#define USG 0 /* UNIX system V */
|
||||
#define VMS 0 /* VAX/VMS */
|
||||
@ -308,7 +308,7 @@
|
||||
#define FIOEOF 2 /* File I/O, end of file. */
|
||||
#define FIOERR 3 /* File I/O, error. */
|
||||
#define FIOMEM 4 /* File I/O, out of memory */
|
||||
#define FIOFUN 5 /* File I/O, eod of file/bad line*/
|
||||
#define FIOFUN 5 /* File I/O, eod of file/bad line */
|
||||
|
||||
#define CFCPCN 0x0001 /* Last command was C-P, C-N */
|
||||
#define CFKILL 0x0002 /* Last command was a kill */
|
||||
@ -496,7 +496,7 @@ typedef struct BUFFER {
|
||||
#define NUMMODES 9 /* # of defined modes */
|
||||
|
||||
#define MDWRAP 0x0001 /* word wrap */
|
||||
#define MDCMOD 0x0002 /* C indentation and fence match*/
|
||||
#define MDCMOD 0x0002 /* C indentation and fence match */
|
||||
#define MDSPELL 0x0004 /* spell error parcing */
|
||||
#define MDEXACT 0x0008 /* Exact matching for searches */
|
||||
#define MDVIEW 0x0010 /* read-only buffer */
|
||||
@ -551,28 +551,28 @@ typedef struct {
|
||||
short t_nrow; /* current number of rows used */
|
||||
short t_mcol; /* max Number of columns. */
|
||||
short t_ncol; /* current Number of columns. */
|
||||
short t_margin; /* min margin for extended lines*/
|
||||
short t_margin; /* min margin for extended lines */
|
||||
short t_scrsiz; /* size of scroll region " */
|
||||
int t_pause; /* # times thru update to pause */
|
||||
int (*t_open)(); /* Open terminal at the start. */
|
||||
int (*t_close)(); /* Close terminal at end. */
|
||||
int (*t_kopen)(); /* Open keyboard */
|
||||
int (*t_kclose)(); /* close keyboard */
|
||||
int (*t_getchar)(); /* Get character from keyboard. */
|
||||
int (*t_putchar)(); /* Put character to display. */
|
||||
int (*t_flush)(); /* Flush output buffers. */
|
||||
int (*t_move)(); /* Move the cursor, origin 0. */
|
||||
int (*t_eeol)(); /* Erase to end of line. */
|
||||
int (*t_eeop)(); /* Erase to end of page. */
|
||||
int (*t_beep)(); /* Beep. */
|
||||
int (*t_rev)(); /* set reverse video state */
|
||||
int (*t_rez)(); /* change screen resolution */
|
||||
int (*t_open) (); /* Open terminal at the start. */
|
||||
int (*t_close) (); /* Close terminal at end. */
|
||||
int (*t_kopen) (); /* Open keyboard */
|
||||
int (*t_kclose) (); /* close keyboard */
|
||||
int (*t_getchar) (); /* Get character from keyboard. */
|
||||
int (*t_putchar) (); /* Put character to display. */
|
||||
int (*t_flush) (); /* Flush output buffers. */
|
||||
int (*t_move) (); /* Move the cursor, origin 0. */
|
||||
int (*t_eeol) (); /* Erase to end of line. */
|
||||
int (*t_eeop) (); /* Erase to end of page. */
|
||||
int (*t_beep) (); /* Beep. */
|
||||
int (*t_rev) (); /* set reverse video state */
|
||||
int (*t_rez) (); /* change screen resolution */
|
||||
#if COLOR
|
||||
int (*t_setfor)(); /* set forground color */
|
||||
int (*t_setback)(); /* set background color */
|
||||
int (*t_setfor) (); /* set forground color */
|
||||
int (*t_setback) (); /* set background color */
|
||||
#endif
|
||||
#if SCROLLCODE
|
||||
int (*t_scroll)(); /* scroll a region of the screen */
|
||||
int (*t_scroll) (); /* scroll a region of the screen */
|
||||
#endif
|
||||
} TERM;
|
||||
|
||||
@ -601,14 +601,14 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
short k_code; /* Key code */
|
||||
int (*k_fp)(); /* Routine to handle it */
|
||||
int (*k_fp) (); /* Routine to handle it */
|
||||
} KEYTAB;
|
||||
|
||||
/* structure for the name binding table */
|
||||
|
||||
typedef struct {
|
||||
char *n_name; /* name of function key */
|
||||
int (*n_func)(); /* function name is bound to */
|
||||
int (*n_func) (); /* function name is bound to */
|
||||
} NBIND;
|
||||
|
||||
/* The editor holds deleted text chunks in the KILL buffer. The
|
||||
@ -642,7 +642,7 @@ typedef struct VDESC {
|
||||
|
||||
typedef struct WHBLOCK {
|
||||
LINE *w_begin; /* ptr to !while statement */
|
||||
LINE *w_end; /* ptr to the !endwhile statement*/
|
||||
LINE *w_end; /* ptr to the !endwhile statement */
|
||||
int w_type; /* block type */
|
||||
struct WHBLOCK *w_next; /* next while */
|
||||
} WHBLOCK;
|
||||
@ -678,30 +678,30 @@ typedef struct WHBLOCK {
|
||||
* Defines for the metacharacters in the regular expression
|
||||
* search routines.
|
||||
*/
|
||||
#define MCNIL 0 /* Like the '\0' for strings.*/
|
||||
#define LITCHAR 1 /* Literal character, or string.*/
|
||||
#define MCNIL 0 /* Like the '\0' for strings. */
|
||||
#define LITCHAR 1 /* Literal character, or string. */
|
||||
#define ANY 2
|
||||
#define CCL 3
|
||||
#define NCCL 4
|
||||
#define BOL 5
|
||||
#define EOL 6
|
||||
#define DITTO 7
|
||||
#define CLOSURE 256 /* An or-able value.*/
|
||||
#define CLOSURE 256 /* An or-able value. */
|
||||
#define MASKCL CLOSURE - 1
|
||||
|
||||
#define MC_ANY '.' /* 'Any' character (except newline).*/
|
||||
#define MC_CCL '[' /* Character class.*/
|
||||
#define MC_NCCL '^' /* Negate character class.*/
|
||||
#define MC_RCCL '-' /* Range in character class.*/
|
||||
#define MC_ECCL ']' /* End of character class.*/
|
||||
#define MC_BOL '^' /* Beginning of line.*/
|
||||
#define MC_EOL '$' /* End of line.*/
|
||||
#define MC_CLOSURE '*' /* Closure - does not extend past newline.*/
|
||||
#define MC_DITTO '&' /* Use matched string in replacement.*/
|
||||
#define MC_ESC '\\' /* Escape - suppress meta-meaning.*/
|
||||
#define MC_ANY '.' /* 'Any' character (except newline). */
|
||||
#define MC_CCL '[' /* Character class. */
|
||||
#define MC_NCCL '^' /* Negate character class. */
|
||||
#define MC_RCCL '-' /* Range in character class. */
|
||||
#define MC_ECCL ']' /* End of character class. */
|
||||
#define MC_BOL '^' /* Beginning of line. */
|
||||
#define MC_EOL '$' /* End of line. */
|
||||
#define MC_CLOSURE '*' /* Closure - does not extend past newline. */
|
||||
#define MC_DITTO '&' /* Use matched string in replacement. */
|
||||
#define MC_ESC '\\' /* Escape - suppress meta-meaning. */
|
||||
|
||||
#define BIT(n) (1 << (n)) /* An integer with one bit set.*/
|
||||
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter.*/
|
||||
#define BIT(n) (1 << (n)) /* An integer with one bit set. */
|
||||
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */
|
||||
|
||||
/* HICHAR - 1 is the largest character we will deal with.
|
||||
* HIBYTE represents the number of bytes in the bitmap.
|
||||
@ -728,4 +728,3 @@ typedef struct {
|
||||
char *rstr;
|
||||
} RMC;
|
||||
#endif
|
||||
|
||||
|
598
eval.c
598
eval.c
@ -11,17 +11,16 @@
|
||||
#include "edef.h"
|
||||
#include "evar.h"
|
||||
|
||||
varinit() /* initialize the user variable list */
|
||||
|
||||
{
|
||||
varinit()
|
||||
{ /* initialize the user variable list */
|
||||
register int i;
|
||||
|
||||
for (i=0; i < MAXVARS; i++)
|
||||
for (i = 0; i < MAXVARS; i++)
|
||||
uv[i].u_name[0] = 0;
|
||||
}
|
||||
|
||||
char *gtfun(fname) /* evaluate a function */
|
||||
|
||||
char *gtfun(fname)
|
||||
/* evaluate a function */
|
||||
char *fname; /* name of function to evaluate */
|
||||
|
||||
{
|
||||
@ -47,89 +46,126 @@ char *fname; /* name of function to evaluate */
|
||||
|
||||
/* return errorm on a bad reference */
|
||||
if (fnum == NFUNCS)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
|
||||
/* if needed, retrieve the first argument */
|
||||
if (funcs[fnum].f_type >= MONAMIC) {
|
||||
if ((status = macarg(arg1)) != TRUE)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
|
||||
/* if needed, retrieve the second argument */
|
||||
if (funcs[fnum].f_type >= DYNAMIC) {
|
||||
if ((status = macarg(arg2)) != TRUE)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
|
||||
/* if needed, retrieve the third argument */
|
||||
if (funcs[fnum].f_type >= TRINAMIC)
|
||||
if ((status = macarg(arg3)) != TRUE)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* and now evaluate it! */
|
||||
switch (fnum) {
|
||||
case UFADD: return(itoa(atoi(arg1) + atoi(arg2)));
|
||||
case UFSUB: return(itoa(atoi(arg1) - atoi(arg2)));
|
||||
case UFTIMES: return(itoa(atoi(arg1) * atoi(arg2)));
|
||||
case UFDIV: return(itoa(atoi(arg1) / atoi(arg2)));
|
||||
case UFMOD: return(itoa(atoi(arg1) % atoi(arg2)));
|
||||
case UFNEG: return(itoa(-atoi(arg1)));
|
||||
case UFCAT: strcpy(result, arg1);
|
||||
return(strcat(result, arg2));
|
||||
case UFLEFT: return(strncpy(result, arg1, atoi(arg2)));
|
||||
case UFRIGHT: return(strcpy(result,
|
||||
case UFADD:
|
||||
return (itoa(atoi(arg1) + atoi(arg2)));
|
||||
case UFSUB:
|
||||
return (itoa(atoi(arg1) - atoi(arg2)));
|
||||
case UFTIMES:
|
||||
return (itoa(atoi(arg1) * atoi(arg2)));
|
||||
case UFDIV:
|
||||
return (itoa(atoi(arg1) / atoi(arg2)));
|
||||
case UFMOD:
|
||||
return (itoa(atoi(arg1) % atoi(arg2)));
|
||||
case UFNEG:
|
||||
return (itoa(-atoi(arg1)));
|
||||
case UFCAT:
|
||||
strcpy(result, arg1);
|
||||
return (strcat(result, arg2));
|
||||
case UFLEFT:
|
||||
return (strncpy(result, arg1, atoi(arg2)));
|
||||
case UFRIGHT:
|
||||
return (strcpy(result,
|
||||
&arg1[(strlen(arg1) - atoi(arg2))]));
|
||||
case UFMID: return(strncpy(result, &arg1[atoi(arg2)-1],
|
||||
case UFMID:
|
||||
return (strncpy(result, &arg1[atoi(arg2) - 1],
|
||||
atoi(arg3)));
|
||||
case UFNOT: return(ltos(stol(arg1) == FALSE));
|
||||
case UFEQUAL: return(ltos(atoi(arg1) == atoi(arg2)));
|
||||
case UFLESS: return(ltos(atoi(arg1) < atoi(arg2)));
|
||||
case UFGREATER: return(ltos(atoi(arg1) > atoi(arg2)));
|
||||
case UFSEQUAL: return(ltos(strcmp(arg1, arg2) == 0));
|
||||
case UFSLESS: return(ltos(strcmp(arg1, arg2) < 0));
|
||||
case UFSGREAT: return(ltos(strcmp(arg1, arg2) > 0));
|
||||
case UFIND: return(strcpy(result, getval(arg1)));
|
||||
case UFAND: return(ltos(stol(arg1) && stol(arg2)));
|
||||
case UFOR: return(ltos(stol(arg1) || stol(arg2)));
|
||||
case UFLENGTH: return(itoa(strlen(arg1)));
|
||||
case UFUPPER: return(mkupper(arg1));
|
||||
case UFLOWER: return(mklower(arg1));
|
||||
case UFTRUTH: return(ltos(atoi(arg1) == 42));
|
||||
case UFASCII: return(itoa((int)arg1[0]));
|
||||
case UFCHR: result[0] = atoi(arg1);
|
||||
case UFNOT:
|
||||
return (ltos(stol(arg1) == FALSE));
|
||||
case UFEQUAL:
|
||||
return (ltos(atoi(arg1) == atoi(arg2)));
|
||||
case UFLESS:
|
||||
return (ltos(atoi(arg1) < atoi(arg2)));
|
||||
case UFGREATER:
|
||||
return (ltos(atoi(arg1) > atoi(arg2)));
|
||||
case UFSEQUAL:
|
||||
return (ltos(strcmp(arg1, arg2) == 0));
|
||||
case UFSLESS:
|
||||
return (ltos(strcmp(arg1, arg2) < 0));
|
||||
case UFSGREAT:
|
||||
return (ltos(strcmp(arg1, arg2) > 0));
|
||||
case UFIND:
|
||||
return (strcpy(result, getval(arg1)));
|
||||
case UFAND:
|
||||
return (ltos(stol(arg1) && stol(arg2)));
|
||||
case UFOR:
|
||||
return (ltos(stol(arg1) || stol(arg2)));
|
||||
case UFLENGTH:
|
||||
return (itoa(strlen(arg1)));
|
||||
case UFUPPER:
|
||||
return (mkupper(arg1));
|
||||
case UFLOWER:
|
||||
return (mklower(arg1));
|
||||
case UFTRUTH:
|
||||
return (ltos(atoi(arg1) == 42));
|
||||
case UFASCII:
|
||||
return (itoa((int) arg1[0]));
|
||||
case UFCHR:
|
||||
result[0] = atoi(arg1);
|
||||
result[1] = 0;
|
||||
return(result);
|
||||
case UFGTKEY: result[0] = tgetc();
|
||||
return (result);
|
||||
case UFGTKEY:
|
||||
result[0] = tgetc();
|
||||
result[1] = 0;
|
||||
return(result);
|
||||
case UFRND: return(itoa((ernd() % abs(atoi(arg1))) + 1));
|
||||
case UFABS: return(itoa(abs(atoi(arg1))));
|
||||
case UFSINDEX: return(itoa(sindex(arg1, arg2)));
|
||||
return (result);
|
||||
case UFRND:
|
||||
return (itoa((ernd() % abs(atoi(arg1))) + 1));
|
||||
case UFABS:
|
||||
return (itoa(abs(atoi(arg1))));
|
||||
case UFSINDEX:
|
||||
return (itoa(sindex(arg1, arg2)));
|
||||
case UFENV:
|
||||
#if ENVFUNC
|
||||
tsp = getenv(arg1);
|
||||
return(tsp == NULL ? "" : tsp);
|
||||
return (tsp == NULL ? "" : tsp);
|
||||
#else
|
||||
return("");
|
||||
return ("");
|
||||
#endif
|
||||
case UFBIND: return(transbind(arg1));
|
||||
case UFEXIST: return(ltos(fexist(arg1)));
|
||||
case UFBIND:
|
||||
return (transbind(arg1));
|
||||
case UFEXIST:
|
||||
return (ltos(fexist(arg1)));
|
||||
case UFFIND:
|
||||
tsp = flook(arg1, TRUE);
|
||||
return(tsp == NULL ? "" : tsp);
|
||||
case UFBAND: return(itoa(atoi(arg1) & atoi(arg2)));
|
||||
case UFBOR: return(itoa(atoi(arg1) | atoi(arg2)));
|
||||
case UFBXOR: return(itoa(atoi(arg1) ^ atoi(arg2)));
|
||||
case UFBNOT: return(itoa(~atoi(arg1)));
|
||||
case UFXLATE: return(xlat(arg1, arg2, arg3));
|
||||
return (tsp == NULL ? "" : tsp);
|
||||
case UFBAND:
|
||||
return (itoa(atoi(arg1) & atoi(arg2)));
|
||||
case UFBOR:
|
||||
return (itoa(atoi(arg1) | atoi(arg2)));
|
||||
case UFBXOR:
|
||||
return (itoa(atoi(arg1) ^ atoi(arg2)));
|
||||
case UFBNOT:
|
||||
return (itoa(~atoi(arg1)));
|
||||
case UFXLATE:
|
||||
return (xlat(arg1, arg2, arg3));
|
||||
}
|
||||
|
||||
exit(-11); /* never should get here */
|
||||
}
|
||||
|
||||
char *gtusr(vname) /* look up a user var's value */
|
||||
|
||||
char *gtusr(vname)
|
||||
/* look up a user var's value */
|
||||
char *vname; /* name of user variable to fetch */
|
||||
|
||||
{
|
||||
@ -139,13 +175,13 @@ char *vname; /* name of user variable to fetch */
|
||||
/* scan the list looking for the user var name */
|
||||
for (vnum = 0; vnum < MAXVARS; vnum++) {
|
||||
if (uv[vnum].u_name[0] == 0)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
if (strcmp(vname, uv[vnum].u_name) == 0)
|
||||
return(uv[vnum].u_value);
|
||||
return (uv[vnum].u_value);
|
||||
}
|
||||
|
||||
/* return errorm if we run off the end */
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
}
|
||||
|
||||
char *gtenv(vname)
|
||||
@ -169,78 +205,116 @@ char *vname; /* name of environment variable to retrieve */
|
||||
char *ename = getenv(vname);
|
||||
|
||||
if (ename != NULL)
|
||||
return(ename);
|
||||
return (ename);
|
||||
else
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
}
|
||||
#else
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
#endif
|
||||
|
||||
/* otherwise, fetch the appropriate value */
|
||||
switch (vnum) {
|
||||
case EVFILLCOL: return(itoa(fillcol));
|
||||
case EVPAGELEN: return(itoa(term.t_nrow + 1));
|
||||
case EVCURCOL: return(itoa(getccol(FALSE)));
|
||||
case EVCURLINE: return(itoa(getcline()));
|
||||
case EVRAM: return(itoa((int)(envram / 1024l)));
|
||||
case EVFLICKER: return(ltos(flickcode));
|
||||
case EVCURWIDTH:return(itoa(term.t_ncol));
|
||||
case EVCBUFNAME:return(curbp->b_bname);
|
||||
case EVCFNAME: return(curbp->b_fname);
|
||||
case EVSRES: return(sres);
|
||||
case EVDEBUG: return(ltos(macbug));
|
||||
case EVSTATUS: return(ltos(cmdstatus));
|
||||
case EVPALETTE: return(palstr);
|
||||
case EVASAVE: return(itoa(gasave));
|
||||
case EVACOUNT: return(itoa(gacount));
|
||||
case EVLASTKEY: return(itoa(lastkey));
|
||||
case EVFILLCOL:
|
||||
return (itoa(fillcol));
|
||||
case EVPAGELEN:
|
||||
return (itoa(term.t_nrow + 1));
|
||||
case EVCURCOL:
|
||||
return (itoa(getccol(FALSE)));
|
||||
case EVCURLINE:
|
||||
return (itoa(getcline()));
|
||||
case EVRAM:
|
||||
return (itoa((int) (envram / 1024l)));
|
||||
case EVFLICKER:
|
||||
return (ltos(flickcode));
|
||||
case EVCURWIDTH:
|
||||
return (itoa(term.t_ncol));
|
||||
case EVCBUFNAME:
|
||||
return (curbp->b_bname);
|
||||
case EVCFNAME:
|
||||
return (curbp->b_fname);
|
||||
case EVSRES:
|
||||
return (sres);
|
||||
case EVDEBUG:
|
||||
return (ltos(macbug));
|
||||
case EVSTATUS:
|
||||
return (ltos(cmdstatus));
|
||||
case EVPALETTE:
|
||||
return (palstr);
|
||||
case EVASAVE:
|
||||
return (itoa(gasave));
|
||||
case EVACOUNT:
|
||||
return (itoa(gacount));
|
||||
case EVLASTKEY:
|
||||
return (itoa(lastkey));
|
||||
case EVCURCHAR:
|
||||
return(curwp->w_dotp->l_used ==
|
||||
return (curwp->w_dotp->l_used ==
|
||||
curwp->w_doto ? itoa('\n') :
|
||||
itoa(lgetc(curwp->w_dotp, curwp->w_doto)));
|
||||
case EVDISCMD: return(ltos(discmd));
|
||||
case EVVERSION: return(VERSION);
|
||||
case EVPROGNAME:return(PROGNAME);
|
||||
case EVSEED: return(itoa(seed));
|
||||
case EVDISINP: return(ltos(disinp));
|
||||
case EVWLINE: return(itoa(curwp->w_ntrows));
|
||||
case EVCWLINE: return(itoa(getwpos()));
|
||||
case EVTARGET: saveflag = lastflag;
|
||||
return(itoa(curgoal));
|
||||
case EVSEARCH: return(pat);
|
||||
case EVREPLACE: return(rpat);
|
||||
case EVMATCH: return((patmatch == NULL)? "": patmatch);
|
||||
case EVKILL: return(getkill());
|
||||
case EVCMODE: return(itoa(curbp->b_mode));
|
||||
case EVGMODE: return(itoa(gmode));
|
||||
case EVTPAUSE: return(itoa(term.t_pause));
|
||||
case EVDISCMD:
|
||||
return (ltos(discmd));
|
||||
case EVVERSION:
|
||||
return (VERSION);
|
||||
case EVPROGNAME:
|
||||
return (PROGNAME);
|
||||
case EVSEED:
|
||||
return (itoa(seed));
|
||||
case EVDISINP:
|
||||
return (ltos(disinp));
|
||||
case EVWLINE:
|
||||
return (itoa(curwp->w_ntrows));
|
||||
case EVCWLINE:
|
||||
return (itoa(getwpos()));
|
||||
case EVTARGET:
|
||||
saveflag = lastflag;
|
||||
return (itoa(curgoal));
|
||||
case EVSEARCH:
|
||||
return (pat);
|
||||
case EVREPLACE:
|
||||
return (rpat);
|
||||
case EVMATCH:
|
||||
return ((patmatch == NULL) ? "" : patmatch);
|
||||
case EVKILL:
|
||||
return (getkill());
|
||||
case EVCMODE:
|
||||
return (itoa(curbp->b_mode));
|
||||
case EVGMODE:
|
||||
return (itoa(gmode));
|
||||
case EVTPAUSE:
|
||||
return (itoa(term.t_pause));
|
||||
case EVPENDING:
|
||||
#if TYPEAH
|
||||
return(ltos(typahead()));
|
||||
return (ltos(typahead()));
|
||||
#else
|
||||
return(falsem);
|
||||
return (falsem);
|
||||
#endif
|
||||
case EVLWIDTH: return(itoa(llength(curwp->w_dotp)));
|
||||
case EVLINE: return(getctext());
|
||||
case EVGFLAGS: return(itoa(gflags));
|
||||
case EVRVAL: return(itoa(rval));
|
||||
case EVTAB: return(itoa(tabmask+1));
|
||||
case EVOVERLAP: return(itoa(overlap));
|
||||
case EVLWIDTH:
|
||||
return (itoa(llength(curwp->w_dotp)));
|
||||
case EVLINE:
|
||||
return (getctext());
|
||||
case EVGFLAGS:
|
||||
return (itoa(gflags));
|
||||
case EVRVAL:
|
||||
return (itoa(rval));
|
||||
case EVTAB:
|
||||
return (itoa(tabmask + 1));
|
||||
case EVOVERLAP:
|
||||
return (itoa(overlap));
|
||||
case EVSCROLLCOUNT:
|
||||
return(itoa(scrollcount));
|
||||
return (itoa(scrollcount));
|
||||
#if SCROLLCODE
|
||||
case EVSCROLL: return(ltos(term.t_scroll != NULL));
|
||||
case EVSCROLL:
|
||||
return (ltos(term.t_scroll != NULL));
|
||||
#else
|
||||
case EVSCROLL: return(ltos(0));
|
||||
case EVSCROLL:
|
||||
return (ltos(0));
|
||||
#endif
|
||||
}
|
||||
exit(-12); /* again, we should never get here */
|
||||
}
|
||||
|
||||
char *getkill() /* return some of the contents of the kill buffer */
|
||||
|
||||
{
|
||||
char *getkill()
|
||||
{ /* return some of the contents of the kill buffer */
|
||||
register int size; /* max number of chars to return */
|
||||
static char value[NSTRING]; /* temp buffer for value */
|
||||
|
||||
@ -257,11 +331,11 @@ char *getkill() /* return some of the contents of the kill buffer */
|
||||
}
|
||||
|
||||
/* and return the constructed value */
|
||||
return(value);
|
||||
return (value);
|
||||
}
|
||||
|
||||
int setvar(f, n) /* set a variable */
|
||||
|
||||
int setvar(f, n)
|
||||
/* set a variable */
|
||||
int f; /* default flag */
|
||||
int n; /* numeric arg (can overide prompted value) */
|
||||
|
||||
@ -272,14 +346,14 @@ int n; /* numeric arg (can overide prompted value) */
|
||||
register char *ep; /* ptr to end of outline */
|
||||
#endif
|
||||
VDESC vd; /* variable num/type */
|
||||
char var[NVSIZE+1]; /* name of variable to fetch */
|
||||
char var[NVSIZE + 1]; /* name of variable to fetch */
|
||||
char value[NSTRING]; /* value to set variable to */
|
||||
|
||||
/* first get the variable to set.. */
|
||||
if (clexec == FALSE) {
|
||||
status = mlreply("Variable to set: ", &var[0], NVSIZE);
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
} else { /* macro line argument */
|
||||
/* grab token and skip it */
|
||||
execstr = token(execstr, var, NVSIZE + 1);
|
||||
@ -291,7 +365,7 @@ int n; /* numeric arg (can overide prompted value) */
|
||||
/* if its not legal....bitch */
|
||||
if (vd.v_type == -1) {
|
||||
mlwrite("%%No such variable as '%s'", var);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* get the value for that variable */
|
||||
@ -300,7 +374,7 @@ int n; /* numeric arg (can overide prompted value) */
|
||||
else {
|
||||
status = mlreply("Value: ", &value[0], NSTRING);
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* and set the appropriate value */
|
||||
@ -331,12 +405,11 @@ int n; /* numeric arg (can overide prompted value) */
|
||||
if (*sp++ == '%') {
|
||||
/* advance to the end */
|
||||
ep = --sp;
|
||||
while (*ep++)
|
||||
;
|
||||
while (*ep++);
|
||||
/* null terminate the string one out */
|
||||
*(ep + 1) = 0;
|
||||
/* copy backwards */
|
||||
while(ep-- > sp)
|
||||
while (ep-- > sp)
|
||||
*(ep + 1) = *ep;
|
||||
|
||||
/* and advance sp past the new % */
|
||||
@ -356,11 +429,11 @@ int n; /* numeric arg (can overide prompted value) */
|
||||
#endif
|
||||
|
||||
/* and return it */
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
findvar(var, vd, size) /* find a variables type and name */
|
||||
|
||||
findvar(var, vd, size)
|
||||
/* find a variables type and name */
|
||||
char *var; /* name of var to get */
|
||||
VDESC *vd; /* structure to hold type and ptr */
|
||||
int size; /* size of var array */
|
||||
@ -369,7 +442,7 @@ int size; /* size of var array */
|
||||
register int vnum; /* subscript in varable arrays */
|
||||
register int vtype; /* type to return */
|
||||
|
||||
fvar: vtype = -1;
|
||||
fvar:vtype = -1;
|
||||
switch (var[0]) {
|
||||
|
||||
case '$': /* check for legal enviromnent var */
|
||||
@ -414,8 +487,8 @@ fvar: vtype = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
int svar(var, value) /* set a variable */
|
||||
|
||||
int svar(var, value)
|
||||
/* set a variable */
|
||||
VDESC *var; /* variable to set */
|
||||
char *value; /* value to set to */
|
||||
|
||||
@ -424,7 +497,7 @@ char *value; /* value to set to */
|
||||
register int vtype; /* type of variable to set */
|
||||
register int status; /* status return */
|
||||
register int c; /* translated character */
|
||||
register char * sp; /* scratch string pointer */
|
||||
register char *sp; /* scratch string pointer */
|
||||
|
||||
/* simplify the vd structure (we are gonna look at it a lot) */
|
||||
vnum = var->v_num;
|
||||
@ -438,7 +511,7 @@ char *value; /* value to set to */
|
||||
free(uv[vnum].u_value);
|
||||
sp = malloc(strlen(value) + 1);
|
||||
if (sp == NULL)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
strcpy(sp, value);
|
||||
uv[vnum].u_value = sp;
|
||||
break;
|
||||
@ -446,41 +519,58 @@ char *value; /* value to set to */
|
||||
case TKENV: /* set an environment variable */
|
||||
status = TRUE; /* by default */
|
||||
switch (vnum) {
|
||||
case EVFILLCOL: fillcol = atoi(value);
|
||||
case EVFILLCOL:
|
||||
fillcol = atoi(value);
|
||||
break;
|
||||
case EVPAGELEN: status = newsize(TRUE, atoi(value));
|
||||
case EVPAGELEN:
|
||||
status = newsize(TRUE, atoi(value));
|
||||
break;
|
||||
case EVCURCOL: status = setccol(atoi(value));
|
||||
case EVCURCOL:
|
||||
status = setccol(atoi(value));
|
||||
break;
|
||||
case EVCURLINE: status = gotoline(TRUE, atoi(value));
|
||||
case EVCURLINE:
|
||||
status = gotoline(TRUE, atoi(value));
|
||||
break;
|
||||
case EVRAM: break;
|
||||
case EVFLICKER: flickcode = stol(value);
|
||||
case EVRAM:
|
||||
break;
|
||||
case EVCURWIDTH:status = newwidth(TRUE, atoi(value));
|
||||
case EVFLICKER:
|
||||
flickcode = stol(value);
|
||||
break;
|
||||
case EVCBUFNAME:strcpy(curbp->b_bname, value);
|
||||
case EVCURWIDTH:
|
||||
status = newwidth(TRUE, atoi(value));
|
||||
break;
|
||||
case EVCBUFNAME:
|
||||
strcpy(curbp->b_bname, value);
|
||||
curwp->w_flag |= WFMODE;
|
||||
break;
|
||||
case EVCFNAME: strcpy(curbp->b_fname, value);
|
||||
case EVCFNAME:
|
||||
strcpy(curbp->b_fname, value);
|
||||
curwp->w_flag |= WFMODE;
|
||||
break;
|
||||
case EVSRES: status = TTrez(value);
|
||||
case EVSRES:
|
||||
status = TTrez(value);
|
||||
break;
|
||||
case EVDEBUG: macbug = stol(value);
|
||||
case EVDEBUG:
|
||||
macbug = stol(value);
|
||||
break;
|
||||
case EVSTATUS: cmdstatus = stol(value);
|
||||
case EVSTATUS:
|
||||
cmdstatus = stol(value);
|
||||
break;
|
||||
case EVPALETTE: strncpy(palstr, value, 48);
|
||||
case EVPALETTE:
|
||||
strncpy(palstr, value, 48);
|
||||
spal(palstr);
|
||||
break;
|
||||
case EVASAVE: gasave = atoi(value);
|
||||
case EVASAVE:
|
||||
gasave = atoi(value);
|
||||
break;
|
||||
case EVACOUNT: gacount = atoi(value);
|
||||
case EVACOUNT:
|
||||
gacount = atoi(value);
|
||||
break;
|
||||
case EVLASTKEY: lastkey = atoi(value);
|
||||
case EVLASTKEY:
|
||||
lastkey = atoi(value);
|
||||
break;
|
||||
case EVCURCHAR: ldelete(1L, FALSE); /* delete 1 char */
|
||||
case EVCURCHAR:
|
||||
ldelete(1L, FALSE); /* delete 1 char */
|
||||
c = atoi(value);
|
||||
if (c == '\n')
|
||||
lnewline(FALSE, 1);
|
||||
@ -488,65 +578,86 @@ char *value; /* value to set to */
|
||||
linsert(1, c);
|
||||
backchar(FALSE, 1);
|
||||
break;
|
||||
case EVDISCMD: discmd = stol(value);
|
||||
case EVDISCMD:
|
||||
discmd = stol(value);
|
||||
break;
|
||||
case EVVERSION: break;
|
||||
case EVPROGNAME:break;
|
||||
case EVSEED: seed = atoi(value);
|
||||
case EVVERSION:
|
||||
break;
|
||||
case EVDISINP: disinp = stol(value);
|
||||
case EVPROGNAME:
|
||||
break;
|
||||
case EVWLINE: status = resize(TRUE, atoi(value));
|
||||
case EVSEED:
|
||||
seed = atoi(value);
|
||||
break;
|
||||
case EVCWLINE: status = forwline(TRUE,
|
||||
atoi(value) - getwpos());
|
||||
case EVDISINP:
|
||||
disinp = stol(value);
|
||||
break;
|
||||
case EVTARGET: curgoal = atoi(value);
|
||||
case EVWLINE:
|
||||
status = resize(TRUE, atoi(value));
|
||||
break;
|
||||
case EVCWLINE:
|
||||
status = forwline(TRUE, atoi(value) - getwpos());
|
||||
break;
|
||||
case EVTARGET:
|
||||
curgoal = atoi(value);
|
||||
thisflag = saveflag;
|
||||
break;
|
||||
case EVSEARCH: strcpy(pat, value);
|
||||
case EVSEARCH:
|
||||
strcpy(pat, value);
|
||||
rvstrcpy(tap, pat);
|
||||
#if MAGIC
|
||||
mcclear();
|
||||
#endif
|
||||
break;
|
||||
case EVREPLACE: strcpy(rpat, value);
|
||||
case EVREPLACE:
|
||||
strcpy(rpat, value);
|
||||
break;
|
||||
case EVMATCH: break;
|
||||
case EVKILL: break;
|
||||
case EVCMODE: curbp->b_mode = atoi(value);
|
||||
case EVMATCH:
|
||||
break;
|
||||
case EVKILL:
|
||||
break;
|
||||
case EVCMODE:
|
||||
curbp->b_mode = atoi(value);
|
||||
curwp->w_flag |= WFMODE;
|
||||
break;
|
||||
case EVGMODE: gmode = atoi(value);
|
||||
case EVGMODE:
|
||||
gmode = atoi(value);
|
||||
break;
|
||||
case EVTPAUSE: term.t_pause = atoi(value);
|
||||
case EVTPAUSE:
|
||||
term.t_pause = atoi(value);
|
||||
break;
|
||||
case EVPENDING: break;
|
||||
case EVLWIDTH: break;
|
||||
case EVLINE: putctext(value);
|
||||
case EVGFLAGS: gflags = atoi(value);
|
||||
case EVPENDING:
|
||||
break;
|
||||
case EVRVAL: break;
|
||||
case EVTAB: tabmask = atoi(value)-1;
|
||||
case EVLWIDTH:
|
||||
break;
|
||||
case EVLINE:
|
||||
putctext(value);
|
||||
case EVGFLAGS:
|
||||
gflags = atoi(value);
|
||||
break;
|
||||
case EVRVAL:
|
||||
break;
|
||||
case EVTAB:
|
||||
tabmask = atoi(value) - 1;
|
||||
if (tabmask != 0x07 && tabmask != 0x03)
|
||||
tabmask = 0x07;
|
||||
curwp->w_flag |= WFHARD;
|
||||
break;
|
||||
case EVOVERLAP: overlap = atoi(value);
|
||||
case EVOVERLAP:
|
||||
overlap = atoi(value);
|
||||
break;
|
||||
case EVSCROLLCOUNT:
|
||||
scrollcount = atoi(value);
|
||||
break;
|
||||
case EVSCROLL:
|
||||
#if SCROLLCODE
|
||||
if (! stol(value))
|
||||
if (!stol(value))
|
||||
term.t_scroll = NULL;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* atoi: ascii string to integer......This is too
|
||||
@ -581,9 +692,9 @@ char *st;
|
||||
if (c >= '0' && c <= '9')
|
||||
result = result * 10 + c - '0';
|
||||
else
|
||||
return(0);
|
||||
return (0);
|
||||
|
||||
return(result * sign);
|
||||
return (result * sign);
|
||||
}
|
||||
|
||||
/* itoa: integer to ascii string.......... This is too
|
||||
@ -597,9 +708,9 @@ int i; /* integer to translate to a string */
|
||||
register int digit; /* current digit being used */
|
||||
register char *sp; /* pointer into result */
|
||||
register int sign; /* sign of resulting number */
|
||||
static char result[INTWIDTH+1]; /* resulting string */
|
||||
static char result[INTWIDTH + 1]; /* resulting string */
|
||||
|
||||
/* record the sign...*/
|
||||
/* record the sign... */
|
||||
sign = 1;
|
||||
if (i < 0) {
|
||||
sign = -1;
|
||||
@ -620,11 +731,11 @@ int i; /* integer to translate to a string */
|
||||
*(--sp) = '-'; /* and install the minus sign */
|
||||
}
|
||||
|
||||
return(sp);
|
||||
return (sp);
|
||||
}
|
||||
|
||||
int gettyp(token) /* find the type of a passed token */
|
||||
|
||||
int gettyp(token)
|
||||
/* find the type of a passed token */
|
||||
char *token; /* token to analyze */
|
||||
|
||||
{
|
||||
@ -635,29 +746,38 @@ char *token; /* token to analyze */
|
||||
|
||||
/* no blanks!!! */
|
||||
if (c == 0)
|
||||
return(TKNUL);
|
||||
return (TKNUL);
|
||||
|
||||
/* a numeric literal? */
|
||||
if (c >= '0' && c <= '9')
|
||||
return(TKLIT);
|
||||
return (TKLIT);
|
||||
|
||||
switch (c) {
|
||||
case '"': return(TKSTR);
|
||||
case '"':
|
||||
return (TKSTR);
|
||||
|
||||
case '!': return(TKDIR);
|
||||
case '@': return(TKARG);
|
||||
case '#': return(TKBUF);
|
||||
case '$': return(TKENV);
|
||||
case '%': return(TKVAR);
|
||||
case '&': return(TKFUN);
|
||||
case '*': return(TKLBL);
|
||||
case '!':
|
||||
return (TKDIR);
|
||||
case '@':
|
||||
return (TKARG);
|
||||
case '#':
|
||||
return (TKBUF);
|
||||
case '$':
|
||||
return (TKENV);
|
||||
case '%':
|
||||
return (TKVAR);
|
||||
case '&':
|
||||
return (TKFUN);
|
||||
case '*':
|
||||
return (TKLBL);
|
||||
|
||||
default: return(TKCMD);
|
||||
default:
|
||||
return (TKCMD);
|
||||
}
|
||||
}
|
||||
|
||||
char *getval(token) /* find the value of a token */
|
||||
|
||||
char *getval(token)
|
||||
/* find the value of a token */
|
||||
char *token; /* token to evaluate */
|
||||
|
||||
{
|
||||
@ -665,21 +785,21 @@ char *token; /* token to evaluate */
|
||||
register BUFFER *bp; /* temp buffer pointer */
|
||||
register int blen; /* length of buffer argument */
|
||||
register int distmp; /* temporary discmd flag */
|
||||
static char buf[NSTRING];/* string buffer for some returns */
|
||||
static char buf[NSTRING]; /* string buffer for some returns */
|
||||
|
||||
switch (gettyp(token)) {
|
||||
case TKNUL: return("");
|
||||
case TKNUL:
|
||||
return ("");
|
||||
|
||||
case TKARG: /* interactive argument */
|
||||
strcpy(token, getval(&token[1]));
|
||||
distmp = discmd; /* echo it always! */
|
||||
discmd = TRUE;
|
||||
status = getstring(token,
|
||||
buf, NSTRING, ctoec('\n'));
|
||||
status = getstring(token, buf, NSTRING, ctoec('\n'));
|
||||
discmd = distmp;
|
||||
if (status == ABORT)
|
||||
return(errorm);
|
||||
return(buf);
|
||||
return (errorm);
|
||||
return (buf);
|
||||
|
||||
case TKBUF: /* buffer contents fetch */
|
||||
|
||||
@ -687,7 +807,7 @@ char *token; /* token to evaluate */
|
||||
strcpy(token, getval(&token[1]));
|
||||
bp = bfind(token, FALSE, 0);
|
||||
if (bp == NULL)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
|
||||
/* if the buffer is displayed, get the window
|
||||
vars instead of the buffer vars */
|
||||
@ -698,21 +818,20 @@ char *token; /* token to evaluate */
|
||||
|
||||
/* make sure we are not at the end */
|
||||
if (bp->b_linep == bp->b_dotp)
|
||||
return(errorm);
|
||||
return (errorm);
|
||||
|
||||
/* grab the line as an argument */
|
||||
blen = bp->b_dotp->l_used - bp->b_doto;
|
||||
if (blen > NSTRING)
|
||||
blen = NSTRING;
|
||||
strncpy(buf, bp->b_dotp->l_text + bp->b_doto,
|
||||
blen);
|
||||
strncpy(buf, bp->b_dotp->l_text + bp->b_doto, blen);
|
||||
buf[blen] = 0;
|
||||
|
||||
/* and step the buffer's line ptr ahead a line */
|
||||
bp->b_dotp = bp->b_dotp->l_fp;
|
||||
bp->b_doto = 0;
|
||||
|
||||
/* if displayed buffer, reset window ptr vars*/
|
||||
/* if displayed buffer, reset window ptr vars */
|
||||
if (bp->b_nwnd > 0) {
|
||||
curwp->w_dotp = curbp->b_dotp;
|
||||
curwp->w_doto = 0;
|
||||
@ -720,47 +839,55 @@ char *token; /* token to evaluate */
|
||||
}
|
||||
|
||||
/* and return the spoils */
|
||||
return(buf);
|
||||
return (buf);
|
||||
|
||||
case TKVAR: return(gtusr(token+1));
|
||||
case TKENV: return(gtenv(token+1));
|
||||
case TKFUN: return(gtfun(token+1));
|
||||
case TKDIR: return(errorm);
|
||||
case TKLBL: return(errorm);
|
||||
case TKLIT: return(token);
|
||||
case TKSTR: return(token+1);
|
||||
case TKCMD: return(token);
|
||||
case TKVAR:
|
||||
return (gtusr(token + 1));
|
||||
case TKENV:
|
||||
return (gtenv(token + 1));
|
||||
case TKFUN:
|
||||
return (gtfun(token + 1));
|
||||
case TKDIR:
|
||||
return (errorm);
|
||||
case TKLBL:
|
||||
return (errorm);
|
||||
case TKLIT:
|
||||
return (token);
|
||||
case TKSTR:
|
||||
return (token + 1);
|
||||
case TKCMD:
|
||||
return (token);
|
||||
}
|
||||
}
|
||||
|
||||
int stol(val) /* convert a string to a numeric logical */
|
||||
|
||||
int stol(val)
|
||||
/* convert a string to a numeric logical */
|
||||
char *val; /* value to check for stol */
|
||||
|
||||
{
|
||||
/* check for logical values */
|
||||
if (val[0] == 'F')
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
if (val[0] == 'T')
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* check for numeric truth (!= 0) */
|
||||
return((atoi(val) != 0));
|
||||
return ((atoi(val) != 0));
|
||||
}
|
||||
|
||||
char *ltos(val) /* numeric logical to string logical */
|
||||
|
||||
char *ltos(val)
|
||||
/* numeric logical to string logical */
|
||||
int val; /* value to translate */
|
||||
|
||||
{
|
||||
if (val)
|
||||
return(truem);
|
||||
return (truem);
|
||||
else
|
||||
return(falsem);
|
||||
return (falsem);
|
||||
}
|
||||
|
||||
char *mkupper(str) /* make a string upper case */
|
||||
|
||||
char *mkupper(str)
|
||||
/* make a string upper case */
|
||||
char *str; /* string to upper case */
|
||||
|
||||
{
|
||||
@ -772,11 +899,11 @@ char *str; /* string to upper case */
|
||||
*sp += 'A' - 'a';
|
||||
++sp;
|
||||
}
|
||||
return(str);
|
||||
return (str);
|
||||
}
|
||||
|
||||
char *mklower(str) /* make a string lower case */
|
||||
|
||||
char *mklower(str)
|
||||
/* make a string lower case */
|
||||
char *str; /* string to lower case */
|
||||
|
||||
{
|
||||
@ -788,26 +915,25 @@ char *str; /* string to lower case */
|
||||
*sp += 'a' - 'A';
|
||||
++sp;
|
||||
}
|
||||
return(str);
|
||||
return (str);
|
||||
}
|
||||
|
||||
int abs(x) /* take the absolute value of an integer */
|
||||
|
||||
int abs(x)
|
||||
/* take the absolute value of an integer */
|
||||
int x;
|
||||
|
||||
{
|
||||
return(x < 0 ? -x : x);
|
||||
return (x < 0 ? -x : x);
|
||||
}
|
||||
|
||||
int ernd() /* returns a random integer */
|
||||
|
||||
{
|
||||
int ernd()
|
||||
{ /* returns a random integer */
|
||||
seed = abs(seed * 1721 + 10007);
|
||||
return(seed);
|
||||
return (seed);
|
||||
}
|
||||
|
||||
int sindex(source, pattern) /* find pattern within source */
|
||||
|
||||
int sindex(source, pattern)
|
||||
/* find pattern within source */
|
||||
char *source; /* source string to search */
|
||||
char *pattern; /* string to look for */
|
||||
|
||||
@ -831,12 +957,12 @@ char *pattern; /* string to look for */
|
||||
|
||||
/* was it a match? */
|
||||
if (*cp == 0)
|
||||
return((int)(sp - source) + 1);
|
||||
return ((int) (sp - source) + 1);
|
||||
++sp;
|
||||
}
|
||||
|
||||
/* no match at all.. */
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Filter a string through a translation table */
|
||||
@ -870,10 +996,10 @@ char *trans; /* resulting translated characters */
|
||||
/* no match, copy in the source char untranslated */
|
||||
*rp++ = *sp;
|
||||
|
||||
xnext: ++sp;
|
||||
xnext:++sp;
|
||||
}
|
||||
|
||||
/* terminate and return the result */
|
||||
*rp = 0;
|
||||
return(result);
|
||||
return (result);
|
||||
}
|
||||
|
262
exec.c
262
exec.c
@ -18,8 +18,8 @@ namedcmd(f, n)
|
||||
int f, n; /* command arguments [passed through to command executed] */
|
||||
|
||||
{
|
||||
register int (*kfunc)(); /* ptr to the requexted function to bind to */
|
||||
int (*getname())();
|
||||
register int (*kfunc) (); /* ptr to the requexted function to bind to */
|
||||
int (*getname()) ();
|
||||
|
||||
/* prompt the user to type a named command */
|
||||
mlwrite(": ");
|
||||
@ -28,11 +28,11 @@ int f, n; /* command arguments [passed through to command executed] */
|
||||
kfunc = getname();
|
||||
if (kfunc == NULL) {
|
||||
mlwrite("(No such function)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* and then execute the command */
|
||||
return((*kfunc)(f, n));
|
||||
return ((*kfunc) (f, n));
|
||||
}
|
||||
|
||||
/* execcmd: Execute a command line command to be typed in
|
||||
@ -48,10 +48,10 @@ int f, n; /* default Flag and Numeric argument */
|
||||
|
||||
/* get the line wanted */
|
||||
if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
execlevel = 0;
|
||||
return(docmd(cmdstr));
|
||||
return (docmd(cmdstr));
|
||||
}
|
||||
|
||||
/* docmd: take a passed string as a command line and translate
|
||||
@ -72,16 +72,16 @@ char *cline; /* command line to execute */
|
||||
{
|
||||
register int f; /* default argument flag */
|
||||
register int n; /* numeric repeat value */
|
||||
int (*fnc)(); /* function to execute */
|
||||
int (*fnc) (); /* function to execute */
|
||||
int status; /* return status of function */
|
||||
int oldcle; /* old contents of clexec flag */
|
||||
char *oldestr; /* original exec string */
|
||||
char tkn[NSTRING]; /* next token off of command line */
|
||||
int (*fncmatch())();
|
||||
int (*fncmatch()) ();
|
||||
|
||||
/* if we are scanning and not executing..go back here */
|
||||
if (execlevel)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
oldestr = execstr; /* save last ptr to string to execute */
|
||||
execstr = cline; /* and set this one as current */
|
||||
@ -94,7 +94,7 @@ char *cline; /* command line to execute */
|
||||
|
||||
if ((status = macarg(tkn)) != TRUE) { /* and grab the first token */
|
||||
execstr = oldestr;
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* process leadin argument */
|
||||
@ -106,7 +106,7 @@ char *cline; /* command line to execute */
|
||||
/* and now get the command to execute */
|
||||
if ((status = macarg(tkn)) != TRUE) {
|
||||
execstr = oldestr;
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,17 +114,17 @@ char *cline; /* command line to execute */
|
||||
if ((fnc = fncmatch(tkn)) == NULL) {
|
||||
mlwrite("(No such Function)");
|
||||
execstr = oldestr;
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* save the arguments and go execute the command */
|
||||
oldcle = clexec; /* save old clexec flag */
|
||||
clexec = TRUE; /* in cline execution */
|
||||
status = (*fnc)(f, n); /* call the function */
|
||||
status = (*fnc) (f, n); /* call the function */
|
||||
cmdstatus = status; /* save the status */
|
||||
clexec = oldcle; /* restore clexec flag */
|
||||
execstr = oldestr;
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* token: chop a token off a string
|
||||
@ -153,12 +153,23 @@ int size; /* maximum size of token */
|
||||
if (*src == 0)
|
||||
break;
|
||||
switch (*src++) {
|
||||
case 'r': c = 13; break;
|
||||
case 'n': c = 10; break;
|
||||
case 't': c = 9; break;
|
||||
case 'b': c = 8; break;
|
||||
case 'f': c = 12; break;
|
||||
default: c = *(src-1);
|
||||
case 'r':
|
||||
c = 13;
|
||||
break;
|
||||
case 'n':
|
||||
c = 10;
|
||||
break;
|
||||
case 't':
|
||||
c = 9;
|
||||
break;
|
||||
case 'b':
|
||||
c = 8;
|
||||
break;
|
||||
case 'f':
|
||||
c = 12;
|
||||
break;
|
||||
default:
|
||||
c = *(src - 1);
|
||||
}
|
||||
if (--size > 0) {
|
||||
*tok++ = c;
|
||||
@ -188,11 +199,11 @@ int size; /* maximum size of token */
|
||||
if (*src)
|
||||
++src;
|
||||
*tok = 0;
|
||||
return(src);
|
||||
return (src);
|
||||
}
|
||||
|
||||
macarg(tok) /* get a macro line argument */
|
||||
|
||||
macarg(tok)
|
||||
/* get a macro line argument */
|
||||
char *tok; /* buffer to place argument */
|
||||
|
||||
{
|
||||
@ -203,7 +214,7 @@ char *tok; /* buffer to place argument */
|
||||
clexec = TRUE; /* get the argument */
|
||||
status = nextarg("", tok, NSTRING, ctoec('\n'));
|
||||
clexec = savcle; /* restore execution mode */
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* nextarg: get the next argument */
|
||||
@ -218,14 +229,14 @@ int terminator; /* terminating char to be used on interactive fetch */
|
||||
{
|
||||
/* if we are interactive, go get it! */
|
||||
if (clexec == FALSE)
|
||||
return(getstring(prompt, buffer, size, terminator));
|
||||
return (getstring(prompt, buffer, size, terminator));
|
||||
|
||||
/* grab token and advance past */
|
||||
execstr = token(execstr, buffer, size);
|
||||
|
||||
/* evaluate it */
|
||||
strcpy(buffer, getval(buffer));
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* storemac: Set up a macro buffer and flag to store all
|
||||
@ -243,13 +254,13 @@ int n; /* macro number to use */
|
||||
/* must have a numeric argument to this function */
|
||||
if (f == FALSE) {
|
||||
mlwrite("No macro specified");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* range check the macro number */
|
||||
if (n < 1 || n > 40) {
|
||||
mlwrite("Macro number out of range");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* construct the macro buffer name */
|
||||
@ -260,7 +271,7 @@ int n; /* macro number to use */
|
||||
/* set up the new macro buffer */
|
||||
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
||||
mlwrite("Can not create macro");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* and make sure it is empty */
|
||||
@ -269,7 +280,7 @@ int n; /* macro number to use */
|
||||
/* and set the macro store pointers to it */
|
||||
mstore = TRUE;
|
||||
bstore = bp;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if PROC
|
||||
@ -288,11 +299,12 @@ int n; /* macro number to use */
|
||||
|
||||
/* a numeric argument means its a numbered macro */
|
||||
if (f == TRUE)
|
||||
return(storemac(f, n));
|
||||
return (storemac(f, n));
|
||||
|
||||
/* get the name of the procedure */
|
||||
if ((status = mlreply("Procedure name: ", &bname[1], NBUFN-2)) != TRUE)
|
||||
return(status);
|
||||
if ((status =
|
||||
mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE)
|
||||
return (status);
|
||||
|
||||
/* construct the macro buffer name */
|
||||
bname[0] = '*';
|
||||
@ -301,7 +313,7 @@ int n; /* macro number to use */
|
||||
/* set up the new macro buffer */
|
||||
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
||||
mlwrite("Can not create macro");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* and make sure it is empty */
|
||||
@ -310,7 +322,7 @@ int n; /* macro number to use */
|
||||
/* and set the macro store pointers to it */
|
||||
mstore = TRUE;
|
||||
bstore = bp;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* execproc: Execute a procedure */
|
||||
@ -322,27 +334,28 @@ int f, n; /* default flag and numeric arg */
|
||||
{
|
||||
register BUFFER *bp; /* ptr to buffer to execute */
|
||||
register int status; /* status return */
|
||||
char bufn[NBUFN+2]; /* name of buffer to execute */
|
||||
char bufn[NBUFN + 2]; /* name of buffer to execute */
|
||||
|
||||
/* find out what buffer the user wants to execute */
|
||||
if ((status = mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
|
||||
return(status);
|
||||
if ((status =
|
||||
mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
|
||||
return (status);
|
||||
|
||||
/* construct the buffer name */
|
||||
bufn[0] = '*';
|
||||
strcat(bufn, "*");
|
||||
|
||||
/* find the pointer to that buffer */
|
||||
if ((bp=bfind(bufn, FALSE, 0)) == NULL) {
|
||||
if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
|
||||
mlwrite("No such procedure");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* and now execute it as asked */
|
||||
while (n-- > 0)
|
||||
if ((status = dobuf(bp)) != TRUE)
|
||||
return(status);
|
||||
return(TRUE);
|
||||
return (status);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -359,19 +372,19 @@ int f, n; /* default flag and numeric arg */
|
||||
|
||||
/* find out what buffer the user wants to execute */
|
||||
if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
/* find the pointer to that buffer */
|
||||
if ((bp=bfind(bufn, FALSE, 0)) == NULL) {
|
||||
if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
|
||||
mlwrite("No such buffer");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* and now execute it as asked */
|
||||
while (n-- > 0)
|
||||
if ((status = dobuf(bp)) != TRUE)
|
||||
return(status);
|
||||
return(TRUE);
|
||||
return (status);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* dobuf: execute the contents of the buffer pointed to
|
||||
@ -445,12 +458,14 @@ BUFFER *bp; /* buffer to execute */
|
||||
|
||||
/* if is a while directive, make a block... */
|
||||
if (eline[0] == '!' && eline[1] == 'w' && eline[2] == 'h') {
|
||||
whtemp = (WHBLOCK *)malloc(sizeof(WHBLOCK));
|
||||
whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK));
|
||||
if (whtemp == NULL) {
|
||||
noram: mlwrite("%%Out of memory during while scan");
|
||||
failexit: freewhile(scanner);
|
||||
noram:mlwrite
|
||||
("%%Out of memory during while scan");
|
||||
failexit:freewhile
|
||||
(scanner);
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
whtemp->w_begin = lp;
|
||||
whtemp->w_type = BTWHILE;
|
||||
@ -461,10 +476,11 @@ failexit: freewhile(scanner);
|
||||
/* if is a BREAK directive, make a block... */
|
||||
if (eline[0] == '!' && eline[1] == 'b' && eline[2] == 'r') {
|
||||
if (scanner == NULL) {
|
||||
mlwrite("%%!BREAK outside of any !WHILE loop");
|
||||
mlwrite
|
||||
("%%!BREAK outside of any !WHILE loop");
|
||||
goto failexit;
|
||||
}
|
||||
whtemp = (WHBLOCK *)malloc(sizeof(WHBLOCK));
|
||||
whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK));
|
||||
if (whtemp == NULL)
|
||||
goto noram;
|
||||
whtemp->w_begin = lp;
|
||||
@ -476,7 +492,8 @@ failexit: freewhile(scanner);
|
||||
/* if it is an endwhile directive, record the spot... */
|
||||
if (eline[0] == '!' && strncmp(&eline[1], "endw", 4) == 0) {
|
||||
if (scanner == NULL) {
|
||||
mlwrite("%%!ENDWHILE with no preceding !WHILE in '%s'",
|
||||
mlwrite
|
||||
("%%!ENDWHILE with no preceding !WHILE in '%s'",
|
||||
bp->b_bname);
|
||||
goto failexit;
|
||||
}
|
||||
@ -492,7 +509,7 @@ failexit: freewhile(scanner);
|
||||
} while (whlist->w_type == BTBREAK);
|
||||
}
|
||||
|
||||
nxtscan: /* on to the next line */
|
||||
nxtscan: /* on to the next line */
|
||||
lp = lp->l_fp;
|
||||
}
|
||||
|
||||
@ -503,7 +520,7 @@ nxtscan: /* on to the next line */
|
||||
goto failexit;
|
||||
}
|
||||
|
||||
/* let the first command inherit the flags from the last one..*/
|
||||
/* let the first command inherit the flags from the last one.. */
|
||||
thisflag = lastflag;
|
||||
|
||||
/* starting at the beginning of the buffer */
|
||||
@ -512,10 +529,10 @@ nxtscan: /* on to the next line */
|
||||
while (lp != hlp) {
|
||||
/* allocate eline and copy macro line to it */
|
||||
linlen = lp->l_used;
|
||||
if ((einit = eline = malloc(linlen+1)) == NULL) {
|
||||
if ((einit = eline = malloc(linlen + 1)) == NULL) {
|
||||
mlwrite("%%Out of Memory during macro execution");
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
strncpy(eline, lp->l_text, linlen);
|
||||
eline[linlen] = 0; /* make sure it ends */
|
||||
@ -554,12 +571,11 @@ nxtscan: /* on to the next line */
|
||||
if (*sp++ == '%') {
|
||||
/* advance to the end */
|
||||
ep = --sp;
|
||||
while (*ep++)
|
||||
;
|
||||
while (*ep++);
|
||||
/* null terminate the string one out */
|
||||
*(ep + 1) = 0;
|
||||
/* copy backwards */
|
||||
while(ep-- > sp)
|
||||
while (ep-- > sp)
|
||||
*(ep + 1) = *ep;
|
||||
|
||||
/* and advance sp past the new % */
|
||||
@ -574,7 +590,7 @@ nxtscan: /* on to the next line */
|
||||
if ((c = get1key()) == abortc) {
|
||||
mlforce("(Macro aborted)");
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (c == metac)
|
||||
@ -596,7 +612,7 @@ nxtscan: /* on to the next line */
|
||||
if (dirnum == NUMDIRS) {
|
||||
mlwrite("%%Unknown Directive");
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* service only the !ENDM macro here */
|
||||
@ -606,7 +622,7 @@ nxtscan: /* on to the next line */
|
||||
goto onward;
|
||||
}
|
||||
|
||||
/* restore the original eline....*/
|
||||
/* restore the original eline.... */
|
||||
--eline;
|
||||
}
|
||||
|
||||
@ -614,13 +630,14 @@ nxtscan: /* on to the next line */
|
||||
if (mstore) {
|
||||
/* allocate the space for the line */
|
||||
linlen = strlen(eline);
|
||||
if ((mp=lalloc(linlen)) == NULL) {
|
||||
mlwrite("Out of memory while storing macro");
|
||||
if ((mp = lalloc(linlen)) == NULL) {
|
||||
mlwrite
|
||||
("Out of memory while storing macro");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* copy the text into the new line */
|
||||
for (i=0; i<linlen; ++i)
|
||||
for (i = 0; i < linlen; ++i)
|
||||
lputc(mp, i, eline[i]);
|
||||
|
||||
/* attach the line to the end of the buffer */
|
||||
@ -681,9 +698,10 @@ nxtscan: /* on to the next line */
|
||||
}
|
||||
|
||||
if (whtemp == NULL) {
|
||||
mlwrite("%%Internal While loop error");
|
||||
mlwrite
|
||||
("%%Internal While loop error");
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* reset the line pointer back.. */
|
||||
@ -693,7 +711,7 @@ nxtscan: /* on to the next line */
|
||||
case DELSE: /* ELSE directive */
|
||||
if (execlevel == 1)
|
||||
--execlevel;
|
||||
else if (execlevel == 0 )
|
||||
else if (execlevel == 0)
|
||||
++execlevel;
|
||||
goto onward;
|
||||
|
||||
@ -707,12 +725,15 @@ nxtscan: /* on to the next line */
|
||||
if (execlevel == 0) {
|
||||
|
||||
/* grab label to jump to */
|
||||
eline = token(eline, golabel, NPAT);
|
||||
eline =
|
||||
token(eline, golabel, NPAT);
|
||||
linlen = strlen(golabel);
|
||||
glp = hlp->l_fp;
|
||||
while (glp != hlp) {
|
||||
if (*glp->l_text == '*' &&
|
||||
(strncmp(&glp->l_text[1], golabel,
|
||||
(strncmp
|
||||
(&glp->l_text[1],
|
||||
golabel,
|
||||
linlen) == 0)) {
|
||||
lp = glp;
|
||||
goto onward;
|
||||
@ -721,7 +742,7 @@ nxtscan: /* on to the next line */
|
||||
}
|
||||
mlwrite("%%No such label");
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
goto onward;
|
||||
|
||||
@ -738,16 +759,18 @@ nxtscan: /* on to the next line */
|
||||
/* find the right while loop */
|
||||
whtemp = whlist;
|
||||
while (whtemp) {
|
||||
if (whtemp->w_type == BTWHILE &&
|
||||
whtemp->w_end == lp)
|
||||
if (whtemp->w_type ==
|
||||
BTWHILE
|
||||
&& whtemp->w_end == lp)
|
||||
break;
|
||||
whtemp = whtemp->w_next;
|
||||
}
|
||||
|
||||
if (whtemp == NULL) {
|
||||
mlwrite("%%Internal While loop error");
|
||||
mlwrite
|
||||
("%%Internal While loop error");
|
||||
freewhile(whlist);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* reset the line pointer back.. */
|
||||
@ -785,22 +808,22 @@ nxtscan: /* on to the next line */
|
||||
free(einit);
|
||||
execlevel = 0;
|
||||
freewhile(whlist);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
onward: /* on to the next line */
|
||||
onward: /* on to the next line */
|
||||
free(einit);
|
||||
lp = lp->l_fp;
|
||||
}
|
||||
|
||||
eexec: /* exit the current function */
|
||||
eexec: /* exit the current function */
|
||||
execlevel = 0;
|
||||
freewhile(whlist);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
freewhile(wp) /* free a list of while block pointers */
|
||||
|
||||
freewhile(wp)
|
||||
/* free a list of while block pointers */
|
||||
WHBLOCK *wp; /* head of structure to free */
|
||||
|
||||
{
|
||||
@ -811,8 +834,8 @@ WHBLOCK *wp; /* head of structure to free */
|
||||
free(wp);
|
||||
}
|
||||
|
||||
execfile(f, n) /* execute a series of commands in a file */
|
||||
|
||||
execfile(f, n)
|
||||
/* execute a series of commands in a file */
|
||||
int f, n; /* default flag and numeric arg to pass on to file */
|
||||
|
||||
{
|
||||
@ -820,8 +843,9 @@ int f, n; /* default flag and numeric arg to pass on to file */
|
||||
char fname[NSTRING]; /* name of file to execute */
|
||||
char *fspec; /* full file spec */
|
||||
|
||||
if ((status = mlreply("File to execute: ", fname, NSTRING -1)) != TRUE)
|
||||
return(status);
|
||||
if ((status =
|
||||
mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE)
|
||||
return (status);
|
||||
|
||||
#if 1
|
||||
/* look up the path for the file */
|
||||
@ -829,15 +853,15 @@ int f, n; /* default flag and numeric arg to pass on to file */
|
||||
|
||||
/* if it isn't around */
|
||||
if (fspec == NULL)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
#endif
|
||||
/* otherwise, execute it */
|
||||
while (n-- > 0)
|
||||
if ((status=dofile(fspec)) != TRUE)
|
||||
return(status);
|
||||
if ((status = dofile(fspec)) != TRUE)
|
||||
return (status);
|
||||
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* dofile: yank a file into a buffer and execute it
|
||||
@ -856,7 +880,7 @@ char *fname; /* file name to execute */
|
||||
makename(bname, fname); /* derive the name of the buffer */
|
||||
unqname(bname); /* make sure we don't stomp things */
|
||||
if ((bp = bfind(bname, TRUE, 0)) == NULL) /* get the needed buffer */
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
bp->b_mode = MDVIEW; /* mark the buffer as read only */
|
||||
cb = curbp; /* save the old buffer */
|
||||
@ -864,18 +888,18 @@ char *fname; /* file name to execute */
|
||||
/* and try to read in the file to execute */
|
||||
if ((status = readin(fname, FALSE)) != TRUE) {
|
||||
curbp = cb; /* restore the current buffer */
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* go execute it! */
|
||||
curbp = cb; /* restore the current buffer */
|
||||
if ((status = dobuf(bp)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
/* if not displayed, remove the now unneeded buffer and exit */
|
||||
if (bp->b_nwnd == 0)
|
||||
zotbuf(bp);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* cbuf: Execute the contents of a numbered buffer */
|
||||
@ -895,254 +919,214 @@ int bufnum; /* number of buffer to execute */
|
||||
bufname[8] = '0' + (bufnum % 10);
|
||||
|
||||
/* find the pointer to that buffer */
|
||||
if ((bp=bfind(bufname, FALSE, 0)) == NULL) {
|
||||
if ((bp = bfind(bufname, FALSE, 0)) == NULL) {
|
||||
mlwrite("Macro not defined");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* and now execute it as asked */
|
||||
while (n-- > 0)
|
||||
if ((status = dobuf(bp)) != TRUE)
|
||||
return(status);
|
||||
return(TRUE);
|
||||
return (status);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
cbuf1(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 1);
|
||||
}
|
||||
|
||||
cbuf2(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 2);
|
||||
}
|
||||
|
||||
cbuf3(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 3);
|
||||
}
|
||||
|
||||
cbuf4(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 4);
|
||||
}
|
||||
|
||||
cbuf5(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 5);
|
||||
}
|
||||
|
||||
cbuf6(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 6);
|
||||
}
|
||||
|
||||
cbuf7(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 7);
|
||||
}
|
||||
|
||||
cbuf8(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 8);
|
||||
}
|
||||
|
||||
cbuf9(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 9);
|
||||
}
|
||||
|
||||
cbuf10(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 10);
|
||||
}
|
||||
|
||||
cbuf11(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 11);
|
||||
}
|
||||
|
||||
cbuf12(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 12);
|
||||
}
|
||||
|
||||
cbuf13(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 13);
|
||||
}
|
||||
|
||||
cbuf14(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 14);
|
||||
}
|
||||
|
||||
cbuf15(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 15);
|
||||
}
|
||||
|
||||
cbuf16(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 16);
|
||||
}
|
||||
|
||||
cbuf17(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 17);
|
||||
}
|
||||
|
||||
cbuf18(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 18);
|
||||
}
|
||||
|
||||
cbuf19(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 19);
|
||||
}
|
||||
|
||||
cbuf20(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 20);
|
||||
}
|
||||
|
||||
cbuf21(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 21);
|
||||
}
|
||||
|
||||
cbuf22(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 22);
|
||||
}
|
||||
|
||||
cbuf23(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 23);
|
||||
}
|
||||
|
||||
cbuf24(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 24);
|
||||
}
|
||||
|
||||
cbuf25(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 25);
|
||||
}
|
||||
|
||||
cbuf26(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 26);
|
||||
}
|
||||
|
||||
cbuf27(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 27);
|
||||
}
|
||||
|
||||
cbuf28(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 28);
|
||||
}
|
||||
|
||||
cbuf29(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 29);
|
||||
}
|
||||
|
||||
cbuf30(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 30);
|
||||
}
|
||||
|
||||
cbuf31(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 31);
|
||||
}
|
||||
|
||||
cbuf32(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 32);
|
||||
}
|
||||
|
||||
cbuf33(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 33);
|
||||
}
|
||||
|
||||
cbuf34(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 34);
|
||||
}
|
||||
|
||||
cbuf35(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 35);
|
||||
}
|
||||
|
||||
cbuf36(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 36);
|
||||
}
|
||||
|
||||
cbuf37(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 37);
|
||||
}
|
||||
|
||||
cbuf38(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 38);
|
||||
}
|
||||
|
||||
cbuf39(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 39);
|
||||
}
|
||||
|
||||
cbuf40(f, n)
|
||||
|
||||
{
|
||||
return cbuf(f, n, 40);
|
||||
}
|
||||
|
164
file.c
164
file.c
@ -24,10 +24,10 @@ fileread(f, n)
|
||||
char fname[NFILEN];
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return(resterr());
|
||||
if ((s=mlreply("Read file: ", fname, NFILEN)) != TRUE)
|
||||
return(s);
|
||||
return(readin(fname, TRUE));
|
||||
return (resterr());
|
||||
if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE)
|
||||
return (s);
|
||||
return (readin(fname, TRUE));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -43,14 +43,14 @@ insfile(f, n)
|
||||
char fname[NFILEN];
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return(resterr());
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if ((s=mlreply("Insert file: ", fname, NFILEN)) != TRUE)
|
||||
return(s);
|
||||
if ((s=ifile(fname)) != TRUE)
|
||||
return(s);
|
||||
return(reposition(TRUE, -1));
|
||||
return (resterr());
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE)
|
||||
return (s);
|
||||
if ((s = ifile(fname)) != TRUE)
|
||||
return (s);
|
||||
return (reposition(TRUE, -1));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -68,21 +68,21 @@ filefind(f, n)
|
||||
register int s; /* status return */
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return(resterr());
|
||||
if ((s=mlreply("Find file: ", fname, NFILEN)) != TRUE)
|
||||
return(s);
|
||||
return(getfile(fname, TRUE));
|
||||
return (resterr());
|
||||
if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE)
|
||||
return (s);
|
||||
return (getfile(fname, TRUE));
|
||||
}
|
||||
|
||||
viewfile(f, n) /* visit a file in VIEW mode */
|
||||
{
|
||||
viewfile(f, n)
|
||||
{ /* visit a file in VIEW mode */
|
||||
char fname[NFILEN]; /* file user wishes to find */
|
||||
register int s; /* status return */
|
||||
register WINDOW *wp; /* scan for windows that need updating */
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return(resterr());
|
||||
if ((s=mlreply("View file: ", fname, NFILEN)) != TRUE)
|
||||
return (resterr());
|
||||
if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE)
|
||||
return (s);
|
||||
s = getfile(fname, FALSE);
|
||||
if (s) { /* if we succeed, put it in view mode */
|
||||
@ -95,13 +95,12 @@ viewfile(f, n) /* visit a file in VIEW mode */
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
}
|
||||
return(s);
|
||||
return (s);
|
||||
}
|
||||
|
||||
#if CRYPT
|
||||
resetkey() /* reset the encryption key if needed */
|
||||
|
||||
{
|
||||
resetkey()
|
||||
{ /* reset the encryption key if needed */
|
||||
register int s; /* return status */
|
||||
|
||||
/* turn off the encryption flag */
|
||||
@ -112,7 +111,7 @@ resetkey() /* reset the encryption key if needed */
|
||||
if (curbp->b_key[0] == 0) {
|
||||
s = setkey(FALSE, 0);
|
||||
if (s != TRUE)
|
||||
return(s);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/* let others know... */
|
||||
@ -120,15 +119,15 @@ resetkey() /* reset the encryption key if needed */
|
||||
|
||||
/* and set up the key to be used! */
|
||||
/* de-encrypt it */
|
||||
crypt((char *)NULL, 0);
|
||||
crypt((char *) NULL, 0);
|
||||
crypt(curbp->b_key, strlen(curbp->b_key));
|
||||
|
||||
/* re-encrypt it...seeding it to start */
|
||||
crypt((char *)NULL, 0);
|
||||
crypt((char *) NULL, 0);
|
||||
crypt(curbp->b_key, strlen(curbp->b_key));
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -147,22 +146,23 @@ int lockfl; /* check the file for locks? */
|
||||
#if MSDOS
|
||||
mklower(fname); /* msdos isn't case sensitive */
|
||||
#endif
|
||||
for (bp=bheadp; bp!=NULL; bp=bp->b_bufp) {
|
||||
if ((bp->b_flag&BFINVS)==0 && strcmp(bp->b_fname, fname)==0) {
|
||||
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
|
||||
if ((bp->b_flag & BFINVS) == 0
|
||||
&& strcmp(bp->b_fname, fname) == 0) {
|
||||
swbuffer(bp);
|
||||
lp = curwp->w_dotp;
|
||||
i = curwp->w_ntrows/2;
|
||||
while (i-- && lback(lp)!=curbp->b_linep)
|
||||
i = curwp->w_ntrows / 2;
|
||||
while (i-- && lback(lp) != curbp->b_linep)
|
||||
lp = lback(lp);
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_flag |= WFMODE|WFHARD;
|
||||
curwp->w_flag |= WFMODE | WFHARD;
|
||||
cknewwindow();
|
||||
mlwrite("(Old buffer)");
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
makename(bname, fname); /* New buffer name. */
|
||||
while ((bp=bfind(bname, FALSE, 0)) != NULL) {
|
||||
while ((bp = bfind(bname, FALSE, 0)) != NULL) {
|
||||
/* old buffer name conflict code */
|
||||
s = mlreply("Buffer name: ", bname, NBUFN);
|
||||
if (s == ABORT) /* ^G to just quit */
|
||||
@ -172,7 +172,7 @@ int lockfl; /* check the file for locks? */
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bp==NULL && (bp=bfind(bname, TRUE, 0))==NULL) {
|
||||
if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) {
|
||||
mlwrite("Cannot create buffer");
|
||||
return (FALSE);
|
||||
}
|
||||
@ -226,27 +226,27 @@ int lockfl; /* check for file locks? */
|
||||
goto out;
|
||||
}
|
||||
#else
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
#endif
|
||||
#endif
|
||||
#if CRYPT
|
||||
s = resetkey();
|
||||
if (s != TRUE)
|
||||
return(s);
|
||||
return (s);
|
||||
#endif
|
||||
bp = curbp; /* Cheap. */
|
||||
if ((s=bclear(bp)) != TRUE) /* Might be old. */
|
||||
if ((s = bclear(bp)) != TRUE) /* Might be old. */
|
||||
return (s);
|
||||
bp->b_flag &= ~(BFINVS|BFCHG);
|
||||
bp->b_flag &= ~(BFINVS | BFCHG);
|
||||
strcpy(bp->b_fname, fname);
|
||||
|
||||
/* let a user macro get hold of things...if he wants */
|
||||
execute(META|SPEC|'R', FALSE, 1);
|
||||
execute(META | SPEC | 'R', FALSE, 1);
|
||||
|
||||
/* turn off ALL keyboard translation in case we get a dos error */
|
||||
TTkclose();
|
||||
|
||||
if ((s=ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||
if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||
goto out;
|
||||
|
||||
if (s == FIOFNF) { /* File not found. */
|
||||
@ -258,9 +258,9 @@ int lockfl; /* check for file locks? */
|
||||
mlwrite("(Reading file)");
|
||||
nline = 0;
|
||||
lflag = FALSE;
|
||||
while ((s=ffgetline()) == FIOSUC) {
|
||||
while ((s = ffgetline()) == FIOSUC) {
|
||||
nbytes = strlen(fline);
|
||||
if ((lp1=lalloc(nbytes)) == NULL) {
|
||||
if ((lp1 = lalloc(nbytes)) == NULL) {
|
||||
s = FIOMEM; /* Keep message on the */
|
||||
break; /* display. */
|
||||
}
|
||||
@ -275,13 +275,13 @@ int lockfl; /* check for file locks? */
|
||||
lp1->l_fp = curbp->b_linep;
|
||||
lp1->l_bp = lp2;
|
||||
curbp->b_linep->l_bp = lp1;
|
||||
for (i=0; i<nbytes; ++i)
|
||||
for (i = 0; i < nbytes; ++i)
|
||||
lputc(lp1, i, fline[i]);
|
||||
++nline;
|
||||
}
|
||||
ffclose(); /* Ignore errors. */
|
||||
strcpy(mesg, "(");
|
||||
if (s==FIOERR) {
|
||||
if (s == FIOERR) {
|
||||
strcat(mesg, "I/O ERROR, ");
|
||||
curbp->b_flag |= BFTRUNC;
|
||||
}
|
||||
@ -295,23 +295,23 @@ int lockfl; /* check for file locks? */
|
||||
strcat(mesg, ")");
|
||||
mlwrite(mesg);
|
||||
|
||||
out:
|
||||
out:
|
||||
TTkopen(); /* open the keyboard again */
|
||||
for (wp=wheadp; wp!=NULL; wp=wp->w_wndp) {
|
||||
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
|
||||
if (wp->w_bufp == curbp) {
|
||||
wp->w_linep = lforw(curbp->b_linep);
|
||||
wp->w_dotp = lforw(curbp->b_linep);
|
||||
wp->w_doto = 0;
|
||||
wp->w_markp = NULL;
|
||||
wp->w_marko = 0;
|
||||
wp->w_flag |= WFMODE|WFHARD;
|
||||
wp->w_flag |= WFMODE | WFHARD;
|
||||
}
|
||||
}
|
||||
if (s == FIOERR || s == FIOFNF) /* False if error. */
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
#if 0
|
||||
if (s == ABORT)
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
#endif
|
||||
return (TRUE);
|
||||
}
|
||||
@ -336,28 +336,30 @@ char fname[];
|
||||
|
||||
#if VMS
|
||||
#if PKCODE
|
||||
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!=']' && cp1[-1]!='>')
|
||||
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']'
|
||||
&& cp1[-1] != '>')
|
||||
#else
|
||||
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!=']')
|
||||
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']')
|
||||
#endif
|
||||
--cp1;
|
||||
#endif
|
||||
#if MSDOS
|
||||
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!='\\'&&cp1[-1]!='/')
|
||||
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != '\\'
|
||||
&& cp1[-1] != '/')
|
||||
--cp1;
|
||||
#endif
|
||||
#if V7 | USG | BSD
|
||||
while (cp1!=&fname[0] && cp1[-1]!='/')
|
||||
while (cp1 != &fname[0] && cp1[-1] != '/')
|
||||
--cp1;
|
||||
#endif
|
||||
cp2 = &bname[0];
|
||||
while (cp2!=&bname[NBUFN-1] && *cp1!=0 && *cp1!=';')
|
||||
while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != ';')
|
||||
*cp2++ = *cp1++;
|
||||
*cp2 = 0;
|
||||
}
|
||||
|
||||
unqname(name) /* make sure a buffer name is unique */
|
||||
|
||||
unqname(name)
|
||||
/* make sure a buffer name is unique */
|
||||
char *name; /* name to check on */
|
||||
|
||||
{
|
||||
@ -370,7 +372,7 @@ char *name; /* name to check on */
|
||||
sp = name;
|
||||
while (*sp)
|
||||
++sp;
|
||||
if (sp == name || (*(sp-1) <'0' || *(sp-1) > '8')) {
|
||||
if (sp == name || (*(sp - 1) < '0' || *(sp - 1) > '8')) {
|
||||
*sp++ = '0';
|
||||
*sp = 0;
|
||||
} else
|
||||
@ -394,10 +396,10 @@ filewrite(f, n)
|
||||
char fname[NFILEN];
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return(resterr());
|
||||
if ((s=mlreply("Write file: ", fname, NFILEN)) != TRUE)
|
||||
return (resterr());
|
||||
if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE)
|
||||
return (s);
|
||||
if ((s=writeout(fname)) == TRUE) {
|
||||
if ((s = writeout(fname)) == TRUE) {
|
||||
strcpy(curbp->b_fname, fname);
|
||||
curbp->b_flag &= ~BFCHG;
|
||||
wp = wheadp; /* Update mode lines. */
|
||||
@ -423,9 +425,9 @@ filesave(f, n)
|
||||
register WINDOW *wp;
|
||||
register int s;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if ((curbp->b_flag&BFCHG) == 0) /* Return, no changes. */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */
|
||||
return (TRUE);
|
||||
if (curbp->b_fname[0] == 0) { /* Must have a name. */
|
||||
mlwrite("No file name");
|
||||
@ -433,14 +435,14 @@ filesave(f, n)
|
||||
}
|
||||
|
||||
/* complain about truncated files */
|
||||
if ((curbp->b_flag&BFTRUNC) != 0) {
|
||||
if ((curbp->b_flag & BFTRUNC) != 0) {
|
||||
if (mlyesno("Truncated file ... write it out") == FALSE) {
|
||||
mlwrite("(Aborted)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if ((s=writeout(curbp->b_fname)) == TRUE) {
|
||||
if ((s = writeout(curbp->b_fname)) == TRUE) {
|
||||
curbp->b_flag &= ~BFCHG;
|
||||
wp = wheadp; /* Update mode lines. */
|
||||
while (wp != NULL) {
|
||||
@ -470,12 +472,12 @@ char *fn;
|
||||
#if CRYPT
|
||||
s = resetkey();
|
||||
if (s != TRUE)
|
||||
return(s);
|
||||
return (s);
|
||||
#endif
|
||||
/* turn off ALL keyboard translation in case we get a dos error */
|
||||
TTkclose();
|
||||
|
||||
if ((s=ffwopen(fn)) != FIOSUC) { /* Open writes message. */
|
||||
if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */
|
||||
TTkopen();
|
||||
return (FALSE);
|
||||
}
|
||||
@ -483,7 +485,7 @@ char *fn;
|
||||
lp = lforw(curbp->b_linep); /* First line. */
|
||||
nline = 0; /* Number of lines. */
|
||||
while (lp != curbp->b_linep) {
|
||||
if ((s=ffputline(&lp->l_text[0], llength(lp))) != FIOSUC)
|
||||
if ((s = ffputline(&lp->l_text[0], llength(lp))) != FIOSUC)
|
||||
break;
|
||||
++nline;
|
||||
lp = lforw(lp);
|
||||
@ -520,8 +522,8 @@ filename(f, n)
|
||||
char fname[NFILEN];
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return(resterr());
|
||||
if ((s=mlreply("Name: ", fname, NFILEN)) == ABORT)
|
||||
return (resterr());
|
||||
if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT)
|
||||
return (s);
|
||||
if (s == FALSE)
|
||||
strcpy(curbp->b_fname, "");
|
||||
@ -558,19 +560,19 @@ char fname[];
|
||||
|
||||
bp = curbp; /* Cheap. */
|
||||
bp->b_flag |= BFCHG; /* we have changed */
|
||||
bp->b_flag &= ~BFINVS; /* and are not temporary*/
|
||||
if ((s=ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||
bp->b_flag &= ~BFINVS; /* and are not temporary */
|
||||
if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||
goto out;
|
||||
if (s == FIOFNF) { /* File not found. */
|
||||
mlwrite("(No such file)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
mlwrite("(Inserting file)");
|
||||
|
||||
#if CRYPT
|
||||
s = resetkey();
|
||||
if (s != TRUE)
|
||||
return(s);
|
||||
return (s);
|
||||
#endif
|
||||
/* back up a line and save the mark here */
|
||||
curwp->w_dotp = lback(curwp->w_dotp);
|
||||
@ -580,9 +582,9 @@ char fname[];
|
||||
|
||||
nline = 0;
|
||||
lflag = FALSE;
|
||||
while ((s=ffgetline()) == FIOSUC) {
|
||||
while ((s = ffgetline()) == FIOSUC) {
|
||||
nbytes = strlen(fline);
|
||||
if ((lp1=lalloc(nbytes)) == NULL) {
|
||||
if ((lp1 = lalloc(nbytes)) == NULL) {
|
||||
s = FIOMEM; /* Keep message on the */
|
||||
break; /* display. */
|
||||
}
|
||||
@ -597,14 +599,14 @@ char fname[];
|
||||
|
||||
/* and advance and write out the current line */
|
||||
curwp->w_dotp = lp1;
|
||||
for (i=0; i<nbytes; ++i)
|
||||
for (i = 0; i < nbytes; ++i)
|
||||
lputc(lp1, i, fline[i]);
|
||||
++nline;
|
||||
}
|
||||
ffclose(); /* Ignore errors. */
|
||||
curwp->w_markp = lforw(curwp->w_markp);
|
||||
strcpy(mesg, "(");
|
||||
if (s==FIOERR) {
|
||||
if (s == FIOERR) {
|
||||
strcat(mesg, "I/O ERROR, ");
|
||||
curbp->b_flag |= BFTRUNC;
|
||||
}
|
||||
@ -618,7 +620,7 @@ char fname[];
|
||||
strcat(mesg, ")");
|
||||
mlwrite(mesg);
|
||||
|
||||
out:
|
||||
out:
|
||||
/* advance to the next line and mark the window for changes */
|
||||
curwp->w_dotp = lforw(curwp->w_dotp);
|
||||
curwp->w_flag |= WFHARD | WFMODE;
|
||||
|
50
fileio.c
50
fileio.c
@ -23,7 +23,7 @@ int eofflag; /* end-of-file flag */
|
||||
ffropen(fn)
|
||||
char *fn;
|
||||
{
|
||||
if ((ffp=fopen(fn, "r")) == NULL)
|
||||
if ((ffp = fopen(fn, "r")) == NULL)
|
||||
return (FIOFNF);
|
||||
eofflag = FALSE;
|
||||
return (FIOSUC);
|
||||
@ -39,10 +39,10 @@ char *fn;
|
||||
#if VMS
|
||||
register int fd;
|
||||
|
||||
if ((fd=creat(fn, 0666, "rfm=var", "rat=cr")) < 0
|
||||
|| (ffp=fdopen(fd, "w")) == NULL) {
|
||||
if ((fd = creat(fn, 0666, "rfm=var", "rat=cr")) < 0
|
||||
|| (ffp = fdopen(fd, "w")) == NULL) {
|
||||
#else
|
||||
if ((ffp=fopen(fn, "w")) == NULL) {
|
||||
if ((ffp = fopen(fn, "w")) == NULL) {
|
||||
#endif
|
||||
mlwrite("Cannot open file for writing");
|
||||
return (FIOERR);
|
||||
@ -69,9 +69,9 @@ ffclose()
|
||||
#if V7 | USG | BSD | (MSDOS & (MSC | TURBO))
|
||||
if (fclose(ffp) != FALSE) {
|
||||
mlwrite("Error closing file");
|
||||
return(FIOERR);
|
||||
return (FIOERR);
|
||||
}
|
||||
return(FIOSUC);
|
||||
return (FIOSUC);
|
||||
#else
|
||||
fclose(ffp);
|
||||
return (FIOSUC);
|
||||
@ -98,10 +98,10 @@ char buf[];
|
||||
}
|
||||
} else
|
||||
for (i = 0; i < nbuf; ++i)
|
||||
fputc(buf[i]&0xFF, ffp);
|
||||
fputc(buf[i] & 0xFF, ffp);
|
||||
#else
|
||||
for (i = 0; i < nbuf; ++i)
|
||||
fputc(buf[i]&0xFF, ffp);
|
||||
fputc(buf[i] & 0xFF, ffp);
|
||||
#endif
|
||||
|
||||
fputc('\n', ffp);
|
||||
@ -121,7 +121,6 @@ char buf[];
|
||||
* errors too. Return status.
|
||||
*/
|
||||
ffgetline()
|
||||
|
||||
{
|
||||
register int c; /* current character read */
|
||||
register int i; /* current index into fline */
|
||||
@ -129,7 +128,7 @@ ffgetline()
|
||||
|
||||
/* if we are at the end...return it */
|
||||
if (eofflag)
|
||||
return(FIOEOF);
|
||||
return (FIOEOF);
|
||||
|
||||
/* dump fline if it ended up too big */
|
||||
if (flen > NSTRING) {
|
||||
@ -140,25 +139,23 @@ ffgetline()
|
||||
/* if we don't have an fline, allocate one */
|
||||
if (fline == NULL)
|
||||
if ((fline = malloc(flen = NSTRING)) == NULL)
|
||||
return(FIOMEM);
|
||||
return (FIOMEM);
|
||||
|
||||
/* read the line in */
|
||||
#if PKCODE
|
||||
if (!nullflag) {
|
||||
if (fgets(fline, NSTRING, ffp) == (char *)NULL) { /* EOF ? */
|
||||
if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */
|
||||
i = 0;
|
||||
c = EOF;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = strlen(fline);
|
||||
c = 0;
|
||||
if (i > 0) {
|
||||
c = fline[i-1];
|
||||
c = fline[i - 1];
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
i = 0;
|
||||
c = fgetc(ffp);
|
||||
}
|
||||
@ -173,8 +170,9 @@ ffgetline()
|
||||
fline[i++] = c;
|
||||
/* if it's longer, get more room */
|
||||
if (i >= flen) {
|
||||
if ((tmpline = malloc(flen+NSTRING)) == NULL)
|
||||
return(FIOMEM);
|
||||
if ((tmpline =
|
||||
malloc(flen + NSTRING)) == NULL)
|
||||
return (FIOMEM);
|
||||
strncpy(tmpline, fline, flen);
|
||||
flen += NSTRING;
|
||||
free(fline);
|
||||
@ -190,13 +188,13 @@ ffgetline()
|
||||
if (c == EOF) {
|
||||
if (ferror(ffp)) {
|
||||
mlwrite("File read error");
|
||||
return(FIOERR);
|
||||
return (FIOERR);
|
||||
}
|
||||
|
||||
if (i != 0)
|
||||
eofflag = TRUE;
|
||||
else
|
||||
return(FIOEOF);
|
||||
return (FIOEOF);
|
||||
}
|
||||
|
||||
/* terminate and decrypt the string */
|
||||
@ -205,11 +203,11 @@ ffgetline()
|
||||
if (cryptflag)
|
||||
crypt(fline, strlen(fline));
|
||||
#endif
|
||||
return(FIOSUC);
|
||||
return (FIOSUC);
|
||||
}
|
||||
|
||||
int fexist(fname) /* does <fname> exist on disk? */
|
||||
|
||||
int fexist(fname)
|
||||
/* does <fname> exist on disk? */
|
||||
char *fname; /* file to check for existance */
|
||||
|
||||
{
|
||||
@ -220,9 +218,9 @@ char *fname; /* file to check for existance */
|
||||
|
||||
/* if it fails, just return false! */
|
||||
if (fp == NULL)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* otherwise, close it and report true */
|
||||
fclose(fp);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
129
ibmpc.c
129
ibmpc.c
@ -54,7 +54,7 @@ int dtype = -1; /* current display type */
|
||||
char drvname[][8] = { /* screen resolution names */
|
||||
"CGA", "MONO", "EGA"
|
||||
#if PKCODE
|
||||
,"VGA"
|
||||
, "VGA"
|
||||
#endif
|
||||
};
|
||||
long scadd; /* address of screen ram */
|
||||
@ -89,9 +89,9 @@ int cfcolor = -1; /* current forground color */
|
||||
int cbcolor = -1; /* current background color */
|
||||
int ctrans[] = /* ansi to ibm color translation table */
|
||||
#if PKCODE
|
||||
{0, 4, 2, 6, 1, 5, 3, 7, 15};
|
||||
{ 0, 4, 2, 6, 1, 5, 3, 7, 15 };
|
||||
#else
|
||||
{0, 4, 2, 6, 1, 5, 3, 7};
|
||||
{ 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -100,8 +100,8 @@ int ctrans[] = /* ansi to ibm color translation table */
|
||||
* "termio" code.
|
||||
*/
|
||||
TERM term = {
|
||||
NROW-1,
|
||||
NROW-1,
|
||||
NROW - 1,
|
||||
NROW - 1,
|
||||
NCOL,
|
||||
NCOL,
|
||||
MARGIN,
|
||||
@ -130,16 +130,16 @@ TERM term = {
|
||||
};
|
||||
|
||||
#if COLOR
|
||||
ibmfcol(color) /* set the current output color */
|
||||
|
||||
ibmfcol(color)
|
||||
/* set the current output color */
|
||||
int color; /* color to set */
|
||||
|
||||
{
|
||||
cfcolor = ctrans[color];
|
||||
}
|
||||
|
||||
ibmbcol(color) /* set the current background color */
|
||||
|
||||
ibmbcol(color)
|
||||
/* set the current background color */
|
||||
int color; /* color to set */
|
||||
|
||||
{
|
||||
@ -156,9 +156,8 @@ ibmmove(row, col)
|
||||
int86(0x10, &rg, &rg);
|
||||
}
|
||||
|
||||
ibmeeol() /* erase to the end of the line */
|
||||
|
||||
{
|
||||
ibmeeol()
|
||||
{ /* erase to the end of the line */
|
||||
unsigned int attr; /* attribute byte mask to place in RAM */
|
||||
unsigned int *lnptr; /* pointer to the destination line */
|
||||
int i;
|
||||
@ -182,27 +181,25 @@ ibmeeol() /* erase to the end of the line */
|
||||
attr = 0x0700;
|
||||
#endif
|
||||
lnptr = &sline[0];
|
||||
for (i=0; i < term.t_ncol; i++)
|
||||
for (i = 0; i < term.t_ncol; i++)
|
||||
*lnptr++ = SPACE | attr;
|
||||
|
||||
if (flickcode && (dtype == CDCGA)) {
|
||||
/* wait for vertical retrace to be off */
|
||||
while ((inp(0x3da) & 8))
|
||||
;
|
||||
while ((inp(0x3da) & 8));
|
||||
|
||||
/* and to be back on */
|
||||
while ((inp(0x3da) & 8) == 0)
|
||||
;
|
||||
while ((inp(0x3da) & 8) == 0);
|
||||
}
|
||||
|
||||
/* and send the string out */
|
||||
movmem(&sline[0], scptr[crow]+ccol, (term.t_ncol-ccol)*2);
|
||||
movmem(&sline[0], scptr[crow] + ccol, (term.t_ncol - ccol) * 2);
|
||||
|
||||
}
|
||||
|
||||
ibmputc(ch) /* put a character at the current position in the
|
||||
ibmputc(ch)
|
||||
/* put a character at the current position in the
|
||||
current colors */
|
||||
|
||||
int ch;
|
||||
|
||||
{
|
||||
@ -230,7 +227,8 @@ ibmeeop()
|
||||
/* lower right corner of scroll */
|
||||
#if COLOR
|
||||
if (dtype != CDMONO)
|
||||
attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
|
||||
attr =
|
||||
((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
|
||||
else
|
||||
attr = 0;
|
||||
#else
|
||||
@ -240,16 +238,16 @@ ibmeeop()
|
||||
int86(0x10, &rg, &rg);
|
||||
}
|
||||
|
||||
ibmrev(state) /* change reverse video state */
|
||||
|
||||
ibmrev(state)
|
||||
/* change reverse video state */
|
||||
int state; /* TRUE = reverse, FALSE = normal */
|
||||
|
||||
{
|
||||
/* This never gets used under the IBM-PC driver */
|
||||
}
|
||||
|
||||
ibmcres(res) /* change screen resolution */
|
||||
|
||||
ibmcres(res)
|
||||
/* change screen resolution */
|
||||
char *res; /* resolution to change to */
|
||||
|
||||
{
|
||||
@ -258,9 +256,9 @@ char *res; /* resolution to change to */
|
||||
for (i = 0; i < NDRIVE; i++)
|
||||
if (strcmp(res, drvname[i]) == 0) {
|
||||
scinit(i);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
@ -272,19 +270,19 @@ ibmscroll_reg(from, to, howmany)
|
||||
|
||||
if (to < from)
|
||||
for (i = 0; i < howmany; i++)
|
||||
movmem(scptr[from+i], scptr[to+i], term.t_ncol*2);
|
||||
else
|
||||
if (to > from)
|
||||
for (i = howmany-1; i >= 0; i--)
|
||||
movmem(scptr[from+i], scptr[to+i], term.t_ncol*2);
|
||||
movmem(scptr[from + i], scptr[to + i],
|
||||
term.t_ncol * 2);
|
||||
else if (to > from)
|
||||
for (i = howmany - 1; i >= 0; i--)
|
||||
movmem(scptr[from + i], scptr[to + i],
|
||||
term.t_ncol * 2);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
spal() /* reset the pallette registers */
|
||||
|
||||
{
|
||||
spal()
|
||||
{ /* reset the pallette registers */
|
||||
/* nothin here now..... */
|
||||
}
|
||||
|
||||
@ -301,7 +299,6 @@ ibmopen()
|
||||
}
|
||||
|
||||
ibmclose()
|
||||
|
||||
{
|
||||
#if COLOR
|
||||
ibmfcol(7);
|
||||
@ -318,18 +315,16 @@ ibmclose()
|
||||
ttclose();
|
||||
}
|
||||
|
||||
ibmkopen() /* open the keyboard */
|
||||
|
||||
{
|
||||
ibmkopen()
|
||||
{ /* open the keyboard */
|
||||
}
|
||||
|
||||
ibmkclose() /* close the keyboard */
|
||||
|
||||
{
|
||||
ibmkclose()
|
||||
{ /* close the keyboard */
|
||||
}
|
||||
|
||||
scinit(type) /* initialize the screen head pointers */
|
||||
|
||||
scinit(type)
|
||||
/* initialize the screen head pointers */
|
||||
int type; /* type of adapter to init for */
|
||||
|
||||
{
|
||||
@ -345,11 +340,11 @@ int type; /* type of adapter to init for */
|
||||
|
||||
/* if we have nothing to do....don't do it */
|
||||
if (dtype == type)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* if we try to switch to EGA and there is none, don't */
|
||||
if (type == CDEGA && egaexist != TRUE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* if we had the EGA open... close it */
|
||||
if (dtype == CDEGA)
|
||||
@ -389,10 +384,10 @@ int type; /* type of adapter to init for */
|
||||
|
||||
/* initialize the screen pointer array */
|
||||
for (i = 0; i < NROW; i++) {
|
||||
addr.laddr = scadd + (long)(NCOL * i * 2);
|
||||
addr.laddr = scadd + (long) (NCOL * i * 2);
|
||||
scptr[i] = addr.paddr;
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* getboard: Determine which type of display board is attached.
|
||||
@ -410,7 +405,6 @@ int type; /* type of adapter to init for */
|
||||
*/
|
||||
|
||||
int getboard()
|
||||
|
||||
{
|
||||
int type; /* board type to return */
|
||||
|
||||
@ -422,14 +416,13 @@ int getboard()
|
||||
/* test if EGA present */
|
||||
rg.x.ax = 0x1200;
|
||||
rg.x.bx = 0xff10;
|
||||
int86(0x10,&rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */
|
||||
int86(0x10, &rg, &rg); /* If EGA, bh=0-1 and bl=0-3 */
|
||||
egaexist = !(rg.x.bx & 0xfefc); /* Yes, it's EGA */
|
||||
return(type);
|
||||
return (type);
|
||||
}
|
||||
|
||||
egaopen() /* init the computer to work with the EGA */
|
||||
|
||||
{
|
||||
egaopen()
|
||||
{ /* init the computer to work with the EGA */
|
||||
/* put the beast into EGA 43 row mode */
|
||||
rg.x.ax = 3;
|
||||
int86(16, &rg, &rg);
|
||||
@ -453,15 +446,14 @@ egaopen() /* init the computer to work with the EGA */
|
||||
}
|
||||
|
||||
egaclose()
|
||||
|
||||
{
|
||||
/* put the beast into 80 column mode */
|
||||
rg.x.ax = 3;
|
||||
int86(16, &rg, &rg);
|
||||
}
|
||||
|
||||
scwrite(row, outstr, forg, bacg) /* write a line out*/
|
||||
|
||||
scwrite(row, outstr, forg, bacg)
|
||||
/* write a line out */
|
||||
int row; /* row of screen to place outstr on */
|
||||
char *outstr; /* string to write out (must be term.t_ncol long) */
|
||||
int forg; /* forground color of string to write */
|
||||
@ -475,38 +467,38 @@ int bacg; /* background color */
|
||||
/* build the attribute byte and setup the screen pointer */
|
||||
#if COLOR
|
||||
if (dtype != CDMONO)
|
||||
attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8;
|
||||
attr =
|
||||
(((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) <<
|
||||
8;
|
||||
else
|
||||
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
||||
#else
|
||||
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
||||
#endif
|
||||
lnptr = &sline[0];
|
||||
for (i=0; i<term.t_ncol; i++)
|
||||
for (i = 0; i < term.t_ncol; i++)
|
||||
*lnptr++ = (outstr[i] & 255) | attr;
|
||||
|
||||
if (flickcode && (dtype == CDCGA)) {
|
||||
/* wait for vertical retrace to be off */
|
||||
while ((inp(0x3da) & 8))
|
||||
;
|
||||
while ((inp(0x3da) & 8));
|
||||
|
||||
/* and to be back on */
|
||||
while ((inp(0x3da) & 8) == 0)
|
||||
;
|
||||
while ((inp(0x3da) & 8) == 0);
|
||||
}
|
||||
|
||||
/* and send the string out */
|
||||
movmem(&sline[0], scptr[row], term.t_ncol*2);
|
||||
movmem(&sline[0], scptr[row], term.t_ncol * 2);
|
||||
}
|
||||
|
||||
#if FNLABEL
|
||||
fnclabel(f, n) /* label a function key */
|
||||
|
||||
int f,n; /* default flag, numeric argument [unused] */
|
||||
fnclabel(f, n)
|
||||
/* label a function key */
|
||||
int f, n; /* default flag, numeric argument [unused] */
|
||||
|
||||
{
|
||||
/* on machines with no function keys...don't bother */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
@ -514,4 +506,3 @@ ibmhello()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
224
input.c
224
input.c
@ -46,13 +46,13 @@ char *prompt;
|
||||
c = tgetc();
|
||||
|
||||
if (c == ectoc(abortc)) /* Bail out! */
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
|
||||
if (c=='y' || c=='Y')
|
||||
return(TRUE);
|
||||
if (c == 'y' || c == 'Y')
|
||||
return (TRUE);
|
||||
|
||||
if (c=='n' || c=='N')
|
||||
return(FALSE);
|
||||
if (c == 'n' || c == 'N')
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,10 +65,10 @@ char *prompt;
|
||||
*/
|
||||
|
||||
mlreply(prompt, buf, nbuf)
|
||||
char *prompt;
|
||||
char *buf;
|
||||
char *prompt;
|
||||
char *buf;
|
||||
{
|
||||
return(nextarg(prompt, buf, nbuf, ctoec('\n')));
|
||||
return (nextarg(prompt, buf, nbuf, ctoec('\n')));
|
||||
}
|
||||
|
||||
mlreplyt(prompt, buf, nbuf, eolchar)
|
||||
@ -78,7 +78,7 @@ char *buf;
|
||||
int eolchar;
|
||||
|
||||
{
|
||||
return(nextarg(prompt, buf, nbuf, eolchar));
|
||||
return (nextarg(prompt, buf, nbuf, eolchar));
|
||||
}
|
||||
|
||||
/* ectoc: expanded character to character
|
||||
@ -92,8 +92,8 @@ int c;
|
||||
if (c & CONTROL)
|
||||
c = c & ~(CONTROL | 0x40);
|
||||
if (c & SPEC)
|
||||
c= c & 255;
|
||||
return(c);
|
||||
c = c & 255;
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* ctoec: character to extended character
|
||||
@ -104,8 +104,8 @@ ctoec(c)
|
||||
int c;
|
||||
|
||||
{
|
||||
if (c>=0x00 && c<=0x1F)
|
||||
c = CONTROL | (c+'@');
|
||||
if (c >= 0x00 && c <= 0x1F)
|
||||
c = CONTROL | (c + '@');
|
||||
return (c);
|
||||
}
|
||||
|
||||
@ -114,8 +114,7 @@ int c;
|
||||
name if it is unique.
|
||||
*/
|
||||
|
||||
int (*getname())()
|
||||
|
||||
int (*getname()) ()
|
||||
{
|
||||
register int cpos; /* current column on screen output */
|
||||
register int c;
|
||||
@ -124,7 +123,7 @@ int (*getname())()
|
||||
register NBIND *cffp; /* current ptr to entry in name binding table */
|
||||
register NBIND *lffp; /* last ptr to entry in name binding table */
|
||||
char buf[NSTRING]; /* buffer to hold tentative command name */
|
||||
int (*fncmatch())();
|
||||
int (*fncmatch()) ();
|
||||
|
||||
/* starting at the beginning of the string buffer */
|
||||
cpos = 0;
|
||||
@ -132,8 +131,8 @@ int (*getname())()
|
||||
/* if we are executing a command line get the next arg and match it */
|
||||
if (clexec) {
|
||||
if (macarg(buf) != TRUE)
|
||||
return(FALSE);
|
||||
return(fncmatch(&buf[0]));
|
||||
return (FALSE);
|
||||
return (fncmatch(&buf[0]));
|
||||
}
|
||||
|
||||
/* build a name string from the keyboard */
|
||||
@ -145,12 +144,12 @@ int (*getname())()
|
||||
buf[cpos] = 0;
|
||||
|
||||
/* and match it off */
|
||||
return(fncmatch(&buf[0]));
|
||||
return (fncmatch(&buf[0]));
|
||||
|
||||
} else if (c == ectoc(abortc)) { /* Bell, abort */
|
||||
ctrlg(FALSE, 0);
|
||||
TTflush();
|
||||
return( (int (*)()) NULL);
|
||||
return ((int (*)()) NULL);
|
||||
|
||||
} else if (c == 0x7F || c == 0x08) { /* rubout/erase */
|
||||
if (cpos != 0) {
|
||||
@ -179,24 +178,34 @@ int (*getname())()
|
||||
buf[cpos] = 0; /* terminate it for us */
|
||||
ffp = &names[0]; /* scan for matches */
|
||||
while (ffp->n_func != NULL) {
|
||||
if (strncmp(buf, ffp->n_name, strlen(buf)) == 0) {
|
||||
if (strncmp(buf, ffp->n_name, strlen(buf))
|
||||
== 0) {
|
||||
/* a possible match! More than one? */
|
||||
if ((ffp + 1)->n_func == NULL ||
|
||||
(strncmp(buf, (ffp+1)->n_name, strlen(buf)) != 0)) {
|
||||
(strncmp
|
||||
(buf, (ffp + 1)->n_name,
|
||||
strlen(buf)) != 0)) {
|
||||
/* no...we match, print it */
|
||||
sp = ffp->n_name + cpos;
|
||||
while (*sp)
|
||||
TTputc(*sp++);
|
||||
TTflush();
|
||||
return(ffp->n_func);
|
||||
return (ffp->n_func);
|
||||
} else {
|
||||
/* << << << << << << << << << << << << << << << << << */
|
||||
/* try for a partial match against the list */
|
||||
|
||||
/* first scan down until we no longer match the current input */
|
||||
lffp = (ffp + 1);
|
||||
while ((lffp+1)->n_func != NULL) {
|
||||
if (strncmp(buf, (lffp+1)->n_name, strlen(buf)) != 0)
|
||||
while ((lffp +
|
||||
1)->n_func !=
|
||||
NULL) {
|
||||
if (strncmp
|
||||
(buf,
|
||||
(lffp +
|
||||
1)->n_name,
|
||||
strlen(buf))
|
||||
!= 0)
|
||||
break;
|
||||
++lffp;
|
||||
}
|
||||
@ -204,18 +213,27 @@ int (*getname())()
|
||||
/* and now, attempt to partial complete the string, char at a time */
|
||||
while (TRUE) {
|
||||
/* add the next char in */
|
||||
buf[cpos] = ffp->n_name[cpos];
|
||||
buf[cpos] =
|
||||
ffp->
|
||||
n_name[cpos];
|
||||
|
||||
/* scan through the candidates */
|
||||
cffp = ffp + 1;
|
||||
while (cffp <= lffp) {
|
||||
if (cffp->n_name[cpos] != buf[cpos])
|
||||
while (cffp <=
|
||||
lffp) {
|
||||
if (cffp->
|
||||
n_name
|
||||
[cpos]
|
||||
!=
|
||||
buf
|
||||
[cpos])
|
||||
goto onward;
|
||||
++cffp;
|
||||
}
|
||||
|
||||
/* add the character */
|
||||
TTputc(buf[cpos++]);
|
||||
TTputc(buf
|
||||
[cpos++]);
|
||||
}
|
||||
/* << << << << << << << << << << << << << << << << << */
|
||||
}
|
||||
@ -225,11 +243,11 @@ int (*getname())()
|
||||
|
||||
/* no match.....beep and onward */
|
||||
TTbeep();
|
||||
onward:;
|
||||
onward:;
|
||||
TTflush();
|
||||
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
|
||||
} else {
|
||||
if (cpos < NSTRING-1 && c > ' ') {
|
||||
if (cpos < NSTRING - 1 && c > ' ') {
|
||||
buf[cpos++] = c;
|
||||
TTputc(c);
|
||||
}
|
||||
@ -244,7 +262,6 @@ onward:;
|
||||
macro action */
|
||||
|
||||
int tgetc()
|
||||
|
||||
{
|
||||
int c; /* fetched character */
|
||||
|
||||
@ -253,7 +270,7 @@ int tgetc()
|
||||
|
||||
/* if there is some left... */
|
||||
if (kbdptr < kbdend)
|
||||
return((int)*kbdptr++);
|
||||
return ((int) *kbdptr++);
|
||||
|
||||
/* at the end of last repitition? */
|
||||
if (--kbdrep < 1) {
|
||||
@ -266,7 +283,7 @@ int tgetc()
|
||||
|
||||
/* reset the macro to the begining for the next rep */
|
||||
kbdptr = &kbdm[0];
|
||||
return((int)*kbdptr++);
|
||||
return ((int) *kbdptr++);
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,7 +306,7 @@ int tgetc()
|
||||
}
|
||||
|
||||
/* and finally give the char back */
|
||||
return(c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* GET1KEY: Get one keystroke. The only prefixs legal here
|
||||
@ -297,7 +314,6 @@ int tgetc()
|
||||
*/
|
||||
|
||||
get1key()
|
||||
|
||||
{
|
||||
int c;
|
||||
|
||||
@ -307,14 +323,14 @@ get1key()
|
||||
#if MSDOS
|
||||
if (c == 0) { /* Apply SPEC prefix */
|
||||
c = tgetc();
|
||||
if (c>=0x00 && c<=0x1F) /* control key? */
|
||||
c = CONTROL | (c+'@');
|
||||
return(SPEC | c);
|
||||
if (c >= 0x00 && c <= 0x1F) /* control key? */
|
||||
c = CONTROL | (c + '@');
|
||||
return (SPEC | c);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (c>=0x00 && c<=0x1F) /* C0 control -> C- */
|
||||
c = CONTROL | (c+'@');
|
||||
if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */
|
||||
c = CONTROL | (c + '@');
|
||||
return (c);
|
||||
}
|
||||
|
||||
@ -322,7 +338,6 @@ get1key()
|
||||
prefix keys
|
||||
*/
|
||||
getcmd()
|
||||
|
||||
{
|
||||
int c; /* fetched keystroke */
|
||||
#if VT220
|
||||
@ -333,7 +348,7 @@ getcmd()
|
||||
c = get1key();
|
||||
|
||||
#if VT220
|
||||
proc_metac:
|
||||
proc_metac:
|
||||
#endif
|
||||
/* process META prefix */
|
||||
if (c == (CONTROL | '[')) {
|
||||
@ -342,20 +357,24 @@ proc_metac:
|
||||
if (c == '[' || c == 'O') { /* CSI P.K. */
|
||||
c = get1key();
|
||||
if (c >= 'A' && c <= 'D')
|
||||
return(SPEC | c | cmask);
|
||||
return (SPEC | c | cmask);
|
||||
if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c')
|
||||
return(SPEC | c | cmask);
|
||||
return (SPEC | c | cmask);
|
||||
d = get1key();
|
||||
if (d == '~') /* ESC [ n ~ P.K. */
|
||||
return(SPEC | c | cmask);
|
||||
return (SPEC | c | cmask);
|
||||
switch (c) { /* ESC [ n n ~ P.K. */
|
||||
case '1': c = d + 32;
|
||||
case '1':
|
||||
c = d + 32;
|
||||
break;
|
||||
case '2': c = d + 48;
|
||||
case '2':
|
||||
c = d + 48;
|
||||
break;
|
||||
case '3': c = d + 64;
|
||||
case '3':
|
||||
c = d + 64;
|
||||
break;
|
||||
default: c = '?';
|
||||
default:
|
||||
c = '?';
|
||||
break;
|
||||
}
|
||||
if (d != '~') /* eat tilde P.K. */
|
||||
@ -363,11 +382,10 @@ proc_metac:
|
||||
if (c == 'i') { /* DO key P.K. */
|
||||
c = ctlxc;
|
||||
goto proc_ctlxc;
|
||||
}
|
||||
else if (c == 'c') /* ESC key P.K. */
|
||||
} else if (c == 'c') /* ESC key P.K. */
|
||||
c = get1key();
|
||||
else
|
||||
return(SPEC | c | cmask);
|
||||
return (SPEC | c | cmask);
|
||||
}
|
||||
#endif
|
||||
#if VT220
|
||||
@ -378,13 +396,12 @@ proc_metac:
|
||||
#endif
|
||||
if (islower(c)) /* Force to upper */
|
||||
c ^= DIFCASE;
|
||||
if (c>=0x00 && c<=0x1F) /* control key */
|
||||
c = CONTROL | (c+'@');
|
||||
return(META | c );
|
||||
if (c >= 0x00 && c <= 0x1F) /* control key */
|
||||
c = CONTROL | (c + '@');
|
||||
return (META | c);
|
||||
}
|
||||
#if PKCODE
|
||||
else
|
||||
if (c == metac) {
|
||||
else if (c == metac) {
|
||||
c = get1key();
|
||||
#if VT220
|
||||
if (c == (CONTROL | '[')) {
|
||||
@ -394,15 +411,15 @@ proc_metac:
|
||||
#endif
|
||||
if (islower(c)) /* Force to upper */
|
||||
c ^= DIFCASE;
|
||||
if (c>=0x00 && c<=0x1F) /* control key */
|
||||
c = CONTROL | (c+'@');
|
||||
return(META | c );
|
||||
if (c >= 0x00 && c <= 0x1F) /* control key */
|
||||
c = CONTROL | (c + '@');
|
||||
return (META | c);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if VT220
|
||||
proc_ctlxc:
|
||||
proc_ctlxc:
|
||||
#endif
|
||||
/* process CTLX prefix */
|
||||
if (c == ctlxc) {
|
||||
@ -413,15 +430,15 @@ proc_ctlxc:
|
||||
goto proc_metac;
|
||||
}
|
||||
#endif
|
||||
if (c>='a' && c<='z') /* Force to upper */
|
||||
if (c >= 'a' && c <= 'z') /* Force to upper */
|
||||
c -= 0x20;
|
||||
if (c>=0x00 && c<=0x1F) /* control key */
|
||||
c = CONTROL | (c+'@');
|
||||
return(CTLX | c);
|
||||
if (c >= 0x00 && c <= 0x1F) /* control key */
|
||||
c = CONTROL | (c + '@');
|
||||
return (CTLX | c);
|
||||
}
|
||||
|
||||
/* otherwise, just return it */
|
||||
return(c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* A more generalized prompt/reply function allowing the caller
|
||||
@ -430,7 +447,9 @@ proc_ctlxc:
|
||||
*/
|
||||
getstring(prompt, buf, nbuf, eolchar)
|
||||
|
||||
char *prompt; char *buf; int eolchar;
|
||||
char *prompt;
|
||||
char *buf;
|
||||
int eolchar;
|
||||
|
||||
{
|
||||
register int cpos; /* current character position in string */
|
||||
@ -462,7 +481,7 @@ char *prompt; char *buf; int eolchar;
|
||||
|
||||
for (;;) {
|
||||
#if COMPLC
|
||||
if (! didtry)
|
||||
if (!didtry)
|
||||
nskip = -1;
|
||||
didtry = 0;
|
||||
#endif
|
||||
@ -487,9 +506,9 @@ char *prompt; char *buf; int eolchar;
|
||||
|
||||
/* if we default the buffer, return FALSE */
|
||||
if (buf[0] == 0)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* change from command form back to character form */
|
||||
@ -499,8 +518,8 @@ char *prompt; char *buf; int eolchar;
|
||||
/* Abort the input? */
|
||||
ctrlg(FALSE, 0);
|
||||
TTflush();
|
||||
return(ABORT);
|
||||
} else if ((c==0x7F || c==0x08) && quotef==FALSE) {
|
||||
return (ABORT);
|
||||
} else if ((c == 0x7F || c == 0x08) && quotef == FALSE) {
|
||||
/* rubout/erase */
|
||||
if (cpos != 0) {
|
||||
outstring("\b \b");
|
||||
@ -536,7 +555,8 @@ char *prompt; char *buf; int eolchar;
|
||||
TTflush();
|
||||
|
||||
#if COMPLC
|
||||
} else if ((c == 0x09 || c == ' ') && quotef == FALSE && ffile) {
|
||||
} else if ((c == 0x09 || c == ' ') && quotef == FALSE
|
||||
&& ffile) {
|
||||
/* TAB, complete file name */
|
||||
char ffbuf[255];
|
||||
#if MSDOS
|
||||
@ -564,13 +584,13 @@ char *prompt; char *buf; int eolchar;
|
||||
#if MSDOS
|
||||
if (lsav < 0 && (buf[cpos] == '\\' ||
|
||||
buf[cpos] == '/' ||
|
||||
buf[cpos] == ':' && cpos == 1))
|
||||
buf[cpos] == ':'
|
||||
&& cpos == 1))
|
||||
lsav = cpos;
|
||||
#endif
|
||||
}
|
||||
TTflush();
|
||||
if (nskip < 0)
|
||||
{
|
||||
if (nskip < 0) {
|
||||
buf[ocpos] = 0;
|
||||
#if UNIX
|
||||
if (tmpf != NULL)
|
||||
@ -578,8 +598,8 @@ char *prompt; char *buf; int eolchar;
|
||||
strcpy(tmp, "/tmp/meXXXXXX");
|
||||
strcpy(ffbuf, "echo ");
|
||||
strcat(ffbuf, buf);
|
||||
if (! iswild)
|
||||
strcat(ffbuf,"*");
|
||||
if (!iswild)
|
||||
strcat(ffbuf, "*");
|
||||
strcat(ffbuf, " >");
|
||||
mktemp(tmp);
|
||||
strcat(ffbuf, tmp);
|
||||
@ -589,49 +609,47 @@ char *prompt; char *buf; int eolchar;
|
||||
#endif
|
||||
#if MSDOS
|
||||
strcpy(sffbuf, buf);
|
||||
if (! iswild)
|
||||
strcat(sffbuf,"*.*");
|
||||
if (!iswild)
|
||||
strcat(sffbuf, "*.*");
|
||||
#endif
|
||||
nskip = 0;
|
||||
}
|
||||
#if UNIX
|
||||
c = ' ';
|
||||
for (n = nskip; n > 0; n--)
|
||||
while ((c = getc(tmpf)) != EOF && c != ' ');
|
||||
while ((c = getc(tmpf)) != EOF
|
||||
&& c != ' ');
|
||||
#endif
|
||||
#if MSDOS
|
||||
if (nskip == 0)
|
||||
{
|
||||
if (nskip == 0) {
|
||||
strcpy(ffbuf, sffbuf);
|
||||
c = findfirst(ffbuf, &ffblk, FA_DIREC) ? '*' : ' ';
|
||||
}
|
||||
else if (nskip > 0)
|
||||
c = findfirst(ffbuf, &ffblk,
|
||||
FA_DIREC) ? '*' : ' ';
|
||||
} else if (nskip > 0)
|
||||
c = findnext(&ffblk) ? 0 : ' ';
|
||||
#endif
|
||||
nskip++;
|
||||
|
||||
if (c != ' ')
|
||||
{
|
||||
if (c != ' ') {
|
||||
TTbeep();
|
||||
nskip = 0;
|
||||
}
|
||||
|
||||
#if UNIX
|
||||
while ((c = getc(tmpf)) != EOF && c != '\n' && c != ' ' && c != '*')
|
||||
while ((c = getc(tmpf)) != EOF && c != '\n'
|
||||
&& c != ' ' && c != '*')
|
||||
#endif
|
||||
#if MSDOS
|
||||
if (c == '*')
|
||||
fcp = sffbuf;
|
||||
else
|
||||
{
|
||||
strncpy(buf, sffbuf, lsav+1);
|
||||
cpos = lsav+1;
|
||||
else {
|
||||
strncpy(buf, sffbuf, lsav + 1);
|
||||
cpos = lsav + 1;
|
||||
fcp = ffblk.ff_name;
|
||||
}
|
||||
while (c != 0 && (c = *fcp++) != 0 && c != '*')
|
||||
#endif
|
||||
{
|
||||
if (cpos < nbuf-1)
|
||||
if (cpos < nbuf - 1)
|
||||
buf[cpos++] = c;
|
||||
}
|
||||
#if UNIX
|
||||
@ -639,8 +657,7 @@ char *prompt; char *buf; int eolchar;
|
||||
TTbeep();
|
||||
#endif
|
||||
|
||||
for (n = 0; n < cpos; n++)
|
||||
{
|
||||
for (n = 0; n < cpos; n++) {
|
||||
c = buf[n];
|
||||
if ((c < ' ') && (c != '\n')) {
|
||||
outstring("^");
|
||||
@ -668,7 +685,7 @@ char *prompt; char *buf; int eolchar;
|
||||
quotef = TRUE;
|
||||
} else {
|
||||
quotef = FALSE;
|
||||
if (cpos < nbuf-1) {
|
||||
if (cpos < nbuf - 1) {
|
||||
buf[cpos++] = c;
|
||||
|
||||
if ((c < ' ') && (c != '\n')) {
|
||||
@ -691,8 +708,8 @@ char *prompt; char *buf; int eolchar;
|
||||
}
|
||||
}
|
||||
|
||||
outstring(s) /* output a string of characters */
|
||||
|
||||
outstring(s)
|
||||
/* output a string of characters */
|
||||
char *s; /* string to output */
|
||||
|
||||
{
|
||||
@ -701,8 +718,8 @@ char *s; /* string to output */
|
||||
TTputc(*s++);
|
||||
}
|
||||
|
||||
ostring(s) /* output a string of output characters */
|
||||
|
||||
ostring(s)
|
||||
/* output a string of output characters */
|
||||
char *s; /* string to output */
|
||||
|
||||
{
|
||||
@ -710,4 +727,3 @@ char *s; /* string to output */
|
||||
while (*s)
|
||||
TTputc(*s++);
|
||||
}
|
||||
|
||||
|
125
isearch.c
125
isearch.c
@ -33,7 +33,7 @@ extern int eq(); /* Compare chars, match case */
|
||||
|
||||
/* A couple of "own" variables for re-eat */
|
||||
|
||||
int (*saved_get_char)(); /* Get character routine */
|
||||
int (*saved_get_char) (); /* Get character routine */
|
||||
int eaten_char = -1; /* Re-eaten char */
|
||||
|
||||
/* A couple more "own" variables for the command string */
|
||||
@ -62,17 +62,17 @@ int risearch(f, n)
|
||||
|
||||
backchar(TRUE, 1); /* Back up a character */
|
||||
|
||||
if (!(isearch(f, -n))) /* Call ISearch backwards */
|
||||
{ /* If error in search: */
|
||||
if (!(isearch(f, -n))) { /* Call ISearch backwards *//* If error in search: */
|
||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||
curwp->w_doto = curoff; /* and the offset to original value */
|
||||
curwp->w_flag |= WFMOVE; /* Say we've moved */
|
||||
update(FALSE); /* And force an update */
|
||||
mlwrite ("(search failed)"); /* Say we died */
|
||||
mlwrite("(search failed)"); /* Say we died */
|
||||
#if PKCODE
|
||||
matchlen = strlen(pat);
|
||||
#endif
|
||||
} else mlerase (); /* If happy, just erase the cmd line */
|
||||
} else
|
||||
mlerase(); /* If happy, just erase the cmd line */
|
||||
#if PKCODE
|
||||
matchlen = strlen(pat);
|
||||
#endif
|
||||
@ -92,17 +92,17 @@ int fisearch(f, n)
|
||||
|
||||
/* do the search */
|
||||
|
||||
if (!(isearch(f, n))) /* Call ISearch forwards */
|
||||
{ /* If error in search: */
|
||||
if (!(isearch(f, n))) { /* Call ISearch forwards *//* If error in search: */
|
||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||
curwp->w_doto = curoff; /* and the offset to original value */
|
||||
curwp->w_flag |= WFMOVE; /* Say we've moved */
|
||||
update(FALSE); /* And force an update */
|
||||
mlwrite ("(search failed)"); /* Say we died */
|
||||
mlwrite("(search failed)"); /* Say we died */
|
||||
#if PKCODE
|
||||
matchlen = strlen(pat);
|
||||
#endif
|
||||
} else mlerase (); /* If happy, just erase the cmd line */
|
||||
} else
|
||||
mlerase(); /* If happy, just erase the cmd line */
|
||||
#if PKCODE
|
||||
matchlen = strlen(pat);
|
||||
#endif
|
||||
@ -151,14 +151,14 @@ isearch(f, n)
|
||||
cmd_reexecute = -1; /* We're not re-executing (yet?) */
|
||||
cmd_offset = 0; /* Start at the beginning of the buff */
|
||||
cmd_buff[0] = '\0'; /* Init the command buffer */
|
||||
strncpy (pat_save, pat, NPAT); /* Save the old pattern string */
|
||||
strncpy(pat_save, pat, NPAT); /* Save the old pattern string */
|
||||
curline = curwp->w_dotp; /* Save the current line pointer */
|
||||
curoff = curwp->w_doto; /* Save the current offset */
|
||||
init_direction = n; /* Save the initial search direction */
|
||||
|
||||
/* This is a good place to start a re-execution: */
|
||||
|
||||
start_over:
|
||||
start_over:
|
||||
|
||||
/* ask the user for the text of a pattern */
|
||||
col = promptpattern("ISearch: "); /* Prompt, remember the col */
|
||||
@ -172,15 +172,12 @@ start_over:
|
||||
*/
|
||||
|
||||
c = ectoc(expc = get_char()); /* Get the first character */
|
||||
if ((c == IS_FORWARD) ||
|
||||
(c == IS_REVERSE) ||
|
||||
(c == IS_VMSFORW)) /* Reuse old search string? */
|
||||
{
|
||||
if ((c == IS_FORWARD) || (c == IS_REVERSE) || (c == IS_VMSFORW)) { /* Reuse old search string? */
|
||||
for (cpos = 0; pat[cpos] != 0; cpos++) /* Yup, find the length */
|
||||
col = echochar(pat[cpos],col); /* and re-echo the string */
|
||||
col = echochar(pat[cpos], col); /* and re-echo the string */
|
||||
if (c == IS_REVERSE) { /* forward search? */
|
||||
n = -1; /* No, search in reverse */
|
||||
backchar (TRUE, 1); /* Be defensive about EOB */
|
||||
backchar(TRUE, 1); /* Be defensive about EOB */
|
||||
} else
|
||||
n = 1; /* Yes, search forward */
|
||||
status = scanmore(pat, n); /* Do the search */
|
||||
@ -189,18 +186,16 @@ start_over:
|
||||
|
||||
/* Top of the per character loop */
|
||||
|
||||
for (;;) /* ISearch per character loop */
|
||||
{
|
||||
for (;;) { /* ISearch per character loop */
|
||||
/* Check for special characters first: */
|
||||
/* Most cases here change the search */
|
||||
|
||||
if (expc == metac) /* Want to quit searching? */
|
||||
return (TRUE); /* Quit searching now */
|
||||
|
||||
switch (c) /* dispatch on the input char */
|
||||
{
|
||||
switch (c) { /* dispatch on the input char */
|
||||
case IS_ABORT: /* If abort search request */
|
||||
return(FALSE); /* Quit searching again */
|
||||
return (FALSE); /* Quit searching again */
|
||||
|
||||
case IS_REVERSE: /* If backward search */
|
||||
case IS_FORWARD: /* If forward search */
|
||||
@ -211,7 +206,7 @@ start_over:
|
||||
n = 1; /* go forward */
|
||||
status = scanmore(pat, n); /* Start the search again */
|
||||
c = ectoc(expc = get_char()); /* Get the next char */
|
||||
continue; /* Go continue with the search*/
|
||||
continue; /* Go continue with the search */
|
||||
|
||||
case IS_NEWLINE: /* Carriage return */
|
||||
c = '\n'; /* Make it a new line */
|
||||
@ -234,16 +229,15 @@ start_over:
|
||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||
curwp->w_doto = curoff; /* and the offset */
|
||||
n = init_direction; /* Reset the search direction */
|
||||
strncpy (pat, pat_save, NPAT); /* Restore the old search str */
|
||||
strncpy(pat, pat_save, NPAT); /* Restore the old search str */
|
||||
cmd_reexecute = 0; /* Start the whole mess over */
|
||||
goto start_over; /* Let it take care of itself */
|
||||
|
||||
/* Presumably a quasi-normal character comes here */
|
||||
|
||||
default: /* All other chars */
|
||||
if (c < ' ') /* Is it printable? */
|
||||
{ /* Nope. */
|
||||
reeat (c); /* Re-eat the char */
|
||||
if (c < ' ') { /* Is it printable? *//* Nope. */
|
||||
reeat(c); /* Re-eat the char */
|
||||
return (TRUE); /* And return the last status */
|
||||
}
|
||||
} /* Switch */
|
||||
@ -251,18 +245,16 @@ start_over:
|
||||
/* I guess we got something to search for, so search for it */
|
||||
|
||||
pat[cpos++] = c; /* put the char in the buffer */
|
||||
if (cpos >= NPAT) /* too many chars in string? */
|
||||
{ /* Yup. Complain about it */
|
||||
if (cpos >= NPAT) { /* too many chars in string? *//* Yup. Complain about it */
|
||||
mlwrite("? Search string too long");
|
||||
return(TRUE); /* Return an error */
|
||||
return (TRUE); /* Return an error */
|
||||
}
|
||||
pat[cpos] = 0; /* null terminate the buffer */
|
||||
col = echochar(c,col); /* Echo the character */
|
||||
col = echochar(c, col); /* Echo the character */
|
||||
if (!status) { /* If we lost last time */
|
||||
TTputc(BELL); /* Feep again */
|
||||
TTflush(); /* see that the feep feeps */
|
||||
} else /* Otherwise, we must have won*/
|
||||
if (!(status = checknext(c, pat, n))) /* See if match */
|
||||
} else /* Otherwise, we must have won */ if (!(status = checknext(c, pat, n))) /* See if match */
|
||||
status = scanmore(pat, n); /* or find the next match */
|
||||
c = ectoc(expc = get_char()); /* Get the next char */
|
||||
} /* for {;;} */
|
||||
@ -279,7 +271,7 @@ start_over:
|
||||
* scanmore or something.
|
||||
*/
|
||||
|
||||
int checknext (chr, patrn, dir) /* Check next character in search string */
|
||||
int checknext(chr, patrn, dir) /* Check next character in search string */
|
||||
char chr; /* Next char to look for */
|
||||
char *patrn; /* The entire search string (incl chr) */
|
||||
int dir; /* Search direction */
|
||||
@ -295,10 +287,8 @@ int dir; /* Search direction */
|
||||
curline = curwp->w_dotp; /* Get the current line structure */
|
||||
curoff = curwp->w_doto; /* Get the offset within that line */
|
||||
|
||||
if (dir > 0) /* If searching forward */
|
||||
{
|
||||
if (curoff == llength(curline)) /* If at end of line */
|
||||
{
|
||||
if (dir > 0) { /* If searching forward */
|
||||
if (curoff == llength(curline)) { /* If at end of line */
|
||||
curline = lforw(curline); /* Skip to the next line */
|
||||
if (curline == curbp->b_linep)
|
||||
return (FALSE); /* Abort if at end of buffer */
|
||||
@ -306,15 +296,14 @@ int dir; /* Search direction */
|
||||
buffchar = '\n'; /* And say the next char is NL */
|
||||
} else
|
||||
buffchar = lgetc(curline, curoff++); /* Get the next char */
|
||||
if (status = eq(buffchar, chr)) /* Is it what we're looking for? */
|
||||
{
|
||||
if (status = eq(buffchar, chr)) { /* Is it what we're looking for? */
|
||||
curwp->w_dotp = curline; /* Yes, set the buffer's point */
|
||||
curwp->w_doto = curoff; /* to the matched character */
|
||||
curwp->w_flag |= WFMOVE; /* Say that we've moved */
|
||||
}
|
||||
return (status); /* And return the status */
|
||||
} else /* Else, if reverse search: */
|
||||
return (match_pat (patrn)); /* See if we're in the right place */
|
||||
return (match_pat(patrn)); /* See if we're in the right place */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -333,21 +322,18 @@ int dir; /* direction to search */
|
||||
{
|
||||
int sts; /* search status */
|
||||
|
||||
if (dir < 0) /* reverse search? */
|
||||
{
|
||||
if (dir < 0) { /* reverse search? */
|
||||
rvstrcpy(tap, patrn); /* Put reversed string in tap */
|
||||
sts = scanner(tap, REVERSE, PTBEG);
|
||||
}
|
||||
else
|
||||
} else
|
||||
sts = scanner(patrn, FORWARD, PTEND); /* Nope. Go forward */
|
||||
|
||||
if (!sts)
|
||||
{
|
||||
if (!sts) {
|
||||
TTputc(BELL); /* Feep if search fails */
|
||||
TTflush(); /* see that the feep feeps */
|
||||
}
|
||||
|
||||
return(sts); /* else, don't even try */
|
||||
return (sts); /* else, don't even try */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -360,7 +346,7 @@ int dir; /* direction to search */
|
||||
* be done is match the last char input.
|
||||
*/
|
||||
|
||||
int match_pat (patrn) /* See if the pattern string matches string at "." */
|
||||
int match_pat(patrn) /* See if the pattern string matches string at "." */
|
||||
char *patrn; /* String to match to buffer */
|
||||
{
|
||||
register int i; /* Generic loop index/offset */
|
||||
@ -375,10 +361,8 @@ char *patrn; /* String to match to buffer */
|
||||
|
||||
/* top of per character compare loop: */
|
||||
|
||||
for (i = 0; i < strlen(patrn); i++) /* Loop for all characters in patrn */
|
||||
{
|
||||
if (curoff == llength(curline)) /* If at end of line */
|
||||
{
|
||||
for (i = 0; i < strlen(patrn); i++) { /* Loop for all characters in patrn */
|
||||
if (curoff == llength(curline)) { /* If at end of line */
|
||||
curline = lforw(curline); /* Skip to the next line */
|
||||
curoff = 0; /* Start at the beginning of the line */
|
||||
if (curline == curbp->b_linep)
|
||||
@ -389,7 +373,7 @@ char *patrn; /* String to match to buffer */
|
||||
if (!eq(buffchar, patrn[i])) /* Is it what we're looking for? */
|
||||
return (FALSE); /* Nope, just punt it then */
|
||||
}
|
||||
return (TRUE); /* Everything matched? Let's celebrate*/
|
||||
return (TRUE); /* Everything matched? Let's celebrate */
|
||||
}
|
||||
|
||||
/* Routine to prompt for I-Search string. */
|
||||
@ -397,31 +381,29 @@ char *patrn; /* String to match to buffer */
|
||||
int promptpattern(prompt)
|
||||
char *prompt;
|
||||
{
|
||||
char tpat[NPAT+20];
|
||||
char tpat[NPAT + 20];
|
||||
|
||||
strcpy(tpat, prompt); /* copy prompt to output string */
|
||||
strcat(tpat, " ("); /* build new prompt string */
|
||||
expandp(pat, &tpat[strlen(tpat)], NPAT/2); /* add old pattern */
|
||||
expandp(pat, &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
|
||||
strcat(tpat, ")<Meta>: ");
|
||||
|
||||
/* check to see if we are executing a command line */
|
||||
if (!clexec) {
|
||||
mlwrite(tpat);
|
||||
}
|
||||
return(strlen(tpat));
|
||||
return (strlen(tpat));
|
||||
}
|
||||
|
||||
/* routine to echo i-search characters */
|
||||
|
||||
int echochar(c,col)
|
||||
int echochar(c, col)
|
||||
int c; /* character to be echoed */
|
||||
int col; /* column to be echoed in */
|
||||
{
|
||||
movecursor(term.t_nrow,col); /* Position the cursor */
|
||||
if ((c < ' ') || (c == 0x7F)) /* Control character? */
|
||||
{
|
||||
switch (c) /* Yes, dispatch special cases*/
|
||||
{
|
||||
movecursor(term.t_nrow, col); /* Position the cursor */
|
||||
if ((c < ' ') || (c == 0x7F)) { /* Control character? */
|
||||
switch (c) { /* Yes, dispatch special cases */
|
||||
case '\n': /* Newline */
|
||||
TTputc('<');
|
||||
TTputc('N');
|
||||
@ -447,13 +429,13 @@ int col; /* column to be echoed in */
|
||||
|
||||
default: /* Vanilla control char */
|
||||
TTputc('^'); /* Yes, output prefix */
|
||||
TTputc(c+0x40); /* Make it "^X" */
|
||||
TTputc(c + 0x40); /* Make it "^X" */
|
||||
col++; /* Count this char */
|
||||
}
|
||||
} else
|
||||
TTputc(c); /* Otherwise, output raw char */
|
||||
TTflush(); /* Flush the output */
|
||||
return(++col); /* return the new column no */
|
||||
return (++col); /* return the new column no */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -463,7 +445,7 @@ int col; /* column to be echoed in */
|
||||
* next character.
|
||||
*/
|
||||
|
||||
int get_char ()
|
||||
int get_char()
|
||||
{
|
||||
int c; /* A place to get a character */
|
||||
|
||||
@ -477,14 +459,13 @@ int get_char ()
|
||||
|
||||
cmd_reexecute = -1; /* Say we're in real mode again */
|
||||
update(FALSE); /* Pretty up the screen */
|
||||
if (cmd_offset >= CMDBUFLEN-1) /* If we're getting too big ... */
|
||||
{
|
||||
mlwrite ("? command too long"); /* Complain loudly and bitterly */
|
||||
if (cmd_offset >= CMDBUFLEN - 1) { /* If we're getting too big ... */
|
||||
mlwrite("? command too long"); /* Complain loudly and bitterly */
|
||||
return (metac); /* And force a quit */
|
||||
}
|
||||
c = get1key(); /* Get the next character */
|
||||
cmd_buff[cmd_offset++] = c; /* Save the char for next time */
|
||||
cmd_buff[cmd_offset] = '\0';/* And terminate the buffer */
|
||||
cmd_buff[cmd_offset] = '\0'; /* And terminate the buffer */
|
||||
return (c); /* Return the character */
|
||||
}
|
||||
|
||||
@ -502,14 +483,14 @@ int uneat()
|
||||
term.t_getchar = saved_get_char; /* restore the routine address */
|
||||
c = eaten_char; /* Get the re-eaten char */
|
||||
eaten_char = -1; /* Clear the old char */
|
||||
return(c); /* and return the last char */
|
||||
return (c); /* and return the last char */
|
||||
}
|
||||
|
||||
int reeat(c)
|
||||
int c;
|
||||
{
|
||||
if (eaten_char != -1) /* If we've already been here */
|
||||
return/*(NULL)*/; /* Don't do it again */
|
||||
return /*(NULL) */ ; /* Don't do it again */
|
||||
eaten_char = c; /* Else, save the char for later */
|
||||
saved_get_char = term.t_getchar; /* Save the char get routine */
|
||||
term.t_getchar = uneat; /* Replace it with ours */
|
||||
|
98
line.c
98
line.c
@ -35,10 +35,10 @@ register int used;
|
||||
register int size;
|
||||
char *malloc();
|
||||
|
||||
size = (used+NBLOCK-1) & ~(NBLOCK-1);
|
||||
size = (used + NBLOCK - 1) & ~(NBLOCK - 1);
|
||||
if (size == 0) /* Assume that an empty */
|
||||
size = NBLOCK; /* line is for type-in. */
|
||||
if ((lp = (LINE *) malloc(sizeof(LINE)+size)) == NULL) {
|
||||
if ((lp = (LINE *) malloc(sizeof(LINE) + size)) == NULL) {
|
||||
mlwrite("(OUT OF MEMORY)");
|
||||
return (NULL);
|
||||
}
|
||||
@ -106,7 +106,7 @@ register int flag;
|
||||
|
||||
if (curbp->b_nwnd != 1) /* Ensure hard. */
|
||||
flag = WFHARD;
|
||||
if ((curbp->b_flag&BFCHG) == 0) { /* First change, so */
|
||||
if ((curbp->b_flag & BFCHG) == 0) { /* First change, so */
|
||||
flag |= WFMODE; /* update mode lines. */
|
||||
curbp->b_flag |= BFCHG;
|
||||
}
|
||||
@ -118,8 +118,8 @@ register int flag;
|
||||
}
|
||||
}
|
||||
|
||||
insspace(f, n) /* insert spaces forward into text */
|
||||
|
||||
insspace(f, n)
|
||||
/* insert spaces forward into text */
|
||||
int f, n; /* default flag and numeric argument */
|
||||
|
||||
{
|
||||
@ -139,7 +139,8 @@ char *instr;
|
||||
|
||||
if (instr != NULL)
|
||||
while ((tmpc = *instr) && status == TRUE) {
|
||||
status = (tmpc == '\n'? lnewline(): linsert(1, tmpc));
|
||||
status =
|
||||
(tmpc == '\n' ? lnewline() : linsert(1, tmpc));
|
||||
|
||||
/* Insertion error? */
|
||||
if (status != TRUE) {
|
||||
@ -148,7 +149,7 @@ char *instr;
|
||||
}
|
||||
instr++;
|
||||
}
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -172,8 +173,8 @@ linsert(n, c)
|
||||
register int i;
|
||||
register WINDOW *wp;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
lchange(WFEDIT);
|
||||
lp1 = curwp->w_dotp; /* Current line */
|
||||
if (lp1 == curbp->b_linep) { /* At the end: special */
|
||||
@ -181,22 +182,22 @@ linsert(n, c)
|
||||
mlwrite("bug: linsert");
|
||||
return (FALSE);
|
||||
}
|
||||
if ((lp2=lalloc(n)) == NULL) /* Allocate new line */
|
||||
if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */
|
||||
return (FALSE);
|
||||
lp3 = lp1->l_bp; /* Previous line */
|
||||
lp3->l_fp = lp2; /* Link in */
|
||||
lp2->l_fp = lp1;
|
||||
lp1->l_bp = lp2;
|
||||
lp2->l_bp = lp3;
|
||||
for (i=0; i<n; ++i)
|
||||
for (i = 0; i < n; ++i)
|
||||
lp2->l_text[i] = c;
|
||||
curwp->w_dotp = lp2;
|
||||
curwp->w_doto = n;
|
||||
return (TRUE);
|
||||
}
|
||||
doto = curwp->w_doto; /* Save for later. */
|
||||
if (lp1->l_used+n > lp1->l_size) { /* Hard: reallocate */
|
||||
if ((lp2=lalloc(lp1->l_used+n)) == NULL)
|
||||
if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */
|
||||
if ((lp2 = lalloc(lp1->l_used + n)) == NULL)
|
||||
return (FALSE);
|
||||
cp1 = &lp1->l_text[0];
|
||||
cp2 = &lp2->l_text[0];
|
||||
@ -214,19 +215,19 @@ linsert(n, c)
|
||||
lp2 = lp1; /* Pretend new line */
|
||||
lp2->l_used += n;
|
||||
cp2 = &lp1->l_text[lp1->l_used];
|
||||
cp1 = cp2-n;
|
||||
cp1 = cp2 - n;
|
||||
while (cp1 != &lp1->l_text[doto])
|
||||
*--cp2 = *--cp1;
|
||||
}
|
||||
for (i=0; i<n; ++i) /* Add the characters */
|
||||
lp2->l_text[doto+i] = c;
|
||||
for (i = 0; i < n; ++i) /* Add the characters */
|
||||
lp2->l_text[doto + i] = c;
|
||||
wp = wheadp; /* Update windows */
|
||||
while (wp != NULL) {
|
||||
if (wp->w_linep == lp1)
|
||||
wp->w_linep = lp2;
|
||||
if (wp->w_dotp == lp1) {
|
||||
wp->w_dotp = lp2;
|
||||
if (wp==curwp || wp->w_doto>doto)
|
||||
if (wp == curwp || wp->w_doto > doto)
|
||||
wp->w_doto += n;
|
||||
}
|
||||
if (wp->w_markp == lp1) {
|
||||
@ -253,7 +254,7 @@ char c; /* character to overwrite on current position */
|
||||
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||
((curwp->w_doto) & tabmask) == tabmask))
|
||||
ldelete(1L, FALSE);
|
||||
return(linsert(1, c));
|
||||
return (linsert(1, c));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -270,16 +271,18 @@ char *ostr;
|
||||
|
||||
if (ostr != NULL)
|
||||
while ((tmpc = *ostr) && status == TRUE) {
|
||||
status = (tmpc == '\n'? lnewline(): lowrite(tmpc));
|
||||
status =
|
||||
(tmpc == '\n' ? lnewline() : lowrite(tmpc));
|
||||
|
||||
/* Insertion error? */
|
||||
if (status != TRUE) {
|
||||
mlwrite("%%Out of memory while overwriting");
|
||||
mlwrite
|
||||
("%%Out of memory while overwriting");
|
||||
break;
|
||||
}
|
||||
ostr++;
|
||||
}
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -299,16 +302,16 @@ lnewline()
|
||||
register int doto;
|
||||
register WINDOW *wp;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
#if SCROLLCODE
|
||||
lchange(WFHARD|WFINS);
|
||||
lchange(WFHARD | WFINS);
|
||||
#else
|
||||
lchange(WFHARD);
|
||||
#endif
|
||||
lp1 = curwp->w_dotp; /* Get the address and */
|
||||
doto = curwp->w_doto; /* offset of "." */
|
||||
if ((lp2=lalloc(doto)) == NULL) /* New first half line */
|
||||
if ((lp2 = lalloc(doto)) == NULL) /* New first half line */
|
||||
return (FALSE);
|
||||
cp1 = &lp1->l_text[0]; /* Shuffle text around */
|
||||
cp2 = &lp2->l_text[0];
|
||||
@ -362,24 +365,24 @@ int kflag; /* put killed text in kill buffer flag */
|
||||
register int chunk;
|
||||
register WINDOW *wp;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
while (n != 0) {
|
||||
dotp = curwp->w_dotp;
|
||||
doto = curwp->w_doto;
|
||||
if (dotp == curbp->b_linep) /* Hit end of buffer. */
|
||||
return (FALSE);
|
||||
chunk = dotp->l_used-doto; /* Size of chunk. */
|
||||
chunk = dotp->l_used - doto; /* Size of chunk. */
|
||||
if (chunk > n)
|
||||
chunk = n;
|
||||
if (chunk == 0) { /* End of line, merge. */
|
||||
#if SCROLLCODE
|
||||
lchange(WFHARD|WFKILLS);
|
||||
lchange(WFHARD | WFKILLS);
|
||||
#else
|
||||
lchange(WFHARD);
|
||||
#endif
|
||||
if (ldelnewline() == FALSE
|
||||
|| (kflag!=FALSE && kinsert('\n')==FALSE))
|
||||
|| (kflag != FALSE && kinsert('\n') == FALSE))
|
||||
return (FALSE);
|
||||
--n;
|
||||
continue;
|
||||
@ -400,12 +403,12 @@ int kflag; /* put killed text in kill buffer flag */
|
||||
dotp->l_used -= chunk;
|
||||
wp = wheadp; /* Fix windows */
|
||||
while (wp != NULL) {
|
||||
if (wp->w_dotp==dotp && wp->w_doto>=doto) {
|
||||
if (wp->w_dotp == dotp && wp->w_doto >= doto) {
|
||||
wp->w_doto -= chunk;
|
||||
if (wp->w_doto < doto)
|
||||
wp->w_doto = doto;
|
||||
}
|
||||
if (wp->w_markp==dotp && wp->w_marko>=doto) {
|
||||
if (wp->w_markp == dotp && wp->w_marko >= doto) {
|
||||
wp->w_marko -= chunk;
|
||||
if (wp->w_marko < doto)
|
||||
wp->w_marko = doto;
|
||||
@ -422,7 +425,6 @@ int kflag; /* put killed text in kill buffer flag */
|
||||
*/
|
||||
|
||||
char *getctext()
|
||||
|
||||
{
|
||||
register LINE *lp; /* line to copy */
|
||||
register int size; /* length of line to return */
|
||||
@ -442,7 +444,7 @@ char *getctext()
|
||||
while (size--)
|
||||
*dp++ = *sp++;
|
||||
*dp = 0;
|
||||
return(rline);
|
||||
return (rline);
|
||||
}
|
||||
|
||||
/* putctext: replace the current line with the passed in text */
|
||||
@ -457,14 +459,14 @@ char *iline; /* contents of new line */
|
||||
/* delete the current line */
|
||||
curwp->w_doto = 0; /* starting at the beginning of the line */
|
||||
if ((status = killtext(TRUE, 1)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
/* insert the new line */
|
||||
if ((status = linstr(iline)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
status = lnewline();
|
||||
backline(TRUE, 1);
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -485,8 +487,8 @@ ldelnewline()
|
||||
register LINE *lp3;
|
||||
register WINDOW *wp;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
lp1 = curwp->w_dotp;
|
||||
lp2 = lp1->l_fp;
|
||||
if (lp2 == curbp->b_linep) { /* At the buffer end. */
|
||||
@ -494,7 +496,7 @@ ldelnewline()
|
||||
lfree(lp1);
|
||||
return (TRUE);
|
||||
}
|
||||
if (lp2->l_used <= lp1->l_size-lp1->l_used) {
|
||||
if (lp2->l_used <= lp1->l_size - lp1->l_used) {
|
||||
cp1 = &lp1->l_text[lp1->l_used];
|
||||
cp2 = &lp2->l_text[0];
|
||||
while (cp2 != &lp2->l_text[lp2->l_used])
|
||||
@ -519,7 +521,7 @@ ldelnewline()
|
||||
free((char *) lp2);
|
||||
return (TRUE);
|
||||
}
|
||||
if ((lp3=lalloc(lp1->l_used+lp2->l_used)) == NULL)
|
||||
if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL)
|
||||
return (FALSE);
|
||||
cp1 = &lp1->l_text[0];
|
||||
cp2 = &lp3->l_text[0];
|
||||
@ -534,7 +536,7 @@ ldelnewline()
|
||||
lp3->l_bp = lp1->l_bp;
|
||||
wp = wheadp;
|
||||
while (wp != NULL) {
|
||||
if (wp->w_linep==lp1 || wp->w_linep==lp2)
|
||||
if (wp->w_linep == lp1 || wp->w_linep == lp2)
|
||||
wp->w_linep = lp3;
|
||||
if (wp->w_dotp == lp1)
|
||||
wp->w_dotp = lp3;
|
||||
@ -594,8 +596,8 @@ int c; /* character to insert in the kill buffer */
|
||||
|
||||
/* check to see if we need a new chunk */
|
||||
if (kused >= KBLOCK) {
|
||||
if ((nchunk = (KILL *)malloc(sizeof(KILL))) == NULL)
|
||||
return(FALSE);
|
||||
if ((nchunk = (KILL *) malloc(sizeof(KILL))) == NULL)
|
||||
return (FALSE);
|
||||
if (kbufh == NULL) /* set head ptr if first time */
|
||||
kbufh = nchunk;
|
||||
if (kbufp != NULL) /* point the current to this new one */
|
||||
@ -607,7 +609,7 @@ int c; /* character to insert in the kill buffer */
|
||||
|
||||
/* and now insert the character */
|
||||
kbufp->d_chunk[kused++] = c;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -622,13 +624,13 @@ yank(f, n)
|
||||
register char *sp; /* pointer into string to insert */
|
||||
KILL *kp; /* pointer into kill buffer */
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
/* make sure there is something to yank */
|
||||
if (kbufh == NULL)
|
||||
return(TRUE); /* not an error, just nothing */
|
||||
return (TRUE); /* not an error, just nothing */
|
||||
|
||||
/* for each time.... */
|
||||
while (n--) {
|
||||
|
43
lock.c
43
lock.c
@ -32,41 +32,40 @@ char *fname; /* file to check for a lock */
|
||||
|
||||
/* check to see if that file is already locked here */
|
||||
if (numlocks > 0)
|
||||
for (i=0; i < numlocks; ++i)
|
||||
for (i = 0; i < numlocks; ++i)
|
||||
if (strcmp(fname, lname[i]) == 0)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* if we have a full locking table, bitch and leave */
|
||||
if (numlocks == NLOCKS) {
|
||||
mlwrite("LOCK ERROR: Lock table full");
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
}
|
||||
|
||||
/* next, try to lock it */
|
||||
status = lock(fname);
|
||||
if (status == ABORT) /* file is locked, no override */
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
if (status == FALSE) /* locked, overriden, dont add to table */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* we have now locked it, add it to our table */
|
||||
lname[++numlocks - 1] = (char *)malloc(strlen(fname) + 1);
|
||||
lname[++numlocks - 1] = (char *) malloc(strlen(fname) + 1);
|
||||
if (lname[numlocks - 1] == NULL) { /* malloc failure */
|
||||
undolock(fname); /* free the lock */
|
||||
mlwrite("Cannot lock, out of memory");
|
||||
--numlocks;
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
}
|
||||
|
||||
/* everthing is cool, add it to the table */
|
||||
strcpy(lname[numlocks-1], fname);
|
||||
return(TRUE);
|
||||
strcpy(lname[numlocks - 1], fname);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* lockrel: release all the file locks so others may edit */
|
||||
|
||||
lockrel()
|
||||
|
||||
{
|
||||
register int i; /* loop index */
|
||||
register int status; /* status of locks */
|
||||
@ -74,13 +73,13 @@ lockrel()
|
||||
|
||||
status = TRUE;
|
||||
if (numlocks > 0)
|
||||
for (i=0; i < numlocks; ++i) {
|
||||
for (i = 0; i < numlocks; ++i) {
|
||||
if ((s = unlock(lname[i])) != TRUE)
|
||||
status = s;
|
||||
free(lname[i]);
|
||||
}
|
||||
numlocks = 0;
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/* lock: Check and lock a file from access by others
|
||||
@ -102,12 +101,12 @@ char *fname; /* file name to lock */
|
||||
/* attempt to lock the file */
|
||||
locker = dolock(fname);
|
||||
if (locker == NULL) /* we win */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* file failed...abort */
|
||||
if (strncmp(locker, "LOCK", 4) == 0) {
|
||||
lckerror(locker);
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
}
|
||||
|
||||
/* someone else has it....override? */
|
||||
@ -116,9 +115,9 @@ char *fname; /* file name to lock */
|
||||
strcat(msg, ", override?");
|
||||
status = mlyesno(msg); /* ask them */
|
||||
if (status == TRUE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
else
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
}
|
||||
|
||||
/* unlock: Unlock a file
|
||||
@ -136,15 +135,15 @@ char *fname; /* file to unlock */
|
||||
/* unclock and return */
|
||||
locker = undolock(fname);
|
||||
if (locker == NULL)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* report the error and come back */
|
||||
lckerror(locker);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
lckerror(errstr) /* report a lock error */
|
||||
|
||||
lckerror(errstr)
|
||||
/* report a lock error */
|
||||
char *errstr; /* lock error string to print out */
|
||||
|
||||
{
|
||||
@ -160,7 +159,7 @@ char *errstr; /* lock error string to print out */
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
lckhello() /* dummy function */
|
||||
{
|
||||
lckhello()
|
||||
{ /* dummy function */
|
||||
}
|
||||
#endif
|
||||
|
149
main.c
149
main.c
@ -84,7 +84,7 @@ extern unsigned _stklen = 32766;
|
||||
#include <signal.h>
|
||||
static void emergencyexit();
|
||||
#ifdef SIGWINCH
|
||||
extern void sizesignal();
|
||||
extern void sizesignal();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -122,8 +122,8 @@ char *argv[]; /* argument strings */
|
||||
extern *pathname[]; /* startup file path/name array */
|
||||
int newc;
|
||||
#if PKCODE
|
||||
int (*getbind())();
|
||||
int (*execfunc)(); /* ptr to function to execute */
|
||||
int (*getbind()) ();
|
||||
int (*execfunc) (); /* ptr to function to execute */
|
||||
#endif
|
||||
|
||||
#if PKCODE & VMS
|
||||
@ -204,7 +204,7 @@ char *argv[]; /* argument strings */
|
||||
case 's': /* -s for initial search string */
|
||||
case 'S':
|
||||
searchflag = TRUE;
|
||||
strncpy(pat,&argv[carg][2],NPAT);
|
||||
strncpy(pat, &argv[carg][2], NPAT);
|
||||
break;
|
||||
case 'v': /* -v for View File */
|
||||
case 'V':
|
||||
@ -215,7 +215,7 @@ char *argv[]; /* argument strings */
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (argv[carg][0]== '@') {
|
||||
} else if (argv[carg][0] == '@') {
|
||||
|
||||
/* Process Startup macroes */
|
||||
if (startup(&argv[carg][1]) == TRUE)
|
||||
@ -245,7 +245,7 @@ char *argv[]; /* argument strings */
|
||||
#if CRYPT
|
||||
if (cryptflag) {
|
||||
bp->b_mode |= MDCRYPT;
|
||||
crypt((char *)NULL, 0);
|
||||
crypt((char *) NULL, 0);
|
||||
crypt(ekey, strlen(ekey));
|
||||
strncpy(bp->b_key, ekey, NPAT);
|
||||
}
|
||||
@ -284,9 +284,8 @@ char *argv[]; /* argument strings */
|
||||
if (gotoflag && searchflag) {
|
||||
update(FALSE);
|
||||
mlwrite("(Can not search and goto at the same time!)");
|
||||
}
|
||||
else if (gotoflag) {
|
||||
if (gotoline(TRUE,gline) == FALSE) {
|
||||
} else if (gotoflag) {
|
||||
if (gotoline(TRUE, gline) == FALSE) {
|
||||
update(FALSE);
|
||||
mlwrite("(Bogus goto argument)");
|
||||
}
|
||||
@ -298,37 +297,32 @@ char *argv[]; /* argument strings */
|
||||
/* setup to process commands */
|
||||
lastflag = 0; /* Fake last flags. */
|
||||
|
||||
loop:
|
||||
loop:
|
||||
|
||||
#if CALLED
|
||||
/* if we were called as a subroutine and want to leave, do so */
|
||||
if (eexitflag)
|
||||
return(eexitval);
|
||||
return (eexitval);
|
||||
#endif
|
||||
|
||||
/* execute the "command" macro...normally null */
|
||||
saveflag = lastflag; /* preserve lastflag through this */
|
||||
execute(META|SPEC|'C', FALSE, 1);
|
||||
execute(META | SPEC | 'C', FALSE, 1);
|
||||
lastflag = saveflag;
|
||||
|
||||
#if TYPEAH && PKCODE
|
||||
if (typahead())
|
||||
{
|
||||
if (typahead()) {
|
||||
newc = getcmd();
|
||||
update(FALSE);
|
||||
do
|
||||
{
|
||||
do {
|
||||
if (c == newc && (execfunc = getbind(c)) != NULL
|
||||
&& execfunc != newline
|
||||
&& execfunc != tab)
|
||||
&& execfunc != newline && execfunc != tab)
|
||||
newc = getcmd();
|
||||
else
|
||||
break;
|
||||
} while (typahead());
|
||||
c = newc;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
update(FALSE);
|
||||
c = getcmd();
|
||||
}
|
||||
@ -371,7 +365,7 @@ loop:
|
||||
if ((n == 0) && (mflag == -1)) /* lonely - */
|
||||
mlwrite("Arg:");
|
||||
else
|
||||
mlwrite("Arg: %d",n * mflag);
|
||||
mlwrite("Arg: %d", n * mflag);
|
||||
|
||||
c = getcmd(); /* get the next key */
|
||||
}
|
||||
@ -385,10 +379,11 @@ loop:
|
||||
n = 4; /* with argument of 4 */
|
||||
mflag = 0; /* that can be discarded. */
|
||||
mlwrite("Arg: 4");
|
||||
while ((c=getcmd()) >='0' && c<='9' || c==reptc || c=='-'){
|
||||
while ((c = getcmd()) >= '0' && c <= '9' || c == reptc
|
||||
|| c == '-') {
|
||||
if (c == reptc)
|
||||
if ((n > 0) == ((n*4) > 0))
|
||||
n = n*4;
|
||||
if ((n > 0) == ((n * 4) > 0))
|
||||
n = n * 4;
|
||||
else
|
||||
n = 1;
|
||||
/*
|
||||
@ -410,9 +405,10 @@ loop:
|
||||
n = 0;
|
||||
mflag = 1;
|
||||
}
|
||||
n = 10*n + c - '0';
|
||||
n = 10 * n + c - '0';
|
||||
}
|
||||
mlwrite("Arg: %d", (mflag >=0) ? n : (n ? -n : -1));
|
||||
mlwrite("Arg: %d",
|
||||
(mflag >= 0) ? n : (n ? -n : -1));
|
||||
}
|
||||
/*
|
||||
* Make arguments preceded by a minus sign negative and change
|
||||
@ -445,7 +441,7 @@ char bname[];
|
||||
bp = bfind(bname, TRUE, 0); /* First buffer */
|
||||
blistp = bfind("*List*", TRUE, BFINVS); /* Buffer list buffer */
|
||||
wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window */
|
||||
if (bp==NULL || wp==NULL || blistp==NULL)
|
||||
if (bp == NULL || wp == NULL || blistp == NULL)
|
||||
exit(1);
|
||||
curbp = bp; /* Make this current */
|
||||
wheadp = wp;
|
||||
@ -464,9 +460,9 @@ char bname[];
|
||||
wp->w_fcolor = gfcolor;
|
||||
wp->w_bcolor = gbcolor;
|
||||
#endif
|
||||
wp->w_ntrows = term.t_nrow-1; /* "-1" for mode line. */
|
||||
wp->w_ntrows = term.t_nrow - 1; /* "-1" for mode line. */
|
||||
wp->w_force = 0;
|
||||
wp->w_flag = WFMODE|WFHARD; /* Full. */
|
||||
wp->w_flag = WFMODE | WFHARD; /* Full. */
|
||||
}
|
||||
|
||||
/*
|
||||
@ -478,14 +474,14 @@ char bname[];
|
||||
execute(c, f, n)
|
||||
{
|
||||
register int status;
|
||||
int (*execfunc)(); /* ptr to function to execute */
|
||||
int (*getbind())();
|
||||
int (*execfunc) (); /* ptr to function to execute */
|
||||
int (*getbind()) ();
|
||||
|
||||
/* if the keystroke is a bound function...do it */
|
||||
execfunc = getbind(c);
|
||||
if (execfunc != NULL) {
|
||||
thisflag = 0;
|
||||
status = (*execfunc)(f, n);
|
||||
status = (*execfunc) (f, n);
|
||||
lastflag = thisflag;
|
||||
return (status);
|
||||
}
|
||||
@ -498,25 +494,25 @@ execute(c, f, n)
|
||||
if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 &&
|
||||
n >= 0 && getccol(FALSE) > fillcol &&
|
||||
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
||||
execute(META|SPEC|'W', FALSE, 1);
|
||||
execute(META | SPEC | 'W', FALSE, 1);
|
||||
|
||||
#if PKCODE
|
||||
if ((c>=0x20 && c<=0x7E) /* Self inserting. */
|
||||
if ((c >= 0x20 && c <= 0x7E) /* Self inserting. */
|
||||
#if IBMPC
|
||||
|| (c>=0x80 && c<=0xFE)) {
|
||||
|| (c >= 0x80 && c <= 0xFE)) {
|
||||
#else
|
||||
#if VMS || BSD || USG /* 8BIT P.K. */
|
||||
|| (c>=0xA0 && c<=0xFE)) {
|
||||
|| (c >= 0xA0 && c <= 0xFE)) {
|
||||
#else
|
||||
) {
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
if ((c>=0x20 && c<=0xFF)) { /* Self inserting. */
|
||||
if ((c >= 0x20 && c <= 0xFF)) { /* Self inserting. */
|
||||
#endif
|
||||
if (n <= 0) { /* Fenceposts. */
|
||||
lastflag = 0;
|
||||
return (n<0 ? FALSE : TRUE);
|
||||
return (n < 0 ? FALSE : TRUE);
|
||||
}
|
||||
thisflag = 0; /* For the future. */
|
||||
|
||||
@ -576,24 +572,24 @@ quickexit(f, n)
|
||||
|
||||
bp = bheadp;
|
||||
while (bp != NULL) {
|
||||
if ((bp->b_flag&BFCHG) != 0 /* Changed. */
|
||||
&& (bp->b_flag&BFTRUNC) == 0 /* Not truncated P.K. */
|
||||
&& (bp->b_flag&BFINVS) == 0) { /* Real. */
|
||||
if ((bp->b_flag & BFCHG) != 0 /* Changed. */
|
||||
&& (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */
|
||||
&& (bp->b_flag & BFINVS) == 0) { /* Real. */
|
||||
curbp = bp; /* make that buffer cur */
|
||||
mlwrite("(Saving %s)",bp->b_fname);
|
||||
mlwrite("(Saving %s)", bp->b_fname);
|
||||
#if PKCODE
|
||||
#else
|
||||
mlwrite("\n");
|
||||
#endif
|
||||
if ((status = filesave(f, n)) != TRUE) {
|
||||
curbp = oldcb; /* restore curbp */
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
bp = bp->b_bufp; /* on to the next buffer */
|
||||
}
|
||||
quit(f, n); /* conditionally quit */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static void emergencyexit(signr)
|
||||
@ -614,7 +610,8 @@ quit(f, n)
|
||||
if (f != FALSE /* Argument forces it. */
|
||||
|| anycb() == FALSE /* All buffers clean. */
|
||||
/* User says it's OK. */
|
||||
|| (s=mlyesno("Modified buffers exist. Leave anyway")) == TRUE) {
|
||||
|| (s =
|
||||
mlyesno("Modified buffers exist. Leave anyway")) == TRUE) {
|
||||
#if (FILOCK && BSD) || SVR4
|
||||
if (lockrel() != TRUE) {
|
||||
TTputc('\n');
|
||||
@ -631,7 +628,7 @@ quit(f, n)
|
||||
exit(GOOD);
|
||||
}
|
||||
mlwrite("");
|
||||
return(s);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -643,7 +640,7 @@ ctlxlp(f, n)
|
||||
{
|
||||
if (kbdmode != STOP) {
|
||||
mlwrite("%%Macro already active");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
mlwrite("(Start macro)");
|
||||
kbdptr = &kbdm[0];
|
||||
@ -660,13 +657,13 @@ ctlxrp(f, n)
|
||||
{
|
||||
if (kbdmode == STOP) {
|
||||
mlwrite("%%Macro not active");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
if (kbdmode == RECORD) {
|
||||
mlwrite("(End macro)");
|
||||
kbdmode = STOP;
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -678,14 +675,14 @@ ctlxe(f, n)
|
||||
{
|
||||
if (kbdmode != STOP) {
|
||||
mlwrite("%%Macro already active");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
if (n <= 0)
|
||||
return (TRUE);
|
||||
kbdrep = n; /* remember how many times to execute */
|
||||
kbdmode = PLAY; /* start us in play mode */
|
||||
kbdptr = &kbdm[0]; /* at the beginning */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -698,43 +695,40 @@ ctrlg(f, n)
|
||||
TTbeep();
|
||||
kbdmode = STOP;
|
||||
mlwrite("(Aborted)");
|
||||
return(ABORT);
|
||||
return (ABORT);
|
||||
}
|
||||
|
||||
/* tell the user that this command is illegal while we are in
|
||||
VIEW (read-only) mode */
|
||||
|
||||
rdonly()
|
||||
|
||||
{
|
||||
TTbeep();
|
||||
mlwrite("(Key illegal in VIEW mode)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
resterr()
|
||||
|
||||
{
|
||||
TTbeep();
|
||||
mlwrite("(That command is RESTRICTED)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
nullproc() /* user function that does NOTHING */
|
||||
|
||||
{
|
||||
nullproc()
|
||||
{ /* user function that does NOTHING */
|
||||
}
|
||||
|
||||
meta() /* dummy function for binding to meta prefix */
|
||||
{
|
||||
meta()
|
||||
{ /* dummy function for binding to meta prefix */
|
||||
}
|
||||
|
||||
cex() /* dummy function for binding to control-x prefix */
|
||||
{
|
||||
cex()
|
||||
{ /* dummy function for binding to control-x prefix */
|
||||
}
|
||||
|
||||
unarg() /* dummy function for binding to universal-argument */
|
||||
{
|
||||
unarg()
|
||||
{ /* dummy function for binding to universal-argument */
|
||||
}
|
||||
|
||||
/***** Compiler specific Library functions ****/
|
||||
@ -764,7 +758,7 @@ int maxlen; /* maximum length */
|
||||
*dptr = 0; /* orig */
|
||||
/* if (maxlen > 0)
|
||||
*dptr = 0; */
|
||||
return(dst);
|
||||
return (dst);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -781,8 +775,8 @@ int maxlen; /* maximum length */
|
||||
#undef malloc
|
||||
#undef free
|
||||
|
||||
char *allocate(nbytes) /* allocate nbytes and track */
|
||||
|
||||
char *allocate(nbytes)
|
||||
/* allocate nbytes and track */
|
||||
unsigned nbytes; /* # of bytes to allocate */
|
||||
|
||||
{
|
||||
@ -797,11 +791,11 @@ unsigned nbytes; /* # of bytes to allocate */
|
||||
#endif
|
||||
}
|
||||
|
||||
return(mp);
|
||||
return (mp);
|
||||
}
|
||||
|
||||
release(mp) /* release malloced memory and track */
|
||||
|
||||
release(mp)
|
||||
/* release malloced memory and track */
|
||||
char *mp; /* chunk of RAM to release */
|
||||
|
||||
{
|
||||
@ -809,8 +803,8 @@ char *mp; /* chunk of RAM to release */
|
||||
|
||||
if (mp) {
|
||||
/* update amount of ram currently malloced */
|
||||
lp = ((unsigned *)mp) - 1;
|
||||
envram -= (long)*lp - 2;
|
||||
lp = ((unsigned *) mp) - 1;
|
||||
envram -= (long) *lp - 2;
|
||||
free(mp);
|
||||
#if RAMSHOW
|
||||
dspram();
|
||||
@ -819,9 +813,8 @@ char *mp; /* chunk of RAM to release */
|
||||
}
|
||||
|
||||
#if RAMSHOW
|
||||
dspram() /* display the amount of RAM currently malloced */
|
||||
|
||||
{
|
||||
dspram()
|
||||
{ /* display the amount of RAM currently malloced */
|
||||
char mbuf[20];
|
||||
char *sp;
|
||||
|
||||
@ -883,7 +876,7 @@ int status; /* return status of emacs */
|
||||
#if CALLED
|
||||
eexitflag = TRUE; /* flag a program exit */
|
||||
eexitval = status;
|
||||
return(status);
|
||||
return (status);
|
||||
#else
|
||||
#undef exit
|
||||
exit(status);
|
||||
|
25
pklock.c
25
pklock.c
@ -26,7 +26,7 @@
|
||||
|
||||
int gethostname(char *name, int namelen)
|
||||
{
|
||||
return(sysinfo(SI_HOSTNAME, name, namelen));
|
||||
return (sysinfo(SI_HOSTNAME, name, namelen));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -40,10 +40,10 @@ int gethostname(char *name, int namelen)
|
||||
*
|
||||
*********************/
|
||||
char *dolock(fname)
|
||||
char *fname;
|
||||
char *fname;
|
||||
{
|
||||
int fd, lk, n;
|
||||
static char lname[MAXLOCK], locker[MAXNAME+1];
|
||||
static char lname[MAXLOCK], locker[MAXNAME + 1];
|
||||
int mask;
|
||||
struct stat sbuf;
|
||||
|
||||
@ -59,17 +59,16 @@ char *dolock(fname)
|
||||
if (stat(lname, &sbuf) == 0)
|
||||
#endif
|
||||
#if defined(S_ISREG)
|
||||
if (! S_ISREG(sbuf.st_mode))
|
||||
if (!S_ISREG(sbuf.st_mode))
|
||||
#else
|
||||
if (! (((sbuf.st_mode) & 070000) == 0)) /* SysV R2 */
|
||||
if (!(((sbuf.st_mode) & 070000) == 0)) /* SysV R2 */
|
||||
#endif
|
||||
return "LOCK ERROR: not a regular file";
|
||||
|
||||
mask = umask(0);
|
||||
fd = open(lname, O_RDWR | O_CREAT, 0666);
|
||||
umask(mask);
|
||||
if (fd < 0)
|
||||
{
|
||||
if (fd < 0) {
|
||||
if (errno == EACCES)
|
||||
return NULL;
|
||||
#ifdef EROFS
|
||||
@ -78,13 +77,12 @@ char *dolock(fname)
|
||||
#endif
|
||||
return "LOCK ERROR: cannot access lock file";
|
||||
}
|
||||
if ((n = read(fd, locker, MAXNAME)) < 1)
|
||||
{
|
||||
if ((n = read(fd, locker, MAXNAME)) < 1) {
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
/* strcpy(locker, getlogin()); */
|
||||
cuserid(locker);
|
||||
strcat(locker+strlen(locker), "@");
|
||||
gethostname(locker+strlen(locker), 64);
|
||||
strcat(locker + strlen(locker), "@");
|
||||
gethostname(locker + strlen(locker), 64);
|
||||
write(fd, locker, strlen(locker));
|
||||
close(fd);
|
||||
return NULL;
|
||||
@ -104,14 +102,13 @@ char *dolock(fname)
|
||||
*********************/
|
||||
|
||||
char *undolock(fname)
|
||||
char *fname;
|
||||
char *fname;
|
||||
{
|
||||
int fd, lk;
|
||||
static char lname[MAXLOCK];
|
||||
|
||||
strcat(strcpy(lname, fname), ".lock~");
|
||||
if (unlink(lname) != 0)
|
||||
{
|
||||
if (unlink(lname) != 0) {
|
||||
if (errno == EACCES || errno == ENOENT)
|
||||
return NULL;
|
||||
#ifdef EROFS
|
||||
|
13
posix.c
13
posix.c
@ -53,12 +53,13 @@ ttopen()
|
||||
| INPCK | INLCR | IGNCR | ICRNL);
|
||||
|
||||
/* raw CR/NR etc output handling */
|
||||
ntermios.c_oflag &= ~(OPOST | ONLCR | OLCUC | OCRNL | ONOCR | ONLRET);
|
||||
ntermios.c_oflag &=
|
||||
~(OPOST | ONLCR | OLCUC | OCRNL | ONOCR | ONLRET);
|
||||
|
||||
/* No signal handling, no echo etc */
|
||||
ntermios.c_lflag &= ~(ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK
|
||||
| ECHONL | NOFLSH | TOSTOP | ECHOCTL | ECHOPRT
|
||||
| ECHOKE | FLUSHO | PENDIN | IEXTEN);
|
||||
| ECHONL | NOFLSH | TOSTOP | ECHOCTL |
|
||||
ECHOPRT | ECHOKE | FLUSHO | PENDIN | IEXTEN);
|
||||
|
||||
/* one character, no timeout */
|
||||
ntermios.c_cc[VMIN] = 1;
|
||||
@ -71,7 +72,7 @@ ttopen()
|
||||
*/
|
||||
setbuffer(stdout, &tobuf[0], TBUFSIZ);
|
||||
|
||||
kbdflgs = fcntl( 0, F_GETFL, 0 );
|
||||
kbdflgs = fcntl(0, F_GETFL, 0);
|
||||
kbdpoll = FALSE;
|
||||
|
||||
/* on all screens we are not sure of the initial position
|
||||
@ -136,7 +137,7 @@ ttflush()
|
||||
*/
|
||||
ttgetc()
|
||||
{
|
||||
return(255 & fgetc(stdin)); /* 8BIT P.K. */
|
||||
return (255 & fgetc(stdin)); /* 8BIT P.K. */
|
||||
}
|
||||
|
||||
/* typahead: Check to see if any characters are already in the
|
||||
@ -148,7 +149,7 @@ typahead()
|
||||
int x; /* holds # of pending chars */
|
||||
|
||||
#ifdef FIONREAD
|
||||
if (ioctl(0,FIONREAD,&x) < 0)
|
||||
if (ioctl(0, FIONREAD, &x) < 0)
|
||||
x = 0;
|
||||
#else
|
||||
x = 0;
|
||||
|
375
random.c
375
random.c
@ -18,8 +18,8 @@ int tabsize; /* Tab size (0: use real tabs) */
|
||||
setfillcol(f, n)
|
||||
{
|
||||
fillcol = n;
|
||||
mlwrite("(Fill column is %d)",n);
|
||||
return(TRUE);
|
||||
mlwrite("(Fill column is %d)", n);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -94,12 +94,12 @@ showcpos(f, n)
|
||||
|
||||
ratio = 0; /* Ratio before dot. */
|
||||
if (numchars != 0)
|
||||
ratio = (100L*predchars) / numchars;
|
||||
ratio = (100L * predchars) / numchars;
|
||||
|
||||
/* summarize and report the info */
|
||||
#if PKCODE
|
||||
pk_mlrec.pk_clin = predlines+1;
|
||||
pk_mlrec.pk_tlin = numlines+1;
|
||||
pk_mlrec.pk_clin = predlines + 1;
|
||||
pk_mlrec.pk_tlin = numlines + 1;
|
||||
pk_mlrec.pk_ccol = col;
|
||||
pk_mlrec.pk_tcol = ecol;
|
||||
pk_mlrec.pk_cchr = predchars;
|
||||
@ -110,15 +110,14 @@ showcpos(f, n)
|
||||
&pk_mlrec);
|
||||
#else
|
||||
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x",
|
||||
predlines+1, numlines+1, col, ecol,
|
||||
predlines + 1, numlines + 1, col, ecol,
|
||||
predchars, numchars, ratio, curchar);
|
||||
#endif
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
getcline() /* get the current line number */
|
||||
|
||||
{
|
||||
getcline()
|
||||
{ /* get the current line number */
|
||||
register LINE *lp; /* current line */
|
||||
register int numlines; /* # of lines before point */
|
||||
|
||||
@ -136,7 +135,7 @@ getcline() /* get the current line number */
|
||||
}
|
||||
|
||||
/* and return the resulting count */
|
||||
return(numlines + 1);
|
||||
return (numlines + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -147,17 +146,17 @@ int bflg;
|
||||
{
|
||||
register int c, i, col;
|
||||
col = 0;
|
||||
for (i=0; i<curwp->w_doto; ++i) {
|
||||
for (i = 0; i < curwp->w_doto; ++i) {
|
||||
c = lgetc(curwp->w_dotp, i);
|
||||
if (c!=' ' && c!='\t' && bflg)
|
||||
if (c != ' ' && c != '\t' && bflg)
|
||||
break;
|
||||
if (c == '\t')
|
||||
col |= tabmask;
|
||||
else if (c<0x20 || c==0x7F)
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
++col;
|
||||
++col;
|
||||
}
|
||||
return(col);
|
||||
return (col);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -186,7 +185,7 @@ int pos; /* position to set cursor */
|
||||
c = lgetc(curwp->w_dotp, i);
|
||||
if (c == '\t')
|
||||
col |= tabmask;
|
||||
else if (c<0x20 || c==0x7F)
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
++col;
|
||||
++col;
|
||||
}
|
||||
@ -195,7 +194,7 @@ int pos; /* position to set cursor */
|
||||
curwp->w_doto = i;
|
||||
|
||||
/* and tell weather we made it */
|
||||
return(col >= pos);
|
||||
return (col >= pos);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -212,18 +211,18 @@ twiddle(f, n)
|
||||
register int cl;
|
||||
register int cr;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
dotp = curwp->w_dotp;
|
||||
doto = curwp->w_doto;
|
||||
if (doto==llength(dotp) && --doto<0)
|
||||
if (doto == llength(dotp) && --doto < 0)
|
||||
return (FALSE);
|
||||
cr = lgetc(dotp, doto);
|
||||
if (--doto < 0)
|
||||
return (FALSE);
|
||||
cl = lgetc(dotp, doto);
|
||||
lputc(dotp, doto+0, cr);
|
||||
lputc(dotp, doto+1, cl);
|
||||
lputc(dotp, doto + 0, cr);
|
||||
lputc(dotp, doto + 1, cl);
|
||||
lchange(WFEDIT);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -239,8 +238,8 @@ quote(f, n)
|
||||
register int s;
|
||||
register int c;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
c = tgetc();
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
@ -249,7 +248,7 @@ quote(f, n)
|
||||
if (c == '\n') {
|
||||
do {
|
||||
s = lnewline();
|
||||
} while (s==TRUE && --n);
|
||||
} while (s == TRUE && --n);
|
||||
return (s);
|
||||
}
|
||||
return (linsert(n, c));
|
||||
@ -268,23 +267,23 @@ tab(f, n)
|
||||
return (FALSE);
|
||||
if (n == 0 || n > 1) {
|
||||
tabsize = n;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
if (! tabsize)
|
||||
return(linsert(1, '\t'));
|
||||
return(linsert(tabsize - (getccol(FALSE) % tabsize), ' '));
|
||||
if (!tabsize)
|
||||
return (linsert(1, '\t'));
|
||||
return (linsert(tabsize - (getccol(FALSE) % tabsize), ' '));
|
||||
}
|
||||
|
||||
#if AEDIT
|
||||
detab(f, n) /* change tabs to spaces */
|
||||
|
||||
int f,n; /* default flag and numeric repeat count */
|
||||
detab(f, n)
|
||||
/* change tabs to spaces */
|
||||
int f, n; /* default flag and numeric repeat count */
|
||||
|
||||
{
|
||||
register int inc; /* increment to next line [sgn(n)] */
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
@ -299,7 +298,9 @@ int f,n; /* default flag and numeric repeat count */
|
||||
/* if we have a tab */
|
||||
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
|
||||
ldelete(1L, FALSE);
|
||||
insspace(TRUE, (tabmask+1) - (curwp->w_doto & tabmask));
|
||||
insspace(TRUE,
|
||||
(tabmask + 1) -
|
||||
(curwp->w_doto & tabmask));
|
||||
}
|
||||
forwchar(FALSE, 1);
|
||||
}
|
||||
@ -311,12 +312,12 @@ int f,n; /* default flag and numeric repeat count */
|
||||
curwp->w_doto = 0; /* to the begining of the line */
|
||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||
lchange(WFEDIT); /* yes, we have made at least an edit */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
entab(f, n) /* change spaces to tabs where posible */
|
||||
|
||||
int f,n; /* default flag and numeric repeat count */
|
||||
entab(f, n)
|
||||
/* change spaces to tabs where posible */
|
||||
int f, n; /* default flag and numeric repeat count */
|
||||
|
||||
{
|
||||
register int inc; /* increment to next line [sgn(n)] */
|
||||
@ -324,8 +325,8 @@ int f,n; /* default flag and numeric repeat count */
|
||||
register int ccol; /* current cursor column */
|
||||
register char cchar; /* current character */
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
@ -347,7 +348,8 @@ int f,n; /* default flag and numeric repeat count */
|
||||
/* there is a bug here dealing with mixed space/tabed
|
||||
lines.......it will get fixed */
|
||||
backchar(TRUE, ccol - fspace);
|
||||
ldelete((long)(ccol - fspace), FALSE);
|
||||
ldelete((long) (ccol - fspace),
|
||||
FALSE);
|
||||
linsert(1, '\t');
|
||||
fspace = -1;
|
||||
}
|
||||
@ -381,12 +383,12 @@ int f,n; /* default flag and numeric repeat count */
|
||||
curwp->w_doto = 0; /* to the begining of the line */
|
||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||
lchange(WFEDIT); /* yes, we have made at least an edit */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
trim(f, n) /* trim trailing whitespace from the point to eol */
|
||||
|
||||
int f,n; /* default flag and numeric repeat count */
|
||||
trim(f, n)
|
||||
/* trim trailing whitespace from the point to eol */
|
||||
int f, n; /* default flag and numeric repeat count */
|
||||
|
||||
{
|
||||
register LINE *lp; /* current line pointer */
|
||||
@ -394,8 +396,8 @@ int f,n; /* default flag and numeric repeat count */
|
||||
register int length; /* current length */
|
||||
register int inc; /* increment to next line [sgn(n)] */
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
@ -409,8 +411,8 @@ int f,n; /* default flag and numeric repeat count */
|
||||
|
||||
/* trim the current line */
|
||||
while (length > offset) {
|
||||
if (lgetc(lp, length-1) != ' ' &&
|
||||
lgetc(lp, length-1) != '\t')
|
||||
if (lgetc(lp, length - 1) != ' ' &&
|
||||
lgetc(lp, length - 1) != '\t')
|
||||
break;
|
||||
length--;
|
||||
}
|
||||
@ -422,7 +424,7 @@ int f,n; /* default flag and numeric repeat count */
|
||||
}
|
||||
lchange(WFEDIT);
|
||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -436,8 +438,8 @@ openline(f, n)
|
||||
register int i;
|
||||
register int s;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
if (n == 0)
|
||||
@ -445,7 +447,7 @@ openline(f, n)
|
||||
i = n; /* Insert newlines. */
|
||||
do {
|
||||
s = lnewline();
|
||||
} while (s==TRUE && --i);
|
||||
} while (s == TRUE && --i);
|
||||
if (s == TRUE) /* Then back up overtop */
|
||||
s = backchar(f, n); /* of them all. */
|
||||
return (s);
|
||||
@ -459,15 +461,15 @@ newline(f, n)
|
||||
{
|
||||
register int s;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
|
||||
/* if we are in C mode and this is a default <NL> */
|
||||
if (n == 1 && (curbp->b_mode & MDCMOD) &&
|
||||
curwp->w_dotp != curbp->b_linep)
|
||||
return(cinsert());
|
||||
return (cinsert());
|
||||
|
||||
/*
|
||||
* If a newline was typed, fill column is defined, the argument is non-
|
||||
@ -477,11 +479,11 @@ newline(f, n)
|
||||
if ((curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 &&
|
||||
getccol(FALSE) > fillcol &&
|
||||
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
||||
execute(META|SPEC|'W', FALSE, 1);
|
||||
execute(META | SPEC | 'W', FALSE, 1);
|
||||
|
||||
/* insert some lines */
|
||||
while (n--) {
|
||||
if ((s=lnewline()) != TRUE)
|
||||
if ((s = lnewline()) != TRUE)
|
||||
return (s);
|
||||
#if SCROLLCODE
|
||||
curwp->w_flag |= WFINS;
|
||||
@ -490,9 +492,8 @@ newline(f, n)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
cinsert() /* insert a newline and indentation for C */
|
||||
|
||||
{
|
||||
cinsert()
|
||||
{ /* insert a newline and indentation for C */
|
||||
register char *cptr; /* string pointer into text to copy */
|
||||
register int tptr; /* index to scan into line */
|
||||
register int bracef; /* was there a brace at the end of line? */
|
||||
@ -517,7 +518,7 @@ cinsert() /* insert a newline and indentation for C */
|
||||
|
||||
/* put in the newline */
|
||||
if (lnewline() == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* and the saved indentation */
|
||||
linstr(ichar);
|
||||
@ -529,12 +530,12 @@ cinsert() /* insert a newline and indentation for C */
|
||||
#if SCROLLCODE
|
||||
curwp->w_flag |= WFINS;
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if NBRACE
|
||||
insbrace(n, c) /* insert a brace into the text here...we are in CMODE */
|
||||
|
||||
insbrace(n, c)
|
||||
/* insert a brace into the text here...we are in CMODE */
|
||||
int n; /* repeat count */
|
||||
int c; /* brace to insert (always } for now) */
|
||||
|
||||
@ -553,21 +554,29 @@ int c; /* brace to insert (always } for now) */
|
||||
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||
ch = lgetc(curwp->w_dotp, i);
|
||||
if (ch != ' ' && ch != '\t')
|
||||
return(linsert(n, c));
|
||||
return (linsert(n, c));
|
||||
}
|
||||
|
||||
/* chercher le caractere oppose correspondant */
|
||||
switch (c) {
|
||||
case '}': oc = '{'; break;
|
||||
case ']': oc = '['; break;
|
||||
case ')': oc = '('; break;
|
||||
default: return(FALSE);
|
||||
case '}':
|
||||
oc = '{';
|
||||
break;
|
||||
case ']':
|
||||
oc = '[';
|
||||
break;
|
||||
case ')':
|
||||
oc = '(';
|
||||
break;
|
||||
default:
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
oldlp = curwp->w_dotp;
|
||||
oldoff = curwp->w_doto;
|
||||
|
||||
count = 1; backchar(FALSE, 1);
|
||||
count = 1;
|
||||
backchar(FALSE, 1);
|
||||
|
||||
while (count > 0) {
|
||||
if (curwp->w_doto == llength(curwp->w_dotp))
|
||||
@ -575,8 +584,10 @@ int c; /* brace to insert (always } for now) */
|
||||
else
|
||||
ch = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
|
||||
if (ch == c) ++count;
|
||||
if (ch == oc) --count;
|
||||
if (ch == c)
|
||||
++count;
|
||||
if (ch == oc)
|
||||
--count;
|
||||
|
||||
backchar(FALSE, 1);
|
||||
if (boundry(curwp->w_dotp, curwp->w_doto, REVERSE))
|
||||
@ -586,12 +597,13 @@ int c; /* brace to insert (always } for now) */
|
||||
if (count != 0) { /* no match */
|
||||
curwp->w_dotp = oldlp;
|
||||
curwp->w_doto = oldoff;
|
||||
return(linsert(n, c));
|
||||
return (linsert(n, c));
|
||||
}
|
||||
|
||||
curwp->w_doto = 0; /* debut de ligne */
|
||||
/* aller au debut de la ligne apres la tabulation */
|
||||
while ((ch = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ' || ch == '\t')
|
||||
while ((ch = lgetc(curwp->w_dotp, curwp->w_doto)) == ' '
|
||||
|| ch == '\t')
|
||||
forwchar(FALSE, 1);
|
||||
|
||||
/* delete back first */
|
||||
@ -605,17 +617,17 @@ int c; /* brace to insert (always } for now) */
|
||||
backdel(FALSE, 1);
|
||||
else { /* on doit en inserer */
|
||||
while (target - getccol(FALSE) >= 8)
|
||||
linsert(1,'\t');
|
||||
linsert(1, '\t');
|
||||
linsert(target - getccol(FALSE), ' ');
|
||||
}
|
||||
}
|
||||
|
||||
/* and insert the required brace(s) */
|
||||
return(linsert(n, c));
|
||||
return (linsert(n, c));
|
||||
}
|
||||
#else
|
||||
insbrace(n, c) /* insert a brace into the text here...we are in CMODE */
|
||||
|
||||
insbrace(n, c)
|
||||
/* insert a brace into the text here...we are in CMODE */
|
||||
int n; /* repeat count */
|
||||
int c; /* brace to insert (always { for now) */
|
||||
|
||||
@ -626,13 +638,13 @@ int c; /* brace to insert (always { for now) */
|
||||
|
||||
/* if we are at the beginning of the line, no go */
|
||||
if (curwp->w_doto == 0)
|
||||
return(linsert(n,c));
|
||||
return (linsert(n, c));
|
||||
|
||||
/* scan to see if all space before this is white space */
|
||||
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||
ch = lgetc(curwp->w_dotp, i);
|
||||
if (ch != ' ' && ch != '\t')
|
||||
return(linsert(n, c));
|
||||
return (linsert(n, c));
|
||||
}
|
||||
|
||||
/* delete back first */
|
||||
@ -643,25 +655,24 @@ int c; /* brace to insert (always { for now) */
|
||||
backdel(FALSE, 1);
|
||||
|
||||
/* and insert the required brace(s) */
|
||||
return(linsert(n, c));
|
||||
return (linsert(n, c));
|
||||
}
|
||||
#endif
|
||||
|
||||
inspound() /* insert a # into the text here...we are in CMODE */
|
||||
|
||||
{
|
||||
inspound()
|
||||
{ /* insert a # into the text here...we are in CMODE */
|
||||
register int ch; /* last character before input */
|
||||
register int i;
|
||||
|
||||
/* if we are at the beginning of the line, no go */
|
||||
if (curwp->w_doto == 0)
|
||||
return(linsert(1,'#'));
|
||||
return (linsert(1, '#'));
|
||||
|
||||
/* scan to see if all space before this is white space */
|
||||
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||
ch = lgetc(curwp->w_dotp, i);
|
||||
if (ch != ' ' && ch != '\t')
|
||||
return(linsert(1, '#'));
|
||||
return (linsert(1, '#'));
|
||||
}
|
||||
|
||||
/* delete back first */
|
||||
@ -669,7 +680,7 @@ inspound() /* insert a # into the text here...we are in CMODE */
|
||||
backdel(FALSE, 1);
|
||||
|
||||
/* and insert the required pound */
|
||||
return(linsert(1, '#'));
|
||||
return (linsert(1, '#'));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -686,14 +697,14 @@ deblank(f, n)
|
||||
register LINE *lp2;
|
||||
long nld;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
lp1 = curwp->w_dotp;
|
||||
while (llength(lp1)==0 && (lp2=lback(lp1))!=curbp->b_linep)
|
||||
while (llength(lp1) == 0 && (lp2 = lback(lp1)) != curbp->b_linep)
|
||||
lp1 = lp2;
|
||||
lp2 = lp1;
|
||||
nld = 0;
|
||||
while ((lp2=lforw(lp2))!=curbp->b_linep && llength(lp2)==0)
|
||||
while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0)
|
||||
++nld;
|
||||
if (nld == 0)
|
||||
return (TRUE);
|
||||
@ -716,23 +727,23 @@ indent(f, n)
|
||||
register int c;
|
||||
register int i;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
while (n--) {
|
||||
nicol = 0;
|
||||
for (i=0; i<llength(curwp->w_dotp); ++i) {
|
||||
for (i = 0; i < llength(curwp->w_dotp); ++i) {
|
||||
c = lgetc(curwp->w_dotp, i);
|
||||
if (c!=' ' && c!='\t')
|
||||
if (c != ' ' && c != '\t')
|
||||
break;
|
||||
if (c == '\t')
|
||||
nicol |= tabmask;
|
||||
++nicol;
|
||||
}
|
||||
if (lnewline() == FALSE
|
||||
|| ((i=nicol/8)!=0 && linsert(i, '\t')==FALSE)
|
||||
|| ((i=nicol%8)!=0 && linsert(i, ' ')==FALSE))
|
||||
|| ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE)
|
||||
|| ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
@ -746,16 +757,16 @@ indent(f, n)
|
||||
*/
|
||||
forwdel(f, n)
|
||||
{
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (backdel(f, -n));
|
||||
if (f != FALSE) { /* Really a kill. */
|
||||
if ((lastflag&CFKILL) == 0)
|
||||
if ((lastflag & CFKILL) == 0)
|
||||
kdelete();
|
||||
thisflag |= CFKILL;
|
||||
}
|
||||
return (ldelete((long)n, f));
|
||||
return (ldelete((long) n, f));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -768,17 +779,17 @@ backdel(f, n)
|
||||
{
|
||||
register int s;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (forwdel(f, -n));
|
||||
if (f != FALSE) { /* Really a kill. */
|
||||
if ((lastflag&CFKILL) == 0)
|
||||
if ((lastflag & CFKILL) == 0)
|
||||
kdelete();
|
||||
thisflag |= CFKILL;
|
||||
}
|
||||
if ((s=backchar(f, n)) == TRUE)
|
||||
s = ldelete((long)n, f);
|
||||
if ((s = backchar(f, n)) == TRUE)
|
||||
s = ldelete((long) n, f);
|
||||
return (s);
|
||||
}
|
||||
|
||||
@ -795,36 +806,36 @@ killtext(f, n)
|
||||
register LINE *nextp;
|
||||
long chunk;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if ((lastflag&CFKILL) == 0) /* Clear kill buffer if */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */
|
||||
kdelete(); /* last wasn't a kill. */
|
||||
thisflag |= CFKILL;
|
||||
if (f == FALSE) {
|
||||
chunk = llength(curwp->w_dotp)-curwp->w_doto;
|
||||
chunk = llength(curwp->w_dotp) - curwp->w_doto;
|
||||
if (chunk == 0)
|
||||
chunk = 1;
|
||||
} else if (n == 0) {
|
||||
chunk = curwp->w_doto;
|
||||
curwp->w_doto = 0;
|
||||
} else if (n > 0) {
|
||||
chunk = llength(curwp->w_dotp)-curwp->w_doto+1;
|
||||
chunk = llength(curwp->w_dotp) - curwp->w_doto + 1;
|
||||
nextp = lforw(curwp->w_dotp);
|
||||
while (--n) {
|
||||
if (nextp == curbp->b_linep)
|
||||
return (FALSE);
|
||||
chunk += llength(nextp)+1;
|
||||
chunk += llength(nextp) + 1;
|
||||
nextp = lforw(nextp);
|
||||
}
|
||||
} else {
|
||||
mlwrite("neg kill");
|
||||
return (FALSE);
|
||||
}
|
||||
return(ldelete(chunk, TRUE));
|
||||
return (ldelete(chunk, TRUE));
|
||||
}
|
||||
|
||||
setmode(f, n) /* prompt and set an editor mode */
|
||||
|
||||
setmode(f, n)
|
||||
/* prompt and set an editor mode */
|
||||
int f, n; /* default and argument */
|
||||
|
||||
{
|
||||
@ -835,8 +846,8 @@ int f, n; /* default and argument */
|
||||
#endif
|
||||
}
|
||||
|
||||
delmode(f, n) /* prompt and delete an editor mode */
|
||||
|
||||
delmode(f, n)
|
||||
/* prompt and delete an editor mode */
|
||||
int f, n; /* default and argument */
|
||||
|
||||
{
|
||||
@ -847,8 +858,8 @@ int f, n; /* default and argument */
|
||||
#endif
|
||||
}
|
||||
|
||||
setgmode(f, n) /* prompt and set a global editor mode */
|
||||
|
||||
setgmode(f, n)
|
||||
/* prompt and set a global editor mode */
|
||||
int f, n; /* default and argument */
|
||||
|
||||
{
|
||||
@ -859,8 +870,8 @@ int f, n; /* default and argument */
|
||||
#endif
|
||||
}
|
||||
|
||||
delgmode(f, n) /* prompt and delete a global editor mode */
|
||||
|
||||
delgmode(f, n)
|
||||
/* prompt and delete a global editor mode */
|
||||
int f, n; /* default and argument */
|
||||
|
||||
{
|
||||
@ -871,8 +882,8 @@ int f, n; /* default and argument */
|
||||
#endif
|
||||
}
|
||||
|
||||
adjustmode(kind, global) /* change the editor mode status */
|
||||
|
||||
adjustmode(kind, global)
|
||||
/* change the editor mode status */
|
||||
int kind; /* true = set, false = delete */
|
||||
int global; /* true = global flag, false = current buffer flag */
|
||||
{
|
||||
@ -887,9 +898,9 @@ int global; /* true = global flag, false = current buffer flag */
|
||||
|
||||
/* build the proper prompt string */
|
||||
if (global)
|
||||
strcpy(prompt,"Global mode to ");
|
||||
strcpy(prompt, "Global mode to ");
|
||||
else
|
||||
strcpy(prompt,"Mode to ");
|
||||
strcpy(prompt, "Mode to ");
|
||||
|
||||
if (kind == TRUE)
|
||||
strcat(prompt, "add: ");
|
||||
@ -900,7 +911,7 @@ int global; /* true = global flag, false = current buffer flag */
|
||||
|
||||
status = mlreply(prompt, cbuf, NPAT - 1);
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
/* make it uppercase */
|
||||
|
||||
@ -916,24 +927,21 @@ int global; /* true = global flag, false = current buffer flag */
|
||||
|
||||
/* test it first against the colors we know */
|
||||
#if PKCODE & IBMPC
|
||||
for (i=0; i<=NCOLORS; i++) {
|
||||
for (i = 0; i <= NCOLORS; i++) {
|
||||
#else
|
||||
for (i=0; i<NCOLORS; i++) {
|
||||
for (i = 0; i < NCOLORS; i++) {
|
||||
#endif
|
||||
if (strcmp(cbuf, cname[i]) == 0) {
|
||||
/* finding the match, we set the color */
|
||||
#if COLOR
|
||||
if (uflag)
|
||||
{
|
||||
if (uflag) {
|
||||
if (global)
|
||||
gfcolor = i;
|
||||
#if PKCODE == 0
|
||||
else
|
||||
#endif
|
||||
curwp->w_fcolor = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (global)
|
||||
gbcolor = i;
|
||||
#if PKCODE == 0
|
||||
@ -945,13 +953,13 @@ int global; /* true = global flag, false = current buffer flag */
|
||||
curwp->w_flag |= WFCOLR;
|
||||
#endif
|
||||
mlerase();
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/* test it against the modes we know */
|
||||
|
||||
for (i=0; i < NUMMODES; i++) {
|
||||
for (i = 0; i < NUMMODES; i++) {
|
||||
if (strcmp(cbuf, modename[i]) == 0) {
|
||||
/* finding a match, we process it */
|
||||
if (kind == TRUE)
|
||||
@ -959,8 +967,7 @@ int global; /* true = global flag, false = current buffer flag */
|
||||
gmode |= (1 << i);
|
||||
else
|
||||
curbp->b_mode |= (1 << i);
|
||||
else
|
||||
if (global)
|
||||
else if (global)
|
||||
gmode &= ~(1 << i);
|
||||
else
|
||||
curbp->b_mode &= ~(1 << i);
|
||||
@ -968,12 +975,12 @@ int global; /* true = global flag, false = current buffer flag */
|
||||
if (global == 0)
|
||||
upmode();
|
||||
mlerase(); /* erase the junk */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
mlwrite("No such mode!");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* This function simply clears the message line,
|
||||
@ -985,7 +992,7 @@ int f, n; /* arguments ignored */
|
||||
|
||||
{
|
||||
mlforce("");
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* This function writes a string on the message line
|
||||
@ -1000,10 +1007,11 @@ int f, n; /* arguments ignored */
|
||||
register char *np; /* ptr into nbuf */
|
||||
register int status;
|
||||
char buf[NPAT]; /* buffer to recieve message into */
|
||||
char nbuf[NPAT*2]; /* buffer to expand string into */
|
||||
char nbuf[NPAT * 2]; /* buffer to expand string into */
|
||||
|
||||
if ((status = mlreply("Message to write: ", buf, NPAT - 1)) != TRUE)
|
||||
return(status);
|
||||
if ((status =
|
||||
mlreply("Message to write: ", buf, NPAT - 1)) != TRUE)
|
||||
return (status);
|
||||
|
||||
/* expand all '%' to "%%" so mlwrite won't expect arguments */
|
||||
sp = buf;
|
||||
@ -1017,7 +1025,7 @@ int f, n; /* arguments ignored */
|
||||
|
||||
/* write the message out */
|
||||
mlforce(nbuf);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if CFENCE
|
||||
@ -1048,13 +1056,33 @@ int f, n; /* not used */
|
||||
|
||||
/* setup proper matching fence */
|
||||
switch (ch) {
|
||||
case '(': ofence = ')'; sdir = FORWARD; break;
|
||||
case '{': ofence = '}'; sdir = FORWARD; break;
|
||||
case '[': ofence = ']'; sdir = FORWARD; break;
|
||||
case ')': ofence = '('; sdir = REVERSE; break;
|
||||
case '}': ofence = '{'; sdir = REVERSE; break;
|
||||
case ']': ofence = '['; sdir = REVERSE; break;
|
||||
default: TTbeep(); return(FALSE);
|
||||
case '(':
|
||||
ofence = ')';
|
||||
sdir = FORWARD;
|
||||
break;
|
||||
case '{':
|
||||
ofence = '}';
|
||||
sdir = FORWARD;
|
||||
break;
|
||||
case '[':
|
||||
ofence = ']';
|
||||
sdir = FORWARD;
|
||||
break;
|
||||
case ')':
|
||||
ofence = '(';
|
||||
sdir = REVERSE;
|
||||
break;
|
||||
case '}':
|
||||
ofence = '{';
|
||||
sdir = REVERSE;
|
||||
break;
|
||||
case ']':
|
||||
ofence = '[';
|
||||
sdir = REVERSE;
|
||||
break;
|
||||
default:
|
||||
TTbeep();
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* set up for scan */
|
||||
@ -1089,14 +1117,14 @@ int f, n; /* not used */
|
||||
else
|
||||
forwchar(FALSE, 1);
|
||||
curwp->w_flag |= WFMOVE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* restore the current position */
|
||||
curwp->w_dotp = oldlp;
|
||||
curwp->w_doto = oldoff;
|
||||
TTbeep();
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1164,58 +1192,57 @@ char ch; /* fence type to match against */
|
||||
/* restore the current position */
|
||||
curwp->w_dotp = oldlp;
|
||||
curwp->w_doto = oldoff;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
istring(f, n) /* ask for and insert a string into the current
|
||||
istring(f, n)
|
||||
/* ask for and insert a string into the current
|
||||
buffer at the current point */
|
||||
|
||||
int f, n; /* ignored arguments */
|
||||
|
||||
{
|
||||
register int status; /* status return code */
|
||||
char tstring[NPAT+1]; /* string to add */
|
||||
char tstring[NPAT + 1]; /* string to add */
|
||||
|
||||
/* ask for string to insert */
|
||||
status = mlreplyt("String to insert<META>: ", tstring, NPAT, metac);
|
||||
status =
|
||||
mlreplyt("String to insert<META>: ", tstring, NPAT, metac);
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
|
||||
if (n < 0)
|
||||
n = - n;
|
||||
n = -n;
|
||||
|
||||
/* insert it */
|
||||
while (n-- && (status = linstr(tstring)))
|
||||
;
|
||||
return(status);
|
||||
while (n-- && (status = linstr(tstring)));
|
||||
return (status);
|
||||
}
|
||||
|
||||
ovstring(f, n) /* ask for and overwite a string into the current
|
||||
ovstring(f, n)
|
||||
/* ask for and overwite a string into the current
|
||||
buffer at the current point */
|
||||
|
||||
int f, n; /* ignored arguments */
|
||||
|
||||
{
|
||||
register int status; /* status return code */
|
||||
char tstring[NPAT+1]; /* string to add */
|
||||
char tstring[NPAT + 1]; /* string to add */
|
||||
|
||||
/* ask for string to insert */
|
||||
status = mlreplyt("String to overwrite<META>: ", tstring, NPAT, metac);
|
||||
status =
|
||||
mlreplyt("String to overwrite<META>: ", tstring, NPAT, metac);
|
||||
if (status != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
|
||||
if (n < 0)
|
||||
n = - n;
|
||||
n = -n;
|
||||
|
||||
/* insert it */
|
||||
while (n-- && (status = lover(tstring)))
|
||||
;
|
||||
return(status);
|
||||
while (n-- && (status = lover(tstring)));
|
||||
return (status);
|
||||
}
|
||||
|
||||
|
55
region.c
55
region.c
@ -24,11 +24,11 @@ killregion(f, n)
|
||||
register int s;
|
||||
REGION region;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if ((s=getregion(®ion)) != TRUE)
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return (s);
|
||||
if ((lastflag&CFKILL) == 0) /* This is a kill type */
|
||||
if ((lastflag & CFKILL) == 0) /* This is a kill type */
|
||||
kdelete(); /* command, so do magic */
|
||||
thisflag |= CFKILL; /* kill buffer stuff. */
|
||||
curwp->w_dotp = region.r_linep;
|
||||
@ -49,21 +49,21 @@ copyregion(f, n)
|
||||
register int s;
|
||||
REGION region;
|
||||
|
||||
if ((s=getregion(®ion)) != TRUE)
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return (s);
|
||||
if ((lastflag&CFKILL) == 0) /* Kill type command. */
|
||||
if ((lastflag & CFKILL) == 0) /* Kill type command. */
|
||||
kdelete();
|
||||
thisflag |= CFKILL;
|
||||
linep = region.r_linep; /* Current line. */
|
||||
loffs = region.r_offset; /* Current offset. */
|
||||
while (region.r_size--) {
|
||||
if (loffs == llength(linep)) { /* End of line. */
|
||||
if ((s=kinsert('\n')) != TRUE)
|
||||
if ((s = kinsert('\n')) != TRUE)
|
||||
return (s);
|
||||
linep = lforw(linep);
|
||||
loffs = 0;
|
||||
} else { /* Middle of line. */
|
||||
if ((s=kinsert(lgetc(linep, loffs))) != TRUE)
|
||||
if ((s = kinsert(lgetc(linep, loffs))) != TRUE)
|
||||
return (s);
|
||||
++loffs;
|
||||
}
|
||||
@ -88,9 +88,9 @@ lowerregion(f, n)
|
||||
register int s;
|
||||
REGION region;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if ((s=getregion(®ion)) != TRUE)
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return (s);
|
||||
lchange(WFHARD);
|
||||
linep = region.r_linep;
|
||||
@ -101,8 +101,8 @@ lowerregion(f, n)
|
||||
loffs = 0;
|
||||
} else {
|
||||
c = lgetc(linep, loffs);
|
||||
if (c>='A' && c<='Z')
|
||||
lputc(linep, loffs, c+'a'-'A');
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
lputc(linep, loffs, c + 'a' - 'A');
|
||||
++loffs;
|
||||
}
|
||||
}
|
||||
@ -125,9 +125,9 @@ upperregion(f, n)
|
||||
register int s;
|
||||
REGION region;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if ((s=getregion(®ion)) != TRUE)
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if ((s = getregion(®ion)) != TRUE)
|
||||
return (s);
|
||||
lchange(WFHARD);
|
||||
linep = region.r_linep;
|
||||
@ -138,8 +138,8 @@ upperregion(f, n)
|
||||
loffs = 0;
|
||||
} else {
|
||||
c = lgetc(linep, loffs);
|
||||
if (c>='a' && c<='z')
|
||||
lputc(linep, loffs, c-'a'+'A');
|
||||
if (c >= 'a' && c <= 'z')
|
||||
lputc(linep, loffs, c - 'a' + 'A');
|
||||
++loffs;
|
||||
}
|
||||
}
|
||||
@ -173,31 +173,33 @@ register REGION *rp;
|
||||
rp->r_linep = curwp->w_dotp;
|
||||
if (curwp->w_doto < curwp->w_marko) {
|
||||
rp->r_offset = curwp->w_doto;
|
||||
rp->r_size = (long)(curwp->w_marko-curwp->w_doto);
|
||||
rp->r_size =
|
||||
(long) (curwp->w_marko - curwp->w_doto);
|
||||
} else {
|
||||
rp->r_offset = curwp->w_marko;
|
||||
rp->r_size = (long)(curwp->w_doto-curwp->w_marko);
|
||||
rp->r_size =
|
||||
(long) (curwp->w_doto - curwp->w_marko);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
blp = curwp->w_dotp;
|
||||
bsize = (long)curwp->w_doto;
|
||||
bsize = (long) curwp->w_doto;
|
||||
flp = curwp->w_dotp;
|
||||
fsize = (long)(llength(flp)-curwp->w_doto+1);
|
||||
while (flp!=curbp->b_linep || lback(blp)!=curbp->b_linep) {
|
||||
fsize = (long) (llength(flp) - curwp->w_doto + 1);
|
||||
while (flp != curbp->b_linep || lback(blp) != curbp->b_linep) {
|
||||
if (flp != curbp->b_linep) {
|
||||
flp = lforw(flp);
|
||||
if (flp == curwp->w_markp) {
|
||||
rp->r_linep = curwp->w_dotp;
|
||||
rp->r_offset = curwp->w_doto;
|
||||
rp->r_size = fsize+curwp->w_marko;
|
||||
rp->r_size = fsize + curwp->w_marko;
|
||||
return (TRUE);
|
||||
}
|
||||
fsize += llength(flp)+1;
|
||||
fsize += llength(flp) + 1;
|
||||
}
|
||||
if (lback(blp) != curbp->b_linep) {
|
||||
blp = lback(blp);
|
||||
bsize += llength(blp)+1;
|
||||
bsize += llength(blp) + 1;
|
||||
if (blp == curwp->w_markp) {
|
||||
rp->r_linep = blp;
|
||||
rp->r_offset = curwp->w_marko;
|
||||
@ -209,4 +211,3 @@ register REGION *rp;
|
||||
mlwrite("Bug: lost mark");
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
|
136
spawn.c
136
spawn.c
@ -49,7 +49,7 @@ spawncli(f, n)
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return(resterr());
|
||||
return (resterr());
|
||||
|
||||
#if VMS
|
||||
movecursor(term.t_nrow, 0); /* In last line. */
|
||||
@ -61,7 +61,7 @@ spawncli(f, n)
|
||||
mlputs("\r\n(Returning from DCL)\r\n");
|
||||
TTflush();
|
||||
sleep(1);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
#if MSDOS & (MSC | TURBO)
|
||||
movecursor(term.t_nrow, 0); /* Seek to last line. */
|
||||
@ -70,7 +70,7 @@ spawncli(f, n)
|
||||
shellprog("");
|
||||
TTkopen();
|
||||
sgarbf = TRUE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
#if V7 | USG | BSD
|
||||
movecursor(term.t_nrow, 0); /* Seek to last line. */
|
||||
@ -95,17 +95,17 @@ spawncli(f, n)
|
||||
* -lbt
|
||||
*/
|
||||
chg_width = term.t_ncol;
|
||||
chg_height = term.t_nrow+1;
|
||||
chg_height = term.t_nrow + 1;
|
||||
term.t_nrow = term.t_ncol = 0;
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if BSD | __hpux | SVR4
|
||||
|
||||
bktoshell() /* suspend MicroEMACS and wait to wake up */
|
||||
{
|
||||
bktoshell()
|
||||
{ /* suspend MicroEMACS and wait to wake up */
|
||||
int pid;
|
||||
|
||||
vttidy();
|
||||
@ -136,10 +136,10 @@ spawn(f, n)
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return(resterr());
|
||||
return (resterr());
|
||||
|
||||
#if VMS
|
||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTflush();
|
||||
@ -153,8 +153,8 @@ spawn(f, n)
|
||||
return (s);
|
||||
#endif
|
||||
#if MSDOS
|
||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
||||
return(s);
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
@ -168,7 +168,7 @@ spawn(f, n)
|
||||
return (TRUE);
|
||||
#endif
|
||||
#if V7 | USG | BSD
|
||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
@ -180,8 +180,7 @@ spawn(f, n)
|
||||
if (clexec == FALSE) {
|
||||
mlputs("(End)"); /* Pause. */
|
||||
TTflush();
|
||||
while ((s = tgetc()) != '\r' && s != ' ')
|
||||
;
|
||||
while ((s = tgetc()) != '\r' && s != ' ');
|
||||
mlputs("\r\n");
|
||||
}
|
||||
TTkopen();
|
||||
@ -197,17 +196,16 @@ spawn(f, n)
|
||||
*/
|
||||
|
||||
execprg(f, n)
|
||||
|
||||
{
|
||||
register int s;
|
||||
char line[NLINE];
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return(resterr());
|
||||
return (resterr());
|
||||
|
||||
#if VMS
|
||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
TTflush();
|
||||
s = sys(line); /* Run the command. */
|
||||
@ -219,8 +217,8 @@ execprg(f, n)
|
||||
#endif
|
||||
|
||||
#if MSDOS
|
||||
if ((s=mlreply("$", line, NLINE)) != TRUE)
|
||||
return(s);
|
||||
if ((s = mlreply("$", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
execprog(line);
|
||||
@ -235,7 +233,7 @@ execprg(f, n)
|
||||
#endif
|
||||
|
||||
#if V7 | USG | BSD
|
||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
TTputc('\n'); /* Already have '\r' */
|
||||
TTflush();
|
||||
@ -245,8 +243,7 @@ execprg(f, n)
|
||||
TTopen();
|
||||
mlputs("(End)"); /* Pause. */
|
||||
TTflush();
|
||||
while ((s = tgetc()) != '\r' && s != ' ')
|
||||
;
|
||||
while ((s = tgetc()) != '\r' && s != ' ');
|
||||
sgarbf = TRUE;
|
||||
return (TRUE);
|
||||
#endif
|
||||
@ -276,31 +273,33 @@ pipecmd(f, n)
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return(resterr());
|
||||
return (resterr());
|
||||
|
||||
#if MSDOS
|
||||
if ((tmp = getenv("TMP")) == NULL && (tmp = getenv("TEMP")) == NULL)
|
||||
if ((tmp = getenv("TMP")) == NULL
|
||||
&& (tmp = getenv("TEMP")) == NULL)
|
||||
strcpy(filnam, "command");
|
||||
else {
|
||||
strcpy(filnam, tmp);
|
||||
len = strlen(tmp);
|
||||
if (len <= 0 || filnam[len-1] != '\\' && filnam[len-1] != '/')
|
||||
strcat(filnam,"\\");
|
||||
strcat(filnam,"command");
|
||||
if (len <= 0 || filnam[len - 1] != '\\'
|
||||
&& filnam[len - 1] != '/')
|
||||
strcat(filnam, "\\");
|
||||
strcat(filnam, "command");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if VMS
|
||||
mlwrite("Not available under VMS");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
#endif
|
||||
|
||||
/* get the command to pipe in */
|
||||
if ((s=mlreply("@", line, NLINE)) != TRUE)
|
||||
return(s);
|
||||
if ((s = mlreply("@", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
|
||||
/* get rid of the command output buffer if it exists */
|
||||
if ((bp=bfind(bname, FALSE, 0)) != FALSE) {
|
||||
if ((bp = bfind(bname, FALSE, 0)) != FALSE) {
|
||||
/* try to make sure we are off screen */
|
||||
wp = wheadp;
|
||||
while (wp != NULL) {
|
||||
@ -320,12 +319,11 @@ pipecmd(f, n)
|
||||
}
|
||||
if (zotbuf(bp) != TRUE)
|
||||
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
#if MSDOS
|
||||
strcat(line," >>");
|
||||
strcat(line,filnam);
|
||||
strcat(line, " >>");
|
||||
strcat(line, filnam);
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
@ -342,8 +340,8 @@ pipecmd(f, n)
|
||||
#if V7 | USG | BSD
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
strcat(line,">");
|
||||
strcat(line,filnam);
|
||||
strcat(line, ">");
|
||||
strcat(line, filnam);
|
||||
system(line);
|
||||
TTopen();
|
||||
TTflush();
|
||||
@ -352,15 +350,15 @@ pipecmd(f, n)
|
||||
#endif
|
||||
|
||||
if (s != TRUE)
|
||||
return(s);
|
||||
return (s);
|
||||
|
||||
/* split the current window to make room for the command output */
|
||||
if (splitwind(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* and read the stuff in */
|
||||
if (getfile(filnam, FALSE) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* make this window in VIEW mode, update all mode lines */
|
||||
curwp->w_bufp->b_mode |= MDVIEW;
|
||||
@ -372,7 +370,7 @@ pipecmd(f, n)
|
||||
|
||||
/* and get rid of the temporary file */
|
||||
unlink(filnam);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -380,7 +378,6 @@ pipecmd(f, n)
|
||||
* Bound to ^X #
|
||||
*/
|
||||
filter(f, n)
|
||||
|
||||
{
|
||||
register int s; /* return status from CLI */
|
||||
register BUFFER *bp; /* pointer to buffer to zot */
|
||||
@ -393,19 +390,19 @@ filter(f, n)
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return(resterr());
|
||||
return (resterr());
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
|
||||
#if VMS
|
||||
mlwrite("Not available under VMS");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
#endif
|
||||
|
||||
/* get the filter name and its args */
|
||||
if ((s=mlreply("#", line, NLINE)) != TRUE)
|
||||
return(s);
|
||||
if ((s = mlreply("#", line, NLINE)) != TRUE)
|
||||
return (s);
|
||||
|
||||
/* setup the proper file names */
|
||||
bp = curbp;
|
||||
@ -416,11 +413,10 @@ filter(f, n)
|
||||
if (writeout(filnam1) != TRUE) {
|
||||
mlwrite("(Cannot write filter file)");
|
||||
strcpy(bp->b_fname, tmpnam);
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
#if MSDOS
|
||||
strcat(line," <fltinp >fltout");
|
||||
strcat(line, " <fltinp >fltout");
|
||||
movecursor(term.t_nrow - 1, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
@ -433,7 +429,7 @@ filter(f, n)
|
||||
TTputc('\n'); /* Already have '\r' */
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
strcat(line," <fltinp >fltout");
|
||||
strcat(line, " <fltinp >fltout");
|
||||
system(line);
|
||||
TTopen();
|
||||
TTflush();
|
||||
@ -442,12 +438,12 @@ filter(f, n)
|
||||
#endif
|
||||
|
||||
/* on failure, escape gracefully */
|
||||
if (s != TRUE || (readin(filnam2,FALSE) == FALSE)) {
|
||||
if (s != TRUE || (readin(filnam2, FALSE) == FALSE)) {
|
||||
mlwrite("(Execution failed)");
|
||||
strcpy(bp->b_fname, tmpnam);
|
||||
unlink(filnam1);
|
||||
unlink(filnam2);
|
||||
return(s);
|
||||
return (s);
|
||||
}
|
||||
|
||||
/* reset file name */
|
||||
@ -457,7 +453,7 @@ filter(f, n)
|
||||
/* and get rid of the temporary file */
|
||||
unlink(filnam1);
|
||||
unlink(filnam2);
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if VMS
|
||||
@ -478,7 +474,7 @@ register char *cmd;
|
||||
|
||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||
oldmode, sizeof(oldmode), 0, 0, 0, 0);
|
||||
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
|
||||
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
|
||||
return (FALSE);
|
||||
cdscp = NULL; /* Assume DCL. */
|
||||
if (cmd != NULL) { /* Build descriptor. */
|
||||
@ -493,9 +489,9 @@ register char *cmd;
|
||||
substatus = status;
|
||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||
newmode, sizeof(newmode), 0, 0, 0, 0);
|
||||
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
|
||||
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
|
||||
return (FALSE);
|
||||
if ((substatus&STS$M_SUCCESS) == 0) /* Command failed. */
|
||||
if ((substatus & STS$M_SUCCESS) == 0) /* Command failed. */
|
||||
return (FALSE);
|
||||
return (TRUE);
|
||||
}
|
||||
@ -521,11 +517,11 @@ char *cmd; /* Incoming command line to execute */
|
||||
regs.h.ah = 0x37; /* get setting data */
|
||||
regs.h.al = 0x00; /* get switch character */
|
||||
intdos(®s, ®s);
|
||||
swchar = (char)regs.h.dl;
|
||||
swchar = (char) regs.h.dl;
|
||||
|
||||
/* get name of system shell */
|
||||
if ((shell = getenv("COMSPEC")) == NULL) {
|
||||
return(FALSE); /* No shell located */
|
||||
return (FALSE); /* No shell located */
|
||||
}
|
||||
|
||||
/* trim leading whitespace off the command */
|
||||
@ -543,9 +539,9 @@ char *cmd; /* Incoming command line to execute */
|
||||
comline[strlen(comline)] = swchar;
|
||||
strcat(comline, "c ");
|
||||
strcat(comline, cmd);
|
||||
return(execprog(comline));
|
||||
return (execprog(comline));
|
||||
} else
|
||||
return(execprog(shell));
|
||||
return (execprog(shell));
|
||||
}
|
||||
|
||||
/* EXECPROG: A function to execute a named program
|
||||
@ -581,16 +577,16 @@ char *cmd; /* Incoming command line to execute */
|
||||
/* and parse out the command tail */
|
||||
while (*cmd && ((*cmd == ' ') || (*cmd == '\t')))
|
||||
++cmd;
|
||||
*tail = (char)(strlen(cmd)); /* record the byte length */
|
||||
*tail = (char) (strlen(cmd)); /* record the byte length */
|
||||
strcpy(&tail[1], cmd);
|
||||
strcat(&tail[1], "\r");
|
||||
|
||||
/* look up the program on the path trying various extentions */
|
||||
if ((sp = flook(prog, TRUE)) == NULL)
|
||||
if ((sp = flook(strcat(prog, ".exe"), TRUE)) == NULL) {
|
||||
strcpy(&prog[strlen(prog)-4], ".com");
|
||||
strcpy(&prog[strlen(prog) - 4], ".com");
|
||||
if ((sp = flook(prog, TRUE)) == NULL)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
strcpy(prog, sp);
|
||||
|
||||
@ -606,10 +602,10 @@ char *cmd; /* Incoming command line to execute */
|
||||
/* and make the call */
|
||||
regs.h.ah = 0x4b; /* EXEC Load or Execute a Program */
|
||||
regs.h.al = 0x00; /* load end execute function subcode */
|
||||
segreg.ds = ((unsigned long)(prog) >> 16); /* program name ptr */
|
||||
regs.x.dx = (unsigned int)(prog);
|
||||
segreg.es = ((unsigned long)(&pblock) >> 16); /* set up param block ptr */
|
||||
regs.x.bx = (unsigned int)(&pblock);
|
||||
segreg.ds = ((unsigned long) (prog) >> 16); /* program name ptr */
|
||||
regs.x.dx = (unsigned int) (prog);
|
||||
segreg.es = ((unsigned long) (&pblock) >> 16); /* set up param block ptr */
|
||||
regs.x.bx = (unsigned int) (&pblock);
|
||||
#if TURBO | MSC
|
||||
intdosx(®s, ®s, &segreg);
|
||||
if (regs.x.cflag == 0) {
|
||||
@ -623,6 +619,6 @@ char *cmd; /* Incoming command line to execute */
|
||||
rval = -_doserrno; /* failed child call */
|
||||
#endif
|
||||
#endif
|
||||
return((rval < 0) ? FALSE : TRUE);
|
||||
return ((rval < 0) ? FALSE : TRUE);
|
||||
}
|
||||
#endif
|
||||
|
92
tcap.c
92
tcap.c
@ -107,7 +107,6 @@ TERM term = {
|
||||
};
|
||||
|
||||
tcapopen()
|
||||
|
||||
{
|
||||
char *getenv();
|
||||
char *t, *p, *tgetstr();
|
||||
@ -117,37 +116,36 @@ tcapopen()
|
||||
int int_col, int_row;
|
||||
|
||||
#if PKCODE && USE_BROKEN_OPTIMIZATION
|
||||
if (! term_init_ok)
|
||||
{
|
||||
if (!term_init_ok) {
|
||||
#endif
|
||||
if ((tv_stype = getenv("TERM")) == NULL)
|
||||
{
|
||||
if ((tv_stype = getenv("TERM")) == NULL) {
|
||||
puts("Environment variable TERM not defined!");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((tgetent(tcbuf, tv_stype)) != 1)
|
||||
{
|
||||
sprintf(err_str, "Unknown terminal type %s!", tv_stype);
|
||||
if ((tgetent(tcbuf, tv_stype)) != 1) {
|
||||
sprintf(err_str, "Unknown terminal type %s!",
|
||||
tv_stype);
|
||||
puts(err_str);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Get screen size from system, or else from termcap. */
|
||||
getscreensize(&int_col, &int_row);
|
||||
term.t_nrow = int_row-1;
|
||||
term.t_nrow = int_row - 1;
|
||||
term.t_ncol = int_col;
|
||||
|
||||
if ((term.t_nrow <= 0) && (term.t_nrow=(short)tgetnum("li")-1) == -1){
|
||||
if ((term.t_nrow <= 0)
|
||||
&& (term.t_nrow = (short) tgetnum("li") - 1) == -1) {
|
||||
puts("termcap entry incomplete (lines)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((term.t_ncol <= 0) && (term.t_ncol=(short)tgetnum("co")) == -1){
|
||||
if ((term.t_ncol <= 0)
|
||||
&& (term.t_ncol = (short) tgetnum("co")) == -1) {
|
||||
puts("Termcap entry incomplete (columns)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef SIGWINCH
|
||||
term.t_mrow = MAXROW;
|
||||
term.t_mcol = MAXCOL;
|
||||
@ -157,7 +155,7 @@ tcapopen()
|
||||
#endif
|
||||
p = tcapbuf;
|
||||
t = tgetstr("pc", &p);
|
||||
if(t)
|
||||
if (t)
|
||||
PC = *t;
|
||||
else
|
||||
PC = 0;
|
||||
@ -180,8 +178,7 @@ tcapopen()
|
||||
TE = tgetstr("te", &p);
|
||||
#endif
|
||||
|
||||
if(CL == NULL || CM == NULL || UP == NULL)
|
||||
{
|
||||
if (CL == NULL || CM == NULL || UP == NULL) {
|
||||
puts("Incomplete termcap entry\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -206,8 +203,7 @@ tcapopen()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p >= &tcapbuf[TCAPSLEN])
|
||||
{
|
||||
if (p >= &tcapbuf[TCAPSLEN]) {
|
||||
puts("Terminal description too big!\n");
|
||||
exit(1);
|
||||
}
|
||||
@ -221,7 +217,6 @@ tcapopen()
|
||||
#if PKCODE
|
||||
|
||||
tcapclose()
|
||||
|
||||
{
|
||||
putpad(tgoto(CM, 0, term.t_nrow));
|
||||
putpad(TE);
|
||||
@ -231,7 +226,6 @@ tcapclose()
|
||||
#endif
|
||||
|
||||
tcapkopen()
|
||||
|
||||
{
|
||||
#if PKCODE
|
||||
putpad(TI);
|
||||
@ -241,7 +235,6 @@ tcapkopen()
|
||||
}
|
||||
|
||||
tcapkclose()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
@ -261,8 +254,8 @@ tcapeeop()
|
||||
putpad(CL);
|
||||
}
|
||||
|
||||
tcaprev(state) /* change reverse video status */
|
||||
|
||||
tcaprev(state)
|
||||
/* change reverse video status */
|
||||
int state; /* FALSE = normal video, TRUE = reverse video */
|
||||
|
||||
{
|
||||
@ -270,32 +263,31 @@ int state; /* FALSE = normal video, TRUE = reverse video */
|
||||
if (state) {
|
||||
if (SO != NULL)
|
||||
putpad(SO);
|
||||
} else
|
||||
if (SE != NULL)
|
||||
} else if (SE != NULL)
|
||||
putpad(SE);
|
||||
}
|
||||
|
||||
tcapcres() /* change screen resolution */
|
||||
|
||||
{
|
||||
return(TRUE);
|
||||
tcapcres()
|
||||
{ /* change screen resolution */
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if SCROLLCODE
|
||||
|
||||
/* move howmanylines lines starting at from to to */
|
||||
tcapscroll_reg(from,to,howmanylines)
|
||||
tcapscroll_reg(from, to, howmanylines)
|
||||
{
|
||||
int i;
|
||||
if (to == from) return;
|
||||
if (to == from)
|
||||
return;
|
||||
if (to < from) {
|
||||
tcapscrollregion(to, from + howmanylines - 1);
|
||||
tcapmove(from + howmanylines - 1,0);
|
||||
tcapmove(from + howmanylines - 1, 0);
|
||||
for (i = from - to; i > 0; i--)
|
||||
putpad(SF);
|
||||
} else { /* from < to */
|
||||
tcapscrollregion(from, to + howmanylines - 1);
|
||||
tcapmove(from,0);
|
||||
tcapmove(from, 0);
|
||||
for (i = to - from; i > 0; i--)
|
||||
putpad(SR);
|
||||
}
|
||||
@ -303,29 +295,30 @@ tcapscroll_reg(from,to,howmanylines)
|
||||
}
|
||||
|
||||
/* move howmanylines lines starting at from to to */
|
||||
tcapscroll_delins(from,to,howmanylines)
|
||||
tcapscroll_delins(from, to, howmanylines)
|
||||
{
|
||||
int i;
|
||||
if (to == from) return;
|
||||
if (to == from)
|
||||
return;
|
||||
if (to < from) {
|
||||
tcapmove(to,0);
|
||||
tcapmove(to, 0);
|
||||
for (i = from - to; i > 0; i--)
|
||||
putpad(DL);
|
||||
tcapmove(to+howmanylines,0);
|
||||
tcapmove(to + howmanylines, 0);
|
||||
for (i = from - to; i > 0; i--)
|
||||
putpad(AL);
|
||||
} else {
|
||||
tcapmove(from+howmanylines,0);
|
||||
tcapmove(from + howmanylines, 0);
|
||||
for (i = to - from; i > 0; i--)
|
||||
putpad(DL);
|
||||
tcapmove(from,0);
|
||||
tcapmove(from, 0);
|
||||
for (i = to - from; i > 0; i--)
|
||||
putpad(AL);
|
||||
}
|
||||
}
|
||||
|
||||
/* cs is set up just like cm, so we use tgoto... */
|
||||
tcapscrollregion(top,bot)
|
||||
tcapscrollregion(top, bot)
|
||||
{
|
||||
ttputc(PC);
|
||||
putpad(tgoto(CS, bot, top));
|
||||
@ -333,19 +326,18 @@ tcapscrollregion(top,bot)
|
||||
|
||||
#endif
|
||||
|
||||
spal(dummy) /* change palette string */
|
||||
|
||||
{
|
||||
spal(dummy)
|
||||
{ /* change palette string */
|
||||
/* Does nothing here */
|
||||
}
|
||||
|
||||
#if COLOR
|
||||
tcapfcol() /* no colors here, ignore this */
|
||||
{
|
||||
tcapfcol()
|
||||
{ /* no colors here, ignore this */
|
||||
}
|
||||
|
||||
tcapbcol() /* no colors here, ignore this */
|
||||
{
|
||||
tcapbcol()
|
||||
{ /* no colors here, ignore this */
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -368,13 +360,13 @@ char *str;
|
||||
|
||||
|
||||
#if FNLABEL
|
||||
fnclabel(f, n) /* label a function key */
|
||||
|
||||
int f,n; /* default flag, numeric argument [unused] */
|
||||
fnclabel(f, n)
|
||||
/* label a function key */
|
||||
int f, n; /* default flag, numeric argument [unused] */
|
||||
|
||||
{
|
||||
/* on machines with no function keys...don't bother */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
89
termio.c
89
termio.c
@ -64,14 +64,17 @@ struct sgttyb nstate; /* values for editor mode */
|
||||
struct tchars otchars; /* Saved terminal special character set */
|
||||
#if XONXOFF
|
||||
struct tchars ntchars = { 0xff, 0xff, 0x11, 0x13, 0xff, 0xff };
|
||||
|
||||
/* A lot of nothing and XON/XOFF */
|
||||
#else
|
||||
struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
/* A lot of nothing */
|
||||
#endif
|
||||
#if BSD & PKCODE
|
||||
struct ltchars oltchars; /* Saved terminal local special character set */
|
||||
struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
/* A lot of nothing */
|
||||
#endif
|
||||
|
||||
@ -115,7 +118,7 @@ ttopen()
|
||||
odsc.dsc$a_pointer = &oname[0];
|
||||
odsc.dsc$w_length = sizeof(oname);
|
||||
status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc);
|
||||
if (status!=SS$_NORMAL && status!=SS$_NOTRAN)
|
||||
if (status != SS$_NORMAL && status != SS$_NOTRAN)
|
||||
exit(status);
|
||||
if (oname[0] == 0x1B) {
|
||||
odsc.dsc$a_pointer += 4;
|
||||
@ -127,21 +130,21 @@ ttopen()
|
||||
exit(status);
|
||||
status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
|
||||
oldmode, sizeof(oldmode), 0, 0, 0, 0);
|
||||
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
|
||||
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
|
||||
exit(status);
|
||||
newmode[0] = oldmode[0];
|
||||
newmode[1] = oldmode[1] | TT$M_NOECHO;
|
||||
#if XONXOFF
|
||||
#else
|
||||
newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC);
|
||||
newmode[1] &= ~(TT$M_TTSYNC | TT$M_HOSTSYNC);
|
||||
#endif
|
||||
newmode[2] = oldmode[2] | TT2$M_PASTHRU;
|
||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||
newmode, sizeof(newmode), 0, 0, 0, 0);
|
||||
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
|
||||
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
|
||||
exit(status);
|
||||
term.t_nrow = (newmode[1]>>24) - 1;
|
||||
term.t_ncol = newmode[0]>>16;
|
||||
term.t_nrow = (newmode[1] >> 24) - 1;
|
||||
term.t_ncol = newmode[0] >> 16;
|
||||
|
||||
#endif
|
||||
|
||||
@ -170,7 +173,7 @@ ttopen()
|
||||
#else
|
||||
ioctl(0, TCSETA, &ntermio); /* and activate them */
|
||||
#endif
|
||||
kbdflgs = fcntl( 0, F_GETFL, 0 );
|
||||
kbdflgs = fcntl(0, F_GETFL, 0);
|
||||
kbdpoll = FALSE;
|
||||
#endif
|
||||
|
||||
@ -178,11 +181,11 @@ ttopen()
|
||||
gtty(0, &ostate); /* save old state */
|
||||
gtty(0, &nstate); /* get base of new state */
|
||||
#if XONXOFF
|
||||
nstate.sg_flags |= (CBREAK|TANDEM);
|
||||
nstate.sg_flags |= (CBREAK | TANDEM);
|
||||
#else
|
||||
nstate.sg_flags |= RAW;
|
||||
#endif
|
||||
nstate.sg_flags &= ~(ECHO|CRMOD); /* no echo for now... */
|
||||
nstate.sg_flags &= ~(ECHO | CRMOD); /* no echo for now... */
|
||||
stty(0, &nstate); /* set mode */
|
||||
ioctl(0, TIOCGETC, &otchars); /* Save old characters */
|
||||
ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */
|
||||
@ -194,8 +197,8 @@ ttopen()
|
||||
/* provide a smaller terminal output buffer so that
|
||||
the type ahead detection works better (more often) */
|
||||
setbuffer(stdout, &tobuf[0], TBUFSIZ);
|
||||
signal(SIGTSTP,SIG_DFL); /* set signals so that we can */
|
||||
signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */
|
||||
signal(SIGTSTP, SIG_DFL); /* set signals so that we can */
|
||||
signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -203,8 +206,8 @@ ttopen()
|
||||
/* provide a smaller terminal output buffer so that
|
||||
the type ahead detection works better (more often) */
|
||||
setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ);
|
||||
signal(SIGTSTP,SIG_DFL); /* set signals so that we can */
|
||||
signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */
|
||||
signal(SIGTSTP, SIG_DFL); /* set signals so that we can */
|
||||
signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */
|
||||
TTflush();
|
||||
#endif /* __hpux */
|
||||
|
||||
@ -228,7 +231,7 @@ ttclose()
|
||||
ttflush();
|
||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||
oldmode, sizeof(oldmode), 0, 0, 0, 0);
|
||||
if (status!=SS$_NORMAL || (iosb[0]&0xFFFF)!=SS$_NORMAL)
|
||||
if (status != SS$_NORMAL || (iosb[0] & 0xFFFF) != SS$_NORMAL)
|
||||
exit(status);
|
||||
status = SYS$DASSGN(iochan);
|
||||
if (status != SS$_NORMAL)
|
||||
@ -295,7 +298,8 @@ ttflush()
|
||||
|
||||
status = SS$_NORMAL;
|
||||
if (nobuf != 0) {
|
||||
status = SYS$QIOW(EFN, iochan, IO$_WRITELBLK|IO$M_NOFORMAT,
|
||||
status =
|
||||
SYS$QIOW(EFN, iochan, IO$_WRITELBLK | IO$M_NOFORMAT,
|
||||
iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
|
||||
if (status == SS$_NORMAL)
|
||||
status = iosb[0] & 0xFFFF;
|
||||
@ -346,23 +350,24 @@ ttgetc()
|
||||
ibufi = 0;
|
||||
term[0] = 0;
|
||||
term[1] = 0;
|
||||
status = SYS$QIOW(EFN, iochan, IO$_READLBLK|IO$M_TIMED,
|
||||
status = SYS$QIOW(EFN, iochan, IO$_READLBLK | IO$M_TIMED,
|
||||
iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0);
|
||||
if (status != SS$_NORMAL)
|
||||
exit(status);
|
||||
status = iosb[0] & 0xFFFF;
|
||||
if (status!=SS$_NORMAL && status!=SS$_TIMEOUT &&
|
||||
status!=SS$_DATAOVERUN)
|
||||
if (status != SS$_NORMAL && status != SS$_TIMEOUT &&
|
||||
status != SS$_DATAOVERUN)
|
||||
exit(status);
|
||||
nibuf = (iosb[0]>>16) + (iosb[1]>>16);
|
||||
nibuf = (iosb[0] >> 16) + (iosb[1] >> 16);
|
||||
if (nibuf == 0) {
|
||||
status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
|
||||
iosb, 0, 0, ibuf, 1, 0, term, 0, 0);
|
||||
iosb, 0, 0, ibuf, 1, 0, term, 0,
|
||||
0);
|
||||
if (status != SS$_NORMAL
|
||||
|| (status = (iosb[0]&0xFFFF)) != SS$_NORMAL)
|
||||
|| (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL)
|
||||
if (status != SS$_DATAOVERUN)
|
||||
exit(status);
|
||||
nibuf = (iosb[0]>>16) + (iosb[1]>>16);
|
||||
nibuf = (iosb[0] >> 16) + (iosb[1] >> 16);
|
||||
}
|
||||
}
|
||||
return (ibuf[ibufi++] & 0xFF); /* Allow multinational */
|
||||
@ -375,32 +380,30 @@ ttgetc()
|
||||
if (nxtchar >= 0) {
|
||||
c = nxtchar;
|
||||
nxtchar = -1;
|
||||
return(c);
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* call the dos to get a char */
|
||||
rg.h.ah = 7; /* dos Direct Console Input call */
|
||||
intdos(&rg, &rg);
|
||||
c = rg.h.al; /* grab the char */
|
||||
return(c & 255);
|
||||
return (c & 255);
|
||||
#endif
|
||||
|
||||
#if V7 | BSD
|
||||
return(255 & fgetc(stdin)); /* 8BIT P.K. */
|
||||
return (255 & fgetc(stdin)); /* 8BIT P.K. */
|
||||
#endif
|
||||
|
||||
#if USG
|
||||
if( kbdqp )
|
||||
if (kbdqp)
|
||||
kbdqp = FALSE;
|
||||
else
|
||||
{
|
||||
if( kbdpoll && fcntl( 0, F_SETFL, kbdflgs ) < 0 )
|
||||
else {
|
||||
if (kbdpoll && fcntl(0, F_SETFL, kbdflgs) < 0)
|
||||
return FALSE;
|
||||
kbdpoll = FALSE;
|
||||
while (read(0, &kbdq, 1) != 1)
|
||||
;
|
||||
while (read(0, &kbdq, 1) != 1);
|
||||
}
|
||||
return ( kbdq & 255 );
|
||||
return (kbdq & 255);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -410,40 +413,38 @@ ttgetc()
|
||||
*/
|
||||
|
||||
typahead()
|
||||
|
||||
{
|
||||
#if MSDOS & (MSC | TURBO)
|
||||
if (kbhit() != 0)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
else
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
#endif
|
||||
|
||||
#if BSD
|
||||
int x; /* holds # of pending chars */
|
||||
|
||||
return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x);
|
||||
return ((ioctl(0, FIONREAD, &x) < 0) ? 0 : x);
|
||||
#endif
|
||||
|
||||
#if PKCODE & VMS
|
||||
return(ibufi < nibuf);
|
||||
return (ibufi < nibuf);
|
||||
#endif
|
||||
|
||||
#if USG
|
||||
if( !kbdqp )
|
||||
{
|
||||
if( !kbdpoll && fcntl( 0, F_SETFL, kbdflgs | O_NDELAY ) < 0 )
|
||||
return(FALSE);
|
||||
if (!kbdqp) {
|
||||
if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0)
|
||||
return (FALSE);
|
||||
#if PKCODE
|
||||
kbdpoll = 1;
|
||||
#endif
|
||||
kbdqp = (1 == read( 0, &kbdq, 1 ));
|
||||
kbdqp = (1 == read(0, &kbdq, 1));
|
||||
}
|
||||
return ( kbdqp );
|
||||
return (kbdqp);
|
||||
#endif
|
||||
|
||||
#if !UNIX & !VMS & !MSDOS
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
72
vmsvt.c
72
vmsvt.c
@ -34,8 +34,8 @@ int vmsfcol(), vmsbcol();
|
||||
#endif
|
||||
|
||||
/** SMG stuff **/
|
||||
static char * begin_reverse, * end_reverse, * erase_to_end_line;
|
||||
static char * erase_whole_display;
|
||||
static char *begin_reverse, *end_reverse, *erase_to_end_line;
|
||||
static char *erase_whole_display;
|
||||
static int termtype;
|
||||
|
||||
#define SMG$K_BEGIN_REVERSE 0x1bf
|
||||
@ -61,10 +61,12 @@ TERM term = {
|
||||
#else
|
||||
24 - 1, /* Max number of rows allowable */
|
||||
#endif
|
||||
/* Filled in */ - 1, /* Current number of rows used */
|
||||
/* Filled in */ -1,
|
||||
/* Current number of rows used */
|
||||
MAXCOL, /* Max number of columns */
|
||||
/* Filled in */ 0, /* Current number of columns */
|
||||
64, /* Min margin for extended lines*/
|
||||
/* Filled in */ 0,
|
||||
/* Current number of columns */
|
||||
64, /* Min margin for extended lines */
|
||||
8, /* Size of scroll region */
|
||||
100, /* # times thru update to pause */
|
||||
vmsopen, /* Open terminal at the start */
|
||||
@ -95,7 +97,7 @@ TERM term = {
|
||||
* Nothing returned
|
||||
***/
|
||||
ttputs(string)
|
||||
char * string; /* String to write */
|
||||
char *string; /* String to write */
|
||||
{
|
||||
if (string)
|
||||
while (*string != '\0')
|
||||
@ -117,7 +119,7 @@ int col; /* Column position */
|
||||
static int request_code = SMG$K_SET_CURSOR_ABS;
|
||||
static int max_buffer_length = sizeof(buffer);
|
||||
static int arg_list[3] = { 2 };
|
||||
register char * cp;
|
||||
register char *cp;
|
||||
|
||||
register int i;
|
||||
|
||||
@ -133,10 +135,11 @@ int col; /* Column position */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer, /* Capability data buffer */
|
||||
arg_list) /* Argument list array */
|
||||
arg_list)
|
||||
|
||||
/* Argument list array */
|
||||
/* We'll know soon enough if this doesn't work */
|
||||
& 1) == 0) {
|
||||
&1) == 0) {
|
||||
ttputs("OOPS");
|
||||
return;
|
||||
}
|
||||
@ -150,18 +153,19 @@ int col; /* Column position */
|
||||
|
||||
#if SCROLLCODE
|
||||
|
||||
vmsscroll_reg(from,to,howmany)
|
||||
vmsscroll_reg(from, to, howmany)
|
||||
{
|
||||
int i;
|
||||
if (to == from) return;
|
||||
if (to == from)
|
||||
return;
|
||||
if (to < from) {
|
||||
vmsscrollregion(to, from + howmany - 1);
|
||||
vmsmove(from + howmany - 1,0);
|
||||
vmsmove(from + howmany - 1, 0);
|
||||
for (i = from - to; i > 0; i--)
|
||||
ttputs(scroll_forward);
|
||||
} else { /* from < to */
|
||||
vmsscrollregion(from, to + howmany - 1);
|
||||
vmsmove(from,0);
|
||||
vmsmove(from, 0);
|
||||
for (i = to - from; i > 0; i--)
|
||||
ttputs(scroll_reverse);
|
||||
}
|
||||
@ -177,7 +181,7 @@ int bot; /* Bottom position */
|
||||
static int request_code = SMG$K_SET_SCROLL_REGION;
|
||||
static int max_buffer_length = sizeof(buffer);
|
||||
static int arg_list[3] = { 2 };
|
||||
register char * cp;
|
||||
register char *cp;
|
||||
|
||||
register int i;
|
||||
|
||||
@ -193,10 +197,11 @@ int bot; /* Bottom position */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer, /* Capability data buffer */
|
||||
arg_list) /* Argument list array */
|
||||
arg_list)
|
||||
|
||||
/* Argument list array */
|
||||
/* We'll know soon enough if this doesn't work */
|
||||
& 1) == 0) {
|
||||
&1) == 0) {
|
||||
ttputs("OOPS");
|
||||
return;
|
||||
}
|
||||
@ -295,12 +300,12 @@ vmsbeep()
|
||||
* Returns: Escape sequence
|
||||
* NULL No escape sequence available
|
||||
***/
|
||||
char * vmsgetstr(request_code)
|
||||
char *vmsgetstr(request_code)
|
||||
int request_code; /* Request code */
|
||||
{
|
||||
register char * result;
|
||||
register char *result;
|
||||
static char seq_storage[1024];
|
||||
static char * buffer = seq_storage;
|
||||
static char *buffer = seq_storage;
|
||||
static int arg_list[2] = { 1, 1 };
|
||||
int max_buffer_length, ret_length;
|
||||
|
||||
@ -313,25 +318,25 @@ int request_code; /* Request code */
|
||||
if ((smg$get_term_data( /* Get terminal data */
|
||||
&termtype, /* Terminal table address */
|
||||
&request_code, /* Request code */
|
||||
&max_buffer_length,/* Maximum buffer length */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer, /* Capability data buffer */
|
||||
arg_list) /* Argument list array */
|
||||
arg_list)
|
||||
|
||||
|
||||
/* Argument list array */
|
||||
/* If this doesn't work, try again with no arguments */
|
||||
|
||||
& 1) == 0 &&
|
||||
|
||||
(smg$get_term_data( /* Get terminal data */
|
||||
&1) == 0 && (smg$get_term_data( /* Get terminal data */
|
||||
&termtype, /* Terminal table address */
|
||||
&request_code, /* Request code */
|
||||
&max_buffer_length,/* Maximum buffer length */
|
||||
&max_buffer_length, /* Maximum buffer length */
|
||||
&ret_length, /* Return length */
|
||||
buffer) /* Capability data buffer */
|
||||
buffer)
|
||||
|
||||
|
||||
/* Capability data buffer */
|
||||
/* Return NULL pointer if capability is not available */
|
||||
|
||||
& 1) == 0)
|
||||
&1) == 0)
|
||||
return NULL;
|
||||
|
||||
/* Check for empty result */
|
||||
@ -385,7 +390,7 @@ vmsgtty()
|
||||
/* Assign input to a channel */
|
||||
status = sys$assign(&devnam, &fd, 0, 0);
|
||||
if ((status & 1) == 0)
|
||||
exit (status);
|
||||
exit(status);
|
||||
|
||||
/* Get terminal characteristics */
|
||||
status = sys$qiow( /* Queue and wait */
|
||||
@ -421,7 +426,8 @@ vmsopen()
|
||||
vmsgtty();
|
||||
if (tc.t_type == TT$_UNKNOWN) {
|
||||
printf("Terminal type is unknown!\n");
|
||||
printf("Try set your terminal type with SET TERMINAL/INQUIRE\n");
|
||||
printf
|
||||
("Try set your terminal type with SET TERMINAL/INQUIRE\n");
|
||||
printf("Or get help on SET TERMINAL/DEVICE_TYPE\n");
|
||||
exit(3);
|
||||
}
|
||||
@ -488,10 +494,10 @@ vmskclose()
|
||||
***/
|
||||
#if FNLABEL
|
||||
fnclabel(f, n) /* label a function key */
|
||||
int f,n; /* default flag, numeric argument [unused] */
|
||||
int f, n; /* default flag, numeric argument [unused] */
|
||||
{
|
||||
/* on machines with no function keys...don't bother */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
43
vt52.c
43
vt52.c
@ -54,8 +54,8 @@ extern int vt52bcol();
|
||||
* terminal I/O code.
|
||||
*/
|
||||
TERM term = {
|
||||
NROW-1,
|
||||
NROW-1,
|
||||
NROW - 1,
|
||||
NROW - 1,
|
||||
NCOL,
|
||||
NCOL,
|
||||
MARGIN,
|
||||
@ -87,8 +87,8 @@ vt52move(row, col)
|
||||
{
|
||||
ttputc(ESC);
|
||||
ttputc('Y');
|
||||
ttputc(row+BIAS);
|
||||
ttputc(col+BIAS);
|
||||
ttputc(row + BIAS);
|
||||
ttputc(col + BIAS);
|
||||
}
|
||||
|
||||
vt52eeol()
|
||||
@ -103,33 +103,31 @@ vt52eeop()
|
||||
ttputc('J');
|
||||
}
|
||||
|
||||
vt52rev(status) /* set the reverse video state */
|
||||
|
||||
vt52rev(status)
|
||||
/* set the reverse video state */
|
||||
int status; /* TRUE = reverse video, FALSE = normal video */
|
||||
|
||||
{
|
||||
/* can't do this here, so we won't */
|
||||
}
|
||||
|
||||
vt52cres() /* change screen resolution - (not here though) */
|
||||
|
||||
{
|
||||
return(TRUE);
|
||||
vt52cres()
|
||||
{ /* change screen resolution - (not here though) */
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
spal() /* change palette string */
|
||||
|
||||
{
|
||||
spal()
|
||||
{ /* change palette string */
|
||||
/* Does nothing here */
|
||||
}
|
||||
|
||||
#if COLOR
|
||||
vt52fcol() /* set the forground color [NOT IMPLIMENTED] */
|
||||
{
|
||||
vt52fcol()
|
||||
{ /* set the forground color [NOT IMPLIMENTED] */
|
||||
}
|
||||
|
||||
vt52bcol() /* set the background color [NOT IMPLIMENTED] */
|
||||
{
|
||||
vt52bcol()
|
||||
{ /* set the background color [NOT IMPLIMENTED] */
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -160,30 +158,27 @@ vt52open()
|
||||
}
|
||||
|
||||
vt52kopen()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
vt52kclose()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#if FNLABEL
|
||||
fnclabel(f, n) /* label a function key */
|
||||
|
||||
int f,n; /* default flag, numeric argument [unused] */
|
||||
fnclabel(f, n)
|
||||
/* label a function key */
|
||||
int f, n; /* default flag, numeric argument [unused] */
|
||||
|
||||
{
|
||||
/* on machines with no function keys...don't bother */
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
|
||||
vt52hello()
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
169
window.c
169
window.c
@ -16,30 +16,29 @@
|
||||
* redisplay code does). With no argument it defaults to 0. Bound to M-!.
|
||||
*/
|
||||
reposition(f, n)
|
||||
{
|
||||
{
|
||||
if (f == FALSE) /* default to 0 to center screen */
|
||||
n = 0;
|
||||
curwp->w_force = n;
|
||||
curwp->w_flag |= WFFORCE;
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Refresh the screen. With no argument, it just does the refresh. With an
|
||||
* argument it recenters "." in the current window. Bound to "C-L".
|
||||
*/
|
||||
refresh(f, n)
|
||||
{
|
||||
{
|
||||
if (f == FALSE)
|
||||
sgarbf = TRUE;
|
||||
else
|
||||
{
|
||||
else {
|
||||
curwp->w_force = 0; /* Center dot. */
|
||||
curwp->w_flag |= WFFORCE;
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The command make the next window (next => down the screen) the current
|
||||
@ -79,10 +78,9 @@ int f, n; /* default flag and numeric argument */
|
||||
wp = wp->w_wndp;
|
||||
} else {
|
||||
mlwrite("Window number out of range");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
} else
|
||||
if ((wp = curwp->w_wndp) == NULL)
|
||||
} else if ((wp = curwp->w_wndp) == NULL)
|
||||
wp = wheadp;
|
||||
curwp = wp;
|
||||
curbp = wp->w_bufp;
|
||||
@ -103,7 +101,7 @@ prevwind(f, n)
|
||||
|
||||
/* if we have an argument, we mean the nth window from the bottom */
|
||||
if (f)
|
||||
return(nextwind(f, -n));
|
||||
return (nextwind(f, -n));
|
||||
|
||||
wp1 = wheadp;
|
||||
wp2 = curwp;
|
||||
@ -144,30 +142,26 @@ int n;
|
||||
* "C-X C-P".
|
||||
*/
|
||||
mvupwind(f, n)
|
||||
int n;
|
||||
int n;
|
||||
|
||||
{
|
||||
{
|
||||
register LINE *lp;
|
||||
register int i;
|
||||
|
||||
lp = curwp->w_linep;
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
while (n++ && lp!=curbp->b_linep)
|
||||
if (n < 0) {
|
||||
while (n++ && lp != curbp->b_linep)
|
||||
lp = lforw(lp);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (n-- && lback(lp)!=curbp->b_linep)
|
||||
} else {
|
||||
while (n-- && lback(lp) != curbp->b_linep)
|
||||
lp = lback(lp);
|
||||
}
|
||||
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_flag |= WFHARD; /* Mode line is OK. */
|
||||
|
||||
for (i = 0; i < curwp->w_ntrows; ++i)
|
||||
{
|
||||
for (i = 0; i < curwp->w_ntrows; ++i) {
|
||||
if (lp == curwp->w_dotp)
|
||||
return (TRUE);
|
||||
if (lp == curbp->b_linep)
|
||||
@ -176,7 +170,7 @@ mvupwind(f, n)
|
||||
}
|
||||
|
||||
lp = curwp->w_linep;
|
||||
i = curwp->w_ntrows/2;
|
||||
i = curwp->w_ntrows / 2;
|
||||
|
||||
while (i-- && lp != curbp->b_linep)
|
||||
lp = lforw(lp);
|
||||
@ -184,7 +178,7 @@ mvupwind(f, n)
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = 0;
|
||||
return (TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* This command makes the current window the only window on the screen. Bound
|
||||
@ -223,14 +217,14 @@ onlywind(f, n)
|
||||
}
|
||||
lp = curwp->w_linep;
|
||||
i = curwp->w_toprow;
|
||||
while (i!=0 && lback(lp)!=curbp->b_linep) {
|
||||
while (i != 0 && lback(lp) != curbp->b_linep) {
|
||||
--i;
|
||||
lp = lback(lp);
|
||||
}
|
||||
curwp->w_toprow = 0;
|
||||
curwp->w_ntrows = term.t_nrow-1;
|
||||
curwp->w_ntrows = term.t_nrow - 1;
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_flag |= WFMODE|WFHARD;
|
||||
curwp->w_flag |= WFMODE | WFHARD;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -239,7 +233,7 @@ onlywind(f, n)
|
||||
* or, if it is the top window, the window below. Bound to C-X 0.
|
||||
*/
|
||||
|
||||
delwind(f,n)
|
||||
delwind(f, n)
|
||||
|
||||
int f, n; /* arguments are ignored for this command */
|
||||
|
||||
@ -251,7 +245,7 @@ int f, n; /* arguments are ignored for this command */
|
||||
/* if there is only one window, don't delete it */
|
||||
if (wheadp->w_wndp == NULL) {
|
||||
mlwrite("Can not delete this window");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* find window before curwp in linked list */
|
||||
@ -275,7 +269,7 @@ int f, n; /* arguments are ignored for this command */
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
if (wp == NULL)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
wp->w_toprow = 0;
|
||||
wp->w_ntrows += target;
|
||||
} else {
|
||||
@ -287,7 +281,7 @@ int f, n; /* arguments are ignored for this command */
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
if (wp == NULL)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
wp->w_ntrows += 1 + curwp->w_ntrows;
|
||||
}
|
||||
|
||||
@ -302,13 +296,13 @@ int f, n; /* arguments are ignored for this command */
|
||||
wheadp = curwp->w_wndp;
|
||||
else
|
||||
lwp->w_wndp = curwp->w_wndp;
|
||||
free((char *)curwp);
|
||||
free((char *) curwp);
|
||||
curwp = wp;
|
||||
wp->w_flag |= WFHARD;
|
||||
curbp = wp->w_bufp;
|
||||
cknewwindow();
|
||||
upmode();
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -355,8 +349,8 @@ int f, n; /* default flag and numeric argument */
|
||||
wp->w_fcolor = gfcolor;
|
||||
wp->w_bcolor = gbcolor;
|
||||
#endif
|
||||
ntru = (curwp->w_ntrows-1) / 2; /* Upper size */
|
||||
ntrl = (curwp->w_ntrows-1) - ntru; /* Lower size */
|
||||
ntru = (curwp->w_ntrows - 1) / 2; /* Upper size */
|
||||
ntrl = (curwp->w_ntrows - 1) - ntru; /* Lower size */
|
||||
lp = curwp->w_linep;
|
||||
ntrd = 0;
|
||||
while (lp != curwp->w_dotp) {
|
||||
@ -371,7 +365,7 @@ int f, n; /* default flag and numeric argument */
|
||||
curwp->w_ntrows = ntru;
|
||||
wp->w_wndp = curwp->w_wndp;
|
||||
curwp->w_wndp = wp;
|
||||
wp->w_toprow = curwp->w_toprow+ntru+1;
|
||||
wp->w_toprow = curwp->w_toprow + ntru + 1;
|
||||
wp->w_ntrows = ntrl;
|
||||
} else { /* Old is lower window */
|
||||
wp1 = NULL;
|
||||
@ -395,8 +389,8 @@ int f, n; /* default flag and numeric argument */
|
||||
}
|
||||
curwp->w_linep = lp; /* Adjust the top lines */
|
||||
wp->w_linep = lp; /* if necessary. */
|
||||
curwp->w_flag |= WFMODE|WFHARD;
|
||||
wp->w_flag |= WFMODE|WFHARD;
|
||||
curwp->w_flag |= WFMODE | WFHARD;
|
||||
wp->w_flag |= WFMODE | WFHARD;
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@ -418,7 +412,7 @@ enlargewind(f, n)
|
||||
mlwrite("Only one window");
|
||||
return (FALSE);
|
||||
}
|
||||
if ((adjwp=curwp->w_wndp) == NULL) {
|
||||
if ((adjwp = curwp->w_wndp) == NULL) {
|
||||
adjwp = wheadp;
|
||||
while (adjwp->w_wndp != curwp)
|
||||
adjwp = adjwp->w_wndp;
|
||||
@ -429,13 +423,13 @@ enlargewind(f, n)
|
||||
}
|
||||
if (curwp->w_wndp == adjwp) { /* Shrink below. */
|
||||
lp = adjwp->w_linep;
|
||||
for (i=0; i<n && lp!=adjwp->w_bufp->b_linep; ++i)
|
||||
for (i = 0; i < n && lp != adjwp->w_bufp->b_linep; ++i)
|
||||
lp = lforw(lp);
|
||||
adjwp->w_linep = lp;
|
||||
adjwp->w_toprow += n;
|
||||
} else { /* Shrink above. */
|
||||
lp = curwp->w_linep;
|
||||
for (i=0; i<n && lback(lp)!=curbp->b_linep; ++i)
|
||||
for (i = 0; i < n && lback(lp) != curbp->b_linep; ++i)
|
||||
lp = lback(lp);
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_toprow -= n;
|
||||
@ -443,11 +437,11 @@ enlargewind(f, n)
|
||||
curwp->w_ntrows += n;
|
||||
adjwp->w_ntrows -= n;
|
||||
#if SCROLLCODE
|
||||
curwp->w_flag |= WFMODE|WFHARD|WFINS;
|
||||
adjwp->w_flag |= WFMODE|WFHARD|WFKILLS;
|
||||
curwp->w_flag |= WFMODE | WFHARD | WFINS;
|
||||
adjwp->w_flag |= WFMODE | WFHARD | WFKILLS;
|
||||
#else
|
||||
curwp->w_flag |= WFMODE|WFHARD;
|
||||
adjwp->w_flag |= WFMODE|WFHARD;
|
||||
curwp->w_flag |= WFMODE | WFHARD;
|
||||
adjwp->w_flag |= WFMODE | WFHARD;
|
||||
#endif
|
||||
return (TRUE);
|
||||
}
|
||||
@ -469,7 +463,7 @@ shrinkwind(f, n)
|
||||
mlwrite("Only one window");
|
||||
return (FALSE);
|
||||
}
|
||||
if ((adjwp=curwp->w_wndp) == NULL) {
|
||||
if ((adjwp = curwp->w_wndp) == NULL) {
|
||||
adjwp = wheadp;
|
||||
while (adjwp->w_wndp != curwp)
|
||||
adjwp = adjwp->w_wndp;
|
||||
@ -480,13 +474,14 @@ shrinkwind(f, n)
|
||||
}
|
||||
if (curwp->w_wndp == adjwp) { /* Grow below. */
|
||||
lp = adjwp->w_linep;
|
||||
for (i=0; i<n && lback(lp)!=adjwp->w_bufp->b_linep; ++i)
|
||||
for (i = 0; i < n && lback(lp) != adjwp->w_bufp->b_linep;
|
||||
++i)
|
||||
lp = lback(lp);
|
||||
adjwp->w_linep = lp;
|
||||
adjwp->w_toprow -= n;
|
||||
} else { /* Grow above. */
|
||||
lp = curwp->w_linep;
|
||||
for (i=0; i<n && lp!=curbp->b_linep; ++i)
|
||||
for (i = 0; i < n && lp != curbp->b_linep; ++i)
|
||||
lp = lforw(lp);
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_toprow += n;
|
||||
@ -494,11 +489,11 @@ shrinkwind(f, n)
|
||||
curwp->w_ntrows -= n;
|
||||
adjwp->w_ntrows += n;
|
||||
#if SCROLLCODE
|
||||
curwp->w_flag |= WFMODE|WFHARD|WFKILLS;
|
||||
adjwp->w_flag |= WFMODE|WFHARD|WFINS;
|
||||
curwp->w_flag |= WFMODE | WFHARD | WFKILLS;
|
||||
adjwp->w_flag |= WFMODE | WFHARD | WFINS;
|
||||
#else
|
||||
curwp->w_flag |= WFMODE|WFHARD;
|
||||
adjwp->w_flag |= WFMODE|WFHARD;
|
||||
curwp->w_flag |= WFMODE | WFHARD;
|
||||
adjwp->w_flag |= WFMODE | WFHARD;
|
||||
#endif
|
||||
return (TRUE);
|
||||
}
|
||||
@ -514,16 +509,16 @@ int f, n; /* default flag and numeric argument */
|
||||
|
||||
/* must have a non-default argument, else ignore call */
|
||||
if (f == FALSE)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
/* find out what to do */
|
||||
clines = curwp->w_ntrows;
|
||||
|
||||
/* already the right size? */
|
||||
if (clines == n)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
|
||||
return(enlargewind(TRUE, n - clines));
|
||||
return (enlargewind(TRUE, n - clines));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -531,8 +526,7 @@ int f, n; /* default flag and numeric argument */
|
||||
* Pick the uppermost window that isn't the current window. An LRU algorithm
|
||||
* might be better. Return a pointer, or NULL on error.
|
||||
*/
|
||||
WINDOW *
|
||||
wpopup()
|
||||
WINDOW *wpopup()
|
||||
{
|
||||
register WINDOW *wp;
|
||||
|
||||
@ -540,37 +534,33 @@ wpopup()
|
||||
&& splitwind(FALSE, 0) == FALSE) /* and it won't split */
|
||||
return (NULL);
|
||||
wp = wheadp; /* Find window to use */
|
||||
while (wp!=NULL && wp==curwp)
|
||||
while (wp != NULL && wp == curwp)
|
||||
wp = wp->w_wndp;
|
||||
return (wp);
|
||||
}
|
||||
|
||||
scrnextup(f, n) /* scroll the next window up (back) a page */
|
||||
|
||||
{
|
||||
scrnextup(f, n)
|
||||
{ /* scroll the next window up (back) a page */
|
||||
nextwind(FALSE, 1);
|
||||
backpage(f, n);
|
||||
prevwind(FALSE, 1);
|
||||
}
|
||||
|
||||
scrnextdw(f, n) /* scroll the next window down (forward) a page */
|
||||
|
||||
{
|
||||
scrnextdw(f, n)
|
||||
{ /* scroll the next window down (forward) a page */
|
||||
nextwind(FALSE, 1);
|
||||
forwpage(f, n);
|
||||
prevwind(FALSE, 1);
|
||||
}
|
||||
|
||||
savewnd(f, n) /* save ptr to current window */
|
||||
|
||||
{
|
||||
savewnd(f, n)
|
||||
{ /* save ptr to current window */
|
||||
swindow = curwp;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
restwnd(f, n) /* restore the saved screen */
|
||||
|
||||
{
|
||||
restwnd(f, n)
|
||||
{ /* restore the saved screen */
|
||||
register WINDOW *wp;
|
||||
|
||||
/* find the window */
|
||||
@ -586,11 +576,11 @@ restwnd(f, n) /* restore the saved screen */
|
||||
}
|
||||
|
||||
mlwrite("(No such window exists)");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
newsize(f, n) /* resize the screen, re-writing the screen */
|
||||
|
||||
newsize(f, n)
|
||||
/* resize the screen, re-writing the screen */
|
||||
int f; /* default flag */
|
||||
int n; /* numeric argument */
|
||||
|
||||
@ -607,11 +597,11 @@ int n; /* numeric argument */
|
||||
/* make sure it's in range */
|
||||
if (n < 3 || n > term.t_mrow + 1) {
|
||||
mlwrite("%%Screen size out of range");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if (term.t_nrow == n - 1)
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
else if (term.t_nrow < n - 1) {
|
||||
|
||||
/* go to the last window */
|
||||
@ -621,7 +611,7 @@ int n; /* numeric argument */
|
||||
|
||||
/* and enlarge it as needed */
|
||||
wp->w_ntrows = n - wp->w_toprow - 2;
|
||||
wp->w_flag |= WFHARD|WFMODE;
|
||||
wp->w_flag |= WFHARD | WFMODE;
|
||||
|
||||
} else {
|
||||
|
||||
@ -652,15 +642,16 @@ int n; /* numeric argument */
|
||||
lastwp->w_wndp = NULL;
|
||||
|
||||
/* free the structure */
|
||||
free((char *)wp);
|
||||
free((char *) wp);
|
||||
wp = NULL;
|
||||
|
||||
} else {
|
||||
/* need to change this window size? */
|
||||
lastline = wp->w_toprow + wp->w_ntrows - 1;
|
||||
if (lastline >= n - 2) {
|
||||
wp->w_ntrows = n - wp->w_toprow - 2;
|
||||
wp->w_flag |= WFHARD|WFMODE;
|
||||
wp->w_ntrows =
|
||||
n - wp->w_toprow - 2;
|
||||
wp->w_flag |= WFHARD | WFMODE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,11 +662,11 @@ int n; /* numeric argument */
|
||||
/* screen is garbage */
|
||||
term.t_nrow = n - 1;
|
||||
sgarbf = TRUE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
newwidth(f, n) /* resize the screen, re-writing the screen */
|
||||
|
||||
newwidth(f, n)
|
||||
/* resize the screen, re-writing the screen */
|
||||
int f; /* default flag */
|
||||
int n; /* numeric argument */
|
||||
|
||||
@ -689,7 +680,7 @@ int n; /* numeric argument */
|
||||
/* make sure it's in range */
|
||||
if (n < 10 || n > term.t_mcol) {
|
||||
mlwrite("%%Screen width out of range");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* otherwise, just re-width it (no big deal) */
|
||||
@ -705,12 +696,11 @@ int n; /* numeric argument */
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
int getwpos() /* get screen offset of current line in current window */
|
||||
|
||||
{
|
||||
int getwpos()
|
||||
{ /* get screen offset of current line in current window */
|
||||
register int sline; /* screen line from top of window */
|
||||
register LINE *lp; /* scannile line pointer */
|
||||
|
||||
@ -723,11 +713,10 @@ int getwpos() /* get screen offset of current line in current window */
|
||||
}
|
||||
|
||||
/* and return the value */
|
||||
return(sline);
|
||||
return (sline);
|
||||
}
|
||||
|
||||
cknewwindow()
|
||||
{
|
||||
execute(META|SPEC|'X', FALSE, 1);
|
||||
execute(META | SPEC | 'X', FALSE, 1);
|
||||
}
|
||||
|
||||
|
129
word.c
129
word.c
@ -29,7 +29,7 @@ int n; /* numeric argument */
|
||||
|
||||
/* backup from the <NL> 1 char */
|
||||
if (!backchar(0, 1))
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* back up until we aren't in a word,
|
||||
make sure there is a break in the line */
|
||||
@ -38,28 +38,28 @@ int n; /* numeric argument */
|
||||
&& (c != '\t')) {
|
||||
cnt++;
|
||||
if (!backchar(0, 1))
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
/* if we make it to the beginning, start a new line */
|
||||
if (curwp->w_doto == 0) {
|
||||
gotoeol(FALSE, 0);
|
||||
return(lnewline());
|
||||
return (lnewline());
|
||||
}
|
||||
}
|
||||
|
||||
/* delete the forward white space */
|
||||
if (!forwdel(0, 1))
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* put in a end of line */
|
||||
if (!lnewline())
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
|
||||
/* and past the first word */
|
||||
while (cnt-- > 0) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -105,7 +105,7 @@ forwword(f, n)
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -117,8 +117,8 @@ upperword(f, n)
|
||||
{
|
||||
register int c;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
while (n--) {
|
||||
@ -131,9 +131,9 @@ upperword(f, n)
|
||||
#if PKCODE
|
||||
if (islower(c)) {
|
||||
#else
|
||||
if (c>='a' && c<='z') {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
#endif
|
||||
c -= 'a'-'A';
|
||||
c -= 'a' - 'A';
|
||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||
lchange(WFHARD);
|
||||
}
|
||||
@ -153,8 +153,8 @@ lowerword(f, n)
|
||||
{
|
||||
register int c;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
while (n--) {
|
||||
@ -167,9 +167,9 @@ lowerword(f, n)
|
||||
#if PKCODE
|
||||
if (isupper(c)) {
|
||||
#else
|
||||
if (c>='A' && c<='Z') {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
#endif
|
||||
c += 'a'-'A';
|
||||
c += 'a' - 'A';
|
||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||
lchange(WFHARD);
|
||||
}
|
||||
@ -190,8 +190,8 @@ capword(f, n)
|
||||
{
|
||||
register int c;
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
while (n--) {
|
||||
@ -204,9 +204,9 @@ capword(f, n)
|
||||
#if PKCODE
|
||||
if (islower(c)) {
|
||||
#else
|
||||
if (c>='a' && c<='z') {
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
#endif
|
||||
c -= 'a'-'A';
|
||||
c -= 'a' - 'A';
|
||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||
lchange(WFHARD);
|
||||
}
|
||||
@ -217,10 +217,11 @@ capword(f, n)
|
||||
#if PKCODE
|
||||
if (isupper(c)) {
|
||||
#else
|
||||
if (c>='A' && c<='Z') {
|
||||
if (c >= 'A' && c <= 'Z') {
|
||||
#endif
|
||||
c += 'a'-'A';
|
||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||
c += 'a' - 'A';
|
||||
lputc(curwp->w_dotp, curwp->w_doto,
|
||||
c);
|
||||
lchange(WFHARD);
|
||||
}
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
@ -245,15 +246,15 @@ delfword(f, n)
|
||||
long size; /* # of chars to delete */
|
||||
|
||||
/* don't allow this command if we are in read only mode */
|
||||
if (curbp->b_mode&MDVIEW)
|
||||
return(rdonly());
|
||||
if (curbp->b_mode & MDVIEW)
|
||||
return (rdonly());
|
||||
|
||||
/* ignore the command if there is a negative argument */
|
||||
if (n < 0)
|
||||
return (FALSE);
|
||||
|
||||
/* Clear the kill buffer if last command wasn't a kill */
|
||||
if ((lastflag&CFKILL) == 0)
|
||||
if ((lastflag & CFKILL) == 0)
|
||||
kdelete();
|
||||
thisflag |= CFKILL; /* this command is a kill */
|
||||
|
||||
@ -267,7 +268,7 @@ delfword(f, n)
|
||||
/* get us into a word.... */
|
||||
while (inword() == FALSE) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
++size;
|
||||
}
|
||||
|
||||
@ -275,7 +276,7 @@ delfword(f, n)
|
||||
/* skip one word, no whitespace! */
|
||||
while (inword() == TRUE) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
++size;
|
||||
}
|
||||
} else {
|
||||
@ -285,14 +286,14 @@ delfword(f, n)
|
||||
/* if we are at EOL; skip to the beginning of the next */
|
||||
while (curwp->w_doto == llength(curwp->w_dotp)) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
++size;
|
||||
}
|
||||
|
||||
/* move forward till we are at the end of the word */
|
||||
while (inword() == TRUE) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
++size;
|
||||
}
|
||||
|
||||
@ -300,15 +301,15 @@ delfword(f, n)
|
||||
if (n != 0)
|
||||
while (inword() == FALSE) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
++size;
|
||||
}
|
||||
}
|
||||
|
||||
/* skip whitespace and newlines */
|
||||
while ((curwp->w_doto == llength(curwp->w_dotp)) ||
|
||||
((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ') ||
|
||||
(c == '\t')) {
|
||||
((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ')
|
||||
|| (c == '\t')) {
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
break;
|
||||
++size;
|
||||
@ -331,15 +332,15 @@ delbword(f, n)
|
||||
long size;
|
||||
|
||||
/* don't allow this command if we are in read only mode */
|
||||
if (curbp->b_mode&MDVIEW)
|
||||
return(rdonly());
|
||||
if (curbp->b_mode & MDVIEW)
|
||||
return (rdonly());
|
||||
|
||||
/* ignore the command if there is a nonpositive argument */
|
||||
if (n <= 0)
|
||||
return (FALSE);
|
||||
|
||||
/* Clear the kill buffer if last command wasn't a kill */
|
||||
if ((lastflag&CFKILL) == 0)
|
||||
if ((lastflag & CFKILL) == 0)
|
||||
kdelete();
|
||||
thisflag |= CFKILL; /* this command is a kill */
|
||||
|
||||
@ -360,7 +361,7 @@ delbword(f, n)
|
||||
}
|
||||
if (forwchar(FALSE, 1) == FALSE)
|
||||
return (FALSE);
|
||||
bckdel: return (ldelete(size, TRUE));
|
||||
bckdel:return (ldelete(size, TRUE));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -377,20 +378,20 @@ inword()
|
||||
#if PKCODE
|
||||
if (isletter(c))
|
||||
#else
|
||||
if (c>='a' && c<='z')
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return (TRUE);
|
||||
if (c>='A' && c<='Z')
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
#endif
|
||||
return (TRUE);
|
||||
if (c>='0' && c<='9')
|
||||
if (c >= '0' && c <= '9')
|
||||
return (TRUE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
#if WORDPRO
|
||||
fillpara(f, n) /* Fill the current paragraph according to the current
|
||||
fillpara(f, n)
|
||||
/* Fill the current paragraph according to the current
|
||||
fill column */
|
||||
|
||||
int f, n; /* deFault flag and Numeric argument */
|
||||
|
||||
{
|
||||
@ -405,11 +406,11 @@ int f, n; /* deFault flag and Numeric argument */
|
||||
register int dotflag; /* was the last char a period? */
|
||||
char wbuf[NSTRING]; /* buffer for current word */
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (fillcol == 0) { /* no fill column set */
|
||||
mlwrite("No fill column set");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
#if PKCODE
|
||||
justflag = FALSE;
|
||||
@ -467,7 +468,7 @@ int f, n; /* deFault flag and Numeric argument */
|
||||
}
|
||||
|
||||
/* and add the word in in either case */
|
||||
for (i=0; i<wordlen; i++) {
|
||||
for (i = 0; i < wordlen; i++) {
|
||||
linsert(1, wbuf[i]);
|
||||
++clength;
|
||||
}
|
||||
@ -480,13 +481,13 @@ int f, n; /* deFault flag and Numeric argument */
|
||||
}
|
||||
/* and add a last newline for the end of our new paragraph */
|
||||
lnewline();
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if PKCODE
|
||||
justpara(f, n) /* Fill the current paragraph according to the current
|
||||
justpara(f, n)
|
||||
/* Fill the current paragraph according to the current
|
||||
fill column and cursor position */
|
||||
|
||||
int f, n; /* deFault flag and Numeric argument */
|
||||
|
||||
{
|
||||
@ -501,18 +502,18 @@ int f, n; /* deFault flag and Numeric argument */
|
||||
char wbuf[NSTRING]; /* buffer for current word */
|
||||
int leftmarg; /* left marginal */
|
||||
|
||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
||||
return(rdonly()); /* we are in read only mode */
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return (rdonly()); /* we are in read only mode */
|
||||
if (fillcol == 0) { /* no fill column set */
|
||||
mlwrite("No fill column set");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
justflag = TRUE;
|
||||
leftmarg = curwp->w_doto;
|
||||
if (leftmarg+10 > fillcol) {
|
||||
if (leftmarg + 10 > fillcol) {
|
||||
leftmarg = 0;
|
||||
mlwrite("Column too narrow");
|
||||
return(FALSE);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* record the pointer to the line just past the EOP */
|
||||
@ -565,13 +566,13 @@ int f, n; /* deFault flag and Numeric argument */
|
||||
} else {
|
||||
/* start a new line */
|
||||
lnewline();
|
||||
for (i=0; i<leftmarg; i++)
|
||||
for (i = 0; i < leftmarg; i++)
|
||||
linsert(1, ' ');
|
||||
clength = leftmarg;
|
||||
}
|
||||
|
||||
/* and add the word in in either case */
|
||||
for (i=0; i<wordlen; i++) {
|
||||
for (i = 0; i < wordlen; i++) {
|
||||
linsert(1, wbuf[i]);
|
||||
++clength;
|
||||
}
|
||||
@ -588,12 +589,12 @@ int f, n; /* deFault flag and Numeric argument */
|
||||
curwp->w_doto = llength(curwp->w_dotp);
|
||||
|
||||
justflag = FALSE;
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
killpara(f, n) /* delete n paragraphs starting with the current one */
|
||||
|
||||
killpara(f, n)
|
||||
/* delete n paragraphs starting with the current one */
|
||||
int f; /* default flag */
|
||||
int n; /* # of paras to delete */
|
||||
|
||||
@ -615,12 +616,12 @@ int n; /* # of paras to delete */
|
||||
|
||||
/* and delete it */
|
||||
if ((status = killregion(FALSE, 1)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
|
||||
/* and clean up the 2 extra lines */
|
||||
ldelete(2L, TRUE);
|
||||
}
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
@ -657,7 +658,7 @@ int f, n; /* ignored numeric arguments */
|
||||
|
||||
/* make sure we have a region to count */
|
||||
if ((status = getregion(®ion)) != TRUE)
|
||||
return(status);
|
||||
return (status);
|
||||
lp = region.r_linep;
|
||||
offset = region.r_offset;
|
||||
size = region.r_size;
|
||||
@ -697,7 +698,7 @@ int f, n; /* ignored numeric arguments */
|
||||
|
||||
/* and report on the info */
|
||||
if (nwords > 0L)
|
||||
avgch = (int)((100L * nchars) / nwords);
|
||||
avgch = (int) ((100L * nchars) / nwords);
|
||||
else
|
||||
avgch = 0;
|
||||
|
||||
@ -712,6 +713,6 @@ int f, n; /* ignored numeric arguments */
|
||||
mlwrite("Words %D Chars %D Lines %d Avg chars/word %f",
|
||||
nwords, nchars, nlines + 1, avgch);
|
||||
#endif
|
||||
return(TRUE);
|
||||
return (TRUE);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user