annotate src/sign.c @ 16351:f1ef4271f2ef

Added tag v8.1.1180 for changeset ffa791471a4cbe2a594514a5f94af21c2f723d61
author Bram Moolenaar <Bram@vim.org>
date Wed, 17 Apr 2019 17:00:06 +0200
parents 9e0154efac3a
children 695d9ef00b03
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 group = (signgroup_T *)alloc(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 (unsigned)(sizeof(signgroup_T) + STRLEN(groupname)));
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 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
91 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 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
93 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
94 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
95 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
96 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 // existing group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 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
101 group->refcount++;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 return group;
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 * 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
109 * 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
110 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 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
113 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 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
115 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
116
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 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
118 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
119 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 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
121 group->refcount--;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 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
123 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 // 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
125 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
126 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
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 * 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
133 * 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
134 * 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
135 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 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
138 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 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
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 || (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
142 && 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
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146 * 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
147 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 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
150 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 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
152 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
153 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
154 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
155 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
156
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 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
158 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 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
160 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
161 return id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 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
163 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15484
diff changeset
165 // 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
166 while (!found)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 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
169 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
170 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 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
172
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 // 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
174 found = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 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
176 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 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
178 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 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
180 break;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 return id;
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189 * 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
190 * 'next' signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 insert_sign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 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
202 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 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
204
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 newsign = (signlist_T *)lalloc_id((long_u)sizeof(signlist_T), FALSE,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 aid_insert_sign);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 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
208 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 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
210 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
211 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
212 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
213 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 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
215 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
216 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 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
218 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 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
223 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
224 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
225 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
226 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
227 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
228
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 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
230 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 // 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
232 // 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
233 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
234 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 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
236 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
237 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 // 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
240 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
241 #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
242 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
243 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
244 #endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 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
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
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 * 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
253 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 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
265
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 // 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
267 // 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
268 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
269 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
270 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
271 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
272 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 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
274
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 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
276 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277
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 * 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
280 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 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
282 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
283 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284 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
285
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 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
287 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
288 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
289 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
290 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291
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 * 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
294 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
295 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
296 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
297 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 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
299
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
300 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
301 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
302 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
303 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
304 (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
305 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
306 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
307 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
308
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
309 return d;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
311
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
313 * 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
314 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
316 buf_addsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 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
318 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
319 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
320 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
321 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
322 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
323 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
324 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
325 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
326
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
327 prev = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 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
329 {
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
330 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
331 && 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
332 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
333 // 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
334 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
335 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
336 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
337 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
338 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339 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
340 lnum, typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
342 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 prev = sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 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
347 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 * 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
352 * 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
353 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 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
355 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
356 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
357 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
358 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
359 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
360 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 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
362
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
363 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
364 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
365 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
366 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
367 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
368 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
369 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 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
373 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
374
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
376 * 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
377 * 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
378 * 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
379 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
380 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
381 buf_getsigntype(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 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
383 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
384 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
385 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
386 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
387
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 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
389 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
390 && (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
391 # 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
392 || (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
393 && 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
394 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 || (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
396 && 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
397 || (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
398 && 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
399 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
400 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 }
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 * 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
405 * 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
406 * 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
407 * 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
408 * 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
409 * 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
410 * 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
411 * 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
412 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413 linenr_T
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 buf_delsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 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
416 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
417 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
418 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
419 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 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
421 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
422 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
423 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
424
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 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
426 lnum = 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427 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
428 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 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
430 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
431 && (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
432 && 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
433
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 *lastp = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 // 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
445 // 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
446 // 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
447 // 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
448 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
449 || (*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
450 || (*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
451 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
452 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454 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
455 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
457 // 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
458 // 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
459 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
460 {
882bbbdc9c76 patch 8.1.0750: when the last sign is deleted the signcolumn may remain
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
461 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
462 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
463 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 return lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 * 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
471 * 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
472 * 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
473 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
474 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
475 buf_findsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
476 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
477 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
478 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
479 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480 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
481
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482 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
483 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
484 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
485
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
486 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
487 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
488
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
489 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 * 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
491 * 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
492 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
493 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
494 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
495 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
496 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
497 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
498 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
499 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
500
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 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
502 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
503 return sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 return NULL;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 * 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
510 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 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
513 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
514 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
515 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
516 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 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
518
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
519 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
520 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
521 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
522
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
523 return 0;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526 # 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
527 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 * 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
529 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 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
532 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
533 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
534 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
535 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
536 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
537
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538 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
539 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
540 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
541
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544
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 # 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
547 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
548 * 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
549 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
550 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
551 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
552 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
553 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
554 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
555
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 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
557 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
558 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
559 count++;
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 return count;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 # 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
564 # 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
565
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
567 * 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
568 * 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
569 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
570 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571 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
572 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 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
574 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
575 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
576
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
577 // 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
578 // 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
579 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
580 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
581 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
582 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
583 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 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
586 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
587 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 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
589 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
590 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 *lastp = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 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
593 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
594 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
595 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
596 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
597 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599 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
600 }
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 * 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
605 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607 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
608 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 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
610 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
611 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
612 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
613
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
614 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
615 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
616 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
617 buf = firstbuf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
618 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
619 buf = rbuf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 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
621 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 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
623 {
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
624 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
625 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
626 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
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 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 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
631 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 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
633 continue;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 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
635 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
636 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
637 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 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
639 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
640 _(" 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
641 (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
642 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
643 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
644 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
645 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 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
647 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 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
649 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651
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 * 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
654 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 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
657 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
658 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
659 long amount,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 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
661 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
662 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
663 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
664
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665 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
666 {
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
667 // 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
668 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
669 continue;
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
670 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
671 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
672 {
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
673 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
674 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
675 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 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
677 // 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
678 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
679
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
680 // 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
681 // 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
682 // 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
683 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
684 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
685 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 * 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
690 * "*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
691 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 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
694 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
695 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
696 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 int idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 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
699
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 *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
701 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
702 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
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 *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
705 return idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
709 * 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
710 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
711 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
712 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
713 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714 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
715
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 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
717 *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
718 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
719 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 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
721 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 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
723 *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
724 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 return sp;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 /*
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
730 * 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
731 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
732 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
733 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
734 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
735 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
736 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
737 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
738
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
739 // 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
740 sp = (sign_T *)alloc_clear_id((unsigned)sizeof(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
741 aid_sign_define_by_name);
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
742 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
743 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
744
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
745 // 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
746 // 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
747 // 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
748 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
749 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
750 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
751 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
752 ++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
753 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
754 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
755 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
756 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
757 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
758 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
759 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
760 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
761 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
762 continue;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
763 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
764 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
765 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
766
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
767 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
768 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
769 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
770
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
771 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
772 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
773 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
774 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
775 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
776 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
777
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
778 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
779 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
780
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
781 /*
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
782 * 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
783 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
784 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
785 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
786 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
787 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
788 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
789 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
790 # 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
791 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
792 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
793 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
794 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
795 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
796 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
797 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
798 # endif
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
799 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
800
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
801 /*
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
802 * 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
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 int
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
805 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
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 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
808 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
809 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
810 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
811
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
812 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
813
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
814 // 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
815 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
816 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
817 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
818 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
819 --endp;
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
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
822 // 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
823 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
824 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
825 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
826 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
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 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
829 break;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
830 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
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 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
833 else
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 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
836 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
837 break;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
838 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
839 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
840
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
841 // 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
842 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
843 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
844 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
845 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
846 }
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 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
849 // 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
850 // 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
851 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
852 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
853
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
854 // 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
855 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
856 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
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 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
859 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
860
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
861 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
862 * 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
863 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
864 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
865 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
866 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
867 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
868 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
869 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
870 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
871 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 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
873 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
874
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
875 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
876 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
877 {
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
878 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
879 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
880 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
881
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
882 // 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
883 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
884 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
885 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 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
887 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 // 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
890 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
891 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
892
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
893 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
894 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
895
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
896 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
897 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
898
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 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
900 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
901
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
903 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
904
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
905 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 * 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
907 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 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
910 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911 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
912 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
913
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 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
915 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
916 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
917 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
918 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 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
921
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926 * 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
927 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 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
930 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931 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
932
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 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
934 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
935 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
936 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
937 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
938 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
940 /*
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
941 * 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
942 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
943 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
944 sign_place(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
945 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
946 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
947 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
948 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
949 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
950 int prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
951 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 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
953
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
954 // 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
955 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
956 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
957
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
958 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
959 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
960 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
961 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
962 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
963 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
964 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
965 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
966 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
967 *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
968
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
969 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
970 // ":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
971 // 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
972 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
973 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
974 // ":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
975 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
976 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
977 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
978 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
979 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
980 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
981 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
982 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
983
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
984 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
985 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
986
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
987 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
988 * 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
989 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
990 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
991 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
992 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
993 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
994 return OK;
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 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
997 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
998 // 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
999 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
1000 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
1001 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1002 else
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 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
1005
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1006 // 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
1007 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
1008 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
1009 return FAIL;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1012 return OK;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1015 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1016 * 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
1017 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1018 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1019 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
1020 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1021 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
1022
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1023 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
1024 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
1025 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
1026 else
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1027 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
1028 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1029
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1030 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1031 * 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
1032 */
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1033 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
1034 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
1035 {
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1036 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
1037
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1038 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
1039 {
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15484
diff changeset
1040 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
1041 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
1042 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1043
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1044 // 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
1045 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
1046 { // ... 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
1047 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
1048 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
1049 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
1050 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1051 else
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1052 { // ... 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
1053 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
1054
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1055 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
1056 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1057 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
1058 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
1059 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1060 cmd = alloc((unsigned)STRLEN(buf->b_fname) + 25);
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1061 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
1062 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
1063 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
1064 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
1065 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
1066 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1067 # 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
1068 foldOpenCursor();
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1069 # endif
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1070
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1071 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
1072 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1073
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1074 /*
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1075 * ":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
1076 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1077 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1078 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
1079 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080 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
1081 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
1082 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
1083 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
1084 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
1085 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
1086 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
1087
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1088 // 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
1089 for (;;)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1091 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
1092 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
1093 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1094 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
1095 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
1096 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 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
1099 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1100 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
1101 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1102 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1103 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
1104 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105 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
1106 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1107 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1108 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
1109 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1110 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
1111 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1112 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1113 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
1114 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1115 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1116 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1117 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
1118 failed = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1119 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1120 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1121 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 if (!failed)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124 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
1125
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1126 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
1127 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
1128 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
1129 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
1130 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1131
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1132 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1133 * ":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
1134 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1136 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
1137 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
1138 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
1139 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
1140 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1141 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
1142 int prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1144 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
1145 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1146 // 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
1147 // :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
1148 // :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
1149 // :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
1150 // :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
1151 // :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
1152 // :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
1153 // :sign place
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154 // :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
1155 // :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
1156 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
1157 || (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
1158 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
1159 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1160 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
1161 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1162 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1164 // 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
1165 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
1166 || (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
1167 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1168 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
1169 return;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1172 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
1173 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1174 }
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 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1177 * ":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
1178 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1179 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1180 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
1181 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
1182 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
1183 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
1184 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1185 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
1186 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1187 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
1188 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1189 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
1190 return;
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 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
1194 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 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
1196 // :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
1197 // :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
1198 // :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
1199 // :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
1200 // :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
1201 // :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
1202 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
1203 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1204 // :sign unplace *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 // :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
1206 // :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
1207 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
1208 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
1209 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
1210 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1211 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1212 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1213 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
1214 // :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
1215 // :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
1216 // :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
1217 // :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
1218 // :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
1219 // :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
1220 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
1221 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1222 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1223 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
1224 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 // :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
1226 // :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
1227 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
1228 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1229 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1230 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1231 // :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
1232 // :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
1233 // :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
1234 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
1235 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
1236 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1237 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1238 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1239 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1240
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1241 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1242 * 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
1243 * :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
1244 * :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
1245 * :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
1246 * :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
1247 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1249 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
1250 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
1251 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
1252 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
1253 int id,
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 *group)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1255 {
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1256 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
1257 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1258 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
1259 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1260 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1262 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
1263 || 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
1264 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 // 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
1266 // 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
1267 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
1268 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1269 }
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1270 (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
1271 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1272
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 * 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
1275 * ":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
1276 * 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
1277 * 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
1278 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1279 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 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
1281 int cmd,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 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
1283 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
1284 int *signid,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1285 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
1286 int *prio,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1287 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
1288 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
1289 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290 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
1291 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
1292 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
1293 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
1294
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1295 // 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
1296 arg1 = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1297 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
1298 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1299 *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
1300 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
1301 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1302 *signid = -1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1303 arg = arg1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1304 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1305 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1306 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
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 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
1310 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1311 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
1312 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1313 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1314 *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
1315 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
1316 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
1317 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1318 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
1319 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1320 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
1321 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1322 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
1323 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1324 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1325 *signid = -2;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1326 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
1327 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1328 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
1329 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1330 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1331 name = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1332 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
1333 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
1334 *arg++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1335 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
1336 ++name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1337 *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
1338 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 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
1340 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 arg += 6;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1342 *group = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1343 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
1344 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
1345 *arg++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1346 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1347 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
1348 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1349 arg += 9;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1350 *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
1351 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
1352 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1353 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
1354 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1355 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 filename = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1357 *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
1358 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1359 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1360 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
1361 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1362 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 filename = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364 *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
1365 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
1366 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
1367 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1368 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1369 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1370 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1371 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
1372 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1373 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1374 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
1375 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1377 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
1378 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1379 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
1380 return FAIL;
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
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1383 // 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
1384 // 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
1385 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
1386 || cmd == SIGNCMD_JUMP))
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1387 *buf = curwin->w_buffer;
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1388
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1389 return OK;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1392 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1393 * ":sign" command
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1394 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396 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
1397 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 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
1399 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
1400 int idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 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
1402 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
1403
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1404 // 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
1405 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
1406 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
1407 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
1408 {
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1409 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
1410 return;
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 = skipwhite(p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1413
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1414 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
1415 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1416 // 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
1417 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
1418 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1419 // ":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
1420 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
1421 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
1422 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 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
1424 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
1425 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1427 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
1428
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1429 // 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
1430 // 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
1431 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
1432 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
1433 *p++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1434 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
1435 ++arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 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
1437
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1438 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
1439 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
1440 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
1441 // ":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
1442 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
1443 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 // ":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
1445 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
1446
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1447 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
1448 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1449 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1450 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 else
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 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
1454 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
1455 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
1456 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
1457 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
1458
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1459 // 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
1460 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
1461 &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
1462 return;
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 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
1465 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
1466 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
1467 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
1468 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
1469 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
1470 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1471 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1473 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1474 * 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
1475 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1476 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477 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
1478 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1479 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
1480
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1481 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
1482 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
1483 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
1484 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
1485 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
1486 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
1487 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1488 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
1489 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
1490 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
1491 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
1492 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 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
1494 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1495 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
1496 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
1497 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
1498 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
1499 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1500 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1501
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1502 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1503 * 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
1504 * 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
1505 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1506 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 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
1508 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1509 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
1510 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
1511
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1512 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
1513 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1514 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
1515 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
1516 return;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 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
1520 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521 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
1522 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 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
1524 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1525 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
1526
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1527 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
1528 break;
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 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1532 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1533 * 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
1534 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1535 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 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
1537 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1538 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
1539 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
1540
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 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
1542 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1543 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
1544 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
1545 }
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1548 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1549 * 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
1550 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1552 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
1553 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
1554 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
1555 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
1556 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
1557 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
1558 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1559 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
1560 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
1561 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
1562 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
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 ((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
1565 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1566 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
1567
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1568 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
1569
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1570 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
1571 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572 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
1573
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1574 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
1575 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1576 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
1577 continue;
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1578 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
1579 || (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
1580 || (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
1581 || (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
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 ((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
1584 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
1585 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1586 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1587 }
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 * 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
1591 * 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
1592 * 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
1593 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1594 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1595 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
1596 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
1597 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
1598 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
1599 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
1600 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
1601 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1602 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
1603 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
1604 else
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 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
1607 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 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
1609 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
1610 }
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 }
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 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
1615 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1616 * 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
1617 * 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
1618 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1620 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
1621 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1622 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
1623
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 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
1625 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
1626 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
1627 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 # endif
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631 * 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
1632 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1633 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1634 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
1635 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1636 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
1637
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1638 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
1639 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
1640 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1641 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
1642 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
1643 # 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
1644 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
1645 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
1646 # else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1647 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
1648 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1649 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1650 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
1651 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1652 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
1653 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
1654 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 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
1656 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1657 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
1658 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
1659 if (p == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1660 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
1661 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1662 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
1663 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1664 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
1665 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1666 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
1667 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
1668 if (p == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1669 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
1670 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1671 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
1672 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1673 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1674
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1675 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1676 * 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
1677 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1679 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
1680 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1681 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
1682 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
1683 # 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
1684 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
1685 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1686 out_flush();
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1687 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
1688 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1689 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1690 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
1691 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
1692 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
1693 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1694 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
1695 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
1696 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1697
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 * 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
1700 * 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
1701 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1702 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1703 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
1704 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 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 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
1708 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
1709 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1710 if (line)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1712 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
1713 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
1714 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1715 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1716 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1717 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
1718 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
1719 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1721 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1722 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1723 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1724
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 * 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
1727 * 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
1728 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1729 char_u *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1730 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
1731 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1732 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
1733
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734 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
1735 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
1736 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
1737 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1738 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1739
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1740 # 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
1741 void *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1742 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
1743 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
1744 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1745 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
1746
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1747 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
1748 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
1749 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
1750 return NULL;
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 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1753
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1754 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1755 * 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
1756 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1757 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1758 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
1759 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1760 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
1761 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
1762 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1763
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1764 # 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
1765 static enum
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1767 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
1768 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
1769 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
1770 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
1771 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
1772 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
1773 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
1774 } expand_what;
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 /*
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1777 * 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
1778 */
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1779 static char_u *
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1780 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
1781 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1782 int current_idx;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1783 sign_T *sp;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1784
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1785 // 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
1786 current_idx = 0;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1787 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
1788 if (current_idx++ == idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1789 return sp->sn_name;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1790 return NULL;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1791 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1792
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1793 /*
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1794 * 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
1795 */
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1796 static char_u *
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1797 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
1798 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1799 int current_idx;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1800 int todo;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1801 hashitem_T *hi;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1802 signgroup_T *group;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1803
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1804 // 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
1805 current_idx = 0;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1806 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
1807 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
1808 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1809 if (!HASHITEM_EMPTY(hi))
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1810 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1811 --todo;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1812 if (current_idx++ == idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1813 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1814 group = HI2SG(hi);
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1815 return group->sg_name;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1816 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1817 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1818 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1819 return NULL;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1820 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1821
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1822 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 * 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
1824 * expansion.
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 char_u *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 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
1828 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829 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
1830 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1831 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
1832 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
1833 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
1834 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1835 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
1836 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1837 "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
1838 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1839 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
1840 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1841 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
1842 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1843 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
1844 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1845 "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
1846 "buffer=", NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1847 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1848 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
1849 }
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1850 case EXP_LIST:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1851 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1852 char *list_arg[] =
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1853 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1854 "group=", "file=", "buffer=", NULL
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 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
1857 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1858 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
1859 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1860 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
1861 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
1862 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1863 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
1864 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
1865 case EXP_SIGN_GROUPS:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1866 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
1867 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1868 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1869 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1870 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1871
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1872 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1873 * 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
1874 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1875 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1876 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
1877 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1878 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
1879 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
1880 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
1881 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
1882 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
1883
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1884 // 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
1885 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
1886 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
1887 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
1888
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1889 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
1890 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
1891 // 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
1892 // :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
1893 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1894
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1895 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
1896
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1897 // :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
1898 // |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1899 // 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
1900 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
1901
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1902 // 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
1903
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1904 // :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
1905 // |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1906 // p
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1907
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1908 // 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
1909 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
1910 do
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 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
1913 last = p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1914 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
1915 } 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
1916
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1917 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
1918
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1919 // :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
1920 // | |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1921 // 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
1922 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
1923 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1924 // 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
1925 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
1926 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
1927 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1928 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
1929 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
1930 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1931 case SIGNCMD_PLACE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1932 // List placed signs
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1933 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
1934 // :sign place {id} {args}...
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1935 expand_what = EXP_PLACE;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1936 else
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1937 // :sign place {args}...
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1938 expand_what = EXP_LIST;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1939 break;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1940 case SIGNCMD_LIST:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1941 case SIGNCMD_UNDEFINE:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1942 // :sign list <CTRL-D>
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1943 // :sign undefine <CTRL-D>
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1944 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
1945 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 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
1947 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
1948 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
1949 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1950 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1951 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
1952 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1953 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1954 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1955 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1956 // 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
1957 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
1958 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
1959 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1960 case SIGNCMD_DEFINE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1961 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
1962 || 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
1963 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
1964 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
1965 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
1966 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1967 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
1968 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1969 case SIGNCMD_PLACE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1970 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
1971 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
1972 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
1973 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
1974 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
1975 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
1976 else
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1977 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
1978 break;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1979 case SIGNCMD_UNPLACE:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1980 case SIGNCMD_JUMP:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
1981 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
1982 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
1983 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
1984 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
1985 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1986 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
1987 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1988 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1989 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
1990 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1991 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1992 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1993 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1994
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1995 #endif /* FEAT_SIGNS */