Mercurial > vim
comparison src/sign.c @ 18422:1848b3e07266 v8.1.2205
patch 8.1.2205: sign entry structure has confusing name
Commit: https://github.com/vim/vim/commit/6656c2ec4cc2163cd0a51d617f429ad7fb46d2d5
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Oct 24 15:00:04 2019 +0200
patch 8.1.2205: sign entry structure has confusing name
Problem: Sign entry structure has confusing name.
Solution: Rename signlist_T to sign_entry_T and prefix se_ to the fields.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 24 Oct 2019 15:15:04 +0200 |
parents | 313f498c646e |
children | f249b44039e0 |
comparison
equal
deleted
inserted
replaced
18421:bf9c90b6a79b | 18422:1848b3e07266 |
---|---|
87 // new group | 87 // new group |
88 group = alloc(offsetof(signgroup_T, sg_name) + STRLEN(groupname) + 1); | 88 group = alloc(offsetof(signgroup_T, sg_name) + STRLEN(groupname) + 1); |
89 if (group == NULL) | 89 if (group == NULL) |
90 return NULL; | 90 return NULL; |
91 STRCPY(group->sg_name, groupname); | 91 STRCPY(group->sg_name, groupname); |
92 group->refcount = 1; | 92 group->sg_refcount = 1; |
93 group->next_sign_id = 1; | 93 group->sg_next_sign_id = 1; |
94 hash_add_item(&sg_table, hi, group->sg_name, hash); | 94 hash_add_item(&sg_table, hi, group->sg_name, hash); |
95 } | 95 } |
96 else | 96 else |
97 { | 97 { |
98 // existing group | 98 // existing group |
99 group = HI2SG(hi); | 99 group = HI2SG(hi); |
100 group->refcount++; | 100 group->sg_refcount++; |
101 } | 101 } |
102 | 102 |
103 return group; | 103 return group; |
104 } | 104 } |
105 | 105 |
115 | 115 |
116 hi = hash_find(&sg_table, groupname); | 116 hi = hash_find(&sg_table, groupname); |
117 if (!HASHITEM_EMPTY(hi)) | 117 if (!HASHITEM_EMPTY(hi)) |
118 { | 118 { |
119 group = HI2SG(hi); | 119 group = HI2SG(hi); |
120 group->refcount--; | 120 group->sg_refcount--; |
121 if (group->refcount == 0) | 121 if (group->sg_refcount == 0) |
122 { | 122 { |
123 // All the signs in this group are removed | 123 // All the signs in this group are removed |
124 hash_remove(&sg_table, hi); | 124 hash_remove(&sg_table, hi); |
125 vim_free(group); | 125 vim_free(group); |
126 } | 126 } |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 /* | 130 /* |
131 * Returns TRUE if 'sign' is in 'group'. | 131 * Returns TRUE if 'sign' is in 'group'. |
132 * A sign can either be in the global group (sign->group == NULL) | 132 * A sign can either be in the global group (sign->se_group == NULL) |
133 * or in a named group. If 'group' is '*', then the sign is part of the group. | 133 * or in a named group. If 'group' is '*', then the sign is part of the group. |
134 */ | 134 */ |
135 static int | 135 static int |
136 sign_in_group(signlist_T *sign, char_u *group) | 136 sign_in_group(sign_entry_T *sign, char_u *group) |
137 { | 137 { |
138 return ((group != NULL && STRCMP(group, "*") == 0) | 138 return ((group != NULL && STRCMP(group, "*") == 0) |
139 || (group == NULL && sign->group == NULL) | 139 || (group == NULL && sign->se_group == NULL) |
140 || (group != NULL && sign->group != NULL | 140 || (group != NULL && sign->se_group != NULL |
141 && STRCMP(group, sign->group->sg_name) == 0)); | 141 && STRCMP(group, sign->se_group->sg_name) == 0)); |
142 } | 142 } |
143 | 143 |
144 /* | 144 /* |
145 * Get the next free sign identifier in the specified group | 145 * Get the next free sign identifier in the specified group |
146 */ | 146 */ |
147 static int | 147 static int |
148 sign_group_get_next_signid(buf_T *buf, char_u *groupname) | 148 sign_group_get_next_signid(buf_T *buf, char_u *groupname) |
149 { | 149 { |
150 int id = 1; | 150 int id = 1; |
151 signgroup_T *group = NULL; | 151 signgroup_T *group = NULL; |
152 signlist_T *sign; | 152 sign_entry_T *sign; |
153 hashitem_T *hi; | 153 hashitem_T *hi; |
154 int found = FALSE; | 154 int found = FALSE; |
155 | 155 |
156 if (groupname != NULL) | 156 if (groupname != NULL) |
157 { | 157 { |
165 while (!found) | 165 while (!found) |
166 { | 166 { |
167 if (group == NULL) | 167 if (group == NULL) |
168 id = next_sign_id++; // global group | 168 id = next_sign_id++; // global group |
169 else | 169 else |
170 id = group->next_sign_id++; | 170 id = group->sg_next_sign_id++; |
171 | 171 |
172 // Check whether this sign is already placed in the buffer | 172 // Check whether this sign is already placed in the buffer |
173 found = TRUE; | 173 found = TRUE; |
174 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 174 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
175 { | 175 { |
176 if (id == sign->id && sign_in_group(sign, groupname)) | 176 if (id == sign->se_id && sign_in_group(sign, groupname)) |
177 { | 177 { |
178 found = FALSE; // sign identifier is in use | 178 found = FALSE; // sign identifier is in use |
179 break; | 179 break; |
180 } | 180 } |
181 } | 181 } |
189 * 'next' signs. | 189 * 'next' signs. |
190 */ | 190 */ |
191 static void | 191 static void |
192 insert_sign( | 192 insert_sign( |
193 buf_T *buf, // buffer to store sign in | 193 buf_T *buf, // buffer to store sign in |
194 signlist_T *prev, // previous sign entry | 194 sign_entry_T *prev, // previous sign entry |
195 signlist_T *next, // next sign entry | 195 sign_entry_T *next, // next sign entry |
196 int id, // sign ID | 196 int id, // sign ID |
197 char_u *group, // sign group; NULL for global group | 197 char_u *group, // sign group; NULL for global group |
198 int prio, // sign priority | 198 int prio, // sign priority |
199 linenr_T lnum, // line number which gets the mark | 199 linenr_T lnum, // line number which gets the mark |
200 int typenr) // typenr of sign we are adding | 200 int typenr) // typenr of sign we are adding |
201 { | 201 { |
202 signlist_T *newsign; | 202 sign_entry_T *newsign; |
203 | 203 |
204 newsign = lalloc_id(sizeof(signlist_T), FALSE, aid_insert_sign); | 204 newsign = lalloc_id(sizeof(sign_entry_T), FALSE, aid_insert_sign); |
205 if (newsign != NULL) | 205 if (newsign != NULL) |
206 { | 206 { |
207 newsign->id = id; | 207 newsign->se_id = id; |
208 newsign->lnum = lnum; | 208 newsign->se_lnum = lnum; |
209 newsign->typenr = typenr; | 209 newsign->se_typenr = typenr; |
210 if (group != NULL) | 210 if (group != NULL) |
211 { | 211 { |
212 newsign->group = sign_group_ref(group); | 212 newsign->se_group = sign_group_ref(group); |
213 if (newsign->group == NULL) | 213 if (newsign->se_group == NULL) |
214 { | 214 { |
215 vim_free(newsign); | 215 vim_free(newsign); |
216 return; | 216 return; |
217 } | 217 } |
218 } | 218 } |
219 else | 219 else |
220 newsign->group = NULL; | 220 newsign->se_group = NULL; |
221 newsign->priority = prio; | 221 newsign->se_priority = prio; |
222 newsign->next = next; | 222 newsign->se_next = next; |
223 newsign->prev = prev; | 223 newsign->se_prev = prev; |
224 if (next != NULL) | 224 if (next != NULL) |
225 next->prev = newsign; | 225 next->se_prev = newsign; |
226 | 226 |
227 if (prev == NULL) | 227 if (prev == NULL) |
228 { | 228 { |
229 // When adding first sign need to redraw the windows to create the | 229 // When adding first sign need to redraw the windows to create the |
230 // column for signs. | 230 // column for signs. |
240 if (netbeans_active()) | 240 if (netbeans_active()) |
241 buf->b_has_sign_column = TRUE; | 241 buf->b_has_sign_column = TRUE; |
242 #endif | 242 #endif |
243 } | 243 } |
244 else | 244 else |
245 prev->next = newsign; | 245 prev->se_next = newsign; |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 /* | 249 /* |
250 * Insert a new sign sorted by line number and sign priority. | 250 * Insert a new sign sorted by line number and sign priority. |
251 */ | 251 */ |
252 static void | 252 static void |
253 insert_sign_by_lnum_prio( | 253 insert_sign_by_lnum_prio( |
254 buf_T *buf, // buffer to store sign in | 254 buf_T *buf, // buffer to store sign in |
255 signlist_T *prev, // previous sign entry | 255 sign_entry_T *prev, // previous sign entry |
256 int id, // sign ID | 256 int id, // sign ID |
257 char_u *group, // sign group; NULL for global group | 257 char_u *group, // sign group; NULL for global group |
258 int prio, // sign priority | 258 int prio, // sign priority |
259 linenr_T lnum, // line number which gets the mark | 259 linenr_T lnum, // line number which gets the mark |
260 int typenr) // typenr of sign we are adding | 260 int typenr) // typenr of sign we are adding |
261 { | 261 { |
262 signlist_T *sign; | 262 sign_entry_T *sign; |
263 | 263 |
264 // keep signs sorted by lnum and by priority: insert new sign at | 264 // keep signs sorted by lnum and by priority: insert new sign at |
265 // the proper position in the list for this lnum. | 265 // the proper position in the list for this lnum. |
266 while (prev != NULL && prev->lnum == lnum && prev->priority <= prio) | 266 while (prev != NULL && prev->se_lnum == lnum && prev->se_priority <= prio) |
267 prev = prev->prev; | 267 prev = prev->se_prev; |
268 if (prev == NULL) | 268 if (prev == NULL) |
269 sign = buf->b_signlist; | 269 sign = buf->b_signlist; |
270 else | 270 else |
271 sign = prev->next; | 271 sign = prev->se_next; |
272 | 272 |
273 insert_sign(buf, prev, sign, id, group, prio, lnum, typenr); | 273 insert_sign(buf, prev, sign, id, group, prio, lnum, typenr); |
274 } | 274 } |
275 | 275 |
276 /* | 276 /* |
303 | 303 |
304 /* | 304 /* |
305 * Return information about a sign in a Dict | 305 * Return information about a sign in a Dict |
306 */ | 306 */ |
307 static dict_T * | 307 static dict_T * |
308 sign_get_info(signlist_T *sign) | 308 sign_get_info(sign_entry_T *sign) |
309 { | 309 { |
310 dict_T *d; | 310 dict_T *d; |
311 | 311 |
312 if ((d = dict_alloc_id(aid_sign_getinfo)) == NULL) | 312 if ((d = dict_alloc_id(aid_sign_getinfo)) == NULL) |
313 return NULL; | 313 return NULL; |
314 dict_add_number(d, "id", sign->id); | 314 dict_add_number(d, "id", sign->se_id); |
315 dict_add_string(d, "group", (sign->group == NULL) ? | 315 dict_add_string(d, "group", (sign->se_group == NULL) ? |
316 (char_u *)"" : sign->group->sg_name); | 316 (char_u *)"" : sign->se_group->sg_name); |
317 dict_add_number(d, "lnum", sign->lnum); | 317 dict_add_number(d, "lnum", sign->se_lnum); |
318 dict_add_string(d, "name", sign_typenr2name(sign->typenr)); | 318 dict_add_string(d, "name", sign_typenr2name(sign->se_typenr)); |
319 dict_add_number(d, "priority", sign->priority); | 319 dict_add_number(d, "priority", sign->se_priority); |
320 | 320 |
321 return d; | 321 return d; |
322 } | 322 } |
323 | 323 |
324 /* | 324 /* |
325 * Sort the signs placed on the same line as "sign" by priority. Invoked after | 325 * Sort the signs placed on the same line as "sign" by priority. Invoked after |
326 * changing the priority of an already placed sign. Assumes the signs in the | 326 * changing the priority of an already placed sign. Assumes the signs in the |
327 * buffer are sorted by line number and priority. | 327 * buffer are sorted by line number and priority. |
328 */ | 328 */ |
329 static void | 329 static void |
330 sign_sort_by_prio_on_line(buf_T *buf, signlist_T *sign) | 330 sign_sort_by_prio_on_line(buf_T *buf, sign_entry_T *sign) |
331 { | 331 { |
332 signlist_T *p = NULL; | 332 sign_entry_T *p = NULL; |
333 | 333 |
334 // If there is only one sign in the buffer or only one sign on the line or | 334 // If there is only one sign in the buffer or only one sign on the line or |
335 // the sign is already sorted by priority, then return. | 335 // the sign is already sorted by priority, then return. |
336 if ((sign->prev == NULL | 336 if ((sign->se_prev == NULL |
337 || sign->prev->lnum != sign->lnum | 337 || sign->se_prev->se_lnum != sign->se_lnum |
338 || sign->prev->priority > sign->priority) | 338 || sign->se_prev->se_priority > sign->se_priority) |
339 && (sign->next == NULL | 339 && (sign->se_next == NULL |
340 || sign->next->lnum != sign->lnum | 340 || sign->se_next->se_lnum != sign->se_lnum |
341 || sign->next->priority < sign->priority)) | 341 || sign->se_next->se_priority < sign->se_priority)) |
342 return; | 342 return; |
343 | 343 |
344 // One or more signs on the same line as 'sign' | 344 // One or more signs on the same line as 'sign' |
345 // Find a sign after which 'sign' should be inserted | 345 // Find a sign after which 'sign' should be inserted |
346 | 346 |
347 // First search backward for a sign with higher priority on the same line | 347 // First search backward for a sign with higher priority on the same line |
348 p = sign; | 348 p = sign; |
349 while (p->prev != NULL && p->prev->lnum == sign->lnum | 349 while (p->se_prev != NULL && p->se_prev->se_lnum == sign->se_lnum |
350 && p->prev->priority <= sign->priority) | 350 && p->se_prev->se_priority <= sign->se_priority) |
351 p = p->prev; | 351 p = p->se_prev; |
352 | 352 |
353 if (p == sign) | 353 if (p == sign) |
354 { | 354 { |
355 // Sign not found. Search forward for a sign with priority just before | 355 // Sign not found. Search forward for a sign with priority just before |
356 // 'sign'. | 356 // 'sign'. |
357 p = sign->next; | 357 p = sign->se_next; |
358 while (p->next != NULL && p->next->lnum == sign->lnum | 358 while (p->se_next != NULL && p->se_next->se_lnum == sign->se_lnum |
359 && p->next->priority > sign->priority) | 359 && p->se_next->se_priority > sign->se_priority) |
360 p = p->next; | 360 p = p->se_next; |
361 } | 361 } |
362 | 362 |
363 // Remove 'sign' from the list | 363 // Remove 'sign' from the list |
364 if (buf->b_signlist == sign) | 364 if (buf->b_signlist == sign) |
365 buf->b_signlist = sign->next; | 365 buf->b_signlist = sign->se_next; |
366 if (sign->prev != NULL) | 366 if (sign->se_prev != NULL) |
367 sign->prev->next = sign->next; | 367 sign->se_prev->se_next = sign->se_next; |
368 if (sign->next != NULL) | 368 if (sign->se_next != NULL) |
369 sign->next->prev = sign->prev; | 369 sign->se_next->se_prev = sign->se_prev; |
370 sign->prev = NULL; | 370 sign->se_prev = NULL; |
371 sign->next = NULL; | 371 sign->se_next = NULL; |
372 | 372 |
373 // Re-insert 'sign' at the right place | 373 // Re-insert 'sign' at the right place |
374 if (p->priority <= sign->priority) | 374 if (p->se_priority <= sign->se_priority) |
375 { | 375 { |
376 // 'sign' has a higher priority and should be inserted before 'p' | 376 // 'sign' has a higher priority and should be inserted before 'p' |
377 sign->prev = p->prev; | 377 sign->se_prev = p->se_prev; |
378 sign->next = p; | 378 sign->se_next = p; |
379 p->prev = sign; | 379 p->se_prev = sign; |
380 if (sign->prev != NULL) | 380 if (sign->se_prev != NULL) |
381 sign->prev->next = sign; | 381 sign->se_prev->se_next = sign; |
382 if (buf->b_signlist == p) | 382 if (buf->b_signlist == p) |
383 buf->b_signlist = sign; | 383 buf->b_signlist = sign; |
384 } | 384 } |
385 else | 385 else |
386 { | 386 { |
387 // 'sign' has a lower priority and should be inserted after 'p' | 387 // 'sign' has a lower priority and should be inserted after 'p' |
388 sign->prev = p; | 388 sign->se_prev = p; |
389 sign->next = p->next; | 389 sign->se_next = p->se_next; |
390 p->next = sign; | 390 p->se_next = sign; |
391 if (sign->next != NULL) | 391 if (sign->se_next != NULL) |
392 sign->next->prev = sign; | 392 sign->se_next->se_prev = sign; |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 /* | 396 /* |
397 * Add the sign into the signlist. Find the right spot to do it though. | 397 * Add the sign into the signlist. Find the right spot to do it though. |
403 char_u *groupname, // sign group | 403 char_u *groupname, // sign group |
404 int prio, // sign priority | 404 int prio, // sign priority |
405 linenr_T lnum, // line number which gets the mark | 405 linenr_T lnum, // line number which gets the mark |
406 int typenr) // typenr of sign we are adding | 406 int typenr) // typenr of sign we are adding |
407 { | 407 { |
408 signlist_T *sign; // a sign in the signlist | 408 sign_entry_T *sign; // a sign in the signlist |
409 signlist_T *prev; // the previous sign | 409 sign_entry_T *prev; // the previous sign |
410 | 410 |
411 prev = NULL; | 411 prev = NULL; |
412 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 412 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
413 { | 413 { |
414 if (lnum == sign->lnum && id == sign->id | 414 if (lnum == sign->se_lnum && id == sign->se_id |
415 && sign_in_group(sign, groupname)) | 415 && sign_in_group(sign, groupname)) |
416 { | 416 { |
417 // Update an existing sign | 417 // Update an existing sign |
418 sign->typenr = typenr; | 418 sign->se_typenr = typenr; |
419 sign->priority = prio; | 419 sign->se_priority = prio; |
420 sign_sort_by_prio_on_line(buf, sign); | 420 sign_sort_by_prio_on_line(buf, sign); |
421 return; | 421 return; |
422 } | 422 } |
423 else if (lnum < sign->lnum) | 423 else if (lnum < sign->se_lnum) |
424 { | 424 { |
425 insert_sign_by_lnum_prio(buf, prev, id, groupname, prio, | 425 insert_sign_by_lnum_prio(buf, prev, id, groupname, prio, |
426 lnum, typenr); | 426 lnum, typenr); |
427 return; | 427 return; |
428 } | 428 } |
443 int markId, // sign ID | 443 int markId, // sign ID |
444 char_u *group, // sign group | 444 char_u *group, // sign group |
445 int typenr, // typenr of sign we are adding | 445 int typenr, // typenr of sign we are adding |
446 int prio) // sign priority | 446 int prio) // sign priority |
447 { | 447 { |
448 signlist_T *sign; // a sign in the signlist | 448 sign_entry_T *sign; // a sign in the signlist |
449 | 449 |
450 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 450 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
451 { | 451 { |
452 if (sign->id == markId && sign_in_group(sign, group)) | 452 if (sign->se_id == markId && sign_in_group(sign, group)) |
453 { | 453 { |
454 sign->typenr = typenr; | 454 sign->se_typenr = typenr; |
455 sign->priority = prio; | 455 sign->se_priority = prio; |
456 sign_sort_by_prio_on_line(buf, sign); | 456 sign_sort_by_prio_on_line(buf, sign); |
457 return sign->lnum; | 457 return sign->se_lnum; |
458 } | 458 } |
459 } | 459 } |
460 | 460 |
461 return (linenr_T)0; | 461 return (linenr_T)0; |
462 } | 462 } |
467 * 'lnum', FALSE otherwise. | 467 * 'lnum', FALSE otherwise. |
468 */ | 468 */ |
469 int | 469 int |
470 buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T *sattr) | 470 buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T *sattr) |
471 { | 471 { |
472 signlist_T *sign; | 472 sign_entry_T *sign; |
473 sign_T *sp; | 473 sign_T *sp; |
474 | 474 |
475 vim_memset(sattr, 0, sizeof(sign_attrs_T)); | 475 vim_memset(sattr, 0, sizeof(sign_attrs_T)); |
476 | 476 |
477 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 477 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
478 { | 478 { |
479 if (sign->lnum > lnum) | 479 if (sign->se_lnum > lnum) |
480 // Signs are sorted by line number in the buffer. No need to check | 480 // Signs are sorted by line number in the buffer. No need to check |
481 // for signs after the specified line number 'lnum'. | 481 // for signs after the specified line number 'lnum'. |
482 break; | 482 break; |
483 | 483 |
484 if (sign->lnum == lnum) | 484 if (sign->se_lnum == lnum) |
485 { | 485 { |
486 sattr->typenr = sign->typenr; | 486 sattr->sat_typenr = sign->se_typenr; |
487 sp = find_sign_by_typenr(sign->typenr); | 487 sp = find_sign_by_typenr(sign->se_typenr); |
488 if (sp == NULL) | 488 if (sp == NULL) |
489 return FALSE; | 489 return FALSE; |
490 | 490 |
491 # ifdef FEAT_SIGN_ICONS | 491 # ifdef FEAT_SIGN_ICONS |
492 sattr->icon = sp->sn_image; | 492 sattr->sat_icon = sp->sn_image; |
493 # endif | 493 # endif |
494 sattr->text = sp->sn_text; | 494 sattr->sat_text = sp->sn_text; |
495 if (sattr->text != NULL && sp->sn_text_hl > 0) | 495 if (sattr->sat_text != NULL && sp->sn_text_hl > 0) |
496 sattr->texthl = syn_id2attr(sp->sn_text_hl); | 496 sattr->sat_texthl = syn_id2attr(sp->sn_text_hl); |
497 if (sp->sn_line_hl > 0) | 497 if (sp->sn_line_hl > 0) |
498 sattr->linehl = syn_id2attr(sp->sn_line_hl); | 498 sattr->sat_linehl = syn_id2attr(sp->sn_line_hl); |
499 return TRUE; | 499 return TRUE; |
500 } | 500 } |
501 } | 501 } |
502 return FALSE; | 502 return FALSE; |
503 } | 503 } |
517 buf_T *buf, // buffer sign is stored in | 517 buf_T *buf, // buffer sign is stored in |
518 linenr_T atlnum, // sign at this line, 0 - at any line | 518 linenr_T atlnum, // sign at this line, 0 - at any line |
519 int id, // sign id | 519 int id, // sign id |
520 char_u *group) // sign group | 520 char_u *group) // sign group |
521 { | 521 { |
522 signlist_T **lastp; // pointer to pointer to current sign | 522 sign_entry_T **lastp; // pointer to pointer to current sign |
523 signlist_T *sign; // a sign in a b_signlist | 523 sign_entry_T *sign; // a sign in a b_signlist |
524 signlist_T *next; // the next sign in a b_signlist | 524 sign_entry_T *next; // the next sign in a b_signlist |
525 linenr_T lnum; // line number whose sign was deleted | 525 linenr_T lnum; // line number whose sign was deleted |
526 | 526 |
527 lastp = &buf->b_signlist; | 527 lastp = &buf->b_signlist; |
528 lnum = 0; | 528 lnum = 0; |
529 for (sign = buf->b_signlist; sign != NULL; sign = next) | 529 for (sign = buf->b_signlist; sign != NULL; sign = next) |
530 { | 530 { |
531 next = sign->next; | 531 next = sign->se_next; |
532 if ((id == 0 || sign->id == id) | 532 if ((id == 0 || sign->se_id == id) |
533 && (atlnum == 0 || sign->lnum == atlnum) | 533 && (atlnum == 0 || sign->se_lnum == atlnum) |
534 && sign_in_group(sign, group)) | 534 && sign_in_group(sign, group)) |
535 | 535 |
536 { | 536 { |
537 *lastp = next; | 537 *lastp = next; |
538 if (next != NULL) | 538 if (next != NULL) |
539 next->prev = sign->prev; | 539 next->se_prev = sign->se_prev; |
540 lnum = sign->lnum; | 540 lnum = sign->se_lnum; |
541 if (sign->group != NULL) | 541 if (sign->se_group != NULL) |
542 sign_group_unref(sign->group->sg_name); | 542 sign_group_unref(sign->se_group->sg_name); |
543 vim_free(sign); | 543 vim_free(sign); |
544 redraw_buf_line_later(buf, lnum); | 544 redraw_buf_line_later(buf, lnum); |
545 | 545 |
546 // Check whether only one sign needs to be deleted | 546 // Check whether only one sign needs to be deleted |
547 // If deleting a sign with a specific identifier in a particular | 547 // If deleting a sign with a specific identifier in a particular |
551 || (*group != '*' && id != 0) | 551 || (*group != '*' && id != 0) |
552 || (*group == '*' && atlnum != 0)) | 552 || (*group == '*' && atlnum != 0)) |
553 break; | 553 break; |
554 } | 554 } |
555 else | 555 else |
556 lastp = &sign->next; | 556 lastp = &sign->se_next; |
557 } | 557 } |
558 | 558 |
559 // When deleting the last sign the cursor position may change, because the | 559 // When deleting the last sign the cursor position may change, because the |
560 // sign columns no longer shows. And the 'signcolumn' may be hidden. | 560 // sign columns no longer shows. And the 'signcolumn' may be hidden. |
561 if (buf->b_signlist == NULL) | 561 if (buf->b_signlist == NULL) |
577 buf_findsign( | 577 buf_findsign( |
578 buf_T *buf, // buffer to store sign in | 578 buf_T *buf, // buffer to store sign in |
579 int id, // sign ID | 579 int id, // sign ID |
580 char_u *group) // sign group | 580 char_u *group) // sign group |
581 { | 581 { |
582 signlist_T *sign; // a sign in the signlist | 582 sign_entry_T *sign; // a sign in the signlist |
583 | 583 |
584 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 584 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
585 if (sign->id == id && sign_in_group(sign, group)) | 585 if (sign->se_id == id && sign_in_group(sign, group)) |
586 return sign->lnum; | 586 return sign->se_lnum; |
587 | 587 |
588 return 0; | 588 return 0; |
589 } | 589 } |
590 | 590 |
591 /* | 591 /* |
592 * Return the sign at line 'lnum' in buffer 'buf'. Returns NULL if a sign is | 592 * Return the sign at line 'lnum' in buffer 'buf'. Returns NULL if a sign is |
593 * not found at the line. If 'groupname' is NULL, searches in the global group. | 593 * not found at the line. If 'groupname' is NULL, searches in the global group. |
594 */ | 594 */ |
595 static signlist_T * | 595 static sign_entry_T * |
596 buf_getsign_at_line( | 596 buf_getsign_at_line( |
597 buf_T *buf, // buffer whose sign we are searching for | 597 buf_T *buf, // buffer whose sign we are searching for |
598 linenr_T lnum, // line number of sign | 598 linenr_T lnum, // line number of sign |
599 char_u *groupname) // sign group name | 599 char_u *groupname) // sign group name |
600 { | 600 { |
601 signlist_T *sign; // a sign in the signlist | 601 sign_entry_T *sign; // a sign in the signlist |
602 | 602 |
603 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 603 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
604 { | 604 { |
605 if (sign->lnum > lnum) | 605 if (sign->se_lnum > lnum) |
606 // Signs are sorted by line number in the buffer. No need to check | 606 // Signs are sorted by line number in the buffer. No need to check |
607 // for signs after the specified line number 'lnum'. | 607 // for signs after the specified line number 'lnum'. |
608 break; | 608 break; |
609 | 609 |
610 if (sign->lnum == lnum && sign_in_group(sign, groupname)) | 610 if (sign->se_lnum == lnum && sign_in_group(sign, groupname)) |
611 return sign; | 611 return sign; |
612 } | 612 } |
613 | 613 |
614 return NULL; | 614 return NULL; |
615 } | 615 } |
621 buf_findsign_id( | 621 buf_findsign_id( |
622 buf_T *buf, // buffer whose sign we are searching for | 622 buf_T *buf, // buffer whose sign we are searching for |
623 linenr_T lnum, // line number of sign | 623 linenr_T lnum, // line number of sign |
624 char_u *groupname) // sign group name | 624 char_u *groupname) // sign group name |
625 { | 625 { |
626 signlist_T *sign; // a sign in the signlist | 626 sign_entry_T *sign; // a sign in the signlist |
627 | 627 |
628 sign = buf_getsign_at_line(buf, lnum, groupname); | 628 sign = buf_getsign_at_line(buf, lnum, groupname); |
629 if (sign != NULL) | 629 if (sign != NULL) |
630 return sign->id; | 630 return sign->se_id; |
631 | 631 |
632 return 0; | 632 return 0; |
633 } | 633 } |
634 | 634 |
635 # if defined(FEAT_NETBEANS_INTG) || defined(PROTO) | 635 # if defined(FEAT_NETBEANS_INTG) || defined(PROTO) |
640 buf_findsigntype_id( | 640 buf_findsigntype_id( |
641 buf_T *buf, // buffer whose sign we are searching for | 641 buf_T *buf, // buffer whose sign we are searching for |
642 linenr_T lnum, // line number of sign | 642 linenr_T lnum, // line number of sign |
643 int typenr) // sign type number | 643 int typenr) // sign type number |
644 { | 644 { |
645 signlist_T *sign; // a sign in the signlist | 645 sign_entry_T *sign; // a sign in the signlist |
646 | 646 |
647 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 647 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
648 { | 648 { |
649 if (sign->lnum > lnum) | 649 if (sign->se_lnum > lnum) |
650 // Signs are sorted by line number in the buffer. No need to check | 650 // Signs are sorted by line number in the buffer. No need to check |
651 // for signs after the specified line number 'lnum'. | 651 // for signs after the specified line number 'lnum'. |
652 break; | 652 break; |
653 | 653 |
654 if (sign->lnum == lnum && sign->typenr == typenr) | 654 if (sign->se_lnum == lnum && sign->se_typenr == typenr) |
655 return sign->id; | 655 return sign->se_id; |
656 } | 656 } |
657 | 657 |
658 return 0; | 658 return 0; |
659 } | 659 } |
660 | 660 |
664 * Return the number of icons on the given line. | 664 * Return the number of icons on the given line. |
665 */ | 665 */ |
666 int | 666 int |
667 buf_signcount(buf_T *buf, linenr_T lnum) | 667 buf_signcount(buf_T *buf, linenr_T lnum) |
668 { | 668 { |
669 signlist_T *sign; // a sign in the signlist | 669 sign_entry_T *sign; // a sign in the signlist |
670 int count = 0; | 670 int count = 0; |
671 | 671 |
672 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 672 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
673 { | 673 { |
674 if (sign->lnum > lnum) | 674 if (sign->se_lnum > lnum) |
675 // Signs are sorted by line number in the buffer. No need to check | 675 // Signs are sorted by line number in the buffer. No need to check |
676 // for signs after the specified line number 'lnum'. | 676 // for signs after the specified line number 'lnum'. |
677 break; | 677 break; |
678 | 678 |
679 if (sign->lnum == lnum) | 679 if (sign->se_lnum == lnum) |
680 if (sign_get_image(sign->typenr) != NULL) | 680 if (sign_get_image(sign->se_typenr) != NULL) |
681 count++; | 681 count++; |
682 } | 682 } |
683 | 683 |
684 return count; | 684 return count; |
685 } | 685 } |
691 * delete all the signs. | 691 * delete all the signs. |
692 */ | 692 */ |
693 void | 693 void |
694 buf_delete_signs(buf_T *buf, char_u *group) | 694 buf_delete_signs(buf_T *buf, char_u *group) |
695 { | 695 { |
696 signlist_T *sign; | 696 sign_entry_T *sign; |
697 signlist_T **lastp; // pointer to pointer to current sign | 697 sign_entry_T **lastp; // pointer to pointer to current sign |
698 signlist_T *next; | 698 sign_entry_T *next; |
699 | 699 |
700 // When deleting the last sign need to redraw the windows to remove the | 700 // When deleting the last sign need to redraw the windows to remove the |
701 // sign column. Not when curwin is NULL (this means we're exiting). | 701 // sign column. Not when curwin is NULL (this means we're exiting). |
702 if (buf->b_signlist != NULL && curwin != NULL) | 702 if (buf->b_signlist != NULL && curwin != NULL) |
703 { | 703 { |
706 } | 706 } |
707 | 707 |
708 lastp = &buf->b_signlist; | 708 lastp = &buf->b_signlist; |
709 for (sign = buf->b_signlist; sign != NULL; sign = next) | 709 for (sign = buf->b_signlist; sign != NULL; sign = next) |
710 { | 710 { |
711 next = sign->next; | 711 next = sign->se_next; |
712 if (sign_in_group(sign, group)) | 712 if (sign_in_group(sign, group)) |
713 { | 713 { |
714 *lastp = next; | 714 *lastp = next; |
715 if (next != NULL) | 715 if (next != NULL) |
716 next->prev = sign->prev; | 716 next->se_prev = sign->se_prev; |
717 if (sign->group != NULL) | 717 if (sign->se_group != NULL) |
718 sign_group_unref(sign->group->sg_name); | 718 sign_group_unref(sign->se_group->sg_name); |
719 vim_free(sign); | 719 vim_free(sign); |
720 } | 720 } |
721 else | 721 else |
722 lastp = &sign->next; | 722 lastp = &sign->se_next; |
723 } | 723 } |
724 } | 724 } |
725 | 725 |
726 /* | 726 /* |
727 * List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers. | 727 * List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers. |
728 */ | 728 */ |
729 static void | 729 static void |
730 sign_list_placed(buf_T *rbuf, char_u *sign_group) | 730 sign_list_placed(buf_T *rbuf, char_u *sign_group) |
731 { | 731 { |
732 buf_T *buf; | 732 buf_T *buf; |
733 signlist_T *sign; | 733 sign_entry_T *sign; |
734 char lbuf[MSG_BUF_LEN]; | 734 char lbuf[MSG_BUF_LEN]; |
735 char group[MSG_BUF_LEN]; | 735 char group[MSG_BUF_LEN]; |
736 | 736 |
737 msg_puts_title(_("\n--- Signs ---")); | 737 msg_puts_title(_("\n--- Signs ---")); |
738 msg_putchar('\n'); | 738 msg_putchar('\n'); |
739 if (rbuf == NULL) | 739 if (rbuf == NULL) |
740 buf = firstbuf; | 740 buf = firstbuf; |
752 { | 752 { |
753 if (got_int) | 753 if (got_int) |
754 break; | 754 break; |
755 if (!sign_in_group(sign, sign_group)) | 755 if (!sign_in_group(sign, sign_group)) |
756 continue; | 756 continue; |
757 if (sign->group != NULL) | 757 if (sign->se_group != NULL) |
758 vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"), | 758 vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"), |
759 sign->group->sg_name); | 759 sign->se_group->sg_name); |
760 else | 760 else |
761 group[0] = '\0'; | 761 group[0] = '\0'; |
762 vim_snprintf(lbuf, MSG_BUF_LEN, | 762 vim_snprintf(lbuf, MSG_BUF_LEN, |
763 _(" line=%ld id=%d%s name=%s priority=%d"), | 763 _(" line=%ld id=%d%s name=%s priority=%d"), |
764 (long)sign->lnum, sign->id, group, | 764 (long)sign->se_lnum, sign->se_id, group, |
765 sign_typenr2name(sign->typenr), sign->priority); | 765 sign_typenr2name(sign->se_typenr), sign->se_priority); |
766 msg_puts(lbuf); | 766 msg_puts(lbuf); |
767 msg_putchar('\n'); | 767 msg_putchar('\n'); |
768 } | 768 } |
769 if (rbuf != NULL) | 769 if (rbuf != NULL) |
770 break; | 770 break; |
780 linenr_T line1, | 780 linenr_T line1, |
781 linenr_T line2, | 781 linenr_T line2, |
782 long amount, | 782 long amount, |
783 long amount_after) | 783 long amount_after) |
784 { | 784 { |
785 signlist_T *sign; // a sign in a b_signlist | 785 sign_entry_T *sign; // a sign in a b_signlist |
786 linenr_T new_lnum; | 786 linenr_T new_lnum; |
787 | 787 |
788 FOR_ALL_SIGNS_IN_BUF(curbuf, sign) | 788 FOR_ALL_SIGNS_IN_BUF(curbuf, sign) |
789 { | 789 { |
790 // Ignore changes to lines after the sign | 790 // Ignore changes to lines after the sign |
791 if (sign->lnum < line1) | 791 if (sign->se_lnum < line1) |
792 continue; | 792 continue; |
793 new_lnum = sign->lnum; | 793 new_lnum = sign->se_lnum; |
794 if (sign->lnum >= line1 && sign->lnum <= line2) | 794 if (sign->se_lnum >= line1 && sign->se_lnum <= line2) |
795 { | 795 { |
796 if (amount != MAXLNUM) | 796 if (amount != MAXLNUM) |
797 new_lnum += amount; | 797 new_lnum += amount; |
798 } | 798 } |
799 else if (sign->lnum > line2) | 799 else if (sign->se_lnum > line2) |
800 // Lines inserted or deleted before the sign | 800 // Lines inserted or deleted before the sign |
801 new_lnum += amount_after; | 801 new_lnum += amount_after; |
802 | 802 |
803 // If the new sign line number is past the last line in the buffer, | 803 // If the new sign line number is past the last line in the buffer, |
804 // then don't adjust the line number. Otherwise, it will always be past | 804 // then don't adjust the line number. Otherwise, it will always be past |
805 // the last line and will not be visible. | 805 // the last line and will not be visible. |
806 if (new_lnum <= curbuf->b_ml.ml_line_count) | 806 if (new_lnum <= curbuf->b_ml.ml_line_count) |
807 sign->lnum = new_lnum; | 807 sign->se_lnum = new_lnum; |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
811 /* | 811 /* |
812 * Find index of a ":sign" subcmd from its name. | 812 * Find index of a ":sign" subcmd from its name. |
1692 * Returns information about signs placed in a buffer as list of dicts. | 1692 * Returns information about signs placed in a buffer as list of dicts. |
1693 */ | 1693 */ |
1694 void | 1694 void |
1695 get_buffer_signs(buf_T *buf, list_T *l) | 1695 get_buffer_signs(buf_T *buf, list_T *l) |
1696 { | 1696 { |
1697 signlist_T *sign; | 1697 sign_entry_T *sign; |
1698 dict_T *d; | 1698 dict_T *d; |
1699 | 1699 |
1700 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 1700 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
1701 { | 1701 { |
1702 if ((d = sign_get_info(sign)) != NULL) | 1702 if ((d = sign_get_info(sign)) != NULL) |
1703 list_append_dict(l, d); | 1703 list_append_dict(l, d); |
1713 linenr_T lnum, | 1713 linenr_T lnum, |
1714 int sign_id, | 1714 int sign_id, |
1715 char_u *sign_group, | 1715 char_u *sign_group, |
1716 list_T *retlist) | 1716 list_T *retlist) |
1717 { | 1717 { |
1718 dict_T *d; | 1718 dict_T *d; |
1719 list_T *l; | 1719 list_T *l; |
1720 signlist_T *sign; | 1720 sign_entry_T *sign; |
1721 dict_T *sdict; | 1721 dict_T *sdict; |
1722 | 1722 |
1723 if ((d = dict_alloc_id(aid_sign_getplaced_dict)) == NULL) | 1723 if ((d = dict_alloc_id(aid_sign_getplaced_dict)) == NULL) |
1724 return; | 1724 return; |
1725 list_append_dict(retlist, d); | 1725 list_append_dict(retlist, d); |
1726 | 1726 |
1733 FOR_ALL_SIGNS_IN_BUF(buf, sign) | 1733 FOR_ALL_SIGNS_IN_BUF(buf, sign) |
1734 { | 1734 { |
1735 if (!sign_in_group(sign, sign_group)) | 1735 if (!sign_in_group(sign, sign_group)) |
1736 continue; | 1736 continue; |
1737 if ((lnum == 0 && sign_id == 0) | 1737 if ((lnum == 0 && sign_id == 0) |
1738 || (sign_id == 0 && lnum == sign->lnum) | 1738 || (sign_id == 0 && lnum == sign->se_lnum) |
1739 || (lnum == 0 && sign_id == sign->id) | 1739 || (lnum == 0 && sign_id == sign->se_id) |
1740 || (lnum == sign->lnum && sign_id == sign->id)) | 1740 || (lnum == sign->se_lnum && sign_id == sign->se_id)) |
1741 { | 1741 { |
1742 if ((sdict = sign_get_info(sign)) != NULL) | 1742 if ((sdict = sign_get_info(sign)) != NULL) |
1743 list_append_dict(l, sdict); | 1743 list_append_dict(l, sdict); |
1744 } | 1744 } |
1745 } | 1745 } |