Mercurial > vim
comparison src/textprop.c @ 17863:08f1dd29550e v8.1.1928
patch 8.1.1928: popup windows don't move with the text when making changes
Commit: https://github.com/vim/vim/commit/12034e22dd80cf533ac1c681be521ab299383f63
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 25 22:25:02 2019 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 25 Aug 2019 22:30:03 +0200 |
parents | 0f7ae8010787 |
children | eaf8b21d80e7 |
comparison
equal
deleted
inserted
replaced
17862:debebb1dcef1 | 17863:08f1dd29550e |
---|---|
89 return NULL; | 89 return NULL; |
90 return HI2PT(hi); | 90 return HI2PT(hi); |
91 } | 91 } |
92 | 92 |
93 /* | 93 /* |
94 * Get the prop type ID of "name". | |
95 * When not found return zero. | |
96 */ | |
97 int | |
98 find_prop_type_id(char_u *name, buf_T *buf) | |
99 { | |
100 proptype_T *pt = find_prop(name, buf); | |
101 | |
102 if (pt == NULL) | |
103 return 0; | |
104 return pt->pt_id; | |
105 } | |
106 | |
107 /* | |
94 * Lookup a property type by name. First in "buf" and when not found in the | 108 * Lookup a property type by name. First in "buf" and when not found in the |
95 * global types. | 109 * global types. |
96 * When not found gives an error message and returns NULL. | 110 * When not found gives an error message and returns NULL. |
97 */ | 111 */ |
98 static proptype_T * | 112 static proptype_T * |
363 return 0; | 377 return 0; |
364 } | 378 } |
365 if (proplen > 0) | 379 if (proplen > 0) |
366 *props = text + textlen; | 380 *props = text + textlen; |
367 return (int)(proplen / sizeof(textprop_T)); | 381 return (int)(proplen / sizeof(textprop_T)); |
382 } | |
383 | |
384 /* | |
385 * Find text property "type_id" in the visible lines of window "wp". | |
386 * Match "id" when it is > 0. | |
387 * Returns FAIL when not found. | |
388 */ | |
389 int | |
390 find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop, | |
391 linenr_T *found_lnum) | |
392 { | |
393 linenr_T lnum; | |
394 char_u *props; | |
395 int count; | |
396 int i; | |
397 | |
398 // w_botline may not have been updated yet. | |
399 if (wp->w_botline > wp->w_buffer->b_ml.ml_line_count) | |
400 wp->w_botline = wp->w_buffer->b_ml.ml_line_count + 1; | |
401 for (lnum = wp->w_topline; lnum < wp->w_botline; ++lnum) | |
402 { | |
403 count = get_text_props(wp->w_buffer, lnum, &props, FALSE); | |
404 for (i = 0; i < count; ++i) | |
405 { | |
406 mch_memmove(prop, props + i * sizeof(textprop_T), | |
407 sizeof(textprop_T)); | |
408 if (prop->tp_type == type_id && (id <= 0 || prop->tp_id == id)) | |
409 { | |
410 *found_lnum = lnum; | |
411 return OK; | |
412 } | |
413 } | |
414 } | |
415 return FAIL; | |
368 } | 416 } |
369 | 417 |
370 /* | 418 /* |
371 * Set the text properties for line "lnum" to "props" with length "len". | 419 * Set the text properties for line "lnum" to "props" with length "len". |
372 * If "len" is zero text properties are removed, "props" is not used. | 420 * If "len" is zero text properties are removed, "props" is not used. |