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 = {
|
TERM term = {
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
MROW-1,
|
MROW - 1,
|
||||||
#else
|
#else
|
||||||
NROW-1,
|
NROW - 1,
|
||||||
#endif
|
#endif
|
||||||
NROW-1,
|
NROW - 1,
|
||||||
NCOL,
|
NCOL,
|
||||||
NCOL,
|
NCOL,
|
||||||
MARGIN,
|
MARGIN,
|
||||||
@ -91,8 +91,8 @@ TERM term = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if COLOR
|
#if COLOR
|
||||||
ansifcol(color) /* set the current output color */
|
ansifcol(color)
|
||||||
|
/* set the current output color */
|
||||||
int color; /* color to set */
|
int color; /* color to set */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -100,13 +100,13 @@ int color; /* color to set */
|
|||||||
return;
|
return;
|
||||||
ttputc(ESC);
|
ttputc(ESC);
|
||||||
ttputc('[');
|
ttputc('[');
|
||||||
ansiparm(color+30);
|
ansiparm(color + 30);
|
||||||
ttputc('m');
|
ttputc('m');
|
||||||
cfcolor = color;
|
cfcolor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
ansibcol(color) /* set the current background color */
|
ansibcol(color)
|
||||||
|
/* set the current background color */
|
||||||
int color; /* color to set */
|
int color; /* color to set */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -114,7 +114,7 @@ int color; /* color to set */
|
|||||||
return;
|
return;
|
||||||
ttputc(ESC);
|
ttputc(ESC);
|
||||||
ttputc('[');
|
ttputc('[');
|
||||||
ansiparm(color+40);
|
ansiparm(color + 40);
|
||||||
ttputc('m');
|
ttputc('m');
|
||||||
cbcolor = color;
|
cbcolor = color;
|
||||||
}
|
}
|
||||||
@ -124,9 +124,9 @@ ansimove(row, col)
|
|||||||
{
|
{
|
||||||
ttputc(ESC);
|
ttputc(ESC);
|
||||||
ttputc('[');
|
ttputc('[');
|
||||||
ansiparm(row+1);
|
ansiparm(row + 1);
|
||||||
ttputc(';');
|
ttputc(';');
|
||||||
ansiparm(col+1);
|
ansiparm(col + 1);
|
||||||
ttputc('H');
|
ttputc('H');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,8 +148,8 @@ ansieeop()
|
|||||||
ttputc('J');
|
ttputc('J');
|
||||||
}
|
}
|
||||||
|
|
||||||
ansirev(state) /* change reverse video state */
|
ansirev(state)
|
||||||
|
/* change reverse video state */
|
||||||
int state; /* TRUE = reverse, FALSE = normal */
|
int state; /* TRUE = reverse, FALSE = normal */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -159,7 +159,7 @@ int state; /* TRUE = reverse, FALSE = normal */
|
|||||||
|
|
||||||
ttputc(ESC);
|
ttputc(ESC);
|
||||||
ttputc('[');
|
ttputc('[');
|
||||||
ttputc(state ? '7': '0');
|
ttputc(state ? '7' : '0');
|
||||||
ttputc('m');
|
ttputc('m');
|
||||||
#if COLOR
|
#if COLOR
|
||||||
if (state == FALSE) {
|
if (state == FALSE) {
|
||||||
@ -173,15 +173,13 @@ int state; /* TRUE = reverse, FALSE = normal */
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ansicres() /* change screen resolution */
|
ansicres()
|
||||||
|
{ /* change screen resolution */
|
||||||
{
|
return (TRUE);
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spal(dummy) /* change pallette settings */
|
spal(dummy)
|
||||||
|
{ /* change pallette settings */
|
||||||
{
|
|
||||||
/* none for now */
|
/* none for now */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,17 +192,17 @@ ansibeep()
|
|||||||
ansiparm(n)
|
ansiparm(n)
|
||||||
register int n;
|
register int n;
|
||||||
{
|
{
|
||||||
register int q,r;
|
register int q, r;
|
||||||
|
|
||||||
q = n/10;
|
q = n / 10;
|
||||||
if (q != 0) {
|
if (q != 0) {
|
||||||
r = q/10;
|
r = q / 10;
|
||||||
if (r != 0) {
|
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()
|
ansiopen()
|
||||||
@ -228,7 +226,6 @@ ansiopen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ansiclose()
|
ansiclose()
|
||||||
|
|
||||||
{
|
{
|
||||||
#if COLOR
|
#if COLOR
|
||||||
ansifcol(7);
|
ansifcol(7);
|
||||||
@ -237,24 +234,22 @@ ansiclose()
|
|||||||
ttclose();
|
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
|
#if FNLABEL
|
||||||
fnclabel(f, n) /* label a function key */
|
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 */
|
/* on machines with no function keys...don't bother */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
58
basic.c
58
basic.c
@ -39,7 +39,7 @@ register int n;
|
|||||||
return (forwchar(f, -n));
|
return (forwchar(f, -n));
|
||||||
while (n--) {
|
while (n--) {
|
||||||
if (curwp->w_doto == 0) {
|
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);
|
return (FALSE);
|
||||||
curwp->w_dotp = lp;
|
curwp->w_dotp = lp;
|
||||||
curwp->w_doto = llength(lp);
|
curwp->w_doto = llength(lp);
|
||||||
@ -83,30 +83,30 @@ register int n;
|
|||||||
return (TRUE);
|
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
|
argument (n) must be a positive integer for
|
||||||
this to actually do anything */
|
this to actually do anything */
|
||||||
|
|
||||||
{
|
|
||||||
register int status; /* status return */
|
register int status; /* status return */
|
||||||
char arg[NSTRING]; /* buffer to hold argument */
|
char arg[NSTRING]; /* buffer to hold argument */
|
||||||
|
|
||||||
/* get an argument if one doesnt exist */
|
/* get an argument if one doesnt exist */
|
||||||
if (f == FALSE) {
|
if (f == FALSE) {
|
||||||
if ((status = mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
|
if ((status =
|
||||||
|
mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
|
||||||
mlwrite("(Aborted)");
|
mlwrite("(Aborted)");
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
n = atoi(arg);
|
n = atoi(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n < 1) /* if a bogus argument...then leave */
|
if (n < 1) /* if a bogus argument...then leave */
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* first, we go to the start of the buffer */
|
/* first, we go to the start of the buffer */
|
||||||
curwp->w_dotp = lforw(curbp->b_linep);
|
curwp->w_dotp = lforw(curbp->b_linep);
|
||||||
curwp->w_doto = 0;
|
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 we are on the last line as we start....fail the command */
|
||||||
if (curwp->w_dotp == curbp->b_linep)
|
if (curwp->w_dotp == curbp->b_linep)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* if the last command was not note a line move,
|
/* if the last command was not note a line move,
|
||||||
reset the goal column */
|
reset the goal column */
|
||||||
if ((lastflag&CFCPCN) == 0)
|
if ((lastflag & CFCPCN) == 0)
|
||||||
curgoal = getccol(FALSE);
|
curgoal = getccol(FALSE);
|
||||||
|
|
||||||
/* flag this command as a line move */
|
/* flag this command as a line move */
|
||||||
@ -162,7 +162,7 @@ forwline(f, n)
|
|||||||
|
|
||||||
/* and move the point down */
|
/* and move the point down */
|
||||||
dlp = curwp->w_dotp;
|
dlp = curwp->w_dotp;
|
||||||
while (n-- && dlp!=curbp->b_linep)
|
while (n-- && dlp != curbp->b_linep)
|
||||||
dlp = lforw(dlp);
|
dlp = lforw(dlp);
|
||||||
|
|
||||||
/* reseting the current position */
|
/* 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 we are on the last line as we start....fail the command */
|
||||||
if (lback(curwp->w_dotp) == curbp->b_linep)
|
if (lback(curwp->w_dotp) == curbp->b_linep)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* if the last command was not note a line move,
|
/* if the last command was not note a line move,
|
||||||
reset the goal column */
|
reset the goal column */
|
||||||
if ((lastflag&CFCPCN) == 0)
|
if ((lastflag & CFCPCN) == 0)
|
||||||
curgoal = getccol(FALSE);
|
curgoal = getccol(FALSE);
|
||||||
|
|
||||||
/* flag this command as a line move */
|
/* flag this command as a line move */
|
||||||
@ -200,7 +200,7 @@ backline(f, n)
|
|||||||
|
|
||||||
/* and move the point up */
|
/* and move the point up */
|
||||||
dlp = curwp->w_dotp;
|
dlp = curwp->w_dotp;
|
||||||
while (n-- && lback(dlp)!=curbp->b_linep)
|
while (n-- && lback(dlp) != curbp->b_linep)
|
||||||
dlp = lback(dlp);
|
dlp = lback(dlp);
|
||||||
|
|
||||||
/* reseting the current position */
|
/* reseting the current position */
|
||||||
@ -211,17 +211,17 @@ backline(f, n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if WORDPRO
|
#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>
|
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
|
||||||
combination to delimit the beginning of a paragraph */
|
combination to delimit the beginning of a paragraph */
|
||||||
|
|
||||||
int f, n; /* default Flag & Numeric argument */
|
int f, n; /* default Flag & Numeric argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int suc; /* success of last backchar */
|
register int suc; /* success of last backchar */
|
||||||
|
|
||||||
if (n < 0) /* the other way...*/
|
if (n < 0) /* the other way... */
|
||||||
return(gotoeop(f, -n));
|
return (gotoeop(f, -n));
|
||||||
|
|
||||||
while (n-- > 0) { /* for each one asked for */
|
while (n-- > 0) { /* for each one asked for */
|
||||||
|
|
||||||
@ -253,20 +253,20 @@ int f, n; /* default Flag & Numeric argument */
|
|||||||
suc = forwchar(FALSE, 1);
|
suc = forwchar(FALSE, 1);
|
||||||
}
|
}
|
||||||
curwp->w_flag |= WFMOVE; /* force screen update */
|
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>
|
here we look for a <NL><NL> or <NL><TAB> or <NL><SPACE>
|
||||||
combination to delimit the beginning of a paragraph */
|
combination to delimit the beginning of a paragraph */
|
||||||
|
|
||||||
int f, n; /* default Flag & Numeric argument */
|
int f, n; /* default Flag & Numeric argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int suc; /* success of last backchar */
|
register int suc; /* success of last backchar */
|
||||||
|
|
||||||
if (n < 0) /* the other way...*/
|
if (n < 0) /* the other way... */
|
||||||
return(gotobop(f, -n));
|
return (gotobop(f, -n));
|
||||||
|
|
||||||
while (n-- > 0) { /* for each one asked for */
|
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_doto = llength(curwp->w_dotp); /* and to the EOL */
|
||||||
}
|
}
|
||||||
curwp->w_flag |= WFMOVE; /* force screen update */
|
curwp->w_flag |= WFMOVE; /* force screen update */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ register LINE *dlp;
|
|||||||
newcol = col;
|
newcol = col;
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
newcol |= tabmask;
|
newcol |= tabmask;
|
||||||
else if (c<0x20 || c==0x7F)
|
else if (c < 0x20 || c == 0x7F)
|
||||||
++newcol;
|
++newcol;
|
||||||
++newcol;
|
++newcol;
|
||||||
if (newcol > curgoal)
|
if (newcol > curgoal)
|
||||||
@ -368,13 +368,13 @@ register int n;
|
|||||||
n *= curwp->w_ntrows; /* to lines. */
|
n *= curwp->w_ntrows; /* to lines. */
|
||||||
#endif
|
#endif
|
||||||
lp = curwp->w_linep;
|
lp = curwp->w_linep;
|
||||||
while (n-- && lp!=curbp->b_linep)
|
while (n-- && lp != curbp->b_linep)
|
||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_dotp = lp;
|
curwp->w_dotp = lp;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFHARD|WFKILLS;
|
curwp->w_flag |= WFHARD | WFKILLS;
|
||||||
#else
|
#else
|
||||||
curwp->w_flag |= WFHARD;
|
curwp->w_flag |= WFHARD;
|
||||||
#endif
|
#endif
|
||||||
@ -411,13 +411,13 @@ register int n;
|
|||||||
n *= curwp->w_ntrows; /* to lines. */
|
n *= curwp->w_ntrows; /* to lines. */
|
||||||
#endif
|
#endif
|
||||||
lp = curwp->w_linep;
|
lp = curwp->w_linep;
|
||||||
while (n-- && lback(lp)!=curbp->b_linep)
|
while (n-- && lback(lp) != curbp->b_linep)
|
||||||
lp = lback(lp);
|
lp = lback(lp);
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_dotp = lp;
|
curwp->w_dotp = lp;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFHARD|WFINS;
|
curwp->w_flag |= WFHARD | WFINS;
|
||||||
#else
|
#else
|
||||||
curwp->w_flag |= WFHARD;
|
curwp->w_flag |= WFHARD;
|
||||||
#endif
|
#endif
|
||||||
|
147
bind.c
147
bind.c
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
extern int meta(), cex(), unarg(), ctrlg(); /* dummy prefix binding functions */
|
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
|
bring up a fake buffer and read the help file
|
||||||
into it with view mode */
|
into it with view mode */
|
||||||
{
|
|
||||||
register WINDOW *wp; /* scaning pointer to windows */
|
register WINDOW *wp; /* scaning pointer to windows */
|
||||||
register BUFFER *bp; /* buffer pointer to help */
|
register BUFFER *bp; /* buffer pointer to help */
|
||||||
char *fname; /* ptr to file returned by flook() */
|
char *fname; /* ptr to file returned by flook() */
|
||||||
@ -29,18 +29,18 @@ help(f, n) /* give me some help!!!!
|
|||||||
fname = flook(pathname[1], FALSE);
|
fname = flook(pathname[1], FALSE);
|
||||||
if (fname == NULL) {
|
if (fname == NULL) {
|
||||||
mlwrite("(Help file is not online)");
|
mlwrite("(Help file is not online)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* split the current window to make room for the help stuff */
|
/* split the current window to make room for the help stuff */
|
||||||
if (splitwind(FALSE, 1) == FALSE)
|
if (splitwind(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
if (bp == NULL) {
|
if (bp == NULL) {
|
||||||
/* and read the stuff in */
|
/* and read the stuff in */
|
||||||
if (getfile(fname, FALSE) == FALSE)
|
if (getfile(fname, FALSE) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
} else
|
} else
|
||||||
swbuffer(bp);
|
swbuffer(bp);
|
||||||
|
|
||||||
@ -52,16 +52,15 @@ help(f, n) /* give me some help!!!!
|
|||||||
wp->w_flag |= WFMODE;
|
wp->w_flag |= WFMODE;
|
||||||
wp = wp->w_wndp;
|
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 int c; /* key to describe */
|
||||||
register char *ptr; /* string pointer to scan output strings */
|
register char *ptr; /* string pointer to scan output strings */
|
||||||
char outseq[NSTRING]; /* output buffer for command sequence */
|
char outseq[NSTRING]; /* output buffer for command sequence */
|
||||||
int (*getbind())();
|
int (*getbind()) ();
|
||||||
|
|
||||||
/* prompt the user to type us a key to describe */
|
/* prompt the user to type us a key to describe */
|
||||||
mlwrite(": describe-key ");
|
mlwrite(": describe-key ");
|
||||||
@ -89,12 +88,12 @@ bindtokey(f, n)
|
|||||||
int f, n; /* command arguments [IGNORED] */
|
int f, n; /* command arguments [IGNORED] */
|
||||||
|
|
||||||
{
|
{
|
||||||
register unsigned int c;/* command key to bind */
|
register unsigned int c; /* command key to bind */
|
||||||
register int (*kfunc)();/* ptr to the requested function to bind to */
|
register int (*kfunc) (); /* ptr to the requested function to bind to */
|
||||||
register KEYTAB *ktp; /* pointer into the command table */
|
register KEYTAB *ktp; /* pointer into the command table */
|
||||||
register int found; /* matched command flag */
|
register int found; /* matched command flag */
|
||||||
char outseq[80]; /* output buffer for keystroke sequence */
|
char outseq[80]; /* output buffer for keystroke sequence */
|
||||||
int (*getname())();
|
int (*getname()) ();
|
||||||
|
|
||||||
/* prompt the user to type in a key to bind */
|
/* prompt the user to type in a key to bind */
|
||||||
mlwrite(": bind-to-key ");
|
mlwrite(": bind-to-key ");
|
||||||
@ -103,7 +102,7 @@ int f, n; /* command arguments [IGNORED] */
|
|||||||
kfunc = getname();
|
kfunc = getname();
|
||||||
if (kfunc == NULL) {
|
if (kfunc == NULL) {
|
||||||
mlwrite("(No such function)");
|
mlwrite("(No such function)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
ostring(" ");
|
ostring(" ");
|
||||||
|
|
||||||
@ -158,7 +157,7 @@ int f, n; /* command arguments [IGNORED] */
|
|||||||
/* if we run out of binding room, bitch */
|
/* if we run out of binding room, bitch */
|
||||||
if (ktp >= &keytab[NBINDS]) {
|
if (ktp >= &keytab[NBINDS]) {
|
||||||
mlwrite("Binding table FULL!");
|
mlwrite("Binding table FULL!");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ktp->k_code = c; /* add keycode */
|
ktp->k_code = c; /* add keycode */
|
||||||
@ -167,7 +166,7 @@ int f, n; /* command arguments [IGNORED] */
|
|||||||
ktp->k_code = 0;
|
ktp->k_code = 0;
|
||||||
ktp->k_fp = NULL;
|
ktp->k_fp = NULL;
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unbindkey: delete a key from the key binding table */
|
/* 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 it isn't bound, bitch */
|
||||||
if (unbindchar(c) == FALSE) {
|
if (unbindchar(c) == FALSE) {
|
||||||
mlwrite("(Key not bound)");
|
mlwrite("(Key not bound)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
unbindchar(c)
|
unbindchar(c)
|
||||||
@ -222,7 +221,7 @@ int c; /* command key to unbind */
|
|||||||
|
|
||||||
/* if it isn't bound, bitch */
|
/* if it isn't bound, bitch */
|
||||||
if (!found)
|
if (!found)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* save the pointer and scan to the end of the table */
|
/* save the pointer and scan to the end of the table */
|
||||||
sktp = ktp;
|
sktp = ktp;
|
||||||
@ -237,33 +236,32 @@ int c; /* command key to unbind */
|
|||||||
/* null out the last one */
|
/* null out the last one */
|
||||||
ktp->k_code = 0;
|
ktp->k_code = 0;
|
||||||
ktp->k_fp = NULL;
|
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
|
bring up a fake buffer and list the key bindings
|
||||||
into it with view mode */
|
into it with view mode */
|
||||||
|
|
||||||
#if APROP
|
#if APROP
|
||||||
{
|
{
|
||||||
buildlist(TRUE, "");
|
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 */
|
char mstring[NSTRING]; /* string to match cmd names to */
|
||||||
int status; /* status return */
|
int status; /* status return */
|
||||||
|
|
||||||
status = mlreply("Apropos string: ", mstring, NSTRING - 1);
|
status = mlreply("Apropos string: ", mstring, NSTRING - 1);
|
||||||
if (status != TRUE)
|
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 */
|
int type; /* true = full list, false = partial list */
|
||||||
char *mstring; /* match string if a 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 */
|
/* split the current window to make room for the binding list */
|
||||||
if (splitwind(FALSE, 1) == FALSE)
|
if (splitwind(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* and get a buffer for it */
|
/* and get a buffer for it */
|
||||||
bp = bfind("*Binding list*", TRUE, 0);
|
bp = bfind("*Binding list*", TRUE, 0);
|
||||||
if (bp == NULL || bclear(bp) == FALSE) {
|
if (bp == NULL || bclear(bp) == FALSE) {
|
||||||
mlwrite("Can not display binding list");
|
mlwrite("Can not display binding list");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let us know this is in progress */
|
/* let us know this is in progress */
|
||||||
@ -306,7 +304,7 @@ char *mstring; /* match string if a partial list */
|
|||||||
wp = curwp;
|
wp = curwp;
|
||||||
wp->w_bufp = bp;
|
wp->w_bufp = bp;
|
||||||
wp->w_linep = bp->b_linep;
|
wp->w_linep = bp->b_linep;
|
||||||
wp->w_flag = WFHARD|WFFORCE;
|
wp->w_flag = WFHARD | WFFORCE;
|
||||||
wp->w_dotp = bp->b_dotp;
|
wp->w_dotp = bp->b_dotp;
|
||||||
wp->w_doto = bp->b_doto;
|
wp->w_doto = bp->b_doto;
|
||||||
wp->w_markp = NULL;
|
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 */
|
/* and add it as a line into the buffer */
|
||||||
if (linstr(outseq) != TRUE)
|
if (linstr(outseq) != TRUE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
cpos = 0; /* and clear the line */
|
cpos = 0; /* and clear the line */
|
||||||
}
|
}
|
||||||
@ -353,16 +351,16 @@ char *mstring; /* match string if a partial list */
|
|||||||
outseq[cpos++] = '\n';
|
outseq[cpos++] = '\n';
|
||||||
outseq[cpos] = 0;
|
outseq[cpos] = 0;
|
||||||
if (linstr(outseq) != TRUE)
|
if (linstr(outseq) != TRUE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
fail: /* and on to the next name */
|
fail: /* and on to the next name */
|
||||||
++nptr;
|
++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 */
|
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->w_doto = 0;
|
||||||
wp = wheadp; /* and update ALL mode lines */
|
wp = wheadp; /* and update ALL mode lines */
|
||||||
while (wp != NULL) {
|
while (wp != NULL) {
|
||||||
@ -370,12 +368,12 @@ fail: /* and on to the next name */
|
|||||||
wp = wp->w_wndp;
|
wp = wp->w_wndp;
|
||||||
}
|
}
|
||||||
mlwrite(""); /* clear the mode line */
|
mlwrite(""); /* clear the mode line */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if APROP
|
#if APROP
|
||||||
strinc(source, sub) /* does source include sub? */
|
strinc(source, sub)
|
||||||
|
/* does source include sub? */
|
||||||
char *source; /* string to search in */
|
char *source; /* string to search in */
|
||||||
char *sub; /* substring to look for */
|
char *sub; /* substring to look for */
|
||||||
|
|
||||||
@ -400,12 +398,12 @@ char *sub; /* substring to look for */
|
|||||||
|
|
||||||
/* yes, return a success */
|
/* yes, return a success */
|
||||||
if (*tp == 0)
|
if (*tp == 0)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* no, onward */
|
/* no, onward */
|
||||||
sp++;
|
sp++;
|
||||||
}
|
}
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -422,7 +420,7 @@ int mflag; /* going for a meta sequence? */
|
|||||||
/* check to see if we are executing a command line */
|
/* check to see if we are executing a command line */
|
||||||
if (clexec) {
|
if (clexec) {
|
||||||
macarg(tok); /* get the next token */
|
macarg(tok); /* get the next token */
|
||||||
return(stock(tok));
|
return (stock(tok));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* or the normal way */
|
/* or the normal way */
|
||||||
@ -430,7 +428,7 @@ int mflag; /* going for a meta sequence? */
|
|||||||
c = get1key();
|
c = get1key();
|
||||||
else
|
else
|
||||||
c = getcmd();
|
c = getcmd();
|
||||||
return(c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execute the startup file */
|
/* 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 it isn't around, don't sweat it */
|
||||||
if (fname == NULL)
|
if (fname == NULL)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* otherwise, execute the sucker */
|
/* otherwise, execute the sucker */
|
||||||
return(dofile(fname));
|
return (dofile(fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look up the existance of a file along the normal or PATH
|
/* 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 */
|
/* and try it out */
|
||||||
if (ffropen(fspec) == FIOSUC) {
|
if (ffropen(fspec) == FIOSUC) {
|
||||||
ffclose();
|
ffclose();
|
||||||
return(fspec);
|
return (fspec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -496,9 +494,8 @@ int hflag; /* Look in the HOME environment variable first? */
|
|||||||
/* always try the current directory first */
|
/* always try the current directory first */
|
||||||
if (ffropen(fname) == FIOSUC) {
|
if (ffropen(fname) == FIOSUC) {
|
||||||
ffclose();
|
ffclose();
|
||||||
return(fname);
|
return (fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENVFUNC
|
#if ENVFUNC
|
||||||
/* get the PATH variable */
|
/* get the PATH variable */
|
||||||
path = getenv("PATH");
|
path = getenv("PATH");
|
||||||
@ -519,7 +516,7 @@ int hflag; /* Look in the HOME environment variable first? */
|
|||||||
/* and try it out */
|
/* and try it out */
|
||||||
if (ffropen(fspec) == FIOSUC) {
|
if (ffropen(fspec) == FIOSUC) {
|
||||||
ffclose();
|
ffclose();
|
||||||
return(fspec);
|
return (fspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*path == PATHCHR)
|
if (*path == PATHCHR)
|
||||||
@ -528,22 +525,22 @@ int hflag; /* Look in the HOME environment variable first? */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* look it up via the old table method */
|
/* look it up via the old table method */
|
||||||
for (i=2; i < NPNAMES; i++) {
|
for (i = 2; i < NPNAMES; i++) {
|
||||||
strcpy(fspec, pathname[i]);
|
strcpy(fspec, pathname[i]);
|
||||||
strcat(fspec, fname);
|
strcat(fspec, fname);
|
||||||
|
|
||||||
/* and try it out */
|
/* and try it out */
|
||||||
if (ffropen(fspec) == FIOSUC) {
|
if (ffropen(fspec) == FIOSUC) {
|
||||||
ffclose();
|
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 */
|
int c; /* sequence to translate */
|
||||||
char *seq; /* destination string for sequence */
|
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 */
|
/* 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 */
|
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. */
|
ktp = &keytab[0]; /* Look in key table. */
|
||||||
while (ktp->k_fp != NULL) {
|
while (ktp->k_fp != NULL) {
|
||||||
if (ktp->k_code == c)
|
if (ktp->k_code == c)
|
||||||
return(ktp->k_fp);
|
return (ktp->k_fp);
|
||||||
++ktp;
|
++ktp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no such binding */
|
/* no such binding */
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getfname: This function takes a ptr to function and gets the name
|
/* 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)
|
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 */
|
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];
|
nptr = &names[0];
|
||||||
while (nptr->n_func != NULL) {
|
while (nptr->n_func != NULL) {
|
||||||
if (nptr->n_func == func)
|
if (nptr->n_func == func)
|
||||||
return(nptr->n_name);
|
return (nptr->n_name);
|
||||||
++nptr;
|
++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 */
|
and return any match or NULL if none */
|
||||||
|
|
||||||
char *fname; /* name to attempt to match */
|
char *fname; /* name to attempt to match */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -635,10 +632,10 @@ char *fname; /* name to attempt to match */
|
|||||||
ffp = &names[0];
|
ffp = &names[0];
|
||||||
while (ffp->n_func != NULL) {
|
while (ffp->n_func != NULL) {
|
||||||
if (strcmp(fname, ffp->n_name) == 0)
|
if (strcmp(fname, ffp->n_name) == 0)
|
||||||
return(ffp->n_func);
|
return (ffp->n_func);
|
||||||
++ffp;
|
++ffp;
|
||||||
}
|
}
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stock: String key name TO Command Key */
|
/* stock: String key name TO Command Key */
|
||||||
@ -654,25 +651,25 @@ char *keyname; /* name of key to translate to Command key form */
|
|||||||
c = 0;
|
c = 0;
|
||||||
|
|
||||||
/* first, the META prefix */
|
/* first, the META prefix */
|
||||||
if (*keyname == 'M' && *(keyname+1) == '-') {
|
if (*keyname == 'M' && *(keyname + 1) == '-') {
|
||||||
c = META;
|
c = META;
|
||||||
keyname += 2;
|
keyname += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* next the function prefix */
|
/* next the function prefix */
|
||||||
if (*keyname == 'F' && *(keyname+1) == 'N') {
|
if (*keyname == 'F' && *(keyname + 1) == 'N') {
|
||||||
c |= SPEC;
|
c |= SPEC;
|
||||||
keyname += 2;
|
keyname += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* control-x as well... (but not with FN) */
|
/* control-x as well... (but not with FN) */
|
||||||
if (*keyname == '^' && *(keyname+1) == 'X'&& !(c & SPEC)) {
|
if (*keyname == '^' && *(keyname + 1) == 'X' && !(c & SPEC)) {
|
||||||
c |= CTLX;
|
c |= CTLX;
|
||||||
keyname += 2;
|
keyname += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a control char? */
|
/* a control char? */
|
||||||
if (*keyname == '^' && *(keyname+1) != 0) {
|
if (*keyname == '^' && *(keyname + 1) != 0) {
|
||||||
c |= CONTROL;
|
c |= CONTROL;
|
||||||
++keyname;
|
++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))
|
if (*keyname >= 'a' && *keyname <= 'z' && !(c & SPEC))
|
||||||
*keyname -= 32;
|
*keyname -= 32;
|
||||||
|
|
||||||
/* the final sequence... */
|
/* the final sequence... */
|
||||||
c |= *keyname;
|
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 *skey; /* name of keey to get binding for */
|
||||||
|
|
||||||
{
|
{
|
||||||
char *bindname;
|
char *bindname;
|
||||||
unsigned int stock();
|
unsigned int stock();
|
||||||
int (*getbind())();
|
int (*getbind()) ();
|
||||||
|
|
||||||
bindname = getfname(getbind(stock(skey)));
|
bindname = getfname(getbind(stock(skey)));
|
||||||
if (bindname == NULL)
|
if (bindname == NULL)
|
||||||
bindname = "ERROR";
|
bindname = "ERROR";
|
||||||
|
|
||||||
return(bindname);
|
return (bindname);
|
||||||
}
|
}
|
||||||
|
117
buffer.c
117
buffer.c
@ -25,25 +25,25 @@ usebuffer(f, n)
|
|||||||
register int s;
|
register int s;
|
||||||
char bufn[NBUFN];
|
char bufn[NBUFN];
|
||||||
|
|
||||||
if ((s=mlreply("Use buffer: ", bufn, NBUFN)) != TRUE)
|
if ((s = mlreply("Use buffer: ", bufn, NBUFN)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
if ((bp=bfind(bufn, TRUE, 0)) == NULL)
|
if ((bp = bfind(bufn, TRUE, 0)) == NULL)
|
||||||
return (FALSE);
|
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 */
|
int f, n; /* default flag, numeric argument */
|
||||||
{
|
{
|
||||||
register BUFFER *bp; /* eligable buffer to switch to*/
|
register BUFFER *bp; /* eligable buffer to switch to */
|
||||||
register BUFFER *bbp; /* eligable buffer to switch to*/
|
register BUFFER *bbp; /* eligable buffer to switch to */
|
||||||
|
|
||||||
/* make sure the arg is legit */
|
/* make sure the arg is legit */
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
n = 1;
|
n = 1;
|
||||||
if (n < 1)
|
if (n < 1)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
bbp = curbp;
|
bbp = curbp;
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
@ -59,18 +59,18 @@ int f, n; /* default flag, numeric argument */
|
|||||||
|
|
||||||
/* don't get caught in an infinite loop! */
|
/* don't get caught in an infinite loop! */
|
||||||
if (bp == bbp)
|
if (bp == bbp)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bbp = bp;
|
bbp = bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(swbuffer(bp));
|
return (swbuffer(bp));
|
||||||
}
|
}
|
||||||
|
|
||||||
swbuffer(bp) /* make buffer BP current */
|
swbuffer(bp)
|
||||||
|
/* make buffer BP current */
|
||||||
BUFFER *bp;
|
BUFFER *bp;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ BUFFER *bp;
|
|||||||
curbp->b_marko = curwp->w_marko;
|
curbp->b_marko = curwp->w_marko;
|
||||||
}
|
}
|
||||||
curbp = bp; /* Switch. */
|
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 */
|
/* read it in and activate it */
|
||||||
readin(curbp->b_fname, TRUE);
|
readin(curbp->b_fname, TRUE);
|
||||||
curbp->b_dotp = lforw(curbp->b_linep);
|
curbp->b_dotp = lforw(curbp->b_linep);
|
||||||
@ -93,7 +93,7 @@ BUFFER *bp;
|
|||||||
}
|
}
|
||||||
curwp->w_bufp = bp;
|
curwp->w_bufp = bp;
|
||||||
curwp->w_linep = bp->b_linep; /* For macros, ignored. */
|
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. */
|
if (bp->b_nwnd++ == 0) { /* First use. */
|
||||||
curwp->w_dotp = bp->b_dotp;
|
curwp->w_dotp = bp->b_dotp;
|
||||||
curwp->w_doto = bp->b_doto;
|
curwp->w_doto = bp->b_doto;
|
||||||
@ -104,7 +104,7 @@ BUFFER *bp;
|
|||||||
}
|
}
|
||||||
wp = wheadp; /* Look for old. */
|
wp = wheadp; /* Look for old. */
|
||||||
while (wp != NULL) {
|
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_dotp = wp->w_dotp;
|
||||||
curwp->w_doto = wp->w_doto;
|
curwp->w_doto = wp->w_doto;
|
||||||
curwp->w_markp = wp->w_markp;
|
curwp->w_markp = wp->w_markp;
|
||||||
@ -126,23 +126,22 @@ BUFFER *bp;
|
|||||||
* line and the buffer header. Bound to "C-X K".
|
* line and the buffer header. Bound to "C-X K".
|
||||||
*/
|
*/
|
||||||
killbuffer(f, n)
|
killbuffer(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
register BUFFER *bp;
|
register BUFFER *bp;
|
||||||
register int s;
|
register int s;
|
||||||
char bufn[NBUFN];
|
char bufn[NBUFN];
|
||||||
|
|
||||||
if ((s=mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
|
if ((s = mlreply("Kill buffer: ", bufn, NBUFN)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
if ((bp=bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
|
if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
|
||||||
return (TRUE);
|
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 (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;
|
register BUFFER *bp;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -154,7 +153,7 @@ register BUFFER *bp;
|
|||||||
mlwrite("Buffer is being displayed");
|
mlwrite("Buffer is being displayed");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if ((s=bclear(bp)) != TRUE) /* Blow text away. */
|
if ((s = bclear(bp)) != TRUE) /* Blow text away. */
|
||||||
return (s);
|
return (s);
|
||||||
free((char *) bp->b_linep); /* Release header line. */
|
free((char *) bp->b_linep); /* Release header line. */
|
||||||
bp1 = NULL; /* Find the header. */
|
bp1 = NULL; /* Find the header. */
|
||||||
@ -172,8 +171,8 @@ register BUFFER *bp;
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
namebuffer(f,n) /* Rename the current buffer */
|
namebuffer(f, n)
|
||||||
|
/* Rename the current buffer */
|
||||||
int f, n; /* default Flag & Numeric arg */
|
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 */
|
char bufn[NBUFN]; /* buffer to hold buffer name */
|
||||||
|
|
||||||
/* prompt for and get the new buffer name */
|
/* prompt for and get the new buffer name */
|
||||||
ask: if (mlreply("Change buffer name to: ", bufn, NBUFN) != TRUE)
|
ask:if (mlreply("Change buffer name to: ", bufn, NBUFN) !=
|
||||||
return(FALSE);
|
TRUE)
|
||||||
|
return (FALSE);
|
||||||
|
|
||||||
/* and check for duplicates */
|
/* and check for duplicates */
|
||||||
bp = bheadp;
|
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 */
|
strcpy(curbp->b_bname, bufn); /* copy buffer name to structure */
|
||||||
curwp->w_flag |= WFMODE; /* make mode line replot */
|
curwp->w_flag |= WFMODE; /* make mode line replot */
|
||||||
mlerase();
|
mlerase();
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -217,10 +217,10 @@ listbuffers(f, n)
|
|||||||
register BUFFER *bp;
|
register BUFFER *bp;
|
||||||
register int s;
|
register int s;
|
||||||
|
|
||||||
if ((s=makelist(f)) != TRUE)
|
if ((s = makelist(f)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
if (blistp->b_nwnd == 0) { /* Not on screen yet. */
|
if (blistp->b_nwnd == 0) { /* Not on screen yet. */
|
||||||
if ((wp=wpopup()) == NULL)
|
if ((wp = wpopup()) == NULL)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
bp = wp->w_bufp;
|
bp = wp->w_bufp;
|
||||||
if (--bp->b_nwnd == 0) {
|
if (--bp->b_nwnd == 0) {
|
||||||
@ -240,7 +240,7 @@ listbuffers(f, n)
|
|||||||
wp->w_doto = 0;
|
wp->w_doto = 0;
|
||||||
wp->w_markp = NULL;
|
wp->w_markp = NULL;
|
||||||
wp->w_marko = 0;
|
wp->w_marko = 0;
|
||||||
wp->w_flag |= WFMODE|WFHARD;
|
wp->w_flag |= WFMODE | WFHARD;
|
||||||
}
|
}
|
||||||
wp = wp->w_wndp;
|
wp = wp->w_wndp;
|
||||||
}
|
}
|
||||||
@ -270,15 +270,16 @@ int iflag; /* list hidden buffer flag */
|
|||||||
register int s;
|
register int s;
|
||||||
register int i;
|
register int i;
|
||||||
long nbytes; /* # of bytes in current buffer */
|
long nbytes; /* # of bytes in current buffer */
|
||||||
char b[7+1];
|
char b[7 + 1];
|
||||||
char line[MAXLINE];
|
char line[MAXLINE];
|
||||||
|
|
||||||
blistp->b_flag &= ~BFCHG; /* Don't complain! */
|
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);
|
return (s);
|
||||||
strcpy(blistp->b_fname, "");
|
strcpy(blistp->b_fname, "");
|
||||||
if (addline("ACT MODES Size Buffer File") == FALSE
|
if (addline("ACT MODES Size Buffer File") == FALSE
|
||||||
|| addline("--- ----- ---- ------ ----") == FALSE)
|
|| addline("--- ----- ---- ------ ----") ==
|
||||||
|
FALSE)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
bp = bheadp; /* For all buffers */
|
bp = bheadp; /* For all buffers */
|
||||||
|
|
||||||
@ -297,12 +298,12 @@ int iflag; /* list hidden buffer flag */
|
|||||||
*cp1++ = '.';
|
*cp1++ = '.';
|
||||||
strcpy(cp1, " Global Modes");
|
strcpy(cp1, " Global Modes");
|
||||||
if (addline(line) == FALSE)
|
if (addline(line) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* output the list of buffers */
|
/* output the list of buffers */
|
||||||
while (bp != NULL) {
|
while (bp != NULL) {
|
||||||
/* skip invisable buffers if iflag is false */
|
/* 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;
|
bp = bp->b_bufp;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -315,13 +316,13 @@ int iflag; /* list hidden buffer flag */
|
|||||||
*cp1++ = ' ';
|
*cp1++ = ' ';
|
||||||
|
|
||||||
/* output status of changed flag */
|
/* output status of changed flag */
|
||||||
if ((bp->b_flag&BFCHG) != 0) /* "*" if changed */
|
if ((bp->b_flag & BFCHG) != 0) /* "*" if changed */
|
||||||
*cp1++ = '*';
|
*cp1++ = '*';
|
||||||
else
|
else
|
||||||
*cp1++ = ' ';
|
*cp1++ = ' ';
|
||||||
|
|
||||||
/* report if the file is truncated */
|
/* report if the file is truncated */
|
||||||
if ((bp->b_flag&BFTRUNC) != 0)
|
if ((bp->b_flag & BFTRUNC) != 0)
|
||||||
*cp1++ = '#';
|
*cp1++ = '#';
|
||||||
else
|
else
|
||||||
*cp1++ = ' ';
|
*cp1++ = ' ';
|
||||||
@ -339,7 +340,7 @@ int iflag; /* list hidden buffer flag */
|
|||||||
nbytes = 0L; /* Count bytes in buf. */
|
nbytes = 0L; /* Count bytes in buf. */
|
||||||
lp = lforw(bp->b_linep);
|
lp = lforw(bp->b_linep);
|
||||||
while (lp != bp->b_linep) {
|
while (lp != bp->b_linep) {
|
||||||
nbytes += (long)llength(lp)+1L;
|
nbytes += (long) llength(lp) + 1L;
|
||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
}
|
}
|
||||||
ltoa(b, 7, nbytes); /* 6 digit buffer size. */
|
ltoa(b, 7, nbytes); /* 6 digit buffer size. */
|
||||||
@ -352,10 +353,10 @@ int iflag; /* list hidden buffer flag */
|
|||||||
*cp1++ = c;
|
*cp1++ = c;
|
||||||
cp2 = &bp->b_fname[0]; /* File name */
|
cp2 = &bp->b_fname[0]; /* File name */
|
||||||
if (*cp2 != 0) {
|
if (*cp2 != 0) {
|
||||||
while (cp1 < &line[3+1+5+1+6+4+NBUFN])
|
while (cp1 < &line[3 + 1 + 5 + 1 + 6 + 4 + NBUFN])
|
||||||
*cp1++ = ' ';
|
*cp1++ = ' ';
|
||||||
while ((c = *cp2++) != 0) {
|
while ((c = *cp2++) != 0) {
|
||||||
if (cp1 < &line[MAXLINE-1])
|
if (cp1 < &line[MAXLINE - 1])
|
||||||
*cp1++ = c;
|
*cp1++ = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -376,10 +377,10 @@ long num;
|
|||||||
{
|
{
|
||||||
buf[width] = 0; /* End of string. */
|
buf[width] = 0; /* End of string. */
|
||||||
while (num >= 10) { /* Conditional digits. */
|
while (num >= 10) { /* Conditional digits. */
|
||||||
buf[--width] = (int)(num%10L) + '0';
|
buf[--width] = (int) (num % 10L) + '0';
|
||||||
num /= 10L;
|
num /= 10L;
|
||||||
}
|
}
|
||||||
buf[--width] = (int)num + '0'; /* Always 1 digit. */
|
buf[--width] = (int) num + '0'; /* Always 1 digit. */
|
||||||
while (width != 0) /* Pad with blanks. */
|
while (width != 0) /* Pad with blanks. */
|
||||||
buf[--width] = ' ';
|
buf[--width] = ' ';
|
||||||
}
|
}
|
||||||
@ -399,9 +400,9 @@ char *text;
|
|||||||
register int ntext;
|
register int ntext;
|
||||||
|
|
||||||
ntext = strlen(text);
|
ntext = strlen(text);
|
||||||
if ((lp=lalloc(ntext)) == NULL)
|
if ((lp = lalloc(ntext)) == NULL)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
for (i=0; i<ntext; ++i)
|
for (i = 0; i < ntext; ++i)
|
||||||
lputc(lp, i, text[i]);
|
lputc(lp, i, text[i]);
|
||||||
blistp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */
|
blistp->b_linep->l_bp->l_fp = lp; /* Hook onto the end */
|
||||||
lp->l_bp = blistp->b_linep->l_bp;
|
lp->l_bp = blistp->b_linep->l_bp;
|
||||||
@ -428,7 +429,8 @@ anycb()
|
|||||||
|
|
||||||
bp = bheadp;
|
bp = bheadp;
|
||||||
while (bp != NULL) {
|
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);
|
return (TRUE);
|
||||||
bp = bp->b_bufp;
|
bp = bp->b_bufp;
|
||||||
}
|
}
|
||||||
@ -442,8 +444,7 @@ anycb()
|
|||||||
* and the "cflag" is TRUE, create it. The "bflag" is
|
* and the "cflag" is TRUE, create it. The "bflag" is
|
||||||
* the settings for the flags in in buffer.
|
* the settings for the flags in in buffer.
|
||||||
*/
|
*/
|
||||||
BUFFER *
|
BUFFER *bfind(bname, cflag, bflag)
|
||||||
bfind(bname, cflag, bflag)
|
|
||||||
register char *bname;
|
register char *bname;
|
||||||
{
|
{
|
||||||
register BUFFER *bp;
|
register BUFFER *bp;
|
||||||
@ -458,9 +459,9 @@ register char *bname;
|
|||||||
bp = bp->b_bufp;
|
bp = bp->b_bufp;
|
||||||
}
|
}
|
||||||
if (cflag != FALSE) {
|
if (cflag != FALSE) {
|
||||||
if ((bp=(BUFFER *)malloc(sizeof(BUFFER))) == NULL)
|
if ((bp = (BUFFER *) malloc(sizeof(BUFFER))) == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
if ((lp=lalloc(0)) == NULL) {
|
if ((lp = lalloc(0)) == NULL) {
|
||||||
free((char *) bp);
|
free((char *) bp);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -519,12 +520,12 @@ register BUFFER *bp;
|
|||||||
register LINE *lp;
|
register LINE *lp;
|
||||||
register int s;
|
register int s;
|
||||||
|
|
||||||
if ((bp->b_flag&BFINVS) == 0 /* Not scratch buffer. */
|
if ((bp->b_flag & BFINVS) == 0 /* Not scratch buffer. */
|
||||||
&& (bp->b_flag&BFCHG) != 0 /* Something changed */
|
&& (bp->b_flag & BFCHG) != 0 /* Something changed */
|
||||||
&& (s=mlyesno("Discard changes")) != TRUE)
|
&& (s = mlyesno("Discard changes")) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
bp->b_flag &= ~BFCHG; /* Not changed */
|
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);
|
lfree(lp);
|
||||||
bp->b_dotp = bp->b_linep; /* Fix "." */
|
bp->b_dotp = bp->b_linep; /* Fix "." */
|
||||||
bp->b_doto = 0;
|
bp->b_doto = 0;
|
||||||
@ -533,12 +534,12 @@ register BUFFER *bp;
|
|||||||
return (TRUE);
|
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 */
|
int f, n; /* unused command arguments */
|
||||||
|
|
||||||
{
|
{
|
||||||
curbp->b_flag &= ~BFCHG;
|
curbp->b_flag &= ~BFCHG;
|
||||||
curwp->w_flag |= WFMODE;
|
curwp->w_flag |= WFMODE;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
12
crypt.c
12
crypt.c
@ -13,8 +13,8 @@
|
|||||||
|
|
||||||
static int mod95();
|
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 f; /* default flag */
|
||||||
int n; /* numeric argument */
|
int n; /* numeric argument */
|
||||||
|
|
||||||
@ -31,16 +31,16 @@ int n; /* numeric argument */
|
|||||||
status = mlreply("Encryption String: ", key, NPAT - 1);
|
status = mlreply("Encryption String: ", key, NPAT - 1);
|
||||||
disinp = odisinp;
|
disinp = odisinp;
|
||||||
if (status != TRUE)
|
if (status != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
/* and encrypt it */
|
/* and encrypt it */
|
||||||
crypt((char *)NULL, 0);
|
crypt((char *) NULL, 0);
|
||||||
crypt(key, strlen(key));
|
crypt(key, strlen(key));
|
||||||
|
|
||||||
/* and save it off */
|
/* and save it off */
|
||||||
strcpy(curbp->b_key, key);
|
strcpy(curbp->b_key, key);
|
||||||
mlwrite(" "); /* clear it off the bottom line */
|
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
|
so that the left shift here will be more portable and the
|
||||||
mod95() faster **/
|
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
|
/** the salt will spice up the key a little bit, helping to obscure
|
||||||
any patterns in the clear text, particularly when all the
|
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 */
|
TTopen(); /* open the screen */
|
||||||
TTkopen(); /* open the keyboard */
|
TTkopen(); /* open the keyboard */
|
||||||
TTrev(FALSE);
|
TTrev(FALSE);
|
||||||
vscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
|
vscreen = (VIDEO **) malloc(term.t_mrow * sizeof(VIDEO *));
|
||||||
|
|
||||||
if (vscreen == NULL)
|
if (vscreen == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
#if MEMMAP == 0 || SCROLLCODE
|
#if MEMMAP == 0 || SCROLLCODE
|
||||||
pscreen = (VIDEO **) malloc(term.t_mrow*sizeof(VIDEO *));
|
pscreen = (VIDEO **) malloc(term.t_mrow * sizeof(VIDEO *));
|
||||||
|
|
||||||
if (pscreen == NULL)
|
if (pscreen == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < term.t_mrow; ++i)
|
for (i = 0; i < term.t_mrow; ++i) {
|
||||||
{
|
vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol);
|
||||||
vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
|
|
||||||
|
|
||||||
if (vp == NULL)
|
if (vp == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -87,7 +86,7 @@ vtinit()
|
|||||||
#endif
|
#endif
|
||||||
vscreen[i] = vp;
|
vscreen[i] = vp;
|
||||||
#if MEMMAP == 0 || SCROLLCODE
|
#if MEMMAP == 0 || SCROLLCODE
|
||||||
vp = (VIDEO *) malloc(sizeof(VIDEO)+term.t_mcol);
|
vp = (VIDEO *) malloc(sizeof(VIDEO) + term.t_mcol);
|
||||||
|
|
||||||
if (vp == NULL)
|
if (vp == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -169,7 +168,7 @@ int c;
|
|||||||
if (c == '\t') {
|
if (c == '\t') {
|
||||||
do {
|
do {
|
||||||
vtputc(' ');
|
vtputc(' ');
|
||||||
} while (((vtcol + taboff)&tabmask) != 0);
|
} while (((vtcol + taboff) & tabmask) != 0);
|
||||||
} else {
|
} else {
|
||||||
vtputc('^');
|
vtputc('^');
|
||||||
vtputc(c ^ 0x40);
|
vtputc(c ^ 0x40);
|
||||||
@ -200,10 +199,9 @@ vteeol()
|
|||||||
always finishes complete update */
|
always finishes complete update */
|
||||||
|
|
||||||
upscreen(f, n)
|
upscreen(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
update(TRUE);
|
update(TRUE);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
@ -226,11 +224,11 @@ int force; /* force update past type ahead? */
|
|||||||
|
|
||||||
#if TYPEAH && ! PKCODE
|
#if TYPEAH && ! PKCODE
|
||||||
if (force == FALSE && typahead())
|
if (force == FALSE && typahead())
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
#if VISMAC == 0
|
#if VISMAC == 0
|
||||||
if (force == FALSE && kbdmode == PLAY)
|
if (force == FALSE && kbdmode == PLAY)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
displaying = TRUE;
|
displaying = TRUE;
|
||||||
@ -265,9 +263,10 @@ int force; /* force update past type ahead? */
|
|||||||
/* if the window has changed, service it */
|
/* if the window has changed, service it */
|
||||||
reframe(wp); /* check the framing */
|
reframe(wp); /* check the framing */
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
if (wp->w_flag & (WFKILLS|WFINS)) {
|
if (wp->w_flag & (WFKILLS | WFINS)) {
|
||||||
scrflags |= (wp->w_flag & (WFINS|WFKILLS));
|
scrflags |=
|
||||||
wp->w_flag &= ~(WFKILLS|WFINS);
|
(wp->w_flag & (WFINS | WFKILLS));
|
||||||
|
wp->w_flag &= ~(WFKILLS | WFINS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if ((wp->w_flag & ~WFMODE) == WFEDIT)
|
if ((wp->w_flag & ~WFMODE) == WFEDIT)
|
||||||
@ -311,9 +310,9 @@ int force; /* force update past type ahead? */
|
|||||||
displaying = FALSE;
|
displaying = FALSE;
|
||||||
#if SIGWINCH
|
#if SIGWINCH
|
||||||
while (chg_width || chg_height)
|
while (chg_width || chg_height)
|
||||||
newscreensize(chg_height,chg_width);
|
newscreensize(chg_height, chg_width);
|
||||||
#endif
|
#endif
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reframe: check to see if the cursor is on in the window
|
/* reframe: check to see if the cursor is on in the window
|
||||||
@ -339,7 +338,7 @@ WINDOW *wp;
|
|||||||
i = -1;
|
i = -1;
|
||||||
lp = lp0;
|
lp = lp0;
|
||||||
}
|
}
|
||||||
for (; i <= (int)(wp->w_ntrows); i++)
|
for (; i <= (int) (wp->w_ntrows); i++)
|
||||||
#else
|
#else
|
||||||
lp = wp->w_linep;
|
lp = wp->w_linep;
|
||||||
for (i = 0; i < wp->w_ntrows; i++)
|
for (i = 0; i < wp->w_ntrows; i++)
|
||||||
@ -349,7 +348,7 @@ WINDOW *wp;
|
|||||||
if (lp == wp->w_dotp) {
|
if (lp == wp->w_dotp) {
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
/* if not _quite_ in, we'll reframe gently */
|
/* 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
|
/* if the terminal can't help, then
|
||||||
we're simply outside */
|
we're simply outside */
|
||||||
if (term.t_scroll == NULL)
|
if (term.t_scroll == NULL)
|
||||||
@ -357,7 +356,7 @@ WINDOW *wp;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we are at the end of the file, reframe */
|
/* if we are at the end of the file, reframe */
|
||||||
@ -368,7 +367,6 @@ WINDOW *wp;
|
|||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
if (i == -1) { /* we're just above the window */
|
if (i == -1) { /* we're just above the window */
|
||||||
i = scrollcount; /* put dot at first line */
|
i = scrollcount; /* put dot at first line */
|
||||||
@ -404,7 +402,7 @@ WINDOW *wp;
|
|||||||
wp->w_linep = lp;
|
wp->w_linep = lp;
|
||||||
wp->w_flag |= WFHARD;
|
wp->w_flag |= WFHARD;
|
||||||
wp->w_flag &= ~WFFORCE;
|
wp->w_flag &= ~WFFORCE;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* updone: update the current line to the virtual screen */
|
/* 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 |= VFCHG;
|
||||||
vscreen[sline]->v_flag &= ~VFREQ;
|
vscreen[sline]->v_flag &= ~VFREQ;
|
||||||
vtmove(sline, 0);
|
vtmove(sline, 0);
|
||||||
for (i=0; i < llength(lp); ++i)
|
for (i = 0; i < llength(lp); ++i)
|
||||||
vtputc(lgetc(lp, i));
|
vtputc(lgetc(lp, i));
|
||||||
#if COLOR
|
#if COLOR
|
||||||
vscreen[sline]->v_rfcolor = wp->w_fcolor;
|
vscreen[sline]->v_rfcolor = wp->w_fcolor;
|
||||||
@ -461,7 +459,7 @@ WINDOW *wp; /* window to update lines in */
|
|||||||
vtmove(sline, 0);
|
vtmove(sline, 0);
|
||||||
if (lp != wp->w_bufp->b_linep) {
|
if (lp != wp->w_bufp->b_linep) {
|
||||||
/* if we are not at the end */
|
/* 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));
|
vtputc(lgetc(lp, i));
|
||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
}
|
}
|
||||||
@ -481,7 +479,6 @@ WINDOW *wp; /* window to update lines in */
|
|||||||
lines. This is the only update for simple moves. */
|
lines. This is the only update for simple moves. */
|
||||||
|
|
||||||
updpos()
|
updpos()
|
||||||
|
|
||||||
{
|
{
|
||||||
register LINE *lp;
|
register LINE *lp;
|
||||||
register int c;
|
register int c;
|
||||||
@ -502,8 +499,7 @@ updpos()
|
|||||||
c = lgetc(lp, i++);
|
c = lgetc(lp, i++);
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
curcol |= tabmask;
|
curcol |= tabmask;
|
||||||
else
|
else if (c < 0x20 || c == 0x7f)
|
||||||
if (c < 0x20 || c == 0x7f)
|
|
||||||
++curcol;
|
++curcol;
|
||||||
|
|
||||||
++curcol;
|
++curcol;
|
||||||
@ -520,11 +516,10 @@ updpos()
|
|||||||
/* upddex: de-extend any line that derserves it */
|
/* upddex: de-extend any line that derserves it */
|
||||||
|
|
||||||
upddex()
|
upddex()
|
||||||
|
|
||||||
{
|
{
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
register LINE *lp;
|
register LINE *lp;
|
||||||
register int i,j;
|
register int i, j;
|
||||||
|
|
||||||
wp = wheadp;
|
wp = wheadp;
|
||||||
|
|
||||||
@ -558,10 +553,9 @@ upddex()
|
|||||||
the virtual screen and force a full update */
|
the virtual screen and force a full update */
|
||||||
|
|
||||||
updgar()
|
updgar()
|
||||||
|
|
||||||
{
|
{
|
||||||
register char *txt;
|
register char *txt;
|
||||||
register int i,j;
|
register int i, j;
|
||||||
|
|
||||||
for (i = 0; i < term.t_nrow; ++i) {
|
for (i = 0; i < term.t_nrow; ++i) {
|
||||||
vscreen[i]->v_flag |= VFCHG;
|
vscreen[i]->v_flag |= VFCHG;
|
||||||
@ -580,7 +574,7 @@ updgar()
|
|||||||
}
|
}
|
||||||
|
|
||||||
movecursor(0, 0); /* Erase the screen. */
|
movecursor(0, 0); /* Erase the screen. */
|
||||||
(*term.t_eeop)();
|
(*term.t_eeop) ();
|
||||||
sgarbf = FALSE; /* Erase-page clears */
|
sgarbf = FALSE; /* Erase-page clears */
|
||||||
mpresf = FALSE; /* the message area. */
|
mpresf = FALSE; /* the message area. */
|
||||||
#if COLOR
|
#if COLOR
|
||||||
@ -609,11 +603,11 @@ int force; /* forced update flag */
|
|||||||
for (i = 0; i < term.t_nrow; ++i) {
|
for (i = 0; i < term.t_nrow; ++i) {
|
||||||
vp1 = vscreen[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 ((vp1->v_flag & VFCHG) != 0) {
|
||||||
#if TYPEAH && ! PKCODE
|
#if TYPEAH && ! PKCODE
|
||||||
if (force == FALSE && typahead())
|
if (force == FALSE && typahead())
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
#if MEMMAP && ! SCROLLCODE
|
#if MEMMAP && ! SCROLLCODE
|
||||||
updateline(i, vp1);
|
updateline(i, vp1);
|
||||||
@ -622,33 +616,32 @@ int force; /* forced update flag */
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
|
|
||||||
/* optimize out scrolls (line breaks, and newlines) */
|
/* optimize out scrolls (line breaks, and newlines) */
|
||||||
/* arg. chooses between looking for inserts or deletes */
|
/* arg. chooses between looking for inserts or deletes */
|
||||||
int
|
int scrolls(inserts)
|
||||||
scrolls(inserts) /* returns true if it does something */
|
{ /* returns true if it does something */
|
||||||
{
|
struct VIDEO *vpv; /* virtual screen image */
|
||||||
struct VIDEO *vpv ; /* virtual screen image */
|
struct VIDEO *vpp; /* physical screen image */
|
||||||
struct VIDEO *vpp ; /* physical screen image */
|
int i, j, k;
|
||||||
int i, j, k ;
|
int rows, cols;
|
||||||
int rows, cols ;
|
int first, match, count, ptarget, vtarget, end;
|
||||||
int first, match, count, ptarget, vtarget, end ;
|
|
||||||
int longmatch, longcount;
|
int longmatch, longcount;
|
||||||
int from, to;
|
int from, to;
|
||||||
|
|
||||||
if (!term.t_scroll) /* no way to scroll */
|
if (!term.t_scroll) /* no way to scroll */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
rows = term.t_nrow ;
|
rows = term.t_nrow;
|
||||||
cols = term.t_ncol ;
|
cols = term.t_ncol;
|
||||||
|
|
||||||
first = -1 ;
|
first = -1;
|
||||||
for (i = 0; i < rows; i++) { /* find first wrong line */
|
for (i = 0; i < rows; i++) { /* find first wrong line */
|
||||||
if (!texttest(i,i)) {
|
if (!texttest(i, i)) {
|
||||||
first = i;
|
first = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -657,36 +650,38 @@ scrolls(inserts) /* returns true if it does something */
|
|||||||
if (first < 0)
|
if (first < 0)
|
||||||
return FALSE; /* no text changes */
|
return FALSE; /* no text changes */
|
||||||
|
|
||||||
vpv = vscreen[first] ;
|
vpv = vscreen[first];
|
||||||
vpp = pscreen[first] ;
|
vpp = pscreen[first];
|
||||||
|
|
||||||
if (inserts) {
|
if (inserts) {
|
||||||
/* determine types of potential scrolls */
|
/* determine types of potential scrolls */
|
||||||
end = endofline(vpv->v_text,cols) ;
|
end = endofline(vpv->v_text, cols);
|
||||||
if ( end == 0 )
|
if (end == 0)
|
||||||
ptarget = first ; /* newlines */
|
ptarget = first; /* newlines */
|
||||||
else if ( strncmp(vpp->v_text, vpv->v_text, end) == 0 )
|
else if (strncmp(vpp->v_text, vpv->v_text, end) == 0)
|
||||||
ptarget = first + 1 ; /* broken line newlines */
|
ptarget = first + 1; /* broken line newlines */
|
||||||
else
|
else
|
||||||
ptarget = first ;
|
ptarget = first;
|
||||||
} else {
|
} else {
|
||||||
vtarget = first + 1 ;
|
vtarget = first + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find the matching shifted area */
|
/* find the matching shifted area */
|
||||||
match = -1 ;
|
match = -1;
|
||||||
longmatch = -1;
|
longmatch = -1;
|
||||||
longcount = 0;
|
longcount = 0;
|
||||||
from = inserts ? ptarget : vtarget;
|
from = inserts ? ptarget : vtarget;
|
||||||
for (i = from+1; i < rows-longcount /* P.K. */; i++) {
|
for (i = from + 1; i < rows - longcount /* P.K. */ ; i++) {
|
||||||
if (inserts ? texttest(i,from) : texttest(from,i) ) {
|
if (inserts ? texttest(i, from) : texttest(from, i)) {
|
||||||
match = i ;
|
match = i;
|
||||||
count = 1 ;
|
count = 1;
|
||||||
for (j=match+1, k=from+1; j<rows && k<rows; j++, k++) {
|
for (j = match + 1, k = from + 1;
|
||||||
if (inserts ? texttest(j,k) : texttest(k,j))
|
j < rows && k < rows; j++, k++) {
|
||||||
count++ ;
|
if (inserts ? texttest(j, k) :
|
||||||
|
texttest(k, j))
|
||||||
|
count++;
|
||||||
else
|
else
|
||||||
break ;
|
break;
|
||||||
}
|
}
|
||||||
if (longcount < count) {
|
if (longcount < count) {
|
||||||
longcount = count;
|
longcount = count;
|
||||||
@ -699,15 +694,15 @@ scrolls(inserts) /* returns true if it does something */
|
|||||||
|
|
||||||
if (!inserts) {
|
if (!inserts) {
|
||||||
/* full kill case? */
|
/* full kill case? */
|
||||||
if (match > 0 && texttest(first, match-1)) {
|
if (match > 0 && texttest(first, match - 1)) {
|
||||||
vtarget-- ;
|
vtarget--;
|
||||||
match-- ;
|
match--;
|
||||||
count++ ;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* do the scroll */
|
/* 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 */
|
/* move the count lines starting at ptarget to match */
|
||||||
if (inserts) {
|
if (inserts) {
|
||||||
from = ptarget;
|
from = ptarget;
|
||||||
@ -721,32 +716,33 @@ scrolls(inserts) /* returns true if it does something */
|
|||||||
char line[NLINE];
|
char line[NLINE];
|
||||||
sprintf(line,
|
sprintf(line,
|
||||||
"scrolls: move the %d lines starting at %d to %d, first %d, scrolls %d",
|
"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);
|
mlwrite(line);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (2*count < abs(from-to))
|
if (2 * count < abs(from - to))
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
scrscroll(from, to, count) ;
|
scrscroll(from, to, count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
vpp = pscreen[to+i] ;
|
vpp = pscreen[to + i];
|
||||||
vpv = vscreen[to+i];
|
vpv = vscreen[to + i];
|
||||||
strncpy(vpp->v_text, vpv->v_text, cols) ;
|
strncpy(vpp->v_text, vpv->v_text, cols);
|
||||||
vpp->v_flag = vpv->v_flag; /* XXX */
|
vpp->v_flag = vpv->v_flag; /* XXX */
|
||||||
if (vpp->v_flag & VFREV) {
|
if (vpp->v_flag & VFREV) {
|
||||||
vpp->v_flag &= ~VFREV;
|
vpp->v_flag &= ~VFREV;
|
||||||
vpp->v_flag |= ~VFREQ;
|
vpp->v_flag |= ~VFREQ;
|
||||||
}
|
}
|
||||||
#if MEMMAP
|
#if MEMMAP
|
||||||
vscreen[to+i]->v_flag &= ~VFCHG;
|
vscreen[to + i]->v_flag &= ~VFCHG;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (inserts) {
|
if (inserts) {
|
||||||
from = ptarget;
|
from = ptarget;
|
||||||
to = match;
|
to = match;
|
||||||
} else {
|
} else {
|
||||||
from = vtarget+count;
|
from = vtarget + count;
|
||||||
to = match+count;
|
to = match + count;
|
||||||
}
|
}
|
||||||
#if MEMMAP == 0
|
#if MEMMAP == 0
|
||||||
for (i = from; i < to; i++) {
|
for (i = from; i < to; i++) {
|
||||||
@ -757,36 +753,36 @@ scrolls(inserts) /* returns true if it does something */
|
|||||||
vscreen[i]->v_flag |= VFCHG;
|
vscreen[i]->v_flag |= VFCHG;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return(TRUE) ;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
return(FALSE) ;
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move the "count" lines starting at "from" to "to" */
|
/* move the "count" lines starting at "from" to "to" */
|
||||||
scrscroll(from, to, count)
|
scrscroll(from, to, count)
|
||||||
{
|
{
|
||||||
ttrow = ttcol = -1;
|
ttrow = ttcol = -1;
|
||||||
(*term.t_scroll)(from,to,count);
|
(*term.t_scroll) (from, to, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
texttest(vrow,prow) /* return TRUE on text match */
|
texttest(vrow, prow) /* return TRUE on text match */
|
||||||
int vrow, prow ; /* virtual, physical rows */
|
int vrow, prow; /* virtual, physical rows */
|
||||||
{
|
{
|
||||||
struct VIDEO *vpv = vscreen[vrow] ; /* virtual screen image */
|
struct VIDEO *vpv = vscreen[vrow]; /* virtual screen image */
|
||||||
struct VIDEO *vpp = pscreen[prow] ; /* physical 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 */
|
/* return the index of the first blank of trailing whitespace */
|
||||||
int
|
int endofline(s, n)
|
||||||
endofline(s,n)
|
char *s;
|
||||||
char *s ;
|
|
||||||
{
|
{
|
||||||
int i ;
|
int i;
|
||||||
for (i = n - 1; i >= 0; i--)
|
for (i = n - 1; i >= 0; i--)
|
||||||
if (s[i] != ' ') return(i+1) ;
|
if (s[i] != ' ')
|
||||||
return(0) ;
|
return (i + 1);
|
||||||
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SCROLLCODE */
|
#endif /* SCROLLCODE */
|
||||||
@ -798,7 +794,6 @@ int i ;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
updext()
|
updext()
|
||||||
|
|
||||||
{
|
{
|
||||||
register int rcursor; /* real cursor location */
|
register int rcursor; /* real cursor location */
|
||||||
register LINE *lp; /* pointer to current line */
|
register LINE *lp; /* pointer to current line */
|
||||||
@ -812,7 +807,7 @@ updext()
|
|||||||
/* once we reach the left edge */
|
/* once we reach the left edge */
|
||||||
vtmove(currow, -lbound); /* start scanning offscreen */
|
vtmove(currow, -lbound); /* start scanning offscreen */
|
||||||
lp = curwp->w_dotp; /* line to output */
|
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));
|
vtputc(lgetc(lp, j));
|
||||||
|
|
||||||
/* truncate the virtual line, restore tab offset */
|
/* truncate the virtual line, restore tab offset */
|
||||||
@ -836,7 +831,7 @@ updateline(row, vp1
|
|||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
, vp2
|
, vp2
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
|
|
||||||
int row; /* row of screen to update */
|
int row; /* row of screen to update */
|
||||||
struct VIDEO *vp1; /* virtual screen image */
|
struct VIDEO *vp1; /* virtual screen image */
|
||||||
@ -853,8 +848,7 @@ struct VIDEO *vp2;
|
|||||||
cp1 = &vp1->v_text[0];
|
cp1 = &vp1->v_text[0];
|
||||||
cp2 = &vp2->v_text[0];
|
cp2 = &vp2->v_text[0];
|
||||||
nch = term.t_ncol;
|
nch = term.t_ncol;
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
*cp2 = *cp1;
|
*cp2 = *cp1;
|
||||||
++cp2;
|
++cp2;
|
||||||
++cp1;
|
++cp1;
|
||||||
@ -896,11 +890,10 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
|
|
||||||
cp1 = &vp1->v_text[0]; /* Use fast video. */
|
cp1 = &vp1->v_text[0]; /* Use fast video. */
|
||||||
cp2 = &vp2->v_text[0];
|
cp2 = &vp2->v_text[0];
|
||||||
putline(row+1, 1, cp1);
|
putline(row + 1, 1, cp1);
|
||||||
nch = term.t_ncol;
|
nch = term.t_ncol;
|
||||||
|
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
*cp2 = *cp1;
|
*cp2 = *cp1;
|
||||||
++cp2;
|
++cp2;
|
||||||
++cp1;
|
++cp1;
|
||||||
@ -936,13 +929,14 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
req = (vp1->v_flag & VFREQ) == VFREQ;
|
req = (vp1->v_flag & VFREQ) == VFREQ;
|
||||||
if ((rev != req)
|
if ((rev != req)
|
||||||
#if COLOR
|
#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
|
#endif
|
||||||
) {
|
) {
|
||||||
movecursor(row, 0); /* Go to start of line. */
|
movecursor(row, 0); /* Go to start of line. */
|
||||||
/* set rev video if needed */
|
/* set rev video if needed */
|
||||||
if (rev != req)
|
if (rev != req)
|
||||||
(*term.t_rev)(req);
|
(*term.t_rev) (req);
|
||||||
|
|
||||||
/* scan through the line and dump it to the screen and
|
/* scan through the line and dump it to the screen and
|
||||||
the virtual screen array */
|
the virtual screen array */
|
||||||
@ -954,7 +948,7 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
}
|
}
|
||||||
/* turn rev video off */
|
/* turn rev video off */
|
||||||
if (rev != req)
|
if (rev != req)
|
||||||
(*term.t_rev)(FALSE);
|
(*term.t_rev) (FALSE);
|
||||||
|
|
||||||
/* update the needed flags */
|
/* update the needed flags */
|
||||||
vp1->v_flag &= ~VFCHG;
|
vp1->v_flag &= ~VFCHG;
|
||||||
@ -966,7 +960,7 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
vp1->v_fcolor = vp1->v_rfcolor;
|
vp1->v_fcolor = vp1->v_rfcolor;
|
||||||
vp1->v_bcolor = vp1->v_rbcolor;
|
vp1->v_bcolor = vp1->v_rbcolor;
|
||||||
#endif
|
#endif
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -985,7 +979,7 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
/* if both lines are the same, no update needs to be done */
|
/* if both lines are the same, no update needs to be done */
|
||||||
if (cp1 == &vp1->v_text[term.t_ncol]) {
|
if (cp1 == &vp1->v_text[term.t_ncol]) {
|
||||||
vp1->v_flag &= ~VFCHG; /* flag this line is changed */
|
vp1->v_flag &= ~VFCHG; /* flag this line is changed */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find out if there is a match on the right */
|
/* find out if there is a match on the right */
|
||||||
@ -1004,10 +998,10 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
|
|
||||||
/* Erase to EOL ? */
|
/* Erase to EOL ? */
|
||||||
if (nbflag == FALSE && eolexist == TRUE && (req != TRUE)) {
|
if (nbflag == FALSE && eolexist == TRUE && (req != TRUE)) {
|
||||||
while (cp5!=cp1 && cp5[-1]==' ')
|
while (cp5 != cp1 && cp5[-1] == ' ')
|
||||||
--cp5;
|
--cp5;
|
||||||
|
|
||||||
if (cp3-cp5 <= 3) /* Use only if erase is */
|
if (cp3 - cp5 <= 3) /* Use only if erase is */
|
||||||
cp5 = cp3; /* fewer characters. */
|
cp5 = cp3; /* fewer characters. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1031,7 +1025,7 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
TTrev(FALSE);
|
TTrev(FALSE);
|
||||||
#endif
|
#endif
|
||||||
vp1->v_flag &= ~VFCHG; /* flag this line as updated */
|
vp1->v_flag &= ~VFCHG; /* flag this line as updated */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1043,7 +1037,7 @@ struct VIDEO *vp2; /* physical screen image */
|
|||||||
* any time there is a dirty window.
|
* any time there is a dirty window.
|
||||||
*/
|
*/
|
||||||
modeline(wp)
|
modeline(wp)
|
||||||
WINDOW *wp;
|
WINDOW *wp;
|
||||||
{
|
{
|
||||||
register char *cp;
|
register char *cp;
|
||||||
register int c;
|
register int c;
|
||||||
@ -1054,11 +1048,11 @@ modeline(wp)
|
|||||||
register int firstm; /* is this the first mode? */
|
register int firstm; /* is this the first mode? */
|
||||||
char tline[NLINE]; /* buffer for part of mode line */
|
char tline[NLINE]; /* buffer for part of mode line */
|
||||||
|
|
||||||
n = wp->w_toprow+wp->w_ntrows; /* Location. */
|
n = wp->w_toprow + wp->w_ntrows; /* Location. */
|
||||||
vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL;/* Redraw next time. */
|
vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL; /* Redraw next time. */
|
||||||
#if COLOR
|
#if COLOR
|
||||||
vscreen[n]->v_rfcolor = 0; /* black on */
|
vscreen[n]->v_rfcolor = 0; /* black on */
|
||||||
vscreen[n]->v_rbcolor = 7; /* white.....*/
|
vscreen[n]->v_rbcolor = 7; /* white..... */
|
||||||
#endif
|
#endif
|
||||||
vtmove(n, 0); /* Seek to right line. */
|
vtmove(n, 0); /* Seek to right line. */
|
||||||
if (wp == curwp) /* mark the current buffer */
|
if (wp == curwp) /* mark the current buffer */
|
||||||
@ -1077,13 +1071,13 @@ modeline(wp)
|
|||||||
|
|
||||||
bp = wp->w_bufp;
|
bp = wp->w_bufp;
|
||||||
#if PKCODE == 0
|
#if PKCODE == 0
|
||||||
if ((bp->b_flag&BFTRUNC) != 0)
|
if ((bp->b_flag & BFTRUNC) != 0)
|
||||||
vtputc('#');
|
vtputc('#');
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
vtputc(lchar);
|
vtputc(lchar);
|
||||||
|
|
||||||
if ((bp->b_flag&BFCHG) != 0) /* "*" if changed. */
|
if ((bp->b_flag & BFCHG) != 0) /* "*" if changed. */
|
||||||
vtputc('*');
|
vtputc('*');
|
||||||
else
|
else
|
||||||
vtputc(lchar);
|
vtputc(lchar);
|
||||||
@ -1096,15 +1090,13 @@ modeline(wp)
|
|||||||
strcat(tline, VERSION);
|
strcat(tline, VERSION);
|
||||||
strcat(tline, ": ");
|
strcat(tline, ": ");
|
||||||
cp = &tline[0];
|
cp = &tline[0];
|
||||||
while ((c = *cp++) != 0)
|
while ((c = *cp++) != 0) {
|
||||||
{
|
|
||||||
vtputc(c);
|
vtputc(c);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
|
|
||||||
cp = &bp->b_bname[0];
|
cp = &bp->b_bname[0];
|
||||||
while ((c = *cp++) != 0)
|
while ((c = *cp++) != 0) {
|
||||||
{
|
|
||||||
vtputc(c);
|
vtputc(c);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
@ -1114,8 +1106,7 @@ modeline(wp)
|
|||||||
/* display the modes */
|
/* display the modes */
|
||||||
|
|
||||||
firstm = TRUE;
|
firstm = TRUE;
|
||||||
if ((bp->b_flag&BFTRUNC) != 0)
|
if ((bp->b_flag & BFTRUNC) != 0) {
|
||||||
{
|
|
||||||
firstm = FALSE;
|
firstm = FALSE;
|
||||||
strcat(tline, "Truncated");
|
strcat(tline, "Truncated");
|
||||||
}
|
}
|
||||||
@ -1126,30 +1117,28 @@ modeline(wp)
|
|||||||
firstm = FALSE;
|
firstm = FALSE;
|
||||||
strcat(tline, mode2name[i]);
|
strcat(tline, mode2name[i]);
|
||||||
}
|
}
|
||||||
strcat(tline,") ");
|
strcat(tline, ") ");
|
||||||
|
|
||||||
cp = &tline[0];
|
cp = &tline[0];
|
||||||
while ((c = *cp++) != 0)
|
while ((c = *cp++) != 0) {
|
||||||
{
|
|
||||||
vtputc(c);
|
vtputc(c);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
vtputc(lchar);
|
vtputc(lchar);
|
||||||
vtputc((wp->w_flag&WFCOLR) != 0 ? 'C' : lchar);
|
vtputc((wp->w_flag & WFCOLR) != 0 ? 'C' : lchar);
|
||||||
vtputc((wp->w_flag&WFMODE) != 0 ? 'M' : lchar);
|
vtputc((wp->w_flag & WFMODE) != 0 ? 'M' : lchar);
|
||||||
vtputc((wp->w_flag&WFHARD) != 0 ? 'H' : lchar);
|
vtputc((wp->w_flag & WFHARD) != 0 ? 'H' : lchar);
|
||||||
vtputc((wp->w_flag&WFEDIT) != 0 ? 'E' : lchar);
|
vtputc((wp->w_flag & WFEDIT) != 0 ? 'E' : lchar);
|
||||||
vtputc((wp->w_flag&WFMOVE) != 0 ? 'V' : lchar);
|
vtputc((wp->w_flag & WFMOVE) != 0 ? 'V' : lchar);
|
||||||
vtputc((wp->w_flag&WFFORCE) != 0 ? 'F' : lchar);
|
vtputc((wp->w_flag & WFFORCE) != 0 ? 'F' : lchar);
|
||||||
vtputc(lchar);
|
vtputc(lchar);
|
||||||
n += 8;
|
n += 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (bp->b_fname[0] != 0 &&
|
if (bp->b_fname[0] != 0 && strcmp(bp->b_bname, bp->b_fname) != 0)
|
||||||
strcmp(bp->b_bname, bp->b_fname) != 0)
|
|
||||||
#else
|
#else
|
||||||
if (bp->b_fname[0] != 0) /* File name. */
|
if (bp->b_fname[0] != 0) /* File name. */
|
||||||
#endif
|
#endif
|
||||||
@ -1157,8 +1146,7 @@ modeline(wp)
|
|||||||
#if PKCODE == 0
|
#if PKCODE == 0
|
||||||
cp = "File: ";
|
cp = "File: ";
|
||||||
|
|
||||||
while ((c = *cp++) != 0)
|
while ((c = *cp++) != 0) {
|
||||||
{
|
|
||||||
vtputc(c);
|
vtputc(c);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
@ -1166,8 +1154,7 @@ modeline(wp)
|
|||||||
|
|
||||||
cp = &bp->b_fname[0];
|
cp = &bp->b_fname[0];
|
||||||
|
|
||||||
while ((c = *cp++) != 0)
|
while ((c = *cp++) != 0) {
|
||||||
{
|
|
||||||
vtputc(c);
|
vtputc(c);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
@ -1176,8 +1163,7 @@ modeline(wp)
|
|||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (n < term.t_ncol) /* Pad to full width. */
|
while (n < term.t_ncol) { /* Pad to full width. */
|
||||||
{
|
|
||||||
vtputc(lchar);
|
vtputc(lchar);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
@ -1205,8 +1191,7 @@ modeline(wp)
|
|||||||
msg = " Top ";
|
msg = " Top ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!msg)
|
if (!msg) {
|
||||||
{
|
|
||||||
LINE *lp;
|
LINE *lp;
|
||||||
int numlines, predlines, ratio;
|
int numlines, predlines, ratio;
|
||||||
|
|
||||||
@ -1224,7 +1209,8 @@ modeline(wp)
|
|||||||
} else {
|
} else {
|
||||||
ratio = 0;
|
ratio = 0;
|
||||||
if (numlines != 0)
|
if (numlines != 0)
|
||||||
ratio = (100L*predlines) / numlines;
|
ratio =
|
||||||
|
(100L * predlines) / numlines;
|
||||||
if (ratio > 99)
|
if (ratio > 99)
|
||||||
ratio = 99;
|
ratio = 99;
|
||||||
sprintf(tline, " %2d%% ", ratio);
|
sprintf(tline, " %2d%% ", ratio);
|
||||||
@ -1233,17 +1219,15 @@ modeline(wp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cp = msg;
|
cp = msg;
|
||||||
while ((c = *cp++) != 0)
|
while ((c = *cp++) != 0) {
|
||||||
{
|
|
||||||
vtputc(c);
|
vtputc(c);
|
||||||
++n;
|
++n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
upmode() /* update all the mode lines */
|
upmode()
|
||||||
|
{ /* update all the mode lines */
|
||||||
{
|
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
wp = wheadp;
|
wp = wheadp;
|
||||||
@ -1259,14 +1243,13 @@ upmode() /* update all the mode lines */
|
|||||||
* random calls. Update "ttrow" and "ttcol".
|
* random calls. Update "ttrow" and "ttcol".
|
||||||
*/
|
*/
|
||||||
movecursor(row, col)
|
movecursor(row, col)
|
||||||
{
|
{
|
||||||
if (row!=ttrow || col!=ttcol)
|
if (row != ttrow || col != ttcol) {
|
||||||
{
|
|
||||||
ttrow = row;
|
ttrow = row;
|
||||||
ttcol = col;
|
ttcol = col;
|
||||||
TTmove(row, col);
|
TTmove(row, col);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Erase the message line. This is a special routine because the message line
|
* 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.
|
* immediately; the terminal buffer is flushed via a call to the flusher.
|
||||||
*/
|
*/
|
||||||
mlerase()
|
mlerase()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
movecursor(term.t_nrow, 0);
|
movecursor(term.t_nrow, 0);
|
||||||
@ -1295,7 +1278,7 @@ mlerase()
|
|||||||
}
|
}
|
||||||
TTflush();
|
TTflush();
|
||||||
mpresf = FALSE;
|
mpresf = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write a message into the message line. Keep track of the physical cursor
|
* 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);
|
movecursor(term.t_nrow, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COLOR
|
#if COLOR
|
||||||
/* set up the proper colors for the command line */
|
/* set up the proper colors for the command line */
|
||||||
TTforg(7);
|
TTforg(7);
|
||||||
@ -1342,36 +1324,36 @@ char *arg; /* pointer to first argument to print */
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
case '*':
|
case '*':
|
||||||
ap = *(char **)ap;
|
ap = *(char **) ap;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'd':
|
case 'd':
|
||||||
mlputi(*(int *)ap, 10);
|
mlputi(*(int *) ap, 10);
|
||||||
ap += sizeof(int);
|
ap += sizeof(int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
mlputi(*(int *)ap, 8);
|
mlputi(*(int *) ap, 8);
|
||||||
ap += sizeof(int);
|
ap += sizeof(int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'x':
|
case 'x':
|
||||||
mlputi(*(int *)ap, 16);
|
mlputi(*(int *) ap, 16);
|
||||||
ap += sizeof(int);
|
ap += sizeof(int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
mlputli(*(long *)ap, 10);
|
mlputli(*(long *) ap, 10);
|
||||||
ap += sizeof(long);
|
ap += sizeof(long);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
mlputs(*(char **)ap);
|
mlputs(*(char **) ap);
|
||||||
ap += sizeof(char *);
|
ap += sizeof(char *);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'f':
|
case 'f':
|
||||||
mlputf(*(int *)ap);
|
mlputf(*(int *) ap);
|
||||||
ap += sizeof(int);
|
ap += sizeof(int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1413,63 +1395,60 @@ char *s; /* string to force out */
|
|||||||
* things will get screwed up a little.
|
* things will get screwed up a little.
|
||||||
*/
|
*/
|
||||||
mlputs(s)
|
mlputs(s)
|
||||||
char *s;
|
char *s;
|
||||||
{
|
{
|
||||||
register int c;
|
register int c;
|
||||||
|
|
||||||
while ((c = *s++) != 0)
|
while ((c = *s++) != 0) {
|
||||||
{
|
|
||||||
TTputc(c);
|
TTputc(c);
|
||||||
++ttcol;
|
++ttcol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write out an integer, in the specified radix. Update the physical cursor
|
* Write out an integer, in the specified radix. Update the physical cursor
|
||||||
* position.
|
* position.
|
||||||
*/
|
*/
|
||||||
mlputi(i, r)
|
mlputi(i, r)
|
||||||
{
|
{
|
||||||
register int q;
|
register int q;
|
||||||
static char hexdigits[] = "0123456789ABCDEF";
|
static char hexdigits[] = "0123456789ABCDEF";
|
||||||
|
|
||||||
if (i < 0)
|
if (i < 0) {
|
||||||
{
|
|
||||||
i = -i;
|
i = -i;
|
||||||
TTputc('-');
|
TTputc('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
q = i/r;
|
q = i / r;
|
||||||
|
|
||||||
if (q != 0)
|
if (q != 0)
|
||||||
mlputi(q, r);
|
mlputi(q, r);
|
||||||
|
|
||||||
TTputc(hexdigits[i%r]);
|
TTputc(hexdigits[i % r]);
|
||||||
++ttcol;
|
++ttcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* do the same except as a long integer.
|
* do the same except as a long integer.
|
||||||
*/
|
*/
|
||||||
mlputli(l, r)
|
mlputli(l, r)
|
||||||
long l;
|
long l;
|
||||||
{
|
{
|
||||||
register long q;
|
register long q;
|
||||||
|
|
||||||
if (l < 0)
|
if (l < 0) {
|
||||||
{
|
|
||||||
l = -l;
|
l = -l;
|
||||||
TTputc('-');
|
TTputc('-');
|
||||||
}
|
}
|
||||||
|
|
||||||
q = l/r;
|
q = l / r;
|
||||||
|
|
||||||
if (q != 0)
|
if (q != 0)
|
||||||
mlputli(q, r);
|
mlputli(q, r);
|
||||||
|
|
||||||
TTputc((int)(l%r)+'0');
|
TTputc((int) (l % r) + '0');
|
||||||
++ttcol;
|
++ttcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* write out a scaled integer with two decimal places
|
* write out a scaled integer with two decimal places
|
||||||
@ -1498,30 +1477,30 @@ int s; /* scaled integer to output */
|
|||||||
#if RAINBOW
|
#if RAINBOW
|
||||||
|
|
||||||
putline(row, col, buf)
|
putline(row, col, buf)
|
||||||
int row, col;
|
int row, col;
|
||||||
char buf[];
|
char buf[];
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
n = strlen(buf);
|
n = strlen(buf);
|
||||||
if (col + n - 1 > term.t_ncol)
|
if (col + n - 1 > term.t_ncol)
|
||||||
n = term.t_ncol - col + 1;
|
n = term.t_ncol - col + 1;
|
||||||
Put_Data(row, col, n, buf);
|
Put_Data(row, col, n, buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get terminal size from system.
|
/* Get terminal size from system.
|
||||||
Store number of lines into *heightp and width into *widthp.
|
Store number of lines into *heightp and width into *widthp.
|
||||||
If zero or a negative number is stored, the value is not valid. */
|
If zero or a negative number is stored, the value is not valid. */
|
||||||
|
|
||||||
getscreensize (widthp, heightp)
|
getscreensize(widthp, heightp)
|
||||||
int *widthp, *heightp;
|
int *widthp, *heightp;
|
||||||
{
|
{
|
||||||
#ifdef TIOCGWINSZ
|
#ifdef TIOCGWINSZ
|
||||||
struct winsize size;
|
struct winsize size;
|
||||||
*widthp = 0;
|
*widthp = 0;
|
||||||
*heightp = 0;
|
*heightp = 0;
|
||||||
if (ioctl (0, TIOCGWINSZ, &size) < 0)
|
if (ioctl(0, TIOCGWINSZ, &size) < 0)
|
||||||
return;
|
return;
|
||||||
*widthp = size.ws_col;
|
*widthp = size.ws_col;
|
||||||
*heightp = size.ws_row;
|
*heightp = size.ws_row;
|
||||||
@ -1539,16 +1518,16 @@ int signr;
|
|||||||
extern int errno;
|
extern int errno;
|
||||||
int old_errno = 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);
|
newscreensize(h, w);
|
||||||
|
|
||||||
signal (SIGWINCH, sizesignal);
|
signal(SIGWINCH, sizesignal);
|
||||||
errno = old_errno;
|
errno = old_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
newscreensize (h, w)
|
newscreensize(h, w)
|
||||||
int h, w;
|
int h, w;
|
||||||
{
|
{
|
||||||
/* do the change later */
|
/* do the change later */
|
||||||
@ -1559,13 +1538,12 @@ int h, w;
|
|||||||
}
|
}
|
||||||
chg_width = chg_height = 0;
|
chg_width = chg_height = 0;
|
||||||
if (h - 1 < term.t_mrow)
|
if (h - 1 < term.t_mrow)
|
||||||
newsize(TRUE,h);
|
newsize(TRUE, h);
|
||||||
if (w < term.t_mcol)
|
if (w < term.t_mcol)
|
||||||
newwidth(TRUE,w);
|
newwidth(TRUE, w);
|
||||||
|
|
||||||
update(TRUE);
|
update(TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
523
ebind.h
523
ebind.h
@ -12,238 +12,407 @@
|
|||||||
* control-X commands.
|
* control-X commands.
|
||||||
*/
|
*/
|
||||||
KEYTAB keytab[NBINDS] = {
|
KEYTAB keytab[NBINDS] = {
|
||||||
{CONTROL|'A', gotobol},
|
{CONTROL | 'A', gotobol}
|
||||||
{CONTROL|'B', backchar},
|
,
|
||||||
{CONTROL|'C', insspace},
|
{CONTROL | 'B', backchar}
|
||||||
{CONTROL|'D', forwdel},
|
,
|
||||||
{CONTROL|'E', gotoeol},
|
{CONTROL | 'C', insspace}
|
||||||
{CONTROL|'F', forwchar},
|
,
|
||||||
{CONTROL|'G', ctrlg},
|
{CONTROL | 'D', forwdel}
|
||||||
{CONTROL|'H', backdel},
|
,
|
||||||
{CONTROL|'I', tab},
|
{CONTROL | 'E', gotoeol}
|
||||||
{CONTROL|'J', indent},
|
,
|
||||||
{CONTROL|'K', killtext},
|
{CONTROL | 'F', forwchar}
|
||||||
{CONTROL|'L', refresh},
|
,
|
||||||
{CONTROL|'M', newline},
|
{CONTROL | 'G', ctrlg}
|
||||||
{CONTROL|'N', forwline},
|
,
|
||||||
{CONTROL|'O', openline},
|
{CONTROL | 'H', backdel}
|
||||||
{CONTROL|'P', backline},
|
,
|
||||||
{CONTROL|'Q', quote},
|
{CONTROL | 'I', tab}
|
||||||
{CONTROL|'R', backsearch},
|
,
|
||||||
{CONTROL|'S', forwsearch},
|
{CONTROL | 'J', indent}
|
||||||
{CONTROL|'T', twiddle},
|
,
|
||||||
{CONTROL|'U', unarg},
|
{CONTROL | 'K', killtext}
|
||||||
{CONTROL|'V', forwpage},
|
,
|
||||||
{CONTROL|'W', killregion},
|
{CONTROL | 'L', refresh}
|
||||||
{CONTROL|'X', cex},
|
,
|
||||||
{CONTROL|'Y', yank},
|
{CONTROL | 'M', newline}
|
||||||
{CONTROL|'Z', backpage},
|
,
|
||||||
{CONTROL|']', meta},
|
{CONTROL | 'N', forwline}
|
||||||
{CTLX|CONTROL|'B', listbuffers},
|
,
|
||||||
{CTLX|CONTROL|'C', quit}, /* Hard quit. */
|
{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
|
#if PKCODE & AEDIT
|
||||||
{CTLX|CONTROL|'A', detab},
|
{CTLX | CONTROL | 'A', detab}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{CTLX|CONTROL|'D', filesave}, /* alternative */
|
{CTLX | CONTROL | 'D', filesave}
|
||||||
|
, /* alternative */
|
||||||
#else
|
#else
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{CTLX|CONTROL|'D', detab},
|
{CTLX | CONTROL | 'D', detab}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{CTLX|CONTROL|'E', entab},
|
{CTLX | CONTROL | 'E', entab}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{CTLX|CONTROL|'F', filefind},
|
{CTLX | CONTROL | 'F', filefind}
|
||||||
{CTLX|CONTROL|'I', insfile},
|
,
|
||||||
{CTLX|CONTROL|'L', lowerregion},
|
{CTLX | CONTROL | 'I', insfile}
|
||||||
{CTLX|CONTROL|'M', delmode},
|
,
|
||||||
{CTLX|CONTROL|'N', mvdnwind},
|
{CTLX | CONTROL | 'L', lowerregion}
|
||||||
{CTLX|CONTROL|'O', deblank},
|
,
|
||||||
{CTLX|CONTROL|'P', mvupwind},
|
{CTLX | CONTROL | 'M', delmode}
|
||||||
{CTLX|CONTROL|'R', fileread},
|
,
|
||||||
{CTLX|CONTROL|'S', filesave},
|
{CTLX | CONTROL | 'N', mvdnwind}
|
||||||
|
,
|
||||||
|
{CTLX | CONTROL | 'O', deblank}
|
||||||
|
,
|
||||||
|
{CTLX | CONTROL | 'P', mvupwind}
|
||||||
|
,
|
||||||
|
{CTLX | CONTROL | 'R', fileread}
|
||||||
|
,
|
||||||
|
{CTLX | CONTROL | 'S', filesave}
|
||||||
|
,
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
{CTLX|CONTROL|'T', trim},
|
{CTLX | CONTROL | 'T', trim}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{CTLX|CONTROL|'U', upperregion},
|
{CTLX | CONTROL | 'U', upperregion}
|
||||||
{CTLX|CONTROL|'V', viewfile},
|
,
|
||||||
{CTLX|CONTROL|'W', filewrite},
|
{CTLX | CONTROL | 'V', viewfile}
|
||||||
{CTLX|CONTROL|'X', swapmark},
|
,
|
||||||
{CTLX|CONTROL|'Z', shrinkwind},
|
{CTLX | CONTROL | 'W', filewrite}
|
||||||
{CTLX|'?', deskey},
|
,
|
||||||
{CTLX|'!', spawn},
|
{CTLX | CONTROL | 'X', swapmark}
|
||||||
{CTLX|'@', pipecmd},
|
,
|
||||||
{CTLX|'#', filter},
|
{CTLX | CONTROL | 'Z', shrinkwind}
|
||||||
{CTLX|'$', execprg},
|
,
|
||||||
{CTLX|'=', showcpos},
|
{CTLX | '?', deskey}
|
||||||
{CTLX|'(', ctlxlp},
|
,
|
||||||
{CTLX|')', ctlxrp},
|
{CTLX | '!', spawn}
|
||||||
{CTLX|'^', enlargewind},
|
,
|
||||||
{CTLX|'0', delwind},
|
{CTLX | '@', pipecmd}
|
||||||
{CTLX|'1', onlywind},
|
,
|
||||||
{CTLX|'2', splitwind},
|
{CTLX | '#', filter}
|
||||||
{CTLX|'A', setvar},
|
,
|
||||||
{CTLX|'B', usebuffer},
|
{CTLX | '$', execprg}
|
||||||
{CTLX|'C', spawncli},
|
,
|
||||||
|
{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
|
#if BSD | __hpux | SVR4
|
||||||
{CTLX|'D', bktoshell},
|
{CTLX | 'D', bktoshell}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{CTLX|'E', ctlxe},
|
{CTLX | 'E', ctlxe}
|
||||||
{CTLX|'F', setfillcol},
|
,
|
||||||
{CTLX|'K', killbuffer},
|
{CTLX | 'F', setfillcol}
|
||||||
{CTLX|'M', setmode},
|
,
|
||||||
{CTLX|'N', filename},
|
{CTLX | 'K', killbuffer}
|
||||||
{CTLX|'O', nextwind},
|
,
|
||||||
{CTLX|'P', prevwind},
|
{CTLX | 'M', setmode}
|
||||||
|
,
|
||||||
|
{CTLX | 'N', filename}
|
||||||
|
,
|
||||||
|
{CTLX | 'O', nextwind}
|
||||||
|
,
|
||||||
|
{CTLX | 'P', prevwind}
|
||||||
|
,
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{CTLX|'Q', quote}, /* alternative */
|
{CTLX | 'Q', quote}
|
||||||
|
, /* alternative */
|
||||||
#endif
|
#endif
|
||||||
#if ISRCH
|
#if ISRCH
|
||||||
{CTLX|'R', risearch},
|
{CTLX | 'R', risearch}
|
||||||
{CTLX|'S', fisearch},
|
,
|
||||||
|
{CTLX | 'S', fisearch}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{CTLX|'W', resize},
|
{CTLX | 'W', resize}
|
||||||
{CTLX|'X', nextbuffer},
|
,
|
||||||
{CTLX|'Z', enlargewind},
|
{CTLX | 'X', nextbuffer}
|
||||||
|
,
|
||||||
|
{CTLX | 'Z', enlargewind}
|
||||||
|
,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{META|CONTROL|'C', wordcount},
|
{META | CONTROL | 'C', wordcount}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{META|CONTROL|'D', newsize},
|
{META | CONTROL | 'D', newsize}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#if PROC
|
#if PROC
|
||||||
{META|CONTROL|'E', execproc},
|
{META | CONTROL | 'E', execproc}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#if CFENCE
|
#if CFENCE
|
||||||
{META|CONTROL|'F', getfence},
|
{META | CONTROL | 'F', getfence}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{META|CONTROL|'H', delbword},
|
{META | CONTROL | 'H', delbword}
|
||||||
{META|CONTROL|'K', unbindkey},
|
,
|
||||||
{META|CONTROL|'L', reposition},
|
{META | CONTROL | 'K', unbindkey}
|
||||||
{META|CONTROL|'M', delgmode},
|
,
|
||||||
{META|CONTROL|'N', namebuffer},
|
{META | CONTROL | 'L', reposition}
|
||||||
{META|CONTROL|'R', qreplace},
|
,
|
||||||
{META|CONTROL|'S', newsize},
|
{META | CONTROL | 'M', delgmode}
|
||||||
{META|CONTROL|'T', newwidth},
|
,
|
||||||
{META|CONTROL|'V', scrnextdw},
|
{META | CONTROL | 'N', namebuffer}
|
||||||
|
,
|
||||||
|
{META | CONTROL | 'R', qreplace}
|
||||||
|
,
|
||||||
|
{META | CONTROL | 'S', newsize}
|
||||||
|
,
|
||||||
|
{META | CONTROL | 'T', newwidth}
|
||||||
|
,
|
||||||
|
{META | CONTROL | 'V', scrnextdw}
|
||||||
|
,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{META|CONTROL|'W', killpara},
|
{META | CONTROL | 'W', killpara}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{META|CONTROL|'Z', scrnextup},
|
{META | CONTROL | 'Z', scrnextup}
|
||||||
{META|' ', setmark},
|
,
|
||||||
{META|'?', help},
|
{META | ' ', setmark}
|
||||||
{META|'!', reposition},
|
,
|
||||||
{META|'.', setmark},
|
{META | '?', help}
|
||||||
{META|'>', gotoeob},
|
,
|
||||||
{META|'<', gotobob},
|
{META | '!', reposition}
|
||||||
{META|'~', unmark},
|
,
|
||||||
|
{META | '.', setmark}
|
||||||
|
,
|
||||||
|
{META | '>', gotoeob}
|
||||||
|
,
|
||||||
|
{META | '<', gotobob}
|
||||||
|
,
|
||||||
|
{META | '~', unmark}
|
||||||
|
,
|
||||||
#if APROP
|
#if APROP
|
||||||
{META|'A', apro},
|
{META | 'A', apro}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{META|'B', backword},
|
{META | 'B', backword}
|
||||||
{META|'C', capword},
|
,
|
||||||
{META|'D', delfword},
|
{META | 'C', capword}
|
||||||
|
,
|
||||||
|
{META | 'D', delfword}
|
||||||
|
,
|
||||||
#if CRYPT
|
#if CRYPT
|
||||||
{META|'E', setkey},
|
{META | 'E', setkey}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{META|'F', forwword},
|
{META | 'F', forwword}
|
||||||
{META|'G', gotoline},
|
,
|
||||||
|
{META | 'G', gotoline}
|
||||||
|
,
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{META|'J', justpara},
|
{META | 'J', justpara}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{META|'K', bindtokey},
|
{META | 'K', bindtokey}
|
||||||
{META|'L', lowerword},
|
,
|
||||||
{META|'M', setgmode},
|
{META | 'L', lowerword}
|
||||||
|
,
|
||||||
|
{META | 'M', setgmode}
|
||||||
|
,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{META|'N', gotoeop},
|
{META | 'N', gotoeop}
|
||||||
{META|'P', gotobop},
|
,
|
||||||
{META|'Q', fillpara},
|
{META | 'P', gotobop}
|
||||||
|
,
|
||||||
|
{META | 'Q', fillpara}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{META|'R', sreplace},
|
{META | 'R', sreplace}
|
||||||
|
,
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{META|'S', forwsearch}, /* alternative P.K. */
|
{META | 'S', forwsearch}
|
||||||
|
, /* alternative P.K. */
|
||||||
#else
|
#else
|
||||||
#if BSD
|
#if BSD
|
||||||
{META|'S', bktoshell},
|
{META | 'S', bktoshell}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{META|'U', upperword},
|
{META | 'U', upperword}
|
||||||
{META|'V', backpage},
|
,
|
||||||
{META|'W', copyregion},
|
{META | 'V', backpage}
|
||||||
{META|'X', namedcmd},
|
,
|
||||||
{META|'Z', quickexit},
|
{META | 'W', copyregion}
|
||||||
{META|0x7F, delbword},
|
,
|
||||||
|
{META | 'X', namedcmd}
|
||||||
|
,
|
||||||
|
{META | 'Z', quickexit}
|
||||||
|
,
|
||||||
|
{META | 0x7F, delbword}
|
||||||
|
,
|
||||||
|
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
{SPEC|CONTROL|'_', forwhunt},
|
{SPEC | CONTROL | '_', forwhunt}
|
||||||
{SPEC|CONTROL|'S', backhunt},
|
,
|
||||||
{SPEC|71, gotobol},
|
{SPEC | CONTROL | 'S', backhunt}
|
||||||
{SPEC|72, backline},
|
,
|
||||||
{SPEC|73, backpage},
|
{SPEC | 71, gotobol}
|
||||||
{SPEC|75, backchar},
|
,
|
||||||
{SPEC|77, forwchar},
|
{SPEC | 72, backline}
|
||||||
{SPEC|79, gotoeol},
|
,
|
||||||
{SPEC|80, forwline},
|
{SPEC | 73, backpage}
|
||||||
{SPEC|81, forwpage},
|
,
|
||||||
{SPEC|82, insspace},
|
{SPEC | 75, backchar}
|
||||||
{SPEC|83, forwdel},
|
,
|
||||||
{SPEC|115, backword},
|
{SPEC | 77, forwchar}
|
||||||
{SPEC|116, forwword},
|
,
|
||||||
|
{SPEC | 79, gotoeol}
|
||||||
|
,
|
||||||
|
{SPEC | 80, forwline}
|
||||||
|
,
|
||||||
|
{SPEC | 81, forwpage}
|
||||||
|
,
|
||||||
|
{SPEC | 82, insspace}
|
||||||
|
,
|
||||||
|
{SPEC | 83, forwdel}
|
||||||
|
,
|
||||||
|
{SPEC | 115, backword}
|
||||||
|
,
|
||||||
|
{SPEC | 116, forwword}
|
||||||
|
,
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
{SPEC|132, gotobop},
|
{SPEC | 132, gotobop}
|
||||||
{SPEC|118, gotoeop},
|
,
|
||||||
|
{SPEC | 118, gotoeop}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
{SPEC|84, cbuf1},
|
{SPEC | 84, cbuf1}
|
||||||
{SPEC|85, cbuf2},
|
,
|
||||||
{SPEC|86, cbuf3},
|
{SPEC | 85, cbuf2}
|
||||||
{SPEC|87, cbuf4},
|
,
|
||||||
{SPEC|88, cbuf5},
|
{SPEC | 86, cbuf3}
|
||||||
{SPEC|89, cbuf6},
|
,
|
||||||
{SPEC|90, cbuf7},
|
{SPEC | 87, cbuf4}
|
||||||
{SPEC|91, cbuf8},
|
,
|
||||||
{SPEC|92, cbuf9},
|
{SPEC | 88, cbuf5}
|
||||||
{SPEC|93, cbuf10},
|
,
|
||||||
|
{SPEC | 89, cbuf6}
|
||||||
|
,
|
||||||
|
{SPEC | 90, cbuf7}
|
||||||
|
,
|
||||||
|
{SPEC | 91, cbuf8}
|
||||||
|
,
|
||||||
|
{SPEC | 92, cbuf9}
|
||||||
|
,
|
||||||
|
{SPEC | 93, cbuf10}
|
||||||
|
,
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{SPEC|117, gotoeob},
|
{SPEC | 117, gotoeob}
|
||||||
{SPEC|119, gotobob},
|
,
|
||||||
{SPEC|141, gotobop},
|
{SPEC | 119, gotobob}
|
||||||
{SPEC|145, gotoeop},
|
,
|
||||||
{SPEC|146, yank},
|
{SPEC | 141, gotobop}
|
||||||
{SPEC|147, killregion},
|
,
|
||||||
|
{SPEC | 145, gotoeop}
|
||||||
|
,
|
||||||
|
{SPEC | 146, yank}
|
||||||
|
,
|
||||||
|
{SPEC | 147, killregion}
|
||||||
|
,
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VT220
|
#if VT220
|
||||||
{SPEC|'1', fisearch}, /* VT220 keys */
|
{SPEC | '1', fisearch}
|
||||||
{SPEC|'2', yank},
|
, /* VT220 keys */
|
||||||
{SPEC|'3', killregion},
|
{SPEC | '2', yank}
|
||||||
{SPEC|'4', setmark},
|
,
|
||||||
{SPEC|'5', backpage},
|
{SPEC | '3', killregion}
|
||||||
{SPEC|'6', forwpage},
|
,
|
||||||
{SPEC|'A', backline},
|
{SPEC | '4', setmark}
|
||||||
{SPEC|'B', forwline},
|
,
|
||||||
{SPEC|'C', forwchar},
|
{SPEC | '5', backpage}
|
||||||
{SPEC|'D', backchar},
|
,
|
||||||
{SPEC|'c', meta},
|
{SPEC | '6', forwpage}
|
||||||
{SPEC|'d', backchar},
|
,
|
||||||
{SPEC|'e', forwline},
|
{SPEC | 'A', backline}
|
||||||
{SPEC|'f', gotobob},
|
,
|
||||||
{SPEC|'h', help},
|
{SPEC | 'B', forwline}
|
||||||
{SPEC|'i', cex},
|
,
|
||||||
|
{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
|
#endif
|
||||||
|
|
||||||
{0x7F, backdel},
|
{0x7F, backdel}
|
||||||
|
,
|
||||||
|
|
||||||
/* special internal bindings */
|
/* special internal bindings */
|
||||||
SPEC|META|'W', wrapword, /* called on word wrap */
|
SPEC | META | 'W', wrapword, /* called on word wrap */
|
||||||
SPEC|META|'C', nullproc, /* every command input */
|
SPEC | META | 'C', nullproc, /* every command input */
|
||||||
SPEC|META|'R', nullproc, /* on file read */
|
SPEC | META | 'R', nullproc, /* on file read */
|
||||||
SPEC|META|'X', nullproc, /* on window change P.K. */
|
SPEC | META | 'X', nullproc, /* on window change P.K. */
|
||||||
|
|
||||||
{0, NULL}
|
{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? */
|
int flickcode = FALSE; /* do flicker supression? */
|
||||||
char *modename[] = { /* name of modes */
|
char *modename[] = { /* name of modes */
|
||||||
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
|
"WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER",
|
||||||
"MAGIC", "CRYPT", "ASAVE"};
|
"MAGIC", "CRYPT", "ASAVE"
|
||||||
|
};
|
||||||
char *mode2name[] = { /* name of modes */
|
char *mode2name[] = { /* name of modes */
|
||||||
"Wrap", "Cmode", "Spell", "Exact", "View", "Over",
|
"Wrap", "Cmode", "Spell", "Exact", "View", "Over",
|
||||||
"Magic", "Crypt", "Asave"};
|
"Magic", "Crypt", "Asave"
|
||||||
|
};
|
||||||
char modecode[] = "WCSEVOMYA"; /* letters to represent modes */
|
char modecode[] = "WCSEVOMYA"; /* letters to represent modes */
|
||||||
int gmode = 0; /* global editor mode */
|
int gmode = 0; /* global editor mode */
|
||||||
int gflags = GFREAD; /* global control flag */
|
int gflags = GFREAD; /* global control flag */
|
||||||
@ -58,7 +60,7 @@ int gfcolor = 8; /* global forgrnd color (white) */
|
|||||||
#else
|
#else
|
||||||
int gfcolor = 7; /* global forgrnd color (white) */
|
int gfcolor = 7; /* global forgrnd color (white) */
|
||||||
#endif
|
#endif
|
||||||
int gbcolor = 0; /* global backgrnd color (black)*/
|
int gbcolor = 0; /* global backgrnd color (black) */
|
||||||
int gasave = 256; /* global ASAVE size */
|
int gasave = 256; /* global ASAVE size */
|
||||||
int gacount = 256; /* count until next ASAVE */
|
int gacount = 256; /* count until next ASAVE */
|
||||||
int sgarbf = TRUE; /* TRUE if screen is garbage */
|
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 mstore = FALSE; /* storing text to macro flag */
|
||||||
int discmd = TRUE; /* display command flag */
|
int discmd = TRUE; /* display command flag */
|
||||||
int disinp = TRUE; /* display input characters */
|
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 vtrow = 0; /* Row location of SW cursor */
|
||||||
int vtcol = 0; /* Column location of SW cursor */
|
int vtcol = 0; /* Column location of SW cursor */
|
||||||
int ttrow = HUGE; /* Row location of HW cursor */
|
int ttrow = HUGE; /* Row location of HW cursor */
|
||||||
@ -86,9 +88,9 @@ char *cname[] = { /* names of colors */
|
|||||||
"BLACK", "RED", "GREEN", "YELLOW", "BLUE",
|
"BLACK", "RED", "GREEN", "YELLOW", "BLUE",
|
||||||
"MAGENTA", "CYAN", "WHITE"
|
"MAGENTA", "CYAN", "WHITE"
|
||||||
#if PKCODE & IBMPC
|
#if PKCODE & IBMPC
|
||||||
,"HIGH"
|
, "HIGH"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
KILL *kbufp = NULL; /* current kill buffer chunk pointer */
|
KILL *kbufp = NULL; /* current kill buffer chunk pointer */
|
||||||
KILL *kbufh = NULL; /* kill buffer header pointer */
|
KILL *kbufh = NULL; /* kill buffer header pointer */
|
||||||
int kused = KBLOCK; /* # of bytes used in kill buffer */
|
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 gmode; /* global editor mode */
|
||||||
extern int gflags; /* global control flag */
|
extern int gflags; /* global control flag */
|
||||||
extern int gfcolor; /* global forgrnd color (white) */
|
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 gasave; /* global ASAVE size */
|
||||||
extern int gacount; /* count until next ASAVE */
|
extern int gacount; /* count until next ASAVE */
|
||||||
extern int sgarbf; /* State of screen unknown */
|
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 mstore; /* storing text to macro flag */
|
||||||
extern int discmd; /* display command flag */
|
extern int discmd; /* display command flag */
|
||||||
extern int disinp; /* display input characters */
|
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 vtrow; /* Row location of SW cursor */
|
||||||
extern int vtcol; /* Column location of SW cursor */
|
extern int vtcol; /* Column location of SW cursor */
|
||||||
extern int ttrow; /* Row location of HW 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
|
#ifndef termdef
|
||||||
extern TERM term; /* Terminal information. */
|
extern TERM term; /* Terminal information. */
|
||||||
#endif
|
#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 spawncli(); /* Run CLI in a subjob. */
|
||||||
extern int spawn(); /* Run a command in a subjob. */
|
extern int spawn(); /* Run a command in a subjob. */
|
||||||
#if BSD | __hpux | SVR4
|
#if BSD | __hpux | SVR4
|
||||||
extern int bktoshell(); /* suspend emacs to parent shell*/
|
extern int bktoshell(); /* suspend emacs to parent shell */
|
||||||
extern int rtfrmshell(); /* return from a suspended state*/
|
extern int rtfrmshell(); /* return from a suspended state */
|
||||||
#endif
|
#endif
|
||||||
extern int quickexit(); /* low keystroke style exit. */
|
extern int quickexit(); /* low keystroke style exit. */
|
||||||
extern int setmode(); /* set an editor mode */
|
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 delgmode(); /* delete a global mode */
|
||||||
extern int insspace(); /* insert a space forword */
|
extern int insspace(); /* insert a space forword */
|
||||||
extern int forwhunt(); /* hunt forward for next match */
|
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 pipecmd(); /* pipe command into buffer */
|
||||||
extern int filter(); /* filter buffer through dos */
|
extern int filter(); /* filter buffer through dos */
|
||||||
extern int delwind(); /* delete the current window */
|
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 */
|
/* possible names and paths of help files under different OSs */
|
||||||
|
|
||||||
char *pathname[] =
|
char *pathname[] =
|
||||||
|
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
{
|
{
|
||||||
"emacs.rc",
|
"emacs.rc",
|
||||||
@ -24,30 +23,20 @@ char *pathname[] =
|
|||||||
|
|
||||||
#if V7 | BSD | USG
|
#if V7 | BSD | USG
|
||||||
{
|
{
|
||||||
".emacsrc",
|
".emacsrc", "emacs.hlp",
|
||||||
"emacs.hlp",
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
"/usr/global/lib/",
|
"/usr/global/lib/", "/usr/local/bin/", "/usr/local/lib/",
|
||||||
"/usr/local/bin/",
|
|
||||||
"/usr/local/lib/",
|
|
||||||
#endif
|
#endif
|
||||||
"/usr/local/",
|
"/usr/local/", "/usr/lib/", ""};
|
||||||
"/usr/lib/",
|
|
||||||
""
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
{
|
{
|
||||||
"emacs.rc",
|
"emacs.rc", "emacs.hlp", "",
|
||||||
"emacs.hlp",
|
|
||||||
"",
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
"sys$login:",
|
"sys$login:", "emacs_dir:",
|
||||||
"emacs_dir:",
|
|
||||||
#endif
|
#endif
|
||||||
"sys$sysdevice:[vmstools]"
|
"sys$sysdevice:[vmstools]"};
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NPNAMES (sizeof(pathname)/sizeof(char *))
|
#define NPNAMES (sizeof(pathname)/sizeof(char *))
|
||||||
|
77
estruct.h
77
estruct.h
@ -77,7 +77,7 @@
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#define MSDOS 1 /* MS-DOS */
|
#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 BSD 0 /* UNIX BSD 4.2 and ULTRIX */
|
||||||
#define USG 0 /* UNIX system V */
|
#define USG 0 /* UNIX system V */
|
||||||
#define VMS 0 /* VAX/VMS */
|
#define VMS 0 /* VAX/VMS */
|
||||||
@ -308,7 +308,7 @@
|
|||||||
#define FIOEOF 2 /* File I/O, end of file. */
|
#define FIOEOF 2 /* File I/O, end of file. */
|
||||||
#define FIOERR 3 /* File I/O, error. */
|
#define FIOERR 3 /* File I/O, error. */
|
||||||
#define FIOMEM 4 /* File I/O, out of memory */
|
#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 CFCPCN 0x0001 /* Last command was C-P, C-N */
|
||||||
#define CFKILL 0x0002 /* Last command was a kill */
|
#define CFKILL 0x0002 /* Last command was a kill */
|
||||||
@ -496,7 +496,7 @@ typedef struct BUFFER {
|
|||||||
#define NUMMODES 9 /* # of defined modes */
|
#define NUMMODES 9 /* # of defined modes */
|
||||||
|
|
||||||
#define MDWRAP 0x0001 /* word wrap */
|
#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 MDSPELL 0x0004 /* spell error parcing */
|
||||||
#define MDEXACT 0x0008 /* Exact matching for searches */
|
#define MDEXACT 0x0008 /* Exact matching for searches */
|
||||||
#define MDVIEW 0x0010 /* read-only buffer */
|
#define MDVIEW 0x0010 /* read-only buffer */
|
||||||
@ -551,28 +551,28 @@ typedef struct {
|
|||||||
short t_nrow; /* current number of rows used */
|
short t_nrow; /* current number of rows used */
|
||||||
short t_mcol; /* max Number of columns. */
|
short t_mcol; /* max Number of columns. */
|
||||||
short t_ncol; /* current 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 " */
|
short t_scrsiz; /* size of scroll region " */
|
||||||
int t_pause; /* # times thru update to pause */
|
int t_pause; /* # times thru update to pause */
|
||||||
int (*t_open)(); /* Open terminal at the start. */
|
int (*t_open) (); /* Open terminal at the start. */
|
||||||
int (*t_close)(); /* Close terminal at end. */
|
int (*t_close) (); /* Close terminal at end. */
|
||||||
int (*t_kopen)(); /* Open keyboard */
|
int (*t_kopen) (); /* Open keyboard */
|
||||||
int (*t_kclose)(); /* close keyboard */
|
int (*t_kclose) (); /* close keyboard */
|
||||||
int (*t_getchar)(); /* Get character from keyboard. */
|
int (*t_getchar) (); /* Get character from keyboard. */
|
||||||
int (*t_putchar)(); /* Put character to display. */
|
int (*t_putchar) (); /* Put character to display. */
|
||||||
int (*t_flush)(); /* Flush output buffers. */
|
int (*t_flush) (); /* Flush output buffers. */
|
||||||
int (*t_move)(); /* Move the cursor, origin 0. */
|
int (*t_move) (); /* Move the cursor, origin 0. */
|
||||||
int (*t_eeol)(); /* Erase to end of line. */
|
int (*t_eeol) (); /* Erase to end of line. */
|
||||||
int (*t_eeop)(); /* Erase to end of page. */
|
int (*t_eeop) (); /* Erase to end of page. */
|
||||||
int (*t_beep)(); /* Beep. */
|
int (*t_beep) (); /* Beep. */
|
||||||
int (*t_rev)(); /* set reverse video state */
|
int (*t_rev) (); /* set reverse video state */
|
||||||
int (*t_rez)(); /* change screen resolution */
|
int (*t_rez) (); /* change screen resolution */
|
||||||
#if COLOR
|
#if COLOR
|
||||||
int (*t_setfor)(); /* set forground color */
|
int (*t_setfor) (); /* set forground color */
|
||||||
int (*t_setback)(); /* set background color */
|
int (*t_setback) (); /* set background color */
|
||||||
#endif
|
#endif
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
int (*t_scroll)(); /* scroll a region of the screen */
|
int (*t_scroll) (); /* scroll a region of the screen */
|
||||||
#endif
|
#endif
|
||||||
} TERM;
|
} TERM;
|
||||||
|
|
||||||
@ -601,14 +601,14 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
short k_code; /* Key code */
|
short k_code; /* Key code */
|
||||||
int (*k_fp)(); /* Routine to handle it */
|
int (*k_fp) (); /* Routine to handle it */
|
||||||
} KEYTAB;
|
} KEYTAB;
|
||||||
|
|
||||||
/* structure for the name binding table */
|
/* structure for the name binding table */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *n_name; /* name of function key */
|
char *n_name; /* name of function key */
|
||||||
int (*n_func)(); /* function name is bound to */
|
int (*n_func) (); /* function name is bound to */
|
||||||
} NBIND;
|
} NBIND;
|
||||||
|
|
||||||
/* The editor holds deleted text chunks in the KILL buffer. The
|
/* The editor holds deleted text chunks in the KILL buffer. The
|
||||||
@ -642,7 +642,7 @@ typedef struct VDESC {
|
|||||||
|
|
||||||
typedef struct WHBLOCK {
|
typedef struct WHBLOCK {
|
||||||
LINE *w_begin; /* ptr to !while statement */
|
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 */
|
int w_type; /* block type */
|
||||||
struct WHBLOCK *w_next; /* next while */
|
struct WHBLOCK *w_next; /* next while */
|
||||||
} WHBLOCK;
|
} WHBLOCK;
|
||||||
@ -678,30 +678,30 @@ typedef struct WHBLOCK {
|
|||||||
* Defines for the metacharacters in the regular expression
|
* Defines for the metacharacters in the regular expression
|
||||||
* search routines.
|
* search routines.
|
||||||
*/
|
*/
|
||||||
#define MCNIL 0 /* Like the '\0' for strings.*/
|
#define MCNIL 0 /* Like the '\0' for strings. */
|
||||||
#define LITCHAR 1 /* Literal character, or string.*/
|
#define LITCHAR 1 /* Literal character, or string. */
|
||||||
#define ANY 2
|
#define ANY 2
|
||||||
#define CCL 3
|
#define CCL 3
|
||||||
#define NCCL 4
|
#define NCCL 4
|
||||||
#define BOL 5
|
#define BOL 5
|
||||||
#define EOL 6
|
#define EOL 6
|
||||||
#define DITTO 7
|
#define DITTO 7
|
||||||
#define CLOSURE 256 /* An or-able value.*/
|
#define CLOSURE 256 /* An or-able value. */
|
||||||
#define MASKCL CLOSURE - 1
|
#define MASKCL CLOSURE - 1
|
||||||
|
|
||||||
#define MC_ANY '.' /* 'Any' character (except newline).*/
|
#define MC_ANY '.' /* 'Any' character (except newline). */
|
||||||
#define MC_CCL '[' /* Character class.*/
|
#define MC_CCL '[' /* Character class. */
|
||||||
#define MC_NCCL '^' /* Negate character class.*/
|
#define MC_NCCL '^' /* Negate character class. */
|
||||||
#define MC_RCCL '-' /* Range in character class.*/
|
#define MC_RCCL '-' /* Range in character class. */
|
||||||
#define MC_ECCL ']' /* End of character class.*/
|
#define MC_ECCL ']' /* End of character class. */
|
||||||
#define MC_BOL '^' /* Beginning of line.*/
|
#define MC_BOL '^' /* Beginning of line. */
|
||||||
#define MC_EOL '$' /* End of line.*/
|
#define MC_EOL '$' /* End of line. */
|
||||||
#define MC_CLOSURE '*' /* Closure - does not extend past newline.*/
|
#define MC_CLOSURE '*' /* Closure - does not extend past newline. */
|
||||||
#define MC_DITTO '&' /* Use matched string in replacement.*/
|
#define MC_DITTO '&' /* Use matched string in replacement. */
|
||||||
#define MC_ESC '\\' /* Escape - suppress meta-meaning.*/
|
#define MC_ESC '\\' /* Escape - suppress meta-meaning. */
|
||||||
|
|
||||||
#define BIT(n) (1 << (n)) /* An integer with one bit set.*/
|
#define BIT(n) (1 << (n)) /* An integer with one bit set. */
|
||||||
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter.*/
|
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */
|
||||||
|
|
||||||
/* HICHAR - 1 is the largest character we will deal with.
|
/* HICHAR - 1 is the largest character we will deal with.
|
||||||
* HIBYTE represents the number of bytes in the bitmap.
|
* HIBYTE represents the number of bytes in the bitmap.
|
||||||
@ -728,4 +728,3 @@ typedef struct {
|
|||||||
char *rstr;
|
char *rstr;
|
||||||
} RMC;
|
} RMC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
598
eval.c
598
eval.c
@ -11,17 +11,16 @@
|
|||||||
#include "edef.h"
|
#include "edef.h"
|
||||||
#include "evar.h"
|
#include "evar.h"
|
||||||
|
|
||||||
varinit() /* initialize the user variable list */
|
varinit()
|
||||||
|
{ /* initialize the user variable list */
|
||||||
{
|
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
for (i=0; i < MAXVARS; i++)
|
for (i = 0; i < MAXVARS; i++)
|
||||||
uv[i].u_name[0] = 0;
|
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 */
|
char *fname; /* name of function to evaluate */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -47,89 +46,126 @@ char *fname; /* name of function to evaluate */
|
|||||||
|
|
||||||
/* return errorm on a bad reference */
|
/* return errorm on a bad reference */
|
||||||
if (fnum == NFUNCS)
|
if (fnum == NFUNCS)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
|
|
||||||
/* if needed, retrieve the first argument */
|
/* if needed, retrieve the first argument */
|
||||||
if (funcs[fnum].f_type >= MONAMIC) {
|
if (funcs[fnum].f_type >= MONAMIC) {
|
||||||
if ((status = macarg(arg1)) != TRUE)
|
if ((status = macarg(arg1)) != TRUE)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
|
|
||||||
/* if needed, retrieve the second argument */
|
/* if needed, retrieve the second argument */
|
||||||
if (funcs[fnum].f_type >= DYNAMIC) {
|
if (funcs[fnum].f_type >= DYNAMIC) {
|
||||||
if ((status = macarg(arg2)) != TRUE)
|
if ((status = macarg(arg2)) != TRUE)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
|
|
||||||
/* if needed, retrieve the third argument */
|
/* if needed, retrieve the third argument */
|
||||||
if (funcs[fnum].f_type >= TRINAMIC)
|
if (funcs[fnum].f_type >= TRINAMIC)
|
||||||
if ((status = macarg(arg3)) != TRUE)
|
if ((status = macarg(arg3)) != TRUE)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* and now evaluate it! */
|
/* and now evaluate it! */
|
||||||
switch (fnum) {
|
switch (fnum) {
|
||||||
case UFADD: return(itoa(atoi(arg1) + atoi(arg2)));
|
case UFADD:
|
||||||
case UFSUB: return(itoa(atoi(arg1) - atoi(arg2)));
|
return (itoa(atoi(arg1) + atoi(arg2)));
|
||||||
case UFTIMES: return(itoa(atoi(arg1) * atoi(arg2)));
|
case UFSUB:
|
||||||
case UFDIV: return(itoa(atoi(arg1) / atoi(arg2)));
|
return (itoa(atoi(arg1) - atoi(arg2)));
|
||||||
case UFMOD: return(itoa(atoi(arg1) % atoi(arg2)));
|
case UFTIMES:
|
||||||
case UFNEG: return(itoa(-atoi(arg1)));
|
return (itoa(atoi(arg1) * atoi(arg2)));
|
||||||
case UFCAT: strcpy(result, arg1);
|
case UFDIV:
|
||||||
return(strcat(result, arg2));
|
return (itoa(atoi(arg1) / atoi(arg2)));
|
||||||
case UFLEFT: return(strncpy(result, arg1, atoi(arg2)));
|
case UFMOD:
|
||||||
case UFRIGHT: return(strcpy(result,
|
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))]));
|
&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)));
|
atoi(arg3)));
|
||||||
case UFNOT: return(ltos(stol(arg1) == FALSE));
|
case UFNOT:
|
||||||
case UFEQUAL: return(ltos(atoi(arg1) == atoi(arg2)));
|
return (ltos(stol(arg1) == FALSE));
|
||||||
case UFLESS: return(ltos(atoi(arg1) < atoi(arg2)));
|
case UFEQUAL:
|
||||||
case UFGREATER: return(ltos(atoi(arg1) > atoi(arg2)));
|
return (ltos(atoi(arg1) == atoi(arg2)));
|
||||||
case UFSEQUAL: return(ltos(strcmp(arg1, arg2) == 0));
|
case UFLESS:
|
||||||
case UFSLESS: return(ltos(strcmp(arg1, arg2) < 0));
|
return (ltos(atoi(arg1) < atoi(arg2)));
|
||||||
case UFSGREAT: return(ltos(strcmp(arg1, arg2) > 0));
|
case UFGREATER:
|
||||||
case UFIND: return(strcpy(result, getval(arg1)));
|
return (ltos(atoi(arg1) > atoi(arg2)));
|
||||||
case UFAND: return(ltos(stol(arg1) && stol(arg2)));
|
case UFSEQUAL:
|
||||||
case UFOR: return(ltos(stol(arg1) || stol(arg2)));
|
return (ltos(strcmp(arg1, arg2) == 0));
|
||||||
case UFLENGTH: return(itoa(strlen(arg1)));
|
case UFSLESS:
|
||||||
case UFUPPER: return(mkupper(arg1));
|
return (ltos(strcmp(arg1, arg2) < 0));
|
||||||
case UFLOWER: return(mklower(arg1));
|
case UFSGREAT:
|
||||||
case UFTRUTH: return(ltos(atoi(arg1) == 42));
|
return (ltos(strcmp(arg1, arg2) > 0));
|
||||||
case UFASCII: return(itoa((int)arg1[0]));
|
case UFIND:
|
||||||
case UFCHR: result[0] = atoi(arg1);
|
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;
|
result[1] = 0;
|
||||||
return(result);
|
return (result);
|
||||||
case UFGTKEY: result[0] = tgetc();
|
case UFGTKEY:
|
||||||
|
result[0] = tgetc();
|
||||||
result[1] = 0;
|
result[1] = 0;
|
||||||
return(result);
|
return (result);
|
||||||
case UFRND: return(itoa((ernd() % abs(atoi(arg1))) + 1));
|
case UFRND:
|
||||||
case UFABS: return(itoa(abs(atoi(arg1))));
|
return (itoa((ernd() % abs(atoi(arg1))) + 1));
|
||||||
case UFSINDEX: return(itoa(sindex(arg1, arg2)));
|
case UFABS:
|
||||||
|
return (itoa(abs(atoi(arg1))));
|
||||||
|
case UFSINDEX:
|
||||||
|
return (itoa(sindex(arg1, arg2)));
|
||||||
case UFENV:
|
case UFENV:
|
||||||
#if ENVFUNC
|
#if ENVFUNC
|
||||||
tsp = getenv(arg1);
|
tsp = getenv(arg1);
|
||||||
return(tsp == NULL ? "" : tsp);
|
return (tsp == NULL ? "" : tsp);
|
||||||
#else
|
#else
|
||||||
return("");
|
return ("");
|
||||||
#endif
|
#endif
|
||||||
case UFBIND: return(transbind(arg1));
|
case UFBIND:
|
||||||
case UFEXIST: return(ltos(fexist(arg1)));
|
return (transbind(arg1));
|
||||||
|
case UFEXIST:
|
||||||
|
return (ltos(fexist(arg1)));
|
||||||
case UFFIND:
|
case UFFIND:
|
||||||
tsp = flook(arg1, TRUE);
|
tsp = flook(arg1, TRUE);
|
||||||
return(tsp == NULL ? "" : tsp);
|
return (tsp == NULL ? "" : tsp);
|
||||||
case UFBAND: return(itoa(atoi(arg1) & atoi(arg2)));
|
case UFBAND:
|
||||||
case UFBOR: return(itoa(atoi(arg1) | atoi(arg2)));
|
return (itoa(atoi(arg1) & atoi(arg2)));
|
||||||
case UFBXOR: return(itoa(atoi(arg1) ^ atoi(arg2)));
|
case UFBOR:
|
||||||
case UFBNOT: return(itoa(~atoi(arg1)));
|
return (itoa(atoi(arg1) | atoi(arg2)));
|
||||||
case UFXLATE: return(xlat(arg1, arg2, arg3));
|
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 */
|
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 */
|
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 */
|
/* scan the list looking for the user var name */
|
||||||
for (vnum = 0; vnum < MAXVARS; vnum++) {
|
for (vnum = 0; vnum < MAXVARS; vnum++) {
|
||||||
if (uv[vnum].u_name[0] == 0)
|
if (uv[vnum].u_name[0] == 0)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
if (strcmp(vname, uv[vnum].u_name) == 0)
|
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 if we run off the end */
|
||||||
return(errorm);
|
return (errorm);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *gtenv(vname)
|
char *gtenv(vname)
|
||||||
@ -169,78 +205,116 @@ char *vname; /* name of environment variable to retrieve */
|
|||||||
char *ename = getenv(vname);
|
char *ename = getenv(vname);
|
||||||
|
|
||||||
if (ename != NULL)
|
if (ename != NULL)
|
||||||
return(ename);
|
return (ename);
|
||||||
else
|
else
|
||||||
return(errorm);
|
return (errorm);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return(errorm);
|
return (errorm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* otherwise, fetch the appropriate value */
|
/* otherwise, fetch the appropriate value */
|
||||||
switch (vnum) {
|
switch (vnum) {
|
||||||
case EVFILLCOL: return(itoa(fillcol));
|
case EVFILLCOL:
|
||||||
case EVPAGELEN: return(itoa(term.t_nrow + 1));
|
return (itoa(fillcol));
|
||||||
case EVCURCOL: return(itoa(getccol(FALSE)));
|
case EVPAGELEN:
|
||||||
case EVCURLINE: return(itoa(getcline()));
|
return (itoa(term.t_nrow + 1));
|
||||||
case EVRAM: return(itoa((int)(envram / 1024l)));
|
case EVCURCOL:
|
||||||
case EVFLICKER: return(ltos(flickcode));
|
return (itoa(getccol(FALSE)));
|
||||||
case EVCURWIDTH:return(itoa(term.t_ncol));
|
case EVCURLINE:
|
||||||
case EVCBUFNAME:return(curbp->b_bname);
|
return (itoa(getcline()));
|
||||||
case EVCFNAME: return(curbp->b_fname);
|
case EVRAM:
|
||||||
case EVSRES: return(sres);
|
return (itoa((int) (envram / 1024l)));
|
||||||
case EVDEBUG: return(ltos(macbug));
|
case EVFLICKER:
|
||||||
case EVSTATUS: return(ltos(cmdstatus));
|
return (ltos(flickcode));
|
||||||
case EVPALETTE: return(palstr);
|
case EVCURWIDTH:
|
||||||
case EVASAVE: return(itoa(gasave));
|
return (itoa(term.t_ncol));
|
||||||
case EVACOUNT: return(itoa(gacount));
|
case EVCBUFNAME:
|
||||||
case EVLASTKEY: return(itoa(lastkey));
|
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:
|
case EVCURCHAR:
|
||||||
return(curwp->w_dotp->l_used ==
|
return (curwp->w_dotp->l_used ==
|
||||||
curwp->w_doto ? itoa('\n') :
|
curwp->w_doto ? itoa('\n') :
|
||||||
itoa(lgetc(curwp->w_dotp, curwp->w_doto)));
|
itoa(lgetc(curwp->w_dotp, curwp->w_doto)));
|
||||||
case EVDISCMD: return(ltos(discmd));
|
case EVDISCMD:
|
||||||
case EVVERSION: return(VERSION);
|
return (ltos(discmd));
|
||||||
case EVPROGNAME:return(PROGNAME);
|
case EVVERSION:
|
||||||
case EVSEED: return(itoa(seed));
|
return (VERSION);
|
||||||
case EVDISINP: return(ltos(disinp));
|
case EVPROGNAME:
|
||||||
case EVWLINE: return(itoa(curwp->w_ntrows));
|
return (PROGNAME);
|
||||||
case EVCWLINE: return(itoa(getwpos()));
|
case EVSEED:
|
||||||
case EVTARGET: saveflag = lastflag;
|
return (itoa(seed));
|
||||||
return(itoa(curgoal));
|
case EVDISINP:
|
||||||
case EVSEARCH: return(pat);
|
return (ltos(disinp));
|
||||||
case EVREPLACE: return(rpat);
|
case EVWLINE:
|
||||||
case EVMATCH: return((patmatch == NULL)? "": patmatch);
|
return (itoa(curwp->w_ntrows));
|
||||||
case EVKILL: return(getkill());
|
case EVCWLINE:
|
||||||
case EVCMODE: return(itoa(curbp->b_mode));
|
return (itoa(getwpos()));
|
||||||
case EVGMODE: return(itoa(gmode));
|
case EVTARGET:
|
||||||
case EVTPAUSE: return(itoa(term.t_pause));
|
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:
|
case EVPENDING:
|
||||||
#if TYPEAH
|
#if TYPEAH
|
||||||
return(ltos(typahead()));
|
return (ltos(typahead()));
|
||||||
#else
|
#else
|
||||||
return(falsem);
|
return (falsem);
|
||||||
#endif
|
#endif
|
||||||
case EVLWIDTH: return(itoa(llength(curwp->w_dotp)));
|
case EVLWIDTH:
|
||||||
case EVLINE: return(getctext());
|
return (itoa(llength(curwp->w_dotp)));
|
||||||
case EVGFLAGS: return(itoa(gflags));
|
case EVLINE:
|
||||||
case EVRVAL: return(itoa(rval));
|
return (getctext());
|
||||||
case EVTAB: return(itoa(tabmask+1));
|
case EVGFLAGS:
|
||||||
case EVOVERLAP: return(itoa(overlap));
|
return (itoa(gflags));
|
||||||
|
case EVRVAL:
|
||||||
|
return (itoa(rval));
|
||||||
|
case EVTAB:
|
||||||
|
return (itoa(tabmask + 1));
|
||||||
|
case EVOVERLAP:
|
||||||
|
return (itoa(overlap));
|
||||||
case EVSCROLLCOUNT:
|
case EVSCROLLCOUNT:
|
||||||
return(itoa(scrollcount));
|
return (itoa(scrollcount));
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
case EVSCROLL: return(ltos(term.t_scroll != NULL));
|
case EVSCROLL:
|
||||||
|
return (ltos(term.t_scroll != NULL));
|
||||||
#else
|
#else
|
||||||
case EVSCROLL: return(ltos(0));
|
case EVSCROLL:
|
||||||
|
return (ltos(0));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
exit(-12); /* again, we should never get here */
|
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 */
|
register int size; /* max number of chars to return */
|
||||||
static char value[NSTRING]; /* temp buffer for value */
|
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 */
|
/* 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 f; /* default flag */
|
||||||
int n; /* numeric arg (can overide prompted value) */
|
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 */
|
register char *ep; /* ptr to end of outline */
|
||||||
#endif
|
#endif
|
||||||
VDESC vd; /* variable num/type */
|
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 */
|
char value[NSTRING]; /* value to set variable to */
|
||||||
|
|
||||||
/* first get the variable to set.. */
|
/* first get the variable to set.. */
|
||||||
if (clexec == FALSE) {
|
if (clexec == FALSE) {
|
||||||
status = mlreply("Variable to set: ", &var[0], NVSIZE);
|
status = mlreply("Variable to set: ", &var[0], NVSIZE);
|
||||||
if (status != TRUE)
|
if (status != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
} else { /* macro line argument */
|
} else { /* macro line argument */
|
||||||
/* grab token and skip it */
|
/* grab token and skip it */
|
||||||
execstr = token(execstr, var, NVSIZE + 1);
|
execstr = token(execstr, var, NVSIZE + 1);
|
||||||
@ -291,7 +365,7 @@ int n; /* numeric arg (can overide prompted value) */
|
|||||||
/* if its not legal....bitch */
|
/* if its not legal....bitch */
|
||||||
if (vd.v_type == -1) {
|
if (vd.v_type == -1) {
|
||||||
mlwrite("%%No such variable as '%s'", var);
|
mlwrite("%%No such variable as '%s'", var);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the value for that variable */
|
/* get the value for that variable */
|
||||||
@ -300,7 +374,7 @@ int n; /* numeric arg (can overide prompted value) */
|
|||||||
else {
|
else {
|
||||||
status = mlreply("Value: ", &value[0], NSTRING);
|
status = mlreply("Value: ", &value[0], NSTRING);
|
||||||
if (status != TRUE)
|
if (status != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and set the appropriate value */
|
/* and set the appropriate value */
|
||||||
@ -331,12 +405,11 @@ int n; /* numeric arg (can overide prompted value) */
|
|||||||
if (*sp++ == '%') {
|
if (*sp++ == '%') {
|
||||||
/* advance to the end */
|
/* advance to the end */
|
||||||
ep = --sp;
|
ep = --sp;
|
||||||
while (*ep++)
|
while (*ep++);
|
||||||
;
|
|
||||||
/* null terminate the string one out */
|
/* null terminate the string one out */
|
||||||
*(ep + 1) = 0;
|
*(ep + 1) = 0;
|
||||||
/* copy backwards */
|
/* copy backwards */
|
||||||
while(ep-- > sp)
|
while (ep-- > sp)
|
||||||
*(ep + 1) = *ep;
|
*(ep + 1) = *ep;
|
||||||
|
|
||||||
/* and advance sp past the new % */
|
/* and advance sp past the new % */
|
||||||
@ -356,11 +429,11 @@ int n; /* numeric arg (can overide prompted value) */
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* and return it */
|
/* 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 */
|
char *var; /* name of var to get */
|
||||||
VDESC *vd; /* structure to hold type and ptr */
|
VDESC *vd; /* structure to hold type and ptr */
|
||||||
int size; /* size of var array */
|
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 vnum; /* subscript in varable arrays */
|
||||||
register int vtype; /* type to return */
|
register int vtype; /* type to return */
|
||||||
|
|
||||||
fvar: vtype = -1;
|
fvar:vtype = -1;
|
||||||
switch (var[0]) {
|
switch (var[0]) {
|
||||||
|
|
||||||
case '$': /* check for legal enviromnent var */
|
case '$': /* check for legal enviromnent var */
|
||||||
@ -414,8 +487,8 @@ fvar: vtype = -1;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int svar(var, value) /* set a variable */
|
int svar(var, value)
|
||||||
|
/* set a variable */
|
||||||
VDESC *var; /* variable to set */
|
VDESC *var; /* variable to set */
|
||||||
char *value; /* value to set to */
|
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 vtype; /* type of variable to set */
|
||||||
register int status; /* status return */
|
register int status; /* status return */
|
||||||
register int c; /* translated character */
|
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) */
|
/* simplify the vd structure (we are gonna look at it a lot) */
|
||||||
vnum = var->v_num;
|
vnum = var->v_num;
|
||||||
@ -438,7 +511,7 @@ char *value; /* value to set to */
|
|||||||
free(uv[vnum].u_value);
|
free(uv[vnum].u_value);
|
||||||
sp = malloc(strlen(value) + 1);
|
sp = malloc(strlen(value) + 1);
|
||||||
if (sp == NULL)
|
if (sp == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
strcpy(sp, value);
|
strcpy(sp, value);
|
||||||
uv[vnum].u_value = sp;
|
uv[vnum].u_value = sp;
|
||||||
break;
|
break;
|
||||||
@ -446,41 +519,58 @@ char *value; /* value to set to */
|
|||||||
case TKENV: /* set an environment variable */
|
case TKENV: /* set an environment variable */
|
||||||
status = TRUE; /* by default */
|
status = TRUE; /* by default */
|
||||||
switch (vnum) {
|
switch (vnum) {
|
||||||
case EVFILLCOL: fillcol = atoi(value);
|
case EVFILLCOL:
|
||||||
|
fillcol = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVPAGELEN: status = newsize(TRUE, atoi(value));
|
case EVPAGELEN:
|
||||||
|
status = newsize(TRUE, atoi(value));
|
||||||
break;
|
break;
|
||||||
case EVCURCOL: status = setccol(atoi(value));
|
case EVCURCOL:
|
||||||
|
status = setccol(atoi(value));
|
||||||
break;
|
break;
|
||||||
case EVCURLINE: status = gotoline(TRUE, atoi(value));
|
case EVCURLINE:
|
||||||
|
status = gotoline(TRUE, atoi(value));
|
||||||
break;
|
break;
|
||||||
case EVRAM: break;
|
case EVRAM:
|
||||||
case EVFLICKER: flickcode = stol(value);
|
|
||||||
break;
|
break;
|
||||||
case EVCURWIDTH:status = newwidth(TRUE, atoi(value));
|
case EVFLICKER:
|
||||||
|
flickcode = stol(value);
|
||||||
break;
|
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;
|
curwp->w_flag |= WFMODE;
|
||||||
break;
|
break;
|
||||||
case EVCFNAME: strcpy(curbp->b_fname, value);
|
case EVCFNAME:
|
||||||
|
strcpy(curbp->b_fname, value);
|
||||||
curwp->w_flag |= WFMODE;
|
curwp->w_flag |= WFMODE;
|
||||||
break;
|
break;
|
||||||
case EVSRES: status = TTrez(value);
|
case EVSRES:
|
||||||
|
status = TTrez(value);
|
||||||
break;
|
break;
|
||||||
case EVDEBUG: macbug = stol(value);
|
case EVDEBUG:
|
||||||
|
macbug = stol(value);
|
||||||
break;
|
break;
|
||||||
case EVSTATUS: cmdstatus = stol(value);
|
case EVSTATUS:
|
||||||
|
cmdstatus = stol(value);
|
||||||
break;
|
break;
|
||||||
case EVPALETTE: strncpy(palstr, value, 48);
|
case EVPALETTE:
|
||||||
|
strncpy(palstr, value, 48);
|
||||||
spal(palstr);
|
spal(palstr);
|
||||||
break;
|
break;
|
||||||
case EVASAVE: gasave = atoi(value);
|
case EVASAVE:
|
||||||
|
gasave = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVACOUNT: gacount = atoi(value);
|
case EVACOUNT:
|
||||||
|
gacount = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVLASTKEY: lastkey = atoi(value);
|
case EVLASTKEY:
|
||||||
|
lastkey = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVCURCHAR: ldelete(1L, FALSE); /* delete 1 char */
|
case EVCURCHAR:
|
||||||
|
ldelete(1L, FALSE); /* delete 1 char */
|
||||||
c = atoi(value);
|
c = atoi(value);
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
lnewline(FALSE, 1);
|
lnewline(FALSE, 1);
|
||||||
@ -488,65 +578,86 @@ char *value; /* value to set to */
|
|||||||
linsert(1, c);
|
linsert(1, c);
|
||||||
backchar(FALSE, 1);
|
backchar(FALSE, 1);
|
||||||
break;
|
break;
|
||||||
case EVDISCMD: discmd = stol(value);
|
case EVDISCMD:
|
||||||
|
discmd = stol(value);
|
||||||
break;
|
break;
|
||||||
case EVVERSION: break;
|
case EVVERSION:
|
||||||
case EVPROGNAME:break;
|
|
||||||
case EVSEED: seed = atoi(value);
|
|
||||||
break;
|
break;
|
||||||
case EVDISINP: disinp = stol(value);
|
case EVPROGNAME:
|
||||||
break;
|
break;
|
||||||
case EVWLINE: status = resize(TRUE, atoi(value));
|
case EVSEED:
|
||||||
|
seed = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVCWLINE: status = forwline(TRUE,
|
case EVDISINP:
|
||||||
atoi(value) - getwpos());
|
disinp = stol(value);
|
||||||
break;
|
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;
|
thisflag = saveflag;
|
||||||
break;
|
break;
|
||||||
case EVSEARCH: strcpy(pat, value);
|
case EVSEARCH:
|
||||||
|
strcpy(pat, value);
|
||||||
rvstrcpy(tap, pat);
|
rvstrcpy(tap, pat);
|
||||||
#if MAGIC
|
#if MAGIC
|
||||||
mcclear();
|
mcclear();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case EVREPLACE: strcpy(rpat, value);
|
case EVREPLACE:
|
||||||
|
strcpy(rpat, value);
|
||||||
break;
|
break;
|
||||||
case EVMATCH: break;
|
case EVMATCH:
|
||||||
case EVKILL: break;
|
break;
|
||||||
case EVCMODE: curbp->b_mode = atoi(value);
|
case EVKILL:
|
||||||
|
break;
|
||||||
|
case EVCMODE:
|
||||||
|
curbp->b_mode = atoi(value);
|
||||||
curwp->w_flag |= WFMODE;
|
curwp->w_flag |= WFMODE;
|
||||||
break;
|
break;
|
||||||
case EVGMODE: gmode = atoi(value);
|
case EVGMODE:
|
||||||
|
gmode = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVTPAUSE: term.t_pause = atoi(value);
|
case EVTPAUSE:
|
||||||
|
term.t_pause = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVPENDING: break;
|
case EVPENDING:
|
||||||
case EVLWIDTH: break;
|
|
||||||
case EVLINE: putctext(value);
|
|
||||||
case EVGFLAGS: gflags = atoi(value);
|
|
||||||
break;
|
break;
|
||||||
case EVRVAL: break;
|
case EVLWIDTH:
|
||||||
case EVTAB: tabmask = atoi(value)-1;
|
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)
|
if (tabmask != 0x07 && tabmask != 0x03)
|
||||||
tabmask = 0x07;
|
tabmask = 0x07;
|
||||||
curwp->w_flag |= WFHARD;
|
curwp->w_flag |= WFHARD;
|
||||||
break;
|
break;
|
||||||
case EVOVERLAP: overlap = atoi(value);
|
case EVOVERLAP:
|
||||||
|
overlap = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVSCROLLCOUNT:
|
case EVSCROLLCOUNT:
|
||||||
scrollcount = atoi(value);
|
scrollcount = atoi(value);
|
||||||
break;
|
break;
|
||||||
case EVSCROLL:
|
case EVSCROLL:
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
if (! stol(value))
|
if (!stol(value))
|
||||||
term.t_scroll = NULL;
|
term.t_scroll = NULL;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* atoi: ascii string to integer......This is too
|
/* atoi: ascii string to integer......This is too
|
||||||
@ -581,9 +692,9 @@ char *st;
|
|||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
result = result * 10 + c - '0';
|
result = result * 10 + c - '0';
|
||||||
else
|
else
|
||||||
return(0);
|
return (0);
|
||||||
|
|
||||||
return(result * sign);
|
return (result * sign);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* itoa: integer to ascii string.......... This is too
|
/* 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 int digit; /* current digit being used */
|
||||||
register char *sp; /* pointer into result */
|
register char *sp; /* pointer into result */
|
||||||
register int sign; /* sign of resulting number */
|
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;
|
sign = 1;
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
sign = -1;
|
sign = -1;
|
||||||
@ -620,11 +731,11 @@ int i; /* integer to translate to a string */
|
|||||||
*(--sp) = '-'; /* and install the minus sign */
|
*(--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 */
|
char *token; /* token to analyze */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -635,29 +746,38 @@ char *token; /* token to analyze */
|
|||||||
|
|
||||||
/* no blanks!!! */
|
/* no blanks!!! */
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
return(TKNUL);
|
return (TKNUL);
|
||||||
|
|
||||||
/* a numeric literal? */
|
/* a numeric literal? */
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
return(TKLIT);
|
return (TKLIT);
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '"': return(TKSTR);
|
case '"':
|
||||||
|
return (TKSTR);
|
||||||
|
|
||||||
case '!': return(TKDIR);
|
case '!':
|
||||||
case '@': return(TKARG);
|
return (TKDIR);
|
||||||
case '#': return(TKBUF);
|
case '@':
|
||||||
case '$': return(TKENV);
|
return (TKARG);
|
||||||
case '%': return(TKVAR);
|
case '#':
|
||||||
case '&': return(TKFUN);
|
return (TKBUF);
|
||||||
case '*': return(TKLBL);
|
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 */
|
char *token; /* token to evaluate */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -665,21 +785,21 @@ char *token; /* token to evaluate */
|
|||||||
register BUFFER *bp; /* temp buffer pointer */
|
register BUFFER *bp; /* temp buffer pointer */
|
||||||
register int blen; /* length of buffer argument */
|
register int blen; /* length of buffer argument */
|
||||||
register int distmp; /* temporary discmd flag */
|
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)) {
|
switch (gettyp(token)) {
|
||||||
case TKNUL: return("");
|
case TKNUL:
|
||||||
|
return ("");
|
||||||
|
|
||||||
case TKARG: /* interactive argument */
|
case TKARG: /* interactive argument */
|
||||||
strcpy(token, getval(&token[1]));
|
strcpy(token, getval(&token[1]));
|
||||||
distmp = discmd; /* echo it always! */
|
distmp = discmd; /* echo it always! */
|
||||||
discmd = TRUE;
|
discmd = TRUE;
|
||||||
status = getstring(token,
|
status = getstring(token, buf, NSTRING, ctoec('\n'));
|
||||||
buf, NSTRING, ctoec('\n'));
|
|
||||||
discmd = distmp;
|
discmd = distmp;
|
||||||
if (status == ABORT)
|
if (status == ABORT)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
return(buf);
|
return (buf);
|
||||||
|
|
||||||
case TKBUF: /* buffer contents fetch */
|
case TKBUF: /* buffer contents fetch */
|
||||||
|
|
||||||
@ -687,7 +807,7 @@ char *token; /* token to evaluate */
|
|||||||
strcpy(token, getval(&token[1]));
|
strcpy(token, getval(&token[1]));
|
||||||
bp = bfind(token, FALSE, 0);
|
bp = bfind(token, FALSE, 0);
|
||||||
if (bp == NULL)
|
if (bp == NULL)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
|
|
||||||
/* if the buffer is displayed, get the window
|
/* if the buffer is displayed, get the window
|
||||||
vars instead of the buffer vars */
|
vars instead of the buffer vars */
|
||||||
@ -698,21 +818,20 @@ char *token; /* token to evaluate */
|
|||||||
|
|
||||||
/* make sure we are not at the end */
|
/* make sure we are not at the end */
|
||||||
if (bp->b_linep == bp->b_dotp)
|
if (bp->b_linep == bp->b_dotp)
|
||||||
return(errorm);
|
return (errorm);
|
||||||
|
|
||||||
/* grab the line as an argument */
|
/* grab the line as an argument */
|
||||||
blen = bp->b_dotp->l_used - bp->b_doto;
|
blen = bp->b_dotp->l_used - bp->b_doto;
|
||||||
if (blen > NSTRING)
|
if (blen > NSTRING)
|
||||||
blen = NSTRING;
|
blen = NSTRING;
|
||||||
strncpy(buf, bp->b_dotp->l_text + bp->b_doto,
|
strncpy(buf, bp->b_dotp->l_text + bp->b_doto, blen);
|
||||||
blen);
|
|
||||||
buf[blen] = 0;
|
buf[blen] = 0;
|
||||||
|
|
||||||
/* and step the buffer's line ptr ahead a line */
|
/* and step the buffer's line ptr ahead a line */
|
||||||
bp->b_dotp = bp->b_dotp->l_fp;
|
bp->b_dotp = bp->b_dotp->l_fp;
|
||||||
bp->b_doto = 0;
|
bp->b_doto = 0;
|
||||||
|
|
||||||
/* if displayed buffer, reset window ptr vars*/
|
/* if displayed buffer, reset window ptr vars */
|
||||||
if (bp->b_nwnd > 0) {
|
if (bp->b_nwnd > 0) {
|
||||||
curwp->w_dotp = curbp->b_dotp;
|
curwp->w_dotp = curbp->b_dotp;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
@ -720,47 +839,55 @@ char *token; /* token to evaluate */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* and return the spoils */
|
/* and return the spoils */
|
||||||
return(buf);
|
return (buf);
|
||||||
|
|
||||||
case TKVAR: return(gtusr(token+1));
|
case TKVAR:
|
||||||
case TKENV: return(gtenv(token+1));
|
return (gtusr(token + 1));
|
||||||
case TKFUN: return(gtfun(token+1));
|
case TKENV:
|
||||||
case TKDIR: return(errorm);
|
return (gtenv(token + 1));
|
||||||
case TKLBL: return(errorm);
|
case TKFUN:
|
||||||
case TKLIT: return(token);
|
return (gtfun(token + 1));
|
||||||
case TKSTR: return(token+1);
|
case TKDIR:
|
||||||
case TKCMD: return(token);
|
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 */
|
char *val; /* value to check for stol */
|
||||||
|
|
||||||
{
|
{
|
||||||
/* check for logical values */
|
/* check for logical values */
|
||||||
if (val[0] == 'F')
|
if (val[0] == 'F')
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
if (val[0] == 'T')
|
if (val[0] == 'T')
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* check for numeric truth (!= 0) */
|
/* 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 */
|
int val; /* value to translate */
|
||||||
|
|
||||||
{
|
{
|
||||||
if (val)
|
if (val)
|
||||||
return(truem);
|
return (truem);
|
||||||
else
|
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 */
|
char *str; /* string to upper case */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -772,11 +899,11 @@ char *str; /* string to upper case */
|
|||||||
*sp += 'A' - 'a';
|
*sp += 'A' - 'a';
|
||||||
++sp;
|
++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 */
|
char *str; /* string to lower case */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -788,26 +915,25 @@ char *str; /* string to lower case */
|
|||||||
*sp += 'a' - 'A';
|
*sp += 'a' - 'A';
|
||||||
++sp;
|
++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;
|
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);
|
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 *source; /* source string to search */
|
||||||
char *pattern; /* string to look for */
|
char *pattern; /* string to look for */
|
||||||
|
|
||||||
@ -831,12 +957,12 @@ char *pattern; /* string to look for */
|
|||||||
|
|
||||||
/* was it a match? */
|
/* was it a match? */
|
||||||
if (*cp == 0)
|
if (*cp == 0)
|
||||||
return((int)(sp - source) + 1);
|
return ((int) (sp - source) + 1);
|
||||||
++sp;
|
++sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no match at all.. */
|
/* no match at all.. */
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Filter a string through a translation table */
|
/* Filter a string through a translation table */
|
||||||
@ -870,10 +996,10 @@ char *trans; /* resulting translated characters */
|
|||||||
/* no match, copy in the source char untranslated */
|
/* no match, copy in the source char untranslated */
|
||||||
*rp++ = *sp;
|
*rp++ = *sp;
|
||||||
|
|
||||||
xnext: ++sp;
|
xnext:++sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* terminate and return the result */
|
/* terminate and return the result */
|
||||||
*rp = 0;
|
*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] */
|
int f, n; /* command arguments [passed through to command executed] */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int (*kfunc)(); /* ptr to the requexted function to bind to */
|
register int (*kfunc) (); /* ptr to the requexted function to bind to */
|
||||||
int (*getname())();
|
int (*getname()) ();
|
||||||
|
|
||||||
/* prompt the user to type a named command */
|
/* prompt the user to type a named command */
|
||||||
mlwrite(": ");
|
mlwrite(": ");
|
||||||
@ -28,11 +28,11 @@ int f, n; /* command arguments [passed through to command executed] */
|
|||||||
kfunc = getname();
|
kfunc = getname();
|
||||||
if (kfunc == NULL) {
|
if (kfunc == NULL) {
|
||||||
mlwrite("(No such function)");
|
mlwrite("(No such function)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and then execute the command */
|
/* and then execute the command */
|
||||||
return((*kfunc)(f, n));
|
return ((*kfunc) (f, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execcmd: Execute a command line command to be typed in
|
/* 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 */
|
/* get the line wanted */
|
||||||
if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE)
|
if ((status = mlreply(": ", cmdstr, NSTRING)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
execlevel = 0;
|
execlevel = 0;
|
||||||
return(docmd(cmdstr));
|
return (docmd(cmdstr));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* docmd: take a passed string as a command line and translate
|
/* 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 f; /* default argument flag */
|
||||||
register int n; /* numeric repeat value */
|
register int n; /* numeric repeat value */
|
||||||
int (*fnc)(); /* function to execute */
|
int (*fnc) (); /* function to execute */
|
||||||
int status; /* return status of function */
|
int status; /* return status of function */
|
||||||
int oldcle; /* old contents of clexec flag */
|
int oldcle; /* old contents of clexec flag */
|
||||||
char *oldestr; /* original exec string */
|
char *oldestr; /* original exec string */
|
||||||
char tkn[NSTRING]; /* next token off of command line */
|
char tkn[NSTRING]; /* next token off of command line */
|
||||||
int (*fncmatch())();
|
int (*fncmatch()) ();
|
||||||
|
|
||||||
/* if we are scanning and not executing..go back here */
|
/* if we are scanning and not executing..go back here */
|
||||||
if (execlevel)
|
if (execlevel)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
oldestr = execstr; /* save last ptr to string to execute */
|
oldestr = execstr; /* save last ptr to string to execute */
|
||||||
execstr = cline; /* and set this one as current */
|
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 */
|
if ((status = macarg(tkn)) != TRUE) { /* and grab the first token */
|
||||||
execstr = oldestr;
|
execstr = oldestr;
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process leadin argument */
|
/* process leadin argument */
|
||||||
@ -106,7 +106,7 @@ char *cline; /* command line to execute */
|
|||||||
/* and now get the command to execute */
|
/* and now get the command to execute */
|
||||||
if ((status = macarg(tkn)) != TRUE) {
|
if ((status = macarg(tkn)) != TRUE) {
|
||||||
execstr = oldestr;
|
execstr = oldestr;
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,17 +114,17 @@ char *cline; /* command line to execute */
|
|||||||
if ((fnc = fncmatch(tkn)) == NULL) {
|
if ((fnc = fncmatch(tkn)) == NULL) {
|
||||||
mlwrite("(No such Function)");
|
mlwrite("(No such Function)");
|
||||||
execstr = oldestr;
|
execstr = oldestr;
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the arguments and go execute the command */
|
/* save the arguments and go execute the command */
|
||||||
oldcle = clexec; /* save old clexec flag */
|
oldcle = clexec; /* save old clexec flag */
|
||||||
clexec = TRUE; /* in cline execution */
|
clexec = TRUE; /* in cline execution */
|
||||||
status = (*fnc)(f, n); /* call the function */
|
status = (*fnc) (f, n); /* call the function */
|
||||||
cmdstatus = status; /* save the status */
|
cmdstatus = status; /* save the status */
|
||||||
clexec = oldcle; /* restore clexec flag */
|
clexec = oldcle; /* restore clexec flag */
|
||||||
execstr = oldestr;
|
execstr = oldestr;
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* token: chop a token off a string
|
/* token: chop a token off a string
|
||||||
@ -153,12 +153,23 @@ int size; /* maximum size of token */
|
|||||||
if (*src == 0)
|
if (*src == 0)
|
||||||
break;
|
break;
|
||||||
switch (*src++) {
|
switch (*src++) {
|
||||||
case 'r': c = 13; break;
|
case 'r':
|
||||||
case 'n': c = 10; break;
|
c = 13;
|
||||||
case 't': c = 9; break;
|
break;
|
||||||
case 'b': c = 8; break;
|
case 'n':
|
||||||
case 'f': c = 12; break;
|
c = 10;
|
||||||
default: c = *(src-1);
|
break;
|
||||||
|
case 't':
|
||||||
|
c = 9;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
c = 8;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
c = 12;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
c = *(src - 1);
|
||||||
}
|
}
|
||||||
if (--size > 0) {
|
if (--size > 0) {
|
||||||
*tok++ = c;
|
*tok++ = c;
|
||||||
@ -188,11 +199,11 @@ int size; /* maximum size of token */
|
|||||||
if (*src)
|
if (*src)
|
||||||
++src;
|
++src;
|
||||||
*tok = 0;
|
*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 */
|
char *tok; /* buffer to place argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -203,7 +214,7 @@ char *tok; /* buffer to place argument */
|
|||||||
clexec = TRUE; /* get the argument */
|
clexec = TRUE; /* get the argument */
|
||||||
status = nextarg("", tok, NSTRING, ctoec('\n'));
|
status = nextarg("", tok, NSTRING, ctoec('\n'));
|
||||||
clexec = savcle; /* restore execution mode */
|
clexec = savcle; /* restore execution mode */
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* nextarg: get the next argument */
|
/* 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 we are interactive, go get it! */
|
||||||
if (clexec == FALSE)
|
if (clexec == FALSE)
|
||||||
return(getstring(prompt, buffer, size, terminator));
|
return (getstring(prompt, buffer, size, terminator));
|
||||||
|
|
||||||
/* grab token and advance past */
|
/* grab token and advance past */
|
||||||
execstr = token(execstr, buffer, size);
|
execstr = token(execstr, buffer, size);
|
||||||
|
|
||||||
/* evaluate it */
|
/* evaluate it */
|
||||||
strcpy(buffer, getval(buffer));
|
strcpy(buffer, getval(buffer));
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* storemac: Set up a macro buffer and flag to store all
|
/* 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 */
|
/* must have a numeric argument to this function */
|
||||||
if (f == FALSE) {
|
if (f == FALSE) {
|
||||||
mlwrite("No macro specified");
|
mlwrite("No macro specified");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* range check the macro number */
|
/* range check the macro number */
|
||||||
if (n < 1 || n > 40) {
|
if (n < 1 || n > 40) {
|
||||||
mlwrite("Macro number out of range");
|
mlwrite("Macro number out of range");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* construct the macro buffer name */
|
/* construct the macro buffer name */
|
||||||
@ -260,7 +271,7 @@ int n; /* macro number to use */
|
|||||||
/* set up the new macro buffer */
|
/* set up the new macro buffer */
|
||||||
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
||||||
mlwrite("Can not create macro");
|
mlwrite("Can not create macro");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and make sure it is empty */
|
/* and make sure it is empty */
|
||||||
@ -269,7 +280,7 @@ int n; /* macro number to use */
|
|||||||
/* and set the macro store pointers to it */
|
/* and set the macro store pointers to it */
|
||||||
mstore = TRUE;
|
mstore = TRUE;
|
||||||
bstore = bp;
|
bstore = bp;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PROC
|
#if PROC
|
||||||
@ -288,11 +299,12 @@ int n; /* macro number to use */
|
|||||||
|
|
||||||
/* a numeric argument means its a numbered macro */
|
/* a numeric argument means its a numbered macro */
|
||||||
if (f == TRUE)
|
if (f == TRUE)
|
||||||
return(storemac(f, n));
|
return (storemac(f, n));
|
||||||
|
|
||||||
/* get the name of the procedure */
|
/* get the name of the procedure */
|
||||||
if ((status = mlreply("Procedure name: ", &bname[1], NBUFN-2)) != TRUE)
|
if ((status =
|
||||||
return(status);
|
mlreply("Procedure name: ", &bname[1], NBUFN - 2)) != TRUE)
|
||||||
|
return (status);
|
||||||
|
|
||||||
/* construct the macro buffer name */
|
/* construct the macro buffer name */
|
||||||
bname[0] = '*';
|
bname[0] = '*';
|
||||||
@ -301,7 +313,7 @@ int n; /* macro number to use */
|
|||||||
/* set up the new macro buffer */
|
/* set up the new macro buffer */
|
||||||
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
if ((bp = bfind(bname, TRUE, BFINVS)) == NULL) {
|
||||||
mlwrite("Can not create macro");
|
mlwrite("Can not create macro");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and make sure it is empty */
|
/* and make sure it is empty */
|
||||||
@ -310,7 +322,7 @@ int n; /* macro number to use */
|
|||||||
/* and set the macro store pointers to it */
|
/* and set the macro store pointers to it */
|
||||||
mstore = TRUE;
|
mstore = TRUE;
|
||||||
bstore = bp;
|
bstore = bp;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* execproc: Execute a procedure */
|
/* 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 BUFFER *bp; /* ptr to buffer to execute */
|
||||||
register int status; /* status return */
|
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 */
|
/* find out what buffer the user wants to execute */
|
||||||
if ((status = mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
|
if ((status =
|
||||||
return(status);
|
mlreply("Execute procedure: ", &bufn[1], NBUFN)) != TRUE)
|
||||||
|
return (status);
|
||||||
|
|
||||||
/* construct the buffer name */
|
/* construct the buffer name */
|
||||||
bufn[0] = '*';
|
bufn[0] = '*';
|
||||||
strcat(bufn, "*");
|
strcat(bufn, "*");
|
||||||
|
|
||||||
/* find the pointer to that buffer */
|
/* find the pointer to that buffer */
|
||||||
if ((bp=bfind(bufn, FALSE, 0)) == NULL) {
|
if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
|
||||||
mlwrite("No such procedure");
|
mlwrite("No such procedure");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and now execute it as asked */
|
/* and now execute it as asked */
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
if ((status = dobuf(bp)) != TRUE)
|
if ((status = dobuf(bp)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -359,19 +372,19 @@ int f, n; /* default flag and numeric arg */
|
|||||||
|
|
||||||
/* find out what buffer the user wants to execute */
|
/* find out what buffer the user wants to execute */
|
||||||
if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE)
|
if ((status = mlreply("Execute buffer: ", bufn, NBUFN)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
/* find the pointer to that buffer */
|
/* find the pointer to that buffer */
|
||||||
if ((bp=bfind(bufn, FALSE, 0)) == NULL) {
|
if ((bp = bfind(bufn, FALSE, 0)) == NULL) {
|
||||||
mlwrite("No such buffer");
|
mlwrite("No such buffer");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and now execute it as asked */
|
/* and now execute it as asked */
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
if ((status = dobuf(bp)) != TRUE)
|
if ((status = dobuf(bp)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dobuf: execute the contents of the buffer pointed to
|
/* 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 is a while directive, make a block... */
|
||||||
if (eline[0] == '!' && eline[1] == 'w' && eline[2] == 'h') {
|
if (eline[0] == '!' && eline[1] == 'w' && eline[2] == 'h') {
|
||||||
whtemp = (WHBLOCK *)malloc(sizeof(WHBLOCK));
|
whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK));
|
||||||
if (whtemp == NULL) {
|
if (whtemp == NULL) {
|
||||||
noram: mlwrite("%%Out of memory during while scan");
|
noram:mlwrite
|
||||||
failexit: freewhile(scanner);
|
("%%Out of memory during while scan");
|
||||||
|
failexit:freewhile
|
||||||
|
(scanner);
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
whtemp->w_begin = lp;
|
whtemp->w_begin = lp;
|
||||||
whtemp->w_type = BTWHILE;
|
whtemp->w_type = BTWHILE;
|
||||||
@ -461,10 +476,11 @@ failexit: freewhile(scanner);
|
|||||||
/* if is a BREAK directive, make a block... */
|
/* if is a BREAK directive, make a block... */
|
||||||
if (eline[0] == '!' && eline[1] == 'b' && eline[2] == 'r') {
|
if (eline[0] == '!' && eline[1] == 'b' && eline[2] == 'r') {
|
||||||
if (scanner == NULL) {
|
if (scanner == NULL) {
|
||||||
mlwrite("%%!BREAK outside of any !WHILE loop");
|
mlwrite
|
||||||
|
("%%!BREAK outside of any !WHILE loop");
|
||||||
goto failexit;
|
goto failexit;
|
||||||
}
|
}
|
||||||
whtemp = (WHBLOCK *)malloc(sizeof(WHBLOCK));
|
whtemp = (WHBLOCK *) malloc(sizeof(WHBLOCK));
|
||||||
if (whtemp == NULL)
|
if (whtemp == NULL)
|
||||||
goto noram;
|
goto noram;
|
||||||
whtemp->w_begin = lp;
|
whtemp->w_begin = lp;
|
||||||
@ -476,7 +492,8 @@ failexit: freewhile(scanner);
|
|||||||
/* if it is an endwhile directive, record the spot... */
|
/* if it is an endwhile directive, record the spot... */
|
||||||
if (eline[0] == '!' && strncmp(&eline[1], "endw", 4) == 0) {
|
if (eline[0] == '!' && strncmp(&eline[1], "endw", 4) == 0) {
|
||||||
if (scanner == NULL) {
|
if (scanner == NULL) {
|
||||||
mlwrite("%%!ENDWHILE with no preceding !WHILE in '%s'",
|
mlwrite
|
||||||
|
("%%!ENDWHILE with no preceding !WHILE in '%s'",
|
||||||
bp->b_bname);
|
bp->b_bname);
|
||||||
goto failexit;
|
goto failexit;
|
||||||
}
|
}
|
||||||
@ -492,7 +509,7 @@ failexit: freewhile(scanner);
|
|||||||
} while (whlist->w_type == BTBREAK);
|
} while (whlist->w_type == BTBREAK);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtscan: /* on to the next line */
|
nxtscan: /* on to the next line */
|
||||||
lp = lp->l_fp;
|
lp = lp->l_fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,7 +520,7 @@ nxtscan: /* on to the next line */
|
|||||||
goto failexit;
|
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;
|
thisflag = lastflag;
|
||||||
|
|
||||||
/* starting at the beginning of the buffer */
|
/* starting at the beginning of the buffer */
|
||||||
@ -512,10 +529,10 @@ nxtscan: /* on to the next line */
|
|||||||
while (lp != hlp) {
|
while (lp != hlp) {
|
||||||
/* allocate eline and copy macro line to it */
|
/* allocate eline and copy macro line to it */
|
||||||
linlen = lp->l_used;
|
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");
|
mlwrite("%%Out of Memory during macro execution");
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
strncpy(eline, lp->l_text, linlen);
|
strncpy(eline, lp->l_text, linlen);
|
||||||
eline[linlen] = 0; /* make sure it ends */
|
eline[linlen] = 0; /* make sure it ends */
|
||||||
@ -554,12 +571,11 @@ nxtscan: /* on to the next line */
|
|||||||
if (*sp++ == '%') {
|
if (*sp++ == '%') {
|
||||||
/* advance to the end */
|
/* advance to the end */
|
||||||
ep = --sp;
|
ep = --sp;
|
||||||
while (*ep++)
|
while (*ep++);
|
||||||
;
|
|
||||||
/* null terminate the string one out */
|
/* null terminate the string one out */
|
||||||
*(ep + 1) = 0;
|
*(ep + 1) = 0;
|
||||||
/* copy backwards */
|
/* copy backwards */
|
||||||
while(ep-- > sp)
|
while (ep-- > sp)
|
||||||
*(ep + 1) = *ep;
|
*(ep + 1) = *ep;
|
||||||
|
|
||||||
/* and advance sp past the new % */
|
/* and advance sp past the new % */
|
||||||
@ -574,7 +590,7 @@ nxtscan: /* on to the next line */
|
|||||||
if ((c = get1key()) == abortc) {
|
if ((c = get1key()) == abortc) {
|
||||||
mlforce("(Macro aborted)");
|
mlforce("(Macro aborted)");
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == metac)
|
if (c == metac)
|
||||||
@ -596,7 +612,7 @@ nxtscan: /* on to the next line */
|
|||||||
if (dirnum == NUMDIRS) {
|
if (dirnum == NUMDIRS) {
|
||||||
mlwrite("%%Unknown Directive");
|
mlwrite("%%Unknown Directive");
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* service only the !ENDM macro here */
|
/* service only the !ENDM macro here */
|
||||||
@ -606,7 +622,7 @@ nxtscan: /* on to the next line */
|
|||||||
goto onward;
|
goto onward;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore the original eline....*/
|
/* restore the original eline.... */
|
||||||
--eline;
|
--eline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,13 +630,14 @@ nxtscan: /* on to the next line */
|
|||||||
if (mstore) {
|
if (mstore) {
|
||||||
/* allocate the space for the line */
|
/* allocate the space for the line */
|
||||||
linlen = strlen(eline);
|
linlen = strlen(eline);
|
||||||
if ((mp=lalloc(linlen)) == NULL) {
|
if ((mp = lalloc(linlen)) == NULL) {
|
||||||
mlwrite("Out of memory while storing macro");
|
mlwrite
|
||||||
|
("Out of memory while storing macro");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy the text into the new line */
|
/* copy the text into the new line */
|
||||||
for (i=0; i<linlen; ++i)
|
for (i = 0; i < linlen; ++i)
|
||||||
lputc(mp, i, eline[i]);
|
lputc(mp, i, eline[i]);
|
||||||
|
|
||||||
/* attach the line to the end of the buffer */
|
/* attach the line to the end of the buffer */
|
||||||
@ -681,9 +698,10 @@ nxtscan: /* on to the next line */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (whtemp == NULL) {
|
if (whtemp == NULL) {
|
||||||
mlwrite("%%Internal While loop error");
|
mlwrite
|
||||||
|
("%%Internal While loop error");
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the line pointer back.. */
|
/* reset the line pointer back.. */
|
||||||
@ -693,7 +711,7 @@ nxtscan: /* on to the next line */
|
|||||||
case DELSE: /* ELSE directive */
|
case DELSE: /* ELSE directive */
|
||||||
if (execlevel == 1)
|
if (execlevel == 1)
|
||||||
--execlevel;
|
--execlevel;
|
||||||
else if (execlevel == 0 )
|
else if (execlevel == 0)
|
||||||
++execlevel;
|
++execlevel;
|
||||||
goto onward;
|
goto onward;
|
||||||
|
|
||||||
@ -707,12 +725,15 @@ nxtscan: /* on to the next line */
|
|||||||
if (execlevel == 0) {
|
if (execlevel == 0) {
|
||||||
|
|
||||||
/* grab label to jump to */
|
/* grab label to jump to */
|
||||||
eline = token(eline, golabel, NPAT);
|
eline =
|
||||||
|
token(eline, golabel, NPAT);
|
||||||
linlen = strlen(golabel);
|
linlen = strlen(golabel);
|
||||||
glp = hlp->l_fp;
|
glp = hlp->l_fp;
|
||||||
while (glp != hlp) {
|
while (glp != hlp) {
|
||||||
if (*glp->l_text == '*' &&
|
if (*glp->l_text == '*' &&
|
||||||
(strncmp(&glp->l_text[1], golabel,
|
(strncmp
|
||||||
|
(&glp->l_text[1],
|
||||||
|
golabel,
|
||||||
linlen) == 0)) {
|
linlen) == 0)) {
|
||||||
lp = glp;
|
lp = glp;
|
||||||
goto onward;
|
goto onward;
|
||||||
@ -721,7 +742,7 @@ nxtscan: /* on to the next line */
|
|||||||
}
|
}
|
||||||
mlwrite("%%No such label");
|
mlwrite("%%No such label");
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
goto onward;
|
goto onward;
|
||||||
|
|
||||||
@ -738,16 +759,18 @@ nxtscan: /* on to the next line */
|
|||||||
/* find the right while loop */
|
/* find the right while loop */
|
||||||
whtemp = whlist;
|
whtemp = whlist;
|
||||||
while (whtemp) {
|
while (whtemp) {
|
||||||
if (whtemp->w_type == BTWHILE &&
|
if (whtemp->w_type ==
|
||||||
whtemp->w_end == lp)
|
BTWHILE
|
||||||
|
&& whtemp->w_end == lp)
|
||||||
break;
|
break;
|
||||||
whtemp = whtemp->w_next;
|
whtemp = whtemp->w_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whtemp == NULL) {
|
if (whtemp == NULL) {
|
||||||
mlwrite("%%Internal While loop error");
|
mlwrite
|
||||||
|
("%%Internal While loop error");
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the line pointer back.. */
|
/* reset the line pointer back.. */
|
||||||
@ -785,22 +808,22 @@ nxtscan: /* on to the next line */
|
|||||||
free(einit);
|
free(einit);
|
||||||
execlevel = 0;
|
execlevel = 0;
|
||||||
freewhile(whlist);
|
freewhile(whlist);
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
onward: /* on to the next line */
|
onward: /* on to the next line */
|
||||||
free(einit);
|
free(einit);
|
||||||
lp = lp->l_fp;
|
lp = lp->l_fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
eexec: /* exit the current function */
|
eexec: /* exit the current function */
|
||||||
execlevel = 0;
|
execlevel = 0;
|
||||||
freewhile(whlist);
|
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 */
|
WHBLOCK *wp; /* head of structure to free */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -811,8 +834,8 @@ WHBLOCK *wp; /* head of structure to free */
|
|||||||
free(wp);
|
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 */
|
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 fname[NSTRING]; /* name of file to execute */
|
||||||
char *fspec; /* full file spec */
|
char *fspec; /* full file spec */
|
||||||
|
|
||||||
if ((status = mlreply("File to execute: ", fname, NSTRING -1)) != TRUE)
|
if ((status =
|
||||||
return(status);
|
mlreply("File to execute: ", fname, NSTRING - 1)) != TRUE)
|
||||||
|
return (status);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
/* look up the path for the file */
|
/* 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 it isn't around */
|
||||||
if (fspec == NULL)
|
if (fspec == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* otherwise, execute it */
|
/* otherwise, execute it */
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
if ((status=dofile(fspec)) != TRUE)
|
if ((status = dofile(fspec)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dofile: yank a file into a buffer and execute it
|
/* 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 */
|
makename(bname, fname); /* derive the name of the buffer */
|
||||||
unqname(bname); /* make sure we don't stomp things */
|
unqname(bname); /* make sure we don't stomp things */
|
||||||
if ((bp = bfind(bname, TRUE, 0)) == NULL) /* get the needed buffer */
|
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 */
|
bp->b_mode = MDVIEW; /* mark the buffer as read only */
|
||||||
cb = curbp; /* save the old buffer */
|
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 */
|
/* and try to read in the file to execute */
|
||||||
if ((status = readin(fname, FALSE)) != TRUE) {
|
if ((status = readin(fname, FALSE)) != TRUE) {
|
||||||
curbp = cb; /* restore the current buffer */
|
curbp = cb; /* restore the current buffer */
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* go execute it! */
|
/* go execute it! */
|
||||||
curbp = cb; /* restore the current buffer */
|
curbp = cb; /* restore the current buffer */
|
||||||
if ((status = dobuf(bp)) != TRUE)
|
if ((status = dobuf(bp)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
/* if not displayed, remove the now unneeded buffer and exit */
|
/* if not displayed, remove the now unneeded buffer and exit */
|
||||||
if (bp->b_nwnd == 0)
|
if (bp->b_nwnd == 0)
|
||||||
zotbuf(bp);
|
zotbuf(bp);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cbuf: Execute the contents of a numbered buffer */
|
/* cbuf: Execute the contents of a numbered buffer */
|
||||||
@ -895,254 +919,214 @@ int bufnum; /* number of buffer to execute */
|
|||||||
bufname[8] = '0' + (bufnum % 10);
|
bufname[8] = '0' + (bufnum % 10);
|
||||||
|
|
||||||
/* find the pointer to that buffer */
|
/* find the pointer to that buffer */
|
||||||
if ((bp=bfind(bufname, FALSE, 0)) == NULL) {
|
if ((bp = bfind(bufname, FALSE, 0)) == NULL) {
|
||||||
mlwrite("Macro not defined");
|
mlwrite("Macro not defined");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and now execute it as asked */
|
/* and now execute it as asked */
|
||||||
while (n-- > 0)
|
while (n-- > 0)
|
||||||
if ((status = dobuf(bp)) != TRUE)
|
if ((status = dobuf(bp)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf1(f, n)
|
cbuf1(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 1);
|
return cbuf(f, n, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf2(f, n)
|
cbuf2(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 2);
|
return cbuf(f, n, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf3(f, n)
|
cbuf3(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 3);
|
return cbuf(f, n, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf4(f, n)
|
cbuf4(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 4);
|
return cbuf(f, n, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf5(f, n)
|
cbuf5(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 5);
|
return cbuf(f, n, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf6(f, n)
|
cbuf6(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 6);
|
return cbuf(f, n, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf7(f, n)
|
cbuf7(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 7);
|
return cbuf(f, n, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf8(f, n)
|
cbuf8(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 8);
|
return cbuf(f, n, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf9(f, n)
|
cbuf9(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 9);
|
return cbuf(f, n, 9);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf10(f, n)
|
cbuf10(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 10);
|
return cbuf(f, n, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf11(f, n)
|
cbuf11(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 11);
|
return cbuf(f, n, 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf12(f, n)
|
cbuf12(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 12);
|
return cbuf(f, n, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf13(f, n)
|
cbuf13(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 13);
|
return cbuf(f, n, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf14(f, n)
|
cbuf14(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 14);
|
return cbuf(f, n, 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf15(f, n)
|
cbuf15(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 15);
|
return cbuf(f, n, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf16(f, n)
|
cbuf16(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 16);
|
return cbuf(f, n, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf17(f, n)
|
cbuf17(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 17);
|
return cbuf(f, n, 17);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf18(f, n)
|
cbuf18(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 18);
|
return cbuf(f, n, 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf19(f, n)
|
cbuf19(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 19);
|
return cbuf(f, n, 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf20(f, n)
|
cbuf20(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 20);
|
return cbuf(f, n, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf21(f, n)
|
cbuf21(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 21);
|
return cbuf(f, n, 21);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf22(f, n)
|
cbuf22(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 22);
|
return cbuf(f, n, 22);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf23(f, n)
|
cbuf23(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 23);
|
return cbuf(f, n, 23);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf24(f, n)
|
cbuf24(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 24);
|
return cbuf(f, n, 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf25(f, n)
|
cbuf25(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 25);
|
return cbuf(f, n, 25);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf26(f, n)
|
cbuf26(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 26);
|
return cbuf(f, n, 26);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf27(f, n)
|
cbuf27(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 27);
|
return cbuf(f, n, 27);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf28(f, n)
|
cbuf28(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 28);
|
return cbuf(f, n, 28);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf29(f, n)
|
cbuf29(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 29);
|
return cbuf(f, n, 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf30(f, n)
|
cbuf30(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 30);
|
return cbuf(f, n, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf31(f, n)
|
cbuf31(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 31);
|
return cbuf(f, n, 31);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf32(f, n)
|
cbuf32(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 32);
|
return cbuf(f, n, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf33(f, n)
|
cbuf33(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 33);
|
return cbuf(f, n, 33);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf34(f, n)
|
cbuf34(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 34);
|
return cbuf(f, n, 34);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf35(f, n)
|
cbuf35(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 35);
|
return cbuf(f, n, 35);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf36(f, n)
|
cbuf36(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 36);
|
return cbuf(f, n, 36);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf37(f, n)
|
cbuf37(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 37);
|
return cbuf(f, n, 37);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf38(f, n)
|
cbuf38(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 38);
|
return cbuf(f, n, 38);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf39(f, n)
|
cbuf39(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 39);
|
return cbuf(f, n, 39);
|
||||||
}
|
}
|
||||||
|
|
||||||
cbuf40(f, n)
|
cbuf40(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
return cbuf(f, n, 40);
|
return cbuf(f, n, 40);
|
||||||
}
|
}
|
||||||
|
164
file.c
164
file.c
@ -24,10 +24,10 @@ fileread(f, n)
|
|||||||
char fname[NFILEN];
|
char fname[NFILEN];
|
||||||
|
|
||||||
if (restflag) /* don't allow this command if restricted */
|
if (restflag) /* don't allow this command if restricted */
|
||||||
return(resterr());
|
return (resterr());
|
||||||
if ((s=mlreply("Read file: ", fname, NFILEN)) != TRUE)
|
if ((s = mlreply("Read file: ", fname, NFILEN)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
return(readin(fname, TRUE));
|
return (readin(fname, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -43,14 +43,14 @@ insfile(f, n)
|
|||||||
char fname[NFILEN];
|
char fname[NFILEN];
|
||||||
|
|
||||||
if (restflag) /* don't allow this command if restricted */
|
if (restflag) /* don't allow this command if restricted */
|
||||||
return(resterr());
|
return (resterr());
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if ((s=mlreply("Insert file: ", fname, NFILEN)) != TRUE)
|
if ((s = mlreply("Insert file: ", fname, NFILEN)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
if ((s=ifile(fname)) != TRUE)
|
if ((s = ifile(fname)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
return(reposition(TRUE, -1));
|
return (reposition(TRUE, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -68,21 +68,21 @@ filefind(f, n)
|
|||||||
register int s; /* status return */
|
register int s; /* status return */
|
||||||
|
|
||||||
if (restflag) /* don't allow this command if restricted */
|
if (restflag) /* don't allow this command if restricted */
|
||||||
return(resterr());
|
return (resterr());
|
||||||
if ((s=mlreply("Find file: ", fname, NFILEN)) != TRUE)
|
if ((s = mlreply("Find file: ", fname, NFILEN)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
return(getfile(fname, TRUE));
|
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 */
|
char fname[NFILEN]; /* file user wishes to find */
|
||||||
register int s; /* status return */
|
register int s; /* status return */
|
||||||
register WINDOW *wp; /* scan for windows that need updating */
|
register WINDOW *wp; /* scan for windows that need updating */
|
||||||
|
|
||||||
if (restflag) /* don't allow this command if restricted */
|
if (restflag) /* don't allow this command if restricted */
|
||||||
return(resterr());
|
return (resterr());
|
||||||
if ((s=mlreply("View file: ", fname, NFILEN)) != TRUE)
|
if ((s = mlreply("View file: ", fname, NFILEN)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
s = getfile(fname, FALSE);
|
s = getfile(fname, FALSE);
|
||||||
if (s) { /* if we succeed, put it in view mode */
|
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;
|
wp = wp->w_wndp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CRYPT
|
#if CRYPT
|
||||||
resetkey() /* reset the encryption key if needed */
|
resetkey()
|
||||||
|
{ /* reset the encryption key if needed */
|
||||||
{
|
|
||||||
register int s; /* return status */
|
register int s; /* return status */
|
||||||
|
|
||||||
/* turn off the encryption flag */
|
/* turn off the encryption flag */
|
||||||
@ -112,7 +111,7 @@ resetkey() /* reset the encryption key if needed */
|
|||||||
if (curbp->b_key[0] == 0) {
|
if (curbp->b_key[0] == 0) {
|
||||||
s = setkey(FALSE, 0);
|
s = setkey(FALSE, 0);
|
||||||
if (s != TRUE)
|
if (s != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let others know... */
|
/* let others know... */
|
||||||
@ -120,15 +119,15 @@ resetkey() /* reset the encryption key if needed */
|
|||||||
|
|
||||||
/* and set up the key to be used! */
|
/* and set up the key to be used! */
|
||||||
/* de-encrypt it */
|
/* de-encrypt it */
|
||||||
crypt((char *)NULL, 0);
|
crypt((char *) NULL, 0);
|
||||||
crypt(curbp->b_key, strlen(curbp->b_key));
|
crypt(curbp->b_key, strlen(curbp->b_key));
|
||||||
|
|
||||||
/* re-encrypt it...seeding it to start */
|
/* re-encrypt it...seeding it to start */
|
||||||
crypt((char *)NULL, 0);
|
crypt((char *) NULL, 0);
|
||||||
crypt(curbp->b_key, strlen(curbp->b_key));
|
crypt(curbp->b_key, strlen(curbp->b_key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -147,22 +146,23 @@ int lockfl; /* check the file for locks? */
|
|||||||
#if MSDOS
|
#if MSDOS
|
||||||
mklower(fname); /* msdos isn't case sensitive */
|
mklower(fname); /* msdos isn't case sensitive */
|
||||||
#endif
|
#endif
|
||||||
for (bp=bheadp; bp!=NULL; bp=bp->b_bufp) {
|
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
|
||||||
if ((bp->b_flag&BFINVS)==0 && strcmp(bp->b_fname, fname)==0) {
|
if ((bp->b_flag & BFINVS) == 0
|
||||||
|
&& strcmp(bp->b_fname, fname) == 0) {
|
||||||
swbuffer(bp);
|
swbuffer(bp);
|
||||||
lp = curwp->w_dotp;
|
lp = curwp->w_dotp;
|
||||||
i = curwp->w_ntrows/2;
|
i = curwp->w_ntrows / 2;
|
||||||
while (i-- && lback(lp)!=curbp->b_linep)
|
while (i-- && lback(lp) != curbp->b_linep)
|
||||||
lp = lback(lp);
|
lp = lback(lp);
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_flag |= WFMODE|WFHARD;
|
curwp->w_flag |= WFMODE | WFHARD;
|
||||||
cknewwindow();
|
cknewwindow();
|
||||||
mlwrite("(Old buffer)");
|
mlwrite("(Old buffer)");
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
makename(bname, fname); /* New buffer name. */
|
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 */
|
/* old buffer name conflict code */
|
||||||
s = mlreply("Buffer name: ", bname, NBUFN);
|
s = mlreply("Buffer name: ", bname, NBUFN);
|
||||||
if (s == ABORT) /* ^G to just quit */
|
if (s == ABORT) /* ^G to just quit */
|
||||||
@ -172,7 +172,7 @@ int lockfl; /* check the file for locks? */
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bp==NULL && (bp=bfind(bname, TRUE, 0))==NULL) {
|
if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) {
|
||||||
mlwrite("Cannot create buffer");
|
mlwrite("Cannot create buffer");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
@ -226,27 +226,27 @@ int lockfl; /* check for file locks? */
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if CRYPT
|
#if CRYPT
|
||||||
s = resetkey();
|
s = resetkey();
|
||||||
if (s != TRUE)
|
if (s != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
#endif
|
#endif
|
||||||
bp = curbp; /* Cheap. */
|
bp = curbp; /* Cheap. */
|
||||||
if ((s=bclear(bp)) != TRUE) /* Might be old. */
|
if ((s = bclear(bp)) != TRUE) /* Might be old. */
|
||||||
return (s);
|
return (s);
|
||||||
bp->b_flag &= ~(BFINVS|BFCHG);
|
bp->b_flag &= ~(BFINVS | BFCHG);
|
||||||
strcpy(bp->b_fname, fname);
|
strcpy(bp->b_fname, fname);
|
||||||
|
|
||||||
/* let a user macro get hold of things...if he wants */
|
/* 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 */
|
/* turn off ALL keyboard translation in case we get a dos error */
|
||||||
TTkclose();
|
TTkclose();
|
||||||
|
|
||||||
if ((s=ffropen(fname)) == FIOERR) /* Hard file open. */
|
if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (s == FIOFNF) { /* File not found. */
|
if (s == FIOFNF) { /* File not found. */
|
||||||
@ -258,9 +258,9 @@ int lockfl; /* check for file locks? */
|
|||||||
mlwrite("(Reading file)");
|
mlwrite("(Reading file)");
|
||||||
nline = 0;
|
nline = 0;
|
||||||
lflag = FALSE;
|
lflag = FALSE;
|
||||||
while ((s=ffgetline()) == FIOSUC) {
|
while ((s = ffgetline()) == FIOSUC) {
|
||||||
nbytes = strlen(fline);
|
nbytes = strlen(fline);
|
||||||
if ((lp1=lalloc(nbytes)) == NULL) {
|
if ((lp1 = lalloc(nbytes)) == NULL) {
|
||||||
s = FIOMEM; /* Keep message on the */
|
s = FIOMEM; /* Keep message on the */
|
||||||
break; /* display. */
|
break; /* display. */
|
||||||
}
|
}
|
||||||
@ -275,13 +275,13 @@ int lockfl; /* check for file locks? */
|
|||||||
lp1->l_fp = curbp->b_linep;
|
lp1->l_fp = curbp->b_linep;
|
||||||
lp1->l_bp = lp2;
|
lp1->l_bp = lp2;
|
||||||
curbp->b_linep->l_bp = lp1;
|
curbp->b_linep->l_bp = lp1;
|
||||||
for (i=0; i<nbytes; ++i)
|
for (i = 0; i < nbytes; ++i)
|
||||||
lputc(lp1, i, fline[i]);
|
lputc(lp1, i, fline[i]);
|
||||||
++nline;
|
++nline;
|
||||||
}
|
}
|
||||||
ffclose(); /* Ignore errors. */
|
ffclose(); /* Ignore errors. */
|
||||||
strcpy(mesg, "(");
|
strcpy(mesg, "(");
|
||||||
if (s==FIOERR) {
|
if (s == FIOERR) {
|
||||||
strcat(mesg, "I/O ERROR, ");
|
strcat(mesg, "I/O ERROR, ");
|
||||||
curbp->b_flag |= BFTRUNC;
|
curbp->b_flag |= BFTRUNC;
|
||||||
}
|
}
|
||||||
@ -295,23 +295,23 @@ int lockfl; /* check for file locks? */
|
|||||||
strcat(mesg, ")");
|
strcat(mesg, ")");
|
||||||
mlwrite(mesg);
|
mlwrite(mesg);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
TTkopen(); /* open the keyboard again */
|
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) {
|
if (wp->w_bufp == curbp) {
|
||||||
wp->w_linep = lforw(curbp->b_linep);
|
wp->w_linep = lforw(curbp->b_linep);
|
||||||
wp->w_dotp = lforw(curbp->b_linep);
|
wp->w_dotp = lforw(curbp->b_linep);
|
||||||
wp->w_doto = 0;
|
wp->w_doto = 0;
|
||||||
wp->w_markp = NULL;
|
wp->w_markp = NULL;
|
||||||
wp->w_marko = 0;
|
wp->w_marko = 0;
|
||||||
wp->w_flag |= WFMODE|WFHARD;
|
wp->w_flag |= WFMODE | WFHARD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s == FIOERR || s == FIOFNF) /* False if error. */
|
if (s == FIOERR || s == FIOFNF) /* False if error. */
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
#if 0
|
#if 0
|
||||||
if (s == ABORT)
|
if (s == ABORT)
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
#endif
|
#endif
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -336,28 +336,30 @@ char fname[];
|
|||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!=']' && cp1[-1]!='>')
|
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']'
|
||||||
|
&& cp1[-1] != '>')
|
||||||
#else
|
#else
|
||||||
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!=']')
|
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != ']')
|
||||||
#endif
|
#endif
|
||||||
--cp1;
|
--cp1;
|
||||||
#endif
|
#endif
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
while (cp1!=&fname[0] && cp1[-1]!=':' && cp1[-1]!='\\'&&cp1[-1]!='/')
|
while (cp1 != &fname[0] && cp1[-1] != ':' && cp1[-1] != '\\'
|
||||||
|
&& cp1[-1] != '/')
|
||||||
--cp1;
|
--cp1;
|
||||||
#endif
|
#endif
|
||||||
#if V7 | USG | BSD
|
#if V7 | USG | BSD
|
||||||
while (cp1!=&fname[0] && cp1[-1]!='/')
|
while (cp1 != &fname[0] && cp1[-1] != '/')
|
||||||
--cp1;
|
--cp1;
|
||||||
#endif
|
#endif
|
||||||
cp2 = &bname[0];
|
cp2 = &bname[0];
|
||||||
while (cp2!=&bname[NBUFN-1] && *cp1!=0 && *cp1!=';')
|
while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != ';')
|
||||||
*cp2++ = *cp1++;
|
*cp2++ = *cp1++;
|
||||||
*cp2 = 0;
|
*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 */
|
char *name; /* name to check on */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -370,7 +372,7 @@ char *name; /* name to check on */
|
|||||||
sp = name;
|
sp = name;
|
||||||
while (*sp)
|
while (*sp)
|
||||||
++sp;
|
++sp;
|
||||||
if (sp == name || (*(sp-1) <'0' || *(sp-1) > '8')) {
|
if (sp == name || (*(sp - 1) < '0' || *(sp - 1) > '8')) {
|
||||||
*sp++ = '0';
|
*sp++ = '0';
|
||||||
*sp = 0;
|
*sp = 0;
|
||||||
} else
|
} else
|
||||||
@ -394,10 +396,10 @@ filewrite(f, n)
|
|||||||
char fname[NFILEN];
|
char fname[NFILEN];
|
||||||
|
|
||||||
if (restflag) /* don't allow this command if restricted */
|
if (restflag) /* don't allow this command if restricted */
|
||||||
return(resterr());
|
return (resterr());
|
||||||
if ((s=mlreply("Write file: ", fname, NFILEN)) != TRUE)
|
if ((s = mlreply("Write file: ", fname, NFILEN)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
if ((s=writeout(fname)) == TRUE) {
|
if ((s = writeout(fname)) == TRUE) {
|
||||||
strcpy(curbp->b_fname, fname);
|
strcpy(curbp->b_fname, fname);
|
||||||
curbp->b_flag &= ~BFCHG;
|
curbp->b_flag &= ~BFCHG;
|
||||||
wp = wheadp; /* Update mode lines. */
|
wp = wheadp; /* Update mode lines. */
|
||||||
@ -423,9 +425,9 @@ filesave(f, n)
|
|||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
register int s;
|
register int s;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if ((curbp->b_flag&BFCHG) == 0) /* Return, no changes. */
|
if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
if (curbp->b_fname[0] == 0) { /* Must have a name. */
|
if (curbp->b_fname[0] == 0) { /* Must have a name. */
|
||||||
mlwrite("No file name");
|
mlwrite("No file name");
|
||||||
@ -433,14 +435,14 @@ filesave(f, n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* complain about truncated files */
|
/* complain about truncated files */
|
||||||
if ((curbp->b_flag&BFTRUNC) != 0) {
|
if ((curbp->b_flag & BFTRUNC) != 0) {
|
||||||
if (mlyesno("Truncated file ... write it out") == FALSE) {
|
if (mlyesno("Truncated file ... write it out") == FALSE) {
|
||||||
mlwrite("(Aborted)");
|
mlwrite("(Aborted)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s=writeout(curbp->b_fname)) == TRUE) {
|
if ((s = writeout(curbp->b_fname)) == TRUE) {
|
||||||
curbp->b_flag &= ~BFCHG;
|
curbp->b_flag &= ~BFCHG;
|
||||||
wp = wheadp; /* Update mode lines. */
|
wp = wheadp; /* Update mode lines. */
|
||||||
while (wp != NULL) {
|
while (wp != NULL) {
|
||||||
@ -470,12 +472,12 @@ char *fn;
|
|||||||
#if CRYPT
|
#if CRYPT
|
||||||
s = resetkey();
|
s = resetkey();
|
||||||
if (s != TRUE)
|
if (s != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
#endif
|
#endif
|
||||||
/* turn off ALL keyboard translation in case we get a dos error */
|
/* turn off ALL keyboard translation in case we get a dos error */
|
||||||
TTkclose();
|
TTkclose();
|
||||||
|
|
||||||
if ((s=ffwopen(fn)) != FIOSUC) { /* Open writes message. */
|
if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */
|
||||||
TTkopen();
|
TTkopen();
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
@ -483,7 +485,7 @@ char *fn;
|
|||||||
lp = lforw(curbp->b_linep); /* First line. */
|
lp = lforw(curbp->b_linep); /* First line. */
|
||||||
nline = 0; /* Number of lines. */
|
nline = 0; /* Number of lines. */
|
||||||
while (lp != curbp->b_linep) {
|
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;
|
break;
|
||||||
++nline;
|
++nline;
|
||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
@ -520,8 +522,8 @@ filename(f, n)
|
|||||||
char fname[NFILEN];
|
char fname[NFILEN];
|
||||||
|
|
||||||
if (restflag) /* don't allow this command if restricted */
|
if (restflag) /* don't allow this command if restricted */
|
||||||
return(resterr());
|
return (resterr());
|
||||||
if ((s=mlreply("Name: ", fname, NFILEN)) == ABORT)
|
if ((s = mlreply("Name: ", fname, NFILEN)) == ABORT)
|
||||||
return (s);
|
return (s);
|
||||||
if (s == FALSE)
|
if (s == FALSE)
|
||||||
strcpy(curbp->b_fname, "");
|
strcpy(curbp->b_fname, "");
|
||||||
@ -558,19 +560,19 @@ char fname[];
|
|||||||
|
|
||||||
bp = curbp; /* Cheap. */
|
bp = curbp; /* Cheap. */
|
||||||
bp->b_flag |= BFCHG; /* we have changed */
|
bp->b_flag |= BFCHG; /* we have changed */
|
||||||
bp->b_flag &= ~BFINVS; /* and are not temporary*/
|
bp->b_flag &= ~BFINVS; /* and are not temporary */
|
||||||
if ((s=ffropen(fname)) == FIOERR) /* Hard file open. */
|
if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||||
goto out;
|
goto out;
|
||||||
if (s == FIOFNF) { /* File not found. */
|
if (s == FIOFNF) { /* File not found. */
|
||||||
mlwrite("(No such file)");
|
mlwrite("(No such file)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
mlwrite("(Inserting file)");
|
mlwrite("(Inserting file)");
|
||||||
|
|
||||||
#if CRYPT
|
#if CRYPT
|
||||||
s = resetkey();
|
s = resetkey();
|
||||||
if (s != TRUE)
|
if (s != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
#endif
|
#endif
|
||||||
/* back up a line and save the mark here */
|
/* back up a line and save the mark here */
|
||||||
curwp->w_dotp = lback(curwp->w_dotp);
|
curwp->w_dotp = lback(curwp->w_dotp);
|
||||||
@ -580,9 +582,9 @@ char fname[];
|
|||||||
|
|
||||||
nline = 0;
|
nline = 0;
|
||||||
lflag = FALSE;
|
lflag = FALSE;
|
||||||
while ((s=ffgetline()) == FIOSUC) {
|
while ((s = ffgetline()) == FIOSUC) {
|
||||||
nbytes = strlen(fline);
|
nbytes = strlen(fline);
|
||||||
if ((lp1=lalloc(nbytes)) == NULL) {
|
if ((lp1 = lalloc(nbytes)) == NULL) {
|
||||||
s = FIOMEM; /* Keep message on the */
|
s = FIOMEM; /* Keep message on the */
|
||||||
break; /* display. */
|
break; /* display. */
|
||||||
}
|
}
|
||||||
@ -597,14 +599,14 @@ char fname[];
|
|||||||
|
|
||||||
/* and advance and write out the current line */
|
/* and advance and write out the current line */
|
||||||
curwp->w_dotp = lp1;
|
curwp->w_dotp = lp1;
|
||||||
for (i=0; i<nbytes; ++i)
|
for (i = 0; i < nbytes; ++i)
|
||||||
lputc(lp1, i, fline[i]);
|
lputc(lp1, i, fline[i]);
|
||||||
++nline;
|
++nline;
|
||||||
}
|
}
|
||||||
ffclose(); /* Ignore errors. */
|
ffclose(); /* Ignore errors. */
|
||||||
curwp->w_markp = lforw(curwp->w_markp);
|
curwp->w_markp = lforw(curwp->w_markp);
|
||||||
strcpy(mesg, "(");
|
strcpy(mesg, "(");
|
||||||
if (s==FIOERR) {
|
if (s == FIOERR) {
|
||||||
strcat(mesg, "I/O ERROR, ");
|
strcat(mesg, "I/O ERROR, ");
|
||||||
curbp->b_flag |= BFTRUNC;
|
curbp->b_flag |= BFTRUNC;
|
||||||
}
|
}
|
||||||
@ -618,7 +620,7 @@ char fname[];
|
|||||||
strcat(mesg, ")");
|
strcat(mesg, ")");
|
||||||
mlwrite(mesg);
|
mlwrite(mesg);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
/* advance to the next line and mark the window for changes */
|
/* advance to the next line and mark the window for changes */
|
||||||
curwp->w_dotp = lforw(curwp->w_dotp);
|
curwp->w_dotp = lforw(curwp->w_dotp);
|
||||||
curwp->w_flag |= WFHARD | WFMODE;
|
curwp->w_flag |= WFHARD | WFMODE;
|
||||||
|
50
fileio.c
50
fileio.c
@ -23,7 +23,7 @@ int eofflag; /* end-of-file flag */
|
|||||||
ffropen(fn)
|
ffropen(fn)
|
||||||
char *fn;
|
char *fn;
|
||||||
{
|
{
|
||||||
if ((ffp=fopen(fn, "r")) == NULL)
|
if ((ffp = fopen(fn, "r")) == NULL)
|
||||||
return (FIOFNF);
|
return (FIOFNF);
|
||||||
eofflag = FALSE;
|
eofflag = FALSE;
|
||||||
return (FIOSUC);
|
return (FIOSUC);
|
||||||
@ -39,10 +39,10 @@ char *fn;
|
|||||||
#if VMS
|
#if VMS
|
||||||
register int fd;
|
register int fd;
|
||||||
|
|
||||||
if ((fd=creat(fn, 0666, "rfm=var", "rat=cr")) < 0
|
if ((fd = creat(fn, 0666, "rfm=var", "rat=cr")) < 0
|
||||||
|| (ffp=fdopen(fd, "w")) == NULL) {
|
|| (ffp = fdopen(fd, "w")) == NULL) {
|
||||||
#else
|
#else
|
||||||
if ((ffp=fopen(fn, "w")) == NULL) {
|
if ((ffp = fopen(fn, "w")) == NULL) {
|
||||||
#endif
|
#endif
|
||||||
mlwrite("Cannot open file for writing");
|
mlwrite("Cannot open file for writing");
|
||||||
return (FIOERR);
|
return (FIOERR);
|
||||||
@ -69,9 +69,9 @@ ffclose()
|
|||||||
#if V7 | USG | BSD | (MSDOS & (MSC | TURBO))
|
#if V7 | USG | BSD | (MSDOS & (MSC | TURBO))
|
||||||
if (fclose(ffp) != FALSE) {
|
if (fclose(ffp) != FALSE) {
|
||||||
mlwrite("Error closing file");
|
mlwrite("Error closing file");
|
||||||
return(FIOERR);
|
return (FIOERR);
|
||||||
}
|
}
|
||||||
return(FIOSUC);
|
return (FIOSUC);
|
||||||
#else
|
#else
|
||||||
fclose(ffp);
|
fclose(ffp);
|
||||||
return (FIOSUC);
|
return (FIOSUC);
|
||||||
@ -98,10 +98,10 @@ char buf[];
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
for (i = 0; i < nbuf; ++i)
|
for (i = 0; i < nbuf; ++i)
|
||||||
fputc(buf[i]&0xFF, ffp);
|
fputc(buf[i] & 0xFF, ffp);
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < nbuf; ++i)
|
for (i = 0; i < nbuf; ++i)
|
||||||
fputc(buf[i]&0xFF, ffp);
|
fputc(buf[i] & 0xFF, ffp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fputc('\n', ffp);
|
fputc('\n', ffp);
|
||||||
@ -121,7 +121,6 @@ char buf[];
|
|||||||
* errors too. Return status.
|
* errors too. Return status.
|
||||||
*/
|
*/
|
||||||
ffgetline()
|
ffgetline()
|
||||||
|
|
||||||
{
|
{
|
||||||
register int c; /* current character read */
|
register int c; /* current character read */
|
||||||
register int i; /* current index into fline */
|
register int i; /* current index into fline */
|
||||||
@ -129,7 +128,7 @@ ffgetline()
|
|||||||
|
|
||||||
/* if we are at the end...return it */
|
/* if we are at the end...return it */
|
||||||
if (eofflag)
|
if (eofflag)
|
||||||
return(FIOEOF);
|
return (FIOEOF);
|
||||||
|
|
||||||
/* dump fline if it ended up too big */
|
/* dump fline if it ended up too big */
|
||||||
if (flen > NSTRING) {
|
if (flen > NSTRING) {
|
||||||
@ -140,25 +139,23 @@ ffgetline()
|
|||||||
/* if we don't have an fline, allocate one */
|
/* if we don't have an fline, allocate one */
|
||||||
if (fline == NULL)
|
if (fline == NULL)
|
||||||
if ((fline = malloc(flen = NSTRING)) == NULL)
|
if ((fline = malloc(flen = NSTRING)) == NULL)
|
||||||
return(FIOMEM);
|
return (FIOMEM);
|
||||||
|
|
||||||
/* read the line in */
|
/* read the line in */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (!nullflag) {
|
if (!nullflag) {
|
||||||
if (fgets(fline, NSTRING, ffp) == (char *)NULL) { /* EOF ? */
|
if (fgets(fline, NSTRING, ffp) == (char *) NULL) { /* EOF ? */
|
||||||
i = 0;
|
i = 0;
|
||||||
c = EOF;
|
c = EOF;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
i = strlen(fline);
|
i = strlen(fline);
|
||||||
c = 0;
|
c = 0;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
c = fline[i-1];
|
c = fline[i - 1];
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
i = 0;
|
i = 0;
|
||||||
c = fgetc(ffp);
|
c = fgetc(ffp);
|
||||||
}
|
}
|
||||||
@ -173,8 +170,9 @@ ffgetline()
|
|||||||
fline[i++] = c;
|
fline[i++] = c;
|
||||||
/* if it's longer, get more room */
|
/* if it's longer, get more room */
|
||||||
if (i >= flen) {
|
if (i >= flen) {
|
||||||
if ((tmpline = malloc(flen+NSTRING)) == NULL)
|
if ((tmpline =
|
||||||
return(FIOMEM);
|
malloc(flen + NSTRING)) == NULL)
|
||||||
|
return (FIOMEM);
|
||||||
strncpy(tmpline, fline, flen);
|
strncpy(tmpline, fline, flen);
|
||||||
flen += NSTRING;
|
flen += NSTRING;
|
||||||
free(fline);
|
free(fline);
|
||||||
@ -190,13 +188,13 @@ ffgetline()
|
|||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
if (ferror(ffp)) {
|
if (ferror(ffp)) {
|
||||||
mlwrite("File read error");
|
mlwrite("File read error");
|
||||||
return(FIOERR);
|
return (FIOERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != 0)
|
if (i != 0)
|
||||||
eofflag = TRUE;
|
eofflag = TRUE;
|
||||||
else
|
else
|
||||||
return(FIOEOF);
|
return (FIOEOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* terminate and decrypt the string */
|
/* terminate and decrypt the string */
|
||||||
@ -205,11 +203,11 @@ ffgetline()
|
|||||||
if (cryptflag)
|
if (cryptflag)
|
||||||
crypt(fline, strlen(fline));
|
crypt(fline, strlen(fline));
|
||||||
#endif
|
#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 */
|
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 it fails, just return false! */
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* otherwise, close it and report true */
|
/* otherwise, close it and report true */
|
||||||
fclose(fp);
|
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 */
|
char drvname[][8] = { /* screen resolution names */
|
||||||
"CGA", "MONO", "EGA"
|
"CGA", "MONO", "EGA"
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
,"VGA"
|
, "VGA"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
long scadd; /* address of screen ram */
|
long scadd; /* address of screen ram */
|
||||||
@ -89,9 +89,9 @@ int cfcolor = -1; /* current forground color */
|
|||||||
int cbcolor = -1; /* current background color */
|
int cbcolor = -1; /* current background color */
|
||||||
int ctrans[] = /* ansi to ibm color translation table */
|
int ctrans[] = /* ansi to ibm color translation table */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
{0, 4, 2, 6, 1, 5, 3, 7, 15};
|
{ 0, 4, 2, 6, 1, 5, 3, 7, 15 };
|
||||||
#else
|
#else
|
||||||
{0, 4, 2, 6, 1, 5, 3, 7};
|
{ 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -100,8 +100,8 @@ int ctrans[] = /* ansi to ibm color translation table */
|
|||||||
* "termio" code.
|
* "termio" code.
|
||||||
*/
|
*/
|
||||||
TERM term = {
|
TERM term = {
|
||||||
NROW-1,
|
NROW - 1,
|
||||||
NROW-1,
|
NROW - 1,
|
||||||
NCOL,
|
NCOL,
|
||||||
NCOL,
|
NCOL,
|
||||||
MARGIN,
|
MARGIN,
|
||||||
@ -130,16 +130,16 @@ TERM term = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#if COLOR
|
#if COLOR
|
||||||
ibmfcol(color) /* set the current output color */
|
ibmfcol(color)
|
||||||
|
/* set the current output color */
|
||||||
int color; /* color to set */
|
int color; /* color to set */
|
||||||
|
|
||||||
{
|
{
|
||||||
cfcolor = ctrans[color];
|
cfcolor = ctrans[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
ibmbcol(color) /* set the current background color */
|
ibmbcol(color)
|
||||||
|
/* set the current background color */
|
||||||
int color; /* color to set */
|
int color; /* color to set */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -156,9 +156,8 @@ ibmmove(row, col)
|
|||||||
int86(0x10, &rg, &rg);
|
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 attr; /* attribute byte mask to place in RAM */
|
||||||
unsigned int *lnptr; /* pointer to the destination line */
|
unsigned int *lnptr; /* pointer to the destination line */
|
||||||
int i;
|
int i;
|
||||||
@ -182,27 +181,25 @@ ibmeeol() /* erase to the end of the line */
|
|||||||
attr = 0x0700;
|
attr = 0x0700;
|
||||||
#endif
|
#endif
|
||||||
lnptr = &sline[0];
|
lnptr = &sline[0];
|
||||||
for (i=0; i < term.t_ncol; i++)
|
for (i = 0; i < term.t_ncol; i++)
|
||||||
*lnptr++ = SPACE | attr;
|
*lnptr++ = SPACE | attr;
|
||||||
|
|
||||||
if (flickcode && (dtype == CDCGA)) {
|
if (flickcode && (dtype == CDCGA)) {
|
||||||
/* wait for vertical retrace to be off */
|
/* wait for vertical retrace to be off */
|
||||||
while ((inp(0x3da) & 8))
|
while ((inp(0x3da) & 8));
|
||||||
;
|
|
||||||
|
|
||||||
/* and to be back on */
|
/* and to be back on */
|
||||||
while ((inp(0x3da) & 8) == 0)
|
while ((inp(0x3da) & 8) == 0);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and send the string out */
|
/* 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 */
|
current colors */
|
||||||
|
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -230,7 +227,8 @@ ibmeeop()
|
|||||||
/* lower right corner of scroll */
|
/* lower right corner of scroll */
|
||||||
#if COLOR
|
#if COLOR
|
||||||
if (dtype != CDMONO)
|
if (dtype != CDMONO)
|
||||||
attr = ((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
|
attr =
|
||||||
|
((ctrans[gbcolor] & 15) << 4) | (ctrans[gfcolor] & 15);
|
||||||
else
|
else
|
||||||
attr = 0;
|
attr = 0;
|
||||||
#else
|
#else
|
||||||
@ -240,16 +238,16 @@ ibmeeop()
|
|||||||
int86(0x10, &rg, &rg);
|
int86(0x10, &rg, &rg);
|
||||||
}
|
}
|
||||||
|
|
||||||
ibmrev(state) /* change reverse video state */
|
ibmrev(state)
|
||||||
|
/* change reverse video state */
|
||||||
int state; /* TRUE = reverse, FALSE = normal */
|
int state; /* TRUE = reverse, FALSE = normal */
|
||||||
|
|
||||||
{
|
{
|
||||||
/* This never gets used under the IBM-PC driver */
|
/* 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 */
|
char *res; /* resolution to change to */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -258,9 +256,9 @@ char *res; /* resolution to change to */
|
|||||||
for (i = 0; i < NDRIVE; i++)
|
for (i = 0; i < NDRIVE; i++)
|
||||||
if (strcmp(res, drvname[i]) == 0) {
|
if (strcmp(res, drvname[i]) == 0) {
|
||||||
scinit(i);
|
scinit(i);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
@ -272,19 +270,19 @@ ibmscroll_reg(from, to, howmany)
|
|||||||
|
|
||||||
if (to < from)
|
if (to < from)
|
||||||
for (i = 0; i < howmany; i++)
|
for (i = 0; i < howmany; i++)
|
||||||
movmem(scptr[from+i], scptr[to+i], term.t_ncol*2);
|
movmem(scptr[from + i], scptr[to + i],
|
||||||
else
|
term.t_ncol * 2);
|
||||||
if (to > from)
|
else if (to > from)
|
||||||
for (i = howmany-1; i >= 0; i--)
|
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);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
spal() /* reset the pallette registers */
|
spal()
|
||||||
|
{ /* reset the pallette registers */
|
||||||
{
|
|
||||||
/* nothin here now..... */
|
/* nothin here now..... */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +299,6 @@ ibmopen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ibmclose()
|
ibmclose()
|
||||||
|
|
||||||
{
|
{
|
||||||
#if COLOR
|
#if COLOR
|
||||||
ibmfcol(7);
|
ibmfcol(7);
|
||||||
@ -318,18 +315,16 @@ ibmclose()
|
|||||||
ttclose();
|
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 */
|
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 we have nothing to do....don't do it */
|
||||||
if (dtype == type)
|
if (dtype == type)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* if we try to switch to EGA and there is none, don't */
|
/* if we try to switch to EGA and there is none, don't */
|
||||||
if (type == CDEGA && egaexist != TRUE)
|
if (type == CDEGA && egaexist != TRUE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* if we had the EGA open... close it */
|
/* if we had the EGA open... close it */
|
||||||
if (dtype == CDEGA)
|
if (dtype == CDEGA)
|
||||||
@ -389,10 +384,10 @@ int type; /* type of adapter to init for */
|
|||||||
|
|
||||||
/* initialize the screen pointer array */
|
/* initialize the screen pointer array */
|
||||||
for (i = 0; i < NROW; i++) {
|
for (i = 0; i < NROW; i++) {
|
||||||
addr.laddr = scadd + (long)(NCOL * i * 2);
|
addr.laddr = scadd + (long) (NCOL * i * 2);
|
||||||
scptr[i] = addr.paddr;
|
scptr[i] = addr.paddr;
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* getboard: Determine which type of display board is attached.
|
/* getboard: Determine which type of display board is attached.
|
||||||
@ -410,7 +405,6 @@ int type; /* type of adapter to init for */
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int getboard()
|
int getboard()
|
||||||
|
|
||||||
{
|
{
|
||||||
int type; /* board type to return */
|
int type; /* board type to return */
|
||||||
|
|
||||||
@ -422,14 +416,13 @@ int getboard()
|
|||||||
/* test if EGA present */
|
/* test if EGA present */
|
||||||
rg.x.ax = 0x1200;
|
rg.x.ax = 0x1200;
|
||||||
rg.x.bx = 0xff10;
|
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 */
|
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 */
|
/* put the beast into EGA 43 row mode */
|
||||||
rg.x.ax = 3;
|
rg.x.ax = 3;
|
||||||
int86(16, &rg, &rg);
|
int86(16, &rg, &rg);
|
||||||
@ -453,15 +446,14 @@ egaopen() /* init the computer to work with the EGA */
|
|||||||
}
|
}
|
||||||
|
|
||||||
egaclose()
|
egaclose()
|
||||||
|
|
||||||
{
|
{
|
||||||
/* put the beast into 80 column mode */
|
/* put the beast into 80 column mode */
|
||||||
rg.x.ax = 3;
|
rg.x.ax = 3;
|
||||||
int86(16, &rg, &rg);
|
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 */
|
int row; /* row of screen to place outstr on */
|
||||||
char *outstr; /* string to write out (must be term.t_ncol long) */
|
char *outstr; /* string to write out (must be term.t_ncol long) */
|
||||||
int forg; /* forground color of string to write */
|
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 */
|
/* build the attribute byte and setup the screen pointer */
|
||||||
#if COLOR
|
#if COLOR
|
||||||
if (dtype != CDMONO)
|
if (dtype != CDMONO)
|
||||||
attr = (((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) << 8;
|
attr =
|
||||||
|
(((ctrans[bacg] & 15) << 4) | (ctrans[forg] & 15)) <<
|
||||||
|
8;
|
||||||
else
|
else
|
||||||
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
||||||
#else
|
#else
|
||||||
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
attr = (((bacg & 15) << 4) | (forg & 15)) << 8;
|
||||||
#endif
|
#endif
|
||||||
lnptr = &sline[0];
|
lnptr = &sline[0];
|
||||||
for (i=0; i<term.t_ncol; i++)
|
for (i = 0; i < term.t_ncol; i++)
|
||||||
*lnptr++ = (outstr[i] & 255) | attr;
|
*lnptr++ = (outstr[i] & 255) | attr;
|
||||||
|
|
||||||
if (flickcode && (dtype == CDCGA)) {
|
if (flickcode && (dtype == CDCGA)) {
|
||||||
/* wait for vertical retrace to be off */
|
/* wait for vertical retrace to be off */
|
||||||
while ((inp(0x3da) & 8))
|
while ((inp(0x3da) & 8));
|
||||||
;
|
|
||||||
|
|
||||||
/* and to be back on */
|
/* and to be back on */
|
||||||
while ((inp(0x3da) & 8) == 0)
|
while ((inp(0x3da) & 8) == 0);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and send the string out */
|
/* 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
|
#if FNLABEL
|
||||||
fnclabel(f, n) /* label a function key */
|
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 */
|
/* on machines with no function keys...don't bother */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
@ -514,4 +506,3 @@ ibmhello()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
224
input.c
224
input.c
@ -46,13 +46,13 @@ char *prompt;
|
|||||||
c = tgetc();
|
c = tgetc();
|
||||||
|
|
||||||
if (c == ectoc(abortc)) /* Bail out! */
|
if (c == ectoc(abortc)) /* Bail out! */
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
|
|
||||||
if (c=='y' || c=='Y')
|
if (c == 'y' || c == 'Y')
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
if (c=='n' || c=='N')
|
if (c == 'n' || c == 'N')
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +65,10 @@ char *prompt;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
mlreply(prompt, buf, nbuf)
|
mlreply(prompt, buf, nbuf)
|
||||||
char *prompt;
|
char *prompt;
|
||||||
char *buf;
|
char *buf;
|
||||||
{
|
{
|
||||||
return(nextarg(prompt, buf, nbuf, ctoec('\n')));
|
return (nextarg(prompt, buf, nbuf, ctoec('\n')));
|
||||||
}
|
}
|
||||||
|
|
||||||
mlreplyt(prompt, buf, nbuf, eolchar)
|
mlreplyt(prompt, buf, nbuf, eolchar)
|
||||||
@ -78,7 +78,7 @@ char *buf;
|
|||||||
int eolchar;
|
int eolchar;
|
||||||
|
|
||||||
{
|
{
|
||||||
return(nextarg(prompt, buf, nbuf, eolchar));
|
return (nextarg(prompt, buf, nbuf, eolchar));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ectoc: expanded character to character
|
/* ectoc: expanded character to character
|
||||||
@ -92,8 +92,8 @@ int c;
|
|||||||
if (c & CONTROL)
|
if (c & CONTROL)
|
||||||
c = c & ~(CONTROL | 0x40);
|
c = c & ~(CONTROL | 0x40);
|
||||||
if (c & SPEC)
|
if (c & SPEC)
|
||||||
c= c & 255;
|
c = c & 255;
|
||||||
return(c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ctoec: character to extended character
|
/* ctoec: character to extended character
|
||||||
@ -104,8 +104,8 @@ ctoec(c)
|
|||||||
int c;
|
int c;
|
||||||
|
|
||||||
{
|
{
|
||||||
if (c>=0x00 && c<=0x1F)
|
if (c >= 0x00 && c <= 0x1F)
|
||||||
c = CONTROL | (c+'@');
|
c = CONTROL | (c + '@');
|
||||||
return (c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,8 +114,7 @@ int c;
|
|||||||
name if it is unique.
|
name if it is unique.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int (*getname())()
|
int (*getname()) ()
|
||||||
|
|
||||||
{
|
{
|
||||||
register int cpos; /* current column on screen output */
|
register int cpos; /* current column on screen output */
|
||||||
register int c;
|
register int c;
|
||||||
@ -124,7 +123,7 @@ int (*getname())()
|
|||||||
register NBIND *cffp; /* current ptr to entry in name binding table */
|
register NBIND *cffp; /* current ptr to entry in name binding table */
|
||||||
register NBIND *lffp; /* last 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 */
|
char buf[NSTRING]; /* buffer to hold tentative command name */
|
||||||
int (*fncmatch())();
|
int (*fncmatch()) ();
|
||||||
|
|
||||||
/* starting at the beginning of the string buffer */
|
/* starting at the beginning of the string buffer */
|
||||||
cpos = 0;
|
cpos = 0;
|
||||||
@ -132,8 +131,8 @@ int (*getname())()
|
|||||||
/* if we are executing a command line get the next arg and match it */
|
/* if we are executing a command line get the next arg and match it */
|
||||||
if (clexec) {
|
if (clexec) {
|
||||||
if (macarg(buf) != TRUE)
|
if (macarg(buf) != TRUE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
return(fncmatch(&buf[0]));
|
return (fncmatch(&buf[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* build a name string from the keyboard */
|
/* build a name string from the keyboard */
|
||||||
@ -145,12 +144,12 @@ int (*getname())()
|
|||||||
buf[cpos] = 0;
|
buf[cpos] = 0;
|
||||||
|
|
||||||
/* and match it off */
|
/* and match it off */
|
||||||
return(fncmatch(&buf[0]));
|
return (fncmatch(&buf[0]));
|
||||||
|
|
||||||
} else if (c == ectoc(abortc)) { /* Bell, abort */
|
} else if (c == ectoc(abortc)) { /* Bell, abort */
|
||||||
ctrlg(FALSE, 0);
|
ctrlg(FALSE, 0);
|
||||||
TTflush();
|
TTflush();
|
||||||
return( (int (*)()) NULL);
|
return ((int (*)()) NULL);
|
||||||
|
|
||||||
} else if (c == 0x7F || c == 0x08) { /* rubout/erase */
|
} else if (c == 0x7F || c == 0x08) { /* rubout/erase */
|
||||||
if (cpos != 0) {
|
if (cpos != 0) {
|
||||||
@ -179,24 +178,34 @@ int (*getname())()
|
|||||||
buf[cpos] = 0; /* terminate it for us */
|
buf[cpos] = 0; /* terminate it for us */
|
||||||
ffp = &names[0]; /* scan for matches */
|
ffp = &names[0]; /* scan for matches */
|
||||||
while (ffp->n_func != NULL) {
|
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? */
|
/* a possible match! More than one? */
|
||||||
if ((ffp + 1)->n_func == NULL ||
|
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 */
|
/* no...we match, print it */
|
||||||
sp = ffp->n_name + cpos;
|
sp = ffp->n_name + cpos;
|
||||||
while (*sp)
|
while (*sp)
|
||||||
TTputc(*sp++);
|
TTputc(*sp++);
|
||||||
TTflush();
|
TTflush();
|
||||||
return(ffp->n_func);
|
return (ffp->n_func);
|
||||||
} else {
|
} else {
|
||||||
/* << << << << << << << << << << << << << << << << << */
|
/* << << << << << << << << << << << << << << << << << */
|
||||||
/* try for a partial match against the list */
|
/* try for a partial match against the list */
|
||||||
|
|
||||||
/* first scan down until we no longer match the current input */
|
/* first scan down until we no longer match the current input */
|
||||||
lffp = (ffp + 1);
|
lffp = (ffp + 1);
|
||||||
while ((lffp+1)->n_func != NULL) {
|
while ((lffp +
|
||||||
if (strncmp(buf, (lffp+1)->n_name, strlen(buf)) != 0)
|
1)->n_func !=
|
||||||
|
NULL) {
|
||||||
|
if (strncmp
|
||||||
|
(buf,
|
||||||
|
(lffp +
|
||||||
|
1)->n_name,
|
||||||
|
strlen(buf))
|
||||||
|
!= 0)
|
||||||
break;
|
break;
|
||||||
++lffp;
|
++lffp;
|
||||||
}
|
}
|
||||||
@ -204,18 +213,27 @@ int (*getname())()
|
|||||||
/* and now, attempt to partial complete the string, char at a time */
|
/* and now, attempt to partial complete the string, char at a time */
|
||||||
while (TRUE) {
|
while (TRUE) {
|
||||||
/* add the next char in */
|
/* add the next char in */
|
||||||
buf[cpos] = ffp->n_name[cpos];
|
buf[cpos] =
|
||||||
|
ffp->
|
||||||
|
n_name[cpos];
|
||||||
|
|
||||||
/* scan through the candidates */
|
/* scan through the candidates */
|
||||||
cffp = ffp + 1;
|
cffp = ffp + 1;
|
||||||
while (cffp <= lffp) {
|
while (cffp <=
|
||||||
if (cffp->n_name[cpos] != buf[cpos])
|
lffp) {
|
||||||
|
if (cffp->
|
||||||
|
n_name
|
||||||
|
[cpos]
|
||||||
|
!=
|
||||||
|
buf
|
||||||
|
[cpos])
|
||||||
goto onward;
|
goto onward;
|
||||||
++cffp;
|
++cffp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add the character */
|
/* add the character */
|
||||||
TTputc(buf[cpos++]);
|
TTputc(buf
|
||||||
|
[cpos++]);
|
||||||
}
|
}
|
||||||
/* << << << << << << << << << << << << << << << << << */
|
/* << << << << << << << << << << << << << << << << << */
|
||||||
}
|
}
|
||||||
@ -225,11 +243,11 @@ int (*getname())()
|
|||||||
|
|
||||||
/* no match.....beep and onward */
|
/* no match.....beep and onward */
|
||||||
TTbeep();
|
TTbeep();
|
||||||
onward:;
|
onward:;
|
||||||
TTflush();
|
TTflush();
|
||||||
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
|
/* <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
|
||||||
} else {
|
} else {
|
||||||
if (cpos < NSTRING-1 && c > ' ') {
|
if (cpos < NSTRING - 1 && c > ' ') {
|
||||||
buf[cpos++] = c;
|
buf[cpos++] = c;
|
||||||
TTputc(c);
|
TTputc(c);
|
||||||
}
|
}
|
||||||
@ -244,7 +262,6 @@ onward:;
|
|||||||
macro action */
|
macro action */
|
||||||
|
|
||||||
int tgetc()
|
int tgetc()
|
||||||
|
|
||||||
{
|
{
|
||||||
int c; /* fetched character */
|
int c; /* fetched character */
|
||||||
|
|
||||||
@ -253,7 +270,7 @@ int tgetc()
|
|||||||
|
|
||||||
/* if there is some left... */
|
/* if there is some left... */
|
||||||
if (kbdptr < kbdend)
|
if (kbdptr < kbdend)
|
||||||
return((int)*kbdptr++);
|
return ((int) *kbdptr++);
|
||||||
|
|
||||||
/* at the end of last repitition? */
|
/* at the end of last repitition? */
|
||||||
if (--kbdrep < 1) {
|
if (--kbdrep < 1) {
|
||||||
@ -266,7 +283,7 @@ int tgetc()
|
|||||||
|
|
||||||
/* reset the macro to the begining for the next rep */
|
/* reset the macro to the begining for the next rep */
|
||||||
kbdptr = &kbdm[0];
|
kbdptr = &kbdm[0];
|
||||||
return((int)*kbdptr++);
|
return ((int) *kbdptr++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +306,7 @@ int tgetc()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* and finally give the char back */
|
/* and finally give the char back */
|
||||||
return(c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* GET1KEY: Get one keystroke. The only prefixs legal here
|
/* GET1KEY: Get one keystroke. The only prefixs legal here
|
||||||
@ -297,7 +314,6 @@ int tgetc()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
get1key()
|
get1key()
|
||||||
|
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
@ -307,14 +323,14 @@ get1key()
|
|||||||
#if MSDOS
|
#if MSDOS
|
||||||
if (c == 0) { /* Apply SPEC prefix */
|
if (c == 0) { /* Apply SPEC prefix */
|
||||||
c = tgetc();
|
c = tgetc();
|
||||||
if (c>=0x00 && c<=0x1F) /* control key? */
|
if (c >= 0x00 && c <= 0x1F) /* control key? */
|
||||||
c = CONTROL | (c+'@');
|
c = CONTROL | (c + '@');
|
||||||
return(SPEC | c);
|
return (SPEC | c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (c>=0x00 && c<=0x1F) /* C0 control -> C- */
|
if (c >= 0x00 && c <= 0x1F) /* C0 control -> C- */
|
||||||
c = CONTROL | (c+'@');
|
c = CONTROL | (c + '@');
|
||||||
return (c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +338,6 @@ get1key()
|
|||||||
prefix keys
|
prefix keys
|
||||||
*/
|
*/
|
||||||
getcmd()
|
getcmd()
|
||||||
|
|
||||||
{
|
{
|
||||||
int c; /* fetched keystroke */
|
int c; /* fetched keystroke */
|
||||||
#if VT220
|
#if VT220
|
||||||
@ -333,7 +348,7 @@ getcmd()
|
|||||||
c = get1key();
|
c = get1key();
|
||||||
|
|
||||||
#if VT220
|
#if VT220
|
||||||
proc_metac:
|
proc_metac:
|
||||||
#endif
|
#endif
|
||||||
/* process META prefix */
|
/* process META prefix */
|
||||||
if (c == (CONTROL | '[')) {
|
if (c == (CONTROL | '[')) {
|
||||||
@ -342,20 +357,24 @@ proc_metac:
|
|||||||
if (c == '[' || c == 'O') { /* CSI P.K. */
|
if (c == '[' || c == 'O') { /* CSI P.K. */
|
||||||
c = get1key();
|
c = get1key();
|
||||||
if (c >= 'A' && c <= 'D')
|
if (c >= 'A' && c <= 'D')
|
||||||
return(SPEC | c | cmask);
|
return (SPEC | c | cmask);
|
||||||
if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c')
|
if (c >= 'E' && c <= 'z' && c != 'i' && c != 'c')
|
||||||
return(SPEC | c | cmask);
|
return (SPEC | c | cmask);
|
||||||
d = get1key();
|
d = get1key();
|
||||||
if (d == '~') /* ESC [ n ~ P.K. */
|
if (d == '~') /* ESC [ n ~ P.K. */
|
||||||
return(SPEC | c | cmask);
|
return (SPEC | c | cmask);
|
||||||
switch (c) { /* ESC [ n n ~ P.K. */
|
switch (c) { /* ESC [ n n ~ P.K. */
|
||||||
case '1': c = d + 32;
|
case '1':
|
||||||
|
c = d + 32;
|
||||||
break;
|
break;
|
||||||
case '2': c = d + 48;
|
case '2':
|
||||||
|
c = d + 48;
|
||||||
break;
|
break;
|
||||||
case '3': c = d + 64;
|
case '3':
|
||||||
|
c = d + 64;
|
||||||
break;
|
break;
|
||||||
default: c = '?';
|
default:
|
||||||
|
c = '?';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (d != '~') /* eat tilde P.K. */
|
if (d != '~') /* eat tilde P.K. */
|
||||||
@ -363,11 +382,10 @@ proc_metac:
|
|||||||
if (c == 'i') { /* DO key P.K. */
|
if (c == 'i') { /* DO key P.K. */
|
||||||
c = ctlxc;
|
c = ctlxc;
|
||||||
goto proc_ctlxc;
|
goto proc_ctlxc;
|
||||||
}
|
} else if (c == 'c') /* ESC key P.K. */
|
||||||
else if (c == 'c') /* ESC key P.K. */
|
|
||||||
c = get1key();
|
c = get1key();
|
||||||
else
|
else
|
||||||
return(SPEC | c | cmask);
|
return (SPEC | c | cmask);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if VT220
|
#if VT220
|
||||||
@ -378,13 +396,12 @@ proc_metac:
|
|||||||
#endif
|
#endif
|
||||||
if (islower(c)) /* Force to upper */
|
if (islower(c)) /* Force to upper */
|
||||||
c ^= DIFCASE;
|
c ^= DIFCASE;
|
||||||
if (c>=0x00 && c<=0x1F) /* control key */
|
if (c >= 0x00 && c <= 0x1F) /* control key */
|
||||||
c = CONTROL | (c+'@');
|
c = CONTROL | (c + '@');
|
||||||
return(META | c );
|
return (META | c);
|
||||||
}
|
}
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
else
|
else if (c == metac) {
|
||||||
if (c == metac) {
|
|
||||||
c = get1key();
|
c = get1key();
|
||||||
#if VT220
|
#if VT220
|
||||||
if (c == (CONTROL | '[')) {
|
if (c == (CONTROL | '[')) {
|
||||||
@ -394,15 +411,15 @@ proc_metac:
|
|||||||
#endif
|
#endif
|
||||||
if (islower(c)) /* Force to upper */
|
if (islower(c)) /* Force to upper */
|
||||||
c ^= DIFCASE;
|
c ^= DIFCASE;
|
||||||
if (c>=0x00 && c<=0x1F) /* control key */
|
if (c >= 0x00 && c <= 0x1F) /* control key */
|
||||||
c = CONTROL | (c+'@');
|
c = CONTROL | (c + '@');
|
||||||
return(META | c );
|
return (META | c);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if VT220
|
#if VT220
|
||||||
proc_ctlxc:
|
proc_ctlxc:
|
||||||
#endif
|
#endif
|
||||||
/* process CTLX prefix */
|
/* process CTLX prefix */
|
||||||
if (c == ctlxc) {
|
if (c == ctlxc) {
|
||||||
@ -413,15 +430,15 @@ proc_ctlxc:
|
|||||||
goto proc_metac;
|
goto proc_metac;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (c>='a' && c<='z') /* Force to upper */
|
if (c >= 'a' && c <= 'z') /* Force to upper */
|
||||||
c -= 0x20;
|
c -= 0x20;
|
||||||
if (c>=0x00 && c<=0x1F) /* control key */
|
if (c >= 0x00 && c <= 0x1F) /* control key */
|
||||||
c = CONTROL | (c+'@');
|
c = CONTROL | (c + '@');
|
||||||
return(CTLX | c);
|
return (CTLX | c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* otherwise, just return it */
|
/* otherwise, just return it */
|
||||||
return(c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A more generalized prompt/reply function allowing the caller
|
/* A more generalized prompt/reply function allowing the caller
|
||||||
@ -430,7 +447,9 @@ proc_ctlxc:
|
|||||||
*/
|
*/
|
||||||
getstring(prompt, buf, nbuf, eolchar)
|
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 */
|
register int cpos; /* current character position in string */
|
||||||
@ -462,7 +481,7 @@ char *prompt; char *buf; int eolchar;
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
#if COMPLC
|
#if COMPLC
|
||||||
if (! didtry)
|
if (!didtry)
|
||||||
nskip = -1;
|
nskip = -1;
|
||||||
didtry = 0;
|
didtry = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -487,9 +506,9 @@ char *prompt; char *buf; int eolchar;
|
|||||||
|
|
||||||
/* if we default the buffer, return FALSE */
|
/* if we default the buffer, return FALSE */
|
||||||
if (buf[0] == 0)
|
if (buf[0] == 0)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* change from command form back to character form */
|
/* change from command form back to character form */
|
||||||
@ -499,8 +518,8 @@ char *prompt; char *buf; int eolchar;
|
|||||||
/* Abort the input? */
|
/* Abort the input? */
|
||||||
ctrlg(FALSE, 0);
|
ctrlg(FALSE, 0);
|
||||||
TTflush();
|
TTflush();
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
} else if ((c==0x7F || c==0x08) && quotef==FALSE) {
|
} else if ((c == 0x7F || c == 0x08) && quotef == FALSE) {
|
||||||
/* rubout/erase */
|
/* rubout/erase */
|
||||||
if (cpos != 0) {
|
if (cpos != 0) {
|
||||||
outstring("\b \b");
|
outstring("\b \b");
|
||||||
@ -536,7 +555,8 @@ char *prompt; char *buf; int eolchar;
|
|||||||
TTflush();
|
TTflush();
|
||||||
|
|
||||||
#if COMPLC
|
#if COMPLC
|
||||||
} else if ((c == 0x09 || c == ' ') && quotef == FALSE && ffile) {
|
} else if ((c == 0x09 || c == ' ') && quotef == FALSE
|
||||||
|
&& ffile) {
|
||||||
/* TAB, complete file name */
|
/* TAB, complete file name */
|
||||||
char ffbuf[255];
|
char ffbuf[255];
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
@ -564,13 +584,13 @@ char *prompt; char *buf; int eolchar;
|
|||||||
#if MSDOS
|
#if MSDOS
|
||||||
if (lsav < 0 && (buf[cpos] == '\\' ||
|
if (lsav < 0 && (buf[cpos] == '\\' ||
|
||||||
buf[cpos] == '/' ||
|
buf[cpos] == '/' ||
|
||||||
buf[cpos] == ':' && cpos == 1))
|
buf[cpos] == ':'
|
||||||
|
&& cpos == 1))
|
||||||
lsav = cpos;
|
lsav = cpos;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
TTflush();
|
TTflush();
|
||||||
if (nskip < 0)
|
if (nskip < 0) {
|
||||||
{
|
|
||||||
buf[ocpos] = 0;
|
buf[ocpos] = 0;
|
||||||
#if UNIX
|
#if UNIX
|
||||||
if (tmpf != NULL)
|
if (tmpf != NULL)
|
||||||
@ -578,8 +598,8 @@ char *prompt; char *buf; int eolchar;
|
|||||||
strcpy(tmp, "/tmp/meXXXXXX");
|
strcpy(tmp, "/tmp/meXXXXXX");
|
||||||
strcpy(ffbuf, "echo ");
|
strcpy(ffbuf, "echo ");
|
||||||
strcat(ffbuf, buf);
|
strcat(ffbuf, buf);
|
||||||
if (! iswild)
|
if (!iswild)
|
||||||
strcat(ffbuf,"*");
|
strcat(ffbuf, "*");
|
||||||
strcat(ffbuf, " >");
|
strcat(ffbuf, " >");
|
||||||
mktemp(tmp);
|
mktemp(tmp);
|
||||||
strcat(ffbuf, tmp);
|
strcat(ffbuf, tmp);
|
||||||
@ -589,49 +609,47 @@ char *prompt; char *buf; int eolchar;
|
|||||||
#endif
|
#endif
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
strcpy(sffbuf, buf);
|
strcpy(sffbuf, buf);
|
||||||
if (! iswild)
|
if (!iswild)
|
||||||
strcat(sffbuf,"*.*");
|
strcat(sffbuf, "*.*");
|
||||||
#endif
|
#endif
|
||||||
nskip = 0;
|
nskip = 0;
|
||||||
}
|
}
|
||||||
#if UNIX
|
#if UNIX
|
||||||
c = ' ';
|
c = ' ';
|
||||||
for (n = nskip; n > 0; n--)
|
for (n = nskip; n > 0; n--)
|
||||||
while ((c = getc(tmpf)) != EOF && c != ' ');
|
while ((c = getc(tmpf)) != EOF
|
||||||
|
&& c != ' ');
|
||||||
#endif
|
#endif
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
if (nskip == 0)
|
if (nskip == 0) {
|
||||||
{
|
|
||||||
strcpy(ffbuf, sffbuf);
|
strcpy(ffbuf, sffbuf);
|
||||||
c = findfirst(ffbuf, &ffblk, FA_DIREC) ? '*' : ' ';
|
c = findfirst(ffbuf, &ffblk,
|
||||||
}
|
FA_DIREC) ? '*' : ' ';
|
||||||
else if (nskip > 0)
|
} else if (nskip > 0)
|
||||||
c = findnext(&ffblk) ? 0 : ' ';
|
c = findnext(&ffblk) ? 0 : ' ';
|
||||||
#endif
|
#endif
|
||||||
nskip++;
|
nskip++;
|
||||||
|
|
||||||
if (c != ' ')
|
if (c != ' ') {
|
||||||
{
|
|
||||||
TTbeep();
|
TTbeep();
|
||||||
nskip = 0;
|
nskip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNIX
|
#if UNIX
|
||||||
while ((c = getc(tmpf)) != EOF && c != '\n' && c != ' ' && c != '*')
|
while ((c = getc(tmpf)) != EOF && c != '\n'
|
||||||
|
&& c != ' ' && c != '*')
|
||||||
#endif
|
#endif
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
if (c == '*')
|
if (c == '*')
|
||||||
fcp = sffbuf;
|
fcp = sffbuf;
|
||||||
else
|
else {
|
||||||
{
|
strncpy(buf, sffbuf, lsav + 1);
|
||||||
strncpy(buf, sffbuf, lsav+1);
|
cpos = lsav + 1;
|
||||||
cpos = lsav+1;
|
|
||||||
fcp = ffblk.ff_name;
|
fcp = ffblk.ff_name;
|
||||||
}
|
}
|
||||||
while (c != 0 && (c = *fcp++) != 0 && c != '*')
|
while (c != 0 && (c = *fcp++) != 0 && c != '*')
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (cpos < nbuf-1)
|
if (cpos < nbuf - 1)
|
||||||
buf[cpos++] = c;
|
buf[cpos++] = c;
|
||||||
}
|
}
|
||||||
#if UNIX
|
#if UNIX
|
||||||
@ -639,8 +657,7 @@ char *prompt; char *buf; int eolchar;
|
|||||||
TTbeep();
|
TTbeep();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (n = 0; n < cpos; n++)
|
for (n = 0; n < cpos; n++) {
|
||||||
{
|
|
||||||
c = buf[n];
|
c = buf[n];
|
||||||
if ((c < ' ') && (c != '\n')) {
|
if ((c < ' ') && (c != '\n')) {
|
||||||
outstring("^");
|
outstring("^");
|
||||||
@ -668,7 +685,7 @@ char *prompt; char *buf; int eolchar;
|
|||||||
quotef = TRUE;
|
quotef = TRUE;
|
||||||
} else {
|
} else {
|
||||||
quotef = FALSE;
|
quotef = FALSE;
|
||||||
if (cpos < nbuf-1) {
|
if (cpos < nbuf - 1) {
|
||||||
buf[cpos++] = c;
|
buf[cpos++] = c;
|
||||||
|
|
||||||
if ((c < ' ') && (c != '\n')) {
|
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 */
|
char *s; /* string to output */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -701,8 +718,8 @@ char *s; /* string to output */
|
|||||||
TTputc(*s++);
|
TTputc(*s++);
|
||||||
}
|
}
|
||||||
|
|
||||||
ostring(s) /* output a string of output characters */
|
ostring(s)
|
||||||
|
/* output a string of output characters */
|
||||||
char *s; /* string to output */
|
char *s; /* string to output */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -710,4 +727,3 @@ char *s; /* string to output */
|
|||||||
while (*s)
|
while (*s)
|
||||||
TTputc(*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 */
|
/* 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 */
|
int eaten_char = -1; /* Re-eaten char */
|
||||||
|
|
||||||
/* A couple more "own" variables for the command string */
|
/* A couple more "own" variables for the command string */
|
||||||
@ -62,17 +62,17 @@ int risearch(f, n)
|
|||||||
|
|
||||||
backchar(TRUE, 1); /* Back up a character */
|
backchar(TRUE, 1); /* Back up a character */
|
||||||
|
|
||||||
if (!(isearch(f, -n))) /* Call ISearch backwards */
|
if (!(isearch(f, -n))) { /* Call ISearch backwards *//* If error in search: */
|
||||||
{ /* If error in search: */
|
|
||||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||||
curwp->w_doto = curoff; /* and the offset to original value */
|
curwp->w_doto = curoff; /* and the offset to original value */
|
||||||
curwp->w_flag |= WFMOVE; /* Say we've moved */
|
curwp->w_flag |= WFMOVE; /* Say we've moved */
|
||||||
update(FALSE); /* And force an update */
|
update(FALSE); /* And force an update */
|
||||||
mlwrite ("(search failed)"); /* Say we died */
|
mlwrite("(search failed)"); /* Say we died */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
matchlen = strlen(pat);
|
matchlen = strlen(pat);
|
||||||
#endif
|
#endif
|
||||||
} else mlerase (); /* If happy, just erase the cmd line */
|
} else
|
||||||
|
mlerase(); /* If happy, just erase the cmd line */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
matchlen = strlen(pat);
|
matchlen = strlen(pat);
|
||||||
#endif
|
#endif
|
||||||
@ -92,17 +92,17 @@ int fisearch(f, n)
|
|||||||
|
|
||||||
/* do the search */
|
/* do the search */
|
||||||
|
|
||||||
if (!(isearch(f, n))) /* Call ISearch forwards */
|
if (!(isearch(f, n))) { /* Call ISearch forwards *//* If error in search: */
|
||||||
{ /* If error in search: */
|
|
||||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||||
curwp->w_doto = curoff; /* and the offset to original value */
|
curwp->w_doto = curoff; /* and the offset to original value */
|
||||||
curwp->w_flag |= WFMOVE; /* Say we've moved */
|
curwp->w_flag |= WFMOVE; /* Say we've moved */
|
||||||
update(FALSE); /* And force an update */
|
update(FALSE); /* And force an update */
|
||||||
mlwrite ("(search failed)"); /* Say we died */
|
mlwrite("(search failed)"); /* Say we died */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
matchlen = strlen(pat);
|
matchlen = strlen(pat);
|
||||||
#endif
|
#endif
|
||||||
} else mlerase (); /* If happy, just erase the cmd line */
|
} else
|
||||||
|
mlerase(); /* If happy, just erase the cmd line */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
matchlen = strlen(pat);
|
matchlen = strlen(pat);
|
||||||
#endif
|
#endif
|
||||||
@ -151,14 +151,14 @@ isearch(f, n)
|
|||||||
cmd_reexecute = -1; /* We're not re-executing (yet?) */
|
cmd_reexecute = -1; /* We're not re-executing (yet?) */
|
||||||
cmd_offset = 0; /* Start at the beginning of the buff */
|
cmd_offset = 0; /* Start at the beginning of the buff */
|
||||||
cmd_buff[0] = '\0'; /* Init the command buffer */
|
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 */
|
curline = curwp->w_dotp; /* Save the current line pointer */
|
||||||
curoff = curwp->w_doto; /* Save the current offset */
|
curoff = curwp->w_doto; /* Save the current offset */
|
||||||
init_direction = n; /* Save the initial search direction */
|
init_direction = n; /* Save the initial search direction */
|
||||||
|
|
||||||
/* This is a good place to start a re-execution: */
|
/* This is a good place to start a re-execution: */
|
||||||
|
|
||||||
start_over:
|
start_over:
|
||||||
|
|
||||||
/* ask the user for the text of a pattern */
|
/* ask the user for the text of a pattern */
|
||||||
col = promptpattern("ISearch: "); /* Prompt, remember the col */
|
col = promptpattern("ISearch: "); /* Prompt, remember the col */
|
||||||
@ -172,15 +172,12 @@ start_over:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
c = ectoc(expc = get_char()); /* Get the first character */
|
c = ectoc(expc = get_char()); /* Get the first character */
|
||||||
if ((c == IS_FORWARD) ||
|
if ((c == IS_FORWARD) || (c == IS_REVERSE) || (c == IS_VMSFORW)) { /* Reuse old search string? */
|
||||||
(c == IS_REVERSE) ||
|
|
||||||
(c == IS_VMSFORW)) /* Reuse old search string? */
|
|
||||||
{
|
|
||||||
for (cpos = 0; pat[cpos] != 0; cpos++) /* Yup, find the length */
|
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? */
|
if (c == IS_REVERSE) { /* forward search? */
|
||||||
n = -1; /* No, search in reverse */
|
n = -1; /* No, search in reverse */
|
||||||
backchar (TRUE, 1); /* Be defensive about EOB */
|
backchar(TRUE, 1); /* Be defensive about EOB */
|
||||||
} else
|
} else
|
||||||
n = 1; /* Yes, search forward */
|
n = 1; /* Yes, search forward */
|
||||||
status = scanmore(pat, n); /* Do the search */
|
status = scanmore(pat, n); /* Do the search */
|
||||||
@ -189,18 +186,16 @@ start_over:
|
|||||||
|
|
||||||
/* Top of the per character loop */
|
/* Top of the per character loop */
|
||||||
|
|
||||||
for (;;) /* ISearch per character loop */
|
for (;;) { /* ISearch per character loop */
|
||||||
{
|
|
||||||
/* Check for special characters first: */
|
/* Check for special characters first: */
|
||||||
/* Most cases here change the search */
|
/* Most cases here change the search */
|
||||||
|
|
||||||
if (expc == metac) /* Want to quit searching? */
|
if (expc == metac) /* Want to quit searching? */
|
||||||
return (TRUE); /* Quit searching now */
|
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 */
|
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_REVERSE: /* If backward search */
|
||||||
case IS_FORWARD: /* If forward search */
|
case IS_FORWARD: /* If forward search */
|
||||||
@ -211,7 +206,7 @@ start_over:
|
|||||||
n = 1; /* go forward */
|
n = 1; /* go forward */
|
||||||
status = scanmore(pat, n); /* Start the search again */
|
status = scanmore(pat, n); /* Start the search again */
|
||||||
c = ectoc(expc = get_char()); /* Get the next char */
|
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 */
|
case IS_NEWLINE: /* Carriage return */
|
||||||
c = '\n'; /* Make it a new line */
|
c = '\n'; /* Make it a new line */
|
||||||
@ -234,16 +229,15 @@ start_over:
|
|||||||
curwp->w_dotp = curline; /* Reset the line pointer */
|
curwp->w_dotp = curline; /* Reset the line pointer */
|
||||||
curwp->w_doto = curoff; /* and the offset */
|
curwp->w_doto = curoff; /* and the offset */
|
||||||
n = init_direction; /* Reset the search direction */
|
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 */
|
cmd_reexecute = 0; /* Start the whole mess over */
|
||||||
goto start_over; /* Let it take care of itself */
|
goto start_over; /* Let it take care of itself */
|
||||||
|
|
||||||
/* Presumably a quasi-normal character comes here */
|
/* Presumably a quasi-normal character comes here */
|
||||||
|
|
||||||
default: /* All other chars */
|
default: /* All other chars */
|
||||||
if (c < ' ') /* Is it printable? */
|
if (c < ' ') { /* Is it printable? *//* Nope. */
|
||||||
{ /* Nope. */
|
reeat(c); /* Re-eat the char */
|
||||||
reeat (c); /* Re-eat the char */
|
|
||||||
return (TRUE); /* And return the last status */
|
return (TRUE); /* And return the last status */
|
||||||
}
|
}
|
||||||
} /* Switch */
|
} /* Switch */
|
||||||
@ -251,18 +245,16 @@ start_over:
|
|||||||
/* I guess we got something to search for, so search for it */
|
/* I guess we got something to search for, so search for it */
|
||||||
|
|
||||||
pat[cpos++] = c; /* put the char in the buffer */
|
pat[cpos++] = c; /* put the char in the buffer */
|
||||||
if (cpos >= NPAT) /* too many chars in string? */
|
if (cpos >= NPAT) { /* too many chars in string? *//* Yup. Complain about it */
|
||||||
{ /* Yup. Complain about it */
|
|
||||||
mlwrite("? Search string too long");
|
mlwrite("? Search string too long");
|
||||||
return(TRUE); /* Return an error */
|
return (TRUE); /* Return an error */
|
||||||
}
|
}
|
||||||
pat[cpos] = 0; /* null terminate the buffer */
|
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 */
|
if (!status) { /* If we lost last time */
|
||||||
TTputc(BELL); /* Feep again */
|
TTputc(BELL); /* Feep again */
|
||||||
TTflush(); /* see that the feep feeps */
|
TTflush(); /* see that the feep feeps */
|
||||||
} else /* Otherwise, we must have won*/
|
} else /* Otherwise, we must have won */ if (!(status = checknext(c, pat, n))) /* See if match */
|
||||||
if (!(status = checknext(c, pat, n))) /* See if match */
|
|
||||||
status = scanmore(pat, n); /* or find the next match */
|
status = scanmore(pat, n); /* or find the next match */
|
||||||
c = ectoc(expc = get_char()); /* Get the next char */
|
c = ectoc(expc = get_char()); /* Get the next char */
|
||||||
} /* for {;;} */
|
} /* for {;;} */
|
||||||
@ -279,7 +271,7 @@ start_over:
|
|||||||
* scanmore or something.
|
* 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 chr; /* Next char to look for */
|
||||||
char *patrn; /* The entire search string (incl chr) */
|
char *patrn; /* The entire search string (incl chr) */
|
||||||
int dir; /* Search direction */
|
int dir; /* Search direction */
|
||||||
@ -295,10 +287,8 @@ int dir; /* Search direction */
|
|||||||
curline = curwp->w_dotp; /* Get the current line structure */
|
curline = curwp->w_dotp; /* Get the current line structure */
|
||||||
curoff = curwp->w_doto; /* Get the offset within that line */
|
curoff = curwp->w_doto; /* Get the offset within that line */
|
||||||
|
|
||||||
if (dir > 0) /* If searching forward */
|
if (dir > 0) { /* If searching forward */
|
||||||
{
|
if (curoff == llength(curline)) { /* If at end of line */
|
||||||
if (curoff == llength(curline)) /* If at end of line */
|
|
||||||
{
|
|
||||||
curline = lforw(curline); /* Skip to the next line */
|
curline = lforw(curline); /* Skip to the next line */
|
||||||
if (curline == curbp->b_linep)
|
if (curline == curbp->b_linep)
|
||||||
return (FALSE); /* Abort if at end of buffer */
|
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 */
|
buffchar = '\n'; /* And say the next char is NL */
|
||||||
} else
|
} else
|
||||||
buffchar = lgetc(curline, curoff++); /* Get the next char */
|
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_dotp = curline; /* Yes, set the buffer's point */
|
||||||
curwp->w_doto = curoff; /* to the matched character */
|
curwp->w_doto = curoff; /* to the matched character */
|
||||||
curwp->w_flag |= WFMOVE; /* Say that we've moved */
|
curwp->w_flag |= WFMOVE; /* Say that we've moved */
|
||||||
}
|
}
|
||||||
return (status); /* And return the status */
|
return (status); /* And return the status */
|
||||||
} else /* Else, if reverse search: */
|
} 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 */
|
int sts; /* search status */
|
||||||
|
|
||||||
if (dir < 0) /* reverse search? */
|
if (dir < 0) { /* reverse search? */
|
||||||
{
|
|
||||||
rvstrcpy(tap, patrn); /* Put reversed string in tap */
|
rvstrcpy(tap, patrn); /* Put reversed string in tap */
|
||||||
sts = scanner(tap, REVERSE, PTBEG);
|
sts = scanner(tap, REVERSE, PTBEG);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
sts = scanner(patrn, FORWARD, PTEND); /* Nope. Go forward */
|
sts = scanner(patrn, FORWARD, PTEND); /* Nope. Go forward */
|
||||||
|
|
||||||
if (!sts)
|
if (!sts) {
|
||||||
{
|
|
||||||
TTputc(BELL); /* Feep if search fails */
|
TTputc(BELL); /* Feep if search fails */
|
||||||
TTflush(); /* see that the feep feeps */
|
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.
|
* 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 */
|
char *patrn; /* String to match to buffer */
|
||||||
{
|
{
|
||||||
register int i; /* Generic loop index/offset */
|
register int i; /* Generic loop index/offset */
|
||||||
@ -375,10 +361,8 @@ char *patrn; /* String to match to buffer */
|
|||||||
|
|
||||||
/* top of per character compare loop: */
|
/* top of per character compare loop: */
|
||||||
|
|
||||||
for (i = 0; i < strlen(patrn); i++) /* Loop for all characters in patrn */
|
for (i = 0; i < strlen(patrn); i++) { /* Loop for all characters in patrn */
|
||||||
{
|
if (curoff == llength(curline)) { /* If at end of line */
|
||||||
if (curoff == llength(curline)) /* If at end of line */
|
|
||||||
{
|
|
||||||
curline = lforw(curline); /* Skip to the next line */
|
curline = lforw(curline); /* Skip to the next line */
|
||||||
curoff = 0; /* Start at the beginning of the line */
|
curoff = 0; /* Start at the beginning of the line */
|
||||||
if (curline == curbp->b_linep)
|
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? */
|
if (!eq(buffchar, patrn[i])) /* Is it what we're looking for? */
|
||||||
return (FALSE); /* Nope, just punt it then */
|
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. */
|
/* Routine to prompt for I-Search string. */
|
||||||
@ -397,31 +381,29 @@ char *patrn; /* String to match to buffer */
|
|||||||
int promptpattern(prompt)
|
int promptpattern(prompt)
|
||||||
char *prompt;
|
char *prompt;
|
||||||
{
|
{
|
||||||
char tpat[NPAT+20];
|
char tpat[NPAT + 20];
|
||||||
|
|
||||||
strcpy(tpat, prompt); /* copy prompt to output string */
|
strcpy(tpat, prompt); /* copy prompt to output string */
|
||||||
strcat(tpat, " ("); /* build new prompt 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>: ");
|
strcat(tpat, ")<Meta>: ");
|
||||||
|
|
||||||
/* check to see if we are executing a command line */
|
/* check to see if we are executing a command line */
|
||||||
if (!clexec) {
|
if (!clexec) {
|
||||||
mlwrite(tpat);
|
mlwrite(tpat);
|
||||||
}
|
}
|
||||||
return(strlen(tpat));
|
return (strlen(tpat));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* routine to echo i-search characters */
|
/* routine to echo i-search characters */
|
||||||
|
|
||||||
int echochar(c,col)
|
int echochar(c, col)
|
||||||
int c; /* character to be echoed */
|
int c; /* character to be echoed */
|
||||||
int col; /* column to be echoed in */
|
int col; /* column to be echoed in */
|
||||||
{
|
{
|
||||||
movecursor(term.t_nrow,col); /* Position the cursor */
|
movecursor(term.t_nrow, col); /* Position the cursor */
|
||||||
if ((c < ' ') || (c == 0x7F)) /* Control character? */
|
if ((c < ' ') || (c == 0x7F)) { /* Control character? */
|
||||||
{
|
switch (c) { /* Yes, dispatch special cases */
|
||||||
switch (c) /* Yes, dispatch special cases*/
|
|
||||||
{
|
|
||||||
case '\n': /* Newline */
|
case '\n': /* Newline */
|
||||||
TTputc('<');
|
TTputc('<');
|
||||||
TTputc('N');
|
TTputc('N');
|
||||||
@ -447,13 +429,13 @@ int col; /* column to be echoed in */
|
|||||||
|
|
||||||
default: /* Vanilla control char */
|
default: /* Vanilla control char */
|
||||||
TTputc('^'); /* Yes, output prefix */
|
TTputc('^'); /* Yes, output prefix */
|
||||||
TTputc(c+0x40); /* Make it "^X" */
|
TTputc(c + 0x40); /* Make it "^X" */
|
||||||
col++; /* Count this char */
|
col++; /* Count this char */
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
TTputc(c); /* Otherwise, output raw char */
|
TTputc(c); /* Otherwise, output raw char */
|
||||||
TTflush(); /* Flush the output */
|
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.
|
* next character.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int get_char ()
|
int get_char()
|
||||||
{
|
{
|
||||||
int c; /* A place to get a character */
|
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 */
|
cmd_reexecute = -1; /* Say we're in real mode again */
|
||||||
update(FALSE); /* Pretty up the screen */
|
update(FALSE); /* Pretty up the screen */
|
||||||
if (cmd_offset >= CMDBUFLEN-1) /* If we're getting too big ... */
|
if (cmd_offset >= CMDBUFLEN - 1) { /* If we're getting too big ... */
|
||||||
{
|
mlwrite("? command too long"); /* Complain loudly and bitterly */
|
||||||
mlwrite ("? command too long"); /* Complain loudly and bitterly */
|
|
||||||
return (metac); /* And force a quit */
|
return (metac); /* And force a quit */
|
||||||
}
|
}
|
||||||
c = get1key(); /* Get the next character */
|
c = get1key(); /* Get the next character */
|
||||||
cmd_buff[cmd_offset++] = c; /* Save the char for next time */
|
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 */
|
return (c); /* Return the character */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,14 +483,14 @@ int uneat()
|
|||||||
term.t_getchar = saved_get_char; /* restore the routine address */
|
term.t_getchar = saved_get_char; /* restore the routine address */
|
||||||
c = eaten_char; /* Get the re-eaten char */
|
c = eaten_char; /* Get the re-eaten char */
|
||||||
eaten_char = -1; /* Clear the old 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 reeat(c)
|
||||||
int c;
|
int c;
|
||||||
{
|
{
|
||||||
if (eaten_char != -1) /* If we've already been here */
|
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 */
|
eaten_char = c; /* Else, save the char for later */
|
||||||
saved_get_char = term.t_getchar; /* Save the char get routine */
|
saved_get_char = term.t_getchar; /* Save the char get routine */
|
||||||
term.t_getchar = uneat; /* Replace it with ours */
|
term.t_getchar = uneat; /* Replace it with ours */
|
||||||
|
98
line.c
98
line.c
@ -35,10 +35,10 @@ register int used;
|
|||||||
register int size;
|
register int size;
|
||||||
char *malloc();
|
char *malloc();
|
||||||
|
|
||||||
size = (used+NBLOCK-1) & ~(NBLOCK-1);
|
size = (used + NBLOCK - 1) & ~(NBLOCK - 1);
|
||||||
if (size == 0) /* Assume that an empty */
|
if (size == 0) /* Assume that an empty */
|
||||||
size = NBLOCK; /* line is for type-in. */
|
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)");
|
mlwrite("(OUT OF MEMORY)");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ register int flag;
|
|||||||
|
|
||||||
if (curbp->b_nwnd != 1) /* Ensure hard. */
|
if (curbp->b_nwnd != 1) /* Ensure hard. */
|
||||||
flag = WFHARD;
|
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. */
|
flag |= WFMODE; /* update mode lines. */
|
||||||
curbp->b_flag |= BFCHG;
|
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 */
|
int f, n; /* default flag and numeric argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -139,7 +139,8 @@ char *instr;
|
|||||||
|
|
||||||
if (instr != NULL)
|
if (instr != NULL)
|
||||||
while ((tmpc = *instr) && status == TRUE) {
|
while ((tmpc = *instr) && status == TRUE) {
|
||||||
status = (tmpc == '\n'? lnewline(): linsert(1, tmpc));
|
status =
|
||||||
|
(tmpc == '\n' ? lnewline() : linsert(1, tmpc));
|
||||||
|
|
||||||
/* Insertion error? */
|
/* Insertion error? */
|
||||||
if (status != TRUE) {
|
if (status != TRUE) {
|
||||||
@ -148,7 +149,7 @@ char *instr;
|
|||||||
}
|
}
|
||||||
instr++;
|
instr++;
|
||||||
}
|
}
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -172,8 +173,8 @@ linsert(n, c)
|
|||||||
register int i;
|
register int i;
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
lchange(WFEDIT);
|
lchange(WFEDIT);
|
||||||
lp1 = curwp->w_dotp; /* Current line */
|
lp1 = curwp->w_dotp; /* Current line */
|
||||||
if (lp1 == curbp->b_linep) { /* At the end: special */
|
if (lp1 == curbp->b_linep) { /* At the end: special */
|
||||||
@ -181,22 +182,22 @@ linsert(n, c)
|
|||||||
mlwrite("bug: linsert");
|
mlwrite("bug: linsert");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if ((lp2=lalloc(n)) == NULL) /* Allocate new line */
|
if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
lp3 = lp1->l_bp; /* Previous line */
|
lp3 = lp1->l_bp; /* Previous line */
|
||||||
lp3->l_fp = lp2; /* Link in */
|
lp3->l_fp = lp2; /* Link in */
|
||||||
lp2->l_fp = lp1;
|
lp2->l_fp = lp1;
|
||||||
lp1->l_bp = lp2;
|
lp1->l_bp = lp2;
|
||||||
lp2->l_bp = lp3;
|
lp2->l_bp = lp3;
|
||||||
for (i=0; i<n; ++i)
|
for (i = 0; i < n; ++i)
|
||||||
lp2->l_text[i] = c;
|
lp2->l_text[i] = c;
|
||||||
curwp->w_dotp = lp2;
|
curwp->w_dotp = lp2;
|
||||||
curwp->w_doto = n;
|
curwp->w_doto = n;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
doto = curwp->w_doto; /* Save for later. */
|
doto = curwp->w_doto; /* Save for later. */
|
||||||
if (lp1->l_used+n > lp1->l_size) { /* Hard: reallocate */
|
if (lp1->l_used + n > lp1->l_size) { /* Hard: reallocate */
|
||||||
if ((lp2=lalloc(lp1->l_used+n)) == NULL)
|
if ((lp2 = lalloc(lp1->l_used + n)) == NULL)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
cp1 = &lp1->l_text[0];
|
cp1 = &lp1->l_text[0];
|
||||||
cp2 = &lp2->l_text[0];
|
cp2 = &lp2->l_text[0];
|
||||||
@ -214,19 +215,19 @@ linsert(n, c)
|
|||||||
lp2 = lp1; /* Pretend new line */
|
lp2 = lp1; /* Pretend new line */
|
||||||
lp2->l_used += n;
|
lp2->l_used += n;
|
||||||
cp2 = &lp1->l_text[lp1->l_used];
|
cp2 = &lp1->l_text[lp1->l_used];
|
||||||
cp1 = cp2-n;
|
cp1 = cp2 - n;
|
||||||
while (cp1 != &lp1->l_text[doto])
|
while (cp1 != &lp1->l_text[doto])
|
||||||
*--cp2 = *--cp1;
|
*--cp2 = *--cp1;
|
||||||
}
|
}
|
||||||
for (i=0; i<n; ++i) /* Add the characters */
|
for (i = 0; i < n; ++i) /* Add the characters */
|
||||||
lp2->l_text[doto+i] = c;
|
lp2->l_text[doto + i] = c;
|
||||||
wp = wheadp; /* Update windows */
|
wp = wheadp; /* Update windows */
|
||||||
while (wp != NULL) {
|
while (wp != NULL) {
|
||||||
if (wp->w_linep == lp1)
|
if (wp->w_linep == lp1)
|
||||||
wp->w_linep = lp2;
|
wp->w_linep = lp2;
|
||||||
if (wp->w_dotp == lp1) {
|
if (wp->w_dotp == lp1) {
|
||||||
wp->w_dotp = lp2;
|
wp->w_dotp = lp2;
|
||||||
if (wp==curwp || wp->w_doto>doto)
|
if (wp == curwp || wp->w_doto > doto)
|
||||||
wp->w_doto += n;
|
wp->w_doto += n;
|
||||||
}
|
}
|
||||||
if (wp->w_markp == lp1) {
|
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' ||
|
(lgetc(curwp->w_dotp, curwp->w_doto) != '\t' ||
|
||||||
((curwp->w_doto) & tabmask) == tabmask))
|
((curwp->w_doto) & tabmask) == tabmask))
|
||||||
ldelete(1L, FALSE);
|
ldelete(1L, FALSE);
|
||||||
return(linsert(1, c));
|
return (linsert(1, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -270,16 +271,18 @@ char *ostr;
|
|||||||
|
|
||||||
if (ostr != NULL)
|
if (ostr != NULL)
|
||||||
while ((tmpc = *ostr) && status == TRUE) {
|
while ((tmpc = *ostr) && status == TRUE) {
|
||||||
status = (tmpc == '\n'? lnewline(): lowrite(tmpc));
|
status =
|
||||||
|
(tmpc == '\n' ? lnewline() : lowrite(tmpc));
|
||||||
|
|
||||||
/* Insertion error? */
|
/* Insertion error? */
|
||||||
if (status != TRUE) {
|
if (status != TRUE) {
|
||||||
mlwrite("%%Out of memory while overwriting");
|
mlwrite
|
||||||
|
("%%Out of memory while overwriting");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ostr++;
|
ostr++;
|
||||||
}
|
}
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -299,16 +302,16 @@ lnewline()
|
|||||||
register int doto;
|
register int doto;
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
lchange(WFHARD|WFINS);
|
lchange(WFHARD | WFINS);
|
||||||
#else
|
#else
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
#endif
|
#endif
|
||||||
lp1 = curwp->w_dotp; /* Get the address and */
|
lp1 = curwp->w_dotp; /* Get the address and */
|
||||||
doto = curwp->w_doto; /* offset of "." */
|
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);
|
return (FALSE);
|
||||||
cp1 = &lp1->l_text[0]; /* Shuffle text around */
|
cp1 = &lp1->l_text[0]; /* Shuffle text around */
|
||||||
cp2 = &lp2->l_text[0];
|
cp2 = &lp2->l_text[0];
|
||||||
@ -362,24 +365,24 @@ int kflag; /* put killed text in kill buffer flag */
|
|||||||
register int chunk;
|
register int chunk;
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
while (n != 0) {
|
while (n != 0) {
|
||||||
dotp = curwp->w_dotp;
|
dotp = curwp->w_dotp;
|
||||||
doto = curwp->w_doto;
|
doto = curwp->w_doto;
|
||||||
if (dotp == curbp->b_linep) /* Hit end of buffer. */
|
if (dotp == curbp->b_linep) /* Hit end of buffer. */
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
chunk = dotp->l_used-doto; /* Size of chunk. */
|
chunk = dotp->l_used - doto; /* Size of chunk. */
|
||||||
if (chunk > n)
|
if (chunk > n)
|
||||||
chunk = n;
|
chunk = n;
|
||||||
if (chunk == 0) { /* End of line, merge. */
|
if (chunk == 0) { /* End of line, merge. */
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
lchange(WFHARD|WFKILLS);
|
lchange(WFHARD | WFKILLS);
|
||||||
#else
|
#else
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
#endif
|
#endif
|
||||||
if (ldelnewline() == FALSE
|
if (ldelnewline() == FALSE
|
||||||
|| (kflag!=FALSE && kinsert('\n')==FALSE))
|
|| (kflag != FALSE && kinsert('\n') == FALSE))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
--n;
|
--n;
|
||||||
continue;
|
continue;
|
||||||
@ -400,12 +403,12 @@ int kflag; /* put killed text in kill buffer flag */
|
|||||||
dotp->l_used -= chunk;
|
dotp->l_used -= chunk;
|
||||||
wp = wheadp; /* Fix windows */
|
wp = wheadp; /* Fix windows */
|
||||||
while (wp != NULL) {
|
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;
|
wp->w_doto -= chunk;
|
||||||
if (wp->w_doto < doto)
|
if (wp->w_doto < doto)
|
||||||
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;
|
wp->w_marko -= chunk;
|
||||||
if (wp->w_marko < doto)
|
if (wp->w_marko < doto)
|
||||||
wp->w_marko = doto;
|
wp->w_marko = doto;
|
||||||
@ -422,7 +425,6 @@ int kflag; /* put killed text in kill buffer flag */
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
char *getctext()
|
char *getctext()
|
||||||
|
|
||||||
{
|
{
|
||||||
register LINE *lp; /* line to copy */
|
register LINE *lp; /* line to copy */
|
||||||
register int size; /* length of line to return */
|
register int size; /* length of line to return */
|
||||||
@ -442,7 +444,7 @@ char *getctext()
|
|||||||
while (size--)
|
while (size--)
|
||||||
*dp++ = *sp++;
|
*dp++ = *sp++;
|
||||||
*dp = 0;
|
*dp = 0;
|
||||||
return(rline);
|
return (rline);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* putctext: replace the current line with the passed in text */
|
/* putctext: replace the current line with the passed in text */
|
||||||
@ -457,14 +459,14 @@ char *iline; /* contents of new line */
|
|||||||
/* delete the current line */
|
/* delete the current line */
|
||||||
curwp->w_doto = 0; /* starting at the beginning of the line */
|
curwp->w_doto = 0; /* starting at the beginning of the line */
|
||||||
if ((status = killtext(TRUE, 1)) != TRUE)
|
if ((status = killtext(TRUE, 1)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
/* insert the new line */
|
/* insert the new line */
|
||||||
if ((status = linstr(iline)) != TRUE)
|
if ((status = linstr(iline)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
status = lnewline();
|
status = lnewline();
|
||||||
backline(TRUE, 1);
|
backline(TRUE, 1);
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -485,8 +487,8 @@ ldelnewline()
|
|||||||
register LINE *lp3;
|
register LINE *lp3;
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
lp1 = curwp->w_dotp;
|
lp1 = curwp->w_dotp;
|
||||||
lp2 = lp1->l_fp;
|
lp2 = lp1->l_fp;
|
||||||
if (lp2 == curbp->b_linep) { /* At the buffer end. */
|
if (lp2 == curbp->b_linep) { /* At the buffer end. */
|
||||||
@ -494,7 +496,7 @@ ldelnewline()
|
|||||||
lfree(lp1);
|
lfree(lp1);
|
||||||
return (TRUE);
|
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];
|
cp1 = &lp1->l_text[lp1->l_used];
|
||||||
cp2 = &lp2->l_text[0];
|
cp2 = &lp2->l_text[0];
|
||||||
while (cp2 != &lp2->l_text[lp2->l_used])
|
while (cp2 != &lp2->l_text[lp2->l_used])
|
||||||
@ -519,7 +521,7 @@ ldelnewline()
|
|||||||
free((char *) lp2);
|
free((char *) lp2);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
if ((lp3=lalloc(lp1->l_used+lp2->l_used)) == NULL)
|
if ((lp3 = lalloc(lp1->l_used + lp2->l_used)) == NULL)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
cp1 = &lp1->l_text[0];
|
cp1 = &lp1->l_text[0];
|
||||||
cp2 = &lp3->l_text[0];
|
cp2 = &lp3->l_text[0];
|
||||||
@ -534,7 +536,7 @@ ldelnewline()
|
|||||||
lp3->l_bp = lp1->l_bp;
|
lp3->l_bp = lp1->l_bp;
|
||||||
wp = wheadp;
|
wp = wheadp;
|
||||||
while (wp != NULL) {
|
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;
|
wp->w_linep = lp3;
|
||||||
if (wp->w_dotp == lp1)
|
if (wp->w_dotp == lp1)
|
||||||
wp->w_dotp = lp3;
|
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 */
|
/* check to see if we need a new chunk */
|
||||||
if (kused >= KBLOCK) {
|
if (kused >= KBLOCK) {
|
||||||
if ((nchunk = (KILL *)malloc(sizeof(KILL))) == NULL)
|
if ((nchunk = (KILL *) malloc(sizeof(KILL))) == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
if (kbufh == NULL) /* set head ptr if first time */
|
if (kbufh == NULL) /* set head ptr if first time */
|
||||||
kbufh = nchunk;
|
kbufh = nchunk;
|
||||||
if (kbufp != NULL) /* point the current to this new one */
|
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 */
|
/* and now insert the character */
|
||||||
kbufp->d_chunk[kused++] = c;
|
kbufp->d_chunk[kused++] = c;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -622,13 +624,13 @@ yank(f, n)
|
|||||||
register char *sp; /* pointer into string to insert */
|
register char *sp; /* pointer into string to insert */
|
||||||
KILL *kp; /* pointer into kill buffer */
|
KILL *kp; /* pointer into kill buffer */
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
/* make sure there is something to yank */
|
/* make sure there is something to yank */
|
||||||
if (kbufh == NULL)
|
if (kbufh == NULL)
|
||||||
return(TRUE); /* not an error, just nothing */
|
return (TRUE); /* not an error, just nothing */
|
||||||
|
|
||||||
/* for each time.... */
|
/* for each time.... */
|
||||||
while (n--) {
|
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 */
|
/* check to see if that file is already locked here */
|
||||||
if (numlocks > 0)
|
if (numlocks > 0)
|
||||||
for (i=0; i < numlocks; ++i)
|
for (i = 0; i < numlocks; ++i)
|
||||||
if (strcmp(fname, lname[i]) == 0)
|
if (strcmp(fname, lname[i]) == 0)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* if we have a full locking table, bitch and leave */
|
/* if we have a full locking table, bitch and leave */
|
||||||
if (numlocks == NLOCKS) {
|
if (numlocks == NLOCKS) {
|
||||||
mlwrite("LOCK ERROR: Lock table full");
|
mlwrite("LOCK ERROR: Lock table full");
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* next, try to lock it */
|
/* next, try to lock it */
|
||||||
status = lock(fname);
|
status = lock(fname);
|
||||||
if (status == ABORT) /* file is locked, no override */
|
if (status == ABORT) /* file is locked, no override */
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
if (status == FALSE) /* locked, overriden, dont add to table */
|
if (status == FALSE) /* locked, overriden, dont add to table */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* we have now locked it, add it to our table */
|
/* 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 */
|
if (lname[numlocks - 1] == NULL) { /* malloc failure */
|
||||||
undolock(fname); /* free the lock */
|
undolock(fname); /* free the lock */
|
||||||
mlwrite("Cannot lock, out of memory");
|
mlwrite("Cannot lock, out of memory");
|
||||||
--numlocks;
|
--numlocks;
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* everthing is cool, add it to the table */
|
/* everthing is cool, add it to the table */
|
||||||
strcpy(lname[numlocks-1], fname);
|
strcpy(lname[numlocks - 1], fname);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lockrel: release all the file locks so others may edit */
|
/* lockrel: release all the file locks so others may edit */
|
||||||
|
|
||||||
lockrel()
|
lockrel()
|
||||||
|
|
||||||
{
|
{
|
||||||
register int i; /* loop index */
|
register int i; /* loop index */
|
||||||
register int status; /* status of locks */
|
register int status; /* status of locks */
|
||||||
@ -74,13 +73,13 @@ lockrel()
|
|||||||
|
|
||||||
status = TRUE;
|
status = TRUE;
|
||||||
if (numlocks > 0)
|
if (numlocks > 0)
|
||||||
for (i=0; i < numlocks; ++i) {
|
for (i = 0; i < numlocks; ++i) {
|
||||||
if ((s = unlock(lname[i])) != TRUE)
|
if ((s = unlock(lname[i])) != TRUE)
|
||||||
status = s;
|
status = s;
|
||||||
free(lname[i]);
|
free(lname[i]);
|
||||||
}
|
}
|
||||||
numlocks = 0;
|
numlocks = 0;
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lock: Check and lock a file from access by others
|
/* 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 */
|
/* attempt to lock the file */
|
||||||
locker = dolock(fname);
|
locker = dolock(fname);
|
||||||
if (locker == NULL) /* we win */
|
if (locker == NULL) /* we win */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* file failed...abort */
|
/* file failed...abort */
|
||||||
if (strncmp(locker, "LOCK", 4) == 0) {
|
if (strncmp(locker, "LOCK", 4) == 0) {
|
||||||
lckerror(locker);
|
lckerror(locker);
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* someone else has it....override? */
|
/* someone else has it....override? */
|
||||||
@ -116,9 +115,9 @@ char *fname; /* file name to lock */
|
|||||||
strcat(msg, ", override?");
|
strcat(msg, ", override?");
|
||||||
status = mlyesno(msg); /* ask them */
|
status = mlyesno(msg); /* ask them */
|
||||||
if (status == TRUE)
|
if (status == TRUE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
else
|
else
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* unlock: Unlock a file
|
/* unlock: Unlock a file
|
||||||
@ -136,15 +135,15 @@ char *fname; /* file to unlock */
|
|||||||
/* unclock and return */
|
/* unclock and return */
|
||||||
locker = undolock(fname);
|
locker = undolock(fname);
|
||||||
if (locker == NULL)
|
if (locker == NULL)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* report the error and come back */
|
/* report the error and come back */
|
||||||
lckerror(locker);
|
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 */
|
char *errstr; /* lock error string to print out */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -160,7 +159,7 @@ char *errstr; /* lock error string to print out */
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
lckhello() /* dummy function */
|
lckhello()
|
||||||
{
|
{ /* dummy function */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
149
main.c
149
main.c
@ -84,7 +84,7 @@ extern unsigned _stklen = 32766;
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
static void emergencyexit();
|
static void emergencyexit();
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
extern void sizesignal();
|
extern void sizesignal();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -122,8 +122,8 @@ char *argv[]; /* argument strings */
|
|||||||
extern *pathname[]; /* startup file path/name array */
|
extern *pathname[]; /* startup file path/name array */
|
||||||
int newc;
|
int newc;
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
int (*getbind())();
|
int (*getbind()) ();
|
||||||
int (*execfunc)(); /* ptr to function to execute */
|
int (*execfunc) (); /* ptr to function to execute */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PKCODE & VMS
|
#if PKCODE & VMS
|
||||||
@ -204,7 +204,7 @@ char *argv[]; /* argument strings */
|
|||||||
case 's': /* -s for initial search string */
|
case 's': /* -s for initial search string */
|
||||||
case 'S':
|
case 'S':
|
||||||
searchflag = TRUE;
|
searchflag = TRUE;
|
||||||
strncpy(pat,&argv[carg][2],NPAT);
|
strncpy(pat, &argv[carg][2], NPAT);
|
||||||
break;
|
break;
|
||||||
case 'v': /* -v for View File */
|
case 'v': /* -v for View File */
|
||||||
case 'V':
|
case 'V':
|
||||||
@ -215,7 +215,7 @@ char *argv[]; /* argument strings */
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (argv[carg][0]== '@') {
|
} else if (argv[carg][0] == '@') {
|
||||||
|
|
||||||
/* Process Startup macroes */
|
/* Process Startup macroes */
|
||||||
if (startup(&argv[carg][1]) == TRUE)
|
if (startup(&argv[carg][1]) == TRUE)
|
||||||
@ -245,7 +245,7 @@ char *argv[]; /* argument strings */
|
|||||||
#if CRYPT
|
#if CRYPT
|
||||||
if (cryptflag) {
|
if (cryptflag) {
|
||||||
bp->b_mode |= MDCRYPT;
|
bp->b_mode |= MDCRYPT;
|
||||||
crypt((char *)NULL, 0);
|
crypt((char *) NULL, 0);
|
||||||
crypt(ekey, strlen(ekey));
|
crypt(ekey, strlen(ekey));
|
||||||
strncpy(bp->b_key, ekey, NPAT);
|
strncpy(bp->b_key, ekey, NPAT);
|
||||||
}
|
}
|
||||||
@ -284,9 +284,8 @@ char *argv[]; /* argument strings */
|
|||||||
if (gotoflag && searchflag) {
|
if (gotoflag && searchflag) {
|
||||||
update(FALSE);
|
update(FALSE);
|
||||||
mlwrite("(Can not search and goto at the same time!)");
|
mlwrite("(Can not search and goto at the same time!)");
|
||||||
}
|
} else if (gotoflag) {
|
||||||
else if (gotoflag) {
|
if (gotoline(TRUE, gline) == FALSE) {
|
||||||
if (gotoline(TRUE,gline) == FALSE) {
|
|
||||||
update(FALSE);
|
update(FALSE);
|
||||||
mlwrite("(Bogus goto argument)");
|
mlwrite("(Bogus goto argument)");
|
||||||
}
|
}
|
||||||
@ -298,37 +297,32 @@ char *argv[]; /* argument strings */
|
|||||||
/* setup to process commands */
|
/* setup to process commands */
|
||||||
lastflag = 0; /* Fake last flags. */
|
lastflag = 0; /* Fake last flags. */
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
|
||||||
#if CALLED
|
#if CALLED
|
||||||
/* if we were called as a subroutine and want to leave, do so */
|
/* if we were called as a subroutine and want to leave, do so */
|
||||||
if (eexitflag)
|
if (eexitflag)
|
||||||
return(eexitval);
|
return (eexitval);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* execute the "command" macro...normally null */
|
/* execute the "command" macro...normally null */
|
||||||
saveflag = lastflag; /* preserve lastflag through this */
|
saveflag = lastflag; /* preserve lastflag through this */
|
||||||
execute(META|SPEC|'C', FALSE, 1);
|
execute(META | SPEC | 'C', FALSE, 1);
|
||||||
lastflag = saveflag;
|
lastflag = saveflag;
|
||||||
|
|
||||||
#if TYPEAH && PKCODE
|
#if TYPEAH && PKCODE
|
||||||
if (typahead())
|
if (typahead()) {
|
||||||
{
|
|
||||||
newc = getcmd();
|
newc = getcmd();
|
||||||
update(FALSE);
|
update(FALSE);
|
||||||
do
|
do {
|
||||||
{
|
|
||||||
if (c == newc && (execfunc = getbind(c)) != NULL
|
if (c == newc && (execfunc = getbind(c)) != NULL
|
||||||
&& execfunc != newline
|
&& execfunc != newline && execfunc != tab)
|
||||||
&& execfunc != tab)
|
|
||||||
newc = getcmd();
|
newc = getcmd();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
} while (typahead());
|
} while (typahead());
|
||||||
c = newc;
|
c = newc;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
update(FALSE);
|
update(FALSE);
|
||||||
c = getcmd();
|
c = getcmd();
|
||||||
}
|
}
|
||||||
@ -371,7 +365,7 @@ loop:
|
|||||||
if ((n == 0) && (mflag == -1)) /* lonely - */
|
if ((n == 0) && (mflag == -1)) /* lonely - */
|
||||||
mlwrite("Arg:");
|
mlwrite("Arg:");
|
||||||
else
|
else
|
||||||
mlwrite("Arg: %d",n * mflag);
|
mlwrite("Arg: %d", n * mflag);
|
||||||
|
|
||||||
c = getcmd(); /* get the next key */
|
c = getcmd(); /* get the next key */
|
||||||
}
|
}
|
||||||
@ -385,10 +379,11 @@ loop:
|
|||||||
n = 4; /* with argument of 4 */
|
n = 4; /* with argument of 4 */
|
||||||
mflag = 0; /* that can be discarded. */
|
mflag = 0; /* that can be discarded. */
|
||||||
mlwrite("Arg: 4");
|
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 (c == reptc)
|
||||||
if ((n > 0) == ((n*4) > 0))
|
if ((n > 0) == ((n * 4) > 0))
|
||||||
n = n*4;
|
n = n * 4;
|
||||||
else
|
else
|
||||||
n = 1;
|
n = 1;
|
||||||
/*
|
/*
|
||||||
@ -410,9 +405,10 @@ loop:
|
|||||||
n = 0;
|
n = 0;
|
||||||
mflag = 1;
|
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
|
* Make arguments preceded by a minus sign negative and change
|
||||||
@ -445,7 +441,7 @@ char bname[];
|
|||||||
bp = bfind(bname, TRUE, 0); /* First buffer */
|
bp = bfind(bname, TRUE, 0); /* First buffer */
|
||||||
blistp = bfind("*List*", TRUE, BFINVS); /* Buffer list buffer */
|
blistp = bfind("*List*", TRUE, BFINVS); /* Buffer list buffer */
|
||||||
wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window */
|
wp = (WINDOW *) malloc(sizeof(WINDOW)); /* First window */
|
||||||
if (bp==NULL || wp==NULL || blistp==NULL)
|
if (bp == NULL || wp == NULL || blistp == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
curbp = bp; /* Make this current */
|
curbp = bp; /* Make this current */
|
||||||
wheadp = wp;
|
wheadp = wp;
|
||||||
@ -464,9 +460,9 @@ char bname[];
|
|||||||
wp->w_fcolor = gfcolor;
|
wp->w_fcolor = gfcolor;
|
||||||
wp->w_bcolor = gbcolor;
|
wp->w_bcolor = gbcolor;
|
||||||
#endif
|
#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_force = 0;
|
||||||
wp->w_flag = WFMODE|WFHARD; /* Full. */
|
wp->w_flag = WFMODE | WFHARD; /* Full. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -478,14 +474,14 @@ char bname[];
|
|||||||
execute(c, f, n)
|
execute(c, f, n)
|
||||||
{
|
{
|
||||||
register int status;
|
register int status;
|
||||||
int (*execfunc)(); /* ptr to function to execute */
|
int (*execfunc) (); /* ptr to function to execute */
|
||||||
int (*getbind())();
|
int (*getbind()) ();
|
||||||
|
|
||||||
/* if the keystroke is a bound function...do it */
|
/* if the keystroke is a bound function...do it */
|
||||||
execfunc = getbind(c);
|
execfunc = getbind(c);
|
||||||
if (execfunc != NULL) {
|
if (execfunc != NULL) {
|
||||||
thisflag = 0;
|
thisflag = 0;
|
||||||
status = (*execfunc)(f, n);
|
status = (*execfunc) (f, n);
|
||||||
lastflag = thisflag;
|
lastflag = thisflag;
|
||||||
return (status);
|
return (status);
|
||||||
}
|
}
|
||||||
@ -498,25 +494,25 @@ execute(c, f, n)
|
|||||||
if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 &&
|
if (c == ' ' && (curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 &&
|
||||||
n >= 0 && getccol(FALSE) > fillcol &&
|
n >= 0 && getccol(FALSE) > fillcol &&
|
||||||
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
||||||
execute(META|SPEC|'W', FALSE, 1);
|
execute(META | SPEC | 'W', FALSE, 1);
|
||||||
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
if ((c>=0x20 && c<=0x7E) /* Self inserting. */
|
if ((c >= 0x20 && c <= 0x7E) /* Self inserting. */
|
||||||
#if IBMPC
|
#if IBMPC
|
||||||
|| (c>=0x80 && c<=0xFE)) {
|
|| (c >= 0x80 && c <= 0xFE)) {
|
||||||
#else
|
#else
|
||||||
#if VMS || BSD || USG /* 8BIT P.K. */
|
#if VMS || BSD || USG /* 8BIT P.K. */
|
||||||
|| (c>=0xA0 && c<=0xFE)) {
|
|| (c >= 0xA0 && c <= 0xFE)) {
|
||||||
#else
|
#else
|
||||||
) {
|
) {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
if ((c>=0x20 && c<=0xFF)) { /* Self inserting. */
|
if ((c >= 0x20 && c <= 0xFF)) { /* Self inserting. */
|
||||||
#endif
|
#endif
|
||||||
if (n <= 0) { /* Fenceposts. */
|
if (n <= 0) { /* Fenceposts. */
|
||||||
lastflag = 0;
|
lastflag = 0;
|
||||||
return (n<0 ? FALSE : TRUE);
|
return (n < 0 ? FALSE : TRUE);
|
||||||
}
|
}
|
||||||
thisflag = 0; /* For the future. */
|
thisflag = 0; /* For the future. */
|
||||||
|
|
||||||
@ -576,24 +572,24 @@ quickexit(f, n)
|
|||||||
|
|
||||||
bp = bheadp;
|
bp = bheadp;
|
||||||
while (bp != NULL) {
|
while (bp != NULL) {
|
||||||
if ((bp->b_flag&BFCHG) != 0 /* Changed. */
|
if ((bp->b_flag & BFCHG) != 0 /* Changed. */
|
||||||
&& (bp->b_flag&BFTRUNC) == 0 /* Not truncated P.K. */
|
&& (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */
|
||||||
&& (bp->b_flag&BFINVS) == 0) { /* Real. */
|
&& (bp->b_flag & BFINVS) == 0) { /* Real. */
|
||||||
curbp = bp; /* make that buffer cur */
|
curbp = bp; /* make that buffer cur */
|
||||||
mlwrite("(Saving %s)",bp->b_fname);
|
mlwrite("(Saving %s)", bp->b_fname);
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
#else
|
#else
|
||||||
mlwrite("\n");
|
mlwrite("\n");
|
||||||
#endif
|
#endif
|
||||||
if ((status = filesave(f, n)) != TRUE) {
|
if ((status = filesave(f, n)) != TRUE) {
|
||||||
curbp = oldcb; /* restore curbp */
|
curbp = oldcb; /* restore curbp */
|
||||||
return(status);
|
return (status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bp = bp->b_bufp; /* on to the next buffer */
|
bp = bp->b_bufp; /* on to the next buffer */
|
||||||
}
|
}
|
||||||
quit(f, n); /* conditionally quit */
|
quit(f, n); /* conditionally quit */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emergencyexit(signr)
|
static void emergencyexit(signr)
|
||||||
@ -614,7 +610,8 @@ quit(f, n)
|
|||||||
if (f != FALSE /* Argument forces it. */
|
if (f != FALSE /* Argument forces it. */
|
||||||
|| anycb() == FALSE /* All buffers clean. */
|
|| anycb() == FALSE /* All buffers clean. */
|
||||||
/* User says it's OK. */
|
/* 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 (FILOCK && BSD) || SVR4
|
||||||
if (lockrel() != TRUE) {
|
if (lockrel() != TRUE) {
|
||||||
TTputc('\n');
|
TTputc('\n');
|
||||||
@ -631,7 +628,7 @@ quit(f, n)
|
|||||||
exit(GOOD);
|
exit(GOOD);
|
||||||
}
|
}
|
||||||
mlwrite("");
|
mlwrite("");
|
||||||
return(s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -643,7 +640,7 @@ ctlxlp(f, n)
|
|||||||
{
|
{
|
||||||
if (kbdmode != STOP) {
|
if (kbdmode != STOP) {
|
||||||
mlwrite("%%Macro already active");
|
mlwrite("%%Macro already active");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
mlwrite("(Start macro)");
|
mlwrite("(Start macro)");
|
||||||
kbdptr = &kbdm[0];
|
kbdptr = &kbdm[0];
|
||||||
@ -660,13 +657,13 @@ ctlxrp(f, n)
|
|||||||
{
|
{
|
||||||
if (kbdmode == STOP) {
|
if (kbdmode == STOP) {
|
||||||
mlwrite("%%Macro not active");
|
mlwrite("%%Macro not active");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if (kbdmode == RECORD) {
|
if (kbdmode == RECORD) {
|
||||||
mlwrite("(End macro)");
|
mlwrite("(End macro)");
|
||||||
kbdmode = STOP;
|
kbdmode = STOP;
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -678,14 +675,14 @@ ctlxe(f, n)
|
|||||||
{
|
{
|
||||||
if (kbdmode != STOP) {
|
if (kbdmode != STOP) {
|
||||||
mlwrite("%%Macro already active");
|
mlwrite("%%Macro already active");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
kbdrep = n; /* remember how many times to execute */
|
kbdrep = n; /* remember how many times to execute */
|
||||||
kbdmode = PLAY; /* start us in play mode */
|
kbdmode = PLAY; /* start us in play mode */
|
||||||
kbdptr = &kbdm[0]; /* at the beginning */
|
kbdptr = &kbdm[0]; /* at the beginning */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -698,43 +695,40 @@ ctrlg(f, n)
|
|||||||
TTbeep();
|
TTbeep();
|
||||||
kbdmode = STOP;
|
kbdmode = STOP;
|
||||||
mlwrite("(Aborted)");
|
mlwrite("(Aborted)");
|
||||||
return(ABORT);
|
return (ABORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tell the user that this command is illegal while we are in
|
/* tell the user that this command is illegal while we are in
|
||||||
VIEW (read-only) mode */
|
VIEW (read-only) mode */
|
||||||
|
|
||||||
rdonly()
|
rdonly()
|
||||||
|
|
||||||
{
|
{
|
||||||
TTbeep();
|
TTbeep();
|
||||||
mlwrite("(Key illegal in VIEW mode)");
|
mlwrite("(Key illegal in VIEW mode)");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
resterr()
|
resterr()
|
||||||
|
|
||||||
{
|
{
|
||||||
TTbeep();
|
TTbeep();
|
||||||
mlwrite("(That command is RESTRICTED)");
|
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 ****/
|
/***** Compiler specific Library functions ****/
|
||||||
@ -764,7 +758,7 @@ int maxlen; /* maximum length */
|
|||||||
*dptr = 0; /* orig */
|
*dptr = 0; /* orig */
|
||||||
/* if (maxlen > 0)
|
/* if (maxlen > 0)
|
||||||
*dptr = 0; */
|
*dptr = 0; */
|
||||||
return(dst);
|
return (dst);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -781,8 +775,8 @@ int maxlen; /* maximum length */
|
|||||||
#undef malloc
|
#undef malloc
|
||||||
#undef free
|
#undef free
|
||||||
|
|
||||||
char *allocate(nbytes) /* allocate nbytes and track */
|
char *allocate(nbytes)
|
||||||
|
/* allocate nbytes and track */
|
||||||
unsigned nbytes; /* # of bytes to allocate */
|
unsigned nbytes; /* # of bytes to allocate */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -797,11 +791,11 @@ unsigned nbytes; /* # of bytes to allocate */
|
|||||||
#endif
|
#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 */
|
char *mp; /* chunk of RAM to release */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -809,8 +803,8 @@ char *mp; /* chunk of RAM to release */
|
|||||||
|
|
||||||
if (mp) {
|
if (mp) {
|
||||||
/* update amount of ram currently malloced */
|
/* update amount of ram currently malloced */
|
||||||
lp = ((unsigned *)mp) - 1;
|
lp = ((unsigned *) mp) - 1;
|
||||||
envram -= (long)*lp - 2;
|
envram -= (long) *lp - 2;
|
||||||
free(mp);
|
free(mp);
|
||||||
#if RAMSHOW
|
#if RAMSHOW
|
||||||
dspram();
|
dspram();
|
||||||
@ -819,9 +813,8 @@ char *mp; /* chunk of RAM to release */
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if RAMSHOW
|
#if RAMSHOW
|
||||||
dspram() /* display the amount of RAM currently malloced */
|
dspram()
|
||||||
|
{ /* display the amount of RAM currently malloced */
|
||||||
{
|
|
||||||
char mbuf[20];
|
char mbuf[20];
|
||||||
char *sp;
|
char *sp;
|
||||||
|
|
||||||
@ -883,7 +876,7 @@ int status; /* return status of emacs */
|
|||||||
#if CALLED
|
#if CALLED
|
||||||
eexitflag = TRUE; /* flag a program exit */
|
eexitflag = TRUE; /* flag a program exit */
|
||||||
eexitval = status;
|
eexitval = status;
|
||||||
return(status);
|
return (status);
|
||||||
#else
|
#else
|
||||||
#undef exit
|
#undef exit
|
||||||
exit(status);
|
exit(status);
|
||||||
|
25
pklock.c
25
pklock.c
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
int gethostname(char *name, int namelen)
|
int gethostname(char *name, int namelen)
|
||||||
{
|
{
|
||||||
return(sysinfo(SI_HOSTNAME, name, namelen));
|
return (sysinfo(SI_HOSTNAME, name, namelen));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ int gethostname(char *name, int namelen)
|
|||||||
*
|
*
|
||||||
*********************/
|
*********************/
|
||||||
char *dolock(fname)
|
char *dolock(fname)
|
||||||
char *fname;
|
char *fname;
|
||||||
{
|
{
|
||||||
int fd, lk, n;
|
int fd, lk, n;
|
||||||
static char lname[MAXLOCK], locker[MAXNAME+1];
|
static char lname[MAXLOCK], locker[MAXNAME + 1];
|
||||||
int mask;
|
int mask;
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
|
||||||
@ -59,17 +59,16 @@ char *dolock(fname)
|
|||||||
if (stat(lname, &sbuf) == 0)
|
if (stat(lname, &sbuf) == 0)
|
||||||
#endif
|
#endif
|
||||||
#if defined(S_ISREG)
|
#if defined(S_ISREG)
|
||||||
if (! S_ISREG(sbuf.st_mode))
|
if (!S_ISREG(sbuf.st_mode))
|
||||||
#else
|
#else
|
||||||
if (! (((sbuf.st_mode) & 070000) == 0)) /* SysV R2 */
|
if (!(((sbuf.st_mode) & 070000) == 0)) /* SysV R2 */
|
||||||
#endif
|
#endif
|
||||||
return "LOCK ERROR: not a regular file";
|
return "LOCK ERROR: not a regular file";
|
||||||
|
|
||||||
mask = umask(0);
|
mask = umask(0);
|
||||||
fd = open(lname, O_RDWR | O_CREAT, 0666);
|
fd = open(lname, O_RDWR | O_CREAT, 0666);
|
||||||
umask(mask);
|
umask(mask);
|
||||||
if (fd < 0)
|
if (fd < 0) {
|
||||||
{
|
|
||||||
if (errno == EACCES)
|
if (errno == EACCES)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef EROFS
|
#ifdef EROFS
|
||||||
@ -78,13 +77,12 @@ char *dolock(fname)
|
|||||||
#endif
|
#endif
|
||||||
return "LOCK ERROR: cannot access lock file";
|
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);
|
lseek(fd, 0, SEEK_SET);
|
||||||
/* strcpy(locker, getlogin()); */
|
/* strcpy(locker, getlogin()); */
|
||||||
cuserid(locker);
|
cuserid(locker);
|
||||||
strcat(locker+strlen(locker), "@");
|
strcat(locker + strlen(locker), "@");
|
||||||
gethostname(locker+strlen(locker), 64);
|
gethostname(locker + strlen(locker), 64);
|
||||||
write(fd, locker, strlen(locker));
|
write(fd, locker, strlen(locker));
|
||||||
close(fd);
|
close(fd);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -104,14 +102,13 @@ char *dolock(fname)
|
|||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
char *undolock(fname)
|
char *undolock(fname)
|
||||||
char *fname;
|
char *fname;
|
||||||
{
|
{
|
||||||
int fd, lk;
|
int fd, lk;
|
||||||
static char lname[MAXLOCK];
|
static char lname[MAXLOCK];
|
||||||
|
|
||||||
strcat(strcpy(lname, fname), ".lock~");
|
strcat(strcpy(lname, fname), ".lock~");
|
||||||
if (unlink(lname) != 0)
|
if (unlink(lname) != 0) {
|
||||||
{
|
|
||||||
if (errno == EACCES || errno == ENOENT)
|
if (errno == EACCES || errno == ENOENT)
|
||||||
return NULL;
|
return NULL;
|
||||||
#ifdef EROFS
|
#ifdef EROFS
|
||||||
|
13
posix.c
13
posix.c
@ -53,12 +53,13 @@ ttopen()
|
|||||||
| INPCK | INLCR | IGNCR | ICRNL);
|
| INPCK | INLCR | IGNCR | ICRNL);
|
||||||
|
|
||||||
/* raw CR/NR etc output handling */
|
/* 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 */
|
/* No signal handling, no echo etc */
|
||||||
ntermios.c_lflag &= ~(ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK
|
ntermios.c_lflag &= ~(ISIG | ICANON | XCASE | ECHO | ECHOE | ECHOK
|
||||||
| ECHONL | NOFLSH | TOSTOP | ECHOCTL | ECHOPRT
|
| ECHONL | NOFLSH | TOSTOP | ECHOCTL |
|
||||||
| ECHOKE | FLUSHO | PENDIN | IEXTEN);
|
ECHOPRT | ECHOKE | FLUSHO | PENDIN | IEXTEN);
|
||||||
|
|
||||||
/* one character, no timeout */
|
/* one character, no timeout */
|
||||||
ntermios.c_cc[VMIN] = 1;
|
ntermios.c_cc[VMIN] = 1;
|
||||||
@ -71,7 +72,7 @@ ttopen()
|
|||||||
*/
|
*/
|
||||||
setbuffer(stdout, &tobuf[0], TBUFSIZ);
|
setbuffer(stdout, &tobuf[0], TBUFSIZ);
|
||||||
|
|
||||||
kbdflgs = fcntl( 0, F_GETFL, 0 );
|
kbdflgs = fcntl(0, F_GETFL, 0);
|
||||||
kbdpoll = FALSE;
|
kbdpoll = FALSE;
|
||||||
|
|
||||||
/* on all screens we are not sure of the initial position
|
/* on all screens we are not sure of the initial position
|
||||||
@ -136,7 +137,7 @@ ttflush()
|
|||||||
*/
|
*/
|
||||||
ttgetc()
|
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
|
/* typahead: Check to see if any characters are already in the
|
||||||
@ -148,7 +149,7 @@ typahead()
|
|||||||
int x; /* holds # of pending chars */
|
int x; /* holds # of pending chars */
|
||||||
|
|
||||||
#ifdef FIONREAD
|
#ifdef FIONREAD
|
||||||
if (ioctl(0,FIONREAD,&x) < 0)
|
if (ioctl(0, FIONREAD, &x) < 0)
|
||||||
x = 0;
|
x = 0;
|
||||||
#else
|
#else
|
||||||
x = 0;
|
x = 0;
|
||||||
|
375
random.c
375
random.c
@ -18,8 +18,8 @@ int tabsize; /* Tab size (0: use real tabs) */
|
|||||||
setfillcol(f, n)
|
setfillcol(f, n)
|
||||||
{
|
{
|
||||||
fillcol = n;
|
fillcol = n;
|
||||||
mlwrite("(Fill column is %d)",n);
|
mlwrite("(Fill column is %d)", n);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -94,12 +94,12 @@ showcpos(f, n)
|
|||||||
|
|
||||||
ratio = 0; /* Ratio before dot. */
|
ratio = 0; /* Ratio before dot. */
|
||||||
if (numchars != 0)
|
if (numchars != 0)
|
||||||
ratio = (100L*predchars) / numchars;
|
ratio = (100L * predchars) / numchars;
|
||||||
|
|
||||||
/* summarize and report the info */
|
/* summarize and report the info */
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
pk_mlrec.pk_clin = predlines+1;
|
pk_mlrec.pk_clin = predlines + 1;
|
||||||
pk_mlrec.pk_tlin = numlines+1;
|
pk_mlrec.pk_tlin = numlines + 1;
|
||||||
pk_mlrec.pk_ccol = col;
|
pk_mlrec.pk_ccol = col;
|
||||||
pk_mlrec.pk_tcol = ecol;
|
pk_mlrec.pk_tcol = ecol;
|
||||||
pk_mlrec.pk_cchr = predchars;
|
pk_mlrec.pk_cchr = predchars;
|
||||||
@ -110,15 +110,14 @@ showcpos(f, n)
|
|||||||
&pk_mlrec);
|
&pk_mlrec);
|
||||||
#else
|
#else
|
||||||
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x",
|
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);
|
predchars, numchars, ratio, curchar);
|
||||||
#endif
|
#endif
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
getcline() /* get the current line number */
|
getcline()
|
||||||
|
{ /* get the current line number */
|
||||||
{
|
|
||||||
register LINE *lp; /* current line */
|
register LINE *lp; /* current line */
|
||||||
register int numlines; /* # of lines before point */
|
register int numlines; /* # of lines before point */
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ getcline() /* get the current line number */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* and return the resulting count */
|
/* and return the resulting count */
|
||||||
return(numlines + 1);
|
return (numlines + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -147,17 +146,17 @@ int bflg;
|
|||||||
{
|
{
|
||||||
register int c, i, col;
|
register int c, i, col;
|
||||||
col = 0;
|
col = 0;
|
||||||
for (i=0; i<curwp->w_doto; ++i) {
|
for (i = 0; i < curwp->w_doto; ++i) {
|
||||||
c = lgetc(curwp->w_dotp, i);
|
c = lgetc(curwp->w_dotp, i);
|
||||||
if (c!=' ' && c!='\t' && bflg)
|
if (c != ' ' && c != '\t' && bflg)
|
||||||
break;
|
break;
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
col |= tabmask;
|
col |= tabmask;
|
||||||
else if (c<0x20 || c==0x7F)
|
else if (c < 0x20 || c == 0x7F)
|
||||||
++col;
|
++col;
|
||||||
++col;
|
++col;
|
||||||
}
|
}
|
||||||
return(col);
|
return (col);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -186,7 +185,7 @@ int pos; /* position to set cursor */
|
|||||||
c = lgetc(curwp->w_dotp, i);
|
c = lgetc(curwp->w_dotp, i);
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
col |= tabmask;
|
col |= tabmask;
|
||||||
else if (c<0x20 || c==0x7F)
|
else if (c < 0x20 || c == 0x7F)
|
||||||
++col;
|
++col;
|
||||||
++col;
|
++col;
|
||||||
}
|
}
|
||||||
@ -195,7 +194,7 @@ int pos; /* position to set cursor */
|
|||||||
curwp->w_doto = i;
|
curwp->w_doto = i;
|
||||||
|
|
||||||
/* and tell weather we made it */
|
/* and tell weather we made it */
|
||||||
return(col >= pos);
|
return (col >= pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -212,18 +211,18 @@ twiddle(f, n)
|
|||||||
register int cl;
|
register int cl;
|
||||||
register int cr;
|
register int cr;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
dotp = curwp->w_dotp;
|
dotp = curwp->w_dotp;
|
||||||
doto = curwp->w_doto;
|
doto = curwp->w_doto;
|
||||||
if (doto==llength(dotp) && --doto<0)
|
if (doto == llength(dotp) && --doto < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
cr = lgetc(dotp, doto);
|
cr = lgetc(dotp, doto);
|
||||||
if (--doto < 0)
|
if (--doto < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
cl = lgetc(dotp, doto);
|
cl = lgetc(dotp, doto);
|
||||||
lputc(dotp, doto+0, cr);
|
lputc(dotp, doto + 0, cr);
|
||||||
lputc(dotp, doto+1, cl);
|
lputc(dotp, doto + 1, cl);
|
||||||
lchange(WFEDIT);
|
lchange(WFEDIT);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -239,8 +238,8 @@ quote(f, n)
|
|||||||
register int s;
|
register int s;
|
||||||
register int c;
|
register int c;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
c = tgetc();
|
c = tgetc();
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
@ -249,7 +248,7 @@ quote(f, n)
|
|||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
do {
|
do {
|
||||||
s = lnewline();
|
s = lnewline();
|
||||||
} while (s==TRUE && --n);
|
} while (s == TRUE && --n);
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
return (linsert(n, c));
|
return (linsert(n, c));
|
||||||
@ -268,23 +267,23 @@ tab(f, n)
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
if (n == 0 || n > 1) {
|
if (n == 0 || n > 1) {
|
||||||
tabsize = n;
|
tabsize = n;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
if (! tabsize)
|
if (!tabsize)
|
||||||
return(linsert(1, '\t'));
|
return (linsert(1, '\t'));
|
||||||
return(linsert(tabsize - (getccol(FALSE) % tabsize), ' '));
|
return (linsert(tabsize - (getccol(FALSE) % tabsize), ' '));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if AEDIT
|
#if AEDIT
|
||||||
detab(f, n) /* change tabs to spaces */
|
detab(f, n)
|
||||||
|
/* change tabs to spaces */
|
||||||
int f,n; /* default flag and numeric repeat count */
|
int f, n; /* default flag and numeric repeat count */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int inc; /* increment to next line [sgn(n)] */
|
register int inc; /* increment to next line [sgn(n)] */
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
|
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -299,7 +298,9 @@ int f,n; /* default flag and numeric repeat count */
|
|||||||
/* if we have a tab */
|
/* if we have a tab */
|
||||||
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
|
if (lgetc(curwp->w_dotp, curwp->w_doto) == '\t') {
|
||||||
ldelete(1L, FALSE);
|
ldelete(1L, FALSE);
|
||||||
insspace(TRUE, (tabmask+1) - (curwp->w_doto & tabmask));
|
insspace(TRUE,
|
||||||
|
(tabmask + 1) -
|
||||||
|
(curwp->w_doto & tabmask));
|
||||||
}
|
}
|
||||||
forwchar(FALSE, 1);
|
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 */
|
curwp->w_doto = 0; /* to the begining of the line */
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
lchange(WFEDIT); /* yes, we have made at least an edit */
|
lchange(WFEDIT); /* yes, we have made at least an edit */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
entab(f, n) /* change spaces to tabs where posible */
|
entab(f, n)
|
||||||
|
/* change spaces to tabs where posible */
|
||||||
int f,n; /* default flag and numeric repeat count */
|
int f, n; /* default flag and numeric repeat count */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int inc; /* increment to next line [sgn(n)] */
|
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 int ccol; /* current cursor column */
|
||||||
register char cchar; /* current character */
|
register char cchar; /* current character */
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
|
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
n = 1;
|
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
|
/* there is a bug here dealing with mixed space/tabed
|
||||||
lines.......it will get fixed */
|
lines.......it will get fixed */
|
||||||
backchar(TRUE, ccol - fspace);
|
backchar(TRUE, ccol - fspace);
|
||||||
ldelete((long)(ccol - fspace), FALSE);
|
ldelete((long) (ccol - fspace),
|
||||||
|
FALSE);
|
||||||
linsert(1, '\t');
|
linsert(1, '\t');
|
||||||
fspace = -1;
|
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 */
|
curwp->w_doto = 0; /* to the begining of the line */
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
lchange(WFEDIT); /* yes, we have made at least an edit */
|
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 */
|
trim(f, n)
|
||||||
|
/* trim trailing whitespace from the point to eol */
|
||||||
int f,n; /* default flag and numeric repeat count */
|
int f, n; /* default flag and numeric repeat count */
|
||||||
|
|
||||||
{
|
{
|
||||||
register LINE *lp; /* current line pointer */
|
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 length; /* current length */
|
||||||
register int inc; /* increment to next line [sgn(n)] */
|
register int inc; /* increment to next line [sgn(n)] */
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
|
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
n = 1;
|
n = 1;
|
||||||
@ -409,8 +411,8 @@ int f,n; /* default flag and numeric repeat count */
|
|||||||
|
|
||||||
/* trim the current line */
|
/* trim the current line */
|
||||||
while (length > offset) {
|
while (length > offset) {
|
||||||
if (lgetc(lp, length-1) != ' ' &&
|
if (lgetc(lp, length - 1) != ' ' &&
|
||||||
lgetc(lp, length-1) != '\t')
|
lgetc(lp, length - 1) != '\t')
|
||||||
break;
|
break;
|
||||||
length--;
|
length--;
|
||||||
}
|
}
|
||||||
@ -422,7 +424,7 @@ int f,n; /* default flag and numeric repeat count */
|
|||||||
}
|
}
|
||||||
lchange(WFEDIT);
|
lchange(WFEDIT);
|
||||||
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
thisflag &= ~CFCPCN; /* flag that this resets the goal column */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -436,8 +438,8 @@ openline(f, n)
|
|||||||
register int i;
|
register int i;
|
||||||
register int s;
|
register int s;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
@ -445,7 +447,7 @@ openline(f, n)
|
|||||||
i = n; /* Insert newlines. */
|
i = n; /* Insert newlines. */
|
||||||
do {
|
do {
|
||||||
s = lnewline();
|
s = lnewline();
|
||||||
} while (s==TRUE && --i);
|
} while (s == TRUE && --i);
|
||||||
if (s == TRUE) /* Then back up overtop */
|
if (s == TRUE) /* Then back up overtop */
|
||||||
s = backchar(f, n); /* of them all. */
|
s = backchar(f, n); /* of them all. */
|
||||||
return (s);
|
return (s);
|
||||||
@ -459,15 +461,15 @@ newline(f, n)
|
|||||||
{
|
{
|
||||||
register int s;
|
register int s;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* if we are in C mode and this is a default <NL> */
|
/* if we are in C mode and this is a default <NL> */
|
||||||
if (n == 1 && (curbp->b_mode & MDCMOD) &&
|
if (n == 1 && (curbp->b_mode & MDCMOD) &&
|
||||||
curwp->w_dotp != curbp->b_linep)
|
curwp->w_dotp != curbp->b_linep)
|
||||||
return(cinsert());
|
return (cinsert());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If a newline was typed, fill column is defined, the argument is non-
|
* 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 &&
|
if ((curwp->w_bufp->b_mode & MDWRAP) && fillcol > 0 &&
|
||||||
getccol(FALSE) > fillcol &&
|
getccol(FALSE) > fillcol &&
|
||||||
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
(curwp->w_bufp->b_mode & MDVIEW) == FALSE)
|
||||||
execute(META|SPEC|'W', FALSE, 1);
|
execute(META | SPEC | 'W', FALSE, 1);
|
||||||
|
|
||||||
/* insert some lines */
|
/* insert some lines */
|
||||||
while (n--) {
|
while (n--) {
|
||||||
if ((s=lnewline()) != TRUE)
|
if ((s = lnewline()) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFINS;
|
curwp->w_flag |= WFINS;
|
||||||
@ -490,9 +492,8 @@ newline(f, n)
|
|||||||
return (TRUE);
|
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 char *cptr; /* string pointer into text to copy */
|
||||||
register int tptr; /* index to scan into line */
|
register int tptr; /* index to scan into line */
|
||||||
register int bracef; /* was there a brace at the end of 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 */
|
/* put in the newline */
|
||||||
if (lnewline() == FALSE)
|
if (lnewline() == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* and the saved indentation */
|
/* and the saved indentation */
|
||||||
linstr(ichar);
|
linstr(ichar);
|
||||||
@ -529,12 +530,12 @@ cinsert() /* insert a newline and indentation for C */
|
|||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFINS;
|
curwp->w_flag |= WFINS;
|
||||||
#endif
|
#endif
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if NBRACE
|
#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 n; /* repeat count */
|
||||||
int c; /* brace to insert (always } for now) */
|
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) {
|
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||||
ch = lgetc(curwp->w_dotp, i);
|
ch = lgetc(curwp->w_dotp, i);
|
||||||
if (ch != ' ' && ch != '\t')
|
if (ch != ' ' && ch != '\t')
|
||||||
return(linsert(n, c));
|
return (linsert(n, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* chercher le caractere oppose correspondant */
|
/* chercher le caractere oppose correspondant */
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '}': oc = '{'; break;
|
case '}':
|
||||||
case ']': oc = '['; break;
|
oc = '{';
|
||||||
case ')': oc = '('; break;
|
break;
|
||||||
default: return(FALSE);
|
case ']':
|
||||||
|
oc = '[';
|
||||||
|
break;
|
||||||
|
case ')':
|
||||||
|
oc = '(';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
oldlp = curwp->w_dotp;
|
oldlp = curwp->w_dotp;
|
||||||
oldoff = curwp->w_doto;
|
oldoff = curwp->w_doto;
|
||||||
|
|
||||||
count = 1; backchar(FALSE, 1);
|
count = 1;
|
||||||
|
backchar(FALSE, 1);
|
||||||
|
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
if (curwp->w_doto == llength(curwp->w_dotp))
|
if (curwp->w_doto == llength(curwp->w_dotp))
|
||||||
@ -575,8 +584,10 @@ int c; /* brace to insert (always } for now) */
|
|||||||
else
|
else
|
||||||
ch = lgetc(curwp->w_dotp, curwp->w_doto);
|
ch = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||||
|
|
||||||
if (ch == c) ++count;
|
if (ch == c)
|
||||||
if (ch == oc) --count;
|
++count;
|
||||||
|
if (ch == oc)
|
||||||
|
--count;
|
||||||
|
|
||||||
backchar(FALSE, 1);
|
backchar(FALSE, 1);
|
||||||
if (boundry(curwp->w_dotp, curwp->w_doto, REVERSE))
|
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 */
|
if (count != 0) { /* no match */
|
||||||
curwp->w_dotp = oldlp;
|
curwp->w_dotp = oldlp;
|
||||||
curwp->w_doto = oldoff;
|
curwp->w_doto = oldoff;
|
||||||
return(linsert(n, c));
|
return (linsert(n, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
curwp->w_doto = 0; /* debut de ligne */
|
curwp->w_doto = 0; /* debut de ligne */
|
||||||
/* aller au debut de la ligne apres la tabulation */
|
/* 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);
|
forwchar(FALSE, 1);
|
||||||
|
|
||||||
/* delete back first */
|
/* delete back first */
|
||||||
@ -605,17 +617,17 @@ int c; /* brace to insert (always } for now) */
|
|||||||
backdel(FALSE, 1);
|
backdel(FALSE, 1);
|
||||||
else { /* on doit en inserer */
|
else { /* on doit en inserer */
|
||||||
while (target - getccol(FALSE) >= 8)
|
while (target - getccol(FALSE) >= 8)
|
||||||
linsert(1,'\t');
|
linsert(1, '\t');
|
||||||
linsert(target - getccol(FALSE), ' ');
|
linsert(target - getccol(FALSE), ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and insert the required brace(s) */
|
/* and insert the required brace(s) */
|
||||||
return(linsert(n, c));
|
return (linsert(n, c));
|
||||||
}
|
}
|
||||||
#else
|
#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 n; /* repeat count */
|
||||||
int c; /* brace to insert (always { for now) */
|
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 we are at the beginning of the line, no go */
|
||||||
if (curwp->w_doto == 0)
|
if (curwp->w_doto == 0)
|
||||||
return(linsert(n,c));
|
return (linsert(n, c));
|
||||||
|
|
||||||
/* scan to see if all space before this is white space */
|
/* scan to see if all space before this is white space */
|
||||||
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||||
ch = lgetc(curwp->w_dotp, i);
|
ch = lgetc(curwp->w_dotp, i);
|
||||||
if (ch != ' ' && ch != '\t')
|
if (ch != ' ' && ch != '\t')
|
||||||
return(linsert(n, c));
|
return (linsert(n, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete back first */
|
/* delete back first */
|
||||||
@ -643,25 +655,24 @@ int c; /* brace to insert (always { for now) */
|
|||||||
backdel(FALSE, 1);
|
backdel(FALSE, 1);
|
||||||
|
|
||||||
/* and insert the required brace(s) */
|
/* and insert the required brace(s) */
|
||||||
return(linsert(n, c));
|
return (linsert(n, c));
|
||||||
}
|
}
|
||||||
#endif
|
#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 ch; /* last character before input */
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
/* if we are at the beginning of the line, no go */
|
/* if we are at the beginning of the line, no go */
|
||||||
if (curwp->w_doto == 0)
|
if (curwp->w_doto == 0)
|
||||||
return(linsert(1,'#'));
|
return (linsert(1, '#'));
|
||||||
|
|
||||||
/* scan to see if all space before this is white space */
|
/* scan to see if all space before this is white space */
|
||||||
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
for (i = curwp->w_doto - 1; i >= 0; --i) {
|
||||||
ch = lgetc(curwp->w_dotp, i);
|
ch = lgetc(curwp->w_dotp, i);
|
||||||
if (ch != ' ' && ch != '\t')
|
if (ch != ' ' && ch != '\t')
|
||||||
return(linsert(1, '#'));
|
return (linsert(1, '#'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete back first */
|
/* delete back first */
|
||||||
@ -669,7 +680,7 @@ inspound() /* insert a # into the text here...we are in CMODE */
|
|||||||
backdel(FALSE, 1);
|
backdel(FALSE, 1);
|
||||||
|
|
||||||
/* and insert the required pound */
|
/* and insert the required pound */
|
||||||
return(linsert(1, '#'));
|
return (linsert(1, '#'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -686,14 +697,14 @@ deblank(f, n)
|
|||||||
register LINE *lp2;
|
register LINE *lp2;
|
||||||
long nld;
|
long nld;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
lp1 = curwp->w_dotp;
|
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;
|
lp1 = lp2;
|
||||||
lp2 = lp1;
|
lp2 = lp1;
|
||||||
nld = 0;
|
nld = 0;
|
||||||
while ((lp2=lforw(lp2))!=curbp->b_linep && llength(lp2)==0)
|
while ((lp2 = lforw(lp2)) != curbp->b_linep && llength(lp2) == 0)
|
||||||
++nld;
|
++nld;
|
||||||
if (nld == 0)
|
if (nld == 0)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@ -716,23 +727,23 @@ indent(f, n)
|
|||||||
register int c;
|
register int c;
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
while (n--) {
|
while (n--) {
|
||||||
nicol = 0;
|
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);
|
c = lgetc(curwp->w_dotp, i);
|
||||||
if (c!=' ' && c!='\t')
|
if (c != ' ' && c != '\t')
|
||||||
break;
|
break;
|
||||||
if (c == '\t')
|
if (c == '\t')
|
||||||
nicol |= tabmask;
|
nicol |= tabmask;
|
||||||
++nicol;
|
++nicol;
|
||||||
}
|
}
|
||||||
if (lnewline() == FALSE
|
if (lnewline() == FALSE
|
||||||
|| ((i=nicol/8)!=0 && linsert(i, '\t')==FALSE)
|
|| ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE)
|
||||||
|| ((i=nicol%8)!=0 && linsert(i, ' ')==FALSE))
|
|| ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
@ -746,16 +757,16 @@ indent(f, n)
|
|||||||
*/
|
*/
|
||||||
forwdel(f, n)
|
forwdel(f, n)
|
||||||
{
|
{
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (backdel(f, -n));
|
return (backdel(f, -n));
|
||||||
if (f != FALSE) { /* Really a kill. */
|
if (f != FALSE) { /* Really a kill. */
|
||||||
if ((lastflag&CFKILL) == 0)
|
if ((lastflag & CFKILL) == 0)
|
||||||
kdelete();
|
kdelete();
|
||||||
thisflag |= CFKILL;
|
thisflag |= CFKILL;
|
||||||
}
|
}
|
||||||
return (ldelete((long)n, f));
|
return (ldelete((long) n, f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -768,17 +779,17 @@ backdel(f, n)
|
|||||||
{
|
{
|
||||||
register int s;
|
register int s;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (forwdel(f, -n));
|
return (forwdel(f, -n));
|
||||||
if (f != FALSE) { /* Really a kill. */
|
if (f != FALSE) { /* Really a kill. */
|
||||||
if ((lastflag&CFKILL) == 0)
|
if ((lastflag & CFKILL) == 0)
|
||||||
kdelete();
|
kdelete();
|
||||||
thisflag |= CFKILL;
|
thisflag |= CFKILL;
|
||||||
}
|
}
|
||||||
if ((s=backchar(f, n)) == TRUE)
|
if ((s = backchar(f, n)) == TRUE)
|
||||||
s = ldelete((long)n, f);
|
s = ldelete((long) n, f);
|
||||||
return (s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -795,36 +806,36 @@ killtext(f, n)
|
|||||||
register LINE *nextp;
|
register LINE *nextp;
|
||||||
long chunk;
|
long chunk;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if ((lastflag&CFKILL) == 0) /* Clear kill buffer if */
|
if ((lastflag & CFKILL) == 0) /* Clear kill buffer if */
|
||||||
kdelete(); /* last wasn't a kill. */
|
kdelete(); /* last wasn't a kill. */
|
||||||
thisflag |= CFKILL;
|
thisflag |= CFKILL;
|
||||||
if (f == FALSE) {
|
if (f == FALSE) {
|
||||||
chunk = llength(curwp->w_dotp)-curwp->w_doto;
|
chunk = llength(curwp->w_dotp) - curwp->w_doto;
|
||||||
if (chunk == 0)
|
if (chunk == 0)
|
||||||
chunk = 1;
|
chunk = 1;
|
||||||
} else if (n == 0) {
|
} else if (n == 0) {
|
||||||
chunk = curwp->w_doto;
|
chunk = curwp->w_doto;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
} else if (n > 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);
|
nextp = lforw(curwp->w_dotp);
|
||||||
while (--n) {
|
while (--n) {
|
||||||
if (nextp == curbp->b_linep)
|
if (nextp == curbp->b_linep)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
chunk += llength(nextp)+1;
|
chunk += llength(nextp) + 1;
|
||||||
nextp = lforw(nextp);
|
nextp = lforw(nextp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mlwrite("neg kill");
|
mlwrite("neg kill");
|
||||||
return (FALSE);
|
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 */
|
int f, n; /* default and argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -835,8 +846,8 @@ int f, n; /* default and argument */
|
|||||||
#endif
|
#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 */
|
int f, n; /* default and argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -847,8 +858,8 @@ int f, n; /* default and argument */
|
|||||||
#endif
|
#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 */
|
int f, n; /* default and argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -859,8 +870,8 @@ int f, n; /* default and argument */
|
|||||||
#endif
|
#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 */
|
int f, n; /* default and argument */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -871,8 +882,8 @@ int f, n; /* default and argument */
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
adjustmode(kind, global) /* change the editor mode status */
|
adjustmode(kind, global)
|
||||||
|
/* change the editor mode status */
|
||||||
int kind; /* true = set, false = delete */
|
int kind; /* true = set, false = delete */
|
||||||
int global; /* true = global flag, false = current buffer flag */
|
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 */
|
/* build the proper prompt string */
|
||||||
if (global)
|
if (global)
|
||||||
strcpy(prompt,"Global mode to ");
|
strcpy(prompt, "Global mode to ");
|
||||||
else
|
else
|
||||||
strcpy(prompt,"Mode to ");
|
strcpy(prompt, "Mode to ");
|
||||||
|
|
||||||
if (kind == TRUE)
|
if (kind == TRUE)
|
||||||
strcat(prompt, "add: ");
|
strcat(prompt, "add: ");
|
||||||
@ -900,7 +911,7 @@ int global; /* true = global flag, false = current buffer flag */
|
|||||||
|
|
||||||
status = mlreply(prompt, cbuf, NPAT - 1);
|
status = mlreply(prompt, cbuf, NPAT - 1);
|
||||||
if (status != TRUE)
|
if (status != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
/* make it uppercase */
|
/* make it uppercase */
|
||||||
|
|
||||||
@ -916,24 +927,21 @@ int global; /* true = global flag, false = current buffer flag */
|
|||||||
|
|
||||||
/* test it first against the colors we know */
|
/* test it first against the colors we know */
|
||||||
#if PKCODE & IBMPC
|
#if PKCODE & IBMPC
|
||||||
for (i=0; i<=NCOLORS; i++) {
|
for (i = 0; i <= NCOLORS; i++) {
|
||||||
#else
|
#else
|
||||||
for (i=0; i<NCOLORS; i++) {
|
for (i = 0; i < NCOLORS; i++) {
|
||||||
#endif
|
#endif
|
||||||
if (strcmp(cbuf, cname[i]) == 0) {
|
if (strcmp(cbuf, cname[i]) == 0) {
|
||||||
/* finding the match, we set the color */
|
/* finding the match, we set the color */
|
||||||
#if COLOR
|
#if COLOR
|
||||||
if (uflag)
|
if (uflag) {
|
||||||
{
|
|
||||||
if (global)
|
if (global)
|
||||||
gfcolor = i;
|
gfcolor = i;
|
||||||
#if PKCODE == 0
|
#if PKCODE == 0
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
curwp->w_fcolor = i;
|
curwp->w_fcolor = i;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (global)
|
if (global)
|
||||||
gbcolor = i;
|
gbcolor = i;
|
||||||
#if PKCODE == 0
|
#if PKCODE == 0
|
||||||
@ -945,13 +953,13 @@ int global; /* true = global flag, false = current buffer flag */
|
|||||||
curwp->w_flag |= WFCOLR;
|
curwp->w_flag |= WFCOLR;
|
||||||
#endif
|
#endif
|
||||||
mlerase();
|
mlerase();
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test it against the modes we know */
|
/* 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) {
|
if (strcmp(cbuf, modename[i]) == 0) {
|
||||||
/* finding a match, we process it */
|
/* finding a match, we process it */
|
||||||
if (kind == TRUE)
|
if (kind == TRUE)
|
||||||
@ -959,8 +967,7 @@ int global; /* true = global flag, false = current buffer flag */
|
|||||||
gmode |= (1 << i);
|
gmode |= (1 << i);
|
||||||
else
|
else
|
||||||
curbp->b_mode |= (1 << i);
|
curbp->b_mode |= (1 << i);
|
||||||
else
|
else if (global)
|
||||||
if (global)
|
|
||||||
gmode &= ~(1 << i);
|
gmode &= ~(1 << i);
|
||||||
else
|
else
|
||||||
curbp->b_mode &= ~(1 << i);
|
curbp->b_mode &= ~(1 << i);
|
||||||
@ -968,12 +975,12 @@ int global; /* true = global flag, false = current buffer flag */
|
|||||||
if (global == 0)
|
if (global == 0)
|
||||||
upmode();
|
upmode();
|
||||||
mlerase(); /* erase the junk */
|
mlerase(); /* erase the junk */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mlwrite("No such mode!");
|
mlwrite("No such mode!");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function simply clears the message line,
|
/* This function simply clears the message line,
|
||||||
@ -985,7 +992,7 @@ int f, n; /* arguments ignored */
|
|||||||
|
|
||||||
{
|
{
|
||||||
mlforce("");
|
mlforce("");
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function writes a string on the message line
|
/* 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 char *np; /* ptr into nbuf */
|
||||||
register int status;
|
register int status;
|
||||||
char buf[NPAT]; /* buffer to recieve message into */
|
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)
|
if ((status =
|
||||||
return(status);
|
mlreply("Message to write: ", buf, NPAT - 1)) != TRUE)
|
||||||
|
return (status);
|
||||||
|
|
||||||
/* expand all '%' to "%%" so mlwrite won't expect arguments */
|
/* expand all '%' to "%%" so mlwrite won't expect arguments */
|
||||||
sp = buf;
|
sp = buf;
|
||||||
@ -1017,7 +1025,7 @@ int f, n; /* arguments ignored */
|
|||||||
|
|
||||||
/* write the message out */
|
/* write the message out */
|
||||||
mlforce(nbuf);
|
mlforce(nbuf);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CFENCE
|
#if CFENCE
|
||||||
@ -1048,13 +1056,33 @@ int f, n; /* not used */
|
|||||||
|
|
||||||
/* setup proper matching fence */
|
/* setup proper matching fence */
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '(': ofence = ')'; sdir = FORWARD; break;
|
case '(':
|
||||||
case '{': ofence = '}'; sdir = FORWARD; break;
|
ofence = ')';
|
||||||
case '[': ofence = ']'; sdir = FORWARD; break;
|
sdir = FORWARD;
|
||||||
case ')': ofence = '('; sdir = REVERSE; break;
|
break;
|
||||||
case '}': ofence = '{'; sdir = REVERSE; break;
|
case '{':
|
||||||
case ']': ofence = '['; sdir = REVERSE; break;
|
ofence = '}';
|
||||||
default: TTbeep(); return(FALSE);
|
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 */
|
/* set up for scan */
|
||||||
@ -1089,14 +1117,14 @@ int f, n; /* not used */
|
|||||||
else
|
else
|
||||||
forwchar(FALSE, 1);
|
forwchar(FALSE, 1);
|
||||||
curwp->w_flag |= WFMOVE;
|
curwp->w_flag |= WFMOVE;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* restore the current position */
|
/* restore the current position */
|
||||||
curwp->w_dotp = oldlp;
|
curwp->w_dotp = oldlp;
|
||||||
curwp->w_doto = oldoff;
|
curwp->w_doto = oldoff;
|
||||||
TTbeep();
|
TTbeep();
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1164,58 +1192,57 @@ char ch; /* fence type to match against */
|
|||||||
/* restore the current position */
|
/* restore the current position */
|
||||||
curwp->w_dotp = oldlp;
|
curwp->w_dotp = oldlp;
|
||||||
curwp->w_doto = oldoff;
|
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 */
|
buffer at the current point */
|
||||||
|
|
||||||
int f, n; /* ignored arguments */
|
int f, n; /* ignored arguments */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int status; /* status return code */
|
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 */
|
/* 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)
|
if (status != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n = - n;
|
n = -n;
|
||||||
|
|
||||||
/* insert it */
|
/* insert it */
|
||||||
while (n-- && (status = linstr(tstring)))
|
while (n-- && (status = linstr(tstring)));
|
||||||
;
|
return (status);
|
||||||
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 */
|
buffer at the current point */
|
||||||
|
|
||||||
int f, n; /* ignored arguments */
|
int f, n; /* ignored arguments */
|
||||||
|
|
||||||
{
|
{
|
||||||
register int status; /* status return code */
|
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 */
|
/* 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)
|
if (status != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
n = 1;
|
n = 1;
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
n = - n;
|
n = -n;
|
||||||
|
|
||||||
/* insert it */
|
/* insert it */
|
||||||
while (n-- && (status = lover(tstring)))
|
while (n-- && (status = lover(tstring)));
|
||||||
;
|
return (status);
|
||||||
return(status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
55
region.c
55
region.c
@ -24,11 +24,11 @@ killregion(f, n)
|
|||||||
register int s;
|
register int s;
|
||||||
REGION region;
|
REGION region;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if ((s=getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
return (s);
|
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 */
|
kdelete(); /* command, so do magic */
|
||||||
thisflag |= CFKILL; /* kill buffer stuff. */
|
thisflag |= CFKILL; /* kill buffer stuff. */
|
||||||
curwp->w_dotp = region.r_linep;
|
curwp->w_dotp = region.r_linep;
|
||||||
@ -49,21 +49,21 @@ copyregion(f, n)
|
|||||||
register int s;
|
register int s;
|
||||||
REGION region;
|
REGION region;
|
||||||
|
|
||||||
if ((s=getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
if ((lastflag&CFKILL) == 0) /* Kill type command. */
|
if ((lastflag & CFKILL) == 0) /* Kill type command. */
|
||||||
kdelete();
|
kdelete();
|
||||||
thisflag |= CFKILL;
|
thisflag |= CFKILL;
|
||||||
linep = region.r_linep; /* Current line. */
|
linep = region.r_linep; /* Current line. */
|
||||||
loffs = region.r_offset; /* Current offset. */
|
loffs = region.r_offset; /* Current offset. */
|
||||||
while (region.r_size--) {
|
while (region.r_size--) {
|
||||||
if (loffs == llength(linep)) { /* End of line. */
|
if (loffs == llength(linep)) { /* End of line. */
|
||||||
if ((s=kinsert('\n')) != TRUE)
|
if ((s = kinsert('\n')) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
linep = lforw(linep);
|
linep = lforw(linep);
|
||||||
loffs = 0;
|
loffs = 0;
|
||||||
} else { /* Middle of line. */
|
} else { /* Middle of line. */
|
||||||
if ((s=kinsert(lgetc(linep, loffs))) != TRUE)
|
if ((s = kinsert(lgetc(linep, loffs))) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
++loffs;
|
++loffs;
|
||||||
}
|
}
|
||||||
@ -88,9 +88,9 @@ lowerregion(f, n)
|
|||||||
register int s;
|
register int s;
|
||||||
REGION region;
|
REGION region;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if ((s=getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
linep = region.r_linep;
|
linep = region.r_linep;
|
||||||
@ -101,8 +101,8 @@ lowerregion(f, n)
|
|||||||
loffs = 0;
|
loffs = 0;
|
||||||
} else {
|
} else {
|
||||||
c = lgetc(linep, loffs);
|
c = lgetc(linep, loffs);
|
||||||
if (c>='A' && c<='Z')
|
if (c >= 'A' && c <= 'Z')
|
||||||
lputc(linep, loffs, c+'a'-'A');
|
lputc(linep, loffs, c + 'a' - 'A');
|
||||||
++loffs;
|
++loffs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,9 +125,9 @@ upperregion(f, n)
|
|||||||
register int s;
|
register int s;
|
||||||
REGION region;
|
REGION region;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if ((s=getregion(®ion)) != TRUE)
|
if ((s = getregion(®ion)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
linep = region.r_linep;
|
linep = region.r_linep;
|
||||||
@ -138,8 +138,8 @@ upperregion(f, n)
|
|||||||
loffs = 0;
|
loffs = 0;
|
||||||
} else {
|
} else {
|
||||||
c = lgetc(linep, loffs);
|
c = lgetc(linep, loffs);
|
||||||
if (c>='a' && c<='z')
|
if (c >= 'a' && c <= 'z')
|
||||||
lputc(linep, loffs, c-'a'+'A');
|
lputc(linep, loffs, c - 'a' + 'A');
|
||||||
++loffs;
|
++loffs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,31 +173,33 @@ register REGION *rp;
|
|||||||
rp->r_linep = curwp->w_dotp;
|
rp->r_linep = curwp->w_dotp;
|
||||||
if (curwp->w_doto < curwp->w_marko) {
|
if (curwp->w_doto < curwp->w_marko) {
|
||||||
rp->r_offset = curwp->w_doto;
|
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 {
|
} else {
|
||||||
rp->r_offset = curwp->w_marko;
|
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);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
blp = curwp->w_dotp;
|
blp = curwp->w_dotp;
|
||||||
bsize = (long)curwp->w_doto;
|
bsize = (long) curwp->w_doto;
|
||||||
flp = curwp->w_dotp;
|
flp = curwp->w_dotp;
|
||||||
fsize = (long)(llength(flp)-curwp->w_doto+1);
|
fsize = (long) (llength(flp) - curwp->w_doto + 1);
|
||||||
while (flp!=curbp->b_linep || lback(blp)!=curbp->b_linep) {
|
while (flp != curbp->b_linep || lback(blp) != curbp->b_linep) {
|
||||||
if (flp != curbp->b_linep) {
|
if (flp != curbp->b_linep) {
|
||||||
flp = lforw(flp);
|
flp = lforw(flp);
|
||||||
if (flp == curwp->w_markp) {
|
if (flp == curwp->w_markp) {
|
||||||
rp->r_linep = curwp->w_dotp;
|
rp->r_linep = curwp->w_dotp;
|
||||||
rp->r_offset = curwp->w_doto;
|
rp->r_offset = curwp->w_doto;
|
||||||
rp->r_size = fsize+curwp->w_marko;
|
rp->r_size = fsize + curwp->w_marko;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
fsize += llength(flp)+1;
|
fsize += llength(flp) + 1;
|
||||||
}
|
}
|
||||||
if (lback(blp) != curbp->b_linep) {
|
if (lback(blp) != curbp->b_linep) {
|
||||||
blp = lback(blp);
|
blp = lback(blp);
|
||||||
bsize += llength(blp)+1;
|
bsize += llength(blp) + 1;
|
||||||
if (blp == curwp->w_markp) {
|
if (blp == curwp->w_markp) {
|
||||||
rp->r_linep = blp;
|
rp->r_linep = blp;
|
||||||
rp->r_offset = curwp->w_marko;
|
rp->r_offset = curwp->w_marko;
|
||||||
@ -209,4 +211,3 @@ register REGION *rp;
|
|||||||
mlwrite("Bug: lost mark");
|
mlwrite("Bug: lost mark");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
136
spawn.c
136
spawn.c
@ -49,7 +49,7 @@ spawncli(f, n)
|
|||||||
|
|
||||||
/* don't allow this command if restricted */
|
/* don't allow this command if restricted */
|
||||||
if (restflag)
|
if (restflag)
|
||||||
return(resterr());
|
return (resterr());
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
movecursor(term.t_nrow, 0); /* In last line. */
|
movecursor(term.t_nrow, 0); /* In last line. */
|
||||||
@ -61,7 +61,7 @@ spawncli(f, n)
|
|||||||
mlputs("\r\n(Returning from DCL)\r\n");
|
mlputs("\r\n(Returning from DCL)\r\n");
|
||||||
TTflush();
|
TTflush();
|
||||||
sleep(1);
|
sleep(1);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
#if MSDOS & (MSC | TURBO)
|
#if MSDOS & (MSC | TURBO)
|
||||||
movecursor(term.t_nrow, 0); /* Seek to last line. */
|
movecursor(term.t_nrow, 0); /* Seek to last line. */
|
||||||
@ -70,7 +70,7 @@ spawncli(f, n)
|
|||||||
shellprog("");
|
shellprog("");
|
||||||
TTkopen();
|
TTkopen();
|
||||||
sgarbf = TRUE;
|
sgarbf = TRUE;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
#if V7 | USG | BSD
|
#if V7 | USG | BSD
|
||||||
movecursor(term.t_nrow, 0); /* Seek to last line. */
|
movecursor(term.t_nrow, 0); /* Seek to last line. */
|
||||||
@ -95,17 +95,17 @@ spawncli(f, n)
|
|||||||
* -lbt
|
* -lbt
|
||||||
*/
|
*/
|
||||||
chg_width = term.t_ncol;
|
chg_width = term.t_ncol;
|
||||||
chg_height = term.t_nrow+1;
|
chg_height = term.t_nrow + 1;
|
||||||
term.t_nrow = term.t_ncol = 0;
|
term.t_nrow = term.t_ncol = 0;
|
||||||
#endif
|
#endif
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BSD | __hpux | SVR4
|
#if BSD | __hpux | SVR4
|
||||||
|
|
||||||
bktoshell() /* suspend MicroEMACS and wait to wake up */
|
bktoshell()
|
||||||
{
|
{ /* suspend MicroEMACS and wait to wake up */
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
vttidy();
|
vttidy();
|
||||||
@ -136,10 +136,10 @@ spawn(f, n)
|
|||||||
|
|
||||||
/* don't allow this command if restricted */
|
/* don't allow this command if restricted */
|
||||||
if (restflag)
|
if (restflag)
|
||||||
return(resterr());
|
return (resterr());
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
movecursor(term.t_nrow, 0);
|
movecursor(term.t_nrow, 0);
|
||||||
TTflush();
|
TTflush();
|
||||||
@ -153,8 +153,8 @@ spawn(f, n)
|
|||||||
return (s);
|
return (s);
|
||||||
#endif
|
#endif
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
movecursor(term.t_nrow, 0);
|
movecursor(term.t_nrow, 0);
|
||||||
TTkclose();
|
TTkclose();
|
||||||
shellprog(line);
|
shellprog(line);
|
||||||
@ -168,7 +168,7 @@ spawn(f, n)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
#if V7 | USG | BSD
|
#if V7 | USG | BSD
|
||||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
TTflush();
|
TTflush();
|
||||||
TTclose(); /* stty to old modes */
|
TTclose(); /* stty to old modes */
|
||||||
@ -180,8 +180,7 @@ spawn(f, n)
|
|||||||
if (clexec == FALSE) {
|
if (clexec == FALSE) {
|
||||||
mlputs("(End)"); /* Pause. */
|
mlputs("(End)"); /* Pause. */
|
||||||
TTflush();
|
TTflush();
|
||||||
while ((s = tgetc()) != '\r' && s != ' ')
|
while ((s = tgetc()) != '\r' && s != ' ');
|
||||||
;
|
|
||||||
mlputs("\r\n");
|
mlputs("\r\n");
|
||||||
}
|
}
|
||||||
TTkopen();
|
TTkopen();
|
||||||
@ -197,17 +196,16 @@ spawn(f, n)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
execprg(f, n)
|
execprg(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
register int s;
|
register int s;
|
||||||
char line[NLINE];
|
char line[NLINE];
|
||||||
|
|
||||||
/* don't allow this command if restricted */
|
/* don't allow this command if restricted */
|
||||||
if (restflag)
|
if (restflag)
|
||||||
return(resterr());
|
return (resterr());
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
TTflush();
|
TTflush();
|
||||||
s = sys(line); /* Run the command. */
|
s = sys(line); /* Run the command. */
|
||||||
@ -219,8 +217,8 @@ execprg(f, n)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
if ((s=mlreply("$", line, NLINE)) != TRUE)
|
if ((s = mlreply("$", line, NLINE)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
movecursor(term.t_nrow, 0);
|
movecursor(term.t_nrow, 0);
|
||||||
TTkclose();
|
TTkclose();
|
||||||
execprog(line);
|
execprog(line);
|
||||||
@ -235,7 +233,7 @@ execprg(f, n)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if V7 | USG | BSD
|
#if V7 | USG | BSD
|
||||||
if ((s=mlreply("!", line, NLINE)) != TRUE)
|
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||||
return (s);
|
return (s);
|
||||||
TTputc('\n'); /* Already have '\r' */
|
TTputc('\n'); /* Already have '\r' */
|
||||||
TTflush();
|
TTflush();
|
||||||
@ -245,8 +243,7 @@ execprg(f, n)
|
|||||||
TTopen();
|
TTopen();
|
||||||
mlputs("(End)"); /* Pause. */
|
mlputs("(End)"); /* Pause. */
|
||||||
TTflush();
|
TTflush();
|
||||||
while ((s = tgetc()) != '\r' && s != ' ')
|
while ((s = tgetc()) != '\r' && s != ' ');
|
||||||
;
|
|
||||||
sgarbf = TRUE;
|
sgarbf = TRUE;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
#endif
|
#endif
|
||||||
@ -276,31 +273,33 @@ pipecmd(f, n)
|
|||||||
|
|
||||||
/* don't allow this command if restricted */
|
/* don't allow this command if restricted */
|
||||||
if (restflag)
|
if (restflag)
|
||||||
return(resterr());
|
return (resterr());
|
||||||
|
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
if ((tmp = getenv("TMP")) == NULL && (tmp = getenv("TEMP")) == NULL)
|
if ((tmp = getenv("TMP")) == NULL
|
||||||
|
&& (tmp = getenv("TEMP")) == NULL)
|
||||||
strcpy(filnam, "command");
|
strcpy(filnam, "command");
|
||||||
else {
|
else {
|
||||||
strcpy(filnam, tmp);
|
strcpy(filnam, tmp);
|
||||||
len = strlen(tmp);
|
len = strlen(tmp);
|
||||||
if (len <= 0 || filnam[len-1] != '\\' && filnam[len-1] != '/')
|
if (len <= 0 || filnam[len - 1] != '\\'
|
||||||
strcat(filnam,"\\");
|
&& filnam[len - 1] != '/')
|
||||||
strcat(filnam,"command");
|
strcat(filnam, "\\");
|
||||||
|
strcat(filnam, "command");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
mlwrite("Not available under VMS");
|
mlwrite("Not available under VMS");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get the command to pipe in */
|
/* get the command to pipe in */
|
||||||
if ((s=mlreply("@", line, NLINE)) != TRUE)
|
if ((s = mlreply("@", line, NLINE)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
|
|
||||||
/* get rid of the command output buffer if it exists */
|
/* 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 */
|
/* try to make sure we are off screen */
|
||||||
wp = wheadp;
|
wp = wheadp;
|
||||||
while (wp != NULL) {
|
while (wp != NULL) {
|
||||||
@ -320,12 +319,11 @@ pipecmd(f, n)
|
|||||||
}
|
}
|
||||||
if (zotbuf(bp) != TRUE)
|
if (zotbuf(bp) != TRUE)
|
||||||
|
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
strcat(line," >>");
|
strcat(line, " >>");
|
||||||
strcat(line,filnam);
|
strcat(line, filnam);
|
||||||
movecursor(term.t_nrow, 0);
|
movecursor(term.t_nrow, 0);
|
||||||
TTkclose();
|
TTkclose();
|
||||||
shellprog(line);
|
shellprog(line);
|
||||||
@ -342,8 +340,8 @@ pipecmd(f, n)
|
|||||||
#if V7 | USG | BSD
|
#if V7 | USG | BSD
|
||||||
TTflush();
|
TTflush();
|
||||||
TTclose(); /* stty to old modes */
|
TTclose(); /* stty to old modes */
|
||||||
strcat(line,">");
|
strcat(line, ">");
|
||||||
strcat(line,filnam);
|
strcat(line, filnam);
|
||||||
system(line);
|
system(line);
|
||||||
TTopen();
|
TTopen();
|
||||||
TTflush();
|
TTflush();
|
||||||
@ -352,15 +350,15 @@ pipecmd(f, n)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (s != TRUE)
|
if (s != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
|
|
||||||
/* split the current window to make room for the command output */
|
/* split the current window to make room for the command output */
|
||||||
if (splitwind(FALSE, 1) == FALSE)
|
if (splitwind(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* and read the stuff in */
|
/* and read the stuff in */
|
||||||
if (getfile(filnam, FALSE) == FALSE)
|
if (getfile(filnam, FALSE) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* make this window in VIEW mode, update all mode lines */
|
/* make this window in VIEW mode, update all mode lines */
|
||||||
curwp->w_bufp->b_mode |= MDVIEW;
|
curwp->w_bufp->b_mode |= MDVIEW;
|
||||||
@ -372,7 +370,7 @@ pipecmd(f, n)
|
|||||||
|
|
||||||
/* and get rid of the temporary file */
|
/* and get rid of the temporary file */
|
||||||
unlink(filnam);
|
unlink(filnam);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -380,7 +378,6 @@ pipecmd(f, n)
|
|||||||
* Bound to ^X #
|
* Bound to ^X #
|
||||||
*/
|
*/
|
||||||
filter(f, n)
|
filter(f, n)
|
||||||
|
|
||||||
{
|
{
|
||||||
register int s; /* return status from CLI */
|
register int s; /* return status from CLI */
|
||||||
register BUFFER *bp; /* pointer to buffer to zot */
|
register BUFFER *bp; /* pointer to buffer to zot */
|
||||||
@ -393,19 +390,19 @@ filter(f, n)
|
|||||||
|
|
||||||
/* don't allow this command if restricted */
|
/* don't allow this command if restricted */
|
||||||
if (restflag)
|
if (restflag)
|
||||||
return(resterr());
|
return (resterr());
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
mlwrite("Not available under VMS");
|
mlwrite("Not available under VMS");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* get the filter name and its args */
|
/* get the filter name and its args */
|
||||||
if ((s=mlreply("#", line, NLINE)) != TRUE)
|
if ((s = mlreply("#", line, NLINE)) != TRUE)
|
||||||
return(s);
|
return (s);
|
||||||
|
|
||||||
/* setup the proper file names */
|
/* setup the proper file names */
|
||||||
bp = curbp;
|
bp = curbp;
|
||||||
@ -416,11 +413,10 @@ filter(f, n)
|
|||||||
if (writeout(filnam1) != TRUE) {
|
if (writeout(filnam1) != TRUE) {
|
||||||
mlwrite("(Cannot write filter file)");
|
mlwrite("(Cannot write filter file)");
|
||||||
strcpy(bp->b_fname, tmpnam);
|
strcpy(bp->b_fname, tmpnam);
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MSDOS
|
#if MSDOS
|
||||||
strcat(line," <fltinp >fltout");
|
strcat(line, " <fltinp >fltout");
|
||||||
movecursor(term.t_nrow - 1, 0);
|
movecursor(term.t_nrow - 1, 0);
|
||||||
TTkclose();
|
TTkclose();
|
||||||
shellprog(line);
|
shellprog(line);
|
||||||
@ -433,7 +429,7 @@ filter(f, n)
|
|||||||
TTputc('\n'); /* Already have '\r' */
|
TTputc('\n'); /* Already have '\r' */
|
||||||
TTflush();
|
TTflush();
|
||||||
TTclose(); /* stty to old modes */
|
TTclose(); /* stty to old modes */
|
||||||
strcat(line," <fltinp >fltout");
|
strcat(line, " <fltinp >fltout");
|
||||||
system(line);
|
system(line);
|
||||||
TTopen();
|
TTopen();
|
||||||
TTflush();
|
TTflush();
|
||||||
@ -442,12 +438,12 @@ filter(f, n)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* on failure, escape gracefully */
|
/* on failure, escape gracefully */
|
||||||
if (s != TRUE || (readin(filnam2,FALSE) == FALSE)) {
|
if (s != TRUE || (readin(filnam2, FALSE) == FALSE)) {
|
||||||
mlwrite("(Execution failed)");
|
mlwrite("(Execution failed)");
|
||||||
strcpy(bp->b_fname, tmpnam);
|
strcpy(bp->b_fname, tmpnam);
|
||||||
unlink(filnam1);
|
unlink(filnam1);
|
||||||
unlink(filnam2);
|
unlink(filnam2);
|
||||||
return(s);
|
return (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset file name */
|
/* reset file name */
|
||||||
@ -457,7 +453,7 @@ filter(f, n)
|
|||||||
/* and get rid of the temporary file */
|
/* and get rid of the temporary file */
|
||||||
unlink(filnam1);
|
unlink(filnam1);
|
||||||
unlink(filnam2);
|
unlink(filnam2);
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VMS
|
#if VMS
|
||||||
@ -478,7 +474,7 @@ register char *cmd;
|
|||||||
|
|
||||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||||
oldmode, sizeof(oldmode), 0, 0, 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);
|
return (FALSE);
|
||||||
cdscp = NULL; /* Assume DCL. */
|
cdscp = NULL; /* Assume DCL. */
|
||||||
if (cmd != NULL) { /* Build descriptor. */
|
if (cmd != NULL) { /* Build descriptor. */
|
||||||
@ -493,9 +489,9 @@ register char *cmd;
|
|||||||
substatus = status;
|
substatus = status;
|
||||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||||
newmode, sizeof(newmode), 0, 0, 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);
|
return (FALSE);
|
||||||
if ((substatus&STS$M_SUCCESS) == 0) /* Command failed. */
|
if ((substatus & STS$M_SUCCESS) == 0) /* Command failed. */
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -521,11 +517,11 @@ char *cmd; /* Incoming command line to execute */
|
|||||||
regs.h.ah = 0x37; /* get setting data */
|
regs.h.ah = 0x37; /* get setting data */
|
||||||
regs.h.al = 0x00; /* get switch character */
|
regs.h.al = 0x00; /* get switch character */
|
||||||
intdos(®s, ®s);
|
intdos(®s, ®s);
|
||||||
swchar = (char)regs.h.dl;
|
swchar = (char) regs.h.dl;
|
||||||
|
|
||||||
/* get name of system shell */
|
/* get name of system shell */
|
||||||
if ((shell = getenv("COMSPEC")) == NULL) {
|
if ((shell = getenv("COMSPEC")) == NULL) {
|
||||||
return(FALSE); /* No shell located */
|
return (FALSE); /* No shell located */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* trim leading whitespace off the command */
|
/* trim leading whitespace off the command */
|
||||||
@ -543,9 +539,9 @@ char *cmd; /* Incoming command line to execute */
|
|||||||
comline[strlen(comline)] = swchar;
|
comline[strlen(comline)] = swchar;
|
||||||
strcat(comline, "c ");
|
strcat(comline, "c ");
|
||||||
strcat(comline, cmd);
|
strcat(comline, cmd);
|
||||||
return(execprog(comline));
|
return (execprog(comline));
|
||||||
} else
|
} else
|
||||||
return(execprog(shell));
|
return (execprog(shell));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EXECPROG: A function to execute a named program
|
/* 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 */
|
/* and parse out the command tail */
|
||||||
while (*cmd && ((*cmd == ' ') || (*cmd == '\t')))
|
while (*cmd && ((*cmd == ' ') || (*cmd == '\t')))
|
||||||
++cmd;
|
++cmd;
|
||||||
*tail = (char)(strlen(cmd)); /* record the byte length */
|
*tail = (char) (strlen(cmd)); /* record the byte length */
|
||||||
strcpy(&tail[1], cmd);
|
strcpy(&tail[1], cmd);
|
||||||
strcat(&tail[1], "\r");
|
strcat(&tail[1], "\r");
|
||||||
|
|
||||||
/* look up the program on the path trying various extentions */
|
/* look up the program on the path trying various extentions */
|
||||||
if ((sp = flook(prog, TRUE)) == NULL)
|
if ((sp = flook(prog, TRUE)) == NULL)
|
||||||
if ((sp = flook(strcat(prog, ".exe"), 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)
|
if ((sp = flook(prog, TRUE)) == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
strcpy(prog, sp);
|
strcpy(prog, sp);
|
||||||
|
|
||||||
@ -606,10 +602,10 @@ char *cmd; /* Incoming command line to execute */
|
|||||||
/* and make the call */
|
/* and make the call */
|
||||||
regs.h.ah = 0x4b; /* EXEC Load or Execute a Program */
|
regs.h.ah = 0x4b; /* EXEC Load or Execute a Program */
|
||||||
regs.h.al = 0x00; /* load end execute function subcode */
|
regs.h.al = 0x00; /* load end execute function subcode */
|
||||||
segreg.ds = ((unsigned long)(prog) >> 16); /* program name ptr */
|
segreg.ds = ((unsigned long) (prog) >> 16); /* program name ptr */
|
||||||
regs.x.dx = (unsigned int)(prog);
|
regs.x.dx = (unsigned int) (prog);
|
||||||
segreg.es = ((unsigned long)(&pblock) >> 16); /* set up param block ptr */
|
segreg.es = ((unsigned long) (&pblock) >> 16); /* set up param block ptr */
|
||||||
regs.x.bx = (unsigned int)(&pblock);
|
regs.x.bx = (unsigned int) (&pblock);
|
||||||
#if TURBO | MSC
|
#if TURBO | MSC
|
||||||
intdosx(®s, ®s, &segreg);
|
intdosx(®s, ®s, &segreg);
|
||||||
if (regs.x.cflag == 0) {
|
if (regs.x.cflag == 0) {
|
||||||
@ -623,6 +619,6 @@ char *cmd; /* Incoming command line to execute */
|
|||||||
rval = -_doserrno; /* failed child call */
|
rval = -_doserrno; /* failed child call */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return((rval < 0) ? FALSE : TRUE);
|
return ((rval < 0) ? FALSE : TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
92
tcap.c
92
tcap.c
@ -107,7 +107,6 @@ TERM term = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
tcapopen()
|
tcapopen()
|
||||||
|
|
||||||
{
|
{
|
||||||
char *getenv();
|
char *getenv();
|
||||||
char *t, *p, *tgetstr();
|
char *t, *p, *tgetstr();
|
||||||
@ -117,37 +116,36 @@ tcapopen()
|
|||||||
int int_col, int_row;
|
int int_col, int_row;
|
||||||
|
|
||||||
#if PKCODE && USE_BROKEN_OPTIMIZATION
|
#if PKCODE && USE_BROKEN_OPTIMIZATION
|
||||||
if (! term_init_ok)
|
if (!term_init_ok) {
|
||||||
{
|
|
||||||
#endif
|
#endif
|
||||||
if ((tv_stype = getenv("TERM")) == NULL)
|
if ((tv_stype = getenv("TERM")) == NULL) {
|
||||||
{
|
|
||||||
puts("Environment variable TERM not defined!");
|
puts("Environment variable TERM not defined!");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tgetent(tcbuf, tv_stype)) != 1)
|
if ((tgetent(tcbuf, tv_stype)) != 1) {
|
||||||
{
|
sprintf(err_str, "Unknown terminal type %s!",
|
||||||
sprintf(err_str, "Unknown terminal type %s!", tv_stype);
|
tv_stype);
|
||||||
puts(err_str);
|
puts(err_str);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get screen size from system, or else from termcap. */
|
/* Get screen size from system, or else from termcap. */
|
||||||
getscreensize(&int_col, &int_row);
|
getscreensize(&int_col, &int_row);
|
||||||
term.t_nrow = int_row-1;
|
term.t_nrow = int_row - 1;
|
||||||
term.t_ncol = int_col;
|
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)");
|
puts("termcap entry incomplete (lines)");
|
||||||
exit(1);
|
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)");
|
puts("Termcap entry incomplete (columns)");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SIGWINCH
|
#ifdef SIGWINCH
|
||||||
term.t_mrow = MAXROW;
|
term.t_mrow = MAXROW;
|
||||||
term.t_mcol = MAXCOL;
|
term.t_mcol = MAXCOL;
|
||||||
@ -157,7 +155,7 @@ tcapopen()
|
|||||||
#endif
|
#endif
|
||||||
p = tcapbuf;
|
p = tcapbuf;
|
||||||
t = tgetstr("pc", &p);
|
t = tgetstr("pc", &p);
|
||||||
if(t)
|
if (t)
|
||||||
PC = *t;
|
PC = *t;
|
||||||
else
|
else
|
||||||
PC = 0;
|
PC = 0;
|
||||||
@ -180,8 +178,7 @@ tcapopen()
|
|||||||
TE = tgetstr("te", &p);
|
TE = tgetstr("te", &p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(CL == NULL || CM == NULL || UP == NULL)
|
if (CL == NULL || CM == NULL || UP == NULL) {
|
||||||
{
|
|
||||||
puts("Incomplete termcap entry\n");
|
puts("Incomplete termcap entry\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -206,8 +203,7 @@ tcapopen()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (p >= &tcapbuf[TCAPSLEN])
|
if (p >= &tcapbuf[TCAPSLEN]) {
|
||||||
{
|
|
||||||
puts("Terminal description too big!\n");
|
puts("Terminal description too big!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -221,7 +217,6 @@ tcapopen()
|
|||||||
#if PKCODE
|
#if PKCODE
|
||||||
|
|
||||||
tcapclose()
|
tcapclose()
|
||||||
|
|
||||||
{
|
{
|
||||||
putpad(tgoto(CM, 0, term.t_nrow));
|
putpad(tgoto(CM, 0, term.t_nrow));
|
||||||
putpad(TE);
|
putpad(TE);
|
||||||
@ -231,7 +226,6 @@ tcapclose()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
tcapkopen()
|
tcapkopen()
|
||||||
|
|
||||||
{
|
{
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
putpad(TI);
|
putpad(TI);
|
||||||
@ -241,7 +235,6 @@ tcapkopen()
|
|||||||
}
|
}
|
||||||
|
|
||||||
tcapkclose()
|
tcapkclose()
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +254,8 @@ tcapeeop()
|
|||||||
putpad(CL);
|
putpad(CL);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcaprev(state) /* change reverse video status */
|
tcaprev(state)
|
||||||
|
/* change reverse video status */
|
||||||
int state; /* FALSE = normal video, TRUE = reverse video */
|
int state; /* FALSE = normal video, TRUE = reverse video */
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -270,32 +263,31 @@ int state; /* FALSE = normal video, TRUE = reverse video */
|
|||||||
if (state) {
|
if (state) {
|
||||||
if (SO != NULL)
|
if (SO != NULL)
|
||||||
putpad(SO);
|
putpad(SO);
|
||||||
} else
|
} else if (SE != NULL)
|
||||||
if (SE != NULL)
|
|
||||||
putpad(SE);
|
putpad(SE);
|
||||||
}
|
}
|
||||||
|
|
||||||
tcapcres() /* change screen resolution */
|
tcapcres()
|
||||||
|
{ /* change screen resolution */
|
||||||
{
|
return (TRUE);
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
|
|
||||||
/* move howmanylines lines starting at from to to */
|
/* move howmanylines lines starting at from to to */
|
||||||
tcapscroll_reg(from,to,howmanylines)
|
tcapscroll_reg(from, to, howmanylines)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (to == from) return;
|
if (to == from)
|
||||||
|
return;
|
||||||
if (to < from) {
|
if (to < from) {
|
||||||
tcapscrollregion(to, from + howmanylines - 1);
|
tcapscrollregion(to, from + howmanylines - 1);
|
||||||
tcapmove(from + howmanylines - 1,0);
|
tcapmove(from + howmanylines - 1, 0);
|
||||||
for (i = from - to; i > 0; i--)
|
for (i = from - to; i > 0; i--)
|
||||||
putpad(SF);
|
putpad(SF);
|
||||||
} else { /* from < to */
|
} else { /* from < to */
|
||||||
tcapscrollregion(from, to + howmanylines - 1);
|
tcapscrollregion(from, to + howmanylines - 1);
|
||||||
tcapmove(from,0);
|
tcapmove(from, 0);
|
||||||
for (i = to - from; i > 0; i--)
|
for (i = to - from; i > 0; i--)
|
||||||
putpad(SR);
|
putpad(SR);
|
||||||
}
|
}
|
||||||
@ -303,29 +295,30 @@ tcapscroll_reg(from,to,howmanylines)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* move howmanylines lines starting at from to to */
|
/* move howmanylines lines starting at from to to */
|
||||||
tcapscroll_delins(from,to,howmanylines)
|
tcapscroll_delins(from, to, howmanylines)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (to == from) return;
|
if (to == from)
|
||||||
|
return;
|
||||||
if (to < from) {
|
if (to < from) {
|
||||||
tcapmove(to,0);
|
tcapmove(to, 0);
|
||||||
for (i = from - to; i > 0; i--)
|
for (i = from - to; i > 0; i--)
|
||||||
putpad(DL);
|
putpad(DL);
|
||||||
tcapmove(to+howmanylines,0);
|
tcapmove(to + howmanylines, 0);
|
||||||
for (i = from - to; i > 0; i--)
|
for (i = from - to; i > 0; i--)
|
||||||
putpad(AL);
|
putpad(AL);
|
||||||
} else {
|
} else {
|
||||||
tcapmove(from+howmanylines,0);
|
tcapmove(from + howmanylines, 0);
|
||||||
for (i = to - from; i > 0; i--)
|
for (i = to - from; i > 0; i--)
|
||||||
putpad(DL);
|
putpad(DL);
|
||||||
tcapmove(from,0);
|
tcapmove(from, 0);
|
||||||
for (i = to - from; i > 0; i--)
|
for (i = to - from; i > 0; i--)
|
||||||
putpad(AL);
|
putpad(AL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cs is set up just like cm, so we use tgoto... */
|
/* cs is set up just like cm, so we use tgoto... */
|
||||||
tcapscrollregion(top,bot)
|
tcapscrollregion(top, bot)
|
||||||
{
|
{
|
||||||
ttputc(PC);
|
ttputc(PC);
|
||||||
putpad(tgoto(CS, bot, top));
|
putpad(tgoto(CS, bot, top));
|
||||||
@ -333,19 +326,18 @@ tcapscrollregion(top,bot)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
spal(dummy) /* change palette string */
|
spal(dummy)
|
||||||
|
{ /* change palette string */
|
||||||
{
|
|
||||||
/* Does nothing here */
|
/* Does nothing here */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COLOR
|
#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
|
#endif
|
||||||
|
|
||||||
@ -368,13 +360,13 @@ char *str;
|
|||||||
|
|
||||||
|
|
||||||
#if FNLABEL
|
#if FNLABEL
|
||||||
fnclabel(f, n) /* label a function key */
|
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 */
|
/* on machines with no function keys...don't bother */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#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 */
|
struct tchars otchars; /* Saved terminal special character set */
|
||||||
#if XONXOFF
|
#if XONXOFF
|
||||||
struct tchars ntchars = { 0xff, 0xff, 0x11, 0x13, 0xff, 0xff };
|
struct tchars ntchars = { 0xff, 0xff, 0x11, 0x13, 0xff, 0xff };
|
||||||
|
|
||||||
/* A lot of nothing and XON/XOFF */
|
/* A lot of nothing and XON/XOFF */
|
||||||
#else
|
#else
|
||||||
struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
struct tchars ntchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||||
|
|
||||||
/* A lot of nothing */
|
/* A lot of nothing */
|
||||||
#endif
|
#endif
|
||||||
#if BSD & PKCODE
|
#if BSD & PKCODE
|
||||||
struct ltchars oltchars; /* Saved terminal local special character set */
|
struct ltchars oltchars; /* Saved terminal local special character set */
|
||||||
struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
struct ltchars nltchars = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||||
|
|
||||||
/* A lot of nothing */
|
/* A lot of nothing */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -115,7 +118,7 @@ ttopen()
|
|||||||
odsc.dsc$a_pointer = &oname[0];
|
odsc.dsc$a_pointer = &oname[0];
|
||||||
odsc.dsc$w_length = sizeof(oname);
|
odsc.dsc$w_length = sizeof(oname);
|
||||||
status = LIB$SYS_TRNLOG(&idsc, &odsc.dsc$w_length, &odsc);
|
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);
|
exit(status);
|
||||||
if (oname[0] == 0x1B) {
|
if (oname[0] == 0x1B) {
|
||||||
odsc.dsc$a_pointer += 4;
|
odsc.dsc$a_pointer += 4;
|
||||||
@ -127,21 +130,21 @@ ttopen()
|
|||||||
exit(status);
|
exit(status);
|
||||||
status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
|
status = SYS$QIOW(EFN, iochan, IO$_SENSEMODE, iosb, 0, 0,
|
||||||
oldmode, sizeof(oldmode), 0, 0, 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);
|
exit(status);
|
||||||
newmode[0] = oldmode[0];
|
newmode[0] = oldmode[0];
|
||||||
newmode[1] = oldmode[1] | TT$M_NOECHO;
|
newmode[1] = oldmode[1] | TT$M_NOECHO;
|
||||||
#if XONXOFF
|
#if XONXOFF
|
||||||
#else
|
#else
|
||||||
newmode[1] &= ~(TT$M_TTSYNC|TT$M_HOSTSYNC);
|
newmode[1] &= ~(TT$M_TTSYNC | TT$M_HOSTSYNC);
|
||||||
#endif
|
#endif
|
||||||
newmode[2] = oldmode[2] | TT2$M_PASTHRU;
|
newmode[2] = oldmode[2] | TT2$M_PASTHRU;
|
||||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||||
newmode, sizeof(newmode), 0, 0, 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);
|
exit(status);
|
||||||
term.t_nrow = (newmode[1]>>24) - 1;
|
term.t_nrow = (newmode[1] >> 24) - 1;
|
||||||
term.t_ncol = newmode[0]>>16;
|
term.t_ncol = newmode[0] >> 16;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -170,7 +173,7 @@ ttopen()
|
|||||||
#else
|
#else
|
||||||
ioctl(0, TCSETA, &ntermio); /* and activate them */
|
ioctl(0, TCSETA, &ntermio); /* and activate them */
|
||||||
#endif
|
#endif
|
||||||
kbdflgs = fcntl( 0, F_GETFL, 0 );
|
kbdflgs = fcntl(0, F_GETFL, 0);
|
||||||
kbdpoll = FALSE;
|
kbdpoll = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -178,11 +181,11 @@ ttopen()
|
|||||||
gtty(0, &ostate); /* save old state */
|
gtty(0, &ostate); /* save old state */
|
||||||
gtty(0, &nstate); /* get base of new state */
|
gtty(0, &nstate); /* get base of new state */
|
||||||
#if XONXOFF
|
#if XONXOFF
|
||||||
nstate.sg_flags |= (CBREAK|TANDEM);
|
nstate.sg_flags |= (CBREAK | TANDEM);
|
||||||
#else
|
#else
|
||||||
nstate.sg_flags |= RAW;
|
nstate.sg_flags |= RAW;
|
||||||
#endif
|
#endif
|
||||||
nstate.sg_flags &= ~(ECHO|CRMOD); /* no echo for now... */
|
nstate.sg_flags &= ~(ECHO | CRMOD); /* no echo for now... */
|
||||||
stty(0, &nstate); /* set mode */
|
stty(0, &nstate); /* set mode */
|
||||||
ioctl(0, TIOCGETC, &otchars); /* Save old characters */
|
ioctl(0, TIOCGETC, &otchars); /* Save old characters */
|
||||||
ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */
|
ioctl(0, TIOCSETC, &ntchars); /* Place new character into K */
|
||||||
@ -194,8 +197,8 @@ ttopen()
|
|||||||
/* provide a smaller terminal output buffer so that
|
/* provide a smaller terminal output buffer so that
|
||||||
the type ahead detection works better (more often) */
|
the type ahead detection works better (more often) */
|
||||||
setbuffer(stdout, &tobuf[0], TBUFSIZ);
|
setbuffer(stdout, &tobuf[0], TBUFSIZ);
|
||||||
signal(SIGTSTP,SIG_DFL); /* set signals so that we can */
|
signal(SIGTSTP, SIG_DFL); /* set signals so that we can */
|
||||||
signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */
|
signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -203,8 +206,8 @@ ttopen()
|
|||||||
/* provide a smaller terminal output buffer so that
|
/* provide a smaller terminal output buffer so that
|
||||||
the type ahead detection works better (more often) */
|
the type ahead detection works better (more often) */
|
||||||
setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ);
|
setvbuf(stdout, &tobuf[0], _IOFBF, TBUFSIZ);
|
||||||
signal(SIGTSTP,SIG_DFL); /* set signals so that we can */
|
signal(SIGTSTP, SIG_DFL); /* set signals so that we can */
|
||||||
signal(SIGCONT,rtfrmshell); /* suspend & restart emacs */
|
signal(SIGCONT, rtfrmshell); /* suspend & restart emacs */
|
||||||
TTflush();
|
TTflush();
|
||||||
#endif /* __hpux */
|
#endif /* __hpux */
|
||||||
|
|
||||||
@ -228,7 +231,7 @@ ttclose()
|
|||||||
ttflush();
|
ttflush();
|
||||||
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
status = SYS$QIOW(EFN, iochan, IO$_SETMODE, iosb, 0, 0,
|
||||||
oldmode, sizeof(oldmode), 0, 0, 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);
|
exit(status);
|
||||||
status = SYS$DASSGN(iochan);
|
status = SYS$DASSGN(iochan);
|
||||||
if (status != SS$_NORMAL)
|
if (status != SS$_NORMAL)
|
||||||
@ -295,7 +298,8 @@ ttflush()
|
|||||||
|
|
||||||
status = SS$_NORMAL;
|
status = SS$_NORMAL;
|
||||||
if (nobuf != 0) {
|
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);
|
iosb, 0, 0, obuf, nobuf, 0, 0, 0, 0);
|
||||||
if (status == SS$_NORMAL)
|
if (status == SS$_NORMAL)
|
||||||
status = iosb[0] & 0xFFFF;
|
status = iosb[0] & 0xFFFF;
|
||||||
@ -346,23 +350,24 @@ ttgetc()
|
|||||||
ibufi = 0;
|
ibufi = 0;
|
||||||
term[0] = 0;
|
term[0] = 0;
|
||||||
term[1] = 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);
|
iosb, 0, 0, ibuf, NIBUF, 0, term, 0, 0);
|
||||||
if (status != SS$_NORMAL)
|
if (status != SS$_NORMAL)
|
||||||
exit(status);
|
exit(status);
|
||||||
status = iosb[0] & 0xFFFF;
|
status = iosb[0] & 0xFFFF;
|
||||||
if (status!=SS$_NORMAL && status!=SS$_TIMEOUT &&
|
if (status != SS$_NORMAL && status != SS$_TIMEOUT &&
|
||||||
status!=SS$_DATAOVERUN)
|
status != SS$_DATAOVERUN)
|
||||||
exit(status);
|
exit(status);
|
||||||
nibuf = (iosb[0]>>16) + (iosb[1]>>16);
|
nibuf = (iosb[0] >> 16) + (iosb[1] >> 16);
|
||||||
if (nibuf == 0) {
|
if (nibuf == 0) {
|
||||||
status = SYS$QIOW(EFN, iochan, IO$_READLBLK,
|
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
|
if (status != SS$_NORMAL
|
||||||
|| (status = (iosb[0]&0xFFFF)) != SS$_NORMAL)
|
|| (status = (iosb[0] & 0xFFFF)) != SS$_NORMAL)
|
||||||
if (status != SS$_DATAOVERUN)
|
if (status != SS$_DATAOVERUN)
|
||||||
exit(status);
|
exit(status);
|
||||||
nibuf = (iosb[0]>>16) + (iosb[1]>>16);
|
nibuf = (iosb[0] >> 16) + (iosb[1] >> 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (ibuf[ibufi++] & 0xFF); /* Allow multinational */
|
return (ibuf[ibufi++] & 0xFF); /* Allow multinational */
|
||||||
@ -375,32 +380,30 @@ ttgetc()
|
|||||||
if (nxtchar >= 0) {
|
if (nxtchar >= 0) {
|
||||||
c = nxtchar;
|
c = nxtchar;
|
||||||
nxtchar = -1;
|
nxtchar = -1;
|
||||||
return(c);
|
return (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* call the dos to get a char */
|
/* call the dos to get a char */
|
||||||
rg.h.ah = 7; /* dos Direct Console Input call */
|
rg.h.ah = 7; /* dos Direct Console Input call */
|
||||||
intdos(&rg, &rg);
|
intdos(&rg, &rg);
|
||||||
c = rg.h.al; /* grab the char */
|
c = rg.h.al; /* grab the char */
|
||||||
return(c & 255);
|
return (c & 255);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if V7 | BSD
|
#if V7 | BSD
|
||||||
return(255 & fgetc(stdin)); /* 8BIT P.K. */
|
return (255 & fgetc(stdin)); /* 8BIT P.K. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USG
|
#if USG
|
||||||
if( kbdqp )
|
if (kbdqp)
|
||||||
kbdqp = FALSE;
|
kbdqp = FALSE;
|
||||||
else
|
else {
|
||||||
{
|
if (kbdpoll && fcntl(0, F_SETFL, kbdflgs) < 0)
|
||||||
if( kbdpoll && fcntl( 0, F_SETFL, kbdflgs ) < 0 )
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
kbdpoll = FALSE;
|
kbdpoll = FALSE;
|
||||||
while (read(0, &kbdq, 1) != 1)
|
while (read(0, &kbdq, 1) != 1);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
return ( kbdq & 255 );
|
return (kbdq & 255);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,40 +413,38 @@ ttgetc()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typahead()
|
typahead()
|
||||||
|
|
||||||
{
|
{
|
||||||
#if MSDOS & (MSC | TURBO)
|
#if MSDOS & (MSC | TURBO)
|
||||||
if (kbhit() != 0)
|
if (kbhit() != 0)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
else
|
else
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BSD
|
#if BSD
|
||||||
int x; /* holds # of pending chars */
|
int x; /* holds # of pending chars */
|
||||||
|
|
||||||
return((ioctl(0,FIONREAD,&x) < 0) ? 0 : x);
|
return ((ioctl(0, FIONREAD, &x) < 0) ? 0 : x);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if PKCODE & VMS
|
#if PKCODE & VMS
|
||||||
return(ibufi < nibuf);
|
return (ibufi < nibuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USG
|
#if USG
|
||||||
if( !kbdqp )
|
if (!kbdqp) {
|
||||||
{
|
if (!kbdpoll && fcntl(0, F_SETFL, kbdflgs | O_NDELAY) < 0)
|
||||||
if( !kbdpoll && fcntl( 0, F_SETFL, kbdflgs | O_NDELAY ) < 0 )
|
return (FALSE);
|
||||||
return(FALSE);
|
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
kbdpoll = 1;
|
kbdpoll = 1;
|
||||||
#endif
|
#endif
|
||||||
kbdqp = (1 == read( 0, &kbdq, 1 ));
|
kbdqp = (1 == read(0, &kbdq, 1));
|
||||||
}
|
}
|
||||||
return ( kbdqp );
|
return (kbdqp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !UNIX & !VMS & !MSDOS
|
#if !UNIX & !VMS & !MSDOS
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
72
vmsvt.c
72
vmsvt.c
@ -34,8 +34,8 @@ int vmsfcol(), vmsbcol();
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/** SMG stuff **/
|
/** SMG stuff **/
|
||||||
static char * begin_reverse, * end_reverse, * erase_to_end_line;
|
static char *begin_reverse, *end_reverse, *erase_to_end_line;
|
||||||
static char * erase_whole_display;
|
static char *erase_whole_display;
|
||||||
static int termtype;
|
static int termtype;
|
||||||
|
|
||||||
#define SMG$K_BEGIN_REVERSE 0x1bf
|
#define SMG$K_BEGIN_REVERSE 0x1bf
|
||||||
@ -61,10 +61,12 @@ TERM term = {
|
|||||||
#else
|
#else
|
||||||
24 - 1, /* Max number of rows allowable */
|
24 - 1, /* Max number of rows allowable */
|
||||||
#endif
|
#endif
|
||||||
/* Filled in */ - 1, /* Current number of rows used */
|
/* Filled in */ -1,
|
||||||
|
/* Current number of rows used */
|
||||||
MAXCOL, /* Max number of columns */
|
MAXCOL, /* Max number of columns */
|
||||||
/* Filled in */ 0, /* Current number of columns */
|
/* Filled in */ 0,
|
||||||
64, /* Min margin for extended lines*/
|
/* Current number of columns */
|
||||||
|
64, /* Min margin for extended lines */
|
||||||
8, /* Size of scroll region */
|
8, /* Size of scroll region */
|
||||||
100, /* # times thru update to pause */
|
100, /* # times thru update to pause */
|
||||||
vmsopen, /* Open terminal at the start */
|
vmsopen, /* Open terminal at the start */
|
||||||
@ -95,7 +97,7 @@ TERM term = {
|
|||||||
* Nothing returned
|
* Nothing returned
|
||||||
***/
|
***/
|
||||||
ttputs(string)
|
ttputs(string)
|
||||||
char * string; /* String to write */
|
char *string; /* String to write */
|
||||||
{
|
{
|
||||||
if (string)
|
if (string)
|
||||||
while (*string != '\0')
|
while (*string != '\0')
|
||||||
@ -117,7 +119,7 @@ int col; /* Column position */
|
|||||||
static int request_code = SMG$K_SET_CURSOR_ABS;
|
static int request_code = SMG$K_SET_CURSOR_ABS;
|
||||||
static int max_buffer_length = sizeof(buffer);
|
static int max_buffer_length = sizeof(buffer);
|
||||||
static int arg_list[3] = { 2 };
|
static int arg_list[3] = { 2 };
|
||||||
register char * cp;
|
register char *cp;
|
||||||
|
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
@ -133,10 +135,11 @@ int col; /* Column position */
|
|||||||
&max_buffer_length, /* Maximum buffer length */
|
&max_buffer_length, /* Maximum buffer length */
|
||||||
&ret_length, /* Return length */
|
&ret_length, /* Return length */
|
||||||
buffer, /* Capability data buffer */
|
buffer, /* Capability data buffer */
|
||||||
arg_list) /* Argument list array */
|
arg_list)
|
||||||
|
|
||||||
|
/* Argument list array */
|
||||||
/* We'll know soon enough if this doesn't work */
|
/* We'll know soon enough if this doesn't work */
|
||||||
& 1) == 0) {
|
&1) == 0) {
|
||||||
ttputs("OOPS");
|
ttputs("OOPS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -150,18 +153,19 @@ int col; /* Column position */
|
|||||||
|
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
|
|
||||||
vmsscroll_reg(from,to,howmany)
|
vmsscroll_reg(from, to, howmany)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if (to == from) return;
|
if (to == from)
|
||||||
|
return;
|
||||||
if (to < from) {
|
if (to < from) {
|
||||||
vmsscrollregion(to, from + howmany - 1);
|
vmsscrollregion(to, from + howmany - 1);
|
||||||
vmsmove(from + howmany - 1,0);
|
vmsmove(from + howmany - 1, 0);
|
||||||
for (i = from - to; i > 0; i--)
|
for (i = from - to; i > 0; i--)
|
||||||
ttputs(scroll_forward);
|
ttputs(scroll_forward);
|
||||||
} else { /* from < to */
|
} else { /* from < to */
|
||||||
vmsscrollregion(from, to + howmany - 1);
|
vmsscrollregion(from, to + howmany - 1);
|
||||||
vmsmove(from,0);
|
vmsmove(from, 0);
|
||||||
for (i = to - from; i > 0; i--)
|
for (i = to - from; i > 0; i--)
|
||||||
ttputs(scroll_reverse);
|
ttputs(scroll_reverse);
|
||||||
}
|
}
|
||||||
@ -177,7 +181,7 @@ int bot; /* Bottom position */
|
|||||||
static int request_code = SMG$K_SET_SCROLL_REGION;
|
static int request_code = SMG$K_SET_SCROLL_REGION;
|
||||||
static int max_buffer_length = sizeof(buffer);
|
static int max_buffer_length = sizeof(buffer);
|
||||||
static int arg_list[3] = { 2 };
|
static int arg_list[3] = { 2 };
|
||||||
register char * cp;
|
register char *cp;
|
||||||
|
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
@ -193,10 +197,11 @@ int bot; /* Bottom position */
|
|||||||
&max_buffer_length, /* Maximum buffer length */
|
&max_buffer_length, /* Maximum buffer length */
|
||||||
&ret_length, /* Return length */
|
&ret_length, /* Return length */
|
||||||
buffer, /* Capability data buffer */
|
buffer, /* Capability data buffer */
|
||||||
arg_list) /* Argument list array */
|
arg_list)
|
||||||
|
|
||||||
|
/* Argument list array */
|
||||||
/* We'll know soon enough if this doesn't work */
|
/* We'll know soon enough if this doesn't work */
|
||||||
& 1) == 0) {
|
&1) == 0) {
|
||||||
ttputs("OOPS");
|
ttputs("OOPS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -295,12 +300,12 @@ vmsbeep()
|
|||||||
* Returns: Escape sequence
|
* Returns: Escape sequence
|
||||||
* NULL No escape sequence available
|
* NULL No escape sequence available
|
||||||
***/
|
***/
|
||||||
char * vmsgetstr(request_code)
|
char *vmsgetstr(request_code)
|
||||||
int request_code; /* Request code */
|
int request_code; /* Request code */
|
||||||
{
|
{
|
||||||
register char * result;
|
register char *result;
|
||||||
static char seq_storage[1024];
|
static char seq_storage[1024];
|
||||||
static char * buffer = seq_storage;
|
static char *buffer = seq_storage;
|
||||||
static int arg_list[2] = { 1, 1 };
|
static int arg_list[2] = { 1, 1 };
|
||||||
int max_buffer_length, ret_length;
|
int max_buffer_length, ret_length;
|
||||||
|
|
||||||
@ -313,25 +318,25 @@ int request_code; /* Request code */
|
|||||||
if ((smg$get_term_data( /* Get terminal data */
|
if ((smg$get_term_data( /* Get terminal data */
|
||||||
&termtype, /* Terminal table address */
|
&termtype, /* Terminal table address */
|
||||||
&request_code, /* Request code */
|
&request_code, /* Request code */
|
||||||
&max_buffer_length,/* Maximum buffer length */
|
&max_buffer_length, /* Maximum buffer length */
|
||||||
&ret_length, /* Return length */
|
&ret_length, /* Return length */
|
||||||
buffer, /* Capability data buffer */
|
buffer, /* Capability data buffer */
|
||||||
arg_list) /* Argument list array */
|
arg_list)
|
||||||
|
|
||||||
|
|
||||||
|
/* Argument list array */
|
||||||
/* If this doesn't work, try again with no arguments */
|
/* 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 */
|
&termtype, /* Terminal table address */
|
||||||
&request_code, /* Request code */
|
&request_code, /* Request code */
|
||||||
&max_buffer_length,/* Maximum buffer length */
|
&max_buffer_length, /* Maximum buffer length */
|
||||||
&ret_length, /* Return length */
|
&ret_length, /* Return length */
|
||||||
buffer) /* Capability data buffer */
|
buffer)
|
||||||
|
|
||||||
|
|
||||||
|
/* Capability data buffer */
|
||||||
/* Return NULL pointer if capability is not available */
|
/* Return NULL pointer if capability is not available */
|
||||||
|
&1) == 0)
|
||||||
& 1) == 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Check for empty result */
|
/* Check for empty result */
|
||||||
@ -385,7 +390,7 @@ vmsgtty()
|
|||||||
/* Assign input to a channel */
|
/* Assign input to a channel */
|
||||||
status = sys$assign(&devnam, &fd, 0, 0);
|
status = sys$assign(&devnam, &fd, 0, 0);
|
||||||
if ((status & 1) == 0)
|
if ((status & 1) == 0)
|
||||||
exit (status);
|
exit(status);
|
||||||
|
|
||||||
/* Get terminal characteristics */
|
/* Get terminal characteristics */
|
||||||
status = sys$qiow( /* Queue and wait */
|
status = sys$qiow( /* Queue and wait */
|
||||||
@ -421,7 +426,8 @@ vmsopen()
|
|||||||
vmsgtty();
|
vmsgtty();
|
||||||
if (tc.t_type == TT$_UNKNOWN) {
|
if (tc.t_type == TT$_UNKNOWN) {
|
||||||
printf("Terminal type is unknown!\n");
|
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");
|
printf("Or get help on SET TERMINAL/DEVICE_TYPE\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
@ -488,10 +494,10 @@ vmskclose()
|
|||||||
***/
|
***/
|
||||||
#if FNLABEL
|
#if FNLABEL
|
||||||
fnclabel(f, n) /* label a function key */
|
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 */
|
/* on machines with no function keys...don't bother */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
43
vt52.c
43
vt52.c
@ -54,8 +54,8 @@ extern int vt52bcol();
|
|||||||
* terminal I/O code.
|
* terminal I/O code.
|
||||||
*/
|
*/
|
||||||
TERM term = {
|
TERM term = {
|
||||||
NROW-1,
|
NROW - 1,
|
||||||
NROW-1,
|
NROW - 1,
|
||||||
NCOL,
|
NCOL,
|
||||||
NCOL,
|
NCOL,
|
||||||
MARGIN,
|
MARGIN,
|
||||||
@ -87,8 +87,8 @@ vt52move(row, col)
|
|||||||
{
|
{
|
||||||
ttputc(ESC);
|
ttputc(ESC);
|
||||||
ttputc('Y');
|
ttputc('Y');
|
||||||
ttputc(row+BIAS);
|
ttputc(row + BIAS);
|
||||||
ttputc(col+BIAS);
|
ttputc(col + BIAS);
|
||||||
}
|
}
|
||||||
|
|
||||||
vt52eeol()
|
vt52eeol()
|
||||||
@ -103,33 +103,31 @@ vt52eeop()
|
|||||||
ttputc('J');
|
ttputc('J');
|
||||||
}
|
}
|
||||||
|
|
||||||
vt52rev(status) /* set the reverse video state */
|
vt52rev(status)
|
||||||
|
/* set the reverse video state */
|
||||||
int status; /* TRUE = reverse video, FALSE = normal video */
|
int status; /* TRUE = reverse video, FALSE = normal video */
|
||||||
|
|
||||||
{
|
{
|
||||||
/* can't do this here, so we won't */
|
/* can't do this here, so we won't */
|
||||||
}
|
}
|
||||||
|
|
||||||
vt52cres() /* change screen resolution - (not here though) */
|
vt52cres()
|
||||||
|
{ /* change screen resolution - (not here though) */
|
||||||
{
|
return (TRUE);
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spal() /* change palette string */
|
spal()
|
||||||
|
{ /* change palette string */
|
||||||
{
|
|
||||||
/* Does nothing here */
|
/* Does nothing here */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if COLOR
|
#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
|
#endif
|
||||||
|
|
||||||
@ -160,30 +158,27 @@ vt52open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
vt52kopen()
|
vt52kopen()
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
vt52kclose()
|
vt52kclose()
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if FNLABEL
|
#if FNLABEL
|
||||||
fnclabel(f, n) /* label a function key */
|
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 */
|
/* on machines with no function keys...don't bother */
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|
||||||
vt52hello()
|
vt52hello()
|
||||||
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
169
window.c
169
window.c
@ -16,30 +16,29 @@
|
|||||||
* redisplay code does). With no argument it defaults to 0. Bound to M-!.
|
* redisplay code does). With no argument it defaults to 0. Bound to M-!.
|
||||||
*/
|
*/
|
||||||
reposition(f, n)
|
reposition(f, n)
|
||||||
{
|
{
|
||||||
if (f == FALSE) /* default to 0 to center screen */
|
if (f == FALSE) /* default to 0 to center screen */
|
||||||
n = 0;
|
n = 0;
|
||||||
curwp->w_force = n;
|
curwp->w_force = n;
|
||||||
curwp->w_flag |= WFFORCE;
|
curwp->w_flag |= WFFORCE;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Refresh the screen. With no argument, it just does the refresh. With an
|
* Refresh the screen. With no argument, it just does the refresh. With an
|
||||||
* argument it recenters "." in the current window. Bound to "C-L".
|
* argument it recenters "." in the current window. Bound to "C-L".
|
||||||
*/
|
*/
|
||||||
refresh(f, n)
|
refresh(f, n)
|
||||||
{
|
{
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
sgarbf = TRUE;
|
sgarbf = TRUE;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
curwp->w_force = 0; /* Center dot. */
|
curwp->w_force = 0; /* Center dot. */
|
||||||
curwp->w_flag |= WFFORCE;
|
curwp->w_flag |= WFFORCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The command make the next window (next => down the screen) the current
|
* 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;
|
wp = wp->w_wndp;
|
||||||
} else {
|
} else {
|
||||||
mlwrite("Window number out of range");
|
mlwrite("Window number out of range");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
} else
|
} else if ((wp = curwp->w_wndp) == NULL)
|
||||||
if ((wp = curwp->w_wndp) == NULL)
|
|
||||||
wp = wheadp;
|
wp = wheadp;
|
||||||
curwp = wp;
|
curwp = wp;
|
||||||
curbp = wp->w_bufp;
|
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 we have an argument, we mean the nth window from the bottom */
|
||||||
if (f)
|
if (f)
|
||||||
return(nextwind(f, -n));
|
return (nextwind(f, -n));
|
||||||
|
|
||||||
wp1 = wheadp;
|
wp1 = wheadp;
|
||||||
wp2 = curwp;
|
wp2 = curwp;
|
||||||
@ -144,30 +142,26 @@ int n;
|
|||||||
* "C-X C-P".
|
* "C-X C-P".
|
||||||
*/
|
*/
|
||||||
mvupwind(f, n)
|
mvupwind(f, n)
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
{
|
{
|
||||||
register LINE *lp;
|
register LINE *lp;
|
||||||
register int i;
|
register int i;
|
||||||
|
|
||||||
lp = curwp->w_linep;
|
lp = curwp->w_linep;
|
||||||
|
|
||||||
if (n < 0)
|
if (n < 0) {
|
||||||
{
|
while (n++ && lp != curbp->b_linep)
|
||||||
while (n++ && lp!=curbp->b_linep)
|
|
||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
}
|
} else {
|
||||||
else
|
while (n-- && lback(lp) != curbp->b_linep)
|
||||||
{
|
|
||||||
while (n-- && lback(lp)!=curbp->b_linep)
|
|
||||||
lp = lback(lp);
|
lp = lback(lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_flag |= WFHARD; /* Mode line is OK. */
|
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)
|
if (lp == curwp->w_dotp)
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
if (lp == curbp->b_linep)
|
if (lp == curbp->b_linep)
|
||||||
@ -176,7 +170,7 @@ mvupwind(f, n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lp = curwp->w_linep;
|
lp = curwp->w_linep;
|
||||||
i = curwp->w_ntrows/2;
|
i = curwp->w_ntrows / 2;
|
||||||
|
|
||||||
while (i-- && lp != curbp->b_linep)
|
while (i-- && lp != curbp->b_linep)
|
||||||
lp = lforw(lp);
|
lp = lforw(lp);
|
||||||
@ -184,7 +178,7 @@ mvupwind(f, n)
|
|||||||
curwp->w_dotp = lp;
|
curwp->w_dotp = lp;
|
||||||
curwp->w_doto = 0;
|
curwp->w_doto = 0;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This command makes the current window the only window on the screen. Bound
|
* This command makes the current window the only window on the screen. Bound
|
||||||
@ -223,14 +217,14 @@ onlywind(f, n)
|
|||||||
}
|
}
|
||||||
lp = curwp->w_linep;
|
lp = curwp->w_linep;
|
||||||
i = curwp->w_toprow;
|
i = curwp->w_toprow;
|
||||||
while (i!=0 && lback(lp)!=curbp->b_linep) {
|
while (i != 0 && lback(lp) != curbp->b_linep) {
|
||||||
--i;
|
--i;
|
||||||
lp = lback(lp);
|
lp = lback(lp);
|
||||||
}
|
}
|
||||||
curwp->w_toprow = 0;
|
curwp->w_toprow = 0;
|
||||||
curwp->w_ntrows = term.t_nrow-1;
|
curwp->w_ntrows = term.t_nrow - 1;
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_flag |= WFMODE|WFHARD;
|
curwp->w_flag |= WFMODE | WFHARD;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +233,7 @@ onlywind(f, n)
|
|||||||
* or, if it is the top window, the window below. Bound to C-X 0.
|
* 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 */
|
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 there is only one window, don't delete it */
|
||||||
if (wheadp->w_wndp == NULL) {
|
if (wheadp->w_wndp == NULL) {
|
||||||
mlwrite("Can not delete this window");
|
mlwrite("Can not delete this window");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find window before curwp in linked list */
|
/* find window before curwp in linked list */
|
||||||
@ -275,7 +269,7 @@ int f, n; /* arguments are ignored for this command */
|
|||||||
wp = wp->w_wndp;
|
wp = wp->w_wndp;
|
||||||
}
|
}
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
wp->w_toprow = 0;
|
wp->w_toprow = 0;
|
||||||
wp->w_ntrows += target;
|
wp->w_ntrows += target;
|
||||||
} else {
|
} else {
|
||||||
@ -287,7 +281,7 @@ int f, n; /* arguments are ignored for this command */
|
|||||||
wp = wp->w_wndp;
|
wp = wp->w_wndp;
|
||||||
}
|
}
|
||||||
if (wp == NULL)
|
if (wp == NULL)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
wp->w_ntrows += 1 + curwp->w_ntrows;
|
wp->w_ntrows += 1 + curwp->w_ntrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,13 +296,13 @@ int f, n; /* arguments are ignored for this command */
|
|||||||
wheadp = curwp->w_wndp;
|
wheadp = curwp->w_wndp;
|
||||||
else
|
else
|
||||||
lwp->w_wndp = curwp->w_wndp;
|
lwp->w_wndp = curwp->w_wndp;
|
||||||
free((char *)curwp);
|
free((char *) curwp);
|
||||||
curwp = wp;
|
curwp = wp;
|
||||||
wp->w_flag |= WFHARD;
|
wp->w_flag |= WFHARD;
|
||||||
curbp = wp->w_bufp;
|
curbp = wp->w_bufp;
|
||||||
cknewwindow();
|
cknewwindow();
|
||||||
upmode();
|
upmode();
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -355,8 +349,8 @@ int f, n; /* default flag and numeric argument */
|
|||||||
wp->w_fcolor = gfcolor;
|
wp->w_fcolor = gfcolor;
|
||||||
wp->w_bcolor = gbcolor;
|
wp->w_bcolor = gbcolor;
|
||||||
#endif
|
#endif
|
||||||
ntru = (curwp->w_ntrows-1) / 2; /* Upper size */
|
ntru = (curwp->w_ntrows - 1) / 2; /* Upper size */
|
||||||
ntrl = (curwp->w_ntrows-1) - ntru; /* Lower size */
|
ntrl = (curwp->w_ntrows - 1) - ntru; /* Lower size */
|
||||||
lp = curwp->w_linep;
|
lp = curwp->w_linep;
|
||||||
ntrd = 0;
|
ntrd = 0;
|
||||||
while (lp != curwp->w_dotp) {
|
while (lp != curwp->w_dotp) {
|
||||||
@ -371,7 +365,7 @@ int f, n; /* default flag and numeric argument */
|
|||||||
curwp->w_ntrows = ntru;
|
curwp->w_ntrows = ntru;
|
||||||
wp->w_wndp = curwp->w_wndp;
|
wp->w_wndp = curwp->w_wndp;
|
||||||
curwp->w_wndp = wp;
|
curwp->w_wndp = wp;
|
||||||
wp->w_toprow = curwp->w_toprow+ntru+1;
|
wp->w_toprow = curwp->w_toprow + ntru + 1;
|
||||||
wp->w_ntrows = ntrl;
|
wp->w_ntrows = ntrl;
|
||||||
} else { /* Old is lower window */
|
} else { /* Old is lower window */
|
||||||
wp1 = NULL;
|
wp1 = NULL;
|
||||||
@ -395,8 +389,8 @@ int f, n; /* default flag and numeric argument */
|
|||||||
}
|
}
|
||||||
curwp->w_linep = lp; /* Adjust the top lines */
|
curwp->w_linep = lp; /* Adjust the top lines */
|
||||||
wp->w_linep = lp; /* if necessary. */
|
wp->w_linep = lp; /* if necessary. */
|
||||||
curwp->w_flag |= WFMODE|WFHARD;
|
curwp->w_flag |= WFMODE | WFHARD;
|
||||||
wp->w_flag |= WFMODE|WFHARD;
|
wp->w_flag |= WFMODE | WFHARD;
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,7 +412,7 @@ enlargewind(f, n)
|
|||||||
mlwrite("Only one window");
|
mlwrite("Only one window");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if ((adjwp=curwp->w_wndp) == NULL) {
|
if ((adjwp = curwp->w_wndp) == NULL) {
|
||||||
adjwp = wheadp;
|
adjwp = wheadp;
|
||||||
while (adjwp->w_wndp != curwp)
|
while (adjwp->w_wndp != curwp)
|
||||||
adjwp = adjwp->w_wndp;
|
adjwp = adjwp->w_wndp;
|
||||||
@ -429,13 +423,13 @@ enlargewind(f, n)
|
|||||||
}
|
}
|
||||||
if (curwp->w_wndp == adjwp) { /* Shrink below. */
|
if (curwp->w_wndp == adjwp) { /* Shrink below. */
|
||||||
lp = adjwp->w_linep;
|
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);
|
lp = lforw(lp);
|
||||||
adjwp->w_linep = lp;
|
adjwp->w_linep = lp;
|
||||||
adjwp->w_toprow += n;
|
adjwp->w_toprow += n;
|
||||||
} else { /* Shrink above. */
|
} else { /* Shrink above. */
|
||||||
lp = curwp->w_linep;
|
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);
|
lp = lback(lp);
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_toprow -= n;
|
curwp->w_toprow -= n;
|
||||||
@ -443,11 +437,11 @@ enlargewind(f, n)
|
|||||||
curwp->w_ntrows += n;
|
curwp->w_ntrows += n;
|
||||||
adjwp->w_ntrows -= n;
|
adjwp->w_ntrows -= n;
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFMODE|WFHARD|WFINS;
|
curwp->w_flag |= WFMODE | WFHARD | WFINS;
|
||||||
adjwp->w_flag |= WFMODE|WFHARD|WFKILLS;
|
adjwp->w_flag |= WFMODE | WFHARD | WFKILLS;
|
||||||
#else
|
#else
|
||||||
curwp->w_flag |= WFMODE|WFHARD;
|
curwp->w_flag |= WFMODE | WFHARD;
|
||||||
adjwp->w_flag |= WFMODE|WFHARD;
|
adjwp->w_flag |= WFMODE | WFHARD;
|
||||||
#endif
|
#endif
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -469,7 +463,7 @@ shrinkwind(f, n)
|
|||||||
mlwrite("Only one window");
|
mlwrite("Only one window");
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
if ((adjwp=curwp->w_wndp) == NULL) {
|
if ((adjwp = curwp->w_wndp) == NULL) {
|
||||||
adjwp = wheadp;
|
adjwp = wheadp;
|
||||||
while (adjwp->w_wndp != curwp)
|
while (adjwp->w_wndp != curwp)
|
||||||
adjwp = adjwp->w_wndp;
|
adjwp = adjwp->w_wndp;
|
||||||
@ -480,13 +474,14 @@ shrinkwind(f, n)
|
|||||||
}
|
}
|
||||||
if (curwp->w_wndp == adjwp) { /* Grow below. */
|
if (curwp->w_wndp == adjwp) { /* Grow below. */
|
||||||
lp = adjwp->w_linep;
|
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);
|
lp = lback(lp);
|
||||||
adjwp->w_linep = lp;
|
adjwp->w_linep = lp;
|
||||||
adjwp->w_toprow -= n;
|
adjwp->w_toprow -= n;
|
||||||
} else { /* Grow above. */
|
} else { /* Grow above. */
|
||||||
lp = curwp->w_linep;
|
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);
|
lp = lforw(lp);
|
||||||
curwp->w_linep = lp;
|
curwp->w_linep = lp;
|
||||||
curwp->w_toprow += n;
|
curwp->w_toprow += n;
|
||||||
@ -494,11 +489,11 @@ shrinkwind(f, n)
|
|||||||
curwp->w_ntrows -= n;
|
curwp->w_ntrows -= n;
|
||||||
adjwp->w_ntrows += n;
|
adjwp->w_ntrows += n;
|
||||||
#if SCROLLCODE
|
#if SCROLLCODE
|
||||||
curwp->w_flag |= WFMODE|WFHARD|WFKILLS;
|
curwp->w_flag |= WFMODE | WFHARD | WFKILLS;
|
||||||
adjwp->w_flag |= WFMODE|WFHARD|WFINS;
|
adjwp->w_flag |= WFMODE | WFHARD | WFINS;
|
||||||
#else
|
#else
|
||||||
curwp->w_flag |= WFMODE|WFHARD;
|
curwp->w_flag |= WFMODE | WFHARD;
|
||||||
adjwp->w_flag |= WFMODE|WFHARD;
|
adjwp->w_flag |= WFMODE | WFHARD;
|
||||||
#endif
|
#endif
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
@ -514,16 +509,16 @@ int f, n; /* default flag and numeric argument */
|
|||||||
|
|
||||||
/* must have a non-default argument, else ignore call */
|
/* must have a non-default argument, else ignore call */
|
||||||
if (f == FALSE)
|
if (f == FALSE)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
/* find out what to do */
|
/* find out what to do */
|
||||||
clines = curwp->w_ntrows;
|
clines = curwp->w_ntrows;
|
||||||
|
|
||||||
/* already the right size? */
|
/* already the right size? */
|
||||||
if (clines == n)
|
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
|
* Pick the uppermost window that isn't the current window. An LRU algorithm
|
||||||
* might be better. Return a pointer, or NULL on error.
|
* might be better. Return a pointer, or NULL on error.
|
||||||
*/
|
*/
|
||||||
WINDOW *
|
WINDOW *wpopup()
|
||||||
wpopup()
|
|
||||||
{
|
{
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
@ -540,37 +534,33 @@ wpopup()
|
|||||||
&& splitwind(FALSE, 0) == FALSE) /* and it won't split */
|
&& splitwind(FALSE, 0) == FALSE) /* and it won't split */
|
||||||
return (NULL);
|
return (NULL);
|
||||||
wp = wheadp; /* Find window to use */
|
wp = wheadp; /* Find window to use */
|
||||||
while (wp!=NULL && wp==curwp)
|
while (wp != NULL && wp == curwp)
|
||||||
wp = wp->w_wndp;
|
wp = wp->w_wndp;
|
||||||
return (wp);
|
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);
|
nextwind(FALSE, 1);
|
||||||
backpage(f, n);
|
backpage(f, n);
|
||||||
prevwind(FALSE, 1);
|
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);
|
nextwind(FALSE, 1);
|
||||||
forwpage(f, n);
|
forwpage(f, n);
|
||||||
prevwind(FALSE, 1);
|
prevwind(FALSE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
savewnd(f, n) /* save ptr to current window */
|
savewnd(f, n)
|
||||||
|
{ /* save ptr to current window */
|
||||||
{
|
|
||||||
swindow = curwp;
|
swindow = curwp;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
restwnd(f, n) /* restore the saved screen */
|
restwnd(f, n)
|
||||||
|
{ /* restore the saved screen */
|
||||||
{
|
|
||||||
register WINDOW *wp;
|
register WINDOW *wp;
|
||||||
|
|
||||||
/* find the window */
|
/* find the window */
|
||||||
@ -586,11 +576,11 @@ restwnd(f, n) /* restore the saved screen */
|
|||||||
}
|
}
|
||||||
|
|
||||||
mlwrite("(No such window exists)");
|
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 f; /* default flag */
|
||||||
int n; /* numeric argument */
|
int n; /* numeric argument */
|
||||||
|
|
||||||
@ -607,11 +597,11 @@ int n; /* numeric argument */
|
|||||||
/* make sure it's in range */
|
/* make sure it's in range */
|
||||||
if (n < 3 || n > term.t_mrow + 1) {
|
if (n < 3 || n > term.t_mrow + 1) {
|
||||||
mlwrite("%%Screen size out of range");
|
mlwrite("%%Screen size out of range");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (term.t_nrow == n - 1)
|
if (term.t_nrow == n - 1)
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
else if (term.t_nrow < n - 1) {
|
else if (term.t_nrow < n - 1) {
|
||||||
|
|
||||||
/* go to the last window */
|
/* go to the last window */
|
||||||
@ -621,7 +611,7 @@ int n; /* numeric argument */
|
|||||||
|
|
||||||
/* and enlarge it as needed */
|
/* and enlarge it as needed */
|
||||||
wp->w_ntrows = n - wp->w_toprow - 2;
|
wp->w_ntrows = n - wp->w_toprow - 2;
|
||||||
wp->w_flag |= WFHARD|WFMODE;
|
wp->w_flag |= WFHARD | WFMODE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -652,15 +642,16 @@ int n; /* numeric argument */
|
|||||||
lastwp->w_wndp = NULL;
|
lastwp->w_wndp = NULL;
|
||||||
|
|
||||||
/* free the structure */
|
/* free the structure */
|
||||||
free((char *)wp);
|
free((char *) wp);
|
||||||
wp = NULL;
|
wp = NULL;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* need to change this window size? */
|
/* need to change this window size? */
|
||||||
lastline = wp->w_toprow + wp->w_ntrows - 1;
|
lastline = wp->w_toprow + wp->w_ntrows - 1;
|
||||||
if (lastline >= n - 2) {
|
if (lastline >= n - 2) {
|
||||||
wp->w_ntrows = n - wp->w_toprow - 2;
|
wp->w_ntrows =
|
||||||
wp->w_flag |= WFHARD|WFMODE;
|
n - wp->w_toprow - 2;
|
||||||
|
wp->w_flag |= WFHARD | WFMODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,11 +662,11 @@ int n; /* numeric argument */
|
|||||||
/* screen is garbage */
|
/* screen is garbage */
|
||||||
term.t_nrow = n - 1;
|
term.t_nrow = n - 1;
|
||||||
sgarbf = TRUE;
|
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 f; /* default flag */
|
||||||
int n; /* numeric argument */
|
int n; /* numeric argument */
|
||||||
|
|
||||||
@ -689,7 +680,7 @@ int n; /* numeric argument */
|
|||||||
/* make sure it's in range */
|
/* make sure it's in range */
|
||||||
if (n < 10 || n > term.t_mcol) {
|
if (n < 10 || n > term.t_mcol) {
|
||||||
mlwrite("%%Screen width out of range");
|
mlwrite("%%Screen width out of range");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* otherwise, just re-width it (no big deal) */
|
/* otherwise, just re-width it (no big deal) */
|
||||||
@ -705,12 +696,11 @@ int n; /* numeric argument */
|
|||||||
}
|
}
|
||||||
sgarbf = TRUE;
|
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 int sline; /* screen line from top of window */
|
||||||
register LINE *lp; /* scannile line pointer */
|
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 */
|
/* and return the value */
|
||||||
return(sline);
|
return (sline);
|
||||||
}
|
}
|
||||||
|
|
||||||
cknewwindow()
|
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 */
|
/* backup from the <NL> 1 char */
|
||||||
if (!backchar(0, 1))
|
if (!backchar(0, 1))
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* back up until we aren't in a word,
|
/* back up until we aren't in a word,
|
||||||
make sure there is a break in the line */
|
make sure there is a break in the line */
|
||||||
@ -38,28 +38,28 @@ int n; /* numeric argument */
|
|||||||
&& (c != '\t')) {
|
&& (c != '\t')) {
|
||||||
cnt++;
|
cnt++;
|
||||||
if (!backchar(0, 1))
|
if (!backchar(0, 1))
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
/* if we make it to the beginning, start a new line */
|
/* if we make it to the beginning, start a new line */
|
||||||
if (curwp->w_doto == 0) {
|
if (curwp->w_doto == 0) {
|
||||||
gotoeol(FALSE, 0);
|
gotoeol(FALSE, 0);
|
||||||
return(lnewline());
|
return (lnewline());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delete the forward white space */
|
/* delete the forward white space */
|
||||||
if (!forwdel(0, 1))
|
if (!forwdel(0, 1))
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* put in a end of line */
|
/* put in a end of line */
|
||||||
if (!lnewline())
|
if (!lnewline())
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* and past the first word */
|
/* and past the first word */
|
||||||
while (cnt-- > 0) {
|
while (cnt-- > 0) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -105,7 +105,7 @@ forwword(f, n)
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -117,8 +117,8 @@ upperword(f, n)
|
|||||||
{
|
{
|
||||||
register int c;
|
register int c;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
while (n--) {
|
while (n--) {
|
||||||
@ -131,9 +131,9 @@ upperword(f, n)
|
|||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
#else
|
#else
|
||||||
if (c>='a' && c<='z') {
|
if (c >= 'a' && c <= 'z') {
|
||||||
#endif
|
#endif
|
||||||
c -= 'a'-'A';
|
c -= 'a' - 'A';
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
@ -153,8 +153,8 @@ lowerword(f, n)
|
|||||||
{
|
{
|
||||||
register int c;
|
register int c;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
while (n--) {
|
while (n--) {
|
||||||
@ -167,9 +167,9 @@ lowerword(f, n)
|
|||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (isupper(c)) {
|
if (isupper(c)) {
|
||||||
#else
|
#else
|
||||||
if (c>='A' && c<='Z') {
|
if (c >= 'A' && c <= 'Z') {
|
||||||
#endif
|
#endif
|
||||||
c += 'a'-'A';
|
c += 'a' - 'A';
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
@ -190,8 +190,8 @@ capword(f, n)
|
|||||||
{
|
{
|
||||||
register int c;
|
register int c;
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
while (n--) {
|
while (n--) {
|
||||||
@ -204,9 +204,9 @@ capword(f, n)
|
|||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (islower(c)) {
|
if (islower(c)) {
|
||||||
#else
|
#else
|
||||||
if (c>='a' && c<='z') {
|
if (c >= 'a' && c <= 'z') {
|
||||||
#endif
|
#endif
|
||||||
c -= 'a'-'A';
|
c -= 'a' - 'A';
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
@ -217,10 +217,11 @@ capword(f, n)
|
|||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (isupper(c)) {
|
if (isupper(c)) {
|
||||||
#else
|
#else
|
||||||
if (c>='A' && c<='Z') {
|
if (c >= 'A' && c <= 'Z') {
|
||||||
#endif
|
#endif
|
||||||
c += 'a'-'A';
|
c += 'a' - 'A';
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto,
|
||||||
|
c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
@ -245,15 +246,15 @@ delfword(f, n)
|
|||||||
long size; /* # of chars to delete */
|
long size; /* # of chars to delete */
|
||||||
|
|
||||||
/* don't allow this command if we are in read only mode */
|
/* don't allow this command if we are in read only mode */
|
||||||
if (curbp->b_mode&MDVIEW)
|
if (curbp->b_mode & MDVIEW)
|
||||||
return(rdonly());
|
return (rdonly());
|
||||||
|
|
||||||
/* ignore the command if there is a negative argument */
|
/* ignore the command if there is a negative argument */
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* Clear the kill buffer if last command wasn't a kill */
|
/* Clear the kill buffer if last command wasn't a kill */
|
||||||
if ((lastflag&CFKILL) == 0)
|
if ((lastflag & CFKILL) == 0)
|
||||||
kdelete();
|
kdelete();
|
||||||
thisflag |= CFKILL; /* this command is a kill */
|
thisflag |= CFKILL; /* this command is a kill */
|
||||||
|
|
||||||
@ -267,7 +268,7 @@ delfword(f, n)
|
|||||||
/* get us into a word.... */
|
/* get us into a word.... */
|
||||||
while (inword() == FALSE) {
|
while (inword() == FALSE) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
++size;
|
++size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +276,7 @@ delfword(f, n)
|
|||||||
/* skip one word, no whitespace! */
|
/* skip one word, no whitespace! */
|
||||||
while (inword() == TRUE) {
|
while (inword() == TRUE) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
++size;
|
++size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -285,14 +286,14 @@ delfword(f, n)
|
|||||||
/* if we are at EOL; skip to the beginning of the next */
|
/* if we are at EOL; skip to the beginning of the next */
|
||||||
while (curwp->w_doto == llength(curwp->w_dotp)) {
|
while (curwp->w_doto == llength(curwp->w_dotp)) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
++size;
|
++size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move forward till we are at the end of the word */
|
/* move forward till we are at the end of the word */
|
||||||
while (inword() == TRUE) {
|
while (inword() == TRUE) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
++size;
|
++size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,15 +301,15 @@ delfword(f, n)
|
|||||||
if (n != 0)
|
if (n != 0)
|
||||||
while (inword() == FALSE) {
|
while (inword() == FALSE) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
++size;
|
++size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip whitespace and newlines */
|
/* skip whitespace and newlines */
|
||||||
while ((curwp->w_doto == llength(curwp->w_dotp)) ||
|
while ((curwp->w_doto == llength(curwp->w_dotp)) ||
|
||||||
((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ') ||
|
((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ')
|
||||||
(c == '\t')) {
|
|| (c == '\t')) {
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
break;
|
break;
|
||||||
++size;
|
++size;
|
||||||
@ -331,15 +332,15 @@ delbword(f, n)
|
|||||||
long size;
|
long size;
|
||||||
|
|
||||||
/* don't allow this command if we are in read only mode */
|
/* don't allow this command if we are in read only mode */
|
||||||
if (curbp->b_mode&MDVIEW)
|
if (curbp->b_mode & MDVIEW)
|
||||||
return(rdonly());
|
return (rdonly());
|
||||||
|
|
||||||
/* ignore the command if there is a nonpositive argument */
|
/* ignore the command if there is a nonpositive argument */
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
/* Clear the kill buffer if last command wasn't a kill */
|
/* Clear the kill buffer if last command wasn't a kill */
|
||||||
if ((lastflag&CFKILL) == 0)
|
if ((lastflag & CFKILL) == 0)
|
||||||
kdelete();
|
kdelete();
|
||||||
thisflag |= CFKILL; /* this command is a kill */
|
thisflag |= CFKILL; /* this command is a kill */
|
||||||
|
|
||||||
@ -360,7 +361,7 @@ delbword(f, n)
|
|||||||
}
|
}
|
||||||
if (forwchar(FALSE, 1) == FALSE)
|
if (forwchar(FALSE, 1) == FALSE)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
bckdel: return (ldelete(size, TRUE));
|
bckdel:return (ldelete(size, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -377,20 +378,20 @@ inword()
|
|||||||
#if PKCODE
|
#if PKCODE
|
||||||
if (isletter(c))
|
if (isletter(c))
|
||||||
#else
|
#else
|
||||||
if (c>='a' && c<='z')
|
if (c >= 'a' && c <= 'z')
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
if (c>='A' && c<='Z')
|
if (c >= 'A' && c <= 'Z')
|
||||||
#endif
|
#endif
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
if (c>='0' && c<='9')
|
if (c >= '0' && c <= '9')
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WORDPRO
|
#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 */
|
fill column */
|
||||||
|
|
||||||
int f, n; /* deFault flag and Numeric argument */
|
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? */
|
register int dotflag; /* was the last char a period? */
|
||||||
char wbuf[NSTRING]; /* buffer for current word */
|
char wbuf[NSTRING]; /* buffer for current word */
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (fillcol == 0) { /* no fill column set */
|
if (fillcol == 0) { /* no fill column set */
|
||||||
mlwrite("No fill column set");
|
mlwrite("No fill column set");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
#if PKCODE
|
#if PKCODE
|
||||||
justflag = FALSE;
|
justflag = FALSE;
|
||||||
@ -467,7 +468,7 @@ int f, n; /* deFault flag and Numeric argument */
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* and add the word in in either case */
|
/* and add the word in in either case */
|
||||||
for (i=0; i<wordlen; i++) {
|
for (i = 0; i < wordlen; i++) {
|
||||||
linsert(1, wbuf[i]);
|
linsert(1, wbuf[i]);
|
||||||
++clength;
|
++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 */
|
/* and add a last newline for the end of our new paragraph */
|
||||||
lnewline();
|
lnewline();
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PKCODE
|
#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 */
|
fill column and cursor position */
|
||||||
|
|
||||||
int f, n; /* deFault flag and Numeric argument */
|
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 */
|
char wbuf[NSTRING]; /* buffer for current word */
|
||||||
int leftmarg; /* left marginal */
|
int leftmarg; /* left marginal */
|
||||||
|
|
||||||
if (curbp->b_mode&MDVIEW) /* don't allow this command if */
|
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||||
return(rdonly()); /* we are in read only mode */
|
return (rdonly()); /* we are in read only mode */
|
||||||
if (fillcol == 0) { /* no fill column set */
|
if (fillcol == 0) { /* no fill column set */
|
||||||
mlwrite("No fill column set");
|
mlwrite("No fill column set");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
justflag = TRUE;
|
justflag = TRUE;
|
||||||
leftmarg = curwp->w_doto;
|
leftmarg = curwp->w_doto;
|
||||||
if (leftmarg+10 > fillcol) {
|
if (leftmarg + 10 > fillcol) {
|
||||||
leftmarg = 0;
|
leftmarg = 0;
|
||||||
mlwrite("Column too narrow");
|
mlwrite("Column too narrow");
|
||||||
return(FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* record the pointer to the line just past the EOP */
|
/* record the pointer to the line just past the EOP */
|
||||||
@ -565,13 +566,13 @@ int f, n; /* deFault flag and Numeric argument */
|
|||||||
} else {
|
} else {
|
||||||
/* start a new line */
|
/* start a new line */
|
||||||
lnewline();
|
lnewline();
|
||||||
for (i=0; i<leftmarg; i++)
|
for (i = 0; i < leftmarg; i++)
|
||||||
linsert(1, ' ');
|
linsert(1, ' ');
|
||||||
clength = leftmarg;
|
clength = leftmarg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* and add the word in in either case */
|
/* and add the word in in either case */
|
||||||
for (i=0; i<wordlen; i++) {
|
for (i = 0; i < wordlen; i++) {
|
||||||
linsert(1, wbuf[i]);
|
linsert(1, wbuf[i]);
|
||||||
++clength;
|
++clength;
|
||||||
}
|
}
|
||||||
@ -588,12 +589,12 @@ int f, n; /* deFault flag and Numeric argument */
|
|||||||
curwp->w_doto = llength(curwp->w_dotp);
|
curwp->w_doto = llength(curwp->w_dotp);
|
||||||
|
|
||||||
justflag = FALSE;
|
justflag = FALSE;
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#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 f; /* default flag */
|
||||||
int n; /* # of paras to delete */
|
int n; /* # of paras to delete */
|
||||||
|
|
||||||
@ -615,12 +616,12 @@ int n; /* # of paras to delete */
|
|||||||
|
|
||||||
/* and delete it */
|
/* and delete it */
|
||||||
if ((status = killregion(FALSE, 1)) != TRUE)
|
if ((status = killregion(FALSE, 1)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
|
|
||||||
/* and clean up the 2 extra lines */
|
/* and clean up the 2 extra lines */
|
||||||
ldelete(2L, TRUE);
|
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 */
|
/* make sure we have a region to count */
|
||||||
if ((status = getregion(®ion)) != TRUE)
|
if ((status = getregion(®ion)) != TRUE)
|
||||||
return(status);
|
return (status);
|
||||||
lp = region.r_linep;
|
lp = region.r_linep;
|
||||||
offset = region.r_offset;
|
offset = region.r_offset;
|
||||||
size = region.r_size;
|
size = region.r_size;
|
||||||
@ -697,7 +698,7 @@ int f, n; /* ignored numeric arguments */
|
|||||||
|
|
||||||
/* and report on the info */
|
/* and report on the info */
|
||||||
if (nwords > 0L)
|
if (nwords > 0L)
|
||||||
avgch = (int)((100L * nchars) / nwords);
|
avgch = (int) ((100L * nchars) / nwords);
|
||||||
else
|
else
|
||||||
avgch = 0;
|
avgch = 0;
|
||||||
|
|
||||||
@ -712,6 +713,6 @@ int f, n; /* ignored numeric arguments */
|
|||||||
mlwrite("Words %D Chars %D Lines %d Avg chars/word %f",
|
mlwrite("Words %D Chars %D Lines %d Avg chars/word %f",
|
||||||
nwords, nchars, nlines + 1, avgch);
|
nwords, nchars, nlines + 1, avgch);
|
||||||
#endif
|
#endif
|
||||||
return(TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user