aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.ci/clang-asan.sh34
-rw-r--r--.ci/common.sh36
-rw-r--r--.ci/gcc-32.sh13
-rw-r--r--.ci/gcc.sh22
-rw-r--r--.travis.yml52
-rw-r--r--README.md2
-rw-r--r--clint-files.txt2
-rw-r--r--runtime/doc/autocmd.txt4
-rw-r--r--runtime/doc/cmdline.txt10
-rw-r--r--runtime/doc/editing.txt12
-rw-r--r--runtime/doc/eval.txt3
-rw-r--r--runtime/doc/gui.txt2
-rw-r--r--runtime/doc/insert.txt4
-rw-r--r--runtime/doc/job_control.txt2
-rw-r--r--runtime/doc/options.txt39
-rw-r--r--runtime/doc/print.txt12
-rw-r--r--runtime/doc/quickfix.txt4
-rw-r--r--runtime/doc/repeat.txt2
-rw-r--r--runtime/doc/starting.txt29
-rw-r--r--runtime/doc/todo.txt9
-rw-r--r--runtime/doc/usr_01.txt2
-rw-r--r--runtime/doc/usr_05.txt1
-rw-r--r--runtime/doc/usr_41.txt2
-rw-r--r--runtime/doc/vi_diff.txt2
-rw-r--r--runtime/gvimrc_example.vim2
-rw-r--r--runtime/menu.vim2
-rw-r--r--runtime/optwin.vim4
-rw-r--r--runtime/tools/README.txt2
-rw-r--r--runtime/vimrc_example.vim2
-rw-r--r--src/nvim/CMakeLists.txt4
-rw-r--r--src/nvim/api/vim.c31
-rw-r--r--src/nvim/buffer.c13
-rw-r--r--src/nvim/buffer_defs.h5
-rw-r--r--src/nvim/charset.c5
-rw-r--r--src/nvim/cursor_shape.c2
-rw-r--r--src/nvim/digraph.c8
-rw-r--r--src/nvim/edit.c48
-rw-r--r--src/nvim/eval.c31
-rw-r--r--src/nvim/ex_cmds.c15
-rw-r--r--src/nvim/ex_cmds2.c3
-rw-r--r--src/nvim/ex_docmd.c16
-rw-r--r--src/nvim/ex_eval.c6
-rw-r--r--src/nvim/ex_getln.c34
-rw-r--r--src/nvim/file_search.c41
-rw-r--r--src/nvim/fileio.c11
-rw-r--r--src/nvim/getchar.c14
-rw-r--r--src/nvim/globals.h5
-rw-r--r--src/nvim/hardcopy.c4
-rw-r--r--src/nvim/if_cscope.c4
-rw-r--r--src/nvim/indent_c.c47
-rw-r--r--src/nvim/main.c114
-rw-r--r--src/nvim/mark.c6
-rw-r--r--src/nvim/mbyte.c21
-rw-r--r--src/nvim/memfile.c6
-rw-r--r--src/nvim/memline.c4
-rw-r--r--src/nvim/memory.c1
-rw-r--r--src/nvim/message.c8
-rw-r--r--src/nvim/misc1.c16
-rw-r--r--src/nvim/misc2.c5
-rw-r--r--src/nvim/mouse.c438
-rw-r--r--src/nvim/mouse.h32
-rw-r--r--src/nvim/normal.c34
-rw-r--r--src/nvim/ops.c13
-rw-r--r--src/nvim/option.c24
-rw-r--r--src/nvim/option_defs.h4
-rw-r--r--src/nvim/os/input.c22
-rw-r--r--src/nvim/os_unix.c64
-rw-r--r--src/nvim/os_unix_defs.h10
-rw-r--r--src/nvim/path.c8
-rw-r--r--src/nvim/quickfix.c4
-rw-r--r--src/nvim/screen.c10
-rw-r--r--src/nvim/search.c7
-rw-r--r--src/nvim/spell.c6
-rw-r--r--src/nvim/strings.c1
-rw-r--r--src/nvim/syntax.c4
-rw-r--r--src/nvim/tag.c9
-rw-r--r--src/nvim/term.c61
-rw-r--r--src/nvim/testdir/test_listlbr.in8
-rw-r--r--src/nvim/testdir/test_listlbr.ok4
-rw-r--r--src/nvim/ui.c614
-rw-r--r--src/nvim/ui.h21
-rw-r--r--src/nvim/version.c12
-rw-r--r--test/functional/api/vim_spec.lua43
-rw-r--r--test/functional/shell/viml_system_spec.lua6
-rw-r--r--test/unit/helpers.lua24
-rw-r--r--third-party/CMakeLists.txt2
86 files changed, 1090 insertions, 1235 deletions
diff --git a/.ci/clang-asan.sh b/.ci/clang-asan.sh
index c6f28848d1..b1909ea689 100644
--- a/.ci/clang-asan.sh
+++ b/.ci/clang-asan.sh
@@ -1,19 +1,30 @@
. "$CI_SCRIPTS/common.sh"
-set_environment /opt/neovim-deps/64
-
sudo pip install cpp-coveralls
-clang_version=3.4
+if [ "$TRAVIS_OS_NAME" = "linux" ]; then
+ clang_version=3.4.2
+ clang_suffix=x86_64-unknown-ubuntu12.04.xz
+elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
+ clang_version=3.5.0
+ clang_suffix=macosx-apple-darwin.tar.xz
+else
+ echo "Unknown OS '$TRAVIS_OS_NAME'."
+ exit 1
+fi
+
if [ ! -d /usr/local/clang-$clang_version ]; then
echo "Downloading clang $clang_version..."
sudo mkdir /usr/local/clang-$clang_version
- wget -q -O - http://llvm.org/releases/$clang_version/clang+llvm-$clang_version-x86_64-unknown-ubuntu12.04.xz \
+ wget -q -O - http://llvm.org/releases/$clang_version/clang+llvm-$clang_version-$clang_suffix \
| sudo tar xJf - --strip-components=1 -C /usr/local/clang-$clang_version
fi
+
export CC=/usr/local/clang-$clang_version/bin/clang
symbolizer=/usr/local/clang-$clang_version/bin/llvm-symbolizer
+setup_prebuilt_deps x64
+
export SANITIZE=1
export ASAN_SYMBOLIZER_PATH=$symbolizer
export ASAN_OPTIONS="detect_leaks=1:log_path=$tmpdir/asan"
@@ -22,14 +33,20 @@ export TSAN_OPTIONS="external_symbolizer_path=$symbolizer:log_path=$tmpdir/tsan"
export SKIP_UNITTEST=1
export UBSAN_OPTIONS="log_path=$tmpdir/ubsan" # not sure if this works
-install_dir="$(pwd)/dist"
-$MAKE_CMD cmake CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DCMAKE_INSTALL_PREFIX=$install_dir -DUSE_GCOV=ON"
+CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DUSE_GCOV=ON"
+
+# Build and output version info.
+$MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" nvim
+build/bin/nvim --version
+
+# Run functional tests.
if ! $MAKE_CMD test; then
asan_check "$tmpdir"
exit 1
fi
asan_check "$tmpdir"
+# Run legacy tests.
if ! $MAKE_CMD oldtest; then
reset
asan_check "$tmpdir"
@@ -39,4 +56,7 @@ asan_check "$tmpdir"
coveralls --encoding iso-8859-1 || echo 'coveralls upload failed.'
-$MAKE_CMD install
+# Test if correctly installed.
+sudo -E $MAKE_CMD install
+/usr/local/bin/nvim --version
+/usr/local/bin/nvim -e -c "quit"
diff --git a/.ci/common.sh b/.ci/common.sh
index 8498d16506..b27a756683 100644
--- a/.ci/common.sh
+++ b/.ci/common.sh
@@ -35,43 +35,11 @@ check_core_dumps() {
done
}
-set_environment() {
- local prefix="$1/usr"
- eval $($prefix/bin/luarocks path)
- export PATH="$prefix/bin:$PATH"
- export PKG_CONFIG_PATH="$prefix/lib/pkgconfig"
- export USE_BUNDLED_DEPS=OFF
-}
-
-
-install_prebuilt_deps() {
- # install prebuilt dependencies
- if [ ! -d /opt/neovim-deps ]; then
- cd /opt
- sudo git clone --depth=1 git://github.com/neovim/deps neovim-deps
- cd -
- fi
+setup_prebuilt_deps() {
+ eval "$(curl -Ss https://raw.githubusercontent.com/neovim/bot-ci/master/scripts/travis-setup.sh) deps-${1}"
}
tmpdir="$(pwd)/tmp"
rm -rf "$tmpdir"
mkdir -p "$tmpdir"
suppressions="$(pwd)/.valgrind.supp"
-
-# Travis reports back that it has 32-cores via /proc/cpuinfo, but it's not
-# what we really have available. According to their documentation, it only has
-# 1.5 virtual cores.
-# See:
-# http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
-# for more information.
-MAKE_CMD="make -j2"
-
-install_prebuilt_deps
-
-# Pins the version of the java package installed on the Travis VMs
-# and avoids a lengthy upgrade process for them.
-sudo apt-mark hold oracle-java7-installer oracle-java8-installer
-
-sudo apt-get update
-
-export CFLAGS='-DMIN_LOG_LEVEL=0' # force verification of DLOG macros
diff --git a/.ci/gcc-32.sh b/.ci/gcc-32.sh
index aea996f5a0..13b2d46d8f 100644
--- a/.ci/gcc-32.sh
+++ b/.ci/gcc-32.sh
@@ -1,6 +1,6 @@
. "$CI_SCRIPTS/common.sh"
-set_environment /opt/neovim-deps/32
+setup_prebuilt_deps x86
# Need this to keep apt-get from removing gcc when installing libncurses
# below.
@@ -21,8 +21,17 @@ CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON \
-DCMAKE_IGNORE_PATH=/lib:/usr/lib:/usr/local/lib \
-DCMAKE_TOOLCHAIN_FILE=cmake/i386-linux-gnu.toolchain.cmake"
-$MAKE_CMD CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS}" unittest
+# Build and output version info.
+$MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" nvim
+build/bin/nvim --version
+
+# Run unittests.
+$MAKE_CMD unittest
+
+# Run functional tests.
$MAKE_CMD test
check_core_dumps
+
+# Run legacy tests.
$MAKE_CMD oldtest
check_core_dumps
diff --git a/.ci/gcc.sh b/.ci/gcc.sh
index b4a331cfed..8d09c756a7 100644
--- a/.ci/gcc.sh
+++ b/.ci/gcc.sh
@@ -1,23 +1,37 @@
. "$CI_SCRIPTS/common.sh"
-set_environment /opt/neovim-deps/64
-
sudo pip install cpp-coveralls
-sudo apt-get install valgrind
+if [ "$TRAVIS_OS_NAME" = "linux" ]; then
+ sudo apt-get install valgrind
+elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
+ brew install valgrind
+else
+ echo "Unknown OS '$TRAVIS_OS_NAME'."
+ exit 1
+fi
+
+setup_prebuilt_deps x64
export VALGRIND=1
export VALGRIND_LOG="$tmpdir/valgrind-%p.log"
CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DUSE_GCOV=ON"
-$MAKE_CMD CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS}" unittest
+# Build and output version info.
+$MAKE_CMD CMAKE_EXTRA_FLAGS="$CMAKE_EXTRA_FLAGS" nvim
build/bin/nvim --version
+
+# Run unittests.
+make unittest
+
+# Run functional tests.
if ! $MAKE_CMD test; then
valgrind_check "$tmpdir"
exit 1
fi
valgrind_check "$tmpdir"
+# Run legacy tests.
if ! $MAKE_CMD oldtest; then
valgrind_check "$tmpdir"
exit 1
diff --git a/.travis.yml b/.travis.yml
index a82246986d..02cd32ee35 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,24 +1,60 @@
language: c
+os:
+ - linux
env:
global:
- - PROJECT_ROOT="$(pwd)"
- - CI_SCRIPTS="$PROJECT_ROOT/.ci"
+ - CI_SCRIPTS=$TRAVIS_BUILD_DIR/.ci
+ # Travis reports back that it has 32-cores via /proc/cpuinfo, but it's not
+ # what we really have available. According to their documentation, it only has
+ # 1.5 virtual cores.
+ # See
+ # http://docs.travis-ci.com/user/speeding-up-the-build/#Paralellizing-your-build-on-one-VM
+ # for more information.
+ - MAKE_CMD="make -j2"
+ # Force verification of DLOG macros.
+ - CFLAGS='-DMIN_LOG_LEVEL=0'
matrix:
- CI_TARGET=clang-asan
- CI_TARGET=gcc
- CI_TARGET=gcc-32
- CI_TARGET=clint
+matrix:
+ include:
+ - os: osx
+ env: CI_TARGET=clang-asan
+ - os: osx
+ env: CI_TARGET=gcc
+ compiler: gcc-4.9
+ allow_failures:
+ - os: osx
before_install:
+ # Pins the version of the java package installed on the Travis VMs
+ # and avoids a lengthy upgrade process for them.
+ - if [ $TRAVIS_OS_NAME = linux ]; then
+ sudo apt-mark hold oracle-java7-installer oracle-java8-installer;
+ sudo apt-get update;
+ elif [ $TRAVIS_OS_NAME = osx ]; then
+ brew update;
+ fi
+install:
+ - if [ $TRAVIS_OS_NAME = linux ]; then
+ sudo apt-get install xclip gdb;
+ fi
+before_script:
# Adds user to a dummy group.
# That allows to test changing the group of the file by `os_fchown`.
- - sudo groupadd chown_test
- - sudo usermod -a -G chown_test ${USER}
# Need xvfb for running some tests with xclip
- - export DISPLAY=:99.0
- - sh -e /etc/init.d/xvfb start
- - sudo apt-get install xclip gdb
+ - if [ $TRAVIS_OS_NAME = linux ]; then
+ sudo groupadd chown_test;
+ sudo usermod -a -G chown_test $USER;
+ export DISPLAY=:99.0;
+ sh -e /etc/init.d/xvfb start;
+ elif [ $TRAVIS_OS_NAME = osx ]; then
+ sudo dscl . -create /Groups/chown_test;
+ sudo dscl . -append /Groups/chown_test GroupMembership $USER;
+ fi
script:
# This will pass the environment variables down to a bash process which runs
# as $USER, while retaining the environment variables defined and belonging
# to secondary groups given above in usermod.
- - sudo -E su ${USER} -c "ulimit -c 102400; sh -e \"${CI_SCRIPTS}/${CI_TARGET}.sh\""
+ - sudo -E su $USER -c "ulimit -c 102400; sh -e \"$CI_SCRIPTS/$CI_TARGET.sh\""
diff --git a/README.md b/README.md
index 91bbe7bb9b..0db2a817c3 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ For lots more details, see
### What's being worked on now
-- Port all IO to [libuv](https://github.com/joyent/libuv/blob/master/README.md)
+- Port all IO to [libuv](https://github.com/libuv/libuv/blob/master/README.md)
- Lots of refactoring
- A VimL => Lua transpiler
diff --git a/clint-files.txt b/clint-files.txt
index a0aec7a31c..6f4a293205 100644
--- a/clint-files.txt
+++ b/clint-files.txt
@@ -25,6 +25,8 @@ src/nvim/map_defs.h
src/nvim/memfile.c
src/nvim/memfile.h
src/nvim/memfile_defs.h
+src/nvim/mouse.c
+src/nvim/mouse.h
src/nvim/msgpack_rpc/channel.c
src/nvim/msgpack_rpc/channel.h
src/nvim/msgpack_rpc/helpers.c
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 55bd508109..9f8e0acccd 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1003,8 +1003,8 @@ The pattern is interpreted like mostly used in file names:
[^ch] match any character but 'c' and 'h'
Note that for all systems the '/' character is used for path separator (even
-MS-DOS and OS/2). This was done because the backslash is difficult to use
-in a pattern and to make the autocommands portable across different systems.
+MS-DOS). This was done because the backslash is difficult to use in a pattern
+and to make the autocommands portable across different systems.
*autocmd-changes*
Matching with the pattern is done when an event is triggered. Changing the
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index f58389af8c..2892faa496 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -855,7 +855,7 @@ These modifiers can be given, in this order:
separator is removed. Thus ":p:h" on a directory name results
on the directory name itself (without trailing slash).
When the file name is an absolute path (starts with "/" for
- Unix; "x:\" for MS-DOS, WIN32, OS/2; "drive:" for Amiga), that
+ Unix; "x:\" for MS-DOS, WIN32; "drive:" for Amiga), that
part is not removed. When there is no head (path is relative
to current directory) the result is empty.
:t Tail of the file name (last component of the name). Must
@@ -954,10 +954,10 @@ option contains "sh", this is done twice, to avoid the shell trying to expand
the "!".
*filename-backslash*
-For filesystems that use a backslash as directory separator (MS-DOS, Windows,
-OS/2), it's a bit difficult to recognize a backslash that is used to escape
-the special meaning of the next character. The general rule is: If the
-backslash is followed by a normal file name character, it does not have a
+For filesystems that use a backslash as directory separator (MS-DOS and
+Windows), it's a bit difficult to recognize a backslash that is used
+to escape the special meaning of the next character. The general rule is: If
+the backslash is followed by a normal file name character, it does not have a
special meaning. Therefore "\file\foo" is a valid file name, you don't have
to type the backslash twice.
diff --git a/runtime/doc/editing.txt b/runtime/doc/editing.txt
index f2f2bee79e..e4867e7a90 100644
--- a/runtime/doc/editing.txt
+++ b/runtime/doc/editing.txt
@@ -502,8 +502,8 @@ The 'fileformat' option sets the <EOL> style for a file:
"mac" <CR> Mac format *Mac-format*
When reading a file, the mentioned characters are interpreted as the <EOL>.
-In DOS format (default for MS-DOS, OS/2 and Win32), <CR><NL> and <NL> are both
-interpreted as the <EOL>. Note that when writing the file in DOS format,
+In DOS format (default for MS-DOS and Win32), <CR><NL> and <NL> are both
+interpreted as the <EOL>. Note that when writing the file in DOS format,
<CR> characters will be added for each single <NL>. Also see |file-read|.
When writing a file, the mentioned characters are used for <EOL>. For DOS
@@ -1011,11 +1011,11 @@ lost the original file.
*DOS-format-write*
If the 'fileformat' is "dos", <CR> <NL> is used for <EOL>. This is default
-for MS-DOS, Win32 and OS/2. On other systems the message "[dos format]" is
-shown to remind you that an unusual <EOL> was used.
+for MS-DOS and Win32. On other systems the message "[dos format]" is shown to
+remind you that an unusual <EOL> was used.
*Unix-format-write*
-If the 'fileformat' is "unix", <NL> is used for <EOL>. On MS-DOS, Win32 and
-OS/2 the message "[unix format]" is shown.
+If the 'fileformat' is "unix", <NL> is used for <EOL>. On MS-DOS and Win32
+the message "[unix format]" is shown.
*Mac-format-write*
If the 'fileformat' is "mac", <CR> is used for <EOL>. On non-Mac systems the
message "[mac format]" is shown.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index fca8ac1291..91a9f1292f 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -6172,7 +6172,7 @@ system({expr} [, {input}]) *system()* *E677*
The command executed is constructed using several options:
'shell' 'shellcmdflag' 'shellxquote' {expr} 'shellredir' {tmp} 'shellxquote'
({tmp} is an automatically generated file name).
- For Unix and OS/2 braces are put around {expr} to allow for
+ For Unix braces are put around {expr} to allow for
concatenated commands.
The command will be executed in "cooked" mode, so that a
@@ -6756,7 +6756,6 @@ multi_byte_ime Compiled with support for IME input method.
multi_lang Compiled with support for multiple languages.
mzscheme Compiled with MzScheme interface |mzscheme|.
ole Compiled with OLE automation support for Win32.
-os2 OS/2 version of Vim.
path_extra Compiled with up/downwards search in 'path' and 'tags'
perl Compiled with Perl interface.
persistent_undo Compiled with support for persistent undo history.
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index d77976330b..bdddec585d 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -94,8 +94,6 @@ terminal version.
Recommended place for your personal GUI initializations:
Unix $HOME/.gvimrc or $HOME/.vim/gvimrc
- OS/2 $HOME/.gvimrc, $HOME/vimfiles/gvimrc
- or $VIM/.gvimrc
MS-DOS and Win32 $HOME/_gvimrc, $HOME/vimfiles/gvimrc
or $VIM/_gvimrc
Amiga s:.gvimrc, home:.gvimrc, home:vimfiles:gvimrc
diff --git a/runtime/doc/insert.txt b/runtime/doc/insert.txt
index ce92f14f81..60454fa8e1 100644
--- a/runtime/doc/insert.txt
+++ b/runtime/doc/insert.txt
@@ -1938,9 +1938,9 @@ If the 'fileformats' option is not empty Vim tries to recognize the type of
changed, the detected format is only used while reading the file.
A similar thing happens with 'fileencodings'.
-On non-MS-DOS, Win32, and OS/2 systems the message "[dos format]" is shown if
+On non-MS-DOS and Win32 systems the message "[dos format]" is shown if
a file is read in DOS format, to remind you that something unusual is done.
-On Macintosh, MS-DOS, Win32, and OS/2 the message "[unix format]" is shown if
+On Macintosh, MS-DOS, and Win32 the message "[unix format]" is shown if
a file is read in Unix format.
On non-Macintosh systems, the message "[Mac format]" is shown if a file is
read in Mac format.
diff --git a/runtime/doc/job_control.txt b/runtime/doc/job_control.txt
index 226244875d..f381d5ad66 100644
--- a/runtime/doc/job_control.txt
+++ b/runtime/doc/job_control.txt
@@ -31,7 +31,7 @@ facilities for calling with external commands, job control does not depend
on installed shells, calling OS functions for process management directly.
Internally, Nvim job control is powered by libuv, which has a nice
-cross-platform API for managing processes. See https://github.com/joyent/libuv
+cross-platform API for managing processes. See https://github.com/libuv/libuv
for details
==============================================================================
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index a875179967..813ed83be4 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -861,7 +861,7 @@ A jump table for the options with a short description can be found at |Q_op|.
putting a ":gui" command in the .gvimrc file, before where the value
of 'background' is used (e.g., before ":syntax on").
- For MS-DOS, Windows and OS/2 the default is "dark".
+ For MS-DOS and Windows the default is "dark".
For other systems "dark" is used when 'term' is "linux",
"screen.linux", "cygwin" or "putty", or $COLORFGBG suggests a dark
background. Otherwise the default is "light".
@@ -1689,7 +1689,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'esckeys' + off no <Esc>-keys in Insert mode
'expandtab' off tabs not expanded to spaces
'fileformats' + "" no automatic file format detection,
- "dos,unix" except for DOS, Windows and OS/2
+ "dos,unix" except for DOS and Windows
'formatoptions' + "vt" Vi compatible formatting
'gdefault' off no default 'g' flag for ":s"
'history' + 0 no commandline history
@@ -2873,7 +2873,7 @@ A jump table for the options with a short description can be found at |Q_op|.
is read.
*'fileformat'* *'ff'*
-'fileformat' 'ff' string (MS-DOS, MS-Windows, OS/2 default: "dos",
+'fileformat' 'ff' string (MS-DOS and MS-Windows default: "dos",
Unix default: "unix",
Macintosh default: "mac")
local to buffer
@@ -2896,7 +2896,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'fileformats'* *'ffs'*
'fileformats' 'ffs' string (default:
- Vim+Vi MS-DOS, MS-Windows OS/2: "dos,unix",
+ Vim+Vi MS-DOS and MS-Windows: "dos,unix",
Vim Unix: "unix,dos",
Vim Mac: "mac,unix,dos",
Vi Cygwin: "unix,dos",
@@ -4292,7 +4292,7 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is reset when 'compatible' is set.
*'isfname'* *'isf'*
-'isfname' 'isf' string (default for MS-DOS, Win32 and OS/2:
+'isfname' 'isf' string (default for MS-DOS and Win32:
"@,48-57,/,\,.,-,_,+,,,#,$,%,{,},[,],:,@-@,!,~,="
for AMIGA: "@,48-57,/,.,-,_,+,,,$,:"
for VMS: "@,48-57,/,.,-,_,+,,,#,$,%,<,>,[,],:,;,~"
@@ -4347,7 +4347,7 @@ A jump table for the options with a short description can be found at |Q_op|.
See |option-backslash| about including spaces and backslashes.
*'isident'* *'isi'*
-'isident' 'isi' string (default for MS-DOS, Win32 and OS/2:
+'isident' 'isi' string (default for MS-DOS and Win32:
"@,48-57,_,128-167,224-235"
otherwise: "@,48-57,_,192-255")
global
@@ -4380,7 +4380,7 @@ A jump table for the options with a short description can be found at |Q_op|.
set and to the Vim default value when 'compatible' is reset.
*'isprint'* *'isp'*
-'isprint' 'isp' string (default for MS-DOS, Win32, OS/2 and Macintosh:
+'isprint' 'isp' string (default for MS-DOS, Win32, and Macintosh:
"@,~-255"; otherwise: "@,161-255")
global
{not in Vi}
@@ -4466,7 +4466,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'keywordprg'* *'kp'*
'keywordprg' 'kp' string (default "man" or "man -s", DOS: ":help",
- OS/2: "view /", VMS: "help")
+ VMS: "help")
global or local to buffer |global-local|
{not in Vi}
Program to use for the |K| command. Environment variables are
@@ -5232,7 +5232,7 @@ A jump table for the options with a short description can be found at |Q_op|.
'opendevice' 'odev' boolean (default off)
global
{not in Vi}
- {only for MS-DOS, MS-Windows and OS/2}
+ {only for MS-DOS and MS-Windows}
Enable reading and writing from devices. This may get Vim stuck on a
device that can be opened but doesn't actually do the I/O. Therefore
it is off by default.
@@ -5363,7 +5363,6 @@ A jump table for the options with a short description can be found at |Q_op|.
*'path'* *'pa'* *E343* *E345* *E347* *E854*
'path' 'pa' string (default on Unix: ".,/usr/include,,"
- on OS/2: ".,/emx/include,,"
other systems: ".,,")
global or local to buffer |global-local|
{not in Vi}
@@ -5740,11 +5739,6 @@ A jump table for the options with a short description can be found at |Q_op|.
$VIMRUNTIME,
$VIM/vimfiles/after,
home:vimfiles/after"
- PC, OS/2: "$HOME/vimfiles,
- $VIM/vimfiles,
- $VIMRUNTIME,
- $VIM/vimfiles/after,
- $HOME/vimfiles/after"
Macintosh: "$VIM:vimfiles,
$VIMRUNTIME,
$VIM:vimfiles:after"
@@ -6001,7 +5995,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'shell'* *'sh'* *E91*
'shell' 'sh' string (default $SHELL or "sh",
MS-DOS and Win32: "command.com" or
- "cmd.exe", OS/2: "cmd")
+ "cmd.exe")
global
Name of the shell to use for ! and :! commands. When changing the
value also check these options: 'shellpipe', 'shellslash'
@@ -6039,8 +6033,7 @@ A jump table for the options with a short description can be found at |Q_op|.
Flag passed to the shell to execute "!" and ":!" commands; e.g.,
"bash.exe -c ls" or "command.com /c dir". For the MS-DOS-like
systems, the default is set according to the value of 'shell', to
- reduce the need to set this option by the user. It's not used for
- OS/2 (EMX figures this out itself).
+ reduce the need to set this option by the user.
On Unix it can have more than one flag. Each white space separated
part is passed as an argument to the shell command.
See |option-backslash| about including spaces and backslashes.
@@ -6129,7 +6122,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'shellslash'* *'ssl'* *'noshellslash'* *'nossl'*
'shellslash' 'ssl' boolean (default off)
global
- {not in Vi} {only for MSDOS, MS-Windows and OS/2}
+ {not in Vi} {only for MSDOS and MS-Windows}
When set, a forward slash is used when expanding file names. This is
useful when a Unix-like shell is used instead of command.com or
cmd.exe. Backward slashes can still be typed, but they are changed to
@@ -7135,9 +7128,7 @@ A jump table for the options with a short description can be found at |Q_op|.
on Amiga: "amiga"
on BeOS: "beos-ansi"
on Mac: "mac-ansi"
- on MiNT: "vt52"
on MS-DOS: "pcterm"
- on OS/2: "os2ansi"
on Unix: "ansi"
on VMS: "ansi"
on Win 32: "win32")
@@ -7578,7 +7569,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'undolevels'* *'ul'*
'undolevels' 'ul' number (default 100, 1000 for Unix, VMS,
- Win32 and OS/2)
+ and Win32)
global or local to buffer |global-local|
{not in Vi}
Maximum number of changes that can be undone. Since undo information
@@ -7680,7 +7671,7 @@ A jump table for the options with a short description can be found at |Q_op|.
displayed when 'verbosefile' is set.
*'viewdir'* *'vdir'*
-'viewdir' 'vdir' string (default for Amiga, MS-DOS, OS/2 and Win32:
+'viewdir' 'vdir' string (default for Amiga, MS-DOS, and Win32:
"$VIM/vimfiles/view",
for Unix: "~/.vim/view",
for Macintosh: "$VIM:vimfiles:view"
@@ -7719,7 +7710,7 @@ A jump table for the options with a short description can be found at |Q_op|.
*'viminfo'* *'vi'* *E526* *E527* *E528*
'viminfo' 'vi' string (Vi default: "", Vim default for MS-DOS,
- Windows and OS/2: '100,<50,s10,h,rA:,rB:,
+ Windows: '100,<50,s10,h,rA:,rB:,
for Amiga: '100,<50,s10,h,rdf0:,rdf1:,rdf2:
for others: '100,<50,s10,h)
global
diff --git a/runtime/doc/print.txt b/runtime/doc/print.txt
index 2ff6b1063c..5fcaa6f624 100644
--- a/runtime/doc/print.txt
+++ b/runtime/doc/print.txt
@@ -93,7 +93,7 @@ If the option is empty, then vim will use the system default printer for
*penc-option* *E620*
'printencoding' 'penc' String (default empty, except for:
- Windows, OS/2: cp1252,
+ Windows: cp1252,
Macintosh: mac-roman,
VMS: dec-mcs,
HPUX: hp-roman8,
@@ -123,8 +123,8 @@ cannot be converted will be replaced with upside down question marks.
Four print character encoding files are provided to support default Mac, VMS,
HPUX, and EBCDIC character encodings and are used by default on these
-platforms. Code page 1252 print character encoding is used by default on
-Windows and OS/2 platforms.
+platforms. Code page 1252 print character encoding is used by default on
+the Windows platform.
*pexpr-option*
'printexpr' 'pexpr' String (default: see below)
@@ -142,7 +142,7 @@ the file: >
system('lpr' . (&printdevice == '' ? '' : ' -P' . &printdevice)
. ' ' . v:fname_in) . delete(v:fname_in) + v:shell_error
-On MS-Dos, MS-Windows and OS/2 machines the default is to copy the file to the
+On MS-Dos and MS-Windows machines the default is to copy the file to the
currently specified printdevice: >
system('copy' . ' ' . v:fname_in . (&printdevice == ''
@@ -621,7 +621,7 @@ OpenVMS
http://wwwthep.physik.uni-mainz.de/~plass/gv/
-Windows and OS/2
+Windows
- GSview. Obtainable from:
@@ -636,7 +636,7 @@ DOS
Linux
-- GSview. Linux version of the popular Windows and OS/2 previewer.
+- GSview. Linux version of the popular Windows previewer.
Obtainable from:
http://www.cs.wisc.edu/~ghost/gsview/
diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt
index 22d99b908b..6b80482f6b 100644
--- a/runtime/doc/quickfix.txt
+++ b/runtime/doc/quickfix.txt
@@ -938,8 +938,8 @@ normally happens by matching following characters and items. When nothing is
following the rest of the line is matched. If "%f" is followed by a '%' or a
backslash, it will look for a sequence of 'isfname' characters.
-On MS-DOS, MS-Windows and OS/2 a leading "C:" will be included in "%f", even
-when using "%f:". This means that a file name which is a single alphabetical
+On MS-DOS and MS-Windows a leading "C:" will be included in "%f", even when
+using "%f:". This means that a file name which is a single alphabetical
letter will not be detected.
The "%p" conversion is normally followed by a "^". It's used for compilers
diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt
index 4b28e8617b..a8e573a52e 100644
--- a/runtime/doc/repeat.txt
+++ b/runtime/doc/repeat.txt
@@ -299,7 +299,7 @@ with CTRL-V followed by the three digit decimal code. This does NOT work for
the <t_xx> termcap codes, these can only be used in mappings.
*:source_crnl* *W15*
-MS-DOS, Win32 and OS/2: Files that are read with ":source" normally have
+MS-DOS and Win32: Files that are read with ":source" normally have
<CR><NL> <EOL>s. These always work. If you are using a file with <NL> <EOL>s
(for example, a file made on Unix), this will be recognized if 'fileformats'
is not empty and the first line does not end in a <CR>. This fails if the
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index dfe46b1047..d002a3a4ab 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -750,8 +750,6 @@ accordingly. Vim proceeds in this order:
Places for your personal initializations:
Unix $HOME/.vimrc or $HOME/.vim/vimrc
- OS/2 $HOME/.vimrc, $HOME/vimfiles/vimrc
- or $VIM/.vimrc (or _vimrc)
MS-Windows $HOME/_vimrc, $HOME/vimfiles/vimrc
or $VIM/_vimrc
Amiga s:.vimrc, home:.vimrc, home:vimfiles:vimrc
@@ -777,7 +775,7 @@ accordingly. Vim proceeds in this order:
a. If vim was started as |evim| or |eview| or with the |-y| argument, the
script $VIMRUNTIME/evim.vim will be loaded.
*system-vimrc*
- b. For Unix, MS-DOS, MS-Windows, OS/2, VMS, Macintosh, RISC-OS and Amiga
+ b. For Unix, MS-DOS, MS-Windows, VMS, Macintosh, RISC-OS and Amiga
the system vimrc file is read for initializations. The path of this
file is shown with the ":version" command. Mostly it's "$VIM/vimrc".
Note that this file is ALWAYS read in 'compatible' mode, since the
@@ -793,16 +791,16 @@ accordingly. Vim proceeds in this order:
- The environment variable VIMINIT (see also |compatible-default|) (*)
The value of $VIMINIT is used as an Ex command line.
- The user vimrc file(s):
- "$HOME/.vimrc" (for Unix and OS/2) (*)
- "$HOME/.vim/vimrc" (for Unix and OS/2) (*)
+ "$HOME/.vimrc" (for Unix) (*)
+ "$HOME/.vim/vimrc" (for Unix) (*)
"s:.vimrc" (for Amiga) (*)
"home:.vimrc" (for Amiga) (*)
"home:vimfiles:vimrc" (for Amiga) (*)
- "$VIM/.vimrc" (for OS/2 and Amiga) (*)
+ "$VIM/.vimrc" (for Amiga) (*)
"$HOME/_vimrc" (for MS-DOS and Win32) (*)
"$HOME/vimfiles/vimrc" (for MS-DOS and Win32) (*)
"$VIM/_vimrc" (for MS-DOS and Win32) (*)
- Note: For Unix, OS/2 and Amiga, when ".vimrc" does not exist,
+ Note: For Unix and Amiga, when ".vimrc" does not exist,
"_vimrc" is also tried, in case an MS-DOS compatible file
system is used. For MS-DOS and Win32 ".vimrc" is checked
after "_vimrc", in case long file names are used.
@@ -818,11 +816,11 @@ accordingly. Vim proceeds in this order:
d. If the 'exrc' option is on (which is not the default), the current
directory is searched for three files. The first that exists is used,
the others are ignored.
- - The file ".vimrc" (for Unix, Amiga and OS/2) (*)
+ - The file ".vimrc" (for Unix and Amiga) (*)
"_vimrc" (for MS-DOS and Win32) (*)
- - The file "_vimrc" (for Unix, Amiga and OS/2) (*)
+ - The file "_vimrc" (for Unix and Amiga) (*)
".vimrc" (for MS-DOS and Win32) (*)
- - The file ".exrc" (for Unix, Amiga and OS/2)
+ - The file ".exrc" (for Unix and Amiga)
"_exrc" (for MS-DOS and Win32)
(*) Using this file or environment variable will cause 'compatible' to be
@@ -889,7 +887,7 @@ Some hints on using initializations:
Standard setup:
Create a vimrc file to set the default settings and mappings for all your edit
sessions. Put it in a place so that it will be found by 3b:
- ~/.vimrc (Unix and OS/2)
+ ~/.vimrc (Unix)
s:.vimrc (Amiga)
$VIM\_vimrc (MS-DOS and Win32)
Note that creating a vimrc file will cause the 'compatible' option to be off
@@ -923,7 +921,7 @@ manual. The environment variables set with the old Manx Set command (before
version 5.0) are not recognized.
MS-DOS line separators:
-On MS-DOS-like systems (MS-DOS itself, Win32, and OS/2), Vim assumes that all
+On MS-DOS-like systems (MS-DOS itself and Win32), Vim assumes that all
the vimrc files have <CR> <NL> pairs as line separators. This will give
problems if you have a file with only <NL>s and have a line like
":map xx yy^M". The trailing ^M will be ignored.
@@ -1042,7 +1040,7 @@ will try to get the value for $VIM in this order:
problem). The file name ("help.txt" or any other) is removed. Then
trailing directory names are removed, in this order: "doc", "runtime" and
"vim{version}" (e.g., "vim54").
-3. For MSDOS, Win32 and OS/2 Vim tries to use the directory name of the
+3. For MSDOS and Win32 Vim tries to use the directory name of the
executable. If it ends in "/src", this is removed. This is useful if you
unpacked the .zip file in some directory, and adjusted the search path to
find the vim executable. Trailing directory names are removed, in this
@@ -1428,11 +1426,10 @@ remembered.
VIMINFO FILE NAME *viminfo-file-name*
-- The default name of the viminfo file is "$HOME/.viminfo" for Unix and OS/2,
+- The default name of the viminfo file is "$HOME/.viminfo" for Unix,
"s:.viminfo" for Amiga, "$HOME\_viminfo" for MS-DOS and Win32. For the last
two, when $HOME is not set, "$VIM\_viminfo" is used. When $VIM is also not
- set, "c:\_viminfo" is used. For OS/2 "$VIM/.viminfo" is used when $HOME is
- not set and $VIM is set.
+ set, "c:\_viminfo" is used.
- The 'n' flag in the 'viminfo' option can be used to specify another viminfo
file name |'viminfo'|.
- The "-i" Vim argument can be used to set another file name, |-i|. When the
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 7440f6072b..1cab028bc2 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -2301,14 +2301,7 @@ GUI:
currently. This is very obvious on a 66Mhz 486.
-MSDOS, OS/2 and Win32:
-8 OS/2: Add backtick expansion. Undefine NO_EXPANDPATH and use
- gen_expand_wildcards().
-8 OS/2: Add clipboard support? See example clipbrd.exe from Alexander
- Wagner.
-8 OS/2: Add Extended Attributes support and define HAVE_ACL.
-8 OS/2: When editing a file name "foo.txt" that is actually called FOO.txt,
- writing uses "foo.txt". Should obtain the real file name.
+MSDOS and Win32:
8 Should $USERPROFILE be preferred above $HOMEDRIVE/$HOMEPATH? No, but it's
a good fallback, thus use:
$HOME
diff --git a/runtime/doc/usr_01.txt b/runtime/doc/usr_01.txt
index 11fa2173d6..0de1fac803 100644
--- a/runtime/doc/usr_01.txt
+++ b/runtime/doc/usr_01.txt
@@ -71,7 +71,7 @@ you are using:
Unix: >
:!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrc
-MS-DOS, MS-Windows, OS/2: >
+MS-DOS, MS-Windows: >
:!copy $VIMRUNTIME/vimrc_example.vim $VIM/_vimrc
Amiga: >
:!copy $VIMRUNTIME/vimrc_example.vim $VIM/.vimrc
diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt
index f71cf42cff..ac377675ee 100644
--- a/runtime/doc/usr_05.txt
+++ b/runtime/doc/usr_05.txt
@@ -314,7 +314,6 @@ Then copy the file to your plugin directory:
system plugin directory ~
Unix ~/.vim/plugin/
- PC and OS/2 $HOME/vimfiles/plugin or $VIM/vimfiles/plugin
Amiga s:vimfiles/plugin
Macintosh $VIM:vimfiles:plugin
Mac OS X ~/.vim/plugin/
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index f30b79a2ea..71255e46d8 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1495,7 +1495,7 @@ Here is a summary of items that apply to Vim scripts. They are also mentioned
elsewhere, but form a nice checklist.
The end-of-line character depends on the system. For Unix a single <NL>
-character is used. For MS-DOS, Windows, OS/2 and the like, <CR><LF> is used.
+character is used. For MS-DOS, Windows and the like, <CR><LF> is used.
This is important when using mappings that end in a <CR>. See |:source_crnl|.
diff --git a/runtime/doc/vi_diff.txt b/runtime/doc/vi_diff.txt
index 4a7b067fc1..aa90dc94b0 100644
--- a/runtime/doc/vi_diff.txt
+++ b/runtime/doc/vi_diff.txt
@@ -136,8 +136,6 @@ Support for different systems.
- MS-DOS in real-mode (no additional drivers required).
- In protected mode on Windows 3.1 and MS-DOS (DPMI driver required).
- Windows 95 and Windows NT, with support for long file names.
- - OS/2 (needs emx.dll)
- - Atari MiNT
- VMS
- BeOS
- Macintosh
diff --git a/runtime/gvimrc_example.vim b/runtime/gvimrc_example.vim
index 5a5197e99a..26b3001220 100644
--- a/runtime/gvimrc_example.vim
+++ b/runtime/gvimrc_example.vim
@@ -5,7 +5,7 @@
" Last change: 2001 Sep 02
"
" To use it, copy it to
-" for Unix and OS/2: ~/.gvimrc
+" for Unix: ~/.gvimrc
" for Amiga: s:.gvimrc
" for MS-DOS and Win32: $VIM\_gvimrc
" for OpenVMS: sys$login:.gvimrc
diff --git a/runtime/menu.vim b/runtime/menu.vim
index 5c5bb97208..e0745585a6 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -188,7 +188,7 @@ an 20.435 &Edit.Startup\ &Settings :call <SID>EditVimrc()<CR>
fun! s:EditVimrc()
if $MYVIMRC != ''
let fname = $MYVIMRC
- elseif has("win32") || has("dos32") || has("dos16") || has("os2")
+ elseif has("win32") || has("dos32") || has("dos16")
if $HOME != ''
let fname = $HOME . "/_vimrc"
else
diff --git a/runtime/optwin.vim b/runtime/optwin.vim
index 6c1c743a00..22581ed98b 100644
--- a/runtime/optwin.vim
+++ b/runtime/optwin.vim
@@ -1107,14 +1107,14 @@ if has("quickfix")
endif
-if has("msdos") || has("os2") || has("win16") || has("win32") || has("osfiletype")
+if has("msdos") || has("win16") || has("win32") || has("osfiletype")
call <SID>Header("system specific")
if has("osfiletype")
call append("$", "osfiletype\tOS-specific information about the type of file")
call append("$", "\t(local to buffer)")
call <SID>OptionL("oft")
endif
- if has("msdos") || has("os2") || has("win16") || has("win32")
+ if has("msdos") || has("win16") || has("win32")
call append("$", "shellslash\tuse forward slashes in file names; for Unix-like shells")
call <SID>BinOptionG("ssl", &ssl)
endif
diff --git a/runtime/tools/README.txt b/runtime/tools/README.txt
index fa176c776d..19976b325c 100644
--- a/runtime/tools/README.txt
+++ b/runtime/tools/README.txt
@@ -34,4 +34,4 @@ xcmdsrv_client.c: Example for a client program that communicates with a Vim
unicode.vim Vim script to generate tables for src/mbyte.c.
-[xxd (and tee for OS/2) can be found in the src directory]
+[xxd can be found in the src directory]
diff --git a/runtime/vimrc_example.vim b/runtime/vimrc_example.vim
index 27a5cfc222..3175711aa1 100644
--- a/runtime/vimrc_example.vim
+++ b/runtime/vimrc_example.vim
@@ -4,7 +4,7 @@
" Last change: 2014 Feb 05
"
" To use it, copy it to
-" for Unix and OS/2: ~/.vimrc
+" for Unix: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index e13add71e3..184bcc0548 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -48,17 +48,14 @@ set(CONV_SOURCES
ex_cmds2.c
ex_cmds.c
ex_docmd.c
- ex_eval.c
ex_getln.c
farsi.c
fileio.c
- file_search.c
fold.c
getchar.c
hardcopy.c
if_cscope.c
indent.c
- indent_c.c
keymap.c
main.c
mark.c
@@ -76,7 +73,6 @@ set(CONV_SOURCES
popupmnu.c
quickfix.c
regexp.c
- regexp_nfa.c
screen.c
search.c
sha256.c
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index addcbf62e9..fe5fa6274b 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -49,8 +49,10 @@ void vim_command(String str, Error *err)
///
/// @param keys to be typed
/// @param mode specifies the mapping options
+/// @param escape_csi the string needs escaping for K_SPECIAL/CSI bytes
/// @see feedkeys()
-void vim_feedkeys(String keys, String mode)
+/// @see vim_strsave_escape_csi
+void vim_feedkeys(String keys, String mode, Boolean escape_csi)
FUNC_ATTR_DEFERRED
{
bool remap = true;
@@ -68,12 +70,20 @@ void vim_feedkeys(String keys, String mode)
}
}
- /* Need to escape K_SPECIAL and CSI before putting the string in the
- * typeahead buffer. */
- char *keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data);
+ char *keys_esc;
+ if (escape_csi) {
+ // Need to escape K_SPECIAL and CSI before putting the string in the
+ // typeahead buffer.
+ keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data);
+ } else {
+ keys_esc = keys.data;
+ }
ins_typebuf((char_u *)keys_esc, (remap ? REMAP_YES : REMAP_NONE),
typebuf.tb_len, !typed, false);
- free(keys_esc);
+
+ if (escape_csi) {
+ free(keys_esc);
+ }
if (vgetc_busy)
typebuf_was_filled = true;
@@ -197,12 +207,11 @@ ArrayOf(String) vim_list_runtime_paths(void)
rv.items[i].type = kObjectTypeString;
rv.items[i].data.string.data = xmalloc(MAXPATHL);
// Copy the path from 'runtimepath' to rv.items[i]
- int length = copy_option_part(&rtp,
- (char_u *)rv.items[i].data.string.data,
- MAXPATHL,
- ",");
- assert(length >= 0);
- rv.items[i].data.string.size = (size_t)length;
+ size_t length = copy_option_part(&rtp,
+ (char_u *)rv.items[i].data.string.data,
+ MAXPATHL,
+ ",");
+ rv.items[i].data.string.size = length;
}
return rv;
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 6b5b97fe67..ec10a826c7 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -69,10 +69,11 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#define HAVE_BUFLIST_MATCH
@@ -716,7 +717,7 @@ do_bufdel (
} else /* addr_count == 1 */
bnr = end_bnr;
- for (; !got_int; ui_breakcheck()) {
+ for (; !got_int; os_breakcheck()) {
/*
* delete the current buffer last, otherwise when the
* current buffer is deleted, the next buffer becomes
@@ -1422,7 +1423,7 @@ buflist_new (
EMSG(_("W14: Warning: List of file names overflow"));
if (emsg_silent == 0) {
out_flush();
- ui_delay(3000L, true); /* make sure it is noticed */
+ os_delay(3000L, true); /* make sure it is noticed */
}
top_file_num = 1;
}
@@ -2162,7 +2163,7 @@ void buflist_list(exarg_T *eap)
: (int64_t)buflist_findlnum(buf));
msg_outtrans(IObuff);
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
}
@@ -3801,7 +3802,7 @@ do_arg_all (
++autocmd_no_leave;
use_firstwin = FALSE;
}
- ui_breakcheck();
+ os_breakcheck();
/* When ":tab" was used open a new tab for a new window repeatedly. */
if (had_tab > 0 && tabpage_index(NULL) <= p_tpm)
@@ -3965,7 +3966,7 @@ void ex_buffer_all(exarg_T *eap)
#endif
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
(void)vgetc(); /* only break the file loading, not the rest */
break;
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 196b975d2a..23f20c3c75 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -578,12 +578,7 @@ struct file_buffer {
#define B_IMODE_USE_INSERT -1 /* Use b_p_iminsert value for search */
#define B_IMODE_NONE 0 /* Input via none */
#define B_IMODE_LMAP 1 /* Input via langmap */
-#ifndef USE_IM_CONTROL
# define B_IMODE_LAST 1
-#else
-# define B_IMODE_IM 2 /* Input via input method */
-# define B_IMODE_LAST 2
-#endif
short b_kmap_state; /* using "lmap" mappings */
# define KEYMAP_INIT 1 /* 'keymap' was set, call keymap_init() */
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index c4e5986012..9e5194a5df 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -1058,6 +1058,11 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he
if (col >= (colnr_T)wp->w_width) {
col -= wp->w_width;
numberextra = wp->w_width - (numberextra - win_col_off2(wp));
+ if (*p_sbr != NUL) {
+ colnr_T sbrlen = (colnr_T)MB_CHARLEN(p_sbr);
+ if (col >= sbrlen)
+ col -= sbrlen;
+ }
if (numberextra > 0) {
col = col % numberextra;
}
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 06c8186bf9..87064b4ef3 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -135,7 +135,7 @@ char_u *parse_shape_opt(int what)
p += len;
if (!VIM_ISDIGIT(*p))
return (char_u *)N_("E548: digit expected");
- long digits = getdigits(&p);
+ int64_t digits = getdigits(&p);
assert(digits <= INT_MAX);
int n = (int)digits;
if (len == 3) { /* "ver" or "hor" */
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index bc355f3b49..2b5fdea2fe 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -23,7 +23,7 @@
#include "nvim/normal.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
-#include "nvim/ui.h"
+#include "nvim/os/input.h"
typedef int result_T;
@@ -1611,7 +1611,7 @@ void putdigraph(char_u *str)
EMSG(_(e_number_exp));
return;
}
- long digits = getdigits(&str);
+ int64_t digits = getdigits(&str);
assert(digits <= INT_MAX);
int n = (int)digits;
@@ -1659,13 +1659,13 @@ void listdigraphs(void)
printdigraph(&tmp);
}
dp++;
- ui_breakcheck();
+ os_breakcheck();
}
dp = (digr_T *)user_digraphs.ga_data;
for (int i = 0; i < user_digraphs.ga_len && !got_int; ++i) {
printdigraph(dp);
- ui_breakcheck();
+ os_breakcheck();
dp++;
}
// clear screen, because some digraphs may be wrong, in which case we messed
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index b9ecbc71fe..c7f20783a9 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -56,9 +56,12 @@
#include "nvim/tag.h"
#include "nvim/term.h"
#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/event.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
/*
* definitions used for CTRL-X submode
@@ -388,9 +391,6 @@ edit (
*/
if (curbuf->b_p_iminsert == B_IMODE_LMAP)
State |= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
-#endif
setmouse();
clear_showcmd();
@@ -1761,7 +1761,7 @@ static int has_compl_option(int dict_opt)
vim_beep();
setcursor();
out_flush();
- ui_delay(2000L, false);
+ os_delay(2000L, false);
}
return FALSE;
}
@@ -2005,7 +2005,7 @@ ins_compl_add (
compl_T *match;
int dir = (cdir == 0 ? compl_direction : cdir);
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return FAIL;
if (len < 0)
@@ -5078,6 +5078,10 @@ internal_format (
colnr_T leader_len;
int no_leader = FALSE;
int do_comments = (flags & INSCHAR_DO_COM);
+ int has_lbr = curwin->w_p_lbr;
+
+ // make sure win_lbr_chartabsize() counts correctly
+ curwin->w_p_lbr = false;
/*
* When 'ai' is off we don't want a space under the cursor to be
@@ -5367,6 +5371,8 @@ internal_format (
if (save_char != NUL) /* put back space after cursor */
pchar_cursor(save_char);
+ curwin->w_p_lbr = has_lbr;
+
if (!format_only && haveto_redraw) {
update_topline();
redraw_curbuf_later(VALID);
@@ -6755,19 +6761,11 @@ static void ins_reg(void)
* message for it. Only call it explicitly. */
++no_u_sync;
if (regname == '=') {
-# ifdef USE_IM_CONTROL
- int im_on = im_get_status();
-# endif
/* Sync undo when evaluating the expression calls setline() or
* append(), so that it can be undone separately. */
u_sync_once = 2;
regname = get_expr_register();
-# ifdef USE_IM_CONTROL
- /* Restore the Input Method. */
- if (im_on)
- im_set_active(TRUE);
-# endif
}
if (regname == NUL || !valid_yank_reg(regname, FALSE)) {
vim_beep();
@@ -6864,24 +6862,8 @@ static void ins_ctrl_hat(void)
} else {
curbuf->b_p_iminsert = B_IMODE_LMAP;
State |= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(FALSE);
-#endif
- }
- }
-#ifdef USE_IM_CONTROL
- else {
- /* There are no ":lmap" mappings, toggle IM */
- if (im_get_status()) {
- curbuf->b_p_iminsert = B_IMODE_NONE;
- im_set_active(FALSE);
- } else {
- curbuf->b_p_iminsert = B_IMODE_IM;
- State &= ~LANGMAP;
- im_set_active(TRUE);
}
}
-#endif
set_iminsert_global();
showmode();
/* Show/unshow value of 'keymap' in status lines. */
@@ -6981,14 +6963,6 @@ ins_esc (
}
}
-#ifdef USE_IM_CONTROL
- /* Disable IM to allow typing English directly for Normal mode commands.
- * When ":lmap" is enabled don't change 'iminsert' (IM can be enabled as
- * well). */
- if (!(State & LANGMAP))
- im_save_status(&curbuf->b_p_iminsert);
- im_set_active(FALSE);
-#endif
State = NORMAL;
/* need to position cursor again (e.g. when on a TAB ) */
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 5975777261..8be25bc34e 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -76,7 +76,7 @@
#include "nvim/tag.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"
@@ -90,6 +90,7 @@
#include "nvim/api/vim.h"
#include "nvim/os/dl.h"
#include "nvim/os/event.h"
+#include "nvim/os/input.h"
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */
@@ -8414,7 +8415,7 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv)
}
vim_feedkeys(cstr_as_string((char *)keys),
- cstr_as_string((char *)flags));
+ cstr_as_string((char *)flags), true);
}
}
@@ -10273,12 +10274,6 @@ static void get_user_input(typval_T *argvars, typval_T *rettv, int inputdialog)
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
-#ifdef NO_CONSOLE_INPUT
- /* While starting up, there is no place to enter text. */
- if (no_console_input())
- return;
-#endif
-
cmd_silent = FALSE; /* Want to see the prompt. */
if (prompt != NULL) {
/* Only the part of the message after the last NL is considered as
@@ -10373,11 +10368,6 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv)
int selected;
int mouse_used;
-#ifdef NO_CONSOLE_INPUT
- /* While starting up, there is no place to enter text. */
- if (no_console_input())
- return;
-#endif
if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL) {
EMSG2(_(e_listarg), "inputlist()");
return;
@@ -10641,10 +10631,10 @@ static void f_jobsend(typval_T *argvars, typval_T *rettv)
ssize_t input_len;
char *input = (char *) save_tv_as_string(&argvars[1], &input_len, true);
- if (input_len < 0) {
- return; // Error handled by save_tv_as_string().
- } else if (input_len == 0) {
- return; // Not an error, but nothing to do.
+ if (!input) {
+ // Either the error has been handled by save_tv_as_string(), or there is no
+ // input to send.
+ return;
}
WBuffer *buf = wstream_new_buffer(input, input_len, 1, free);
@@ -14569,7 +14559,8 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
// get input to the shell command (if any), and its length
ssize_t input_len;
char *input = (char *) save_tv_as_string(&argvars[1], &input_len, false);
- if (input_len == -1) {
+ if (input_len < 0) {
+ assert(input == NULL);
return;
}
@@ -17281,7 +17272,7 @@ void ex_function(exarg_T *eap)
msg_putchar(' ');
msg_prt_line(FUNCLINE(fp, j), FALSE);
out_flush(); /* show a line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
if (!got_int) {
msg_putchar('\n');
@@ -19306,7 +19297,7 @@ void ex_oldfiles(exarg_T *eap)
msg_outtrans(get_tv_string(&li->li_tv));
msg_putchar('\n');
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
/* Assume "got_int" was set to truncate the listing. */
got_int = FALSE;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index f33a96cc50..0829049e4d 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -62,11 +62,11 @@
#include "nvim/tag.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/input.h"
/*
* Struct to hold the sign properties.
@@ -1110,7 +1110,7 @@ do_filter (
/* When interrupting the shell command, it may still have produced some
* useful output. Reset got_int here, so that readfile() won't cancel
* reading. */
- ui_breakcheck();
+ os_breakcheck();
got_int = FALSE;
if (do_out) {
@@ -3602,8 +3602,13 @@ void do_sub(exarg_T *eap)
eap->flags = EXFLAG_PRINT;
}
- do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE, true);
- sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
+ linenr_T joined_lines_count = eap->line2 < curbuf->b_ml.ml_line_count
+ ? eap->line2 - eap->line1 + 2
+ : eap->line2 - eap->line1 + 1;
+ if (joined_lines_count >= 2) {
+ do_join(joined_lines_count, FALSE, TRUE, FALSE, true);
+ }
+ sub_nlines = sub_nsubs = joined_lines_count - 1;
do_sub_msg(false);
ex_may_print(eap);
@@ -4560,7 +4565,7 @@ void global_exe(char_u *cmd)
do_cmdline((char_u *)"p", NULL, NULL, DOCMD_NOWAIT);
else
do_cmdline(cmd, NULL, NULL, DOCMD_NOWAIT);
- ui_breakcheck();
+ os_breakcheck();
}
global_busy = 0;
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 96410897df..24a1ccf85d 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -2116,7 +2116,8 @@ int do_in_runtimepath(char_u *name, int all, DoInRuntimepathCB callback,
np = name;
while (*np != NUL && (all || !did_one)) {
/* Append the pattern from "name" to buf[]. */
- copy_option_part(&np, tail, (int)(MAXPATHL - (tail - buf)),
+ assert(MAXPATHL >= (tail - buf));
+ copy_option_part(&np, tail, (size_t)(MAXPATHL - (tail - buf)),
"\t ");
if (p_verbose > 2) {
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index ac29e5c451..706aef0133 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -67,6 +67,8 @@
#include "nvim/version.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
#include "nvim/ex_cmds_defs.h"
static int quitmore = 0;
@@ -4337,7 +4339,7 @@ static void uc_list(char_u *name, size_t name_len)
if (p_verbose > 0)
last_set_msg(cmd->uc_scriptID);
out_flush();
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
break;
}
@@ -5459,7 +5461,7 @@ static void ex_print(exarg_T *eap)
if (curbuf->b_ml.ml_flags & ML_EMPTY)
EMSG(_(e_emptybuf));
else {
- for (; !got_int; ui_breakcheck()) {
+ for (; !got_int; os_breakcheck()) {
print_line(eap->line1,
(eap->cmdidx == CMD_number || eap->cmdidx == CMD_pound
|| (eap->flags & EXFLAG_NR)),
@@ -5586,7 +5588,7 @@ void alist_set(alist_T *al, int count, char_u **files, int use_curbuf, int *fnum
buf_set_name(fnum_list[i], files[i]);
alist_add(al, files[i], use_curbuf ? 2 : 1);
- ui_breakcheck();
+ os_breakcheck();
}
free(files);
}
@@ -5842,7 +5844,7 @@ static void ex_tabs(exarg_T *eap)
vim_snprintf((char *)IObuff, IOSIZE, _("Tab page %d"), tabcount++);
msg_outtrans_attr(IObuff, hl_attr(HLF_T));
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
FOR_ALL_WINDOWS_IN_TAB(wp, tp) {
if (got_int) {
@@ -5861,7 +5863,7 @@ static void ex_tabs(exarg_T *eap)
IObuff, IOSIZE, TRUE);
msg_outtrans(IObuff);
out_flush(); /* output one line at a time */
- ui_breakcheck();
+ os_breakcheck();
}
}
}
@@ -6408,8 +6410,8 @@ void do_sleep(long msec)
cursor_on();
out_flush();
for (done = 0; !got_int && done < msec; done += 1000L) {
- ui_delay(msec - done > 1000L ? 1000L : msec - done, true);
- ui_breakcheck();
+ os_delay(msec - done > 1000L ? 1000L : msec - done, true);
+ os_breakcheck();
}
}
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index fba0b93253..ef3facb18b 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -11,6 +11,7 @@
*/
#include <assert.h>
#include <stdbool.h>
+#include <stdint.h>
#include <inttypes.h>
#include "nvim/vim.h"
@@ -1307,7 +1308,7 @@ void ex_catch(exarg_T *eap)
int skip = FALSE;
int caught = FALSE;
char_u *end;
- int save_char = 0;
+ char_u save_char = 0;
char_u *save_cpo;
regmatch_T regmatch;
int prev_got_int;
@@ -1530,7 +1531,8 @@ void ex_finally(exarg_T *eap)
pending |= did_throw ? CSTP_THROW : 0;
pending |= did_emsg ? CSTP_ERROR : 0;
pending |= got_int ? CSTP_INTERRUPT : 0;
- cstack->cs_pending[cstack->cs_idx] = pending;
+ assert(pending >= CHAR_MIN && pending <= CHAR_MAX);
+ cstack->cs_pending[cstack->cs_idx] = (char)pending;
/* It's mandatory that the current exception is stored in the
* cstack so that it can be rethrown at the ":endtry" or be
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 2be3757821..70db2dc479 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -265,14 +265,7 @@ getcmdline (
b_im_ptr = &curbuf->b_p_imsearch;
if (*b_im_ptr == B_IMODE_LMAP)
State |= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(*b_im_ptr == B_IMODE_IM);
-#endif
}
-#ifdef USE_IM_CONTROL
- else if (p_imcmdline)
- im_set_active(TRUE);
-#endif
setmouse();
ui_cursor_shape(); /* may show different cursor shape */
@@ -867,9 +860,6 @@ getcmdline (
if (map_to_exists_mode((char_u *)"", LANGMAP, FALSE)) {
/* ":lmap" mappings exists, toggle use of mappings. */
State ^= LANGMAP;
-#ifdef USE_IM_CONTROL
- im_set_active(FALSE); /* Disable input method */
-#endif
if (b_im_ptr != NULL) {
if (State & LANGMAP)
*b_im_ptr = B_IMODE_LMAP;
@@ -877,23 +867,6 @@ getcmdline (
*b_im_ptr = B_IMODE_NONE;
}
}
-#ifdef USE_IM_CONTROL
- else {
- /* There are no ":lmap" mappings, toggle IM. When
- * 'imdisable' is set don't try getting the status, it's
- * always off. */
- if ((p_imdisable && b_im_ptr != NULL)
- ? *b_im_ptr == B_IMODE_IM : im_get_status()) {
- im_set_active(FALSE); /* Disable input method */
- if (b_im_ptr != NULL)
- *b_im_ptr = B_IMODE_NONE;
- } else {
- im_set_active(TRUE); /* Enable input method */
- if (b_im_ptr != NULL)
- *b_im_ptr = B_IMODE_IM;
- }
- }
-#endif
if (b_im_ptr != NULL) {
if (b_im_ptr == &curbuf->b_p_iminsert)
set_iminsert_global();
@@ -1542,11 +1515,6 @@ returncmd:
need_wait_return = FALSE;
State = save_State;
-#ifdef USE_IM_CONTROL
- if (b_im_ptr != NULL && *b_im_ptr != B_IMODE_LMAP)
- im_save_status(b_im_ptr);
- im_set_active(FALSE);
-#endif
setmouse();
ui_cursor_shape(); /* may show different cursor shape */
@@ -1946,7 +1914,7 @@ redraw:
msg_col = 0;
if (msg_row < Rows - 1)
++msg_row;
- emsg_on_display = FALSE; /* don't want ui_delay() */
+ emsg_on_display = FALSE; /* don't want os_delay() */
if (got_int)
ga_clear(&line_ga);
diff --git a/src/nvim/file_search.c b/src/nvim/file_search.c
index 955b0b0a68..a51f088586 100644
--- a/src/nvim/file_search.c
+++ b/src/nvim/file_search.c
@@ -44,10 +44,13 @@
* functions.
*/
+#include <assert.h>
#include <errno.h>
#include <string.h>
#include <stdbool.h>
+#include <stdint.h>
#include <inttypes.h>
+#include <limits.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
@@ -62,9 +65,9 @@
#include "nvim/path.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#include "nvim/os/fs_defs.h"
static char_u *ff_expand_buffer = NULL; /* used for expanding filenames */
@@ -355,12 +358,11 @@ vim_findfile_init (
*/
if (stopdirs != NULL) {
char_u *walker = stopdirs;
- int dircount;
while (*walker == ';')
walker++;
- dircount = 1;
+ size_t dircount = 1;
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *));
do {
@@ -397,7 +399,7 @@ vim_findfile_init (
*/
wc_part = vim_strchr(path, '*');
if (wc_part != NULL) {
- int llevel;
+ int64_t llevel;
int len;
char *errpt;
@@ -425,7 +427,7 @@ vim_findfile_init (
llevel = strtol((char *)wc_part, &errpt, 10);
if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255)
- ff_expand_buffer[len++] = llevel;
+ ff_expand_buffer[len++] = (char_u)llevel;
else if ((char_u *)errpt != wc_part && llevel == 0)
/* restrict is 0 -> remove already added '**' */
len -= 2;
@@ -580,8 +582,7 @@ char_u *vim_findfile(void *search_ctx_arg)
char_u *rest_of_wildcards;
char_u *path_end = NULL;
ff_stack_T *stackp;
- int len;
- int i;
+ size_t len;
char_u *p;
char_u *suf;
ff_search_ctx_T *search_ctx;
@@ -607,7 +608,7 @@ char_u *vim_findfile(void *search_ctx_arg)
/* downward search loop */
for (;; ) {
/* check if user user wants to stop the search*/
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
break;
@@ -701,7 +702,7 @@ char_u *vim_findfile(void *search_ctx_arg)
rest_of_wildcards = stackp->ffs_wc_path;
if (*rest_of_wildcards != NUL) {
- len = (int)STRLEN(file_path);
+ len = STRLEN(file_path);
if (STRNCMP(rest_of_wildcards, "**", 2) == 0) {
/* pointer to the restrict byte
* The restrict byte is not a character!
@@ -772,7 +773,7 @@ char_u *vim_findfile(void *search_ctx_arg)
* We don't have further wildcards to expand, so we have to
* check for the final file now.
*/
- for (i = stackp->ffs_filearray_cur;
+ for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
if (!path_with_url(stackp->ffs_filearray[i])
&& !os_isdir(stackp->ffs_filearray[i]))
@@ -788,7 +789,7 @@ char_u *vim_findfile(void *search_ctx_arg)
* Try without extra suffix and then with suffixes
* from 'suffixesadd'.
*/
- len = (int)STRLEN(file_path);
+ len = STRLEN(file_path);
if (search_ctx->ffsc_tagfile)
suf = (char_u *)"";
else
@@ -829,7 +830,8 @@ char_u *vim_findfile(void *search_ctx_arg)
#endif
/* push dir to examine rest of subdirs later */
- stackp->ffs_filearray_cur = i + 1;
+ assert(i < UCHAR_MAX - 1);
+ stackp->ffs_filearray_cur = (char_u)(i + 1);
ff_push(search_ctx, stackp);
if (!path_with_url(file_path))
@@ -856,6 +858,7 @@ char_u *vim_findfile(void *search_ctx_arg)
/* Not found or found already, try next suffix. */
if (*suf == NUL)
break;
+ assert(MAXPATHL >= len);
copy_option_part(&suf, file_path + len,
MAXPATHL - len, ",");
}
@@ -865,7 +868,7 @@ char_u *vim_findfile(void *search_ctx_arg)
* still wildcards left, push the directories for further
* search
*/
- for (i = stackp->ffs_filearray_cur;
+ for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
if (!os_isdir(stackp->ffs_filearray[i]))
continue; /* not a directory */
@@ -886,7 +889,7 @@ char_u *vim_findfile(void *search_ctx_arg)
* leaves of the directory tree.
*/
if (STRNCMP(stackp->ffs_wc_path, "**", 2) == 0) {
- for (i = stackp->ffs_filearray_cur;
+ for (int i = stackp->ffs_filearray_cur;
i < stackp->ffs_filearray_size; ++i) {
if (fnamecmp(stackp->ffs_filearray[i],
stackp->ffs_fix_path) == 0)
@@ -1397,9 +1400,6 @@ find_file_in_path_option (
* filename on the first call.
*/
if (first == TRUE) {
- int l;
- int run;
-
if (path_with_url(ff_file_to_find)) {
file_name = vim_strsave(ff_file_to_find);
goto theend;
@@ -1407,8 +1407,8 @@ find_file_in_path_option (
/* When FNAME_REL flag given first use the directory of the file.
* Otherwise or when this fails use the current directory. */
- for (run = 1; run <= 2; ++run) {
- l = (int)STRLEN(ff_file_to_find);
+ for (int run = 1; run <= 2; ++run) {
+ size_t l = STRLEN(ff_file_to_find);
if (run == 1
&& rel_to_curdir
&& (options & FNAME_REL)
@@ -1416,7 +1416,7 @@ find_file_in_path_option (
&& STRLEN(rel_fname) + l < MAXPATHL) {
STRCPY(NameBuff, rel_fname);
STRCPY(path_tail(NameBuff), ff_file_to_find);
- l = (int)STRLEN(NameBuff);
+ l = STRLEN(NameBuff);
} else {
STRCPY(NameBuff, ff_file_to_find);
run = 2;
@@ -1436,6 +1436,7 @@ find_file_in_path_option (
}
if (*buf == NUL)
break;
+ assert(MAXPATHL >= l);
copy_option_part(&buf, NameBuff + l, MAXPATHL - l, ",");
}
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 97a357bff7..3be9d89d87 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -53,10 +53,11 @@
#include "nvim/tempfile.h"
#include "nvim/term.h"
#include "nvim/types.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#if defined(HAVE_UTIME) && defined(HAVE_UTIME_H)
# include <utime.h> /* for struct utimbuf */
@@ -1704,7 +1705,7 @@ rewind_retry:
}
}
linerest = (long)(ptr - line_start);
- ui_breakcheck();
+ os_breakcheck();
}
failed:
@@ -2927,7 +2928,7 @@ buf_write (
"E506: Can't write to backup file (add ! to override)");
break;
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
errmsg = (char_u *)_(e_interr);
break;
@@ -3377,7 +3378,7 @@ restore_backup:
s = buffer;
len = 0;
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
end = 0; /* Interrupted, break loop */
break;
@@ -4958,7 +4959,7 @@ buf_check_timestamp (
if (emsg_silent == 0) {
out_flush();
/* give the user some time to think about it */
- ui_delay(1000L, true);
+ os_delay(1000L, true);
/* don't redraw and erase the message */
redraw_cmdline = FALSE;
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 1bec0fa1bb..d0bdcde9e8 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -47,7 +47,6 @@
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/os/event.h"
#include "nvim/os/input.h"
@@ -1702,14 +1701,14 @@ static int vgetorpeek(int advance)
*/
for (;; ) {
/*
- * ui_breakcheck() is slow, don't use it too often when
+ * os_breakcheck() is slow, don't use it too often when
* inside a mapping. But call it each time for typed
* characters.
*/
if (typebuf.tb_maplen)
line_breakcheck();
else
- ui_breakcheck(); /* check for CTRL-C */
+ os_breakcheck(); /* check for CTRL-C */
keylen = 0;
if (got_int) {
/* flush all input */
@@ -2350,11 +2349,6 @@ static int vgetorpeek(int advance)
+ typebuf.tb_len] != NUL)
typebuf.tb_noremap[typebuf.tb_off
+ typebuf.tb_len++] = RM_YES;
-#ifdef USE_IM_CONTROL
- /* Get IM status right after getting keys, not after the
- * timeout for a mapping (focus may be lost by then). */
- vgetc_im_active = im_get_status();
-#endif
}
} /* for (;;) */
} /* if (!character from stuffbuf) */
@@ -2481,7 +2475,7 @@ inchar (
char_u dum[DUM_LEN + 1];
for (;; ) {
- len = ui_inchar(dum, DUM_LEN, 0L, 0);
+ len = os_inchar(dum, DUM_LEN, 0L, 0);
if (len == 0 || (len == 1 && dum[0] == 3))
break;
}
@@ -2498,7 +2492,7 @@ inchar (
* Fill up to a third of the buffer, because each character may be
* tripled below.
*/
- len = ui_inchar(buf, maxlen / 3, wait_time, tb_change_cnt);
+ len = os_inchar(buf, maxlen / 3, wait_time, tb_change_cnt);
}
if (typebuf_changed(tb_change_cnt))
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index cd9f7a648f..ea91135194 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -855,7 +855,6 @@ EXTERN char_u *exe_name; /* the name of the executable */
EXTERN int dont_scroll INIT(= FALSE); /* don't use scrollbars when TRUE */
#endif
EXTERN int mapped_ctrl_c INIT(= FALSE); /* CTRL-C is mapped */
-EXTERN bool ctrl_c_interrupts INIT(= true); /* CTRL-C sets got_int */
EXTERN cmdmod_T cmdmod; /* Ex command modifiers */
@@ -898,10 +897,6 @@ EXTERN int stop_insert_mode; /* for ":stopinsert" and 'insertmode' */
EXTERN int KeyTyped; /* TRUE if user typed current char */
EXTERN int KeyStuffed; /* TRUE if current char from stuffbuf */
-#ifdef USE_IM_CONTROL
-EXTERN int vgetc_im_active; /* Input Method was active for last
- character obtained from vgetc() */
-#endif
EXTERN int maptick INIT(= 0); /* tick for each non-mapped char */
EXTERN char_u chartab[256]; /* table used in charset.c; See
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index 1d15e30921..5d9d353fc8 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -41,8 +41,8 @@
#include "nvim/syntax.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
/*
* To implement printing on a platform, the following functions must be
@@ -724,7 +724,7 @@ void ex_hardcopy(exarg_T *eap)
*/
/* Check for interrupt character every page. */
- ui_breakcheck();
+ os_breakcheck();
if (got_int || settings.user_abort)
goto print_fail;
diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c
index 667e6512f3..bb41db6168 100644
--- a/src/nvim/if_cscope.c
+++ b/src/nvim/if_cscope.c
@@ -29,9 +29,9 @@
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -1735,7 +1735,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, int num_matches)
if (msg_col)
msg_putchar('\n');
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
got_int = FALSE; /* don't print any more matches */
break;
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 509f94dbf2..82f9194fa7 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -1,4 +1,6 @@
+#include <assert.h>
#include <inttypes.h>
+#include <stdint.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
@@ -37,7 +39,7 @@ find_start_comment ( /* XXX */
pos_T *pos;
char_u *line;
char_u *p;
- int cur_maxcomment = ind_maxcomment;
+ int64_t cur_maxcomment = ind_maxcomment;
for (;; ) {
pos = findmatchlimit(NULL, '*', FM_BACKWARD, cur_maxcomment);
@@ -115,27 +117,25 @@ static char_u *skip_string(char_u *p)
/*
- * Return TRUE if the string "line" starts with a word from 'cinwords'.
+ * Return true if the string "line" starts with a word from 'cinwords'.
*/
-int cin_is_cinword(char_u *line)
+bool cin_is_cinword(char_u *line)
{
- char_u *cinw;
- char_u *cinw_buf;
- int cinw_len;
- int retval = FALSE;
- int len;
+ bool retval = false;
- cinw_len = (int)STRLEN(curbuf->b_p_cinw) + 1;
- cinw_buf = xmalloc(cinw_len);
+ size_t cinw_len = STRLEN(curbuf->b_p_cinw) + 1;
+ char_u *cinw_buf = xmalloc(cinw_len);
line = skipwhite(line);
- for (cinw = curbuf->b_p_cinw; *cinw; ) {
- len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
+
+ for (char_u *cinw = curbuf->b_p_cinw; *cinw; ) {
+ size_t len = copy_option_part(&cinw, cinw_buf, cinw_len, ",");
if (STRNCMP(line, cinw_buf, len) == 0
&& (!vim_iswordc(line[len]) || !vim_iswordc(line[len - 1]))) {
- retval = TRUE;
+ retval = true;
break;
}
}
+
free(cinw_buf);
return retval;
@@ -662,7 +662,7 @@ static int cin_islinecomment(char_u *p)
* Return the character terminating the line (ending char's have precedence if
* both apply in order to determine initializations).
*/
-static int
+static char_u
cin_isterminated (
char_u *s,
int incl_open, /* include '{' at the end as terminator */
@@ -1281,8 +1281,6 @@ void parse_cino(buf_T *buf)
{
char_u *p;
char_u *l;
- char_u *digits;
- int n;
int divider;
int fraction = 0;
int sw = (int)get_sw_value(buf);
@@ -1415,11 +1413,13 @@ void parse_cino(buf_T *buf)
l = p++;
if (*p == '-')
++p;
- digits = p; /* remember where the digits start */
- n = getdigits(&p);
+ char_u *digits_start = p; /* remember where the digits start */
+ int64_t digits = getdigits(&p);
+ assert(digits <= INT_MAX);
+ int n = (int)digits;
divider = 0;
if (*p == '.') { /* ".5s" means a fraction */
- fraction = atol((char *)++p);
+ fraction = atoi((char *)++p);
while (VIM_ISDIGIT(*p)) {
++p;
if (divider)
@@ -1429,7 +1429,7 @@ void parse_cino(buf_T *buf)
}
}
if (*p == 's') { /* "2s" means two times 'shiftwidth' */
- if (p == digits)
+ if (p == digits_start)
n = sw; /* just "s" is one 'shiftwidth' */
else {
n *= sw;
@@ -1625,8 +1625,11 @@ int get_c_indent(void)
what = *p++;
else if (*p == COM_LEFT || *p == COM_RIGHT)
align = *p++;
- else if (VIM_ISDIGIT(*p) || *p == '-')
- off = getdigits(&p);
+ else if (VIM_ISDIGIT(*p) || *p == '-') {
+ int64_t digits = getdigits(&p);
+ assert(digits <= INT_MAX);
+ off = (int)digits;
+ }
else
++p;
}
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 4447c404d5..54077acfe3 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -57,12 +57,16 @@
#include "nvim/ui.h"
#include "nvim/version.h"
#include "nvim/window.h"
+#include "nvim/os/time.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/event.h"
#include "nvim/os/signal.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
+#include "nvim/api/private/handle.h"
/* Maximum number of commands from + or -c arguments. */
#define MAX_ARG_CMDS 10
@@ -141,13 +145,60 @@ static char *(main_errors[]) =
#define ME_INVALID_ARG 5
};
+/// Performs early initialization.
+///
+/// Needed for unit tests. Must be called after `time_init()`.
+void early_init(void)
+{
+ handle_init();
+
+ (void)mb_init(); // init mb_bytelen_tab[] to ones
+ eval_init(); // init global variables
+
+#ifdef __QNXNTO__
+ qnx_init(); // PhAttach() for clipboard, (and gui)
+#endif
+
+ // Init the table of Normal mode commands.
+ init_normal_cmds();
+
+#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
+ // Setup to use the current locale (for ctype() and many other things).
+ // NOTE: Translated messages with encodings other than latin1 will not
+ // work until set_init_1() has been called!
+ init_locale();
+#endif
+
+ // Allocate the first window and buffer.
+ // Can't do anything without it, exit when it fails.
+ if (!win_alloc_first()) {
+ mch_exit(0);
+ }
+
+ init_yank(); // init yank buffers
+
+ alist_init(&global_alist); // Init the argument list to empty.
+ global_alist.id = 0;
+
+ // Set the default values for the options.
+ // NOTE: Non-latin1 translated messages are working only after this,
+ // because this is where "has_mbyte" will be set, which is used by
+ // msg_outtrans_len_attr().
+ // First find out the home directory, needed to expand "~" in options.
+ init_homedir(); // find real value of $HOME
+ set_init_1();
+ TIME_MSG("inits 1");
+
+ set_lang_var(); // set v:lang and v:ctype
+}
+
#ifndef NO_VIM_MAIN /* skip this for unittests */
int main(int argc, char **argv)
{
char_u *fname = NULL; /* file name from command line */
mparm_T params; /* various parameters passed between
* main() and other functions. */
- mch_early_init();
+ time_init();
/* Many variables are in "params" so that we can pass them to invoked
* functions without a lot of arguments. "argc" and "argv" are also
@@ -156,24 +207,7 @@ int main(int argc, char **argv)
init_startuptime(&params);
- (void)mb_init(); /* init mb_bytelen_tab[] to ones */
- eval_init(); /* init global variables */
-
-#ifdef __QNXNTO__
- qnx_init(); /* PhAttach() for clipboard, (and gui) */
-#endif
-
- /* Init the table of Normal mode commands. */
- init_normal_cmds();
-
-#if defined(HAVE_LOCALE_H) || defined(X_LOCALE)
- /*
- * Setup to use the current locale (for ctype() and many other things).
- * NOTE: Translated messages with encodings other than latin1 will not
- * work until set_init_1() has been called!
- */
- init_locale();
-#endif
+ early_init();
/*
* Check if we have an interactive window.
@@ -184,32 +218,6 @@ int main(int argc, char **argv)
check_and_set_isatty(&params);
/*
- * Allocate the first window and buffer.
- * Can't do anything without it, exit when it fails.
- */
- if (win_alloc_first() == FAIL)
- mch_exit(0);
-
- init_yank(); /* init yank buffers */
-
- alist_init(&global_alist); /* Init the argument list to empty. */
- global_alist.id = 0;
-
- /*
- * Set the default values for the options.
- * NOTE: Non-latin1 translated messages are working only after this,
- * because this is where "has_mbyte" will be set, which is used by
- * msg_outtrans_len_attr().
- * First find out the home directory, needed to expand "~" in options.
- */
- init_homedir(); /* find real value of $HOME */
- set_init_1();
- TIME_MSG("inits 1");
-
- set_lang_var(); /* set v:lang and v:ctype */
-
-
- /*
* Figure out the way to work from the command name argv[0].
* "vimdiff" starts diff mode, "rvim" sets "restricted", etc.
*/
@@ -251,14 +259,12 @@ int main(int argc, char **argv)
*/
- /*
- * mch_init() sets up the terminal (window) for use. This must be
- * done after resetting full_screen, otherwise it may move the cursor
- * Note that we may use mch_exit() before mch_init()!
- */
- mch_init();
+ // term_init() sets up the terminal (window) for use. This must be
+ // done after resetting full_screen, otherwise it may move the cursor
+ term_init();
TIME_MSG("shell init");
+ event_init();
if (!embedded_mode) {
// Print a warning if stdout is not a terminal.
@@ -1608,7 +1614,7 @@ static void check_tty(mparm_T *parmp)
mch_errmsg(_("Vim: Warning: Input is not from a terminal\n"));
out_flush();
if (scriptin[0] == NULL)
- ui_delay(2000L, true);
+ os_delay(2000L, true);
TIME_MSG("Warning delay");
}
}
@@ -1742,7 +1748,7 @@ static void create_windows(mparm_T *parmp)
#endif
dorewind = TRUE; /* start again */
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
(void)vgetc(); /* only break the file loading, not the rest */
break;
@@ -1832,7 +1838,7 @@ static void edit_buffers(mparm_T *parmp)
arg_had_last = TRUE;
++arg_idx;
}
- ui_breakcheck();
+ os_breakcheck();
if (got_int) {
(void)vgetc(); /* only break the file loading, not the rest */
break;
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 120645cfe6..4ded438f52 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -38,8 +38,8 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
/*
* This file contains routines to maintain and manipulate marks.
@@ -811,7 +811,7 @@ void ex_jumps(exarg_T *eap)
curwin->w_jumplist[i].fmark.fnum == curbuf->b_fnum
? hl_attr(HLF_D) : 0);
free(name);
- ui_breakcheck();
+ os_breakcheck();
}
out_flush();
}
@@ -845,7 +845,7 @@ void ex_changes(exarg_T *eap)
name = mark_line(&curbuf->b_changelist[i], 17);
msg_outtrans_attr(name, hl_attr(HLF_D));
free(name);
- ui_breakcheck();
+ os_breakcheck();
}
out_flush();
}
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 438e8bc603..9b4513e979 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -103,7 +103,6 @@
#include "nvim/screen.h"
#include "nvim/spell.h"
#include "nvim/strings.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
#include "nvim/arabic.h"
@@ -3972,3 +3971,23 @@ char_u * string_convert_ext(vimconv_T *vcp, char_u *ptr, int *lenp,
return retval;
}
+
+// Check bounds for column number
+static int check_col(int col)
+{
+ if (col < 0)
+ return 0;
+ if (col >= (int)screen_Columns)
+ return (int)screen_Columns - 1;
+ return col;
+}
+
+// Check bounds for row number
+static int check_row(int row)
+{
+ if (row < 0)
+ return 0;
+ if (row >= (int)screen_Rows)
+ return (int)screen_Rows - 1;
+ return row;
+}
diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c
index 1656acb689..d8d59474a2 100644
--- a/src/nvim/memfile.c
+++ b/src/nvim/memfile.c
@@ -61,8 +61,8 @@
#include "nvim/memory.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#define MEMFILE_PAGE_SIZE 4096 /// default page size
@@ -455,10 +455,10 @@ int mf_sync(memfile_T *mfp, int flags)
status = FAIL;
}
if (flags & MFS_STOP) { // Stop when char available now.
- if (ui_char_avail())
+ if (os_char_avail())
break;
} else {
- ui_breakcheck();
+ os_breakcheck();
}
if (got_int)
break;
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index e9edeb842f..f6246c8b57 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -71,10 +71,10 @@
#include "nvim/strings.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#ifndef UNIX /* it's in os_unix_defs.h for Unix */
# include <time.h>
@@ -1642,7 +1642,7 @@ void ml_sync_all(int check_file, int check_char)
if (buf->b_ml.ml_mfp->mf_dirty) {
(void)mf_sync(buf->b_ml.ml_mfp, (check_char ? MFS_STOP : 0)
| (bufIsChanged(buf) ? MFS_FLUSH : 0));
- if (check_char && ui_char_avail()) /* character available now */
+ if (check_char && os_char_avail()) /* character available now */
break;
}
}
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index a4cf6dd8ed..f959ea55e4 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -431,7 +431,6 @@ void do_outofmem_msg(size_t size)
#include "nvim/spell.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 23feeab173..cd0c548fb4 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -42,8 +42,10 @@
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
/*
* To be able to scroll back at the "more" and "hit-enter" prompts we need to
@@ -877,7 +879,7 @@ void wait_return(int redraw)
|| c == K_X1MOUSE
|| c == K_X2MOUSE))
);
- ui_breakcheck();
+ os_breakcheck();
/*
* Avoid that the mouse-up event causes visual mode to start.
*/
@@ -2702,11 +2704,9 @@ do_dialog (
int c;
int i;
-#ifndef NO_CONSOLE
/* Don't output anything in silent mode ("ex -s") */
if (silent_mode)
return dfltbutton; /* return default option */
-#endif
oldState = State;
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 310cb6faac..230e198121 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -58,6 +58,8 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
+#include "nvim/os/input.h"
+#include "nvim/os/time.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "misc1.c.generated.h"
@@ -1840,7 +1842,7 @@ void changed(void)
* and don't let the emsg() set msg_scroll. */
if (need_wait_return && emsg_silent == 0) {
out_flush();
- ui_delay(2000L, true);
+ os_delay(2000L, true);
wait_return(TRUE);
msg_scroll = save_msg_scroll;
}
@@ -2261,7 +2263,7 @@ change_warning (
(void)msg_end();
if (msg_silent == 0 && !silent_mode) {
out_flush();
- ui_delay(1000L, true); /* give the user time to think about it */
+ os_delay(1000L, true); /* give the user time to think about it */
}
curbuf->b_did_warn = true;
redraw_cmdline = FALSE; /* don't redraw and erase the message */
@@ -2383,7 +2385,7 @@ int get_keystroke(void)
/* First time: blocking wait. Second time: wait up to 100ms for a
* terminal code to complete. */
- n = ui_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
+ n = os_inchar(buf + len, maxlen, len == 0 ? -1L : 100L, 0);
if (n > 0) {
/* Replace zero and CSI by a special key code. */
n = fix_input_buffer(buf + len, n, FALSE);
@@ -3362,8 +3364,8 @@ void preserve_exit(void)
/*
* Check for CTRL-C pressed, but only once in a while.
- * Should be used instead of ui_breakcheck() for functions that check for
- * each line in the file. Calling ui_breakcheck() each time takes too much
+ * Should be used instead of os_breakcheck() for functions that check for
+ * each line in the file. Calling os_breakcheck() each time takes too much
* time, because it can be a system call.
*/
@@ -3377,7 +3379,7 @@ void line_breakcheck(void)
{
if (++breakcheck_count >= BREAKCHECK_SKIP) {
breakcheck_count = 0;
- ui_breakcheck();
+ os_breakcheck();
}
}
@@ -3388,7 +3390,7 @@ void fast_breakcheck(void)
{
if (++breakcheck_count >= BREAKCHECK_SKIP * 10) {
breakcheck_count = 0;
- ui_breakcheck();
+ os_breakcheck();
}
}
diff --git a/src/nvim/misc2.c b/src/nvim/misc2.c
index 3fe5f1a0ed..bc65056b21 100644
--- a/src/nvim/misc2.c
+++ b/src/nvim/misc2.c
@@ -50,7 +50,6 @@
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
@@ -168,9 +167,9 @@ int csh_like_shell(void)
* "*option" is advanced to the next part.
* The length is returned.
*/
-int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars)
+size_t copy_option_part(char_u **option, char_u *buf, size_t maxlen, char *sep_chars)
{
- int len = 0;
+ size_t len = 0;
char_u *p = *option;
/* skip '.' at start of option part, for 'suffixes' */
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
new file mode 100644
index 0000000000..7fc581a7c0
--- /dev/null
+++ b/src/nvim/mouse.c
@@ -0,0 +1,438 @@
+#include <stdbool.h>
+
+#include "nvim/mouse.h"
+#include "nvim/vim.h"
+#include "nvim/screen.h"
+#include "nvim/window.h"
+#include "nvim/term.h"
+#include "nvim/fold.h"
+#include "nvim/diff.h"
+#include "nvim/move.h"
+#include "nvim/misc1.h"
+#include "nvim/cursor.h"
+#include "nvim/buffer_defs.h"
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mouse.c.generated.h"
+#endif
+
+// Move the cursor to the specified row and column on the screen.
+// Change current window if necessary. Returns an integer with the
+// CURSOR_MOVED bit set if the cursor has moved or unset otherwise.
+//
+// The MOUSE_FOLD_CLOSE bit is set when clicked on the '-' in a fold column.
+// The MOUSE_FOLD_OPEN bit is set when clicked on the '+' in a fold column.
+//
+// If flags has MOUSE_FOCUS, then the current window will not be changed, and
+// if the mouse is outside the window then the text will scroll, or if the
+// mouse was previously on a status line, then the status line may be dragged.
+//
+// If flags has MOUSE_MAY_VIS, then VIsual mode will be started before the
+// cursor is moved unless the cursor was on a status line.
+// This function returns one of IN_UNKNOWN, IN_BUFFER, IN_STATUS_LINE or
+// IN_SEP_LINE depending on where the cursor was clicked.
+//
+// If flags has MOUSE_MAY_STOP_VIS, then Visual mode will be stopped, unless
+// the mouse is on the status line of the same window.
+//
+// If flags has MOUSE_DID_MOVE, nothing is done if the mouse didn't move since
+// the last call.
+//
+// If flags has MOUSE_SETPOS, nothing is done, only the current position is
+// remembered.
+int jump_to_mouse(int flags,
+ bool *inclusive, // used for inclusive operator, can be NULL
+ int which_button) // MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE
+{
+ static int on_status_line = 0; // #lines below bottom of window
+ static int on_sep_line = 0; // on separator right of window
+ static int prev_row = -1;
+ static int prev_col = -1;
+ static win_T *dragwin = NULL; // window being dragged
+ static int did_drag = false; // drag was noticed
+
+ win_T *wp, *old_curwin;
+ pos_T old_cursor;
+ int count;
+ bool first;
+ int row = mouse_row;
+ int col = mouse_col;
+ int mouse_char;
+
+ mouse_past_bottom = false;
+ mouse_past_eol = false;
+
+ if (flags & MOUSE_RELEASED) {
+ // On button release we may change window focus if positioned on a
+ // status line and no dragging happened.
+ if (dragwin != NULL && !did_drag)
+ flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE);
+ dragwin = NULL;
+ did_drag = false;
+ }
+
+ if ((flags & MOUSE_DID_MOVE)
+ && prev_row == mouse_row
+ && prev_col == mouse_col) {
+retnomove:
+ // before moving the cursor for a left click which is NOT in a status
+ // line, stop Visual mode
+ if (on_status_line)
+ return IN_STATUS_LINE;
+ if (on_sep_line)
+ return IN_SEP_LINE;
+ if (flags & MOUSE_MAY_STOP_VIS) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED); // delete the inversion
+ }
+ return IN_BUFFER;
+ }
+
+ prev_row = mouse_row;
+ prev_col = mouse_col;
+
+ if (flags & MOUSE_SETPOS)
+ goto retnomove; // ugly goto...
+
+ // Remember the character under the mouse, it might be a '-' or '+' in the
+ // fold column.
+ if (row >= 0 && row < Rows && col >= 0 && col <= Columns
+ && ScreenLines != NULL)
+ mouse_char = ScreenLines[LineOffset[row] + (unsigned)col];
+ else
+ mouse_char = ' ';
+
+ old_curwin = curwin;
+ old_cursor = curwin->w_cursor;
+
+ if (!(flags & MOUSE_FOCUS)) {
+ if (row < 0 || col < 0) // check if it makes sense
+ return IN_UNKNOWN;
+
+ // find the window where the row is in
+ wp = mouse_find_win(&row, &col);
+ dragwin = NULL;
+ // winpos and height may change in win_enter()!
+ if (row >= wp->w_height) { // In (or below) status line
+ on_status_line = row - wp->w_height + 1;
+ dragwin = wp;
+ } else {
+ on_status_line = 0;
+ }
+
+ if (col >= wp->w_width) { // In separator line
+ on_sep_line = col - wp->w_width + 1;
+ dragwin = wp;
+ } else {
+ on_sep_line = 0;
+ }
+
+ // The rightmost character of the status line might be a vertical
+ // separator character if there is no connecting window to the right.
+ if (on_status_line && on_sep_line) {
+ if (stl_connected(wp))
+ on_sep_line = 0;
+ else
+ on_status_line = 0;
+ }
+
+ // Before jumping to another buffer, or moving the cursor for a left
+ // click, stop Visual mode.
+ if (VIsual_active
+ && (wp->w_buffer != curwin->w_buffer
+ || (!on_status_line
+ && !on_sep_line
+ && (
+ wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
+ col >= wp->w_p_fdc
+ + (cmdwin_type == 0 && wp ==
+ curwin ? 0 : 1)
+ )
+ && (flags & MOUSE_MAY_STOP_VIS)))) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED); // delete the inversion
+ }
+ if (cmdwin_type != 0 && wp != curwin) {
+ // A click outside the command-line window: Use modeless
+ // selection if possible. Allow dragging the status lines.
+ on_sep_line = 0;
+ row = 0;
+ col += wp->w_wincol;
+ wp = curwin;
+ }
+ // Only change window focus when not clicking on or dragging the
+ // status line. Do change focus when releasing the mouse button
+ // (MOUSE_FOCUS was set above if we dragged first).
+ if (dragwin == NULL || (flags & MOUSE_RELEASED))
+ win_enter(wp, true); // can make wp invalid!
+# ifdef CHECK_DOUBLE_CLICK
+ // set topline, to be able to check for double click ourselves
+ if (curwin != old_curwin)
+ set_mouse_topline(curwin);
+# endif
+ if (on_status_line) { // In (or below) status line
+ // Don't use start_arrow() if we're in the same window
+ if (curwin == old_curwin)
+ return IN_STATUS_LINE;
+ else
+ return IN_STATUS_LINE | CURSOR_MOVED;
+ }
+ if (on_sep_line) { // In (or below) status line
+ // Don't use start_arrow() if we're in the same window
+ if (curwin == old_curwin)
+ return IN_SEP_LINE;
+ else
+ return IN_SEP_LINE | CURSOR_MOVED;
+ }
+
+ curwin->w_cursor.lnum = curwin->w_topline;
+ } else if (on_status_line && which_button == MOUSE_LEFT) {
+ if (dragwin != NULL) {
+ // Drag the status line
+ count = row - dragwin->w_winrow - dragwin->w_height + 1
+ - on_status_line;
+ win_drag_status_line(dragwin, count);
+ did_drag |= count;
+ }
+ return IN_STATUS_LINE; // Cursor didn't move
+ } else if (on_sep_line && which_button == MOUSE_LEFT) {
+ if (dragwin != NULL) {
+ // Drag the separator column
+ count = col - dragwin->w_wincol - dragwin->w_width + 1
+ - on_sep_line;
+ win_drag_vsep_line(dragwin, count);
+ did_drag |= count;
+ }
+ return IN_SEP_LINE; // Cursor didn't move
+ } else {
+ // keep_window_focus must be true
+ // before moving the cursor for a left click, stop Visual mode
+ if (flags & MOUSE_MAY_STOP_VIS) {
+ end_visual_mode();
+ redraw_curbuf_later(INVERTED); // delete the inversion
+ }
+
+
+ row -= curwin->w_winrow;
+ col -= curwin->w_wincol;
+
+ // When clicking beyond the end of the window, scroll the screen.
+ // Scroll by however many rows outside the window we are.
+ if (row < 0) {
+ count = 0;
+ for (first = true; curwin->w_topline > 1; ) {
+ if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
+ ++count;
+ else
+ count += plines(curwin->w_topline - 1);
+ if (!first && count > -row)
+ break;
+ first = false;
+ hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
+ if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) {
+ ++curwin->w_topfill;
+ } else {
+ --curwin->w_topline;
+ curwin->w_topfill = 0;
+ }
+ }
+ check_topfill(curwin, false);
+ curwin->w_valid &=
+ ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
+ redraw_later(VALID);
+ row = 0;
+ } else if (row >= curwin->w_height) {
+ count = 0;
+ for (first = true; curwin->w_topline < curbuf->b_ml.ml_line_count; ) {
+ if (curwin->w_topfill > 0) {
+ ++count;
+ } else {
+ count += plines(curwin->w_topline);
+ }
+
+ if (!first && count > row - curwin->w_height + 1) {
+ break;
+ }
+ first = false;
+
+ if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
+ && curwin->w_topline == curbuf->b_ml.ml_line_count) {
+ break;
+ }
+
+ if (curwin->w_topfill > 0) {
+ --curwin->w_topfill;
+ } else {
+ ++curwin->w_topline;
+ curwin->w_topfill =
+ diff_check_fill(curwin, curwin->w_topline);
+ }
+ }
+ check_topfill(curwin, false);
+ redraw_later(VALID);
+ curwin->w_valid &=
+ ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
+ row = curwin->w_height - 1;
+ } else if (row == 0) {
+ // When dragging the mouse, while the text has been scrolled up as
+ // far as it goes, moving the mouse in the top line should scroll
+ // the text down (done later when recomputing w_topline).
+ if (mouse_dragging > 0
+ && curwin->w_cursor.lnum
+ == curwin->w_buffer->b_ml.ml_line_count
+ && curwin->w_cursor.lnum == curwin->w_topline) {
+ curwin->w_valid &= ~(VALID_TOPLINE);
+ }
+ }
+ }
+
+ // Check for position outside of the fold column.
+ if (curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
+ col >= curwin->w_p_fdc + (cmdwin_type == 0 ? 0 : 1)) {
+ mouse_char = ' ';
+ }
+
+ // compute the position in the buffer line from the posn on the screen
+ if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum)) {
+ mouse_past_bottom = true;
+ }
+
+ // Start Visual mode before coladvance(), for when 'sel' != "old"
+ if ((flags & MOUSE_MAY_VIS) && !VIsual_active) {
+ check_visual_highlight();
+ VIsual = old_cursor;
+ VIsual_active = true;
+ VIsual_reselect = true;
+ // if 'selectmode' contains "mouse", start Select mode
+ may_start_select('o');
+ setmouse();
+
+ if (p_smd && msg_silent == 0) {
+ redraw_cmdline = true; // show visual mode later
+ }
+ }
+
+ curwin->w_curswant = col;
+ curwin->w_set_curswant = false; // May still have been true
+ if (coladvance(col) == FAIL) { // Mouse click beyond end of line
+ if (inclusive != NULL) {
+ *inclusive = true;
+ }
+ mouse_past_eol = true;
+ } else if (inclusive != NULL) {
+ *inclusive = false;
+ }
+
+ count = IN_BUFFER;
+ if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
+ || curwin->w_cursor.col != old_cursor.col) {
+ count |= CURSOR_MOVED; // Cursor has moved
+ }
+
+ if (mouse_char == '+') {
+ count |= MOUSE_FOLD_OPEN;
+ } else if (mouse_char != ' ') {
+ count |= MOUSE_FOLD_CLOSE;
+ }
+
+ return count;
+}
+
+// Compute the position in the buffer line from the posn on the screen in
+// window "win".
+// Returns true if the position is below the last line.
+bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
+{
+ int col = *colp;
+ int row = *rowp;
+ linenr_T lnum;
+ bool retval = false;
+ int off;
+ int count;
+
+ if (win->w_p_rl)
+ col = win->w_width - 1 - col;
+
+ lnum = win->w_topline;
+
+ while (row > 0) {
+ // Don't include filler lines in "count"
+ if (win->w_p_diff
+ && !hasFoldingWin(win, lnum, NULL, NULL, true, NULL)) {
+ if (lnum == win->w_topline) {
+ row -= win->w_topfill;
+ } else {
+ row -= diff_check_fill(win, lnum);
+ }
+ count = plines_win_nofill(win, lnum, true);
+ } else {
+ count = plines_win(win, lnum, true);
+ }
+
+ if (count > row) {
+ break; // Position is in this buffer line.
+ }
+
+ (void)hasFoldingWin(win, lnum, NULL, &lnum, true, NULL);
+
+ if (lnum == win->w_buffer->b_ml.ml_line_count) {
+ retval = true;
+ break; // past end of file
+ }
+ row -= count;
+ ++lnum;
+ }
+
+ if (!retval) {
+ // Compute the column without wrapping.
+ off = win_col_off(win) - win_col_off2(win);
+ if (col < off)
+ col = off;
+ col += row * (win->w_width - off);
+ // add skip column (for long wrapping line)
+ col += win->w_skipcol;
+ }
+
+ if (!win->w_p_wrap) {
+ col += win->w_leftcol;
+ }
+
+ // skip line number and fold column in front of the line
+ col -= win_col_off(win);
+ if (col < 0) {
+ col = 0;
+ }
+
+ *colp = col;
+ *rowp = row;
+ *lnump = lnum;
+ return retval;
+}
+
+// Find the window at screen position "*rowp" and "*colp". The positions are
+// updated to become relative to the top-left of the window.
+win_T *mouse_find_win(int *rowp, int *colp)
+{
+ frame_T *fp;
+
+ fp = topframe;
+ *rowp -= firstwin->w_winrow;
+ for (;; ) {
+ if (fp->fr_layout == FR_LEAF)
+ break;
+ if (fp->fr_layout == FR_ROW) {
+ for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
+ if (*colp < fp->fr_width)
+ break;
+ *colp -= fp->fr_width;
+ }
+ } else { // fr_layout == FR_COL
+ for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
+ if (*rowp < fp->fr_height)
+ break;
+ *rowp -= fp->fr_height;
+ }
+ }
+ }
+ return fp->fr_win;
+}
diff --git a/src/nvim/mouse.h b/src/nvim/mouse.h
new file mode 100644
index 0000000000..4f797c7480
--- /dev/null
+++ b/src/nvim/mouse.h
@@ -0,0 +1,32 @@
+#ifndef NVIM_MOUSE_H
+#define NVIM_MOUSE_H
+
+#include <stdbool.h>
+
+#include "nvim/vim.h"
+#include "nvim/buffer_defs.h"
+
+// jump_to_mouse() returns one of first four these values, possibly with
+// some of the other three added.
+#define IN_UNKNOWN 0
+#define IN_BUFFER 1
+#define IN_STATUS_LINE 2 // on status or command line
+#define IN_SEP_LINE 4 // on vertical separator line
+#define IN_OTHER_WIN 8 // in other window but can't go there
+#define CURSOR_MOVED 0x100
+#define MOUSE_FOLD_CLOSE 0x200 // clicked on '-' in fold column
+#define MOUSE_FOLD_OPEN 0x400 // clicked on '+' in fold column
+
+// flags for jump_to_mouse()
+#define MOUSE_FOCUS 0x01 // need to stay in this window
+#define MOUSE_MAY_VIS 0x02 // may start Visual mode
+#define MOUSE_DID_MOVE 0x04 // only act when mouse has moved
+#define MOUSE_SETPOS 0x08 // only set current mouse position
+#define MOUSE_MAY_STOP_VIS 0x10 // may stop Visual mode
+#define MOUSE_RELEASED 0x20 // button was released
+
+#ifdef INCLUDE_GENERATED_DECLARATIONS
+# include "mouse.h.generated.h"
+#endif
+
+#endif // NVIM_MOUSE_H
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index f58e044c2c..0a43d59607 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -57,9 +57,11 @@
#include "nvim/tag.h"
#include "nvim/term.h"
#include "nvim/ui.h"
+#include "nvim/mouse.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/event.h"
+#include "nvim/os/time.h"
/*
* The Visual area is remembered for reselection.
@@ -715,9 +717,6 @@ getcount:
bool lit = false; /* get extra character literally */
bool langmap_active = false; /* using :lmap mappings */
int lang; /* getting a text character */
-#ifdef USE_IM_CONTROL
- bool save_smd; /* saved value of p_smd */
-#endif
++no_mapping;
++allow_keys; /* no mapping for nchar, but allow key codes */
@@ -766,12 +765,6 @@ getcount:
State = LANGMAP;
langmap_active = true;
}
-#ifdef USE_IM_CONTROL
- save_smd = p_smd;
- p_smd = false; /* Don't let the IM code show the mode here */
- if (lang && curbuf->b_p_iminsert == B_IMODE_IM)
- im_set_active(true);
-#endif
*cp = plain_vgetc();
@@ -781,14 +774,6 @@ getcount:
++allow_keys;
State = NORMAL_BUSY;
}
-#ifdef USE_IM_CONTROL
- if (lang) {
- if (curbuf->b_p_iminsert != B_IMODE_LMAP)
- im_save_status(&curbuf->b_p_iminsert);
- im_set_active(false);
- }
- p_smd = save_smd;
-#endif
State = NORMAL_BUSY;
need_flushbuf |= add_to_showcmd(*cp);
@@ -1008,8 +993,8 @@ getcount:
cursor_on();
out_flush();
if (msg_scroll || emsg_on_display)
- ui_delay(1000L, true); /* wait at least one second */
- ui_delay(3000L, false); /* wait up to three seconds */
+ os_delay(1000L, true); /* wait at least one second */
+ os_delay(3000L, false); /* wait up to three seconds */
State = save_State;
msg_scroll = false;
@@ -1106,6 +1091,10 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
pos_T old_cursor;
bool empty_region_error;
int restart_edit_save;
+ int lbr_saved = curwin->w_p_lbr;
+
+ curwin->w_p_lbr = false; /* avoid a problem with unwanted linebreaks in
+ * block mode */
/* The visual area is remembered for redo */
static int redo_VIsual_mode = NUL; /* 'v', 'V', or Ctrl-V */
@@ -1718,6 +1707,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank)
oap->block_mode = false;
clearop(oap);
}
+ curwin->w_p_lbr = lbr_saved;
}
/*
@@ -3499,7 +3489,11 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
* screenline or move two screenlines.
*/
validate_virtcol();
- if (curwin->w_virtcol > curwin->w_curswant
+ colnr_T virtcol = curwin->w_virtcol;
+ if (virtcol > (colnr_T)width1 && *p_sbr != NUL)
+ virtcol -= vim_strsize(p_sbr);
+
+ if (virtcol > curwin->w_curswant
&& (curwin->w_curswant < (colnr_T)width1
? (curwin->w_curswant > (colnr_T)width1 / 2)
: ((curwin->w_curswant - width1) % width2
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 5ef605bb3b..6bf3f6036f 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -45,10 +45,9 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
-#include "nvim/api/private/helpers.h"
+#include "nvim/os/input.h"
/*
* Registers:
@@ -1112,7 +1111,7 @@ insert_reg (
* register a and then, in insert mode, doing CTRL-R a.
* If you hit CTRL-C, the loop will be broken here.
*/
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return FAIL;
@@ -1296,7 +1295,7 @@ cmdline_paste_reg (
/* Check for CTRL-C, in case someone tries to paste a few thousand
* lines and gets bored. */
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return FAIL;
}
@@ -3254,7 +3253,7 @@ void ex_display(exarg_T *eap)
MSG_PUTS_ATTR("^J", attr);
out_flush(); /* show one line at a time */
}
- ui_breakcheck();
+ os_breakcheck();
}
/*
@@ -3339,7 +3338,7 @@ dis_msg (
} else
msg_outtrans_len(p++, 1);
}
- ui_breakcheck();
+ os_breakcheck();
}
/*
@@ -5079,7 +5078,7 @@ void cursor_pos_info(void)
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
/* Check for a CTRL-C every 100000 characters. */
if (byte_count > last_check) {
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return;
last_check = byte_count + 100000L;
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 830a30204b..ee70b5bf8a 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -75,10 +75,10 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
/*
* The options that are local to a window or buffer have "indir" set to one of
@@ -912,18 +912,10 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
{(char_u *)"", (char_u *)0L} SCRIPTID_INIT},
{"imcmdline", "imc", P_BOOL|P_VI_DEF,
-#ifdef USE_IM_CONTROL
- (char_u *)&p_imcmdline, PV_NONE,
-#else
(char_u *)NULL, PV_NONE,
-#endif
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"imdisable", "imd", P_BOOL|P_VI_DEF,
-#ifdef USE_IM_CONTROL
- (char_u *)&p_imdisable, PV_NONE,
-#else
(char_u *)NULL, PV_NONE,
-#endif
{(char_u *)FALSE, (char_u *)0L}
SCRIPTID_INIT},
{"iminsert", "imi", P_NUM|P_VI_DEF,
@@ -5134,18 +5126,6 @@ set_bool_option (
foldUpdateAll(curwin);
}
-#ifdef USE_IM_CONTROL
- /* 'imdisable' */
- else if ((int *)varp == &p_imdisable) {
- /* Only de-activate it here, it will be enabled when changing mode. */
- if (p_imdisable)
- im_set_active(FALSE);
- else if (State & INSERT)
- /* When the option is set from an autocommand, it may need to take
- * effect right away. */
- im_set_active(curbuf->b_p_iminsert == B_IMODE_IM);
- }
-#endif
/* 'spell' */
else if ((int *)varp == &curwin->w_p_spell) {
@@ -6123,7 +6103,7 @@ showoptions (
col += INC;
}
out_flush();
- ui_breakcheck();
+ os_breakcheck();
}
}
free(items);
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index cd61b6427c..89264f8982 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -416,10 +416,6 @@ EXTERN int p_arshape; /* 'arabicshape' */
EXTERN int p_icon; /* 'icon' */
EXTERN char_u *p_iconstring; /* 'iconstring' */
EXTERN int p_ic; /* 'ignorecase' */
-#ifdef USE_IM_CONTROL
-EXTERN int p_imcmdline; /* 'imcmdline' */
-EXTERN int p_imdisable; /* 'imdisable' */
-#endif
EXTERN int p_is; /* 'incsearch' */
EXTERN int p_im; /* 'insertmode' */
EXTERN char_u *p_isf; /* 'isfname' */
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index d10d20b20e..686fe1f06d 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -17,8 +17,11 @@
#include "nvim/keymap.h"
#include "nvim/mbyte.h"
#include "nvim/fileio.h"
+#include "nvim/ex_cmds2.h"
#include "nvim/getchar.h"
#include "nvim/term.h"
+#include "nvim/main.h"
+#include "nvim/misc1.h"
#define READ_BUFFER_SIZE 0xfff
#define INPUT_BUFFER_SIZE (READ_BUFFER_SIZE * 4)
@@ -184,7 +187,16 @@ size_t input_enqueue(String keys)
static bool input_poll(int ms)
{
+ if (do_profiling == PROF_YES && ms) {
+ prof_inchar_enter();
+ }
+
event_poll_until(ms, input_ready());
+
+ if (do_profiling == PROF_YES && ms) {
+ prof_inchar_exit();
+ }
+
return input_ready();
}
@@ -282,7 +294,7 @@ static void convert_input(void)
static void process_interrupts(void)
{
- if (!ctrl_c_interrupts) {
+ if (mapped_ctrl_c) {
return;
}
@@ -326,3 +338,11 @@ static bool input_ready(void)
(!embedded_mode && eof); // Stdin closed
}
+// Exit because of an input read error.
+static void read_error_exit(void)
+{
+ if (silent_mode) /* Normal way to exit for "ex -s" */
+ getout(0);
+ STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
+ preserve_exit();
+}
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 8ab61045dc..8784559b50 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -1,6 +1,5 @@
/*
* VIM - Vi IMproved by Bram Moolenaar
- * OS/2 port by Paul Slootman
* VMS merge by Zoltan Arpadffy
*
* Do ":help uganda" in Vim to read copying and usage conditions.
@@ -10,7 +9,7 @@
/*
* os_unix.c -- code for all flavors of Unix (BSD, SYSV, SVR4, POSIX, ...)
- * Also for BeOS and Atari MiNT.
+ * Also for BeOS
*
* A lot of this file was originally written by Juergen Weigert and later
* changed beyond recognition.
@@ -46,7 +45,6 @@
#include "nvim/tempfile.h"
#include "nvim/term.h"
#include "nvim/types.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/os/event.h"
@@ -83,47 +81,22 @@ static int did_set_title = FALSE;
static char_u *oldicon = NULL;
static int did_set_icon = FALSE;
-
-
-/*
- * Write s[len] to the screen.
- */
-void mch_write(char_u *s, int len)
-{
- if (embedded_mode) {
- // TODO(tarruda): This is a temporary hack to stop Neovim from writing
- // messages to stdout in embedded mode. In the future, embedded mode will
- // be the only possibility(GUIs will always start neovim with a msgpack-rpc
- // over stdio) and this function won't exist.
- //
- // The reason for this is because before Neovim fully migrates to a
- // msgpack-rpc-driven architecture, we must have a fully functional
- // UI working
- return;
- }
-
- ignored = (int)write(1, (char *)s, len);
- if (p_wd) /* Unix is too fast, slow down a bit more */
- os_microdelay(p_wd, false);
-}
-
/*
* If the machine has job control, use it to suspend the program,
* otherwise fake it by starting a new shell.
*/
void mch_suspend(void)
{
- /* BeOS does have SIGTSTP, but it doesn't work. */
-#if defined(SIGTSTP) && !defined(__BEOS__)
+#if defined(SIGTSTP)
out_flush(); /* needed to make cursor visible on some systems */
settmode(TMODE_COOK);
out_flush(); /* needed to disable mouse on some systems */
-
+ // Note: compiler defines _REENTRANT when given -pthread flag.
# if defined(_REENTRANT) && defined(SIGCONT)
sigcont_received = FALSE;
# endif
- kill(0, SIGTSTP); /* send ourselves a STOP signal */
+ uv_kill(0, SIGTSTP); // send ourselves a STOP signal
# if defined(_REENTRANT) && defined(SIGCONT)
/*
* Wait for the SIGCONT signal to be handled. It generally happens
@@ -155,20 +128,6 @@ void mch_suspend(void)
#endif
}
-void mch_init(void)
-{
- Columns = 80;
- Rows = 24;
-
- out_flush();
-
-#ifdef MACOS_CONVERT
- mac_conv_init();
-#endif
-
- event_init();
-}
-
static int get_x11_title(int test_only)
{
return FALSE;
@@ -479,12 +438,6 @@ int mch_nodetype(char_u *name)
return NODE_WRITABLE;
}
-void mch_early_init(void)
-{
- handle_init();
- time_init();
-}
-
#if defined(EXITFREE) || defined(PROTO)
void mch_free_mem(void)
{
@@ -570,9 +523,8 @@ void mch_settmode(int tmode)
{
static int first = TRUE;
- /* Why is NeXT excluded here (and not in os_unixx.h)? */
#if defined(ECHOE) && defined(ICANON) && (defined(HAVE_TERMIO_H) || \
- defined(HAVE_TERMIOS_H)) && !defined(__NeXT__)
+ defined(HAVE_TERMIOS_H))
/*
* for "new" tty systems
*/
@@ -600,9 +552,8 @@ void mch_settmode(int tmode)
*/
tnew.c_iflag &= ~ICRNL;
tnew.c_lflag &= ~(ICANON | ECHO | ISIG | ECHOE
-# if defined(IEXTEN) && !defined(__MINT__)
+# if defined(IEXTEN)
| IEXTEN /* IEXTEN enables typing ^V on SOLARIS */
- /* but it breaks function keys on MINT */
# endif
);
# ifdef ONLCR /* don't map NL -> CR NL, we do it ourselves */
@@ -668,9 +619,8 @@ void get_stty(void)
char_u buf[2];
char_u *p;
- /* Why is NeXT excluded here (and not in os_unixx.h)? */
#if defined(ECHOE) && defined(ICANON) && (defined(HAVE_TERMIO_H) || \
- defined(HAVE_TERMIOS_H)) && !defined(__NeXT__)
+ defined(HAVE_TERMIOS_H))
/* for "new" tty systems */
# ifdef HAVE_TERMIOS_H
struct termios keys;
diff --git a/src/nvim/os_unix_defs.h b/src/nvim/os_unix_defs.h
index 2a44ec3412..ebea86ebcf 100644
--- a/src/nvim/os_unix_defs.h
+++ b/src/nvim/os_unix_defs.h
@@ -8,17 +8,13 @@
* Do ":help credits" in Vim to see a list of people who contributed.
*/
-/*
- * NextStep has a problem with configure, undefine a few things:
- */
-
#include <stdio.h>
#include <ctype.h>
-# include <sys/types.h>
-# include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/stat.h>
-# include <stdlib.h>
+#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
diff --git a/src/nvim/path.c b/src/nvim/path.c
index ff97b7774a..e8d31f3f73 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -31,7 +31,7 @@
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/types.h"
-#include "nvim/ui.h"
+#include "nvim/os/input.h"
#include "nvim/window.h"
#define URL_SLASH 1 /* path_is_url() has found "://" */
@@ -449,7 +449,7 @@ unix_expandpath (
/* Expanding "**" may take a long time, check for CTRL-C. */
if (stardepth > 0) {
- ui_breakcheck();
+ os_breakcheck();
if (got_int)
return 0;
}
@@ -850,7 +850,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
STRMOVE(path + STRLEN(path), short_name);
}
}
- ui_breakcheck();
+ os_breakcheck();
}
/* Shorten filenames in /in/current/directory/{filename} */
@@ -879,7 +879,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
free(fnames[i]);
fnames[i] = rel_path;
sort_again = TRUE;
- ui_breakcheck();
+ os_breakcheck();
}
free(curdir);
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 3de7f73339..4baba00ccf 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -49,9 +49,9 @@
#include "nvim/strings.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
struct dir_stack_T {
@@ -1791,7 +1791,7 @@ void qf_list(exarg_T *eap)
qfp = qfp->qf_next;
++i;
- ui_breakcheck();
+ os_breakcheck();
}
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 3cbdbdd81f..2dbf3f8888 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -129,10 +129,10 @@
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/window.h"
+#include "nvim/os/time.h"
#define MB_FILLER_CHAR '<' /* character used when a double-width character
* doesn't fit. */
@@ -1205,8 +1205,13 @@ static void win_update(win_T *wp)
*/
if (VIsual_mode == Ctrl_V) {
colnr_T fromc, toc;
+ int save_ve_flags = ve_flags;
+
+ if (curwin->w_p_lbr)
+ ve_flags = VE_ALL;
getvcols(wp, &VIsual, &curwin->w_cursor, &fromc, &toc);
+ ve_flags = save_ve_flags;
++toc;
if (curwin->w_curswant == MAXCOL)
toc = MAXCOL;
@@ -3725,6 +3730,7 @@ win_line (
* special character (via 'listchars' option "precedes:<char>".
*/
if (lcs_prec_todo != NUL
+ && wp->w_p_list
&& (wp->w_p_wrap ? wp->w_skipcol > 0 : wp->w_leftcol > 0)
&& filler_todo <= 0
&& draw_state > WL_NR
@@ -6255,7 +6261,7 @@ void check_for_delay(int check_msg_scroll)
&& !did_wait_return
&& emsg_silent == 0) {
out_flush();
- ui_delay(1000L, true);
+ os_delay(1000L, true);
emsg_on_display = FALSE;
if (check_msg_scroll)
msg_scroll = FALSE;
diff --git a/src/nvim/search.c b/src/nvim/search.c
index bd1811c7fb..e9184d84cd 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -48,6 +48,7 @@
#include "nvim/term.h"
#include "nvim/ui.h"
#include "nvim/window.h"
+#include "nvim/os/time.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS
@@ -1429,7 +1430,7 @@ static int check_prevcol(char_u *linep, int col, int ch, int *prevcol)
* NULL
*/
-pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int maxtravel)
+pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
{
static pos_T pos; /* current search position */
int findc = 0; /* matching brace */
@@ -2053,9 +2054,9 @@ showmatch (
* available.
*/
if (vim_strchr(p_cpo, CPO_SHOWMATCH) != NULL)
- ui_delay(p_mat * 100L, true);
+ os_delay(p_mat * 100L, true);
else if (!char_avail())
- ui_delay(p_mat * 100L, false);
+ os_delay(p_mat * 100L, false);
curwin->w_cursor = save_cursor; /* restore cursor position */
p_so = save_so;
p_siso = save_siso;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index ea5ce7ee0d..fa786fdd74 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -325,9 +325,9 @@
#include "nvim/syntax.h"
#include "nvim/term.h"
#include "nvim/tempfile.h"
-#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/os/os.h"
+#include "nvim/os/input.h"
#ifndef UNIX // it's in os_unix_defs.h for Unix
# include <time.h> // for time_t
@@ -9018,7 +9018,7 @@ static void spell_suggest_intern(suginfo_T *su, bool interactive)
// When CTRL-C was hit while searching do show the results. Only clear
// got_int when using a command, not for spellsuggest().
- ui_breakcheck();
+ os_breakcheck();
if (interactive && got_int) {
(void)vgetc();
got_int = FALSE;
@@ -10616,7 +10616,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
// Don't check for CTRL-C too often, it takes time.
if (--breakcheckcount == 0) {
- ui_breakcheck();
+ os_breakcheck();
breakcheckcount = 1000;
}
}
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 91c4495464..d862b0b4dc 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -42,7 +42,6 @@
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 6c5c0f37b1..69d6479cf3 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -44,8 +44,8 @@
#include "nvim/strings.h"
#include "nvim/syntax_defs.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
/*
* Structure that stores information about a highlight group.
@@ -7606,7 +7606,7 @@ static void highlight_list_two(int cnt, int attr)
msg_puts_attr((char_u *)&("N \bI \b! \b"[cnt / 11]), attr);
msg_clr_eos();
out_flush();
- ui_delay(cnt == 99 ? 40L : (long)cnt * 50L, false);
+ os_delay(cnt == 99 ? 40L : (long)cnt * 50L, false);
}
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 6ac6dc5cd2..fb39e069f0 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -49,9 +49,10 @@
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/term.h"
-#include "nvim/ui.h"
#include "nvim/window.h"
#include "nvim/os/os.h"
+#include "nvim/os/time.h"
+#include "nvim/os/input.h"
/*
* Structure to hold pointers to various items in a tag line.
@@ -672,7 +673,7 @@ do_tag (
}
if (msg_col)
msg_putchar('\n');
- ui_breakcheck();
+ os_breakcheck();
}
if (got_int)
got_int = FALSE; /* only stop the listing */
@@ -881,7 +882,7 @@ do_tag (
give_warning(IObuff, ic);
if (ic && !msg_scrolled && msg_silent == 0) {
out_flush();
- ui_delay(1000L, true);
+ os_delay(1000L, true);
}
}
@@ -2493,7 +2494,7 @@ jumpto_tag (
MSG(_("E435: Couldn't find tag, just guessing!"));
if (!msg_scrolled && msg_silent == 0) {
out_flush();
- ui_delay(1000L, true);
+ os_delay(1000L, true);
}
}
retval = OK;
diff --git a/src/nvim/term.c b/src/nvim/term.c
index 263b81fc3a..9da7e11b96 100644
--- a/src/nvim/term.c
+++ b/src/nvim/term.c
@@ -54,6 +54,7 @@
#include "nvim/window.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
+#include "nvim/os/input.h"
#ifdef HAVE_TGETENT
# ifdef HAVE_TERMIOS_H
@@ -638,7 +639,7 @@ static struct builtin_term builtin_termcaps[] =
{K_BS, "\x7f"}, /* for some reason 0177 doesn't work */
# endif
-# if defined(ALL_BUILTIN_TCAPS) || defined(__MINT__)
+# if defined(ALL_BUILTIN_TCAPS)
/*
* Ordinary vt52
*/
@@ -997,7 +998,7 @@ static struct builtin_term builtin_termcaps[] =
-#if defined(UNIX) && !defined(__MINT__)
+#if defined(UNIX)
# define DEFAULT_TERM (char_u *)"ansi"
#endif
@@ -1009,6 +1010,30 @@ static struct builtin_term builtin_termcaps[] =
# define DEFAULT_TERM (char_u *)"dumb"
#endif
+/// Sets up the terminal window for use.
+///
+/// This must be done after resetting full_screen, otherwise it may move the
+/// cursor.
+///
+/// @remark We may call mch_exit() before calling this.
+void term_init(void)
+{
+ Columns = 80;
+ Rows = 24;
+
+ // Prevent buffering output.
+ // Output gets explicitly buffered and flushed by out_flush() at times like,
+ // for example, when the user presses a key. Without this line, vim will not
+ // render the screen correctly.
+ setbuf(stdout, NULL);
+
+ out_flush();
+
+#ifdef MACOS_CONVERT
+ mac_conv_init();
+#endif
+}
+
/*
* Term_strings contains currently used terminal output strings.
* It is initialized with the default values by parse_builtin_tcap().
@@ -1330,7 +1355,7 @@ int set_termname(char_u *term)
if (emsg_silent == 0) {
screen_start(); /* don't know where cursor is now */
out_flush();
- ui_delay(2000L, true);
+ os_delay(2000L, true);
}
set_string_option_direct((char_u *)"term", -1, term,
OPT_FREE, 0);
@@ -1821,11 +1846,35 @@ void termcapinit(char_u *name)
set_termname(T_NAME != NULL ? T_NAME : term);
}
+/// Write s[len] to the screen.
+void term_write(char_u *s, size_t len)
+{
+ if (embedded_mode) {
+ // TODO(tarruda): This is a temporary hack to stop Neovim from writing
+ // messages to stdout in embedded mode. In the future, embedded mode will
+ // be the only possibility(GUIs will always start neovim with a msgpack-rpc
+ // over stdio) and this function won't exist.
+ //
+ // The reason for this is because before Neovim fully migrates to a
+ // msgpack-rpc-driven architecture, we must have a fully functional
+ // UI working
+ return;
+ }
+
+ (void) fwrite(s, len, 1, stdout);
+
+#ifdef UNIX
+ if (p_wd) { // Unix is too fast, slow down a bit more
+ os_microdelay(p_wd, false);
+ }
+#endif
+}
+
/*
* the number of calls to ui_write is reduced by using the buffer "out_buf"
*/
# define OUT_SIZE 2047
-/* Add one to allow mch_write() in os_win32.c to append a NUL */
+// Add one to allow term_write() in os_win32.c to append a NUL
static char_u out_buf[OUT_SIZE + 1];
static int out_pos = 0; /* number of chars in out_buf */
@@ -2302,7 +2351,7 @@ void set_shellsize(int width, int height, int mustset)
Rows = height;
Columns = width;
check_shellsize();
- ui_set_shellsize(mustset);
+ mch_set_shellsize();
} else
check_shellsize();
@@ -4111,7 +4160,7 @@ void show_termcodes(void)
col += INC3;
}
out_flush();
- ui_breakcheck();
+ os_breakcheck();
}
}
free(items);
diff --git a/src/nvim/testdir/test_listlbr.in b/src/nvim/testdir/test_listlbr.in
index 2f28126554..75b06b4cc7 100644
--- a/src/nvim/testdir/test_listlbr.in
+++ b/src/nvim/testdir/test_listlbr.in
@@ -56,6 +56,14 @@ STARTTEST
:syn match All /.*/ contains=ConcealVar
:let line=ScreenChar(winwidth(0))
:call DoRecordScreen()
+:set cpo&vim linebreak
+:let g:test ="Test 6: set linebreak with visual block mode"
+:let line="REMOVE: this not"
+:$put =line
+:let line="REMOVE: aaaaaaaaaaaaa"
+:$put =line
+:1/^REMOVE:
+0jf x:$put
:%w! test.out
:qa!
ENDTEST
diff --git a/src/nvim/testdir/test_listlbr.ok b/src/nvim/testdir/test_listlbr.ok
index 9b8037f4d3..ee74667661 100644
--- a/src/nvim/testdir/test_listlbr.ok
+++ b/src/nvim/testdir/test_listlbr.ok
@@ -32,3 +32,7 @@ Sabbbbbb bla
~
~
~
+this not
+aaaaaaaaaaaaa
+REMOVE:
+REMOVE:
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index d6269897d7..eab6251288 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -44,7 +44,6 @@
void ui_write(char_u *s, int len)
{
-#ifndef NO_CONSOLE
/* Don't output anything in silent mode ("ex -s") unless 'verbose' set */
if (!(silent_mode && p_verbose == 0)) {
char_u *tofree = NULL;
@@ -56,117 +55,11 @@ void ui_write(char_u *s, int len)
s = tofree;
}
- mch_write(s, len);
+ term_write(s, len);
if (output_conv.vc_type != CONV_NONE)
free(tofree);
}
-#endif
-}
-
-/*
- * ui_inchar(): low level input function.
- * Get characters from the keyboard.
- * Return the number of characters that are available.
- * If "wtime" == 0 do not wait for characters.
- * If "wtime" == -1 wait forever for characters.
- * If "wtime" > 0 wait "wtime" milliseconds for a character.
- *
- * "tb_change_cnt" is the value of typebuf.tb_change_cnt if "buf" points into
- * it. When typebuf.tb_change_cnt changes (e.g., when a message is received
- * from a remote client) "buf" can no longer be used. "tb_change_cnt" is NULL
- * otherwise.
- */
-int
-ui_inchar (
- char_u *buf,
- int maxlen,
- long wtime, /* don't use "time", MIPS cannot handle it */
- int tb_change_cnt
-)
-{
- int retval = 0;
-
-
- if (do_profiling == PROF_YES && wtime != 0)
- prof_inchar_enter();
-
-#ifdef NO_CONSOLE_INPUT
- /* Don't wait for character input when the window hasn't been opened yet.
- * Do try reading, this works when redirecting stdin from a file.
- * Must return something, otherwise we'll loop forever. If we run into
- * this very often we probably got stuck, exit Vim. */
- if (no_console_input()) {
- static int count = 0;
-
-# ifndef NO_CONSOLE
- retval = os_inchar(buf, maxlen, (wtime >= 0 && wtime < 10)
- ? 10L : wtime, tb_change_cnt);
- if (retval > 0 || typebuf_changed(tb_change_cnt) || wtime >= 0)
- goto theend;
-# endif
- if (wtime == -1 && ++count == 1000)
- read_error_exit();
- buf[0] = CAR;
- retval = 1;
- goto theend;
- }
-#endif
-
- /* If we are going to wait for some time or block... */
- if (wtime == -1 || wtime > 100L) {
- /* ... allow signals to kill us. */
- signal_accept_deadly();
-
- /* ... there is no need for CTRL-C to interrupt something, don't let
- * it set got_int when it was mapped. */
- if (mapped_ctrl_c)
- ctrl_c_interrupts = false;
- }
-
-#ifndef NO_CONSOLE
- {
- retval = os_inchar(buf, maxlen, wtime, tb_change_cnt);
- }
-#endif
-
- if (wtime == -1 || wtime > 100L)
- /* block SIGHUP et al. */
- signal_reject_deadly();
-
- ctrl_c_interrupts = true;
-
-#ifdef NO_CONSOLE_INPUT
-theend:
-#endif
- if (do_profiling == PROF_YES && wtime != 0)
- prof_inchar_exit();
- return retval;
-}
-
-/*
- * return non-zero if a character is available
- */
-int ui_char_avail(void)
-{
-#ifndef NO_CONSOLE
-# ifdef NO_CONSOLE_INPUT
- if (no_console_input())
- return 0;
-# endif
- return os_char_avail();
-#else
- return 0;
-#endif
-}
-
-/*
- * Delay for the given number of milliseconds. If ignoreinput is FALSE then we
- * cancel the delay if a key is hit.
- */
-void ui_delay(long msec, bool ignoreinput)
-{
- os_delay(msec, ignoreinput);
}
/*
@@ -201,516 +94,11 @@ int ui_get_shellsize(void)
}
/*
- * Set the size of the Vim shell according to Rows and Columns, if possible.
- * The gui_set_shellsize() or mch_set_shellsize() function will try to set the
- * new size. If this is not possible, it will adjust Rows and Columns.
- */
-void
-ui_set_shellsize(int mustset)
-{
- mch_set_shellsize();
-}
-
-void ui_breakcheck(void)
-{
- os_breakcheck();
-}
-
-/*****************************************************************************
- * Functions for copying and pasting text between applications.
- * This is always included in a GUI version, but may also be included when the
- * clipboard and mouse is available to a terminal version such as xterm.
- * Note: there are some more functions in ops.c that handle selection stuff.
- *
- * Also note that the majority of functions here deal with the X 'primary'
- * (visible - for Visual mode use) selection, and only that. There are no
- * versions of these for the 'clipboard' selection, as Visual mode has no use
- * for them.
- */
-
-/*
- * Exit because of an input read error.
- */
-void read_error_exit(void)
-{
- if (silent_mode) /* Normal way to exit for "ex -s" */
- getout(0);
- STRCPY(IObuff, _("Vim: Error reading input, exiting...\n"));
- preserve_exit();
-}
-
-/*
* May update the shape of the cursor.
*/
void ui_cursor_shape(void)
{
term_cursor_shape();
-
-
conceal_check_cursur_line();
}
-/*
- * Check bounds for column number
- */
-int check_col(int col)
-{
- if (col < 0)
- return 0;
- if (col >= (int)screen_Columns)
- return (int)screen_Columns - 1;
- return col;
-}
-
-/*
- * Check bounds for row number
- */
-int check_row(int row)
-{
- if (row < 0)
- return 0;
- if (row >= (int)screen_Rows)
- return (int)screen_Rows - 1;
- return row;
-}
-
-/*
- * Stuff for the X clipboard. Shared between VMS and Unix.
- */
-
-/*
- * Move the cursor to the specified row and column on the screen.
- * Change current window if necessary. Returns an integer with the
- * CURSOR_MOVED bit set if the cursor has moved or unset otherwise.
- *
- * The MOUSE_FOLD_CLOSE bit is set when clicked on the '-' in a fold column.
- * The MOUSE_FOLD_OPEN bit is set when clicked on the '+' in a fold column.
- *
- * If flags has MOUSE_FOCUS, then the current window will not be changed, and
- * if the mouse is outside the window then the text will scroll, or if the
- * mouse was previously on a status line, then the status line may be dragged.
- *
- * If flags has MOUSE_MAY_VIS, then VIsual mode will be started before the
- * cursor is moved unless the cursor was on a status line.
- * This function returns one of IN_UNKNOWN, IN_BUFFER, IN_STATUS_LINE or
- * IN_SEP_LINE depending on where the cursor was clicked.
- *
- * If flags has MOUSE_MAY_STOP_VIS, then Visual mode will be stopped, unless
- * the mouse is on the status line of the same window.
- *
- * If flags has MOUSE_DID_MOVE, nothing is done if the mouse didn't move since
- * the last call.
- *
- * If flags has MOUSE_SETPOS, nothing is done, only the current position is
- * remembered.
- */
-int
-jump_to_mouse (
- int flags,
- bool *inclusive, /* used for inclusive operator, can be NULL */
- int which_button /* MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE */
-)
-{
- static int on_status_line = 0; /* #lines below bottom of window */
- static int on_sep_line = 0; /* on separator right of window */
- static int prev_row = -1;
- static int prev_col = -1;
- static win_T *dragwin = NULL; /* window being dragged */
- static int did_drag = FALSE; /* drag was noticed */
-
- win_T *wp, *old_curwin;
- pos_T old_cursor;
- int count;
- bool first;
- int row = mouse_row;
- int col = mouse_col;
- int mouse_char;
-
- mouse_past_bottom = false;
- mouse_past_eol = false;
-
- if (flags & MOUSE_RELEASED) {
- /* On button release we may change window focus if positioned on a
- * status line and no dragging happened. */
- if (dragwin != NULL && !did_drag)
- flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE);
- dragwin = NULL;
- did_drag = FALSE;
- }
-
- if ((flags & MOUSE_DID_MOVE)
- && prev_row == mouse_row
- && prev_col == mouse_col) {
-retnomove:
- /* before moving the cursor for a left click which is NOT in a status
- * line, stop Visual mode */
- if (on_status_line)
- return IN_STATUS_LINE;
- if (on_sep_line)
- return IN_SEP_LINE;
- if (flags & MOUSE_MAY_STOP_VIS) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED); /* delete the inversion */
- }
- return IN_BUFFER;
- }
-
- prev_row = mouse_row;
- prev_col = mouse_col;
-
- if (flags & MOUSE_SETPOS)
- goto retnomove; /* ugly goto... */
-
- /* Remember the character under the mouse, it might be a '-' or '+' in the
- * fold column. */
- if (row >= 0 && row < Rows && col >= 0 && col <= Columns
- && ScreenLines != NULL)
- mouse_char = ScreenLines[LineOffset[row] + col];
- else
- mouse_char = ' ';
-
- old_curwin = curwin;
- old_cursor = curwin->w_cursor;
-
- if (!(flags & MOUSE_FOCUS)) {
- if (row < 0 || col < 0) /* check if it makes sense */
- return IN_UNKNOWN;
-
- /* find the window where the row is in */
- wp = mouse_find_win(&row, &col);
- dragwin = NULL;
- /*
- * winpos and height may change in win_enter()!
- */
- if (row >= wp->w_height) { /* In (or below) status line */
- on_status_line = row - wp->w_height + 1;
- dragwin = wp;
- } else
- on_status_line = 0;
- if (col >= wp->w_width) { /* In separator line */
- on_sep_line = col - wp->w_width + 1;
- dragwin = wp;
- } else
- on_sep_line = 0;
-
- /* The rightmost character of the status line might be a vertical
- * separator character if there is no connecting window to the right. */
- if (on_status_line && on_sep_line) {
- if (stl_connected(wp))
- on_sep_line = 0;
- else
- on_status_line = 0;
- }
-
- /* Before jumping to another buffer, or moving the cursor for a left
- * click, stop Visual mode. */
- if (VIsual_active
- && (wp->w_buffer != curwin->w_buffer
- || (!on_status_line
- && !on_sep_line
- && (
- wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
- col >= wp->w_p_fdc
- + (cmdwin_type == 0 && wp ==
- curwin ? 0 : 1)
- )
- && (flags & MOUSE_MAY_STOP_VIS)))) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED); /* delete the inversion */
- }
- if (cmdwin_type != 0 && wp != curwin) {
- /* A click outside the command-line window: Use modeless
- * selection if possible. Allow dragging the status lines. */
- on_sep_line = 0;
- row = 0;
- col += wp->w_wincol;
- wp = curwin;
- }
- /* Only change window focus when not clicking on or dragging the
- * status line. Do change focus when releasing the mouse button
- * (MOUSE_FOCUS was set above if we dragged first). */
- if (dragwin == NULL || (flags & MOUSE_RELEASED))
- win_enter(wp, true); /* can make wp invalid! */
-# ifdef CHECK_DOUBLE_CLICK
- /* set topline, to be able to check for double click ourselves */
- if (curwin != old_curwin)
- set_mouse_topline(curwin);
-# endif
- if (on_status_line) { /* In (or below) status line */
- /* Don't use start_arrow() if we're in the same window */
- if (curwin == old_curwin)
- return IN_STATUS_LINE;
- else
- return IN_STATUS_LINE | CURSOR_MOVED;
- }
- if (on_sep_line) { /* In (or below) status line */
- /* Don't use start_arrow() if we're in the same window */
- if (curwin == old_curwin)
- return IN_SEP_LINE;
- else
- return IN_SEP_LINE | CURSOR_MOVED;
- }
-
- curwin->w_cursor.lnum = curwin->w_topline;
- } else if (on_status_line && which_button == MOUSE_LEFT) {
- if (dragwin != NULL) {
- /* Drag the status line */
- count = row - dragwin->w_winrow - dragwin->w_height + 1
- - on_status_line;
- win_drag_status_line(dragwin, count);
- did_drag |= count;
- }
- return IN_STATUS_LINE; /* Cursor didn't move */
- } else if (on_sep_line && which_button == MOUSE_LEFT) {
- if (dragwin != NULL) {
- /* Drag the separator column */
- count = col - dragwin->w_wincol - dragwin->w_width + 1
- - on_sep_line;
- win_drag_vsep_line(dragwin, count);
- did_drag |= count;
- }
- return IN_SEP_LINE; /* Cursor didn't move */
- } else { /* keep_window_focus must be TRUE */
- /* before moving the cursor for a left click, stop Visual mode */
- if (flags & MOUSE_MAY_STOP_VIS) {
- end_visual_mode();
- redraw_curbuf_later(INVERTED); /* delete the inversion */
- }
-
-
- row -= curwin->w_winrow;
- col -= curwin->w_wincol;
-
- /*
- * When clicking beyond the end of the window, scroll the screen.
- * Scroll by however many rows outside the window we are.
- */
- if (row < 0) {
- count = 0;
- for (first = true; curwin->w_topline > 1; ) {
- if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
- ++count;
- else
- count += plines(curwin->w_topline - 1);
- if (!first && count > -row)
- break;
- first = false;
- hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
- if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
- ++curwin->w_topfill;
- else {
- --curwin->w_topline;
- curwin->w_topfill = 0;
- }
- }
- check_topfill(curwin, false);
- curwin->w_valid &=
- ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
- redraw_later(VALID);
- row = 0;
- } else if (row >= curwin->w_height) {
- count = 0;
- for (first = true; curwin->w_topline < curbuf->b_ml.ml_line_count; ) {
- if (curwin->w_topfill > 0)
- ++count;
- else
- count += plines(curwin->w_topline);
- if (!first && count > row - curwin->w_height + 1)
- break;
- first = false;
- if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
- && curwin->w_topline == curbuf->b_ml.ml_line_count)
- break;
- if (curwin->w_topfill > 0)
- --curwin->w_topfill;
- else {
- ++curwin->w_topline;
- curwin->w_topfill =
- diff_check_fill(curwin, curwin->w_topline);
- }
- }
- check_topfill(curwin, false);
- redraw_later(VALID);
- curwin->w_valid &=
- ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
- row = curwin->w_height - 1;
- } else if (row == 0) {
- /* When dragging the mouse, while the text has been scrolled up as
- * far as it goes, moving the mouse in the top line should scroll
- * the text down (done later when recomputing w_topline). */
- if (mouse_dragging > 0
- && curwin->w_cursor.lnum
- == curwin->w_buffer->b_ml.ml_line_count
- && curwin->w_cursor.lnum == curwin->w_topline)
- curwin->w_valid &= ~(VALID_TOPLINE);
- }
- }
-
- /* Check for position outside of the fold column. */
- if (
- curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
- col >= curwin->w_p_fdc
- + (cmdwin_type == 0 ? 0 : 1)
- )
- mouse_char = ' ';
-
- /* compute the position in the buffer line from the posn on the screen */
- if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum))
- mouse_past_bottom = true;
-
- /* Start Visual mode before coladvance(), for when 'sel' != "old" */
- if ((flags & MOUSE_MAY_VIS) && !VIsual_active) {
- check_visual_highlight();
- VIsual = old_cursor;
- VIsual_active = TRUE;
- VIsual_reselect = TRUE;
- /* if 'selectmode' contains "mouse", start Select mode */
- may_start_select('o');
- setmouse();
- if (p_smd && msg_silent == 0)
- redraw_cmdline = TRUE; /* show visual mode later */
- }
-
- curwin->w_curswant = col;
- curwin->w_set_curswant = FALSE; /* May still have been TRUE */
- if (coladvance(col) == FAIL) { /* Mouse click beyond end of line */
- if (inclusive != NULL)
- *inclusive = true;
- mouse_past_eol = true;
- } else if (inclusive != NULL)
- *inclusive = false;
-
- count = IN_BUFFER;
- if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
- || curwin->w_cursor.col != old_cursor.col)
- count |= CURSOR_MOVED; /* Cursor has moved */
-
- if (mouse_char == '+')
- count |= MOUSE_FOLD_OPEN;
- else if (mouse_char != ' ')
- count |= MOUSE_FOLD_CLOSE;
-
- return count;
-}
-
-/*
- * Compute the position in the buffer line from the posn on the screen in
- * window "win".
- * Returns TRUE if the position is below the last line.
- */
-bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump)
-{
- int col = *colp;
- int row = *rowp;
- linenr_T lnum;
- bool retval = false;
- int off;
- int count;
-
- if (win->w_p_rl)
- col = win->w_width - 1 - col;
-
- lnum = win->w_topline;
-
- while (row > 0) {
- /* Don't include filler lines in "count" */
- if (win->w_p_diff
- && !hasFoldingWin(win, lnum, NULL, NULL, TRUE, NULL)
- ) {
- if (lnum == win->w_topline)
- row -= win->w_topfill;
- else
- row -= diff_check_fill(win, lnum);
- count = plines_win_nofill(win, lnum, TRUE);
- } else
- count = plines_win(win, lnum, TRUE);
- if (count > row)
- break; /* Position is in this buffer line. */
- (void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL);
- if (lnum == win->w_buffer->b_ml.ml_line_count) {
- retval = true;
- break; /* past end of file */
- }
- row -= count;
- ++lnum;
- }
-
- if (!retval) {
- /* Compute the column without wrapping. */
- off = win_col_off(win) - win_col_off2(win);
- if (col < off)
- col = off;
- col += row * (win->w_width - off);
- /* add skip column (for long wrapping line) */
- col += win->w_skipcol;
- }
-
- if (!win->w_p_wrap)
- col += win->w_leftcol;
-
- /* skip line number and fold column in front of the line */
- col -= win_col_off(win);
- if (col < 0) {
- col = 0;
- }
-
- *colp = col;
- *rowp = row;
- *lnump = lnum;
- return retval;
-}
-
-/*
- * Find the window at screen position "*rowp" and "*colp". The positions are
- * updated to become relative to the top-left of the window.
- */
-win_T *mouse_find_win(int *rowp, int *colp)
-{
- frame_T *fp;
-
- fp = topframe;
- *rowp -= firstwin->w_winrow;
- for (;; ) {
- if (fp->fr_layout == FR_LEAF)
- break;
- if (fp->fr_layout == FR_ROW) {
- for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
- if (*colp < fp->fr_width)
- break;
- *colp -= fp->fr_width;
- }
- } else { /* fr_layout == FR_COL */
- for (fp = fp->fr_child; fp->fr_next != NULL; fp = fp->fr_next) {
- if (*rowp < fp->fr_height)
- break;
- *rowp -= fp->fr_height;
- }
- }
- }
- return fp->fr_win;
-}
-
-#if defined(USE_IM_CONTROL) || defined(PROTO)
-/*
- * Save current Input Method status to specified place.
- */
-void im_save_status(long *psave)
-{
- /* Don't save when 'imdisable' is set or "xic" is NULL, IM is always
- * disabled then (but might start later).
- * Also don't save when inside a mapping, vgetc_im_active has not been set
- * then.
- * And don't save when the keys were stuffed (e.g., for a "." command).
- * And don't save when the GUI is running but our window doesn't have
- * input focus (e.g., when a find dialog is open). */
- if (!p_imdisable && KeyTyped && !KeyStuffed
- ) {
- /* Do save when IM is on, or IM is off and saved status is on. */
- if (vgetc_im_active)
- *psave = B_IMODE_IM;
- else if (*psave == B_IMODE_IM)
- *psave = B_IMODE_NONE;
- }
-}
-#endif
-
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index 2b1543a918..b174af9abe 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -3,27 +3,6 @@
#include <stdbool.h>
-/*
- * jump_to_mouse() returns one of first four these values, possibly with
- * some of the other three added.
- */
-#define IN_UNKNOWN 0
-#define IN_BUFFER 1
-#define IN_STATUS_LINE 2 /* on status or command line */
-#define IN_SEP_LINE 4 /* on vertical separator line */
-#define IN_OTHER_WIN 8 /* in other window but can't go there */
-#define CURSOR_MOVED 0x100
-#define MOUSE_FOLD_CLOSE 0x200 /* clicked on '-' in fold column */
-#define MOUSE_FOLD_OPEN 0x400 /* clicked on '+' in fold column */
-
-/* flags for jump_to_mouse() */
-#define MOUSE_FOCUS 0x01 /* need to stay in this window */
-#define MOUSE_MAY_VIS 0x02 /* may start Visual mode */
-#define MOUSE_DID_MOVE 0x04 /* only act when mouse has moved */
-#define MOUSE_SETPOS 0x08 /* only set current mouse position */
-#define MOUSE_MAY_STOP_VIS 0x10 /* may stop Visual mode */
-#define MOUSE_RELEASED 0x20 /* button was released */
-
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "ui.h.generated.h"
#endif
diff --git a/src/nvim/version.c b/src/nvim/version.c
index c2818edcc5..f73e5c8cae 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -188,18 +188,18 @@ static int included_patches[] = {
//481,
//480,
//479,
- //478,
+ 478,
//477,
//476,
//475,
//474,
- //473,
- //472,
+ 473,
+ 472,
//471,
//470,
//469,
//468,
- //467,
+ 467,
//465,
//464,
//463,
@@ -230,7 +230,7 @@ static int included_patches[] = {
//438,
437,
436,
- //435,
+ 435,
//434,
433,
//432 NA
@@ -240,7 +240,7 @@ static int included_patches[] = {
//428 NA
427,
//426 NA
- //425,
+ 425,
//424 NA
//423,
//422,
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index abf9c9efcd..f34df8cefb 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1,6 +1,6 @@
-- Sanity checks for vim_* API calls via msgpack-rpc
local helpers = require('test.functional.helpers')
-local clear, nvim, eq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.ok
+local clear, nvim, eq, neq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.neq, helpers.ok
describe('vim_* functions', function()
@@ -106,6 +106,47 @@ describe('vim_* functions', function()
end)
end)
+ describe('replace_termcodes', function()
+ it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
+ eq(helpers.nvim('replace_termcodes', '\x80', true, true, true), '\x80\xfeX')
+ end)
+
+ it('leaves non K_SPECIAL string unchanged', function()
+ eq(helpers.nvim('replace_termcodes', 'abc', true, true, true), 'abc')
+ end)
+
+ it('converts <expressions>', function()
+ eq(helpers.nvim('replace_termcodes', '<Leader>', true, true, true), '\\')
+ end)
+ end)
+
+ describe('feedkeys', function()
+ it('CSI escaping', function()
+ local function on_setup()
+ -- notice the special char(…) \xe2\80\xa6
+ nvim('feedkeys', ':let x1="…"\n', '', true)
+
+ -- Both replace_termcodes and feedkeys escape \x80
+ local inp = helpers.nvim('replace_termcodes', ':let x2="…"<CR>', true, true, true)
+ nvim('feedkeys', inp, '', true)
+
+ -- Disabling CSI escaping in feedkeys
+ inp = helpers.nvim('replace_termcodes', ':let x3="…"<CR>', true, true, true)
+ nvim('feedkeys', inp, '', false)
+
+ helpers.stop()
+ end
+
+ -- spin the loop a bit
+ helpers.run(nil, nil, on_setup)
+
+ eq(nvim('get_var', 'x1'), '…')
+ -- Because of the double escaping this is neq
+ neq(nvim('get_var', 'x2'), '…')
+ eq(nvim('get_var', 'x3'), '…')
+ end)
+ end)
+
it('can throw exceptions', function()
local status, err = pcall(nvim, 'get_option', 'invalid-option')
eq(false, status)
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 84c8765b48..8d212c1375 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -22,11 +22,9 @@ end
-- Some tests require the xclip program and a x server.
local xclip = nil
-do
+do
if os.getenv('DISPLAY') then
- local proc = io.popen('which xclip')
- xclip = proc:read()
- proc:close()
+ xclip = (os.execute('command -v xclip > /dev/null 2>&1') == 0)
end
end
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 544a53fa10..1b97a2f15a 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -139,26 +139,10 @@ local function vim_init()
if vim_init_called ~= nil then
return
end
- -- import os_unix.h for mch_early_init(), which initializes some globals
- local all = cimport('./src/nvim/os_unix.h',
- './src/nvim/misc1.h',
- './src/nvim/eval.h',
- './src/nvim/os_unix.h',
- './src/nvim/option.h',
- './src/nvim/ex_cmds2.h',
- './src/nvim/window.h',
- './src/nvim/ops.h',
- './src/nvim/normal.h',
- './src/nvim/mbyte.h')
- all.mch_early_init()
- all.mb_init()
- all.eval_init()
- all.init_normal_cmds()
- all.win_alloc_first()
- all.init_yank()
- all.init_homedir()
- all.set_init_1()
- all.set_lang_var()
+ local main = cimport('./src/nvim/main.h')
+ local time = cimport('./src/nvim/os/time.h')
+ time.time_init()
+ main.early_init()
vim_init_called = true
end
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 39bd31896e..83c2cfdc61 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -51,7 +51,7 @@ endif()
include(ExternalProject)
-set(LIBUV_URL https://github.com/joyent/libuv/archive/v0.11.28.tar.gz)
+set(LIBUV_URL https://github.com/libuv/libuv/archive/v0.11.28.tar.gz)
set(LIBUV_SHA1 3b70b65467ee693228b8b8385665a52690d74092)
set(LIBUV_MD5 1a849ba4fc571d531482ed74bc7aabc4)