home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume8
/
smile
/
smile_main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-10-01
|
3KB
|
105 lines
/* SMiLE -- Simple MIni Line Editor
Copyright (C) 1989 By Alejandro Liu
You are given permission to Freely Copy and distribute this program
in its unmodifed form provided that this copyright notice is included.
*/
#include "bsd_tty.h"
#include "smile.h"
#include <stdio.h>
main(argc,argv)
int argc;
char *argv[];
{
int x;
extern int smile();
ed_line head, *basura;
char width, tk[256];
FILE *ants;
init_tty();
if ((argc < 2)||(argc > 3)) {
fprintf(stderr, "Usage: %s file [line lenght]\n",argv[0]);
restore_tty();
exit(1);
}
width = 35;
if (argc == 3)
width = atoi(argv[2]);
if ((ants = fopen(argv[1],"r")) == NULL) {
head.previous = head.next = NULL;
head.data = (char *)malloc(2);
head.len = *(head.data) = 0;
}
else {
head.previous = NULL;
basura = &head;
loop:
if (fgets(tk, width, ants)) {
basura->len = strlen(tk);
tk[--(basura->len)] = 0;
basura->data = (char *)malloc(basura->len + 1);
strcpy(basura->data,tk);
basura->next = (ed_line *)malloc(sizeof(head));
(basura->next)->previous = basura;
basura = basura->next;
goto loop;
}
else {
basura->next = NULL;
basura->len = 0;
basura->data = (char *)malloc(2);
*(basura->data) = 0;
}
fclose(ants);
}
x = smile(&head, 1, width);
if (x == ABORT) {
prtstr("SMiLE Aborted... Changes Discarded\n");
}
else {
prtstr("SMiLE saving File\n");
if (ants = fopen(argv[1],"w")) {
basura = &head;
while (basura) {
fprintf(ants,"%s\n",basura->data);
basura = basura->next;
}
fclose(ants);
}
else
fprintf(stderr,"%s: can not write to file %s\n",argv[0],argv[1]);
}
restore_tty();
}
smile_help(wwst,width)
char wwst,width;
{
prtstr("SMiLE Help SubSystem\n\n");
prtstr("Current Screen Width = ");
printf("%2d",width);
prtstr(" Word Wrap is ");
if (wwst)
prtstr("enabled\n");
else
prtstr("disabled\n");
prtstr("SMiLE -- Simple MIni Line Editor\n\n");
prtstr("This is a simple mini line editor, suitable for editing messages for mail\n");
prtstr("or BBS posts. It has two integrated command sets for maximum compatibilty.\n");
prtstr("First Command set is the SMiLE command set, that supports Easy Multi line\n");
prtstr("editing with easy cursor control, and the other is a C-Net or Color BBS, dot\n");
prtstr("command or slash command set.\n");
prtstr("The Slash and Command Set of C-Net and Color BBS is not completely supported\n");
prtstr("except for the most common commands.\n");
pause();
prtstr("The New SMiLE commands that allow all the powerful SMiLE features are:\n");
prtstr("CTRL + N Next Line CTRL + P Previous Line\n");
prtstr("CTRL + B Backward Char CTRL + F Forward Char\n");
prtstr("CTRL + K Kill Line CTRL + L List The Text\n");
prtstr("CTRL + A Previews Text CTRL + [ ESC Key, invokes SMiLE Menu\n");
prtstr("Typing . or / at the beggining of a Line enters the QUICK Menu Mode. i.e.\n");
prtstr("you will be prompted for a option from the SMiLE menu, but no menu will be\n");
prtstr("displayed. (C-Net/Color BBS Compatibility command)\n");
}