Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ex_getln.c File Reference
#include <assert.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "nvim/log.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/arabic.h"
#include "nvim/ex_getln.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/digraph.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/ex_cmds.h"
#include "nvim/ex_cmds2.h"
#include "nvim/ex_docmd.h"
#include "nvim/ex_eval.h"
#include "nvim/farsi.h"
#include "nvim/fileio.h"
#include "nvim/func_attr.h"
#include "nvim/getchar.h"
#include "nvim/highlight.h"
#include "nvim/if_cscope.h"
#include "nvim/indent.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memline.h"
#include "nvim/menu.h"
#include "nvim/message.h"
#include "nvim/misc1.h"
#include "nvim/memory.h"
#include "nvim/cursor_shape.h"
#include "nvim/keymap.h"
#include "nvim/garray.h"
#include "nvim/move.h"
#include "nvim/mouse.h"
#include "nvim/ops.h"
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/strings.h"
#include "nvim/state.h"
#include "nvim/syntax.h"
#include "nvim/tag.h"
#include "nvim/window.h"
#include "nvim/ui.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/event/loop.h"
#include "nvim/os/time.h"
#include "nvim/lib/kvec.h"
#include "nvim/api/private/helpers.h"
#include "nvim/highlight_defs.h"
#include "nvim/viml/parser/parser.h"
#include "nvim/viml/parser/expressions.h"

Data Structures

struct  CmdlineColorChunk
struct  cmdline_info
struct  command_line_state


#define PRINT_ERRMSG(...)
#define PATH_ESC_CHARS   ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
#define SHELL_ESC_CHARS   ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")
#define L_SHOWFILE(m)   (showtail ? sm_gettail(files_found[m]) : files_found[m])


typedef struct command_line_state CommandLineState
typedef struct cmdline_info CmdlineInfo
typedef void *(* user_expand_func_T) (const char_u *, int, const char_u *const *, bool)
typedef char_u *(* ExpandFunc) (expand_T *, int)


enum  CmdRedraw { kCmdRedrawNone, kCmdRedrawPos, kCmdRedrawAll }
 Keeps track how much state must be sent to external ui. More...
enum  { MAX_CB_ERRORS = 1 }


typedef kvec_t (CmdlineColorChunk)
char_ugetcmdline (int firstc, long count, int indent)
char * getcmdline_prompt (const char firstc, const char *const prompt, const int attr, const int xp_context, const char *const xp_arg, const Callback highlight_callback) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
int text_locked (void)
void text_locked_msg (void)
char_uget_text_locked_msg (void)
int curbuf_locked (void)
int allbuf_locked (void)
char_ugetexline (int c, void *cookie, int indent)
char_ugetexmodeline (int promptc, void *cookie, int indent)
bool cmdline_overstrike (void)
bool cmdline_at_end (void)
 Return true if the cursor is at the end of the cmdline. More...
void ui_ext_cmdline_block_append (int indent, const char *line)
void ui_ext_cmdline_block_leave (void)
void cmdline_screen_cleared (void)
void cmdline_ui_flush (void)
 called by ui_flush, do what redraws neccessary to keep cmdline updated. More...
void putcmdline (int c, int shift)
void unputcmdline (void)
 Undo a putcmdline(c, FALSE). More...
void put_on_cmdline (char_u *str, int len, int redraw)
char_usave_cmdline_alloc (void)
void restore_cmdline_alloc (char_u *p)
void cmdline_paste_str (char_u *s, int literally)
void redrawcmdline (void)
void redrawcmd (void)
void compute_cmdrow (void)
void gotocmdline (int clr)
char_uExpandOne (expand_T *xp, char_u *str, char_u *orig, int options, int mode)
void ExpandInit (expand_T *xp)
void ExpandCleanup (expand_T *xp)
void ExpandEscape (expand_T *xp, char_u *str, int numfiles, char_u **files, int options)
char * vim_strsave_fnameescape (const char *const fname, const bool shell) FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
void tilde_replace (char_u *orig_pat, int num_files, char_u **files)
char_usm_gettail (char_u *s)
char_uaddstar (char_u *fname, int len, int context) FUNC_ATTR_NONNULL_RET
void set_cmd_context (expand_T *xp, char_u *str, int len, int col, int use_ccline)
int expand_cmdline (expand_T *xp, char_u *str, int col, int *matchcount, char_u ***matches)
void ExpandGeneric (expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file, CompleteListItemGetter func, int escaped)
void globpath (char_u *path, char_u *file, garray_T *ga, int expand_options)
void init_history (void)
HistoryType get_histtype (const char *const name, const size_t len, const bool return_default) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
void add_to_history (int histype, char_u *new_entry, int in_map, int sep)
int get_history_idx (int histype)
char_uget_cmdline_str (void)
int get_cmdline_pos (void)
int set_cmdline_pos (int pos)
int get_cmdline_type (void)
char_uget_history_entry (int histype, int idx)
int clr_history (const int histype)
int del_history_entry (int histype, char_u *str)
int del_history_idx (int histype, int idx)
int get_list_range (char_u **str, int *num1, int *num2)
void ex_history (exarg_T *eap)
int hist_type2char (int type) FUNC_ATTR_CONST
 Translate a history type number to the associated character. More...
void cmd_pchar (int c, int offset)
int cmd_gchar (int offset)
char * script_get (exarg_T *const eap, size_t *const lenp) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC
const void * hist_iter (const void *const iter, const uint8_t history_type, const bool zero, histentry_T *const hist) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(4)
histentry_Thist_get_array (const uint8_t history_type, int **const new_hisidx, int **const new_hisnum) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL



Macro Definition Documentation

#define L_SHOWFILE (   m)    (showtail ? sm_gettail(files_found[m]) : files_found[m])
#define PATH_ESC_CHARS   ((char_u *)" \t\n*?[{`$\\%#'\"|!<")
#define PRINT_ERRMSG (   ...)
do { \
printed_errmsg = true; \
} while (0)
#define MSG_HIST
Definition: vim.h:39
#define HL_ATTR(n)
Definition: vim.h:279
void msg_putchar(int c)
Definition: message.c:1113
Definition: highlight_defs.h:51
void msg_printf_attr(const int attr, const char *const fmt,...) FUNC_ATTR_NONNULL_ARG(2) FUNC_ATTR_PRINTF(2
#define SHELL_ESC_CHARS   ((char_u *)" \t\n*?[{`$\\%#'\"|!<>();&")

Typedef Documentation

typedef struct cmdline_info CmdlineInfo
typedef char_u*(* ExpandFunc) (expand_T *, int)
typedef void*(* user_expand_func_T) (const char_u *, int, const char_u *const *, bool)

Enumeration Type Documentation

anonymous enum
enum CmdRedraw

Keeps track how much state must be sent to external ui.


Function Documentation

void add_to_history ( int  histype,
char_u new_entry,
int  in_map,
int  sep 
char_u* addstar ( char_u fname,
int  len,
int  context 
int allbuf_locked ( void  )
int clr_history ( const int  histype)

Clear all entries in a history

[in]histypeOne of the HIST_ values.
OK if there was something to clean and histype was one of HIST_ values, FAIL otherwise.
int cmd_gchar ( int  offset)
void cmd_pchar ( int  c,
int  offset 
bool cmdline_at_end ( void  )

Return true if the cursor is at the end of the cmdline.

bool cmdline_overstrike ( void  )
void cmdline_paste_str ( char_u s,
int  literally 
void cmdline_screen_cleared ( void  )

Extra redrawing needed for redraw! and on ui_attach assumes "redrawcmdline()" will already be invoked

void cmdline_ui_flush ( void  )

called by ui_flush, do what redraws neccessary to keep cmdline updated.

void compute_cmdrow ( void  )
int curbuf_locked ( void  )
int del_history_entry ( int  histype,
char_u str 
int del_history_idx ( int  histype,
int  idx 
void ex_history ( exarg_T eap)
int expand_cmdline ( expand_T xp,
char_u str,
int  col,
int *  matchcount,
char_u ***  matches 
void ExpandCleanup ( expand_T xp)
void ExpandEscape ( expand_T xp,
char_u str,
int  numfiles,
char_u **  files,
int  options 
void ExpandGeneric ( expand_T xp,
regmatch_T regmatch,
int *  num_file,
char_u ***  file,
CompleteListItemGetter  func,
int  escaped 
void ExpandInit ( expand_T xp)
char_u* ExpandOne ( expand_T xp,
char_u str,
char_u orig,
int  options,
int  mode 
int get_cmdline_pos ( void  )
char_u* get_cmdline_str ( void  )
int get_cmdline_type ( void  )
char_u* get_history_entry ( int  histype,
int  idx 
int get_history_idx ( int  histype)
HistoryType get_histtype ( const char *const  name,
const size_t  len,
const bool  return_default 

Convert history name to its HIST_ equivalent

Names are taken from the table above. When name is empty returns currently active history or HIST_DEFAULT, depending on return_default argument.

[in]nameConverted name.
[in]lenName length.
[in]return_defaultDetermines whether HIST_DEFAULT should be returned or value based on ccline.cmdfirstc.
Any value from HistoryType enum, including HIST_INVALID. May not return HIST_DEFAULT unless return_default is true.
int get_list_range ( char_u **  str,
int *  num1,
int *  num2 

Get indices that specify a range within a list (not a range of text lines in a buffer!) from a string. Used for ":history" and ":clist".

strstring to parse range from
OK if parsed successfully, otherwise FAIL.
char_u* get_text_locked_msg ( void  )
char_u* getcmdline ( int  firstc,
long  count,
int  indent 
char* getcmdline_prompt ( const char  firstc,
const char *const  prompt,
const int  attr,
const int  xp_context,
const char *const  xp_arg,
const Callback  highlight_callback 

Get a command line with a prompt

This is prepared to be called recursively from getcmdline() (e.g. by f_input() when evaluating an expression from <C-r>=).

[in]firstcPrompt type: e.g. '@' for input(), '>' for debug.
[in]promptPrompt string: what is displayed before the user text.
[in]attrPrompt highlighting.
[in]xp_contextType of expansion.
[in]xp_argUser-defined expansion argument.
[in]highlight_callbackCallback used for highlighting user input.
[allocated] Command line or NULL.
char_u* getexline ( int  c,
void *  cookie,
int  indent 
char_u* getexmodeline ( int  promptc,
void *  cookie,
int  indent 
void globpath ( char_u path,
char_u file,
garray_T ga,
int  expand_options 

Expand file for all comma-separated directories in path. Adds matches to ga.

void gotocmdline ( int  clr)
histentry_T* hist_get_array ( const uint8_t  history_type,
int **const  new_hisidx,
int **const  new_hisnum 

Get array of history items

[in]history_typeType of the history to get array for.
[out]new_hisidxLocation where last index in the new array should be saved.
[out]new_hisnumLocation where last history number in the new history should be saved.
Pointer to the array or NULL.
const void* hist_iter ( const void *const  iter,
const uint8_t  history_type,
const bool  zero,
histentry_T *const  hist 

Iterate over history items

No history-editing functions must be run while iteration is in progress.
[in]iterPointer to the last history entry.
[in]history_typeType of the history (HIST_*). Ignored if iter parameter is not NULL.
[in]zeroIf true then zero (but not free) returned items.
                       @warning When using this parameter user is
                                responsible for calling clr_history()
                                itself after iteration is over. If
                                clr_history() is not called behaviour is
                                undefined. No functions that work with
                                history must be called during iteration
                                in this case.
[out]histNext history entry.
Pointer used in next iteration or NULL to indicate that iteration was finished.
int hist_type2char ( int  type)

Translate a history type number to the associated character.

void init_history ( void  )

Initialize command line history. Also used to re-allocate history tables when size changes.

typedef kvec_t ( CmdlineColorChunk  )

Command-line colors

Holds data about all colors. Command-line coloring

Holds both what are the colors and what have been colored. Latter is used to suppress unnecessary calls to coloring callbacks.

< ID of the prompt which was colored last.

< What exactly was colored last time or NULL.

< Last colors.

void put_on_cmdline ( char_u str,
int  len,
int  redraw 
void putcmdline ( int  c,
int  shift 
void redrawcmd ( void  )
void redrawcmdline ( void  )
void restore_cmdline_alloc ( char_u p)
char_u* save_cmdline_alloc ( void  )
char* script_get ( exarg_T *const  eap,
size_t *const  lenp 

Get script string

Used for commands which accept either :command script or

:command << endmarker
eapCommand being run.
[out]lenpLocation where length of resulting string is saved. Will be set to zero when skipping.
[allocated] NULL or script. Does not show any error messages. NULL is returned when skipping and on error.
void set_cmd_context ( expand_T xp,
char_u str,
int  len,
int  col,
int  use_ccline 
int set_cmdline_pos ( int  pos)
char_u* sm_gettail ( char_u s)
int text_locked ( void  )
void text_locked_msg ( void  )
void tilde_replace ( char_u orig_pat,
int  num_files,
char_u **  files 
void ui_ext_cmdline_block_append ( int  indent,
const char *  line 
void ui_ext_cmdline_block_leave ( void  )
void unputcmdline ( void  )

Undo a putcmdline(c, FALSE).

char* vim_strsave_fnameescape ( const char *const  fname,
const bool  shell 

Escape special characters in a file name for use as a command argument

[in]fnameFile name to escape.
[in]shellWhat to escape for: if false, escapes for VimL command, if true then it escapes for a shell command.
[allocated] escaped file name.

Variable Documentation