extmark: rename ExtendedMark => Extmark
This commit is contained in:
parent
54473e9a67
commit
2d7e1c32a8
|
@ -1027,9 +1027,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedMark *extmark = extmark_from_id(buf,
|
Extmark *extmark = extmark_from_id(buf, (uint64_t)ns_id, (uint64_t)id);
|
||||||
(uint64_t)ns_id,
|
|
||||||
(uint64_t)id);
|
|
||||||
if (!extmark) {
|
if (!extmark) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1129,7 +1127,7 @@ Array nvim_buf_get_extmarks(Buffer buffer, Integer ns_id,
|
||||||
|
|
||||||
for (size_t i = 0; i < kv_size(marks); i++) {
|
for (size_t i = 0; i < kv_size(marks); i++) {
|
||||||
Array mark = ARRAY_DICT_INIT;
|
Array mark = ARRAY_DICT_INIT;
|
||||||
ExtendedMark *extmark = kv_A(marks, i);
|
Extmark *extmark = kv_A(marks, i);
|
||||||
ADD(mark, INTEGER_OBJ((Integer)extmark->mark_id));
|
ADD(mark, INTEGER_OBJ((Integer)extmark->mark_id));
|
||||||
ADD(mark, INTEGER_OBJ(extmark->line->lnum-1));
|
ADD(mark, INTEGER_OBJ(extmark->line->lnum-1));
|
||||||
ADD(mark, INTEGER_OBJ(extmark->col-1));
|
ADD(mark, INTEGER_OBJ(extmark->col-1));
|
||||||
|
|
|
@ -1512,11 +1512,8 @@ ArrayOf(Dictionary) keymap_array(String mode, buf_T *buf)
|
||||||
// If throw == true then an error will be raised if nothing
|
// If throw == true then an error will be raised if nothing
|
||||||
// was found
|
// was found
|
||||||
// Returns NULL if something went wrong
|
// Returns NULL if something went wrong
|
||||||
ExtendedMark *extmark_from_id_or_pos(Buffer buffer,
|
Extmark *extmark_from_id_or_pos(Buffer buffer, Integer namespace, Object id,
|
||||||
Integer namespace,
|
Error *err, bool throw)
|
||||||
Object id,
|
|
||||||
Error *err,
|
|
||||||
bool throw)
|
|
||||||
{
|
{
|
||||||
buf_T *buf = find_buffer_by_handle(buffer, err);
|
buf_T *buf = find_buffer_by_handle(buffer, err);
|
||||||
|
|
||||||
|
@ -1524,7 +1521,7 @@ ExtendedMark *extmark_from_id_or_pos(Buffer buffer,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedMark *extmark = NULL;
|
Extmark *extmark = NULL;
|
||||||
if (id.type == kObjectTypeArray) {
|
if (id.type == kObjectTypeArray) {
|
||||||
if (id.data.array.size != 2) {
|
if (id.data.array.size != 2) {
|
||||||
api_set_error(err, kErrorTypeValidation,
|
api_set_error(err, kErrorTypeValidation,
|
||||||
|
@ -1603,8 +1600,7 @@ bool set_extmark_index_from_obj(buf_T *buf, Integer namespace,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedMark *extmark = extmark_from_id(buf, (uint64_t)namespace,
|
Extmark *extmark = extmark_from_id(buf, (uint64_t)namespace, (uint64_t)id);
|
||||||
(uint64_t)id);
|
|
||||||
if (extmark) {
|
if (extmark) {
|
||||||
*lnum = extmark->line->lnum;
|
*lnum = extmark->line->lnum;
|
||||||
*colnr = extmark->col;
|
*colnr = extmark->col;
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
int extmark_set(buf_T *buf, uint64_t ns, uint64_t id,
|
int extmark_set(buf_T *buf, uint64_t ns, uint64_t id,
|
||||||
linenr_T lnum, colnr_T col, ExtmarkOp op)
|
linenr_T lnum, colnr_T col, ExtmarkOp op)
|
||||||
{
|
{
|
||||||
ExtendedMark *extmark = extmark_from_id(buf, ns, id);
|
Extmark *extmark = extmark_from_id(buf, ns, id);
|
||||||
if (!extmark) {
|
if (!extmark) {
|
||||||
extmark_create(buf, ns, id, lnum, col, op);
|
extmark_create(buf, ns, id, lnum, col, op);
|
||||||
return true;
|
return true;
|
||||||
|
@ -72,7 +72,7 @@ int extmark_set(buf_T *buf, uint64_t ns, uint64_t id,
|
||||||
// Returns 0 on missing id
|
// Returns 0 on missing id
|
||||||
int extmark_del(buf_T *buf, uint64_t ns, uint64_t id, ExtmarkOp op)
|
int extmark_del(buf_T *buf, uint64_t ns, uint64_t id, ExtmarkOp op)
|
||||||
{
|
{
|
||||||
ExtendedMark *extmark = extmark_from_id(buf, ns, id);
|
Extmark *extmark = extmark_from_id(buf, ns, id);
|
||||||
if (!extmark) {
|
if (!extmark) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ static void extmark_create(buf_T *buf, uint64_t ns, uint64_t id,
|
||||||
|
|
||||||
// update the position of an extmark
|
// update the position of an extmark
|
||||||
// to update while iterating pass the markitems itr
|
// to update while iterating pass the markitems itr
|
||||||
static void extmark_update(ExtendedMark *extmark, buf_T *buf,
|
static void extmark_update(Extmark *extmark, buf_T *buf,
|
||||||
uint64_t ns, uint64_t id,
|
uint64_t ns, uint64_t id,
|
||||||
linenr_T lnum, colnr_T col,
|
linenr_T lnum, colnr_T col,
|
||||||
ExtmarkOp op, kbitr_t(markitems) *mitr)
|
ExtmarkOp op, kbitr_t(markitems) *mitr)
|
||||||
|
@ -234,7 +234,7 @@ static void extmark_update(ExtendedMark *extmark, buf_T *buf,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extmark_delete(ExtendedMark *extmark,
|
static int extmark_delete(Extmark *extmark,
|
||||||
buf_T *buf,
|
buf_T *buf,
|
||||||
uint64_t ns,
|
uint64_t ns,
|
||||||
uint64_t id,
|
uint64_t id,
|
||||||
|
@ -261,7 +261,7 @@ static int extmark_delete(ExtendedMark *extmark,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup an extmark by id
|
// Lookup an extmark by id
|
||||||
ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id)
|
Extmark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id)
|
||||||
{
|
{
|
||||||
if (!buf->b_extmark_ns) {
|
if (!buf->b_extmark_ns) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -285,8 +285,7 @@ ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lookup an extmark by position
|
// Lookup an extmark by position
|
||||||
ExtendedMark *extmark_from_pos(buf_T *buf,
|
Extmark *extmark_from_pos(buf_T *buf, uint64_t ns, linenr_T lnum, colnr_T col)
|
||||||
uint64_t ns, linenr_T lnum, colnr_T col)
|
|
||||||
{
|
{
|
||||||
if (!buf->b_extmark_ns) {
|
if (!buf->b_extmark_ns) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1045,7 +1044,7 @@ bool extmark_copy_and_place(buf_T *buf,
|
||||||
// marks within the same extmarkline. Too keep it simple, first delete all
|
// marks within the same extmarkline. Too keep it simple, first delete all
|
||||||
// items from the extmarkline and put them back in the right order.
|
// items from the extmarkline and put them back in the right order.
|
||||||
FOR_ALL_EXTMARKLINES(buf, l_lnum, u_lnum, {
|
FOR_ALL_EXTMARKLINES(buf, l_lnum, u_lnum, {
|
||||||
kvec_t(ExtendedMark) temp_space = KV_INITIAL_VALUE;
|
kvec_t(Extmark) temp_space = KV_INITIAL_VALUE;
|
||||||
bool same_line = extmarkline == destline;
|
bool same_line = extmarkline == destline;
|
||||||
FOR_ALL_EXTMARKS_IN_LINE(extmarkline->items,
|
FOR_ALL_EXTMARKS_IN_LINE(extmarkline->items,
|
||||||
(extmarkline->lnum > l_lnum) ? 0 : l_col,
|
(extmarkline->lnum > l_lnum) ? 0 : l_col,
|
||||||
|
@ -1068,7 +1067,7 @@ bool extmark_copy_and_place(buf_T *buf,
|
||||||
})
|
})
|
||||||
if (same_line) {
|
if (same_line) {
|
||||||
for (size_t i = 0; i < kv_size(temp_space); i++) {
|
for (size_t i = 0; i < kv_size(temp_space); i++) {
|
||||||
ExtendedMark mark = kv_A(temp_space, i);
|
Extmark mark = kv_A(temp_space, i);
|
||||||
extmark_put(p_col, mark.mark_id, extmarkline, mark.ns_id);
|
extmark_put(p_col, mark.mark_id, extmarkline, mark.ns_id);
|
||||||
}
|
}
|
||||||
kv_destroy(temp_space);
|
kv_destroy(temp_space);
|
||||||
|
@ -1120,7 +1119,7 @@ void extmarkline_free(ExtMarkLine *extmarkline)
|
||||||
void extmark_put(colnr_T col, uint64_t id,
|
void extmark_put(colnr_T col, uint64_t id,
|
||||||
ExtMarkLine *extmarkline, uint64_t ns)
|
ExtMarkLine *extmarkline, uint64_t ns)
|
||||||
{
|
{
|
||||||
ExtendedMark t;
|
Extmark t;
|
||||||
t.col = col;
|
t.col = col;
|
||||||
t.mark_id = id;
|
t.mark_id = id;
|
||||||
t.line = extmarkline;
|
t.line = extmarkline;
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
// see FOR_ALL_? for documentation
|
// see FOR_ALL_? for documentation
|
||||||
#define FOR_ALL_EXTMARKS(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\
|
#define FOR_ALL_EXTMARKS(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\
|
||||||
kbitr_t(markitems) mitr;\
|
kbitr_t(markitems) mitr;\
|
||||||
ExtendedMark mt;\
|
Extmark mt;\
|
||||||
mt.ns_id = ns;\
|
mt.ns_id = ns;\
|
||||||
mt.mark_id = 0;\
|
mt.mark_id = 0;\
|
||||||
mt.line = NULL;\
|
mt.line = NULL;\
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \
|
if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \
|
||||||
kb_itr_next(markitems, &extmarkline->items, &mitr);\
|
kb_itr_next(markitems, &extmarkline->items, &mitr);\
|
||||||
} \
|
} \
|
||||||
ExtendedMark *extmark;\
|
Extmark *extmark;\
|
||||||
for (; \
|
for (; \
|
||||||
kb_itr_valid(&mitr); \
|
kb_itr_valid(&mitr); \
|
||||||
kb_itr_next(markitems, &extmarkline->items, &mitr)) { \
|
kb_itr_next(markitems, &extmarkline->items, &mitr)) { \
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
// see FOR_ALL_? for documentation
|
// see FOR_ALL_? for documentation
|
||||||
#define FOR_ALL_EXTMARKS_PREV(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\
|
#define FOR_ALL_EXTMARKS_PREV(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\
|
||||||
kbitr_t(markitems) mitr;\
|
kbitr_t(markitems) mitr;\
|
||||||
ExtendedMark mt;\
|
Extmark mt;\
|
||||||
mt.mark_id = sizeof(uint64_t);\
|
mt.mark_id = sizeof(uint64_t);\
|
||||||
mt.ns_id = ns;\
|
mt.ns_id = ns;\
|
||||||
FOR_ALL_EXTMARKLINES_PREV(buf, l_lnum, u_lnum, { \
|
FOR_ALL_EXTMARKLINES_PREV(buf, l_lnum, u_lnum, { \
|
||||||
|
@ -85,7 +85,7 @@
|
||||||
if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \
|
if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \
|
||||||
kb_itr_prev(markitems, &extmarkline->items, &mitr);\
|
kb_itr_prev(markitems, &extmarkline->items, &mitr);\
|
||||||
} \
|
} \
|
||||||
ExtendedMark *extmark;\
|
Extmark *extmark;\
|
||||||
for (; \
|
for (; \
|
||||||
kb_itr_valid(&mitr); \
|
kb_itr_valid(&mitr); \
|
||||||
kb_itr_prev(markitems, &extmarkline->items, &mitr)) { \
|
kb_itr_prev(markitems, &extmarkline->items, &mitr)) { \
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
|
|
||||||
#define FOR_ALL_EXTMARKS_IN_LINE(items, l_col, u_col, code)\
|
#define FOR_ALL_EXTMARKS_IN_LINE(items, l_col, u_col, code)\
|
||||||
kbitr_t(markitems) mitr;\
|
kbitr_t(markitems) mitr;\
|
||||||
ExtendedMark mt;\
|
Extmark mt;\
|
||||||
mt.ns_id = 0;\
|
mt.ns_id = 0;\
|
||||||
mt.mark_id = 0;\
|
mt.mark_id = 0;\
|
||||||
mt.line = NULL;\
|
mt.line = NULL;\
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
if (!kb_itr_get(markitems, &items, mt, &mitr)) { \
|
if (!kb_itr_get(markitems, &items, mt, &mitr)) { \
|
||||||
kb_itr_next(markitems, &items, &mitr);\
|
kb_itr_next(markitems, &items, &mitr);\
|
||||||
} \
|
} \
|
||||||
ExtendedMark *extmark;\
|
Extmark *extmark;\
|
||||||
for (; kb_itr_valid(&mitr); kb_itr_next(markitems, &items, &mitr)) { \
|
for (; kb_itr_valid(&mitr); kb_itr_next(markitems, &items, &mitr)) { \
|
||||||
extmark = &kb_itr_key(&mitr);\
|
extmark = &kb_itr_key(&mitr);\
|
||||||
if (extmark->col > extmarkline_u_col) { \
|
if (extmark->col > extmarkline_u_col) { \
|
||||||
|
@ -126,7 +126,7 @@ typedef struct ExtmarkNs { // For namespacing extmarks
|
||||||
} ExtmarkNs;
|
} ExtmarkNs;
|
||||||
|
|
||||||
|
|
||||||
typedef kvec_t(ExtendedMark *) ExtmarkArray;
|
typedef kvec_t(Extmark *) ExtmarkArray;
|
||||||
|
|
||||||
|
|
||||||
// Undo/redo extmarks
|
// Undo/redo extmarks
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
|
|
||||||
struct ExtMarkLine;
|
struct ExtMarkLine;
|
||||||
|
|
||||||
typedef struct ExtendedMark
|
typedef struct Extmark
|
||||||
{
|
{
|
||||||
uint64_t ns_id;
|
uint64_t ns_id;
|
||||||
uint64_t mark_id;
|
uint64_t mark_id;
|
||||||
struct ExtMarkLine *line;
|
struct ExtMarkLine *line;
|
||||||
colnr_T col;
|
colnr_T col;
|
||||||
} ExtendedMark;
|
} Extmark;
|
||||||
|
|
||||||
|
|
||||||
// We only need to compare columns as rows are stored in a different tree.
|
// We only need to compare columns as rows are stored in a different tree.
|
||||||
// Marks are ordered by: position, namespace, mark_id
|
// Marks are ordered by: position, namespace, mark_id
|
||||||
// This improves moving marks but slows down all other use cases (searches)
|
// This improves moving marks but slows down all other use cases (searches)
|
||||||
static inline int extmark_cmp(ExtendedMark a, ExtendedMark b)
|
static inline int extmark_cmp(Extmark a, Extmark b)
|
||||||
{
|
{
|
||||||
int cmp = kb_generic_cmp(a.col, b.col);
|
int cmp = kb_generic_cmp(a.col, b.col);
|
||||||
if (cmp != 0) {
|
if (cmp != 0) {
|
||||||
|
@ -35,7 +35,7 @@ static inline int extmark_cmp(ExtendedMark a, ExtendedMark b)
|
||||||
|
|
||||||
|
|
||||||
#define markitems_cmp(a, b) (extmark_cmp((a), (b)))
|
#define markitems_cmp(a, b) (extmark_cmp((a), (b)))
|
||||||
KBTREE_INIT(markitems, ExtendedMark, markitems_cmp, 10)
|
KBTREE_INIT(markitems, Extmark, markitems_cmp, 10)
|
||||||
|
|
||||||
typedef struct ExtMarkLine
|
typedef struct ExtMarkLine
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue