/* main.c */ /* Author: * Steve Kirkendall * 14407 SW Teal Blvd. #C * Beaverton, OR 97005 * kirkenda@cs.pdx.edu */ /* This file contains the main() function of vi */ /* HACK! bcc needs to disable use of precompiled headers for this file, or else command line args will not be passed to elvis */ #if __BORLANDC__ #include "borland.h" #endif #include "config.h" #include #include "vi.h" extern trapint(); /* defined below */ extern char *getenv(); jmp_buf jmpenv; #ifndef NO_DIGRAPH static init_digraphs(); #endif /*---------------------------------------------------------------------*/ #if AMIGA # include "amiwild.c" main (argc, argv) #else # if VMS # include "vmswild.c" main (argc, argv) # else void main(argc, argv) # endif #endif int argc; char *argv[]; { int i; char *cmd = (char *)0; char *err = (char *)0; char *str; char *tag = (char *)0; /* set mode to MODE_VI or MODE_EX depending on program name */ switch (argv[0][strlen(argv[0]) - 1]) { case 'x': /* "ex" */ mode = MODE_EX; break; case 'w': /* "view" */ mode = MODE_VI; *o_readonly = TRUE; break; #ifndef NO_EXTENSIONS case 't': /* "edit" or "input" */ mode = MODE_VI; *o_inputmode = TRUE; break; #endif default: /* "vi" or "elvis" */ mode = MODE_VI; } #ifndef DEBUG # ifdef SIGQUIT /* normally, we ignore SIGQUIT. SIGINT is trapped later */ signal(SIGQUIT, SIG_IGN); # endif #endif /* temporarily ignore SIGINT */ signal(SIGINT, SIG_IGN); /* start curses */ initscr(); cbreak(); noecho(); scrollok(stdscr, TRUE); /* arrange for deadly signals to be caught */ # ifdef SIGHUP signal(SIGHUP, (void(*)()) deathtrap); # endif # ifndef DEBUG # ifdef SIGILL signal(SIGILL, (void(*)()) deathtrap); # endif # ifdef SIGBUS signal(SIGBUS, (void(*)()) deathtrap); # endif # ifdef SIGSEGV signal(SIGSEGV, (void(*)()) deathtrap); # endif # ifdef SIGSYS signal(SIGSYS, (void(*)()) deathtrap); # endif # endif /* !DEBUG */ # ifdef SIGPIPE signal(SIGPIPE, (void(*)()) deathtrap); # endif # ifdef SIGTERM signal(SIGTERM, (void(*)()) deathtrap); # endif # ifdef SIGUSR1 signal(SIGUSR1, (void(*)()) deathtrap); # endif # ifdef SIGUSR2 signal(SIGUSR2, (void(*)()) deathtrap); # endif /* initialize the options - must be done after initscr(), so that * we can alter LINES and COLS if necessary. */ initopts(); /* map the arrow keys. The KU,KD,KL,and KR variables correspond to * the :ku=: (etc.) termcap capabilities. The variables are defined * as part of the curses package. */ if (has_KU) mapkey(has_KU, "k", WHEN_VICMD|WHEN_INMV, ""); if (has_KD) mapkey(has_KD, "j", WHEN_VICMD|WHEN_INMV, ""); if (has_KL) mapkey(has_KL, "h", WHEN_VICMD|WHEN_INMV, ""); if (has_KR) mapkey(has_KR, "l", WHEN_VICMD|WHEN_INMV, ""); if (has_HM) mapkey(has_HM, "^", WHEN_VICMD|WHEN_INMV, ""); if (has_EN) mapkey(has_EN, "$", WHEN_VICMD|WHEN_INMV, ""); if (has_PU) mapkey(has_PU, "\002", WHEN_VICMD|WHEN_INMV, ""); if (has_PD) mapkey(has_PD, "\006", WHEN_VICMD|WHEN_INMV, ""); if (has_KI) mapkey(has_KI, "i", WHEN_VICMD|WHEN_INMV, ""); #if MSDOS # if RAINBOW if (!strcmp("rainbow", o_term)) { mapkey("\033[1~", "/", WHEN_VICMD, ""); mapkey("\033[3~", "x", WHEN_VICMD|WHEN_INMV, ""); mapkey("\033[4~", "v", WHEN_VICMD|WHEN_INMV, "