Commit Graph

429 Commits

Author SHA1 Message Date
Shougo Matsushita
d9f97e3026 completion: Add v:completed_item feature #2563
Reviewed-by: Michael Reed <m.reed@mykolab.com>
Reviewed-by: Luke Andrew <luke.github@la.id.au>
Reviewed-by: Justin M. Keyes <justinkz@gmail.com>
Reviewed-by: Florian Walch <florian@fwalch.com>
2015-05-24 17:05:12 -04:00
David Bürgin
32837cc7df 'cpoptions': Remove "-" flag #2655 2015-05-21 01:31:30 -04:00
Michael Reed
5e60180a1e Remove char_u: ex_docmd:do_cmdline_cmd() 2015-05-13 15:29:49 -04:00
Florian Walch
64a4ef679a vim-patch:7.4.653 #2527
Problem:    Insert mode completion with complete() may have CTRL-L work like
	    CTRL-P.
Solution:   Handle completion with complete() differently. (Yasuhiro
	    Matsumoto, Christian Brabandt, Hirohito Higashi)

https://github.com/vim/vim/commit/v7-4-653
2015-04-30 14:26:35 -04:00
Eliseo Martínez
7c956dcbe8 Enable -Wconversion: normal.c.
Refactor summary:
- extern int opcount --> extern long opcount
- bool find_decl(..., int len, ...) --> bool find_decl(..., size_t len, ...)
  * int find_ident_under_cursor(...) --> size_t find_ident_under_cursor(...)
    - int find_ident_at_pos(...) --> size_t find_ident_at_pos(...)
    - int modify_fname(..., int *usedlen, ..., int *fnamelen) --> int modify_fname(..., size_t *usedlen, ..., size_t *fnamelen)
      * char_u *eval_vars(..., int *usedlen, ...) --> char_u *eval_vars(..., size_t *usedlen, ...)
        - int find_cmdline_var(..., int *usedlen) --> ssize_t find_cmdline_var(..., size_t *usedlen)
        - static char_u *repl_cmdline(..., int srclen, ...) --> static char_u *repl_cmdline(..., size_t srclen, ...)
    - bool get_visual_text(..., int *lenp) --> bool get_visual_text(..., size_t *lenp)
      * char_u *find_file_name_in_path(..., int len, ...) --> char_u *find_file_name_in_path(..., size_t len, ...)
        - static char_u *eval_includeexpr(..., int len) --> static char_u *eval_includeexpr(..., size_t len)
        - char_u *find_file_in_path(..., int len, ...) --> char_u *find_file_in_path(..., size_t len, ...)
          * char_u *find_file_in_path_option(..., int len, ...) --> char_u *find_file_in_path_option(..., size_t len, ...)
            - char_u *find_directory_in_path(..., int len, ...) --> char_u *find_directory_in_path(..., size_t len, ...)
      * int spell_move_to(...) --> size_t spell_move_to(...)
        - int spell_check(...) --> size_t spell_check(...)
        - static int spell_bad_len --> static size_t spell_bad_len
    - void find_pattern_in_path(..., int len, ...) --> void find_pattern_in_path(..., size_t len, ...)

Helped-by: Justin M. Keyes <justinkz@gmail.com>
2015-04-27 19:27:07 +02:00
Felipe Oliveira Carvalho
bcfc37ea98 Replace vim_isspace() with ascii_isspace() defined in ascii.h 2015-04-24 20:37:13 -03:00
Felipe Oliveira Carvalho
2ca8afc74e Replace vim_isxdigit() with to ascii_isxdigit() defined in ascii.h 2015-04-24 20:37:13 -03:00
Felipe Oliveira Carvalho
caabcae0b7 Replace VIM_ISDIGIT() and vim_isdigit() with ascii_isdigit() defined in ascii.h 2015-04-24 20:37:13 -03:00
Felipe Oliveira Carvalho
93bf201119 Replace vim_iswhite with ascii_iswhite() defined in ascii.h 2015-04-24 20:37:13 -03:00
Björn Linse
26fedb133d clipboard: cleanup valid_yank_reg and use it for :redir
This fixes missing clipboard support for `:redir`

Helped-By: Michael Reed <m.reed@mykolab.com>
Helped-By: Scott Prager <splinterofchaos@gmail.com>
2015-04-17 16:12:32 +02:00
Björn Linse
edb13791bd clipboard: simplify handling of of put in visual mode.
When clipboard=unnamed and put over visual selection, reduces number of
provider calls from 6 to 2. Also add test.
2015-04-17 11:34:06 +02:00
Thiago de Arruda
34c48aaf12 memory: Add free wrapper and refactor project to use it
We already use wrappers for allocation, the new `xfree` function is the
equivalent for deallocation and provides a way to fully replace the malloc
implementation used by Neovim.
2015-04-13 08:22:44 -03:00
Scott Prager
e1bac3b840 Merge pull request #2346 from splinterofchaos/fix-terminal
[RFC] terminal: Handle loss of focus in event loop.
2015-04-08 12:27:52 -04:00
Eliseo Martínez
fa2fcf13aa Enable -Wconversion: fold.c.
Refactor summary:
- foldinfo_T.fi_lnum: int --> linenr_T
                      Reorder field for optimal packing.
- foldAddMarker(..., markerlen): int --> size_t
    * foldstartmarkerlen: int --> size_t
        - foldDelMarker(..., markerlen): int --> size_t
            * foldendmarkerlen: int --> size_t

Helped-by: oni-link <knil.ino@gmail.com>
2015-04-07 12:56:28 +02:00
Scott Prager
b6296f4e84 terminal: Handle loss of focus in event loop.
While in a terminal and insert mode, if an event caused loss of focus,
nvim would stay in the terminal event loop causing an inconsistent view
of internal state and/or segfault.

Remove the "term" argument from terminal_enter() as it only makes sense
to call it with curbuf->terminal. Terminate the loop when switched to a
different buffer.

fixes #2301
2015-04-05 13:39:55 -04:00
Thiago de Arruda
cdedd89d22 terminal: New module that implements a terminal emulator
This commit integrates libvterm with Neovim and implements a terminal emulator
with nvim buffers as the display mechanism. Terminal buffers can be created
using any of the following methods:

- Opening a file with name following the "term://[${cwd}//[${pid}:]]${cmd}"
  URI pattern where:
  - cwd is the working directory of the process
  - pid is the process id. This is just for use in session files where a pid
    would have been assigned to the saved buffer title.
  - cmd is the command to run
- Invoking the `:terminal` ex command
- Invoking the `termopen` function which returns a job id for automating the
  terminal window.

Some extra changes were also implemented to adapt with terminal buffers. Here's
an overview:

- The `main` function now sets a BufReadCmd autocmd to intercept the term:// URI
  and spawn the terminal buffer instead of reading the file.
- terminal buffers behave as if the following local buffer options were set:
  - `nomodifiable`
  - `swapfile`
  - `undolevels=-1`
  - `bufhidden=hide`
- All commands that delete buffers(`:bun`, `:bd` and `:bw`) behave the same for
  terminal buffers, but only work when bang is passed(eg: `:bwipeout!`)
- A new "terminal" mode was added. A consequence is that a new set of mapping
  commands were implemented with the "t" prefix(tmap, tunmap, tnoremap...)
- The `edit` function(which enters insert mode) will actually enter terminal
  mode if the current buffer is a terminal
- The `put` operator was adapted to send data to the terminal instead of
  modifying the buffer directly.
- A window being resized will also trigger a terminal resize if the window
  displays the terminal.
2015-03-25 18:57:35 -03:00
Thiago de Arruda
c546875daf ui: Replace cursor_{on,off} by busy_{stop,start}
Switching cursor off is only necessary in two occasions:

- When redrawing to avoid terminal flickering
- When the editor is busy

The first can now be handled by the TUI, so most calls to ui_cursor_off can be
removed from the core.

So, before this commit it was only necessary to switch the cursor off to notify
the user that nvim was running some long operation. Now the cursor_{on,off}
functions have been replaced by busy_{stop,start} which can be handled in a
UI-specific way(turning the cursor off or showing a busy indicator, for
example).

To make things even more simpler, nvim is always busy except when waiting for
user input or other asynchronous events: It automatically switches to a non-busy
state when the event loop is about to be entered for more than 100 milliseconds.

`ui_busy_start` can be called when its not desired to change the busy state in
the event loop (As its now done by functions that perform blocking shell
invocations).
2015-03-15 10:30:59 -03:00
Anton Ovchinnikov
9925b3a047 Remove redundant casts 2015-03-09 00:40:50 +01:00
Michael Reed
4d7b31fd61 Macro cleanup: USE_ON_FLY_SCROLL 2015-03-05 19:03:36 -05:00
Michael Reed
357583ff8c Macro cleanup: HAVE_SANDBOX 2015-03-05 19:03:34 -05:00
Thiago de Arruda
3baba1e7bc refactor: Remove term modules and termcap options
- Removed term.c, term.h and term_defs.h
- Tests for T_* values were removed. screen.c was simplified as a
  consequence(the best strategy for drawing is implemented in the UI layer)
- Redraw functions now call ui.c functions directly. Updates are flushed with
  `ui_flush()`
- Removed all termcap options(they now return empty strings for compatibility)
- &term/&ttybuiltin options return a constant value(nvim)
- &t_Co is still available, but it mirrors t_colors directly
- Remove cursor tracking from screen.c and the `screen_start` function. Now the
  UI is expected to maintain cursor state across any call, and reset it when
  resized.
- Remove unused code
2015-02-21 05:08:21 -03:00
Eliseo Martínez
7dd48d7af0 Enable -Wconversion: mark.c.
Refactoring summary:
- MB_STRNICMP: Inlined.
- MB_STRNCMP: Inlined.
2015-02-18 20:54:13 -05:00
Eliseo Martínez
883e3a7a73 Remove nonnullret deadcode: xcalloc. 2015-01-27 01:33:33 +01:00
Eliseo Martínez
d228b8a93e Remove nonnullret deadcode: vim_strsave. 2015-01-27 01:33:33 +01:00
Eliseo Martínez
46065f6978 Remove nonnullret deadcode: str_foldcase & vim_strnsave. 2015-01-27 01:33:32 +01:00
Eliseo Martínez
c94863dec4 Remove nonnullret deadcode: addstar. 2015-01-27 01:33:31 +01:00
Florian Walch
51aacc2dea vim-patch:7.4.514
Problem:    Memory access error. (Dominique Pelle)
Solution:   Update tpos. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-514
2015-01-26 02:19:14 -05:00
Jack Danger Canty
19c22cdb80 "halfway a line" is a very confusing phrase
If you Google for this phrase found in the Vim documentation you'll find
almost exclusively hits from the Vim documentation. I think changing
"halfway a line" to "halfway through a line" makes more sense.

There seems to be an pervasive odd use of the word 'halfway' in the
original docs which I'm updating everywhere.
2015-01-22 21:57:03 -08:00
Pavel Platto
1d5222985c vim-patch:7.4.492
Problem:    In Insert mode, after inserting a newline that inserts a comment
	    leader, CTRL-O moves to the right. (ZyX) Issue 57.
Solution:   Correct the condition for moving the cursor back to the NUL.
	    (Christian Brabandt)

  https://code.google.com/p/vim/source/detail?r=v7-4-492
2015-01-19 23:39:01 +02:00
Michael Reed
d86ebc7afb Macro cleanup: PROTO
Regarding dict_lookup() in eval.c: both definitions are the same, the
only difference being the spacing between the indirection operator and
the indentation level.
2015-01-14 15:07:16 -05:00
Justin M. Keyes
d7e18b5c95 Revert "[WIP] "abstract_ui" fixes and improvements" 2015-01-12 10:14:52 -05:00
Thiago de Arruda
748920d505 ui: Test for abstract_ui whenever a minimal t_colors value is required
t_colors should not be checked when abstract_ui is active, because nvim UI is
not limited to a terminal.
2015-01-10 21:41:32 -03:00
Felipe Oliveira Carvalho
77135447e0 Reduce indentation level by early returning or continuing loop
Replace code like this

```c
func() {
    if (cond) {
	...
	...
	...
    }
    return ret;
}
```

```c
for (...) {
    if (cond) {
	...
	...
	...
    }
}
```

with

```c
func() {
    if (!cond) {
	return ret;
    }
    ...
    ...
    ...
}
```

```c
for (...) {
    if (!cond) {
	continue;
    }
    ...
    ...
    ...
}
```
2014-12-13 23:36:11 -03:00
Eliseo Martínez
a71c5e9eb9 Fix warnings: edit.c: ins_compl_next_buf(): Np dereference: MI.
Problem    : Dereference of null pointer @ 3247.
Diagnostic : Multithreading issue.
Rationale  : Problem only occurs if global `ctrl_x_mode` is modified
             while calling function is executing.
Solution   : Use local copy instead of global.
2014-12-06 17:40:12 +01:00
Justin M. Keyes
49b65b0fcd Merge pull request #1516 from fmoralesc/new-patches
vim-patch:7.4.425,435,467,472,473,478
2014-11-27 20:58:39 -05:00
Thiago de Arruda
6f7fe5d1b9 Remove code defined under USE_IM_CONTROL #ifdefs
This is not being used and should not be part of the core anyway.
2014-11-27 20:26:10 -03:00
Felipe Morales
cfa8b4a186 vim-patch:7.4.435: Disable linebreak temporarily when formatting lines.
vim-patch:7.4.435

Problem:    Line formatting behaves differently when 'linebreak' is set.
            (mvxxc)
Solution:   Disable 'linebreak' temporarily. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-435
2014-11-27 19:40:51 -03:00
Thiago de Arruda
a3534138a8 ui: Extract mouse.c/mouse.h 2014-11-27 14:48:30 -03:00
Thiago de Arruda
1865b8c1c1 ui: Remove ui_delay, ui_breakcheck and ui_set_shellsize
These functions only used to call another os_* function, so remove them and
replace all occurences in the project.
2014-11-27 14:27:18 -03:00
Thiago de Arruda
f09a33bbc1 event: No longer process K_EVENT automatically
Two new functions, `event_enable_deferred()`/`event_disable_deferred()` have to
be called by code that is capable of handling asynchronicity. User-dialog states
like "press ENTER to continue" or the swap file confirmation no longer will
generate K_EVENT.
2014-11-21 15:41:02 -03:00
Wayne Rowcliffe
63e2558870 Convert some values from buffer_defs.h to bools 2014-11-12 00:38:34 -06:00
Eliseo Martínez
74817b546e Fix warnings: edit.c: ins_bs(): Garbage result: MI.
Problem    : Result of operation is garbage or undefined @ 7460.
Diagnostic : Multithreading issue.
Rationale  : Problem occurs if any of globals `enc_utf8`, `p_deco is
             modified while function is executing.
Resolution : Use local copy of globals.
2014-11-06 09:51:59 +01:00
Eliseo Martínez
d0a0efaf32 Fix warnings: edit.c: replace_do_bs(): Garbage value: MI.
Problem    : Assigned value is garbage or undefined @ 6359.
Diagnostic : Multithreading issue.
Rationale  : Problem only occurs if global `State` changes while
             function is executing.
Resolution : Use local copy of global in function.
2014-11-06 09:51:58 +01:00
Eliseo Martínez
cefc26ab63 Fix warnings: edit.c: mb_replace_pop_ins(): Unitilialized arg: FP.
Problem    : Uninitialized argument value @ 6296.
Diagnostic : False positive.
Rationale  : Error occurs if n <= 1. That's not possible because
             n >= 1 due to `MB_BYTE2LEN` postcondition and n != 1
             because we are in the else branch.
Resolution : Assert n > 1.
2014-11-06 09:51:58 +01:00
Eliseo Martínez
da4c9447a4 Fix warnings: edit.c: ins_compl_get_exp(): Np dereference (2): FP.
Problems   : Dereference of null pointer @ 3615.
             Dereference of null pointer @ 3764.
Diagnostic : False positives.
Rationale  : `ins_buf` is local static, so maintains value between calls.
             This function will be called first when `compl_started` is
             false, and in that case it initializes `ins_buf`. After
             that, it can be called multiple times with `compl_started`
             true, where `ins_buf` will be updated but not to null.
             So, when arriving to both points, `ins_buf` should never be
             null.
Resolution : Assert `ins_buf` at both points.
2014-11-06 09:51:58 +01:00
Eliseo Martínez
0bda79a847 Fix warnings: edit.c: ins_compl_next_buf(): Np dereference: FP.
Problem    : Dereference of null pointer @ 3234.
Diagnostic : False positive.
Rationale  : `wp` is local static, so maintains value between calls.
             First time function is called for a given flag will have
             `buf == curbuf`, implying `wp` initialization.
Resolution : Assert variable always having been initialized.
2014-11-06 09:51:58 +01: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
André Twupack
ea492696cf vim-patch:7.4.407
Problem:    Inserting text for Visual block mode, with cursor movement,
            repeats the wrong text. (Aleksandar Ivanov)
Solution:   Reset the update_Insstart_orig flag. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-407
2014-09-19 21:12:47 +02:00
Shougo Matsushita
3b9a44fbea vim-patch: 7.4.381
Problem:    Get u_undo error when backspacing in Insert mode deletes more than
            one line break. (Ayberk Ozgur)
Solution:   Also decrement Insstart.lnum.

https://code.google.com/p/vim/source/detail?r=v7-4-381
2014-09-18 20:08:42 +09:00
Naveen Kumar Molleti
4f3d49d921 vim-patch:7.4.387
Problem:    "4gro" replaces one character then executes "ooo". (Urtica
Dioica)
Solution:   Write the ESC in the second stuff buffer.

https://code.google.com/p/vim/source/detail?r=v7-4-387
2014-09-15 15:35:49 +05:30