annotate src/sign.c @ 35568:fff85588c140 v9.1.0538

patch 9.1.0538: not possible to assign priority when defining a sign Commit: https://github.com/vim/vim/commit/b975ddfdf96644b8df808415dee36f99abd48753 Author: LemonBoy <thatlemon@gmail.com> Date: Sat Jul 6 18:04:09 2024 +0200 patch 9.1.0538: not possible to assign priority when defining a sign Problem: not possible to assign priority when defining a sign (Mathias Fu?enegger) Solution: Add the priority argument for the :sign-define ex command and the sign_define() function (LemonBoy) Use the specified value instead of the default one (SIGN_DEF_PRIO) when no priority is explicitly specified in sign_place or :sign place. fixes: #8334 closes: #15124 Signed-off-by: LemonBoy <thatlemon@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sat, 06 Jul 2024 18:15:03 +0200
parents 04d9dff67d99
children f2d9ef5eb778
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
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
35 int sn_cul_hl; // highlight ID for text on current line when 'cursorline' is set
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
36 int sn_num_hl; // highlight ID for line number
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
37 int sn_priority; // default priority of this sign, -1 means SIGN_DEF_PRIO
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 };
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 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
41 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
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 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
44 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
45
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 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
47 "define",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 # 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
49 "undefine",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 # 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
51 "list",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 # 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
53 "place",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 # 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
55 "unplace",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 # 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
57 "jump",
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 # 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
59 NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 # 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
61 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
63 #define FOR_ALL_SIGNS(sp) \
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
64 for ((sp) = first_sign; (sp) != NULL; (sp) = (sp)->sn_next)
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
65
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66 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
67 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
68
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 * 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
71 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 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
74 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 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
76 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77
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 * 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
80 * 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
81 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 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
83 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
84 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85 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
86 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
87 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
88
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89 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
90 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
91 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
92 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93 // new group
17659
121bdff812b4 patch 8.1.1827: allocating more memory than needed for extended structs
Bram Moolenaar <Bram@vim.org>
parents: 17440
diff changeset
94 group = alloc(offsetof(signgroup_T, sg_name) + STRLEN(groupname) + 1);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 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
96 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97 STRCPY(group->sg_name, groupname);
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
98 group->sg_refcount = 1;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
99 group->sg_next_sign_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
100 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
101 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102 else
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 // existing group
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 group = HI2SG(hi);
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
106 group->sg_refcount++;
15330
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109 return 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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 * 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
114 * 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
115 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 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
118 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 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
120 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
121
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 hi = hash_find(&sg_table, groupname);
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
123 if (HASHITEM_EMPTY(hi))
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
124 return;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
125
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
126 group = HI2SG(hi);
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
127 group->sg_refcount--;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
128 if (group->sg_refcount == 0)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 {
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
130 // All the signs in this group are removed
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
131 hash_remove(&sg_table, hi, "sign remove");
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
132 vim_free(group);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 * Returns TRUE if 'sign' is in 'group'.
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
138 * A sign can either be in the global group (sign->se_group == NULL)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139 * 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
140 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 static int
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
142 sign_in_group(sign_entry_T *sign, char_u *group)
15330
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 return ((group != NULL && STRCMP(group, "*") == 0)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
145 || (group == NULL && sign->se_group == NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
146 || (group != NULL && sign->se_group != NULL
18744
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
147 && STRCMP(group, sign->se_group->sg_name) == 0));
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
148 }
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
149
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
150 /*
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
151 * Return TRUE if "sign" is to be displayed in window "wp".
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
152 * If the group name starts with "PopUp" it only shows in a popup window.
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
153 */
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
154 static int
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
155 sign_group_for_window(sign_entry_T *sign, win_T *wp)
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
156 {
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
157 int for_popup = sign->se_group != NULL
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
158 && STRNCMP("PopUp", sign->se_group->sg_name, 5) == 0;
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
159
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
160 return WIN_IS_POPUP(wp) ? for_popup : !for_popup;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 * 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
165 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167 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
168 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 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
170 signgroup_T *group = NULL;
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
171 sign_entry_T *sign;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172 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
173 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
174
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 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
176 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177 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
178 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
179 return id;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 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
181 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182
15490
98c35d312987 patch 8.1.0753: printf format not checked for semsg()
Bram Moolenaar <Bram@vim.org>
parents: 15484
diff changeset
183 // 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
184 while (!found)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 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
187 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
188 else
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
189 id = group->sg_next_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
190
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 // 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
192 found = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 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
194 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
195 if (id == sign->se_id && 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
196 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 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
198 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 return id;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 * 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
208 * 'next' signs.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211 insert_sign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 buf_T *buf, // buffer to store sign in
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
213 sign_entry_T *prev, // previous sign entry
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
214 sign_entry_T *next, // next sign entry
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 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
216 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
217 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
218 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
219 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
220 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
221 sign_entry_T *newsign;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
223 newsign = lalloc_id(sizeof(sign_entry_T), FALSE, aid_insert_sign);
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
224 if (newsign == NULL)
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
225 return;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
226
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
227 newsign->se_id = id;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
228 newsign->se_lnum = lnum;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
229 newsign->se_typenr = typenr;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
230 if (group != NULL)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 {
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
232 newsign->se_group = sign_group_ref(group);
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
233 if (newsign->se_group == NULL)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 {
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
235 vim_free(newsign);
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
236 return;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 }
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
238 }
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
239 else
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
240 newsign->se_group = NULL;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
241 newsign->se_priority = prio;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
242 newsign->se_next = next;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
243 newsign->se_prev = prev;
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
244 if (next != NULL)
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
245 next->se_prev = newsign;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
247 if (prev == NULL)
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
248 {
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
249 // When adding first sign need to redraw the windows to create the
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
250 // column for signs.
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
251 if (buf->b_signlist == NULL)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 {
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
253 redraw_buf_later(buf, UPD_NOT_VALID);
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
254 changed_line_abv_curs();
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
255 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
257 // first sign in signlist
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
258 buf->b_signlist = newsign;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 #ifdef FEAT_NETBEANS_INTG
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
260 if (netbeans_active())
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
261 buf->b_has_sign_column = TRUE;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 #endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 }
31809
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
264 else
543153d582d5 patch 9.0.1237: code is indented more than necessary
Bram Moolenaar <Bram@vim.org>
parents: 31231
diff changeset
265 prev->se_next = newsign;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 * 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
270 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 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
273 buf_T *buf, // buffer to store sign in
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
274 sign_entry_T *prev, // previous sign entry
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 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
276 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
277 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
278 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
279 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
280 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
281 sign_entry_T *sign;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 // 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
284 // the proper position in the list for this lnum.
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
285 while (prev != NULL && prev->se_lnum == lnum && prev->se_priority <= prio)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
286 prev = prev->se_prev;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287 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
288 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
289 else
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
290 sign = prev->se_next;
15330
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 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
293 }
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 /*
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
296 * Lookup a sign by typenr. Returns NULL if sign is not found.
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
297 */
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
298 static sign_T *
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
299 find_sign_by_typenr(int typenr)
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
300 {
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
301 sign_T *sp;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
302
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
303 FOR_ALL_SIGNS(sp)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
304 if (sp->sn_typenr == typenr)
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
305 return sp;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
306 return NULL;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
307 }
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
308
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
309 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
310 * 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
311 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
312 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
313 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
314 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
315 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
316
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
317 FOR_ALL_SIGNS(sp)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318 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
319 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
320 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
321 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
322
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 * 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
325 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
326 static dict_T *
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
327 sign_get_info(sign_entry_T *sign)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
328 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 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
330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 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
332 return NULL;
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
333 dict_add_number(d, "id", sign->se_id);
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
334 dict_add_string(d, "group", (sign->se_group == NULL) ?
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
335 (char_u *)"" : sign->se_group->sg_name);
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
336 dict_add_number(d, "lnum", sign->se_lnum);
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
337 dict_add_string(d, "name", sign_typenr2name(sign->se_typenr));
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
338 dict_add_number(d, "priority", sign->se_priority);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
339
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
340 return d;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
341 }
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 /*
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
344 * Sort the signs placed on the same line as "sign" by priority. Invoked after
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
345 * changing the priority of an already placed sign. Assumes the signs in the
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
346 * buffer are sorted by line number and priority.
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
347 */
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
348 static void
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
349 sign_sort_by_prio_on_line(buf_T *buf, sign_entry_T *sign)
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
350 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
351 sign_entry_T *p = NULL;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
352
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
353 // If there is only one sign in the buffer or only one sign on the line or
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
354 // the sign is already sorted by priority, then return.
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
355 if ((sign->se_prev == NULL
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
356 || sign->se_prev->se_lnum != sign->se_lnum
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
357 || sign->se_prev->se_priority > sign->se_priority)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
358 && (sign->se_next == NULL
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
359 || sign->se_next->se_lnum != sign->se_lnum
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
360 || sign->se_next->se_priority < sign->se_priority))
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
361 return;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
362
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
363 // One or more signs on the same line as 'sign'
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
364 // Find a sign after which 'sign' should be inserted
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
365
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
366 // First search backward for a sign with higher priority on the same line
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
367 p = sign;
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
368 while (p->se_prev != NULL && p->se_prev->se_lnum == sign->se_lnum
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
369 && p->se_prev->se_priority <= sign->se_priority)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
370 p = p->se_prev;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
371
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
372 if (p == sign)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
373 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
374 // Sign not found. Search forward for a sign with priority just before
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
375 // 'sign'.
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
376 p = sign->se_next;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
377 while (p->se_next != NULL && p->se_next->se_lnum == sign->se_lnum
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
378 && p->se_next->se_priority > sign->se_priority)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
379 p = p->se_next;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
380 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
381
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
382 // Remove 'sign' from the list
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
383 if (buf->b_signlist == sign)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
384 buf->b_signlist = sign->se_next;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
385 if (sign->se_prev != NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
386 sign->se_prev->se_next = sign->se_next;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
387 if (sign->se_next != NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
388 sign->se_next->se_prev = sign->se_prev;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
389 sign->se_prev = NULL;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
390 sign->se_next = NULL;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
391
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
392 // Re-insert 'sign' at the right place
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
393 if (p->se_priority <= sign->se_priority)
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
394 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
395 // 'sign' has a higher priority and should be inserted before 'p'
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
396 sign->se_prev = p->se_prev;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
397 sign->se_next = p;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
398 p->se_prev = sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
399 if (sign->se_prev != NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
400 sign->se_prev->se_next = sign;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
401 if (buf->b_signlist == p)
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
402 buf->b_signlist = sign;
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
403 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
404 else
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
405 {
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
406 // 'sign' has a lower priority and should be inserted after 'p'
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
407 sign->se_prev = p;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
408 sign->se_next = p->se_next;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
409 p->se_next = sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
410 if (sign->se_next != NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
411 sign->se_next->se_prev = sign;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
412 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
413 }
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
414
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
415 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 * 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
417 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 buf_addsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 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
421 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
422 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
423 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
424 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
425 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
426 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
427 sign_entry_T *sign; // a sign in the signlist
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
428 sign_entry_T *prev; // the previous sign
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 prev = NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 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
432 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
433 if (lnum == sign->se_lnum && id == sign->se_id
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
434 && 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
435 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436 // Update an existing sign
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
437 sign->se_typenr = typenr;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
438 sign->se_priority = prio;
16978
15bc5a64bd50 patch 8.1.1489: sign order wrong when priority was changed
Bram Moolenaar <Bram@vim.org>
parents: 16930
diff changeset
439 sign_sort_by_prio_on_line(buf, sign);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 }
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
442 else if (lnum < sign->se_lnum)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 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
445 lnum, typenr);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 prev = sign;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
450
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
451 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
452 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
453 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
454
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 * 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
457 * 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
458 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 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
460 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
461 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
462 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
463 char_u *group, // sign group
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
464 int typenr, // typenr of sign we are adding
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
465 int prio) // sign priority
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
467 sign_entry_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
468
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 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
470 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
471 if (sign->se_id == markId && 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
472 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
473 sign->se_typenr = typenr;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
474 sign->se_priority = prio;
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
475 sign_sort_by_prio_on_line(buf, sign);
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
476 return sign->se_lnum;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
477 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
478 }
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 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
481 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
482
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
483 /*
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
484 * Return the attributes of the first sign placed on line 'lnum' in buffer
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
485 * 'buf'. Used when refreshing the screen. Returns TRUE if a sign is found on
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
486 * 'lnum', FALSE otherwise.
15330
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 int
18603
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
489 buf_get_signattrs(win_T *wp, linenr_T lnum, sign_attrs_T *sattr)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
490 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
491 sign_entry_T *sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
492 sign_T *sp;
18603
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
493 buf_T *buf = wp->w_buffer;
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
494
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19888
diff changeset
495 CLEAR_POINTER(sattr);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
496
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
497 FOR_ALL_SIGNS_IN_BUF(buf, sign)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
498 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
499 if (sign->se_lnum > lnum)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
500 // Signs are sorted by line number in the buffer. No need to check
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
501 // for signs after the specified line number 'lnum'.
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
502 break;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
503
18603
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
504 if (sign->se_lnum == lnum
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18744
diff changeset
505 # ifdef FEAT_PROP_POPUP
18744
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
506 && sign_group_for_window(sign, wp)
18603
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
507 # endif
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
508 )
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
509 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
510 sattr->sat_typenr = sign->se_typenr;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
511 sp = find_sign_by_typenr(sign->se_typenr);
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
512 if (sp == NULL)
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
513 return FALSE;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
514
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 # ifdef FEAT_SIGN_ICONS
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
516 sattr->sat_icon = sp->sn_image;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 # endif
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
518 sattr->sat_text = sp->sn_text;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
519 if (sattr->sat_text != NULL && sp->sn_text_hl > 0)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
520 sattr->sat_texthl = syn_id2attr(sp->sn_text_hl);
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
521 if (sp->sn_line_hl > 0)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
522 sattr->sat_linehl = syn_id2attr(sp->sn_line_hl);
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
523 if (sp->sn_cul_hl > 0)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
524 sattr->sat_culhl = syn_id2attr(sp->sn_cul_hl);
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
525 if (sp->sn_num_hl > 0)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
526 sattr->sat_numhl = syn_id2attr(sp->sn_num_hl);
22017
2794a2666769 patch 8.2.1558: signs test fails
Bram Moolenaar <Bram@vim.org>
parents: 21461
diff changeset
527 sattr->sat_priority = sign->se_priority;
19447
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
528
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
529 // If there is another sign next with the same priority, may
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
530 // combine the text and the line highlighting.
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
531 if (sign->se_next != NULL
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
532 && sign->se_next->se_priority == sign->se_priority
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
533 && sign->se_next->se_lnum == sign->se_lnum)
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
534 {
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
535 sign_T *next_sp = find_sign_by_typenr(sign->se_next->se_typenr);
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
536
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
537 if (next_sp != NULL)
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
538 {
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
539 if (sattr->sat_icon == NULL && sattr->sat_text == NULL)
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
540 {
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
541 # ifdef FEAT_SIGN_ICONS
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
542 sattr->sat_icon = next_sp->sn_image;
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
543 # endif
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
544 sattr->sat_text = next_sp->sn_text;
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
545 }
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
546 if (sp->sn_text_hl <= 0 && next_sp->sn_text_hl > 0)
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
547 sattr->sat_texthl = syn_id2attr(next_sp->sn_text_hl);
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
548 if (sp->sn_line_hl <= 0 && next_sp->sn_line_hl > 0)
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
549 sattr->sat_linehl = syn_id2attr(next_sp->sn_line_hl);
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
550 if (sp->sn_cul_hl <= 0 && next_sp->sn_cul_hl > 0)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
551 sattr->sat_culhl = syn_id2attr(next_sp->sn_cul_hl);
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
552 if (sp->sn_num_hl <= 0 && next_sp->sn_num_hl > 0)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
553 sattr->sat_numhl = syn_id2attr(next_sp->sn_num_hl);
19447
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
554 }
5b82f041dbbb patch 8.2.0281: two placed signs in the same line are not combined
Bram Moolenaar <Bram@vim.org>
parents: 19095
diff changeset
555 }
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
556 return TRUE;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
557 }
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
558 }
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
559 return FALSE;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
560 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
561
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
562 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
563 * 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
564 * 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
565 * 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
566 * 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
567 * 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
568 * 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
569 * 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
570 * 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
571 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
572 linenr_T
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
573 buf_delsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
574 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
575 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
576 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
577 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
578 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
579 sign_entry_T **lastp; // pointer to pointer to current sign
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
580 sign_entry_T *sign; // a sign in a b_signlist
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
581 sign_entry_T *next; // the next sign in a b_signlist
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
582 linenr_T lnum; // line number whose sign was deleted
15330
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 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
585 lnum = 0;
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 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
588 next = sign->se_next;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
589 if ((id == 0 || sign->se_id == id)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
590 && (atlnum == 0 || sign->se_lnum == atlnum)
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
591 && 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
592
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594 *lastp = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 if (next != NULL)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
596 next->se_prev = sign->se_prev;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
597 lnum = sign->se_lnum;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
598 if (sign->se_group != NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
599 sign_group_unref(sign->se_group->sg_name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 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
601 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
602
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603 // 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
604 // 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
605 // 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
606 // 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
607 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
608 || (*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
609 || (*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
610 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 else
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
613 lastp = &sign->se_next;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
616 // 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
617 // 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
618 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
619 {
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
620 redraw_buf_later(buf, UPD_NOT_VALID);
17105
811c5c2f5236 patch 8.1.1552: cursor position is wrong after sign column changes
Bram Moolenaar <Bram@vim.org>
parents: 16978
diff changeset
621 changed_line_abv_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
622 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 return lnum;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 * 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
630 * 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
631 * 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
632 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 buf_findsign(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 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
636 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
637 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
638 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
639 sign_entry_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
640
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641 FOR_ALL_SIGNS_IN_BUF(buf, sign)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
642 if (sign->se_id == id && sign_in_group(sign, group))
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
643 return sign->se_lnum;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649 * 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
650 * 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
651 */
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
652 static sign_entry_T *
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 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
654 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
655 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
656 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
657 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
658 sign_entry_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
659
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660 FOR_ALL_SIGNS_IN_BUF(buf, sign)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
661 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
662 if (sign->se_lnum > lnum)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
663 // Signs are sorted by line number in the buffer. No need to check
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
664 // for signs after the specified line number 'lnum'.
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
665 break;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
666
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
667 if (sign->se_lnum == lnum && 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
668 return sign;
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
669 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
670
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 * 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
676 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 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
679 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
680 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
681 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
682 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
683 sign_entry_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
684
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 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
686 if (sign != NULL)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
687 return sign->se_id;
15330
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 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 }
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 # 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
693 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 * 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
695 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 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
698 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
699 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
700 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
701 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
702 sign_entry_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
703
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 FOR_ALL_SIGNS_IN_BUF(buf, sign)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
705 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
706 if (sign->se_lnum > lnum)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
707 // Signs are sorted by line number in the buffer. No need to check
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
708 // for signs after the specified line number 'lnum'.
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
709 break;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
710
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
711 if (sign->se_lnum == lnum && sign->se_typenr == typenr)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
712 return sign->se_id;
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
713 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
714
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
715 return 0;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 # 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
720 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 * 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
722 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724 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
725 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
726 sign_entry_T *sign; // a sign in the signlist
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
727 int count = 0;
15330
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 FOR_ALL_SIGNS_IN_BUF(buf, sign)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
730 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
731 if (sign->se_lnum > lnum)
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
732 // Signs are sorted by line number in the buffer. No need to check
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
733 // for signs after the specified line number 'lnum'.
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
734 break;
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
735
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
736 if (sign->se_lnum == lnum)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
737 if (sign_get_image(sign->se_typenr) != NULL)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
738 count++;
17264
82b5d981fe59 patch 8.1.1631: displaying signs is inefficient
Bram Moolenaar <Bram@vim.org>
parents: 17247
diff changeset
739 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
740
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
741 return count;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
742 }
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
743 # endif // FEAT_SIGN_ICONS
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
744 # endif // FEAT_NETBEANS_INTG
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
747 * 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
748 * 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
749 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
750 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
751 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
752 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
753 sign_entry_T *sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
754 sign_entry_T **lastp; // pointer to pointer to current sign
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
755 sign_entry_T *next;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
757 // 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
758 // 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
759 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
760 {
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
761 redraw_buf_later(buf, UPD_NOT_VALID);
17105
811c5c2f5236 patch 8.1.1552: cursor position is wrong after sign column changes
Bram Moolenaar <Bram@vim.org>
parents: 16978
diff changeset
762 changed_line_abv_curs();
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
763 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 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
766 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
767 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
768 next = sign->se_next;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 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
770 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
771 *lastp = next;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
772 if (next != NULL)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
773 next->se_prev = sign->se_prev;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
774 if (sign->se_group != NULL)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
775 sign_group_unref(sign->se_group->sg_name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
776 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
777 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 else
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
779 lastp = &sign->se_next;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784 * 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
785 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 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
788 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
789 buf_T *buf;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
790 sign_entry_T *sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
791 char lbuf[MSG_BUF_LEN];
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
792 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
793
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
794 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
795 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
796 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
797 buf = firstbuf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
798 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
799 buf = rbuf;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
800 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
801 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
802 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
803 {
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
804 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
805 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
806 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
807 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
808 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
809 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
810 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
811 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
812 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
813 continue;
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
814 if (sign->se_group != NULL)
15386
317846db300a patch 8.1.0701: sign message not translated and inconsistent spacing
Bram Moolenaar <Bram@vim.org>
parents: 15378
diff changeset
815 vim_snprintf(group, MSG_BUF_LEN, _(" group=%s"),
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
816 sign->se_group->sg_name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 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
819 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
820 _(" line=%ld id=%d%s name=%s priority=%d"),
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
821 (long)sign->se_lnum, sign->se_id, group,
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
822 sign_typenr2name(sign->se_typenr), sign->se_priority);
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
823 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
824 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
825 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
826 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
827 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
828 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
829 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
830 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
831
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
832 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
833 * 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
834 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
835 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
836 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
837 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
838 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
839 long amount,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
840 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
841 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
842 sign_entry_T *sign; // a sign in a b_signlist
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
843 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
844
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 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
846 {
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
847 // Ignore changes to lines after the sign
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
848 if (sign->se_lnum < line1)
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
849 continue;
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
850 new_lnum = sign->se_lnum;
28169
bef82285dda0 patch 8.2.4610: some conditions are always true
Bram Moolenaar <Bram@vim.org>
parents: 27426
diff changeset
851 if (sign->se_lnum <= line2)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852 {
15519
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
853 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
854 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
855 }
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
856 else if (sign->se_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
857 // 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
858 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
859
89e76a598b30 patch 8.1.0767: when deleting lines at the bottom signs are misplaced
Bram Moolenaar <Bram@vim.org>
parents: 15490
diff changeset
860 // 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
861 // 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
862 // 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
863 if (new_lnum <= curbuf->b_ml.ml_line_count)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
864 sign->se_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
865 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
866 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
867
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
868 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
869 * 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
870 * "*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
871 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
872 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
873 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
874 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
875 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
876 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
877 int idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
878 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
879
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
880 *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
881 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
882 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
883 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
884 *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
885 return idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
886 }
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 * 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
890 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 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
892 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
893 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894 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
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 (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
897 *sp_prev = NULL;
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
898 FOR_ALL_SIGNS(sp)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 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
901 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
902 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
903 *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
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 return sp;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 /*
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
910 * 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
911 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
912 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
913 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
914 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
915 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
916 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
917 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
918
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
919 // Allocate a new sign.
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16782
diff changeset
920 sp = alloc_clear_id(sizeof(sign_T), aid_sign_define_by_name);
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
921 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
922 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
923
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
924 // 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
925 // 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
926 // 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
927 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
928 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
929 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
930 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
931 ++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
932 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
933 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
934 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
935 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
936 vim_free(sp);
26948
51ddf6740ac6 patch 8.2.4003: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26893
diff changeset
937 emsg(_(e_too_many_signs_defined));
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
938 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
939 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
940 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
941 continue;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
942 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
943 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
944 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
945
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
946 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
947 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
948 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
949
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
950 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
951 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
952 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
953 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
954 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
955 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
956
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
957 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
958 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
959
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
960 /*
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
961 * 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
962 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
963 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
964 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
965 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
966 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
967 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
968 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
969 # 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
970 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
971 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
972 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
973 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
974 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
975 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
976 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
977 # endif
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
978 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
979
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
980 /*
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
981 * 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
982 */
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
983 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
984 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
985 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
986 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
987 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
988 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
989 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
990
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
991 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
992
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
993 // 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
994 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
995 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
996 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
997 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
998 --endp;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
999 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1000
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1001 // 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
1002 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
1003 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1004 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
1005 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
1006 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1007 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
1008 break;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1009 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
1010 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1011 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1012 else
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1013 {
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1014 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
1015 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
1016 break;
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1017 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
1018 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1019
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1020 // 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
1021 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
1022 {
26893
79c76ca2c53c patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
1023 semsg(_(e_invalid_sign_text_str), text);
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1024 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
1025 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1026
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1027 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
1028 // 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
1029 // 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
1030 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
1031 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
1032
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1033 // 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
1034 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
1035 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
1036
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1037 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
1038 }
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1039
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1040 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1041 * 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
1042 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1043 int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1044 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
1045 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
1046 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
1047 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
1048 char_u *text,
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1049 char_u *texthl,
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1050 char_u *culhl,
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1051 char_u *numhl,
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1052 int prio)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1053 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1054 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
1055 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
1056
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1057 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
1058 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
1059 {
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1060 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
1061 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
1062 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1063
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1064 // 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
1065 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
1066 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
1067 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1068 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
1069 }
19095
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1070 else
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1071 {
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1072 win_T *wp;
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1073
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1074 // Signs may already exist, a redraw is needed in windows with a
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1075 // non-empty sign list.
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1076 FOR_ALL_WINDOWS(wp)
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1077 if (wp->w_buffer->b_signlist != NULL)
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1078 redraw_buf_later(wp->w_buffer, UPD_NOT_VALID);
19095
5cd0986ab02e patch 8.2.0108: when sign text is changed a manual redraw is needed
Bram Moolenaar <Bram@vim.org>
parents: 18812
diff changeset
1079 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1080
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1081 // 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
1082 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
1083 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
1084
15529
233e2c585e03 patch 8.1.0772: the sign_define_by_name() function is too long
Bram Moolenaar <Bram@vim.org>
parents: 15519
diff changeset
1085 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
1086 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
1087
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1088 sp->sn_priority = prio;
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1089
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1090 if (linehl != NULL)
26432
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1091 {
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1092 if (*linehl == NUL)
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1093 sp->sn_line_hl = 0;
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1094 else
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1095 sp->sn_line_hl = syn_check_group(linehl, (int)STRLEN(linehl));
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1096 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1097
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1098 if (texthl != NULL)
26432
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1099 {
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1100 if (*texthl == NUL)
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1101 sp->sn_text_hl = 0;
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1102 else
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1103 sp->sn_text_hl = syn_check_group(texthl, (int)STRLEN(texthl));
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1104 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1105
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1106 if (culhl != NULL)
26432
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1107 {
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1108 if (*culhl == NUL)
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1109 sp->sn_cul_hl = 0;
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1110 else
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1111 sp->sn_cul_hl = syn_check_group(culhl, (int)STRLEN(culhl));
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1112 }
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1113
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1114 if (numhl != NULL)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1115 {
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1116 if (*numhl == NUL)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1117 sp->sn_num_hl = 0;
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1118 else
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1119 sp->sn_num_hl = syn_check_group(numhl, (int)STRLEN(numhl));
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1120 }
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1121
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1122 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1123 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1124
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1125 /*
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1126 * Return TRUE if sign "name" exists.
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1127 */
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1128 int
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1129 sign_exists_by_name(char_u *name)
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1130 {
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1131 return sign_find(name, NULL) != NULL;
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1132 }
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1133
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1134 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1135 * 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
1136 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1137 int
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1138 sign_undefine_by_name(char_u *name, int give_error)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1139 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1140 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
1141 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
1142
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1143 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
1144 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
1145 {
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1146 if (give_error)
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1147 semsg(_(e_unknown_sign_str), name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1148 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1149 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1150 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
1151
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1152 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1153 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1154
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1155 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1156 * 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
1157 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1158 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1159 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
1160 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1161 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
1162
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1163 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
1164 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
1165 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
1166 else
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1167 semsg(_(e_unknown_sign_str), name);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1168 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1169
17247
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1170 static void
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1171 may_force_numberwidth_recompute(buf_T *buf, int unplace)
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1172 {
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1173 tabpage_T *tp;
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1174 win_T *wp;
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1175
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1176 FOR_ALL_TAB_WINDOWS(tp, wp)
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1177 if (wp->w_buffer == buf
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1178 && (wp->w_p_nu || wp->w_p_rnu)
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1179 && (unplace || wp->w_nrwidth_width < 2)
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1180 && (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1181 wp->w_nrwidth_line_count = 0;
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1182 }
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1183
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1184 /*
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
1185 * 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
1186 */
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1187 int
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1188 sign_place(
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1189 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
1190 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
1191 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
1192 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
1193 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
1194 int prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1195 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1196 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
1197
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1198 // 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
1199 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
1200 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1201
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
1202 FOR_ALL_SIGNS(sp)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1203 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
1204 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1205 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
1206 {
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1207 semsg(_(e_unknown_sign_str), 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
1208 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1209 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1210 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
1211 *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
1212
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1213 // Use the default priority value for this sign.
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1214 if (prio == -1)
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1215 prio = (sp->sn_priority != -1) ? sp->sn_priority : SIGN_DEF_PRIO;
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1216
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1217 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
1218 // ":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
1219 // 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
1220 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
1221 else
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
1222 // ":sign place {id} file={fname}": change sign type and/or priority
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
1223 lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
1224 prio);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1225 if (lnum > 0)
17247
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1226 {
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1227 redraw_buf_line_later(buf, lnum);
17247
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1228
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1229 // When displaying signs in the 'number' column, if the width of the
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1230 // number column is less than 2, then force recomputing the width.
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1231 may_force_numberwidth_recompute(buf, FALSE);
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1232 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1233 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1234 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26948
diff changeset
1235 semsg(_(e_not_possible_to_change_sign_str), 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
1236 return FAIL;
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 return OK;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1242 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1243 * 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
1244 */
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
1245 static int
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1246 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
1247 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1248 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
1249 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1250
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1251 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
1252 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1253 // Delete all the signs in the specified buffer
29732
89e1d67814a9 patch 9.0.0206: redraw flags are not named specifically
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1254 redraw_buf_later(buf, UPD_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
1255 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
1256 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1257 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1258 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1259 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
1260
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1261 // 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
1262 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
1263 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
1264 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1265 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1266
17247
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1267 // When all the signs in a buffer are removed, force recomputing the
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1268 // number column width (if enabled) in all the windows displaying the
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1269 // buffer if 'signcolumn' is set to 'number' in that window.
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1270 if (buf->b_signlist == NULL)
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1271 may_force_numberwidth_recompute(buf, TRUE);
cbd0432cf8ff patch 8.1.1623: display wrong with signs in narrow number column
Bram Moolenaar <Bram@vim.org>
parents: 17218
diff changeset
1272
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1273 return OK;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1274 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1275
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1276 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1277 * 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
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 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1280 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
1281 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1282 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
1283
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1284 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
1285 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
1286 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
1287 else
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1288 emsg(_(e_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
1289 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1290
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1291 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1292 * 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
1293 */
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
1294 static linenr_T
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1295 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
1296 {
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1297 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
1298
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1299 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
1300 {
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1301 semsg(_(e_invalid_sign_id_nr), 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
1302 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
1303 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1304
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1305 // 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
1306 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
1307 { // ... 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
1308 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
1309 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
1310 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
1311 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1312 else
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1313 { // ... 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
1314 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
1315
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1316 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
1317 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26948
diff changeset
1318 emsg(_(e_cannot_jump_to_buffer_that_does_not_have_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
1319 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
1320 }
16768
695d9ef00b03 patch 8.1.1386: unessesary type casts for lalloc()
Bram Moolenaar <Bram@vim.org>
parents: 15864
diff changeset
1321 cmd = alloc(STRLEN(buf->b_fname) + 25);
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1322 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
1323 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
1324 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
1325 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
1326 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
1327 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1328 # 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
1329 foldOpenCursor();
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1330 # endif
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1331
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1332 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
1333 }
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1334
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1335 /*
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1336 * ":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
1337 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1338 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1339 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
1340 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1341 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
1342 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
1343 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
1344 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
1345 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
1346 char_u *texthl = NULL;
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1347 char_u *culhl = NULL;
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1348 char_u *numhl = NULL;
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1349 int prio = -1;
26432
99a512bd8423 patch 8.2.3747: cannot remove highlight from an existing sign
Bram Moolenaar <Bram@vim.org>
parents: 26424
diff changeset
1350 int failed = FALSE;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1351
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1352 // 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
1353 for (;;)
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 = skipwhite(p);
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1356 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
1357 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1358 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
1359 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
1360 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1361 arg += 5;
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1362 icon = vim_strnsave(arg, p - arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1363 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1364 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
1365 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1366 arg += 5;
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1367 text = vim_strnsave(arg, p - arg);
15330
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 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
1370 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1371 arg += 7;
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1372 linehl = vim_strnsave(arg, p - arg);
15330
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 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
1375 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1376 arg += 7;
20830
9064044fd4f6 patch 8.2.0967: unnecessary type casts for vim_strnsave()
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
1377 texthl = vim_strnsave(arg, p - arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1378 }
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1379 else if (STRNCMP(arg, "culhl=", 6) == 0)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1380 {
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1381 arg += 6;
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1382 culhl = vim_strnsave(arg, p - arg);
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1383 }
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1384 else if (STRNCMP(arg, "numhl=", 6) == 0)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1385 {
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1386 arg += 6;
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1387 numhl = vim_strnsave(arg, p - arg);
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1388 }
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1389 else if (STRNCMP(arg, "priority=", 9) == 0)
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1390 {
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1391 arg += 9;
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1392 prio = atoi((char *)arg);
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1393 arg = skiptowhite(arg);
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1394 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1395 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1396 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1397 semsg(_(e_invalid_argument_str), arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1398 failed = TRUE;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1399 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1400 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1401 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1402
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1403 if (!failed)
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1404 sign_define_by_name(sign_name, icon, linehl, text, texthl, culhl, numhl, prio);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1405
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1406 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
1407 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
1408 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
1409 vim_free(texthl);
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1410 vim_free(culhl);
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1411 vim_free(numhl);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1412 }
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 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1415 * ":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
1416 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1417 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1418 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
1419 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
1420 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
1421 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
1422 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1423 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
1424 int prio)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1425 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1426 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
1427 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1428 // 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
1429 // :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
1430 // :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
1431 // :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
1432 // :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
1433 // :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
1434 // :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
1435 // :sign place
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1436 // :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
1437 // :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
1438 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
1439 || (group != NULL && *group == '\0'))
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1440 emsg(_(e_invalid_argument));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1441 else
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_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
1443 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1444 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1445 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1446 // 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
1447 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
1448 || (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
1449 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1450 emsg(_(e_invalid_argument));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1451 return;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1454 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
1455 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1456 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1457
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1458 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1459 * ":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
1460 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1461 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1462 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
1463 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
1464 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
1465 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
1466 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1467 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
1468 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1469 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
1470 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1471 emsg(_(e_invalid_argument));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1472 return;
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1475 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
1476 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1477 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
1478 // :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
1479 // :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
1480 // :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
1481 // :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
1482 // :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
1483 // :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
1484 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
1485 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1486 // :sign unplace *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1487 // :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
1488 // :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
1489 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
1490 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
1491 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
1492 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1493 else
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 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
1496 // :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
1497 // :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
1498 // :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
1499 // :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
1500 // :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
1501 // :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
1502 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
1503 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1504 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1505 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
1506 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1507 // :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
1508 // :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
1509 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
1510 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1511 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1512 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1513 // :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
1514 // :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
1515 // :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
1516 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
1517 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
1518 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1519 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1520 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1521 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1522
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1523 /*
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1524 * 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
1525 * :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
1526 * :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
1527 * :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
1528 * :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
1529 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1530 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1531 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
1532 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
1533 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
1534 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
1535 int id,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1536 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
1537 {
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1538 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
1539 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1540 emsg(_(e_argument_required));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1541 return;
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
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1544 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
1545 || 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
1546 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1547 // 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
1548 // or a line number or a sign name is specified.
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1549 emsg(_(e_invalid_argument));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1550 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1551 }
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
1552 (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
1553 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1554
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1555 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1556 * 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
1557 * ":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
1558 * 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
1559 * 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
1560 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1561 static int
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1562 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
1563 int cmd,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1564 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
1565 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
1566 int *signid,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1567 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
1568 int *prio,
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1569 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
1570 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
1571 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1572 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
1573 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
1574 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
1575 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
1576
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1577 // 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
1578 arg1 = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1579 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
1580 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1581 *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
1582 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
1583 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1584 *signid = -1;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1585 arg = arg1;
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 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1588 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
1589 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1590
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1591 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
1592 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1593 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
1594 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1595 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1596 *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
1597 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
1598 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
1599 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1600 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
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 (*signid != -1)
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1603 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1604 emsg(_(e_invalid_argument));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1605 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1606 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1607 *signid = -2;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1608 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
1609 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1610 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
1611 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1612 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1613 name = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1614 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
1615 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
1616 *arg++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1617 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
1618 ++name;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1619 *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
1620 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1621 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
1622 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1623 arg += 6;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1624 *group = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1625 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
1626 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
1627 *arg++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1628 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1629 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
1630 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1631 arg += 9;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1632 *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
1633 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
1634 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1635 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
1636 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1637 arg += 5;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1638 filename = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1639 *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
1640 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1641 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1642 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
1643 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1644 arg += 7;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1645 filename = arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1646 *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
1647 if (*skipwhite(arg) != NUL)
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26877
diff changeset
1648 semsg(_(e_trailing_characters_str), arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1649 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1650 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1651 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1652 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
1653 emsg(_(e_invalid_argument));
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1654 return FAIL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1655 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1656 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
1657 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1658
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1659 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
1660 {
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1661 semsg(_(e_invalid_buffer_name_str), filename);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1662 return FAIL;
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
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1665 // 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
1666 // 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
1667 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
1668 || cmd == SIGNCMD_JUMP))
15378
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1669 *buf = curwin->w_buffer;
0d76dd701e49 patch 8.1.0697: ":sign place" requires the buffer argument
Bram Moolenaar <Bram@vim.org>
parents: 15330
diff changeset
1670
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1671 return OK;
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 * ":sign" command
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1676 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1677 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1678 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
1679 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1680 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
1681 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
1682 int idx;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1683 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
1684 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
1685
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1686 // 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
1687 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
1688 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
1689 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
1690 {
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1691 semsg(_(e_unknown_sign_command_str), arg);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1692 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1693 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1694 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
1695
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1696 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
1697 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1698 // 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
1699 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
1700 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1701 // ":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
1702 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
1703 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
1704 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1705 else if (*arg == NUL)
26853
806f31579357 patch 8.2.3955: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26690
diff changeset
1706 emsg(_(e_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
1707 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1708 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1709 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
1710
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1711 // 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
1712 // 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
1713 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
1714 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
1715 *p++ = NUL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1716 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
1717 ++arg;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1718 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
1719
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1720 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
1721 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
1722 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
1723 // ":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
1724 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
1725 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1726 // ":sign undefine {name}"
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
1727 sign_undefine_by_name(name, TRUE);
15330
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 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
1730 return;
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 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1733 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1734 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1735 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
1736 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
1737 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
1738 char_u *group = NULL;
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1739 int prio = -1;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1740
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1741 // 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
1742 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
1743 &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
1744 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1745
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1746 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
1747 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
1748 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
1749 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
1750 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
1751 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
1752 }
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1756 * 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
1757 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1758 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1759 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
1760 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1761 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
1762
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1763 dict_add_string(retdict, "name", 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
1764 if (sp->sn_icon != NULL)
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1765 dict_add_string(retdict, "icon", sp->sn_icon);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1766 if (sp->sn_text != NULL)
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1767 dict_add_string(retdict, "text", sp->sn_text);
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1768 if (sp->sn_priority > 0)
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1769 dict_add_number(retdict, "priority", sp->sn_priority);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1770 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
1771 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1772 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
1773 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
1774 p = (char_u *)"NONE";
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1775 dict_add_string(retdict, "linehl", p);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1776 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1777 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
1778 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1779 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
1780 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
1781 p = (char_u *)"NONE";
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1782 dict_add_string(retdict, "texthl", p);
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1783 }
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1784 if (sp->sn_cul_hl > 0)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1785 {
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1786 p = get_highlight_name_ext(NULL, sp->sn_cul_hl - 1, FALSE);
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1787 if (p == NULL)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1788 p = (char_u *)"NONE";
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1789 dict_add_string(retdict, "culhl", p);
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1790 }
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1791 if (sp->sn_num_hl > 0)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1792 {
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1793 p = get_highlight_name_ext(NULL, sp->sn_num_hl - 1, FALSE);
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1794 if (p == NULL)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1795 p = (char_u *)"NONE";
27426
41e0dcf38521 patch 8.2.4241: some type casts are redundant
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1796 dict_add_string(retdict, "numhl", p);
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1797 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1798 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1799
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1800 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1801 * 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
1802 * 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
1803 */
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
1804 static void
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1805 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
1806 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1807 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
1808 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
1809
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1810 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
1811 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1812 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
1813 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
1814 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1815 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1816
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1817 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
1818 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1819 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
1820 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1821 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
1822 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1823 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
1824
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1825 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
1826 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1827 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1828 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1829
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 * 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
1832 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1833 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1834 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
1835 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1836 sign_entry_T *sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1837 dict_T *d;
15330
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 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
1840 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1841 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
1842 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
1843 }
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
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1846 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1847 * 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
1848 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1849 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1850 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
1851 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
1852 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
1853 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
1854 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
1855 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
1856 {
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1857 dict_T *d;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1858 list_T *l;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1859 sign_entry_T *sign;
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1860 dict_T *sdict;
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1861
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1862 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
1863 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1864 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
1865
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1866 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
1867
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1868 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
1869 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1870 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
1871
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1872 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
1873 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1874 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
1875 continue;
15402
c17b5e30a0af patch 8.1.0709: windows are updated for every added/deleted sign
Bram Moolenaar <Bram@vim.org>
parents: 15388
diff changeset
1876 if ((lnum == 0 && sign_id == 0)
18422
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1877 || (sign_id == 0 && lnum == sign->se_lnum)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1878 || (lnum == 0 && sign_id == sign->se_id)
1848b3e07266 patch 8.1.2205: sign entry structure has confusing name
Bram Moolenaar <Bram@vim.org>
parents: 17805
diff changeset
1879 || (lnum == sign->se_lnum && sign_id == sign->se_id))
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1880 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1881 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
1882 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
1883 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1884 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1885 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1886
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1887 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1888 * 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
1889 * 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
1890 * 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
1891 */
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
1892 static void
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1893 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
1894 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
1895 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
1896 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
1897 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
1898 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
1899 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1900 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
1901 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
1902 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1903 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1904 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
1905 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
1906 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
1907 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1908 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1909
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1910 # 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
1911 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1912 * 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
1913 * 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
1914 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1915 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1916 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
1917 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1918 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
1919
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
1920 FOR_ALL_SIGNS(sp)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1921 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
1922 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
1923 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1924 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1925
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1926 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1927 * 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
1928 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1929 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1930 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
1931 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1932 char_u *p;
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1933 char lbuf[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
1934
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 15418
diff changeset
1935 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
1936 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
1937 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1938 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
1939 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
1940 # 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
1941 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
1942 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
1943 # else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1944 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
1945 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1946 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1947 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
1948 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1949 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
1950 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
1951 }
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1952 if (sp->sn_priority > 0)
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1953 {
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1954 vim_snprintf(lbuf, MSG_BUF_LEN, " priority=%d", sp->sn_priority);
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1955 msg_puts(lbuf);
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
1956 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1957 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
1958 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1959 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
1960 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
1961 if (p == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1962 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
1963 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1964 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
1965 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1966 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
1967 {
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1968 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
1969 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
1970 if (p == NULL)
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1971 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
1972 else
15543
dd725a8ab112 patch 8.1.0779: argument for message functions is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 15529
diff changeset
1973 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
1974 }
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1975 if (sp->sn_cul_hl > 0)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1976 {
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1977 msg_puts(" culhl=");
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1978 p = get_highlight_name_ext(NULL, sp->sn_cul_hl - 1, FALSE);
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1979 if (p == NULL)
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1980 msg_puts("NONE");
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1981 else
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1982 msg_puts((char *)p);
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
1983 }
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1984 if (sp->sn_num_hl > 0)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1985 {
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1986 msg_puts(" numhl=");
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1987 p = get_highlight_name_ext(NULL, sp->sn_num_hl - 1, FALSE);
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1988 if (p == NULL)
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1989 msg_puts("NONE");
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1990 else
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1991 msg_puts((char *)p);
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
1992 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1993 }
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 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1996 * 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
1997 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1998 static void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1999 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
2000 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2001 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
2002 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
2003 # 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
2004 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
2005 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2006 out_flush();
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2007 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
2008 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2009 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2010 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
2011 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
2012 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
2013 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2014 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
2015 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
2016 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2017
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2018 # 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
2019 void *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2020 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
2021 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
2022 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2023 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
2024
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
2025 FOR_ALL_SIGNS(sp)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2026 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
2027 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
2028 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2029 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2030 # endif
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2031
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2032 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2033 * 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
2034 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2035 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2036 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
2037 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2038 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
2039 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
2040 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2041
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2042 static enum
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2043 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2044 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
2045 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
2046 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
2047 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
2048 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
2049 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
2050 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
2051 } expand_what;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2052
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2053 /*
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2054 * 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
2055 */
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2056 static char_u *
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2057 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
2058 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2059 int current_idx;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2060 sign_T *sp;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2061
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2062 // 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
2063 current_idx = 0;
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
2064 FOR_ALL_SIGNS(sp)
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2065 if (current_idx++ == idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2066 return sp->sn_name;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2067 return NULL;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2068 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2069
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2070 /*
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2071 * 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
2072 */
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2073 static char_u *
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2074 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
2075 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2076 int current_idx;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2077 int todo;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2078 hashitem_T *hi;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2079 signgroup_T *group;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2080
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2081 // 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
2082 current_idx = 0;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2083 todo = (int)sg_table.ht_used;
32118
04d9dff67d99 patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Bram Moolenaar <Bram@vim.org>
parents: 31809
diff changeset
2084 FOR_ALL_HASHTAB_ITEMS(&sg_table, hi, todo)
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2085 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2086 if (!HASHITEM_EMPTY(hi))
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2087 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2088 --todo;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2089 if (current_idx++ == idx)
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2090 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2091 group = HI2SG(hi);
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2092 return group->sg_name;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2093 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2094 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2095 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2096 return NULL;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2097 }
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2098
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2099 /*
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2100 * 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
2101 * expansion.
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2102 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2103 char_u *
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2104 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
2105 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2106 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
2107 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2108 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
2109 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
2110 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
2111 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2112 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
2113 {
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
2114 "culhl=", "icon=", "linehl=", "numhl=", "text=", "texthl=", "priority=",
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
2115 NULL
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2116 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2117 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
2118 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2119 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
2120 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2121 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
2122 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2123 "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
2124 "buffer=", NULL
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2125 };
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2126 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
2127 }
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2128 case EXP_LIST:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2129 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2130 char *list_arg[] =
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2131 {
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2132 "group=", "file=", "buffer=", NULL
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2133 };
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2134 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
2135 }
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2136 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
2137 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2138 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
2139 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
2140 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2141 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
2142 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
2143 case EXP_SIGN_GROUPS:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2144 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
2145 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2146 return NULL;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2147 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2148 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2149
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2150 /*
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2151 * 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
2152 */
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2153 void
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2154 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
2155 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2156 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
2157 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
2158 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
2159 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
2160 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
2161
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2162 // 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
2163 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
2164 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
2165 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
2166
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2167 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
2168 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
2169 // 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
2170 // :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
2171 return;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2172
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2173 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
2174
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2175 // :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
2176 // |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2177 // 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
2178 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
2179
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2180 // 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
2181
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2182 // :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
2183 // |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2184 // p
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2185
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2186 // 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
2187 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
2188 do
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2189 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2190 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
2191 last = p;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2192 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
2193 } 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
2194
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2195 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
2196
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2197 // :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
2198 // | |
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2199 // 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
2200 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
2201 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2202 // 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
2203 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
2204 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
2205 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2206 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
2207 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
2208 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2209 case SIGNCMD_PLACE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2210 // List placed signs
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2211 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
2212 // :sign place {id} {args}...
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2213 expand_what = EXP_PLACE;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2214 else
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2215 // :sign place {args}...
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2216 expand_what = EXP_LIST;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2217 break;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2218 case SIGNCMD_LIST:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2219 case SIGNCMD_UNDEFINE:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2220 // :sign list <CTRL-D>
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2221 // :sign undefine <CTRL-D>
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2222 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
2223 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2224 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
2225 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
2226 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
2227 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2228 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2229 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
2230 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2231 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2232 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2233 {
15418
51b3c36b0523 patch 8.1.0717: there is no function for the ":sign jump" command
Bram Moolenaar <Bram@vim.org>
parents: 15402
diff changeset
2234 // 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
2235 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
2236 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
2237 {
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2238 case SIGNCMD_DEFINE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2239 if (STRNCMP(last, "texthl", 6) == 0
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
2240 || STRNCMP(last, "linehl", 6) == 0
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
2241 || STRNCMP(last, "culhl", 5) == 0
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
2242 || STRNCMP(last, "numhl", 5) == 0)
15330
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2243 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
2244 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
2245 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
2246 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2247 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
2248 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2249 case SIGNCMD_PLACE:
15864
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2250 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
2251 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
2252 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
2253 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
2254 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
2255 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
2256 else
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2257 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
2258 break;
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2259 case SIGNCMD_UNPLACE:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2260 case SIGNCMD_JUMP:
9e0154efac3a patch 8.1.0939: no completion for sign group names
Bram Moolenaar <Bram@vim.org>
parents: 15605
diff changeset
2261 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
2262 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
2263 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
2264 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
2265 else
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2266 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
2267 break;
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2268 default:
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2269 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
2270 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2271 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2272 }
a6330a49e036 patch 8.1.0673: functionality for signs is spread out over several files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2273
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2274 /*
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2275 * Define a sign using the attributes in 'dict'. Returns 0 on success and -1 on
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2276 * failure.
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2277 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2278 static int
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2279 sign_define_from_dict(char_u *name_arg, dict_T *dict)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2280 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2281 char_u *name = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2282 char_u *icon = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2283 char_u *linehl = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2284 char_u *text = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2285 char_u *texthl = NULL;
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
2286 char_u *culhl = NULL;
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
2287 char_u *numhl = NULL;
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
2288 int prio = -1;
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2289 int retval = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2290
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2291 if (name_arg == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2292 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2293 if (dict == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2294 return -1;
29442
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2295 name = dict_get_string(dict, "name", TRUE);
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2296 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2297 else
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2298 name = vim_strsave(name_arg);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2299 if (name == NULL || name[0] == NUL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2300 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2301 if (dict != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2302 {
29442
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2303 icon = dict_get_string(dict, "icon", TRUE);
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2304 linehl = dict_get_string(dict, "linehl", TRUE);
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2305 text = dict_get_string(dict, "text", TRUE);
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2306 texthl = dict_get_string(dict, "texthl", TRUE);
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2307 culhl = dict_get_string(dict, "culhl", TRUE);
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2308 numhl = dict_get_string(dict, "numhl", TRUE);
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
2309 prio = dict_get_number_def(dict, "priority", -1);
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2310 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2311
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
2312 if (sign_define_by_name(name, icon, linehl, text, texthl, culhl, numhl, prio) == OK)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2313 retval = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2314
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2315 cleanup:
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2316 vim_free(name);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2317 vim_free(icon);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2318 vim_free(linehl);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2319 vim_free(text);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2320 vim_free(texthl);
26266
365e7f083f02 patch 8.2.3664: cannot adjust sign highlighting for 'cursorline'
Bram Moolenaar <Bram@vim.org>
parents: 25822
diff changeset
2321 vim_free(culhl);
26690
84d60deb8f82 patch 8.2.3874: cannot highlight the number column for a sign
Bram Moolenaar <Bram@vim.org>
parents: 26434
diff changeset
2322 vim_free(numhl);
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2323
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2324 return retval;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2325 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2326
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2327 /*
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2328 * Define multiple signs using attributes from list 'l' and store the return
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2329 * values in 'retlist'.
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2330 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2331 static void
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2332 sign_define_multiple(list_T *l, list_T *retlist)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2333 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2334 listitem_T *li;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2335 int retval;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2336
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
2337 FOR_ALL_LIST_ITEMS(l, li)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2338 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2339 retval = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2340 if (li->li_tv.v_type == VAR_DICT)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2341 retval = sign_define_from_dict(NULL, li->li_tv.vval.v_dict);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2342 else
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2343 emsg(_(e_dictionary_required));
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2344 list_append_number(retlist, retval);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2345 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2346 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2347
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2348 /*
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2349 * "sign_define()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2350 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2351 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2352 f_sign_define(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2353 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2354 char_u *name;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2355
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2356 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2357 && (check_for_string_or_list_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2358 || check_for_opt_dict_arg(argvars, 1) == FAIL))
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2359 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2360
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2361 if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_UNKNOWN)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2362 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2363 // Define multiple signs
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
2364 if (rettv_list_alloc(rettv) == FAIL)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2365 return;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2367 sign_define_multiple(argvars[0].vval.v_list, rettv->vval.v_list);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2368 return;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2369 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2370
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2371 // Define a single sign
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2372 rettv->vval.v_number = -1;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2373
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2374 name = tv_get_string_chk(&argvars[0]);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2375 if (name == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2376 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2377
29994
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2378 if (check_for_opt_dict_arg(argvars, 1) == FAIL)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2379 return;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2380
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2381 rettv->vval.v_number = sign_define_from_dict(name,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2382 argvars[1].v_type == VAR_DICT ? argvars[1].vval.v_dict : NULL);
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2383 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2384
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2385 /*
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2386 * "sign_getdefined()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2387 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2388 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2389 f_sign_getdefined(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2390 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2391 char_u *name = NULL;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2392
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
2393 if (rettv_list_alloc_id(rettv, aid_sign_getdefined) == FAIL)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2394 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2395
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2396 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2397 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2398
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2399 if (argvars[0].v_type != VAR_UNKNOWN)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2400 name = tv_get_string(&argvars[0]);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2401
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2402 sign_getlist(name, rettv->vval.v_list);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2403 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2404
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2405 /*
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2406 * "sign_getplaced()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2407 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2408 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2409 f_sign_getplaced(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2410 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2411 buf_T *buf = NULL;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2412 dict_T *dict;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2413 dictitem_T *di;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2414 linenr_T lnum = 0;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2415 int sign_id = 0;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2416 char_u *group = NULL;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2417 int notanum = FALSE;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2418
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
2419 if (rettv_list_alloc_id(rettv, aid_sign_getplaced) == FAIL)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2420 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2421
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2422 if (in_vim9script()
25314
7e620652bd13 patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25302
diff changeset
2423 && (check_for_opt_buffer_arg(argvars, 0) == FAIL
25302
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2424 || (argvars[0].v_type != VAR_UNKNOWN
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2425 && check_for_opt_dict_arg(argvars, 1) == FAIL)))
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2426 return;
4d3c68196d05 patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25252
diff changeset
2427
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2428 if (argvars[0].v_type != VAR_UNKNOWN)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2429 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2430 // get signs placed in the specified buffer
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2431 buf = get_buf_arg(&argvars[0]);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2432 if (buf == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2433 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2434
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2435 if (argvars[1].v_type != VAR_UNKNOWN)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2436 {
29994
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2437 if (check_for_nonnull_dict_arg(argvars, 1) == FAIL)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2438 return;
29994
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2439 dict = argvars[1].vval.v_dict;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2440 if ((di = dict_find(dict, (char_u *)"lnum", -1)) != NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2441 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2442 // get signs placed at this line
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2443 (void)tv_get_number_chk(&di->di_tv, &notanum);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2444 if (notanum)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2445 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2446 lnum = tv_get_lnum(&di->di_tv);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2447 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2448 if ((di = dict_find(dict, (char_u *)"id", -1)) != NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2449 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2450 // get sign placed with this identifier
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2451 sign_id = (int)tv_get_number_chk(&di->di_tv, &notanum);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2452 if (notanum)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2453 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2454 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2455 if ((di = dict_find(dict, (char_u *)"group", -1)) != NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2456 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2457 group = tv_get_string_chk(&di->di_tv);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2458 if (group == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2459 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2460 if (*group == '\0') // empty string means global group
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2461 group = NULL;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2462 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2463 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2464 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2465
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2466 sign_get_placed(buf, lnum, sign_id, group, rettv->vval.v_list);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2467 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2468
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2469 /*
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2470 * "sign_jump()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2471 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2472 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2473 f_sign_jump(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2474 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2475 int sign_id;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2476 char_u *sign_group = NULL;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2477 buf_T *buf;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2478 int notanum = FALSE;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2479
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2480 rettv->vval.v_number = -1;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2481
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2482 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2483 && (check_for_number_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2484 || check_for_string_arg(argvars, 1) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2485 || check_for_buffer_arg(argvars, 2) == FAIL))
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2486 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2487
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2488 // Sign identifier
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2489 sign_id = (int)tv_get_number_chk(&argvars[0], &notanum);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2490 if (notanum)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2491 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2492 if (sign_id <= 0)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2493 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
2494 emsg(_(e_invalid_argument));
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2495 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2496 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2497
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2498 // Sign group
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2499 sign_group = tv_get_string_chk(&argvars[1]);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2500 if (sign_group == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2501 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2502 if (sign_group[0] == '\0')
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2503 sign_group = NULL; // global sign group
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2504 else
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2505 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2506 sign_group = vim_strsave(sign_group);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2507 if (sign_group == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2508 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2509 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2510
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2511 // Buffer to place the sign
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2512 buf = get_buf_arg(&argvars[2]);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2513 if (buf == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2514 goto cleanup;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2515
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2516 rettv->vval.v_number = sign_jump(sign_id, sign_group, buf);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2517
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2518 cleanup:
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2519 vim_free(sign_group);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2520 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2521
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2522 /*
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2523 * Place a new sign using the values specified in dict 'dict'. Returns the sign
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2524 * identifier if successfully placed, otherwise returns 0.
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2525 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2526 static int
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2527 sign_place_from_dict(
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2528 typval_T *id_tv,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2529 typval_T *group_tv,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2530 typval_T *name_tv,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2531 typval_T *buf_tv,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2532 dict_T *dict)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2533 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2534 int sign_id = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2535 char_u *group = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2536 char_u *sign_name = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2537 buf_T *buf = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2538 dictitem_T *di;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2539 linenr_T lnum = 0;
35568
fff85588c140 patch 9.1.0538: not possible to assign priority when defining a sign
Christian Brabandt <cb@256bit.org>
parents: 32118
diff changeset
2540 int prio = -1;
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2541 int notanum = FALSE;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2542 int ret_sign_id = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2543
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2544 // sign identifier
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2545 if (id_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2546 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2547 di = dict_find(dict, (char_u *)"id", -1);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2548 if (di != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2549 id_tv = &di->di_tv;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2550 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2551 if (id_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2552 sign_id = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2553 else
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2554 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2555 sign_id = tv_get_number_chk(id_tv, &notanum);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2556 if (notanum)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2557 return -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2558 if (sign_id < 0)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2559 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
2560 emsg(_(e_invalid_argument));
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2561 return -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2562 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2563 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2564
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2565 // sign group
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2566 if (group_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2567 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2568 di = dict_find(dict, (char_u *)"group", -1);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2569 if (di != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2570 group_tv = &di->di_tv;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2571 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2572 if (group_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2573 group = NULL; // global group
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2574 else
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2575 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2576 group = tv_get_string_chk(group_tv);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2577 if (group == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2578 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2579 if (group[0] == '\0') // global sign group
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2580 group = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2581 else
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2582 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2583 group = vim_strsave(group);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2584 if (group == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2585 return -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2586 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2587 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2588
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2589 // sign name
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2590 if (name_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2591 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2592 di = dict_find(dict, (char_u *)"name", -1);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2593 if (di != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2594 name_tv = &di->di_tv;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2595 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2596 if (name_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2597 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2598 sign_name = tv_get_string_chk(name_tv);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2599 if (sign_name == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2600 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2601
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2602 // buffer to place the sign
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2603 if (buf_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2604 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2605 di = dict_find(dict, (char_u *)"buffer", -1);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2606 if (di != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2607 buf_tv = &di->di_tv;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2608 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2609 if (buf_tv == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2610 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2611 buf = get_buf_arg(buf_tv);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2612 if (buf == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2613 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2614
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2615 // line number of the sign
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2616 di = dict_find(dict, (char_u *)"lnum", -1);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2617 if (di != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2618 {
17805
313f498c646e patch 8.1.1899: sign_place() does not work as documented
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
2619 lnum = tv_get_lnum(&di->di_tv);
313f498c646e patch 8.1.1899: sign_place() does not work as documented
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
2620 if (lnum <= 0)
313f498c646e patch 8.1.1899: sign_place() does not work as documented
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
2621 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
2622 emsg(_(e_invalid_argument));
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2623 goto cleanup;
17805
313f498c646e patch 8.1.1899: sign_place() does not work as documented
Bram Moolenaar <Bram@vim.org>
parents: 17781
diff changeset
2624 }
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2625 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2626
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2627 // sign priority
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2628 di = dict_find(dict, (char_u *)"priority", -1);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2629 if (di != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2630 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2631 prio = (int)tv_get_number_chk(&di->di_tv, &notanum);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2632 if (notanum)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2633 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2634 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2635
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2636 if (sign_place(&sign_id, group, sign_name, buf, lnum, prio) == OK)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2637 ret_sign_id = sign_id;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2638
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2639 cleanup:
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2640 vim_free(group);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2641
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2642 return ret_sign_id;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2643 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2644
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2645 /*
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2646 * "sign_place()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2647 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2648 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2649 f_sign_place(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2650 {
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2651 dict_T *dict = NULL;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2652
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2653 rettv->vval.v_number = -1;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2654
25338
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2655 if (in_vim9script()
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2656 && (check_for_number_arg(argvars, 0) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2657 || check_for_string_arg(argvars, 1) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2658 || check_for_string_arg(argvars, 2) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2659 || check_for_buffer_arg(argvars, 3) == FAIL
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2660 || check_for_opt_dict_arg(argvars, 4) == FAIL))
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2661 return;
e2be9f3c5907 patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents: 25314
diff changeset
2662
29994
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2663 if (argvars[4].v_type != VAR_UNKNOWN)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2664 {
29994
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2665 if (check_for_nonnull_dict_arg(argvars, 4) == FAIL)
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2666 return;
86eb4aba16c3 patch 9.0.0335: checks for Dictionary argument often give a vague error
Bram Moolenaar <Bram@vim.org>
parents: 29732
diff changeset
2667 dict = argvars[4].vval.v_dict;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2668 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2669
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2670 rettv->vval.v_number = sign_place_from_dict(&argvars[0], &argvars[1],
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2671 &argvars[2], &argvars[3], dict);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2672 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2673
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2674 /*
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2675 * "sign_placelist()" function. Place multiple signs.
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2676 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2677 void
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2678 f_sign_placelist(typval_T *argvars, typval_T *rettv)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2679 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2680 listitem_T *li;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2681 int sign_id;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2682
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
2683 if (rettv_list_alloc(rettv) == FAIL)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2684 return;
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2685
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2686 if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2687 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2688
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 29994
diff changeset
2689 if (check_for_list_arg(argvars, 0) == FAIL)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2690 return;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2691
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2692 // Process the List of sign attributes
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
2693 FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2694 {
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2695 sign_id = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2696 if (li->li_tv.v_type == VAR_DICT)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2697 sign_id = sign_place_from_dict(NULL, NULL, NULL, NULL,
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2698 li->li_tv.vval.v_dict);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2699 else
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2700 emsg(_(e_dictionary_required));
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2701 list_append_number(rettv->vval.v_list, sign_id);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2702 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2703 }
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2704
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2705 /*
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2706 * Undefine multiple signs
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2707 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2708 static void
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2709 sign_undefine_multiple(list_T *l, list_T *retlist)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2710 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2711 char_u *name;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2712 listitem_T *li;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2713 int retval;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2714
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
2715 FOR_ALL_LIST_ITEMS(l, li)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2716 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2717 retval = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2718 name = tv_get_string_chk(&li->li_tv);
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
2719 if (name != NULL && (sign_undefine_by_name(name, TRUE) == OK))
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2720 retval = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2721 list_append_number(retlist, retval);
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2722 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2723 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2724
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2725 /*
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2726 * "sign_undefine()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2727 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2728 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2729 f_sign_undefine(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2730 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2731 char_u *name;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2732
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2733 if (in_vim9script()
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2734 && check_for_opt_string_or_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2735 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2736
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2737 if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_UNKNOWN)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2738 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2739 // Undefine multiple signs
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
2740 if (rettv_list_alloc(rettv) == FAIL)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2741 return;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2742
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2743 sign_undefine_multiple(argvars[0].vval.v_list, rettv->vval.v_list);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2744 return;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2745 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2746
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2747 rettv->vval.v_number = -1;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2748
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2749 if (argvars[0].v_type == VAR_UNKNOWN)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2750 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2751 // Free all the signs
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2752 free_signs();
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2753 rettv->vval.v_number = 0;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2754 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2755 else
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2756 {
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2757 // Free only the specified sign
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2758 name = tv_get_string_chk(&argvars[0]);
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2759 if (name == NULL)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2760 return;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2761
17440
a5874fdc8f3a patch 8.1.1718: popup menu highlighting does not look good
Bram Moolenaar <Bram@vim.org>
parents: 17366
diff changeset
2762 if (sign_undefine_by_name(name, TRUE) == OK)
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2763 rettv->vval.v_number = 0;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2764 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2765 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2766
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2767 /*
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2768 * Unplace the sign with attributes specified in 'dict'. Returns 0 on success
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2769 * and -1 on failure.
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2770 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2771 static int
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2772 sign_unplace_from_dict(typval_T *group_tv, dict_T *dict)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2773 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2774 dictitem_T *di;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2775 int sign_id = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2776 buf_T *buf = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2777 char_u *group = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2778 int retval = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2779
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2780 // sign group
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2781 if (group_tv != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2782 group = tv_get_string(group_tv);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2783 else
29442
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2784 group = dict_get_string(dict, "group", FALSE);
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2785 if (group != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2786 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2787 if (group[0] == '\0') // global sign group
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2788 group = NULL;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2789 else
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2790 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2791 group = vim_strsave(group);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2792 if (group == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2793 return -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2794 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2795 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2796
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2797 if (dict != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2798 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2799 if ((di = dict_find(dict, (char_u *)"buffer", -1)) != NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2800 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2801 buf = get_buf_arg(&di->di_tv);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2802 if (buf == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2803 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2804 }
28315
62cc3b60493b patch 8.2.4683: verbose check with dict_find() to see if a key is present
Bram Moolenaar <Bram@vim.org>
parents: 28169
diff changeset
2805 if (dict_has_key(dict, "id"))
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2806 {
29442
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29175
diff changeset
2807 sign_id = dict_get_number(dict, "id");
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2808 if (sign_id <= 0)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2809 {
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26853
diff changeset
2810 emsg(_(e_invalid_argument));
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2811 goto cleanup;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2812 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2813 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2814 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2815
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2816 if (buf == NULL)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2817 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2818 // Delete the sign in all the buffers
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2819 retval = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2820 FOR_ALL_BUFFERS(buf)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2821 if (sign_unplace(sign_id, group, buf, 0) != OK)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2822 retval = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2823 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2824 else if (sign_unplace(sign_id, group, buf, 0) == OK)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2825 retval = 0;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2826
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2827 cleanup:
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2828 vim_free(group);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2829
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2830 return retval;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2831 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2832
18603
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2833 sign_entry_T *
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2834 get_first_valid_sign(win_T *wp)
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2835 {
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2836 sign_entry_T *sign = wp->w_buffer->b_signlist;
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2837
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18744
diff changeset
2838 # ifdef FEAT_PROP_POPUP
18744
b29d8a06e72c patch 8.1.2362: cannot place signs in a popup window
Bram Moolenaar <Bram@vim.org>
parents: 18603
diff changeset
2839 while (sign != NULL && !sign_group_for_window(sign, wp))
18603
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2840 sign = sign->se_next;
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2841 # endif
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2842 return sign;
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2843 }
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2844
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2845 /*
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2846 * Return TRUE when window "wp" has a column to draw signs in.
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2847 */
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2848 int
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2849 signcolumn_on(win_T *wp)
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2850 {
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2851 // If 'signcolumn' is set to 'number', signs are displayed in the 'number'
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2852 // column (if present). Otherwise signs are to be displayed in the sign
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2853 // column.
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2854 if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u')
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2855 return get_first_valid_sign(wp) != NULL && !wp->w_p_nu && !wp->w_p_rnu;
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2856
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2857 if (*wp->w_p_scl == 'n')
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2858 return FALSE;
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2859 if (*wp->w_p_scl == 'y')
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2860 return TRUE;
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2861 return (get_first_valid_sign(wp) != NULL
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2862 # ifdef FEAT_NETBEANS_INTG
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2863 || wp->w_buffer->b_has_sign_column
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2864 # endif
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2865 );
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2866 }
f249b44039e0 patch 8.1.2295: if buffer of popup is in another window cursorline sign shows
Bram Moolenaar <Bram@vim.org>
parents: 18422
diff changeset
2867
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2868 /*
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2869 * "sign_unplace()" function
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2870 */
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2871 void
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2872 f_sign_unplace(typval_T *argvars, typval_T *rettv)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2873 {
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2874 dict_T *dict = NULL;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2875
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2876 rettv->vval.v_number = -1;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2877
30043
fd855ad74887 patch 9.0.0359: error message for wrong argument type is not specific
Bram Moolenaar <Bram@vim.org>
parents: 30015
diff changeset
2878 if ((check_for_string_arg(argvars, 0) == FAIL
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2879 || check_for_opt_dict_arg(argvars, 1) == FAIL))
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2880 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2881
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2882 if (argvars[1].v_type != VAR_UNKNOWN)
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2883 dict = argvars[1].vval.v_dict;
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2884
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2885 rettv->vval.v_number = sign_unplace_from_dict(&argvars[0], dict);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2886 }
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2887
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2888 /*
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2889 * "sign_unplacelist()" function
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2890 */
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2891 void
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2892 f_sign_unplacelist(typval_T *argvars, typval_T *rettv)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2893 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2894 listitem_T *li;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2895 int retval;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2896
29175
755ab148288b patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents: 28315
diff changeset
2897 if (rettv_list_alloc(rettv) == FAIL)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2898 return;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2899
25384
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2900 if (in_vim9script() && check_for_list_arg(argvars, 0) == FAIL)
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2901 return;
e8e2c4d33b9b patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents: 25338
diff changeset
2902
30015
adb0de8be4ce patch 9.0.0345: error message for list argument could be clearer
Bram Moolenaar <Bram@vim.org>
parents: 29994
diff changeset
2903 if (check_for_list_arg(argvars, 0) == FAIL)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2904 return;
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2905
19888
435726a03481 patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents: 19447
diff changeset
2906 FOR_ALL_LIST_ITEMS(argvars[0].vval.v_list, li)
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2907 {
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2908 retval = -1;
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2909 if (li->li_tv.v_type == VAR_DICT)
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2910 retval = sign_unplace_from_dict(NULL, li->li_tv.vval.v_dict);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2911 else
26877
06a137af96f8 patch 8.2.3967: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
2912 emsg(_(e_dictionary_required));
17366
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2913 list_append_number(rettv->vval.v_list, retval);
9843fbfa0ee5 patch 8.1.1682: placing a larger number of signs is slow
Bram Moolenaar <Bram@vim.org>
parents: 17264
diff changeset
2914 }
17218
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2915 }
210c4c5f783d patch 8.1.1608: the evalfunc.c file is too big
Bram Moolenaar <Bram@vim.org>
parents: 17105
diff changeset
2916
18812
d34ec6fe207d patch 8.1.2394: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2917 #endif // FEAT_SIGNS