Functions
change.c File Reference
#include "nvim/assert.h"
#include "nvim/buffer.h"
#include "nvim/buffer_updates.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/diff.h"
#include "nvim/edit.h"
#include "nvim/eval.h"
#include "nvim/fileio.h"
#include "nvim/fold.h"
#include "nvim/indent.h"
#include "nvim/indent_c.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/misc1.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/screen.h"
#include "nvim/search.h"
#include "nvim/state.h"
#include "nvim/ui.h"
#include "nvim/undo.h"

Functions

void change_warning (int col)
 change.c: functions related to changing text More...
 
void changed (void)
 
void changed_internal (void)
 
void changed_bytes (linenr_T lnum, colnr_T col)
 
void appended_lines (linenr_T lnum, long count)
 
void appended_lines_mark (linenr_T lnum, long count)
 Like appended_lines(), but adjust marks first. More...
 
void deleted_lines (linenr_T lnum, long count)
 
void deleted_lines_mark (linenr_T lnum, long count)
 
void changed_lines_buf (buf_T *buf, linenr_T lnum, linenr_T lnume, long xtra)
 
void changed_lines (linenr_T lnum, colnr_T col, linenr_T lnume, long xtra, bool do_buf_event)
 
void unchanged (buf_T *buf, int ff, bool always_inc_changedtick)
 
void ins_bytes (char_u *p)
 
void ins_bytes_len (char_u *p, size_t len)
 
void ins_char (int c)
 
void ins_char_bytes (char_u *buf, size_t charlen)
 
void ins_str (char_u *s)
 
int del_char (bool fixpos)
 
int del_chars (long count, int fixpos)
 Like del_bytes(), but delete characters instead of bytes. More...
 
int del_bytes (colnr_T count, bool fixpos_arg, bool use_delcombine)
 
int copy_indent (int size, char_u *src)
 
int open_line (int dir, int flags, int second_line_indent)
 
void truncate_line (int fixpos)
 
void del_lines (long nlines, int undo)
 

Function Documentation

void appended_lines ( linenr_T  lnum,
long  count 
)

Appended "count" lines below line "lnum" in the current buffer. Must be called AFTER the change and after mark_adjust(). Takes care of marking the buffer to be redrawn and sets the changed flag.

void appended_lines_mark ( linenr_T  lnum,
long  count 
)

Like appended_lines(), but adjust marks first.

void change_warning ( int  col)

change.c: functions related to changing text

If the file is readonly, give a warning message with the first change. Don't do this for autocommands. Doesn't use emsg(), because it flushes the macro buffer. If we have undone all changes b_changed will be false, but "b_did_warn" will be true. "col" is the column for the message; non-zero when in insert mode and 'showmode' is on. Careful: may trigger autocommands that reload the buffer.

void changed ( void  )

Call this function when something in the current buffer is changed.

Most often called through changed_bytes() and changed_lines(), which also mark the area of the display to be redrawn.

Careful: may trigger autocommands that reload the buffer.

void changed_bytes ( linenr_T  lnum,
colnr_T  col 
)

Changed bytes within a single line for the current buffer.

  • marks the windows on this buffer to be redisplayed
  • marks the buffer changed by calling changed()
  • invalidates cached values Careful: may trigger autocommands that reload the buffer.
void changed_internal ( void  )

Internal part of changed(), no user interaction. Also used for recovery.

void changed_lines ( linenr_T  lnum,
colnr_T  col,
linenr_T  lnume,
long  xtra,
bool  do_buf_event 
)

Changed lines for the current buffer. Must be called AFTER the change and after mark_adjust().

  • mark the buffer changed by calling changed()
  • mark the windows on this buffer to be redisplayed
  • invalidate cached values "lnum" is the first line that needs displaying, "lnume" the first line below the changed lines (BEFORE the change). When only inserting lines, "lnum" and "lnume" are equal. Takes care of calling changed() and updating b_mod_*. Careful: may trigger autocommands that reload the buffer.
void changed_lines_buf ( buf_T buf,
linenr_T  lnum,
linenr_T  lnume,
long  xtra 
)

Marks the area to be redrawn after a change.

Parameters
bufthe buffer where lines were changed
lnumfirst line with change
lnumeline below last changed line
xtranumber of extra lines (negative when deleting)
int copy_indent ( int  size,
char_u src 
)

Copy the indent from ptr to the current line (and fill to size). Leaves the cursor on the first non-blank in the line.

Returns
true if the line was changed.
int del_bytes ( colnr_T  count,
bool  fixpos_arg,
bool  use_delcombine 
)

Delete "count" bytes under the cursor. If "fixpos" is true, don't leave the cursor on the NUL after the line. Caller must have prepared for undo.

Parameters
countnumber of bytes to be deleted
fixpos_argleave the cursor on the NUL after the line
use_delcombine'delcombine' option applies
Returns
FAIL for failure, OK otherwise
int del_char ( bool  fixpos)
int del_chars ( long  count,
int  fixpos 
)

Like del_bytes(), but delete characters instead of bytes.

void del_lines ( long  nlines,
int  undo 
)

Delete "nlines" lines at the cursor. Saves the lines for undo first if "undo" is true.

void deleted_lines ( linenr_T  lnum,
long  count 
)

Deleted "count" lines at line "lnum" in the current buffer. Must be called AFTER the change and after mark_adjust(). Takes care of marking the buffer to be redrawn and sets the changed flag.

void deleted_lines_mark ( linenr_T  lnum,
long  count 
)

Like deleted_lines(), but adjust marks first. Make sure the cursor is on a valid line before calling, a GUI callback may be triggered to display the cursor.

void ins_bytes ( char_u p)

Insert string "p" at the cursor position. Stops at a NUL byte. Handles Replace mode and multi-byte characters.

void ins_bytes_len ( char_u p,
size_t  len 
)

Insert string "p" with length "len" at the cursor position. Handles Replace mode and multi-byte characters.

void ins_char ( int  c)

Insert or replace a single character at the cursor position. When in REPLACE or VREPLACE mode, replace any existing character. Caller must have prepared for undo. For multi-byte characters we get the whole character, the caller must convert bytes to a character.

void ins_char_bytes ( char_u buf,
size_t  charlen 
)
void ins_str ( char_u s)

Insert a string at the cursor position. Note: Does NOT handle Replace mode. Caller must have prepared for undo.

int open_line ( int  dir,
int  flags,
int  second_line_indent 
)

open_line: Add a new line below or above the current line.

For VREPLACE mode, we only add a new line when we get to the end of the file, otherwise we just start replacing the next line.

Caller must take care of undo. Since VREPLACE may affect any number of lines however, it may call u_save_cursor() again when starting to change a new line. "flags": OPENLINE_DELSPACES delete spaces after cursor OPENLINE_DO_COM format comments OPENLINE_KEEPTRAIL keep trailing spaces OPENLINE_MARKFIX adjust mark positions after the line break OPENLINE_COM_LIST format comments with list or 2nd line indent

"second_line_indent": indent for after ^^D in Insert mode or if flag OPENLINE_COM_LIST

Returns
true on success, false on failure
void truncate_line ( int  fixpos)

Delete from cursor to end of line. Caller must have prepared for undo. If "fixpos" is true fix the cursor position when done.

void unchanged ( buf_T buf,
int  ff,
bool  always_inc_changedtick 
)

Called when the changed flag must be reset for buffer buf. When ff is true also reset 'fileformat'. When always_inc_changedtick is true b:changedtick is incremented even when the changed flag was off.