Mercurial > vim
annotate src/textprop.c @ 21481:279b3415947f v8.2.1291
patch 8.2.1291: Vim9: type of varargs items is not checked
Commit: https://github.com/vim/vim/commit/24aa48b7a265c24e18f0f978dfe0255e138e2b90
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 25 16:33:02 2020 +0200
patch 8.2.1291: Vim9: type of varargs items is not checked
Problem: Vim9: type of varargs items is not checked.
Solution: Check the list item types. (closes https://github.com/vim/vim/issues/6523)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 Jul 2020 16:45:04 +0200 |
parents | 71a36879ac2a |
children | 35c8996a798e |
rev | line source |
---|---|
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
16662
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
11 * Text properties implementation. See ":help text-properties". |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 * TODO: |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
14 * - Adjust text property column and length when text is inserted/deleted. |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
15 * -> a :substitute with a multi-line match |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
16 * -> search for changed_bytes() from misc1.c |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
17 * -> search for mark_col_adjust() |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
18 * - Perhaps we only need TP_FLAG_CONT_NEXT and can drop TP_FLAG_CONT_PREV? |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18442
diff
changeset
|
19 * - Add an array for global_proptypes, to quickly lookup a prop type by ID |
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18442
diff
changeset
|
20 * - Add an array for b_proptypes, to quickly lookup a prop type by ID |
15294
2d8225cc1315
patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents:
15255
diff
changeset
|
21 * - Checking the text length to detect text properties is slow. Use a flag in |
2d8225cc1315
patch 8.1.0655: when appending a line text property flags are not added
Bram Moolenaar <Bram@vim.org>
parents:
15255
diff
changeset
|
22 * the index, like DB_MARKED? |
15255
19e79a1ed6b6
patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents:
15251
diff
changeset
|
23 * - Also test line2byte() with many lines, so that ml_updatechunk() is taken |
19e79a1ed6b6
patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents:
15251
diff
changeset
|
24 * into account. |
15939
8013b532a1f7
patch 8.1.0975: using STRNCPY() wrongly. Warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
25 * - Perhaps have a window-local option to disable highlighting from text |
8013b532a1f7
patch 8.1.0975: using STRNCPY() wrongly. Warning for uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
15470
diff
changeset
|
26 * properties? |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 #include "vim.h" |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18631
diff
changeset
|
31 #if defined(FEAT_PROP_POPUP) || defined(PROTO) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 * In a hashtable item "hi_key" points to "pt_name" in a proptype_T. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 * This avoids adding a pointer to the hashtable item. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 * PT2HIKEY() converts a proptype pointer to a hashitem key pointer. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 * HIKEY2PT() converts a hashitem key pointer to a proptype pointer. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 * HI2PT() converts a hashitem pointer to a proptype pointer. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 #define PT2HIKEY(p) ((p)->pt_name) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 #define HIKEY2PT(p) ((proptype_T *)((p) - offsetof(proptype_T, pt_name))) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 #define HI2PT(hi) HIKEY2PT((hi)->hi_key) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 // The global text property types. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 static hashtab_T *global_proptypes = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 // The last used text property type ID. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 static int proptype_id = 0; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 static char_u e_type_not_exist[] = N_("E971: Property type %s does not exist"); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 static char_u e_invalid_col[] = N_("E964: Invalid column number: %ld"); |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
52 static char_u e_invalid_lnum[] = N_("E966: Invalid line number: %ld"); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 * Find a property type by name, return the hashitem. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 * Returns NULL if the item can't be found. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 static hashitem_T * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 find_prop_hi(char_u *name, buf_T *buf) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 hashtab_T *ht; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 hashitem_T *hi; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 if (*name == NUL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 return NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 if (buf == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 ht = global_proptypes; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 else |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 ht = buf->b_proptypes; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 if (ht == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 return NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 hi = hash_find(ht, name); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 if (HASHITEM_EMPTY(hi)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 return NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 return hi; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 * Like find_prop_hi() but return the property type. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 static proptype_T * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 find_prop(char_u *name, buf_T *buf) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 hashitem_T *hi = find_prop_hi(name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 if (hi == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 return NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 return HI2PT(hi); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 /* |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
93 * Get the prop type ID of "name". |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
94 * When not found return zero. |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
95 */ |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
96 int |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
97 find_prop_type_id(char_u *name, buf_T *buf) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
98 { |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
99 proptype_T *pt = find_prop(name, buf); |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
100 |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
101 if (pt == NULL) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
102 return 0; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
103 return pt->pt_id; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
104 } |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
105 |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
106 /* |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 * Lookup a property type by name. First in "buf" and when not found in the |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 * global types. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 * When not found gives an error message and returns NULL. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 static proptype_T * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 lookup_prop_type(char_u *name, buf_T *buf) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 proptype_T *type = find_prop(name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 if (type == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 type = find_prop(name, NULL); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 if (type == NULL) |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
119 semsg(_(e_type_not_exist), name); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 return type; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 * Get an optional "bufnr" item from the dict in "arg". |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 * When the argument is not used or "bufnr" is not present then "buf" is |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 * unchanged. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 * If "bufnr" is valid or not present return OK. |
18498
9e6d5a4abb1c
patch 8.1.2243: typos in comments
Bram Moolenaar <Bram@vim.org>
parents:
18442
diff
changeset
|
128 * When "arg" is not a dict or "bufnr" is invalid return FAIL. |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 static int |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 get_bufnr_from_arg(typval_T *arg, buf_T **buf) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 dictitem_T *di; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 if (arg->v_type != VAR_DICT) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
137 emsg(_(e_dictreq)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 return FAIL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 if (arg->vval.v_dict == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 return OK; // NULL dict is like an empty dict |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 di = dict_find(arg->vval.v_dict, (char_u *)"bufnr", -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 if (di != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 { |
16772
18093a6accb5
patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents:
16770
diff
changeset
|
145 *buf = get_buf_arg(&di->di_tv); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 if (*buf == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 return FAIL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 return OK; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 * prop_add({lnum}, {col}, {props}) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 f_prop_add(typval_T *argvars, typval_T *rettv UNUSED) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 { |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
158 linenr_T start_lnum; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
159 colnr_T start_col; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
161 start_lnum = tv_get_number(&argvars[0]); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
162 start_col = tv_get_number(&argvars[1]); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
163 if (start_col < 1) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
165 semsg(_(e_invalid_col), (long)start_col); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 if (argvars[2].v_type != VAR_DICT) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
170 emsg(_(e_dictreq)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 } |
16811
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
173 |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
174 prop_add_common(start_lnum, start_col, argvars[2].vval.v_dict, |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
175 curbuf, &argvars[2]); |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
176 } |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
177 |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
178 /* |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
179 * Shared between prop_add() and popup_create(). |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
180 * "dict_arg" is the function argument of a dict containing "bufnr". |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
181 * it is NULL for popup_create(). |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
182 */ |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
183 void |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
184 prop_add_common( |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
185 linenr_T start_lnum, |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
186 colnr_T start_col, |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
187 dict_T *dict, |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
188 buf_T *default_buf, |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
189 typval_T *dict_arg) |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
190 { |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
191 linenr_T lnum; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
192 linenr_T end_lnum; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
193 colnr_T end_col; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
194 char_u *type_name; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
195 proptype_T *type; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
196 buf_T *buf = default_buf; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
197 int id = 0; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
198 char_u *newtext; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
199 int proplen; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
200 size_t textlen; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
201 char_u *props = NULL; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
202 char_u *newprops; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
203 textprop_T tmp_prop; |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
204 int i; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 if (dict == NULL || dict_find(dict, (char_u *)"type", -1) == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
208 emsg(_("E965: missing property type name")); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 } |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15144
diff
changeset
|
211 type_name = dict_get_string(dict, (char_u *)"type", FALSE); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 if (dict_find(dict, (char_u *)"end_lnum", -1) != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 { |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
215 end_lnum = dict_get_number(dict, (char_u *)"end_lnum"); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
216 if (end_lnum < start_lnum) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
217 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
218 semsg(_(e_invargval), "end_lnum"); |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
219 return; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
220 } |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 } |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
222 else |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
223 end_lnum = start_lnum; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 if (dict_find(dict, (char_u *)"length", -1) != NULL) |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
226 { |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
227 long length = dict_get_number(dict, (char_u *)"length"); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
228 |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
229 if (length < 0 || end_lnum > start_lnum) |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
230 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
231 semsg(_(e_invargval), "length"); |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
232 return; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
233 } |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
234 end_col = start_col + length; |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
235 } |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 else if (dict_find(dict, (char_u *)"end_col", -1) != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 { |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
238 end_col = dict_get_number(dict, (char_u *)"end_col"); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
239 if (end_col <= 0) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
241 semsg(_(e_invargval), "end_col"); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 } |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
245 else if (start_lnum == end_lnum) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
246 end_col = start_col; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
247 else |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
248 end_col = 1; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 if (dict_find(dict, (char_u *)"id", -1) != NULL) |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15144
diff
changeset
|
251 id = dict_get_number(dict, (char_u *)"id"); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 |
16811
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
253 if (dict_arg != NULL && get_bufnr_from_arg(dict_arg, &buf) == FAIL) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 type = lookup_prop_type(type_name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 if (type == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
260 if (start_lnum < 1 || start_lnum > buf->b_ml.ml_line_count) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
262 semsg(_(e_invalid_lnum), (long)start_lnum); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 } |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
265 if (end_lnum < start_lnum || end_lnum > buf->b_ml.ml_line_count) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
267 semsg(_(e_invalid_lnum), (long)end_lnum); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 |
16770
09c81f17f83c
patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
271 if (buf->b_ml.ml_mfp == NULL) |
17694
6f9cde96ee3c
patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
272 { |
6f9cde96ee3c
patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
273 emsg(_("E275: Cannot add text property to unloaded buffer")); |
6f9cde96ee3c
patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
274 return; |
6f9cde96ee3c
patch 8.1.1844: buffer no longer unloaded when adding text properties
Bram Moolenaar <Bram@vim.org>
parents:
17659
diff
changeset
|
275 } |
16770
09c81f17f83c
patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
276 |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
277 for (lnum = start_lnum; lnum <= end_lnum; ++lnum) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
278 { |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
279 colnr_T col; // start column |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
280 long length; // in bytes |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
281 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
282 // Fetch the line to get the ml_line_len field updated. |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
283 proplen = get_text_props(buf, lnum, &props, TRUE); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
284 textlen = buf->b_ml.ml_line_len - proplen * sizeof(textprop_T); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
285 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
286 if (lnum == start_lnum) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
287 col = start_col; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
288 else |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
289 col = 1; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
290 if (col - 1 > (colnr_T)textlen) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
291 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
292 semsg(_(e_invalid_col), (long)start_col); |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
293 return; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
294 } |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
295 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
296 if (lnum == end_lnum) |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
297 length = end_col - col; |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
298 else |
15353
21580db06cf3
patch 8.1.0684: warnings from 64-bit compiler
Bram Moolenaar <Bram@vim.org>
parents:
15349
diff
changeset
|
299 length = (int)textlen - col + 1; |
15255
19e79a1ed6b6
patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents:
15251
diff
changeset
|
300 if (length > (long)textlen) |
15353
21580db06cf3
patch 8.1.0684: warnings from 64-bit compiler
Bram Moolenaar <Bram@vim.org>
parents:
15349
diff
changeset
|
301 length = (int)textlen; // can include the end-of-line |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
302 if (length < 0) |
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
303 length = 0; // zero-width property |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
305 // Allocate the new line with space for the new proprety. |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
306 newtext = alloc(buf->b_ml.ml_line_len + sizeof(textprop_T)); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
307 if (newtext == NULL) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
308 return; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
309 // Copy the text, including terminating NUL. |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
310 mch_memmove(newtext, buf->b_ml.ml_line_ptr, textlen); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
311 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
312 // Find the index where to insert the new property. |
16811
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
313 // Since the text properties are not aligned properly when stored with |
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
314 // the text, we need to copy them as bytes before using it as a struct. |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
315 for (i = 0; i < proplen; ++i) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
316 { |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
317 mch_memmove(&tmp_prop, props + i * sizeof(textprop_T), |
16811
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
318 sizeof(textprop_T)); |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
319 if (tmp_prop.tp_col >= col) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
320 break; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
321 } |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
322 newprops = newtext + textlen; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
323 if (i > 0) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
324 mch_memmove(newprops, props, sizeof(textprop_T) * i); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
325 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
326 tmp_prop.tp_col = col; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
327 tmp_prop.tp_len = length; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
328 tmp_prop.tp_id = id; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
329 tmp_prop.tp_type = type->pt_id; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
330 tmp_prop.tp_flags = (lnum > start_lnum ? TP_FLAG_CONT_PREV : 0) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
331 | (lnum < end_lnum ? TP_FLAG_CONT_NEXT : 0); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
332 mch_memmove(newprops + i * sizeof(textprop_T), &tmp_prop, |
16811
0457d49eb2d9
patch 8.1.1407: popup_create() does not support text properties
Bram Moolenaar <Bram@vim.org>
parents:
16782
diff
changeset
|
333 sizeof(textprop_T)); |
15251
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
334 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
335 if (i < proplen) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
336 mch_memmove(newprops + (i + 1) * sizeof(textprop_T), |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
337 props + i * sizeof(textprop_T), |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
338 sizeof(textprop_T) * (proplen - i)); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
339 |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
340 if (buf->b_ml.ml_flags & ML_LINE_DIRTY) |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
341 vim_free(buf->b_ml.ml_line_ptr); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
342 buf->b_ml.ml_line_ptr = newtext; |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
343 buf->b_ml.ml_line_len += sizeof(textprop_T); |
17525ca95e1e
patch 8.1.0634: text properties cannot cross line boundaries
Bram Moolenaar <Bram@vim.org>
parents:
15211
diff
changeset
|
344 buf->b_ml.ml_flags |= ML_LINE_DIRTY; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 |
15255
19e79a1ed6b6
patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents:
15251
diff
changeset
|
347 buf->b_has_textprop = TRUE; // this is never reset |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 redraw_buf_later(buf, NOT_VALID); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 /* |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
352 * Fetch the text properties for line "lnum" in buffer "buf". |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 * Returns the number of text properties and, when non-zero, a pointer to the |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 * first one in "props" (note that it is not aligned, therefore the char_u |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 * pointer). |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 int |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 char_u *text; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 size_t textlen; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 size_t proplen; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 |
15255
19e79a1ed6b6
patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents:
15251
diff
changeset
|
364 // Be quick when no text property types have been defined or the buffer, |
19e79a1ed6b6
patch 8.1.0636: line2byte() gives wrong values with text properties
Bram Moolenaar <Bram@vim.org>
parents:
15251
diff
changeset
|
365 // unless we are adding one. |
16770
09c81f17f83c
patch 8.1.1387: calling prop_add() in an empty buffer doesn't work
Bram Moolenaar <Bram@vim.org>
parents:
16768
diff
changeset
|
366 if ((!buf->b_has_textprop && !will_change) || buf->b_ml.ml_mfp == NULL) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 return 0; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 // Fetch the line to get the ml_line_len field updated. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 text = ml_get_buf(buf, lnum, will_change); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 textlen = STRLEN(text) + 1; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 proplen = buf->b_ml.ml_line_len - textlen; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 if (proplen % sizeof(textprop_T) != 0) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
375 iemsg(_("E967: text property info corrupted")); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 return 0; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 if (proplen > 0) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 *props = text + textlen; |
15182
4b2de998ebd6
patch 8.1.0601: a few compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15146
diff
changeset
|
380 return (int)(proplen / sizeof(textprop_T)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
383 /** |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
384 * Return the number of text properties on line "lnum" in the current buffer. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
385 * When "only_starting" is true only text properties starting in this line will |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
386 * be considered. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
387 */ |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
388 int |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
389 count_props(linenr_T lnum, int only_starting) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
390 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
391 char_u *props; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
392 int proplen = get_text_props(curbuf, lnum, &props, 0); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
393 int result = proplen; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
394 int i; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
395 textprop_T prop; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
396 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
397 if (only_starting) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
398 for (i = 0; i < proplen; ++i) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
399 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
400 mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
401 if (prop.tp_flags & TP_FLAG_CONT_PREV) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
402 --result; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
403 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
404 return result; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
405 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
406 |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
407 /* |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
408 * Find text property "type_id" in the visible lines of window "wp". |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
409 * Match "id" when it is > 0. |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
410 * Returns FAIL when not found. |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
411 */ |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
412 int |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
413 find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop, |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
414 linenr_T *found_lnum) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
415 { |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
416 linenr_T lnum; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
417 char_u *props; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
418 int count; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
419 int i; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
420 |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
421 // w_botline may not have been updated yet. |
17865
eaf8b21d80e7
patch 8.1.1929: no tests for text property popup window
Bram Moolenaar <Bram@vim.org>
parents:
17863
diff
changeset
|
422 validate_botline(); |
17863
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
423 for (lnum = wp->w_topline; lnum < wp->w_botline; ++lnum) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
424 { |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
425 count = get_text_props(wp->w_buffer, lnum, &props, FALSE); |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
426 for (i = 0; i < count; ++i) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
427 { |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
428 mch_memmove(prop, props + i * sizeof(textprop_T), |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
429 sizeof(textprop_T)); |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
430 if (prop->tp_type == type_id && (id <= 0 || prop->tp_id == id)) |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
431 { |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
432 *found_lnum = lnum; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
433 return OK; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
434 } |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
435 } |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
436 } |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
437 return FAIL; |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
438 } |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
439 |
08f1dd29550e
patch 8.1.1928: popup windows don't move with the text when making changes
Bram Moolenaar <Bram@vim.org>
parents:
17789
diff
changeset
|
440 /* |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
441 * Set the text properties for line "lnum" to "props" with length "len". |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
442 * If "len" is zero text properties are removed, "props" is not used. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
443 * Any existing text properties are dropped. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
444 * Only works for the current buffer. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
445 */ |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
446 static void |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
447 set_text_props(linenr_T lnum, char_u *props, int len) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
448 { |
15390
00aa76a735e7
patch 8.1.0703: compiler warnings with 64-bit compiler
Bram Moolenaar <Bram@vim.org>
parents:
15373
diff
changeset
|
449 char_u *text; |
00aa76a735e7
patch 8.1.0703: compiler warnings with 64-bit compiler
Bram Moolenaar <Bram@vim.org>
parents:
15373
diff
changeset
|
450 char_u *newtext; |
00aa76a735e7
patch 8.1.0703: compiler warnings with 64-bit compiler
Bram Moolenaar <Bram@vim.org>
parents:
15373
diff
changeset
|
451 int textlen; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
452 |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
453 text = ml_get(lnum); |
15390
00aa76a735e7
patch 8.1.0703: compiler warnings with 64-bit compiler
Bram Moolenaar <Bram@vim.org>
parents:
15373
diff
changeset
|
454 textlen = (int)STRLEN(text) + 1; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
455 newtext = alloc(textlen + len); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
456 if (newtext == NULL) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
457 return; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
458 mch_memmove(newtext, text, textlen); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
459 if (len > 0) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
460 mch_memmove(newtext + textlen, props, len); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
461 if (curbuf->b_ml.ml_flags & ML_LINE_DIRTY) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
462 vim_free(curbuf->b_ml.ml_line_ptr); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
463 curbuf->b_ml.ml_line_ptr = newtext; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
464 curbuf->b_ml.ml_line_len = textlen + len; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
465 curbuf->b_ml.ml_flags |= ML_LINE_DIRTY; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
466 } |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
467 |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 static proptype_T * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 find_type_by_id(hashtab_T *ht, int id) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 long todo; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 hashitem_T *hi; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 if (ht == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 return NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 // TODO: Make this faster by keeping a list of types sorted on ID and use |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 // a binary search. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 todo = (long)ht->ht_used; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 for (hi = ht->ht_array; todo > 0; ++hi) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 if (!HASHITEM_EMPTY(hi)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 proptype_T *prop = HI2PT(hi); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 if (prop->pt_id == id) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 return prop; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 --todo; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 return NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 /* |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
496 * Fill 'dict' with text properties in 'prop'. |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
497 */ |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
498 static void |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
499 prop_fill_dict(dict_T *dict, textprop_T *prop, buf_T *buf) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
500 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
501 proptype_T *pt; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
502 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
503 dict_add_number(dict, "col", prop->tp_col); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
504 dict_add_number(dict, "length", prop->tp_len); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
505 dict_add_number(dict, "id", prop->tp_id); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
506 dict_add_number(dict, "start", !(prop->tp_flags & TP_FLAG_CONT_PREV)); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
507 dict_add_number(dict, "end", !(prop->tp_flags & TP_FLAG_CONT_NEXT)); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
508 pt = text_prop_type_by_id(buf, prop->tp_type); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
509 if (pt != NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
510 dict_add_string(dict, "type", pt->pt_name); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
511 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
512 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
513 /* |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 * Find a property type by ID in "buf" or globally. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 * Returns NULL if not found. |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 proptype_T * |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 text_prop_type_by_id(buf_T *buf, int id) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 proptype_T *type; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 type = find_type_by_id(buf->b_proptypes, id); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 if (type == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 type = find_type_by_id(global_proptypes, id); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 return type; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 * prop_clear({lnum} [, {lnum_end} [, {bufnr}]]) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 f_prop_clear(typval_T *argvars, typval_T *rettv UNUSED) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
534 linenr_T start = tv_get_number(&argvars[0]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 linenr_T end = start; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 linenr_T lnum; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 buf_T *buf = curbuf; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 if (argvars[1].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
541 end = tv_get_number(&argvars[1]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 if (argvars[2].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 if (get_bufnr_from_arg(&argvars[2], &buf) == FAIL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 if (start < 1 || end < 1) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
550 emsg(_(e_invrange)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 for (lnum = start; lnum <= end; ++lnum) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 char_u *text; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 size_t len; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 if (lnum > buf->b_ml.ml_line_count) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 break; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 text = ml_get_buf(buf, lnum, FALSE); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 len = STRLEN(text) + 1; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 if ((size_t)buf->b_ml.ml_line_len > len) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 if (!(buf->b_ml.ml_flags & ML_LINE_DIRTY)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 char_u *newtext = vim_strsave(text); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 // need to allocate the line now |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 if (newtext == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 buf->b_ml.ml_line_ptr = newtext; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 buf->b_ml.ml_flags |= ML_LINE_DIRTY; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 } |
15182
4b2de998ebd6
patch 8.1.0601: a few compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15146
diff
changeset
|
575 buf->b_ml.ml_line_len = (int)len; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 redraw_buf_later(buf, NOT_VALID); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 /* |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
582 * prop_find({props} [, {direction}]) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
583 */ |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
584 void |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
585 f_prop_find(typval_T *argvars, typval_T *rettv) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
586 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
587 pos_T *cursor = &curwin->w_cursor; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
588 dict_T *dict; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
589 buf_T *buf = curbuf; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
590 dictitem_T *di; |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
591 int lnum_start; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
592 int start_pos_has_prop = 0; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
593 int seen_end = 0; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
594 int id = -1; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
595 int type_id = -1; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
596 int skipstart = 0; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
597 int lnum = -1; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
598 int col = -1; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
599 int dir = 1; // 1 = forward, -1 = backward |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
600 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
601 if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
602 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
603 emsg(_(e_invarg)); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
604 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
605 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
606 dict = argvars[0].vval.v_dict; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
607 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
608 if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
609 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
610 if (buf->b_ml.ml_mfp == NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
611 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
612 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
613 if (argvars[1].v_type != VAR_UNKNOWN) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
614 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
615 char_u *dir_s = tv_get_string(&argvars[1]); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
616 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
617 if (*dir_s == 'b') |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
618 dir = -1; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
619 else if (*dir_s != 'f') |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
620 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
621 emsg(_(e_invarg)); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
622 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
623 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
624 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
625 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
626 di = dict_find(dict, (char_u *)"lnum", -1); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
627 if (di != NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
628 lnum = tv_get_number(&di->di_tv); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
629 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
630 di = dict_find(dict, (char_u *)"col", -1); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
631 if (di != NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
632 col = tv_get_number(&di->di_tv); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
633 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
634 if (lnum == -1) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
635 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
636 lnum = cursor->lnum; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
637 col = cursor->col + 1; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
638 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
639 else if (col == -1) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
640 col = 1; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
641 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
642 if (lnum < 1 || lnum > buf->b_ml.ml_line_count) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
643 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
644 emsg(_(e_invrange)); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
645 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
646 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
647 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
648 di = dict_find(dict, (char_u *)"skipstart", -1); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
649 if (di != NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
650 skipstart = tv_get_number(&di->di_tv); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
651 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
652 if (dict_find(dict, (char_u *)"id", -1) != NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
653 id = dict_get_number(dict, (char_u *)"id"); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
654 if (dict_find(dict, (char_u *)"type", -1)) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
655 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
656 char_u *name = dict_get_string(dict, (char_u *)"type", FALSE); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
657 proptype_T *type = lookup_prop_type(name, buf); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
658 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
659 if (type == NULL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
660 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
661 type_id = type->pt_id; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
662 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
663 if (id == -1 && type_id == -1) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
664 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
665 emsg(_("E968: Need at least one of 'id' or 'type'")); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
666 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
667 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
668 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
669 lnum_start = lnum; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
670 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
671 if (rettv_dict_alloc(rettv) == FAIL) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
672 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
673 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
674 while (1) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
675 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
676 char_u *text = ml_get_buf(buf, lnum, FALSE); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
677 size_t textlen = STRLEN(text) + 1; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
678 int count = (int)((buf->b_ml.ml_line_len - textlen) |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
679 / sizeof(textprop_T)); |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
680 int i; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
681 textprop_T prop; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
682 int prop_start; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
683 int prop_end; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
684 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
685 for (i = 0; i < count; ++i) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
686 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
687 mch_memmove(&prop, text + textlen + i * sizeof(textprop_T), |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
688 sizeof(textprop_T)); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
689 |
19642
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
690 if (lnum == lnum_start) |
19644
d2153928b376
patch 8.2.0379: gcc warns for ambiguous else
Bram Moolenaar <Bram@vim.org>
parents:
19642
diff
changeset
|
691 { |
19642
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
692 if (dir < 0) |
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
693 { |
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
694 if (col < prop.tp_col) |
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
695 break; |
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
696 } |
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
697 else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col) |
647ef636a11e
patch 8.2.0378: prop_find() does not find all props
Bram Moolenaar <Bram@vim.org>
parents:
19631
diff
changeset
|
698 continue; |
19644
d2153928b376
patch 8.2.0379: gcc warns for ambiguous else
Bram Moolenaar <Bram@vim.org>
parents:
19642
diff
changeset
|
699 } |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
700 if (prop.tp_id == id || prop.tp_type == type_id) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
701 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
702 // Check if the starting position has text props. |
19631
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
703 if (lnum_start == lnum |
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
704 && col >= prop.tp_col |
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
705 && (col <= prop.tp_col + prop.tp_len |
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
706 - (prop.tp_len != 0))) |
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
707 start_pos_has_prop = 1; |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
708 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
709 prop_start = !(prop.tp_flags & TP_FLAG_CONT_PREV); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
710 prop_end = !(prop.tp_flags & TP_FLAG_CONT_NEXT); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
711 if (!prop_start && prop_end && dir > 0) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
712 seen_end = 1; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
713 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
714 // Skip lines without the start flag. |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
715 if (!prop_start) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
716 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
717 // Always search backwards for start when search started |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
718 // on a prop and we're not skipping. |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
719 if (start_pos_has_prop && !skipstart) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
720 dir = -1; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
721 break; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
722 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
723 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
724 // If skipstart is true, skip the prop at start pos (even if |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
725 // continued from another line). |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
726 if (start_pos_has_prop && skipstart && !seen_end) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
727 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
728 start_pos_has_prop = 0; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
729 break; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
730 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
731 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
732 prop_fill_dict(rettv->vval.v_dict, &prop, buf); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
733 dict_add_number(rettv->vval.v_dict, "lnum", lnum); |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
734 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
735 return; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
736 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
737 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
738 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
739 if (dir > 0) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
740 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
741 if (lnum >= buf->b_ml.ml_line_count) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
742 break; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
743 lnum++; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
744 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
745 else |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
746 { |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
747 if (lnum <= 1) |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
748 break; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
749 lnum--; |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
750 } |
19631
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
751 // Adjust col to indicate that we're continuing from prev/next line. |
1d493fce1fbd
patch 8.2.0372: prop_find() may not find text property at start of the line
Bram Moolenaar <Bram@vim.org>
parents:
19601
diff
changeset
|
752 col = dir < 0 ? buf->b_ml.ml_line_len : 1; |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
753 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
754 } |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
755 |
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
756 /* |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 * prop_list({lnum} [, {bufnr}]) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 f_prop_list(typval_T *argvars, typval_T *rettv) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
762 linenr_T lnum = tv_get_number(&argvars[0]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 buf_T *buf = curbuf; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 if (argvars[1].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 if (get_bufnr_from_arg(&argvars[1], &buf) == FAIL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 if (lnum < 1 || lnum > buf->b_ml.ml_line_count) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
772 emsg(_(e_invrange)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 if (rettv_list_alloc(rettv) == OK) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 char_u *text = ml_get_buf(buf, lnum, FALSE); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 size_t textlen = STRLEN(text) + 1; |
15182
4b2de998ebd6
patch 8.1.0601: a few compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15146
diff
changeset
|
780 int count = (int)((buf->b_ml.ml_line_len - textlen) |
4b2de998ebd6
patch 8.1.0601: a few compiler warnings
Bram Moolenaar <Bram@vim.org>
parents:
15146
diff
changeset
|
781 / sizeof(textprop_T)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 int i; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 textprop_T prop; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 for (i = 0; i < count; ++i) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 dict_T *d = dict_alloc(); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 if (d == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 break; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 mch_memmove(&prop, text + textlen + i * sizeof(textprop_T), |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 sizeof(textprop_T)); |
19100
91bb12995034
patch 8.2.0110: prop_find() is not implemented
Bram Moolenaar <Bram@vim.org>
parents:
19049
diff
changeset
|
793 prop_fill_dict(d, &prop, buf); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 list_append_dict(rettv->vval.v_list, d); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 * prop_remove({props} [, {lnum} [, {lnum_end}]]) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 f_prop_remove(typval_T *argvars, typval_T *rettv) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 linenr_T start = 1; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 linenr_T end = 0; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 linenr_T lnum; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 dict_T *dict; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 buf_T *buf = curbuf; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 dictitem_T *di; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 int do_all = FALSE; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 int id = -1; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 int type_id = -1; |
19601
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
814 int both = FALSE; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 rettv->vval.v_number = 0; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 if (argvars[0].v_type != VAR_DICT || argvars[0].vval.v_dict == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
819 emsg(_(e_invarg)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 if (argvars[1].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
825 start = tv_get_number(&argvars[1]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 end = start; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 if (argvars[2].v_type != VAR_UNKNOWN) |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
828 end = tv_get_number(&argvars[2]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 if (start < 1 || end < 1) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
831 emsg(_(e_invrange)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 dict = argvars[0].vval.v_dict; |
16772
18093a6accb5
patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents:
16770
diff
changeset
|
837 if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL) |
18093a6accb5
patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents:
16770
diff
changeset
|
838 return; |
18093a6accb5
patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents:
16770
diff
changeset
|
839 if (buf->b_ml.ml_mfp == NULL) |
18093a6accb5
patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents:
16770
diff
changeset
|
840 return; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 di = dict_find(dict, (char_u*)"all", -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 if (di != NULL) |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15144
diff
changeset
|
844 do_all = dict_get_number(dict, (char_u *)"all"); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 if (dict_find(dict, (char_u *)"id", -1) != NULL) |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15144
diff
changeset
|
847 id = dict_get_number(dict, (char_u *)"id"); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 if (dict_find(dict, (char_u *)"type", -1)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 { |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15144
diff
changeset
|
850 char_u *name = dict_get_string(dict, (char_u *)"type", FALSE); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 proptype_T *type = lookup_prop_type(name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 if (type == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 type_id = type->pt_id; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 } |
19601
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
857 if (dict_find(dict, (char_u *)"both", -1) != NULL) |
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
858 both = dict_get_number(dict, (char_u *)"both"); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 if (id == -1 && type_id == -1) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
861 emsg(_("E968: Need at least one of 'id' or 'type'")); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 } |
19601
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
864 if (both && (id == -1 || type_id == -1)) |
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
865 { |
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
866 emsg(_("E860: Need 'id' and 'type' with 'both'")); |
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
867 return; |
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
868 } |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 if (end == 0) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 end = buf->b_ml.ml_line_count; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 for (lnum = start; lnum <= end; ++lnum) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 char_u *text; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 size_t len; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 if (lnum > buf->b_ml.ml_line_count) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 break; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 text = ml_get_buf(buf, lnum, FALSE); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 len = STRLEN(text) + 1; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 if ((size_t)buf->b_ml.ml_line_len > len) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
883 static textprop_T textprop; // static because of alignment |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
884 unsigned idx; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 for (idx = 0; idx < (buf->b_ml.ml_line_len - len) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 / sizeof(textprop_T); ++idx) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 char_u *cur_prop = buf->b_ml.ml_line_ptr + len |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 + idx * sizeof(textprop_T); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 size_t taillen; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 mch_memmove(&textprop, cur_prop, sizeof(textprop_T)); |
19601
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
894 if (both ? textprop.tp_id == id && textprop.tp_type == type_id |
67f39cb0a49c
patch 8.2.0357: cannot delete a text property matching both id and type
Bram Moolenaar <Bram@vim.org>
parents:
19534
diff
changeset
|
895 : textprop.tp_id == id || textprop.tp_type == type_id) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 if (!(buf->b_ml.ml_flags & ML_LINE_DIRTY)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 char_u *newptr = alloc(buf->b_ml.ml_line_len); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 // need to allocate the line to be able to change it |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 if (newptr == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 mch_memmove(newptr, buf->b_ml.ml_line_ptr, |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 buf->b_ml.ml_line_len); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 buf->b_ml.ml_line_ptr = newptr; |
16060
176872829dc2
patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents:
15939
diff
changeset
|
907 buf->b_ml.ml_flags |= ML_LINE_DIRTY; |
176872829dc2
patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents:
15939
diff
changeset
|
908 |
176872829dc2
patch 8.1.1035: prop_remove() second argument is not optional
Bram Moolenaar <Bram@vim.org>
parents:
15939
diff
changeset
|
909 cur_prop = buf->b_ml.ml_line_ptr + len |
16772
18093a6accb5
patch 8.1.1388: errors when calling prop_remove() for an unloaded buffer
Bram Moolenaar <Bram@vim.org>
parents:
16770
diff
changeset
|
910 + idx * sizeof(textprop_T); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 taillen = buf->b_ml.ml_line_len - len |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 - (idx + 1) * sizeof(textprop_T); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 if (taillen > 0) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 mch_memmove(cur_prop, cur_prop + sizeof(textprop_T), |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 taillen); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 buf->b_ml.ml_line_len -= sizeof(textprop_T); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 --idx; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 ++rettv->vval.v_number; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 if (!do_all) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 break; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 redraw_buf_later(buf, NOT_VALID); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 * Common for f_prop_type_add() and f_prop_type_change(). |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 */ |
17789
0f7ae8010787
patch 8.1.1891: functions used in one file are global
Bram Moolenaar <Bram@vim.org>
parents:
17694
diff
changeset
|
934 static void |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 prop_type_set(typval_T *argvars, int add) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 char_u *name; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 buf_T *buf = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 dict_T *dict; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 dictitem_T *di; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 proptype_T *prop; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
943 name = tv_get_string(&argvars[0]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 if (*name == NUL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
946 emsg(_(e_invarg)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 if (get_bufnr_from_arg(&argvars[1], &buf) == FAIL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 dict = argvars[1].vval.v_dict; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 prop = find_prop(name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 if (add) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 hashtab_T **htp; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 if (prop != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
961 semsg(_("E969: Property type %s already defined"), name); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 } |
17659
121bdff812b4
patch 8.1.1827: allocating more memory than needed for extended structs
Bram Moolenaar <Bram@vim.org>
parents:
16924
diff
changeset
|
964 prop = alloc_clear(offsetof(proptype_T, pt_name) + STRLEN(name) + 1); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 if (prop == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 STRCPY(prop->pt_name, name); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 prop->pt_id = ++proptype_id; |
18609
efad02c0e3e1
patch 8.1.2298: missing part of 8.1.2296
Bram Moolenaar <Bram@vim.org>
parents:
18498
diff
changeset
|
969 prop->pt_flags = PT_FLAG_COMBINE; |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 htp = buf == NULL ? &global_proptypes : &buf->b_proptypes; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 if (*htp == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 { |
16825
ce04ebdf26b8
patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents:
16811
diff
changeset
|
973 *htp = ALLOC_ONE(hashtab_T); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 if (*htp == NULL) |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
975 { |
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
976 vim_free(prop); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 return; |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
978 } |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 hash_init(*htp); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 } |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
981 hash_add(*htp, PT2HIKEY(prop)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 else |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 if (prop == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
987 semsg(_(e_type_not_exist), name); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 if (dict != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 di = dict_find(dict, (char_u *)"highlight", -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 if (di != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 char_u *highlight; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 int hl_id = 0; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 |
15146
7903dce131d4
patch 8.1.0583: using illogical name for get_dict_number()/get_dict_string()
Bram Moolenaar <Bram@vim.org>
parents:
15144
diff
changeset
|
1000 highlight = dict_get_string(dict, (char_u *)"highlight", FALSE); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 if (highlight != NULL && *highlight != NUL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 hl_id = syn_name2id(highlight); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 if (hl_id <= 0) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
1005 semsg(_("E970: Unknown highlight group name: '%s'"), |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 highlight == NULL ? (char_u *)"" : highlight); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 prop->pt_hl_id = hl_id; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 |
16549
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1012 di = dict_find(dict, (char_u *)"combine", -1); |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1013 if (di != NULL) |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1014 { |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1015 if (tv_get_number(&di->di_tv)) |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1016 prop->pt_flags |= PT_FLAG_COMBINE; |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1017 else |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1018 prop->pt_flags &= ~PT_FLAG_COMBINE; |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1019 } |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1020 |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 di = dict_find(dict, (char_u *)"priority", -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 if (di != NULL) |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
1023 prop->pt_priority = tv_get_number(&di->di_tv); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 di = dict_find(dict, (char_u *)"start_incl", -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 if (di != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
1028 if (tv_get_number(&di->di_tv)) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 prop->pt_flags |= PT_FLAG_INS_START_INCL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 else |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 prop->pt_flags &= ~PT_FLAG_INS_START_INCL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 di = dict_find(dict, (char_u *)"end_incl", -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 if (di != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
1037 if (tv_get_number(&di->di_tv)) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 prop->pt_flags |= PT_FLAG_INS_END_INCL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 else |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 prop->pt_flags &= ~PT_FLAG_INS_END_INCL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 * prop_type_add({name}, {props}) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 f_prop_type_add(typval_T *argvars, typval_T *rettv UNUSED) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 prop_type_set(argvars, TRUE); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 * prop_type_change({name}, {props}) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 f_prop_type_change(typval_T *argvars, typval_T *rettv UNUSED) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 prop_type_set(argvars, FALSE); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 * prop_type_delete({name} [, {bufnr}]) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 char_u *name; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 buf_T *buf = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 hashitem_T *hi; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
1073 name = tv_get_string(&argvars[0]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 if (*name == NUL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
1076 emsg(_(e_invarg)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 if (argvars[1].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 if (get_bufnr_from_arg(&argvars[1], &buf) == FAIL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 hi = find_prop_hi(name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 if (hi != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 hashtab_T *ht; |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
1090 proptype_T *prop = HI2PT(hi); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 if (buf == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 ht = global_proptypes; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 else |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 ht = buf->b_proptypes; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 hash_remove(ht, hi); |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
1097 vim_free(prop); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 * prop_type_get({name} [, {bufnr}]) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 void |
19049
e47b04b01793
patch 8.2.0085: dead code in builtin functions
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
1105 f_prop_type_get(typval_T *argvars, typval_T *rettv) |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 { |
15211
de63593896b3
patch 8.1.0615: get_tv function names are not consistent
Bram Moolenaar <Bram@vim.org>
parents:
15182
diff
changeset
|
1107 char_u *name = tv_get_string(&argvars[0]); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 if (*name == NUL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 { |
15470
55ccc2d353bd
patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents:
15390
diff
changeset
|
1111 emsg(_(e_invarg)); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 if (rettv_dict_alloc(rettv) == OK) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 proptype_T *prop = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 buf_T *buf = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 if (argvars[1].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 if (get_bufnr_from_arg(&argvars[1], &buf) == FAIL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 prop = find_prop(name, buf); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 if (prop != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 dict_T *d = rettv->vval.v_dict; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 if (prop->pt_hl_id > 0) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 dict_add_string(d, "highlight", syn_id2name(prop->pt_hl_id)); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 dict_add_number(d, "priority", prop->pt_priority); |
16549
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1133 dict_add_number(d, "combine", |
08557bad0b9d
patch 8.1.1278: missing change for "combine" field
Bram Moolenaar <Bram@vim.org>
parents:
16060
diff
changeset
|
1134 (prop->pt_flags & PT_FLAG_COMBINE) ? 1 : 0); |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 dict_add_number(d, "start_incl", |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 (prop->pt_flags & PT_FLAG_INS_START_INCL) ? 1 : 0); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 dict_add_number(d, "end_incl", |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 (prop->pt_flags & PT_FLAG_INS_END_INCL) ? 1 : 0); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 if (buf != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 dict_add_number(d, "bufnr", buf->b_fnum); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 static void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 list_types(hashtab_T *ht, list_T *l) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 long todo; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 hashitem_T *hi; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 todo = (long)ht->ht_used; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 for (hi = ht->ht_array; todo > 0; ++hi) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 if (!HASHITEM_EMPTY(hi)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 proptype_T *prop = HI2PT(hi); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 list_append_string(l, prop->pt_name, -1); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 --todo; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 * prop_type_list([{bufnr}]) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 f_prop_type_list(typval_T *argvars, typval_T *rettv UNUSED) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 buf_T *buf = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 if (rettv_list_alloc(rettv) == OK) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 if (argvars[0].v_type != VAR_UNKNOWN) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 if (get_bufnr_from_arg(&argvars[0], &buf) == FAIL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 if (buf == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 if (global_proptypes != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 list_types(global_proptypes, rettv->vval.v_list); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 else if (buf->b_proptypes != NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 list_types(buf->b_proptypes, rettv->vval.v_list); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 * Free all property types in "ht". |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 static void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 clear_ht_prop_types(hashtab_T *ht) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 long todo; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 hashitem_T *hi; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 if (ht == NULL) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 return; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 todo = (long)ht->ht_used; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 for (hi = ht->ht_array; todo > 0; ++hi) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 if (!HASHITEM_EMPTY(hi)) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 proptype_T *prop = HI2PT(hi); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 vim_free(prop); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 --todo; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 hash_clear(ht); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 vim_free(ht); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 #if defined(EXITFREE) || defined(PROTO) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 /* |
15144
7960bf50d345
patch 8.1.0582: text properties are not enabled
Bram Moolenaar <Bram@vim.org>
parents:
15138
diff
changeset
|
1219 * Free all global property types. |
15138
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 clear_global_prop_types(void) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 clear_ht_prop_types(global_proptypes); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 global_proptypes = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 #endif |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 /* |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 * Free all property types for "buf". |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 */ |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 void |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 clear_buf_prop_types(buf_T *buf) |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 { |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 clear_ht_prop_types(buf->b_proptypes); |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 buf->b_proptypes = NULL; |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 } |
9df130fd5e0d
patch 8.1.0579: cannot attach properties to text
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1239 // Struct used to return two values from adjust_prop(). |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1240 typedef struct |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1241 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1242 int dirty; // if the property was changed |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1243 int can_drop; // whether after this change, the prop may be removed |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1244 } adjustres_T; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1245 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1246 /* |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1247 * Adjust the property for "added" bytes (can be negative) inserted at "col". |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1248 * |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1249 * Note that "col" is zero-based, while tp_col is one-based. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1250 * Only for the current buffer. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1251 * "flags" can have: |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1252 * APC_SUBSTITUTE: Text is replaced, not inserted. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1253 */ |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1254 static adjustres_T |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1255 adjust_prop( |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1256 textprop_T *prop, |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1257 colnr_T col, |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1258 int added, |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1259 int flags) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1260 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1261 proptype_T *pt = text_prop_type_by_id(curbuf, prop->tp_type); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1262 int start_incl = (pt != NULL |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1263 && (pt->pt_flags & PT_FLAG_INS_START_INCL)) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1264 || (flags & APC_SUBSTITUTE); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1265 int end_incl = (pt != NULL |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1266 && (pt->pt_flags & PT_FLAG_INS_END_INCL)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1267 // Do not drop zero-width props if they later can increase in |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1268 // size. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1269 int droppable = !(start_incl || end_incl); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1270 adjustres_T res = {TRUE, FALSE}; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1271 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1272 if (added > 0) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1273 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1274 if (col + 1 <= prop->tp_col |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1275 - (start_incl || (prop->tp_len == 0 && end_incl))) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1276 // Change is entirely before the text property: Only shift |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1277 prop->tp_col += added; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1278 else if (col + 1 < prop->tp_col + prop->tp_len + end_incl) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1279 // Insertion was inside text property |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1280 prop->tp_len += added; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1281 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1282 else if (prop->tp_col > col + 1) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1283 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1284 if (prop->tp_col + added < col + 1) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1285 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1286 prop->tp_len += (prop->tp_col - 1 - col) + added; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1287 prop->tp_col = col + 1; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1288 if (prop->tp_len <= 0) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1289 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1290 prop->tp_len = 0; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1291 res.can_drop = droppable; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1292 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1293 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1294 else |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1295 prop->tp_col += added; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1296 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1297 else if (prop->tp_len > 0 && prop->tp_col + prop->tp_len > col) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1298 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1299 int after = col - added - (prop->tp_col - 1 + prop->tp_len); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1300 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1301 prop->tp_len += after > 0 ? added + after : added; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1302 res.can_drop = prop->tp_len <= 0 && droppable; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1303 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1304 else |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1305 res.dirty = FALSE; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1306 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1307 return res; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1308 } |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1309 |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1310 /* |
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1311 * Adjust the columns of text properties in line "lnum" after position "col" to |
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1312 * shift by "bytes_added" (can be negative). |
15341
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1313 * Note that "col" is zero-based, while tp_col is one-based. |
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1314 * Only for the current buffer. |
16714
ba592f30c082
patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents:
16698
diff
changeset
|
1315 * "flags" can have: |
ba592f30c082
patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents:
16698
diff
changeset
|
1316 * APC_SAVE_FOR_UNDO: Call u_savesub() before making changes to the line. |
ba592f30c082
patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents:
16698
diff
changeset
|
1317 * APC_SUBSTITUTE: Text is replaced, not inserted. |
16682
7847d281cbbf
patch 8.1.1343: text properties not adjusted for Visual block mode delete
Bram Moolenaar <Bram@vim.org>
parents:
16678
diff
changeset
|
1318 * Caller is expected to check b_has_textprop and "bytes_added" being non-zero. |
16698
23af483c4ceb
patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16682
diff
changeset
|
1319 * Returns TRUE when props were changed. |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1320 */ |
16698
23af483c4ceb
patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16682
diff
changeset
|
1321 int |
15349
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1322 adjust_prop_columns( |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1323 linenr_T lnum, |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1324 colnr_T col, |
16698
23af483c4ceb
patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16682
diff
changeset
|
1325 int bytes_added, |
16714
ba592f30c082
patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents:
16698
diff
changeset
|
1326 int flags) |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1327 { |
15341
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1328 int proplen; |
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1329 char_u *props; |
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1330 int dirty = FALSE; |
15349
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1331 int ri, wi; |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1332 size_t textlen; |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1333 |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1334 if (text_prop_frozen > 0) |
16698
23af483c4ceb
patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16682
diff
changeset
|
1335 return FALSE; |
15341
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1336 |
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1337 proplen = get_text_props(curbuf, lnum, &props, TRUE); |
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1338 if (proplen == 0) |
16698
23af483c4ceb
patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16682
diff
changeset
|
1339 return FALSE; |
15349
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1340 textlen = curbuf->b_ml.ml_line_len - proplen * sizeof(textprop_T); |
15341
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1341 |
15349
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1342 wi = 0; // write index |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1343 for (ri = 0; ri < proplen; ++ri) |
15341
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1344 { |
19534
36ec10251b2b
patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents:
19100
diff
changeset
|
1345 textprop_T prop; |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1346 adjustres_T res; |
19534
36ec10251b2b
patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents:
19100
diff
changeset
|
1347 |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1348 mch_memmove(&prop, props + ri * sizeof(prop), sizeof(prop)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1349 res = adjust_prop(&prop, col, bytes_added, flags); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1350 if (res.dirty) |
19534
36ec10251b2b
patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents:
19100
diff
changeset
|
1351 { |
16714
ba592f30c082
patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents:
16698
diff
changeset
|
1352 // Save for undo if requested and not done yet. |
21081
71a36879ac2a
patch 8.2.1092: not checking if saving for undo succeeds
Bram Moolenaar <Bram@vim.org>
parents:
20583
diff
changeset
|
1353 if ((flags & APC_SAVE_FOR_UNDO) && !dirty |
71a36879ac2a
patch 8.2.1092: not checking if saving for undo succeeds
Bram Moolenaar <Bram@vim.org>
parents:
20583
diff
changeset
|
1354 && u_savesub(lnum) == FAIL) |
71a36879ac2a
patch 8.2.1092: not checking if saving for undo succeeds
Bram Moolenaar <Bram@vim.org>
parents:
20583
diff
changeset
|
1355 return FALSE; |
16714
ba592f30c082
patch 8.1.1359: text property wrong after :substitute with backslash
Bram Moolenaar <Bram@vim.org>
parents:
16698
diff
changeset
|
1356 dirty = TRUE; |
19534
36ec10251b2b
patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents:
19100
diff
changeset
|
1357 } |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1358 if (res.can_drop) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1359 continue; // Drop this text property |
19534
36ec10251b2b
patch 8.2.0324: text property not updated correctly when inserting/deleting
Bram Moolenaar <Bram@vim.org>
parents:
19100
diff
changeset
|
1360 mch_memmove(props + wi * sizeof(textprop_T), &prop, sizeof(textprop_T)); |
15349
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1361 ++wi; |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1362 } |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1363 if (dirty) |
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1364 { |
15373
44dd3ce11201
patch 8.1.0694: when using text props may free memory that is not allocated
Bram Moolenaar <Bram@vim.org>
parents:
15367
diff
changeset
|
1365 colnr_T newlen = (int)textlen + wi * (colnr_T)sizeof(textprop_T); |
44dd3ce11201
patch 8.1.0694: when using text props may free memory that is not allocated
Bram Moolenaar <Bram@vim.org>
parents:
15367
diff
changeset
|
1366 |
44dd3ce11201
patch 8.1.0694: when using text props may free memory that is not allocated
Bram Moolenaar <Bram@vim.org>
parents:
15367
diff
changeset
|
1367 if ((curbuf->b_ml.ml_flags & ML_LINE_DIRTY) == 0) |
44dd3ce11201
patch 8.1.0694: when using text props may free memory that is not allocated
Bram Moolenaar <Bram@vim.org>
parents:
15367
diff
changeset
|
1368 curbuf->b_ml.ml_line_ptr = |
44dd3ce11201
patch 8.1.0694: when using text props may free memory that is not allocated
Bram Moolenaar <Bram@vim.org>
parents:
15367
diff
changeset
|
1369 vim_memsave(curbuf->b_ml.ml_line_ptr, newlen); |
15349
6abee072b93c
patch 8.1.0682: text properties not adjusted when backspacing replaced text
Bram Moolenaar <Bram@vim.org>
parents:
15341
diff
changeset
|
1370 curbuf->b_ml.ml_flags |= ML_LINE_DIRTY; |
15373
44dd3ce11201
patch 8.1.0694: when using text props may free memory that is not allocated
Bram Moolenaar <Bram@vim.org>
parents:
15367
diff
changeset
|
1371 curbuf->b_ml.ml_line_len = newlen; |
15341
03a7a9fdb792
patch 8.1.0678: text properties as not adjusted for inserted text
Bram Moolenaar <Bram@vim.org>
parents:
15335
diff
changeset
|
1372 } |
16698
23af483c4ceb
patch 8.1.1351: text property wrong after :substitute
Bram Moolenaar <Bram@vim.org>
parents:
16682
diff
changeset
|
1373 return dirty; |
15335
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1374 } |
18c20ceee4b5
patch 8.1.0675: text property column in screen columns is not practical
Bram Moolenaar <Bram@vim.org>
parents:
15294
diff
changeset
|
1375 |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1376 /* |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1377 * Adjust text properties for a line that was split in two. |
16662
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1378 * "lnum_props" is the line that has the properties from before the split. |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1379 * "lnum_top" is the top line. |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1380 * "kept" is the number of bytes kept in the first line, while |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1381 * "deleted" is the number of bytes deleted. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1382 */ |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1383 void |
16662
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1384 adjust_props_for_split( |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1385 linenr_T lnum_props, |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1386 linenr_T lnum_top, |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1387 int kept, |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1388 int deleted) |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1389 { |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1390 char_u *props; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1391 int count; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1392 garray_T prevprop; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1393 garray_T nextprop; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1394 int i; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1395 int skipped = kept + deleted; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1396 |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1397 if (!curbuf->b_has_textprop) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1398 return; |
16662
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1399 |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1400 // Get the text properties from "lnum_props". |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1401 count = get_text_props(curbuf, lnum_props, &props, FALSE); |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1402 ga_init2(&prevprop, sizeof(textprop_T), 10); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1403 ga_init2(&nextprop, sizeof(textprop_T), 10); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1404 |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1405 // Keep the relevant ones in the first line, reducing the length if needed. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1406 // Copy the ones that include the split to the second line. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1407 // Move the ones after the split to the second line. |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1408 for (i = 0; i < count; ++i) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1409 { |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1410 textprop_T prop; |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1411 proptype_T *pt; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1412 int start_incl, end_incl; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1413 int cont_prev, cont_next; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1414 |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1415 // copy the prop to an aligned structure |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1416 mch_memmove(&prop, props + i * sizeof(textprop_T), sizeof(textprop_T)); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1417 |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1418 pt = text_prop_type_by_id(curbuf, prop.tp_type); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1419 start_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1420 end_incl = (pt != NULL && (pt->pt_flags & PT_FLAG_INS_END_INCL)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1421 cont_prev = prop.tp_col + !start_incl <= kept; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1422 cont_next = skipped <= prop.tp_col + prop.tp_len - !end_incl; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1423 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1424 if (cont_prev && ga_grow(&prevprop, 1) == OK) |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1425 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1426 textprop_T *p = ((textprop_T *)prevprop.ga_data) + prevprop.ga_len; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1427 |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1428 *p = prop; |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1429 ++prevprop.ga_len; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1430 if (p->tp_col + p->tp_len >= kept) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1431 p->tp_len = kept - p->tp_col; |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1432 if (cont_next) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1433 p->tp_flags |= TP_FLAG_CONT_NEXT; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1434 } |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1435 |
16670
5733d8e33bce
patch 8.1.1337: get empty text prop when splitting line just after text prop
Bram Moolenaar <Bram@vim.org>
parents:
16662
diff
changeset
|
1436 // Only add the property to the next line if the length is bigger than |
5733d8e33bce
patch 8.1.1337: get empty text prop when splitting line just after text prop
Bram Moolenaar <Bram@vim.org>
parents:
16662
diff
changeset
|
1437 // zero. |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1438 if (cont_next && ga_grow(&nextprop, 1) == OK) |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1439 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1440 textprop_T *p = ((textprop_T *)nextprop.ga_data) + nextprop.ga_len; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1441 *p = prop; |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1442 ++nextprop.ga_len; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1443 if (p->tp_col > skipped) |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1444 p->tp_col -= skipped - 1; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1445 else |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1446 { |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1447 p->tp_len -= skipped - p->tp_col; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1448 p->tp_col = 1; |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1449 } |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1450 if (cont_prev) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1451 p->tp_flags |= TP_FLAG_CONT_PREV; |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1452 } |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1453 } |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1454 |
16662
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1455 set_text_props(lnum_top, prevprop.ga_data, |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1456 prevprop.ga_len * sizeof(textprop_T)); |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1457 ga_clear(&prevprop); |
16662
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1458 set_text_props(lnum_top + 1, nextprop.ga_data, |
1fc9cd08cf3c
patch 8.1.1333: text properties don't always move after changes
Bram Moolenaar <Bram@vim.org>
parents:
16549
diff
changeset
|
1459 nextprop.ga_len * sizeof(textprop_T)); |
15367
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1460 ga_clear(&nextprop); |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1461 } |
273649cad196
patch 8.1.0691: text properties are not adjusted for :substitute
Bram Moolenaar <Bram@vim.org>
parents:
15355
diff
changeset
|
1462 |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1463 /* |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1464 * Prepend properties of joined line "lnum" to "new_props". |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1465 */ |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1466 void |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1467 prepend_joined_props( |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1468 char_u *new_props, |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1469 int propcount, |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1470 int *props_remaining, |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1471 linenr_T lnum, |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1472 int add_all, |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1473 long col, |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1474 int removed) |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1475 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1476 char_u *props; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1477 int proplen = get_text_props(curbuf, lnum, &props, FALSE); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1478 int i; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1479 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1480 for (i = proplen; i-- > 0; ) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1481 { |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1482 textprop_T prop; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1483 int end; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1484 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1485 mch_memmove(&prop, props + i * sizeof(prop), sizeof(prop)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1486 end = !(prop.tp_flags & TP_FLAG_CONT_NEXT); |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1487 |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1488 adjust_prop(&prop, 0, -removed, 0); // Remove leading spaces |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1489 adjust_prop(&prop, -1, col, 0); // Make line start at its final colum |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1490 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1491 if (add_all || end) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1492 mch_memmove(new_props + --(*props_remaining) * sizeof(prop), |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1493 &prop, sizeof(prop)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1494 else |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1495 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1496 int j; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1497 int found = FALSE; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1498 |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1499 // Search for continuing prop. |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1500 for (j = *props_remaining; j < propcount; ++j) |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1501 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1502 textprop_T op; |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1503 |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1504 mch_memmove(&op, new_props + j * sizeof(op), sizeof(op)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1505 if ((op.tp_flags & TP_FLAG_CONT_PREV) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1506 && op.tp_id == prop.tp_id && op.tp_type == prop.tp_type) |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1507 { |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1508 found = TRUE; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1509 op.tp_len += op.tp_col - prop.tp_col; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1510 op.tp_col = prop.tp_col; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1511 // Start/end is taken care of when deleting joined lines |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1512 op.tp_flags = prop.tp_flags; |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1513 mch_memmove(new_props + j * sizeof(op), &op, sizeof(op)); |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1514 break; |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1515 } |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1516 } |
20583
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1517 if (!found) |
d067be761cd7
patch 8.2.0845: text properties crossing lines not handled correctly
Bram Moolenaar <Bram@vim.org>
parents:
19644
diff
changeset
|
1518 internal_error("text property above joined line not found"); |
16678
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1519 } |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1520 } |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1521 } |
6f453673eb19
patch 8.1.1341: text properties are lost when joining lines
Bram Moolenaar <Bram@vim.org>
parents:
16676
diff
changeset
|
1522 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18631
diff
changeset
|
1523 #endif // FEAT_PROP_POPUP |