/* vi:set ts=8 sts=4 sw=4 noet:
*
* VIM - Vi IMproved by Bram Moolenaar
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
* See README.txt for an overview of the Vim source code.
*/
/*
* Text properties implementation. See ":help text-properties".
*
* TODO:
* - Adjust text property column and length when text is inserted/deleted.
* -> a :substitute with a multi-line match
* -> search for changed_bytes() from misc1.c
* -> search for mark_col_adjust()
* - Perhaps we only need TP_FLAG_CONT_NEXT and can drop TP_FLAG_CONT_PREV?
* - Add an array for global_proptypes, to quickly lookup a prop type by ID
* - Add an array for b_proptypes, to quickly lookup a prop type by ID
* - Checking the text length to detect text properties is slow. Use a flag in
* the index, like DB_MARKED?
* - Also test line2byte() with many lines, so that ml_updatechunk() is taken
* into account.
* - Perhaps have a window-local option to disable highlighting from text
* properties?
*/
#include "vim.h"
#if defined(FEAT_PROP_POPUP) || defined(PROTO)
/*
* In a hashtable item "hi_key" points to "pt_name" in a proptype_T.
* This avoids adding a pointer to the hashtable item.
* PT2HIKEY() converts a proptype pointer to a hashitem key pointer.
* HIKEY2PT() converts a hashitem key pointer to a proptype pointer.
* HI2PT() converts a hashitem pointer to a proptype pointer.
*/
#define PT2HIKEY(p) ((p)->pt_name)
#define HIKEY2PT(p) ((proptype_T *)((p) - offsetof(proptype_T, pt_name)))
#define HI2PT(hi) HIKEY2PT((hi)->hi_key)
// The global text property types.
static hashtab_T *global_proptypes = NULL;
// The last used text property type ID.
static int proptype_id = 0;
static char_u e_type_not_exist[] = N_("E971: Property type %s does not exist");
static char_u e_invalid_col[] = N_