Commit Graph

279 Commits

Author SHA1 Message Date
bambu
5a5ef1c222 mouse: Implement horizontal scroll. #3450
- Code from Vim source.
- Removed the check for 'guioptions'
- mouse_spec.lua: test <ScrollWheelLeft> and <ScrollWheelRight>
- Move horizontal scroll logic to mouse.c
- Remove 'gui_' from the function names
- Renamed variables to be more specific (as opposed to generic p, w).
- Marked some functions as `static`
2016-04-25 01:31:44 -04:00
KillTheMule
23e8d6d94b Linting. 2016-04-23 23:43:39 +02:00
KillTheMule
445f0d7eed vim-patch:7.4.822
Problem:    More problems reported by coverity.
Solution:   Avoid the warnings. (Christian Brabandt)

cde8854730

Applied manually. Files that do not exst anymore: gui.c gui_w16.c gui_w32.c
if_xcmdsrv.c os_unix.c
2016-04-23 23:43:32 +02:00
ZyX
494b1c9bee *: Make set_vim_var_\* functions have proper argument types 2016-04-18 02:48:20 +03:00
Justin M. Keyes
576c5f7b74 Merge pull request #4323 from watiko/vim-7.4.961
vim-patch:7.4.961
2016-03-02 01:48:21 -05:00
Justin M. Keyes
36cb847d09 Merge #4231 'vim-patch:7.4.857'. 2016-03-02 01:08:38 -05:00
watiko
63606bb409 vim-patch:7.4.961
Problem:    Test107 fails in some circunstances.
Solution:   When using "zt", "zb" and "z=" recompute the fraction.

9dc2ce398b
2016-02-23 01:19:10 +09:00
Justin M. Keyes
b2b3768bb4 Merge pull request #4234 from watiko/vim-7.4.977
vim-patch:7.4.{818,883,977}
2016-02-17 04:10:50 -05:00
watiko
8eb0d43c12 vim-patch:7.4.883
Problem:    Block-mode replace works characterwise instead of blockwise after
            column 147. (Issue #422)
Solution:   Set Visual mode. (Christian Brabandt)

10ad1d90da
2016-02-11 16:45:08 +09:00
watiko
66571f64a4 vim-patch:7.4.818
Problem:    'linebreak' breaks c% if the last Visual selection was block.
            (Chris Morganiser, Issue 389)
Solution:   Handle Visual block mode differently. (Christian Brabandt)

89c17c02ca
2016-02-11 16:37:11 +09:00
watiko
51c3e0aa80 vim-patch:7.4.929
Problem:    "gv" after paste selects one character less if 'selection' is
            "exclusive".
Solution:   Increment the end position. (Christian Brabandt)

d29c6fea94
2016-02-11 15:13:30 +09:00
watiko
4a0e10fb2c vim-patch:7.4.734
Problem:    ml_get error when using "p" in a Visual selection in the last
            line.
Solution:   Change the behavior at the last line. (Yukihiro Nakadaira)

d009e86826
2016-02-11 15:13:30 +09:00
Jurica Bradaric
162d4bb3c6 vim-patch:7.4.857
Problem:    Dragging the current tab with the mouse doesn't work properly.
Solution:   Take the current tabpage index into account. (Hirohito Higashi)

4a4b821085
2016-02-10 22:51:16 +01:00
Justin M. Keyes
6fbb9ceb5e Merge pull request #4184 from watiko/vim-7.4.732
vim-patch:7.4.732
2016-02-09 02:14:38 -05:00
watiko
8b2b9b83b7 vim-patch:7.4.732
Problem:    The cursor line is not always updated for the "O" command.
Solution:   Reset the VALID_CROW flag. (Christian Brabandt)

d0d0fe09cf
2016-02-07 08:22:34 +09:00
Jurica Bradaric
ffd143be82 vim-patch:7.4.798
Problem:    Repeating a change in Visual mode does not work as expected.
            (Urtica Dioica)
Solution:   Make redo in Visual mode work better. (Christian Brabandt)

31b259bf95
2016-02-02 18:29:23 +01:00
ZyX
64038bf4e2 tabline: Switch to functions, handle different click types 2016-02-01 21:40:06 +03:00
ZyX
ef662498b1 tabline: Add %[] atom to the tabline, for random commands on click
Currently untested and undocumented.
2016-02-01 21:40:06 +03:00
watiko
2016365ffe vim-patch:7.4.1089
Problem:    Repeating CTRL-A doesn't work.
Solution:   Call prep_redo_cmd(). (Hirohito Higashi)

ef2b5036b3
2016-02-01 03:47:09 +09:00
watiko
8f212568aa vim-patch:7.4.1087
Problem:    CTRL-A and CTRL-X do not work properly with blockwise visual
            selection if there is a mix of Tab and spaces.
Solution:   Add OP_NR_ADD and OP_NR_SUB. (Hirohito Higashi)

d79e55016c
2016-02-01 03:47:09 +09:00
watiko
2f52ae18e7 vim-patch:7.4.1084
Problem:    Using "." to repeat CTRL-A in Visual mode increments the wrong
            numbers.
Solution:   Append right size to the redo buffer. (Ozaki Kiichi)

e1edc1caba
2016-02-01 03:47:09 +09:00
watiko
9664f513f4 vim-patch:7.4.807
Problem:    After CTRL-V CTRL-A mode isn't updated. (Hirohito Higashi)
Solution:   Clear the command line or update the displayed command.

0bbcb5c8ef
2016-02-01 03:43:37 +09:00
watiko
43fd126298 vim-patch:7.4.782
Problem:    Still a few problems with CTRL-A and CTRL-X in Visual mode.
Solution:   Fix the reported problems. (Christian Brabandt)

5d1bc78a2b
2016-02-01 03:43:37 +09:00
watiko
5ef1cb5c2e vim-patch:7.4.765
Problem:    CTRL-A and CTRL-X in Visual mode do not always work well.
Solution:   Improvements for increment and decrement. (Christian Brabandt)

9bb1930af9
2016-02-01 03:43:36 +09:00
watiko
4d074e39ea vim-patch:7.4.754
Problem:    Using CTRL-A in Visual mode does not work well. (Gary Johnson)
Solution:   Make it increment all numbers in the Visual area. (Christian
            Brabandt)

3a304b2382
2016-02-01 03:43:36 +09:00
watiko
8771e84db7 vim-patch:7.4.753
Problem:    Appending in Visual mode with 'linebreak' set does not work
            properly.  Also when 'selection' is "exclusive". (Ingo Karkat)
Solution:   Recalculate virtual columns. (Christian Brabandt)

74db34cc91
2016-01-28 20:52:41 +09:00
Charles Joachim
879c668d14 fileio: Replace some event checking functions with one has_event 2016-01-11 08:45:19 -05:00
Björn Linse
303ac3f283 normal: use oap->motion_type also to represent block motion type
Previously oap->motion_type == MCHAR would be blockwise if
oap->block_mode was set.
2016-01-01 12:56:51 +01:00
Justin M. Keyes
3c9d8ac99e Merge #3718 'vim-patch:7.4.655' 2015-12-13 00:35:09 -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
Johan Klokkhammer Helsing
cfa2107e33 vim-patch:7.4.655
Problem:    Text deleted by "dit" depends on indent of closing tag.
            (Jan Parthey)
Solution:   Do not adjust oap->end in do_pending_operator(). (Christian
            Brabandt)

b6c2735c56
2015-11-22 02:52:50 +01:00
Joe Hermaszewski
33eb33bb62 Implement handling of terminal focus events
Two new keys have been added to key_name_entry in keymap.c:
`FocusGained` and `FocusLost`.

Two cases have been added to the key handing switch in edit.c each
applying their respective autocmds.

In normal.c two functions have been added alongside nv_cursorhold doing
a similar job of applying the autocmd for the appropriate key.

tui/input.c has a new function `handle_focus_event` which eats either of
the control sequences for focus gained or lost. This function is checked
before handle_bracketed_paste and handle_forced_escape.

tui.c registers neovim as able to receive these control sequences in
terminfo_start and undoes that in terminfo_stop.

Closes #2302
2015-11-17 22:36:28 +00:00
oni-link
1d9ae27e38 normal.c: No garbage collection while handling an event in normal mode
Patch by @tarruda

Fixes #3588
2015-11-13 15:59:46 +01:00
Johan Klokkhammer Helsing
f65e7bf30c vim-patch:7.4.686 #3629
Problem:    "zr" and "zm" do not take a count.
Solution:   Implement the count, restrict the fold level to the maximum
            nesting depth.  (Marcin Szamotulski)

7d2757a472
2015-11-08 17:06:33 +01:00
Thiago de Arruda
f1bc3e4c0c normal: Extract some functions from normal_finish_command
- `normal_need_redraw_mode_message`
- `normal_redraw_mode_message`
2015-10-26 10:52:01 -03:00
Thiago de Arruda
4c6e417d2a normal: Extract normal_finish_command from normal_execute 2015-10-26 10:52:01 -03:00
Thiago de Arruda
5abd25f6fb normal: Extract normal_get_command_count from normal_execute 2015-10-26 10:52:01 -03:00
Thiago de Arruda
0f0fae58b9 normal: Extract some functions from normal_execute
- `normal_handle_special_visual_command`
- `normal_need_aditional_char`
- `normal_get_additional_char`
- `normal_invert_horizontal`
2015-10-26 10:52:01 -03:00
Thiago de Arruda
fa83b03fea normal: Split normal_check into multiple functions
Split most code in `normal_check` in:

- `normal_check_stuff_buffer`
- `normal_check_interrupt`
- `normal_check_cursor_moved`
- `normal_check_text_changed`
- `normal_check_folds`
- `normal_redraw`
2015-10-26 10:52:01 -03:00
Thiago de Arruda
8d93621c63 main: Start modeling Nvim as pushdown automaton
From a very high level point of view, Vim/Nvim can be described as state
machines following these instructions in a loop:

- Read user input
- Peform some action. The action is determined by the current state and can
  switch states.
- Possibly display some feedback to the user.

This is not immediately visible because these instructions spread across dozens
of nested loops and function calls, making it very hard to modify the state
machine(to support more event types, for example).

So far, the approach Nvim has taken to allow more events is this:

- At the very core function that blocks for input, poll for arbitrary events.
- If the event received from the OS is user input, just return it normally to
  the callers.
- If the event is not direct result of user input(possibly a vimscript function
  call coming from a msgpack-rpc socket or a job control callback), return a
  special key code(`K_EVENT`) that is handled by callers where it is safer to
  perform arbitrary actions.

One problem with this approach is that the `K_EVENT` signal is being sent across
multiple states that may be unaware of it. This was partially fixed with the
`input_enable_events`/`input_disable_events` functions, which were added as a
mechanism that the upper layers can use to tell the core input functions that it
is ready to accept `K_EVENT`.

Another problem is that the mapping engine is implemented in getchar.c
which is called from every state, but the mapping engine is not aware of
`K_EVENT` so events can break mappings.

While it is theoretically possible to modify getchar.c to make it aware of
`K_EVENT`, this commit fixes the problem with a different approach: Model Nvim
as a pushdown automaton(https://en.wikipedia.org/wiki/Pushdown_automaton). This
design has many advantages which include:

- Decoupling the event loop from the states reponsible for handling events.
- Better control of state transition with less dependency on global variable
  hacks(eg: 'restart_edit' global variable).
- Easier removal of global variables and function splitting. That is because
  many variables are for state-specific information, and probably ended up being
  global to simplify communication between functions, which we fix by storing
  state-specific information in specialized structures.

The final goal is to let Nvim have a single top-level event loop represented by
the following pseudo-code:

```
while not quitting
  let event = read_event
  current_state(event)
  update_screen()
```

This closely mirrors the state machine description above and makes it easier to
understand, extend and debug the program.

Note that while the pseudo code suggests an explicit stack of states that
doesn't rely on return addresses(as suggested by the principles of
automata-based programming:
https://en.wikipedia.org/wiki/Automata-based_programming), for now we'll use the
call stack as a structure to manage state transitioning as it would be very
difficult to refactor Nvim to use an explicit stack of states, and the benefits
would be small.

While this change may seem like an endless amount of work, it is possible to
do it incrementally as was shown in the previous commits. The general procedure
is:

1- Find a blocking `vgetc()`(or derivatives) call. This call represents an
   implicit state of the program.

2- Split the code before and after the `vgetc()` call into functions that match
   the signature of `state_check_callback` and `state_execute_callback.
   Only `state_execute_callback` is required.

3- Create a `VimState` "subclass" and a initializer function that sets the
   function pointers and performs any other required initialization steps. If
   the state has no local variables, just use `VimState` without subclassing.

4- Instead of calling the original function containing the `vgetc()`,
   initialize a stack-allocated `VimState` subclass, then call `state_enter` to
   begin processing events in the state.

5- The check/execute callbacks can return 1 to continue normally, 0 to break the
   loop or -1 to skip to the next iteration. These callbacks contain code that
   execute before and after the old `vgetc()` call.

The functions created in step 2 may contain other `vgetc()` calls. These
represent implicit sub-states of the current state, but it is fine to remove
them later in smaller steps since we didn't break compatibility with existing
code.
2015-10-26 10:52:01 -03:00
Thiago de Arruda
350ffc63db main: Refactor normal_enter to call os_inchar directly
This makes it impossible for K_EVENT to interfere with mappings, but it also
disables processing of events while in the middle of a mapping (Though this will
be fixed later as this refactoring progresses).

`may_sync_undo` is now called when K_EVENT is received. This is necessary to
correctly update undo entry lists before executing some action.
2015-10-26 10:52:01 -03:00
Thiago de Arruda
32594a33a3 main: Call normal_execute from normal_enter
`normal_prepare` is now called by `normal_check` before returning 1(to
continue).

Also remove `input_{enable,disable}_events` calls from `normal_cmd`, which only
exists now as a compatibility function to run normal commands with keys inserted
into the typeahead buffer(We don't want to process events in these cases
anyway).
2015-10-26 10:52:01 -03:00
Thiago de Arruda
e5165bae11 input: Remove CURSORHOLD key
Refactor input.c, normal.c and edit.c to use the K_EVENT special key to trigger
the CURSORHOLD event. In normal and edit mode, K_EVENT is treated as
K_CURSORHOLD, which enables better handling of arbitrary actions in those
states(eg: In normal mode the previous operator counts will be restored).

Also fix a test in vim_spec.lua. The test had a wrong assumption: cmdheight is
only used to determine when the press enter screen will be shown, not to limit
how many lines or control pagination.
2015-10-26 10:52:01 -03:00
Thiago de Arruda
d8055f8eab normal: Fix code style in normal_prepare and normal_execute
This was done separately to make it easier to follow the changes in the previous
commit.
2015-10-26 10:52:01 -03:00
Thiago de Arruda
82bb8c887c normal: Extract most normal_cmd logic into two functions
The new functions are `normal_prepare` and `normal_execute` which contain code
executed before and after input is received in normal mode.
2015-10-26 10:52:01 -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
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