#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/digraph.h"
#include "nvim/edit.h"
#include "nvim/eval/userfunc.h"
#include "nvim/event/loop.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/getchar.h"
#include "nvim/globals.h"
#include "nvim/grid_defs.h"
#include "nvim/indent.h"
#include "nvim/keycodes.h"
#include "nvim/log.h"
#include "nvim/main.h"
#include "nvim/mapping.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/mouse.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/time.h"
#include "nvim/plines.h"
#include "nvim/quickfix.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/spell.h"
#include "nvim/spellfile.h"
#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/vim.h"
#include "nvim/window.h"
Data Structures | |
struct | normal_state |
struct | nv_cmd |
Macros | |
#define | NV_NCH 0x01 |
#define | NV_NCH_NOP (0x02|NV_NCH) |
#define | NV_NCH_ALW (0x04|NV_NCH) |
#define | NV_LANG 0x08 |
#define | NV_SS 0x10 |
#define | NV_SSS 0x20 |
#define | NV_STS 0x40 |
#define | NV_RL 0x80 |
#define | NV_KEEPREG 0x100 |
#define | NV_NCW 0x200 |
#define | NV_CMDS_SIZE ARRAY_SIZE(nv_cmds) |
#define | SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30) |
Typedefs | |
typedef struct normal_state | NormalState |
typedef void(* | nv_func_T) (cmdarg_T *cap) |
Functions | |
void | init_normal_cmds (void) |
Initialize the nv_cmd_idx[] table. More... | |
void | normal_enter (bool cmdwin, bool noexmode) |
bool | do_mouse (oparg_T *oap, int c, int dir, long count, bool fixindent) |
void | end_visual_mode (void) |
void | reset_VIsual_and_resel (void) |
Reset VIsual_active and VIsual_reselect. More... | |
void | reset_VIsual (void) |
Reset VIsual_active and VIsual_reselect if it's set. More... | |
void | restore_visual_mode (void) |
size_t | find_ident_under_cursor (char_u **text, int find_type) FUNC_ATTR_NONNULL_ARG(1) |
size_t | find_ident_at_pos (win_T *wp, linenr_T lnum, colnr_T startcol, char_u **text, int *textcol, int find_type) FUNC_ATTR_NONNULL_ARG(1 |
for (i=(find_type &FIND_IDENT) ? 0 :1;i< 2;i++) | |
if (ptr[col]==NUL||(i==0 &&this_class !=2)) | |
if (textcol !=NULL) | |
while (ptr[col] !=NUL &&((i==0 ? mb_get_class(ptr+col)==this_class :mb_get_class(ptr+col) !=0)||((find_type &FIND_EVAL) &&col<=(int) startcol &&find_is_eval_item(ptr+col, &col, &bn, FORWARD)))) | |
assert (col >=0) | |
return (size_t) | |
Prepare for redo of a normal command. More... | |
void | prep_redo (int regname, long num, int cmd1, int cmd2, int cmd3, int cmd4, int cmd5) |
void | clearop (oparg_T *oap) |
void | clearopbeep (oparg_T *oap) |
void | may_clear_cmdline (void) |
void | clear_showcmd (void) |
bool | add_to_showcmd (int c) |
void | add_to_showcmd_c (int c) |
void | push_showcmd (void) |
void | pop_showcmd (void) |
void | do_check_scrollbind (bool check) |
void | check_scrollbind (linenr_T topline_diff, long leftcol_diff) |
bool | find_decl (char_u *ptr, size_t len, bool locally, bool thisblock, int flags_arg) |
void | scroll_redraw (int up, long count) |
Scroll "count" lines up or down, and redraw. More... | |
void | do_nv_ident (int c1, int c2) |
Call nv_ident() as if "c1" was used, with "c2" as next character. More... | |
bool | get_visual_text (cmdarg_T *cap, char_u **pp, size_t *lenp) |
void | start_selection (void) |
Start selection for Shift-movement keys. More... | |
void | may_start_select (int c) |
bool | unadjust_for_sel (void) |
void | set_cursor_for_append_to_line (void) |
Move the cursor for the "A" command. More... | |
void | normal_cmd (oparg_T *oap, bool toplevel) |
Variables | |
size_t int | i |
int | this_class = 0 |
int | prev_class |
int | prevcol |
int | bn = 0 |
char_u * | ptr = ml_get_buf(wp->w_buffer, lnum, false) |
* | text = ptr |
startcol = col | |
col = 0 | |
#define NV_CMDS_SIZE ARRAY_SIZE(nv_cmds) |
#define NV_KEEPREG 0x100 |
#define NV_LANG 0x08 |
#define NV_NCH 0x01 |
#define NV_NCH_ALW (0x04|NV_NCH) |
#define NV_NCH_NOP (0x02|NV_NCH) |
#define NV_NCW 0x200 |
#define NV_RL 0x80 |
#define NV_SS 0x10 |
#define NV_SSS 0x20 |
#define NV_STS 0x40 |
#define SHOWCMD_BUFLEN (SHOWCMD_COLS + 1 + 30) |
typedef struct normal_state NormalState |
Function to be called for a Normal or Visual mode command. The argument is a cmdarg_T.
bool add_to_showcmd | ( | int | c | ) |
Add 'c' to string of shown command chars.
void add_to_showcmd_c | ( | int | c | ) |
assert | ( | col >= | 0 | ) |
Synchronize any windows that have "scrollbind" set, based on the number of rows by which the current window has changed (1998-11-02 16:21:01 R. Edward Ralston erals[email protected] compu ter. org)
When "check" is false, prepare for commands that scroll the window. When "check" is true, take care of scroll-binding after the window has scrolled. Called from normal_cmd() and edit().
Do the appropriate action for the current mouse click in the current mode. Not used for Command-line mode.
Normal Mode: event modi- position visual change action fier cursor window left press - yes end yes left press C yes end yes "^]" (2) left press S yes end yes "*" (2) left drag - yes start if moved no left relse - yes start if moved no middle press - yes if not active no put register middle press - yes if active no yank and put right press - yes start or extend yes right press S yes no change yes "#" (2) right drag - yes extend no right relse - yes extend no
Insert or Replace Mode: event modi- position visual change action fier cursor window left press - yes (cannot be active) yes left press C yes (cannot be active) yes "CTRL-O^]" (2) left press S yes (cannot be active) yes "CTRL-O*" (2) left drag - yes start or extend (1) no CTRL-O (1) left relse - yes start or extend (1) no CTRL-O (1) middle press - no (cannot be active) no put register right press - yes start or extend yes CTRL-O right press S yes (cannot be active) yes "CTRL-O#" (2)
(1) only if mouse pointer moved since press (2) only if click is in same buffer
oap | operator argument, can be NULL |
c | K_LEFTMOUSE, etc |
dir | Direction to 'put' if necessary |
fixindent | PUT_FIXINDENT if fixing indent necessary |
void do_nv_ident | ( | int | c1, |
int | c2 | ||
) |
Call nv_ident() as if "c1" was used, with "c2" as next character.
End Visual mode. This function should ALWAYS be called to end Visual mode, except from do_pending_operator().
Search for variable declaration of "ptr[len]". When "locally" is true in the current function ("gd"), otherwise in the current file ("gD").
thisblock | when true check the {} block scope. |
flags_arg | flags passed to searchit() |
size_t find_ident_at_pos | ( | win_T * | wp, |
linenr_T | lnum, | ||
colnr_T | startcol, | ||
char_u ** | text, | ||
int * | textcol, | ||
int | find_type | ||
) |
Like find_ident_under_cursor(), but for any window and any position. However: Uses 'iskeyword' from the current window!.
textcol | column where "text" starts, can be NULL |
size_t find_ident_under_cursor | ( | char_u ** | text, |
int | find_type | ||
) |
Find the identifier under or to the right of the cursor. "find_type" can have one of three values: FIND_IDENT: find an identifier (keyword) FIND_STRING: find any non-white text FIND_IDENT + FIND_STRING: find any non-white text, identifier preferred. FIND_EVAL: find text useful for C program debugging
There are three steps:
If text is found, a pointer to the text is put in "*text". This points into the current buffer line and is not always NUL terminated.
for | ( | ) |
Get visually selected text, within one line only.
pp | return: start of selected text |
lenp | return: length of selected text |
if | ( | ptr | [col] = = NUL || (i == 0 && this_class != 2) | ) |
if | ( | textcol ! | = NULL | ) |
If the mode is currently displayed clear the command line or update the command displayed.
void may_start_select | ( | int | c | ) |
Start Select mode, if "c" is in 'selectmode' and not in a mapping or menu. When "c" is 'o' (checking for "mouse") then also when mapped.
Normal state entry point. This is called on:
q:
). Returns when cmdwin_result
!= 0.:global/PAT/visual
for example. Returns when re-entering ex mode(because ex mode recursion is not allowed)This used to be called main_loop on main.c
void prep_redo | ( | int | regname, |
long | num, | ||
int | cmd1, | ||
int | cmd2, | ||
int | cmd3, | ||
int | cmd4, | ||
int | cmd5 | ||
) |
Prepare for redo of any command. Note that only the last argument can be a multi-byte char.
push_showcmd() and pop_showcmd() are used when waiting for the user to type something and there is a partial mapping.
return | ( | size_t | ) |
Prepare for redo of a normal command.
void scroll_redraw | ( | int | up, |
long | count | ||
) |
Scroll "count" lines up or down, and redraw.
Exclude last character at end of Visual area for 'selection' == "exclusive". Should check VIsual_mode before calling this.
while | ( | ptr ! | [col] = NUL && ((i == 0 ? mb_get_class(ptr + col) == this_class : mb_get_class(ptr + col) != 0) || ((find_type & FIND_EVAL) && col <= (int)startcol && find_is_eval_item(ptr + col, &col, &bn, FORWARD))) | ) |
bn = 0 |
col = 0 |
size_t int i |
int prev_class |
int prevcol |
ptr = ml_get_buf(wp->w_buffer, lnum, false) |
startcol = col |
* text = ptr |
this_class = 0 |