Commit Graph

711 Commits

Author SHA1 Message Date
Thiago de Arruda
4233446344 debug: Fix broken DLOG macro calls 2014-10-22 11:26:43 -03:00
Thiago de Arruda
cdfdfae322 input: Fix ctrl+c handling in convert_input 2014-10-22 09:58:17 -03:00
Thiago de Arruda
b49460f930 input: Don't remove Ctrl+C from the input_buffer 2014-10-21 21:20:31 -03:00
Thiago de Arruda
b6c9883169 event: Remove direct calls to uv_run from job.c/shell.c 2014-10-21 12:27:25 -03:00
Thiago de Arruda
79b7263f79 compilation: Add -Wconversion to more files and validate CONV_SOURCES
All files under the os, api and msgpack_rpc directories have -Wconversion
automatically applied. CONV_SOURCES is also checked for missing files(when
renaming, for example)
2014-10-21 11:05:49 -03:00
Thiago de Arruda
cf9571b7b1 api: Add FUNC_ATTR_DEFERRED attribute to a number of functions
Any function that can directly mutate the screen or execute vimscript had the
attribute applied.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
72e3e57bf1 msgpack-rpc: Allow selective deferral API calls
Since all API functions now run immediately after a msgpack-rpc request is
parsed by libuv callbacks, a mechanism was added to override this behavior and
allow certain functions to run in Nvim main loop.

The mechanism is simple: Any API function tagged with the FUNC_ATTR_DEFERRED (a
"dummy" attribute only used by msgpack-gen.lua) will be called when Nvim main
loop receives a K_EVENT key.

To implement this mechanism it was necessary some restructuration on the
msgpack-rpc modules, especially in the msgpack-gen.lua script.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
72f028abcb eval: Defer execution of JobActivity autocommands
JobActivity autocommands run vimscript and must be executed on Nvim main loop.
Since the previous commit removed automatic calls to `event_push` on RStream/Job
callbacks, this adds it back, but in eval.c where job control is implemented.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
b527ac752f event: Extract event_poll loops to event_poll_until macro
A pattern that is becoming common across the project is to poll for events until
a certain condition is true, optionally passing a timeout. To address this
scenario, the event_poll_until macro was created and the job/channel/input
modules were refactored to use it on their blocking functions.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
264e0d872c event: Remove automatic event deferall
This is how asynchronous events are currently handled by Nvim:

- Libuv event loop is entered when Nvim blocks for user input(os_inchar is
  called)
- Any event delivered by libuv that is not user input is queued for processing
- The `K_EVENT` special key code is returned by os_inchar
- `K_EVENT` is returned to a loop that is reading keys for the current Nvim
  mode, which will be handled by calling event_process()

This approach has the advantage of integrating nicely with the current
codebase, eg: vimscript code can be executed asynchronously with little
surprises(Its the same as if the user typed a key).

The problem with using keys to represent any event is that it also interferes with
operators, and not every event needs or should do that. For example, consider
this scenario:

- A msgpack-rpc client calls vim_feedkeys("d")
- Nvim processes K_EVENT, pushing "d" to the input queue
- Nvim processes "d", entering operator-pending mode to wait for a motion
- The client calls vim_feedkeys("w"), expecting Nvim to delete a word
- Nvim processes K_EVENT, breaking out of operator-pending and pushing "w"
- Nvim processes "w", moving a word

This commit fixes the above problem by removing all automatic calls to
`event_push`(which is what generates K_EVENT input). Right now this also breaks
redrawing initiated by asynchronous events(and possibly other stuff too, Nvim is
a complex state machine and we can't simply run vimscript code anywhere).

In future commits the calls to `event_push` will be inserted only where it's
absolutely necessary to run code in "key reading loops", such as when executing
vimscript code or mutating editor data structures in ways that currently can
only be done by the user.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
77cc078c41 event: Remove EventType enum and pass a callback to event_push
This approach is more flexible because we don't need to support a fixed set of
"event types", any module can push events to be handled in main loop by simply
passing a callback to the Event structure.
2014-10-21 11:05:49 -03:00
Thiago de Arruda
cf6f60ce4d channel: Simplify resource management
- Remove unused rpc_call_level field
- Add `returned` field to ChannelCallFrame. This is set when the call returns
  and is the only condition checked by `channel_send_call`.
- Add job_exit callback for properly closing channels created from job(the
  job_exit callback is only called after all read callbacks, so it's the only
  safe place to free the channel).
2014-10-21 11:05:49 -03:00
Thiago de Arruda
b280308ac6 msgpack-rpc: Create subdirectory for msgpack-rpc modules
Create the msgpack_rpc subdirectory and move all modules that deal with
msgpack-rpc to it. Also merge msgpack_rpc.c into msgpack_rpc/helpers.c
2014-10-21 11:05:49 -03:00
Justin M. Keyes
56339036a7 Merge pull request #1311 from GokuITA/issue1295
Fixed sign column redraw
2014-10-20 16:17:51 -04:00
Victor Fonseca
9097b69088 Fix sign column redraw
Fixed a bug introduced in SHA:aa66f2487edde49b9a5ba10cd70d706d06a94e25,
due to a misapplied patch. buf_del_sign should redraw the window if the
sign deleted was the last one in the buffer.
Also moved the curwin verification to the correct function.
2014-10-20 17:23:09 -02:00
Jeff Widman
6c78fd1a64 version: remove "Running in Vi compatible mode" message #1309 2014-10-20 13:29:18 -04:00
Thiago de Arruda
72ae4e8a93 rstream: Add rbuffer_read_ptr/rbuffer_write_ptr functions
rbuffer_data was renamed to rbuffer_read_ptr, and it represents the next read
position in a RBuffer instance. Similarly, rbuffer_write_ptr was added to
represent the next write position.

Also, rbuffer_data was being used for writing(in alloc_cb), replace that by
rbuffer_write_ptr.
2014-10-19 17:53:32 -03:00
Thiago de Arruda
38aa222658 rstream: Initialize 'rstream' field in RBuffer class
This field is used in a conditional jump, so this initialization is fixing a
bug.
2014-10-19 17:53:32 -03:00
Thiago de Arruda
42112e04a9 ui: Refactor input buffer handling
All input buffer code was moved to os/input.c, and `inbuf` is now a `RBuffer`
instance(which abstracts static buffer manipulation).
2014-10-18 12:51:35 -03:00
Thiago de Arruda
68de5d79a2 rstream: Extract some RStream functionality to RBuffer
RBuffer instances represent the internal buffer used by RStreams.

This changes RStream constructor to receive RBuffer pointers and adds a set of
RBuffer methods that expose the lower level buffer manipulation to consumers of
the RStream API.
2014-10-18 08:42:49 -03:00
Justin M. Keyes
56ef9e8668 Merge pull request #1297 from splinterofchaos/server-errors
server: Improve error reporting.
2014-10-17 14:03:58 -04:00
Scott Prager
792882e9e4 server: Improve error reporting.
If we fail to bind to the server address, do not try and listen lest the
reported error always be "invalid argument".

Also, return whether or not we errored from server_init() in case we
want to respond differently in the future.
2014-10-17 12:26:10 -04:00
Scott Prager
f2e5851dd9 vim-patch:7.4.418
Problem:    When leaving ":append" the cursor shape is like in Insert mode.
            (Jacob Niehus)
Solution:   Do not have State set to INSERT when calling getline().

https://code.google.com/p/vim/source/detail?r=v7-4-418
2014-10-16 15:55:54 -04:00
Naveen Kumar Molleti
0a2d9fa8c8 vim-patch:7.4.440 #1244
Problem:  Omni complete popup drawn incorrectly.
Solution: Call validate_cursor() instead of check_cursor(). (Hirohito
          Higashi)

https://code.google.com/p/vim/source/detail?r=v7-4-440
2014-10-16 04:18:18 +00:00
Naveen Kumar Molleti
af40647b66 vim-patch:7.4.439 #1245
Problem:  Duplicate message in message history. Some quickfix messages
          appear twice. (Gary Johnson)
Solution: Do not reset keep_msg too early. (Hirohito Higashi)

https://code.google.com/p/vim/source/detail?r=v7-4-439
2014-10-16 04:04:49 +00:00
Naveen Kumar Molleti
3195aadf27 vim-patch:7.4.436 #1246
Problem:  ml_get error for autocommand that moves the cursor of the
          current window.
Solution: Check the cursor position after switching back to the current
          buffer. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-436
2014-10-16 03:49:05 +00:00
Justin M. Keyes
f68e7aba2c Merge pull request #1265 from dkns/vp-7.4.444
vim-patch:7.4.444
2014-10-13 12:10:01 -04:00
Scott Prager
d62545e5ba vim-patch:7.4.408
Problem:    Visual block insert breaks a multi-byte character.
Solution:   Calculate the position properly. (Yasuhiro Matsumoto)

https://code.google.com/p/vim/source/detail?r=v7-4-408
2014-10-10 15:21:40 -04:00
Scott Prager
21d1016f56 vim-patch:7.4.397
Problem:    Matchparen only uses the topmost syntax item.
Solution:   Go through the syntax stack to find items. (James McCoy)
            Also use getcurpos() when possible.

https://code.google.com/p/vim/source/detail?r=v7-4-397
2014-10-09 22:09:52 -04:00
Justin M. Keyes
ea357eb320 version: remove "Compilation" and "Linking" messages.
Can't reliably get this information from cmake (#1267), so it's
misleading to show these messages at all. We can always revert this
commit if we find a way later.
2014-10-07 10:23:15 +00:00
Justin M. Keyes
a1901941f8 version: generate "build number" from commit timestamp
- cmake: git_timestamp() returns last commit time formatted as
  `YYYYMMddHHmm`.
- Always include commit hash in :version and --version output.

`nvim --version` sample output:
  NVIM 0.0.0-alpha+201410070245 (compiled Oct  7 2014 05:30:45)
  Commit: f747b2b1ff7bfe7eb00cc2be82d7af87c98f1111
2014-10-07 10:23:15 +00:00
Justin M. Keyes
ff023a47e3 version: remove non-functional Vim version identifiers 2014-10-07 02:45:27 +00:00
Justin M. Keyes
b80d803967 version: remove "Included patches" message
It is meaningless to Nvim.
2014-10-07 02:45:27 +00:00
Justin M. Keyes
08c99dcff0 version: update user-facing version indicators
- VIM_VERSION_LONG and VIM_VERSION_LONG_DATE do not affect plugins,
  they are only cosmetic.
- Vim-related version identifiers will be preserved for plugin
  compatibility (has("patchXXX") and v:version).
2014-10-07 02:45:27 +00:00
Scott Prager
e397c57d03 vim-patch:7.4.375
Problem:    Test 63 fails when run with GUI-only Vim.
Solution:   Add guibg attributes. (suggested by Mike Soyka)

https://code.google.com/p/vim/source/detail?r=v7-4-375
2014-10-06 19:38:17 -04:00
Scott Prager
5962daeb96 Mark patches 363 and 366 NA. 2014-10-06 19:38:17 -04:00
Joseph Anthony Pasquale Holsten
ae743f8766 Removes shelltype option and all revelant doc. #1249
Fixes #1240
2014-10-06 16:25:53 -04:00
Daniel Kosinski
c5f9540ccb vim-patch:7.4.444
Problem: Reversed question mark not recognized as punctuation. ( Issue 258 )
Solution: Add the Supplemental Punctuation range.

https://code.google.com/p/vim/source/detail?r=v7-4-444
2014-10-04 00:54:59 +02:00
Justin M. Keyes
5e65e3eae0 Merge pull request #1208 from war1025/dev/remove_for_all_windows
Remove FOR_ALL_WINDOWS and replace with FOR_ALL_WINDOWS_IN_TAB(curtab)
2014-10-03 13:44:50 -04:00
Thiago de Arruda
45525853d3 wstream/shell: Fix memory errors caused by os_system
The os_system function uses a write callback to close the input stream when the
write completes, but this causes a memory error because the callback is invoked
right before the stream is freed by the caller.

This fixes the problem by removing the callback set by os_system. Instead, it
calls job_close_in immediately after writing(the stream will only close after
the write completes). The 'pending' parameter was also removed from the
'write_cb' as it should be hidden by the wstream module.

While the `wstream_set_write_cb` and `job_write_cb` are no longer used, they
will remain in the codebase for future use.
2014-10-01 21:42:00 -03:00
Thiago de Arruda
ba1026c2c7 eval: Fix save_tv_as_string to handle non-string types 2014-10-01 21:42:00 -03:00
Thiago de Arruda
35d7815eb2 test: Add some specs for the viml function system()
These new specs replace src/nvim/testdir/test_system
2014-10-01 21:41:54 -03:00
Paul Jolly
8575f1b52a Use line-specific method names where possible to remove ambiguity and possibility of future clashes 2014-10-01 05:48:35 -03:00
Scott Prager
01fc01e5d6 Implement save_tv_as_string to assist in #1176. 2014-09-30 20:53:26 -04:00
Scott Prager
3928acb032 Fix system() output truncation bug.
Replace NULs with SOH to restore the old behaviour of get_cmd_output().
2014-09-30 19:35:47 -04:00
Scott Prager
44b187dd01 Old-style test for system(list). 2014-09-30 19:35:47 -04:00
Scott Prager
b0bda2ee87 vim-patch:7.4.256
Problem:    Using systemlist() may cause a crash and does not handle NUL
            characters properly.
Solution:   Increase the reference count, allocate memory by length. (Yasuhiro
            Matsumoto)

https://code.google.com/p/vim/source/detail?r=v7-4-256
2014-09-30 19:35:46 -04:00
Scott Prager
78979427d1 Return list from rettv_list_alloc. 2014-09-30 19:35:46 -04:00
Scott Prager
566ce93135 vim-patch:7.4.248
Problem:    Cannot distinguish between NL and NUL in output of system().
Solution:   Add systemlist(). (ZyX)

https://code.google.com/p/vim/source/detail?r=v7-4-248
2014-09-30 19:35:46 -04:00
Scott Prager
d3cd3d2b8f vim-patch:7.4.247
Problem:    When passing input to system() there is no way to keep NUL and
            NL characters separate.
Solution:   Optionally use a list for the system() input. (ZyX)

https://code.google.com/p/vim/source/detail?r=v7-4-247

Implement write_list_to_string() as well since write_list() only works
on files.
2014-09-30 19:35:46 -04:00