Data Structures | Macros | Typedefs | Enumerations | Functions
sign.c File Reference
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
#include "nvim/cursor.h"
#include "nvim/edit.h"
#include "nvim/ex_docmd.h"
#include "nvim/fold.h"
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/screen.h"
#include "nvim/sign.h"
#include "nvim/syntax.h"
#include "nvim/vim.h"

Data Structures

struct  sign
 

Macros

#define SIGNCMD_DEFINE   0
 
#define SIGNCMD_UNDEFINE   1
 
#define SIGNCMD_LIST   2
 
#define SIGNCMD_PLACE   3
 
#define SIGNCMD_UNPLACE   4
 
#define SIGNCMD_JUMP   5
 
#define SIGNCMD_LAST   6
 

Typedefs

typedef struct sign sign_T
 Struct to hold the sign properties. More...
 

Enumerations

enum  {
  EXP_SUBCMD, EXP_DEFINE, EXP_PLACE, EXP_LIST,
  EXP_UNPLACE, EXP_SIGN_NAMES, EXP_SIGN_GROUPS
}
 

Functions

void init_signs (void)
 Initialize data needed for managing signs. More...
 
bool sign_in_group (sign_entry_T *sign, const char_u *group)
 
int sign_group_get_next_signid (buf_T *buf, const char_u *groupname)
 Get the next free sign identifier in the specified group. More...
 
char_usign_typenr2name (int typenr)
 Get the name of a sign by its typenr. More...
 
dict_Tsign_get_info (sign_entry_T *sign)
 Return information about a sign in a Dict. More...
 
void buf_addsign (buf_T *buf, int id, const char_u *groupname, int prio, linenr_T lnum, int typenr, bool has_text_or_icon)
 
linenr_T buf_change_sign_type (buf_T *buf, int markId, const char_u *group, int typenr, int prio)
 
sign_attrs_Tsign_get_attr (SignType type, sign_attrs_T sattrs[], int idx, int max_signs)
 
int buf_get_signattrs (buf_T *buf, linenr_T lnum, sign_attrs_T sattrs[])
 
linenr_T buf_delsign (buf_T *buf, linenr_T atlnum, int id, char_u *group)
 
int buf_findsign (buf_T *buf, int id, char_u *group)
 
int buf_findsign_id (buf_T *buf, linenr_T lnum, char_u *groupname)
 
void buf_delete_signs (buf_T *buf, char_u *group)
 Delete signs in buffer "buf". More...
 
void sign_list_placed (buf_T *rbuf, char_u *sign_group)
 List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers. More...
 
void sign_mark_adjust (linenr_T line1, linenr_T line2, long amount, long amount_after)
 Adjust a placed sign for inserted/deleted lines. More...
 
int sign_define_by_name (char_u *name, char_u *icon, char_u *linehl, char_u *text, char_u *texthl, char *numhl)
 Define a new sign or update an existing sign. More...
 
int sign_undefine_by_name (const char_u *name)
 Free the sign specified by 'name'. More...
 
int sign_place (int *sign_id, const char_u *sign_group, const char_u *sign_name, buf_T *buf, linenr_T lnum, int prio)
 Place a sign at the specified file location or update a sign. More...
 
int sign_unplace (int sign_id, char_u *sign_group, buf_T *buf, linenr_T atlnum)
 Unplace the specified sign. More...
 
linenr_T sign_jump (int sign_id, char_u *sign_group, buf_T *buf)
 Jump to a sign. More...
 
void ex_sign (exarg_T *eap)
 ":sign" command More...
 
void sign_getlist (const char_u *name, list_T *retlist)
 
list_Tget_buffer_signs (buf_T *buf) FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
 Returns information about signs placed in a buffer as list of dicts. More...
 
void sign_get_placed (buf_T *buf, linenr_T lnum, int sign_id, const char_u *sign_group, list_T *retlist)
 
void free_signs (void)
 Undefine/free all signs. More...
 
char_uget_sign_name (expand_T *xp, int idx)
 
void set_context_in_sign_cmd (expand_T *xp, char_u *arg)
 Handle command line completion for :sign command. More...
 
int sign_define_from_dict (const char *name_arg, dict_T *dict)
 
void sign_define_multiple (list_T *l, list_T *retlist)
 
int sign_place_from_dict (typval_T *id_tv, typval_T *group_tv, typval_T *name_tv, typval_T *buf_tv, dict_T *dict)
 
void sign_undefine_multiple (list_T *l, list_T *retlist)
 Undefine multiple signs. More...
 
int sign_unplace_from_dict (typval_T *group_tv, dict_T *dict)
 

Macro Definition Documentation

◆ SIGNCMD_DEFINE

#define SIGNCMD_DEFINE   0

◆ SIGNCMD_JUMP

#define SIGNCMD_JUMP   5

◆ SIGNCMD_LAST

#define SIGNCMD_LAST   6

◆ SIGNCMD_LIST

#define SIGNCMD_LIST   2

◆ SIGNCMD_PLACE

#define SIGNCMD_PLACE   3

◆ SIGNCMD_UNDEFINE

#define SIGNCMD_UNDEFINE   1

◆ SIGNCMD_UNPLACE

#define SIGNCMD_UNPLACE   4

Typedef Documentation

◆ sign_T

typedef struct sign sign_T

Struct to hold the sign properties.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
EXP_SUBCMD 
EXP_DEFINE 
EXP_PLACE 
EXP_LIST 
EXP_UNPLACE 
EXP_SIGN_NAMES 
EXP_SIGN_GROUPS 

Function Documentation

◆ buf_addsign()

void buf_addsign ( buf_T buf,
int  id,
const char_u groupname,
int  prio,
linenr_T  lnum,
int  typenr,
bool  has_text_or_icon 
)

Add the sign into the signlist. Find the right spot to do it though.

Parameters
bufbuffer to store sign in
idsign ID
groupnamesign group
priosign priority
lnumline number which gets the mark
typenrtypenr of sign we are adding
has_text_or_iconsign has text or icon

◆ buf_change_sign_type()

linenr_T buf_change_sign_type ( buf_T buf,
int  markId,
const char_u group,
int  typenr,
int  prio 
)

For an existing, placed sign "markId" change the type to "typenr". Returns the line number of the sign, or zero if the sign is not found.

Parameters
bufbuffer to store sign in
markIdsign ID
groupsign group
typenrtypenr of sign we are adding
priosign priority

◆ buf_delete_signs()

void buf_delete_signs ( buf_T buf,
char_u group 
)

Delete signs in buffer "buf".

◆ buf_delsign()

linenr_T buf_delsign ( buf_T buf,
linenr_T  atlnum,
int  id,
char_u group 
)

Delete sign 'id' in group 'group' from buffer 'buf'. If 'id' is zero, then delete all the signs in group 'group'. Otherwise delete only the specified sign. If 'group' is '*', then delete the sign in all the groups. If 'group' is NULL, then delete the sign in the global group. Otherwise delete the sign in the specified group.

Parameters
bufbuffer sign is stored in
atlnumsign at this line, 0 - at any line
idsign id
groupsign group
Returns
the line number of the deleted sign. If multiple signs are deleted, then returns the line number of the last sign deleted.

◆ buf_findsign()

int buf_findsign ( buf_T buf,
int  id,
char_u group 
)

Find the line number of the sign with the requested id in group 'group'. If the sign does not exist, return 0 as the line number. This will still let the correct file get loaded.

Parameters
bufbuffer to store sign in
idsign ID
groupsign group

◆ buf_findsign_id()

int buf_findsign_id ( buf_T buf,
linenr_T  lnum,
char_u groupname 
)

Return the identifier of the sign at line number 'lnum' in buffer 'buf'.

Parameters
bufbuffer whose sign we are searching for
lnumline number of sign
groupnamesign group name

◆ buf_get_signattrs()

int buf_get_signattrs ( buf_T buf,
linenr_T  lnum,
sign_attrs_T  sattrs[] 
)

Return the attributes of all the signs placed on line 'lnum' in buffer 'buf'. Used when refreshing the screen. Returns the number of signs.

Parameters
bufBuffer in which to search
lnumLine in which to search
sattrsOutput array for attrs
Returns
Number of signs of which attrs were found

◆ ex_sign()

void ex_sign ( exarg_T eap)

":sign" command

◆ free_signs()

void free_signs ( void  )

Undefine/free all signs.

◆ get_buffer_signs()

list_T* get_buffer_signs ( buf_T buf)

Returns information about signs placed in a buffer as list of dicts.

◆ get_sign_name()

char_u* get_sign_name ( expand_T xp,
int  idx 
)

Function given to ExpandGeneric() to obtain the sign command expansion.

◆ init_signs()

void init_signs ( void  )

Initialize data needed for managing signs.

◆ set_context_in_sign_cmd()

void set_context_in_sign_cmd ( expand_T xp,
char_u arg 
)

Handle command line completion for :sign command.

◆ sign_define_by_name()

int sign_define_by_name ( char_u name,
char_u icon,
char_u linehl,
char_u text,
char_u texthl,
char *  numhl 
)

Define a new sign or update an existing sign.

◆ sign_define_from_dict()

int sign_define_from_dict ( const char *  name_arg,
dict_T dict 
)

Define a sign using the attributes in 'dict'. Returns 0 on success and -1 on failure.

◆ sign_define_multiple()

void sign_define_multiple ( list_T l,
list_T retlist 
)

Define multiple signs using attributes from list 'l' and store the return values in 'retlist'.

◆ sign_get_attr()

sign_attrs_T* sign_get_attr ( SignType  type,
sign_attrs_T  sattrs[],
int  idx,
int  max_signs 
)

Return the sign attrs which has the attribute specified by 'type'. Returns NULL if a sign is not found with the specified attribute.

Parameters
typeType of sign to look for
sattrsSign attrs to search through
idxif there multiple signs, this index will pick the n-th out of the most max_signs sorted ascending by Id.
max_signsthe number of signs, with priority for the ones with the highest Ids.
Returns
Attrs of the matching sign, or NULL

◆ sign_get_info()

dict_T* sign_get_info ( sign_entry_T sign)

Return information about a sign in a Dict.

◆ sign_get_placed()

void sign_get_placed ( buf_T buf,
linenr_T  lnum,
int  sign_id,
const char_u sign_group,
list_T retlist 
)

Get a list of signs placed in buffer 'buf'. If 'num' is non-zero, return the sign placed at the line number. If 'lnum' is zero, return all the signs placed in 'buf'. If 'buf' is NULL, return signs placed in all the buffers.

◆ sign_getlist()

void sign_getlist ( const char_u name,
list_T retlist 
)

If 'name' is NULL, return a list of all the defined signs. Otherwise, return information about the specified sign.

◆ sign_group_get_next_signid()

int sign_group_get_next_signid ( buf_T buf,
const char_u groupname 
)

Get the next free sign identifier in the specified group.

◆ sign_in_group()

bool sign_in_group ( sign_entry_T sign,
const char_u group 
)
Returns
true if 'sign' is in 'group'. A sign can either be in the global group (sign->group == NULL) or in a named group. If 'group' is '*', then the sign is part of the group.

◆ sign_jump()

linenr_T sign_jump ( int  sign_id,
char_u sign_group,
buf_T buf 
)

Jump to a sign.

◆ sign_list_placed()

void sign_list_placed ( buf_T rbuf,
char_u sign_group 
)

List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers.

◆ sign_mark_adjust()

void sign_mark_adjust ( linenr_T  line1,
linenr_T  line2,
long  amount,
long  amount_after 
)

Adjust a placed sign for inserted/deleted lines.

◆ sign_place()

int sign_place ( int *  sign_id,
const char_u sign_group,
const char_u sign_name,
buf_T buf,
linenr_T  lnum,
int  prio 
)

Place a sign at the specified file location or update a sign.

◆ sign_place_from_dict()

int sign_place_from_dict ( typval_T id_tv,
typval_T group_tv,
typval_T name_tv,
typval_T buf_tv,
dict_T dict 
)

Place a new sign using the values specified in dict 'dict'. Returns the sign identifier if successfully placed, otherwise returns 0.

◆ sign_typenr2name()

char_u* sign_typenr2name ( int  typenr)

Get the name of a sign by its typenr.

◆ sign_undefine_by_name()

int sign_undefine_by_name ( const char_u name)

Free the sign specified by 'name'.

◆ sign_undefine_multiple()

void sign_undefine_multiple ( list_T l,
list_T retlist 
)

Undefine multiple signs.

◆ sign_unplace()

int sign_unplace ( int  sign_id,
char_u sign_group,
buf_T buf,
linenr_T  atlnum 
)

Unplace the specified sign.

◆ sign_unplace_from_dict()

int sign_unplace_from_dict ( typval_T group_tv,
dict_T dict 
)

Unplace the sign with attributes specified in 'dict'. Returns 0 on success and -1 on failure.