#include "ded.h" /************************************************************************ * * * copyright Richard Bornat 1981 * * * ************************************************************************/ int putout(), quit(); /* forward declarations */ /**************************************************************** * Start up editor. Parameters are - * * * * a file name * * * * -b : set 'text input' mode, in which a newline is forced * * after the right margin * * -b-: force 'no breaks' mode * * * * -d : start reading from dlogging file * * -d-: ignore the dlog file (if any) * * * * -l[+/-][.]: start editing at line * * (+ means line after, - line before) * * (.n is optional position on line) * * * * -m: set c_MODIFY to * * * * -o: select debug option * * * * -s: don't ring the bell (option for paranoiacs) * * * * -t : set 'tab output' mode, in which leading spaces are * * converted to tabs * * -t-: no tab conversion * * * * -Pw.l: input and output is via standard input and output, * * output assumed to be piped to a screen of * * width w characters and length l lines * * * * -$[+/-][.]: start editing at end of file * * (+ means line before, - line after) * * (.n is optional position on line) * * * ****************************************************************/ int xrows,xcols; int s_argc, s_argp; char **s_argv; char *main_argsequence() { return(s_argp>=s_argc ? (char *)0 : s_argv[s_argp++]); } main(argc,argv) int argc; char **argv; { /* fix things for a terminal using learn with no std_er - mtf */ std_ter = open("/dev/tty",2); /* make sure you always get a terminal */ if (std_ter==-1) exit(5); /* ugh */ tty_input = std_in = std_out = std_ter; /* done */ s_argc = argc; s_argp = 1; s_argv = argv; setupedit(main_argsequence, quit); if (mainloop(INMODE)) /* copy file over to new home - exit via 'ok' */ { ttyreset(); savescreen(); if (tmp_changed) { savefile(putout, false); printf("\n"); } else putout("no changes"); } else { ttyreset(); /* exit via 'q' - don't make any changes to files */ printf("\n"); } unlink(dlogname); unlink(tempname); exit(filewritten ? 0 : 1); } /* VARARGS1 */ editerror(s,p1,p2,p3,p4,p5,p6) char *s; int p1,p2,p3,p4,p5,p6; { if (setup_done) { move_to(FOOTROW,0); ttyreset(); } putout(s,p1,p2,p3,p4,p5,p6); unlink(tempname); exit(2); } /* VARARGS1 */ quit(s,p1,p2,p3,p4,p5,p6) char *s; int p1,p2,p3,p4,p5,p6; { unlink(dlogname); editerror(s, p1, p2, p3, p4, p5, p6); } /* VARARGS1 */ putout(s, p1,p2,p3,p4,p5, p6) char *s; int p1, p2, p3, p4, p5, p6; { printf("\n"); printf(s, p1,p2,p3,p4,p5,p6); printf("\n"); }