diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2016-09-11 04:01:41 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2016-09-13 16:20:09 +0200 |
commit | df072c3b2b20fb7d3d9d50b5ab0df92827aa628f (patch) | |
tree | fb80cb1409d60a6316d534b989451cd9986934e6 /src/nvim/state.c | |
parent | 7eb4d2f79dcc712dae1513516b9db5f574d51437 (diff) | |
download | rneovim-df072c3b2b20fb7d3d9d50b5ab0df92827aa628f.tar.gz rneovim-df072c3b2b20fb7d3d9d50b5ab0df92827aa628f.tar.bz2 rneovim-df072c3b2b20fb7d3d9d50b5ab0df92827aa628f.zip |
refactor: eliminate misc2.c
move `call_shell` to misc1.c
Move some fns to state.c
Move some fns to option.c
Move some fns to memline.c
Move `vim_chdir*` fns to file_search.c
Move some fns to new module, bytes.c
Move some fns to fileio.c
Diffstat (limited to 'src/nvim/state.c')
-rw-r--r-- | src/nvim/state.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/nvim/state.c b/src/nvim/state.c index 30133e2201..f792ec00a4 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -2,10 +2,12 @@ #include "nvim/lib/kvec.h" +#include "nvim/ascii.h" #include "nvim/state.h" #include "nvim/vim.h" #include "nvim/main.h" #include "nvim/getchar.h" +#include "nvim/option_defs.h" #include "nvim/ui.h" #include "nvim/os/input.h" @@ -61,3 +63,35 @@ getkey: } } } + +/// Return TRUE if in the current mode we need to use virtual. +int virtual_active(void) +{ + // While an operator is being executed we return "virtual_op", because + // VIsual_active has already been reset, thus we can't check for "block" + // being used. + if (virtual_op != MAYBE) { + return virtual_op; + } + return ve_flags == VE_ALL + || ((ve_flags & VE_BLOCK) && VIsual_active && VIsual_mode == Ctrl_V) + || ((ve_flags & VE_INSERT) && (State & INSERT)); +} + +/// VISUAL, SELECTMODE and OP_PENDING State are never set, they are equal to +/// NORMAL State with a condition. This function returns the real State. +int get_real_state(void) +{ + if (State & NORMAL) { + if (VIsual_active) { + if (VIsual_select) { + return SELECTMODE; + } + return VISUAL; + } else if (finish_op) { + return OP_PENDING; + } + } + return State; +} + |