Data Structures | Macros | Typedefs | Enumerations | Functions
ex_cmds2.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include <fcntl.h>
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/ex_cmds2.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/ex_getln.h"
#include "nvim/fileio.h"
#include "nvim/getchar.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/garray.h"
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/normal.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/strings.h"
#include "nvim/undo.h"
#include "nvim/window.h"
#include "nvim/profile.h"
#include "nvim/os/os.h"
#include "nvim/os/shell.h"
#include "nvim/os/fs_defs.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"

Data Structures

struct  scriptitem_S
 
struct  sn_prl_S
 
struct  source_cookie
 
struct  debuggy
 

Macros

#define SCRIPT_ITEM(id)   (((scriptitem_T *)script_items.ga_data)[(id) - 1])
 
#define PRL_ITEM(si, idx)   (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
 
#define CMD_CONT   1
 
#define CMD_NEXT   2
 
#define CMD_STEP   3
 
#define CMD_FINISH   4
 
#define CMD_QUIT   5
 
#define CMD_INTERRUPT   6
 
#define CMD_BACKTRACE   7
 
#define CMD_FRAME   8
 
#define CMD_UP   9
 
#define CMD_DOWN   10
 
#define BREAKP(idx)   (((struct debuggy *)dbg_breakp.ga_data)[idx])
 
#define DEBUGGY(gap, idx)   (((struct debuggy *)gap->ga_data)[idx])
 
#define DBG_FUNC   1
 
#define DBG_FILE   2
 
#define AL_SET   1
 Code to handle the argument list. More...
 
#define AL_ADD   2
 
#define AL_DEL   3
 

Typedefs

typedef struct scriptitem_S scriptitem_T
 
typedef struct sn_prl_S sn_prl_T
 

Enumerations

enum  { PEXP_SUBCMD, PEXP_FUNC }
 

Functions

void do_debug (char_u *cmd)
 
void ex_debug (exarg_T *eap)
 ":debug". More...
 
void dbg_check_breakpoint (exarg_T *eap)
 
bool dbg_check_skipped (exarg_T *eap)
 
void ex_breakadd (exarg_T *eap)
 ":breakadd". More...
 
void ex_debuggreedy (exarg_T *eap)
 ":debuggreedy". More...
 
void ex_breakdel (exarg_T *eap)
 ":breakdel" and ":profdel". More...
 
void ex_breaklist (exarg_T *eap)
 ":breaklist". More...
 
linenr_T dbg_find_breakpoint (bool file, char_u *fname, linenr_T after)
 
bool has_profiling (bool file, char_u *fname, bool *fp)
 
void dbg_breakpoint (char_u *name, linenr_T lnum)
 Called when a breakpoint was encountered. More...
 
void ex_profile (exarg_T *eap)
 ":profile cmd args" More...
 
void ex_python (exarg_T *eap)
 
void ex_pyfile (exarg_T *eap)
 
void ex_pydo (exarg_T *eap)
 
void ex_ruby (exarg_T *eap)
 
void ex_rubyfile (exarg_T *eap)
 
void ex_rubydo (exarg_T *eap)
 
void ex_python3 (exarg_T *eap)
 
void ex_py3file (exarg_T *eap)
 
void ex_pydo3 (exarg_T *eap)
 
char_uget_profile_name (expand_T *xp, int idx)
 
void set_context_in_profile_cmd (expand_T *xp, const char *arg)
 Handle command line completion for :profile command. More...
 
void profile_dump (void)
 Dump the profiling info. More...
 
void script_prof_save (proftime_T *tm)
 Save time when starting to invoke another script or function. More...
 
void script_prof_restore (proftime_T *tm)
 Count time spent in children after invoking another script or function. More...
 
void prof_inchar_enter (void)
 Called when starting to wait for the user to type a character. More...
 
void prof_inchar_exit (void)
 Called when finished waiting for the user to type a character. More...
 
bool prof_def_func (void)
 
int autowrite (buf_T *buf, int forceit)
 
void autowrite_all (void)
 Flush all buffers, except the ones that are readonly or are never written. More...
 
bool check_changed (buf_T *buf, int flags)
 
void dialog_changed (buf_T *buf, bool checkall)
 
bool dialog_close_terminal (buf_T *buf)
 
bool can_abandon (buf_T *buf, int forceit)
 
bool check_changed_any (bool hidden, bool unload)
 
int check_fname (void)
 
int buf_write_all (buf_T *buf, int forceit)
 
int get_arglist_exp (char_u *str, int *fcountp, char_u ***fnamesp, bool wig)
 
void check_arg_idx (win_T *win)
 Check if window "win" is editing the w_arg_idx file in its argument list. More...
 
void ex_args (exarg_T *eap)
 ":args", ":argslocal" and ":argsglobal". More...
 
void ex_previous (exarg_T *eap)
 ":previous", ":sprevious", ":Next" and ":sNext". More...
 
void ex_rewind (exarg_T *eap)
 ":rewind", ":first", ":sfirst" and ":srewind". More...
 
void ex_last (exarg_T *eap)
 ":last" and ":slast". More...
 
void ex_argument (exarg_T *eap)
 ":argument" and ":sargument". More...
 
void do_argfile (exarg_T *eap, int argn)
 Edit file "argn" of the argument lists. More...
 
void ex_next (exarg_T *eap)
 ":next", and commands that behave like it. More...
 
void ex_argedit (exarg_T *eap)
 ":argedit" More...
 
void ex_argadd (exarg_T *eap)
 ":argadd" More...
 
void ex_argdelete (exarg_T *eap)
 ":argdelete" More...
 
void ex_listdo (exarg_T *eap)
 ":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo" More...
 
char_uget_arglist_name (expand_T *xp FUNC_ATTR_UNUSED, int idx)
 
void ex_compiler (exarg_T *eap)
 ":compiler[!] {name}" More...
 
void ex_runtime (exarg_T *eap)
 ":runtime [what] {name}" More...
 
int do_in_path (char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie)
 
int do_in_path_and_pp (char_u *path, char_u *name, int flags, DoInRuntimepathCB callback, void *cookie)
 
int do_in_runtimepath (char_u *name, int flags, DoInRuntimepathCB callback, void *cookie)
 Just like do_in_path_and_pp(), using 'runtimepath' for "path". More...
 
int source_runtime (char_u *name, int flags)
 
int source_in_path (char_u *path, char_u *name, int flags)
 Just like source_runtime(), but use "path" instead of 'runtimepath'. More...
 
void add_pack_start_dirs (void)
 Add all packages in the "start" directory to 'runtimepath'. More...
 
void load_start_packages (void)
 Load plugins from all packages in the "start" directory. More...
 
void ex_packloadall (exarg_T *eap)
 
void ex_packadd (exarg_T *eap)
 ":packadd[!] {name}" More...
 
void ex_options (exarg_T *eap)
 ":options" More...
 
void init_pyxversion (void)
 
void ex_pyxfile (exarg_T *eap)
 
void ex_pyx (exarg_T *eap)
 
void ex_pyxdo (exarg_T *eap)
 
void ex_source (exarg_T *eap)
 ":source {fname}" More...
 
linenr_Tsource_breakpoint (void *cookie)
 
int * source_dbg_tick (void *cookie)
 Return the address holding the debug tick for a source cookie. More...
 
int source_level (void *cookie)
 Return the nesting level for a source cookie. More...
 
int do_source (char_u *fname, int check_other, int is_vimrc)
 
void ex_scriptnames (exarg_T *eap)
 ":scriptnames" More...
 
char_uget_scriptname (LastSet last_set, bool *should_free)
 Get a pointer to a script name. Used for ":verbose set". More...
 
char_ugetsourceline (int c, void *cookie, int indent)
 
void script_line_start (void)
 
void script_line_exec (void)
 Called when actually executing a function line. More...
 
void script_line_end (void)
 Called when done with a function line. More...
 
void ex_scriptencoding (exarg_T *eap)
 
void ex_finish (exarg_T *eap)
 ":finish": Mark a sourced file as finished. More...
 
void do_finish (exarg_T *eap, int reanimate)
 
bool source_finished (LineGetter fgetline, void *cookie)
 
void ex_checktime (exarg_T *eap)
 ":checktime [buffer]" More...
 
char * get_mess_lang (void)
 
void set_lang_var (void)
 
void ex_drop (exarg_T *eap)
 

Detailed Description

Some more functions for command line commands

Macro Definition Documentation

#define AL_ADD   2
#define AL_DEL   3
#define AL_SET   1

Code to handle the argument list.

#define BREAKP (   idx)    (((struct debuggy *)dbg_breakp.ga_data)[idx])
#define CMD_BACKTRACE   7
#define CMD_CONT   1
#define CMD_DOWN   10
#define CMD_FINISH   4
#define CMD_FRAME   8
#define CMD_INTERRUPT   6
#define CMD_NEXT   2
#define CMD_QUIT   5
#define CMD_STEP   3
#define CMD_UP   9
#define DBG_FILE   2
#define DBG_FUNC   1
#define DEBUGGY (   gap,
  idx 
)    (((struct debuggy *)gap->ga_data)[idx])
#define PRL_ITEM (   si,
  idx 
)    (((sn_prl_T *)(si)->sn_prl_ga.ga_data)[(idx)])
#define SCRIPT_ITEM (   id)    (((scriptitem_T *)script_items.ga_data)[(id) - 1])

Typedef Documentation

typedef struct scriptitem_S scriptitem_T

Growarray to store info about already sourced scripts. Also store the dev/ino, so that we don't have to stat() each script when going through the list.

typedef struct sn_prl_S sn_prl_T

Enumeration Type Documentation

anonymous enum
Enumerator
PEXP_SUBCMD 

expand :profile sub-commands

PEXP_FUNC 

expand :profile func {funcname}

Function Documentation

void add_pack_start_dirs ( void  )

Add all packages in the "start" directory to 'runtimepath'.

int autowrite ( buf_T buf,
int  forceit 
)

If 'autowrite' option set, try to write the file. Careful: autocommands may make "buf" invalid!

Returns
FAIL for failure, OK otherwise
void autowrite_all ( void  )

Flush all buffers, except the ones that are readonly or are never written.

int buf_write_all ( buf_T buf,
int  forceit 
)

Flush the contents of a buffer, unless it has no file name.

Returns
FAIL for failure, OK otherwise
bool can_abandon ( buf_T buf,
int  forceit 
)

Return true if the buffer "buf" can be abandoned, either by making it hidden, autowriting it or unloading it.

void check_arg_idx ( win_T win)

Check if window "win" is editing the w_arg_idx file in its argument list.

bool check_changed ( buf_T buf,
int  flags 
)

Return true if buffer was changed and cannot be abandoned. For flags use the CCGD_ values.

bool check_changed_any ( bool  hidden,
bool  unload 
)

Check if any buffer was changed and cannot be abandoned. That changed buffer becomes the current buffer. When "unload" is true the current buffer is unloaded instead of making it hidden. This is used for ":q!".

Parameters
[in]hiddenspecifies whether to check only hidden buffers.
[in]unloadspecifies whether to unload, instead of hide, the buffer.
Returns
true if any buffer is changed and cannot be abandoned
int check_fname ( void  )

Return FAIL if there is no file name, OK if there is one. Give error message for FAIL.

void dbg_breakpoint ( char_u name,
linenr_T  lnum 
)

Called when a breakpoint was encountered.

void dbg_check_breakpoint ( exarg_T eap)

Go to debug mode when a breakpoint was encountered or "ex_nesting_level" is at or below the break level. But only when the line is actually executed. Return true and set breakpoint_name for skipped commands that decide to execute something themselves. Called from do_one_cmd() before executing a command.

bool dbg_check_skipped ( exarg_T eap)

Go to debug mode if skipped by dbg_check_breakpoint() because eap->skip was set.

Returns
true when the debug mode is entered this time.
linenr_T dbg_find_breakpoint ( bool  file,
char_u fname,
linenr_T  after 
)

Find a breakpoint for a function or sourced file. Returns line number at which to break; zero when no matching breakpoint.

void dialog_changed ( buf_T buf,
bool  checkall 
)

Ask the user what to do when abandoning a changed buffer. Must check 'write' option first!

Parameters
buf
checkallmay abandon all changed buffers
bool dialog_close_terminal ( buf_T buf)

Ask the user whether to close the terminal buffer or not.

Parameters
bufThe terminal buffer.
Returns
bool Whether to close the buffer or not.
void do_argfile ( exarg_T eap,
int  argn 
)

Edit file "argn" of the argument lists.

void do_debug ( char_u cmd)

Debug mode. Repeatedly get Ex commands, until told to continue normal execution.

void do_finish ( exarg_T eap,
int  reanimate 
)

Mark a sourced file as finished. Possibly makes the ":finish" pending. Also called for a pending finish at the ":endtry" or after returning from an extra do_cmdline(). "reanimate" is used in the latter case.

int do_in_path ( char_u path,
char_u name,
int  flags,
DoInRuntimepathCB  callback,
void *  cookie 
)

Find the file "name" in all directories in "path" and invoke "callback(fname, cookie)". "name" can contain wildcards. When "flags" has DIP_ALL: source all files, otherwise only the first one. When "flags" has DIP_DIR: find directories instead of files. When "flags" has DIP_ERR: give an error message if there is no match.

return FAIL when no file could be sourced, OK otherwise.

int do_in_path_and_pp ( char_u path,
char_u name,
int  flags,
DoInRuntimepathCB  callback,
void *  cookie 
)

Find "name" in "path". When found, invoke the callback function for it: callback(fname, "cookie") When "flags" has DIP_ALL repeat for all matches, otherwise only the first one is used. Returns OK when at least one match found, FAIL otherwise. If "name" is NULL calls callback for each entry in "path". Cookie is passed by reference in this case, setting it to NULL indicates that callback has done its job.

int do_in_runtimepath ( char_u name,
int  flags,
DoInRuntimepathCB  callback,
void *  cookie 
)

Just like do_in_path_and_pp(), using 'runtimepath' for "path".

int do_source ( char_u fname,
int  check_other,
int  is_vimrc 
)

Read the file "fname" and execute its lines as EX commands.

This function may be called recursively!

Parameters
fname
check_othercheck for .vimrc and _vimrc
is_vimrcDOSO_ value
Returns
FAIL if file could not be opened, OK otherwise
void ex_argadd ( exarg_T eap)

":argadd"

void ex_argdelete ( exarg_T eap)

":argdelete"

void ex_argedit ( exarg_T eap)

":argedit"

void ex_args ( exarg_T eap)

":args", ":argslocal" and ":argsglobal".

void ex_argument ( exarg_T eap)

":argument" and ":sargument".

void ex_breakadd ( exarg_T eap)

":breakadd".

void ex_breakdel ( exarg_T eap)

":breakdel" and ":profdel".

void ex_breaklist ( exarg_T eap)

":breaklist".

void ex_checktime ( exarg_T eap)

":checktime [buffer]"

void ex_compiler ( exarg_T eap)

":compiler[!] {name}"

void ex_debug ( exarg_T eap)

":debug".

void ex_debuggreedy ( exarg_T eap)

":debuggreedy".

void ex_drop ( exarg_T eap)

":drop" Opens the first argument in a window. When there are two or more arguments the argument list is redefined.

void ex_finish ( exarg_T eap)

":finish": Mark a sourced file as finished.

void ex_last ( exarg_T eap)

":last" and ":slast".

void ex_listdo ( exarg_T eap)

":argdo", ":windo", ":bufdo", ":tabdo", ":cdo", ":ldo", ":cfdo" and ":lfdo"

void ex_next ( exarg_T eap)

":next", and commands that behave like it.

void ex_options ( exarg_T eap)

":options"

void ex_packadd ( exarg_T eap)

":packadd[!] {name}"

void ex_packloadall ( exarg_T eap)
void ex_previous ( exarg_T eap)

":previous", ":sprevious", ":Next" and ":sNext".

void ex_profile ( exarg_T eap)

":profile cmd args"

void ex_py3file ( exarg_T eap)
void ex_pydo ( exarg_T eap)
void ex_pydo3 ( exarg_T eap)
void ex_pyfile ( exarg_T eap)
void ex_python ( exarg_T eap)
void ex_python3 ( exarg_T eap)
void ex_pyx ( exarg_T eap)
void ex_pyxdo ( exarg_T eap)
void ex_pyxfile ( exarg_T eap)
void ex_rewind ( exarg_T eap)

":rewind", ":first", ":sfirst" and ":srewind".

void ex_ruby ( exarg_T eap)
void ex_rubydo ( exarg_T eap)
void ex_rubyfile ( exarg_T eap)
void ex_runtime ( exarg_T eap)

":runtime [what] {name}"

void ex_scriptencoding ( exarg_T eap)

":scriptencoding": Set encoding conversion for a sourced script. Without the multi-byte feature it's simply ignored.

void ex_scriptnames ( exarg_T eap)

":scriptnames"

void ex_source ( exarg_T eap)

":source {fname}"

int get_arglist_exp ( char_u str,
int *  fcountp,
char_u ***  fnamesp,
bool  wig 
)

Parse a list of arguments (file names), expand them and return in "fnames[fcountp]". When "wig" is true, removes files matching 'wildignore'.

Returns
FAIL or OK.
char_u* get_arglist_name ( expand_T *xp  FUNC_ATTR_UNUSED,
int  idx 
)
char* get_mess_lang ( void  )

Obtain the current messages language. Used to set the default for 'helplang'. May return NULL or an empty string.

char_u* get_profile_name ( expand_T xp,
int  idx 
)

Function given to ExpandGeneric() to obtain the profile command specific expansion.

char_u* get_scriptname ( LastSet  last_set,
bool *  should_free 
)

Get a pointer to a script name. Used for ":verbose set".

char_u* getsourceline ( int  c,
void *  cookie,
int  indent 
)

Get one full line from a sourced file. Called by do_cmdline() when it's called from do_source().

Returns
pointer to the line in allocated memory, or NULL for end-of-file or some error.
bool has_profiling ( bool  file,
char_u fname,
bool *  fp 
)
Parameters
filetrue for a file, false for a function
fnamefile or function name
fp[out]forceit
Returns
true if profiling is on for a function or sourced file.
void init_pyxversion ( void  )
void load_start_packages ( void  )

Load plugins from all packages in the "start" directory.

bool prof_def_func ( void  )

Return true when a function defined in the current script should be profiled.

void prof_inchar_enter ( void  )

Called when starting to wait for the user to type a character.

void prof_inchar_exit ( void  )

Called when finished waiting for the user to type a character.

void profile_dump ( void  )

Dump the profiling info.

void script_line_end ( void  )

Called when done with a function line.

void script_line_exec ( void  )

Called when actually executing a function line.

void script_line_start ( void  )

Called when starting to read a script line. "sourcing_lnum" must be correct! When skipping lines it may not actually be executed, but we won't find out until later and we need to store the time now.

void script_prof_restore ( proftime_T tm)

Count time spent in children after invoking another script or function.

void script_prof_save ( proftime_T tm)

Save time when starting to invoke another script or function.

void set_context_in_profile_cmd ( expand_T xp,
const char *  arg 
)

Handle command line completion for :profile command.

void set_lang_var ( void  )

Set the "v:lang" variable according to the current locale setting. Also do "v:lc_time"and "v:ctype".

linenr_T* source_breakpoint ( void *  cookie)

":source" and associated commands.

Returns
address holding the next breakpoint line for a source cookie
int* source_dbg_tick ( void *  cookie)

Return the address holding the debug tick for a source cookie.

bool source_finished ( LineGetter  fgetline,
void *  cookie 
)

Return true when a sourced file had the ":finish" command: Don't give error message for missing ":endif". Return false when not sourcing a file.

int source_in_path ( char_u path,
char_u name,
int  flags 
)

Just like source_runtime(), but use "path" instead of 'runtimepath'.

int source_level ( void *  cookie)

Return the nesting level for a source cookie.

int source_runtime ( char_u name,
int  flags 
)

Source the file "name" from all directories in 'runtimepath'. "name" can contain wildcards. When "flags" has DIP_ALL: source all files, otherwise only the first one.

return FAIL when no file could be sourced, OK otherwise.