Commit Graph

503 Commits

Author SHA1 Message Date
Jason Schulz
f82e982bda Fix lint issues 2016-01-15 20:32:00 -08:00
Jason Schulz
7ad3f077dc Add support for binary numbers 2016-01-15 18:21:06 -08:00
Rui Abreu Ferreira
12b23070d4 Fix Windows code in command_line_execute() 2015-12-04 23:25:04 -05:00
Michael Reed
53ee6425c8 src/*: Remove VIM - Vi improved ... header
Regarding the individual items in the header:

`Vim - Vi improved	by Bram Moolenar`
  Bram Moolenar is already mentioned throughout the documentation, as
  well as the intro screen.

`:help uganda`
  It's already shown to all users who don't use `shortmess+=I` upon
  starting nvim, and is already placed prominently in help.txt, i.e.,
  `:help` run with no arguments.

`:help credits`
  Already mentioned near the top of help.txt.

`README.md`
  Already mentioned in develop.txt.
2015-11-27 16:25:10 -05:00
Rui Abreu Ferreira
4f24b9e06f Remove unnecessary includes for errno.h 2015-11-25 16:38:33 -05:00
Michael Reed
af5483089e src: README.txt -> README.md
The former no longer exists in this repo; see the top of
src/nvim/README.md.
2015-11-23 21:38:08 -05:00
Joe Hermaszewski
442cd0672b Enable focus events in cmdline and terminal modes
This change adds switch cases for K_FOCUSGAINED and K_FOCUSLOST to the
input handling functions in ex_getln.c and terminal.c. The handling is
identical to what's found in edit.c (just calling apply_autocmds).

If one enters cmdline-mode by feeding `:` and sends a focuslost event (by
leaving the window for example) the text `<FocusLost>` will be inserted
into the command line. There is similar behaviour in terminal mode. This
patch corrects this behavior to fire the apropriate autocmd instead.

Fixes #3714
2015-11-23 13:18:27 +01:00
Thiago de Arruda
ed985d06ef ex_getln: Extract command_line_handle_key from command_line_execute 2015-10-26 10:52:02 -03:00
Thiago de Arruda
c0c562f97f ex_getln: Convert cmdline_{not_,}changed labels into functions 2015-10-26 10:52:02 -03:00
Thiago de Arruda
0701e1bfa4 ex_getln: refactor command line mode to use the state_enter loop
Split `getcmdline()` into command_line_{enter,check,execute}`
2015-10-26 10:52:02 -03:00
Thiago de Arruda
52d4978b03 ex_getln: Extract local variables from getcmdline() and fix code style
Begin refactoring getcmdline() into a state that can be managed by the
`state_enter()`:

- Move local variables into a local CommandLineState structure
- Fix code style in the entire function.
2015-10-26 10:52:02 -03:00
Thiago de Arruda
dae006a942 main: Extract normal_check from main_loop
The new function contains logic that must be executed after handling input in
normal mode and also before the first main loop iteration. Also rename
`main_loop` to `normal_enter` and move it to normal.c
2015-10-26 10:52:01 -03:00
Johan Klokkhammer Helsing
3bb2662669 vim-patch:7.4.793
Problem:    Can't specify when not to ring the bell.
Solution:   Add the 'belloff' option. (Christian Brabandt)

165bc69d1b
2015-10-18 01:58:18 +02:00
ZyX
19785a0198 ex_getln: Fix memory leak when overwriting history item 2015-10-08 22:01:12 +03:00
ZyX
ad7b7716bb *: Fix lint errors found in new code in previously ignored files 2015-10-08 22:00:50 +03:00
ZyX
bcd8789609 ex_getln: Return something from hist_type2char without asserts
Otherwise QuickBuild shows a warning that control may reach end of non-void
function.
2015-10-08 22:00:42 +03:00
ZyX
07d9ab26c6 *: Make ShaDa code use VimL values for additional_\* data 2015-10-08 22:00:16 +03:00
ZyX
0fe9679101 shada: Initial support for merging history
Currently only merges history when reading ShaDa file. No tests yet.
2015-10-08 21:59:53 +03:00
ZyX
244dbe3a77 viminfo: First version of ShaDa file dumping
What works:

1. ShaDa file dumping: header, registers, jump list, history, search patterns,
   substitute strings, variables.
2. ShaDa file reading: registers, global marks, variables.

Most was not tested.

TODO:

1. Merging.
2. Reading history, local marks, jump and buffer lists.
3. Documentation update.
4. Converting some data from &encoding.
5. Safer variant of dumping viminfo (dump to temporary file then rename).
6. Removing old viminfo code (currently masked with `#if 0` in a ShaDa file for
   reference).
2015-10-08 21:59:51 +03:00
Thiago de Arruda
1143b416ab tui: Don't use 'pastetoggle' for automatic pasting
Add a new special key that can be used by UIs to toggle the 'paste' option and
use it in the TUI instead of the user's 'pastetoggle' value.

Close #2843 #2092
2015-10-01 15:22:48 -03:00
oni-link
367fc41943 path.c: Fix memory leak in expand_wildcards().
A file that matches with one of the patterns in 'wildignore' is ignored
when using expand_wildcards(). After removing ignored files, the array
of (file name) matches can be empty. But an empty array is never freed.
2015-09-09 19:03:45 +02:00
Thiago de Arruda
502aee690c event: Refactor async event processing
- Improve the implementation of deferred/immediate events.
- Use the new queue module to change how/when events are queued/processed by
  giving a private queue to each emitter.
- Immediate events(which only exist to break uv_run recursion) are now
  represented in the `loop->fast_events` queue.
- Events pushed to child queues are propagated to the event loop main queue and
  processed as K_EVENT keys.
2015-08-13 08:49:38 -03:00
Thiago de Arruda
3f5af6c1c4 loop: Simplify loop.c and move some code to input.c
- Declare poll timer in Loop structure instead of a loop_poll_events local
  variable.
- Move deferred event management to input.c
2015-08-13 07:41:04 -03:00
Thiago de Arruda
991d3ec1e6 event loop: New abstraction layer with refactored time/signal API
- Add event loop abstraction module under src/nvim/event. The
  src/nvim/event/loop module replaces src/nvim/os/event
- Remove direct dependency on libuv signal/timer API and use the new abstraction
  instead.
- Replace all references to uv_default_loop() by &loop.uv, a new global variable
  that wraps libuv main event loop but allows the event loop functions to be
  reused in other contexts.
2015-07-17 00:19:19 -03:00
Mark Bainter
f813fdce38 Remove char_u: add_pathsep() 2015-05-06 21:25:04 -05:00
Felipe Morales
7fc952ab67 vim-patch:7.4.542
Problem:    Using a range for window and buffer commands has a few
            problems.
            Cannot specify the type of range for a user command.
Solution:   Add the -addr argument for user commands.  Fix problems.
            (Marcin Szamotulski

https://code.google.com/p/vim/source/detail?name=v7-4-542
2015-04-28 23:08:31 -03:00
Eliseo Martínez
46f510350e Fix warnings: ex_getln.c: getexmodeline(): HI.
Problem    : Dead increment @ 1795.
Diagnostic : Harmless issue.
Rationale  : Line was necessary before (indent was used by the following
             while loop), but now that loop is removed, assignment is
             indeed dead.
Resolution : Remove line.
2015-04-27 19:50:33 +02:00
Eliseo Martínez
8ee09a3bd2 Fix warnings: ex_getln.c: init_history(): Nonnull attr passed null: HI.
Problem    : Argument with 'nonnull' attribute passed null @ 4227.
Diagnostic : Harmless issue.
Rationale  : It's true we're calling memset with NULL pointer, but it's
             also true we're doing it with zero size. We just thought
             that would work and do nothing (it was a way of avoiding
             to add a guard). It doesn't work, though, as memset
             requires nonnull arguments.
Resolution : Add guard to avoid null argument.
2015-04-27 15:55:03 +02:00
oni-link
2493b6fefc ex_getln: Fixes for some problems with getexmodeline()
Problems with line-input editing commands in Ex mode
('nvim -e' or 'Q' in normal mode):

CTRL_U: Only after the next keystroke the complete
        line change is shown if the indentation was
        not 0.

        :     asdfCTRL_U

CTRL_T: Memory reallocation with ga_grows() before a
        memmove(), but pointers into the memory are
        not updated.

        :set sw=40
        :CTRL_T
        ...

        Should complain about a memory error.

CTRL_D: Trying to reduce an indentation of 0.

        :set sw=1
        :CTRL_D

        Segfault

Helped-by: Scott Prager <splinterofchaos@gmail.com>
2015-04-26 23:47:59 -04: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
caabcae0b7 Replace VIM_ISDIGIT() and vim_isdigit() with ascii_isdigit() defined in ascii.h 2015-04-24 20:37:13 -03:00
Eliseo Martínez
920381c01b Merge #2491: Fix xfree of static value from vim_getenv() refactor.
Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
2015-04-23 22:00:00 +02:00
Mark Bainter
b68ce1460d Fix xfree of static value in expand_shellcmd()
The refactoring of vim_getenv() to remove the mustfree arg
included reworking calling functions.  expand_shellcmd was
also using that to track its usage of the variable within
the function, resulting in #2487. This change addresses
that scenario and cleans up some of the function for style.
2015-04-23 16:12:14 +00:00
Eliseo Martínez
c22b6124e2 Fix warnings: ex_getln.c: init_history(): NP dereference: FP.
Problem    : Dereference of null pointer @ 4199.
Diagnostic : False positive.
Rationale  : Suggested error path implies that newlen == 0 and
             newlen > hislen, which implies hislen < 0, which is
             impossible (hislen is always between 0 and 10000).
Resolution : Refactor code.
             Asserting oldlen >= 0 should have sufficed, but
             for some reason analyzer doesn't follow implications in
             that case.
             Asserting newlen != 0 || newlen <= hislen works.
             But the chance has been taken to do extensive
             refactoring of this function, as it was difficult to
             understand as it was.
             As a result of refactoring, assert is not needed anymore,
             as we don't call clear_hist_entry() in refactored version.
Refactor   : - Rework algorithm:
               * Drop guard for OOM case, which can't happen now.
               * Drop empty/growing/shrinking cases. Simplify to always
                 doing the same.
               * Perform circular array reordering in all cases
                 (before, it only did when shrinking).
               * Work in batches through memcpy/memset, instead of one
                 entry at a time, as it did before.
             - Inline variable declarations.
             - Replace `ssize_t` by `int`.
             - Introduce oldlen as entry value of hislen.
             - Add a lot of comments.

Helped-by: Scott Prager <splinterofchaos@gmail.com>
Helped-by: oni-link <knil.ino@gmail.com>
2015-04-23 16:26:44 +02:00
Eliseo Martínez
7086d435e0 Merge #2418: Remove char_u (4)
Reviewed-by: Scott Prager <splinterofchaos@gmail.com>
Reviewed-by: Michael Reed <m.reed@mykolab.com>
Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
2015-04-19 21:10:21 +02:00
Mark Bainter
a7e17de048 Refactor get_env() to respect const qualifier
Without the casts*, the compiler rightly warns about the os_getenv
losing the qualifier.  This refactor adds a variable to manage this
properly, and renames the original variables to increase clarity.
2015-04-18 21:37:10 +00:00
Mark Bainter
4848158cc1 Remove char_u: vim_getenv() 2015-04-17 14:46:58 +00: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
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
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
oni-link
8ee6f90bf8 Fix problem with coverity/105568 fix.
The original fix 3db0a40d69
does not work for more than one loop iteration, because memory allocated
in the previous iteration could be reused in the current iteration.

Because expand_wildcards() never reads the variables *num_file
and *file before the first assignment to them, the initial
values for these variables can be anything. So instead of
calling expand_shellcmd() with *file = "" we set *file = NULL.
That should help coverity see, that not a array-typed value
is freed.

Helped-by: Eliseo Martínez <eliseomarmol@gmail.com>
2015-04-05 20:27:46 -04:00
oni-link
adb3ec2026 Update comments for expand_wildcards functions.
Be more specific in the description of mch_expand_wildcards():
This function will never free memory pointed to by its arguments.
If OK is returned, *file will always point to allocated memory.
*num_file is set to the number of pointers in *file.
If FAIL is returned *file is set to NULL and *num_file to 0.

If gen_expand_wildcards() returns FAIL, no memory allocation in this
function needs to be undone.

If expand_wildcards() returns FAIL, no memory allocation in this
function needs to be undone.

Helped-by: Eliseo Martínez <eliseomarmol@gmail.com>
Helped-by: Michael Reed <m.reed@mykolab.com>
2015-04-05 20:27:46 -04:00
David Bürgin
21f446ebb4 vim-patch:7.4.324
Problem:    In Ex mode, cyrillic characters are not handled. (Stas Malavin)
Solution:   Support multi-byte characters in Ex mode. (Yukihiro Nakadaira)

https://github.com/vim/vim/releases/tag/v7-4-324
2015-03-30 12:03:33 +02:00
bobtwinkles
03d47965c0 refactor: split some more functions from misc1.c
This commit pulls the some environment-variable handling functions out of
misc1.c and in to os/env.c. Previously submited as #1231, this is the start of
a patch series that does that work based on a more up-to-date master branch.

Major tasks accomplished:
  - move functions and fix includes
  - fix clint/clang analysis warnings
  - correct documentation comments
2015-03-24 16:13:00 -04:00
Eliseo Martínez
3db0a40d69 coverity/105568: Free of array-typed value: FP.
Problem    : Free of array-typed value @ 3628.
Diagnostic : False positive.
Rationale  : expand_shell_cmd() is called with a mock value for file
             (*file = (char_u **)""). That means we want file to be
             filled with a new value. We can't use *file = NULL because
             that means we don't want file to be filled.
             Now, coverity incorrectly thinks that sentinel value is the
             one we are freeing up at some other later point, which is
             not the case.
Resolution : Assert that, when we are freeing *file, its value is
             different than the sentinel one.
2015-03-22 11:31:47 +01:00
Thiago de Arruda
8b7b71f474 ui: Refactor so that busy state won't be the default
Even though assuming nvim is busy most times is simpler, it has a problem: A lot
of unnecessary busy_start/busy_stop notifications are sent to the UI. That's
because in the majority of scenarios almost no time is spent between
`event_poll` calls.

This restores the normal behavior which is to call busy_start only when nvim is
going to perform some task that can take a significant amount of time. Also
improve the usage of buffering in the TUI when changing the cursor state.
2015-03-18 14:16:23 -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
Michael Reed
4d7b31fd61 Macro cleanup: USE_ON_FLY_SCROLL 2015-03-05 19:03:36 -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
Thiago de Arruda
e0e41b30c6 ui: Remove/adapt some old code for a big UI refactor
- Remove abstract_ui global, now it is always active
- Remove some terminal handling code
- Remove unused functions
- Remove HAVE_TGETENT/TERMINFO/TERMIOS/IOCTL #ifdefs
- Remove tgetent/terminfo from version.c
- Remove curses/terminfo dependencies
- Only start/stop termcap when starting/exiting the program
- msg_use_printf will return true if there are no attached UIs(
  messages will be written to stdout)
- Remove `ex_winpos`(implement `:winpos` with `ex_ni`)
2015-02-16 23:17:39 -03:00