extmark: rename ExtendedMark => Extmark

This commit is contained in:
Justin M. Keyes 2019-11-11 22:04:21 -08:00
parent 54473e9a67
commit 2d7e1c32a8
5 changed files with 26 additions and 33 deletions

View File

@ -1027,9 +1027,7 @@ ArrayOf(Integer) nvim_buf_get_extmark_by_id(Buffer buffer, Integer ns_id,
return rv;
}
ExtendedMark *extmark = extmark_from_id(buf,
(uint64_t)ns_id,
(uint64_t)id);
Extmark *extmark = extmark_from_id(buf, (uint64_t)ns_id, (uint64_t)id);
if (!extmark) {
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++) {
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(extmark->line->lnum-1));
ADD(mark, INTEGER_OBJ(extmark->col-1));

View File

@ -1512,11 +1512,8 @@ ArrayOf(Dictionary) keymap_array(String mode, buf_T *buf)
// If throw == true then an error will be raised if nothing
// was found
// Returns NULL if something went wrong
ExtendedMark *extmark_from_id_or_pos(Buffer buffer,
Integer namespace,
Object id,
Error *err,
bool throw)
Extmark *extmark_from_id_or_pos(Buffer buffer, Integer namespace, Object id,
Error *err, bool throw)
{
buf_T *buf = find_buffer_by_handle(buffer, err);
@ -1524,7 +1521,7 @@ ExtendedMark *extmark_from_id_or_pos(Buffer buffer,
return NULL;
}
ExtendedMark *extmark = NULL;
Extmark *extmark = NULL;
if (id.type == kObjectTypeArray) {
if (id.data.array.size != 2) {
api_set_error(err, kErrorTypeValidation,
@ -1603,8 +1600,7 @@ bool set_extmark_index_from_obj(buf_T *buf, Integer namespace,
return false;
}
ExtendedMark *extmark = extmark_from_id(buf, (uint64_t)namespace,
(uint64_t)id);
Extmark *extmark = extmark_from_id(buf, (uint64_t)namespace, (uint64_t)id);
if (extmark) {
*lnum = extmark->line->lnum;
*colnr = extmark->col;

View File

@ -53,7 +53,7 @@
int extmark_set(buf_T *buf, uint64_t ns, uint64_t id,
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) {
extmark_create(buf, ns, id, lnum, col, op);
return true;
@ -72,7 +72,7 @@ int extmark_set(buf_T *buf, uint64_t ns, uint64_t id,
// Returns 0 on missing id
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) {
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
// 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,
linenr_T lnum, colnr_T col,
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,
uint64_t ns,
uint64_t id,
@ -261,7 +261,7 @@ static int extmark_delete(ExtendedMark *extmark,
}
// 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) {
return NULL;
@ -285,8 +285,7 @@ ExtendedMark *extmark_from_id(buf_T *buf, uint64_t ns, uint64_t id)
}
// Lookup an extmark by position
ExtendedMark *extmark_from_pos(buf_T *buf,
uint64_t ns, linenr_T lnum, colnr_T col)
Extmark *extmark_from_pos(buf_T *buf, uint64_t ns, linenr_T lnum, colnr_T col)
{
if (!buf->b_extmark_ns) {
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
// items from the extmarkline and put them back in the right order.
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;
FOR_ALL_EXTMARKS_IN_LINE(extmarkline->items,
(extmarkline->lnum > l_lnum) ? 0 : l_col,
@ -1068,7 +1067,7 @@ bool extmark_copy_and_place(buf_T *buf,
})
if (same_line) {
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);
}
kv_destroy(temp_space);
@ -1120,7 +1119,7 @@ void extmarkline_free(ExtMarkLine *extmarkline)
void extmark_put(colnr_T col, uint64_t id,
ExtMarkLine *extmarkline, uint64_t ns)
{
ExtendedMark t;
Extmark t;
t.col = col;
t.mark_id = id;
t.line = extmarkline;

View File

@ -51,7 +51,7 @@
// see FOR_ALL_? for documentation
#define FOR_ALL_EXTMARKS(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\
kbitr_t(markitems) mitr;\
ExtendedMark mt;\
Extmark mt;\
mt.ns_id = ns;\
mt.mark_id = 0;\
mt.line = NULL;\
@ -60,7 +60,7 @@
if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \
kb_itr_next(markitems, &extmarkline->items, &mitr);\
} \
ExtendedMark *extmark;\
Extmark *extmark;\
for (; \
kb_itr_valid(&mitr); \
kb_itr_next(markitems, &extmarkline->items, &mitr)) { \
@ -77,7 +77,7 @@
// see FOR_ALL_? for documentation
#define FOR_ALL_EXTMARKS_PREV(buf, ns, l_lnum, l_col, u_lnum, u_col, code)\
kbitr_t(markitems) mitr;\
ExtendedMark mt;\
Extmark mt;\
mt.mark_id = sizeof(uint64_t);\
mt.ns_id = ns;\
FOR_ALL_EXTMARKLINES_PREV(buf, l_lnum, u_lnum, { \
@ -85,7 +85,7 @@
if (!kb_itr_get(markitems, &extmarkline->items, mt, &mitr)) { \
kb_itr_prev(markitems, &extmarkline->items, &mitr);\
} \
ExtendedMark *extmark;\
Extmark *extmark;\
for (; \
kb_itr_valid(&mitr); \
kb_itr_prev(markitems, &extmarkline->items, &mitr)) { \
@ -101,7 +101,7 @@
#define FOR_ALL_EXTMARKS_IN_LINE(items, l_col, u_col, code)\
kbitr_t(markitems) mitr;\
ExtendedMark mt;\
Extmark mt;\
mt.ns_id = 0;\
mt.mark_id = 0;\
mt.line = NULL;\
@ -110,7 +110,7 @@
if (!kb_itr_get(markitems, &items, mt, &mitr)) { \
kb_itr_next(markitems, &items, &mitr);\
} \
ExtendedMark *extmark;\
Extmark *extmark;\
for (; kb_itr_valid(&mitr); kb_itr_next(markitems, &items, &mitr)) { \
extmark = &kb_itr_key(&mitr);\
if (extmark->col > extmarkline_u_col) { \
@ -126,7 +126,7 @@ typedef struct ExtmarkNs { // For namespacing extmarks
} ExtmarkNs;
typedef kvec_t(ExtendedMark *) ExtmarkArray;
typedef kvec_t(Extmark *) ExtmarkArray;
// Undo/redo extmarks

View File

@ -8,19 +8,19 @@
struct ExtMarkLine;
typedef struct ExtendedMark
typedef struct Extmark
{
uint64_t ns_id;
uint64_t mark_id;
struct ExtMarkLine *line;
colnr_T col;
} ExtendedMark;
} Extmark;
// We only need to compare columns as rows are stored in a different tree.
// Marks are ordered by: position, namespace, mark_id
// 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);
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)))
KBTREE_INIT(markitems, ExtendedMark, markitems_cmp, 10)
KBTREE_INIT(markitems, Extmark, markitems_cmp, 10)
typedef struct ExtMarkLine
{