diff --git a/Filelist b/Filelist index 8b3449c0e5..56962c84d3 100644 --- a/Filelist +++ b/Filelist @@ -451,6 +451,7 @@ SRC_DOS = \ src/xxd/Make_mvc.mak \ nsis/gvim.nsi \ nsis/gvim_version.nsh \ + nsis/vimrc.ini \ nsis/README.txt \ uninstal.txt \ src/VisVim/Commands.cpp \ diff --git a/nsis/gvim.nsi b/nsis/gvim.nsi index 8447d5ffee..4e9bbfb456 100644 --- a/nsis/gvim.nsi +++ b/nsis/gvim.nsi @@ -83,6 +83,7 @@ SilentInstall normal # These are the pages we use Page license Page components +Page custom SetCustom ValidateCustom ": _vimrc setting" Page directory "" "" CheckInstallDir Page instfiles UninstPage uninstConfirm @@ -135,6 +136,10 @@ Function .onInit StrCpy $1 "-register-OLE" StrCpy $2 "gvim evim gview gvimdiff vimtutor" + # Extract InstallOptions files + # $PLUGINSDIR will automatically be removed when the installer closes + InitPluginsDir + File /oname=$PLUGINSDIR\vimrc.ini "vimrc.ini" FunctionEnd Function .onUserAbort @@ -404,7 +409,7 @@ Section "Add an Edit-with-Vim context menu entry" SectionEnd ########################################################## -Section "Create a _vimrc if it doesn't exist" +Section "Create a _vimrc if it doesn't exist" sec_vimrc_id SectionIn 1 3 StrCpy $1 "$1 -create-vimrc" @@ -462,6 +467,45 @@ Section -post BringToFront SectionEnd +########################################################## +Function SetCustom + # Display the InstallOptions dialog + + # Check if a _vimrc should be created + SectionGetFlags ${sec_vimrc_id} $0 + IntOp $0 $0 & 1 + StrCmp $0 "1" +2 0 + Abort + + Push $3 + InstallOptions::dialog "$PLUGINSDIR\vimrc.ini" + Pop $3 + Pop $3 +FunctionEnd + +Function ValidateCustom + ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 2" "State" + StrCmp $3 "1" 0 +3 + StrCpy $1 "$1 -vimrc-remap no" + Goto behave + + StrCpy $1 "$1 -vimrc-remap win" + + behave: + ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 5" "State" + StrCmp $3 "1" 0 +3 + StrCpy $1 "$1 -vimrc-behave unix" + Goto done + + ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 6" "State" + StrCmp $3 "1" 0 +3 + StrCpy $1 "$1 -vimrc-behave mswin" + Goto done + + StrCpy $1 "$1 -vimrc-behave default" + done: +FunctionEnd + ########################################################## Section Uninstall # Apparently $INSTDIR is set to the directory where the uninstaller is diff --git a/nsis/vimrc.ini b/nsis/vimrc.ini new file mode 100644 index 0000000000..a3e9ecb5bb --- /dev/null +++ b/nsis/vimrc.ini @@ -0,0 +1,68 @@ +[Settings] +NumFields=7 + +[Field 1] +Type=GroupBox +Left=0 +Right=-1 +Top=0 +Bottom=53 +Text=" Key remapping " + +[Field 2] +Type=radiobutton +Text=Do not remap keys for Windows behavior (Default) +Left=10 +Right=-10 +Top=17 +Bottom=25 +State=1 +Flags=GROUP + +[Field 3] +Type=radiobutton +Text=Remap a few keys for Windows behavior (, , , , , etc) +Left=10 +Right=-10 +Top=30 +Bottom=47 +State=0 +Flags=NOTABSTOP + +[Field 4] +Type=GroupBox +Left=0 +Right=-1 +Top=55 +Bottom=-5 +Text=" Mouse behavior " + +[Field 5] +Type=radiobutton +Text=Right button extends selection, left button starts visual mode (Unix) +Left=10 +Right=-5 +Top=72 +Bottom=80 +State=0 +Flags=GROUP + +[Field 6] +Type=radiobutton +Text=Right button has a popup menu, left button starts select mode (Windows) +Left=10 +Right=-5 +Top=85 +Bottom=93 +State=0 +Flags=NOTABSTOP + +[Field 7] +Type=radiobutton +Text=Right button has a popup menu, left button starts visual mode (Default) +Left=10 +Right=-5 +Top=98 +Bottom=106 +State=1 +Flags=NOTABSTOP diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 99210328d4..0ed0d67a25 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8879,9 +8879,8 @@ listcmds Compiled with commands for the buffer list |:files| and the argument list |arglist|. localmap Compiled with local mappings and abbr. |:map-local| lua Compiled with Lua interface |Lua|. -mac Any Macintosh version of Vim, but not all OS X. -macunix Compiled for OS X, with |mac-darwin-feature| -osx Compiled for OS X, with or w/o |mac-darwin-feature| +mac Any Macintosh version of Vim cf. osx +macunix Synonym for osxdarwin menu Compiled with support for |:menu|. mksession Compiled with support for |:mksession|. modify_fname Compiled with file name modifiers. |filename-modifiers| @@ -8905,6 +8904,8 @@ netbeans_intg Compiled with support for |netbeans|. num64 Compiled with 64-bit |Number| support. odbeditor Compiled with |odbeditor| support. ole Compiled with OLE automation support for Win32. +osx Compiled for macOS cf. mac +osxdarwin Compiled for macOS, with |mac-darwin-feature| packages Compiled with |packages| support. path_extra Compiled with up/downwards search in 'path' and 'tags' perl Compiled with Perl interface. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index bdfe1a9b03..2acb6c527b 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -4571,7 +4571,17 @@ A jump table for the options with a short description can be found at |Q_op|. match may not be found. This is to avoid that Vim hangs while you are typing the pattern. The highlighting can be set with the 'i' flag in 'highlight'. - See also: 'hlsearch'. + When 'hlsearch' is on, all matched strings are highlighted too while typing + a search command. See also: 'hlsearch'. + If you don't want turn 'hlsearch' on, but want to highlight all matches + while searching, you can turn on and off 'hlsearch' with autocmd. + Example: > + augroup vimrc-incsearch-highlight + autocmd! + autocmd CmdlineEnter [/\?] :set hlsearch + autocmd CmdlineLeave [/\?] :set nohlsearch + augroup END +< CTRL-L can be used to add one character from after the current match to the command line. If 'ignorecase' and 'smartcase' are set and the command line has no uppercase characters, the added character is diff --git a/runtime/doc/os_mac.txt b/runtime/doc/os_mac.txt index fed39d89ca..3e8dc4c953 100644 --- a/runtime/doc/os_mac.txt +++ b/runtime/doc/os_mac.txt @@ -168,8 +168,9 @@ If you want to disable it, pass `--disable-darwin` to the configure script: > and then run `make` to build Vim. The order of the options doesn't matter. To make sure at runtime whether or not the darwin feature is compiled in, you -can use `has('macunix')` which returns 1 if the feature is compiled in; 0 -otherwise. +can use `has('osxdarwin')` which returns 1 if the feature is compiled in; 0 +otherwise. For backwards comptibility, you can still use `macunix` instead of +`osxdarwin`. Notable use cases where `--disable-darwin` is turned out to be useful are: diff --git a/runtime/mswin.vim b/runtime/mswin.vim index 6dff7e7719..da869a9fc7 100644 --- a/runtime/mswin.vim +++ b/runtime/mswin.vim @@ -1,7 +1,7 @@ " Set options and add mapping such that Vim behaves a lot like MS-Windows " " Maintainer: Bram Moolenaar -" Last change: 2017 Feb 09 +" Last change: 2017 Oct 28 " bail out if this isn't wanted (mrsvim.vim uses this). if exists("g:skip_loading_mswin") && g:skip_loading_mswin @@ -105,14 +105,15 @@ onoremap c if has("gui") " CTRL-F is the search dialog - noremap :promptfind - inoremap :promptfind - cnoremap :promptfind + noremap has("gui_running") ? ":promptfind\" : "/" + inoremap has("gui_running") ? "\\:promptfind\" : "\\/" + cnoremap has("gui_running") ? "\\:promptfind\" : "\\/" - " CTRL-H is the replace dialog - noremap :promptrepl - inoremap :promptrepl - cnoremap :promptrepl + " CTRL-H is the replace dialog, + " but in console, it might be backspace, so don't map it there + nnoremap has("gui_running") ? ":promptrepl\" : "\" + inoremap has("gui_running") ? "\\:promptrepl\" : "\" + cnoremap has("gui_running") ? "\\:promptrepl\" : "\" endif " restore 'cpoptions' diff --git a/src/Makefile b/src/Makefile index 0f78257a5e..116e56166a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -340,7 +340,7 @@ CClink = $(CC) # When both GTK+ 2 and GTK+ 3 are possible then GTK+ 2 will be selected. # To use GTK+ 3 instead use --enable-gui=gtk3 (see below). #CONF_OPT_GUI = --disable-gtk2-check -#CONF_OPT_GUI = --enable-gnome2-check +#CONF_OPT_GUI = --enable-gnome-check #CONF_OPT_GUI = --disable-gtk3-check #CONF_OPT_GUI = --disable-motif-check #CONF_OPT_GUI = --disable-athena-check @@ -483,9 +483,12 @@ CClink = $(CC) #CONF_OPT_CHANNEL = --disable-channel # TERMINAL - Terminal emulator support, :terminal command. Requires the -# channel feature. -# Uncomment this when you want terminal emulator support. +# channel feature. The default is enable for when using "huge" features. +# Uncomment the first line when you want terminal emulator support for +# not-huge builds. Uncomment the second line when you don't want terminal +# emulator support in the huge build. #CONF_OPT_TERMINAL = --enable-terminal +#CONF_OPT_TERMINAL = --disable-terminal # MULTIBYTE - To edit multi-byte characters. # Uncomment this when you want to edit a multibyte language. @@ -2117,13 +2120,12 @@ test1 \ test_listchars \ test_search_mbyte \ test_wordcount \ - test3 test11 test12 test14 test15 test17 test19 \ - test20 test25 test28 test29 \ - test30 test32 test36 test37 test38 test39 \ + test3 test11 test12 test14 test15 test17 \ + test29 test30 test36 test37 test39 \ test40 test42 test44 test45 test48 test49 \ test50 test52 test55 test59 \ - test64 test66 test68 test69 \ - test70 test72 test73 test77 test79 \ + test64 test68 test69 \ + test70 test72 test73 test77 \ test83 test85 test86 test87 test88 \ test94 test95 test99 test108: cd testdir; rm -f $@.out; $(MAKE) -f Makefile $@.out VIMPROG=../$(VIMTARGET) $(GUI_TESTARG) SCRIPTSOURCE=../$(SCRIPTSOURCE) @@ -2257,6 +2259,7 @@ test_arglist \ test_reltime \ test_retab \ test_ruby \ + test_scroll_opt \ test_scrollbind \ test_search \ test_searchpos \ diff --git a/src/auto/configure b/src/auto/configure index 0f7315745f..e687c81d55 100755 --- a/src/auto/configure +++ b/src/auto/configure @@ -4185,6 +4185,8 @@ $as_echo_n "checking for Darwin (Mac OS X)... " >&6; } if test "`(uname) 2>/dev/null`" = Darwin; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } + MACOS_X=yes + CPPFLAGS="$CPPFLAGS -DMACOS_X" { $as_echo "$as_me:${as_lineno-$LINENO}: checking --disable-darwin argument" >&5 $as_echo_n "checking --disable-darwin argument... " >&6; } @@ -4384,10 +4386,10 @@ rm -f core conftest.err conftest.$ac_objext \ if test "$enable_darwin" = "yes"; then - MACOSX=yes + MACOS_X_DARWIN=yes OS_EXTRA_SRC="os_macosx.m os_mac_conv.c"; OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o" - CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX" + CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN" # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ @@ -5189,7 +5191,7 @@ rm -f core conftest.err conftest.$ac_objext \ if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll" else - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then ext="dylib" indexes="" else @@ -5235,7 +5237,7 @@ $as_echo "yes" >&6; } LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS" fi if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \ - test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \ + test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \ test "`(uname -m) 2>/dev/null`" = "x86_64"; then LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS" fi @@ -5440,7 +5442,7 @@ $as_echo "not found" >&6; } for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do if test "X$path" != "X"; then - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then MZSCHEME_LIBS="-framework Racket" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" elif test -f "${path}/libmzscheme3m.a"; then @@ -5767,7 +5769,7 @@ $as_echo "OK" >&6; } perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \ -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'` - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then perllibs=`echo "$perllibs" | sed -e 's/-arch[^-]*//g'` perlcppflags=`echo "$perlcppflags" | sed -e 's/-arch[^-]*//g'` fi @@ -5827,7 +5829,7 @@ $as_echo ">>> too old; need Perl version 5.003_01 or later <<<" >&6; } fi fi - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then dir=/System/Library/Perl darwindir=$dir/darwin if test -d $darwindir; then @@ -6051,7 +6053,7 @@ __: eof eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" rm -f -- "${tmp_mkf}" - if test "x$MACOSX" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \ + if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \ "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then vi_cv_path_python_plibs="-framework Python" if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then @@ -6565,7 +6567,7 @@ $as_echo_n "checking whether we can do without RTLD_GLOBAL for Python... " >&6; CFLAGS="$CFLAGS $PYTHON_CFLAGS" libs_save=$LIBS LIBS="-ldl $LIBS" - if test "x$MACOSX" != "xyes"; then + if test "x$MACOS_X" != "xyes"; then if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} @@ -7039,7 +7041,7 @@ $as_echo "$tclver - OK" >&6; }; { $as_echo "$as_me:${as_lineno-$LINENO}: checking for location of Tcl include" >&5 $as_echo_n "checking for location of Tcl include... " >&6; } - if test "x$MACOSX" != "xyes"; then + if test "x$MACOS_X" != "xyes"; then tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver" else tclinc="/System/Library/Frameworks/Tcl.framework/Headers" @@ -7061,7 +7063,7 @@ $as_echo "" >&6; } if test -z "$SKIP_TCL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for location of tclConfig.sh script" >&5 $as_echo_n "checking for location of tclConfig.sh script... " >&6; } - if test "x$MACOSX" != "xyes"; then + if test "x$MACOS_X" != "xyes"; then tclcnf=`echo $tclinc | sed s/include/lib/g` tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`" else @@ -7559,7 +7561,7 @@ fi $as_echo_n "checking --enable-terminal argument... " >&6; } # Check whether --enable-terminal was given. if test "${enable_terminal+set}" = set; then : - enableval=$enable_terminal; enable_terminal="yes" + enableval=$enable_terminal; else enable_terminal="auto" fi @@ -7651,7 +7653,7 @@ fi $as_echo "$enable_fontset" >&6; } test -z "$with_x" && with_x=yes -test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes +test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes if test "$with_x" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: defaulting to: don't HAVE_X11" >&5 $as_echo "defaulting to: don't HAVE_X11" >&6; } @@ -8668,7 +8670,7 @@ $as_echo "$ac_cv_small_wchar_t" >&6; } fi fi -test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no +test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-gui argument" >&5 $as_echo_n "checking --enable-gui argument... " >&6; } @@ -8711,7 +8713,7 @@ $as_echo "Sorry, $enable_gui GUI is not supported" >&6; } SKIP_PHOTON=YES ;; esac -elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then +elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then SKIP_CARBON= SKIP_MACVIM= case "$enable_gui_canon" in @@ -8911,7 +8913,7 @@ $as_echo "$enable_macvim_check" >&6; }; fi fi -if test "x$MACOSX" = "xyes"; then +if test "x$MACOS_X" = "xyes"; then if test x$prefix = xNONE; then prefix=/Applications fi @@ -10735,7 +10737,7 @@ fi done -if test "x$MACOSX" = "xyes"; then +if test "x$MACOS_X" = "xyes"; then $as_echo "#define NO_STRINGS_WITH_STRING_H 1" >>confdefs.h else @@ -12187,7 +12189,7 @@ for ac_func in fchdir fchown fsync getcwd getpseudotty \ getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \ strnicmp strpbrk strtol tgetent towlower towupper iswupper \ - usleep utime utimes + usleep utime utimes mblen do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -14210,31 +14212,54 @@ fi done -if test "x$MACOSX" = "xyes" -a -n "$PERL"; then +if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then if echo $LIBS | grep -e '-ldl' >/dev/null; then LIBS=`echo $LIBS | sed s/-ldl//` PERL_LIBS="$PERL_LIBS -ldl" fi fi -if test "x$MACOSX" = "xyes"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we need -framework Cocoa" >&5 -$as_echo_n "checking whether we need -framework Cocoa... " >&6; } - if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then - LIBS=$"$LIBS -framework Cocoa" - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } +if test "$MACOS_X" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we need macOS frameworks" >&5 +$as_echo_n "checking whether we need macOS frameworks... " >&6; } + if test "$GUITYPE" = "CARBONGUI"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, we need Carbon" >&5 +$as_echo "yes, we need Carbon" >&6; } + LIBS="$LIBS -framework Carbon" + elif test "$MACOS_X_DARWIN" = "yes"; then + if test "$features" = "tiny"; then + OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'` + OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'` + if test "$enable_multibyte" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, we need CoreServices" >&5 +$as_echo "yes, we need CoreServices" >&6; } + LIBS="$LIBS -framework CoreServices" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'` + OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'` + CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'` + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, we need AppKit" >&5 +$as_echo "yes, we need AppKit" >&6; } + LIBS="$LIBS -framework AppKit" + if test "$features" = "small" -a "$enable_multibyte" = "no"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: +multi_byte will be set in favor of +clipboard" >&5 +$as_echo "$as_me: +multi_byte will be set in favor of +clipboard" >&6;} + enable_multibyte=yes + $as_echo "#define FEAT_MBYTE 1" >>confdefs.h + + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - fi - if test "x$features" = "xtiny"; then - OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'` - OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'` fi fi -if test "x$MACOSX" = "xyes"; then +if test "x$MACOS_X" = "xyes"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking --with-xcodecfg argument" >&5 $as_echo_n "checking --with-xcodecfg argument... " >&6; } diff --git a/src/buffer.c b/src/buffer.c index ff33dc4762..6475bb5ec8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4038,9 +4038,14 @@ build_stl_str_hl( /* remove group if all items are empty and highlight group * doesn't change */ group_start_userhl = group_end_userhl = 0; - for (n = 0; n < groupitem[groupdepth]; n++) + for (n = groupitem[groupdepth] - 1; n >= 0; n--) + { if (item[n].type == Highlight) - group_start_userhl = item[n].minwid; + { + group_start_userhl = group_end_userhl = item[n].minwid; + break; + } + } for (n = groupitem[groupdepth] + 1; n < curitem; n++) { if (item[n].type == Normal) diff --git a/src/charset.c b/src/charset.c index 4516816fe4..003949f0a7 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1852,7 +1852,7 @@ vim_isblankline(char_u *lbuf) * If "what" contains STR2NR_OCT recognize octal numbers * If "what" contains STR2NR_HEX recognize hex numbers * If "what" contains STR2NR_FORCE always assume bin/oct/hex. - * If maxlen > 0, check at a maximum maxlen chars + * If maxlen > 0, check at a maximum maxlen chars. */ void vim_str2nr( @@ -1900,17 +1900,14 @@ vim_str2nr( if (what & STR2NR_OCT) { /* Don't interpret "0", "08" or "0129" as octal. */ - for (n = 1; VIM_ISDIGIT(ptr[n]); ++n) + for (n = 1; n != maxlen && VIM_ISDIGIT(ptr[n]); ++n) { if (ptr[n] > '7') { pre = 0; /* can't be octal */ break; } - if (ptr[n] >= '0') - pre = '0'; /* assume octal */ - if (n == maxlen) - break; + pre = '0'; /* assume octal */ } } } diff --git a/src/config.h.in b/src/config.h.in index fe68d49b14..e692d40ac5 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -212,6 +212,7 @@ #undef HAVE_USLEEP #undef HAVE_UTIME #undef HAVE_BIND_TEXTDOMAIN_CODESET +#undef HAVE_MBLEN /* Define, if needed, for accessing large files. */ #undef _LARGE_FILES diff --git a/src/configure.ac b/src/configure.ac index 8c7f72a2bd..adeff93930 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -134,6 +134,8 @@ dnl are a lot of other things we need to change besides GUI stuff AC_MSG_CHECKING([for Darwin (Mac OS X)]) if test "`(uname) 2>/dev/null`" = Darwin; then AC_MSG_RESULT(yes) + MACOS_X=yes + CPPFLAGS="$CPPFLAGS -DMACOS_X" AC_MSG_CHECKING(--disable-darwin argument) AC_ARG_ENABLE(darwin, @@ -226,12 +228,12 @@ if test "`(uname) 2>/dev/null`" = Darwin; then if test "$enable_darwin" = "yes"; then - MACOSX=yes + MACOS_X_DARWIN=yes OS_EXTRA_SRC="os_macosx.m os_mac_conv.c"; OS_EXTRA_OBJ="objects/os_macosx.o objects/os_mac_conv.o" dnl TODO: use -arch i386 on Intel machines dnl Removed -no-cpp-precomp, only for very old compilers. - CPPFLAGS="$CPPFLAGS -DMACOS_X_UNIX" + CPPFLAGS="$CPPFLAGS -DMACOS_X_DARWIN" dnl If Carbon or Cocoa is found, assume we don't want dnl X11 unless it was specifically asked for (--with-x) @@ -645,7 +647,7 @@ if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then if test -f "${vi_cv_path_lua_pfx}/bin/cyglua-${vi_cv_version_lua}.dll"; then vi_cv_dll_name_lua="cyglua-${vi_cv_version_lua}.dll" else - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then ext="dylib" indexes="" else @@ -689,7 +691,7 @@ if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then LUA_CFLAGS="-DDYNAMIC_LUA_DLL=\\\"${vi_cv_dll_name_lua}\\\" $LUA_CFLAGS" fi if test "X$LUA_CFLAGS$LUA_LIBS" != "X" && \ - test "x$MACOSX" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \ + test "x$MACOS_X" = "xyes" && test "x$vi_cv_with_luajit" != "xno" && \ test "`(uname -m) 2>/dev/null`" = "x86_64"; then dnl OSX/x64 requires these flags. See http://luajit.org/install.html LUA_LIBS="-pagezero_size 10000 -image_base 100000000 $LUA_LIBS" @@ -821,7 +823,7 @@ if test "$enable_mzschemeinterp" = "yes"; then for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do if test "X$path" != "X"; then - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then MZSCHEME_LIBS="-framework Racket" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" elif test -f "${path}/libmzscheme3m.a"; then @@ -1043,7 +1045,7 @@ if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then perlldflags=`cd $srcdir; $vi_cv_path_perl -MExtUtils::Embed \ -e 'ccdlflags' | sed -e 's/-bE:perl.exp//'` - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then dnl Perl on Mac OS X 10.5 and later adds "-arch" flags but these dnl should only be included if requested by passing --with-archs dnl to configure, so strip these flags first (if present) @@ -1088,7 +1090,7 @@ if test "$enable_perlinterp" = "yes" -o "$enable_perlinterp" = "dynamic"; then fi fi - if test "x$MACOSX" = "xyes"; then + if test "x$MACOS_X" = "xyes"; then dnl Mac OS X 10.2 or later dir=/System/Library/Perl darwindir=$dir/darwin @@ -1231,7 +1233,7 @@ eof dnl -- delete the lines from make about Entering/Leaving directory eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" rm -f -- "${tmp_mkf}" - if test "x$MACOSX" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \ + if test "x$MACOS_X" = "xyes" && test -n "${python_PYTHONFRAMEWORK}" && ${vi_cv_path_python} -c \ "import sys; sys.exit(${vi_cv_var_python_version} < 2.3)"; then vi_cv_path_python_plibs="-framework Python" if test "x${vi_cv_path_python}" != "x/usr/bin/python" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then @@ -1299,7 +1301,7 @@ eof AC_MSG_CHECKING([if -pthread should be used]) threadsafe_flag= thread_lib= - dnl if test "x$MACOSX" != "xyes"; then + dnl if test "x$MACOS_X" != "xyes"; then if test "`(uname) 2>/dev/null`" != Darwin; then test "$GCC" = yes && threadsafe_flag="-pthread" if test "`(uname) 2>/dev/null`" = FreeBSD; then @@ -1514,7 +1516,7 @@ eof AC_MSG_CHECKING([if -pthread should be used]) threadsafe_flag= thread_lib= - dnl if test "x$MACOSX" != "xyes"; then + dnl if test "x$MACOS_X" != "xyes"; then if test "`(uname) 2>/dev/null`" != Darwin; then test "$GCC" = yes && threadsafe_flag="-pthread" if test "`(uname) 2>/dev/null`" = FreeBSD; then @@ -1592,7 +1594,7 @@ if test "$python_ok" = yes && test "$python3_ok" = yes; then libs_save=$LIBS dnl -ldl must go first to make this work on Archlinux (Roland Puntaier) LIBS="-ldl $LIBS" - if test "x$MACOSX" != "xyes"; then + if test "x$MACOS_X" != "xyes"; then AC_RUN_IFELSE([AC_LANG_SOURCE([ #include /* If this program fails, then RTLD_GLOBAL is needed. @@ -1781,7 +1783,7 @@ if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then tcldll=`echo 'puts libtcl[[info tclversion]][[info sharedlibextension]]' | $vi_cv_path_tcl -` AC_MSG_CHECKING(for location of Tcl include) - if test "x$MACOSX" != "xyes"; then + if test "x$MACOS_X" != "xyes"; then tclinc="$tclloc/include $tclloc/include/tcl $tclloc/include/tcl$tclver /usr/local/include /usr/local/include/tcl$tclver /usr/include /usr/include/tcl$tclver" else dnl For Mac OS X 10.3, use the OS-provided framework location @@ -1801,7 +1803,7 @@ if test "$enable_tclinterp" = "yes" -o "$enable_tclinterp" = "dynamic"; then fi if test -z "$SKIP_TCL"; then AC_MSG_CHECKING(for location of tclConfig.sh script) - if test "x$MACOSX" != "xyes"; then + if test "x$MACOS_X" != "xyes"; then tclcnf=`echo $tclinc | sed s/include/lib/g` tclcnf="$tclcnf `echo $tclinc | sed s/include/lib64/g`" else @@ -2099,7 +2101,7 @@ fi AC_MSG_CHECKING(--enable-terminal argument) AC_ARG_ENABLE(terminal, [ --enable-terminal Enable terminal emulation support.], - [enable_terminal="yes"], [enable_terminal="auto"]) + , [enable_terminal="auto"]) if test "$enable_terminal" = "yes" || test "$enable_terminal" = "auto" -a "x$features" = "xhuge" ; then if test "x$features" = "xtiny" -o "x$features" = "xsmall"; then AC_MSG_RESULT([cannot use terminal emulator with tiny or small features]) @@ -2157,7 +2159,7 @@ AC_MSG_RESULT($enable_fontset) dnl defining FEAT_XFONTSET is delayed, so that it can be disabled for no GUI test -z "$with_x" && with_x=yes -test "${enable_gui-yes}" != no -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && with_x=yes +test "${enable_gui-yes}" != no -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && with_x=yes if test "$with_x" = no; then AC_MSG_RESULT(defaulting to: don't HAVE_X11) else @@ -2288,7 +2290,7 @@ else fi fi -test "x$with_x" = xno -a "x$MACOSX" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no +test "x$with_x" = xno -a "x$MACOS_X" != "xyes" -a "x$QNX" != "xyes" && enable_gui=no AC_MSG_CHECKING(--enable-gui argument) AC_ARG_ENABLE(gui, @@ -2323,7 +2325,7 @@ if test "x$QNX" = "xyes" -a "x$with_x" = "xno" ; then SKIP_PHOTON=YES ;; esac -elif test "x$MACOSX" = "xyes" -a "x$with_x" = "xno" ; then +elif test "x$MACOS_X" = "xyes" -a "x$with_x" = "xno" ; then SKIP_CARBON= SKIP_MACVIM= case "$enable_gui_canon" in @@ -2461,7 +2463,7 @@ if test "x$SKIP_MACVIM" != "xYES" -a "$enable_gui_canon" != "macvim"; then fi fi -if test "x$MACOSX" = "xyes"; then +if test "x$MACOS_X" = "xyes"; then dnl Default install directory is not /usr/local if test x$prefix = xNONE; then prefix=/Applications @@ -3273,7 +3275,7 @@ AC_TRY_COMPILE([ AC_MSG_RESULT(no)) AC_CHECK_HEADERS(strings.h) -if test "x$MACOSX" = "xyes"; then +if test "x$MACOS_X" = "xyes"; then dnl The strings.h file on OS/X contains a warning and nothing useful. AC_DEFINE(NO_STRINGS_WITH_STRING_H) else @@ -3735,7 +3737,7 @@ AC_CHECK_FUNCS(fchdir fchown fsync getcwd getpseudotty \ getpgid setpgid setsid sigaltstack sigstack sigset sigsetjmp sigaction \ sigprocmask sigvec strcasecmp strerror strftime stricmp strncasecmp \ strnicmp strpbrk strtol tgetent towlower towupper iswupper \ - usleep utime utimes) + usleep utime utimes mblen) AC_FUNC_FSEEKO dnl define _LARGE_FILES, _FILE_OFFSET_BITS and _LARGEFILE_SOURCE when @@ -4362,7 +4364,7 @@ elif test x${DLL} = xdl.h; then fi AC_CHECK_HEADERS(setjmp.h) -if test "x$MACOSX" = "xyes" -a -n "$PERL"; then +if test "x$MACOS_X" = "xyes" -a -n "$PERL"; then dnl -ldl must come after DynaLoader.a if echo $LIBS | grep -e '-ldl' >/dev/null; then LIBS=`echo $LIBS | sed s/-ldl//` @@ -4370,26 +4372,44 @@ if test "x$MACOSX" = "xyes" -a -n "$PERL"; then fi fi -if test "x$MACOSX" = "xyes"; then - AC_MSG_CHECKING(whether we need -framework Cocoa) - dnl Cocoa is needed with FEAT_CLIPBOARD or FEAT_MBYTE (the former is - dnl disabled during tiny build) - if test "x$features" != "xtiny" || test "x$enable_multibyte" = "xyes"; then - LIBS=$"$LIBS -framework Cocoa" - AC_MSG_RESULT(yes) +if test "$MACOS_X" = "yes"; then + AC_MSG_CHECKING([whether we need macOS frameworks]) + if test "$GUITYPE" = "CARBONGUI"; then + AC_MSG_RESULT([yes, we need Carbon]) + LIBS="$LIBS -framework Carbon" + elif test "$MACOS_X_DARWIN" = "yes"; then + if test "$features" = "tiny"; then + dnl Since no FEAT_CLIPBOARD, no longer need for os_macosx.m. + OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'` + OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'` + if test "$enable_multibyte" = "yes"; then + AC_MSG_RESULT([yes, we need CoreServices]) + LIBS="$LIBS -framework CoreServices" + else + dnl Since no FEAT_MBYTE, no longer need for os_mac_conv.c. + AC_MSG_RESULT([no]) + OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_mac_conv.c++'` + OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_mac_conv.o++'` + CPPFLAGS=`echo "$CPPFLAGS" | sed -e 's+-DMACOS_X_DARWIN++'` + fi + else + AC_MSG_RESULT([yes, we need AppKit]) + LIBS="$LIBS -framework AppKit" + if test "$features" = "small" -a "$enable_multibyte" = "no"; then + dnl Since FEAT_CLIPBOARD is to be defined in vim.h for FEAT_SMALL, define + dnl FEAT_MBYTE in order not to compromise the interoperability of the + dnl clipboard. + AC_MSG_NOTICE([+multi_byte will be set in favor of +clipboard]) + enable_multibyte=yes + AC_DEFINE(FEAT_MBYTE) + fi + fi else - AC_MSG_RESULT(no) - fi - dnl As mentioned above, tiny build implies os_macosx.m isn't needed. - dnl Exclude it from OS_EXTRA_SRC so that linker won't complain about - dnl missing Objective-C symbols. - if test "x$features" = "xtiny"; then - OS_EXTRA_SRC=`echo "$OS_EXTRA_SRC" | sed -e 's+os_macosx.m++'` - OS_EXTRA_OBJ=`echo "$OS_EXTRA_OBJ" | sed -e 's+objects/os_macosx.o++'` + AC_MSG_RESULT([no]) fi fi -if test "x$MACOSX" = "xyes"; then +if test "x$MACOS_X" = "xyes"; then AC_MSG_CHECKING(--with-xcodecfg argument) AC_ARG_WITH(xcodecfg, [ --with-xcodecfg=CFG Debug, Release (default: Release)], diff --git a/src/digraph.c b/src/digraph.c index 0b78af7451..6b5a5aac25 100644 --- a/src/digraph.c +++ b/src/digraph.c @@ -321,7 +321,7 @@ static digr_T digraphdefault[] = }; # else -# if defined(MACOS) && !defined(FEAT_MBYTE) +# if defined(MACOS_X) && !defined(FEAT_MBYTE) /* * Macintosh digraphs @@ -449,7 +449,7 @@ static digr_T digraphdefault[] = {NUL, NUL, NUL} }; -# else /* !MACOS */ +# else /* !MACOS_X */ # ifdef OLD_DIGRAPHS diff --git a/src/dosinst.c b/src/dosinst.c index bb95bd86ab..94e8669536 100644 --- a/src/dosinst.c +++ b/src/dosinst.c @@ -80,21 +80,23 @@ char *(remap_choices[]) = "Do not remap keys for Windows behavior", "Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)", }; -int remap_choice = (int)remap_win; +int remap_choice = (int)remap_no; char *remap_text = "- %s"; enum { mouse_xterm = 1, - mouse_mswin + mouse_mswin, + mouse_default }; char *(mouse_choices[]) = { "\nChoose the way how Vim uses the mouse:", "right button extends selection (the Unix way)", - "right button has a popup menu (the Windows way)", + "right button has a popup menu, left button starts select mode (the Windows way)", + "right button has a popup menu, left button starts visual mode", }; -int mouse_choice = (int)mouse_mswin; +int mouse_choice = (int)mouse_default; char *mouse_text = "- The mouse %s"; enum @@ -155,8 +157,7 @@ get_choice(char **table, int entries) { if (idx) printf("%2d ", idx); - printf(table[idx]); - printf("\n"); + puts(table[idx]); } printf("Choice: "); if (scanf("%d", &answer) != 1) @@ -1176,6 +1177,8 @@ install_vimrc(int idx) case mouse_mswin: fprintf(fd, "behave mswin\n"); break; + case mouse_default: + break; } if ((tfd = fopen("diff.exe", "r")) != NULL) { @@ -2205,6 +2208,10 @@ print_cmd_line_help(void) printf(" Create .bat files for Vim variants in the Windows directory.\n"); printf("-create-vimrc\n"); printf(" Create a default _vimrc file if one does not already exist.\n"); + printf("-vimrc-remap [no|win]\n"); + printf(" Remap keys when creating a default _vimrc file.\n"); + printf("-vimrc-behave [unix|mswin|default]\n"); + printf(" Set mouse behavior when creating a default _vimrc file.\n"); printf("-install-popup\n"); printf(" Install the Edit-with-Vim context menu entry\n"); printf("-install-openwith\n"); @@ -2260,6 +2267,28 @@ command_line_setup_choices(int argc, char **argv) */ init_vimrc_choices(); } + else if (strcmp(argv[i], "-vimrc-remap") == 0) + { + if (i + 1 == argc) + break; + i++; + if (strcmp(argv[i], "no") == 0) + remap_choice = remap_no; + else if (strcmp(argv[i], "win") == 0) + remap_choice = remap_win; + } + else if (strcmp(argv[i], "-vimrc-behave") == 0) + { + if (i + 1 == argc) + break; + i++; + if (strcmp(argv[i], "unix") == 0) + mouse_choice = mouse_xterm; + else if (strcmp(argv[i], "mswin") == 0) + mouse_choice = mouse_mswin; + else if (strcmp(argv[i], "default") == 0) + mouse_choice = mouse_default; + } else if (strcmp(argv[i], "-install-popup") == 0) { init_popup_choice(); @@ -2424,8 +2453,7 @@ NULL printf("\n"); for (i = 0; items[i] != NULL; ++i) { - printf(items[i]); - printf("\n"); + puts(items[i]); printf("Hit Enter to continue, b (back) or q (quit help): "); c = getchar(); rewind(stdin); diff --git a/src/edit.c b/src/edit.c index 5514164135..025cfa4bb8 100644 --- a/src/edit.c +++ b/src/edit.c @@ -5991,7 +5991,7 @@ insert_special( * Only use mod_mask for special keys, to avoid things like , * unless 'allow_modmask' is TRUE. */ -#ifdef MACOS +#ifdef MACOS_X /* Command-key never produces a normal key */ if (mod_mask & MOD_MASK_CMD) allow_modmask = TRUE; @@ -8770,7 +8770,7 @@ ins_start_select(int c) case K_KPAGEUP: case K_PAGEDOWN: case K_KPAGEDOWN: -# ifdef MACOS +# ifdef MACOS_X case K_LEFT: case K_RIGHT: case K_UP: diff --git a/src/evalfunc.c b/src/evalfunc.c index 3c19beb96e..114a43fa3b 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -24,7 +24,7 @@ # include #endif -#ifdef MACOS +#ifdef MACOS_X # include /* for time_t */ #endif @@ -5546,14 +5546,13 @@ f_has(typval_T *argvars, typval_T *rettv) #ifdef __BEOS__ "beos", #endif -#ifdef MACOS - "mac", -#endif -#if defined(MACOS_X_UNIX) - "macunix", /* built with 'darwin' enabled */ -#endif -#if defined(__APPLE__) && __APPLE__ == 1 - "osx", /* built with or without 'darwin' enabled */ +#ifdef MACOS_X + "mac", /* Mac OS X (and, once, Mac OS Classic) */ + "osx", /* Mac OS X */ +# ifdef MACOS_X_DARWIN + "macunix", /* Mac OS X, with the darwin feature */ + "osxdarwin", /* synonym for macunix */ +# endif #endif #ifdef __QNX__ "qnx", diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index 5de2d2ab08..18215733b2 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -131,6 +131,7 @@ do_debug(char_u *cmd) redir_off = TRUE; /* don't redirect debug commands */ State = NORMAL; + debug_mode = TRUE; if (!debug_did_msg) MSG(_("Entering Debug mode. Type \"cont\" to continue.")); @@ -319,6 +320,7 @@ do_debug(char_u *cmd) msg_scroll = save_msg_scroll; lines_left = Rows - 1; State = save_State; + debug_mode = FALSE; did_emsg = save_did_emsg; cmd_silent = save_cmd_silent; msg_silent = save_msg_silent; diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 05d2d57f50..ad0bb5910e 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -10742,9 +10742,12 @@ eval_vars( if (*s == '<') /* "#<99" uses v:oldfiles */ ++s; i = (int)getdigits(&s); + if (s == src + 2 && src[1] == '-') + /* just a minus sign, don't skip over it */ + s--; *usedlen = (int)(s - src); /* length of what we expand */ - if (src[1] == '<') + if (src[1] == '<' && i != 0) { if (*usedlen < 2) { @@ -10767,6 +10770,8 @@ eval_vars( } else { + if (i == 0 && src[1] == '<' && *usedlen > 1) + *usedlen = 1; buf = buflist_findnr(i); if (buf == NULL) { diff --git a/src/ex_getln.c b/src/ex_getln.c index 20f6ab6408..f04fa6e9ec 100644 --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -1723,8 +1723,9 @@ getcmdline( if (p_is && !cmd_silent && (firstc == '/' || firstc == '?')) { pos_T t; - int search_flags = SEARCH_KEEP + SEARCH_NOOF; + int search_flags = SEARCH_NOOF; + save_last_search_pattern(); cursor_off(); out_flush(); if (c == Ctrl_G) @@ -1734,6 +1735,8 @@ getcmdline( } else t = match_start; + if (!p_hls) + search_flags += SEARCH_KEEP; ++emsg_off; i = searchit(curwin, curbuf, &t, c == Ctrl_G ? FORWARD : BACKWARD, @@ -1785,6 +1788,7 @@ getcmdline( # endif old_botline = curwin->w_botline; update_screen(NOT_VALID); + restore_last_search_pattern(); redrawcmdline(); } else @@ -1942,12 +1946,17 @@ cmdline_changed: } incsearch_postponed = FALSE; curwin->w_cursor = search_start; /* start at old position */ + save_last_search_pattern(); /* If there is no command line, don't do anything */ if (ccline.cmdlen == 0) + { i = 0; + SET_NO_HLSEARCH(TRUE); /* turn off previous highlight */ + } else { + int search_flags = SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK; cursor_off(); /* so the user knows we're busy */ out_flush(); ++emsg_off; /* So it doesn't beep if bad expr */ @@ -1955,8 +1964,10 @@ cmdline_changed: /* Set the time limit to half a second. */ profile_setlimit(500L, &tm); #endif + if (!p_hls) + search_flags += SEARCH_KEEP; i = do_search(NULL, firstc, ccline.cmdbuff, count, - SEARCH_KEEP + SEARCH_OPT + SEARCH_NOOF + SEARCH_PEEK, + search_flags, #ifdef FEAT_RELTIME &tm, NULL #else @@ -2013,6 +2024,7 @@ cmdline_changed: save_cmdline(&save_ccline); update_screen(SOME_VALID); restore_cmdline(&save_ccline); + restore_last_search_pattern(); /* Leave it at the end to make CTRL-R CTRL-W work. */ if (i != 0) diff --git a/src/feature.h b/src/feature.h index caf0703ddb..e3c92b90ff 100644 --- a/src/feature.h +++ b/src/feature.h @@ -61,10 +61,10 @@ */ #if !defined(FEAT_TINY) && !defined(FEAT_SMALL) && !defined(FEAT_NORMAL) \ && !defined(FEAT_BIG) && !defined(FEAT_HUGE) -# if defined(UNIX) || defined(WIN3264) || defined(MACOS) +# if defined(UNIX) || defined(WIN3264) || defined(MACOS_X) # define FEAT_HUGE # else -# if defined(MSWIN) || defined(VMS) || defined(MACOS) || defined(AMIGA) +# if defined(MSWIN) || defined(VMS) || defined(AMIGA) # define FEAT_BIG # else # define FEAT_NORMAL @@ -363,7 +363,7 @@ */ #ifdef FEAT_NORMAL # define FEAT_EVAL -# if defined(HAVE_FLOAT_FUNCS) || defined(WIN3264) || defined(MACOS) +# if defined(HAVE_FLOAT_FUNCS) || defined(WIN3264) || defined(MACOS_X) # define FEAT_FLOAT # endif # if defined(HAVE_STDINT_H) || defined(WIN3264) || (VIM_SIZEOF_LONG >= 8) @@ -783,7 +783,7 @@ * there is no terminal version, and on Windows we can't figure out how to * fork one off with :gui. */ -#if defined(FEAT_GUI_MSWIN) || (defined(FEAT_GUI_MAC) && !defined(MACOS_X_UNIX)) +#if defined(FEAT_GUI_MSWIN) || (defined(FEAT_GUI_MAC) && !defined(MACOS_X_DARWIN)) # define ALWAYS_USE_GUI #endif diff --git a/src/fileio.c b/src/fileio.c index 3a551c7c9d..eb547e48a4 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -68,7 +68,7 @@ static int au_find_group(char_u *name); # define FIO_PUT_CP(x) (((x) & 0xffff) << 16) /* put codepage in top word */ # define FIO_GET_CP(x) (((x)>>16) & 0xffff) /* get codepage from top word */ # endif -# ifdef MACOS_X +# ifdef MACOS_CONVERT # define FIO_MACROMAN 0x20 /* convert MacRoman */ # endif # define FIO_ENDIAN_L 0x80 /* little endian */ @@ -127,7 +127,7 @@ static int make_bom(char_u *buf, char_u *name); # ifdef WIN3264 static int get_win_fio_flags(char_u *ptr); # endif -# ifdef MACOS_X +# ifdef MACOS_CONVERT static int get_mac_fio_flags(char_u *ptr); # endif #endif @@ -1088,7 +1088,7 @@ retry: fio_flags = get_win_fio_flags(fenc); # endif -# ifdef MACOS_X +# ifdef MACOS_CONVERT /* Conversion from Apple MacRoman to latin1 or UTF-8 */ if (fio_flags == 0) fio_flags = get_mac_fio_flags(fenc); @@ -1274,7 +1274,7 @@ retry: else if (fio_flags & FIO_CODEPAGE) size = size / ICONV_MULT; /* also worst case */ # endif -# ifdef MACOS_X +# ifdef MACOS_CONVERT else if (fio_flags & FIO_MACROMAN) size = size / ICONV_MULT; /* also worst case */ # endif @@ -1956,17 +1956,17 @@ retry: { if (fio_flags & FIO_ENDIAN_L) { - u8c = (*--p << 24); - u8c += (*--p << 16); - u8c += (*--p << 8); + u8c = (unsigned)*--p << 24; + u8c += (unsigned)*--p << 16; + u8c += (unsigned)*--p << 8; u8c += *--p; } else /* big endian */ { u8c = *--p; - u8c += (*--p << 8); - u8c += (*--p << 16); - u8c += (*--p << 24); + u8c += (unsigned)*--p << 8; + u8c += (unsigned)*--p << 16; + u8c += (unsigned)*--p << 24; } } else /* UTF-8 */ @@ -4200,20 +4200,6 @@ buf_write( } } -#ifdef MACOS_CLASSIC /* TODO: Is it need for MACOS_X? (Dany) */ - /* - * Before risking to lose the original file verify if there's - * a resource fork to preserve, and if cannot be done warn - * the users. This happens when overwriting without backups. - */ - if (backup == NULL && overwriting && !append) - if (mch_has_resource_fork(fname)) - { - errmsg = (char_u *)_("E460: The resource fork would be lost (add ! to override)"); - goto restore_backup; - } -#endif - #ifdef VMS vms_remove_version(fname); /* remove version */ #endif @@ -4271,7 +4257,7 @@ buf_write( } # endif -# ifdef MACOS_X +# ifdef MACOS_CONVERT if (converted && wb_flags == 0 && (wb_flags = get_mac_fio_flags(fenc)) != 0) { write_info.bw_conv_buflen = bufsize * 3; @@ -4474,13 +4460,7 @@ restore_backup: } write_info.bw_fd = fd; -#if defined(MACOS_CLASSIC) || defined(WIN3264) - /* TODO: Is it need for MACOS_X? (Dany) */ - /* - * On macintosh copy the original files attributes (i.e. the backup) - * This is done in order to preserve the resource fork and the - * Finder attribute (label, comments, custom icons, file creator) - */ +#if defined(WIN3264) if (backup != NULL && overwriting && !append) { if (backup_copy) @@ -5199,10 +5179,6 @@ nofail: got_int |= prev_got_int; -#ifdef MACOS_CLASSIC /* TODO: Is it need for MACOS_X? (Dany) */ - /* Update machine specific information. */ - mch_post_buffer_write(buf); -#endif #ifdef FEAT_ODB_EDITOR odb_post_buffer_write(buf); #endif @@ -5976,7 +5952,7 @@ get_win_fio_flags(char_u *ptr) } #endif -#ifdef MACOS_X +#ifdef MACOS_CONVERT /* * Check "ptr" for a Carbon supported encoding and return the FIO_ flags * needed for the internal conversion to/from utf-8 or latin1. diff --git a/src/getchar.c b/src/getchar.c index 4a59d3a3b8..87cc6fe8d6 100644 --- a/src/getchar.c +++ b/src/getchar.c @@ -1893,7 +1893,7 @@ char_avail(void) int retval; #ifdef FEAT_EVAL - /* When test_disable_char_avail(1) was called pretend there is no + /* When test_override("char_avail", 1) was called pretend there is no * typeahead. */ if (disable_char_avail_for_testing) return FALSE; @@ -5257,7 +5257,7 @@ check_map( } #endif -#if defined(MSWIN) || defined(MACOS) +#if defined(MSWIN) || defined(MACOS_X) #define VIS_SEL (VISUAL+SELECTMODE) /* abbreviation */ @@ -5308,7 +5308,7 @@ static struct initmap # endif #endif -#if defined(MACOS) +#if defined(MACOS_X) # if !defined(FEAT_GUI_MACVIM) /* Use the Standard MacOS binding. */ /* paste, copy and cut */ @@ -5332,7 +5332,7 @@ static struct initmap void init_mappings(void) { -#if defined(MSWIN) ||defined(MACOS) +#if defined(MSWIN) || defined(MACOS_X) int i; for (i = 0; i < (int)(sizeof(initmappings) / sizeof(struct initmap)); ++i) @@ -5340,7 +5340,8 @@ init_mappings(void) #endif } -#if defined(MSWIN) || defined(FEAT_CMDWIN) || defined(MACOS) || defined(PROTO) +#if defined(MSWIN) || defined(FEAT_CMDWIN) || defined(MACOS_X) \ + || defined(PROTO) /* * Add a mapping "map" for mode "mode". * Need to put string in allocated memory, because do_map() will modify it. diff --git a/src/globals.h b/src/globals.h index 4f126cae3c..0047038c35 100644 --- a/src/globals.h +++ b/src/globals.h @@ -924,9 +924,13 @@ EXTERN char_u composing_hangul_buffer[5]; * "Visual_mode" When State is NORMAL or INSERT. * "finish_op" When State is NORMAL, after typing the operator and before * typing the motion command. + * "debug_mode" Debug mode. */ EXTERN int State INIT(= NORMAL); /* This is the current state of the * command interpreter. */ +#ifdef FEAT_EVAL +EXTERN int debug_mode INIT(= FALSE); +#endif EXTERN int finish_op INIT(= FALSE);/* TRUE while an operator is pending */ EXTERN long opcount INIT(= 0); /* count for pending operator */ @@ -1425,8 +1429,9 @@ EXTERN char_u e_failed[] INIT(= N_("E472: Command failed")); #if defined(FEAT_GUI) && defined(FEAT_XFONTSET) EXTERN char_u e_fontset[] INIT(= N_("E234: Unknown fontset: %s")); #endif -#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(MACOS) \ - || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MSWIN) +#if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \ + || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MSWIN) \ + || defined(FEAT_GUI_MACVIM) EXTERN char_u e_font[] INIT(= N_("E235: Unknown font: %s")); #endif #if defined(FEAT_GUI_X11) && !defined(FEAT_GUI_GTK) @@ -1545,7 +1550,7 @@ EXTERN char_u e_readerrf[] INIT(= N_("E47: Error while reading errorfile")); EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox")); #endif EXTERN char_u e_secure[] INIT(= N_("E523: Not allowed here")); -#if defined(AMIGA) || defined(MACOS) || defined(MSWIN) \ +#if defined(AMIGA) || defined(MACOS_X) || defined(MSWIN) \ || defined(UNIX) || defined(VMS) EXTERN char_u e_screenmode[] INIT(= N_("E359: Screen mode setting not supported")); #endif @@ -1592,7 +1597,7 @@ EXTERN char_u e_invalidreg[] INIT(= N_("E850: Invalid register name")); #endif EXTERN char_u e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\"")); -#ifdef MACOS_X_UNIX +#ifdef FEAT_GUI_MAC EXTERN short disallow_gui INIT(= FALSE); #endif diff --git a/src/gui.c b/src/gui.c index 105e47f80a..654edb0c7a 100644 --- a/src/gui.c +++ b/src/gui.c @@ -37,7 +37,7 @@ static void gui_set_fg_color(char_u *name); static void gui_set_bg_color(char_u *name); static win_T *xy2win(int x, int y); -#if defined(UNIX) && !defined(MACOS_X) && !defined(__APPLE__) +#if defined(UNIX) && !defined(FEAT_GUI_MAC) # define MAY_FORK static void gui_do_fork(void); @@ -2454,9 +2454,14 @@ gui_outstr_nowrap( int cl; /* byte length of current char */ int comping; /* current char is composing */ int scol = col; /* screen column */ - int curr_wide; /* use 'guifontwide' */ + int curr_wide = FALSE; /* use 'guifontwide' */ int prev_wide = FALSE; int wide_changed; +# ifdef WIN3264 + int sep_comp = FALSE; /* Don't separate composing chars. */ +# else + int sep_comp = TRUE; /* Separate composing chars. */ +# endif /* Break the string at a composing character, it has to be drawn on * top of the previous character. */ @@ -2466,21 +2471,24 @@ gui_outstr_nowrap( { c = utf_ptr2char(s + i); cn = utf_char2cells(c); -# ifdef FEAT_GUI_MACVIM - curr_wide = (cn > 1); -# else - if (cn > 1 -# ifdef FEAT_XFONTSET - && fontset == NOFONTSET -# endif - && wide_font != NOFONT) - curr_wide = TRUE; - else - curr_wide = FALSE; -# endif comping = utf_iscomposing(c); if (!comping) /* count cells from non-composing chars */ cells += cn; + if (!comping || sep_comp) + { +# ifdef FEAT_GUI_MACVIM + curr_wide = (cn > 1); +# else + if (cn > 1 +# ifdef FEAT_XFONTSET + && fontset == NOFONTSET +# endif + && wide_font != NOFONT) + curr_wide = TRUE; + else + curr_wide = FALSE; +# endif + } cl = utf_ptr2len(s + i); if (cl == 0) /* hit end of string */ len = i + cl; /* len must be wrong "cannot happen" */ @@ -2489,7 +2497,8 @@ gui_outstr_nowrap( /* Print the string so far if it's the last character or there is * a composing character. */ - if (i + cl >= len || (comping && i > start) || wide_changed + if (i + cl >= len || (comping && sep_comp && i > start) + || wide_changed # if defined(FEAT_GUI_X11) || (cn > 1 # ifdef FEAT_XFONTSET @@ -2501,7 +2510,7 @@ gui_outstr_nowrap( # endif ) { - if (comping || wide_changed) + if ((comping && sep_comp) || wide_changed) thislen = i - start; else thislen = i - start + cl; @@ -2525,7 +2534,7 @@ gui_outstr_nowrap( cells = 0; /* Adjust to not draw a character which width is changed * against with last one. */ - if (wide_changed && !comping) + if (wide_changed && !(comping && sep_comp)) { scol -= cn; cl = 0; @@ -2544,10 +2553,10 @@ gui_outstr_nowrap( # endif } /* Draw a composing char on top of the previous char. */ - if (comping) + if (comping && sep_comp) { # if !defined(FEAT_GUI_MACVIM) && \ - (defined(__APPLE_CC__) || defined(__MRC__)) && TARGET_API_MAC_CARBON + (defined(__APPLE_CC__) && TARGET_API_MAC_CARBON) /* Carbon ATSUI autodraws composing char over previous char */ gui_mch_draw_string(gui.row, scol, s + i, cl, draw_flags | DRAW_TRANSP); diff --git a/src/gui_mac.c b/src/gui_mac.c index 34b7f56687..c2e62a4b8b 100644 --- a/src/gui_mac.c +++ b/src/gui_mac.c @@ -267,9 +267,7 @@ static struct /* {XK_Help, '%', '1'}, */ /* {XK_Undo, '&', '8'}, */ /* {XK_BackSpace, 'k', 'b'}, */ -#ifndef MACOS_X - {vk_Delete, 'k', 'b'}, -#endif +/* {vk_Delete, 'k', 'b'}, */ {vk_Insert, 'k', 'I'}, {vk_FwdDelete, 'k', 'D'}, {vk_Home, 'k', 'h'}, diff --git a/src/gui_w32.c b/src/gui_w32.c index 4eaa2be384..67895cca3e 100644 --- a/src/gui_w32.c +++ b/src/gui_w32.c @@ -6295,8 +6295,8 @@ gui_mch_draw_string( if (enc_utf8 && n < len && unicodebuf != NULL) { - /* Output UTF-8 characters. Caller has already separated - * composing characters. */ + /* Output UTF-8 characters. Composing characters should be + * handled here. */ int i; int wlen; /* string length in words */ int clen; /* string length in characters */ @@ -6320,9 +6320,16 @@ gui_mch_draw_string( { unicodebuf[wlen++] = c; } - cw = utf_char2cells(c); - if (cw > 2) /* don't use 4 for unprintable char */ - cw = 1; + + if (utf_iscomposing(c)) + cw = 0; + else + { + cw = utf_char2cells(c); + if (cw > 2) /* don't use 4 for unprintable char */ + cw = 1; + } + if (unicodepdy != NULL) { /* Use unicodepdy to make characters fit as we expect, even @@ -6337,7 +6344,7 @@ gui_mch_draw_string( unicodepdy[wlen - 1] = cw * gui.char_width; } cells += cw; - i += utfc_ptr2len_len(text + i, len - i); + i += utf_ptr2len_len(text + i, len - i); ++clen; } #if defined(FEAT_DIRECTX) diff --git a/src/if_python.c b/src/if_python.c index 2bc743e9c4..a5602aa4e8 100644 --- a/src/if_python.c +++ b/src/if_python.c @@ -74,10 +74,6 @@ # undef PY_SSIZE_T_CLEAN #endif -#if defined(MACOS) && !defined(MACOS_X_UNIX) -# include "macglue.h" -# include -#endif #undef main /* Defined in python.h - aargh */ #undef HAVE_FCNTL_H /* Clash with os_win32.h */ @@ -956,11 +952,7 @@ Python_Init(void) Py_NoSiteFlag++; #endif -#if !defined(MACOS) || defined(MACOS_X_UNIX) Py_Initialize(); -#else - PyMac_Initialize(); -#endif #if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02070000 /* 'import site' explicitly. */ @@ -1032,9 +1024,6 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) #ifndef PY_CAN_RECURSE static int recursive = 0; #endif -#if defined(MACOS) && !defined(MACOS_X_UNIX) - GrafPtr oldPort; -#endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) char *saved_locale; #endif @@ -1053,12 +1042,6 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) if (python_end_called) return; -#if defined(MACOS) && !defined(MACOS_X_UNIX) - GetPort(&oldPort); - /* Check if the Python library is available */ - if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress) - goto theend; -#endif if (Python_Init()) goto theend; @@ -1107,9 +1090,6 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) Python_Lock_Vim(); /* enter vim */ PythonIO_Flush(); -#if defined(MACOS) && !defined(MACOS_X_UNIX) - SetPort(oldPort); -#endif theend: #ifndef PY_CAN_RECURSE diff --git a/src/if_python3.c b/src/if_python3.c index 42706134c1..8ff495ad57 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -74,10 +74,6 @@ #include -#if defined(MACOS) && !defined(MACOS_X_UNIX) -# include "macglue.h" -# include -#endif #undef main /* Defined in python.h - aargh */ #undef HAVE_FCNTL_H /* Clash with os_win32.h */ @@ -885,11 +881,8 @@ Python3_Init(void) PyImport_AppendInittab("vim", Py3Init_vim); -#if !defined(MACOS) || defined(MACOS_X_UNIX) Py_Initialize(); -#else - PyMac_Initialize(); -#endif + /* Initialise threads, and below save the state using * PyEval_SaveThread. Without the call to PyEval_SaveThread, thread * specific state (such as the system trace hook), will be lost @@ -943,9 +936,6 @@ fail: static void DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) { -#if defined(MACOS) && !defined(MACOS_X_UNIX) - GrafPtr oldPort; -#endif #if defined(HAVE_LOCALE_H) || defined(X_LOCALE) char *saved_locale; #endif @@ -956,12 +946,6 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) if (python_end_called) goto theend; -#if defined(MACOS) && !defined(MACOS_X_UNIX) - GetPort(&oldPort); - /* Check if the Python library is available */ - if ((Ptr)PyMac_Initialize == (Ptr)kUnresolvedCFragSymbolAddress) - goto theend; -#endif if (Python3_Init()) goto theend; @@ -1006,9 +990,6 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg) Python_Lock_Vim(); /* enter vim */ PythonIO_Flush(); -#if defined(MACOS) && !defined(MACOS_X_UNIX) - SetPort(oldPort); -#endif theend: return; /* keeps lint happy */ diff --git a/src/if_ruby.c b/src/if_ruby.c index 23bad465f8..3fac3b21a1 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -136,7 +136,7 @@ #undef _ /* T_DATA defined both by Ruby and Mac header files, hack around it... */ -#if defined(MACOS_X_UNIX) || defined(macintosh) +#if defined(MACOS_X) # define __OPENTRANSPORT__ # define __OPENTRANSPORTPROTOCOL__ # define __OPENTRANSPORTPROVIDERS__ @@ -260,7 +260,8 @@ static void ruby_vim_init(void); # endif # define rb_lastline_get dll_rb_lastline_get # define rb_lastline_set dll_rb_lastline_set -# define rb_load_protect dll_rb_load_protect +# define rb_protect dll_rb_protect +# define rb_load dll_rb_load # ifndef RUBY19_OR_LATER # define rb_num2long dll_rb_num2long # endif @@ -385,7 +386,8 @@ static unsigned long (*dll_rb_num2uint) (VALUE); # endif static VALUE (*dll_rb_lastline_get) (void); static void (*dll_rb_lastline_set) (VALUE); -static void (*dll_rb_load_protect) (VALUE, int, int*); +static void (*dll_rb_protect) (VALUE (*)(VALUE), int, int*); +static void (*dll_rb_load) (VALUE, int); static long (*dll_rb_num2long) (VALUE); static unsigned long (*dll_rb_num2ulong) (VALUE); static VALUE (*dll_rb_obj_alloc) (VALUE); @@ -577,7 +579,8 @@ static struct # endif {"rb_lastline_get", (RUBY_PROC*)&dll_rb_lastline_get}, {"rb_lastline_set", (RUBY_PROC*)&dll_rb_lastline_set}, - {"rb_load_protect", (RUBY_PROC*)&dll_rb_load_protect}, + {"rb_protect", (RUBY_PROC*)&dll_rb_protect}, + {"rb_load", (RUBY_PROC*)&dll_rb_load}, {"rb_num2long", (RUBY_PROC*)&dll_rb_num2long}, {"rb_num2ulong", (RUBY_PROC*)&dll_rb_num2ulong}, {"rb_obj_alloc", (RUBY_PROC*)&dll_rb_obj_alloc}, @@ -840,7 +843,8 @@ void ex_rubyfile(exarg_T *eap) if (ensure_ruby_initialized()) { - rb_load_protect(rb_str_new2((char *) eap->arg), 0, &state); + rb_protect((VALUE (*)(VALUE))rb_load, rb_str_new2((char *)eap->arg), + &state); if (state) error_print(state); } } diff --git a/src/keymap.h b/src/keymap.h index b780c66e0d..18024a8209 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -493,7 +493,7 @@ enum key_extra #define MOD_MASK_2CLICK 0x20 /* use MOD_MASK_MULTI_CLICK */ #define MOD_MASK_3CLICK 0x40 /* use MOD_MASK_MULTI_CLICK */ #define MOD_MASK_4CLICK 0x60 /* use MOD_MASK_MULTI_CLICK */ -#ifdef MACOS +#ifdef MACOS_X # define MOD_MASK_CMD 0x80 #endif diff --git a/src/macros.h b/src/macros.h index c320a3f7d3..1b54b91bae 100644 --- a/src/macros.h +++ b/src/macros.h @@ -209,18 +209,13 @@ # define mch_lstat(n, p) mch_stat((n), (p)) #endif -#ifdef MACOS_CLASSIC -/* MacOS classic doesn't support perm but MacOS X does. */ -# define mch_open(n, m, p) open((n), (m)) -#else -# ifdef VMS +#ifdef VMS /* * It is possible to force some record format with: * # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)), "rat=cr", "rfm=stmlf", "mrs=0") * but it is not recommended, because it can destroy indexes etc. */ -# define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)) -# endif +# define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)) #endif /* mch_open_rw(): invoke mch_open() with third argument for user R/W. */ @@ -266,7 +261,7 @@ * PTR2CHAR(): get character from pointer. */ #ifdef FEAT_MBYTE -/* Get the length of the character p points to */ +/* Get the length of the character p points to, including composing chars */ # define MB_PTR2LEN(p) (has_mbyte ? (*mb_ptr2len)(p) : 1) /* Advance multi-byte pointer, skip over composing chars. */ # define MB_PTR_ADV(p) p += has_mbyte ? (*mb_ptr2len)(p) : 1 diff --git a/src/main.c b/src/main.c index 9ec43ffa8e..27147ebb94 100644 --- a/src/main.c +++ b/src/main.c @@ -315,7 +315,7 @@ main params.want_full_screen = FALSE; #endif -#if defined(FEAT_GUI_MAC) && defined(MACOS_X_UNIX) +#if defined(FEAT_GUI_MAC) && defined(MACOS_X_DARWIN) /* When the GUI is started from Finder, need to display messages in a * message box. isatty(2) returns TRUE anyway, thus we need to check the * name to know we're not started from a terminal. */ @@ -990,13 +990,6 @@ common_init(mparm_T *paramp) qnx_init(); /* PhAttach() for clipboard, (and gui) */ #endif -#ifdef MAC_OS_CLASSIC - /* Prepare for possibly starting GUI sometime */ - /* Macintosh needs this before any memory is allocated. */ - gui_prepare(¶mp->argc, paramp->argv); - TIME_MSG("GUI prepared"); -#endif - /* Init the table of Normal mode commands. */ init_normal_cmds(); @@ -1047,7 +1040,7 @@ common_init(mparm_T *paramp) #ifdef FEAT_SUN_WORKSHOP findYourself(paramp->argv[0]); #endif -#if defined(FEAT_GUI) && !defined(MAC_OS_CLASSIC) +#if defined(FEAT_GUI) /* Prepare for possibly starting GUI sometime */ gui_prepare(¶mp->argc, paramp->argv); TIME_MSG("GUI prepared"); @@ -1802,7 +1795,7 @@ parse_command_name(mparm_T *parmp) initstr = gettail((char_u *)parmp->argv[0]); -#ifdef MACOS_X_UNIX +#ifdef FEAT_GUI_MAC /* An issue has been seen when launching Vim in such a way that * $PWD/$ARGV[0] or $ARGV[0] is not the absolute path to the * executable or a symbolic link of it. Until this issue is resolved @@ -2703,7 +2696,7 @@ read_stdin(void) #if defined(HAS_SWAP_EXISTS_ACTION) check_swap_exists_action(); #endif -#if !(defined(AMIGA) || defined(MACOS)) +#if !(defined(AMIGA) || defined(MACOS_X)) /* * Close stdin and dup it from stderr. Required for GPM to work * properly, and for running external commands. @@ -4269,11 +4262,12 @@ eval_client_expr_to_string(char_u *expr) char_u *res; int save_dbl = debug_break_level; int save_ro = redir_off; - void *fc; + void *fc = NULL; /* Evaluate the expression at the toplevel, don't use variables local to - * the calling function. */ - fc = clear_current_funccal(); + * the calling function. Except when in debug mode. */ + if (!debug_mode) + fc = clear_current_funccal(); /* Disable debugging, otherwise Vim hangs, waiting for "cont" to be * typed. */ @@ -4290,7 +4284,8 @@ eval_client_expr_to_string(char_u *expr) --emsg_silent; if (emsg_silent < 0) emsg_silent = 0; - restore_current_funccal(fc); + if (fc != NULL) + restore_current_funccal(fc); /* A client can tell us to redraw, but not to display the cursor, so do * that here. */ diff --git a/src/mbyte.c b/src/mbyte.c index 9a08fb5881..d239e55075 100644 --- a/src/mbyte.c +++ b/src/mbyte.c @@ -105,7 +105,10 @@ # include #endif #ifdef X_LOCALE -#include +# include +# if !defined(HAVE_MBLEN) && !defined(mblen) +# define mblen _Xmblen +# endif #endif #if defined(FEAT_GUI_GTK) && defined(FEAT_XIM) @@ -415,7 +418,7 @@ enc_alias_table[] = {"euccn", IDX_EUC_CN}, {"gb2312", IDX_EUC_CN}, {"euctw", IDX_EUC_TW}, -#if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS) +#if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS_X) {"japan", IDX_CP932}, {"korea", IDX_CP949}, {"prc", IDX_CP936}, @@ -516,7 +519,7 @@ mb_init(void) int n; int enc_dbcs_new = 0; #if defined(USE_ICONV) && !defined(WIN3264) && !defined(WIN32UNIX) \ - && !defined(MACOS) + && !defined(MACOS_CONVERT) # define LEN_FROM_CONV vimconv_T vimconv; char_u *p; @@ -711,7 +714,8 @@ codepage_invalid: * API */ n = IsDBCSLeadByteEx(enc_dbcs, (WINBYTE)i) ? 2 : 1; #else -# if defined(MACOS) || defined(__amigaos4__) || defined(__ANDROID__) +# if defined(__amigaos4__) || defined(__ANDROID__) || \ + !(defined(HAVE_MBLEN) || defined(X_LOCALE)) /* * if mblen() is not available, character which MSB is turned on * are treated as leading byte character. (note : This assumption @@ -720,18 +724,14 @@ codepage_invalid: n = (i & 0x80) ? 2 : 1; # else char buf[MB_MAXBYTES + 1]; -# ifdef X_LOCALE -# ifndef mblen -# define mblen _Xmblen -# endif -# endif + if (i == NUL) /* just in case mblen() can't handle "" */ n = 1; else { buf[0] = i; buf[1] = 0; -#ifdef LEN_FROM_CONV +# ifdef LEN_FROM_CONV if (vimconv.vc_type != CONV_NONE) { /* @@ -748,7 +748,7 @@ codepage_invalid: n = 2; } else -#endif +# endif { /* * mblen() should return -1 for invalid (means the leading @@ -918,7 +918,7 @@ dbcs_class(unsigned lead, unsigned trail) unsigned char tb = trail; /* convert process code to JIS */ -# if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS) +# if defined(WIN3264) || defined(WIN32UNIX) || defined(MACOS_X) /* process code is SJIS */ if (lb <= 0x9f) lb = (lb - 0x81) * 2 + 0x21; @@ -6612,7 +6612,7 @@ convert_setup_ext( vcp->vc_cpto = to_is_utf8 ? 0 : encname2codepage(to); } #endif -#ifdef MACOS_X +#ifdef MACOS_CONVERT else if ((from_prop & ENC_MACROMAN) && (to_prop & ENC_LATIN1)) { vcp->vc_type = CONV_MAC_LATIN1; diff --git a/src/message.c b/src/message.c index 84e09e64aa..bdb83f2094 100644 --- a/src/message.c +++ b/src/message.c @@ -2664,11 +2664,10 @@ msg_puts_printf(char_u *str, int maxlen) if (!(silent_mode && p_verbose == 0)) { /* NL --> CR NL translation (for Unix, not for "--version") */ - /* NL --> CR translation (for Mac) */ p = &buf[0]; if (*s == '\n' && !info_message) *p++ = '\r'; -#if defined(USE_CR) && !defined(MACOS_X_UNIX) +#if defined(USE_CR) else #endif *p++ = *s; @@ -3009,7 +3008,7 @@ mch_errmsg(char *str) * On Mac, when started from Finder, stderr is the console. */ if ( # ifdef UNIX -# ifdef MACOS_X_UNIX +# ifdef MACOS_X (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0) # else isatty(2) @@ -3076,7 +3075,7 @@ mch_msg(char *str) * On Mac, when started from Finder, stderr is the console. */ if ( # ifdef UNIX -# ifdef MACOS_X_UNIX +# ifdef MACOS_X (isatty(2) && strcmp("/dev/console", ttyname(2)) != 0) # else isatty(2) diff --git a/src/misc1.c b/src/misc1.c index 0f27bc63fb..32599a1230 100644 --- a/src/misc1.c +++ b/src/misc1.c @@ -2313,7 +2313,8 @@ ins_char_bytes(char_u *buf, int charlen) /* Copy bytes after the changed character(s). */ p = newp + col; - mch_memmove(p + newlen, oldp + col + oldlen, + if (linelen > col + oldlen) + mch_memmove(p + newlen, oldp + col + oldlen, (size_t)(linelen - col - oldlen)); /* Insert or overwrite the new character. */ @@ -4339,12 +4340,8 @@ vim_getenv(char_u *name, int *mustfree) } /* remove trailing path separator */ -#ifndef MACOS_CLASSIC - /* With MacOS path (with colons) the final colon is required */ - /* to avoid confusion between absolute and relative path */ if (pend > p && after_pathsep(p, pend)) --pend; -#endif #ifdef MACOS_X if (p == exe_name || p == p_hf) @@ -4504,9 +4501,9 @@ get_env_name( expand_T *xp UNUSED, int idx) { -# if defined(AMIGA) || defined(__MRC__) || defined(__SC__) +# if defined(AMIGA) /* - * No environ[] on the Amiga and on the Mac (using MPW). + * No environ[] on the Amiga. */ return NULL; # else @@ -11001,9 +10998,6 @@ gen_expand_wildcards( { char_u *t = backslash_halve_save(p); -#if defined(MACOS_CLASSIC) - slash_to_colon(t); -#endif /* When EW_NOTFOUND is used, always add files and dirs. Makes * "vim c:/" work. */ if (flags & EW_NOTFOUND) diff --git a/src/misc2.c b/src/misc2.c index 75bdd35605..c850adad35 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2202,7 +2202,7 @@ static struct modmasktable {MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2'}, {MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3'}, {MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4'}, -#ifdef MACOS +#ifdef MACOS_X {MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D'}, #endif /* 'A' must be the last one */ @@ -2933,7 +2933,7 @@ extract_modifiers(int key, int *modp) { int modifiers = *modp; -#ifdef MACOS +#ifdef MACOS_X /* Command-key really special, no fancynest */ if (!(modifiers & MOD_MASK_CMD)) #endif @@ -2960,7 +2960,7 @@ extract_modifiers(int key, int *modp) if (key == 0) key = K_ZERO; } -#ifdef MACOS +#ifdef MACOS_X /* Command-key really special, no fancynest */ if (!(modifiers & MOD_MASK_CMD)) #endif @@ -5939,10 +5939,7 @@ pathcmp(const char *p, const char *q, int maxlen) #define EXTRASIZE 5 /* increment to add to env. size */ static int envsize = -1; /* current size of environment */ -#ifndef MACOS_CLASSIC -extern -#endif - char **environ; /* the global which is your env. */ +extern char **environ; /* the global which is your env. */ static int findenv(char *name); /* look for a name in the env. */ static int newenv(void); /* copy env. from stack to heap */ @@ -6014,19 +6011,14 @@ newenv(void) char **env, *elem; int i, esize; -#ifdef MACOS - /* for Mac a new, empty environment is created */ - i = 0; -#else for (i = 0; environ[i]; i++) ; -#endif + esize = i + EXTRASIZE + 1; env = (char **)alloc((unsigned)(esize * sizeof (elem))); if (env == NULL) return -1; -#ifndef MACOS for (i = 0; environ[i]; i++) { elem = (char *)alloc((unsigned)(strlen(environ[i]) + 1)); @@ -6035,7 +6027,6 @@ newenv(void) env[i] = elem; strcpy(elem, environ[i]); } -#endif env[i] = 0; environ = env; @@ -6099,7 +6090,6 @@ filewritable(char_u *fname) #if defined(UNIX) || defined(VMS) perm = mch_getperm(fname); #endif -#ifndef MACOS_CLASSIC /* TODO: get either mch_writable or mch_access */ if ( # ifdef WIN3264 mch_writable(fname) && @@ -6110,7 +6100,6 @@ filewritable(char_u *fname) # endif mch_access((char *)fname, W_OK) == 0 ) -#endif { ++retval; if (mch_isdir(fname)) diff --git a/src/option.c b/src/option.c index b7e3028459..ce19ea7961 100644 --- a/src/option.c +++ b/src/option.c @@ -1477,7 +1477,7 @@ static struct vimoption options[] = , #if defined(FEAT_GUI) (char_u *)&p_go, PV_NONE, -# if defined(UNIX) && !defined(MACOS) +# if defined(UNIX) && !defined(FEAT_GUI_MAC) {(char_u *)"aegimrLtT", (char_u *)0L} # elif defined(FEAT_GUI_MACVIM) {(char_u *)"egmrL", (char_u *)0L} @@ -1749,8 +1749,7 @@ static struct vimoption options[] = {"isprint", "isp", P_STRING|P_VI_DEF|P_RALL|P_COMMA|P_NODUP, (char_u *)&p_isp, PV_NONE, { -#if defined(MSWIN) || (defined(MACOS) && !defined(MACOS_X)) \ - || defined(VMS) +#if defined(MSWIN) || defined(VMS) (char_u *)"@,~-255", #else # ifdef EBCDIC @@ -2065,7 +2064,7 @@ static struct vimoption options[] = #if defined(MSWIN) (char_u *)"popup", #else -# if defined(MACOS) +# if defined(MACOS_X) (char_u *)"popup_setpos", # else (char_u *)"extend", @@ -2454,7 +2453,7 @@ static struct vimoption options[] = SCRIPTID_INIT}, {"scroll", "scr", P_NUM|P_NO_MKRC|P_VI_DEF, (char_u *)VAR_WIN, PV_SCROLL, - {(char_u *)12L, (char_u *)0L} SCRIPTID_INIT}, + {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, {"scrollbind", "scb", P_BOOL|P_VI_DEF, #ifdef FEAT_SCROLLBIND (char_u *)VAR_WIN, PV_SCBIND, @@ -3772,7 +3771,7 @@ set_init_1(void) options[opt_idx].flags |= P_DEF_ALLOCED; } -#if defined(MSWIN) || defined(MACOS) || defined(VMS) +#if defined(MSWIN) || defined(MACOS_X) || defined(VMS) if (STRCMP(p_enc, "latin1") == 0 # ifdef FEAT_MBYTE || enc_utf8 @@ -4027,10 +4026,9 @@ set_init_2(void) int idx; /* - * 'scroll' defaults to half the window height. Note that this default is - * wrong when the window height changes. + * 'scroll' defaults to half the window height. The stored default is zero, + * which results in the actual value computed from the window height. */ - set_number_default("scroll", (long)((long_u)Rows >> 1)); idx = findoption((char_u *)"scroll"); if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) set_option_default(idx, OPT_LOCAL, p_cp); diff --git a/src/os_mac.h b/src/os_mac.h index a0eda82267..9fc2f92899 100644 --- a/src/os_mac.h +++ b/src/os_mac.h @@ -77,7 +77,7 @@ */ /* When compiled under MacOS X (including CARBON version) * we use the Unix File path style. Also when UNIX is defined. */ -# define USE_UNIXFILENAME +#define USE_UNIXFILENAME /* @@ -94,15 +94,10 @@ quite fast. Did I forgot to update the comment */ - #define USE_FNAME_CASE /* make ":e os_Mac.c" open the file in its original case, as "os_mac.c" */ #define BINARY_FILE_IO #define EOL_DEFAULT EOL_MAC -#ifndef MACOS_X_UNIX /* I hope that switching these two lines */ -# define USE_CR /* does what I want -- BNF */ -# define NO_CONSOLE /* don't include console mode */ -#endif #define HAVE_AVAIL_MEM #ifndef HAVE_CONFIG_H @@ -128,38 +123,38 @@ */ #ifndef SYS_VIMRC_FILE -# define SYS_VIMRC_FILE "$VIM/vimrc" +# define SYS_VIMRC_FILE "$VIM/vimrc" #endif #ifndef SYS_GVIMRC_FILE -# define SYS_GVIMRC_FILE "$VIM/gvimrc" +# define SYS_GVIMRC_FILE "$VIM/gvimrc" #endif #ifndef SYS_MENU_FILE -# define SYS_MENU_FILE "$VIMRUNTIME/menu.vim" +# define SYS_MENU_FILE "$VIMRUNTIME/menu.vim" #endif #ifndef SYS_OPTWIN_FILE -# define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" +# define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" #endif #ifndef VIM_DEFAULTS_FILE -# define VIM_DEFAULTS_FILE "$VIMRUNTIME/defaults.vim" +# define VIM_DEFAULTS_FILE "$VIMRUNTIME/defaults.vim" #endif #ifndef EVIM_FILE -# define EVIM_FILE "$VIMRUNTIME/evim.vim" +# define EVIM_FILE "$VIMRUNTIME/evim.vim" #endif #ifdef FEAT_GUI # ifndef USR_GVIMRC_FILE -# define USR_GVIMRC_FILE "~/.gvimrc" +# define USR_GVIMRC_FILE "~/.gvimrc" # endif # ifndef GVIMRC_FILE # define GVIMRC_FILE "_gvimrc" # endif #endif #ifndef USR_VIMRC_FILE -# define USR_VIMRC_FILE "~/.vimrc" +# define USR_VIMRC_FILE "~/.vimrc" #endif #ifndef USR_EXRC_FILE -# define USR_EXRC_FILE "~/.exrc" +# define USR_EXRC_FILE "~/.exrc" #endif #ifndef VIMRC_FILE @@ -171,7 +166,7 @@ #endif #ifndef DFLT_HELPFILE -# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt" +# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt" #endif #ifndef FILETYPE_FILE @@ -194,12 +189,12 @@ #endif #ifndef SYNTAX_FNAME -# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim" +# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim" #endif #ifdef FEAT_VIMINFO # ifndef VIMINFO_FILE -# define VIMINFO_FILE "~/.viminfo" +# define VIMINFO_FILE "~/.viminfo" # endif #endif /* FEAT_VIMINFO */ @@ -218,7 +213,7 @@ #define DFLT_ERRORFILE "errors.err" #ifndef DFLT_RUNTIMEPATH -# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after" +# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after" #endif /* @@ -226,11 +221,6 @@ */ #define CMDBUFFSIZE 1024 /* size of the command processing buffer */ -#if !defined(MACOS_X_UNIX) -# define MAXPATHL 256 /* Limited by the Pascal Strings */ -# define BASENAMELEN (32-5-1) /* length of base of filename */ -#endif - #ifndef DFLT_MAXMEM # define DFLT_MAXMEM 512 /* use up to 512 Kbyte for buffer */ #endif @@ -245,12 +235,8 @@ #define mch_rename(src, dst) rename(src, dst) #define mch_remove(x) unlink((char *)(x)) #ifndef mch_getenv -# if defined(__MRC__) || defined(__SC__) +# if defined(__APPLE_CC__) # define mch_getenv(name) ((char_u *)getenv((char *)(name))) -# define mch_setenv(name, val, x) setenv((name), (val)) -# elif defined(__APPLE_CC__) -# define mch_getenv(name) ((char_u *)getenv((char *)(name))) -/*# define mch_setenv(name, val, x) setenv((name), (val)) */ /* Obsoleted by Dany on Oct 30, 2001 */ # define mch_setenv(name, val, x) setenv(name, val, x) # else /* vim_getenv() is in pty.c */ @@ -275,33 +261,31 @@ * of ./configure for console MacOS X. */ -#ifdef MACOS_X_UNIX -# ifndef SIGPROTOARG -# define SIGPROTOARG (int) -# endif -# ifndef SIGDEFARG -# define SIGDEFARG(s) (s) int s UNUSED; -# endif -# ifndef SIGDUMMYARG -# define SIGDUMMYARG 0 -# endif -# undef HAVE_AVAIL_MEM -# ifndef HAVE_CONFIG_H -# define RETSIGTYPE void -# define SIGRETURN return +#ifndef SIGPROTOARG +# define SIGPROTOARG (int) +#endif +#ifndef SIGDEFARG +# define SIGDEFARG(s) (s) int s UNUSED; +#endif +#ifndef SIGDUMMYARG +# define SIGDUMMYARG 0 +#endif +#undef HAVE_AVAIL_MEM +#ifndef HAVE_CONFIG_H +# define RETSIGTYPE void +# define SIGRETURN return /*# define USE_SYSTEM */ /* Output ship do debugger :(, but ot compile */ -# define HAVE_SYS_WAIT_H 1 /* Attempt */ -# define HAVE_TERMIOS_H 1 -# define SYS_SELECT_WITH_SYS_TIME 1 -# define HAVE_SELECT 1 -# define HAVE_SYS_SELECT_H 1 -# define HAVE_PUTENV -# define HAVE_SETENV -# define HAVE_RENAME -# endif +# define HAVE_SYS_WAIT_H 1 /* Attempt */ +# define HAVE_TERMIOS_H 1 +# define SYS_SELECT_WITH_SYS_TIME 1 +# define HAVE_SELECT 1 +# define HAVE_SYS_SELECT_H 1 +# define HAVE_PUTENV +# define HAVE_SETENV +# define HAVE_RENAME #endif -#if defined(MACOS_X) && !defined(HAVE_CONFIG_H) +#if !defined(HAVE_CONFIG_H) # define HAVE_PUTENV #endif diff --git a/src/os_macosx.m b/src/os_macosx.m index 9e0af1939d..3bcd031777 100644 --- a/src/os_macosx.m +++ b/src/os_macosx.m @@ -8,20 +8,16 @@ */ /* - * os_macosx.m -- Mac specific things for Mac OS/X. + * os_macosx.m -- Mac specific things for Mac OS X. */ -#ifndef MACOS_X_UNIX - Error: MACOS 9 is no longer supported in Vim 7 -#endif - /* Avoid a conflict for the definition of Boolean between Mac header files and * X11 header files. */ #define NO_X11_INCLUDES #define BalloonEval int /* used in header files */ #include "vim.h" -#import +#import /* diff --git a/src/os_unix.c b/src/os_unix.c index d2ac9df956..f47347b4c5 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -856,10 +856,6 @@ mch_stackcheck(char *p) * completely full. */ -#if defined(HAVE_AVAILABILITYMACROS_H) -# include -#endif - #ifndef SIGSTKSZ # define SIGSTKSZ 8000 /* just a guess of how much stack is needed... */ #endif @@ -879,13 +875,6 @@ init_signal_stack(void) if (signal_stack != NULL) { # ifdef HAVE_SIGALTSTACK -# if defined(__APPLE__) && (!defined(MAC_OS_X_VERSION_MAX_ALLOWED) \ - || MAC_OS_X_VERSION_MAX_ALLOWED <= 1040) - /* missing prototype. Adding it to osdef?.h.in doesn't work, because - * "struct sigaltstack" needs to be declared. */ - extern int sigaltstack(const struct sigaltstack *ss, struct sigaltstack *oss); -# endif - # ifdef HAVE_SS_BASE sigstk.ss_base = signal_stack; # else diff --git a/src/popupmnu.c b/src/popupmnu.c index 418f0ca61a..ec75281e77 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -566,6 +566,7 @@ pum_set_selected(int n, int repeat) && vim_strchr(p_cot, 'p') != NULL) { win_T *curwin_save = curwin; + tabpage_T *curtab_save = curtab; int res = OK; /* Open a preview window. 3 lines by default. Prefer @@ -653,8 +654,13 @@ pum_set_selected(int n, int repeat) curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; - if (curwin != curwin_save && win_valid(curwin_save)) + if ((curwin != curwin_save && win_valid(curwin_save)) + || (curtab != curtab_save + && valid_tabpage(curtab_save))) { + if (curtab != curtab_save && valid_tabpage(curtab_save)) + goto_tabpage_tp(curtab_save, FALSE, FALSE); + /* When the first completion is done and the preview * window is not resized, skip the preview window's * status line redrawing. */ diff --git a/src/proto.h b/src/proto.h index 1b0108ba0a..b4f544073d 100644 --- a/src/proto.h +++ b/src/proto.h @@ -213,7 +213,7 @@ void qsort(void *base, size_t elm_count, size_t elm_size, int (*cmp)(const void # endif # if defined(FEAT_GUI) || defined(FEAT_JOB_CHANNEL) -# if defined(UNIX) || defined(MACOS) +# if defined(UNIX) || defined(MACOS_X) # include "pty.pro" # endif # endif @@ -289,8 +289,12 @@ extern char *vim_SelFile(Widget toplevel, char *prompt, char *init_path, int (*s #ifdef MACOS_CONVERT # include "os_mac_conv.pro" #endif -#ifdef MACOS_X -# include "os_macosx.pro" +#if defined(MACOS_X_DARWIN) && defined(FEAT_CLIPBOARD) && !defined(FEAT_GUI) +/* functions in os_macosx.m */ +void clip_mch_lose_selection(VimClipboard *cbd); +int clip_mch_own_selection(VimClipboard *cbd); +void clip_mch_request_selection(VimClipboard *cbd); +void clip_mch_set_selection(VimClipboard *cbd); #endif #ifdef __BORLANDC__ diff --git a/src/proto/search.pro b/src/proto/search.pro index 63955adee0..41c200612f 100644 --- a/src/proto/search.pro +++ b/src/proto/search.pro @@ -5,6 +5,8 @@ char_u *reverse_text(char_u *s); void save_re_pat(int idx, char_u *pat, int magic); void save_search_patterns(void); void restore_search_patterns(void); +void save_last_search_pattern(void); +void restore_last_search_pattern(void); void free_search_patterns(void); int ignorecase(char_u *pat); int ignorecase_opt(char_u *pat, int ic_in, int scs); diff --git a/src/pty.c b/src/pty.c index 151a2780f7..1a27ab69b7 100644 --- a/src/pty.c +++ b/src/pty.c @@ -89,7 +89,7 @@ # include #endif -#if !defined(SUN_SYSTEM) && !defined(VMS) && !defined(MACOS) +#if !defined(SUN_SYSTEM) && !defined(VMS) # include #endif @@ -379,21 +379,15 @@ OpenPTY(char **ttyn) { for (d = PTYRANGE1; (p[1] = *d) != '\0'; d++) { -#if !defined(MACOS) || defined(USE_CARBONIZED) if ((f = open(PtyName, O_RDWR | O_NOCTTY | O_EXTRA, 0)) == -1) -#else - if ((f = open(PtyName, O_RDWR | O_NOCTTY | O_EXTRA)) == -1) -#endif continue; q[0] = *l; q[1] = *d; -#ifndef MACOS if (geteuid() != ROOT_UID && mch_access(TtyName, R_OK | W_OK)) { close(f); continue; } -#endif #if defined(SUN_SYSTEM) && defined(TIOCGPGRP) && !defined(SUNOS3) /* Hack to ensure that the slave side of the pty is * unused. May not work in anything other than SunOS4.1 diff --git a/src/screen.c b/src/screen.c index 64e551359d..07a7e51930 100644 --- a/src/screen.c +++ b/src/screen.c @@ -2123,7 +2123,11 @@ win_update(win_T *wp) wp->w_lines[idx].wl_lnum = lnum; wp->w_lines[idx].wl_valid = TRUE; - if (row > wp->w_height) /* past end of screen */ + + /* Past end of the window or end of the screen. Note that after + * resizing wp->w_height may be end up too big. That's a problem + * elsewhere, but prevent a crash here. */ + if (row > wp->w_height || row + wp->w_winrow >= Rows) { /* we may need the size of that too long line later on */ if (dollar_vcol == -1) diff --git a/src/search.c b/src/search.c index 3e907f4e7f..6bb614953b 100644 --- a/src/search.c +++ b/src/search.c @@ -100,11 +100,14 @@ static int lastc_bytelen = 1; /* >1 for multi-byte char */ #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) /* copy of spats[], for keeping the search patterns while executing autocmds */ static struct spat saved_spats[2]; -static int saved_last_idx = 0; +#endif # ifdef FEAT_SEARCH_EXTRA +/* copy of spats[RE_SEARCH], for keeping the search patterns while incremental + * searching */ +static struct spat saved_last_search_spat; +static int saved_last_idx = 0; static int saved_no_hlsearch = 0; # endif -#endif static char_u *mr_pattern = NULL; /* pattern used by search_regcomp() */ #ifdef FEAT_RIGHTLEFT @@ -333,9 +336,9 @@ restore_search_patterns(void) { vim_free(spats[0].pat); spats[0] = saved_spats[0]; -#if defined(FEAT_EVAL) +# if defined(FEAT_EVAL) set_vv_searchforward(); -#endif +# endif vim_free(spats[1].pat); spats[1] = saved_spats[1]; last_idx = saved_last_idx; @@ -364,6 +367,38 @@ free_search_patterns(void) } #endif +#ifdef FEAT_SEARCH_EXTRA +/* + * Save and restore the search pattern for incremental highlight search + * feature. + * + * It's similar but differnt from save_search_patterns() and + * restore_search_patterns(), because the search pattern must be restored when + * cannceling incremental searching even if it's called inside user functions. + */ + void +save_last_search_pattern(void) +{ + saved_last_search_spat = spats[RE_SEARCH]; + if (spats[RE_SEARCH].pat != NULL) + saved_last_search_spat.pat = vim_strsave(spats[RE_SEARCH].pat); + saved_last_idx = last_idx; + saved_no_hlsearch = no_hlsearch; +} + + void +restore_last_search_pattern(void) +{ + vim_free(spats[RE_SEARCH].pat); + spats[RE_SEARCH] = saved_last_search_spat; +# if defined(FEAT_EVAL) + set_vv_searchforward(); +# endif + last_idx = saved_last_idx; + SET_NO_HLSEARCH(saved_no_hlsearch); +} +#endif + /* * Return TRUE when case should be ignored for search pattern "pat". * Uses the 'ignorecase' and 'smartcase' options. diff --git a/src/spellfile.c b/src/spellfile.c index 6188aaf40c..f6d7a6432f 100644 --- a/src/spellfile.c +++ b/src/spellfile.c @@ -4277,7 +4277,7 @@ spell_read_wordfile(spellinfo_T *spin, char_u *fname) flags |= WF_REGION; l = *p - '0'; - if (l > spin->si_region_count) + if (l == 0 || l > spin->si_region_count) { smsg((char_u *)_("Invalid region nr in %s line %d: %s"), fname, lnum, p); diff --git a/src/structs.h b/src/structs.h index 1ee6b41020..e620c46583 100644 --- a/src/structs.h +++ b/src/structs.h @@ -969,19 +969,12 @@ typedef struct attr_entry # else # if defined(MACOS_X) # include -# define EILSEQ ENOENT /* MacOS X does not have EILSEQ */ +# ifndef EILSEQ +# define EILSEQ ENOENT /* Early MacOS X does not have EILSEQ */ +# endif typedef struct _iconv_t *iconv_t; # else -# if defined(MACOS_CLASSIC) -typedef struct _iconv_t *iconv_t; -# define EINVAL 22 -# define E2BIG 7 -# define ENOENT 2 -# define EFAULT 14 -# define EILSEQ 123 -# else -# include -# endif +# include # endif typedef void *iconv_t; # endif diff --git a/src/tag.c b/src/tag.c index e39098843f..0233822c1d 100644 --- a/src/tag.c +++ b/src/tag.c @@ -2949,6 +2949,25 @@ test_for_static(tagptrs_T *tagp) return FALSE; } +/* + * Returns the length of a matching tag line. + */ + static size_t +matching_line_len(char_u *lbuf) +{ + char_u *p = lbuf + 1; + + /* does the same thing as parse_match() */ + p += STRLEN(p) + 2; +#ifdef FEAT_EMACS_TAGS + if (*p) + p += STRLEN(p); + else + ++p; +#endif + return (p - lbuf) + STRLEN(p); +} + /* * Parse a line from a matching tag. Does not change the line itself. * @@ -3071,7 +3090,7 @@ tag_full_fname(tagptrs_T *tagp) */ static int jumpto_tag( - char_u *lbuf, /* line from the tags file for this tag */ + char_u *lbuf_arg, /* line from the tags file for this tag */ int forceit, /* :ta with ! */ int keep_help) /* keep help flag (FALSE for cscope) */ { @@ -3079,7 +3098,6 @@ jumpto_tag( int save_magic; int save_p_ws, save_p_scs, save_p_ic; linenr_T save_lnum; - int csave = 0; char_u *str; char_u *pbuf; /* search pattern buffer */ char_u *pbuf_end; @@ -3099,18 +3117,26 @@ jumpto_tag( #ifdef FEAT_FOLDING int old_KeyTyped = KeyTyped; /* getting the file may reset it */ #endif + size_t len; + char_u *lbuf; + + /* Make a copy of the line, it can become invalid when an autocommand calls + * back here recursively. */ + len = matching_line_len(lbuf_arg) + 1; + lbuf = alloc((int)len); + if (lbuf != NULL) + mch_memmove(lbuf, lbuf_arg, len); pbuf = alloc(LSIZE); /* parse the match line into the tagp structure */ - if (pbuf == NULL || parse_match(lbuf, &tagp) == FAIL) + if (pbuf == NULL || lbuf == NULL || parse_match(lbuf, &tagp) == FAIL) { tagp.fname_end = NULL; goto erret; } /* truncate the file name, so it can be used as a string */ - csave = *tagp.fname_end; *tagp.fname_end = NUL; fname = tagp.fname; @@ -3246,7 +3272,10 @@ jumpto_tag( #endif keep_help_flag = curbuf->b_help; } + if (getfile_result == GETFILE_UNUSED) + /* Careful: getfile() may trigger autocommands and call jumpto_tag() + * recursively. */ getfile_result = getfile(0, fname, NULL, TRUE, (linenr_T)0, forceit); keep_help_flag = FALSE; @@ -3441,8 +3470,7 @@ erret: #if defined(FEAT_QUICKFIX) g_do_tagpreview = 0; /* For next time */ #endif - if (tagp.fname_end != NULL) - *tagp.fname_end = csave; + vim_free(lbuf); vim_free(pbuf); vim_free(tofree_fname); vim_free(full_fname); diff --git a/src/term.c b/src/term.c index 6cf91fe8ba..8e593b014d 100644 --- a/src/term.c +++ b/src/term.c @@ -2540,7 +2540,7 @@ out_trash(void) void out_char(unsigned c) { -#if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) +#if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ out_char('\r'); #endif @@ -2560,7 +2560,7 @@ static void out_char_nf(unsigned); static void out_char_nf(unsigned c) { -#if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X_UNIX) +#if defined(UNIX) || defined(VMS) || defined(AMIGA) || defined(MACOS_X) if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */ out_char_nf('\r'); #endif diff --git a/src/termlib.c b/src/termlib.c index fee14ae155..0dc58942eb 100644 --- a/src/termlib.c +++ b/src/termlib.c @@ -13,7 +13,7 @@ #include "vim.h" #include "termlib.pro" -#if !defined(AMIGA) && !defined(VMS) && !defined(MACOS) +#if !defined(AMIGA) && !defined(VMS) # include #endif diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak index d0afdb5614..6edca56c78 100644 --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -16,13 +16,9 @@ SCRIPTS_ALL = \ test3.out \ test14.out \ test15.out \ - test19.out \ - test20.out \ - test28.out \ test29.out \ test36.out \ test37.out \ - test38.out \ test39.out \ test40.out \ test42.out \ @@ -31,12 +27,10 @@ SCRIPTS_ALL = \ test48.out \ test55.out \ test64.out \ - test66.out \ test68.out \ test69.out \ test70.out \ test73.out \ - test79.out \ test88.out \ test94.out \ test95.out \ @@ -65,7 +59,6 @@ SCRIPTS_MORE1 = \ # Tests that run on most systems, but not on Amiga and DOS/Windows. SCRIPTS_MORE2 = \ test12.out \ - test25.out \ test49.out @@ -73,7 +66,6 @@ SCRIPTS_MORE2 = \ SCRIPTS_MORE4 = \ test17.out \ test30.out \ - test32.out \ test59.out \ test72.out \ test83.out @@ -129,6 +121,7 @@ NEW_TESTS = test_arabic.res \ test_hlsearch.res \ test_increment.res \ test_increment_dbcs.res \ + test_ins_complete.res \ test_job_fails.res \ test_json.res \ test_langmap.res \ @@ -173,6 +166,7 @@ NEW_TESTS = test_arabic.res \ test_substitute.res \ test_syntax.res \ test_system.res \ + test_tab.res \ test_tcl.res \ test_terminal.res \ test_terminal_fail.res \ diff --git a/src/testdir/Make_amiga.mak b/src/testdir/Make_amiga.mak index 7a8eca2e28..4a6bd9f66f 100644 --- a/src/testdir/Make_amiga.mak +++ b/src/testdir/Make_amiga.mak @@ -14,7 +14,6 @@ include Make_all.mak # test10 'errorformat' is different # test11 "cat" doesn't work properly # test12 can't unlink a swap file -# test25 uses symbolic link # test52 only for Win32 # test85 no Lua interface # test86, 87 no Python interface diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak index 4e0c8f7dbc..52162bccde 100644 --- a/src/testdir/Make_dos.mak +++ b/src/testdir/Make_dos.mak @@ -13,7 +13,6 @@ default: nongui # test2 "\\tmp" doesn't work. # test10 'errorformat' is different # test12 can't unlink a swap file -# test25 uses symbolic link # test49 fails in various ways # test97 \{ and \$ are not escaped characters. diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak index ea748cd939..11346854fd 100644 --- a/src/testdir/Make_ming.mak +++ b/src/testdir/Make_ming.mak @@ -32,7 +32,6 @@ include Make_all.mak # test2 "\\tmp" doesn't work. # test10 'errorformat' is different # test12 can't unlink a swap file -# test25 uses symbolic link # test97 \{ and \$ are not escaped characters SCRIPTS = $(SCRIPTS_ALL) $(SCRIPTS_MORE1) $(SCRIPTS_MORE4) $(SCRIPTS_WIN32) diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms index 30b671c354..b76c2305d4 100644 --- a/src/testdir/Make_vms.mms +++ b/src/testdir/Make_vms.mms @@ -75,21 +75,13 @@ VIMPROG = <->vim.exe SCRIPT = test1.out test3.out \ test14.out test15.out \ - test19.out test20.out \ - test28.out test29.out test30.out test32.out \ - test36.out test37.out \ - test38.out test39.out test40.out test42.out \ - test44.out test45.out \ - test48.out test49.out \ - test55.out \ - test64.out \ - test66.out test68.out test69.out \ - test72.out \ - test77a.out test79.out \ - test88.out \ - test94.out \ - test95.out test99.out \ - test108.out\ + test29.out test30.out \ + test36.out test37.out test39.out \ + test40.out test42.out test44.out test45.out \ + test48.out test49.out test55.out \ + test64.out test68.out test69.out \ + test72.out test77a.out test88.out \ + test94.out test95.out test99.out test108.out\ test_autocmd_option.out \ test_breakindent.out \ test_changelist.out \ @@ -110,10 +102,6 @@ SCRIPT = test1.out test3.out \ # # test30: bug, most probably - a problem around mac format # -# test32: VMS is not case sensitive and all filenames are lowercase within Vim -# (this should be changed in order to preserve the original filename) - should -# be fixed. VMS allows just one dot in the filename -# # test59: Failed/Hangs - VMS does not support spell files (file names # with too many dots). # @@ -131,7 +119,7 @@ GUI_OPTION = -g .ENDIF .IFDEF WANT_UNIX -SCRIPT_UNIX = test10.out test12.out test17.out test25.out test27.out test49.out test73.out +SCRIPT_UNIX = test10.out test12.out test17.out test27.out test49.out test73.out .ENDIF .IFDEF WANT_WIN diff --git a/src/testdir/main.aap b/src/testdir/main.aap index 51e60de82c..14afaace63 100644 --- a/src/testdir/main.aap +++ b/src/testdir/main.aap @@ -7,11 +7,10 @@ VimProg ?= ../vim Scripts = test1.out test2.out test3.out test6.out test11.out test12.out test13.out test14.out test15.out test17.out - test18.out test19.out test20.out test21.out - test25.out test27.out - test28.out test29.out test30.out test32.out + test18.out test21.out + test27.out test29.out test30.out test36.out test37.out - test38.out test39.out test40.out test42.out + test39.out test40.out test42.out test44.out test45.out test46.out test47.out test48.out test49.out test74.out diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim index 245b51c64f..a35944830a 100644 --- a/src/testdir/runtest.vim +++ b/src/testdir/runtest.vim @@ -99,6 +99,10 @@ func RunTheTest(test) " Clear any overrides. call test_override('ALL', 0) + " Some tests wipe out buffers. To be consistent, always wipe out all + " buffers. + %bwipe! + if exists("*SetUp") try call SetUp() @@ -109,14 +113,21 @@ func RunTheTest(test) call add(s:messages, 'Executing ' . a:test) let s:done += 1 - try + + if a:test =~ 'Test_nocatch_' + " Function handles errors itself. This avoids skipping commands after the + " error. exe 'call ' . a:test - catch /^\cskipped/ - call add(s:messages, ' Skipped') - call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) - catch - call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) - endtry + else + try + exe 'call ' . a:test + catch /^\cskipped/ + call add(s:messages, ' Skipped') + call add(s:skipped, 'SKIPPED ' . a:test . ': ' . substitute(v:exception, '^\S*\s\+', '', '')) + catch + call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) + endtry + endif if exists("*TearDown") try @@ -126,7 +137,14 @@ func RunTheTest(test) endtry endif - " Close any extra windows and make the current one not modified. + " Clear any autocommands + au! + + " Close any extra tab pages and windows and make the current one not modified. + while tabpagenr('$') > 1 + quit! + endwhile + while 1 let wincount = winnr('$') if wincount == 1 @@ -139,7 +157,6 @@ func RunTheTest(test) break endif endwhile - set nomodified endfunc func AfterTheTest() @@ -233,6 +250,7 @@ let s:flaky = [ \ 'Test_quoteplus()', \ 'Test_quotestar()', \ 'Test_reltime()', + \ 'Test_terminal_composing_unicode()', \ 'Test_terminal_noblock()', \ 'Test_with_partial_callback()', \ ] diff --git a/src/testdir/test19.in b/src/testdir/test19.in deleted file mode 100644 index aafa34e521..0000000000 --- a/src/testdir/test19.in +++ /dev/null @@ -1,33 +0,0 @@ -Tests for "r" with 'smarttab' and 'expandtab' set/not set. -Also test that dv_ works correctly - -STARTTEST -:so small.vim -:set smarttab expandtab ts=8 sw=4 -:" make sure that backspace works, no matter what termcap is used -:set t_kD=x7f t_kb=x08 -/some -r :set noexpandtab -/other -r -:" Test replacing with Tabs and then backspacing to undo it -0wR  -:" Test replacing with Tabs -0wR  -:" Test that copyindent works with expandtab set -:set expandtab smartindent copyindent ts=8 sw=8 sts=8 -o{ -x:set nosol -/Second line/ -fwdv_:?^start?,$w! test.out -:qa! -ENDTEST - -start text - some test text -test text - other test text - a cde - f ghi -test text - Second line beginning with whitespace diff --git a/src/testdir/test19.ok b/src/testdir/test19.ok deleted file mode 100644 index 4146214919..0000000000 --- a/src/testdir/test19.ok +++ /dev/null @@ -1,10 +0,0 @@ -start text - ome test text -test text - ther test text - a cde - hi -test text -{ - x - with whitespace diff --git a/src/testdir/test20.in b/src/testdir/test20.in deleted file mode 100644 index 662a1439f2..0000000000 --- a/src/testdir/test20.in +++ /dev/null @@ -1,28 +0,0 @@ -Tests Blockwise Visual when there are TABs before the text. -First test for undo working properly when executing commands from a register. -Also test this in an empty buffer. - -STARTTEST -:so tiny.vim -G0"ay$k@au -:new -@auY:quit! -GP -/start here$ -"by$jjlld -/456$ -jj"bP -:/56$/,$-1w! test.out -:qa! -ENDTEST - -123456 -234567 -345678 - -test text test tex start here - some text - test text -test text - -OxjAykdd diff --git a/src/testdir/test20.ok b/src/testdir/test20.ok deleted file mode 100644 index 7c50ea8db8..0000000000 --- a/src/testdir/test20.ok +++ /dev/null @@ -1,10 +0,0 @@ -123start here56 -234start here67 -345start here78 - -test text test tex rt here - somext - tesext -test text - - diff --git a/src/testdir/test25.in b/src/testdir/test25.in deleted file mode 100644 index 4139865daf..0000000000 --- a/src/testdir/test25.in +++ /dev/null @@ -1,31 +0,0 @@ -Test for jumping to a tag with 'hidden' set, with symbolic link in path of tag. -This only works for Unix, because of the symbolic link. - -STARTTEST -:so small.vim -:set hidden -:" Create a link from test25.dir to the current directory. -:!rm -f test25.dir -:!ln -s . test25.dir -:" Create tags.text, with the current directory name inserted. -/tags line -:r !pwd -d$/test -hP:.w! tags.test -:" Try jumping to a tag in the current file, but with a path that contains a -:" symbolic link. When wrong, this will give the ATTENTION message. The next -:" space will then be eaten by hit-return, instead of moving the cursor to 'd'. -:set tags=tags.test -G x:.w! test.out -:!rm -f test25.dir tags.test -:qa! -ENDTEST - -tags line: -SECTION_OFF /test25.dir/test25.in /^#define SECTION_OFF 3$/ - -/*tx.c*/ -#define SECTION_OFF 3 -#define NUM_SECTIONS 3 - -SECTION_OFF diff --git a/src/testdir/test25.ok b/src/testdir/test25.ok deleted file mode 100644 index 08fc070b7b..0000000000 --- a/src/testdir/test25.ok +++ /dev/null @@ -1 +0,0 @@ -#efine SECTION_OFF 3 diff --git a/src/testdir/test28.in b/src/testdir/test28.in deleted file mode 100644 index 5542c92666..0000000000 Binary files a/src/testdir/test28.in and /dev/null differ diff --git a/src/testdir/test28.ok b/src/testdir/test28.ok deleted file mode 100644 index 911d854655..0000000000 --- a/src/testdir/test28.ok +++ /dev/null @@ -1,2 +0,0 @@ -sd -map __2 asdsecondsdsd0map __5 asd0fifth diff --git a/src/testdir/test32.in b/src/testdir/test32.in deleted file mode 100644 index 602d9e5516..0000000000 --- a/src/testdir/test32.in +++ /dev/null @@ -1,61 +0,0 @@ -Test for insert expansion - -:se cpt=.,w -* add-expands (word from next line) from other window -* add-expands (current buffer first) -* Local expansion, ends in an empty line (unless it becomes a global expansion) -* starts Local and switches to global add-expansion -:se cpt=.,w,i -* i-add-expands and switches to local -* add-expands lines (it would end in an empty line if it didn't ignored it self) -:se cpt=kXtestfile -* checks k-expansion, and file expansion (use Xtest11 instead of test11, -* because TEST11.OUT may match first on DOS) -:se cpt=w -* checks make_cyclic in other window -:se cpt=u nohid -* checks unloaded buffer expansion -* checks adding mode abortion -:se cpt=t,d -* tag expansion, define add-expansion interrupted -* t-expansion - -STARTTEST -:so small.vim -:se nocp viminfo+=nviminfo cpt=.,w ff=unix | $-2,$w!Xtestfile | set ff& -:set belloff=all -:se cot= -nO#include "Xtestfile" -ru -O - - -:se cpt=.,w,i -kOM -   -:se cpt=kXtestfile -:w Xtest11.one -:w Xtest11.two -OIXA -:" use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use -:" CTRL-X CTRL-F again to verify this doesn't cause trouble. -OXddk -:se cpt=w -OST -:se cpt=u nohid -oOEN -unl -:se cpt=t,d def=^\\k* tags=Xtestfile notagbsearch -O -a -:wq! test.out -ENDTEST - -start of testfile -run1 -run2 -end of testfile - -test11 36Gepeto /Tag/ -asd test11file 36G -Makefile to run diff --git a/src/testdir/test32.ok b/src/testdir/test32.ok deleted file mode 100644 index afc4463fac..0000000000 --- a/src/testdir/test32.ok +++ /dev/null @@ -1,15 +0,0 @@ -#include "Xtestfile" -run1 run3 -run3 run3 - -Makefile to run3 -Makefile to run3 -Makefile to run3 -Xtest11.two -STARTTEST -ENDTEST -unless -test11file 36Gepeto /Tag/ asd -asd -run1 run2 - diff --git a/src/testdir/test38.in b/src/testdir/test38.in deleted file mode 100644 index 3e0236251b..0000000000 --- a/src/testdir/test38.in +++ /dev/null @@ -1,35 +0,0 @@ - -Test Virtual replace mode. - -STARTTEST -:so small.vim -:" make sure that backspace works, no matter what termcap is used -:set t_kD=x7f t_kb=x08 -ggdGa -abcdefghi -jk lmn - opq rst -uvwxyz -gg:set ai -:set bs=2 -gR0 1 -A -BCDEFGHIJ - KL -MNO -PQRG:ka -o0 -abcdefghi -jk lmn - opq rst -uvwxyz -'ajgR0 1 -A -BCDEFGHIJ - KL -MNO -PQR:$ -iab cdefghi jkl0gRAB......CDEFGHI.Jo: -iabcdefghijklmnopqrst0gRAB IJKLMNO QR:wq! test.out -ENDTEST - diff --git a/src/testdir/test38.ok b/src/testdir/test38.ok deleted file mode 100644 index e10209667b..0000000000 --- a/src/testdir/test38.ok +++ /dev/null @@ -1,13 +0,0 @@ - 1 - A - BCDEFGHIJ - KL - MNO - PQR - 1 -abcdefghi -jk lmn - opq rst -uvwxyz -AB......CDEFGHI.Jkl -AB IJKLMNO QRst diff --git a/src/testdir/test66.in b/src/testdir/test66.in deleted file mode 100644 index f1fdce3792..0000000000 --- a/src/testdir/test66.in +++ /dev/null @@ -1,33 +0,0 @@ - -Test for visual block shift and tab characters. - -STARTTEST -:so small.vim -/^one -fe4jRugvr1:'<,'>w! test.out -/^abcdefgh -4jI j<<11|D -7|a  -7|a  -7|a 4k13|4j< -:$-5,$w >> test.out -:$-4,$s/\s\+//g -4kI j<< -7|a  -7|a  -7|a 4k13|4j3< -:$-4,$w >> test.out -:qa! -ENDTEST - -one two three -one two three -one two three -one two three -one two three - -abcdefghijklmnopqrstuvwxyz -abcdefghijklmnopqrstuvwxyz -abcdefghijklmnopqrstuvwxyz -abcdefghijklmnopqrstuvwxyz -abcdefghijklmnopqrstuvwxyz diff --git a/src/testdir/test66.ok b/src/testdir/test66.ok deleted file mode 100644 index 4c3ab0fb56..0000000000 --- a/src/testdir/test66.ok +++ /dev/null @@ -1,16 +0,0 @@ -on1 two three -on1 two three -on1 two three -on1 two three -on1 two three - - abcdefghijklmnopqrstuvwxyz -abcdefghij - abc defghijklmnopqrstuvwxyz - abc defghijklmnopqrstuvwxyz - abc defghijklmnopqrstuvwxyz - abcdefghijklmnopqrstuvwxyz -abcdefghij - abc defghijklmnopqrstuvwxyz - abc defghijklmnopqrstuvwxyz - abc defghijklmnopqrstuvwxyz diff --git a/src/testdir/test79.in b/src/testdir/test79.in deleted file mode 100644 index 8278bd8000..0000000000 Binary files a/src/testdir/test79.in and /dev/null differ diff --git a/src/testdir/test79.ok b/src/testdir/test79.ok deleted file mode 100644 index e22eee0b71..0000000000 Binary files a/src/testdir/test79.ok and /dev/null differ diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim index ad133033ac..b8a56502b1 100644 --- a/src/testdir/test_alot.vim +++ b/src/testdir/test_alot.vim @@ -41,6 +41,7 @@ source test_popup.vim source test_put.vim source test_recover.vim source test_reltime.vim +source test_scroll_opt.vim source test_searchpos.vim source test_set.vim source test_sort.vim diff --git a/src/testdir/test_arglist.vim b/src/testdir/test_arglist.vim index 2a2425a93f..19d0cee47a 100644 --- a/src/testdir/test_arglist.vim +++ b/src/testdir/test_arglist.vim @@ -253,10 +253,7 @@ func Test_argedit() call assert_equal(['a', 'b', 'a'], argv()) call assert_equal('a', expand('%:t')) " When file name case is ignored, an existing buffer with only case - " difference is re-used. Make sure they don't exist so the case is - " preserved. - bwipe! c - bwipe! d + " difference is re-used. argedit C D call assert_equal('C', expand('%:t')) call assert_equal(['a', 'b', 'a', 'C', 'D'], argv()) diff --git a/src/testdir/test_autochdir.vim b/src/testdir/test_autochdir.vim index f52e2e668a..05d69631c4 100644 --- a/src/testdir/test_autochdir.vim +++ b/src/testdir/test_autochdir.vim @@ -5,6 +5,7 @@ if !exists("+autochdir") endif func Test_set_filename() + let cwd = getcwd() call test_autochdir() set acd new @@ -13,5 +14,6 @@ func Test_set_filename() call assert_equal("samples", substitute(getcwd(), '.*/\(\k*\)', '\1', '')) bwipe! set noacd + exe 'cd ' . cwd call delete('samples/Xtest') endfunc diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index d02b982ee2..c54525378b 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -249,6 +249,23 @@ func Test_augroup_warning() au! VimEnter endfunc +func Test_BufReadCmdHelp() + " This used to cause access to free memory + au BufReadCmd * e +h + help + + au! BufReadCmd +endfunc + +func Test_BufReadCmdHelpJump() + " This used to cause access to free memory + au BufReadCmd * e +h{ + " } to fix highlighting + call assert_fails('help', 'E434:') + + au! BufReadCmd +endfunc + func Test_augroup_deleted() " This caused a crash before E936 was introduced augroup x diff --git a/src/testdir/test_bufwintabinfo.vim b/src/testdir/test_bufwintabinfo.vim index 1c9350c416..a592cd7b11 100644 --- a/src/testdir/test_bufwintabinfo.vim +++ b/src/testdir/test_bufwintabinfo.vim @@ -1,7 +1,6 @@ " Tests for the getbufinfo(), getwininfo() and gettabinfo() functions function Test_getbufwintabinfo() - 1,$bwipeout edit Xtestfile1 edit Xtestfile2 let buflist = getbufinfo() diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim index ff190821cd..832413e813 100644 --- a/src/testdir/test_cmdline.vim +++ b/src/testdir/test_cmdline.vim @@ -365,6 +365,27 @@ func Test_cmdline_complete_user_cmd() delcommand Foo endfunc +func Test_cmdline_write_alternatefile() + new + call setline('.', ['one', 'two']) + f foo.txt + new + f #-A + call assert_equal('foo.txt-A', expand('%')) + f #<-B.txt + call assert_equal('foo-B.txt', expand('%')) + f %< + call assert_equal('foo-B', expand('%')) + new + call assert_fails('f #<', 'E95') + bw! + f foo-B.txt + f %<-A + call assert_equal('foo-B-A', expand('%')) + bw! + bw! +endfunc + " using a leading backslash here set cpo+=C diff --git a/src/testdir/test_command_count.vim b/src/testdir/test_command_count.vim index e438a8b077..2d793ed88f 100644 --- a/src/testdir/test_command_count.vim +++ b/src/testdir/test_command_count.vim @@ -1,6 +1,7 @@ " Test for user command counts. func Test_command_count_0() + let bufnr = bufnr('%') set hidden set noswapfile @@ -15,17 +16,17 @@ func Test_command_count_0() command! -range=% -addr=buffers RangeBuffersAll :let lines = [, ] .,$RangeLoadedBuffers - call assert_equal([1, 1], lines) + call assert_equal([bufnr, bufnr], lines) %RangeLoadedBuffers - call assert_equal([1, 1], lines) + call assert_equal([bufnr, bufnr], lines) RangeLoadedBuffersAll - call assert_equal([1, 1], lines) + call assert_equal([bufnr, bufnr], lines) .,$RangeBuffers - call assert_equal([1, lastbuf], lines) + call assert_equal([bufnr, lastbuf], lines) %RangeBuffers - call assert_equal([1, lastbuf], lines) + call assert_equal([bufnr, lastbuf], lines) RangeBuffersAll - call assert_equal([1, lastbuf], lines) + call assert_equal([bufnr, lastbuf], lines) delcommand RangeLoadedBuffers delcommand RangeLoadedBuffersAll @@ -138,6 +139,7 @@ func Test_command_count_2() endfunc func Test_command_count_3() + let bufnr = bufnr('%') se nohidden e aaa let buf_aaa = bufnr('%') @@ -145,7 +147,7 @@ func Test_command_count_3() let buf_bbb = bufnr('%') e ccc let buf_ccc = bufnr('%') - buf 1 + exe bufnr . 'buf' call assert_equal([1, 1, 1], [buflisted(buf_aaa), buflisted(buf_bbb), buflisted(buf_ccc)]) exe buf_bbb . "," . buf_ccc . "bdelete" call assert_equal([1, 0, 0], [buflisted(buf_aaa), buflisted(buf_bbb), buflisted(buf_ccc)]) @@ -155,7 +157,7 @@ endfunc func Test_command_count_4() %argd - let bufnr = bufnr('$') + 1 + let bufnr = bufnr('$') arga aa bb cc dd ee ff 3argu let args = [] @@ -171,6 +173,8 @@ func Test_command_count_4() only! exe bufnr . 'buf' + bnext + let bufnr = bufnr('%') let buffers = [] .,$-bufdo call add(buffers, bufnr('%')) call assert_equal([bufnr, bufnr + 1, bufnr + 2, bufnr + 3, bufnr + 4], buffers) diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index 078db8ec38..54e7b644ae 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -215,14 +215,16 @@ endfunc func! Test_edit_08() " reset insertmode from i_ctrl-r_= + let g:bufnr = bufnr('%') new call setline(1, ['abc']) call cursor(1, 4) - call feedkeys(":set im\ZZZ\=setbufvar(1,'&im', 0)\",'tnix') + call feedkeys(":set im\ZZZ\=setbufvar(g:bufnr,'&im', 0)\",'tnix') call assert_equal(['abZZZc'], getline(1,'$')) call assert_equal([0, 1, 1, 0], getpos('.')) call assert_false(0, '&im') bw! + unlet g:bufnr endfunc func! Test_edit_09() diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim index 061c3795ad..1a427f6412 100644 --- a/src/testdir/test_filetype.vim +++ b/src/testdir/test_filetype.vim @@ -548,7 +548,7 @@ func Test_script_detection() for file in files call writefile(file, 'Xtest') split Xtest - call assert_equal(ft, &filetype) + call assert_equal(ft, &filetype, 'for text: ' . string(file)) bwipe! endfor endfor diff --git a/src/testdir/test_hardcopy.vim b/src/testdir/test_hardcopy.vim index 07bb2479b7..f630556bef 100644 --- a/src/testdir/test_hardcopy.vim +++ b/src/testdir/test_hardcopy.vim @@ -50,6 +50,7 @@ endfunc " We don't check much of the contents. func Test_with_syntax() if has('postscript') + edit test_hardcopy.vim set printoptions=syntax:y syn on hardcopy > Xhardcopy diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim new file mode 100644 index 0000000000..bdad26a8c7 --- /dev/null +++ b/src/testdir/test_ins_complete.vim @@ -0,0 +1,92 @@ + +" Test for insert expansion +func Test_ins_complete() + edit test_ins_complete.vim + set ff=unix + call writefile(["test11\t36Gepeto\t/Tag/", + \ "asd\ttest11file\t36G", + \ "Makefile\tto\trun"], 'Xtestfile') + call writefile(['', 'start of testfile', + \ 'ru', + \ 'run1', + \ 'run2', + \ 'STARTTEST', + \ 'ENDTEST', + \ 'end of testfile'], 'Xtestdata') + set ff& + + enew! + edit Xtestdata + new + call append(0, ['#include "Xtestfile"', '']) + call cursor(2, 1) + + set cot= + set cpt=.,w + " add-expands (word from next line) from other window + exe "normal iru\\\\\\" + call assert_equal('run1 run3', getline('.')) + " add-expands (current buffer first) + exe "normal o\\\" + call assert_equal('run3 run3', getline('.')) + " Local expansion, ends in an empty line (unless it becomes a global + " expansion) + exe "normal o\\\\\\" + call assert_equal('', getline('.')) + " starts Local and switches to global add-expansion + exe "normal o\\\\\\\\\" + call assert_equal('run1 run2', getline('.')) + + set cpt=.,w,i + " i-add-expands and switches to local + exe "normal OM\\\\\\\\\" + call assert_equal("Makefile\tto\trun3", getline('.')) + " add-expands lines (it would end in an empty line if it didn't ignored + " itself) + exe "normal o\\\\\\" + call assert_equal("Makefile\tto\trun3", getline('.')) + call assert_equal("Makefile\tto\trun3", getline(line('.') - 1)) + + set cpt=kXtestfile + " checks k-expansion, and file expansion (use Xtest11 instead of test11, + " because TEST11.OUT may match first on DOS) + write Xtest11.one + write Xtest11.two + exe "normal o\\IX\A\\\" + call assert_equal('Xtest11.two', getline('.')) + + " use CTRL-X CTRL-F to complete Xtest11.one, remove it and then use CTRL-X + " CTRL-F again to verify this doesn't cause trouble. + exe "normal oXt\\\\\\\\\\\\" + call assert_equal('Xtest11.one', getline('.')) + normal ddk + + set cpt=w + " checks make_cyclic in other window + exe "normal oST\\\\\" + call assert_equal('STARTTEST', getline('.')) + + set cpt=u nohid + " checks unloaded buffer expansion + only + exe "normal oEN\" + call assert_equal('ENDTEST', getline('.')) + " checks adding mode abortion + exe "normal ounl\\\\" + call assert_equal('unless', getline('.')) + + set cpt=t,d def=^\\k* tags=Xtestfile notagbsearch + " tag expansion, define add-expansion interrupted + exe "normal o\\\\\\\\\\\\\\\" + call assert_equal('test11file 36Gepeto /Tag/ asd', getline('.')) + " t-expansion + exe "normal oa\\" + call assert_equal('asd', getline('.')) + + %bw! + call delete('Xtestfile') + call delete('Xtest11.one') + call delete('Xtest11.two') + call delete('Xtestdata') + set cpt& cot& def& tags& tagbsearch& hidden& +endfunc diff --git a/src/testdir/test_lispwords.vim b/src/testdir/test_lispwords.vim index c7eda83540..4c05504cf1 100644 --- a/src/testdir/test_lispwords.vim +++ b/src/testdir/test_lispwords.vim @@ -78,4 +78,5 @@ func Test_lisp_indent() enew! let &cpoptions=save_copt + set nolisp endfunc diff --git a/src/testdir/test_packadd.vim b/src/testdir/test_packadd.vim index 66cbb47834..c83d4a876a 100644 --- a/src/testdir/test_packadd.vim +++ b/src/testdir/test_packadd.vim @@ -2,7 +2,7 @@ func SetUp() - let s:topdir = expand('%:h') . '/Xdir' + let s:topdir = getcwd() . '/Xdir' exe 'set packpath=' . s:topdir let s:plugdir = s:topdir . '/pack/mine/opt/mytest' endfunc diff --git a/src/testdir/test_popup.vim b/src/testdir/test_popup.vim index b770e560dc..1be4e6fd33 100644 --- a/src/testdir/test_popup.vim +++ b/src/testdir/test_popup.vim @@ -661,4 +661,42 @@ func Test_popup_and_window_resize() bwipe! endfunc +func Test_popup_and_preview_autocommand() + " This used to crash Vim + if !has('python') + return + endif + let h = winheight(0) + if h < 15 + return + endif + new + augroup MyBufAdd + au! + au BufAdd * nested tab sball + augroup END + set omnifunc=pythoncomplete#Complete + call setline(1, 'import os') + " make the line long + call setline(2, ' os.') + $ + call feedkeys("A\\\\\\\", 'tx') + call assert_equal("import os", getline(1)) + call assert_match(' os.\(EX_IOERR\|O_CREAT\)$', getline(2)) + call assert_equal(1, winnr('$')) + " previewwindow option is not set + call assert_equal(0, &previewwindow) + norm! gt + call assert_equal(0, &previewwindow) + norm! gT + call assert_equal(12, tabpagenr('$')) + tabonly + pclose + augroup MyBufAdd + au! + augroup END + augroup! MyBufAdd + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_quickfix.vim b/src/testdir/test_quickfix.vim index 90a51050d0..31b6b9f9c2 100644 --- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -151,7 +151,7 @@ endfunc func XageTests(cchar) call s:setup_commands(a:cchar) - let list = [{'bufnr': 1, 'lnum': 1}] + let list = [{'bufnr': bufnr('%'), 'lnum': 1}] call g:Xsetlist(list) " Jumping to a non existent list should return error diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim new file mode 100644 index 0000000000..77920eb8b0 --- /dev/null +++ b/src/testdir/test_scroll_opt.vim @@ -0,0 +1,36 @@ +" Test for reset 'scroll' +" + +func Test_reset_scroll() + let scr = &l:scroll + + setlocal scroll=1 + setlocal scroll& + call assert_equal(scr, &l:scroll) + + setlocal scroll=1 + setlocal scroll=0 + call assert_equal(scr, &l:scroll) + + try + execute 'setlocal scroll=' . (winheight(0) + 1) + " not reached + call assert_false(1) + catch + call assert_exception('E49:') + endtry + + split + + let scr = &l:scroll + + setlocal scroll=1 + setlocal scroll& + call assert_equal(scr, &l:scroll) + + setlocal scroll=1 + setlocal scroll=0 + call assert_equal(scr, &l:scroll) + + quit! +endfunc diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim index 19e631e699..eb781106a9 100644 --- a/src/testdir/test_search.vim +++ b/src/testdir/test_search.vim @@ -1,5 +1,7 @@ " Test for the search command +source shared.vim + func Test_search_cmdline() if !exists('+incsearch') return @@ -431,3 +433,118 @@ func Test_search_regexp() set undolevels& enew! endfunc + +func Test_search_cmdline_incsearch_highlight() + if !exists('+incsearch') + return + endif + set incsearch hlsearch + " need to disable char_avail, + " so that expansion of commandline works + call test_override("char_avail", 1) + new + call setline(1, ['aaa 1 the first', ' 2 the second', ' 3 the third']) + + 1 + call feedkeys("/second\", 'tx') + call assert_equal('second', @/) + call assert_equal(' 2 the second', getline('.')) + + " Canceling search won't change @/ + 1 + let @/ = 'last pattern' + call feedkeys("/third\", 'tx') + call assert_equal('last pattern', @/) + call feedkeys("/third\", 'tx') + call assert_equal('last pattern', @/) + call feedkeys("/3\\", 'tx') + call assert_equal('last pattern', @/) + call feedkeys("/third\\\", 'tx') + call assert_equal('last pattern', @/) + + " clean up + set noincsearch nohlsearch + bw! +endfunc + +func Test_search_cmdline_incsearch_highlight_attr() + if !exists('+incsearch') || !has('terminal') || has('gui_running') + return + endif + let h = winheight(0) + if h < 3 + return + endif + let g:buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile'], {'term_rows': 3}) + + " Prepare buffer text + let lines = ['abb vim vim vi', 'vimvivim'] + call term_sendkeys(g:buf, 'i' . join(lines, "\n") . "\gg0") + call term_wait(g:buf, 200) + call assert_equal(lines[0], term_getline(g:buf, 1)) + + " Get attr of normal(a0), incsearch(a1), hlsearch(a2) highlight + call term_sendkeys(g:buf, ":set incsearch hlsearch\") + call term_sendkeys(g:buf, '/b') + call term_wait(g:buf, 200) + let screen_line1 = term_scrape(g:buf, 1) + call assert_true(len(screen_line1) > 2) + " a0: attr_normal + let a0 = screen_line1[0].attr + " a1: attr_incsearch + let a1 = screen_line1[1].attr + " a2: attr_hlsearch + let a2 = screen_line1[2].attr + call assert_notequal(a0, a1) + call assert_notequal(a0, a2) + call assert_notequal(a1, a2) + call term_sendkeys(g:buf, "\gg0") + + " Test incremental highlight search + call term_sendkeys(g:buf, "/vim") + call term_wait(g:buf, 200) + " Buffer: + " abb vim vim vi + " vimvivim + " Search: /vim + let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a2,a2,a2,a0,a0,a0] + let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2] + call assert_equal(attr_line1, map(term_scrape(g:buf, 1)[:len(attr_line1)-1], 'v:val.attr')) + call assert_equal(attr_line2, map(term_scrape(g:buf, 2)[:len(attr_line2)-1], 'v:val.attr')) + + " Test + call term_sendkeys(g:buf, "\\") + call term_wait(g:buf, 200) + let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0] + let attr_line2 = [a1,a1,a1,a0,a0,a2,a2,a2] + call assert_equal(attr_line1, map(term_scrape(g:buf, 1)[:len(attr_line1)-1], 'v:val.attr')) + call assert_equal(attr_line2, map(term_scrape(g:buf, 2)[:len(attr_line2)-1], 'v:val.attr')) + + " Test + call term_sendkeys(g:buf, "\") + call term_wait(g:buf, 200) + let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a1,a1,a1,a0,a0,a0] + let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2] + call assert_equal(attr_line1, map(term_scrape(g:buf, 1)[:len(attr_line1)-1], 'v:val.attr')) + call assert_equal(attr_line2, map(term_scrape(g:buf, 2)[:len(attr_line2)-1], 'v:val.attr')) + + " Type Enter and a1(incsearch highlight) should become a2(hlsearch highlight) + call term_sendkeys(g:buf, "\") + call term_wait(g:buf, 200) + let attr_line1 = [a0,a0,a0,a0,a2,a2,a2,a0,a2,a2,a2,a0,a0,a0] + let attr_line2 = [a2,a2,a2,a0,a0,a2,a2,a2] + call assert_equal(attr_line1, map(term_scrape(g:buf, 1)[:len(attr_line1)-1], 'v:val.attr')) + call assert_equal(attr_line2, map(term_scrape(g:buf, 2)[:len(attr_line2)-1], 'v:val.attr')) + + " Test nohlsearch. a2(hlsearch highlight) should become a0(normal highlight) + call term_sendkeys(g:buf, ":1\") + call term_sendkeys(g:buf, ":set nohlsearch\") + call term_sendkeys(g:buf, "/vim") + call term_wait(g:buf, 200) + let attr_line1 = [a0,a0,a0,a0,a1,a1,a1,a0,a0,a0,a0,a0,a0,a0] + let attr_line2 = [a0,a0,a0,a0,a0,a0,a0,a0] + call assert_equal(attr_line1, map(term_scrape(g:buf, 1)[:len(attr_line1)-1], 'v:val.attr')) + call assert_equal(attr_line2, map(term_scrape(g:buf, 2)[:len(attr_line2)-1], 'v:val.attr')) + + bwipe! +endfunc diff --git a/src/testdir/test_signs.vim b/src/testdir/test_signs.vim index 75dbd74b34..a967435346 100644 --- a/src/testdir/test_signs.vim +++ b/src/testdir/test_signs.vim @@ -182,7 +182,7 @@ func Test_sign_invalid_commands() call assert_fails('sign define Sign1 xxx', 'E475:') call assert_fails('sign undefine', 'E156:') call assert_fails('sign list xxx', 'E155:') - call assert_fails('sign place 1 buffer=', 'E158:') + call assert_fails('sign place 1 buffer=999', 'E158:') call assert_fails('sign define Sign2 text=', 'E239:') endfunc diff --git a/src/testdir/test_source_utf8.vim b/src/testdir/test_source_utf8.vim index edb76fc43d..c29c2ec1f3 100644 --- a/src/testdir/test_source_utf8.vim +++ b/src/testdir/test_source_utf8.vim @@ -31,3 +31,33 @@ func Test_source_latin() bwipe! call delete('Xscript') endfunc + +" Test for sourcing a file with CTRL-V's at the end of the line +func Test_source_ctrl_v() + call writefile(['map __1 afirst', + \ 'map __2 asecond', + \ 'map __3 athird', + \ 'map __4 afourth', + \ 'map __5 afifth', + \ "map __1 asd\", + \ "map __2 asd\\", + \ "map __3 asd\\", + \ "map __4 asd\\\", + \ "map __5 asd\\\", + \ ], 'Xtestfile') + source Xtestfile + enew! + exe "normal __1\\__2\__3\\__4\__5\" + exe "%s/\/0/g" + call assert_equal(['sd', + \ "map __2 asd\secondsd\sd0map __5 asd0fifth"], + \ getline(1, 2)) + + enew! + call delete('Xtestfile') + unmap __1 + unmap __2 + unmap __3 + unmap __4 + unmap __5 +endfunc diff --git a/src/testdir/test_spell.vim b/src/testdir/test_spell.vim index e4c236c968..54209fec72 100644 --- a/src/testdir/test_spell.vim +++ b/src/testdir/test_spell.vim @@ -271,6 +271,15 @@ func Test_zz_sal_and_addition() call assert_equal("elekwint", SecondSpellWord()) endfunc +func Test_region_error() + messages clear + call writefile(["/regions=usgbnz", "elequint/0"], "Xtest.latin1.add") + mkspell! Xtest.latin1.add.spl Xtest.latin1.add + call assert_match('Invalid region nr in Xtest.latin1.add line 2: 0', execute('messages')) + call delete('Xtest.latin1.add') + call delete('Xtest.latin1.add.spl') +endfunc + " Check using z= in new buffer (crash fixed by patch 7.4a.028). func Test_zeq_crash() new diff --git a/src/testdir/test_statusline.vim b/src/testdir/test_statusline.vim index de943f2466..eafbecdf69 100644 --- a/src/testdir/test_statusline.vim +++ b/src/testdir/test_statusline.vim @@ -312,6 +312,12 @@ func Test_statusline() call assert_equal(sa1, sa3) call assert_equal(sa1, sa4) + let g:a = '' + set statusline=%#Error#{%(\ %{g:a}\ %)} + call assert_match('^{}\s*$', s:get_statusline()) + let g:a = 'X' + call assert_match('^{ X }\s*$', s:get_statusline()) + " %%: a percent sign. set statusline=10%% call assert_match('^10%\s*$', s:get_statusline()) diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim index cd598dc3ca..1c23f8c6a1 100644 --- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -294,3 +294,209 @@ func Test_sub_replace_10() call assert_equal('aa2a3a', substitute('123', '1\|\ze', 'a', 'g')) call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g')) endfunc + +" Tests for *sub-replace-special* and *sub-replace-expression* on :substitute. + +" Execute a list of :substitute command tests +func Run_SubCmd_Tests(tests) + enew! + for t in a:tests + let start = line('.') + 1 + let end = start + len(t[2]) - 1 + exe "normal o" . t[0] + call cursor(start, 1) + exe t[1] + call assert_equal(t[2], getline(start, end), t[1]) + endfor + enew! +endfunc + +func Test_sub_cmd_1() + set magic + set cpo& + + " List entry format: [input, cmd, output] + let tests = [['A', 's/A/&&/', ['AA']], + \ ['B', 's/B/\&/', ['&']], + \ ['C123456789', 's/C\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/', ['C123456789987654321']], + \ ['D', 's/D/d/', ['d']], + \ ['E', 's/E/~/', ['d']], + \ ['F', 's/F/\~/', ['~']], + \ ['G', 's/G/\ugg/', ['Gg']], + \ ['H', 's/H/\Uh\Eh/', ['Hh']], + \ ['I', 's/I/\lII/', ['iI']], + \ ['J', 's/J/\LJ\EJ/', ['jJ']], + \ ['K', 's/K/\Uk\ek/', ['Kk']], + \ ['lLl', "s/L/\\/", ["l\", 'l']], + \ ['mMm', 's/M/\r/', ['m', 'm']], + \ ['nNn', "s/N/\\\\/", ["n\", 'n']], + \ ['oOo', 's/O/\n/', ["o\no"]], + \ ['pPp', 's/P/\b/', ["p\p"]], + \ ['qQq', 's/Q/\t/', ["q\tq"]], + \ ['rRr', 's/R/\\/', ['r\r']], + \ ['sSs', 's/S/\c/', ['scs']], + \ ['tTt', "s/T/\\/", ["t\\t"]], + \ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']], + \ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']] + \ ] + call Run_SubCmd_Tests(tests) +endfunc + +func Test_sub_cmd_2() + set nomagic + set cpo& + + " List entry format: [input, cmd, output] + let tests = [['A', 's/A/&&/', ['&&']], + \ ['B', 's/B/\&/', ['B']], + \ ['C123456789', 's/\mC\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\0\9\8\7\6\5\4\3\2\1/', ['C123456789987654321']], + \ ['D', 's/D/d/', ['d']], + \ ['E', 's/E/~/', ['~']], + \ ['F', 's/F/\~/', ['~']], + \ ['G', 's/G/\ugg/', ['Gg']], + \ ['H', 's/H/\Uh\Eh/', ['Hh']], + \ ['I', 's/I/\lII/', ['iI']], + \ ['J', 's/J/\LJ\EJ/', ['jJ']], + \ ['K', 's/K/\Uk\ek/', ['Kk']], + \ ['lLl', "s/L/\\/", ["l\", 'l']], + \ ['mMm', 's/M/\r/', ['m', 'm']], + \ ['nNn', "s/N/\\\\/", ["n\", 'n']], + \ ['oOo', 's/O/\n/', ["o\no"]], + \ ['pPp', 's/P/\b/', ["p\p"]], + \ ['qQq', 's/Q/\t/', ["q\tq"]], + \ ['rRr', 's/R/\\/', ['r\r']], + \ ['sSs', 's/S/\c/', ['scs']], + \ ['tTt', "s/T/\\/", ["t\\t"]], + \ ['U', 's/U/\L\uuUu\l\EU/', ['UuuU']], + \ ['V', 's/V/\U\lVvV\u\Ev/', ['vVVv']] + \ ] + call Run_SubCmd_Tests(tests) +endfunc + +func Test_sub_cmd_3() + set nomagic + set cpo& + + " List entry format: [input, cmd, output] + let tests = [['aAa', "s/A/\\='\\'/", ['a\a']], + \ ['bBb', "s/B/\\='\\\\'/", ['b\\b']], + \ ['cCc', "s/C/\\='\\'/", ["c\", 'c']], + \ ['dDd', "s/D/\\='\\\\'/", ["d\\\", 'd']], + \ ['eEe', "s/E/\\='\\\\\\'/", ["e\\\\\", 'e']], + \ ['fFf', "s/F/\\='\r'/", ['f', 'f']], + \ ['gGg', "s/G/\\='\\'/", ["g\", 'g']], + \ ['hHh', "s/H/\\='\\\\'/", ["h\\\", 'h']], + \ ['iIi', "s/I/\\='\\\\\\'/", ["i\\\\\", 'i']], + \ ['jJj', "s/J/\\='\n'/", ['j', 'j']], + \ ['kKk', 's/K/\="\r"/', ['k', 'k']], + \ ['lLl', 's/L/\="\n"/', ['l', 'l']] + \ ] + call Run_SubCmd_Tests(tests) +endfunc + +" Test for submatch() on :substitue. +func Test_sub_cmd_4() + set magic& + set cpo& + + " List entry format: [input, cmd, output] + let tests = [ ['aAa', "s/A/\\=substitute(submatch(0), '.', '\\', '')/", + \ ['a\a']], + \ ['bBb', "s/B/\\=substitute(submatch(0), '.', '\\', '')/", + \ ['b\b']], + \ ['cCc', "s/C/\\=substitute(submatch(0), '.', '\\', '')/", + \ ["c\", 'c']], + \ ['dDd', "s/D/\\=substitute(submatch(0), '.', '\\\\', '')/", + \ ["d\", 'd']], + \ ['eEe', "s/E/\\=substitute(submatch(0), '.', '\\\\\\', '')/", + \ ["e\\\", 'e']], + \ ['fFf', "s/F/\\=substitute(submatch(0), '.', '\\r', '')/", + \ ['f', 'f']], + \ ['gGg', 's/G/\=substitute(submatch(0), ".", "\\", "")/', + \ ["g\", 'g']], + \ ['hHh', 's/H/\=substitute(submatch(0), ".", "\\\\", "")/', + \ ["h\", 'h']], + \ ['iIi', 's/I/\=substitute(submatch(0), ".", "\\\\\\", "")/', + \ ["i\\\", 'i']], + \ ['jJj', "s/J/\\=substitute(submatch(0), '.', '\\n', '')/", + \ ['j', 'j']], + \ ['kKk', "s/K/\\=substitute(submatch(0), '.', '\\r', '')/", + \ ['k', 'k']], + \ ['lLl', "s/L/\\=substitute(submatch(0), '.', '\\n', '')/", + \ ['l', 'l']], + \ ] + call Run_SubCmd_Tests(tests) +endfunc + +func Test_sub_cmd_5() + set magic& + set cpo& + + " List entry format: [input, cmd, output] + let tests = [ ['A123456789', 's/A\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=submatch(0) . submatch(9) . submatch(8) . submatch(7) . submatch(6) . submatch(5) . submatch(4) . submatch(3) . submatch(2) . submatch(1)/', ['A123456789987654321']], + \ ['B123456789', 's/B\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)/\=string([submatch(0, 1), submatch(9, 1), submatch(8, 1), submatch(7, 1), submatch(6, 1), submatch(5, 1), submatch(4, 1), submatch(3, 1), submatch(2, 1), submatch(1, 1)])/', ["[['B123456789'], ['9'], ['8'], ['7'], ['6'], ['5'], ['4'], ['3'], ['2'], ['1']]"]], + \ ] + call Run_SubCmd_Tests(tests) +endfunc + +" Test for *:s%* on :substitute. +func Test_sub_cmd_6() + set magic& + set cpo+=/ + + " List entry format: [input, cmd, output] + let tests = [ ['A', 's/A/a/', ['a']], + \ ['B', 's/B/%/', ['a']], + \ ] + call Run_SubCmd_Tests(tests) + + set cpo-=/ + let tests = [ ['C', 's/C/c/', ['c']], + \ ['D', 's/D/%/', ['%']], + \ ] + call Run_SubCmd_Tests(tests) + + set cpo& +endfunc + +" Test for :s replacing \n with line break. +func Test_sub_cmd_7() + set magic& + set cpo& + + " List entry format: [input, cmd, output] + let tests = [ ["A\\A", 's/A./\=submatch(0)/', ['A', 'A']], + \ ["B\\B", 's/B./\=submatch(0)/', ['B', 'B']], + \ ["C\\C", 's/C./\=strtrans(string(submatch(0, 1)))/', [strtrans("['C\']C")]], + \ ["D\\\nD", 's/D.\nD/\=strtrans(string(submatch(0, 1)))/', [strtrans("['D\', 'D']")]], + \ ["E\\\n\\\n\\\n\\\n\\E", 's/E\_.\{-}E/\=strtrans(string(submatch(0, 1)))/', [strtrans("['E\', '\', '\', '\', '\E']")]], + \ ] + call Run_SubCmd_Tests(tests) + + exe "normal oQ\nQ\k" + call assert_fails('s/Q[^\n]Q/\=submatch(0)."foobar"/', 'E486') + enew! +endfunc + +func TitleString() + let check = 'foo' =~ 'bar' + return "" +endfunc + +func Test_sub_cmd_8() + set titlestring=%{TitleString()} + + enew! + call append(0, ['', 'test_one', 'test_two']) + call cursor(1,1) + /^test_one/s/.*/\="foo\nbar"/ + call assert_equal('foo', getline(2)) + call assert_equal('bar', getline(3)) + call feedkeys(':/^test_two/s/.*/\="foo\nbar"/c', "t") + call feedkeys("\y", "xt") + call assert_equal('foo', getline(4)) + call assert_equal('bar', getline(5)) + + enew! + set titlestring& +endfunc diff --git a/src/testdir/test_tab.vim b/src/testdir/test_tab.vim new file mode 100644 index 0000000000..b847dbd962 --- /dev/null +++ b/src/testdir/test_tab.vim @@ -0,0 +1,45 @@ + +" Tests for "r" with 'smarttab' and 'expandtab' set/not set. +" Also test that dv_ works correctly +func Test_smarttab() + enew! + set smarttab expandtab ts=8 sw=4 + " make sure that backspace works, no matter what termcap is used + exe "set t_kD=\x7f t_kb=\x08" + call append(0, ['start text', + \ "\t\tsome test text", + \ 'test text', + \ "\t\tother test text", + \ ' a cde', + \ ' f ghi', + \ 'test text', + \ ' Second line beginning with whitespace' + \ ]) + call cursor(1, 1) + exe "normal /some\" + exe "normal r\t" + call assert_equal("\t\t ome test text", getline('.')) + set noexpandtab + exe "normal /other\" + exe "normal r\t" + call assert_equal("\t\t ther test text", getline('.')) + + " Test replacing with Tabs and then backspacing to undo it + exe "normal j0wR\t\t\t\\\" + call assert_equal(" a cde", getline('.')) + " Test replacing with Tabs + exe "normal j0wR\t\t\t" + call assert_equal(" \t\thi", getline('.')) + + " Test that copyindent works with expandtab set + set expandtab smartindent copyindent ts=8 sw=8 sts=8 + exe "normal jo{\x" + call assert_equal('{', getline(line('.') - 1)) + call assert_equal(' x', getline('.')) + set nosol + exe "normal /Second line/\" + exe "normal fwdv_" + call assert_equal(' with whitespace', getline('.')) + enew! + set expandtab& smartindent& copyindent& ts& sw& sts& +endfunc diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim index 239b1b965b..95e3c135f2 100644 --- a/src/testdir/test_tabpage.vim +++ b/src/testdir/test_tabpage.vim @@ -475,6 +475,7 @@ endfunc func Test_close_on_quitpre() " This once caused a crash + edit Xtest new only set bufhidden=delete @@ -489,7 +490,7 @@ func Test_close_on_quitpre() while tabpagenr('$') > 1 bwipe! endwhile - 1b + buf Xtest endfunc " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_tagjump.vim b/src/testdir/test_tagjump.vim index bac413dac8..dbab8d9e26 100644 --- a/src/testdir/test_tagjump.vim +++ b/src/testdir/test_tagjump.vim @@ -137,4 +137,41 @@ function Test_keyword_jump() call delete('Xinclude') endfunction +" Test for jumping to a tag with 'hidden' set, with symbolic link in path of +" tag. This only works for Unix, because of the symbolic link. +func Test_tag_symbolic() + if !has('unix') + return + endif + set hidden + call delete("Xtest.dir", "rf") + call system("ln -s . Xtest.dir") + " Create a tags file with the current directory name inserted. + call writefile([ + \ "SECTION_OFF " . getcwd() . "/Xtest.dir/Xtest.c /^#define SECTION_OFF 3$/", + \ '', + \ ], 'Xtags') + call writefile(['#define SECTION_OFF 3', + \ '#define NUM_SECTIONS 3'], 'Xtest.c') + + " Try jumping to a tag, but with a path that contains a symbolic link. When + " wrong, this will give the ATTENTION message. The next space will then be + " eaten by hit-return, instead of moving the cursor to 'd'. + set tags=Xtags + enew! + call append(0, 'SECTION_OFF') + call cursor(1,1) + exe "normal \ " + call assert_equal('Xtest.c', expand('%:t')) + call assert_equal(2, col('.')) + + set hidden& + set tags& + enew! + call delete('Xtags') + call delete('Xtest.c') + call delete("Xtest.dir", "rf") + %bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim index 06732af715..bda7a442f1 100644 --- a/src/testdir/test_undo.vim +++ b/src/testdir/test_undo.vim @@ -273,3 +273,19 @@ func Test_undofile_earlier() call delete('Xfile') call delete('Xundofile') endfunc + +" Test for undo working properly when executing commands from a register. +" Also test this in an empty buffer. +func Test_cmd_in_reg_undo() + enew! + let @a="Ox\jAy\kdd" + edit +/^$ test_undo.vim + normal @au + call assert_equal(0, &modified) + return + new + normal @au + call assert_equal(0, &modified) + only! + let @a='' +endfunc diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim index 0e6231fd6d..4287a9e491 100644 --- a/src/testdir/test_visual.vim +++ b/src/testdir/test_visual.vim @@ -89,3 +89,101 @@ func Test_visual_mode_reset() endfunc +" Test for visual block shift and tab characters. +func Test_block_shift_tab() + enew! + call append(0, repeat(['one two three'], 5)) + call cursor(1,1) + exe "normal i\u" + exe "normal fe\4jR\ugvr1" + call assert_equal('on1 two three', getline(1)) + call assert_equal('on1 two three', getline(2)) + call assert_equal('on1 two three', getline(5)) + + enew! + call append(0, repeat(['abcdefghijklmnopqrstuvwxyz'], 5)) + call cursor(1,1) + exe "normal \4jI \j<<11|D" + exe "normal j7|a\\" + exe "normal j7|a\\ " + exe "normal j7|a\ \\4k13|\4j<" + call assert_equal(' abcdefghijklmnopqrstuvwxyz', getline(1)) + call assert_equal('abcdefghij', getline(2)) + call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(3)) + call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(4)) + call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(5)) + + %s/\s\+//g + call cursor(1,1) + exe "normal \4jI \j<<" + exe "normal j7|a\\" + exe "normal j7|a\\\\\" + exe "normal j7|a\ \\\4k13|\4j3<" + call assert_equal(' abcdefghijklmnopqrstuvwxyz', getline(1)) + call assert_equal('abcdefghij', getline(2)) + call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(3)) + call assert_equal(" abc\\defghijklmnopqrstuvwxyz", getline(4)) + call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(5)) + + enew! +endfunc + +" Tests Blockwise Visual when there are TABs before the text. +func Test_blockwise_visual() + enew! + call append(0, ['123456', + \ '234567', + \ '345678', + \ '', + \ 'test text test tex start here', + \ "\t\tsome text", + \ "\t\ttest text", + \ 'test text']) + call cursor(1,1) + exe "normal /start here$\" + exe 'normal "by$' . "\jjlld" + exe "normal /456$\" + exe "normal \jj" . '"bP' + call assert_equal(['123start here56', + \ '234start here67', + \ '345start here78', + \ '', + \ 'test text test tex rt here', + \ "\t\tsomext", + \ "\t\ttesext"], getline(1, 7)) + + enew! +endfunc + +" Test Virtual replace mode. +func Test_virtual_replace() + exe "set t_kD=\x7f t_kb=\x08" + enew! + exe "normal a\nabcdefghi\njk\tlmn\n opq rst\n\uvwxyz" + call cursor(1,1) + set ai bs=2 + exe "normal gR0\ 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR" + call assert_equal([' 1', + \ ' A', + \ ' BCDEFGHIJ', + \ ' KL', + \ ' MNO', + \ ' PQR', + \ ], getline(1, 6)) + normal G + mark a + exe "normal o0\\nabcdefghi\njk\tlmn\n opq\trst\n\uvwxyz\n" + exe "normal 'ajgR0\ 1\nA\nBCDEFGHIJ\n\tKL\nMNO\nPQR" . repeat("\", 29) + call assert_equal([' 1', + \ 'abcdefghi', + \ 'jk lmn', + \ ' opq rst', + \ 'uvwxyz'], getline(7, 11)) + normal G + exe "normal iab\tcdefghi\tjkl" + exe "normal 0gRAB......CDEFGHI.J\o" + exe "normal iabcdefghijklmnopqrst\0gRAB\tIJKLMNO\tQR" + call assert_equal(['AB......CDEFGHI.Jkl', + \ 'AB IJKLMNO QRst'], getline(12, 13)) + enew! +endfunc diff --git a/src/ui.c b/src/ui.c index 9b808c9ed8..840fa70af7 100644 --- a/src/ui.c +++ b/src/ui.c @@ -1768,7 +1768,7 @@ read_from_input_buf(char_u *buf, long maxlen) void fill_input_buf(int exit_on_error UNUSED) { -#if defined(UNIX) || defined(VMS) || defined(MACOS_X_UNIX) +#if defined(UNIX) || defined(VMS) || defined(MACOS_X) int len; int try; static int did_read_something = FALSE; @@ -1792,7 +1792,7 @@ fill_input_buf(int exit_on_error UNUSED) return; } #endif -#if defined(UNIX) || defined(VMS) || defined(MACOS_X_UNIX) +#if defined(UNIX) || defined(VMS) || defined(MACOS_X) if (vim_is_input_buf_full()) return; /* diff --git a/src/undo.c b/src/undo.c index adb8bd9836..ec34d26ae2 100644 --- a/src/undo.c +++ b/src/undo.c @@ -1750,7 +1750,7 @@ write_error: if (!write_ok) EMSG2(_("E829: write error in undo file: %s"), file_name); -#if defined(MACOS_CLASSIC) || defined(WIN3264) +#if defined(WIN3264) /* Copy file attributes; for systems where this can only be done after * closing the file. */ if (buf->b_ffname != NULL) diff --git a/src/version.c b/src/version.c index 592eae73bb..38db1e1926 100644 --- a/src/version.c +++ b/src/version.c @@ -776,6 +776,50 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1238, +/**/ + 1237, +/**/ + 1236, +/**/ + 1235, +/**/ + 1234, +/**/ + 1233, +/**/ + 1232, +/**/ + 1231, +/**/ + 1230, +/**/ + 1229, +/**/ + 1228, +/**/ + 1227, +/**/ + 1226, +/**/ + 1225, +/**/ + 1224, +/**/ + 1223, +/**/ + 1222, +/**/ + 1221, +/**/ + 1220, +/**/ + 1219, +/**/ + 1218, +/**/ + 1217, /**/ 1216, /**/ @@ -3366,15 +3410,11 @@ list_version(void) # endif # endif #endif -#ifdef MACOS -# ifdef MACOS_X -# ifdef MACOS_X_UNIX - MSG_PUTS(_("\nMacOS X (unix) version")); -# else - MSG_PUTS(_("\nMacOS X version")); -# endif -#else - MSG_PUTS(_("\nMacOS version")); +#if defined(MACOS_X) +# if defined(MACOS_X_DARWIN) + MSG_PUTS(_("\nmacOS version")); +# else + MSG_PUTS(_("\nmacOS version w/o darwin feat.")); # endif #endif @@ -3507,13 +3547,6 @@ list_version(void) # if defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON MSG_PUTS(_("with Carbon GUI.")); # else -# if defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX - MSG_PUTS(_("with Cocoa GUI.")); -# else -# if defined(MACOS) - MSG_PUTS(_("with (classic) GUI.")); -# endif -# endif # endif # endif # endif diff --git a/src/vim.h b/src/vim.h index d90f71140f..26ef2e6d70 100644 --- a/src/vim.h +++ b/src/vim.h @@ -85,28 +85,15 @@ #endif /* - * MACOS_CLASSIC compiling for MacOS prior to MacOS X - * MACOS_X_UNIX compiling for MacOS X (using os_unix.c) - * MACOS_X compiling for MacOS X (using os_unix.c) - * MACOS compiling for either one + * MACOS_X compiling for Mac OS X + * MACOS_X_DARWIN integrating the darwin feature into MACOS_X */ -#if defined(macintosh) && !defined(MACOS_CLASSIC) -# define MACOS_CLASSIC -#endif -#if defined(MACOS_X_UNIX) +#if defined(MACOS_X_DARWIN) && !defined(MACOS_X) # define MACOS_X -# ifndef HAVE_CONFIG_H -# define UNIX -# endif -#endif -#if defined(MACOS_X) || defined(MACOS_CLASSIC) -# define MACOS -#endif -#if defined(MACOS_X) && defined(MACOS_CLASSIC) - Error: To compile for both MACOS X and Classic use a Classic Carbon #endif /* Unless made through the Makefile enforce GUI on Mac */ -#if defined(MACOS) && !defined(HAVE_CONFIG_H) +#if defined(MACOS_X) && !defined(HAVE_CONFIG_H) +# define UNIX # define FEAT_GUI_MAC #endif @@ -165,23 +152,17 @@ # endif # endif #endif -#ifdef MACOS -# if defined(__POWERPC__) || defined(MACOS_X) || defined(__fourbyteints__) \ - || defined(__MRC__) || defined(__SC__) || defined(__APPLE_CC__)/* MPW Compilers */ -# define VIM_SIZEOF_INT 4 -# else -# define VIM_SIZEOF_INT 2 -# endif +#if defined(MACOS_X) && !defined(HAVE_CONFIG_H) +# define VIM_SIZEOF_INT __SIZEOF_INT__ #endif - /* * #defines for optionals and features * Also defines FEAT_TINY, FEAT_SMALL, etc. when FEAT_HUGE is defined. */ #include "feature.h" -#if defined(MACOS_X_UNIX) +#if defined(MACOS_X_DARWIN) # if defined(FEAT_SMALL) && !defined(FEAT_CLIPBOARD) # define FEAT_CLIPBOARD # endif @@ -228,7 +209,7 @@ #endif /* The Mac conversion stuff doesn't work under X11. */ -#if defined(FEAT_MBYTE) && defined(MACOS_X) +#if defined(FEAT_MBYTE) && defined(MACOS_X_DARWIN) # define MACOS_CONVERT #endif @@ -298,10 +279,7 @@ # include "os_mint.h" #endif -#if defined(MACOS) -# if defined(__MRC__) || defined(__SC__) /* MPW Compilers */ -# define HAVE_SETENV -# endif +#if defined(MACOS_X) # include "os_mac.h" #endif @@ -2361,9 +2339,10 @@ typedef enum { # ifdef instr # undef instr # endif - /* bool may cause trouble on MACOS but is required on a few other systems - * and for Perl */ -# if defined(bool) && defined(MACOS) && !defined(FEAT_PERL) + /* bool may cause trouble on some old versions of Mac OS X but is required + * on a few other systems and for Perl */ +# if (defined(MACOS_X) && !defined(MAC_OS_X_VERSION_10_6)) \ + && defined(bool) && !defined(FEAT_PERL) # undef bool # endif diff --git a/src/window.c b/src/window.c index ca36902d97..dfbb57c049 100644 --- a/src/window.c +++ b/src/window.c @@ -6377,7 +6377,7 @@ vim_FullName( /* something failed; use the file name (truncate when too long) */ vim_strncpy(buf, fname, len - 1); } -#if defined(MACOS_CLASSIC) || defined(MSWIN) +#if defined(MSWIN) slash_adjust(buf); #endif return retval;