Commit Graph

268 Commits

Author SHA1 Message Date
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
Björn Linse
8c25ad6cf5 clipboard: missing return NULL when provider not available 2015-04-05 14:31:59 +02:00
Björn Linse
adcf268a72 clipboard: handle clipboard reading directly in get_yank_register
This makes :<c-r>* work as expected and
avoids clobbering zero register ("0) when pasting unnamed clipboard

Helped-By: Scott Prager <splinterofchaos@gmail.com>
Helped-By: Michael Reed <m.reed@mykolab.com>
2015-04-05 11:34:14 +02:00
Björn Linse
7422843f5c clipboard: improve the handling of newlines in get_clipboard
This makes the interpretion consistent with the way newlines are used in
the VIMENC format, while keeping the same fallback behaviour when
regtype is unspecified. Also check both cases explicitly in the tests.
2015-04-05 11:34:13 +02:00
Björn Linse
5600b80c1f clipboard: show "* and "+ in :registers
Helped-by: Robin Allen <r@foon.uk>
Helped-by: Scott Prager <splinterofchaos@gmail.com>
2015-04-05 11:34:13 +02: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
b16c5bf5e6 buffer: Move b_p_ma(modifiable) checks into the MODIFIABLE macro 2015-03-25 18:57:35 -03:00
Anton Ovchinnikov
9925b3a047 Remove redundant casts 2015-03-09 00:40:50 +01:00
Michael Reed
0925870d0c Macro cleanup: ONE_CLIPBOARD 2015-03-05 19:03:35 -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
Björn Linse
d7aea1d7cc clipboard: don't clobber "0 when deleting to unnamed 2015-01-27 19:43:25 -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
Eliseo Martínez
79b5a629eb Remove long_u: ops.c: Refactor long_u. 2015-01-19 19:47:28 +01: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
Eliseo Martínez
7f7262e933 Cleanup: Rename getdigits() family functions. 2015-01-11 21:04:08 +01:00
Eliseo Martínez
04c0658024 Cleanup: Refactor getdigits().
Problem  : getdigits() currently returns a long, but at most places,
           return value is casted (unsafely) into an int. Making casts
           safe would introduce a lot of fuss in the form of assertions
           checking for limits.
Note     : We cannot just change return type to int, because, at some
           places, legitimate long values are used. For example, in
           diff.c, for line numbers.
Solution : Introduce new functions:
           - get_digits()      : Gets an intmax_t from a string.
           - get_int_digits()  : Wrapper for ints.
           - get_long_digits() : Wrapper for longs.
           And replace getdigits() invocations by the appropiate
           wrapper invocations.
2015-01-11 17:18:39 +01:00
Florian Walch
ceb54c55ad vim-patch:7.4.559
Problem:    Appending a block in the middle of a tab does not work correctly
	    when virtualedit is set.
Solution:   Decrement spaces and count, don't reset them. (James McCoy)

https://code.google.com/p/vim/source/detail?r=v7-4-559
2015-01-03 16:08:51 +01:00
Florian Walch
0439e808cb vim-patch:7.4.521
Problem:    When using "vep" a mark is moved to the next line. (Maxi Padulo,
	    Issue 283)
Solution:   Decrement the line number. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=v7-4-521
2014-12-24 23:28:59 +01:00
Eliseo Martínez
a97f9e9594 coverity/13696: Unchecked return value: RI.
Problem    : Unchecked return value (CHECKED_RETURN) @ 2644.
Diagnostic : Real issue.
Rationale  : Other `u_save` invocations are checked, and there's no
             reason to think this invocation could not fail.
Resolution : Check and return if failed (other previous checks in the
             same function just return, without reporting error, so
             we just do the same).
2014-12-16 21:01:22 +01:00
oni-link
bf4b85a5d4 Fix warning: ops.c: read_viminfo_register(): Dereference of null pointer: RI.
Problem    : Array access (via field 'y_array') results in a null pointer
             dereference @ 4487.
Diagnostic : Real issue.
Rationale  : If the array was previously freed and the size of the array
             (y_current->y_size) was not updated to zero, the loop @4486
             could be entered and a NULL pointer would be dereferenced.
Resolution : Use free_yank_all() to take care of the NULL check and
             to free the current yank register.
2014-12-15 20:11:18 +01:00
Joel Teichroeb
e10670ac3b vim-patch:? Fix memory leak in readviminfo
Patch provided by Christian Brabandt
Improved by oni-link
2014-12-13 11:43:48 -08:00
Justin M. Keyes
c729286604 Merge pull request #1635 from danthedeckie/master
replace copy_spaces and copy_chars functions with equivalent memset.
2014-12-12 10:21:21 -05:00
Daniel Fairhead
f8e3cfe220 strings.c: replace copy_spaces, copy_chars with equivalent memset. 2014-12-12 08:11:47 +00:00
Scott Prager
171445ef34 Refactor str_to_reg().
- Update the doxygen comments.
- Use more descriptive types.
- Localize variables.
- Find the '\n' with memchr instead of a for loop.
- Remove `if (size)` checks before memmove
  since memmove(dst,src,0) is a noop.
- Use memcpy instead since the pointers don't alias.
- Use xmemdupz instead of vim_strnsave.
- xrealloc instead of xmalloc/memcpy.
- Use memcnt/xmemscan/memchrsub.
2014-12-11 20:30:00 -05:00
Scott Prager
5fdca47962 vim-patch:7.4.243
Problem:    Cannot use setreg() to add text that includes a NUL.
Solution:   Make setreg() accept a list.

https://code.google.com/p/vim/source/detail?r=v7-4-243
2014-12-11 20:30:00 -05:00
Scott Prager
2f8cc3b9d5 Return void * from get_reg_contents. 2014-12-11 20:29:59 -05:00
Scott Prager
e18538f3ef vim-patch:7.4.242
Problem:    getreg() does not distinguish between a NL used for a line
            break and a NL used for a NUL character.
Solution:   Add another argument to return a list. (ZyX)

https://code.google.com/p/vim/source/detail?r=v7-4-242
2014-12-11 20:29:59 -05:00
Björn Linse
6ddbe6d9be clipboard: fix let @+ = ... and add test 2014-12-08 22:05:05 +01:00
Björn Linse
cccc46acd7 clipboard: better error messages when provider not available 2014-12-08 22:05:05 +01:00
Björn Linse
5476250ba3 options: change "unnamedclip" back to "clipboard=unnamed/unnamedplus"
This allows to configure which of '*' and '+' should be used for
the unnamed clipboard, and is consistent with vim.
2014-12-08 22:05:05 +01:00
Björn Linse
61aaf815db clipboard: clean up unnamedclip logic 2014-12-08 22:05:02 +01:00
Björn Linse
63efb9b1f1 clipboard: handle linewise/charwise selections correctly 2014-12-08 22:01:00 +01:00
Björn Linse
c1854d2433 clipboard: support separate '+' and '*' clipboards 2014-12-08 21:38:35 +01:00
Thiago de Arruda
bf6bb27e79 ui: Remove redundant ui.h includes
Also move read_error_exit to os/input.c
2014-11-27 15:00: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
17a4bfe007 Remove os/provider.{c,h} and all of its references 2014-11-18 07:56:58 -03:00
Thiago de Arruda
375db3b19a eval/ex_cmds2/ops: Implement providers with eval_call_provider
Replace references to provider_call/provider_has with the new functions
eval_call_provider/eval_has_provider.
2014-11-18 07:56:58 -03:00
Scott Prager
f5aee19ac0 Use bool for flags in oparg_T.
Several opart_T members like use_reg_one, end_adjusted, empty,
is_VIsual, and block_mode, only ever store TRUE or FALSE, so make this
constraint explicit by changing them to bools, and TRUE to true and
FALSE to false in the context of their uses.

The member, inclusive, has several other uses such as in arithmetic
equations and one inequality, but every single assignment (obtained with
'grep -r "inclusive \\="') sets it to either TRUE or FALSE.

This also implies that the inequality, "oap->end.coladd <
oap->inclusive", can only be true when coladd==0 and inclusive==true, so
test for that instead.

For consistency, change the first argument of findpar (which ends up
being inclusive) to bool.

Include stdbool.h for consistency with issue #918.

This commit shrinks the size of oparg_T from 128 bytes to 112 (-13%) on
my machine.
2014-11-11 11:34:58 -05:00
Eliseo Martínez
9de544c785 Fix warnings: ops.c: cursor_pos_info(): Various (2): MI.
Problems: Result of operation is garbage or undefined @ 5087.
          http://neovim.org/doc/reports/clang/report-2e3118.html#EndPath

          Result of operation is garbage or undefined @ 5149.

Diagnostic: Multithreading issues.
Rationale : All reported problems can only occur if accesed globals
            change state while executing function, which could only
            happen in a multithreaded environment.
Resolution: Use local variables (copy globals on entry).
            Note that this change alters function semantics, as now
            function only depends on global values at entry time.
            This shouldn't be a problem, though, as new semantics should
            be in fact better.
2014-11-06 09:51:44 +01:00
Eliseo Martínez
0c135a2ff4 Fix warnings: ops.c: do_join(): Nonnull violation: FP.
Problem: Argument with 'nonnull' attribute passed null @ 3540.
         http://neovim.org/doc/reports/clang/report-fc14e0.html#EndPath.

Diagnostic: False potitive.
Rationale : `count` should be >= 2 by function precondition.
Resolution: Assert precondition.
2014-11-06 09:51:44 +01: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
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
Scott Prager
eff839b26d memory: xstrchrnul and xmemscan. 2014-09-30 19:33:48 -04:00
Wayne Rowcliffe
9b6f192693 Replace FOR_ALL_WINDOWS with FOR_ALL_WINDOWS_IN_TAB(curtab) 2014-09-24 19:00:50 -05:00
Thiago de Arruda
cac24cb06d api/msgpack-rpc: Refactor msgpack_rpc_helpers.{c,h}
- Move helpers that are specific to API types to api/private/helpers.{c,h}
- Include headers with generated declarations
- Delete unused macros
2014-09-12 13:25:28 -03:00
Wayne Rowcliffe
fe99930c46 Convert FOR_ALL_WINDOWS to use a locally declared pointer 2014-09-08 17:27:41 -05:00
Thiago de Arruda
a66d2d1538 msgpack-rpc: Always use arrays when sending events or calls
This is required by the msgpack-RPC specification. Also, the
send_call/send_event functions were refactored to accept a variable number of
arguments
2014-08-29 22:08:58 -03:00
Felipe Morales
47391b18e2 Port vim's patch 7.4.338 ('breakindent') 2014-08-20 05:19:49 -04:00
André Twupack
d730c5c57e vim-patch:7.4.331 #1017
Problem:    Relative numbering not updated after a linewise yank.  Issue 235.
Solution:   Redraw after the yank. (Christian Brabandt)

https://code.google.com/p/vim/source/detail?r=6d984caa0409fd284722c44cb09a0a2b5360bd4f
2014-08-13 13:45:54 -04:00
Pavel Platto
e1dd98512f Remove EBCDIC: Clean up comments 2014-08-02 09:16:59 +03:00