vim-patch:8.1.2205: sign entry structure has confusing name (#14289)

Problem:    Sign entry structure has confusing name.
Solution:   Rename signlist_T to sign_entry_T and prefix se_ to the fields.
This commit is contained in:
Lewis Russell
2021-04-05 11:16:44 +01:00
committed by GitHub
parent 9b2d4ff625
commit 9fbeaf7771
6 changed files with 173 additions and 174 deletions

View File

@@ -5489,20 +5489,20 @@ bool find_win_for_buf(buf_T *buf, win_T **wp, tabpage_T **tp)
int buf_signcols(buf_T *buf) int buf_signcols(buf_T *buf)
{ {
if (buf->b_signcols_max == -1) { if (buf->b_signcols_max == -1) {
signlist_T *sign; // a sign in the signlist sign_entry_T *sign; // a sign in the sign list
buf->b_signcols_max = 0; buf->b_signcols_max = 0;
int linesum = 0; int linesum = 0;
linenr_T curline = 0; linenr_T curline = 0;
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->lnum > curline) { if (sign->se_lnum > curline) {
if (linesum > buf->b_signcols_max) { if (linesum > buf->b_signcols_max) {
buf->b_signcols_max = linesum; buf->b_signcols_max = linesum;
} }
curline = sign->lnum; curline = sign->se_lnum;
linesum = 0; linesum = 0;
} }
if (sign->has_text_or_icon) { if (sign->se_has_text_or_icon) {
linesum++; linesum++;
} }
} }

View File

@@ -110,7 +110,7 @@ typedef uint16_t disptick_T; // display tick type
#include "nvim/regexp_defs.h" #include "nvim/regexp_defs.h"
// for synstate_T (needs reg_extmatch_T, win_T, buf_T) // for synstate_T (needs reg_extmatch_T, win_T, buf_T)
#include "nvim/syntax_defs.h" #include "nvim/syntax_defs.h"
// for signlist_T // for sign_entry_T
#include "nvim/sign_defs.h" #include "nvim/sign_defs.h"
#include "nvim/os/fs_defs.h" // for FileID #include "nvim/os/fs_defs.h" // for FileID
@@ -848,7 +848,7 @@ struct file_buffer {
// normally points to this, but some windows // normally points to this, but some windows
// may use a different synblock_T. // may use a different synblock_T.
signlist_T *b_signlist; // list of signs to draw sign_entry_T *b_signlist; // list of placed signs
int b_signcols_max; // cached maximum number of sign columns int b_signcols_max; // cached maximum number of sign columns
int b_signcols; // last calculated number of sign columns int b_signcols; // last calculated number of sign columns

View File

@@ -469,7 +469,7 @@ EXTERN buf_T *curbuf INIT(= NULL); // currently active buffer
// Iterate through all the signs placed in a buffer // Iterate through all the signs placed in a buffer
#define FOR_ALL_SIGNS_IN_BUF(buf, sign) \ #define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
for (sign = buf->b_signlist; sign != NULL; sign = sign->next) // NOLINT for (sign = buf->b_signlist; sign != NULL; sign = sign->se_next) // NOLINT
// List of files being edited (global argument list). curwin->w_alist points // List of files being edited (global argument list). curwin->w_alist points

View File

@@ -2384,7 +2384,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
// TODO(bfredl, vigoux): this should not take priority over decoration! // TODO(bfredl, vigoux): this should not take priority over decoration!
sign_attrs_T * sattr = sign_get_attr(SIGN_LINEHL, sattrs, 0, 1); sign_attrs_T * sattr = sign_get_attr(SIGN_LINEHL, sattrs, 0, 1);
if (sattr != NULL) { if (sattr != NULL) {
line_attr = sattr->linehl; line_attr = sattr->sat_linehl;
} }
// Highlight the current line in the quickfix window. // Highlight the current line in the quickfix window.
@@ -2776,7 +2776,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
sign_attrs_T *num_sattr = sign_get_attr(SIGN_NUMHL, sattrs, 0, 1); sign_attrs_T *num_sattr = sign_get_attr(SIGN_NUMHL, sattrs, 0, 1);
if (num_sattr != NULL) { if (num_sattr != NULL) {
// :sign defined with "numhl" highlight. // :sign defined with "numhl" highlight.
char_attr = num_sattr->numhl; char_attr = num_sattr->sat_numhl;
} else if ((wp->w_p_cul || wp->w_p_rnu) } else if ((wp->w_p_cul || wp->w_p_rnu)
&& lnum == wp->w_cursor.lnum && lnum == wp->w_cursor.lnum
&& filler_todo == 0) { && filler_todo == 0) {
@@ -4485,7 +4485,7 @@ static void get_sign_display_info(
if (row == startrow + filler_lines && filler_todo <= 0) { if (row == startrow + filler_lines && filler_todo <= 0) {
sign_attrs_T *sattr = sign_get_attr(SIGN_TEXT, sattrs, *sign_idxp, count); sign_attrs_T *sattr = sign_get_attr(SIGN_TEXT, sattrs, *sign_idxp, count);
if (sattr != NULL) { if (sattr != NULL) {
*pp_extra = sattr->text; *pp_extra = sattr->sat_text;
if (*pp_extra != NULL) { if (*pp_extra != NULL) {
*c_extrap = NUL; *c_extrap = NUL;
*c_finalp = NUL; *c_finalp = NUL;
@@ -4518,7 +4518,7 @@ static void get_sign_display_info(
(*pp_extra)[*n_extrap] = NUL; (*pp_extra)[*n_extrap] = NUL;
} }
} }
*char_attrp = sattr->texthl; *char_attrp = sattr->sat_texthl;
} }
} }

View File

@@ -83,13 +83,13 @@ static signgroup_T * sign_group_ref(const char_u *groupname)
group = xmalloc((unsigned)(sizeof(signgroup_T) + STRLEN(groupname))); group = xmalloc((unsigned)(sizeof(signgroup_T) + STRLEN(groupname)));
STRCPY(group->sg_name, groupname); STRCPY(group->sg_name, groupname);
group->refcount = 1; group->sg_refcount = 1;
group->next_sign_id = 1; group->sg_next_sign_id = 1;
hash_add_item(&sg_table, hi, group->sg_name, hash); hash_add_item(&sg_table, hi, group->sg_name, hash);
} else { } else {
// existing group // existing group
group = HI2SG(hi); group = HI2SG(hi);
group->refcount++; group->sg_refcount++;
} }
return group; return group;
@@ -105,8 +105,8 @@ static void sign_group_unref(char_u *groupname)
hi = hash_find(&sg_table, groupname); hi = hash_find(&sg_table, groupname);
if (!HASHITEM_EMPTY(hi)) { if (!HASHITEM_EMPTY(hi)) {
group = HI2SG(hi); group = HI2SG(hi);
group->refcount--; group->sg_refcount--;
if (group->refcount == 0) { if (group->sg_refcount == 0) {
// All the signs in this group are removed // All the signs in this group are removed
hash_remove(&sg_table, hi); hash_remove(&sg_table, hi);
xfree(group); xfree(group);
@@ -117,12 +117,12 @@ static void sign_group_unref(char_u *groupname)
/// Returns TRUE if 'sign' is in 'group'. /// Returns TRUE if 'sign' is in 'group'.
/// A sign can either be in the global group (sign->group == NULL) /// 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. /// or in a named group. If 'group' is '*', then the sign is part of the group.
int sign_in_group(signlist_T *sign, const char_u *group) int sign_in_group(sign_entry_T *sign, const char_u *group)
{ {
return ((group != NULL && STRCMP(group, "*") == 0) return ((group != NULL && STRCMP(group, "*") == 0)
|| (group == NULL && sign->group == NULL) || (group == NULL && sign->se_group == NULL)
|| (group != NULL && sign->group != NULL || (group != NULL && sign->se_group != NULL
&& STRCMP(group, sign->group->sg_name) == 0)); && STRCMP(group, sign->se_group->sg_name) == 0));
} }
/// Get the next free sign identifier in the specified group /// Get the next free sign identifier in the specified group
@@ -130,7 +130,7 @@ int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
{ {
int id = 1; int id = 1;
signgroup_T *group = NULL; signgroup_T *group = NULL;
signlist_T *sign; sign_entry_T *sign;
hashitem_T *hi; hashitem_T *hi;
int found = false; int found = false;
@@ -147,13 +147,13 @@ int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
if (group == NULL) { if (group == NULL) {
id = next_sign_id++; // global group id = next_sign_id++; // global group
} else { } else {
id = group->next_sign_id++; id = group->sg_next_sign_id++;
} }
// Check whether this sign is already placed in the buffer // Check whether this sign is already placed in the buffer
found = true; found = true;
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (id == sign->id && sign_in_group(sign, groupname)) { if (id == sign->se_id && sign_in_group(sign, groupname)) {
found = false; // sign identifier is in use found = false; // sign identifier is in use
break; break;
} }
@@ -167,8 +167,8 @@ int sign_group_get_next_signid(buf_T *buf, const char_u *groupname)
/// 'next' signs. /// 'next' signs.
static void insert_sign( static void insert_sign(
buf_T *buf, // buffer to store sign in buf_T *buf, // buffer to store sign in
signlist_T *prev, // previous sign entry sign_entry_T *prev, // previous sign entry
signlist_T *next, // next sign entry sign_entry_T *next, // next sign entry
int id, // sign ID int id, // sign ID
const char_u *group, // sign group; NULL for global group const char_u *group, // sign group; NULL for global group
int prio, // sign priority int prio, // sign priority
@@ -177,21 +177,21 @@ static void insert_sign(
bool has_text_or_icon // sign has text or icon bool has_text_or_icon // sign has text or icon
) )
{ {
signlist_T *newsign = xmalloc(sizeof(signlist_T)); sign_entry_T *newsign = xmalloc(sizeof(sign_entry_T));
newsign->id = id; newsign->se_id = id;
newsign->lnum = lnum; newsign->se_lnum = lnum;
newsign->typenr = typenr; newsign->se_typenr = typenr;
newsign->has_text_or_icon = has_text_or_icon; newsign->se_has_text_or_icon = has_text_or_icon;
if (group != NULL) { if (group != NULL) {
newsign->group = sign_group_ref(group); newsign->se_group = sign_group_ref(group);
} else { } else {
newsign->group = NULL; newsign->se_group = NULL;
} }
newsign->priority = prio; newsign->se_priority = prio;
newsign->next = next; newsign->se_next = next;
newsign->prev = prev; newsign->se_prev = prev;
if (next != NULL) { if (next != NULL) {
next->prev = newsign; next->se_prev = newsign;
} }
buf->b_signcols_max = -1; buf->b_signcols_max = -1;
@@ -206,14 +206,14 @@ static void insert_sign(
// first sign in signlist // first sign in signlist
buf->b_signlist = newsign; buf->b_signlist = newsign;
} else { } else {
prev->next = newsign; prev->se_next = newsign;
} }
} }
/// Insert a new sign sorted by line number and sign priority. /// Insert a new sign sorted by line number and sign priority.
static void insert_sign_by_lnum_prio( static void insert_sign_by_lnum_prio(
buf_T *buf, // buffer to store sign in buf_T *buf, // buffer to store sign in
signlist_T *prev, // previous sign entry sign_entry_T *prev, // previous sign entry
int id, // sign ID int id, // sign ID
const char_u *group, // sign group; NULL for global group const char_u *group, // sign group; NULL for global group
int prio, // sign priority int prio, // sign priority
@@ -222,19 +222,19 @@ static void insert_sign_by_lnum_prio(
bool has_text_or_icon // sign has text or icon bool has_text_or_icon // sign has text or icon
) )
{ {
signlist_T *sign; sign_entry_T *sign;
// keep signs sorted by lnum, priority and id: insert new sign at // keep signs sorted by lnum, priority and id: insert new sign at
// the proper position in the list for this lnum. // the proper position in the list for this lnum.
while (prev != NULL && prev->lnum == lnum while (prev != NULL && prev->se_lnum == lnum
&& (prev->priority < prio && (prev->se_priority < prio
|| (prev->priority == prio && prev->id <= id))) { || (prev->se_priority == prio && prev->se_id <= id))) {
prev = prev->prev; prev = prev->se_prev;
} }
if (prev == NULL) { if (prev == NULL) {
sign = buf->b_signlist; sign = buf->b_signlist;
} else { } else {
sign = prev->next; sign = prev->se_next;
} }
insert_sign(buf, prev, sign, id, group, prio, lnum, typenr, has_text_or_icon); insert_sign(buf, prev, sign, id, group, prio, lnum, typenr, has_text_or_icon);
@@ -254,16 +254,16 @@ char_u * sign_typenr2name(int typenr)
} }
/// Return information about a sign in a Dict /// Return information about a sign in a Dict
dict_T * sign_get_info(signlist_T *sign) dict_T * sign_get_info(sign_entry_T *sign)
{ {
dict_T *d = tv_dict_alloc(); dict_T *d = tv_dict_alloc();
tv_dict_add_nr(d, S_LEN("id"), sign->id); tv_dict_add_nr(d, S_LEN("id"), sign->se_id);
tv_dict_add_str(d, S_LEN("group"), ((sign->group == NULL) tv_dict_add_str(d, S_LEN("group"), ((sign->se_group == NULL)
? (char *)"" ? (char *)""
: (char *)sign->group->sg_name)); : (char *)sign->se_group->sg_name));
tv_dict_add_nr(d, S_LEN("lnum"), sign->lnum); tv_dict_add_nr(d, S_LEN("lnum"), sign->se_lnum);
tv_dict_add_str(d, S_LEN("name"), (char *)sign_typenr2name(sign->typenr)); tv_dict_add_str(d, S_LEN("name"), (char *)sign_typenr2name(sign->se_typenr));
tv_dict_add_nr(d, S_LEN("priority"), sign->priority); tv_dict_add_nr(d, S_LEN("priority"), sign->se_priority);
return d; return d;
} }
@@ -271,17 +271,17 @@ dict_T * sign_get_info(signlist_T *sign)
// Sort the signs placed on the same line as "sign" by priority. Invoked after // Sort the signs placed on the same line as "sign" by priority. Invoked after
// changing the priority of an already placed sign. Assumes the signs in the // changing the priority of an already placed sign. Assumes the signs in the
// buffer are sorted by line number and priority. // buffer are sorted by line number and priority.
static void sign_sort_by_prio_on_line(buf_T *buf, signlist_T *sign) static void sign_sort_by_prio_on_line(buf_T *buf, sign_entry_T *sign)
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_ALL
{ {
// If there is only one sign in the buffer or only one sign on the line or // If there is only one sign in the buffer or only one sign on the line or
// the sign is already sorted by priority, then return. // the sign is already sorted by priority, then return.
if ((sign->prev == NULL if ((sign->se_prev == NULL
|| sign->prev->lnum != sign->lnum || sign->se_prev->se_lnum != sign->se_lnum
|| sign->prev->priority > sign->priority) || sign->se_prev->se_priority > sign->se_priority)
&& (sign->next == NULL && (sign->se_next == NULL
|| sign->next->lnum != sign->lnum || sign->se_next->se_lnum != sign->se_lnum
|| sign->next->priority < sign->priority)) { || sign->se_next->se_priority < sign->se_priority)) {
return; return;
} }
@@ -289,55 +289,55 @@ static void sign_sort_by_prio_on_line(buf_T *buf, signlist_T *sign)
// Find a sign after which 'sign' should be inserted // Find a sign after which 'sign' should be inserted
// First search backward for a sign with higher priority on the same line // First search backward for a sign with higher priority on the same line
signlist_T *p = sign; sign_entry_T *p = sign;
while (p->prev != NULL while (p->se_prev != NULL
&& p->prev->lnum == sign->lnum && p->se_prev->se_lnum == sign->se_lnum
&& p->prev->priority <= sign->priority) { && p->se_prev->se_priority <= sign->se_priority) {
p = p->prev; p = p->se_prev;
} }
if (p == sign) { if (p == sign) {
// Sign not found. Search forward for a sign with priority just before // Sign not found. Search forward for a sign with priority just before
// 'sign'. // 'sign'.
p = sign->next; p = sign->se_next;
while (p->next != NULL while (p->se_next != NULL
&& p->next->lnum == sign->lnum && p->se_next->se_lnum == sign->se_lnum
&& p->next->priority > sign->priority) { && p->se_next->se_priority > sign->se_priority) {
p = p->next; p = p->se_next;
} }
} }
// Remove 'sign' from the list // Remove 'sign' from the list
if (buf->b_signlist == sign) { if (buf->b_signlist == sign) {
buf->b_signlist = sign->next; buf->b_signlist = sign->se_next;
} }
if (sign->prev != NULL) { if (sign->se_prev != NULL) {
sign->prev->next = sign->next; sign->se_prev->se_next = sign->se_next;
} }
if (sign->next != NULL) { if (sign->se_next != NULL) {
sign->next->prev = sign->prev; sign->se_next->se_prev = sign->se_prev;
} }
sign->prev = NULL; sign->se_prev = NULL;
sign->next = NULL; sign->se_next = NULL;
// Re-insert 'sign' at the right place // Re-insert 'sign' at the right place
if (p->priority <= sign->priority) { if (p->se_priority <= sign->se_priority) {
// 'sign' has a higher priority and should be inserted before 'p' // 'sign' has a higher priority and should be inserted before 'p'
sign->prev = p->prev; sign->se_prev = p->se_prev;
sign->next = p; sign->se_next = p;
p->prev = sign; p->se_prev = sign;
if (sign->prev != NULL) { if (sign->se_prev != NULL) {
sign->prev->next = sign; sign->se_prev->se_next = sign;
} }
if (buf->b_signlist == p) { if (buf->b_signlist == p) {
buf->b_signlist = sign; buf->b_signlist = sign;
} }
} else { } else {
// 'sign' has a lower priority and should be inserted after 'p' // 'sign' has a lower priority and should be inserted after 'p'
sign->prev = p; sign->se_prev = p;
sign->next = p->next; sign->se_next = p->se_next;
p->next = sign; p->se_next = sign;
if (sign->next != NULL) { if (sign->se_next != NULL) {
sign->next->prev = sign; sign->se_next->se_prev = sign;
} }
} }
} }
@@ -354,19 +354,19 @@ void buf_addsign(
bool has_text_or_icon // sign has text or icon bool has_text_or_icon // sign has text or icon
) )
{ {
signlist_T *sign; // a sign in the signlist sign_entry_T *sign; // a sign in the signlist
signlist_T *prev; // the previous sign sign_entry_T *prev; // the previous sign
prev = NULL; prev = NULL;
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (lnum == sign->lnum && id == sign->id if (lnum == sign->se_lnum && id == sign->se_id
&& sign_in_group(sign, groupname)) { && sign_in_group(sign, groupname)) {
// Update an existing sign // Update an existing sign
sign->typenr = typenr; sign->se_typenr = typenr;
sign->priority = prio; sign->se_priority = prio;
sign_sort_by_prio_on_line(buf, sign); sign_sort_by_prio_on_line(buf, sign);
return; return;
} else if (lnum < sign->lnum) { } else if (lnum < sign->se_lnum) {
insert_sign_by_lnum_prio( insert_sign_by_lnum_prio(
buf, buf,
prev, prev,
@@ -402,14 +402,14 @@ linenr_T buf_change_sign_type(
int prio // sign priority int prio // sign priority
) )
{ {
signlist_T *sign; // a sign in the signlist sign_entry_T *sign; // a sign in the signlist
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->id == markId && sign_in_group(sign, group)) { if (sign->se_id == markId && sign_in_group(sign, group)) {
sign->typenr = typenr; sign->se_typenr = typenr;
sign->priority = prio; sign->se_priority = prio;
sign_sort_by_prio_on_line(buf, sign); sign_sort_by_prio_on_line(buf, sign);
return sign->lnum; return sign->se_lnum;
} }
} }
@@ -432,9 +432,9 @@ sign_attrs_T * sign_get_attr(SignType type, sign_attrs_T sattrs[],
int nr_matches = 0; int nr_matches = 0;
for (int i = 0; i < SIGN_SHOW_MAX; i++) { for (int i = 0; i < SIGN_SHOW_MAX; i++) {
if ( (type == SIGN_TEXT && sattrs[i].text != NULL) if ( (type == SIGN_TEXT && sattrs[i].sat_text != NULL)
|| (type == SIGN_LINEHL && sattrs[i].linehl != 0) || (type == SIGN_LINEHL && sattrs[i].sat_linehl != 0)
|| (type == SIGN_NUMHL && sattrs[i].numhl != 0)) { || (type == SIGN_NUMHL && sattrs[i].sat_numhl != 0)) {
matches[nr_matches] = &sattrs[i]; matches[nr_matches] = &sattrs[i];
nr_matches++; nr_matches++;
// attr list is sorted with most important (priority, id), thus we // attr list is sorted with most important (priority, id), thus we
@@ -473,33 +473,33 @@ static sign_T * find_sign_by_typenr(int typenr)
/// @return Number of signs of which attrs were found /// @return Number of signs of which attrs were found
int buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T sattrs[]) int buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T sattrs[])
{ {
signlist_T *sign; sign_entry_T *sign;
sign_T *sp; sign_T *sp;
int nr_matches = 0; int nr_matches = 0;
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->lnum > lnum) { if (sign->se_lnum > lnum) {
// Signs are sorted by line number in the buffer. No need to check // Signs are sorted by line number in the buffer. No need to check
// for signs after the specified line number 'lnum'. // for signs after the specified line number 'lnum'.
break; break;
} }
if (sign->lnum == lnum) { if (sign->se_lnum == lnum) {
sign_attrs_T sattr; sign_attrs_T sattr;
memset(&sattr, 0, sizeof(sattr)); memset(&sattr, 0, sizeof(sattr));
sattr.typenr = sign->typenr; sattr.sat_typenr = sign->se_typenr;
sp = find_sign_by_typenr(sign->typenr); sp = find_sign_by_typenr(sign->se_typenr);
if (sp != NULL) { if (sp != NULL) {
sattr.text = sp->sn_text; sattr.sat_text = sp->sn_text;
if (sattr.text != NULL && sp->sn_text_hl != 0) { if (sattr.sat_text != NULL && sp->sn_text_hl != 0) {
sattr.texthl = syn_id2attr(sp->sn_text_hl); sattr.sat_texthl = syn_id2attr(sp->sn_text_hl);
} }
if (sp->sn_line_hl != 0) { if (sp->sn_line_hl != 0) {
sattr.linehl = syn_id2attr(sp->sn_line_hl); sattr.sat_linehl = syn_id2attr(sp->sn_line_hl);
} }
if (sp->sn_num_hl != 0) { if (sp->sn_num_hl != 0) {
sattr.numhl = syn_id2attr(sp->sn_num_hl); sattr.sat_numhl = syn_id2attr(sp->sn_num_hl);
} }
} }
@@ -528,26 +528,26 @@ linenr_T buf_delsign(
char_u *group // sign group char_u *group // sign group
) )
{ {
signlist_T **lastp; // pointer to pointer to current sign sign_entry_T **lastp; // pointer to pointer to current sign
signlist_T *sign; // a sign in a b_signlist sign_entry_T *sign; // a sign in a b_signlist
signlist_T *next; // the next sign in a b_signlist sign_entry_T *next; // the next sign in a b_signlist
linenr_T lnum; // line number whose sign was deleted linenr_T lnum; // line number whose sign was deleted
buf->b_signcols_max = -1; buf->b_signcols_max = -1;
lastp = &buf->b_signlist; lastp = &buf->b_signlist;
lnum = 0; lnum = 0;
for (sign = buf->b_signlist; sign != NULL; sign = next) { for (sign = buf->b_signlist; sign != NULL; sign = next) {
next = sign->next; next = sign->se_next;
if ((id == 0 || sign->id == id) if ((id == 0 || sign->se_id == id)
&& (atlnum == 0 || sign->lnum == atlnum) && (atlnum == 0 || sign->se_lnum == atlnum)
&& sign_in_group(sign, group)) { && sign_in_group(sign, group)) {
*lastp = next; *lastp = next;
if (next != NULL) { if (next != NULL) {
next->prev = sign->prev; next->se_prev = sign->se_prev;
} }
lnum = sign->lnum; lnum = sign->se_lnum;
if (sign->group != NULL) { if (sign->se_group != NULL) {
sign_group_unref(sign->group->sg_name); sign_group_unref(sign->se_group->sg_name);
} }
xfree(sign); xfree(sign);
redraw_buf_line_later(buf, lnum); redraw_buf_line_later(buf, lnum);
@@ -561,7 +561,7 @@ linenr_T buf_delsign(
break; break;
} }
} else { } else {
lastp = &sign->next; lastp = &sign->se_next;
} }
} }
@@ -585,11 +585,11 @@ int buf_findsign(
char_u *group // sign group char_u *group // sign group
) )
{ {
signlist_T *sign; // a sign in the signlist sign_entry_T *sign; // a sign in the signlist
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->id == id && sign_in_group(sign, group)) { if (sign->se_id == id && sign_in_group(sign, group)) {
return (int)sign->lnum; return (int)sign->se_lnum;
} }
} }
@@ -598,22 +598,22 @@ int buf_findsign(
/// Return the sign at line 'lnum' in buffer 'buf'. Returns NULL if a sign is /// Return the sign at line 'lnum' in buffer 'buf'. Returns NULL if a sign is
/// not found at the line. If 'groupname' is NULL, searches in the global group. /// not found at the line. If 'groupname' is NULL, searches in the global group.
static signlist_T * buf_getsign_at_line( static sign_entry_T * buf_getsign_at_line(
buf_T *buf, // buffer whose sign we are searching for buf_T *buf, // buffer whose sign we are searching for
linenr_T lnum, // line number of sign linenr_T lnum, // line number of sign
char_u *groupname // sign group name char_u *groupname // sign group name
) )
{ {
signlist_T *sign; // a sign in the signlist sign_entry_T *sign; // a sign in the signlist
FOR_ALL_SIGNS_IN_BUF(buf, sign) { FOR_ALL_SIGNS_IN_BUF(buf, sign) {
if (sign->lnum > lnum) { if (sign->se_lnum > lnum) {
// Signs are sorted by line number in the buffer. No need to check // Signs are sorted by line number in the buffer. No need to check
// for signs after the specified line number 'lnum'. // for signs after the specified line number 'lnum'.
break; break;
} }
if (sign->lnum == lnum && sign_in_group(sign, groupname)) { if (sign->se_lnum == lnum && sign_in_group(sign, groupname)) {
return sign; return sign;
} }
} }
@@ -628,11 +628,11 @@ int buf_findsign_id(
char_u *groupname // sign group name char_u *groupname // sign group name
) )
{ {
signlist_T *sign; // a sign in the signlist sign_entry_T *sign; // a sign in the signlist
sign = buf_getsign_at_line(buf, lnum, groupname); sign = buf_getsign_at_line(buf, lnum, groupname);
if (sign != NULL) { if (sign != NULL) {
return sign->id; return sign->se_id;
} }
return 0; return 0;
@@ -641,9 +641,9 @@ int buf_findsign_id(
/// Delete signs in buffer "buf". /// Delete signs in buffer "buf".
void buf_delete_signs(buf_T *buf, char_u *group) void buf_delete_signs(buf_T *buf, char_u *group)
{ {
signlist_T *sign; sign_entry_T *sign;
signlist_T **lastp; // pointer to pointer to current sign sign_entry_T **lastp; // pointer to pointer to current sign
signlist_T *next; sign_entry_T *next;
// When deleting the last sign need to redraw the windows to remove the // When deleting the last sign need to redraw the windows to remove the
// sign column. Not when curwin is NULL (this means we're exiting). // sign column. Not when curwin is NULL (this means we're exiting).
@@ -653,18 +653,18 @@ void buf_delete_signs(buf_T *buf, char_u *group)
lastp = &buf->b_signlist; lastp = &buf->b_signlist;
for (sign = buf->b_signlist; sign != NULL; sign = next) { for (sign = buf->b_signlist; sign != NULL; sign = next) {
next = sign->next; next = sign->se_next;
if (sign_in_group(sign, group)) { if (sign_in_group(sign, group)) {
*lastp = next; *lastp = next;
if (next != NULL) { if (next != NULL) {
next->prev = sign->prev; next->se_prev = sign->se_prev;
} }
if (sign->group != NULL) { if (sign->se_group != NULL) {
sign_group_unref(sign->group->sg_name); sign_group_unref(sign->se_group->sg_name);
} }
xfree(sign); xfree(sign);
} else { } else {
lastp = &sign->next; lastp = &sign->se_next;
} }
} }
buf->b_signcols_max = -1; buf->b_signcols_max = -1;
@@ -674,7 +674,7 @@ void buf_delete_signs(buf_T *buf, char_u *group)
void sign_list_placed(buf_T *rbuf, char_u *sign_group) void sign_list_placed(buf_T *rbuf, char_u *sign_group)
{ {
buf_T *buf; buf_T *buf;
signlist_T *sign; sign_entry_T *sign;
char lbuf[MSG_BUF_LEN]; char lbuf[MSG_BUF_LEN];
char group[MSG_BUF_LEN]; char group[MSG_BUF_LEN];
@@ -698,16 +698,16 @@ void sign_list_placed(buf_T *rbuf, char_u *sign_group)
if (!sign_in_group(sign, sign_group)) { if (!sign_in_group(sign, sign_group)) {
continue; continue;
} }
if (sign->group != NULL) { if (sign->se_group != NULL) {
vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"), vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"),
sign->group->sg_name); sign->se_group->sg_name);
} else { } else {
group[0] = '\0'; group[0] = '\0';
} }
vim_snprintf(lbuf, MSG_BUF_LEN, vim_snprintf(lbuf, MSG_BUF_LEN,
_(" line=%ld id=%d%s name=%s priority=%d"), _(" line=%ld id=%d%s name=%s priority=%d"),
(long)sign->lnum, sign->id, group, (long)sign->se_lnum, sign->se_id, group,
sign_typenr2name(sign->typenr), sign->priority); sign_typenr2name(sign->se_typenr), sign->se_priority);
MSG_PUTS(lbuf); MSG_PUTS(lbuf);
msg_putchar('\n'); msg_putchar('\n');
} }
@@ -726,25 +726,25 @@ void sign_mark_adjust(
long amount_after long amount_after
) )
{ {
signlist_T *sign; // a sign in a b_signlist sign_entry_T *sign; // a sign in a b_signlist
linenr_T new_lnum; // new line number to assign to sign linenr_T new_lnum; // new line number to assign to sign
curbuf->b_signcols_max = -1; curbuf->b_signcols_max = -1;
FOR_ALL_SIGNS_IN_BUF(curbuf, sign) { FOR_ALL_SIGNS_IN_BUF(curbuf, sign) {
new_lnum = sign->lnum; new_lnum = sign->se_lnum;
if (sign->lnum >= line1 && sign->lnum <= line2) { if (sign->se_lnum >= line1 && sign->se_lnum <= line2) {
if (amount != MAXLNUM) { if (amount != MAXLNUM) {
new_lnum += amount; new_lnum += amount;
} }
} else if (sign->lnum > line2) { } else if (sign->se_lnum > line2) {
new_lnum += amount_after; new_lnum += amount_after;
} }
// If the new sign line number is past the last line in the buffer, // If the new sign line number is past the last line in the buffer,
// then don't adjust the line number. Otherwise, it will always be past // then don't adjust the line number. Otherwise, it will always be past
// the last line and will not be visible. // the last line and will not be visible.
if (sign->lnum >= line1 && new_lnum <= curbuf->b_ml.ml_line_count) { if (sign->se_lnum >= line1 && new_lnum <= curbuf->b_ml.ml_line_count) {
sign->lnum = new_lnum; sign->se_lnum = new_lnum;
} }
} }
} }
@@ -1544,7 +1544,7 @@ void sign_getlist(const char_u *name, list_T *retlist)
list_T *get_buffer_signs(buf_T *buf) list_T *get_buffer_signs(buf_T *buf)
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
{ {
signlist_T *sign; sign_entry_T *sign;
dict_T *d; dict_T *d;
list_T *const l = tv_list_alloc(kListLenMayKnow); list_T *const l = tv_list_alloc(kListLenMayKnow);
@@ -1565,7 +1565,7 @@ static void sign_get_placed_in_buf(
{ {
dict_T *d; dict_T *d;
list_T *l; list_T *l;
signlist_T *sign; sign_entry_T *sign;
d = tv_dict_alloc(); d = tv_dict_alloc();
tv_list_append_dict(retlist, d); tv_list_append_dict(retlist, d);
@@ -1580,9 +1580,9 @@ static void sign_get_placed_in_buf(
continue; continue;
} }
if ((lnum == 0 && sign_id == 0) if ((lnum == 0 && sign_id == 0)
|| (sign_id == 0 && lnum == sign->lnum) || (sign_id == 0 && lnum == sign->se_lnum)
|| (lnum == 0 && sign_id == sign->id) || (lnum == 0 && sign_id == sign->se_id)
|| (lnum == sign->lnum && sign_id == sign->id)) { || (lnum == sign->se_lnum && sign_id == sign->se_id)) {
tv_list_append_dict(l, sign_get_info(sign)); tv_list_append_dict(l, sign_get_info(sign));
} }
} }

View File

@@ -10,8 +10,8 @@
// Sign group // Sign group
typedef struct signgroup_S typedef struct signgroup_S
{ {
uint16_t refcount; // number of signs in this group uint16_t sg_refcount; // number of signs in this group
int next_sign_id; // next sign id for this group int sg_next_sign_id; // next sign id for this group
char_u sg_name[1]; // sign group name char_u sg_name[1]; // sign group name
} signgroup_T; } signgroup_T;
@@ -19,27 +19,26 @@ typedef struct signgroup_S
#define SGN_KEY_OFF offsetof(signgroup_T, sg_name) #define SGN_KEY_OFF offsetof(signgroup_T, sg_name)
#define HI2SG(hi) ((signgroup_T *)((hi)->hi_key - SGN_KEY_OFF)) #define HI2SG(hi) ((signgroup_T *)((hi)->hi_key - SGN_KEY_OFF))
typedef struct signlist signlist_T; typedef struct sign_entry sign_entry_T;
struct signlist struct sign_entry {
{ int se_id; // unique identifier for each placed sign
int id; // unique identifier for each placed sign int se_typenr; // typenr of sign
int typenr; // typenr of sign int se_priority; // priority for highlighting
int priority; // priority for highlighting bool se_has_text_or_icon; // has text or icon
bool has_text_or_icon; // has text or icon linenr_T se_lnum; // line number which has this sign
linenr_T lnum; // line number which has this sign signgroup_T *se_group; // sign group
signgroup_T *group; // sign group sign_entry_T *se_next; // next entry in a list of signs
signlist_T *next; // next signlist entry sign_entry_T *se_prev; // previous entry -- for easy reordering
signlist_T *prev; // previous entry -- for easy reordering
}; };
/// Sign attributes. Used by the screen refresh routines. /// Sign attributes. Used by the screen refresh routines.
typedef struct sign_attrs_S { typedef struct sign_attrs_S {
int typenr; int sat_typenr;
char_u *text; char_u *sat_text;
int texthl; int sat_texthl;
int linehl; int sat_linehl;
int numhl; int sat_numhl;
} sign_attrs_T; } sign_attrs_T;
#define SIGN_SHOW_MAX 9 #define SIGN_SHOW_MAX 9