1
0
forked from aniani/vim

patch 8.1.1928: popup windows don't move with the text when making changes

Problem:    Popup windows don't move with the text when making changes.
Solution:   Add the 'textprop" property to the popup window options, position
            the popup relative to a text property. (closes #4560)
            No tests yet.
This commit is contained in:
Bram Moolenaar
2019-08-25 22:25:02 +02:00
parent 307c5a5bb7
commit 12034e22dd
10 changed files with 418 additions and 96 deletions

View File

@@ -90,6 +90,20 @@ find_prop(char_u *name, buf_T *buf)
return HI2PT(hi);
}
/*
* Get the prop type ID of "name".
* When not found return zero.
*/
int
find_prop_type_id(char_u *name, buf_T *buf)
{
proptype_T *pt = find_prop(name, buf);
if (pt == NULL)
return 0;
return pt->pt_id;
}
/*
* Lookup a property type by name. First in "buf" and when not found in the
* global types.
@@ -367,6 +381,40 @@ get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change)
return (int)(proplen / sizeof(textprop_T));
}
/*
* Find text property "type_id" in the visible lines of window "wp".
* Match "id" when it is > 0.
* Returns FAIL when not found.
*/
int
find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop,
linenr_T *found_lnum)
{
linenr_T lnum;
char_u *props;
int count;
int i;
// w_botline may not have been updated yet.
if (wp->w_botline > wp->w_buffer->b_ml.ml_line_count)
wp->w_botline = wp->w_buffer->b_ml.ml_line_count + 1;
for (lnum = wp->w_topline; lnum < wp->w_botline; ++lnum)
{
count = get_text_props(wp->w_buffer, lnum, &props, FALSE);
for (i = 0; i < count; ++i)
{
mch_memmove(prop, props + i * sizeof(textprop_T),
sizeof(textprop_T));
if (prop->tp_type == type_id && (id <= 0 || prop->tp_id == id))
{
*found_lnum = lnum;
return OK;
}
}
}
return FAIL;
}
/*
* Set the text properties for line "lnum" to "props" with length "len".
* If "len" is zero text properties are removed, "props" is not used.