Data Structures | Macros | Enumerations | Functions
buffer.c File Reference
#include <assert.h>
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/buffer_updates.h"
#include "nvim/change.h"
#include "nvim/channel.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/decoration.h"
#include "nvim/diff.h"
#include "nvim/digraph.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/file_search.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/garray.h"
#include "nvim/getchar.h"
#include "nvim/hashtab.h"
#include "nvim/highlight_group.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/main.h"
#include "nvim/mark.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h"
#include "nvim/message.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/time.h"
#include "nvim/path.h"
#include "nvim/plines.h"
#include "nvim/quickfix.h"
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/sign.h"
#include "nvim/spell.h"
#include "nvim/strings.h"
#include "nvim/syntax.h"
#include "nvim/ui.h"
#include "nvim/undo.h"
#include "nvim/version.h"
#include "nvim/vim.h"
#include "nvim/window.h"

Data Structures

struct  bufmatch_T
 

Macros

#define MAX_STL_EVAL_DEPTH   100
 
#define SPACE_FOR_FNAME   (sizeof(buf) - 100)
 
#define SPACE_FOR_DIR   (sizeof(buf) - 20)
 
#define SPACE_FOR_ARGNR   (sizeof(buf) - 10)
 
#define TMPLEN   70
 

Enumerations

enum  BufFreeFlags { kBffClearWinInfo = 1, kBffInitChangedtick = 2 }
 
enum  NumberBase { kNumBaseDecimal = 10, kNumBaseHexadecimal = 16 }
 

Functions

int open_buffer (int read_stdin, exarg_T *eap, int flags)
 
void set_bufref (bufref_T *bufref, buf_T *buf)
 
bool bufref_valid (bufref_T *bufref) FUNC_ATTR_PURE
 
bool buf_valid (buf_T *buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool close_buffer (win_T *win, buf_T *buf, int action, bool abort_if_last, bool ignore_abort)
 
void buf_clear_file (buf_T *buf)
 Make buffer not contain a file. More...
 
void buf_clear (void)
 Clears the current buffer contents. More...
 
void buf_freeall (buf_T *buf, int flags)
 
void goto_buffer (exarg_T *eap, int start, int dir, int count)
 Go to another buffer. Handles the result of the ATTENTION dialog. More...
 
void handle_swap_exists (bufref_T *old_curbuf)
 
char * do_bufdel (int command, char_u *arg, int addr_count, int start_bnr, int end_bnr, int forceit)
 
int do_buffer (int action, int start, int dir, int count, int forceit)
 
void set_curbuf (buf_T *buf, int action)
 
void enter_buffer (buf_T *buf)
 
void do_autochdir (void)
 
void no_write_message (void)
 
void no_write_message_nobang (const buf_T *const buf) FUNC_ATTR_NONNULL_ALL
 
buf_Tbuflist_new (char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum, int flags)
 
bool curbuf_reusable (void)
 
void free_buf_options (buf_T *buf, int free_p_ff)
 
int buflist_getfile (int n, linenr_T lnum, int options, int forceit)
 
void buflist_getfpos (void)
 Go to the last known line number for the current buffer. More...
 
buf_Tbuflist_findname_exp (char_u *fname)
 
buf_Tbuflist_findname (char_u *ffname)
 
int buflist_findpat (const char_u *pattern, const char_u *pattern_end, bool unlisted, bool diffmode, bool curtab_only) FUNC_ATTR_NONNULL_ARG(1)
 
int ExpandBufnames (char_u *pat, int *num_file, char_u ***file, int options)
 
buf_Tbuflist_findnr (int nr)
 Find a file in the buffer list by buffer number. More...
 
char_ubuflist_nr2name (int n, int fullname, int helptail)
 
void buflist_setfpos (buf_T *const buf, win_T *const win, linenr_T lnum, colnr_T col, bool copy_options) FUNC_ATTR_NONNULL_ARG(1)
 
void get_winopts (buf_T *buf)
 
pos_Tbuflist_findfpos (buf_T *buf) FUNC_ATTR_PURE
 
linenr_T buflist_findlnum (buf_T *buf) FUNC_ATTR_PURE
 Find the lnum for the buffer 'buf' for the current window. More...
 
void buflist_list (exarg_T *eap)
 List all known file names (for :files and :buffers command). More...
 
int buflist_name_nr (int fnum, char_u **fname, linenr_T *lnum)
 
int setfname (buf_T *buf, char_u *ffname_arg, char_u *sfname_arg, bool message)
 
void buf_set_name (int fnum, char_u *name)
 
void buf_name_changed (buf_T *buf)
 Take care of what needs to be done when the name of buffer "buf" has changed. More...
 
buf_Tsetaltfname (char_u *ffname, char_u *sfname, linenr_T lnum)
 
char_ugetaltfname (bool errmsg)
 
int buflist_add (char_u *fname, int flags)
 
void buflist_altfpos (win_T *win)
 
bool otherfile (char_u *ffname) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 
void buf_set_file_id (buf_T *buf)
 
void fileinfo (int fullname, int shorthelp, int dont_truncate)
 
void col_print (char_u *buf, size_t buflen, int col, int vcol)
 
void maketitle (void)
 Put the title name in the title bar and icon of the window. More...
 
void resettitle (void)
 Set current window title. More...
 
int build_stl_str_hl (win_T *wp, char *out, size_t outlen, char *fmt, int use_sandbox, int fillchar, int maxwidth, stl_hlrec_t **hltab, StlClickRecord **tabtab)
 
void get_rel_pos (win_T *wp, char_u *buf, int buflen)
 
void fname_expand (buf_T *buf, char_u **ffname, char_u **sfname)
 
char_ualist_name (aentry_T *aep)
 Get the file name for an argument list entry. More...
 
void do_arg_all (int count, int forceit, int keep_tabs)
 
bool bt_prompt (buf_T *buf) FUNC_ATTR_PURE
 
void ex_buffer_all (exarg_T *eap)
 Open a window for a number of buffers. More...
 
void do_modelines (int flags)
 
bool bt_help (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool bt_normal (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool bt_quickfix (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool bt_terminal (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool bt_nofile (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool bt_dontwrite (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool bt_dontwrite_msg (const buf_T *const buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
 
bool buf_hide (const buf_T *const buf) FUNC_ATTR_PURE
 
char_ubuf_spname (buf_T *buf)
 
bool find_win_for_buf (buf_T *buf, win_T **wp, tabpage_T **tp)
 
void buf_signcols_del_check (buf_T *buf, linenr_T line1, linenr_T line2)
 
void buf_signcols_add_check (buf_T *buf, sign_entry_T *added)
 
int buf_signcols (buf_T *buf, int maximum)
 
char_ubuf_get_fname (const buf_T *buf) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
 Get "buf->b_fname", use "[No Name]" if it is NULL. More...
 
void set_buflisted (int on)
 Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed. More...
 
bool buf_contents_changed (buf_T *buf) FUNC_ATTR_NONNULL_ALL
 
void wipe_buffer (buf_T *buf, bool aucmd)
 
void buf_open_scratch (handle_T bufnr, char *bufname)
 

Macro Definition Documentation

◆ MAX_STL_EVAL_DEPTH

#define MAX_STL_EVAL_DEPTH   100

◆ SPACE_FOR_ARGNR

#define SPACE_FOR_ARGNR   (sizeof(buf) - 10)

◆ SPACE_FOR_DIR

#define SPACE_FOR_DIR   (sizeof(buf) - 20)

◆ SPACE_FOR_FNAME

#define SPACE_FOR_FNAME   (sizeof(buf) - 100)

◆ TMPLEN

#define TMPLEN   70

Enumeration Type Documentation

◆ BufFreeFlags

Enumerator
kBffClearWinInfo 
kBffInitChangedtick 

◆ NumberBase

enum NumberBase

Enumeration specifying the valid numeric bases that can be used when printing numbers in the status line.

Enumerator
kNumBaseDecimal 
kNumBaseHexadecimal 

Function Documentation

◆ alist_name()

char_u* alist_name ( aentry_T aep)

Get the file name for an argument list entry.

◆ bt_dontwrite()

bool bt_dontwrite ( const buf_T *const  buf)
Returns
true if "buf" is a "nowrite", "nofile", "terminal" or "prompt" buffer.

◆ bt_dontwrite_msg()

bool bt_dontwrite_msg ( const buf_T *const  buf)

◆ bt_help()

bool bt_help ( const buf_T *const  buf)
Returns
true if "buf" is a help buffer.

◆ bt_nofile()

bool bt_nofile ( const buf_T *const  buf)
Returns
true if "buf" is a "nofile", "acwrite", "terminal" or "prompt" / buffer. This means the buffer name is not a file name.

◆ bt_normal()

bool bt_normal ( const buf_T *const  buf)
Returns
true if "buf" is a normal buffer, 'buftype' is empty.

◆ bt_prompt()

bool bt_prompt ( buf_T buf)
Returns
true if "buf" is a prompt buffer.

◆ bt_quickfix()

bool bt_quickfix ( const buf_T *const  buf)
Returns
true if "buf" is the quickfix buffer.

◆ bt_terminal()

bool bt_terminal ( const buf_T *const  buf)
Returns
true if "buf" is a terminal buffer.

◆ buf_clear()

void buf_clear ( void  )

Clears the current buffer contents.

◆ buf_clear_file()

void buf_clear_file ( buf_T buf)

Make buffer not contain a file.

◆ buf_contents_changed()

bool buf_contents_changed ( buf_T buf)

Read the file for "buf" again and check if the contents changed. Return true if it changed or this could not be checked.

Parameters
bufbuffer to check
Returns
true if the buffer's contents have changed

◆ buf_freeall()

void buf_freeall ( buf_T buf,
int  flags 
)

buf_freeall() - free all things allocated for a buffer that are related to the file. Careful: get here with "curwin" NULL when exiting.

Parameters
flagsBFA_DEL buffer is going to be deleted BFA_WIPE buffer is going to be wiped out BFA_KEEP_UNDO do not free undo information BFA_IGNORE_ABORT don't abort even when aborting() returns true

◆ buf_get_fname()

char_u* buf_get_fname ( const buf_T buf)

Get "buf->b_fname", use "[No Name]" if it is NULL.

◆ buf_hide()

bool buf_hide ( const buf_T *const  buf)
Returns
true if the buffer should be hidden, according to 'hidden', ":hide" and 'bufhidden'.

◆ buf_name_changed()

void buf_name_changed ( buf_T buf)

Take care of what needs to be done when the name of buffer "buf" has changed.

◆ buf_open_scratch()

void buf_open_scratch ( handle_T  bufnr,
char *  bufname 
)

Creates or switches to a scratch buffer. :h special-buffers Scratch buffer is:

  • buftype=nofile bufhidden=hide noswapfile
  • Always considered 'nomodified'
Parameters
bufnrBuffer to switch to, or 0 to create a new buffer.
See also
curbufIsChanged()

◆ buf_set_file_id()

void buf_set_file_id ( buf_T buf)

Set file_id for a buffer. Must always be called when b_fname is changed!

◆ buf_set_name()

void buf_set_name ( int  fnum,
char_u name 
)

Crude way of changing the name of a buffer. Use with care! The name should be relative to the current directory.

◆ buf_signcols()

int buf_signcols ( buf_T buf,
int  maximum 
)

◆ buf_signcols_add_check()

void buf_signcols_add_check ( buf_T buf,
sign_entry_T added 
)

Re-calculate the signcolumn after adding a sign.

Parameters
bufbuffer to check
addedsign being added

◆ buf_signcols_del_check()

void buf_signcols_del_check ( buf_T buf,
linenr_T  line1,
linenr_T  line2 
)

Invalidate the signcolumn if needed after deleting signs between line1 and line2 (inclusive).

Parameters
bufbuffer to check
line1start of region being deleted
line2end of region being deleted

◆ buf_spname()

char_u* buf_spname ( buf_T buf)
Returns
special buffer name or NULL when the buffer has a normal file name.

◆ buf_valid()

bool buf_valid ( buf_T buf)

Check that "buf" points to a valid buffer in the buffer list.

Can be slow if there are many buffers, prefer using bufref_valid().

Parameters
bufThe buffer to check for.

◆ buflist_add()

int buflist_add ( char_u fname,
int  flags 
)

Add a file name to the buflist and return its number. Uses same flags as buflist_new(), except BLN_DUMMY.

Used by qf_init(), main() and doarglist()

◆ buflist_altfpos()

void buflist_altfpos ( win_T win)

Set alternate cursor position for the current buffer and window "win". Also save the local window option values.

◆ buflist_findfpos()

pos_T* buflist_findfpos ( buf_T buf)

Find the position (lnum and col) for the buffer 'buf' for the current window.

Returns
a pointer to no_position if no position is found.

◆ buflist_findlnum()

linenr_T buflist_findlnum ( buf_T buf)

Find the lnum for the buffer 'buf' for the current window.

◆ buflist_findname()

buf_T* buflist_findname ( char_u ffname)

Find file in buffer list by name (it has to be for the current window). "ffname" must have a full path. Skips dummy buffers.

Returns
buffer or NULL if not found

◆ buflist_findname_exp()

buf_T* buflist_findname_exp ( char_u fname)

Find file in buffer list by name (it has to be for the current window).

Returns
buffer or NULL if not found

◆ buflist_findnr()

buf_T* buflist_findnr ( int  nr)

Find a file in the buffer list by buffer number.

◆ buflist_findpat()

int buflist_findpat ( const char_u pattern,
const char_u pattern_end,
bool  unlisted,
bool  diffmode,
bool  curtab_only 
)

Find file in buffer list by a regexp pattern.

Parameters
pattern_endpointer to first char after pattern
unlistedfind unlisted buffers
diffmodefind diff-mode buffers only
curtab_onlyfind buffers in current tab only
Returns
fnum of the found buffer or < 0 for error.

◆ buflist_getfile()

int buflist_getfile ( int  n,
linenr_T  lnum,
int  options,
int  forceit 
)

Get alternate file "n". Set linenr to "lnum" or altfpos.lnum if "lnum" == 0. Also set cursor column to altfpos.col if 'startofline' is not set. if (options & GETF_SETMARK) call setpcmark() if (options & GETF_ALT) we are jumping to an alternate file. if (options & GETF_SWITCH) respect 'switchbuf' settings when jumping

Return FAIL for failure, OK for success.

◆ buflist_getfpos()

void buflist_getfpos ( void  )

Go to the last known line number for the current buffer.

◆ buflist_list()

void buflist_list ( exarg_T eap)

List all known file names (for :files and :buffers command).

◆ buflist_name_nr()

int buflist_name_nr ( int  fnum,
char_u **  fname,
linenr_T lnum 
)

Get file name and line number for file 'fnum'. Used by DoOneCmd() for translating '' and '#'. Used by insert_reg() and cmdline_paste() for '#' register.

Returns
FAIL if not found, OK for success.

◆ buflist_new()

buf_T* buflist_new ( char_u ffname_arg,
char_u sfname_arg,
linenr_T  lnum,
int  flags 
)

Add a file name to the buffer list. If the same file name already exists return a pointer to that buffer. If it does not exist, or if fname == NULL, a new entry is created. If (flags & BLN_CURBUF) is true, may use current buffer. If (flags & BLN_LISTED) is true, add new buffer to buffer list. If (flags & BLN_DUMMY) is true, don't count it as a real buffer. If (flags & BLN_NEW) is true, don't use an existing buffer. If (flags & BLN_NOOPT) is true, don't copy options from the current buffer if the buffer already exists. This is the ONLY way to create a new buffer.

Parameters
ffname_argfull path of fname or relative
sfname_argshort fname or NULL
lnumpreferred cursor line
flagsBLN_ defines
bufnr
Returns
pointer to the buffer

◆ buflist_nr2name()

char_u* buflist_nr2name ( int  n,
int  fullname,
int  helptail 
)

Get name of file 'n' in the buffer list. When the file has no name an empty string is returned. home_replace() is used to shorten the file name (used for marks).

Parameters
helptailfor help buffers return tail only
Returns
a pointer to allocated memory, of NULL when failed.

◆ buflist_setfpos()

void buflist_setfpos ( buf_T *const  buf,
win_T *const  win,
linenr_T  lnum,
colnr_T  col,
bool  copy_options 
)

Set the line and column numbers for the given buffer and window

Parameters
[in,out]bufBuffer for which line and column are set.
[in,out]winWindow for which line and column are set. May be NULL when using :badd.
[in]lnumLine number to be set. If it is zero then only options are touched.
[in]colColumn number to be set.
[in]copy_optionsIf true save the local window option values.

◆ bufref_valid()

bool bufref_valid ( bufref_T bufref)

Return true if "bufref->br_buf" points to the same buffer as when set_bufref() was called and it is a valid buffer. Only goes through the buffer list if buf_free_count changed. Also checks if b_fnum is still the same, a :bwipe followed by :new might get the same allocated memory, but it's a different buffer.

Parameters
bufrefBuffer reference to check for.

◆ build_stl_str_hl()

int build_stl_str_hl ( win_T wp,
char *  out,
size_t  outlen,
char *  fmt,
int  use_sandbox,
int  fillchar,
int  maxwidth,
stl_hlrec_t **  hltab,
StlClickRecord **  tabtab 
)

Build a string from the status line items in "fmt". Return length of string in screen cells.

Normally works for window "wp", except when working for 'tabline' then it is "curwin".

Items are drawn interspersed with the text that surrounds it Specials: %-<wid>(xxx%) => group, %= => separation marker, %< => truncation Item: %-<minwid>.<maxwid><itemch> All but <itemch> are optional

If maxwidth is not zero, the string will be filled at any middle marker or truncated if too long, fillchar is used for all whitespace.

Parameters
wpThe window to build a statusline for
outThe output buffer to write the statusline to Note: This should not be NameBuff
outlenThe length of the output buffer
fmtThe statusline format string
use_sandboxUse a sandboxed environment when evaluating fmt
fillcharCharacter to use when filling empty space in the statusline
maxwidthThe maximum width to make the statusline
hltabHL attributes (can be NULL)
tabtabTab clicks definition (can be NULL).
Returns
The final width of the statusline

◆ close_buffer()

bool close_buffer ( win_T win,
buf_T buf,
int  action,
bool  abort_if_last,
bool  ignore_abort 
)

Close the link to a buffer.

Parameters
winIf not NULL, set b_last_cursor.
buf
actionUsed when there is no longer a window for the buffer. Possible values: 0 buffer becomes hidden DOBUF_UNLOAD buffer is unloaded DOBUF_DELETE buffer is unloaded and removed from buffer list DOBUF_WIPE buffer is unloaded and really deleted When doing all but the first one on the current buffer, the caller should get a new buffer very soon! The 'bufhidden' option can force freeing and deleting.
abort_if_lastIf true, do not close the buffer if autocommands cause there to be only one window with this buffer. e.g. when ":quit" is supposed to close the window but autocommands close all other windows.
ignore_abortIf true, don't abort even when aborting() returns true.
Returns
true when we got to the end and b_nwindows was decremented.

◆ col_print()

void col_print ( char_u buf,
size_t  buflen,
int  col,
int  vcol 
)

◆ curbuf_reusable()

bool curbuf_reusable ( void  )

Return true if the current buffer is empty, unnamed, unmodified and used in only one window. That means it can be reused.

◆ do_arg_all()

void do_arg_all ( int  count,
int  forceit,
int  keep_tabs 
)

do_arg_all(): Open up to 'count' windows, one for each argument.

Parameters
forceithide buffers in current windows
keep_tabskeep current tabs, for ":tab drop file"

◆ do_autochdir()

void do_autochdir ( void  )

Change to the directory of the current buffer. Don't do this while still starting up.

◆ do_bufdel()

char* do_bufdel ( int  command,
char_u arg,
int  addr_count,
int  start_bnr,
int  end_bnr,
int  forceit 
)

do_bufdel() - delete or unload buffer(s)

addr_count == 0: ":bdel" - delete current buffer addr_count == 1: ":N bdel" or ":bdel N [N ..]" - first delete buffer "end_bnr", then any other arguments. addr_count == 2: ":N,N bdel" - delete buffers in range

command can be DOBUF_UNLOAD (":bunload"), DOBUF_WIPE (":bwipeout") or DOBUF_DEL (":bdel")

Parameters
argpointer to extra arguments
start_bnrfirst buffer number in a range
end_bnrbuffer nr or last buffer nr in a range
Returns
error message or NULL

◆ do_buffer()

int do_buffer ( int  action,
int  start,
int  dir,
int  count,
int  forceit 
)

Implementation of the commands for the buffer list.

action == DOBUF_GOTO go to specified buffer action == DOBUF_SPLIT split window and go to specified buffer action == DOBUF_UNLOAD unload specified buffer(s) action == DOBUF_DEL delete specified buffer(s) from buffer list action == DOBUF_WIPE delete specified buffer(s) really

start == DOBUF_CURRENT go to "count" buffer from current buffer start == DOBUF_FIRST go to "count" buffer from first buffer start == DOBUF_LAST go to "count" buffer from last buffer start == DOBUF_MOD go to "count" modified buffer from current buffer

Parameters
dirFORWARD or BACKWARD
countbuffer number or number of buffers
forceittrue for :...!
Returns
FAIL or OK.

◆ do_modelines()

void do_modelines ( int  flags)

do_modelines() - process mode lines for the current file

Parameters
flagsOPT_WINONLY only set options local to window OPT_NOWIN don't set options local to window

Returns immediately if the "ml" option isn't set.

◆ enter_buffer()

void enter_buffer ( buf_T buf)

Enter a new current buffer. Old curbuf must have been abandoned already! This also means "curbuf" may be pointing to freed memory.

◆ ex_buffer_all()

void ex_buffer_all ( exarg_T eap)

Open a window for a number of buffers.

◆ ExpandBufnames()

int ExpandBufnames ( char_u pat,
int *  num_file,
char_u ***  file,
int  options 
)

Find all buffer names that match. For command line expansion of ":buf" and ":sbuf".

Returns
OK if matches found, FAIL otherwise.

◆ fileinfo()

void fileinfo ( int  fullname,
int  shorthelp,
int  dont_truncate 
)

Print info about the current buffer.

Parameters
fullnamewhen non-zero print full path

◆ find_win_for_buf()

bool find_win_for_buf ( buf_T buf,
win_T **  wp,
tabpage_T **  tp 
)

Find a window for buffer "buf". If found true is returned and "wp" and "tp" are set to the window and tabpage. If not found, false is returned.

Parameters
bufbuffer to find a window for
[out]wpstores the found window
[out]tpstores the found tabpage
Returns
true if a window was found for the buffer.

◆ fname_expand()

void fname_expand ( buf_T buf,
char_u **  ffname,
char_u **  sfname 
)

Make "*ffname" a full file name, set "*sfname" to "*ffname" if not NULL. "*ffname" becomes a pointer to allocated memory (or NULL). When resolving a link both "*sfname" and "*ffname" will point to the same allocated memory. The "*ffname" and "*sfname" pointer values on call will not be freed. Note that the resulting "*ffname" pointer should be considered not allocated.

◆ free_buf_options()

void free_buf_options ( buf_T buf,
int  free_p_ff 
)

Free the memory for the options of a buffer. If "free_p_ff" is true also free 'fileformat', 'buftype' and 'fileencoding'.

◆ get_rel_pos()

void get_rel_pos ( win_T wp,
char_u buf,
int  buflen 
)

Get relative cursor position in window into "buf[buflen]", in the form 99%, using "Top", "Bot" or "All" when appropriate.

◆ get_winopts()

void get_winopts ( buf_T buf)

Reset the local window options to the values last used in this window. If the buffer wasn't used in this window before, use the values from the most recently used window. If the values were never set, use the global values for the window.

◆ getaltfname()

char_u* getaltfname ( bool  errmsg)

Get alternate file name for current window. Return NULL if there isn't any, and give error message if requested.

Parameters
errmsggive error message

◆ goto_buffer()

void goto_buffer ( exarg_T eap,
int  start,
int  dir,
int  count 
)

Go to another buffer. Handles the result of the ATTENTION dialog.

◆ handle_swap_exists()

void handle_swap_exists ( bufref_T old_curbuf)

Handle the situation of swap_exists_action being set.

It is allowed for "old_curbuf" to be NULL or invalid.

Parameters
old_curbufThe buffer to check for.

◆ maketitle()

void maketitle ( void  )

Put the title name in the title bar and icon of the window.

◆ no_write_message()

void no_write_message ( void  )

◆ no_write_message_nobang()

void no_write_message_nobang ( const buf_T *const  buf)

◆ open_buffer()

int open_buffer ( int  read_stdin,
exarg_T eap,
int  flags 
)

Open current buffer, that is: open the memfile and read the file into memory.

Parameters
read_stdinread file from stdin
eapfor forced 'ff' and 'fenc' or NULL
flagsextra flags for readfile()
Returns
FAIL for failure, OK otherwise.

◆ otherfile()

bool otherfile ( char_u ffname)

Check that "ffname" is not the same file as current file. Fname must have a full path (expanded by path_to_absolute()).

Parameters
ffnamefull path name to check

◆ resettitle()

void resettitle ( void  )

Set current window title.

◆ set_buflisted()

void set_buflisted ( int  on)

Set 'buflisted' for curbuf to "on" and trigger autocommands if it changed.

◆ set_bufref()

void set_bufref ( bufref_T bufref,
buf_T buf 
)

Store "buf" in "bufref" and set the free count.

Parameters
bufrefReference to be used for the buffer.
bufThe buffer to reference.

◆ set_curbuf()

void set_curbuf ( buf_T buf,
int  action 
)

Set current buffer to "buf". Executes autocommands and closes current buffer.

Parameters
actiontells how to close the current buffer: DOBUF_GOTO free or hide it DOBUF_SPLIT nothing DOBUF_UNLOAD unload it DOBUF_DEL delete it DOBUF_WIPE wipe it out

◆ setaltfname()

buf_T* setaltfname ( char_u ffname,
char_u sfname,
linenr_T  lnum 
)

Set alternate file name for current window

Used by do_one_cmd(), do_write() and do_ecmd().

Returns
the buffer.

◆ setfname()

int setfname ( buf_T buf,
char_u ffname_arg,
char_u sfname_arg,
bool  message 
)

Set the file name for "buf" to "ffname_arg", short file name to "sfname_arg". The file name with the full path is also remembered, for when :cd is used.

Parameters
messagegive message when buffer already exists
Returns
FAIL for failure (file name already in use by other buffer) OK otherwise.

◆ wipe_buffer()

void wipe_buffer ( buf_T buf,
bool  aucmd 
)

Wipe out a buffer and decrement the last buffer number if it was used for this buffer. Call this to wipe out a temp buffer that does not contain any marks.

Parameters
aucmdWhen true trigger autocommands.