annotate src/sign.c @ 17015:bc44dd816fc0

Added tag v8.1.1507 for changeset eca47d76ad5a26e57ae74a81c7d7a768d3862465
author Bram Moolenaar <Bram@vim.org>
date Sun, 09 Jun 2019 15:30:06 +0200
parents 15bc5a64bd50
children 811c5c2f5236
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 * sign.c: functions for managing signs
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 #include "vim.h"
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 #if defined(FEAT_SIGNS) || defined(PROTO)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 * Struct to hold the sign properties.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 typedef struct sign sign_T;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 struct sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
25 sign_T *sn_next; // next sign in list
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
26 int sn_typenr; // type number of sign
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
27 char_u *sn_name; // name of sign
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
28 char_u *sn_icon; // name of pixmap
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 # ifdef FEAT_SIGN_ICONS
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
30 void *sn_image; // icon image
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 # endif
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
32 char_u *sn_text; // text used instead of pixmap
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
33 int sn_line_hl; // highlight ID for line
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
34 int sn_text_hl; // highlight ID for text
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 static sign_T *first_sign = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 static int next_sign_typenr = 1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 static void sign_list_defined(sign_T *sp);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 static void sign_undefine(sign_T *sp, sign_T *sp_prev);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 static char *cmds[] = {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 "define",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 # define SIGNCMD_DEFINE 0
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 "undefine",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 # define SIGNCMD_UNDEFINE 1
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 "list",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 # define SIGNCMD_LIST 2
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 "place",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 # define SIGNCMD_PLACE 3
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 "unplace",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 # define SIGNCMD_UNPLACE 4
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 "jump",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 # define SIGNCMD_JUMP 5
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 # define SIGNCMD_LAST 6
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 static hashtab_T sg_table; // sign group (signgroup_T) hashtable
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61 static int next_sign_id = 1; // next sign id in the global group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 * Initialize data needed for managing signs
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 init_signs(void)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 hash_init(&sg_table); // sign group hash table
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 * A new sign in group 'groupname' is added. If the group is not present,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 * create it. Otherwise reference the group.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 static signgroup_T *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 sign_group_ref(char_u *groupname)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 hash_T hash;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 hashitem_T *hi;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 signgroup_T *group;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 hash = hash_hash(groupname);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 hi = hash_lookup(&sg_table, groupname, hash);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 if (HASHITEM_EMPTY(hi))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 // new group
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
88 group = alloc(sizeof(signgroup_T) + STRLEN(groupname));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 if (group == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 STRCPY(group->sg_name, groupname);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 group->refcount = 1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 group->next_sign_id = 1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 hash_add_item(&sg_table, hi, group->sg_name, hash);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 // existing group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 group = HI2SG(hi);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 group->refcount++;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 return group;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 * A sign in group 'groupname' is removed. If all the signs in this group are
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 * removed, then remove the group.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 sign_group_unref(char_u *groupname)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 hashitem_T *hi;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 signgroup_T *group;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 hi = hash_find(&sg_table, groupname);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 if (!HASHITEM_EMPTY(hi))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 group = HI2SG(hi);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 group->refcount--;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 if (group->refcount == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 // All the signs in this group are removed
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 hash_remove(&sg_table, hi);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 vim_free(group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 * Returns TRUE if 'sign' is in 'group'.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 * A sign can either be in the global group (sign->group == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 * or in a named group. If 'group' is '*', then the sign is part of the group.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 sign_in_group(signlist_T *sign, char_u *group)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 return ((group != NULL && STRCMP(group, "*") == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 || (group == NULL && sign->group == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 || (group != NULL && sign->group != NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 && STRCMP(group, sign->group->sg_name) == 0));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 * Get the next free sign identifier in the specified group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 sign_group_get_next_signid(buf_T *buf, char_u *groupname)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 int id = 1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 signgroup_T *group = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 signlist_T *sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 hashitem_T *hi;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 int found = FALSE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 if (groupname != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 hi = hash_find(&sg_table, groupname);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 if (HASHITEM_EMPTY(hi))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160 return id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 group = HI2SG(hi);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15484
diff changeset
164 // Search for the next usable sign identifier
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 while (!found)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 if (group == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 id = next_sign_id++; // global group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 id = group->next_sign_id++;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 // Check whether this sign is already placed in the buffer
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 found = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 if (id == sign->id && sign_in_group(sign, groupname))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 found = FALSE; // sign identifier is in use
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 return id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 * Insert a new sign into the signlist for buffer 'buf' between the 'prev' and
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 * 'next' signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 insert_sign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 buf_T *buf, // buffer to store sign in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 signlist_T *prev, // previous sign entry
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 signlist_T *next, // next sign entry
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 int id, // sign ID
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 char_u *group, // sign group; NULL for global group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 int prio, // sign priority
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 linenr_T lnum, // line number which gets the mark
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 int typenr) // typenr of sign we are adding
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 signlist_T *newsign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
204 newsign = lalloc_id(sizeof(signlist_T), FALSE, aid_insert_sign);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 if (newsign != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 newsign->id = id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 newsign->lnum = lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 newsign->typenr = typenr;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 if (group != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 newsign->group = sign_group_ref(group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 if (newsign->group == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 vim_free(newsign);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 newsign->group = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 newsign->priority = prio;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 newsign->next = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 newsign->prev = prev;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 if (next != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 next->prev = newsign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 if (prev == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 // When adding first sign need to redraw the windows to create the
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 // column for signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 if (buf->b_signlist == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233 redraw_buf_later(buf, NOT_VALID);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 changed_cline_bef_curs();
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 // first sign in signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238 buf->b_signlist = newsign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 #ifdef FEAT_NETBEANS_INTG
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 if (netbeans_active())
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 buf->b_has_sign_column = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 #endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 prev->next = newsign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 * Insert a new sign sorted by line number and sign priority.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 insert_sign_by_lnum_prio(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 buf_T *buf, // buffer to store sign in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 signlist_T *prev, // previous sign entry
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 int id, // sign ID
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 char_u *group, // sign group; NULL for global group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 int prio, // sign priority
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 linenr_T lnum, // line number which gets the mark
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260 int typenr) // typenr of sign we are adding
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 signlist_T *sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 // keep signs sorted by lnum and by priority: insert new sign at
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265 // the proper position in the list for this lnum.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 while (prev != NULL && prev->lnum == lnum && prev->priority <= prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 prev = prev->prev;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 if (prev == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 sign = buf->b_signlist;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 sign = prev->next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 insert_sign(buf, prev, sign, id, group, prio, lnum, typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277 * Get the name of a sign by its typenr.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 static char_u *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 sign_typenr2name(int typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 if (sp->sn_typenr == typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 return sp->sn_name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 return (char_u *)_("[Deleted]");
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 * Return information about a sign in a Dict
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 static dict_T *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 sign_get_info(signlist_T *sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
296 dict_T *d;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
297
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 if ((d = dict_alloc_id(aid_sign_getinfo)) == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
299 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 dict_add_number(d, "id", sign->id);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
301 dict_add_string(d, "group", (sign->group == NULL) ?
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 (char_u *)"" : sign->group->sg_name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
303 dict_add_number(d, "lnum", sign->lnum);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
304 dict_add_string(d, "name", sign_typenr2name(sign->typenr));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 dict_add_number(d, "priority", sign->priority);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 return d;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 /*
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
311 * Sort the signs placed on the same line as "sign" by priority. Invoked after
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
312 * changing the priority of an already placed sign. Assumes the signs in the
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
313 * buffer are sorted by line number and priority.
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
314 */
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
315 static void
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
316 sign_sort_by_prio_on_line(buf_T *buf, signlist_T *sign)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
317 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
318 signlist_T *p = NULL;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
319
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
320 // If there is only one sign in the buffer or only one sign on the line or
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
321 // the sign is already sorted by priority, then return.
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
322 if ((sign->prev == NULL
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
323 || sign->prev->lnum != sign->lnum
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
324 || sign->prev->priority > sign->priority)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
325 && (sign->next == NULL
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
326 || sign->next->lnum != sign->lnum
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
327 || sign->next->priority < sign->priority))
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
328 return;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
329
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
330 // One or more signs on the same line as 'sign'
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
331 // Find a sign after which 'sign' should be inserted
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
332
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
333 // First search backward for a sign with higher priority on the same line
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
334 p = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
335 while (p->prev != NULL && p->prev->lnum == sign->lnum
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
336 && p->prev->priority <= sign->priority)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
337 p = p->prev;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
338
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
339 if (p == sign)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
340 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
341 // Sign not found. Search forward for a sign with priority just before
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
342 // 'sign'.
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
343 p = sign->next;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
344 while (p->next != NULL && p->next->lnum == sign->lnum
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
345 && p->next->priority > sign->priority)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
346 p = p->next;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
347 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
348
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
349 // Remove 'sign' from the list
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
350 if (buf->b_signlist == sign)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
351 buf->b_signlist = sign->next;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
352 if (sign->prev != NULL)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
353 sign->prev->next = sign->next;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
354 if (sign->next != NULL)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
355 sign->next->prev = sign->prev;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
356 sign->prev = NULL;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
357 sign->next = NULL;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
358
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
359 // Re-insert 'sign' at the right place
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
360 if (p->priority <= sign->priority)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
361 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
362 // 'sign' has a higher priority and should be inserted before 'p'
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
363 sign->prev = p->prev;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
364 sign->next = p;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
365 p->prev = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
366 if (sign->prev != NULL)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
367 sign->prev->next = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
368 if (buf->b_signlist == p)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
369 buf->b_signlist = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
370 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
371 else
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
372 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
373 // 'sign' has a lower priority and should be inserted after 'p'
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
374 sign->prev = p;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
375 sign->next = p->next;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
376 p->next = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
377 if (sign->next != NULL)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
378 sign->next->prev = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
379 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
380 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
381
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
382 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383 * Add the sign into the signlist. Find the right spot to do it though.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 buf_addsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387 buf_T *buf, // buffer to store sign in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 int id, // sign ID
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 char_u *groupname, // sign group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 int prio, // sign priority
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 linenr_T lnum, // line number which gets the mark
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 int typenr) // typenr of sign we are adding
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 signlist_T *sign; // a sign in the signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 signlist_T *prev; // the previous sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 prev = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 {
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
400 if (lnum == sign->lnum && id == sign->id
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
401 && sign_in_group(sign, groupname))
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403 // Update an existing sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 sign->typenr = typenr;
16930
1689b52cf297 patch 8.1.1466: not updating priority on existing sign
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
405 sign->priority = prio;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
406 sign_sort_by_prio_on_line(buf, sign);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 else if (lnum < sign->lnum)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 insert_sign_by_lnum_prio(buf, prev, id, groupname, prio,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 lnum, typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 prev = sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 insert_sign_by_lnum_prio(buf, prev, id, groupname, prio, lnum, typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 * For an existing, placed sign "markId" change the type to "typenr".
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 * Returns the line number of the sign, or zero if the sign is not found.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 static linenr_T
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 buf_change_sign_type(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 buf_T *buf, // buffer to store sign in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 int markId, // sign ID
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 char_u *group, // sign group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 int typenr) // typenr of sign we are adding
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 signlist_T *sign; // a sign in the signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 if (sign->id == markId && sign_in_group(sign, group))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 sign->typenr = typenr;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 return sign->lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 return (linenr_T)0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 * Return the type number of the sign at line number 'lnum' in buffer 'buf'
15484
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
449 * which has the attribute specified by 'type'. Returns 0 if a sign is not
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
450 * found at the line number or it doesn't have the specified attribute.
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 buf_getsigntype(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 linenr_T lnum,
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
456 int type) // SIGN_ICON, SIGN_TEXT, SIGN_ANY, SIGN_LINEHL
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
458 signlist_T *sign; // a sign in a b_signlist
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 if (sign->lnum == lnum
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 && (type == SIGN_ANY
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463 # ifdef FEAT_SIGN_ICONS
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 || (type == SIGN_ICON
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 && sign_get_image(sign->typenr) != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 || (type == SIGN_TEXT
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468 && sign_get_text(sign->typenr) != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 || (type == SIGN_LINEHL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 && sign_get_attr(sign->typenr, TRUE) != 0)))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 return sign->typenr;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
473 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 * Delete sign 'id' in group 'group' from buffer 'buf'.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 * If 'id' is zero, then delete all the signs in group 'group'. Otherwise
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 * delete only the specified sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 * If 'group' is '*', then delete the sign in all the groups. If 'group' is
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 * NULL, then delete the sign in the global group. Otherwise delete the sign in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 * the specified group.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 * Returns the line number of the deleted sign. If multiple signs are deleted,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 * then returns the line number of the last sign deleted.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
484 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
485 linenr_T
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 buf_delsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 buf_T *buf, // buffer sign is stored in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488 linenr_T atlnum, // sign at this line, 0 - at any line
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 int id, // sign id
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 char_u *group) // sign group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
491 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492 signlist_T **lastp; // pointer to pointer to current sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 signlist_T *sign; // a sign in a b_signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
494 signlist_T *next; // the next sign in a b_signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
495 linenr_T lnum; // line number whose sign was deleted
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 lastp = &buf->b_signlist;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
498 lnum = 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 for (sign = buf->b_signlist; sign != NULL; sign = next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
500 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 next = sign->next;
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
502 if ((id == 0 || sign->id == id)
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
503 && (atlnum == 0 || sign->lnum == atlnum)
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
504 && sign_in_group(sign, group))
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 *lastp = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 if (next != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 next->prev = sign->prev;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 lnum = sign->lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 if (sign->group != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 sign_group_unref(sign->group->sg_name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513 vim_free(sign);
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
514 redraw_buf_line_later(buf, lnum);
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
515
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 // Check whether only one sign needs to be deleted
15484
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
517 // If deleting a sign with a specific identifier in a particular
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
518 // group or deleting any sign at a particular line number, delete
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 // only one sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
520 if (group == NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
521 || (*group != '*' && id != 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
522 || (*group == '*' && atlnum != 0))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
524 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 lastp = &sign->next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
529 // When deleting the last sign the cursor position may change, because the
15484
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
530 // sign columns no longer shows. And the 'signcolumn' may be hidden.
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 if (buf->b_signlist == NULL)
15484
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
532 {
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
533 redraw_buf_later(buf, NOT_VALID);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 changed_cline_bef_curs();
15484
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
535 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 return lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 * Find the line number of the sign with the requested id in group 'group'. If
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 * the sign does not exist, return 0 as the line number. This will still let
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 * the correct file get loaded.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
545 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
546 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
547 buf_findsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 buf_T *buf, // buffer to store sign in
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
549 int id, // sign ID
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 char_u *group) // sign group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
552 signlist_T *sign; // a sign in the signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
554 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
555 if (sign->id == id && sign_in_group(sign, group))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 return sign->lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
559 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 * Return the sign at line 'lnum' in buffer 'buf'. Returns NULL if a sign is
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 * not found at the line. If 'groupname' is NULL, searches in the global group.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
564 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
565 static signlist_T *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 buf_getsign_at_line(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 buf_T *buf, // buffer whose sign we are searching for
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
568 linenr_T lnum, // line number of sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
569 char_u *groupname) // sign group name
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 signlist_T *sign; // a sign in the signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 if (sign->lnum == lnum && sign_in_group(sign, groupname))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
575 return sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
576
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
578 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
580 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 * Return the identifier of the sign at line number 'lnum' in buffer 'buf'.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 buf_findsign_id(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 buf_T *buf, // buffer whose sign we are searching for
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 linenr_T lnum, // line number of sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 char_u *groupname) // sign group name
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589 signlist_T *sign; // a sign in the signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 sign = buf_getsign_at_line(buf, lnum, groupname);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 if (sign != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 return sign->id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 # if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 * See if a given type of sign exists on a specific line.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 buf_findsigntype_id(
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
604 buf_T *buf, // buffer whose sign we are searching for
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
605 linenr_T lnum, // line number of sign
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
606 int typenr) // sign type number
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
608 signlist_T *sign; // a sign in the signlist
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 if (sign->lnum == lnum && sign->typenr == typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 return sign->id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
616
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
617
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 # if defined(FEAT_SIGN_ICONS) || defined(PROTO)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 * Return the number of icons on the given line.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 buf_signcount(buf_T *buf, linenr_T lnum)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 signlist_T *sign; // a sign in the signlist
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626 int count = 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 if (sign->lnum == lnum)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 if (sign_get_image(sign->typenr) != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 count++;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 return count;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 # endif /* FEAT_SIGN_ICONS */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636 # endif /* FEAT_NETBEANS_INTG */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 * Delete signs in group 'group' in buffer "buf". If 'group' is '*', then
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 * delete all the signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 buf_delete_signs(buf_T *buf, char_u *group)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 signlist_T *sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 signlist_T **lastp; // pointer to pointer to current sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 signlist_T *next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 // When deleting the last sign need to redraw the windows to remove the
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 // sign column. Not when curwin is NULL (this means we're exiting).
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 if (buf->b_signlist != NULL && curwin != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 redraw_buf_later(buf, NOT_VALID);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654 changed_cline_bef_curs();
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 lastp = &buf->b_signlist;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 for (sign = buf->b_signlist; sign != NULL; sign = next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 next = sign->next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 if (sign_in_group(sign, group))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 *lastp = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 if (next != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 next->prev = sign->prev;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 if (sign->group != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 sign_group_unref(sign->group->sg_name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
668 vim_free(sign);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
669 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 lastp = &sign->next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 * List placed signs for "rbuf". If "rbuf" is NULL do it for all buffers.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 sign_list_placed(buf_T *rbuf, char_u *sign_group)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 buf_T *buf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 signlist_T *sign;
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
683 char lbuf[MSG_BUF_LEN];
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
684 char group[MSG_BUF_LEN];
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
686 msg_puts_title(_("\n--- Signs ---"));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 msg_putchar('\n');
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 if (rbuf == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 buf = firstbuf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 buf = rbuf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 while (buf != NULL && !got_int)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 if (buf->b_signlist != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695 {
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
696 vim_snprintf(lbuf, MSG_BUF_LEN, _("Signs for %s:"), buf->b_fname);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
697 msg_puts_attr(lbuf, HL_ATTR(HLF_D));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 msg_putchar('\n');
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 if (got_int)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 if (!sign_in_group(sign, sign_group))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 continue;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 if (sign->group != NULL)
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
707 vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"),
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 sign->group->sg_name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
710 group[0] = '\0';
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
711 vim_snprintf(lbuf, MSG_BUF_LEN,
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
712 _(" line=%ld id=%d%s name=%s priority=%d"),
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
713 (long)sign->lnum, sign->id, group,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 sign_typenr2name(sign->typenr), sign->priority);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
715 msg_puts(lbuf);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 msg_putchar('\n');
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 if (rbuf != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 buf = buf->b_next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 * Adjust a placed sign for inserted/deleted lines.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 sign_mark_adjust(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 linenr_T line1,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 linenr_T line2,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 long amount,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 long amount_after)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
733 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
734 signlist_T *sign; // a sign in a b_signlist
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
735 linenr_T new_lnum;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
736
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
737 FOR_ALL_SIGNS_IN_BUF(curbuf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 {
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
739 // Ignore changes to lines after the sign
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
740 if (sign->lnum < line1)
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
741 continue;
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
742 new_lnum = sign->lnum;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
743 if (sign->lnum >= line1 && sign->lnum <= line2)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
744 {
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
745 if (amount != MAXLNUM)
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
746 new_lnum += amount;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
748 else if (sign->lnum > line2)
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
749 // Lines inserted or deleted before the sign
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
750 new_lnum += amount_after;
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
751
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
752 // If the new sign line number is past the last line in the buffer,
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
753 // then don't adjust the line number. Otherwise, it will always be past
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
754 // the last line and will not be visible.
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
755 if (new_lnum <= curbuf->b_ml.ml_line_count)
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
756 sign->lnum = new_lnum;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
758 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 * Find index of a ":sign" subcmd from its name.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
762 * "*end_cmd" must be writable.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 sign_cmd_idx(
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
766 char_u *begin_cmd, // begin of sign subcmd
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
767 char_u *end_cmd) // just after sign subcmd
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 int idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 char save = *end_cmd;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 *end_cmd = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 for (idx = 0; ; ++idx)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774 if (cmds[idx] == NULL || STRCMP(begin_cmd, cmds[idx]) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 *end_cmd = save;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 return idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 * Find a sign by name. Also returns pointer to the previous sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 static sign_T *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 sign_find(char_u *name, sign_T **sp_prev)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 if (sp_prev != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 *sp_prev = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
792 if (STRCMP(sp->sn_name, name) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
793 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
794 if (sp_prev != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
795 *sp_prev = sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
796 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
797
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 return sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
801 /*
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
802 * Allocate a new sign
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
803 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
804 static sign_T *
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
805 alloc_new_sign(char_u *name)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
806 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
807 sign_T *sp;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
808 sign_T *lp;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
809 int start = next_sign_typenr;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
810
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
811 // Allocate a new sign.
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
812 sp = alloc_clear_id(sizeof(sign_T), aid_sign_define_by_name);
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
813 if (sp == NULL)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
814 return NULL;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
815
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
816 // Check that next_sign_typenr is not already being used.
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
817 // This only happens after wrapping around. Hopefully
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
818 // another one got deleted and we can use its number.
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
819 for (lp = first_sign; lp != NULL; )
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
820 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
821 if (lp->sn_typenr == next_sign_typenr)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
822 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
823 ++next_sign_typenr;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
824 if (next_sign_typenr == MAX_TYPENR)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
825 next_sign_typenr = 1;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
826 if (next_sign_typenr == start)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
827 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
828 vim_free(sp);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
829 emsg(_("E612: Too many signs defined"));
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
830 return NULL;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
831 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
832 lp = first_sign; // start all over
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
833 continue;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
834 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
835 lp = lp->sn_next;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
836 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
837
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
838 sp->sn_typenr = next_sign_typenr;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
839 if (++next_sign_typenr == MAX_TYPENR)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
840 next_sign_typenr = 1; // wrap around
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
841
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
842 sp->sn_name = vim_strsave(name);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
843 if (sp->sn_name == NULL) // out of memory
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
844 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
845 vim_free(sp);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
846 return NULL;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
847 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
848
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
849 return sp;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
850 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
851
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
852 /*
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
853 * Initialize the icon information for a new sign
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
854 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
855 static void
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
856 sign_define_init_icon(sign_T *sp, char_u *icon)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
857 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
858 vim_free(sp->sn_icon);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
859 sp->sn_icon = vim_strsave(icon);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
860 backslash_halve(sp->sn_icon);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
861 # ifdef FEAT_SIGN_ICONS
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
862 if (gui.in_use)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
863 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
864 out_flush();
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
865 if (sp->sn_image != NULL)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
866 gui_mch_destroy_sign(sp->sn_image);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
867 sp->sn_image = gui_mch_register_sign(sp->sn_icon);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
868 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
869 # endif
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
870 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
871
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
872 /*
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
873 * Initialize the text for a new sign
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
874 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
875 static int
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
876 sign_define_init_text(sign_T *sp, char_u *text)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
877 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
878 char_u *s;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
879 char_u *endp;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
880 int cells;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
881 int len;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
882
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
883 endp = text + (int)STRLEN(text);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
884
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
885 // Remove backslashes so that it is possible to use a space.
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
886 for (s = text; s + 1 < endp; ++s)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
887 if (*s == '\\')
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
888 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
889 STRMOVE(s, s + 1);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
890 --endp;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
891 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
892
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
893 // Count cells and check for non-printable chars
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
894 if (has_mbyte)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
895 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
896 cells = 0;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
897 for (s = text; s < endp; s += (*mb_ptr2len)(s))
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
898 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
899 if (!vim_isprintc((*mb_ptr2char)(s)))
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
900 break;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
901 cells += (*mb_ptr2cells)(s);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
902 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
903 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
904 else
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
905 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
906 for (s = text; s < endp; ++s)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
907 if (!vim_isprintc(*s))
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
908 break;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
909 cells = (int)(s - text);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
910 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
911
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
912 // Currently sign text must be one or two display cells
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
913 if (s != endp || cells < 1 || cells > 2)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
914 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
915 semsg(_("E239: Invalid sign text: %s"), text);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
916 return FAIL;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
917 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
918
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
919 vim_free(sp->sn_text);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
920 // Allocate one byte more if we need to pad up
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
921 // with a space.
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
922 len = (int)(endp - text + ((cells == 1) ? 1 : 0));
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
923 sp->sn_text = vim_strnsave(text, len);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
924
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
925 // For single character sign text, pad with a space.
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
926 if (sp->sn_text != NULL && cells == 1)
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
927 STRCPY(sp->sn_text + len - 1, " ");
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
928
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
929 return OK;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
930 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
931
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
932 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 * Define a new sign or update an existing sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
934 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936 sign_define_by_name(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 char_u *name,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 char_u *icon,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 char_u *linehl,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 char_u *text,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
941 char_u *texthl)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
942 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 sign_T *sp_prev;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
946 sp = sign_find(name, &sp_prev);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
947 if (sp == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
948 {
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
949 sp = alloc_new_sign(name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
950 if (sp == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
953 // add the new sign to the list of signs
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 if (sp_prev == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
955 first_sign = sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
956 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957 sp_prev->sn_next = sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
959
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
960 // set values for a defined sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 if (icon != NULL)
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
962 sign_define_init_icon(sp, icon);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
963
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
964 if (text != NULL && (sign_define_init_text(sp, text) == FAIL))
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
965 return FAIL;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
967 if (linehl != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
968 sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
970 if (texthl != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
971 sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
972
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
973 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
975
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
976 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
977 * Free the sign specified by 'name'.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
978 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
980 sign_undefine_by_name(char_u *name)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
981 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 sign_T *sp_prev;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 sp = sign_find(name, &sp_prev);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986 if (sp == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
988 semsg(_("E155: Unknown sign: %s"), name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
989 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 sign_undefine(sp, sp_prev);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
992
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
994 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
995
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
996 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
997 * List the signs matching 'name'
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
999 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1000 sign_list_by_name(char_u *name)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1001 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1003
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1004 sp = sign_find(name, NULL);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1005 if (sp != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 sign_list_defined(sp);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1007 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1008 semsg(_("E155: Unknown sign: %s"), name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1009 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1010
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1011 /*
15484
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
1012 * Place a sign at the specified file location or update a sign.
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1013 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1014 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 sign_place(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 int *sign_id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1017 char_u *sign_group,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 char_u *sign_name,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1020 linenr_T lnum,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 int prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1022 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1024
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1025 // Check for reserved character '*' in group name
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1026 if (sign_group != NULL && (*sign_group == '*' || *sign_group == '\0'))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1027 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1028
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 if (STRCMP(sp->sn_name, sign_name) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1031 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1032 if (sp == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1033 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1034 semsg(_("E155: Unknown sign: %s"), sign_name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1035 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1036 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1037 if (*sign_id == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1038 *sign_id = sign_group_get_next_signid(buf, sign_group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1039
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1040 if (lnum > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 // ":sign place {id} line={lnum} name={name} file={fname}":
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1042 // place a sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 buf_addsign(buf, *sign_id, sign_group, prio, lnum, sp->sn_typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1045 // ":sign place {id} file={fname}": change sign type
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1046 lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1047 if (lnum > 0)
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1048 redraw_buf_line_later(buf, lnum);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1049 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1050 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1051 semsg(_("E885: Not possible to change sign %s"), sign_name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1052 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1055 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1056 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1058 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1059 * Unplace the specified sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1060 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1061 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1062 sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T atlnum)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 if (buf->b_signlist == NULL) // No signs in the buffer
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1065 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1066
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1067 if (sign_id == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1069 // Delete all the signs in the specified buffer
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1070 redraw_buf_later(buf, NOT_VALID);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1071 buf_delete_signs(buf, sign_group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1072 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1073 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1074 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1075 linenr_T lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1076
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 // Delete only the specified signs
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 lnum = buf_delsign(buf, atlnum, sign_id, sign_group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1079 if (lnum == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1082
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1083 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1084 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1085
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1086 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1087 * Unplace the sign at the current cursor line.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1089 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 sign_unplace_at_cursor(char_u *groupname)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1092 int id = -1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1093
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 id = buf_findsign_id(curwin->w_buffer, curwin->w_cursor.lnum, groupname);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1095 if (id > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1096 sign_unplace(id, groupname, curwin->w_buffer, curwin->w_cursor.lnum);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1098 emsg(_("E159: Missing sign number"));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1099 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1101 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1102 * Jump to a sign.
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1103 */
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1104 linenr_T
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1105 sign_jump(int sign_id, char_u *sign_group, buf_T *buf)
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1106 {
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1107 linenr_T lnum;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1108
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1109 if ((lnum = buf_findsign(buf, sign_id, sign_group)) <= 0)
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1110 {
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15484
diff changeset
1111 semsg(_("E157: Invalid sign ID: %d"), sign_id);
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1112 return -1;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1113 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1114
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1115 // goto a sign ...
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1116 if (buf_jump_open_win(buf) != NULL)
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1117 { // ... in a current window
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1118 curwin->w_cursor.lnum = lnum;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1119 check_cursor_lnum();
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1120 beginline(BL_WHITE);
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1121 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1122 else
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1123 { // ... not currently in a window
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1124 char_u *cmd;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1125
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1126 if (buf->b_fname == NULL)
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1127 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1128 emsg(_("E934: Cannot jump to a buffer that does not have a name"));
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1129 return -1;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1130 }
16768
695d9ef00b03 patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents: 15864
diff changeset
1131 cmd = alloc(STRLEN(buf->b_fname) + 25);
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1132 if (cmd == NULL)
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1133 return -1;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1134 sprintf((char *)cmd, "e +%ld %s", (long)lnum, buf->b_fname);
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1135 do_cmdline_cmd(cmd);
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1136 vim_free(cmd);
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1137 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1138 # ifdef FEAT_FOLDING
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1139 foldOpenCursor();
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1140 # endif
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1141
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1142 return lnum;
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1143 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1144
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1145 /*
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1146 * ":sign define {name} ..." command
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1147 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 sign_define_cmd(char_u *sign_name, char_u *cmdline)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1151 char_u *arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 char_u *p = cmdline;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 char_u *icon = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 char_u *text = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 char_u *linehl = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 char_u *texthl = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1157 int failed = FALSE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 // set values for a defined sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 for (;;)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 arg = skipwhite(p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 if (*arg == NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1165 p = skiptowhite_esc(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1166 if (STRNCMP(arg, "icon=", 5) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1167 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169 icon = vim_strnsave(arg, (int)(p - arg));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1170 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1171 else if (STRNCMP(arg, "text=", 5) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1173 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 text = vim_strnsave(arg, (int)(p - arg));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1175 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1176 else if (STRNCMP(arg, "linehl=", 7) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1177 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1178 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 linehl = vim_strnsave(arg, (int)(p - arg));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1181 else if (STRNCMP(arg, "texthl=", 7) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1182 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1183 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 texthl = vim_strnsave(arg, (int)(p - arg));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1186 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1188 semsg(_(e_invarg2), arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 failed = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1190 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1191 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1192 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1193
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1194 if (!failed)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 sign_define_by_name(sign_name, icon, linehl, text, texthl);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1197 vim_free(icon);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 vim_free(text);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1199 vim_free(linehl);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1200 vim_free(texthl);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1202
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1204 * ":sign place" command
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1206 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1207 sign_place_cmd(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1208 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 linenr_T lnum,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 char_u *sign_name,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 char_u *group,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 int prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1214 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1215 if (id <= 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1216 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 // List signs placed in a file/buffer
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1218 // :sign place file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1219 // :sign place group={group} file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1220 // :sign place group=* file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1221 // :sign place buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 // :sign place group={group} buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 // :sign place group=* buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1224 // :sign place
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 // :sign place group={group}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1226 // :sign place group=*
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1227 if (lnum >= 0 || sign_name != NULL
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1228 || (group != NULL && *group == '\0'))
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1229 emsg(_(e_invarg));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 sign_list_placed(buf, group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1232 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1235 // Place a new sign
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1236 if (sign_name == NULL || buf == NULL
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1237 || (group != NULL && *group == '\0'))
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1239 emsg(_(e_invarg));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 sign_place(&id, group, sign_name, buf, lnum, prio);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1244 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1245 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1247 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1248 * ":sign unplace" command
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 sign_unplace_cmd(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1252 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 linenr_T lnum,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1254 char_u *sign_name,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1256 char_u *group)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 if (lnum >= 0 || sign_name != NULL || (group != NULL && *group == '\0'))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1260 emsg(_(e_invarg));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1262 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1263
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1264 if (id == -2)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266 if (buf != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1267 // :sign unplace * file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1268 // :sign unplace * group={group} file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 // :sign unplace * group=* file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1270 // :sign unplace * buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1271 // :sign unplace * group={group} buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272 // :sign unplace * group=* buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 sign_unplace(0, group, buf, 0);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275 // :sign unplace *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 // :sign unplace * group={group}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 // :sign unplace * group=*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1278 FOR_ALL_BUFFERS(buf)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 if (buf->b_signlist != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 buf_delete_signs(buf, group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1281 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1283 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 if (buf != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 // :sign unplace {id} file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1286 // :sign unplace {id} group={group} file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 // :sign unplace {id} group=* file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1288 // :sign unplace {id} buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1289 // :sign unplace {id} group={group} buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 // :sign unplace {id} group=* buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 sign_unplace(id, group, buf, 0);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1292 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1293 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1294 if (id == -1)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1296 // :sign unplace group={group}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 // :sign unplace group=*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1298 sign_unplace_at_cursor(group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1300 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1301 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 // :sign unplace {id}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 // :sign unplace {id} group={group}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 // :sign unplace {id} group=*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 FOR_ALL_BUFFERS(buf)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 sign_unplace(id, group, buf, 0);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1307 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1308 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1309 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1310 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1312 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1313 * Jump to a placed sign commands:
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 * :sign jump {id} file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1315 * :sign jump {id} buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1316 * :sign jump {id} group={group} file={fname}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1317 * :sign jump {id} group={group} buffer={nr}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1319 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 sign_jump_cmd(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1321 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1322 linenr_T lnum,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1323 char_u *sign_name,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 char_u *group)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 {
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1327 if (sign_name == NULL && group == NULL && id == -1)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1329 emsg(_(e_argreq));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1333 if (buf == NULL || (group != NULL && *group == '\0')
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1334 || lnum >= 0 || sign_name != NULL)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1336 // File or buffer is not specified or an empty group is used
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 // or a line number or a sign name is specified.
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1338 emsg(_(e_invarg));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1340 }
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1341 (void)sign_jump(id, group, buf);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1344 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1345 * Parse the command line arguments for the ":sign place", ":sign unplace" and
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 * ":sign jump" commands.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 * The supported arguments are: line={lnum} name={name} group={group}
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1348 * priority={prio} and file={fname} or buffer={nr}.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1350 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351 parse_sign_cmd_args(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 int cmd,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1353 char_u *arg,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1354 char_u **sign_name,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 int *signid,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 char_u **group,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357 int *prio,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 buf_T **buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 linenr_T *lnum)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 char_u *arg1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362 char_u *name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 char_u *filename = NULL;
15388
7444fffa482d patch 8.1.0702: ":sign place" only uses the current buffer
Bram Moolenaar <Bram@vim.org>
parents: 15386
diff changeset
1364 int lnum_arg = FALSE;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1365
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1366 // first arg could be placed sign id
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1367 arg1 = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1368 if (VIM_ISDIGIT(*arg))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1370 *signid = getdigits(&arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1371 if (!VIM_ISWHITE(*arg) && *arg != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1372 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 *signid = -1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374 arg = arg1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1375 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 arg = skipwhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1379
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1380 while (*arg != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1381 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1382 if (STRNCMP(arg, "line=", 5) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1383 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1384 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1385 *lnum = atoi((char *)arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1386 arg = skiptowhite(arg);
15388
7444fffa482d patch 8.1.0702: ":sign place" only uses the current buffer
Bram Moolenaar <Bram@vim.org>
parents: 15386
diff changeset
1387 lnum_arg = TRUE;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1388 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 else if (STRNCMP(arg, "*", 1) == 0 && cmd == SIGNCMD_UNPLACE)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1390 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1391 if (*signid != -1)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1393 emsg(_(e_invarg));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396 *signid = -2;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1397 arg = skiptowhite(arg + 1);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399 else if (STRNCMP(arg, "name=", 5) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402 name = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 arg = skiptowhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 if (*arg != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405 *arg++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1406 while (name[0] == '0' && name[1] != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1407 ++name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1408 *sign_name = name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1409 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1410 else if (STRNCMP(arg, "group=", 6) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1411 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 arg += 6;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413 *group = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414 arg = skiptowhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1415 if (*arg != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 *arg++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 else if (STRNCMP(arg, "priority=", 9) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1420 arg += 9;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1421 *prio = atoi((char *)arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1422 arg = skiptowhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1424 else if (STRNCMP(arg, "file=", 5) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1425 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 filename = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1428 *buf = buflist_findname_exp(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1430 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1431 else if (STRNCMP(arg, "buffer=", 7) == 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1432 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1433 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1434 filename = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1435 *buf = buflist_findnr((int)getdigits(&arg));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 if (*skipwhite(arg) != NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1437 emsg(_(e_trailing));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1439 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1440 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1442 emsg(_(e_invarg));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1443 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 arg = skipwhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1448 if (filename != NULL && *buf == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1450 semsg(_("E158: Invalid buffer name: %s"), filename);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1452 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1453
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1454 // If the filename is not supplied for the sign place or the sign jump
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1455 // command, then use the current buffer.
15388
7444fffa482d patch 8.1.0702: ":sign place" only uses the current buffer
Bram Moolenaar <Bram@vim.org>
parents: 15386
diff changeset
1456 if (filename == NULL && ((cmd == SIGNCMD_PLACE && lnum_arg)
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1457 || cmd == SIGNCMD_JUMP))
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1458 *buf = curwin->w_buffer;
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1459
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1460 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1461 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1462
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1463 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1464 * ":sign" command
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1465 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1466 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1467 ex_sign(exarg_T *eap)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1468 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 char_u *arg = eap->arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1470 char_u *p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471 int idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1473 buf_T *buf = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1474
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1475 // Parse the subcommand.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1476 p = skiptowhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477 idx = sign_cmd_idx(arg, p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1478 if (idx == SIGNCMD_LAST)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1479 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1480 semsg(_("E160: Unknown sign command: %s"), arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1482 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1483 arg = skipwhite(p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1484
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1485 if (idx <= SIGNCMD_LIST)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1486 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1487 // Define, undefine or list signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1488 if (idx == SIGNCMD_LIST && *arg == NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1489 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1490 // ":sign list": list all defined signs
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1491 for (sp = first_sign; sp != NULL && !got_int; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1492 sign_list_defined(sp);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1494 else if (*arg == NUL)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1495 emsg(_("E156: Missing sign name"));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1496 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1497 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1498 char_u *name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1499
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1500 // Isolate the sign name. If it's a number skip leading zeroes,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1501 // so that "099" and "99" are the same sign. But keep "0".
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1502 p = skiptowhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1503 if (*p != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1504 *p++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1505 while (arg[0] == '0' && arg[1] != NUL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1506 ++arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 name = vim_strsave(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1508
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509 if (idx == SIGNCMD_DEFINE)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1510 sign_define_cmd(name, p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1511 else if (idx == SIGNCMD_LIST)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1512 // ":sign list {name}"
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1513 sign_list_by_name(name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1515 // ":sign undefine {name}"
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1516 sign_undefine_by_name(name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1517
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1518 vim_free(name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1520 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1522 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1524 int id = -1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525 linenr_T lnum = -1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1526 char_u *sign_name = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1527 char_u *group = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1528 int prio = SIGN_DEF_PRIO;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1529
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 // Parse command line arguments
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531 if (parse_sign_cmd_args(idx, arg, &sign_name, &id, &group, &prio,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1532 &buf, &lnum) == FAIL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1533 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1534
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 if (idx == SIGNCMD_PLACE)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 sign_place_cmd(buf, lnum, sign_name, id, group, prio);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1537 else if (idx == SIGNCMD_UNPLACE)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 sign_unplace_cmd(buf, lnum, sign_name, id, group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1539 else if (idx == SIGNCMD_JUMP)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1540 sign_jump_cmd(buf, lnum, sign_name, id, group);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1542 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1543
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1544 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1545 * Return information about a specified sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1546 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1547 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1548 sign_getinfo(sign_T *sp, dict_T *retdict)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1549 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1550 char_u *p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1552 dict_add_string(retdict, "name", (char_u *)sp->sn_name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1553 if (sp->sn_icon != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1554 dict_add_string(retdict, "icon", (char_u *)sp->sn_icon);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1555 if (sp->sn_text != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556 dict_add_string(retdict, "text", (char_u *)sp->sn_text);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1557 if (sp->sn_line_hl > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1558 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559 p = get_highlight_name_ext(NULL, sp->sn_line_hl - 1, FALSE);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1560 if (p == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 p = (char_u *)"NONE";
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 dict_add_string(retdict, "linehl", (char_u *)p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1563 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1564 if (sp->sn_text_hl > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1565 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1566 p = get_highlight_name_ext(NULL, sp->sn_text_hl - 1, FALSE);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1567 if (p == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1568 p = (char_u *)"NONE";
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569 dict_add_string(retdict, "texthl", (char_u *)p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1571 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1573 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1574 * If 'name' is NULL, return a list of all the defined signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1575 * Otherwise, return information about the specified sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1576 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1577 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1578 sign_getlist(char_u *name, list_T *retlist)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1579 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1580 sign_T *sp = first_sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1581 dict_T *dict;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1582
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1583 if (name != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 sp = sign_find(name, NULL);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1586 if (sp == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1587 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1588 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1589
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1590 for (; sp != NULL && !got_int; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1591 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1592 if ((dict = dict_alloc_id(aid_sign_getlist)) == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1593 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1594 if (list_append_dict(retlist, dict) == FAIL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1595 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1596 sign_getinfo(sp, dict);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1597
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1598 if (name != NULL) // handle only the specified sign
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1599 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1600 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1601 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1602
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1603 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1604 * Returns information about signs placed in a buffer as list of dicts.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1605 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1606 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1607 get_buffer_signs(buf_T *buf, list_T *l)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1609 signlist_T *sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1610 dict_T *d;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1611
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1612 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1614 if ((d = sign_get_info(sign)) != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1615 list_append_dict(l, d);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1616 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1617 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1618
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1620 * Return information about all the signs placed in a buffer
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1621 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1622 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1623 sign_get_placed_in_buf(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 linenr_T lnum,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1626 int sign_id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1627 char_u *sign_group,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 list_T *retlist)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1629 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1630 dict_T *d;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631 list_T *l;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1632 signlist_T *sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1633 dict_T *sdict;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 if ((d = dict_alloc_id(aid_sign_getplaced_dict)) == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1636 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1637 list_append_dict(retlist, d);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1638
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1639 dict_add_number(d, "bufnr", (long)buf->b_fnum);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1640
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1641 if ((l = list_alloc_id(aid_sign_getplaced_list)) == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1642 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1643 dict_add_list(d, "signs", l);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1644
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1645 FOR_ALL_SIGNS_IN_BUF(buf, sign)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1646 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1647 if (!sign_in_group(sign, sign_group))
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1648 continue;
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1649 if ((lnum == 0 && sign_id == 0)
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1650 || (sign_id == 0 && lnum == sign->lnum)
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1651 || (lnum == 0 && sign_id == sign->id)
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1652 || (lnum == sign->lnum && sign_id == sign->id))
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1653 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1654 if ((sdict = sign_get_info(sign)) != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 list_append_dict(l, sdict);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1656 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1657 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1659
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1660 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1661 * Get a list of signs placed in buffer 'buf'. If 'num' is non-zero, return the
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1662 * sign placed at the line number. If 'lnum' is zero, return all the signs
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1663 * placed in 'buf'. If 'buf' is NULL, return signs placed in all the buffers.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1664 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1665 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1666 sign_get_placed(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1667 buf_T *buf,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1668 linenr_T lnum,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1669 int sign_id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1670 char_u *sign_group,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1671 list_T *retlist)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1672 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1673 if (buf != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1674 sign_get_placed_in_buf(buf, lnum, sign_id, sign_group, retlist);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1675 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1676 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1677 FOR_ALL_BUFFERS(buf)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 if (buf->b_signlist != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680 sign_get_placed_in_buf(buf, 0, sign_id, sign_group, retlist);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1681 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1682 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1683 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1684
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1685 # if defined(FEAT_SIGN_ICONS) || defined(PROTO)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1686 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1687 * Allocate the icons. Called when the GUI has started. Allows defining
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1688 * signs before it starts.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1689 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1690 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1691 sign_gui_started(void)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1692 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1693 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1694
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1695 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1696 if (sp->sn_icon != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1697 sp->sn_image = gui_mch_register_sign(sp->sn_icon);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1698 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1699 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1700
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1701 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1702 * List one sign.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1704 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 sign_list_defined(sign_T *sp)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1706 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1707 char_u *p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1708
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1709 smsg("sign %s", sp->sn_name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1710 if (sp->sn_icon != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1712 msg_puts(" icon=");
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1713 msg_outtrans(sp->sn_icon);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1714 # ifdef FEAT_SIGN_ICONS
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1715 if (sp->sn_image == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1716 msg_puts(_(" (NOT FOUND)"));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1717 # else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1718 msg_puts(_(" (not supported)"));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1719 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1721 if (sp->sn_text != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1722 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1723 msg_puts(" text=");
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724 msg_outtrans(sp->sn_text);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1725 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 if (sp->sn_line_hl > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1727 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1728 msg_puts(" linehl=");
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1729 p = get_highlight_name_ext(NULL, sp->sn_line_hl - 1, FALSE);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1730 if (p == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1731 msg_puts("NONE");
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1732 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1733 msg_puts((char *)p);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1735 if (sp->sn_text_hl > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1736 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1737 msg_puts(" texthl=");
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1738 p = get_highlight_name_ext(NULL, sp->sn_text_hl - 1, FALSE);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1739 if (p == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1740 msg_puts("NONE");
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1741 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1742 msg_puts((char *)p);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1743 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1744 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1745
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1747 * Undefine a sign and free its memory.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1748 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1749 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1750 sign_undefine(sign_T *sp, sign_T *sp_prev)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1751 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1752 vim_free(sp->sn_name);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753 vim_free(sp->sn_icon);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 # ifdef FEAT_SIGN_ICONS
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 if (sp->sn_image != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1757 out_flush();
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1758 gui_mch_destroy_sign(sp->sn_image);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1759 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1760 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 vim_free(sp->sn_text);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1762 if (sp_prev == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1763 first_sign = sp->sn_next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1764 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1765 sp_prev->sn_next = sp->sn_next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 vim_free(sp);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1767 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1768
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1769 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 * Get highlighting attribute for sign "typenr".
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1771 * If "line" is TRUE: line highl, if FALSE: text highl.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1772 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1773 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1774 sign_get_attr(int typenr, int line)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1775 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1778 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 if (sp->sn_typenr == typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1780 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1781 if (line)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1782 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1783 if (sp->sn_line_hl > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1784 return syn_id2attr(sp->sn_line_hl);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1785 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1786 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1787 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1788 if (sp->sn_text_hl > 0)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1789 return syn_id2attr(sp->sn_text_hl);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1790 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1791 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1792 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1793 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1794 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1795
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1796 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1797 * Get text mark for sign "typenr".
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798 * Returns NULL if there isn't one.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1799 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1800 char_u *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1801 sign_get_text(int typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1802 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1803 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1804
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1805 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1806 if (sp->sn_typenr == typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1807 return sp->sn_text;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1808 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1809 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1811 # if defined(FEAT_SIGN_ICONS) || defined(PROTO)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 void *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1813 sign_get_image(
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1814 int typenr) // the attribute which may have a sign
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1815 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1816 sign_T *sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1817
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1818 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1819 if (sp->sn_typenr == typenr)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1820 return sp->sn_image;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1821 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1822 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1824
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1825 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1826 * Undefine/free all signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1828 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829 free_signs(void)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1830 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1831 while (first_sign != NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1832 sign_undefine(first_sign, NULL);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1833 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1834
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1835 # if defined(FEAT_CMDL_COMPL) || defined(PROTO)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1836 static enum
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1837 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1838 EXP_SUBCMD, // expand :sign sub-commands
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1839 EXP_DEFINE, // expand :sign define {name} args
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1840 EXP_PLACE, // expand :sign place {id} args
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1841 EXP_LIST, // expand :sign place args
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1842 EXP_UNPLACE, // expand :sign unplace"
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1843 EXP_SIGN_NAMES, // expand with name of placed signs
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1844 EXP_SIGN_GROUPS // expand with name of placed sign groups
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1845 } expand_what;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1846
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1847 /*
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1848 * Return the n'th sign name (used for command line completion)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1849 */
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1850 static char_u *
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1851 get_nth_sign_name(int idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1852 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1853 int current_idx;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1854 sign_T *sp;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1855
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1856 // Complete with name of signs already defined
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1857 current_idx = 0;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1858 for (sp = first_sign; sp != NULL; sp = sp->sn_next)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1859 if (current_idx++ == idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1860 return sp->sn_name;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1861 return NULL;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1862 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1863
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1864 /*
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1865 * Return the n'th sign group name (used for command line completion)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1866 */
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1867 static char_u *
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1868 get_nth_sign_group_name(int idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1869 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1870 int current_idx;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1871 int todo;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1872 hashitem_T *hi;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1873 signgroup_T *group;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1874
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1875 // Complete with name of sign groups already defined
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1876 current_idx = 0;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1877 todo = (int)sg_table.ht_used;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1878 for (hi = sg_table.ht_array; todo > 0; ++hi)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1879 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1880 if (!HASHITEM_EMPTY(hi))
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1881 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1882 --todo;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1883 if (current_idx++ == idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1884 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1885 group = HI2SG(hi);
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1886 return group->sg_name;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1887 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1888 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1889 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1890 return NULL;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1891 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1892
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1893 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1894 * Function given to ExpandGeneric() to obtain the sign command
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1895 * expansion.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1896 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1897 char_u *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1898 get_sign_name(expand_T *xp UNUSED, int idx)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1899 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1900 switch (expand_what)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1901 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1902 case EXP_SUBCMD:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1903 return (char_u *)cmds[idx];
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1904 case EXP_DEFINE:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1905 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1906 char *define_arg[] =
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1907 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1908 "icon=", "linehl=", "text=", "texthl=", NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1909 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1910 return (char_u *)define_arg[idx];
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1911 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1912 case EXP_PLACE:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1913 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1914 char *place_arg[] =
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1915 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1916 "line=", "name=", "group=", "priority=", "file=",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1917 "buffer=", NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1918 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1919 return (char_u *)place_arg[idx];
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1920 }
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1921 case EXP_LIST:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1922 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1923 char *list_arg[] =
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1924 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1925 "group=", "file=", "buffer=", NULL
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1926 };
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1927 return (char_u *)list_arg[idx];
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1928 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1929 case EXP_UNPLACE:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1931 char *unplace_arg[] = { "group=", "file=", "buffer=", NULL };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1932 return (char_u *)unplace_arg[idx];
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1933 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1934 case EXP_SIGN_NAMES:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1935 return get_nth_sign_name(idx);
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1936 case EXP_SIGN_GROUPS:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1937 return get_nth_sign_group_name(idx);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1938 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1939 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1940 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1941 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1942
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1943 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1944 * Handle command line completion for :sign command.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1945 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1947 set_context_in_sign_cmd(expand_T *xp, char_u *arg)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1948 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1949 char_u *p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1950 char_u *end_subcmd;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1951 char_u *last;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1952 int cmd_idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1953 char_u *begin_subcmd_args;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1954
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1955 // Default: expand subcommands.
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1956 xp->xp_context = EXPAND_SIGN;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1957 expand_what = EXP_SUBCMD;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1958 xp->xp_pattern = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1959
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1960 end_subcmd = skiptowhite(arg);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1961 if (*end_subcmd == NUL)
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1962 // expand subcmd name
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1963 // :sign {subcmd}<CTRL-D>
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1964 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1965
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1966 cmd_idx = sign_cmd_idx(arg, end_subcmd);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1967
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1968 // :sign {subcmd} {subcmd_args}
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1969 // |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1970 // begin_subcmd_args
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1971 begin_subcmd_args = skipwhite(end_subcmd);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1972
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1973 // expand last argument of subcmd
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1974
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1975 // :sign define {name} {args}...
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1976 // |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1977 // p
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1978
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1979 // Loop until reaching last argument.
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1980 p = begin_subcmd_args;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1981 do
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1982 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1983 p = skipwhite(p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1984 last = p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1985 p = skiptowhite(p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1986 } while (*p != NUL);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1987
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1988 p = vim_strchr(last, '=');
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1989
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1990 // :sign define {name} {args}... {last}=
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1991 // | |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1992 // last p
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1993 if (p == NULL)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1994 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1995 // Expand last argument name (before equal sign).
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1996 xp->xp_pattern = last;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1997 switch (cmd_idx)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1998 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1999 case SIGNCMD_DEFINE:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2000 expand_what = EXP_DEFINE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2001 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2002 case SIGNCMD_PLACE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2003 // List placed signs
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2004 if (VIM_ISDIGIT(*begin_subcmd_args))
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2005 // :sign place {id} {args}...
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2006 expand_what = EXP_PLACE;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2007 else
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2008 // :sign place {args}...
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2009 expand_what = EXP_LIST;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2010 break;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2011 case SIGNCMD_LIST:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2012 case SIGNCMD_UNDEFINE:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2013 // :sign list <CTRL-D>
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2014 // :sign undefine <CTRL-D>
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2015 expand_what = EXP_SIGN_NAMES;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2016 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2017 case SIGNCMD_JUMP:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2018 case SIGNCMD_UNPLACE:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2019 expand_what = EXP_UNPLACE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2020 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2021 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2022 xp->xp_context = EXPAND_NOTHING;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2023 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2024 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2025 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2026 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2027 // Expand last argument value (after equal sign).
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2028 xp->xp_pattern = p + 1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2029 switch (cmd_idx)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2030 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2031 case SIGNCMD_DEFINE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2032 if (STRNCMP(last, "texthl", 6) == 0
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2033 || STRNCMP(last, "linehl", 6) == 0)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2034 xp->xp_context = EXPAND_HIGHLIGHT;
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2035 else if (STRNCMP(last, "icon", 4) == 0)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2036 xp->xp_context = EXPAND_FILES;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2037 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2038 xp->xp_context = EXPAND_NOTHING;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2039 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2040 case SIGNCMD_PLACE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2041 if (STRNCMP(last, "name", 4) == 0)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2042 expand_what = EXP_SIGN_NAMES;
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2043 else if (STRNCMP(last, "group", 5) == 0)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2044 expand_what = EXP_SIGN_GROUPS;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2045 else if (STRNCMP(last, "file", 4) == 0)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2046 xp->xp_context = EXPAND_BUFFERS;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2047 else
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2048 xp->xp_context = EXPAND_NOTHING;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2049 break;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2050 case SIGNCMD_UNPLACE:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2051 case SIGNCMD_JUMP:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2052 if (STRNCMP(last, "group", 5) == 0)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2053 expand_what = EXP_SIGN_GROUPS;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2054 else if (STRNCMP(last, "file", 4) == 0)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2055 xp->xp_context = EXPAND_BUFFERS;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2056 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2057 xp->xp_context = EXPAND_NOTHING;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2058 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2059 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2060 xp->xp_context = EXPAND_NOTHING;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2061 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2062 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2063 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2064 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2065
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2066 #endif /* FEAT_SIGNS */