Functions
cursor.c File Reference
#include <inttypes.h>
#include <stdbool.h>
#include "nvim/ascii.h"
#include "nvim/assert.h"
#include "nvim/change.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/extmark.h"
#include "nvim/fold.h"
#include "nvim/mark.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/plines.h"
#include "nvim/screen.h"
#include "nvim/state.h"
#include "nvim/vim.h"

Functions

int getviscol (void)
 
int getviscol2 (colnr_T col, colnr_T coladd)
 
int coladvance_force (colnr_T wcol)
 
int coladvance (colnr_T wcol)
 
int getvpos (pos_T *pos, colnr_T wcol)
 
int inc_cursor (void)
 Increment the cursor position. See inc() for return values. More...
 
int dec_cursor (void)
 
linenr_T get_cursor_rel_lnum (win_T *wp, linenr_T lnum)
 
void check_pos (buf_T *buf, pos_T *pos)
 
void check_cursor_lnum (void)
 Make sure curwin->w_cursor.lnum is valid. More...
 
void check_cursor_col (void)
 Make sure curwin->w_cursor.col is valid. More...
 
void check_cursor_col_win (win_T *win)
 
void check_cursor (void)
 Make sure curwin->w_cursor in on a valid character. More...
 
void adjust_cursor_col (void)
 
bool leftcol_changed (void)
 
int gchar_cursor (void)
 
void pchar_cursor (char_u c)
 
char_uget_cursor_line_ptr (void)
 
char_uget_cursor_pos_ptr (void)
 

Function Documentation

◆ adjust_cursor_col()

void adjust_cursor_col ( void  )

Make sure curwin->w_cursor is not on the NUL at the end of the line. Allow it when in Visual mode and 'selection' is not "old".

◆ check_cursor()

void check_cursor ( void  )

Make sure curwin->w_cursor in on a valid character.

◆ check_cursor_col()

void check_cursor_col ( void  )

Make sure curwin->w_cursor.col is valid.

◆ check_cursor_col_win()

void check_cursor_col_win ( win_T win)

Make sure win->w_cursor.col is valid. Special handling of insert-mode.

See also
mb_check_adjust_col

◆ check_cursor_lnum()

void check_cursor_lnum ( void  )

Make sure curwin->w_cursor.lnum is valid.

◆ check_pos()

void check_pos ( buf_T buf,
pos_T pos 
)

Make sure "pos.lnum" and "pos.col" are valid in "buf". This allows for the col to be on the NUL byte.

◆ coladvance()

int coladvance ( colnr_T  wcol)

Try to advance the Cursor to the specified screen column. If virtual editing: fine tune the cursor position. Note that all virtual positions off the end of a line should share a curwin->w_cursor.col value (n.b. this is equal to STRLEN(line)), beginning at coladd 0.

Returns
OK if desired column is reached, FAIL if not

◆ coladvance_force()

int coladvance_force ( colnr_T  wcol)

Go to column "wcol", and add/insert white space as necessary to get the cursor in that column. The caller must have saved the cursor line for undo!

◆ dec_cursor()

int dec_cursor ( void  )

Decrement the line pointer 'p' crossing line boundaries as necessary.

Returns
1 when crossing a line, -1 when at start of file, 0 otherwise.

◆ gchar_cursor()

int gchar_cursor ( void  )

◆ get_cursor_line_ptr()

char_u* get_cursor_line_ptr ( void  )
Returns
pointer to cursor line.

◆ get_cursor_pos_ptr()

char_u* get_cursor_pos_ptr ( void  )
Returns
pointer to cursor position.

◆ get_cursor_rel_lnum()

linenr_T get_cursor_rel_lnum ( win_T wp,
linenr_T  lnum 
)

Get the line number relative to the current cursor position, i.e. the difference between line number and cursor position. Only look for lines that can be visible, folded lines don't count.

Parameters
lnumline number to get the result for

◆ getviscol()

int getviscol ( void  )
Returns
the screen position of the cursor.

◆ getviscol2()

int getviscol2 ( colnr_T  col,
colnr_T  coladd 
)
Returns
the screen position of character col with a coladd in the cursor line.

◆ getvpos()

int getvpos ( pos_T pos,
colnr_T  wcol 
)

Return in "pos" the position of the cursor advanced to screen column "wcol".

Returns
OK if desired column is reached, FAIL if not

◆ inc_cursor()

int inc_cursor ( void  )

Increment the cursor position. See inc() for return values.

◆ leftcol_changed()

bool leftcol_changed ( void  )

When curwin->w_leftcol has changed, adjust the cursor position.

Returns
true if the cursor was moved.

◆ pchar_cursor()

void pchar_cursor ( char_u  c)

Write a character at the current cursor position. It is directly written into the block.