From e8e01073071369d33ab4cf61be05bebe5a65566e Mon Sep 17 00:00:00 2001 From: Jason Downs Date: Sat, 21 Sep 1996 06:23:56 +0000 Subject: update to vim 4.4beta --- usr.bin/vim/main.c | 91 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 72 insertions(+), 19 deletions(-) (limited to 'usr.bin/vim/main.c') diff --git a/usr.bin/vim/main.c b/usr.bin/vim/main.c index 43d9841e981..eff7a9afaa2 100644 --- a/usr.bin/vim/main.c +++ b/usr.bin/vim/main.c @@ -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 @@ main(argc, argv) if (gui.starting) { gui_start(); - gui.starting = FALSE; full_screen = TRUE; } #endif @@ -792,6 +791,16 @@ main(argc, argv) 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) @@ -814,13 +823,6 @@ main(argc, argv) else 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 @@ -872,28 +874,69 @@ main(argc, argv) 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 + /* + * Don't execute Win/Buf Enter/Leave autocommands here + */ + ++autocmd_no_enter; + ++autocmd_no_leave; +#endif + 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 - apply_autocmds(EVENT_BUFENTER, NULL, NULL); + curwin = firstwin; /* start again */ #endif - do_modelines(); /* do modelines */ + } + 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 @@ main(argc, argv) 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 @@ main(argc, argv) 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 @@ getout(r) #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); } -- cgit v1.2.3