diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 480db4f2ce..8225b80897 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8420,6 +8420,8 @@ timers Compiled with |timer_start()| support. title Compiled with window title support |'title'|. toolbar Compiled with support for |gui-toolbar|. transparency Compiled with 'transparency' support. +ttyin input is a terminal (tty) +ttyout output is a terminal (tty) unix Unix version of Vim. user_commands User-defined commands. vertsplit Compiled with vertically split windows |:vsplit|. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index a0d580bc4f..ad4cd3cb28 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -421,6 +421,10 @@ a slash. Thus "-R" means recovery and "-/R" readonly. not connected to a terminal. This will avoid the warning and the two second delay that would happen. {not in Vi} + *--ttyfail* +--ttyfail When the stdin or stdout is not a terminal (tty) then exit + right away. + *-d* -d Start in diff mode, like |vimdiff|. {not in Vi} {not available when compiled without the |+diff| diff --git a/src/channel.c b/src/channel.c index 263f6ac6ec..faeee25486 100644 --- a/src/channel.c +++ b/src/channel.c @@ -3840,6 +3840,11 @@ channel_parse_messages(void) int ret = FALSE; int r; ch_part_T part = PART_SOCK; +#ifdef ELAPSED_FUNC + ELAPSED_TYPE start_tv; + + ELAPSED_INIT(start_tv); +#endif ++safe_to_invoke_callback; @@ -3884,7 +3889,14 @@ channel_parse_messages(void) r = may_invoke_callback(channel, part); if (r == OK) ret = TRUE; - if (channel_unref(channel) || r == OK) + if (channel_unref(channel) || (r == OK +#ifdef ELAPSED_FUNC + /* Limit the time we loop here to 100 msec, otherwise + * Vim becomes unresponsive when the callback takes + * more than a bit of time. */ + && ELAPSED_FUNC(start_tv) < 100L +#endif + )) { /* channel was freed or something was done, start over */ channel = first_channel; @@ -3912,6 +3924,31 @@ channel_parse_messages(void) return ret; } +/* + * Return TRUE if any channel has readahead. That means we should not block on + * waiting for input. + */ + int +channel_any_readahead(void) +{ + channel_T *channel = first_channel; + ch_part_T part = PART_SOCK; + + while (channel != NULL) + { + if (channel_has_readahead(channel, part)) + return TRUE; + if (part < PART_ERR) + ++part; + else + { + channel = channel->ch_next; + part = PART_SOCK; + } + } + return FALSE; +} + /* * Mark references to lists used in channels. */ diff --git a/src/evalfunc.c b/src/evalfunc.c index f5b1eeb68b..0e51b1f4ca 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5978,6 +5978,10 @@ f_has(typval_T *argvars, typval_T *rettv) } else if (STRICMP(name, "vim_starting") == 0) n = (starting != 0); + else if (STRICMP(name, "ttyin") == 0) + n = mch_input_isatty(); + else if (STRICMP(name, "ttyout") == 0) + n = stdout_isatty; #ifdef FEAT_MBYTE else if (STRICMP(name, "multi_byte_encoding") == 0) n = has_mbyte; diff --git a/src/globals.h b/src/globals.h index ec5174d0f8..da5ec5da92 100644 --- a/src/globals.h +++ b/src/globals.h @@ -643,6 +643,8 @@ EXTERN int exiting INIT(= FALSE); EXTERN int really_exiting INIT(= FALSE); /* TRUE when we are sure to exit, e.g., after * a deadly signal */ +EXTERN int stdout_isatty INIT(= TRUE); /* is stdout a terminal? */ + #if defined(FEAT_AUTOCHDIR) EXTERN int test_autochdir INIT(= FALSE); #endif diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 5020177d95..514ac9e31a 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -3102,7 +3102,7 @@ drawarea_configure_event_cb(GtkWidget *widget, g_return_val_if_fail(event && event->width >= 1 && event->height >= 1, TRUE); -# if GTK_CHECK_VERSION(3,22,2) +# if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) /* As of 3.22.2, GdkWindows have started distributing configure events to * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). * @@ -3123,6 +3123,10 @@ drawarea_configure_event_cb(GtkWidget *widget, * implementation details. Therefore, watch out any relevant internal * changes happening in GTK in the feature (sigh). */ + /* Follow-up + * After a few weeks later, the GdkWindow change mentioned above was + * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). + * The corresponding official release is 3.22.4. */ if (event->send_event == FALSE) return TRUE; # endif @@ -4492,7 +4496,7 @@ form_configure_event(GtkWidget *widget UNUSED, { int usable_height = event->height; -#if GTK_CHECK_VERSION(3,22,2) +#if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) /* As of 3.22.2, GdkWindows have started distributing configure events to * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). * @@ -4508,6 +4512,10 @@ form_configure_event(GtkWidget *widget UNUSED, * To filter out such fallacious events, check if the given event is the * one that was sent out to the right place. Ignore it if not. */ + /* Follow-up + * After a few weeks later, the GdkWindow change mentioned above was + * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). + * The corresponding official release is 3.22.4. */ if (event->window != gtk_widget_get_window(gui.formwin)) return TRUE; #endif diff --git a/src/main.c b/src/main.c index 98db9d565a..c06059b910 100644 --- a/src/main.c +++ b/src/main.c @@ -1036,7 +1036,7 @@ common_init(mparm_T *paramp) * (needed for :! to * work). mch_check_win() will also handle the -d or * -dev argument. */ - paramp->stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); + stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); TIME_MSG("window checked"); /* @@ -1906,6 +1906,7 @@ command_line_scan(mparm_T *parmp) /* "--literal" take files literally */ /* "--nofork" don't fork */ /* "--not-a-term" don't warn for not a term */ + /* "--ttyfail" exit if not a term */ /* "--noplugin[s]" skip plugins */ /* "--cmd " execute cmd before vimrc */ if (STRICMP(argv[0] + argv_idx, "help") == 0) @@ -1935,6 +1936,8 @@ command_line_scan(mparm_T *parmp) p_lpl = FALSE; else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) parmp->not_a_term = TRUE; + else if (STRNICMP(argv[0] + argv_idx, "ttyfail", 7) == 0) + parmp->tty_fail = TRUE; else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) { want_argument = TRUE; @@ -2573,7 +2576,7 @@ check_tty(mparm_T *parmp) if (!input_isatty) silent_mode = TRUE; } - else if (parmp->want_full_screen && (!parmp->stdout_isatty || !input_isatty) + else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) #ifdef FEAT_GUI /* don't want the delay when started from the desktop */ && !gui.starting @@ -2588,7 +2591,7 @@ check_tty(mparm_T *parmp) * input buffer so fast I can't even kill the process in under 2 * minutes (and it beeps continuously the whole time :-) */ - if (netbeans_active() && (!parmp->stdout_isatty || !input_isatty)) + if (netbeans_active() && (!stdout_isatty || !input_isatty)) { mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); exit(1); @@ -2601,11 +2604,13 @@ check_tty(mparm_T *parmp) exit(1); } #endif - if (!parmp->stdout_isatty) + if (!stdout_isatty) mch_errmsg(_("Vim: Warning: Output is not to a terminal\n")); if (!input_isatty) mch_errmsg(_("Vim: Warning: Input is not from a terminal\n")); out_flush(); + if (parmp->tty_fail && (!stdout_isatty || !input_isatty)) + exit(1); if (scriptin[0] == NULL) ui_delay(2000L, TRUE); TIME_MSG("Warning delay"); @@ -3371,6 +3376,7 @@ usage(void) #endif main_msg(_("-T \tSet terminal type to ")); main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal")); + main_msg(_("--ttyfail\t\tExit if input or output is not a terminal")); main_msg(_("-u \t\tUse instead of any .vimrc")); #ifdef FEAT_GUI main_msg(_("-U \t\tUse instead of any .gvimrc")); diff --git a/src/misc2.c b/src/misc2.c index abd1178721..a123a09f7f 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -6269,3 +6269,31 @@ parse_queued_messages(void) # endif } #endif + +#ifdef ELAPSED_TIMEVAL /* no PROTO here, proto is defined in vim.h */ +/* + * Return time in msec since "start_tv". + */ + long +elapsed(struct timeval *start_tv) +{ + struct timeval now_tv; + + gettimeofday(&now_tv, NULL); + return (now_tv.tv_sec - start_tv->tv_sec) * 1000L + + (now_tv.tv_usec - start_tv->tv_usec) / 1000L; +} +#endif + +#ifdef ELAPSED_TICKCOUNT +/* + * Return time in msec since "start_tick". + */ + long +elapsed(DWORD start_tick) +{ + DWORD now = GetTickCount(); + + return (long)now - (long)start_tick; +} +#endif diff --git a/src/option.c b/src/option.c index e156852a3b..6d6748e5ee 100644 --- a/src/option.c +++ b/src/option.c @@ -458,10 +458,11 @@ struct vimoption #define P_NFNAME 0x400000L /* only normal file name chars allowed */ #define P_INSECURE 0x800000L /* option was set from a modeline */ #define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has - side effects) */ + side effects) */ #define P_NO_ML 0x2000000L /* not allowed in modeline */ #define P_CURSWANT 0x4000000L /* update curswant required; not needed when * there is a redraw flag */ +#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */ #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" @@ -1004,7 +1005,7 @@ static struct vimoption options[] = (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, - {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, + {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME, #ifdef FEAT_INS_EXPAND (char_u *)&p_dict, PV_DICT, #else @@ -2111,7 +2112,7 @@ static struct vimoption options[] = {(char_u *)NULL, (char_u *)0L} #endif SCRIPTID_INIT}, - {"printexpr", "pexpr", P_STRING|P_VI_DEF, + {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE, #ifdef FEAT_POSTSCRIPT (char_u *)&p_pexpr, PV_NONE, {(char_u *)"", (char_u *)0L} @@ -2712,7 +2713,7 @@ static struct vimoption options[] = {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF, (char_u *)&p_tw, PV_TW, {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, - {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, + {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME, #ifdef FEAT_INS_EXPAND (char_u *)&p_tsr, PV_TSR, #else @@ -5961,11 +5962,13 @@ did_set_string_option( errmsg = e_secure; } - /* Check for a "normal" file name in some options. Disallow a path - * separator (slash and/or backslash), wildcards and characters that are - * often illegal in a file name. */ - else if ((options[opt_idx].flags & P_NFNAME) - && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) + /* Check for a "normal" directory or file name in some options. Disallow a + * path separator (slash and/or backslash), wildcards and characters that + * are often illegal in a file name. */ + else if (((options[opt_idx].flags & P_NFNAME) + && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL) + || ((options[opt_idx].flags & P_NDNAME) + && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) { errmsg = e_invarg; } @@ -7111,6 +7114,7 @@ did_set_string_option( #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) + /* 'toolbar' */ else if (varp == &p_toolbar) { if (opt_strings_flags(p_toolbar, p_toolbar_values, @@ -7335,6 +7339,7 @@ did_set_string_option( #endif #if defined(FEAT_RENDER_OPTIONS) + /* 'renderoptions' */ else if (varp == &p_rop && gui.in_use) { if (!gui_mch_set_rendering_options(p_rop)) @@ -7362,19 +7367,19 @@ did_set_string_option( else { p = NULL; - if (varp == &p_ww) + if (varp == &p_ww) /* 'whichwrap' */ p = (char_u *)WW_ALL; - if (varp == &p_shm) + if (varp == &p_shm) /* 'shortmess' */ p = (char_u *)SHM_ALL; - else if (varp == &(p_cpo)) + else if (varp == &(p_cpo)) /* 'cpoptions' */ p = (char_u *)CPO_ALL; - else if (varp == &(curbuf->b_p_fo)) + else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */ p = (char_u *)FO_ALL; #ifdef FEAT_CONCEAL - else if (varp == &curwin->w_p_cocu) + else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */ p = (char_u *)COCU_ALL; #endif - else if (varp == &p_mouse) + else if (varp == &p_mouse) /* 'mouse' */ { #ifdef FEAT_MOUSE p = (char_u *)MOUSE_ALL; @@ -7384,7 +7389,7 @@ did_set_string_option( #endif } #if defined(FEAT_GUI) - else if (varp == &p_go) + else if (varp == &p_go) /* 'guioptions' */ p = (char_u *)GO_ALL; #endif if (p != NULL) diff --git a/src/os_unix.c b/src/os_unix.c index 41581bb1e6..6fe927b8fe 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -376,21 +376,6 @@ mch_write(char_u *s, int len) RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL); } -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) -/* - * Return time in msec since "start_tv". - */ - static long -elapsed(struct timeval *start_tv) -{ - struct timeval now_tv; - - gettimeofday(&now_tv, NULL); - return (now_tv.tv_sec - start_tv->tv_sec) * 1000L - + (now_tv.tv_usec - start_tv->tv_usec) / 1000L; -} -#endif - /* * mch_inchar(): low level input function. * Get a characters from the keyboard. @@ -411,10 +396,10 @@ mch_inchar( int did_start_blocking = FALSE; long wait_time; long elapsed_time = 0; -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - struct timeval start_tv; +#ifdef ELAPSED_FUNC + ELAPSED_TYPE start_tv; - gettimeofday(&start_tv, NULL); + ELAPSED_INIT(start_tv); #endif /* repeat until we got a character or waited long enough */ @@ -438,8 +423,8 @@ mch_inchar( else /* going to block after p_ut */ wait_time = p_ut; -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - elapsed_time = elapsed(&start_tv); +#ifdef ELAPSED_FUNC + elapsed_time = ELAPSED_FUNC(start_tv); #endif wait_time -= elapsed_time; if (wait_time < 0) @@ -477,6 +462,10 @@ mch_inchar( /* Checking if a job ended requires polling. Do this every 100 msec. */ if (has_pending_job() && (wait_time < 0 || wait_time > 100L)) wait_time = 100L; + /* If there is readahead then parse_queued_messages() timed out and we + * should call it again soon. */ + if ((wait_time < 0 || wait_time > 100L) && channel_any_readahead()) + wait_time = 10L; #endif /* @@ -1554,18 +1543,16 @@ mch_input_isatty(void) #ifdef FEAT_X11 -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) \ +# if defined(ELAPSED_TIMEVAL) \ && (defined(FEAT_XCLIPBOARD) || defined(FEAT_TITLE)) -static void xopen_message(struct timeval *start_tv); - /* * Give a message about the elapsed time for opening the X window. */ static void -xopen_message(struct timeval *start_tv) +xopen_message(long elapsed_msec) { - smsg((char_u *)_("Opening the X display took %ld msec"), elapsed(start_tv)); + smsg((char_u *)_("Opening the X display took %ld msec"), elapsed_msec); } # endif #endif @@ -1864,11 +1851,11 @@ get_x11_windis(void) #endif if (x11_display != NULL) { -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC if (p_verbose > 0) { verbose_enter(); - xopen_message(&start_tv); + xopen_message(ELAPSED_FUNC(start_tv)); verbose_leave(); } # endif @@ -4648,8 +4635,8 @@ mch_call_shell( ga_init2(&ga, 1, BUFLEN); noread_cnt = 0; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - gettimeofday(&start_tv, NULL); +# ifdef ELAPSED_FUNC + ELAPSED_INIT(start_tv); # endif for (;;) { @@ -4684,8 +4671,8 @@ mch_call_shell( /* Get extra characters when we don't have any. * Reset the counter and timer. */ noread_cnt = 0; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - gettimeofday(&start_tv, NULL); +# ifdef ELAPSED_FUNC + ELAPSED_INIT(start_tv); # endif len = ui_inchar(ta_buf, BUFLEN, 10L, 0); } @@ -4908,10 +4895,10 @@ mch_call_shell( if (got_int) break; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC if (wait_pid == 0) { - long msec = elapsed(&start_tv); + long msec = ELAPSED_FUNC(start_tv); /* Avoid that we keep looping here without * checking for a CTRL-C for a long time. Don't @@ -5654,15 +5641,14 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted) /* May retry getting characters after an event was handled. */ # define MAY_LOOP -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC /* Remember at what time we started, so that we know how much longer we * should wait after being interrupted. */ -# define USE_START_TV long start_msec = msec; - struct timeval start_tv; + ELAPSED_TYPE start_tv; if (msec > 0) - gettimeofday(&start_tv, NULL); + ELAPSED_INIT(start_tv); # endif /* Handle being called recursively. This may happen for the session @@ -5969,9 +5955,9 @@ select_eintr: /* We're going to loop around again, find out for how long */ if (msec > 0) { -# ifdef USE_START_TV +# ifdef ELAPSED_FUNC /* Compute remaining wait time. */ - msec = start_msec - elapsed(&start_tv); + msec = start_msec - ELAPSED_FUNC(start_tv); # else /* Guess we got interrupted halfway. */ msec = msec / 2; @@ -7068,11 +7054,11 @@ setup_term_clip(void) #if defined(HAVE_SETJMP_H) int (*oldIOhandler)(); #endif -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - struct timeval start_tv; +# ifdef ELAPSED_FUNC + ELAPSED_TYPE start_tv; if (p_verbose > 0) - gettimeofday(&start_tv, NULL); + ELAPSED_INIT(start_tv); # endif /* Ignore X errors while opening the display */ @@ -7114,11 +7100,11 @@ setup_term_clip(void) /* Catch terminating error of the X server connection. */ (void)XSetIOErrorHandler(x_IOerror_handler); -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC if (p_verbose > 0) { verbose_enter(); - xopen_message(&start_tv); + xopen_message(ELAPSED_FUNC(start_tv)); verbose_leave(); } # endif diff --git a/src/os_win32.c b/src/os_win32.c index 34b2ca8384..e08adcbb19 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1351,9 +1351,15 @@ WaitForChar(long msec) DWORD dwWaitTime = dwEndTime - dwNow; #ifdef FEAT_JOB_CHANNEL - /* Check channel while waiting input. */ + /* Check channel while waiting for input. */ if (dwWaitTime > 100) + { dwWaitTime = 100; + /* If there is readahead then parse_queued_messages() timed out + * and we should call it again soon. */ + if (channel_any_readahead()) + dwWaitTime = 10; + } #endif #ifdef FEAT_MZSCHEME if (mzthreads_allowed() && p_mzq > 0 @@ -4287,9 +4293,6 @@ mch_system_piped(char *cmd, int options) /* Get extra characters when we don't have any. Reset the * counter and timer. */ noread_cnt = 0; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - gettimeofday(&start_tv, NULL); -# endif len = ui_inchar(ta_buf, BUFLEN, 10L, 0); } if (ta_len > 0 || len > 0) diff --git a/src/popupmnu.c b/src/popupmnu.c index 19d215b9f5..307dbbedc6 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -105,7 +105,8 @@ redo: /* Put the pum below "row" if possible. If there are few lines decide on * where there is more room. */ - if (row - above_row >= below_row - row) + if (row + 2 >= below_row - pum_height + && row - above_row > (below_row - above_row) / 2) { /* pum above "row" */ diff --git a/src/proto/channel.pro b/src/proto/channel.pro index 2ff8908339..afbc8488a5 100644 --- a/src/proto/channel.pro +++ b/src/proto/channel.pro @@ -44,6 +44,7 @@ int channel_poll_check(int ret_in, void *fds_in); int channel_select_setup(int maxfd_in, void *rfds_in, void *wfds_in); int channel_select_check(int ret_in, void *rfds_in, void *wfds_in); int channel_parse_messages(void); +int channel_any_readahead(void); int set_ref_in_channel(int copyID); ch_part_T channel_part_send(channel_T *channel); ch_part_T channel_part_read(channel_T *channel); diff --git a/src/structs.h b/src/structs.h index ec3f18f9fa..8311216a69 100644 --- a/src/structs.h +++ b/src/structs.h @@ -3244,8 +3244,8 @@ typedef struct #endif int want_full_screen; - int stdout_isatty; /* is stdout a terminal? */ int not_a_term; /* no warning for missing term? */ + int tty_fail; /* exit if not a tty */ char_u *term; /* specified terminal name */ #ifdef FEAT_CRYPT int ask_for_key; /* -x argument */ diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 3b6f6625f6..6dfb1bbe60 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -106,3 +106,26 @@ func Test_keymap_valid() call assert_fails(":set kmp=trunc\x00name", "E544:") call assert_fails(":set kmp=trunc\x00name", "trunc") endfunc + +func Check_dir_option(name) + " Check that it's possible to set the option. + exe 'set ' . a:name . '=/usr/share/dict/words' + call assert_equal('/usr/share/dict/words', eval('&' . a:name)) + exe 'set ' . a:name . '=/usr/share/dict/words,/and/there' + call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name)) + exe 'set ' . a:name . '=/usr/share/dict\ words' + call assert_equal('/usr/share/dict words', eval('&' . a:name)) + + " Check rejecting weird characters. + call assert_fails("set " . a:name . "=/not&there", "E474:") + call assert_fails("set " . a:name . "=/not>there", "E474:") + call assert_fails("set " . a:name . "=/not.*there", "E474:") +endfunc + +func Test_dictionary() + call Check_dir_option('dictionary') +endfunc + +func Test_thesaurus() + call Check_dir_option('thesaurus') +endfunc diff --git a/src/version.c b/src/version.c index f53c361cd7..3094a06dde 100644 --- a/src/version.c +++ b/src/version.c @@ -779,6 +779,26 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 104, +/**/ + 103, +/**/ + 102, +/**/ + 101, +/**/ + 100, +/**/ + 99, +/**/ + 98, +/**/ + 97, +/**/ + 96, +/**/ + 95, /**/ 94, /**/ diff --git a/src/vim.h b/src/vim.h index 99962885e8..3a432cb7b8 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2506,4 +2506,20 @@ typedef enum # define OPEN_CHR_FILES #endif +#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# define ELAPSED_TIMEVAL +# define ELAPSED_INIT(v) gettimeofday(&v, NULL) +# define ELAPSED_FUNC(v) elapsed(&v) +# define ELAPSED_TYPE struct timeval + long elapsed(struct timeval *start_tv); +#else +# if defined(WIN32) +# define ELAPSED_TICKCOUNT +# define ELAPSED_INIT(v) v = GetTickCount() +# define ELAPSED_FUNC(v) elapsed(v) +# define ELAPSED_TYPE DWORD + long elapsed(DWORD start_tick); +# endif +#endif + #endif /* VIM__H */