aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xclint.py39
-rw-r--r--config/CMakeLists.txt1
-rw-r--r--runtime/doc/cmdline.txt4
-rw-r--r--runtime/doc/eval.txt33
-rw-r--r--runtime/doc/job_control.txt48
-rw-r--r--runtime/doc/msgpack_rpc.txt66
-rw-r--r--runtime/doc/options.txt12
-rw-r--r--runtime/doc/os_win32.txt2
-rw-r--r--runtime/doc/pattern.txt4
-rw-r--r--runtime/doc/syntax.txt28
-rw-r--r--runtime/doc/todo.txt60
-rw-r--r--runtime/doc/usr_04.txt4
-rw-r--r--runtime/filetype.vim8
-rw-r--r--runtime/ftplugin/dockerfile.vim16
-rw-r--r--runtime/ftplugin/vim.vim11
-rw-r--r--runtime/indent/json.vim169
-rw-r--r--runtime/scripts.vim6
-rw-r--r--runtime/syntax/asciidoc.vim4
-rw-r--r--runtime/syntax/dockerfile.vim24
-rw-r--r--runtime/syntax/tex.vim113
-rwxr-xr-xscripts/vim-patch.sh269
-rw-r--r--src/nvim/CMakeLists.txt2
-rw-r--r--src/nvim/buffer.c22
-rw-r--r--src/nvim/charset.c54
-rw-r--r--src/nvim/cursor_shape.c4
-rw-r--r--src/nvim/diff.c12
-rw-r--r--src/nvim/digraph.c4
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/eval.c88
-rw-r--r--src/nvim/ex_cmds.c18
-rw-r--r--src/nvim/ex_cmds2.c8
-rw-r--r--src/nvim/ex_docmd.c32
-rw-r--r--src/nvim/ex_getln.c2
-rw-r--r--src/nvim/fileio.c8
-rw-r--r--src/nvim/garray.c2
-rw-r--r--src/nvim/getchar.c2
-rw-r--r--src/nvim/globals.h1
-rw-r--r--src/nvim/hardcopy.c209
-rw-r--r--src/nvim/hardcopy.h8
-rw-r--r--src/nvim/indent_c.c8
-rw-r--r--src/nvim/keymap.c6
-rw-r--r--src/nvim/keymap.h4
-rw-r--r--src/nvim/main.c29
-rw-r--r--src/nvim/mark.c11
-rw-r--r--src/nvim/mbyte.c10
-rw-r--r--src/nvim/memline.c6
-rw-r--r--src/nvim/memory.c2
-rw-r--r--src/nvim/menu.c4
-rw-r--r--src/nvim/message.c2
-rw-r--r--src/nvim/misc1.c4
-rw-r--r--src/nvim/msgpack_rpc/channel.c42
-rw-r--r--src/nvim/msgpack_rpc/remote_ui.c109
-rw-r--r--src/nvim/normal.c1
-rw-r--r--src/nvim/ops.c4
-rw-r--r--src/nvim/option.c25
-rw-r--r--src/nvim/option_defs.h3
-rw-r--r--src/nvim/os/input.c22
-rw-r--r--src/nvim/os/job.c9
-rw-r--r--src/nvim/os/shell.c12
-rw-r--r--src/nvim/os/time.c4
-rw-r--r--src/nvim/os_unix.c21
-rw-r--r--src/nvim/path.c6
-rw-r--r--src/nvim/regexp.c6
-rw-r--r--src/nvim/screen.c16
-rw-r--r--src/nvim/search.c26
-rw-r--r--src/nvim/spell.c14
-rw-r--r--src/nvim/strings.c4
-rw-r--r--src/nvim/syntax.c48
-rw-r--r--src/nvim/tag.c2
-rw-r--r--src/nvim/term.c265
-rw-r--r--src/nvim/testdir/test48.in5
-rw-r--r--src/nvim/testdir/test48.ok1
-rw-r--r--src/nvim/testdir/test53.in7
-rw-r--r--src/nvim/testdir/test53.ok6
-rw-r--r--src/nvim/ui.c143
-rw-r--r--src/nvim/ui.h7
-rw-r--r--src/nvim/undo.c2
-rw-r--r--src/nvim/version.c10
-rw-r--r--src/nvim/window.c9
-rw-r--r--test/functional/legacy/066_visual_block_tab_spec.lua10
-rw-r--r--test/functional/shell/viml_system_spec.lua152
-rw-r--r--test/functional/ui/highlight_spec.lua27
-rw-r--r--test/functional/ui/mouse_spec.lua84
-rw-r--r--test/functional/ui/screen.lua115
-rw-r--r--test/functional/ui/screen_basic_spec.lua254
-rw-r--r--test/unit/formatc.lua6
-rw-r--r--test/unit/os/fs_spec.lua4
-rw-r--r--third-party/CMakeLists.txt18
88 files changed, 1976 insertions, 1008 deletions
diff --git a/clint.py b/clint.py
index 28b51fbc9c..38bc13df7f 100755
--- a/clint.py
+++ b/clint.py
@@ -1198,18 +1198,28 @@ def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error):
threading_list = (
- ('asctime(', 'asctime_r('),
- ('ctime(', 'ctime_r('),
- ('getgrgid(', 'getgrgid_r('),
- ('getgrnam(', 'getgrnam_r('),
- ('getlogin(', 'getlogin_r('),
- ('getpwnam(', 'getpwnam_r('),
- ('getpwuid(', 'getpwuid_r('),
- ('gmtime(', 'gmtime_r('),
- ('localtime(', 'localtime_r('),
- ('rand(', 'rand_r('),
- ('strtok(', 'strtok_r('),
- ('ttyname(', 'ttyname_r('),
+ ('asctime(', 'os_asctime_r('),
+ ('ctime(', 'os_ctime_r('),
+ ('getgrgid(', 'os_getgrgid_r('),
+ ('getgrnam(', 'os_getgrnam_r('),
+ ('getlogin(', 'os_getlogin_r('),
+ ('getpwnam(', 'os_getpwnam_r('),
+ ('getpwuid(', 'os_getpwuid_r('),
+ ('gmtime(', 'os_gmtime_r('),
+ ('localtime(', 'os_localtime_r('),
+ ('strtok(', 'os_strtok_r('),
+ ('ttyname(', 'os_ttyname_r('),
+ ('asctime_r(', 'os_asctime_r('),
+ ('ctime_r(', 'os_ctime_r('),
+ ('getgrgid_r(', 'os_getgrgid_r('),
+ ('getgrnam_r(', 'os_getgrnam_r('),
+ ('getlogin_r(', 'os_getlogin_r('),
+ ('getpwnam_r(', 'os_getpwnam_r('),
+ ('getpwuid_r(', 'os_getpwuid_r('),
+ ('gmtime_r(', 'os_gmtime_r('),
+ ('localtime_r(', 'os_localtime_r('),
+ ('strtok_r(', 'os_strtok_r('),
+ ('ttyname_r(', 'os_ttyname_r('),
)
@@ -1235,9 +1245,10 @@ def CheckPosixThreading(filename, clean_lines, linenum, error):
if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and
line[ix - 1] not in ('_', '.', '>'))):
error(filename, linenum, 'runtime/threadsafe_fn', 2,
- 'Consider using ' + multithread_safe_function +
+ 'Use ' + multithread_safe_function +
'...) instead of ' + single_thread_function +
- '...) for improved thread safety.')
+ '...). If it is missing, consider implementing it;' +
+ ' see os_localtime_r for an example.')
# Matches invalid increment: *count++, which moves pointer instead of
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index aab4b5c23d..a46f686d7c 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -5,6 +5,7 @@ include(CheckIncludeFiles)
check_type_size("int" SIZEOF_INT)
check_type_size("long" SIZEOF_LONG)
+check_type_size("intmax_t" SIZEOF_INTMAX_T)
check_type_size("off_t" SIZEOF_OFF_T)
check_type_size("void *" SIZEOF_VOID_PTR)
diff --git a/runtime/doc/cmdline.txt b/runtime/doc/cmdline.txt
index 8b5a6b2f5c..db338a2a56 100644
--- a/runtime/doc/cmdline.txt
+++ b/runtime/doc/cmdline.txt
@@ -1,4 +1,4 @@
-*cmdline.txt* For Vim version 7.4. Last change: 2014 Aug 16
+*cmdline.txt* For Vim version 7.4. Last change: 2014 Sep 06
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -56,7 +56,7 @@ history tables:
These are completely separate. Each history can only be accessed when
entering the same type of line.
Use the 'history' option to set the number of lines that are remembered
-(default: 20).
+(default: 50).
Notes:
- When you enter a command-line that is exactly the same as an older one, the
old one is removed (to avoid repeated commands moving older commands out of
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index a62fa82d12..65b1f2aa3c 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.4. Last change: 2014 Aug 16
+*eval.txt* For Vim version 7.4. Last change: 2014 Sep 09
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1102,9 +1102,9 @@ are known inside the current Vim session. Using expand() will first try using
the environment variables known inside the current Vim session. If that
fails, a shell will be used to expand the variable. This can be slow, but it
does expand all variables that the shell knows about. Example: >
- :echo $version
- :echo expand("$version")
-The first one probably doesn't echo anything, the second echoes the $version
+ :echo $shell
+ :echo expand("$shell")
+The first one probably doesn't echo anything, the second echoes the $shell
variable (if your shell supports it).
@@ -2632,7 +2632,7 @@ cursor({list})
line.
If {col} is zero, the cursor will stay in the current column.
If {curswant} is given it is used to set the preferred column
- for vertical movment. Otherwise {col} is used.
+ for vertical movement. Otherwise {col} is used.
When 'virtualedit' is used {off} specifies the offset in
screen columns from the start of the character. E.g., a
position within a <Tab> or after the last character.
@@ -2923,7 +2923,8 @@ expand({expr} [, {nosuf} [, {list}]]) *expand()*
<
Expand() can also be used to expand variables and environment
variables that are only known in a shell. But this can be
- slow, because a shell must be started. See |expr-env-expand|.
+ slow, because a shell may be used to do the expansion. See
+ |expr-env-expand|.
The expanded variable is still handled like a list of file
names. When an environment variable cannot be expanded, it is
left unchanged. Thus ":echo expand('$FOOBAR')" results in
@@ -3355,6 +3356,7 @@ getcmdtype() *getcmdtype()*
? backward search command
@ |input()| command
- |:insert| or |:append| command
+ = |i_CTRL-R_=|
Only works when editing the command line, thus requires use of
|c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
Returns an empty string otherwise.
@@ -5098,12 +5100,12 @@ rpcnotify({channel}, {event}[, {args}...]) {Nvim} *rpcnotify()*
rpcrequest({channel}, {method}[, {args}...]) {Nvim} *rpcrequest()*
Sends a request to {channel} to invoke {method} via
|msgpack-rpc| and blocks until a response is received.
- Example: >
+ Example: >
:let result = rpcrequest(rpc_chan, "func", 1, 2, 3)
rpcstart({prog}[, {argv}]) {Nvim} *rpcstart()*
- Spawns {prog} as a job(optionally passing the {argv} list),
- and opens a |msgpack-rpc| channel with the spawned process
+ Spawns {prog} as a job (optionally passing the list {argv}),
+ and opens a |msgpack-rpc| channel with the spawned process's
stdin/stdout. It returns:
- The channel id on success, which is used by |rpcrequest()|,
|rpcnotify()| and |rpcstop()|
@@ -5112,10 +5114,9 @@ rpcstart({prog}[, {argv}]) {Nvim} *rpcstart()*
:let rpc_chan = rpcstart('prog', ['arg1', 'arg2'])
rpcstop({channel}) {Nvim} *rpcstop()*
- Closes a |msgpack-rpc| channel, possibly created via
- |rpcstart()| (Though it will also close channels created by
- connections to |$NVIM_LISTEN_ADDRESS|). It accepts the rpc
- channel id as only argument.
+ Closes a |msgpack-rpc| {channel}, possibly created via
+ |rpcstart()|. Also closes channels created by connections to
+ |$NVIM_LISTEN_ADDRESS|.
screenattr(row, col) *screenattr()*
Like screenchar(), but return the attribute. This is a rather
@@ -5558,7 +5559,7 @@ setreg({regname}, {value} [,{options}])
Returns zero for success, non-zero for failure.
*E883*
- Note: you may not use |List| containing more then one item to
+ Note: you may not use |List| containing more than one item to
set search and expression registers. Lists containing no
items act like empty strings.
@@ -5707,7 +5708,7 @@ sort({list} [, {func} [, {dict}]]) *sort()* *E702*
after Strings, |Lists| after Numbers. For sorting text in the
current buffer use |:sort|.
- When {func} is given and it is is '1' or 'i' then case is
+ When {func} is given and it is '1' or 'i' then case is
ignored.
When {func} is given and it is 'n' then all items will be
@@ -6746,7 +6747,6 @@ mouse Compiled with support mouse.
mouse_dec Compiled with support for Dec terminal mouse.
mouse_gpm Compiled with support for gpm (Linux console mouse)
mouse_netterm Compiled with support for netterm mouse.
-mouse_pterm Compiled with support for qnx pterm mouse.
mouse_sysmouse Compiled with support for sysmouse (*BSD console mouse)
mouse_sgr Compiled with support for sgr mouse.
mouse_urxvt Compiled with support for urxvt mouse.
@@ -6766,7 +6766,6 @@ printer Compiled with |:hardcopy| support.
profile Compiled with |:profile| support.
python Compiled with Python 2.x interface. |has-python|
python3 Compiled with Python 3.x interface. |has-python|
-qnx QNX version of Vim.
quickfix Compiled with |quickfix| support.
reltime Compiled with |reltime()| support.
rightleft Compiled with 'rightleft' support.
diff --git a/runtime/doc/job_control.txt b/runtime/doc/job_control.txt
index f381d5ad66..000409597f 100644
--- a/runtime/doc/job_control.txt
+++ b/runtime/doc/job_control.txt
@@ -13,7 +13,7 @@ Nvim's facilities for job control *job-control*
1. Introduction *job-control-intro*
Job control is a simple way to perform multitasking in vimscript. Wikipedia
-contains a more generic/detailed description:
+contains a more generic/detailed description:
"Job control in computing refers to the control of multiple tasks or Jobs on a
computer system, ensuring that they each have access to adequate resources to
@@ -27,8 +27,8 @@ control multiple processes without blocking the current Nvim instance.
Nvim's job control was designed to be simple and familiar to vimscript
programmers, instead of being very powerful but complex. Unlike Vim's
-facilities for calling with external commands, job control does not depend
-on installed shells, calling OS functions for process management directly.
+facilities for calling with external commands, job control does not depend on
+available shells, instead relying on OS functionality for process management.
Internally, Nvim job control is powered by libuv, which has a nice
cross-platform API for managing processes. See https://github.com/libuv/libuv
@@ -43,8 +43,8 @@ event. The best way to understand is with a complete example:
>
set nocp
let job1 = jobstart('shell1', 'bash')
- let job2 = jobstart('shell2', 'bash', ['-c', 'for ((i = 0; i < 10; i++)); do echo -n hello $i!; sleep 2; done'])
-
+ let job2 = jobstart('shell2', 'bash', ['-c', 'for ((i = 0; i < 10; i++)); do echo hello $i!; sleep 1; done'])
+
function JobHandler()
if v:job_data[1] == 'stdout'
let str = 'shell '. v:job_data[0].' stdout: '.join(v:job_data[2])
@@ -53,27 +53,27 @@ event. The best way to understand is with a complete example:
else
let str = 'shell '.v:job_data[0].' exited'
endif
-
+
call append(line('$'), str)
endfunction
-
+
au JobActivity shell* call JobHandler()
<
-To test the above, copy it to the ~/jobcontrol.vim file and start with a clean
+To test the above, copy it to the file ~/jobcontrol.vim and start with a clean
nvim instance:
- >
- nvim -u NONE -S ~/jobcontrol.vim
+>
+ nvim -u NONE -S ~/jobcontrol.vim
<
Here's what is happening:
-- Two bash instances are spawned by |jobstart()| and their stdin/stdout/stderr
- are connected to nvim.
-- The first shell is idle, waiting to read commands from it's stdin
-- The second shell is passed the -c option to execute a command and exit. In
- our case, the command is a for loop that will print numbers and exit after
- a while.
-- The JobHandler function is called by the JobActivity autocommand(notice how
- the shell* pattern matches the `shell1` and `shell2` names passed to
+- Two bash instances are spawned by |jobstart()| with their stdin/stdout/stderr
+ connected to nvim.
+- The first shell is idle, waiting to read commands from its stdin.
+- The second shell is started with the -c argument, causing it to execute a
+ command then exit. In this case, the command is a for loop that will print 0
+ through 9 then exit.
+- The |JobHandler()| function is called by the `JobActivity` autocommand (notice
+ how the shell* pattern matches the names `shell1` and `shell2` passed to
|jobstart()|), and it takes care of displaying stdout/stderr received from
the shells.
- The v:job_data is an array set by the JobActivity event. It has the
@@ -86,16 +86,16 @@ Here's what is happening:
To send data to the job's stdin, one can use the |jobsend()| function, like
this:
>
- :call jobsend(job1, 'ls\n')
- :call jobsend(job1, 'invalid-command\n')
- :call jobsend(job1, 'exit\n')
+ :call jobsend(job1, "ls\n")
+ :call jobsend(job1, "invalid-command\n")
+ :call jobsend(job1, "exit\n")
<
A job may be killed at any time with the |jobstop()| function:
>
:call jobstop(job1)
<
-When |jobstop()| is called, it will send `SIGTERM` to the job. If a job
-doesn't exit after a while, `SIGKILL` will be sent.
-
+When |jobstop()| is called, `SIGTERM` will be sent to the job. If a job does
+not exit after 2 seconds, `SIGKILL` will be sent.
+
==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl:
diff --git a/runtime/doc/msgpack_rpc.txt b/runtime/doc/msgpack_rpc.txt
index 0fb419e5d5..af4ef3e132 100644
--- a/runtime/doc/msgpack_rpc.txt
+++ b/runtime/doc/msgpack_rpc.txt
@@ -4,10 +4,10 @@
NVIM REFERENCE MANUAL by Thiago de Arruda
-The Msgpack-RPC Interface to Nvim *msgpack-rpc*
+The Msgpack-RPC Interface to Nvim *msgpack-rpc*
1. Introduction |msgpack-rpc-intro|
-2. API |msgpack-rpc-api|
+2. API |msgpack-rpc-api|
3. Connecting |msgpack-rpc-connecting|
4. Clients |msgpack-rpc-clients|
5. Types |msgpack-rpc-types|
@@ -40,9 +40,9 @@ Nvim's msgpack-rpc interface can be seen as a more powerful version of Vim's
The Nvim C API is automatically exposed to the msgpack-rpc interface by the
build system, which parses headers at src/nvim/api from the project root. A
-dispatch function is generated, which matches msgpack-rpc method names
-with non-static API functions, converting/validating arguments and return
-values back to msgpack.
+dispatch function is generated, which matches msgpack-rpc method names with
+non-static API functions, converting/validating arguments and return values
+back to msgpack.
Client libraries will normally provide wrappers that hide msgpack-rpc details
from programmers, which can be automatically generated by reading bundled API
@@ -60,7 +60,7 @@ There are two ways to obtain API metadata:
separate compilation step.
Here's a simple way to get human-readable description of the API (requires
-python and the pyyaml/msgpack-python pip packages):
+python and the `pyyaml`/`msgpack-python` pip packages):
>
nvim --api-info | python -c 'import msgpack, sys, yaml; print yaml.dump(msgpack.unpackb(sys.stdin.read()))' > api.yaml
@@ -69,21 +69,19 @@ python and the pyyaml/msgpack-python pip packages):
There are four ways to open msgpack-rpc streams to nvim:
-1. Through nvim's stdin/stdout when started with the `--embed` option. This is
+1. Through Nvim's stdin/stdout when started with the `--embed` option. This is
how other programs can embed nvim.
-2. Through stdin/stdout of a program spawned by the |rpcstart()| function.
+2. Through the stdin/stdout of a program spawned by the |rpcstart()| function.
3. Through the socket automatically created with each instance. To find out
the socket location (which is random by default) from a running nvim
- instance, one can inspect the *$NVIM_LISTEN_ADDRESS* environment variable
- like this:
+ instance, one can inspect the |$NVIM_LISTEN_ADDRESS| environment variable:
>
:echo $NVIM_LISTEN_ADDRESS
<
-4. Through a TCP/IP socket. To make nvim listen on a TCP/IP socket, you need
- to set the $NVIM_LISTEN_ADDRESS environment variable before starting, like
- this:
+4. Through a TCP/IP socket. To make nvim listen on a TCP/IP socket, set the
+ |$NVIM_LISTEN_ADDRESS| environment variable in a shell before starting:
>
NVIM_LISTEN_ADDRESS=127.0.0.1:6666 nvim
<
@@ -120,34 +118,34 @@ functions can be called interactively:
==============================================================================
4. Implementing new clients *msgpack-rpc-clients*
-Nvim is still alpha and there's no in-depth documentation explaining how to
-properly implement a client library. The python client (neovim pip package)
-will be always up-to-date with the latest API changes, so its source code is
-the best documentation currently available. There are some guidelines however:
+Nvim is still in alpha, so there's no in-depth documentation explaining how to
+properly implement a client library yet. The python client (the pip package
+"neovim") will always be up-to-date with the latest API changes, so its source
+code is the best documentation currently available. There are some guidelines
+however:
-- Separate the transport layer from the rest of the library (see
- |msgpack-rpc-connecting| for details of how a client can connect to nvim).
-- Use a msgpack library that implements the spec version 5, Nvim uses the
- BIN/EXT types.
+- Separate the transport layer from the rest of the library. See
+ |msgpack-rpc-connecting| for details on how clients can connect to nvim.
+- Use a MessagePack library that implements at least version 5 of the
+ MessagePack spec, which supports the `bin` and `ext` types used by nvim.
- Read API metadata in order to create client-side wrappers for all
msgpack-rpc methods.
- Use a single-threaded event loop library/pattern.
-- Use a fiber/coroutine library for the language you are implementing a client
- for. These greatly simplify concurrency and allow the library to expose a
- blocking API on top of a non-blocking event loop without the complexity
- that comes with preemptive multitasking.
+- Use a fiber/coroutine library for the language being used for implementing a
+ client. These greatly simplify concurrency and allow the library to expose a
+ blocking API on top of a non-blocking event loop without the complexity that
+ comes with preemptive multitasking.
- Don't assume anything about the order that responses to msgpack-rpc requests
will arrive.
- Clients should expect to receive msgpack-rpc requests, which need to be
handled immediately because Nvim is blocked while waiting for the client
response.
- Clients should expect to receive msgpack-rpc notifications, but these don't
- need to be handled immediately because they won't block Nvim (though you
- probably want to handle them immediately anyway).
-
+ need to be handled immediately because they won't block Nvim (although they
+ should probably be handled immediately anyway).
Most of the complexity could be handled by a msgpack-rpc library that supports
-server->client requests and notifications, but it's not clear if this is part
+server to client requests and notifications, but it's not clear if this is part
of the msgpack-rpc spec. At least the ruby msgpack-rpc library does not seem
to support it:
https://github.com/msgpack-rpc/msgpack-rpc-ruby/blob/master/lib/msgpack/rpc/transport/tcp.rb#L150-L158
@@ -217,7 +215,7 @@ that makes this task easier:
- Methods that operate instances of Nvim's types are prefixed with the type
name in lower case, e.g. `buffer_get_line` represents the `get_line` method
of a Buffer instance.
-- Global methods are prefixed with `vim`, e.g.`vim_list_buffers`.
+- Global methods are prefixed with `vim`, e.g. `vim_list_buffers`.
So, for an object-oriented language, a client library would have the classes
that represent Nvim's types, and the methods of each class could be defined
@@ -227,13 +225,13 @@ class with methods mapped to functions prefixed with `vim_`
==============================================================================
7. Vimscript functions *msgpack-rpc-vim-functions*
-Four functions related to msgpack-rpc are available to vimscript:
+Four functions related to msgpack-rpc are available in vimscript:
1. |rpcstart()|: Similarly to |jobstart()|, this will spawn a co-process with
its standard handles connected to Nvim. The difference is that it's not
- possible to process raw data to/from the process stdin/stdout/stderr (since
- the job's stdin/stdout combo are used as a msgpack channel that is
- processed directly by Nvim C code).
+ possible to process raw data to/from the process's stdin/stdout/stderr.
+ This is because the job's stdin and stdout are used as a single msgpack
+ channel that is processed directly by Nvim.
2. |rpcstop()|: Same as |jobstop()|, but operates on handles returned by
|rpcstart()|.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 6e097fc040..8152c3d3c4 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -1,4 +1,4 @@
-*options.txt* For Vim version 7.4. Last change: 2014 Aug 09
+*options.txt* For Vim version 7.4. Last change: 2014 Sep 09
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -3300,7 +3300,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.
*'grepformat'* *'gfm'*
-'grepformat' 'gfm' string (default "%f:%l%m,%f %l%m")
+'grepformat' 'gfm' string (default "%f:%l:%m,%f:%l%m,%f %l%m")
global
{not in Vi}
Format to recognize for the ":grep" command output.
@@ -4935,9 +4935,8 @@ A jump table for the options with a short description can be found at |Q_op|.
global
{not in Vi}
Enable the use of the mouse. Only works for certain terminals
- (xterm, MS-DOS, Win32 |win32-mouse|, QNX pterm, *BSD console with
- sysmouse and Linux console with gpm). For using the mouse in the
- GUI, see |gui-mouse|.
+ (xterm, Win32 |win32-mouse|, *BSD console with sysmouse and Linux
+ console with gpm). For using the mouse in the GUI, see |gui-mouse|.
The mouse can be enabled for different modes:
n Normal mode
v Visual mode
@@ -7402,8 +7401,6 @@ A jump table for the options with a short description can be found at |Q_op|.
rather complex sequence, starting with "<Esc>[".
This is also available for an Xterm, if it was
configured with "--enable-dec-locator".
- *pterm-mouse*
- pterm QNX pterm mouse handling.
*urxvt-mouse*
urxvt Mouse handling for the urxvt (rxvt-unicode) terminal.
The mouse works only if the terminal supports this
@@ -7601,6 +7598,7 @@ A jump table for the options with a short description can be found at |Q_op|.
fold options
options options and mappings local to a window or buffer (not
global values for local options)
+ localoptions same as "options"
slash backslashes in file names replaced with forward
slashes
unix with Unix end-of-line format (single <NL>), even when
diff --git a/runtime/doc/os_win32.txt b/runtime/doc/os_win32.txt
index 2c25850116..14e524e319 100644
--- a/runtime/doc/os_win32.txt
+++ b/runtime/doc/os_win32.txt
@@ -1,4 +1,4 @@
-*os_win32.txt* For Vim version 7.4. Last change: 2012 May 18
+*os_win32.txt* For Vim version 7.4. Last change: 2014 Aug 29
VIM REFERENCE MANUAL by George Reilly
diff --git a/runtime/doc/pattern.txt b/runtime/doc/pattern.txt
index f66ac170ae..322811b7cf 100644
--- a/runtime/doc/pattern.txt
+++ b/runtime/doc/pattern.txt
@@ -1,4 +1,4 @@
-*pattern.txt* For Vim version 7.4. Last change: 2014 Jul 30
+*pattern.txt* For Vim version 7.4. Last change: 2014 Sep 06
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -829,6 +829,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
branch is used. Example: >
/\(.\{-}\zsFab\)\{3}
< Finds the third occurrence of "Fab".
+ This cannot be followed by a multi. *E888*
{not in Vi} {not available when compiled without the |+syntax| feature}
*/\ze*
\ze Matches at any position, and sets the end of the match there: The
@@ -837,6 +838,7 @@ $ At end of pattern or in front of "\|", "\)" or "\n" ('magic' on):
branch is used.
Example: "end\ze\(if\|for\)" matches the "end" in "endif" and
"endfor".
+ This cannot be followed by a multi. |E888|
{not in Vi} {not available when compiled without the |+syntax| feature}
*/\%^* *start-of-file*
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 35ea3ad7bc..5cd4bd5447 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1,4 +1,4 @@
-*syntax.txt* For Vim version 7.4. Last change: 2014 Jun 27
+*syntax.txt* For Vim version 7.4. Last change: 2014 Sep 09
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -501,7 +501,7 @@ inserted for that purpose if no line numbers are shown. This ID attribute
takes the form of L123 for single-buffer HTML pages, or W2L123 for diff-view
pages, and is used to jump to a specific line (in a specific window of a diff
view). Javascript is inserted to open any closed dynamic folds
-(|g:html_dynamic_folds|) containing the specificed line before jumping. The
+(|g:html_dynamic_folds|) containing the specified line before jumping. The
javascript also allows omitting the window ID in the url, and the leading L.
For example: >
@@ -2975,6 +2975,7 @@ TEX *tex.vim* *ft-tex-syntax* *latex-syntax*
Tex: Taking Advantage of Conceal Mode |tex-conceal|
Tex: Selective Conceal Mode |g:tex_conceal|
Tex: Controlling iskeyword |g:tex_isk|
+ Tex: Fine Subscript and Superscript Control |tex-supersub|
*tex-folding* *g:tex_fold_enabled*
Tex: Want Syntax Folding? ~
@@ -3068,6 +3069,7 @@ selectively to enable just some syntax highlighting: >
<
As an example, let g:tex_fast= "M" will allow math-associated highlighting
but suppress all the other region-based syntax highlighting.
+(also see: |g:tex_conceal| and |tex-supersub|)
*tex-morecommands* *tex-package*
Tex: Want To Highlight More Commands? ~
@@ -3169,6 +3171,28 @@ syntax highlighting script handles this with the following logic:
* If g:tex_isk exists, then it will be used for the local 'iskeyword'
* Else the local 'iskeyword' will be set to 48-57,a-z,A-Z,192-255
+ *tex-supersub* *g:tex_superscripts* *g:tex_subscripts*
+ Tex: Fine Subscript and Superscript Control~
+
+ See |tex-conceal| for how to enable concealed character replacement.
+
+ See |g:tex_conceal| for selectively concealing accents, bold/italic,
+ math, Greek, and superscripts/subscripts.
+
+ One may exert fine control over which superscripts and subscripts one
+ wants syntax-based concealment for (see |:syn-cchar|). Since not all
+ fonts support all characters, one may override the
+ concealed-replacement lists; by default these lists are given by: >
+
+ let g:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]"
+ let g:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]"
+<
+ For example, I use Luxi Mono Bold; it doesn't support subscript
+ characters for "hklmnpst", so I put >
+ let g:tex_subscripts= "[0-9aeijoruvx,+-/().]"
+< in ~/.vim/ftplugin/tex/tex.vim in order to avoid having inscrutable
+ utf-8 glyphs appear.
+
TF *tf.vim* *ft-tf-syntax*
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index e4ac9a55a9..2d5a89ce8e 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt* For Vim version 7.4. Last change: 2014 Aug 23
+*todo.txt* For Vim version 7.4. Last change: 2014 Sep 09
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -58,30 +58,27 @@ Patch to make getregtype() return the right size for non-linux systems.
(Yasuhiro Matsumoto, 2014 Jul 8)
Breaks test_eval. Inefficient, can we only compute y_width when needed?
-Patch to fix a problem with breakindent. (Christian Brabandt, 2014 Aug 17)
-It's actually not a breakindent problem. With test: Aug 19.
-With renamed test: Aug 20
-
Problem that a previous silent ":throw" causes a following try/catch not to
work. (ZyX, 2013 Sep 28)
-ml_get error when using Python, issue 248.
-
-Patch to fix typos in help files. (Dominique, 2014 Aug 9)
-
-Way to reproduce problem that characters are put on the screen twice in Insert
-mode when using system(). (Jacob Niehus, 2014 Aug 9)
-Related to setting TMODE_COOK. Perhaps we can omit that for system()?
-
Update for Romanian spell file. (Vanilla Ice, 2014 Aug 13)
+Still produces errors.
+Add flag to ignore fifth argument of SFX.
+Conversion from utf-8 to cp1250 can't be without errors.
Patch to remove ETO_IGNORELANGUAGE, it causes Chinese characters not to show
up. (Paul Moore, 2014 Jul 30)
Should it depend on the Windows version? Waiting for feedback.
No longer needed after including DirectX patch?
+Related to issue 255?
+
+Problem with linebreak, adds a test that fails. (Nazri Ramliy, 2014 Sep 6)
+
+Patch to avoid problems with encoding conversion with diff.vim.
+(Yasuhiro Matsumoto, 2014 Sep 1.
Patch by Marcin Szamotulski to add count to :close (2014 Aug 10, update Aug
-14)
+14, Aug 30)
Make ":1close" close the first window.
Make ":+1close" close the next window.
Make ":-1close" close the previous window.
@@ -89,9 +86,16 @@ Can't easily close the help window, like ":pc" closes the preview window and
":ccl" closes the quickfix window. Add ":hclose". (Chris Gaal)
Patch for :helpclose, Christian Brabandt, 2010 Sep 6.
+Patch to fix line formatting bug. (Christian Brabandt, 2014 Sep 7)
+
+Patch to fix ml_get error. (Christian Brabandt, 2014 Sep 7)
+
Patch by Marcin Szamotulski to add +cmd to buffer commands.
(2014 Aug 18)
+Patch to fix encoding of arguments when setting 'encoding'. (Yasuhiro
+Matsumoto, 2014 Sep 4)
+
Patch to fix that system() with empty input fails. (Olaf Dabrunz, 2014 Aug 19)
When using a visual selection of multiple words and doing CTRL-W_] it jumps to
@@ -104,6 +108,8 @@ Completion for :buf does not use 'wildignorecase'. (Akshay H, 2014 May 31)
Patch to handle list with some items locked. (ZyX, 2014 Aug 17)
Prefer the second solution.
+Issue 252. Patch by Christian, 2014 Aug 26.
+
":cd C:\Windows\System32\drivers\etc*" does not work, even though the
directory exists. (Sergio Gallelli, 2013 Dec 29)
@@ -118,13 +124,16 @@ Problem using ":try" inside ":execute". (ZyX, 2013 Sep 15)
Python: ":py raw_input('prompt')" doesn't work. (Manu Hack)
Value returned by virtcol() changes depending on how lines wrap. This is
-inconsistant with the documentation.
+inconsistent with the documentation.
MS-Windows: Crash opening very long file name starting with "\\".
(Christian Brock, 2012 Jun 29)
Syntax highlighting slow (hangs) in SASS file. (Niek Bosch, 2013 Aug 21)
+Patch to allow for a different icon on MS-Windows. (Yasuhiro Matsumoto, 2014
+Sep 7).
+
Adding "~" to 'cdpath' doesn't work for completion? (Davido, 2013 Aug 19)
"hi link" does not respect groups with GUI settings only. (Mark Lodato, 2014
@@ -141,20 +150,18 @@ Spell files use a latin single quote. Unicode also has another single quote:
New OpenOffice spell files support this with ICONV. But they are not
compatible with Vim spell files. The old files can no longer be downloaded.
-Win32: use different args for SearchPath()? (Yasuhiro Matsumoto, 2009 Jan 30)
-Also fixes wrong result from executable().
-Update from Ken Takata, 2014 Jan 10. Newer 2014 Apr 3.
-
Win32: patch to use 64 bit stat() if possible. (Ken Takata, 2014 May 12)
More tests May 14. Update May 29. Update Aug 10.
The garbage collector may use too much stack. Make set_ref_in_item()
iterative instead of recursive. Test program by Marc Weber (2013 Dec 10)
Patch by Ben Fritz, 2014 Jun 22.
+Related: Vim hangs when freeing a lot of objects. Patch by Yasuhiro
+Matsumoto, 2014 Aug 26.
Idea: For a window in the middle (has window above and below it), use
right-mouse-drag on the status line to move a window up/down without changing
-it's height? It's like dragging the status bar above it at the same time.
+its height? It's like dragging the status bar above it at the same time.
Can we make ":unlet $VAR" use unsetenv() to delete the env var?
What for systems that don't have unsetenv()?
@@ -236,7 +243,7 @@ Or should we add a more general mechanism, like lambda functions?
Patch for XDG base directory support. (Jean François Bignolles, 2014 Mar 4)
Remark on the docs. Should not be a compile time feature. But then what?
-Completion of ":e" is ":earlier", whould be ":edit". Complete to the matching
+Completion of ":e" is ":earlier", should be ":edit". Complete to the matching
command instead of doing this alphabetically. (Mikel Jorgensen)
Patch to add v:completed_item. (Shougo Matsu, 2013 Nov 29).
@@ -262,9 +269,6 @@ possible. (Christian Brabandt, 2014 Mar 12, update Aug 22)
Updated spec ftplugin. (Matěj Cepl, 2013 Oct 16)
-Some quickfix messages appear twice. (Gary Johnson, 2014 Feb 16)
-Patch by Christian Brabandt, 2014 Feb 17.
-
Patch to right-align signs. (James Kolb (email james), 2013 Sep 23)
Patch to handle integer overflow. (Aaron Burrow, 2013 Dec 12)
@@ -1437,8 +1441,8 @@ files with "foo/**" in 'path'. (Kalisiak, 2006 July 15)
Additional info: When using the |wildcards| ** globing, vim hangs
indefinitely on lots of directories. The |file-searching| globing, like in
":set path=/**" does not hang as often as with globing with |wildcards|, like
-in ":1find /**/file". This is for a files that unix "find" can find very
-quick. Merging the 2 kinds of globing might make this an easier fix. (Ian
+in ":1find /**/file". This is for files that unix "find" can find very
+quickly. Merging the 2 kinds of globing might make this an easier fix. (Ian
Kelling, 2008 July 4)
When the file name has parenthesis, e.g., "foo (bar).txt", ":!ls '%'" has the
@@ -1886,6 +1890,10 @@ restored. (Luc St-Louis)
Patch to support horizontal scroll wheel in GTK. Untested. (Bjorn Winckler,
2010 Jun 30)
+Add an option for a minimal text length before inserting a line break for
+'textwidth'. Avoids very short lines when a very long word follows.
+(Kartik Agaram)
+
At next release:
- Build a huge version by default.
diff --git a/runtime/doc/usr_04.txt b/runtime/doc/usr_04.txt
index c09cb204c5..5f24c8c6f5 100644
--- a/runtime/doc/usr_04.txt
+++ b/runtime/doc/usr_04.txt
@@ -1,4 +1,4 @@
-*usr_04.txt* For Vim version 7.4. Last change: 2008 Sep 06
+*usr_04.txt* For Vim version 7.4. Last change: 2014 Aug 29
VIM USER MANUAL - by Bram Moolenaar
@@ -186,7 +186,7 @@ commands:
/four<Enter> find the first string "four"
cwfive<Esc> change the word to "five"
n find the next "four"
- . repeat the change to "five'
+ . repeat the change to "five"
n find the next "four"
. repeat the change
etc.
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 40ccee960d..3fc109ac0d 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2014 Aug 23
+" Last Change: 2014 Sep 05
" Listen very carefully, I will say this only once
if exists("did_load_filetypes")
@@ -526,6 +526,9 @@ au BufNewFile,BufRead configure.in,configure.ac setf config
" CUDA Cumpute Unified Device Architecture
au BufNewFile,BufRead *.cu setf cuda
+" Dockerfile
+au BufNewFile,BufRead Dockerfile setf dockerfile
+
" WildPackets EtherPeek Decoder
au BufNewFile,BufRead *.dcd setf dcd
@@ -1097,6 +1100,9 @@ au BufNewFile,BufRead *.lou,*.lout setf lout
" Lua
au BufNewFile,BufRead *.lua setf lua
+" Luarocks
+au BufNewFile,BufRead *.rockspec setf lua
+
" Linden Scripting Language (Second Life)
au BufNewFile,BufRead *.lsl setf lsl
diff --git a/runtime/ftplugin/dockerfile.vim b/runtime/ftplugin/dockerfile.vim
new file mode 100644
index 0000000000..2e3c447b59
--- /dev/null
+++ b/runtime/ftplugin/dockerfile.vim
@@ -0,0 +1,16 @@
+" Vim filetype plugin
+" Language: Dockerfile
+" Maintainer: Honza Pokorny <http://honza.ca>
+" Last Change: 2014 Aug 29
+
+" Only do this when not done yet for this buffer
+if exists("b:did_ftplugin")
+ finish
+endif
+
+" Don't load another plugin for this buffer
+let b:did_ftplugin = 1
+
+let b:undo_ftplugin = "setl commentstring<"
+
+setlocal commentstring=#\ %s
diff --git a/runtime/ftplugin/vim.vim b/runtime/ftplugin/vim.vim
index edba37b896..f355d2837d 100644
--- a/runtime/ftplugin/vim.vim
+++ b/runtime/ftplugin/vim.vim
@@ -1,7 +1,7 @@
" Vim filetype plugin
" Language: Vim
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2013 Jun 26
+" Last Change: 2014 Sep 07
" Only do this when not done yet for this buffer
if exists("b:did_ftplugin")
@@ -62,9 +62,12 @@ if exists("loaded_matchit")
\ '\<try\>:\<cat\%[ch]\>:\<fina\%[lly]\>:\<endt\%[ry]\>,' .
\ '\<aug\%[roup]\s\+\%(END\>\)\@!\S:\<aug\%[roup]\s\+END\>,' .
\ '(:)'
- " Ignore ":syntax region" commands, the 'end' argument clobbers if-endif
- let b:match_skip = 'getline(".") =~ "^\\s*sy\\%[ntax]\\s\\+region" ||
- \ synIDattr(synID(line("."),col("."),1),"name") =~? "comment\\|string"'
+ " Ignore syntax region commands and settings, any 'en*' would clobber
+ " if-endif.
+ " - set spl=de,en
+ " - au! FileType javascript syntax region foldBraces start=/{/ end=/}/ …
+ let b:match_skip = 'synIDattr(synID(line("."),col("."),1),"name")
+ \ =~? "comment\\|string\\|vimSynReg\\|vimSet"'
endif
let &cpo = s:cpo_save
diff --git a/runtime/indent/json.vim b/runtime/indent/json.vim
index d50112b934..649f2b8aa5 100644
--- a/runtime/indent/json.vim
+++ b/runtime/indent/json.vim
@@ -1,13 +1,168 @@
" Vim indent file
" Language: JSON
-" Maintainer: David Barnett <daviebdawg+vim@gmail.com>
-" Last Change: 2014 Jul 16
+" Mantainer: Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
+" Last Change: 2014 Aug 29
+" https://github.com/jakar/vim-json/commit/20b650e22aa750c4ab6a66aa646bdd95d7cd548a#diff-e81fc111b2052e306d126bd9989f7b7c
+" Original Author: Rogerz Zhang <rogerz.zhang at gmail.com> http://github.com/rogerz/vim-json
+" Acknowledgement: Based off of vim-javascript maintained by Darrick Wiebe
+" http://www.vim.org/scripts/script.php?script_id=2765
-if exists('b:did_indent')
- finish
+" 0. Initialization {{{1
+" =================
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
endif
+let b:did_indent = 1
-" JSON is a subset of JavaScript. JavaScript indenting should work fine.
-runtime! indent/javascript.vim
+setlocal nosmartindent
-let b:did_indent = 1
+" Now, set up our indentation expression and keys that trigger it.
+setlocal indentexpr=GetJSONIndent()
+setlocal indentkeys=0{,0},0),0[,0],!^F,o,O,e
+
+" Only define the function once.
+if exists("*GetJSONIndent")
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" 1. Variables {{{1
+" ============
+
+let s:line_term = '\s*\%(\%(\/\/\).*\)\=$'
+" Regex that defines blocks.
+let s:block_regex = '\%({\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term
+
+" 2. Auxiliary Functions {{{1
+" ======================
+
+" Check if the character at lnum:col is inside a string.
+function s:IsInString(lnum, col)
+ return synIDattr(synID(a:lnum, a:col, 1), 'name') == 'jsonString'
+endfunction
+
+" Find line above 'lnum' that isn't empty, or in a string.
+function s:PrevNonBlankNonString(lnum)
+ let lnum = prevnonblank(a:lnum)
+ while lnum > 0
+ " If the line isn't empty or in a string, end search.
+ let line = getline(lnum)
+ if !(s:IsInString(lnum, 1) && s:IsInString(lnum, strlen(line)))
+ break
+ endif
+ let lnum = prevnonblank(lnum - 1)
+ endwhile
+ return lnum
+endfunction
+
+" Check if line 'lnum' has more opening brackets than closing ones.
+function s:LineHasOpeningBrackets(lnum)
+ let open_0 = 0
+ let open_2 = 0
+ let open_4 = 0
+ let line = getline(a:lnum)
+ let pos = match(line, '[][(){}]', 0)
+ while pos != -1
+ let idx = stridx('(){}[]', line[pos])
+ if idx % 2 == 0
+ let open_{idx} = open_{idx} + 1
+ else
+ let open_{idx - 1} = open_{idx - 1} - 1
+ endif
+ let pos = match(line, '[][(){}]', pos + 1)
+ endwhile
+ return (open_0 > 0) . (open_2 > 0) . (open_4 > 0)
+endfunction
+
+function s:Match(lnum, regex)
+ let col = match(getline(a:lnum), a:regex) + 1
+ return col > 0 && !s:IsInString(a:lnum, col) ? col : 0
+endfunction
+
+" 3. GetJSONIndent Function {{{1
+" =========================
+
+function GetJSONIndent()
+ " 3.1. Setup {{{2
+ " ----------
+
+ " Set up variables for restoring position in file. Could use v:lnum here.
+ let vcol = col('.')
+
+ " 3.2. Work on the current line {{{2
+ " -----------------------------
+
+ " Get the current line.
+ let line = getline(v:lnum)
+ let ind = -1
+
+ " If we got a closing bracket on an empty line, find its match and indent
+ " according to it.
+ let col = matchend(line, '^\s*[]}]')
+
+ if col > 0 && !s:IsInString(v:lnum, col)
+ call cursor(v:lnum, col)
+ let bs = strpart('{}[]', stridx('}]', line[col - 1]) * 2, 2)
+
+ let pairstart = escape(bs[0], '[')
+ let pairend = escape(bs[1], ']')
+ let pairline = searchpair(pairstart, '', pairend, 'bW')
+
+ if pairline > 0
+ let ind = indent(pairline)
+ else
+ let ind = virtcol('.') - 1
+ endif
+
+ return ind
+ endif
+
+ " If we are in a multi-line string, don't do anything to it.
+ if s:IsInString(v:lnum, matchend(line, '^\s*') + 1)
+ return indent('.')
+ endif
+
+ " 3.3. Work on the previous line. {{{2
+ " -------------------------------
+
+ let lnum = prevnonblank(v:lnum - 1)
+
+ if lnum == 0
+ return 0
+ endif
+
+ " Set up variables for current line.
+ let line = getline(lnum)
+ let ind = indent(lnum)
+
+ " If the previous line ended with a block opening, add a level of indent.
+ " if s:Match(lnum, s:block_regex)
+ " return indent(lnum) + &sw
+ " endif
+
+ " If the previous line contained an opening bracket, and we are still in it,
+ " add indent depending on the bracket type.
+ if line =~ '[[({]'
+ let counts = s:LineHasOpeningBrackets(lnum)
+ if counts[0] == '1' || counts[1] == '1' || counts[2] == '1'
+ return ind + &sw
+ else
+ call cursor(v:lnum, vcol)
+ end
+ endif
+
+ " }}}2
+
+ return ind
+endfunction
+
+" }}}1
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
+
+" vim:set sw=2 sts=2 ts=8 noet:
diff --git a/runtime/scripts.vim b/runtime/scripts.vim
index 93206b8e6e..b62b0a5db8 100644
--- a/runtime/scripts.vim
+++ b/runtime/scripts.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types in scripts
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last change: 2013 May 24
+" Last change: 2014 Aug 24
" This file is called by an autocommand for every file that has just been
" loaded into a buffer. It checks if the type of file can be recognized by
@@ -314,6 +314,10 @@ else
elseif s:line1 =~ '^==\d\+== valgrind' || s:line3 =~ '^==\d\+== Using valgrind'
set ft=valgrind
+ " Go docs
+ elseif s:line1 =~ '^PACKAGE DOCUMENTATION$'
+ set ft=godoc
+
" Renderman Interface Bytestream
elseif s:line1 =~ '^##RenderMan'
set ft=rib
diff --git a/runtime/syntax/asciidoc.vim b/runtime/syntax/asciidoc.vim
index 1303db7cf2..ccb079e06b 100644
--- a/runtime/syntax/asciidoc.vim
+++ b/runtime/syntax/asciidoc.vim
@@ -5,6 +5,7 @@
" URL: http://asciidoc.org/
" Licence: GPL (http://www.gnu.org)
" Remarks: Vim 6 or greater
+" Last Update: 2014 Aug 29 (see Issue 240)
" Limitations:
"
" - Nested quoted text formatting is highlighted according to the outer
@@ -155,7 +156,8 @@ hi def link asciidocQuotedAttributeList Special
hi def link asciidocQuotedBold Special
hi def link asciidocQuotedDoubleQuoted Label
hi def link asciidocQuotedEmphasized2 Type
-hi def link asciidocQuotedEmphasized Type
+hi asciidocQuotedEmphasizedItalic term=italic cterm=italic gui=italic
+hi def link asciidocQuotedEmphasized asciidocQuotedEmphasizedItalic
hi def link asciidocQuotedMonospaced2 Identifier
hi def link asciidocQuotedMonospaced Identifier
hi def link asciidocQuotedSingleQuoted Label
diff --git a/runtime/syntax/dockerfile.vim b/runtime/syntax/dockerfile.vim
new file mode 100644
index 0000000000..d1693cba41
--- /dev/null
+++ b/runtime/syntax/dockerfile.vim
@@ -0,0 +1,24 @@
+" dockerfile.vim - Syntax highlighting for Dockerfiles
+" Maintainer: Honza Pokorny <http://honza.ca>
+" Version: 0.5
+" Last Change: 2014 Aug 29
+" License: BSD
+
+
+if exists("b:current_syntax")
+ finish
+endif
+
+let b:current_syntax = "dockerfile"
+
+syntax case ignore
+
+syntax match dockerfileKeyword /\v^\s*(ONBUILD\s+)?(ADD|CMD|ENTRYPOINT|ENV|EXPOSE|FROM|MAINTAINER|RUN|USER|VOLUME|WORKDIR|COPY)\s/
+
+syntax region dockerfileString start=/\v"/ skip=/\v\\./ end=/\v"/
+
+syntax match dockerfileComment "\v^\s*#.*$"
+
+hi def link dockerfileString String
+hi def link dockerfileKeyword Keyword
+hi def link dockerfileComment Comment
diff --git a/runtime/syntax/tex.vim b/runtime/syntax/tex.vim
index 31114bc093..3f719e8244 100644
--- a/runtime/syntax/tex.vim
+++ b/runtime/syntax/tex.vim
@@ -1,8 +1,8 @@
" Vim syntax file
" Language: TeX
" Maintainer: Charles E. Campbell <NdrchipO@ScampbellPfamily.AbizM>
-" Last Change: Mar 20, 2014
-" Version: 81
+" Last Change: Sep 09, 2014
+" Version: 82
" URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_TEX
"
" Notes: {{{1
@@ -88,6 +88,12 @@ if !exists("g:tex_conceal")
else
let s:tex_conceal= g:tex_conceal
endif
+if !exists("g:tex_superscripts")
+ let g:tex_superscripts= "[0-9a-zA-W.,:;+-<>/()=]"
+endif
+if !exists("g:tex_subscripts")
+ let g:tex_subscripts= "[0-9aehijklmnoprstuvx,+-/().]"
+endif
" Determine whether or not to use "*.sty" mode {{{1
" The user may override the normal determination by setting
@@ -331,22 +337,22 @@ syn match texSpaceCodeChar "`\\\=.\(\^.\)\==\(\d\|\"\x\{1,6}\|`.\)" contained
if s:tex_fast =~ 'p'
if !exists("g:tex_nospell") || !g:tex_nospell
if g:tex_fold_enabled && has("folding")
- syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
+ syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup,@Spell
syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup,@Spell
syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup,@Spell
syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup,@Spell
- syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
+ syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup,@Spell
syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texParaGroup,@Spell
syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@Spell
syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup,@Spell
syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup,@Spell
else
- syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
+ syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup,@Spell
syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup,@Spell
syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup,@Spell
syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup,@Spell
- syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
+ syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup,@Spell
syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup,@Spell
syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup,@Spell
syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@Spell
@@ -355,22 +361,22 @@ if s:tex_fast =~ 'p'
endif
else
if g:tex_fold_enabled && has("folding")
- syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup
+ syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' fold contains=@texFoldGroup,@texDocGroup
syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texPartGroup
syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texChapterGroup
syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSectionGroup
- syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup
+ syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSectionGroup
syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texSubSubSectionGroup
syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup,@texParaGroup
syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' fold contains=@texFoldGroup
syn region texTitle matchgroup=texSection start='\\\%(author\|title\)\>\s*{' end='}' fold contains=@texFoldGroup
syn region texAbstract matchgroup=texSection start='\\begin\s*{\s*abstract\s*}' end='\\end\s*{\s*abstract\s*}' fold contains=@texFoldGroup
else
- syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup
+ syn region texDocZone matchgroup=texSection start='\\begin\s*{\s*document\s*}' end='\\end\s*{\s*document\s*}' contains=@texFoldGroup,@texDocGroup
syn region texPartZone matchgroup=texSection start='\\part\>' end='\ze\s*\\\%(part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texPartGroup
syn region texChapterZone matchgroup=texSection start='\\chapter\>' end='\ze\s*\\\%(chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texChapterGroup
syn region texSectionZone matchgroup=texSection start='\\section\>' end='\ze\s*\\\%(section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSectionGroup
- syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup
+ syn region texSubSectionZone matchgroup=texSection start='\\subsection\>' end='\ze\s*\\\%(\%(sub\)\=section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSectionGroup
syn region texSubSubSectionZone matchgroup=texSection start='\\subsubsection\>' end='\ze\s*\\\%(\%(sub\)\{,2}section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texSubSubSectionGroup
syn region texParaZone matchgroup=texSection start='\\paragraph\>' end='\ze\s*\\\%(paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup,@texParaGroup
syn region texSubParaZone matchgroup=texSection start='\\subparagraph\>' end='\ze\s*\\\%(\%(sub\)\=paragraph\>\|\%(sub\)*section\>\|chapter\>\|part\>\|end\s*{\s*document\s*}\)' contains=@texFoldGroup
@@ -620,7 +626,7 @@ if s:tex_fast =~ 'r'
syn region texRefZone matchgroup=texStatement start="\\\(page\|eq\)ref{" end="}\|%stopzone\>" contains=@texRefGroup
syn region texRefZone matchgroup=texStatement start="\\v\=ref{" end="}\|%stopzone\>" contains=@texRefGroup
syn region texRefOption contained matchgroup=Delimiter start='\[' end=']' contains=@texRefGroup,texRefZone nextgroup=texRefOption,texCite
- syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite
+ syn region texCite contained matchgroup=Delimiter start='{' end='}' contains=@texRefGroup,texRefZone,texCite
endif
syn match texRefZone '\\cite\%([tp]\*\=\)\=' nextgroup=texRefOption,texCite
@@ -1045,8 +1051,11 @@ if has("conceal") && &enc == 'utf-8'
syn region texSubscript matchgroup=Delimiter start='_{' skip="\\\\\|\\[{}]" end='}' contained concealends contains=texSpecialChar,texSubscripts,texStatement,texSubscript,texSuperscript,texMathMatcher
endif
fun! s:SuperSub(group,leader,pat,cchar)
- exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
- exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
+ if a:pat =~ '^\\' || (a:leader == '\^' && a:pat =~ g:tex_superscripts) || (a:leader == '_' && a:pat =~ g:tex_subscripts)
+" call Decho("SuperSub: group<".a:group."> leader<".a:leader."> pat<".a:pat."> cchar<".a:cchar.">")
+ exe 'syn match '.a:group." '".a:leader.a:pat."' contained conceal cchar=".a:cchar
+ exe 'syn match '.a:group."s '".a:pat."' contained conceal cchar=".a:cchar.' nextgroup='.a:group.'s'
+ endif
endfun
call s:SuperSub('texSuperscript','\^','0','⁰')
call s:SuperSub('texSuperscript','\^','1','¹')
@@ -1170,44 +1179,44 @@ if has("conceal") && &enc == 'utf-8'
let i= i + 1
endfor
endfun
- " \` \' \^ \" \~ \. \= \c \H \k \r \u \v
- call s:Accents('a','à','á','â','ä','ã','ȧ','ā',' ',' ','ą','å','ă','ǎ')
- call s:Accents('A','À','Á','Â','Ä','Ã','Ȧ','Ā',' ',' ','Ą','Å','Ă','Ǎ')
- call s:Accents('c',' ','ć','ĉ',' ',' ','ċ',' ','ç',' ',' ',' ',' ','č')
- call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ',' ','Ç',' ',' ',' ',' ','Č')
- call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
- call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
- call s:Accents('e','è','é','ê','ë','ẽ','ė','ē','ȩ',' ','ę',' ','ĕ','ě')
- call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ē','Ȩ',' ','Ę',' ','Ĕ','Ě')
- call s:Accents('g',' ','ǵ','ĝ',' ',' ','ġ',' ','ģ',' ',' ',' ','ğ','ǧ')
- call s:Accents('G',' ','Ǵ','Ĝ',' ',' ','Ġ',' ','Ģ',' ',' ',' ','Ğ','Ǧ')
- call s:Accents('h',' ',' ','ĥ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ȟ')
- call s:Accents('H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ȟ')
- call s:Accents('i','ì','í','î','ï','ĩ','į','ī',' ',' ','į',' ','ĭ','ǐ')
- call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ','Ī',' ',' ','Į',' ','Ĭ','Ǐ')
- call s:Accents('J',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ǰ')
- call s:Accents('k',' ',' ',' ',' ',' ',' ',' ','ķ',' ',' ',' ',' ','ǩ')
- call s:Accents('K',' ',' ',' ',' ',' ',' ',' ','Ķ',' ',' ',' ',' ','Ǩ')
- call s:Accents('l',' ','ĺ','ľ',' ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
- call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
- call s:Accents('n',' ','ń',' ',' ','ñ',' ',' ','ņ',' ',' ',' ',' ','ň')
- call s:Accents('N',' ','Ń',' ',' ','Ñ',' ',' ','Ņ',' ',' ',' ',' ','Ň')
- call s:Accents('o','ò','ó','ô','ö','õ','ȯ','ō',' ','ő','ǫ',' ','ŏ','ǒ')
- call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ','Ō',' ','Ő','Ǫ',' ','Ŏ','Ǒ')
- call s:Accents('r',' ','ŕ',' ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
- call s:Accents('R',' ','Ŕ',' ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
- call s:Accents('s',' ','ś','ŝ',' ',' ',' ',' ','ş',' ','ȿ',' ',' ','š')
- call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
- call s:Accents('t',' ',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
- call s:Accents('T',' ',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
- call s:Accents('u','ù','ú','û','ü','ũ',' ','ū',' ','ű','ų','ů','ŭ','ǔ')
- call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ','Ū',' ','Ű','Ų','Ů','Ŭ','Ǔ')
- call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
- call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
- call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
- call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
- call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ',' ','ž')
- call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ',' ','Ž')
+ " \` \' \^ \" \~ \. \= \c \H \k \r \u \v
+ call s:Accents('a','à','á','â','ä','ã','ȧ','ā',' ',' ','ą','å','ă','ǎ')
+ call s:Accents('A','À','Á','Â','Ä','Ã','Ȧ','Ā',' ',' ','Ą','Å','Ă','Ǎ')
+ call s:Accents('c',' ','ć','ĉ',' ',' ','ċ',' ','ç',' ',' ',' ',' ','č')
+ call s:Accents('C',' ','Ć','Ĉ',' ',' ','Ċ',' ','Ç',' ',' ',' ',' ','Č')
+ call s:Accents('d',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ď')
+ call s:Accents('D',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ď')
+ call s:Accents('e','è','é','ê','ë','ẽ','ė','ē','ȩ',' ','ę',' ','ĕ','ě')
+ call s:Accents('E','È','É','Ê','Ë','Ẽ','Ė','Ē','Ȩ',' ','Ę',' ','Ĕ','Ě')
+ call s:Accents('g',' ','ǵ','ĝ',' ',' ','ġ',' ','ģ',' ',' ',' ','ğ','ǧ')
+ call s:Accents('G',' ','Ǵ','Ĝ',' ',' ','Ġ',' ','Ģ',' ',' ',' ','Ğ','Ǧ')
+ call s:Accents('h',' ',' ','ĥ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ȟ')
+ call s:Accents('H',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Ȟ')
+ call s:Accents('i','ì','í','î','ï','ĩ','į','ī',' ',' ','į',' ','ĭ','ǐ')
+ call s:Accents('I','Ì','Í','Î','Ï','Ĩ','İ','Ī',' ',' ','Į',' ','Ĭ','Ǐ')
+ call s:Accents('J',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','ǰ')
+ call s:Accents('k',' ',' ',' ',' ',' ',' ',' ','ķ',' ',' ',' ',' ','ǩ')
+ call s:Accents('K',' ',' ',' ',' ',' ',' ',' ','Ķ',' ',' ',' ',' ','Ǩ')
+ call s:Accents('l',' ','ĺ','ľ',' ',' ',' ',' ','ļ',' ',' ',' ',' ','ľ')
+ call s:Accents('L',' ','Ĺ','Ľ',' ',' ',' ',' ','Ļ',' ',' ',' ',' ','Ľ')
+ call s:Accents('n',' ','ń',' ',' ','ñ',' ',' ','ņ',' ',' ',' ',' ','ň')
+ call s:Accents('N',' ','Ń',' ',' ','Ñ',' ',' ','Ņ',' ',' ',' ',' ','Ň')
+ call s:Accents('o','ò','ó','ô','ö','õ','ȯ','ō',' ','ő','ǫ',' ','ŏ','ǒ')
+ call s:Accents('O','Ò','Ó','Ô','Ö','Õ','Ȯ','Ō',' ','Ő','Ǫ',' ','Ŏ','Ǒ')
+ call s:Accents('r',' ','ŕ',' ',' ',' ',' ',' ','ŗ',' ',' ',' ',' ','ř')
+ call s:Accents('R',' ','Ŕ',' ',' ',' ',' ',' ','Ŗ',' ',' ',' ',' ','Ř')
+ call s:Accents('s',' ','ś','ŝ',' ',' ',' ',' ','ş',' ','ȿ',' ',' ','š')
+ call s:Accents('S',' ','Ś','Ŝ',' ',' ',' ',' ','Ş',' ',' ',' ',' ','Š')
+ call s:Accents('t',' ',' ',' ',' ',' ',' ',' ','ţ',' ',' ',' ',' ','ť')
+ call s:Accents('T',' ',' ',' ',' ',' ',' ',' ','Ţ',' ',' ',' ',' ','Ť')
+ call s:Accents('u','ù','ú','û','ü','ũ',' ','ū',' ','ű','ų','ů','ŭ','ǔ')
+ call s:Accents('U','Ù','Ú','Û','Ü','Ũ',' ','Ū',' ','Ű','Ų','Ů','Ŭ','Ǔ')
+ call s:Accents('w',' ',' ','ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
+ call s:Accents('W',' ',' ','Ŵ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ')
+ call s:Accents('y','ỳ','ý','ŷ','ÿ','ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
+ call s:Accents('Y','Ỳ','Ý','Ŷ','Ÿ','Ỹ',' ',' ',' ',' ',' ',' ',' ',' ')
+ call s:Accents('z',' ','ź',' ',' ',' ','ż',' ',' ',' ',' ',' ',' ','ž')
+ call s:Accents('Z',' ','Ź',' ',' ',' ','Ż',' ',' ',' ',' ',' ',' ','Ž')
call s:Accents('\\i','ì','í','î','ï','ĩ','į',' ',' ',' ',' ',' ','ĭ',' ')
" \` \' \^ \" \~ \. \= \c \H \k \r \u \v
delfun s:Accents
@@ -1252,7 +1261,7 @@ endif
if did_tex_syntax_inits == 1
let did_tex_syntax_inits= 2
" TeX highlighting groups which should share similar highlighting
- if !exists("s:tex_no_error")
+ if !exists("g:tex_no_error")
if !exists("g:tex_no_math")
HiLink texBadMath texError
HiLink texMathDelimBad texError
diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh
index f6b4793184..4c9a141bd2 100755
--- a/scripts/vim-patch.sh
+++ b/scripts/vim-patch.sh
@@ -7,114 +7,189 @@ NEOVIM_SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VIM_SOURCE_DIR_DEFAULT=${NEOVIM_SOURCE_DIR}/.vim-src
VIM_SOURCE_DIR="${VIM_SOURCE_DIR:-${VIM_SOURCE_DIR_DEFAULT}}"
-if [[ ${#} != 1 ]]; then
+usage() {
>&2 echo "Helper script for porting Vim patches. For more information,"
>&2 echo "see https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim."
>&2 echo
- >&2 echo "Usage: ${0} vim-revision"
+ >&2 echo "Usage: ${0} [option]"
+ >&2 echo " ${0} vim-revision"
+ >&2 echo
+ >&2 echo "Options:"
+ >&2 echo " --help Show this message."
+ >&2 echo " --list Show list of Vim patches missing from Neovim."
+ >&2 echo
>&2 echo "vim-revision can be a version number in format '7.4.xxx'"
>&2 echo "or a Mercurial commit hash."
>&2 echo
>&2 echo "Set VIM_SOURCE_DIR to change where Vim's sources are stored."
>&2 echo "The default is '${VIM_SOURCE_DIR_DEFAULT}'."
+}
+
+get_vim_sources() {
+ echo "Retrieving Vim sources."
+ if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
+ echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
+ hg clone https://code.google.com/p/vim ${VIM_SOURCE_DIR}
+ cd ${VIM_SOURCE_DIR}
+ else
+ echo "Updating Vim sources in '${VIM_SOURCE_DIR}'."
+ cd ${VIM_SOURCE_DIR}
+ hg pull --update &&
+ echo "✔ Updated Vim sources." ||
+ echo "✘ Could not update Vim sources; ignoring error."
+ fi
+}
+
+get_vim_patch() {
+ if [[ "${1}" =~ [0-9]\.[0-9]\.[0-9]{3,4} ]]; then
+ # Interpret parameter as version number.
+ vim_version="${1}"
+ vim_commit="v${1//./-}"
+ strip_commit_line=true
+ else
+ # Interpret parameter as commit hash.
+ vim_version="${1:0:7}"
+ vim_commit="${1}"
+ strip_commit_line=false
+ fi
+
+ hg log --rev ${vim_commit} >/dev/null 2>&1 || {
+ >&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
+ exit 3
+ }
+ echo
+ echo "✔ Found Vim revision '${vim_commit}'."
+
+ # Collect patch details and store into variables.
+ vim_full="$(hg log --patch --git --verbose --rev ${vim_commit})"
+ vim_message="$(hg log --template "{desc}" --rev ${vim_commit})"
+ if [[ "${strip_commit_line}" == "true" ]]; then
+ # Remove first line of commit message.
+ vim_message="$(echo "${vim_message}" | sed -e '1d')"
+ fi
+ vim_diff="$(hg diff --show-function --git --change ${vim_commit} \
+ | sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim.
+ neovim_message="
+ vim-patch:${vim_version}
+
+ ${vim_message}
+
+ https://code.google.com/p/vim/source/detail?r=${vim_commit}"
+ neovim_pr="
+ \`\`\`
+ ${vim_message}
+ \`\`\`
+
+ https://code.google.com/p/vim/source/detail?r=${vim_commit}
+
+ Original patch:
+
+ \`\`\`diff
+ ${vim_diff}
+ \`\`\`"
+ neovim_branch="vim-${vim_version}"
+
+ echo
+ echo "Creating Git branch."
+ cd ${NEOVIM_SOURCE_DIR}
+ output="$(git checkout -b "${neovim_branch}" 2>&1)" &&
+ echo "✔ ${output}" ||
+ (echo "✘ ${output}"; false)
+
+ echo
+ echo "Creating empty commit with correct commit message."
+ output="$(git commit --allow-empty --file 2>&1 - <<< "${neovim_message}")" &&
+ echo "✔ ${output}" ||
+ (echo "✘ ${output}"; false)
+
+ echo
+ echo "Creating files."
+ echo "${vim_diff}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff
+ echo "✔ Saved patch to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff'."
+ echo "${vim_full}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch
+ echo "✔ Saved full commit details to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch'."
+ echo "${neovim_pr}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr
+ echo "✔ Saved suggested PR description to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr'."
+ echo "You can use 'git clean' to remove these files when you're done."
+
+ echo
+ echo "Instructions:"
+ echo
+ echo " Proceed to port the patch."
+ echo " You might want to try 'patch -p1 < ${neovim_branch}.diff' first."
+ echo
+ echo " Stage your changes ('git add ...') and use 'git commit --amend' to commit."
+ echo
+ echo " Push your changes with 'git push origin ${neovim_branch}' and create a"
+ echo " pull request called '[RFC] vim-patch:${vim_version}'. You might want "
+ echo " to use the text in '${neovim_branch}.pr' as the description of this pull request."
+ echo
+ echo " See https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim"
+ echo " for more information."
+}
+
+list_vim_patches() {
+ echo
+ echo "Vim patches missing from Neovim:"
+
+ # Get vim patches and runtime file updates.
+ # Start from 7.4.442. The runtime was re-integrated from 7.4.384, but
+ # runtime patches before between 384 and 442 have already been ported
+ # to Neovim as of the creation of this script.
+ local vim_commits=$(cd ${VIM_SOURCE_DIR} && \
+ hg log --removed --template='{if(startswith("Added tag", firstline(desc)),
+ "{latesttag}\n",
+ "{if(startswith(\"updated for version\", firstline(desc)),
+ \"\",
+ \"{node}\n\")}")}' -r tip:v7-4-442)
+ # Append remaining vim patches.
+ # Start from 7.4.160, where Neovim was forked.
+ local vim_old_commits=$(cd ${VIM_SOURCE_DIR} && \
+ hg log --removed --template='{if(startswith("Added tag",
+ firstline(desc)),
+ "{latesttag}\n")}' -r v7-4-442:v7-4-161)
+
+ local vim_commit
+ for vim_commit in ${vim_commits} ${vim_old_commits}; do
+ local is_missing
+ if [[ "${vim_commit}" =~ v([0-9]-[0-9]-([0-9]{3,4})) ]]; then
+ local patch_number="${BASH_REMATCH[2]}"
+ # "Proper" Vim patch
+ # Check version.c:
+ is_missing="$(sed -n '/static int included_patches/,/}/p' ${NEOVIM_SOURCE_DIR}/src/nvim/version.c |
+ grep -x -e "[[:space:]]*//${patch_number} NA" -e "[[:space:]]*${patch_number}," >/dev/null && echo "false" || echo "true")"
+ vim_commit="${BASH_REMATCH[1]//-/.}"
+ else
+ # Untagged Vim patch, e.g. runtime updates.
+ # Check Neovim log:
+ is_missing="$(cd ${NEOVIM_SOURCE_DIR} &&
+ git log -1 --no-merges --grep="vim\-patch:${vim_commit:0:7}" --pretty=format:"false")"
+ fi
+
+ if [[ "${is_missing}" != "false" ]]; then
+ echo " • ${vim_commit}"
+ fi
+ done
+
+ echo
+ echo "Instructions:"
+ echo
+ echo " To port one of the above patches to Neovim, execute"
+ echo " this script with the patch revision as argument."
+ echo
+ echo " Examples: './scripts/vim-patch.sh 7.4.487'"
+ echo " './scripts/vim-patch.sh 1e8ebf870720e7b671f98f22d653009826304c4f'"
+}
+
+if [[ ${#} != 1 || "${1}" == "--help" ]]; then
+ usage
exit 1
fi
-echo "Retrieving Vim sources."
-if [[ ! -d ${VIM_SOURCE_DIR} ]]; then
- echo "Cloning Vim sources into '${VIM_SOURCE_DIR}'."
- hg clone https://code.google.com/p/vim ${VIM_SOURCE_DIR}
- cd ${VIM_SOURCE_DIR}
-else
- echo "Updating Vim sources in '${VIM_SOURCE_DIR}'."
- cd ${VIM_SOURCE_DIR}
- hg pull --update || echo "✘ Could not update Vim sources."
-fi
+get_vim_sources
-if [[ "${1}" =~ [0-9]\.[0-9]\.[0-9]{3,4} ]]; then
- # Interpret parameter as version number.
- vim_version="${1}"
- vim_commit="v${1//./-}"
- strip_commit_line=true
+if [[ "${1}" == "--list" ]]; then
+ list_vim_patches
else
- # Interpret parameter as commit hash.
- vim_version="${1:0:7}"
- vim_commit="${1}"
- strip_commit_line=false
-fi
-
-hg log --rev ${vim_commit} >/dev/null 2>&1 || {
- >&2 echo "✘ Couldn't find Vim revision '${vim_commit}'."
- exit 3
-}
-echo "✔ Found Vim revision '${vim_commit}'."
-
-# Collect patch details and store into variables.
-vim_full="$(hg log --patch --git --verbose --rev ${vim_commit})"
-vim_message="$(hg log --template "{desc}" --rev ${vim_commit})"
-if [[ "${strip_commit_line}" == "true" ]]; then
- # Remove first line of commit message.
- vim_message="$(echo "${vim_message}" | sed -e '1d')"
+ get_vim_patch ${1}
fi
-vim_diff="$(hg diff --show-function --git --change ${vim_commit} \
- | sed -e 's/\( [ab]\/src\)/\1\/nvim/g')" # Change directory to src/nvim.
-neovim_message="
-vim-patch:${vim_version}
-
-${vim_message}
-
-https://code.google.com/p/vim/source/detail?r=${vim_commit}"
-neovim_pr="
-\`\`\`
-${vim_message}
-\`\`\`
-
-https://code.google.com/p/vim/source/detail?r=${vim_commit}
-
-Original patch:
-
-\`\`\`diff
-${vim_diff}
-\`\`\`"
-neovim_branch="vim-${vim_version}"
-
-echo
-echo "Creating Git branch."
-cd ${NEOVIM_SOURCE_DIR}
-echo -n "✘ "
-# 'git checkout -b' writes to stderr in case of success :-(
-# Re-add newline (stripped by echo -n) in error case.
-git checkout -b "${neovim_branch}" 2>&1 | xargs echo -n || (echo; false)
-echo -n "." # Add trailing dot.
-echo -e "\r✔ " # Replace ✘ with ✔
-
-echo
-echo "Creating empty commit with correct commit message."
-echo -n "✘ "
-git commit --allow-empty --file - <<< "${neovim_message}" | xargs echo -n
-echo -e "\r✔ " # Replace ✘ with ✔
-
-echo
-echo "Creating files."
-echo "${vim_diff}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff
-echo "✔ Saved patch to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.diff'."
-echo "${vim_full}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch
-echo "✔ Saved full commit details to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.patch'."
-echo "${neovim_pr}" > ${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr
-echo "✔ Saved suggested PR description to '${NEOVIM_SOURCE_DIR}/${neovim_branch}.pr'."
-echo "You can use 'git clean' to remove these files when you're done."
-
-echo
-echo "Instructions:"
-echo
-echo " Proceed to port the patch."
-echo " You might want to try 'patch -p1 < ${neovim_branch}.diff' first."
-echo
-echo " Stage your changes ('git add ...') and use 'git commit --amend' to commit."
-echo
-echo " Push your changes with 'git push origin ${neovim_branch}' and create a"
-echo " pull request called '[RFC] vim-patch:${vim_version}'. You might want "
-echo " to use the text in '${neovim_branch}.pr' as the description of this pull request."
-echo
-echo " See https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim"
-echo " for more information."
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 2abac06574..5fe52e3323 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -59,7 +59,6 @@ set(CONV_SOURCES
fileio.c
fold.c
getchar.c
- hardcopy.c
if_cscope.c
indent.c
keymap.c
@@ -84,7 +83,6 @@ set(CONV_SOURCES
spell.c
syntax.c
tag.c
- term.c
ui.c
version.c
window.c)
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 4c40cd631e..3a378ea360 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -602,7 +602,6 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count)
{
(void)do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO,
start, dir, count, eap->forceit);
-#ifdef HAS_SWAP_EXISTS_ACTION
buf_T *old_curbuf = curbuf;
swap_exists_action = SEA_DIALOG;
@@ -624,10 +623,8 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count)
} else {
handle_swap_exists(old_curbuf);
}
-#endif
}
-#if defined(HAS_SWAP_EXISTS_ACTION) || defined(PROTO)
/*
* Handle the situation of swap_exists_action being set.
* It is allowed for "old_curbuf" to be NULL or invalid.
@@ -678,7 +675,6 @@ void handle_swap_exists(buf_T *old_curbuf)
}
swap_exists_action = SEA_NONE;
}
-#endif
/*
* do_bufdel() - delete or unload buffer(s)
@@ -750,7 +746,7 @@ do_bufdel (
break;
arg = p;
} else
- bnr = getdigits(&arg);
+ bnr = getdigits_int(&arg);
}
}
if (!got_int && do_current && do_buffer(command, DOBUF_FIRST,
@@ -2351,7 +2347,7 @@ int buflist_add(char_u *fname, int flags)
return 0;
}
-#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
+#if defined(BACKSLASH_IN_FILENAME)
/*
* Adjust slashes in file names. Called after 'shellslash' was set.
*/
@@ -2752,7 +2748,7 @@ void resettitle(void)
mch_settitle(lasttitle, lasticon);
}
-# if defined(EXITFREE) || defined(PROTO)
+# if defined(EXITFREE)
void free_titles(void)
{
free(lasttitle);
@@ -2997,7 +2993,7 @@ build_stl_str_hl (
l = -1;
}
if (VIM_ISDIGIT(*s)) {
- minwid = (int)getdigits(&s);
+ minwid = getdigits_int(&s);
if (minwid < 0) /* overflow */
minwid = 0;
}
@@ -3033,7 +3029,7 @@ build_stl_str_hl (
if (*s == '.') {
s++;
if (VIM_ISDIGIT(*s)) {
- maxwid = (int)getdigits(&s);
+ maxwid = getdigits_int(&s);
if (maxwid <= 0) /* overflow */
maxwid = 50;
}
@@ -3934,17 +3930,12 @@ void ex_buffer_all(exarg_T *eap)
continue;
/* Open the buffer in this window. */
-#if defined(HAS_SWAP_EXISTS_ACTION)
swap_exists_action = SEA_DIALOG;
-#endif
set_curbuf(buf, DOBUF_GOTO);
if (!buf_valid(buf)) { /* autocommands deleted the buffer!!! */
-#if defined(HAS_SWAP_EXISTS_ACTION)
swap_exists_action = SEA_NONE;
-# endif
break;
}
-#if defined(HAS_SWAP_EXISTS_ACTION)
if (swap_exists_action == SEA_QUIT) {
cleanup_T cs;
@@ -3964,7 +3955,6 @@ void ex_buffer_all(exarg_T *eap)
leave_cleanup(&cs);
} else
handle_swap_exists(NULL);
-#endif
}
os_breakcheck();
@@ -4077,7 +4067,7 @@ chk_modeline (
e = s + 4;
else
e = s + 3;
- vers = getdigits(&e);
+ vers = getdigits_int(&e);
if (*e == ':'
&& (s[0] != 'V'
|| STRNCMP(skipwhite(e + 1), "set", 3) == 0)
diff --git a/src/nvim/charset.c b/src/nvim/charset.c
index 32427cc3ba..b86c66c3fe 100644
--- a/src/nvim/charset.c
+++ b/src/nvim/charset.c
@@ -177,7 +177,7 @@ int buf_init_chartab(buf_T *buf, int global)
}
if (VIM_ISDIGIT(*p)) {
- c = getdigits(&p);
+ c = getdigits_int(&p);
} else if (has_mbyte) {
c = mb_ptr2char_adv(&p);
} else {
@@ -189,7 +189,7 @@ int buf_init_chartab(buf_T *buf, int global)
++p;
if (VIM_ISDIGIT(*p)) {
- c2 = getdigits(&p);
+ c2 = getdigits_int(&p);
} else if (has_mbyte) {
c2 = mb_ptr2char_adv(&p);
} else {
@@ -1676,26 +1676,41 @@ char_u* skiptowhite_esc(char_u *p) {
return p;
}
-/// Getdigits: Get a number from a string and skip over it.
+/// Get a number from a string and skip over it.
///
-/// Note: the argument is a pointer to a char_u pointer!
+/// @param[out] pp A pointer to a pointer to char_u.
+/// It will be advanced past the read number.
///
-/// @param pp
+/// @return Number read from the string.
+intmax_t getdigits(char_u **pp)
+{
+ intmax_t number = strtoimax((char *)*pp, (char **)pp, 10);
+ assert(errno != ERANGE);
+ return number;
+}
+
+/// Get an int number from a string.
///
-/// @return Number from the string.
-long getdigits(char_u **pp)
+/// A getdigits wrapper restricted to int values.
+int getdigits_int(char_u **pp)
{
- char_u *p = *pp;
- long retval = atol((char *)p);
+ intmax_t number = getdigits(pp);
+#if SIZEOF_INTMAX_T > SIZEOF_INT
+ assert(number >= INT_MIN && number <= INT_MAX);
+#endif
+ return (int)number;
+}
- if (*p == '-') {
- // skip negative sign
- ++p;
- }
- // skip to next non-digit
- p = skipdigits(p);
- *pp = p;
- return retval;
+/// Get a long number from a string.
+///
+/// A getdigits wrapper restricted to long values.
+long getdigits_long(char_u **pp)
+{
+ intmax_t number = getdigits(pp);
+#if SIZEOF_INTMAX_T > SIZEOF_LONG
+ assert(number >= LONG_MIN && number <= LONG_MAX);
+#endif
+ return (long)number;
}
/// Return TRUE if "lbuf" is empty or only contains blanks.
@@ -1838,7 +1853,7 @@ int hex2nr(int c)
return c - '0';
}
-#if defined(FEAT_TERMRESPONSE) || defined(FEAT_GUI_GTK) || defined(PROTO)
+#if defined(FEAT_TERMRESPONSE) || defined(FEAT_GUI_GTK)
/// Convert two hex characters to a byte.
/// Return -1 if one of the characters is not hex.
@@ -1855,8 +1870,7 @@ int hexhex2nr(char_u *p)
return (hex2nr(p[0]) << 4) + hex2nr(p[1]);
}
-#endif // if defined(FEAT_TERMRESPONSE) || defined(FEAT_GUI_GTK)
- // || defined(PROTO)
+#endif // if defined(FEAT_TERMRESPONSE) || defined(FEAT_GUI_GTK)
/// Return true if "str" starts with a backslash that should be removed.
/// For WIN32 this is only done when the character after the
diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c
index 87064b4ef3..2e98b8f512 100644
--- a/src/nvim/cursor_shape.c
+++ b/src/nvim/cursor_shape.c
@@ -135,9 +135,7 @@ char_u *parse_shape_opt(int what)
p += len;
if (!VIM_ISDIGIT(*p))
return (char_u *)N_("E548: digit expected");
- int64_t digits = getdigits(&p);
- assert(digits <= INT_MAX);
- int n = (int)digits;
+ int n = getdigits_int(&p);
if (len == 3) { /* "ver" or "hor" */
if (n == 0)
return (char_u *)N_("E549: Illegal percentage");
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index ccff4520dc..b8fa3c24a2 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -1221,11 +1221,11 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname)
// {first}a{first}[,{last}]
// {first}[,{last}]d{first}
p = linebuf;
- f1 = getdigits(&p);
+ f1 = getdigits_long(&p);
if (*p == ',') {
++p;
- l1 = getdigits(&p);
+ l1 = getdigits_long(&p);
} else {
l1 = f1;
}
@@ -1235,11 +1235,11 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname)
continue;
}
difftype = *p++;
- f2 = getdigits(&p);
+ f2 = getdigits_long(&p);
if (*p == ',') {
++p;
- l2 = getdigits(&p);
+ l2 = getdigits_long(&p);
} else {
l2 = f2;
}
@@ -1783,7 +1783,7 @@ int diffopt_changed(void)
diff_flags_new |= DIFF_FILLER;
} else if ((STRNCMP(p, "context:", 8) == 0) && VIM_ISDIGIT(p[8])) {
p += 8;
- diff_context_new = getdigits(&p);
+ diff_context_new = getdigits_int(&p);
} else if (STRNCMP(p, "icase", 5) == 0) {
p += 5;
diff_flags_new |= DIFF_ICASE;
@@ -1798,7 +1798,7 @@ int diffopt_changed(void)
diff_flags_new |= DIFF_VERTICAL;
} else if ((STRNCMP(p, "foldcolumn:", 11) == 0) && VIM_ISDIGIT(p[11])) {
p += 11;
- diff_foldcolumn_new = getdigits(&p);
+ diff_foldcolumn_new = getdigits_int(&p);
}
if ((*p != ',') && (*p != NUL)) {
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c
index 2b5fdea2fe..243468b680 100644
--- a/src/nvim/digraph.c
+++ b/src/nvim/digraph.c
@@ -1611,9 +1611,7 @@ void putdigraph(char_u *str)
EMSG(_(e_number_exp));
return;
}
- int64_t digits = getdigits(&str);
- assert(digits <= INT_MAX);
- int n = (int)digits;
+ int n = getdigits_int(&str);
// If the digraph already exists, replace the result.
dp = (digr_T *)user_digraphs.ga_data;
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index e1a1fb18fa..4c00547daa 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -5800,7 +5800,7 @@ void set_last_insert(int c)
last_insert_skip = 0;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_last_insert(void)
{
free(last_insert);
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 744fb13447..1833461fa9 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -76,6 +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"
@@ -499,7 +500,7 @@ void eval_init(void)
job_event_pool = kmp_init(JobEventPool);
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void eval_clear(void)
{
struct vimvar *p;
@@ -2750,7 +2751,7 @@ void ex_lockvar(exarg_T *eap)
if (eap->forceit)
deep = -1;
else if (vim_isdigit(*arg)) {
- deep = getdigits(&arg);
+ deep = getdigits_int(&arg);
arg = skipwhite(arg);
}
@@ -4498,7 +4499,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
{
char_u *p;
char_u *name;
- int extra = 0;
+ unsigned int extra = 0;
/*
* Find the end of the string, skipping backslashed characters.
@@ -4847,7 +4848,6 @@ list_equal (
return item1 == NULL && item2 == NULL;
}
-#if defined(PROTO)
/*
* Return the dictitem that an entry in a hashtable points to.
*/
@@ -4855,12 +4855,6 @@ dictitem_T *dict_lookup(hashitem_T *hi)
{
return HI2DI(hi);
}
-#endif
-
-dictitem_T * dict_lookup(hashitem_T *hi)
-{
- return HI2DI(hi);
-}
/*
* Return TRUE when two dictionaries have exactly the same key/values.
@@ -5129,7 +5123,7 @@ void list_append_list(list_T *list, list_T *itemlist)
li->li_tv.v_lock = 0;
li->li_tv.vval.v_list = itemlist;
list_append(list, li);
- ++list->lv_refcount;
+ ++itemlist->lv_refcount;
}
/*
@@ -5543,49 +5537,48 @@ int garbage_collect(void)
return did_free;
}
-/*
- * Free lists and dictionaries that are no longer referenced.
- */
+/// Free lists and dictionaries that are no longer referenced.
+///
+/// Note: This function may only be called from garbage_collect().
+///
+/// @param copyID Free lists/dictionaries that don't have this ID.
+/// @return true, if something was freed.
static int free_unref_items(int copyID)
{
- dict_T *dd;
- list_T *ll;
- int did_free = FALSE;
+ bool did_free = false;
- /*
- * Go through the list of dicts and free items without the copyID.
- */
- for (dd = first_dict; dd != NULL; )
+ // Go through the list of dicts and free items without the copyID.
+ for (dict_T *dd = first_dict; dd != NULL; ) {
if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)) {
- /* Free the Dictionary and ordinary items it contains, but don't
- * recurse into Lists and Dictionaries, they will be in the list
- * of dicts or list of lists. */
+ // Free the Dictionary and ordinary items it contains, but don't
+ // recurse into Lists and Dictionaries, they will be in the list
+ // of dicts or list of lists. */
+ dict_T *dd_next = dd->dv_used_next;
dict_free(dd, FALSE);
- did_free = TRUE;
-
- /* restart, next dict may also have been freed */
- dd = first_dict;
- } else
+ did_free = true;
+ dd = dd_next;
+ } else {
dd = dd->dv_used_next;
+ }
+ }
- /*
- * Go through the list of lists and free items without the copyID.
- * But don't free a list that has a watcher (used in a for loop), these
- * are not referenced anywhere.
- */
- for (ll = first_list; ll != NULL; )
+ // Go through the list of lists and free items without the copyID.
+ // But don't free a list that has a watcher (used in a for loop), these
+ // are not referenced anywhere.
+ for (list_T *ll = first_list; ll != NULL;) {
if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
&& ll->lv_watch == NULL) {
- /* Free the List and ordinary items it contains, but don't recurse
- * into Lists and Dictionaries, they will be in the list of dicts
- * or list of lists. */
+ // Free the List and ordinary items it contains, but don't recurse
+ // into Lists and Dictionaries, they will be in the list of dicts
+ // or list of lists.
+ list_T* ll_next = ll->lv_used_next;
list_free(ll, FALSE);
- did_free = TRUE;
-
- /* restart, next list may also have been freed */
- ll = first_list;
- } else
+ did_free = true;
+ ll = ll_next;
+ } else {
ll = ll->lv_used_next;
+ }
+ }
return did_free;
}
@@ -5717,6 +5710,7 @@ dict_free (
/* Lock the hashtab, we don't want it to resize while freeing items. */
hash_lock(&d->dv_hashtab);
+ assert(d->dv_hashtab.ht_locked > 0);
todo = (int)d->dv_hashtab.ht_used;
for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi) {
if (!HASHITEM_EMPTY(hi)) {
@@ -10023,6 +10017,8 @@ static void f_has(typval_T *argvars, typval_T *rettv)
#endif
} else if (STRICMP(name, "syntax_items") == 0) {
n = syntax_present(curwin);
+ } else if (STRICMP(name, "gui_running") == 0) {
+ n = ui_rgb_attached();
}
}
@@ -13370,7 +13366,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv)
yank_type = MBLOCK;
if (VIM_ISDIGIT(stropt[1])) {
++stropt;
- block_len = getdigits(&stropt) - 1;
+ block_len = getdigits_long(&stropt) - 1;
--stropt;
}
break;
@@ -14440,7 +14436,7 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv)
if (modec != 't' && modec != 'c' && modec != 'g')
modec = 0; /* replace invalid with current */
} else {
- if (t_colors > 1)
+ if (abstract_ui || t_colors > 1)
modec = 'c';
else
modec = 't';
@@ -18047,7 +18043,7 @@ static ufunc_T *find_func(char_u *name)
return NULL;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_all_functions(void)
{
hashitem_T *hi;
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 3278de3561..763a2d6212 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -569,7 +569,7 @@ void ex_retab(exarg_T *eap)
save_list = curwin->w_p_list;
curwin->w_p_list = 0; /* don't want list mode here */
- new_ts = getdigits(&(eap->arg));
+ new_ts = getdigits_int(&(eap->arg));
if (new_ts < 0) {
EMSG(_(e_positive));
return;
@@ -825,7 +825,7 @@ void ex_copy(linenr_T line1, linenr_T line2, linenr_T n)
static char_u *prevcmd = NULL; /* the previous command */
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_prev_shellcmd(void)
{
free(prevcmd);
@@ -2978,9 +2978,7 @@ do_ecmd (
lnum = curwin->w_cursor.lnum;
topline = curwin->w_topline;
if (!oldbuf) { /* need to read the file */
-#if defined(HAS_SWAP_EXISTS_ACTION)
swap_exists_action = SEA_DIALOG;
-#endif
curbuf->b_flags |= BF_CHECK_RO; /* set/reset 'ro' flag */
/*
@@ -2989,11 +2987,9 @@ do_ecmd (
if (should_abort(open_buffer(FALSE, eap, readfile_flags)))
retval = FAIL;
-#if defined(HAS_SWAP_EXISTS_ACTION)
if (swap_exists_action == SEA_QUIT)
retval = FAIL;
handle_swap_exists(old_curbuf);
-#endif
} else {
/* Read the modelines, but only to set window-local options. Any
* buffer-local options have already been set and may have been
@@ -3674,7 +3670,7 @@ void do_sub(exarg_T *eap)
*/
cmd = skipwhite(cmd);
if (VIM_ISDIGIT(*cmd)) {
- i = getdigits(&cmd);
+ i = getdigits_long(&cmd);
if (i <= 0 && !eap->skip && do_error) {
EMSG(_(e_zerocount));
return;
@@ -4609,7 +4605,7 @@ void write_viminfo_sub_string(FILE *fp)
}
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_old_sub(void)
{
free(old_sub);
@@ -5920,7 +5916,7 @@ void ex_sign(exarg_T *eap)
arg1 = arg;
if (VIM_ISDIGIT(*arg))
{
- id = getdigits(&arg);
+ id = getdigits_int(&arg);
if (!vim_iswhite(*arg) && *arg != NUL)
{
id = -1;
@@ -5985,7 +5981,7 @@ void ex_sign(exarg_T *eap)
else if (STRNCMP(arg, "buffer=", 7) == 0)
{
arg += 7;
- buf = buflist_findnr((int)getdigits(&arg));
+ buf = buflist_findnr(getdigits_int(&arg));
if (*skipwhite(arg) != NUL)
EMSG(_(e_trailing));
break;
@@ -6184,7 +6180,7 @@ char_u * sign_typenr2name(int typenr)
return (char_u *)_("[Deleted]");
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
/*
* Undefine/free all signs.
*/
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index 072972d24e..7de47cb296 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -471,7 +471,7 @@ dbg_parsearg (
else if (
gap != &prof_ga &&
VIM_ISDIGIT(*p)) {
- bp->dbg_lnum = getdigits(&p);
+ bp->dbg_lnum = getdigits_long(&p);
p = skipwhite(p);
} else
bp->dbg_lnum = 0;
@@ -2546,7 +2546,7 @@ void ex_scriptnames(exarg_T *eap)
}
}
-# if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
+# if defined(BACKSLASH_IN_FILENAME)
/*
* Fix slashes in the list of script names for 'shellslash'.
*/
@@ -2579,7 +2579,7 @@ char_u *get_scriptname(scid_T id)
return SCRIPT_ITEM(id).sn_name;
}
-# if defined(EXITFREE) || defined(PROTO)
+# if defined(EXITFREE)
void free_scriptnames()
{
# define FREE_SCRIPTNAME(item) free((item)->sn_name)
@@ -3204,7 +3204,7 @@ static char_u **find_locales(void)
return (char_u **)locales_ga.ga_data;
}
-# if defined(EXITFREE) || defined(PROTO)
+# if defined(EXITFREE)
void free_locales(void)
{
int i;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index ca79270fcc..b4dfe99aed 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1733,7 +1733,7 @@ static char_u * do_one_cmd(char_u **cmdlinep,
if ((ea.argt & COUNT) && VIM_ISDIGIT(*ea.arg)
&& (!(ea.argt & BUFNAME) || *(p = skipdigits(ea.arg)) == NUL
|| vim_iswhite(*p))) {
- n = getdigits(&ea.arg);
+ n = getdigits_long(&ea.arg);
ea.arg = skipwhite(ea.arg);
if (n <= 0 && !ni && (ea.argt & ZEROR) == 0) {
errormsg = (char_u *)_(e_zerocount);
@@ -3250,7 +3250,7 @@ get_address (
default:
if (VIM_ISDIGIT(*cmd)) /* absolute line number */
- lnum = getdigits(&cmd);
+ lnum = getdigits_long(&cmd);
}
for (;; ) {
@@ -3267,7 +3267,7 @@ get_address (
if (!VIM_ISDIGIT(*cmd)) /* '+' is '+1', but '+0' is not '+1' */
n = 1;
else
- n = getdigits(&cmd);
+ n = getdigits_long(&cmd);
if (i == '-')
lnum -= n;
else
@@ -4439,7 +4439,7 @@ two_count:
return FAIL;
}
- *def = getdigits(&p);
+ *def = getdigits_long(&p);
*argt |= (ZEROR | NOTADR);
if (p != val + vallen || vallen == 0) {
@@ -4456,7 +4456,7 @@ invalid_count:
if (*def >= 0)
goto two_count;
- *def = getdigits(&p);
+ *def = getdigits_long(&p);
if (p != val + vallen)
goto invalid_count;
@@ -5530,7 +5530,7 @@ void alist_new(void)
alist_init(curwin->w_alist);
}
-#if !defined(UNIX) || defined(PROTO)
+#if !defined(UNIX)
/*
* Expand the file names in the global argument list.
* If "fnum_list" is not NULL, use "fnum_list[fnum_len]" as a list of buffer
@@ -5623,7 +5623,7 @@ alist_add (
++al->al_ga.ga_len;
}
-#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
+#if defined(BACKSLASH_IN_FILENAME)
/*
* Adjust slashes in file names. Called after 'shellslash' was set.
*/
@@ -5819,7 +5819,7 @@ static void ex_tabmove(exarg_T *eap)
return;
}
- tab_number = getdigits(&p);
+ tab_number = getdigits_int(&p);
if (relative != 0)
tab_number = tab_number * relative + tabpage_index(curtab) - 1; ;
} else if (eap->addr_count != 0)
@@ -6256,7 +6256,7 @@ static void ex_read(exarg_T *eap)
static char_u *prev_dir = NULL;
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_cd_dir(void)
{
free(prev_dir);
@@ -6441,10 +6441,10 @@ static void ex_winsize(exarg_T *eap)
char_u *arg = eap->arg;
char_u *p;
- w = getdigits(&arg);
+ w = getdigits_int(&arg);
arg = skipwhite(arg);
p = arg;
- h = getdigits(&arg);
+ h = getdigits_int(&arg);
if (*p != NUL && *arg == NUL)
screen_resize(w, h, TRUE);
else
@@ -6494,10 +6494,10 @@ static void ex_winpos(exarg_T *eap)
if (*arg == NUL) {
EMSG(_("E188: Obtaining window position not implemented for this platform"));
} else {
- x = getdigits(&arg);
+ x = getdigits_int(&arg);
arg = skipwhite(arg);
p = arg;
- y = getdigits(&arg);
+ y = getdigits_int(&arg);
if (*p == NUL || *arg != NUL) {
EMSG(_("E466: :winpos requires two number arguments"));
return;
@@ -6744,7 +6744,7 @@ static void ex_later(exarg_T *eap)
if (*p == NUL)
count = 1;
else if (isdigit(*p)) {
- count = getdigits(&p);
+ count = getdigits_long(&p);
switch (*p) {
case 's': ++p; sec = TRUE; break;
case 'm': ++p; sec = TRUE; count *= 60; break;
@@ -7354,7 +7354,7 @@ static void ex_findpat(exarg_T *eap)
n = 1;
if (vim_isdigit(*eap->arg)) { /* get count */
- n = getdigits(&eap->arg);
+ n = getdigits_long(&eap->arg);
eap->arg = skipwhite(eap->arg);
}
if (*eap->arg == '/') { /* Match regexp, not just whole words */
@@ -7618,7 +7618,7 @@ eval_vars (
s = src + 1;
if (*s == '<') /* "#<99" uses v:oldfiles */
++s;
- i = (int)getdigits(&s);
+ i = getdigits_int(&s);
*usedlen = (int)(s - src); /* length of what we expand */
if (src[1] == '<') {
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 3ce8263457..b942f69f61 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -1972,7 +1972,7 @@ static void realloc_cmdbuff(int len)
static char_u *arshape_buf = NULL;
-# if defined(EXITFREE) || defined(PROTO)
+# if defined(EXITFREE)
void free_cmdline_buf(void)
{
free(arshape_buf);
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 58e67fa58c..370584b095 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -636,14 +636,12 @@ readfile (
#endif
}
-#if defined(HAS_SWAP_EXISTS_ACTION)
/* If "Quit" selected at ATTENTION dialog, don't load the file */
if (swap_exists_action == SEA_QUIT) {
if (!read_buffer && !read_stdin)
close(fd);
return FAIL;
}
-#endif
++no_wait_return; /* don't wait for return yet */
@@ -5149,7 +5147,7 @@ void write_lnum_adjust(linenr_T offset)
curbuf->b_no_eol_lnum += offset;
}
-#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)
+#if defined(BACKSLASH_IN_FILENAME)
/*
* Convert all backslashes in fname to forward slashes in-place.
*/
@@ -5547,7 +5545,7 @@ void do_augroup(char_u *arg, int del_group)
}
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_all_autocmds(void)
{
for (current_augroup = -1; current_augroup < augroups.ga_len;
@@ -7454,7 +7452,7 @@ file_pat_to_reg_pat (
return reg_pat;
}
-#if defined(EINTR) || defined(PROTO)
+#if defined(EINTR)
/*
* Version of read() that retries when interrupted by EINTR (possibly
* by a SIGWINCH).
diff --git a/src/nvim/garray.c b/src/nvim/garray.c
index c4f8f66bfe..c3a3426e87 100644
--- a/src/nvim/garray.c
+++ b/src/nvim/garray.c
@@ -199,7 +199,7 @@ void ga_append(garray_T *gap, char c)
GA_APPEND(char, gap, c);
}
-#if defined(UNIX) || defined(WIN3264) || defined(PROTO)
+#if defined(UNIX) || defined(WIN3264)
/// Append the text in "gap" below the cursor line and clear "gap".
///
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index e12601e4c9..d97c983133 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1307,7 +1307,7 @@ static void closescript(void)
--curscript;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void close_all_scripts(void)
{
while (scriptin[0] != NULL)
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 11a7e9ecac..73bcdea226 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -859,7 +859,6 @@ EXTERN int cmd_silent INIT(= FALSE); /* don't echo the command line */
#define SEA_QUIT 2 /* quit editing the file */
#define SEA_RECOVER 3 /* recover the file */
-#define HAS_SWAP_EXISTS_ACTION
EXTERN int swap_exists_action INIT(= SEA_NONE);
/* For dialog when swap file already
* exists. */
diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c
index f1f619066a..92abcbada4 100644
--- a/src/nvim/hardcopy.c
+++ b/src/nvim/hardcopy.c
@@ -10,9 +10,11 @@
* hardcopy.c: printing to paper
*/
+#include <assert.h>
#include <errno.h>
#include <string.h>
#include <inttypes.h>
+#include <stdint.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
@@ -82,11 +84,11 @@
* void mch_print_set_font(int Bold, int Italic, int Underline);
* Called whenever the font style changes.
*
- * void mch_print_set_bg(long_u bgcol);
+ * void mch_print_set_bg(uint32_t bgcol);
* Called to set the background color for the following text. Parameter is an
* RGB value.
*
- * void mch_print_set_fg(long_u fgcol);
+ * void mch_print_set_fg(uint32_t fgcol);
* Called to set the foreground color for the following text. Parameter is an
* RGB value.
*
@@ -124,30 +126,28 @@ static option_table_T printer_opts[OPT_PRINT_NUM_OPTIONS]
;
-static const long_u cterm_color_8[8] =
-{
- (long_u)0x000000L, (long_u)0xff0000L, (long_u)0x00ff00L, (long_u)0xffff00L,
- (long_u)0x0000ffL, (long_u)0xff00ffL, (long_u)0x00ffffL, (long_u)0xffffffL
+static const uint32_t cterm_color_8[8] = {
+ 0x000000, 0xff0000, 0x00ff00, 0xffff00,
+ 0x0000ff, 0xff00ff, 0x00ffff, 0xffffff
};
-static const long_u cterm_color_16[16] =
-{
- (long_u)0x000000L, (long_u)0x0000c0L, (long_u)0x008000L, (long_u)0x004080L,
- (long_u)0xc00000L, (long_u)0xc000c0L, (long_u)0x808000L, (long_u)0xc0c0c0L,
- (long_u)0x808080L, (long_u)0x6060ffL, (long_u)0x00ff00L, (long_u)0x00ffffL,
- (long_u)0xff8080L, (long_u)0xff40ffL, (long_u)0xffff00L, (long_u)0xffffffL
+static const uint32_t cterm_color_16[16] = {
+ 0x000000, 0x0000c0, 0x008000, 0x004080,
+ 0xc00000, 0xc000c0, 0x808000, 0xc0c0c0,
+ 0x808080, 0x6060ff, 0x00ff00, 0x00ffff,
+ 0xff8080, 0xff40ff, 0xffff00, 0xffffff
};
static int current_syn_id;
-#define PRCOLOR_BLACK (long_u)0
-#define PRCOLOR_WHITE (long_u)0xFFFFFFL
+#define PRCOLOR_BLACK 0
+#define PRCOLOR_WHITE 0xffffff
static int curr_italic;
static int curr_bold;
static int curr_underline;
-static long_u curr_bg;
-static long_u curr_fg;
+static uint32_t curr_bg;
+static uint32_t curr_fg;
static int page_count;
# define OPT_MBFONT_USECOURIER 0
@@ -176,7 +176,7 @@ typedef struct {
int print_pos; /* virtual column for computing TABs */
colnr_T column; /* byte column */
linenr_T file_line; /* line nr in the buffer */
- long_u bytes_printed; /* bytes printed so far */
+ size_t bytes_printed; /* bytes printed so far */
int ff; /* seen form feed character */
} prt_pos_T;
@@ -321,7 +321,7 @@ static char_u *parse_list_options(char_u *option_str, option_table_T *table, int
if (!VIM_ISDIGIT(*p))
return (char_u *)N_("E552: digit expected");
- table[idx].number = getdigits(&p); /*advances p*/
+ table[idx].number = getdigits_int(&p);
}
table[idx].string = p;
@@ -340,14 +340,14 @@ static char_u *parse_list_options(char_u *option_str, option_table_T *table, int
* If using a dark background, the colors will probably be too bright to show
* up well on white paper, so reduce their brightness.
*/
-static long_u darken_rgb(long_u rgb)
+static uint32_t darken_rgb(uint32_t rgb)
{
return ((rgb >> 17) << 16)
+ (((rgb & 0xff00) >> 9) << 8)
+ ((rgb & 0xff) >> 1);
}
-static long_u prt_get_term_color(int colorindex)
+static uint32_t prt_get_term_color(int colorindex)
{
/* TODO: Should check for xterm with 88 or 256 colors. */
if (t_colors > 8)
@@ -358,8 +358,7 @@ static long_u prt_get_term_color(int colorindex)
static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
{
int colorindex;
- long_u fg_color;
- long_u bg_color;
+ uint32_t fg_color;
char *color;
pattr->bold = (highlight_has_attr(hl_id, HL_BOLD, modec) != NULL);
@@ -368,8 +367,6 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
pattr->undercurl = (highlight_has_attr(hl_id, HL_UNDERCURL, modec) != NULL);
{
- bg_color = PRCOLOR_WHITE;
-
color = (char *)highlight_color(hl_id, (char_u *)"fg", modec);
if (color == NULL)
colorindex = 0;
@@ -388,10 +385,10 @@ static void prt_get_attr(int hl_id, prt_text_attr_T *pattr, int modec)
fg_color = darken_rgb(fg_color);
pattr->fg_color = fg_color;
- pattr->bg_color = bg_color;
+ pattr->bg_color = PRCOLOR_WHITE;
}
-static void prt_set_fg(long_u fg)
+static void prt_set_fg(uint32_t fg)
{
if (fg != curr_fg) {
curr_fg = fg;
@@ -399,7 +396,7 @@ static void prt_set_fg(long_u fg)
}
}
-static void prt_set_bg(long_u bg)
+static void prt_set_bg(uint32_t bg)
{
if (bg != curr_bg) {
curr_bg = bg;
@@ -455,8 +452,9 @@ static void prt_line_number(prt_settings_T *psettings, int page_line, linenr_T l
*/
int prt_header_height(void)
{
- if (printer_opts[OPT_PRINT_HEADERHEIGHT].present)
+ if (printer_opts[OPT_PRINT_HEADERHEIGHT].present) {
return printer_opts[OPT_PRINT_HEADERHEIGHT].number;
+ }
return 2;
}
@@ -503,7 +501,8 @@ static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum)
if (prt_use_number())
width += PRINT_NUMBER_WIDTH;
- tbuf = xmalloc(width + IOSIZE);
+ assert(width >= 0);
+ tbuf = xmalloc((size_t)width + IOSIZE);
if (*p_header != NUL) {
linenr_T tmp_lnum, tmp_topline, tmp_botline;
@@ -524,7 +523,7 @@ static void prt_header(prt_settings_T *psettings, int pagenum, linenr_T lnum)
printer_page_num = pagenum;
use_sandbox = was_set_insecurely((char_u *)"printheader", 0);
- build_stl_str_hl(curwin, tbuf, (size_t)(width + IOSIZE),
+ build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE,
p_header, use_sandbox,
' ', width, NULL, NULL);
@@ -582,7 +581,7 @@ void ex_hardcopy(exarg_T *eap)
linenr_T lnum;
int collated_copies, uncollated_copies;
prt_settings_T settings;
- long_u bytes_to_print = 0;
+ size_t bytes_to_print = 0;
int page_line;
int jobsplit;
@@ -655,15 +654,15 @@ void ex_hardcopy(exarg_T *eap)
* Estimate the total lines to be printed
*/
for (lnum = eap->line1; lnum <= eap->line2; lnum++)
- bytes_to_print += (long_u)STRLEN(skipwhite(ml_get(lnum)));
+ bytes_to_print += STRLEN(skipwhite(ml_get(lnum)));
if (bytes_to_print == 0) {
MSG(_("No text to be printed"));
goto print_fail_no_begin;
}
/* Set colors and font to normal. */
- curr_bg = (long_u)0xffffffffL;
- curr_fg = (long_u)0xffffffffL;
+ curr_bg = 0xffffffff;
+ curr_fg = 0xffffffff;
curr_italic = MAYBE;
curr_bold = MAYBE;
curr_underline = MAYBE;
@@ -728,13 +727,10 @@ void ex_hardcopy(exarg_T *eap)
if (got_int || settings.user_abort)
goto print_fail;
- sprintf((char *)IObuff, _("Printing page %d (%d%%)"),
- page_count + 1 + side,
- prtpos.bytes_printed > 1000000
- ? (int)(prtpos.bytes_printed /
- (bytes_to_print / 100))
- : (int)((prtpos.bytes_printed * 100)
- / bytes_to_print));
+ assert(prtpos.bytes_printed <= SIZE_MAX / 100);
+ sprintf((char *)IObuff, _("Printing page %d (%zu%%)"),
+ page_count + 1 + side,
+ prtpos.bytes_printed * 100 / bytes_to_print);
if (!mch_print_begin_page(IObuff))
goto print_fail;
@@ -820,7 +816,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
int need_break = FALSE;
int outputlen;
int tab_spaces;
- long_u print_pos;
+ int print_pos;
prt_text_attr_T attr;
int id;
@@ -900,7 +896,7 @@ static colnr_T hardcopy_line(prt_settings_T *psettings, int page_line, prt_pos_T
}
ppos->lead_spaces = tab_spaces;
- ppos->print_pos = (int)print_pos;
+ ppos->print_pos = print_pos;
/*
* Start next line of file if we clip lines, or have reached end of the
@@ -1240,19 +1236,19 @@ static char_u *prt_ps_file_name = NULL;
* Various offsets and dimensions in default PostScript user space (points).
* Used for text positioning calculations
*/
-static float prt_page_width;
-static float prt_page_height;
-static float prt_left_margin;
-static float prt_right_margin;
-static float prt_top_margin;
-static float prt_bottom_margin;
-static float prt_line_height;
-static float prt_first_line_height;
-static float prt_char_width;
-static float prt_number_width;
-static float prt_bgcol_offset;
-static float prt_pos_x_moveto = 0.0;
-static float prt_pos_y_moveto = 0.0;
+static double prt_page_width;
+static double prt_page_height;
+static double prt_left_margin;
+static double prt_right_margin;
+static double prt_top_margin;
+static double prt_bottom_margin;
+static double prt_line_height;
+static double prt_first_line_height;
+static double prt_char_width;
+static double prt_number_width;
+static double prt_bgcol_offset;
+static double prt_pos_x_moveto = 0.0;
+static double prt_pos_y_moveto = 0.0;
/*
* Various control variables used to decide when and how to change the
@@ -1266,13 +1262,13 @@ static int prt_need_underline;
static int prt_underline;
static int prt_do_underline;
static int prt_need_fgcol;
-static int prt_fgcol;
+static uint32_t prt_fgcol;
static int prt_need_bgcol;
static int prt_do_bgcol;
-static int prt_bgcol;
-static int prt_new_bgcol;
+static uint32_t prt_bgcol;
+static uint32_t prt_new_bgcol;
static int prt_attribute_change;
-static float prt_text_run;
+static double prt_text_run;
static int prt_page_num;
static int prt_bufsiz;
@@ -1304,11 +1300,10 @@ static int prt_half_width;
static char *prt_ascii_encoding;
static char_u prt_hexchar[] = "0123456789abcdef";
-static void prt_write_file_raw_len(char_u *buffer, int bytes)
+static void prt_write_file_raw_len(char_u *buffer, size_t bytes)
{
if (!prt_file_error
- && fwrite(buffer, sizeof(char_u), bytes, prt_ps_fd)
- != (size_t)bytes) {
+ && fwrite(buffer, sizeof(char_u), bytes, prt_ps_fd) != bytes) {
EMSG(_("E455: Error writing to PostScript output file"));
prt_file_error = TRUE;
}
@@ -1316,10 +1311,10 @@ static void prt_write_file_raw_len(char_u *buffer, int bytes)
static void prt_write_file(char_u *buffer)
{
- prt_write_file_len(buffer, (int)STRLEN(buffer));
+ prt_write_file_len(buffer, STRLEN(buffer));
}
-static void prt_write_file_len(char_u *buffer, int bytes)
+static void prt_write_file_len(char_u *buffer, size_t bytes)
{
prt_write_file_raw_len(buffer, bytes);
}
@@ -1398,15 +1393,11 @@ static void prt_dup_cidfont(char *original_name, char *new_name)
*/
static void prt_real_bits(double real, int precision, int *pinteger, int *pfraction)
{
- int i;
- int integer;
- float fraction;
-
- integer = (int)real;
- fraction = (float)(real - integer);
- if (real < (double)integer)
+ int integer = (int)real;
+ double fraction = real - integer;
+ if (real < integer)
fraction = -fraction;
- for (i = 0; i < precision; i++)
+ for (int i = 0; i < precision; i++)
fraction *= 10.0;
*pinteger = integer;
@@ -1463,7 +1454,7 @@ static void prt_flush_buffer(void)
if (!GA_EMPTY(&prt_ps_buffer)) {
/* Any background color must be drawn first */
if (prt_do_bgcol && (prt_new_bgcol != PRCOLOR_WHITE)) {
- int r, g, b;
+ unsigned int r, g, b;
if (prt_do_moveto) {
prt_write_real(prt_pos_x_moveto, 2);
@@ -1477,8 +1468,8 @@ static void prt_flush_buffer(void)
prt_write_real(prt_line_height, 2);
/* Lastly add the color of the background */
- r = ((unsigned)prt_new_bgcol & 0xff0000) >> 16;
- g = ((unsigned)prt_new_bgcol & 0xff00) >> 8;
+ r = (prt_new_bgcol & 0xff0000) >> 16;
+ g = (prt_new_bgcol & 0xff00) >> 8;
b = prt_new_bgcol & 0xff;
prt_write_real(r / 255.0, 3);
prt_write_real(g / 255.0, 3);
@@ -1505,7 +1496,8 @@ static void prt_flush_buffer(void)
prt_write_string("<");
else
prt_write_string("(");
- prt_write_file_raw_len(prt_ps_buffer.ga_data, prt_ps_buffer.ga_len);
+ assert(prt_ps_buffer.ga_len >= 0);
+ prt_write_file_raw_len(prt_ps_buffer.ga_data, (size_t)prt_ps_buffer.ga_len);
if (prt_out_mbyte)
prt_write_string(">");
else
@@ -1954,32 +1946,32 @@ void mch_print_cleanup(void)
}
}
-static float to_device_units(int idx, double physsize, int def_number)
+static double to_device_units(int idx, double physsize, int def_number)
{
- float ret;
- int u;
+ double ret;
int nr;
- u = prt_get_unit(idx);
+ int u = prt_get_unit(idx);
if (u == PRT_UNIT_NONE) {
u = PRT_UNIT_PERC;
nr = def_number;
- } else
+ } else {
nr = printer_opts[idx].number;
+ }
switch (u) {
case PRT_UNIT_INCH:
- ret = (float)(nr * PRT_PS_DEFAULT_DPI);
+ ret = nr * PRT_PS_DEFAULT_DPI;
break;
case PRT_UNIT_MM:
- ret = (float)(nr * PRT_PS_DEFAULT_DPI) / (float)25.4;
+ ret = nr * PRT_PS_DEFAULT_DPI / 25.4;
break;
case PRT_UNIT_POINT:
- ret = (float)nr;
+ ret = nr;
break;
case PRT_UNIT_PERC:
default:
- ret = (float)(physsize * nr) / 100;
+ ret = physsize * nr / 100;
break;
}
@@ -2022,7 +2014,8 @@ static int prt_get_cpl(void)
static void prt_build_cid_fontname(int font, char_u *name, int name_len)
{
- char *fontname = xstrndup((char *)name, name_len);
+ assert(name_len >= 0);
+ char *fontname = xstrndup((char *)name, (size_t)name_len);
prt_ps_mb_font.ps_fontname[font] = fontname;
}
@@ -2408,7 +2401,7 @@ static int prt_add_resource(struct prt_ps_resource_S *resource)
}
if (bytes_read == 0)
break;
- prt_write_file_raw_len(resource_buffer, (int)bytes_read);
+ prt_write_file_raw_len(resource_buffer, bytes_read);
if (prt_file_error) {
fclose(fd_resource);
return FALSE;
@@ -2851,8 +2844,8 @@ int mch_print_begin_page(char_u *str)
prt_dsc_noarg("EndPageSetup");
/* We have reset the font attributes, force setting them again. */
- curr_bg = (long_u)0xffffffff;
- curr_fg = (long_u)0xffffffff;
+ curr_bg = 0xffffffff;
+ curr_fg = 0xffffffff;
curr_bold = MAYBE;
return !prt_file_error;
@@ -2863,8 +2856,8 @@ int mch_print_blank_page(void)
return mch_print_begin_page(NULL) ? (mch_print_end_page()) : FALSE;
}
-static float prt_pos_x = 0;
-static float prt_pos_y = 0;
+static double prt_pos_x = 0;
+static double prt_pos_y = 0;
void mch_print_start_line(int margin, int page_line)
{
@@ -2885,8 +2878,8 @@ int mch_print_text_out(char_u *p, int len)
int need_break;
char_u ch;
char_u ch_buff[8];
- float char_width;
- float next_pos;
+ double char_width;
+ double next_pos;
int in_ascii;
int half_width;
@@ -2959,9 +2952,9 @@ int mch_print_text_out(char_u *p, int len)
prt_need_font = FALSE;
}
if (prt_need_fgcol) {
- int r, g, b;
- r = ((unsigned)prt_fgcol & 0xff0000) >> 16;
- g = ((unsigned)prt_fgcol & 0xff00) >> 8;
+ unsigned int r, g, b;
+ r = (prt_fgcol & 0xff0000) >> 16;
+ g = (prt_fgcol & 0xff00) >> 8;
b = prt_fgcol & 0xff;
prt_write_real(r / 255.0, 3);
@@ -3003,9 +2996,9 @@ int mch_print_text_out(char_u *p, int len)
*/
do {
ch = prt_hexchar[(unsigned)(*p) >> 4];
- ga_append(&prt_ps_buffer, ch);
+ ga_append(&prt_ps_buffer, (char)ch);
ch = prt_hexchar[(*p) & 0xf];
- ga_append(&prt_ps_buffer, ch);
+ ga_append(&prt_ps_buffer, (char)ch);
p++;
} while (--len);
} else {
@@ -3032,13 +3025,13 @@ int mch_print_text_out(char_u *p, int len)
default:
sprintf((char *)ch_buff, "%03o", (unsigned int)ch);
- ga_append(&prt_ps_buffer, ch_buff[0]);
- ga_append(&prt_ps_buffer, ch_buff[1]);
- ga_append(&prt_ps_buffer, ch_buff[2]);
+ ga_append(&prt_ps_buffer, (char)ch_buff[0]);
+ ga_append(&prt_ps_buffer, (char)ch_buff[1]);
+ ga_append(&prt_ps_buffer, (char)ch_buff[2]);
break;
}
} else
- ga_append(&prt_ps_buffer, ch);
+ ga_append(&prt_ps_buffer, (char)ch);
}
/* Need to free any translated characters */
@@ -3080,17 +3073,17 @@ void mch_print_set_font(int iBold, int iItalic, int iUnderline)
}
}
-void mch_print_set_bg(long_u bgcol)
+void mch_print_set_bg(uint32_t bgcol)
{
- prt_bgcol = (int)bgcol;
+ prt_bgcol = bgcol;
prt_attribute_change = TRUE;
prt_need_bgcol = TRUE;
}
-void mch_print_set_fg(long_u fgcol)
+void mch_print_set_fg(uint32_t fgcol)
{
- if (fgcol != (long_u)prt_fgcol) {
- prt_fgcol = (int)fgcol;
+ if (fgcol != prt_fgcol) {
+ prt_fgcol = fgcol;
prt_attribute_change = TRUE;
prt_need_fgcol = TRUE;
}
diff --git a/src/nvim/hardcopy.h b/src/nvim/hardcopy.h
index fa171db989..4ead8dd5d4 100644
--- a/src/nvim/hardcopy.h
+++ b/src/nvim/hardcopy.h
@@ -1,12 +1,14 @@
#ifndef NVIM_HARDCOPY_H
#define NVIM_HARDCOPY_H
+#include <stdint.h>
+
/*
* Structure to hold printing color and font attributes.
*/
typedef struct {
- long_u fg_color;
- long_u bg_color;
+ uint32_t fg_color;
+ uint32_t bg_color;
int bold;
int italic;
int underline;
@@ -38,7 +40,7 @@ typedef struct {
typedef struct {
const char *name;
int hasnum;
- long number;
+ int number;
char_u *string; /* points into option string */
int strlen;
int present;
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c
index 39ad512227..56276db3ce 100644
--- a/src/nvim/indent_c.c
+++ b/src/nvim/indent_c.c
@@ -1463,9 +1463,7 @@ void parse_cino(buf_T *buf)
if (*p == '-')
++p;
char_u *digits_start = p; /* remember where the digits start */
- int64_t digits = getdigits(&p);
- assert(digits <= INT_MAX);
- int n = (int)digits;
+ int n = getdigits_int(&p);
divider = 0;
if (*p == '.') { /* ".5s" means a fraction */
fraction = atoi((char *)++p);
@@ -1678,9 +1676,7 @@ int get_c_indent(void)
else if (*p == COM_LEFT || *p == COM_RIGHT)
align = *p++;
else if (VIM_ISDIGIT(*p) || *p == '-') {
- int64_t digits = getdigits(&p);
- assert(digits <= INT_MAX);
- off = (int)digits;
+ off = getdigits_int(&p);
}
else
++p;
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 33eaf35555..251926c01a 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -487,7 +487,7 @@ char_u *get_special_key_name(int c, int modifiers)
* If there is a match, srcp is advanced to after the <> name.
* dst[] must be big enough to hold the result (up to six characters)!
*/
-int
+unsigned int
trans_special (
char_u **srcp,
char_u *dst,
@@ -729,9 +729,9 @@ int get_special_key_code(char_u *name)
return 0;
}
-char_u *get_key_name(int i)
+char_u *get_key_name(size_t i)
{
- if (i >= (int)KEY_NAMES_TABLE_LEN)
+ if (i >= KEY_NAMES_TABLE_LEN)
return NULL;
return key_names_table[i].name;
}
diff --git a/src/nvim/keymap.h b/src/nvim/keymap.h
index 94ea095ace..c82a95c00c 100644
--- a/src/nvim/keymap.h
+++ b/src/nvim/keymap.h
@@ -97,9 +97,6 @@
/* Used a termcap entry that produces a normal character. */
#define KS_KEY 242
-/* Used for the qnx pterm mouse. */
-#define KS_PTERM_MOUSE 241
-
/* Used for click in a tab pages label. */
#define KS_TABLINE 240
@@ -412,7 +409,6 @@ enum key_extra {
#define K_NETTERM_MOUSE TERMCAP2KEY(KS_NETTERM_MOUSE, KE_FILLER)
#define K_DEC_MOUSE TERMCAP2KEY(KS_DEC_MOUSE, KE_FILLER)
-#define K_PTERM_MOUSE TERMCAP2KEY(KS_PTERM_MOUSE, KE_FILLER)
#define K_URXVT_MOUSE TERMCAP2KEY(KS_URXVT_MOUSE, KE_FILLER)
#define K_SGR_MOUSE TERMCAP2KEY(KS_SGR_MOUSE, KE_FILLER)
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 1f6c8ddc81..05b9778102 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -149,10 +149,6 @@ void early_init(void)
(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();
@@ -265,10 +261,7 @@ int main(int argc, char **argv)
if (params.want_full_screen && !silent_mode) {
if (embedded_mode) {
- // In embedded mode don't do terminal-related initializations, assume an
- // initial screen size of 80x20
- full_screen = true;
- screen_resize(80, 20, false);
+ // embedded mode implies abstract_ui
termcapinit((uint8_t *)"abstract_ui");
} else {
// set terminal name and get terminal capabilities (will set full_screen)
@@ -282,7 +275,9 @@ int main(int argc, char **argv)
event_init();
if (abstract_ui) {
+ full_screen = true;
t_colors = 256;
+ T_CCO = (uint8_t *)"256";
} else {
// Print a warning if stdout is not a terminal TODO(tarruda): Remove this
// check once the new terminal UI is implemented
@@ -1564,19 +1559,15 @@ static void handle_quickfix(mparm_T *paramp)
static void handle_tag(char_u *tagname)
{
if (tagname != NULL) {
-#if defined(HAS_SWAP_EXISTS_ACTION)
swap_exists_did_quit = FALSE;
-#endif
vim_snprintf((char *)IObuff, IOSIZE, "ta %s", tagname);
do_cmdline_cmd(IObuff);
TIME_MSG("jumping to tag");
-#if defined(HAS_SWAP_EXISTS_ACTION)
/* If the user doesn't want to edit the file then we quit here. */
if (swap_exists_did_quit)
getout(1);
-#endif
}
}
@@ -1611,10 +1602,8 @@ static void read_stdin(void)
{
int i;
-#if defined(HAS_SWAP_EXISTS_ACTION)
/* When getting the ATTENTION prompt here, use a dialog */
swap_exists_action = SEA_DIALOG;
-#endif
no_wait_return = TRUE;
i = msg_didany;
set_buflisted(TRUE);
@@ -1622,9 +1611,7 @@ static void read_stdin(void)
no_wait_return = FALSE;
msg_didany = i;
TIME_MSG("reading stdin");
-#if defined(HAS_SWAP_EXISTS_ACTION)
check_swap_exists_action();
-#endif
/*
* Close stdin and dup it from stderr. Required for GPM to work
* properly, and for running external commands.
@@ -1706,16 +1693,13 @@ static void create_windows(mparm_T *parmp)
/* Set 'foldlevel' to 'foldlevelstart' if it's not negative. */
if (p_fdls >= 0)
curwin->w_p_fdl = p_fdls;
-#if defined(HAS_SWAP_EXISTS_ACTION)
/* When getting the ATTENTION prompt here, use a dialog */
swap_exists_action = SEA_DIALOG;
-#endif
set_buflisted(TRUE);
/* create memfile, read file */
(void)open_buffer(FALSE, NULL, 0);
-#if defined(HAS_SWAP_EXISTS_ACTION)
if (swap_exists_action == SEA_QUIT) {
if (got_int || only_one_window()) {
/* abort selected or quit and only one window */
@@ -1730,7 +1714,6 @@ static void create_windows(mparm_T *parmp)
swap_exists_action = SEA_NONE;
} else
handle_swap_exists(NULL);
-#endif
dorewind = TRUE; /* start again */
}
os_breakcheck();
@@ -1801,13 +1784,10 @@ static void edit_buffers(mparm_T *parmp)
curwin->w_arg_idx = arg_idx;
/* Edit file from arg list, if there is one. When "Quit" selected
* at the ATTENTION prompt close the window. */
-# ifdef HAS_SWAP_EXISTS_ACTION
swap_exists_did_quit = FALSE;
-# endif
(void)do_ecmd(0, arg_idx < GARGCOUNT
? alist_name(&GARGLIST[arg_idx]) : NULL,
NULL, NULL, ECMD_LASTL, ECMD_HIDE, curwin);
-# ifdef HAS_SWAP_EXISTS_ACTION
if (swap_exists_did_quit) {
/* abort or quit selected */
if (got_int || only_one_window()) {
@@ -1818,7 +1798,6 @@ static void edit_buffers(mparm_T *parmp)
win_close(curwin, TRUE);
advance = FALSE;
}
-# endif
if (arg_idx == GARGCOUNT - 1)
arg_had_last = TRUE;
++arg_idx;
@@ -2219,7 +2198,6 @@ static void usage(void)
mch_exit(0);
}
-#if defined(HAS_SWAP_EXISTS_ACTION)
/*
* Check the result of the ATTENTION dialog:
* When "Quit" selected, exit Vim.
@@ -2232,5 +2210,4 @@ static void check_swap_exists_action(void)
handle_swap_exists(NULL);
}
-#endif
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 4ded438f52..cfc702f189 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -127,6 +127,7 @@ int setmark_pos(int c, pos_T *pos, int fnum)
return OK;
}
if (isupper(c)) {
+ assert(c >= 'A' && c <= 'Z');
i = c - 'A';
namedfm[i].fmark.mark = *pos;
namedfm[i].fmark.fnum = fnum;
@@ -1179,7 +1180,7 @@ void set_last_cursor(win_T *win)
win->w_buffer->b_last_cursor = win->w_cursor;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_all_marks(void)
{
int i;
@@ -1219,13 +1220,15 @@ int read_viminfo_filemark(vir_T *virp, int force)
}
} else if (VIM_ISDIGIT(*str))
fm = &namedfm[*str - '0' + NMARKS];
- else
+ else { // is uppercase
+ assert(*str >= 'A' && *str <= 'Z');
fm = &namedfm[*str - 'A'];
+ }
if (fm != NULL && (fm->fmark.mark.lnum == 0 || force)) {
str = skipwhite(str + 1);
- fm->fmark.mark.lnum = getdigits(&str);
+ fm->fmark.mark.lnum = getdigits_long(&str);
str = skipwhite(str);
- fm->fmark.mark.col = getdigits(&str);
+ fm->fmark.mark.col = getdigits_int(&str);
fm->fmark.mark.coladd = 0;
fm->fmark.fnum = 0;
str = skipwhite(str);
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index 3274c8d8ec..bc8f768724 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -106,8 +106,6 @@
#include "nvim/os/os.h"
#include "nvim/arabic.h"
-#define WINBYTE BYTE
-
typedef struct {
int rangeStart;
int rangeEnd;
@@ -365,10 +363,6 @@ enc_alias_table[] =
{NULL, 0}
};
-#ifndef CP_UTF8
-# define CP_UTF8 65001 /* magic number from winnls.h */
-#endif
-
/*
* Find encoding "name" in the list of canonical encoding names.
* Returns -1 if not found.
@@ -3452,7 +3446,7 @@ char_u * enc_locale(void)
return enc_canonize((char_u *)buf);
}
-# if defined(USE_ICONV) || defined(PROTO)
+# if defined(USE_ICONV)
/*
@@ -3591,7 +3585,7 @@ static char_u * iconv_string(vimconv_T *vcp, char_u *str, int slen, int *unconvl
return result;
}
-# if defined(DYNAMIC_ICONV) || defined(PROTO)
+# if defined(DYNAMIC_ICONV)
/*
* Dynamically load the "iconv.dll" on Win32.
*/
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index f6246c8b57..1fa6d6acc6 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -3000,7 +3000,7 @@ static void ml_lineadd(buf_T *buf, int count)
}
}
-#if defined(HAVE_READLINK) || defined(PROTO)
+#if defined(HAVE_READLINK)
/*
* Resolve a symlink in the last component of a file name.
* Note that f_resolve() does it for every part of the path, we don't do that
@@ -3367,9 +3367,7 @@ findswapname (
* for the current file, and the buffer was not recovered. */
if (differ == FALSE && !(curbuf->b_flags & BF_RECOVERED)
&& vim_strchr(p_shm, SHM_ATTENTION) == NULL) {
-#if defined(HAS_SWAP_EXISTS_ACTION)
int choice = 0;
-#endif
#ifdef UNIX
process_still_running = FALSE;
@@ -3427,7 +3425,6 @@ findswapname (
redraw_all_later(NOT_VALID);
}
-#if defined(HAS_SWAP_EXISTS_ACTION)
if (choice > 0) {
switch (choice) {
case 1:
@@ -3454,7 +3451,6 @@ findswapname (
if (!os_file_exists(fname))
break;
} else
-#endif
{
MSG_PUTS("\n");
if (msg_silent == 0)
diff --git a/src/nvim/memory.c b/src/nvim/memory.c
index f38dfd56ac..a2274a25fe 100644
--- a/src/nvim/memory.c
+++ b/src/nvim/memory.c
@@ -440,7 +440,7 @@ void do_outofmem_msg(size_t size)
}
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
#include "nvim/file_search.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index b31b6c1cec..9c1ca71477 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -120,7 +120,7 @@ ex_menu (
break;
if (vim_iswhite(*p)) {
for (i = 0; i < MENUDEPTH && !vim_iswhite(*arg); ++i) {
- pri_tab[i] = getdigits(&arg);
+ pri_tab[i] = getdigits_int(&arg);
if (pri_tab[i] == 0)
pri_tab[i] = 500;
if (*arg == '.')
@@ -1359,7 +1359,7 @@ void ex_emenu(exarg_T *eap)
#if defined(FEAT_GUI_MSWIN) \
|| defined(FEAT_GUI_GTK) \
- || defined(FEAT_BEVAL_TIP) || defined(PROTO)
+ || defined(FEAT_BEVAL_TIP)
/*
* Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy.
*/
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 46e0a1a0df..9cd3814826 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -10,8 +10,6 @@
* message.c: functions for displaying messages on the command line
*/
-#define MESSAGE_FILE /* don't include prototype for smsg() */
-
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index 4f17f84e11..f756201efb 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -525,7 +525,7 @@ open_line (
if (*p == COM_RIGHT || *p == COM_LEFT)
c = *p++;
else if (VIM_ISDIGIT(*p) || *p == '-')
- off = getdigits(&p);
+ off = getdigits_int(&p);
else
++p;
}
@@ -2662,7 +2662,7 @@ void init_homedir(void)
}
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_homedir(void)
{
free(homedir);
diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c
index 4c35cce09a..c8f8252e6d 100644
--- a/src/nvim/msgpack_rpc/channel.c
+++ b/src/nvim/msgpack_rpc/channel.c
@@ -45,6 +45,7 @@ typedef struct {
typedef struct {
uint64_t id;
+ size_t pending_requests;
PMap(cstr_t) *subscribed_events;
bool is_job, closed;
msgpack_unpacker *unpacker;
@@ -83,7 +84,6 @@ static uint64_t next_id = 1;
static PMap(uint64_t) *channels = NULL;
static PMap(cstr_t) *event_strings = NULL;
static msgpack_sbuffer out_buffer;
-static size_t pending_requests = 0;
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "msgpack_rpc/channel.c.generated.h"
@@ -103,14 +103,7 @@ void channel_init(void)
}
if (abstract_ui) {
- // Add handler for "attach_ui"
remote_ui_init();
- String method = cstr_as_string("attach_ui");
- MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = true};
- msgpack_rpc_add_method_handler(method, handler);
- method = cstr_as_string("detach_ui");
- handler.fn = remote_ui_detach;
- msgpack_rpc_add_method_handler(method, handler);
}
}
@@ -200,20 +193,21 @@ bool channel_send_event(uint64_t id, char *name, Array args)
return false;
}
- if (pending_requests) {
- DelayedNotification p = {
- .channel = channel,
- .method = cstr_to_string(name),
- .args = args
- };
- // Pending request, queue the notification for sending later
- *kl_pushp(DelayedNotification, delayed_notifications) = p;
- } else {
- if (channel) {
- send_event(channel, name, args);
+ if (channel) {
+ if (channel->pending_requests) {
+ DelayedNotification p = {
+ .channel = channel,
+ .method = cstr_to_string(name),
+ .args = args
+ };
+ // Pending request, queue the notification for sending later
+ *kl_pushp(DelayedNotification, delayed_notifications) = p;
} else {
- broadcast_event(name, args);
+ send_event(channel, name, args);
}
+ } else {
+ // TODO(tarruda): Implement event broadcasting in vimscript
+ broadcast_event(name, args);
}
return true;
@@ -246,10 +240,10 @@ Object channel_send_call(uint64_t id,
// Push the frame
ChannelCallFrame frame = {request_id, false, false, NIL};
kv_push(ChannelCallFrame *, channel->call_stack, &frame);
- pending_requests++;
+ channel->pending_requests++;
event_poll_until(-1, frame.returned);
(void)kv_pop(channel->call_stack);
- pending_requests--;
+ channel->pending_requests--;
if (frame.errored) {
api_set_error(err, Exception, "%s", frame.result.data.string.data);
@@ -261,7 +255,7 @@ Object channel_send_call(uint64_t id,
free_channel(channel);
}
- if (!pending_requests) {
+ if (!channel->pending_requests) {
send_delayed_notifications();
}
@@ -644,6 +638,7 @@ static void close_channel(Channel *channel)
uv_handle_t *handle = (uv_handle_t *)channel->data.streams.uv;
if (handle) {
uv_close(handle, close_cb);
+ free_channel(channel);
} else {
event_push((Event) { .handler = on_stdio_close }, false);
}
@@ -687,6 +682,7 @@ static Channel *register_channel(void)
rv->closed = false;
rv->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE);
rv->id = next_id++;
+ rv->pending_requests = 0;
rv->subscribed_events = pmap_new(cstr_t)();
rv->next_request_id = 1;
kv_init(rv->call_stack);
diff --git a/src/nvim/msgpack_rpc/remote_ui.c b/src/nvim/msgpack_rpc/remote_ui.c
index f980a77b4c..361e93a6da 100644
--- a/src/nvim/msgpack_rpc/remote_ui.c
+++ b/src/nvim/msgpack_rpc/remote_ui.c
@@ -26,18 +26,44 @@ static PMap(uint64_t) *connected_uis = NULL;
void remote_ui_init(void)
{
connected_uis = pmap_new(uint64_t)();
+ // Add handler for "attach_ui"
+ String method = cstr_as_string("ui_attach");
+ MsgpackRpcRequestHandler handler = {.fn = remote_ui_attach, .defer = false};
+ msgpack_rpc_add_method_handler(method, handler);
+ method = cstr_as_string("ui_detach");
+ handler.fn = remote_ui_detach;
+ msgpack_rpc_add_method_handler(method, handler);
+ method = cstr_as_string("ui_try_resize");
+ handler.fn = remote_ui_try_resize;
+ msgpack_rpc_add_method_handler(method, handler);
}
-Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args,
- Error *error)
+void remote_ui_disconnect(uint64_t channel_id)
+{
+ UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ if (!ui) {
+ return;
+ }
+ UIData *data = ui->data;
+ // destroy pending screen updates
+ api_free_array(data->buffer);
+ pmap_del(uint64_t)(connected_uis, channel_id);
+ free(ui->data);
+ ui_detach(ui);
+ free(ui);
+}
+
+static Object remote_ui_attach(uint64_t channel_id, uint64_t request_id,
+ Array args, Error *error)
{
if (pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(error, Exception, _("UI already attached for channel"));
return NIL;
}
- if (args.size != 2 || args.items[0].type != kObjectTypeInteger
+ if (args.size != 3 || args.items[0].type != kObjectTypeInteger
|| args.items[1].type != kObjectTypeInteger
+ || args.items[2].type != kObjectTypeBoolean
|| args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) {
api_set_error(error, Validation,
_("Arguments must be a pair of positive integers "
@@ -50,6 +76,7 @@ Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args,
UI *ui = xcalloc(1, sizeof(UI));
ui->width = (int)args.items[0].data.integer;
ui->height = (int)args.items[1].data.integer;
+ ui->rgb = args.items[2].data.boolean;
ui->data = data;
ui->resize = remote_ui_resize;
ui->clear = remote_ui_clear;
@@ -67,16 +94,19 @@ Object remote_ui_attach(uint64_t channel_id, uint64_t request_id, Array args,
ui->put = remote_ui_put;
ui->bell = remote_ui_bell;
ui->visual_bell = remote_ui_visual_bell;
+ ui->update_fg = remote_ui_update_fg;
+ ui->update_bg = remote_ui_update_bg;
ui->flush = remote_ui_flush;
ui->suspend = remote_ui_suspend;
+ ui->set_title = remote_ui_set_title;
+ ui->set_icon = remote_ui_set_icon;
pmap_put(uint64_t)(connected_uis, channel_id, ui);
ui_attach(ui);
-
return NIL;
}
-Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, Array args,
- Error *error)
+static Object remote_ui_detach(uint64_t channel_id, uint64_t request_id,
+ Array args, Error *error)
{
if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
api_set_error(error, Exception, _("UI is not attached for channel"));
@@ -86,21 +116,30 @@ Object remote_ui_detach(uint64_t channel_id, uint64_t request_id, Array args,
return NIL;
}
-void remote_ui_disconnect(uint64_t channel_id)
+static Object remote_ui_try_resize(uint64_t channel_id, uint64_t request_id,
+ Array args, Error *error)
{
- UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
- if (!ui) {
- return;
+ if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ api_set_error(error, Exception, _("UI is not attached for channel"));
}
- UIData *data = ui->data;
- // destroy pending screen updates
- api_free_array(data->buffer);
- pmap_del(uint64_t)(connected_uis, channel_id);
- free(ui->data);
- ui_detach(ui);
- free(ui);
+
+ if (args.size != 2 || args.items[0].type != kObjectTypeInteger
+ || args.items[1].type != kObjectTypeInteger
+ || args.items[0].data.integer <= 0 || args.items[1].data.integer <= 0) {
+ api_set_error(error, Validation,
+ _("Arguments must be a pair of positive integers "
+ "representing the remote screen width/height"));
+ return NIL;
+ }
+
+ UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ ui->width = (int)args.items[0].data.integer;
+ ui->height = (int)args.items[1].data.integer;
+ ui_refresh();
+ return NIL;
}
+
static void push_call(UI *ui, char *name, Array args)
{
Array call = ARRAY_DICT_INIT;
@@ -214,10 +253,6 @@ static void remote_ui_highlight_set(UI *ui, HlAttrs attrs)
PUT(hl, "bold", BOOLEAN_OBJ(true));
}
- if (attrs.standout) {
- PUT(hl, "standout", BOOLEAN_OBJ(true));
- }
-
if (attrs.underline) {
PUT(hl, "underline", BOOLEAN_OBJ(true));
}
@@ -266,6 +301,20 @@ static void remote_ui_visual_bell(UI *ui)
push_call(ui, "visual_bell", args);
}
+static void remote_ui_update_fg(UI *ui, int fg)
+{
+ Array args = ARRAY_DICT_INIT;
+ ADD(args, INTEGER_OBJ(fg));
+ push_call(ui, "update_fg", args);
+}
+
+static void remote_ui_update_bg(UI *ui, int bg)
+{
+ Array args = ARRAY_DICT_INIT;
+ ADD(args, INTEGER_OBJ(bg));
+ push_call(ui, "update_bg", args);
+}
+
static void remote_ui_flush(UI *ui)
{
UIData *data = ui->data;
@@ -275,6 +324,20 @@ static void remote_ui_flush(UI *ui)
static void remote_ui_suspend(UI *ui)
{
- UIData *data = ui->data;
- remote_ui_disconnect(data->channel_id);
+ Array args = ARRAY_DICT_INIT;
+ push_call(ui, "suspend", args);
+}
+
+static void remote_ui_set_title(UI *ui, char *title)
+{
+ Array args = ARRAY_DICT_INIT;
+ ADD(args, STRING_OBJ(cstr_to_string(title)));
+ push_call(ui, "set_title", args);
+}
+
+static void remote_ui_set_icon(UI *ui, char *icon)
+{
+ Array args = ARRAY_DICT_INIT;
+ ADD(args, STRING_OBJ(cstr_to_string(icon)));
+ push_call(ui, "set_icon", args);
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 5a6cc92a33..5b138f2d88 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -389,6 +389,7 @@ static int find_command(int cmdchar)
/* If the character is in the first part: The character is the index into
* nv_cmd_idx[]. */
+ assert(nv_max_linear < (int)NV_CMDS_SIZE);
if (cmdchar <= nv_max_linear)
return nv_cmd_idx[cmdchar];
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index 3cefc9f623..8fb3ba7f08 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2293,7 +2293,7 @@ void init_yank(void)
y_regs[i].y_array = NULL;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void clear_registers(void)
{
int i;
@@ -4501,7 +4501,7 @@ int read_viminfo_register(vir_T *virp, int force)
y_current->y_type = MLINE;
/* get the block width; if it's missing we get a zero, which is OK */
str = skipwhite(skiptowhite(str));
- y_current->y_width = getdigits(&str);
+ y_current->y_width = getdigits_int(&str);
}
while (!(eof = viminfo_readline(virp))
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 1c07bef3e3..88108b14a2 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -887,7 +887,7 @@ static struct vimoption
SCRIPTID_INIT},
{"history", "hi", P_NUM|P_VIM,
(char_u *)&p_hi, PV_NONE,
- {(char_u *)0L, (char_u *)20L} SCRIPTID_INIT},
+ {(char_u *)0L, (char_u *)50L} SCRIPTID_INIT},
{"hkmap", "hk", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_hkmap, PV_NONE,
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
@@ -2237,7 +2237,7 @@ void set_number_default(char *name, long val)
options[opt_idx].def_val[VI_DEFAULT] = (char_u *)val;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
/*
* Free all options.
*/
@@ -2918,7 +2918,7 @@ do_set (
*/
else if (varp == (char_u *)&p_bs
&& VIM_ISDIGIT(**(char_u **)varp)) {
- i = getdigits((char_u **)varp);
+ i = getdigits_int((char_u **)varp);
switch (i) {
case 0:
*(char_u **)varp = empty_option;
@@ -2943,7 +2943,7 @@ do_set (
else if (varp == (char_u *)&p_ww
&& VIM_ISDIGIT(*arg)) {
*errbuf = NUL;
- i = getdigits(&arg);
+ i = getdigits_int(&arg);
if (i & 1)
STRCAT(errbuf, "b,");
if (i & 2)
@@ -4359,7 +4359,7 @@ did_set_string_option (
/* set ru_wid if 'ruf' starts with "%99(" */
if (*++s == '-') /* ignore a '-' */
s++;
- wid = getdigits(&s);
+ wid = getdigits_int(&s);
if (wid && *s == '(' && (errmsg = check_stl_option(p_ruf)) == NULL)
ru_wid = wid;
else
@@ -4664,14 +4664,14 @@ char_u *check_colorcolumn(win_T *wp)
++s;
if (!VIM_ISDIGIT(*s))
return e_invarg;
- col = col * getdigits(&s);
+ col = col * getdigits_int(&s);
if (wp->w_buffer->b_p_tw == 0)
goto skip; /* 'textwidth' not set, skip this item */
col += wp->w_buffer->b_p_tw;
if (col < 0)
goto skip;
} else if (VIM_ISDIGIT(*s))
- col = getdigits(&s);
+ col = getdigits_int(&s);
else
return e_invarg;
color_cols[count++] = col - 1; /* 1-based to 0-based */
@@ -7257,7 +7257,6 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
{
int num_normal = 0; /* Nr of matching non-term-code settings */
int num_term = 0; /* Nr of matching terminal code settings */
- int opt_idx;
int match;
int count = 0;
char_u *str;
@@ -7283,7 +7282,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
(*file)[count++] = vim_strsave((char_u *)names[match]);
}
}
- for (opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
+ for (size_t opt_idx = 0; (str = (char_u *)options[opt_idx].fullname) != NULL;
opt_idx++) {
if (options[opt_idx].var == NULL)
continue;
@@ -7326,7 +7325,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
* Check terminal key codes, these are not in the option table
*/
if (xp->xp_context != EXPAND_BOOL_SETTINGS && num_normal == 0) {
- for (opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) {
+ for (size_t opt_idx = 0; (str = get_termcode(opt_idx)) != NULL; opt_idx++) {
if (!isprint(str[0]) || !isprint(str[1]))
continue;
@@ -7363,7 +7362,7 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***
* Check special key names.
*/
regmatch->rm_ic = TRUE; /* ignore case here */
- for (opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) {
+ for (size_t opt_idx = 0; (str = get_key_name(opt_idx)) != NULL; opt_idx++) {
name_buf[0] = '<';
STRCPY(name_buf + 1, str);
STRCAT(name_buf, ">");
@@ -8115,12 +8114,12 @@ static bool briopt_check(win_T *wp)
&& ((p[6] == '-' && VIM_ISDIGIT(p[7])) || VIM_ISDIGIT(p[6])))
{
p += 6;
- bri_shift = getdigits(&p);
+ bri_shift = getdigits_int(&p);
}
else if (STRNCMP(p, "min:", 4) == 0 && VIM_ISDIGIT(p[4]))
{
p += 4;
- bri_min = getdigits(&p);
+ bri_min = getdigits_long(&p);
}
else if (STRNCMP(p, "sbr", 3) == 0)
{
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index 8b36df3276..99e8e645b6 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -576,13 +576,12 @@ EXTERN char_u *p_ttym; /* 'ttymouse' */
EXTERN unsigned ttym_flags;
# ifdef IN_OPTION_C
static char *(p_ttym_values[]) =
-{"xterm", "xterm2", "dec", "netterm", "pterm", "urxvt", "sgr", NULL};
+{"xterm", "xterm2", "dec", "netterm", "urxvt", "sgr", NULL};
# endif
# define TTYM_XTERM 0x01
# define TTYM_XTERM2 0x02
# define TTYM_DEC 0x04
# define TTYM_NETTERM 0x08
-# define TTYM_PTERM 0x10
# define TTYM_URXVT 0x20
# define TTYM_SGR 0x40
#endif
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index cddc28fac9..2ae4558f3d 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -184,18 +184,24 @@ size_t input_enqueue(String keys)
while (rbuffer_available(input_buffer) >= 6 && ptr < end) {
uint8_t buf[6] = {0};
- int new_size = trans_special((uint8_t **)&ptr, buf, false);
+ unsigned int new_size = trans_special((uint8_t **)&ptr, buf, false);
if (!new_size) {
+ if (*ptr == '<') {
+ // Invalid key sequence, skip until the next '>' or until *end
+ do {
+ ptr++;
+ } while (ptr < end && *ptr != '>');
+ ptr++;
+ continue;
+ }
// copy the character unmodified
*buf = (uint8_t)*ptr++;
new_size = 1;
}
new_size = handle_mouse_event(&ptr, buf, new_size);
- // TODO(tarruda): Don't produce past unclosed '<' characters, except if
- // there's a lot of characters after the '<'
- rbuffer_write(input_buffer, (char *)buf, (size_t)new_size);
+ rbuffer_write(input_buffer, (char *)buf, new_size);
}
size_t rv = (size_t)(ptr - keys.data);
@@ -205,7 +211,8 @@ size_t input_enqueue(String keys)
// Mouse event handling code(Extract row/col if available and detect multiple
// clicks)
-static int handle_mouse_event(char **ptr, uint8_t *buf, int bufsize)
+static unsigned int handle_mouse_event(char **ptr, uint8_t *buf,
+ unsigned int bufsize)
{
int mouse_code = 0;
@@ -216,7 +223,8 @@ static int handle_mouse_event(char **ptr, uint8_t *buf, int bufsize)
mouse_code = buf[5];
}
- if (mouse_code < KE_LEFTMOUSE || mouse_code > KE_RIGHTRELEASE) {
+ if (!((mouse_code >= KE_LEFTMOUSE && mouse_code <= KE_RIGHTRELEASE)
+ || (mouse_code >= KE_MOUSEDOWN && mouse_code <= KE_MOUSERIGHT))) {
return bufsize;
}
@@ -225,7 +233,7 @@ static int handle_mouse_event(char **ptr, uint8_t *buf, int bufsize)
// find mouse coordinates, and it would be too expensive to refactor this
// now.
int col, row, advance;
- if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance)) {
+ if (sscanf(*ptr, "<%d,%d>%n", &col, &row, &advance) != EOF && advance) {
if (col >= 0 && row >= 0) {
mouse_row = row;
mouse_col = col;
diff --git a/src/nvim/os/job.c b/src/nvim/os/job.c
index 17872ab9c9..8db5e3cc39 100644
--- a/src/nvim/os/job.c
+++ b/src/nvim/os/job.c
@@ -310,8 +310,15 @@ int job_wait(Job *job, int ms) FUNC_ATTR_NONNULL_ALL
// we'll assume that a user frantically hitting interrupt doesn't like
// the current job. Signal that it has to be killed.
if (got_int) {
+ got_int = false;
job_stop(job);
- event_poll(0);
+ if (ms == -1) {
+ // We can only return, if all streams/handles are closed and the job
+ // exited.
+ event_poll_until(-1, job->refcount == 1);
+ } else {
+ event_poll(0);
+ }
}
if (job->refcount == 1) {
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index d0f8442768..d481d6af56 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -24,7 +24,6 @@
#include "nvim/option_defs.h"
#include "nvim/charset.h"
#include "nvim/strings.h"
-#include "nvim/ui.h"
#define DYNAMIC_BUFFER_INIT {NULL, 0, 0}
@@ -414,6 +413,7 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer,
char *start = output;
size_t off = 0;
+ int lastrow = (int)Rows - 1;
while (off < remaining) {
if (output[off] == NL) {
// Insert the line
@@ -421,10 +421,8 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer,
if (to_buffer) {
ml_append(curwin->w_cursor.lnum++, (char_u *)output, 0, false);
} else {
- // pending data from the output buffer has been flushed to the screen,
- // safe to call ui_write directly
- ui_write((char_u *)output, (int)off);
- ui_write((char_u *)"\r\n", 2);
+ screen_del_lines(0, 0, 1, (int)Rows, true, NULL);
+ screen_puts_len((char_u *)output, (int)off, lastrow, 0, 0);
}
size_t skip = off + 1;
output += skip;
@@ -448,8 +446,8 @@ static size_t write_output(char *output, size_t remaining, bool to_buffer,
// remember that the NL was missing
curbuf->b_no_eol_lnum = curwin->w_cursor.lnum;
} else {
- ui_write((char_u *)output, (int)remaining);
- ui_write((char_u *)"\r\n", 2);
+ screen_del_lines(0, 0, 1, (int)Rows, true, NULL);
+ screen_puts_len((char_u *)output, (int)remaining, lastrow, 0, 0);
}
output += remaining;
} else if (to_buffer) {
diff --git a/src/nvim/os/time.c b/src/nvim/os/time.c
index 810ddea82b..b69be88fc7 100644
--- a/src/nvim/os/time.c
+++ b/src/nvim/os/time.c
@@ -80,11 +80,11 @@ struct tm *os_localtime_r(const time_t *restrict clock,
{
#ifdef UNIX
// POSIX provides localtime_r() as a thread-safe version of localtime().
- return localtime_r(clock, result);
+ return localtime_r(clock, result); // NOLINT(runtime/threadsafe_fn)
#else
// Windows version of localtime() is thread-safe.
// See http://msdn.microsoft.com/en-us/library/bf12f0hc%28VS.80%29.aspx
- struct tm *local_time = localtime(clock); // NOLINT
+ struct tm *local_time = localtime(clock); // NOLINT(runtime/threadsafe_fn)
if (!local_time) {
return NULL;
}
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index 7ec4059bce..f7b47f9569 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -43,6 +43,7 @@
#include "nvim/syntax.h"
#include "nvim/tempfile.h"
#include "nvim/term.h"
+#include "nvim/ui.h"
#include "nvim/types.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
@@ -181,22 +182,26 @@ void mch_settitle(char_u *title, char_u *icon)
* Note: if "t_ts" is set, title is set with escape sequence rather
* than x11 calls, because the x11 calls don't always work
*/
- if ((type || *T_TS != NUL) && title != NULL) {
+ if ((type || *T_TS != NUL || abstract_ui) && title != NULL) {
if (oldtitle == NULL
) /* first call but not in GUI, save title */
(void)get_x11_title(FALSE);
- if (*T_TS != NUL) /* it's OK if t_fs is empty */
+ if (abstract_ui) {
+ ui_set_title((char *)title);
+ } else if (*T_TS != NUL) /* it's OK if t_fs is empty */
term_settitle(title);
did_set_title = TRUE;
}
- if ((type || *T_CIS != NUL) && icon != NULL) {
+ if ((type || *T_CIS != NUL || abstract_ui) && icon != NULL) {
if (oldicon == NULL
) /* first call, save icon */
get_x11_icon(FALSE);
- if (*T_CIS != NUL) {
+ if (abstract_ui) {
+ ui_set_icon((char *)icon);
+ } else if (*T_CIS != NUL) {
out_str(T_CIS); /* set icon start */
out_str_nf(icon);
out_str(T_CIE); /* set icon end */
@@ -270,7 +275,7 @@ int use_xterm_mouse(void)
return 0;
}
-#if defined(USE_FNAME_CASE) || defined(PROTO)
+#if defined(USE_FNAME_CASE)
/*
* Set the case of the file name, if it already exists. This will cause the
* file name to remain exactly the same.
@@ -326,7 +331,7 @@ int len /* buffer size, only used when name gets longer */
}
#endif
-#if defined(HAVE_ACL) || defined(PROTO)
+#if defined(HAVE_ACL)
# ifdef HAVE_SYS_ACL_H
# include <sys/acl.h>
# endif
@@ -335,7 +340,7 @@ int len /* buffer size, only used when name gets longer */
# endif
-#if defined(HAVE_SELINUX) || defined(PROTO)
+#if defined(HAVE_SELINUX)
/*
* Copy security info from "from_file" to "to_file".
*/
@@ -437,7 +442,7 @@ int mch_nodetype(char_u *name)
return NODE_WRITABLE;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void mch_free_mem(void)
{
free(oldtitle);
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 8af4015611..219dac12de 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -403,9 +403,9 @@ char_u *save_absolute_path(const char_u *name)
}
-#if !defined(NO_EXPANDPATH) || defined(PROTO)
+#if !defined(NO_EXPANDPATH)
-#if defined(UNIX) || defined(USE_UNIXFILENAME) || defined(PROTO)
+#if defined(UNIX) || defined(USE_UNIXFILENAME)
/*
* Unix style wildcard expansion code.
* It's here because it's used both for Unix and Mac.
@@ -1622,7 +1622,7 @@ int same_directory(char_u *f1, char_u *f2)
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
}
-#if !defined(NO_EXPANDPATH) || defined(PROTO)
+#if !defined(NO_EXPANDPATH)
/*
* Compare path "p[]" to "q[]".
* If "maxlen" >= 0 compare "p[maxlen]" to "q[maxlen]"
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index dd7af63ce0..fafd99c046 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -3082,10 +3082,10 @@ static int read_limits(long *minval, long *maxval)
reverse = TRUE;
}
first_char = regparse;
- *minval = getdigits(&regparse);
+ *minval = getdigits_long(&regparse);
if (*regparse == ',') { /* There is a comma */
if (vim_isdigit(*++regparse))
- *maxval = getdigits(&regparse);
+ *maxval = getdigits_long(&regparse);
else
*maxval = MAX_LIMIT;
} else if (VIM_ISDIGIT(*first_char))
@@ -3228,7 +3228,7 @@ static garray_T backpos = GA_EMPTY_INIT_VALUE;
#define REGSTACK_INITIAL 2048
#define BACKPOS_INITIAL 64
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_regexp_stuff(void)
{
ga_clear(&regstack);
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 855c09619e..8f4f894128 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -4548,7 +4548,7 @@ static void screen_line(int row, int coloff, int endcol, int clear_width, int rl
int c;
c = fillchar_vsep(&hl);
- if (ScreenLines[off_to] != c
+ if (ScreenLines[off_to] != (schar_T)c
|| (enc_utf8 && (int)ScreenLinesUC[off_to]
!= (c >= 0x80 ? c : 0))
|| ScreenAttrs[off_to] != hl) {
@@ -5971,7 +5971,7 @@ void screen_stop_highlight(void)
*/
void reset_cterm_colors(void)
{
- if (t_colors > 1) {
+ if (!abstract_ui && t_colors > 1) {
/* set Normal cterm colors */
if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) {
out_str(T_OP);
@@ -6150,8 +6150,7 @@ void screen_fill(int start_row, int end_row, int start_col, int end_col, int c1,
return;
/* it's a "normal" terminal when not in a GUI or cterm */
- norm_term = (
- t_colors <= 1);
+ norm_term = (!abstract_ui && t_colors <= 1);
for (row = start_row; row < end_row; ++row) {
if (has_mbyte
) {
@@ -6675,8 +6674,8 @@ static void linecopy(int to, int from, win_T *wp)
*/
int can_clear(char_u *p)
{
- return *p != NUL && (t_colors <= 1
- || cterm_normal_bg_color == 0 || *T_UT != NUL);
+ return abstract_ui || (*p != NUL && (t_colors <= 1
+ || cterm_normal_bg_color == 0 || *T_UT != NUL));
}
/*
@@ -8186,8 +8185,13 @@ void screen_resize(int width, int height, int mustset)
Columns = width;
}
check_shellsize();
+ height = Rows;
+ width = Columns;
if (abstract_ui) {
+ // Clear the output buffer to ensure UIs don't receive redraw command meant
+ // for invalid screen sizes.
+ out_buf_clear();
ui_resize(width, height);
} else {
mch_set_shellsize();
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 5158e6cd86..e2781f17d5 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -294,7 +294,7 @@ void restore_search_patterns(void)
}
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_search_patterns(void)
{
free(spats[0].pat);
@@ -3757,7 +3757,6 @@ current_quote (
/*
* Find next search match under cursor, cursor at end.
* Used while an operator is pending, and in Visual mode.
- * TODO: redo only works when used in operator pending mode
*/
int
current_search (
@@ -3792,7 +3791,7 @@ current_search (
orig_pos = pos = curwin->w_cursor;
/* Is the pattern is zero-width? */
- int one_char = is_one_char(spats[last_idx].pat);
+ int one_char = is_one_char(spats[last_idx].pat, true);
if (one_char == -1) {
p_ws = old_p_ws;
return FAIL; /* pattern not found */
@@ -3840,6 +3839,10 @@ current_search (
int flags = forward ? SEARCH_END : 0;
pos_T start_pos = pos;
+ /* Check again from the current cursor position,
+ * since the next match might actually be only one char wide */
+ one_char = is_one_char(spats[last_idx].pat, false);
+
/* move to match, except for zero-width matches, in which case, we are
* already on the next match */
if (!one_char)
@@ -3878,24 +3881,33 @@ current_search (
/*
* Check if the pattern is one character or zero-width.
+ * If move is true, check from the beginning of the buffer,
+ * else from the current cursor position.
* Returns TRUE, FALSE or -1 for failure.
*/
-static int is_one_char(char_u *pattern)
+static int is_one_char(char_u *pattern, bool move)
{
regmmatch_T regmatch;
int nmatched = 0;
int result = -1;
pos_T pos;
int save_called_emsg = called_emsg;
+ int flag = 0;
if (search_regcomp(pattern, RE_SEARCH, RE_SEARCH,
SEARCH_KEEP, &regmatch) == FAIL)
return -1;
/* move to match */
- clearpos(&pos);
+ if (move) {
+ clearpos(&pos);
+ } else {
+ pos = curwin->w_cursor;
+ /* accept a match at the cursor position */
+ flag = SEARCH_START;
+ }
if (searchit(curwin, curbuf, &pos, FORWARD, spats[last_idx].pat, 1,
- SEARCH_KEEP, RE_SEARCH, 0, NULL) != FAIL) {
+ SEARCH_KEEP + flag, RE_SEARCH, 0, NULL) != FAIL) {
/* Zero-width pattern should match somewhere, then we can check if
* start and end are in the same position. */
called_emsg = FALSE;
@@ -4599,7 +4611,7 @@ int read_viminfo_search_pattern(vir_T *virp, int force)
if (lp[4] == 'E')
off_end = SEARCH_END;
lp += 5;
- off = getdigits(&lp);
+ off = getdigits_long(&lp);
}
if (lp[0] == '~') { /* use this pattern for last-used pattern */
setlast = TRUE;
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index b8713909b8..5e69a935ca 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -5162,7 +5162,7 @@ static unsigned get_affitem(int flagtype, char_u **pp)
++*pp; // always advance, avoid getting stuck
return 0;
}
- res = getdigits(pp);
+ res = getdigits_int(pp);
} else {
res = mb_ptr2char_adv(pp);
if (flagtype == AFT_LONG || (flagtype == AFT_CAPLONG
@@ -5283,7 +5283,9 @@ static bool flag_in_afflist(int flagtype, char_u *afflist, unsigned flag)
case AFT_NUM:
for (p = afflist; *p != NUL; ) {
- n = getdigits(&p);
+ int digits = getdigits_int(&p);
+ assert(digits >= 0);
+ n = (unsigned int)digits;
if (n == flag)
return true;
if (*p != NUL) // skip over comma
@@ -6357,19 +6359,19 @@ int spell_check_msm(void)
if (!VIM_ISDIGIT(*p))
return FAIL;
// block count = (value * 1024) / SBLOCKSIZE (but avoid overflow)
- start = (getdigits(&p) * 10) / (SBLOCKSIZE / 102);
+ start = (getdigits_long(&p) * 10) / (SBLOCKSIZE / 102);
if (*p != ',')
return FAIL;
++p;
if (!VIM_ISDIGIT(*p))
return FAIL;
- incr = (getdigits(&p) * 102) / (SBLOCKSIZE / 10);
+ incr = (getdigits_long(&p) * 102) / (SBLOCKSIZE / 10);
if (*p != ',')
return FAIL;
++p;
if (!VIM_ISDIGIT(*p))
return FAIL;
- added = getdigits(&p) * 1024;
+ added = getdigits_long(&p) * 1024;
if (*p != NUL)
return FAIL;
@@ -8355,7 +8357,7 @@ int spell_check_sps(void)
f = 0;
if (VIM_ISDIGIT(*buf)) {
s = buf;
- sps_limit = getdigits(&s);
+ sps_limit = getdigits_int(&s);
if (*s != NUL && !VIM_ISDIGIT(*s))
f = -1;
} else if (STRCMP(buf, "best") == 0)
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 25e4a6c93b..20fa35ed1c 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -329,7 +329,7 @@ void vim_strcat(char_u *restrict to, const char_u *restrict from,
STRCPY(to + tolen, from);
}
-#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)) || defined(PROTO)
+#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP))
/*
* Compare two strings, ignoring case, using current locale.
* Doesn't work for multi-byte characters.
@@ -353,7 +353,7 @@ int vim_stricmp(const char *s1, const char *s2)
}
#endif
-#if (!defined(HAVE_STRNCASECMP) && !defined(HAVE_STRNICMP)) || defined(PROTO)
+#if (!defined(HAVE_STRNCASECMP) && !defined(HAVE_STRNICMP))
/*
* Compare two strings, for length "len", ignoring case, using current locale.
* Doesn't work for multi-byte characters.
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 6787ca8080..3980a4d8e6 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -45,6 +45,7 @@
#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"
@@ -223,8 +224,6 @@ struct name_list {
#define ATTR_OFF (HL_ALL + 1)
-#define SYN_NAMELEN 50 /* maximum length of a syntax name */
-
static char *(spo_name_tab[SPO_COUNT]) =
{"ms=", "me=", "hs=", "he=", "rs=", "re=", "lc="};
@@ -4900,7 +4899,7 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
ci->sp_off_flags |= (1 << idx);
if (idx == SPO_LC_OFF) { /* lc=99 */
end += 3;
- *p = getdigits(&end);
+ *p = getdigits_int(&end);
/* "lc=" offset automatically sets "ms=" offset */
if (!(ci->sp_off_flags & (1 << SPO_MS_OFF))) {
@@ -4911,10 +4910,10 @@ static char_u *get_syn_pattern(char_u *arg, synpat_T *ci)
end += 4;
if (*end == '+') {
++end;
- *p = getdigits(&end); /* positive offset */
+ *p = getdigits_int(&end); /* positive offset */
} else if (*end == '-') {
++end;
- *p = -getdigits(&end); /* negative offset */
+ *p = -getdigits_int(&end); /* negative offset */
}
}
if (*end != ',')
@@ -4980,7 +4979,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
illegal = TRUE;
break;
}
- n = getdigits(&arg_end);
+ n = getdigits_long(&arg_end);
if (!eap->skip) {
if (key[4] == 'B')
curwin->w_s->b_syn_sync_linebreaks = n;
@@ -6036,6 +6035,7 @@ int load_colors(char_u *name)
apply_autocmds(EVENT_COLORSCHEME, name, curbuf->b_fname, FALSE, curbuf);
recursive = FALSE;
+ ui_refresh();
return retval;
}
@@ -6070,8 +6070,6 @@ do_highlight (
int error = FALSE;
int color;
int is_normal_group = FALSE; /* "Normal" group */
-# define is_menu_group 0
-# define is_tooltip_group 0
/*
* If no argument, list current highlighting.
@@ -6407,12 +6405,6 @@ do_highlight (
4+8, 4+8, 2+8, 2+8,
6+8, 6+8, 1+8, 1+8, 5+8,
5+8, 3+8, 3+8, 7+8, -1};
-#if defined(__QNXNTO__)
- static int *color_numbers_8_qansi = color_numbers_8;
- /* On qnx, the 8 & 16 color arrays are the same */
- if (STRNCMP(T_NAME, "qansi", 5) == 0)
- color_numbers_8_qansi = color_numbers_16;
-#endif
/* reduce calls to STRICMP a bit, it can be slow */
off = TOUPPER_ASC(*arg);
@@ -6433,11 +6425,7 @@ do_highlight (
if (color >= 0) {
if (t_colors == 8) {
/* t_Co is 8: use the 8 colors table */
-#if defined(__QNXNTO__)
- color = color_numbers_8_qansi[i];
-#else
color = color_numbers_8[i];
-#endif
if (key[5] == 'F') {
/* set/reset bold attribute to get light foreground
* colors (on some terminals, e.g. "linux") */
@@ -6448,8 +6436,7 @@ do_highlight (
HL_TABLE()[idx].sg_cterm &= ~HL_BOLD;
}
color &= 7; /* truncate to 8 colors */
- } else if (t_colors == 16 || t_colors == 88
- || t_colors == 256) {
+ } else if (t_colors == 16 || t_colors == 88 || t_colors == 256) {
/*
* Guess: if the termcap entry ends in 'm', it is
* probably an xterm-like terminal. Use the changed
@@ -6459,7 +6446,7 @@ do_highlight (
p = T_CAF;
else
p = T_CSF;
- if (*p != NUL && *(p + STRLEN(p) - 1) == 'm')
+ if (abstract_ui || (*p != NUL && *(p + STRLEN(p) - 1) == 'm'))
switch (t_colors) {
case 16:
color = color_numbers_8[i];
@@ -6593,7 +6580,7 @@ do_highlight (
* Copy characters from arg[] to buf[], translating <> codes.
*/
for (p = arg, off = 0; off < 100 - 6 && *p; ) {
- len = trans_special(&p, buf + off, FALSE);
+ len = (int)trans_special(&p, buf + off, FALSE);
if (len > 0) /* recognized special char */
off += len;
else /* copy as normal char */
@@ -6642,6 +6629,10 @@ do_highlight (
if (is_normal_group) {
HL_TABLE()[idx].sg_term_attr = 0;
HL_TABLE()[idx].sg_cterm_attr = 0;
+ if (abstract_ui) {
+ // If the normal group has changed, it is simpler to refresh every UI
+ ui_refresh();
+ }
} else
set_hl_attr(idx);
HL_TABLE()[idx].sg_scriptID = current_SID;
@@ -6654,7 +6645,7 @@ do_highlight (
need_highlight_changed = TRUE;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_highlight(void)
{
for (int i = 0; i < highlight_ga.ga_len; ++i) {
@@ -6870,7 +6861,7 @@ int hl_combine_attr(int char_attr, int prim_attr)
if (char_attr <= HL_ALL && prim_attr <= HL_ALL)
return char_attr | prim_attr;
- if (t_colors > 1) {
+ if (abstract_ui || t_colors > 1) {
if (char_attr > HL_ALL)
char_aep = syn_cterm_attr2entry(char_attr);
if (char_aep != NULL)
@@ -6934,7 +6925,7 @@ int syn_attr2attr(int attr)
{
attrentry_T *aep;
- if (t_colors > 1)
+ if (abstract_ui || t_colors > 1)
aep = syn_cterm_attr2entry(attr);
else
aep = syn_term_attr2entry(attr);
@@ -7204,9 +7195,10 @@ set_hl_attr (
* For the color term mode: If there are other than "normal"
* highlighting attributes, need to allocate an attr number.
*/
- if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0)
+ if (sgp->sg_cterm_fg == 0 && sgp->sg_cterm_bg == 0
+ && sgp->sg_rgb_fg == -1 && sgp->sg_rgb_bg == -1) {
sgp->sg_cterm_attr = sgp->sg_cterm;
- else {
+ } else {
at_en.ae_attr = abstract_ui ? sgp->sg_gui : sgp->sg_cterm;
at_en.ae_u.cterm.fg_color = sgp->sg_cterm_fg;
at_en.ae_u.cterm.bg_color = sgp->sg_cterm_bg;
@@ -7361,7 +7353,7 @@ int syn_id2attr(int hl_id)
hl_id = syn_get_final_id(hl_id);
sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */
- if (t_colors > 1)
+ if (abstract_ui || t_colors > 1)
attr = sgp->sg_cterm_attr;
else
attr = sgp->sg_term_attr;
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index fb39e069f0..bab594a27d 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1981,7 +1981,7 @@ static void found_tagfile_cb(char_u *fname, void *cookie)
GA_APPEND(char_u *, &tag_fnames, vim_strsave(fname));
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void free_tag_stuff(void)
{
ga_clear_strings(&tag_fnames);
diff --git a/src/nvim/term.c b/src/nvim/term.c
index cf2b78394f..78fd3c6a67 100644
--- a/src/nvim/term.c
+++ b/src/nvim/term.c
@@ -22,6 +22,7 @@
*/
#define tgetstr tgetstr_defined_wrong
+#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
@@ -169,6 +170,7 @@ static struct builtin_term builtin_termcaps[] =
{(int)KS_DL, "\033|d"},
{(int)KS_CDL, "\033|%p1%dD"},
{(int)KS_CS, "\033|%p1%d;%p2%dR"},
+ {(int)KS_CSV, "\033|%p1%d;%p2%dV"},
{(int)KS_CL, "\033|C"},
// attributes switched on with 'h', off with * 'H'
{(int)KS_ME, "\033|31H"}, // HL_ALL
@@ -1065,8 +1067,8 @@ static void parse_builtin_tcap(char_u *term)
term_strings[p->bt_entry] = (char_u *)p->bt_string;
}
} else {
- name[0] = KEY2TERMCAP0((int)p->bt_entry);
- name[1] = KEY2TERMCAP1((int)p->bt_entry);
+ name[0] = (char_u)KEY2TERMCAP0(p->bt_entry);
+ name[1] = (char_u)KEY2TERMCAP1(p->bt_entry);
if (find_termcode(name) == NULL)
add_termcode(name, (char_u *)p->bt_string, term_8bit);
}
@@ -1255,7 +1257,7 @@ int set_termname(char_u *term)
UP = (char *)TGETSTR("up", &tp);
p = TGETSTR("pc", &tp);
if (p)
- PC = *p;
+ PC = (char)*p;
}
} else /* try == 0 || try == 2 */
#endif /* HAVE_TGETENT */
@@ -1472,13 +1474,12 @@ int set_termname(char_u *term)
# define HMT_NORMAL 1
# define HMT_NETTERM 2
# define HMT_DEC 4
-# define HMT_PTERM 8
# define HMT_URXVT 16
# define HMT_SGR 32
void
set_mouse_termcode (
- int n, /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
+ char_u n, /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
char_u *s
)
{
@@ -1487,10 +1488,10 @@ set_mouse_termcode (
add_termcode(name, s, FALSE);
}
-# if (defined(UNIX) && defined(FEAT_MOUSE_TTY)) || defined(PROTO)
+# if (defined(UNIX) && defined(FEAT_MOUSE_TTY))
void
del_mouse_termcode (
- int n /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
+ char_u n /* KS_MOUSE, KS_NETTERM_MOUSE or KS_DEC_MOUSE */
)
{
char_u name[2] = { n, KE_FILLER };
@@ -1690,7 +1691,7 @@ bool term_is_8bit(char_u *name)
* <Esc>] -> <M-C-]>
* <Esc>O -> <M-C-O>
*/
-static int term_7to8bit(char_u *p)
+static char_u term_7to8bit(char_u *p)
{
if (*p == ESC) {
if (p[1] == '[')
@@ -1704,7 +1705,7 @@ static int term_7to8bit(char_u *p)
}
-#if !defined(HAVE_TGETENT) || defined(PROTO)
+#if !defined(HAVE_TGETENT)
char_u *tltoa(unsigned long i)
{
@@ -1801,7 +1802,9 @@ void term_write(char_u *s, size_t len)
#ifdef UNIX
if (p_wd) { // Unix is too fast, slow down a bit more
- os_microdelay(p_wd);
+ assert(p_wd >= 0
+ && (sizeof(long) <= sizeof(uint64_t) || p_wd <= UINT64_MAX));
+ os_microdelay((uint64_t)p_wd);
}
#endif
}
@@ -1814,17 +1817,20 @@ void term_write(char_u *s, size_t len)
static char_u out_buf[OUT_SIZE + 1];
static int out_pos = 0; /* number of chars in out_buf */
+// Clear the output buffer
+void out_buf_clear(void)
+{
+ out_pos = 0;
+}
+
/*
* out_flush(): flush the output buffer
*/
void out_flush(void)
{
- if (out_pos != 0) {
- /* set out_pos to 0 before ui_write, to avoid recursiveness */
- int len = out_pos;
- out_pos = 0;
- ui_write(out_buf, len);
- }
+ int len = out_pos;
+ out_pos = 0;
+ ui_write(out_buf, len);
}
/*
@@ -1843,7 +1849,7 @@ void out_flush_check(void)
* This should not be used for outputting text on the screen (use functions
* like msg_puts() and screen_putchar() for that).
*/
-void out_char(unsigned c)
+void out_char(char_u c)
{
#if defined(UNIX) || defined(MACOS_X_UNIX)
if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */
@@ -1861,7 +1867,7 @@ void out_char(unsigned c)
/*
* out_char_nf(c): like out_char(), but don't flush when p_wd is set
*/
-static void out_char_nf(unsigned c)
+static void out_char_nf(char_u c)
{
#if defined(UNIX) || defined(MACOS_X_UNIX)
if (c == '\n') /* turn LF into CR-LF (CRMOD doesn't seem to do this) */
@@ -1943,7 +1949,7 @@ void term_delete_lines(int line_count)
OUT_STR(tgoto((char *)T_CDL, 0, line_count));
}
-#if defined(HAVE_TGETENT) || defined(PROTO)
+#if defined(HAVE_TGETENT)
void term_set_winpos(int x, int y)
{
/* Can't handle a negative value here */
@@ -2008,7 +2014,7 @@ static void term_color(char_u *s, int n)
OUT_STR(tgoto((char *)s, 0, n));
}
-#if defined(UNIX) || defined(MACOS_X) || defined(PROTO)
+#if defined(UNIX) || defined(MACOS_X)
/*
* Generic function to set window title, using t_ts and t_fs.
*/
@@ -2112,31 +2118,6 @@ void ttest(int pairs)
t_colors = atoi((char *)T_CCO);
}
-#if defined(FEAT_GUI) || defined(PROTO)
-/*
- * Interpret the next string of bytes in buf as a long integer, with the most
- * significant byte first. Note that it is assumed that buf has been through
- * inchar(), so that NUL and K_SPECIAL will be represented as three bytes each.
- * Puts result in val, and returns the number of bytes read from buf
- * (between sizeof(long_u) and 2 * sizeof(long_u)), or -1 if not enough bytes
- * were present.
- */
-static int get_long_from_buf(char_u *buf, long_u *val)
-{
- char_u bytes[sizeof(long_u)];
-
- *val = 0;
- int len = get_bytes_from_buf(buf, bytes, (int)sizeof(long_u));
- if (len != -1) {
- for (int i = 0; i < (int)sizeof(long_u); i++) {
- int shift = 8 * (sizeof(long_u) - 1 - i);
- *val += (long_u)bytes[i] << shift;
- }
- }
- return len;
-}
-#endif
-
#if defined(FEAT_GUI) \
|| (defined(FEAT_MOUSE) && (!defined(UNIX) || defined(FEAT_MOUSE_XTERM) \
|| defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)))
@@ -2203,8 +2184,8 @@ void limit_screen_size(void)
*/
void win_new_shellsize(void)
{
- static int old_Rows = 0;
- static int old_Columns = 0;
+ static long old_Rows = 0;
+ static long old_Columns = 0;
if (old_Rows != Rows) {
/* if 'window' uses the whole screen, keep it using that */
@@ -2225,7 +2206,11 @@ void win_new_shellsize(void)
*/
void shell_resized(void)
{
- screen_resize(0, 0, FALSE);
+ if (abstract_ui) {
+ ui_refresh();
+ } else {
+ screen_resize(0, 0, FALSE);
+ }
}
/*
@@ -2234,11 +2219,10 @@ void shell_resized(void)
*/
void shell_resized_check(void)
{
- int old_Rows = Rows;
- int old_Columns = Columns;
+ long old_Rows = Rows;
+ long old_Columns = Columns;
- if (!exiting
- ) {
+ if (!exiting) {
(void)ui_get_shellsize();
check_shellsize();
if (old_Rows != Rows || old_Columns != Columns)
@@ -2588,13 +2572,13 @@ static struct termcode {
int modlen; /* length of part before ";*~". */
} *termcodes = NULL;
-static int tc_max_len = 0; /* number of entries that termcodes[] can hold */
-static int tc_len = 0; /* current number of entries in termcodes[] */
+static size_t tc_max_len = 0; /* number of entries that termcodes[] can hold */
+static size_t tc_len = 0; /* current number of entries in termcodes[] */
void clear_termcodes(void)
{
- while (tc_len > 0)
+ while (tc_len != 0)
free(termcodes[--tc_len].code);
free(termcodes);
termcodes = NULL;
@@ -2621,7 +2605,7 @@ void clear_termcodes(void)
void add_termcode(char_u *name, char_u *string, int flags)
{
struct termcode *new_tc;
- int i, j;
+ size_t i, j;
if (string == NULL || *string == NUL) {
del_termcode(name);
@@ -2635,7 +2619,7 @@ void add_termcode(char_u *name, char_u *string, int flags)
STRMOVE(s, s + 1);
s[0] = term_7to8bit(string);
}
- int len = (int)STRLEN(s);
+ size_t len = STRLEN(s);
need_gather = true; // need to fill termleader[]
@@ -2666,15 +2650,14 @@ void add_termcode(char_u *name, char_u *string, int flags)
* Exact match: May replace old code.
*/
if (termcodes[i].name[1] == name[1]) {
- if (flags == ATC_FROM_TERM && (j = termcode_star(
- termcodes[i].code,
- termcodes[i].len)) > 0) {
+ if (flags == ATC_FROM_TERM
+ && (j = termcode_star(termcodes[i].code, termcodes[i].len)) > 0) {
/* Don't replace ESC[123;*X or ESC O*X with another when
* invoked from got_code_from_term(). */
- if (len == termcodes[i].len - j
+ assert(termcodes[i].len >= 0);
+ if (len == (size_t)termcodes[i].len - j
&& STRNCMP(s, termcodes[i].code, len - 1) == 0
- && s[len - 1]
- == termcodes[i].code[termcodes[i].len - 1]) {
+ && s[len - 1] == termcodes[i].code[termcodes[i].len - 1]) {
/* They are equal but for the ";*": don't add it. */
free(s);
return;
@@ -2698,14 +2681,15 @@ void add_termcode(char_u *name, char_u *string, int flags)
termcodes[i].name[0] = name[0];
termcodes[i].name[1] = name[1];
termcodes[i].code = s;
- termcodes[i].len = len;
+ assert(len <= INT_MAX);
+ termcodes[i].len = (int)len;
/* For xterm we recognize special codes like "ESC[42;*X" and "ESC O*X" that
* accept modifiers. */
termcodes[i].modlen = 0;
- j = termcode_star(s, len);
+ j = termcode_star(s, (int)len);
if (j > 0)
- termcodes[i].modlen = len - 1 - j;
+ termcodes[i].modlen = (int)(len - 1 - j);
++tc_len;
}
@@ -2714,7 +2698,7 @@ void add_termcode(char_u *name, char_u *string, int flags)
* The "X" can be any character.
* Return 0 if not found, 2 for ;*X and 1 for O*X and <M-O>*X.
*/
-static int termcode_star(char_u *code, int len)
+static unsigned int termcode_star(char_u *code, int len)
{
/* Shortest is <M-O>*X. With ; shortest is <CSI>1;*X */
if (len >= 3 && code[len - 2] == '*') {
@@ -2728,13 +2712,13 @@ static int termcode_star(char_u *code, int len)
char_u *find_termcode(char_u *name)
{
- for (int i = 0; i < tc_len; ++i)
+ for (size_t i = 0; i < tc_len; ++i)
if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1])
return termcodes[i].code;
return NULL;
}
-char_u *get_termcode(int i)
+char_u *get_termcode(size_t i)
{
if (i >= tc_len)
return NULL;
@@ -2748,7 +2732,7 @@ void del_termcode(char_u *name)
need_gather = true; // need to fill termleader[]
- for (int i = 0; i < tc_len; ++i)
+ for (size_t i = 0; i < tc_len; ++i)
if (termcodes[i].name[0] == name[0] && termcodes[i].name[1] == name[1]) {
del_termcode_idx(i);
return;
@@ -2756,11 +2740,11 @@ void del_termcode(char_u *name)
/* not found. Give error message? */
}
-static void del_termcode_idx(int idx)
+static void del_termcode_idx(size_t idx)
{
free(termcodes[idx].code);
--tc_len;
- for (int i = idx; i < tc_len; ++i)
+ for (size_t i = idx; i < tc_len; ++i)
termcodes[i] = termcodes[i + 1];
}
@@ -2772,8 +2756,8 @@ static void switch_to_8bit(void)
{
/* Only need to do something when not already using 8-bit codes. */
if (!term_is_8bit(T_NAME)) {
- for (int i = 0; i < tc_len; ++i) {
- int c = term_7to8bit(termcodes[i].code);
+ for (size_t i = 0; i < tc_len; ++i) {
+ char_u c = term_7to8bit(termcodes[i].code);
if (c != 0) {
STRMOVE(termcodes[i].code + 1, termcodes[i].code + 2);
termcodes[i].code[0] = c;
@@ -2837,7 +2821,6 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
int extra;
char_u string[MAX_KEY_CODE_LEN + 1];
int i, j;
- int idx = 0;
# if !defined(UNIX) || defined(FEAT_MOUSE_XTERM) || defined(FEAT_GUI) \
|| defined(FEAT_MOUSE_GPM) || defined(FEAT_SYSMOUSE)
char_u bytes[6];
@@ -2912,6 +2895,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
key_name[1] = NUL; /* no key name found yet */
modifiers = 0; /* no modifiers yet */
+ size_t idx;
{
for (idx = 0; idx < tc_len; ++idx) {
/*
@@ -2936,10 +2920,10 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
*/
if (termcodes[idx].name[0] == 'K'
&& VIM_ISDIGIT(termcodes[idx].name[1])) {
- for (j = idx + 1; j < tc_len; ++j)
- if (termcodes[j].len == slen &&
- STRNCMP(termcodes[idx].code,
- termcodes[j].code, slen) == 0) {
+ for (size_t j = idx + 1; j < tc_len; ++j)
+ if (termcodes[j].len == slen
+ && STRNCMP(termcodes[idx].code,
+ termcodes[j].code, slen) == 0) {
idx = j;
break;
}
@@ -3253,7 +3237,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
*/
p = tp + slen;
- mouse_code = getdigits(&p);
+ mouse_code = getdigits_int(&p);
if (*p++ != ';')
return -1;
@@ -3261,11 +3245,11 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
if (key_name[0] == KS_SGR_MOUSE)
mouse_code += 32;
- mouse_col = getdigits(&p) - 1;
+ mouse_col = getdigits_int(&p);
if (*p++ != ';')
return -1;
- mouse_row = getdigits(&p) - 1;
+ mouse_row = getdigits_int(&p);
if (key_name[0] == KS_SGR_MOUSE && *p == 'm')
mouse_code |= MOUSE_RELEASE;
else if (*p != 'M')
@@ -3292,7 +3276,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
}
}
p += j;
- if (cmd_complete && getdigits(&p) == mouse_code) {
+ if (cmd_complete && getdigits_int(&p) == mouse_code) {
slen += j; /* skip the \033[ */
continue;
}
@@ -3338,10 +3322,10 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
* '6' is the row, 45 is the column
*/
p = tp + slen;
- mr = getdigits(&p);
+ mr = getdigits_int(&p);
if (*p++ != ',')
return -1;
- mc = getdigits(&p);
+ mc = getdigits_int(&p);
if (*p++ != '\r')
return -1;
@@ -3406,27 +3390,27 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
p = tp + slen;
/* get event status */
- Pe = getdigits(&p);
+ Pe = getdigits_int(&p);
if (*p++ != ';')
return -1;
/* get button status */
- Pb = getdigits(&p);
+ Pb = getdigits_int(&p);
if (*p++ != ';')
return -1;
/* get row status */
- Pr = getdigits(&p);
+ Pr = getdigits_int(&p);
if (*p++ != ';')
return -1;
/* get column status */
- Pc = getdigits(&p);
+ Pc = getdigits_int(&p);
/* the page parameter is optional */
if (*p == ';') {
p++;
- (void)getdigits(&p);
+ (void)getdigits_int(&p);
}
if (*p++ != '&')
return -1;
@@ -3502,7 +3486,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
// compute the time elapsed since the previous mouse click and
// convert it from ns to ms because p_mouset is stored as ms
- long timediff = (long) (mouse_time - orig_mouse_time) / 1E6;
+ long timediff = (long) (mouse_time - orig_mouse_time) / 1000000;
orig_mouse_time = mouse_time;
if (mouse_code == orig_mouse_code
@@ -3558,9 +3542,10 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
modifiers |= MOD_MASK_ALT;
key_name[1] = (wheel_code & 1)
? (int)KE_MOUSEUP : (int)KE_MOUSEDOWN;
- } else
- key_name[1] = get_pseudo_mouse_code(current_button,
- is_click, is_drag);
+ } else {
+ key_name[1] = (char_u)get_pseudo_mouse_code(current_button,
+ is_click, is_drag);
+ }
}
@@ -3580,13 +3565,13 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen)
if (modifiers != 0) {
string[new_slen++] = K_SPECIAL;
string[new_slen++] = (int)KS_MODIFIER;
- string[new_slen++] = modifiers;
+ string[new_slen++] = (char_u)modifiers;
}
}
/* Finally, add the special key code to our string */
- key_name[0] = KEY2TERMCAP0(key);
- key_name[1] = KEY2TERMCAP1(key);
+ key_name[0] = (char_u)KEY2TERMCAP0(key);
+ key_name[1] = (char_u)KEY2TERMCAP1(key);
if (key_name[0] == KS_KEY) {
/* from ":set <M-b>=xx" */
if (has_mbyte)
@@ -3670,10 +3655,10 @@ replace_termcodes (
int special /* always accept <key> notation */
)
{
- int i;
- int slen;
- int key;
- int dlen = 0;
+ ssize_t i;
+ size_t slen;
+ char_u key;
+ size_t dlen = 0;
char_u *src;
int do_backslash; /* backslash is a special character */
int do_special; /* recognize <> key codes */
@@ -3727,7 +3712,7 @@ replace_termcodes (
result[dlen++] = (int)KS_EXTRA;
result[dlen++] = (int)KE_SNR;
sprintf((char *)result + dlen, "%" PRId64, (int64_t)current_SID);
- dlen += (int)STRLEN(result + dlen);
+ dlen += STRLEN(result + dlen);
result[dlen++] = '_';
continue;
}
@@ -3832,14 +3817,17 @@ replace_termcodes (
* Find a termcode with keys 'src' (must be NUL terminated).
* Return the index in termcodes[], or -1 if not found.
*/
-int find_term_bykeys(char_u *src)
+ssize_t find_term_bykeys(char_u *src)
{
- int slen = (int)STRLEN(src);
-
- for (int i = 0; i < tc_len; ++i) {
- if (slen == termcodes[i].len
- && STRNCMP(termcodes[i].code, src, (size_t)slen) == 0)
- return i;
+ size_t slen = STRLEN(src);
+
+ for (size_t i = 0; i < tc_len; ++i) {
+ assert(termcodes[i].len >= 0);
+ if (slen == (size_t)termcodes[i].len
+ && STRNCMP(termcodes[i].code, src, slen) == 0) {
+ assert(i <= SSIZE_MAX);
+ return (ssize_t)i;
+ }
}
return -1;
}
@@ -3861,7 +3849,7 @@ static void gather_termleader(void)
in 8-bit mode */
termleader[len] = NUL;
- for (int i = 0; i < tc_len; ++i)
+ for (size_t i = 0; i < tc_len; ++i)
if (vim_strchr(termleader, termcodes[i].code[0]) == NULL) {
termleader[len++] = termcodes[i].code[0];
termleader[len] = NUL;
@@ -3876,22 +3864,14 @@ static void gather_termleader(void)
*/
void show_termcodes(void)
{
- int col;
- int *items;
- int item_count;
- int run;
- int row, rows;
- int cols;
- int i;
- int len;
-
#define INC3 27 /* try to make three columns */
#define INC2 40 /* try to make two columns */
#define GAP 2 /* spaces between columns */
if (tc_len == 0) /* no terminal codes (must be GUI) */
return;
- items = xmalloc(sizeof(int) * tc_len);
+
+ size_t *items = xmalloc(sizeof(size_t) * tc_len);
/* Highlight title */
MSG_PUTS_TITLE(_("\n--- Terminal keys ---"));
@@ -3902,14 +3882,14 @@ void show_termcodes(void)
* 2. display the medium items (medium length strings)
* 3. display the long items (remaining strings)
*/
- for (run = 1; run <= 3 && !got_int; ++run) {
+ for (int run = 1; run <= 3 && !got_int; ++run) {
/*
* collect the items in items[]
*/
- item_count = 0;
- for (i = 0; i < tc_len; i++) {
- len = show_one_termcode(termcodes[i].name,
- termcodes[i].code, FALSE);
+ size_t item_count = 0;
+ for (size_t i = 0; i < tc_len; i++) {
+ int len = show_one_termcode(termcodes[i].name,
+ termcodes[i].code, FALSE);
if (len <= INC3 - GAP ? run == 1
: len <= INC2 - GAP ? run == 2
: run == 3)
@@ -3919,22 +3899,24 @@ void show_termcodes(void)
/*
* display the items
*/
+ size_t rows, cols;
if (run <= 2) {
- cols = (Columns + GAP) / (run == 1 ? INC3 : INC2);
+ cols = (size_t)(Columns + GAP) / (run == 1 ? INC3 : INC2);
if (cols == 0)
cols = 1;
rows = (item_count + cols - 1) / cols;
} else /* run == 3 */
rows = item_count;
- for (row = 0; row < rows && !got_int; ++row) {
+ for (size_t row = 0; row < rows && !got_int; ++row) {
msg_putchar('\n'); /* go to next line */
if (got_int) /* 'q' typed in more */
break;
- col = 0;
- for (i = row; i < item_count; i += rows) {
- msg_col = col; /* make columns */
+ size_t col = 0;
+ for (size_t i = row; i < item_count; i += rows) {
+ assert(col <= INT_MAX);
+ msg_col = (int)col; /* make columns */
show_one_termcode(termcodes[items[i]].name,
- termcodes[items[i]].code, TRUE);
+ termcodes[items[i]].code, TRUE);
if (run == 2)
col += INC2;
else
@@ -4047,7 +4029,7 @@ static void got_code_from_term(char_u *code, int len)
#define XT_LEN 100
char_u name[3];
char_u str[XT_LEN];
- int i;
+ ssize_t i;
int j = 0;
int c;
@@ -4056,12 +4038,17 @@ static void got_code_from_term(char_u *code, int len)
* Our names are currently all 2 characters. */
if (code[0] == '1' && code[7] == '=' && len / 2 < XT_LEN) {
/* Get the name from the response and find it in the table. */
- name[0] = hexhex2nr(code + 3);
- name[1] = hexhex2nr(code + 5);
+ int byte = hexhex2nr(code + 3);
+ assert(byte != -1);
+ name[0] = (char_u)byte;
+ byte = hexhex2nr(code + 5);
+ assert(byte != -1);
+ name[1] = (char_u)byte;
name[2] = NUL;
for (i = 0; key_names[i] != NULL; ++i) {
if (STRCMP(key_names[i], name) == 0) {
- xt_index_in = i;
+ assert(i <= INT_MAX);
+ xt_index_in = (int)i;
break;
}
}
@@ -4075,7 +4062,7 @@ static void got_code_from_term(char_u *code, int len)
# endif
if (key_names[i] != NULL) {
for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2)
- str[j++] = c;
+ str[j++] = (char_u)c;
str[j] = NUL;
if (name[0] == 'C' && name[1] == 'o') {
/* Color count is not a key code. */
@@ -4104,7 +4091,7 @@ static void got_code_from_term(char_u *code, int len)
/* First delete any existing entry with the same code. */
i = find_term_bykeys(str);
if (i >= 0)
- del_termcode_idx(i);
+ del_termcode_idx((size_t)i);
add_termcode(name, str, ATC_FROM_TERM);
}
}
@@ -4192,7 +4179,7 @@ translate_mapping (
}
if (cpo_special && cpo_keycode && c == K_SPECIAL && !modifiers) {
/* try to find special key in termcodes */
- int i;
+ size_t i;
for (i = 0; i < tc_len; ++i)
if (termcodes[i].name[0] == str[1]
&& termcodes[i].name[1] == str[2])
@@ -4226,7 +4213,7 @@ translate_mapping (
|| (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash))
ga_append(&ga, cpo_bslash ? Ctrl_V : '\\');
if (c)
- ga_append(&ga, c);
+ ga_append(&ga, (char)c);
}
ga_append(&ga, NUL);
return (char_u *)(ga.ga_data);
diff --git a/src/nvim/testdir/test48.in b/src/nvim/testdir/test48.in
index 25ea2fa154..998e1bba00 100644
--- a/src/nvim/testdir/test48.in
+++ b/src/nvim/testdir/test48.in
@@ -44,6 +44,10 @@ $4lDi<-- 'D' should be intact
/^"r"
$5lrxa<-- should be 'x'
:"
+:" Test "r" on a tab
+:" Note that for this test, 'ts' must be 8 (the default).
+^5lrxA<-- should be ' x '
+:"
:" Test to make sure 'x' can delete control characters
:set display=uhex
^xxxxxxi[This line should contain only the text between the brackets.]
@@ -72,6 +76,7 @@ this is a test
this is a test
this is a test
"r"
+"r"
ab sd
abcv6efi.him0kl
diff --git a/src/nvim/testdir/test48.ok b/src/nvim/testdir/test48.ok
index 334cb5a29c..14cd9b12ec 100644
--- a/src/nvim/testdir/test48.ok
+++ b/src/nvim/testdir/test48.ok
@@ -12,6 +12,7 @@ this is a test
this is a test
this is a test
"r" x<-- should be 'x'
+"r" x <-- should be ' x '
[This line should contain only the text between the brackets.]
v i m <-- should show the name of a noted text editor
6 . 0 <-- and its version number
diff --git a/src/nvim/testdir/test53.in b/src/nvim/testdir/test53.in
index 011c9ae39d..8ca9c9ed29 100644
--- a/src/nvim/testdir/test53.in
+++ b/src/nvim/testdir/test53.in
@@ -79,6 +79,8 @@ ggdgn.
:" test repeating gUgn
/^Depp
gggUgn.
+gg/a:0\@!\zs\d\+
+nygnop
:/^start:/,/^end:/wq! test.out
ENDTEST
@@ -108,6 +110,11 @@ delete first and last chars
uniquepattern uniquepattern
my very excellent mother just served us nachos
for (i=0; i<=10; i++)
+a:10
+
+a:1
+
+a:20
Y
text
Y
diff --git a/src/nvim/testdir/test53.ok b/src/nvim/testdir/test53.ok
index d7ffa6bc51..0c0b9ded16 100644
--- a/src/nvim/testdir/test53.ok
+++ b/src/nvim/testdir/test53.ok
@@ -49,6 +49,12 @@ elete first and last char
uniquepattern
my very excellent mongoose just served us nachos
for (j=0; i<=10; i++)
+a:10
+
+a:1
+1
+
+a:20
text
Y
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 9c58193e8c..a8ca58d633 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -60,11 +60,8 @@ static struct {
int top, bot, left, right;
} sr;
static int current_highlight_mask = 0;
-static HlAttrs current_attrs = {
- false, false, false, false, false, false, -1, -1
-};
static bool cursor_enabled = true;
-static int height = INT_MAX, width = INT_MAX;
+static int height, width;
// This set of macros allow us to use UI_CALL to invoke any function on
// registered UI instances. The functions can have 0-5 arguments(configurable
@@ -98,6 +95,10 @@ void ui_write(uint8_t *s, int len)
return;
}
+ if (!len) {
+ return;
+ }
+
char_u *tofree = NULL;
if (output_conv.vc_type != CONV_NONE) {
@@ -113,6 +114,16 @@ void ui_write(uint8_t *s, int len)
free(tofree);
}
+bool ui_rgb_attached(void)
+{
+ for (size_t i = 0; i < ui_count; i++) {
+ if (uis[i]->rgb) {
+ return true;
+ }
+ }
+ return false;
+}
+
/*
* If the machine has job control, use it to suspend the program,
* otherwise fake it by starting a new shell.
@@ -122,11 +133,24 @@ void ui_suspend(void)
{
if (abstract_ui) {
UI_CALL(suspend);
+ UI_CALL(flush);
} else {
mch_suspend();
}
}
+void ui_set_title(char *title)
+{
+ UI_CALL(set_title, title);
+ UI_CALL(flush);
+}
+
+void ui_set_icon(char *icon)
+{
+ UI_CALL(set_icon, icon);
+ UI_CALL(flush);
+}
+
/*
* Try to get the current Vim shell size. Put the result in Rows and Columns.
* Use the new sizes as defaults for 'columns' and 'lines'.
@@ -165,8 +189,31 @@ void ui_cursor_shape(void)
}
}
-void ui_resize(int width, int height)
+void ui_refresh(void)
{
+ if (!ui_count) {
+ return;
+ }
+
+ int width = INT_MAX, height = INT_MAX;
+
+ for (size_t i = 0; i < ui_count; i++) {
+ UI *ui = uis[i];
+ width = ui->width < width ? ui->width : width;
+ height = ui->height < height ? ui->height : height;
+ }
+
+ screen_resize(width, height, true);
+}
+
+void ui_resize(int new_width, int new_height)
+{
+ width = new_width;
+ height = new_height;
+
+ UI_CALL(update_fg, (ui->rgb ? normal_fg : cterm_normal_fg_color - 1));
+ UI_CALL(update_bg, (ui->rgb ? normal_bg : cterm_normal_bg_color - 1));
+
sr.top = 0;
sr.bot = height - 1;
sr.left = 0;
@@ -240,7 +287,7 @@ void ui_attach(UI *ui)
}
uis[ui_count++] = ui;
- resized(ui);
+ ui_refresh();
}
void ui_detach(UI *ui)
@@ -267,17 +314,8 @@ void ui_detach(UI *ui)
ui_count--;
- if (ui->width == width || ui->height == height) {
- // It is possible that the UI being detached had the smallest screen,
- // so check for the new minimum dimensions
- width = height = INT_MAX;
- for (size_t i = 0; i < ui_count; i++) {
- check_dimensions(uis[i]);
- }
- }
-
if (ui_count) {
- screen_resize(width, height, true);
+ ui_refresh();
}
}
@@ -295,8 +333,7 @@ static void highlight_start(int mask)
return;
}
- set_highlight_args(current_highlight_mask, &current_attrs);
- UI_CALL(highlight_set, current_attrs);
+ set_highlight_args(current_highlight_mask);
}
static void highlight_stop(int mask)
@@ -309,12 +346,12 @@ static void highlight_stop(int mask)
current_highlight_mask &= ~mask;
}
- set_highlight_args(current_highlight_mask, &current_attrs);
- UI_CALL(highlight_set, current_attrs);
+ set_highlight_args(current_highlight_mask);
}
-static void set_highlight_args(int mask, HlAttrs *attrs)
+static void set_highlight_args(int mask)
{
+ HlAttrs rgb_attrs = { false, false, false, false, false, -1, -1 };
attrentry_T *aep = NULL;
if (mask > HL_ALL) {
@@ -322,18 +359,40 @@ static void set_highlight_args(int mask, HlAttrs *attrs)
mask = aep ? aep->ae_attr : 0;
}
- attrs->bold = mask & HL_BOLD;
- attrs->standout = mask & HL_STANDOUT;
- attrs->underline = mask & HL_UNDERLINE;
- attrs->undercurl = mask & HL_UNDERCURL;
- attrs->italic = mask & HL_ITALIC;
- attrs->reverse = mask & HL_INVERSE;
- attrs->foreground = aep && aep->fg_color >= 0 ? aep->fg_color : normal_fg;
- attrs->background = aep && aep->bg_color >= 0 ? aep->bg_color : normal_bg;
+ rgb_attrs.bold = mask & HL_BOLD;
+ rgb_attrs.underline = mask & HL_UNDERLINE;
+ rgb_attrs.undercurl = mask & HL_UNDERCURL;
+ rgb_attrs.italic = mask & HL_ITALIC;
+ rgb_attrs.reverse = mask & (HL_INVERSE | HL_STANDOUT);
+ HlAttrs cterm_attrs = rgb_attrs;
+
+ if (aep) {
+ if (aep->fg_color != normal_fg) {
+ rgb_attrs.foreground = aep->fg_color;
+ }
+
+ if (aep->bg_color != normal_bg) {
+ rgb_attrs.background = aep->bg_color;
+ }
+
+ if (cterm_normal_fg_color != aep->ae_u.cterm.fg_color) {
+ cterm_attrs.foreground = aep->ae_u.cterm.fg_color - 1;
+ }
+
+ if (cterm_normal_bg_color != aep->ae_u.cterm.bg_color) {
+ cterm_attrs.background = aep->ae_u.cterm.bg_color - 1;
+ }
+ }
+
+ UI_CALL(highlight_set, (ui->rgb ? rgb_attrs : cterm_attrs));
}
static void parse_abstract_ui_codes(uint8_t *ptr, int len)
{
+ if (!ui_count) {
+ return;
+ }
+
int arg1 = 0, arg2 = 0;
uint8_t *end = ptr + len, *p, c;
bool update_cursor = false;
@@ -344,14 +403,14 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len)
assert(p != end);
if (VIM_ISDIGIT(*p)) {
- arg1 = (int)getdigits(&p);
+ arg1 = getdigits_int(&p);
if (p >= end) {
break;
}
if (*p == ';') {
p++;
- arg2 = (int)getdigits(&p);
+ arg2 = getdigits_int(&p);
if (p >= end)
break;
}
@@ -444,6 +503,9 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len)
UI_CALL(put, NULL, 0);
col++;
}
+ if (col >= width) {
+ ui_linefeed();
+ }
p += clen;
}
ptr = p;
@@ -457,25 +519,6 @@ static void parse_abstract_ui_codes(uint8_t *ptr, int len)
UI_CALL(flush);
}
-static void resized(UI *ui)
-{
- check_dimensions(ui);
- screen_resize(width, height, true);
-}
-
-static void check_dimensions(UI *ui)
-{
- // The internal screen dimensions are always the minimum required to fit on
- // all connected screens
- if (ui->width < width) {
- width = ui->width;
- }
-
- if (ui->height < height) {
- height = ui->height;
- }
-}
-
static void ui_linefeed(void)
{
int new_col = 0;
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index d0933055cc..099f2643d5 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -6,13 +6,14 @@
#include <stdint.h>
typedef struct {
- bool bold, standout, underline, undercurl, italic, reverse;
+ bool bold, underline, undercurl, italic, reverse;
int foreground, background;
} HlAttrs;
typedef struct ui_t UI;
struct ui_t {
+ bool rgb;
int width, height;
void *data;
void (*resize)(UI *ui, int rows, int columns);
@@ -32,7 +33,11 @@ struct ui_t {
void (*bell)(UI *ui);
void (*visual_bell)(UI *ui);
void (*flush)(UI *ui);
+ void (*update_fg)(UI *ui, int fg);
+ void (*update_bg)(UI *ui, int bg);
void (*suspend)(UI *ui);
+ void (*set_title)(UI *ui, char *title);
+ void (*set_icon)(UI *ui, char *icon);
};
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 59920cfbe1..4d84c69158 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -128,7 +128,7 @@ static int undo_undoes = FALSE;
static int lastmark = 0;
-#if defined(U_DEBUG) || defined(PROTO)
+#if defined(U_DEBUG)
/*
* Check the undo structures for being valid. Print a warning when something
* looks wrong.
diff --git a/src/nvim/version.c b/src/nvim/version.c
index c41610fd0f..e34db7f40a 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -178,6 +178,13 @@ static char *(features[]) = {
};
static int included_patches[] = {
+ 567,
+ //566,
+ //565,
+ //564,
+ 563,
+ //562,
+ //561,
//560 NA
559,
//558 NA
@@ -187,7 +194,7 @@ static int included_patches[] = {
//554,
//553,
552,
- //551,
+ 551,
//550,
549,
//548 NA
@@ -272,6 +279,7 @@ static int included_patches[] = {
//469 NA
468,
467,
+ 466,
//465 NA
//464 NA
463,
diff --git a/src/nvim/window.c b/src/nvim/window.c
index ed4a8d8e7a..cf0977e280 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -371,7 +371,10 @@ newwindow:
postponed_split = Prenum;
else
postponed_split = -1;
- g_do_tagpreview = 0;
+
+ if (nchar != '}') {
+ g_do_tagpreview = 0;
+ }
// Execute the command right here, required when
// "wincmd ]" was used in a function.
@@ -2057,7 +2060,7 @@ win_free_mem (
return wp;
}
-#if defined(EXITFREE) || defined(PROTO)
+#if defined(EXITFREE)
void win_free_all(void)
{
int dummy;
@@ -4908,7 +4911,7 @@ file_name_in_line (
++p; /* skip the separator */
p = skipwhite(p);
if (isdigit(*p))
- *file_lnum = (int)getdigits(&p);
+ *file_lnum = getdigits_long(&p);
}
}
diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua
index cd283e6746..82bb988c67 100644
--- a/test/functional/legacy/066_visual_block_tab_spec.lua
+++ b/test/functional/legacy/066_visual_block_tab_spec.lua
@@ -23,18 +23,18 @@ describe('visual block shift and tab characters', function()
abcdefghijklmnopqrstuvwxyz]])
feed('gg')
- feed([[fe<C-v>4jR<esc>ugvr1:'<,'>yank A<cr>]])
+ feed([[fe<C-v>4jR<esc>ugvr1:'<lt>,'>yank A<cr>]])
execute('/^abcdefgh')
- feed('<C-v>4jI <esc>j<<11|D')
+ feed('<C-v>4jI <esc>j<lt><lt>11|D')
feed('j7|a <esc>')
feed('j7|a <esc>')
- feed('j7|a <esc>4k13|<C-v>4j<')
+ feed('j7|a <esc>4k13|<C-v>4j<lt>')
execute('$-5,$yank A')
execute([[$-4,$s/\s\+//g]])
- feed('<C-v>4kI <esc>j<<')
+ feed('<C-v>4kI <esc>j<lt><lt>')
feed('j7|a <esc>')
feed('j7|a <esc>')
- feed('j7|a <esc>4k13|<C-v>4j3<')
+ feed('j7|a <esc>4k13|<C-v>4j3<lt>')
execute('$-4,$yank A')
-- Put @a and clean empty lines
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 48dc518d7b..25d2b5bc2c 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -6,6 +6,8 @@ local helpers = require('test.functional.helpers')
local eq, clear, eval, feed, nvim =
helpers.eq, helpers.clear, helpers.eval, helpers.feed, helpers.nvim
+local Screen = require('test.functional.ui.screen')
+
local function create_file_with_nuls(name)
return function()
@@ -42,6 +44,81 @@ describe('system()', function()
eq(127, eval('v:shell_error'))
end)
+ describe('executes shell function', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('`echo` and waits for its return', function()
+ feed(':call system("echo")<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :call system("echo") |
+ ]])
+ end)
+
+ it('`yes` and is directly interrupted with CTRL-C', function()
+ feed(':call system("yes")<cr><c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+
+ it('`yes` and is a little bit later interrupted with CTRL-C', function()
+ feed(':call system("yes")<cr>')
+ feed('<c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+ end)
+
describe('passing no input', function()
it('returns the program output', function()
eq("echoed", eval('system("echo -n echoed")'))
@@ -137,6 +214,81 @@ describe('systemlist()', function()
eq(127, eval('v:shell_error'))
end)
+ describe('exectues shell function', function()
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new()
+ screen:attach()
+ end)
+
+ after_each(function()
+ screen:detach()
+ end)
+
+ it('`echo` and waits for its return', function()
+ feed(':call systemlist("echo")<cr>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ :call systemlist("echo") |
+ ]])
+ end)
+
+ it('`yes` and is directly interrupted with CTRL-C', function()
+ feed(':call systemlist("echo")<cr><c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+
+ it('`yes` and is a little bit later interrupted with CTRL-C', function()
+ feed(':call systemlist("echo")<cr>')
+ feed('<c-c>')
+ screen:expect([[
+ ^ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ ~ |
+ Type :quit<Enter> to exit Vim |
+ ]])
+ end)
+ end)
+
describe('passing string with linefeed characters as input', function()
it('splits the output on linefeed characters', function()
eq({'abc', 'def', 'ghi'}, eval([[systemlist("cat -", "abc\ndef\nghi")]]))
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 3c55c09f95..701297cc15 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1,7 +1,30 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
-local execute = helpers.execute
+local execute, request, eq = helpers.execute, helpers.request, helpers.eq
+
+
+describe('color scheme compatibility', function()
+ before_each(function()
+ clear()
+ end)
+
+ it('t_Co is set to 256 by default', function()
+ eq('256', request('vim_eval', '&t_Co'))
+ request('vim_set_option', 't_Co', '88')
+ eq('88', request('vim_eval', '&t_Co'))
+ end)
+
+ it('emulates gui_running when a rgb UI is attached', function()
+ eq(0, request('vim_eval', 'has("gui_running")'))
+ local screen = Screen.new()
+ screen:attach()
+ eq(1, request('vim_eval', 'has("gui_running")'))
+ screen:detach()
+ eq(0, request('vim_eval', 'has("gui_running")'))
+ end)
+end)
+
describe('Default highlight groups', function()
-- Test the default attributes for highlight groups shown by the :highlight
@@ -24,7 +47,6 @@ describe('Default highlight groups', function()
after_each(function()
screen:detach()
end)
-
it('window status bar', function()
screen:set_default_attr_ids({
[1] = {reverse = true, bold = true}, -- StatusLine
@@ -142,7 +164,6 @@ describe('Default highlight groups', function()
end)
it('end of file markers', function()
- nvim('command', 'hi Normal guibg=black')
screen:expect([[
^ |
{1:~ }|
diff --git a/test/functional/ui/mouse_spec.lua b/test/functional/ui/mouse_spec.lua
index 507b5aacae..653d8ad92c 100644
--- a/test/functional/ui/mouse_spec.lua
+++ b/test/functional/ui/mouse_spec.lua
@@ -1,6 +1,7 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
+local insert, execute = helpers.insert, helpers.execute
describe('Mouse input', function()
local screen, hlgroup_colors
@@ -154,4 +155,87 @@ describe('Mouse input', function()
]])
feed('<cr>')
end)
+
+ it('mouse whell will target the hovered window', function()
+ feed('ggdG')
+ insert([[
+ Inserting
+ text
+ with
+ many
+ lines
+ to
+ test
+ mouse scrolling
+ ]])
+ screen:try_resize(53, 14)
+ execute('sp', 'vsp')
+ screen:expect([[
+ lines |lines |
+ to |to |
+ test |test |
+ mouse scrolling |mouse scrolling |
+ ^ | |
+ ~ |~ |
+ [No Name] [+] [No Name] [+] |
+ to |
+ test |
+ mouse scrolling |
+ |
+ ~ |
+ [No Name] [+] |
+ :vsp |
+ ]])
+ feed('<MouseUp><0,0>')
+ screen:expect([[
+ mouse scrolling |lines |
+ ^ |to |
+ ~ |test |
+ ~ |mouse scrolling |
+ ~ | |
+ ~ |~ |
+ [No Name] [+] [No Name] [+] |
+ to |
+ test |
+ mouse scrolling |
+ |
+ ~ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('<MouseDown><27,0>')
+ screen:expect([[
+ mouse scrolling |text |
+ ^ |with |
+ ~ |many |
+ ~ |lines |
+ ~ |to |
+ ~ |test |
+ [No Name] [+] [No Name] [+] |
+ to |
+ test |
+ mouse scrolling |
+ |
+ ~ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('<MouseDown><27,7><MouseDown>')
+ screen:expect([[
+ mouse scrolling |text |
+ ^ |with |
+ ~ |many |
+ ~ |lines |
+ ~ |to |
+ ~ |test |
+ [No Name] [+] [No Name] [+] |
+ Inserting |
+ text |
+ with |
+ many |
+ lines |
+ [No Name] [+] |
+ |
+ ]])
+ end)
end)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 8e7d1ed798..105e43843c 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -83,6 +83,21 @@ local eq, dedent = helpers.eq, helpers.dedent
local Screen = {}
Screen.__index = Screen
+local debug_screen
+
+
+function Screen.debug(command)
+ if not command then
+ command = 'pynvim -n -g -c '
+ end
+ command = command .. request('vim_eval', '$NVIM_LISTEN_ADDRESS')
+ if debug_screen then
+ debug_screen:close()
+ end
+ debug_screen = io.popen(command, 'r')
+ debug_screen:read()
+end
+
function Screen.new(width, height)
if not width then
width = 53
@@ -90,24 +105,22 @@ function Screen.new(width, height)
if not height then
height = 14
end
- return setmetatable({
+ local self = setmetatable({
+ title = '',
+ icon = '',
+ bell = false,
+ visual_bell = false,
+ suspended = false,
_default_attr_ids = nil,
- _width = width,
- _height = height,
- _rows = new_cell_grid(width, height),
_mode = 'normal',
_mouse_enabled = true,
- _bell = false,
- _visual_bell = false,
- _suspended = true,
_attrs = {},
_cursor = {
enabled = true, row = 1, col = 1
- },
- _scroll_region = {
- top = 1, bot = height, left = 1, right = width
}
}, Screen)
+ self:_handle_resize(width, height)
+ return self
end
function Screen:set_default_attr_ids(attr_ids)
@@ -115,13 +128,15 @@ function Screen:set_default_attr_ids(attr_ids)
end
function Screen:attach()
- request('attach_ui', self._width, self._height)
- self._suspended = false
+ request('ui_attach', self._width, self._height, true)
end
function Screen:detach()
- request('detach_ui')
- self._suspended = true
+ request('ui_detach')
+end
+
+function Screen:try_resize(columns, rows)
+ request('ui_try_resize', columns, rows)
end
function Screen:expect(expected, attr_ids)
@@ -134,7 +149,7 @@ function Screen:expect(expected, attr_ids)
table.insert(expected_rows, row)
end
local ids = attr_ids or self._default_attr_ids
- self:_wait(function()
+ self:wait(function()
for i = 1, self._height do
local expected_row = expected_rows[i]
local actual_row = self:_row_repr(self._rows[i], ids)
@@ -146,7 +161,7 @@ function Screen:expect(expected, attr_ids)
end)
end
-function Screen:_wait(check, timeout)
+function Screen:wait(check, timeout)
local err, checked = false
local function notification_cb(method, args)
assert(method == 'redraw')
@@ -181,16 +196,30 @@ function Screen:_redraw(updates)
end
function Screen:_handle_resize(width, height)
- self._rows = new_cell_grid(width, height)
+ local rows = {}
+ for i = 1, height do
+ local cols = {}
+ for j = 1, width do
+ table.insert(cols, {text = ' ', attrs = {}})
+ end
+ table.insert(rows, cols)
+ end
+ self._rows = rows
+ self._width = width
+ self._height = height
+ self._scroll_region = {
+ top = 1, bot = height, left = 1, right = width
+ }
end
function Screen:_handle_clear()
- self:_clear_block(1, self._height, 1, self._width)
+ self:_clear_block(self._scroll_region.top, self._scroll_region.bot,
+ self._scroll_region.left, self._scroll_region.right)
end
function Screen:_handle_eol_clear()
local row, col = self._cursor.row, self._cursor.col
- self:_clear_block(row, 1, col, self._width - col)
+ self:_clear_block(row, 1, col, self._scroll_region.right - col)
end
function Screen:_handle_cursor_goto(row, col)
@@ -250,11 +279,14 @@ function Screen:_handle_scroll(count)
for i = start, stop, step do
local target = self._rows[i]
local source = self._rows[i + count]
- self:_copy_row_section(target, source, left, right)
+ for j = left, right do
+ target[j].text = source[j].text
+ target[j].attrs = source[j].attrs
+ end
end
-- clear invalid rows
- for i = stop + 1, stop + count, step do
+ for i = stop + step, stop + count, step do
self:_clear_row_section(i, left, right)
end
end
@@ -271,15 +303,31 @@ function Screen:_handle_put(str)
end
function Screen:_handle_bell()
- self._bell = true
+ self.bell = true
end
function Screen:_handle_visual_bell()
- self._visual_bell = true
+ self.visual_bell = true
+end
+
+function Screen:_handle_update_fg(fg)
+ self._fg = fg
+end
+
+function Screen:_handle_update_bg(bg)
+ self._bg = bg
end
function Screen:_handle_suspend()
- self._suspended = true
+ self.suspended = true
+end
+
+function Screen:_handle_set_title(title)
+ self.title = title
+end
+
+function Screen:_handle_set_icon(icon)
+ self.icon = icon
end
function Screen:_clear_block(top, lines, left, columns)
@@ -296,13 +344,6 @@ function Screen:_clear_row_section(rownum, startcol, stopcol)
end
end
-function Screen:_copy_row_section(target, source, startcol, stopcol)
- for i = startcol, stopcol do
- target[i].text = source[i].text
- target[i].attrs = source[i].attrs
- end
-end
-
function Screen:_row_repr(row, attr_ids)
local rv = {}
local current_attr_id
@@ -353,18 +394,6 @@ function backward_find_meaningful(tbl, from)
return from
end
-function new_cell_grid(width, height)
- local rows = {}
- for i = 1, height do
- local cols = {}
- for j = 1, width do
- table.insert(cols, {text = ' ', attrs = {}})
- end
- table.insert(rows, cols)
- end
- return rows
-end
-
function get_attr_id(attr_ids, attrs)
if not attr_ids then
return
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index a1110b3231..4ee6c43528 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -16,6 +16,69 @@ describe('Screen', function()
screen:detach()
end)
+ describe(':suspend', function()
+ it('is forwarded to the UI', function()
+ local function check()
+ if not screen.suspended then
+ return 'Screen was not suspended'
+ end
+ end
+ execute('suspend')
+ screen:wait(check)
+ screen.suspended = false
+ feed('<c-z>')
+ screen:wait(check)
+ end)
+ end)
+
+ describe('bell/visual bell', function()
+ it('is forwarded to the UI', function()
+ feed('<left>')
+ screen:wait(function()
+ if not screen.bell or screen.visual_bell then
+ return 'Bell was not sent'
+ end
+ end)
+ screen.bell = false
+ execute('set visualbell')
+ feed('<left>')
+ screen:wait(function()
+ if not screen.visual_bell or screen.bell then
+ return 'Visual bell was not sent'
+ end
+ end)
+ end)
+ end)
+
+ describe(':set title', function()
+ it('is forwarded to the UI', function()
+ local expected = 'test-title'
+ execute('set titlestring='..expected)
+ execute('set title')
+ screen:wait(function()
+ local actual = screen.title
+ if actual ~= expected then
+ return 'Expected title to be "'..expected..'" but was "'..actual..'"'
+ end
+ end)
+ end)
+ end)
+
+ describe(':set icon', function()
+ it('is forwarded to the UI', function()
+ local expected = 'test-icon'
+ execute('set iconstring='..expected)
+ execute('set icon')
+ screen:wait(function()
+ local actual = screen.icon
+ if actual ~= expected then
+ return 'Expected title to be "'..expected..'" but was "'..actual..'"'
+ end
+ end)
+ end)
+ end)
+
+
describe('window', function()
describe('split', function()
it('horizontal', function()
@@ -95,6 +158,8 @@ describe('Screen', function()
|
]])
end)
+
+
end)
end)
@@ -221,4 +286,193 @@ describe('Screen', function()
feed('<cr>') -- skip the "Press ENTER..." state or tests will hang
end)
end)
+
+ describe('scrolling and clearing', function()
+ before_each(function()
+ insert([[
+ Inserting
+ text
+ with
+ many
+ lines
+ to
+ test
+ scrolling
+ and
+ clearing
+ in
+ split
+ windows
+ ]])
+ execute('sp', 'vsp', 'vsp')
+ screen:expect([[
+ and |and |and |
+ clearing |clearing |clearing |
+ in |in |in |
+ split |split |split |
+ windows |windows |windows |
+ ^ | | |
+ [No Name] [+] [No Name] [+] [No Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ end)
+
+ it('only affects the current scroll region', function()
+ feed('6k')
+ screen:expect([[
+ ^crolling |and |and |
+ and |clearing |clearing |
+ clearing |in |in |
+ in |split |split |
+ split |windows |windows |
+ windows | | |
+ [No Name] [+] [No Name] [+] [No Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('<c-w>l')
+ screen:expect([[
+ scrolling |and |and |
+ and |clearing |clearing |
+ clearing |in |in |
+ in |split |split |
+ split |windows |windows |
+ windows |^ | |
+ [No Name] [+] [No Name] [+] <Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('gg')
+ screen:expect([[
+ scrolling |^nserting |and |
+ and |text |clearing |
+ clearing |with |in |
+ in |many |split |
+ split |lines |windows |
+ windows |to | |
+ [No Name] [+] [No Name] [+] <Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('7j')
+ screen:expect([[
+ scrolling |with |and |
+ and |many |clearing |
+ clearing |lines |in |
+ in |to |split |
+ split |test |windows |
+ windows |^crolling | |
+ [No Name] [+] [No Name] [+] <Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('2j')
+ screen:expect([[
+ scrolling |lines |and |
+ and |to |clearing |
+ clearing |test |in |
+ in |scrolling |split |
+ split |and |windows |
+ windows |^learing | |
+ [No Name] [+] [No Name] [+] <Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('5k')
+ screen:expect([[
+ scrolling |^ines |and |
+ and |to |clearing |
+ clearing |test |in |
+ in |scrolling |split |
+ split |and |windows |
+ windows |clearing | |
+ [No Name] [+] [No Name] [+] <Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ feed('k')
+ screen:expect([[
+ scrolling |^any |and |
+ and |lines |clearing |
+ clearing |to |in |
+ in |test |split |
+ split |scrolling |windows |
+ windows |and | |
+ [No Name] [+] [No Name] [+] <Name] [+] |
+ clearing |
+ in |
+ split |
+ windows |
+ |
+ [No Name] [+] |
+ |
+ ]])
+ end)
+ end)
+
+ describe('resize', function()
+ before_each(function()
+ screen:try_resize(25, 5)
+ feed('iresize')
+ end)
+
+ it('rebuilds the whole screen', function()
+ screen:expect([[
+ resize^ |
+ ~ |
+ ~ |
+ ~ |
+ -- INSERT -- |
+ ]])
+ end)
+
+ it('has minimum width/height values', function()
+ screen:try_resize(1, 1)
+ screen:expect([[
+ -- INS^RT --|
+ |
+ ]])
+ feed('<esc>:ls')
+ screen:expect([[
+ resize |
+ :ls^ |
+ ]])
+ end)
+ end)
end)
diff --git a/test/unit/formatc.lua b/test/unit/formatc.lua
index 792894f349..f9397eaec6 100644
--- a/test/unit/formatc.lua
+++ b/test/unit/formatc.lua
@@ -149,8 +149,7 @@ local C_keywords = set {
-- };
--
-- would become:
--- struct mystruct
--- { int a; int b; };
+-- struct mystruct { int a; int b; };
--
-- The first one will have a lot of false positives (the line '{' for
-- example), the second one is more unique.
@@ -179,7 +178,8 @@ local function formatc(str)
-- static and/or inline usually indicate an inline header function,
-- which has no trailing ';', so we have to add a newline after the
-- '}' ourselves.
- if token[1] == 'static' or token[1] == 'inline' then
+ local tok = token[1]
+ if tok == 'static' or tok == 'inline' or tok == '__inline' then
end_at_brace = true
end
elseif typ == 'preprocessor' then
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index 2d54dc6003..90f5a0b7de 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -33,11 +33,11 @@ local absolute_executable = nil
local executable_name = nil
local function assert_file_exists(filepath)
- eq(false, nil == (lfs.attributes(filepath, 'r')))
+ neq(nil, lfs.attributes(filepath))
end
local function assert_file_does_not_exist(filepath)
- eq(true, nil == (lfs.attributes(filepath, 'r')))
+ eq(nil, lfs.attributes(filepath))
end
describe('fs function', function()
diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt
index 5abfa23da4..7c5906931d 100644
--- a/third-party/CMakeLists.txt
+++ b/third-party/CMakeLists.txt
@@ -65,17 +65,17 @@ set(LUAROCKS_URL https://github.com/keplerproject/luarocks/archive/0587afbb5fe8c
set(LUAROCKS_SHA1 61a894fd5d61987bf7e7f9c3e0c5de16ba4b68c4)
set(LUAROCKS_MD5 0f53f42909fbcd2c88be303e8f970516)
-set(LIBUNIBILIUM_URL https://github.com/neovim/unibilium/archive/neovim.tar.gz)
-set(LIBUNIBILIUM_SHA1 ab22e465150458a4ea91b72de997a35f25df1bcf)
-set(LIBUNIBILIUM_MD5 b0749651429aa4c619baf44eedcd15c6)
+set(LIBUNIBILIUM_URL https://github.com/mauke/unibilium/archive/520abbc8b26910e2580619f669b5cc2c4ef7f864.tar.gz)
+set(LIBUNIBILIUM_SHA1 c546e5e8861380f5c109a256f25c93419e4076bf)
+set(LIBUNIBILIUM_MD5 d80d1fc45b22b1e92bebd5bf76e8a98b)
-set(LIBTERMKEY_URL https://github.com/neovim/libtermkey/archive/neovim.tar.gz)
-set(LIBTERMKEY_SHA1 a309038a2297fe4905f03a8807723a9aa07c272a)
-set(LIBTERMKEY_MD5 c99e5546da0063fa26dfa7d7f1d5a26f)
+set(LIBTERMKEY_URL https://github.com/neovim/libtermkey/archive/7b3bdafdf589d08478f2493273d4d75636ecc183.tar.gz)
+set(LIBTERMKEY_SHA1 28bfe54dfd9269910a132b51dee7725a2121578d)
+set(LIBTERMKEY_MD5 f0bac9c2467cc80c821be937ea5c13bc)
-set(LIBTICKIT_URL https://github.com/neovim/libtickit/archive/neovim.tar.gz)
-set(LIBTICKIT_SHA1 08a2aa9ab4bacbeeafefac430691089d829fdb13)
-set(LIBTICKIT_MD5 d2d45eb4f2968b068aa5cc310b7f9abd)
+set(LIBTICKIT_URL https://github.com/neovim/libtickit/archive/33f4afb3891df05955429acbf5b406dfe87ec22b.tar.gz)
+set(LIBTICKIT_SHA1 3aab459b9fb3cd83e85ac2e08f05e5f162c8c9d2)
+set(LIBTICKIT_MD5 19ee9271c16716620d0906db74158ec6)
if(USE_BUNDLED_LIBUNIBILIUM)
ExternalProject_Add(libunibilium