=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/vim/Attic/main.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/vim/Attic/main.c 1996/09/07 21:40:26 1.1 +++ src/usr.bin/vim/Attic/main.c 1996/09/21 06:23:05 1.2 @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.1 1996/09/07 21:40:26 downsj Exp $ */ +/* $OpenBSD: main.c,v 1.2 1996/09/21 06:23:05 downsj Exp $ */ /* vi:set ts=4 sw=4: * * VIM - Vi IMproved by Bram Moolenaar @@ -758,7 +758,6 @@ if (gui.starting) { gui_start(); - gui.starting = FALSE; full_screen = TRUE; } #endif @@ -792,6 +791,16 @@ curbuf->b_p_bin = 1; /* binary file I/O */ } +/* + * "-e errorfile": Load the error file now. + * If the error file can't be read, exit before doing anything else. + */ + if (doqf && qf_init() == FAIL) /* if reading error file fails: exit */ + { + outchar('\n'); + mch_windexit(3); + } + /* Don't set the file name if there was a command in .vimrc that already * loaded the file */ if (curbuf->b_filename == NULL) @@ -815,13 +824,6 @@ window_count = 1; /* - * "-e errorfile": Load the error file now. - * If the error file can't be read, exit before doing anything else. - */ - if (doqf && qf_init() == FAIL) /* if reading error file fails: exit */ - mch_windexit(3); - -/* * Start putting things on the screen. * Scroll screen down before drawing over it * Clear screen now, so file message will not be cleared. @@ -872,28 +874,69 @@ msg_scroll = FALSE; if (curbuf->b_ml.ml_mfp == NULL) /* failed */ getout(1); + do_modelines(); /* do modelines */ + } + else + { + /* + * Open a buffer for windows that don't have one yet. + * Commands in the .vimrc might have loaded a file or split the window. + * Watch out for autocommands that delete a window. + */ #ifdef AUTOCMD - apply_autocmds(EVENT_BUFENTER, NULL, NULL); + /* + * Don't execute Win/Buf Enter/Leave autocommands here + */ + ++autocmd_no_enter; + ++autocmd_no_leave; #endif - do_modelines(); /* do modelines */ + for (curwin = firstwin; curwin != NULL; curwin = curwin->w_next) + { + curbuf = curwin->w_buffer; + if (curbuf->b_ml.ml_mfp == NULL) + { + (void)open_buffer(); /* create memfile and read file */ +#ifdef AUTOCMD + curwin = firstwin; /* start again */ +#endif + } + mch_breakcheck(); + if (got_int) + { + (void)vgetc(); /* only break the file loading, not the rest */ + break; + } + } +#ifdef AUTOCMD + --autocmd_no_enter; + --autocmd_no_leave; +#endif + curwin = firstwin; + curbuf = curwin->w_buffer; } - /* Only read the file if there is none for the current buffer, a command - * in the .vimrc might have loaded a file */ - else if (curbuf->b_ml.ml_mfp == NULL) - (void)open_buffer(); /* create memfile and read file */ +#ifdef AUTOCMD + apply_autocmds(EVENT_BUFENTER, NULL, NULL); +#endif setpcmark(); /* * When started with "-e errorfile" jump to first error now. */ if (doqf) - qf_jump(0, 0); + qf_jump(0, 0, FALSE); /* * If opened more than one window, start editing files in the other windows. * Make_windows() has already opened the windows. */ +#ifdef AUTOCMD + /* + * Don't execute Win/Buf Enter/Leave autocommands here + */ + ++autocmd_no_enter; + ++autocmd_no_leave; +#endif for (i = 1; i < window_count; ++i) { if (curwin->w_next == NULL) /* just checking */ @@ -907,7 +950,7 @@ curwin->w_arg_idx = arg_idx; /* edit file from arg list, if there is one */ (void)do_ecmd(0, arg_idx < arg_count ? arg_files[arg_idx] : NULL, - NULL, NULL, TRUE, (linenr_t)1, FALSE); + NULL, NULL, (linenr_t)1, ECMD_HIDE); if (arg_idx == arg_count - 1) arg_had_last = TRUE; ++arg_idx; @@ -919,7 +962,13 @@ break; } } +#ifdef AUTOCMD + --autocmd_no_enter; +#endif win_enter(firstwin, FALSE); /* back to first window */ +#ifdef AUTOCMD + --autocmd_no_leave; +#endif if (window_count > 1) win_equal(curwin, FALSE); /* adjust heights */ @@ -1070,12 +1119,16 @@ #endif #ifdef VIMINFO + msg_didany = FALSE; /* Write out the registers, history, marks etc, to the viminfo file */ if (*p_viminfo != NUL) write_viminfo(NULL, FALSE); + if (msg_didany) /* make the user read the error message */ + { + no_wait_return = FALSE; + wait_return(FALSE); + } #endif /* VIMINFO */ - outchar('\r'); - outchar('\n'); mch_windexit(r); }