#include <assert.h>
#include <float.h>
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "nvim/api/buffer.h"
#include "nvim/api/extmark.h"
#include "nvim/api/private/defs.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/buffer_updates.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/decoration.h"
#include "nvim/diff.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/ex_getln.h"
#include "nvim/extmark.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/highlight.h"
#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/input.h"
#include "nvim/log.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.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/os.h"
#include "nvim/os/shell.h"
#include "nvim/os/time.h"
#include "nvim/os_unix.h"
#include "nvim/path.h"
#include "nvim/plines.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/spell.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 | subflags_T |
Flags kept between calls to :substitute. More... | |
struct | SubResult |
struct | PreviewLines |
struct | sorti_T |
Struct to store info to be sorted. More... | |
Macros | |
#define | SPACE_FOR_DESC (1 + 1 + 1 + MB_MAXBYTES + 16 + 4 + 3 + 3 + 1) |
#define | ADJUST_SUB_FIRSTLNUM() |
#define | PUSH_PREVIEW_LINES() |
Enumerations | |
enum | SubIgnoreType { kSubHonorOptions = 0, kSubIgnoreCase, kSubMatchCase } |
Case matching style to use for :substitute. More... | |
Functions | |
void | do_ascii (const exarg_T *const eap) |
":ascii" and "ga" implementation More... | |
void | ex_align (exarg_T *eap) |
":left", ":center" and ":right": align text. More... | |
void | ex_sort (exarg_T *eap) |
":sort". More... | |
void | ex_retab (exarg_T *eap) |
":retab". More... | |
int | do_move (linenr_T line1, linenr_T line2, linenr_T dest) |
void | ex_copy (linenr_T line1, linenr_T line2, linenr_T n) |
":copy" More... | |
void | do_bang (int addr_count, exarg_T *eap, bool forceit, bool do_in, bool do_out) FUNC_ATTR_NONNULL_ALL |
void | do_shell (char *cmd, int flags) |
char * | make_filter_cmd (char *cmd, char *itmp, char *otmp) |
void | append_redir (char *const buf, const size_t buflen, const char *const opt, const char *const fname) |
void | print_line_no_prefix (linenr_T lnum, int use_number, int list) |
void | print_line (linenr_T lnum, int use_number, int list) |
Print a text line. Also in silent mode ("ex -s"). More... | |
int | rename_buffer (char *new_fname) |
void | ex_file (exarg_T *eap) |
":file[!] [fname]". More... | |
void | ex_update (exarg_T *eap) |
":update". More... | |
void | ex_write (exarg_T *eap) |
":write" and ":saveas". More... | |
int | do_write (exarg_T *eap) |
int | check_overwrite (exarg_T *eap, buf_T *buf, char *fname, char *ffname, int other) |
void | ex_wnext (exarg_T *eap) |
Handle ":wnext", ":wNext" and ":wprevious" commands. More... | |
void | do_wqall (exarg_T *eap) |
":wall", ":wqall" and ":xall": Write all changed files (and exit). More... | |
bool | not_writing (void) |
int | getfile (int fnum, char *ffname_arg, char *sfname_arg, int setpm, linenr_T lnum, int forceit) |
int | do_ecmd (int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum, int flags, win_T *oldwin) |
void | ex_append (exarg_T *eap) |
":insert" and ":append", also used by ":change" More... | |
void | ex_change (exarg_T *eap) |
":change" More... | |
void | ex_z (exarg_T *eap) |
bool | check_secure (void) |
void | sub_get_replacement (SubReplacementString *const ret_sub) FUNC_ATTR_NONNULL_ALL |
void | sub_set_replacement (SubReplacementString sub) |
bool | do_sub_msg (bool count_only) |
void | ex_global (exarg_T *eap) |
void | global_exe (char *cmd) |
Execute cmd on lines marked with ml_setmarked(). More... | |
bool | prepare_tagpreview (bool undo_sync) |
void | ex_help (exarg_T *eap) |
":help": open a read-only window on a help file More... | |
char * | check_help_lang (char *arg) |
int | help_heuristic (char *matched_string, int offset, int wrong_case) FUNC_ATTR_PURE |
int | find_help_tags (const char *arg, int *num_matches, char ***matches, bool keep_lang) |
void | fix_help_buffer (void) |
void | ex_exusage (exarg_T *eap) |
":exusage" More... | |
void | ex_viusage (exarg_T *eap) |
":viusage" More... | |
void | ex_helptags (exarg_T *eap) |
":helptags" More... | |
void | ex_helpclose (exarg_T *eap) |
":helpclose": Close one help window More... | |
int | sub_preview_win (buf_T *preview_buf) |
void | close_preview_windows (void) |
Closes any open windows for inccommand preview buffer. More... | |
void | ex_substitute (exarg_T *eap) |
char * | skip_vimgrep_pat (char *p, char **s, int *flags) |
void | ex_oldfiles (exarg_T *eap) |
List v:oldfiles in a nice way. More... | |
#define ADJUST_SUB_FIRSTLNUM | ( | ) |
#define PUSH_PREVIEW_LINES | ( | ) |
#define SPACE_FOR_DESC (1 + 1 + 1 + MB_MAXBYTES + 16 + 4 + 3 + 3 + 1) |
enum SubIgnoreType |
void append_redir | ( | char *const | buf, |
const size_t | buflen, | ||
const char *const | opt, | ||
const char *const | fname | ||
) |
Append output redirection for the given file to the end of the buffer
[out] | buf | Buffer to append to. |
[in] | buflen | Buffer length. |
[in] | opt | Separator or format string to append: will append ‘printf(’ ' . opt, fname)if sis found in optor a space, opt, a space and then fname if s` is not found there. |
[in] | fname | File name to append. |
char* check_help_lang | ( | char * | arg | ) |
In an argument search for a language specifiers in the form "@xx". Changes the "@" to NUL if found, and returns a pointer to "xx".
Check if it is allowed to overwrite a file. If b_flags has BF_NOTEDITED, BF_NEW or BF_READERR, check for overwriting current file. May set eap->forceit if a dialog says it's OK to overwrite.
fname | file name to be used (can differ from buf->ffname) |
ffname | full path version of fname |
other | writing under other name |
Handle the ":!cmd" command. Also for ":r !cmd" and ":w !cmd" Bangs in the argument are replaced with the previously entered command. Remember the argument.
int do_ecmd | ( | int | fnum, |
char * | ffname, | ||
char * | sfname, | ||
exarg_T * | eap, | ||
linenr_T | newlnum, | ||
int | flags, | ||
win_T * | oldwin | ||
) |
start editing a new file
fnum | file number; if zero use ffname/sfname |
ffname | the file name
|
sfname | the short file name (or NULL) |
eap | contains the command to be executed after loading the file and forced 'ff' and 'fenc'. Can be NULL! |
newlnum | if > 0: put cursor on this line number (if possible) ECMD_LASTL: use last position in loaded file ECMD_LAST: use last position in all files ECMD_ONE: use first line |
flags | ECMD_HIDE: if TRUE don't free the current buffer ECMD_SET_HELP: set b_help flag of (new) buffer before opening file ECMD_OLDBUF: use existing buffer if it exists ECMD_FORCEIT: ! used for Ex command ECMD_ADDBUF: don't edit, just add to buffer list ECMD_ALTBUF: like ECMD_ADDBUF and also set the alternate file ECMD_NOWINENTER: Do not trigger BufWinEnter |
oldwin | Should be "curwin" when editing a new buffer in the current window, NULL when splitting the window first. When not NULL info of the previous buffer for "oldwin" is stored. |
:move command - move lines line1-line2 to line dest
void do_shell | ( | char * | cmd, |
int | flags | ||
) |
Call a shell to execute a command. When "cmd" is NULL start an interactive shell.
flags | may be SHELL_DOOUT when output is redirected |
Give message for number of substitutions. Can also be used after a ":global" command.
count_only | used 'n' flag for ":s" |
int do_write | ( | exarg_T * | eap | ) |
write current buffer to file 'eap->arg' if 'eap->append' is TRUE, append to the file
if *eap->arg == NUL write to current file
Execute a global command of the form:
g/pattern/X : execute X on all lines where pattern matches v/pattern/X : execute X on all lines where pattern does not match
where 'X' is an EX command
The command character (as well as the trailing slash) is optional, and is assumed to be 'p' if missing.
This is implemented in two passes: first we scan the file for the pattern and set a mark for each line that (not) matches. Secondly we execute the command for each line that has a mark. This is required because after deleting lines we do not know where to search for the next match.
:substitute command
If 'inccommand' is empty: calls do_sub(). If 'inccommand' is set: shows a "live" preview then removes the changes. from undo history.
int find_help_tags | ( | const char * | arg, |
int * | num_matches, | ||
char *** | matches, | ||
bool | keep_lang | ||
) |
Find all help tags matching "arg", sort them and return in matches[], with the number of matches in num_matches. The matches will be sorted with a "best" match algorithm. When "keep_lang" is true try keeping the language of the current buffer.
After reading a help file: May cleanup a help buffer when syntax highlighting is not used.
int getfile | ( | int | fnum, |
char * | ffname_arg, | ||
char * | sfname_arg, | ||
int | setpm, | ||
linenr_T | lnum, | ||
int | forceit | ||
) |
Try to abandon the current file and edit a new or existing file.
fnum | the number of the file, if zero use "ffname_arg"/"sfname_arg". |
lnum | the line number for the cursor in the new file (if non-zero). |
void global_exe | ( | char * | cmd | ) |
Execute cmd
on lines marked with ml_setmarked().
int help_heuristic | ( | char * | matched_string, |
int | offset, | ||
int | wrong_case | ||
) |
Return a heuristic indicating how well the given string matches. The smaller the number, the better the match. This is the order of priorities, from best match to worst match:
offset | offset for match |
wrong_case | no matching case |
char* make_filter_cmd | ( | char * | cmd, |
char * | itmp, | ||
char * | otmp | ||
) |
Create a shell command from a command string, input redirection file and output redirection file.
cmd | Command to execute. |
itmp | NULL or the input file. |
otmp | NULL or the output file. |
Check the 'write' option.
Set up for a tagpreview.
undo_sync | sync undo when leaving the window |
Print a text line. Also in silent mode ("ex -s").
int rename_buffer | ( | char * | new_fname | ) |
char* skip_vimgrep_pat | ( | char * | p, |
char ** | s, | ||
int * | flags | ||
) |
Skip over the pattern argument of ":vimgrep /pat/[g][j]". Put the start of the pattern in "*s", unless "s" is NULL.
flags | if not NULL, put the flags in it: VGR_GLOBAL, VGR_NOJUMP. |
s | if not NULL, terminate the pattern with a NUL. |
void sub_get_replacement | ( | SubReplacementString *const | ret_sub | ) |
Get old substitute replacement string
[out] | ret_sub | Location where old string will be saved. |
int sub_preview_win | ( | buf_T * | preview_buf | ) |
Tries to enter to an existing window of given buffer. If no existing buffer is found, creates a new split.
void sub_set_replacement | ( | SubReplacementString | sub | ) |
Set substitute string and timestamp
sub
must be in allocated memory. It is not copied.[in] | sub | New replacement string. |