home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.wwiv.com
/
ftp.wwiv.com.zip
/
ftp.wwiv.com
/
pub
/
UTILITY
/
ED.ZIP
/
ED.C
next >
Wrap
Text File
|
1988-03-26
|
25KB
|
997 lines
#include <stdio.h>
#include <dos.h>
#include <stdarg.h>
#include <conio.h>
#include "screen.h"
#include "ed.h"
#define scrtop 2
#define null 0
#define HARDCR 20
#define COLORCHAR 3
#define ANSI_AA 100
struct line
{
char s[160];
struct line *next;
struct line *prev;
};
int sx, x, y, savex, savey, scrollt, scrollb, scrwid, scrlen;
int temp, totlines, curline, maxlines, curcol, console;
char scrcol, abt;
char temps[160];
char *savfile, *tabline;
char *_Cdecl strdup(char *s);
int _Cdecl toupper(int ch);
struct line *l; /* Current working line */
struct line *lastl; /* Last line of the text */
struct line *firstl; /* First line of the text */
struct line *templ; /* Temporary line for moves and stuff */
int getkey(void) /* get char & scan code from kb */
{
int key;
key = getch();
return((key == 0) ? getch() + 1000 : key);
} /* getkey */
void scroll(int dir)
{
union REGS reg;
if (dir == UP)
reg.x.ax = 0x0601;
else
reg.x.ax = 0x0701;
reg.h.ch = (char)(scrollt - 1);
reg.h.cl = 0;
reg.h.dh = (char)(scrollb - 1);
reg.h.dl = 79;
reg.h.bh = scrcol;
int86(0x10, ®, ®);
}
void beep(void)
{
printf("\7");
}
void fixsx(void)
{
int i;
curcol = '0';
sx = 0;
for (i = 1; i <= x; ++i)
if (l->s[i] == COLORCHAR)
curcol = l->s[++i];
else if (l->s[i] != HARDCR)
++sx;
}
void fixx(void)
{
int count;
curcol = '0';
count = 0;
x = 1;
while ((x - (count * 2)) < sx)
if (l->s[x] == COLORCHAR)
{
++count;
curcol = l->s[++x];
++x;
}
else
++x;
}
void sansi(char c, ...)
{
va_list ap;
int i, count, param[5];
for (count = 0; count < 5; ++count)
param[count] = 1;
va_start(ap, c);
param[0] = va_arg(ap, int);
param[1] = va_arg(ap, int);
va_end(ap);
switch(c)
{
case ANSI_AA:if (!console)
printf("%c%c", COLORCHAR, param[0]);
break;
case ANSI_KU:--y;
if (y < scrtop)
{
sansi(ANSI_CS, scrtop, scrlen);
sansi(ANSI_SF);
sansi(ANSI_CS, 1, scrlen + 1);
sansi(ANSI_CM, sx, y = scrtop);
sansi(ANSI_SC);
sansi(ANSI_CM, 1, y);
prints("%s", l->s + 1);
sansi(ANSI_RC);
}
else
printf("\033[A");
fixx();
--curline;
break;
case ANSI_KD:++y;
if (y > scrlen)
{
sansi(ANSI_CS, scrtop, scrlen);
sansi(ANSI_SR);
sansi(ANSI_CS, 1, scrlen + 1);
sansi(ANSI_CM, sx, y = scrlen);
sansi(ANSI_SC);
sansi(ANSI_CM, 1, y);
prints("%s", l->s + 1);
sansi(ANSI_RC);
}
else
printf("\033[B");
fixx();
++curline;
break;
case ANSI_KR:if (l->s[x] == COLORCHAR)
{
x += 2;
curcol = l->s[x-1];
}
else if (l->s[x] != HARDCR)
{
printf("\033[C");
++x;
++sx;
}
break;
case ANSI_KL:if (l->s[x - 2] == COLORCHAR)
{
x -= 2;
fixx();
}
else
{
printf("\033[D");
--sx;
--x;
}
break;
/*7*/
case ANSI_SC:printf("\033[s");
savex = sx;
savey = y;
break;
/*8*/
case ANSI_RC:printf("\033[u");
sx = savex;
y = savey;
sansi(ANSI_CM, sx, y);
break;
case ANSI_CL:sansi(ANSI_AA, curcol = '0');
printf("\033[2J\033[H");
break;
case ANSI_CE:sansi(ANSI_AA, '0');
printf("\033[K");
sansi(ANSI_AA, curcol);
break;
case ANSI_CM:printf("\033[%d;%dH", param[1], param[0]);
break;
/**/
case ANSI_CS:printf("\033[%d;%dr", param[0], param[1]);
scrollt = param[0];
scrollb = param[1];
break;
/**/
case ANSI_SF:scroll(DN);
printf("\033D\008 \008");
break;
/**/
case ANSI_SR:printf("\033M\008 \008");
scroll(UP);
break;
case ANSI_MR:printf("\033[7m");
break;
case ANSI_ME:printf("\033[m");
break;
case ANSI_MB:printf("\033[5m");
break;
case ANSI_MD:printf("\033[1m");
break;
default:break;
}
}
void status(char *s)
{
sansi(ANSI_SC);
sansi(ANSI_CM, 1, scrlen + 1);
sansi(ANSI_AA, '0');
sansi(ANSI_CE);
sansi(ANSI_MR);
printf("%s", s);
sansi(ANSI_ME);
sansi(ANSI_AA, curcol);
sansi(ANSI_RC);
}
int realstrlen(char *s)
{
int i = -1;
while (s[++i] != '\0');
return(i);
}
int strlen(char *s)
{
int i, count;
i = -1;
count = 0;
while (s[++i] != '\0')
if (s[i] != HARDCR)
++count;
return(count);
}
int strlens(char *s)
{
int i, count;
i = -1;
count = 0;
while (s[++i] != '\0')
if (s[i] == COLORCHAR)
++i;
else if (s[i] != HARDCR)
++count;
return(count);
}
int prints(char *msg, ...)
{
va_list ap;
char output[160];
int i, ret;
va_start(ap, msg);
ret = vsprintf(output, msg, ap);
va_end(ap);
/**/
sansi(ANSI_AA, curcol);
/**/
i = -1;
while (output[++i] != '\0')
{
if (output[i] == COLORCHAR)
{
sansi(ANSI_AA, output[++i]);
}
else
printf("%c", output[i]);
if (output[i] == HARDCR)
putch(HARDCR);
/* This is a comment for printing out that HARDCR later... */;
}
return(ret);
}
void delete(char *s, int i)
{
char temp[160];
strcpy(temp, s);
strncpy(s, temp, i);
if (temp[i] == COLORCHAR)
strcpy(s + i, temp + i + 2);
else
strcpy(s + i, temp + i + 1);
sansi(ANSI_SC);
prints("%s ", s + i);
sansi(ANSI_RC);
fixx();
}
void deleteword(char *s, int i) /* Remind me to not let it DEL HARDCR */
{
char temp[160];
int start;
strcpy(temp, s);
strncpy(s, temp, i);
start = i;
if (i < strlen(temp))
{
if (temp[i] == ' ')
{
++i;
while ((temp[i] == ' ') && (i < strlen(temp)))
++i;
}
else
{
if (temp[i] == COLORCHAR)
i += 2;
else
++i;
while ((temp[i - 1] != ' ') && ((i - 1) < (strlen(temp) - 1)))
if (temp[i - 1] == COLORCHAR)
i += 2;
else
++i;
}
}
else if (temp[i] == HARDCR)
++i;
strcpy(s + start, temp + i);
sansi(ANSI_SC);
sansi(ANSI_CE);
prints("%s", s + start);
sansi(ANSI_RC);
}
struct line *newline(void)
{
struct line *t;
t = (struct line *) malloc(sizeof(struct line));
strcpy(t->s, " ");
t->next = null;
t->prev = null;
++totlines;
return(t);
}
void nextline(void)
{
if (l->next)
{
l = l->next;
sansi(ANSI_KD);
if (sx > strlens(l->s))
{
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_CM, sx, y);
}
}
}
void prevline(void)
{
if (l->prev)
{
l = l->prev;
sansi(ANSI_KU);
if (sx > strlens(l->s))
{
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_CM, sx, y);
}
}
}
int insert(char *s, int i, int c)
{
char temp[160];
if (strlens(s) < scrwid)
{
strcpy(temp, s);
strncpy(s, temp, i - 1);
s[i] = c;
strcpy(s + i + 1, temp + i);
sansi(ANSI_SC);
prints("%s", s + i);
sansi(ANSI_RC);
return(strlen(s));
}
else if (i == strlen(s)) /*wordwrap*/
{
templ = newline();
templ->prev = l;
templ->next = l->next;
if (l->next)
l->next->prev = templ;
l->next = templ;
if (c != ' ')
{
while (l->s[x] != ' ')
sansi(ANSI_KL);
i = l->s[strlen(l->s)];
if (curcol != '0')
{
templ->s[1] = COLORCHAR;
templ->s[2] = curcol;
strcpy(templ->s + 3, l->s + x + 1);
}
else
strcpy(templ->s + 1, l->s + x + 1);
l->s[x] = 0;
if (i != HARDCR)
templ->s[strlen(templ->s) + 1] = 0;
else
{
templ->s[strlen(templ->s) + 2] = 0;
templ->s[strlen(templ->s) + 1] = HARDCR;
}
templ->s[strlen(templ->s)] = c;
}
else
{
if (l->s[strlen(l->s)] != HARDCR)
templ->s[1] = 0;
else
{
templ->s[2] = 0;
templ->s[1] = HARDCR;
}
l->s[strlen(l->s)] = 0;
}
l = templ;
sansi(ANSI_CE); /*clreol */
if (++y == (scrlen + 1))
{
sansi(ANSI_CS, scrtop, scrlen);
sansi(ANSI_SR);
sansi(ANSI_CS, 1, scrlen + 1);
--y;
}
sansi(ANSI_CS, y, scrlen); /*scroll region = (y,scrlen)*/
sansi(ANSI_SF); /*scroll down */
sansi(ANSI_CS, 1, scrlen + 1);
sansi(ANSI_CM, 1, y); /*get to beginning of line */
sansi(ANSI_CE);
prints("%s", l->s + 1); /*print out line */
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_CM, sx, y); /*move to (strlen, y) */
return(-1);
}
else
return(0);
}
void redraw(void)
{
int tempy;
sansi(ANSI_CL);
scrcol = (char) *(char far *)(0xB8000001L);
sansi(ANSI_CM, 1, 1);
sansi(ANSI_AA, curcol = '0');
for (tempy = 0; tempy < (scrwid + 1); ++tempy)
printf("%c", tabline[tempy]);
templ = l;
tempy = y;
while ((y > scrtop) && templ->prev)
{
templ = templ->prev;
sansi(ANSI_KU);
}
sansi(ANSI_CM, 1, scrtop);
while ((y <= scrlen) && templ)
{
sansi(ANSI_AA, curcol = '0');
prints("%s\n", templ->s + 1);
templ = templ->next;
++y;
}
y = tempy;
sansi(ANSI_CM, sx, y);
status("Type <Ctrl-Q><Ctrl-H> for help.");
}
void load(void)
{
int i;
FILE *f;
if ((f = fopen(savfile, "r")) != NULL)
{
while (!feof(f))
if (fgets(lastl->s + 1, 160, f))
{
i = strlen(lastl->s);
if (lastl->s[i - 2] == '\001')
lastl->s[i - 2] = '\0';
else
lastl->s[i - 1] = HARDCR;
lastl->next = newline();
lastl->next->prev = lastl;
lastl = lastl->next;
}
lastl = lastl->prev;
lastl->next = null;
}
}
void save(void)
{
int i;
struct line *t;
FILE *f;
if ((f = fopen(savfile, "w")) == NULL)
printf("ERROR: I couldn't open the file.\n");
else
{
t = firstl;
while (t != null)
{
if (t->s[strlen(t->s)] == HARDCR)
{
for (i = 1; i < strlen(t->s); ++i)
fprintf(f, "%c", t->s[i]);
fprintf(f, "\n");
}
else if (t->next == null)
fprintf(f, "%s\n", t->s + 1);
else
fprintf(f, "%s\001\n", t->s + 1);
t = t->next;
}
}
}
main(int argc, char *argv[])
{
int c;
savfile = null;
maxlines = 60;
scrwid = 79;
scrlen = 24;
console = 0;
if ((argc > 1) && (argv[1][0] != '-'))
savfile = strdup(argv[1]);
for (c = 1; c < argc; ++c)
if (argv[c][0] == '-')
switch(toupper(argv[c][1]))
{
case 'L':maxlines = (int) strtol(argv[c] + 2, NULL, 0);
break;
case 'C':scrwid = (int) strtol(argv[c] + 2, NULL, 0) - 1;
break;
case 'H':scrlen = (int) strtol(argv[c] + 2, NULL, 0) - 1;
break;
case 'A':console = 1;
break;
}
abt = 0;
totlines = 0;
curcol = '0';
curline = 1;
firstl = lastl = l = newline();
sx = x = 1;
y = scrtop;
tabline = strdup("|----+----+----+----+----+----+----+----|----+----+----+----+----+----+----+---|");
load();
redraw();
while (!abt && ((c = getkey()) != 26)) /* <Ctrl-Z> = End of file */
{
switch(c)
{
case 8: /* <Ctrl-H> = Backspace */
case 127: /* <Ctrl-Backspace> = Delete */
if (x > 1)
{
sansi(ANSI_KL);
delete(l->s, x);
}
break;
case 14: /* <Ctrl-N> = insert line */
case 13: /* <Ctrl-M> or <CR> */
if (totlines < maxlines)
{
templ = newline();
templ->prev = l;
templ->next = l->next;
if (l->next)
l->next->prev = templ;
l->next = templ;
strcpy(templ->s + 1, l->s + x);
l->s[x] = HARDCR;
l->s[x + 1] = 0;
prints("%s", l->s + x);
l = templ;
sansi(ANSI_CE); /*clreol */
if (++y == (scrlen + 1))
{
sansi(ANSI_CS, scrtop, scrlen);
sansi(ANSI_SR);
sansi(ANSI_CS, 1, scrlen + 1);
--y;
}
sansi(ANSI_CM, sx = x = 1, y); /*gotoxy(1, y) if CR */
sansi(ANSI_SC); /*save cursor */
sansi(ANSI_CS, y, scrlen); /*scroll region = (y,scrlen)*/
sansi(ANSI_SF); /*scroll down */
sansi(ANSI_CS, 1, scrlen + 1);
sansi(ANSI_CE);
prints("%s", l->s + 1); /*print out line */
sansi(ANSI_RC); /*restore cursor */
if (c == 14)
{
l = l->prev;
sx = strlens(l->s);
x = strlen(l->s);
sansi(ANSI_CM, sx, --y);
}
}
break;
case 10: /* <Ctrl-J> = Delete to EOL */
l->s[x] = 0;
sansi(ANSI_CE);
break;
case 25: /* <Ctrl-Y> = Delete Line */
if (l->next)
{
if (l->prev)
l->prev->next = l->next;
l->next->prev = l->prev;
templ = l;
l = l->next;
free(templ);
sansi(ANSI_CM, sx = x = 1, y);
sansi(ANSI_SC);
sansi(ANSI_CS, y, scrlen);
sansi(ANSI_SR);
sansi(ANSI_CS, 1, scrlen + 1);
sansi(ANSI_RC);
--totlines;
templ = l;
temp = y;
while ((temp < scrlen) && (templ->next))
{
templ = templ->next;
++temp;
}
if (temp == scrlen)
{
sansi(ANSI_SC);
sansi(ANSI_CM, 1, scrlen);
prints("%s", templ->s + 1);
sansi(ANSI_RC);
}
}
else if (l->prev)
{
l = l->prev;
free(l->next);
l->next = null;
sansi(ANSI_CM, sx = x = 1, y);
sansi(ANSI_CE);
sansi(ANSI_KU);
--totlines;
}
else if (strlen(l->s) > 1)
{
strcpy(l->s, " ");
sansi(ANSI_CM, sx = x = 1, y);
sansi(ANSI_CE);
}
else
beep();
break;
case 7: /* <Ctrl-G> = Delete character */
case DEL:
if ((x < strlen(l->s)) || (l->s[x] == HARDCR))
delete(l->s, x);
break;
case 24: /* <Ctrl-X> = Cursor down */
case CRSRDN:
nextline();
break;
case 5: /* <Ctrl-E> = Cursor up */
case CRSRUP:
prevline();
break;
case 4: /* <Ctrl-D> = Cursor right */
case CRSRRGT:
if (x < strlen(l->s))
sansi(ANSI_KR);
break;
case 19: /* <Ctrl-S> = Cursor left */
case CRSRLFT:
if (x > 1)
sansi(ANSI_KL);
break;
case 1: /* <Ctrl-A> = Word left */
case CTRLCRSRLFT:
if (x > 1)
{
while ((l->s[x - 1] == ' ') && (x > 1))
sansi(ANSI_KL);
while ((l->s[x - 1] != ' ') && (x > 1))
sansi(ANSI_KL);
}
else if (l->prev)
{
l = l->prev;
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_KU);
sansi(ANSI_CM, sx, y);
}
break;
case 6: /* <Ctrl-F> = Word right */
case CTRLCRSRRGT:
if ((x < strlen(l->s)) && (l->s[x] != HARDCR))
{
if ((l->s[x] == ' ') && (x < strlen(l->s)))
while ((l->s[x] == ' ') && (x < strlen(l->s)))
sansi(ANSI_KR);
else
{
while ((l->s[x - 1] == ' ') && (x < strlen(l->s)))
sansi(ANSI_KR);
while ((l->s[x - 1] != ' ') && (x < strlen(l->s)))
sansi(ANSI_KR);
while ((l->s[x] == ' ') && (x < strlen(l->s)))
sansi(ANSI_KR);
}
}
else if (l->next)
{
l = l->next;
sansi(ANSI_KD);
sansi(ANSI_CM, sx = x = 1, y);
}
break;
case 20: /* <Ctrl-T> = Delete next word */
deleteword(l->s, x);
break;
case 23: /* <Ctrl-W> = Delete prev word */
if (x > 1)
{
while ((l->s[x - 1] == ' ') && (x > 1))
sansi(ANSI_KL);
while ((l->s[x - 1] != ' ') && (x > 1))
sansi(ANSI_KL);
}
else if (l->prev)
{
l = l->prev;
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_KU);
sansi(ANSI_CM, sx, y);
}
deleteword(l->s, x);
break;
case 9: /* <Ctrl-I> = Tab */
if ((6 - (sx % 5)) <= (scrwid - sx))
{
insert(l->s, x, ' ');
sansi(ANSI_KR);
while (sx % 5 != 1)
{
insert(l->s, x, ' ');
sansi(ANSI_KR);
}
}
break;
case 12: /* <Ctrl-L> = Redraw screen */
redraw();
break;
case 16: /* <Ctrl-P> = Change color */
status("Enter a number (0-8)");
c = getkey();
status("");
if ((c >= '0') && (c <= '7'))
{
strcpy(temps, l->s);
strncpy(l->s, temps, x - 1);
l->s[x] = COLORCHAR;
l->s[x + 1] = c;
strcpy(l->s + x + 2, temps + x);
curcol = c;
sansi(ANSI_SC);
prints("%s", l->s + x);
sansi(ANSI_RC);
x += 2;
}
break;
case 11: /* <Ctrl-K> = Secondary commands */
if (c == 11)
{
status("Enter secondary code");
c = getkey();
status("");
}
switch(c)
{
case 4: /* <Ctrl-D> = Exit editor */
case 68: /* 'D' */
case 100: /* 'd' */
abt = 2; /* abort but save */
break;
}
break;
case 17: /* <Ctrl-Q> = Secondary commands */
case HOME:
case END:
case CTRLPGUP:
case CTRLPGDN:
case CTRLHOME:
case CTRLEND:
if (c == 17)
{
status("Enter secondary code");
c = getkey();
status("");
}
switch(c)
{
case 8: /* <Ctrl-H> = help */
case 72: /* 'H' */
case 104: /* 'h' */
sansi(ANSI_CL);
printf("| Movement | Insert and Delete |\n");
printf("|----------------------------------------|------------------------------------|\n");
printf("|Ctrl-E = cursor up \\ | Ctrl-G = delete char at cursor |\n");
printf("|Ctrl-X = cursor down | E | Ctrl-H = delete char behind cursor |\n");
printf("|Ctrl-S = cursor left > A S D F | Ctrl-T = delete the next word |\n");
printf("|Ctrl-D = cursor right | X | Ctrl-W = delete the previous word |\n");
printf("|Ctrl-A = word left | | Ctrl-J = delete to end of the line |\n");
printf("|Ctrl-F = word right / | Ctrl-Y = delete a line |\n");
printf("|Ctrl-Q + | Ctrl-N = insert a line at cursor |\n");
printf("| Ctrl-E = top of screen | Ctrl-I = insert a tab |\n");
printf("| Ctrl-X = bottom of screen |====================================|\n");
printf("| Ctrl-S = first char of line | Miscellaneous |\n");
printf("| Ctrl-D = last char of line |------------------------------------|\n");
printf("| Ctrl-R = top of message | Ctrl-L = redraw the screen |\n");
printf("| Ctrl-C = end of message | Ctrl-P + |\n");
printf("| | digit = change the color |\n");
printf("|=============================================================================|\n");
printf(" | Ending the message | \n");
printf(" |--------------------------------| \n");
printf(" | Ctrl-Z = exit and save message | \n");
printf(" | Ctrl-Q + | \n");
printf(" | Ctrl-Z = abort message | \n");
printf(" |================================| \n");
status("Press any key to continue");
getkey();
status("");
redraw();
break;
case 5: /* <Ctrl-E> = top of screen */
case 69: /* 'E' */
case 101: /* 'e' */
case HOME:
while ((y > scrtop) && (l->prev))
{
l = l->prev;
sansi(ANSI_KU);
}
if (sx > strlens(l->s))
{
x = strlen(l->s);
sx = strlens(l->s);
}
sansi(ANSI_CM, sx, y);
break;
case 24: /* <Ctrl-X> = bottom of screen */
case 88: /* 'X' */
case 120: /* 'x' */
case END:
while ((y < scrlen) && (l->next))
{
l = l->next;
sansi(ANSI_KD);
}
if (sx > strlens(l->s))
{
x = strlen(l->s);
sx = strlens(l->s);
}
sansi(ANSI_CM, sx, y);
break;
case 19: /* <Ctrl-S> = beginning of line */
case 83: /* 'S' */
case 115: /* 's' */
case CTRLPGUP:
sansi(ANSI_CM, sx = x = 1, y);
break;
case 4: /* <Ctrl-D> = end of line */
case 68: /* 'D' */
case 100: /* 'd' */
case CTRLPGDN:
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_CM, sx, y);
break;
case 18: /* <Ctrl-R> = top of file */
case 82: /* 'R' */
case 114: /* 'r' */
case CTRLHOME:
while (l != firstl)
{
l = l->prev;
sansi(ANSI_KU);
}
sansi(ANSI_CM, sx = 1, y);
break;
case 3: /* <Ctrl-C> = bottom of file */
case 67: /* 'C' */
case 99: /* 'c' */
case CTRLEND:
while (l != lastl)
{
l = l->next;
sansi(ANSI_KD);
}
x = strlen(l->s);
sx = strlens(l->s);
sansi(ANSI_CM, sx, y);
break;
case 26: /* <Ctrl-Z> = abort message */
case 90: /* 'Z' */
case 122: /* 'z' */
status("Abort: Are you sure?");
sansi(ANSI_SC);
sansi(ANSI_CM, 22, scrlen + 1);
while (((c = getkey()) != 'y') && (c != 'Y') && (c != 'n') && (c != 'N'));
sansi(ANSI_RC);
status("");
if ((c == 'y') || (c == 'Y'))
abt = 1;
break;
}
break;
default:
if ((c >= 32) && (c <= 255))
if ((strlens(l->s) < scrwid) && (x == realstrlen(l->s)))
{
strcpy(temps, l->s);
strncpy(l->s, temps, x - 1);
l->s[x] = c;
strcpy(l->s + x + 1, temps + x);
prints("%c", c);
++x;
++sx;
}
else
switch(insert(l->s, x, c))
{
case -1:break;
case 0:status("\7Too many characters in the line.");
break;
default:sansi(ANSI_KR);
break;
}
break;
}
if (l->next == null)
lastl = l;
}
sansi(ANSI_CM, 1, scrlen + 1);
sansi(ANSI_CE);
if (abt != 1)
{
if (savfile != null)
{
printf("Saving %d lines\n", totlines);
save();
exit(0);
}
else
{
printf("I didn't get a filename to save it under!\n");
exit(2);
}
}
else
{
printf("Aborted\n");
exit(1);
}
}