bufhl: some style cleanup

This commit is contained in:
Björn Linse
2016-08-28 13:32:48 +02:00
parent 28a549d597
commit 7873660e1e
4 changed files with 21 additions and 21 deletions

View File

@@ -5150,7 +5150,8 @@ void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_a
/// @param line the linenumber to lookup
/// @param put if true, put a new line when not found
/// if false, return NULL when not found
BufhlLine *bufhl_tree_ref(kbtree_t(bufhl) *b, linenr_T line, bool put) {
BufhlLine *bufhl_tree_ref(BufhlInfo *b, linenr_T line, bool put)
{
BufhlLine t = BUFHLLINE_INIT(line);
// kp_put() only works if key is absent, try get first
@@ -5207,7 +5208,7 @@ int bufhl_add_hl(buf_T *buf,
BufhlLine *lineinfo = bufhl_tree_ref(&buf->b_bufhl_info, lnum, true);
bufhl_hl_item_T *hlentry = kv_pushp(lineinfo->items);
BufhlItem *hlentry = kv_pushp(lineinfo->items);
hlentry->src_id = src_id;
hlentry->hl_id = hl_id;
hlentry->start = col_start;
@@ -5279,16 +5280,16 @@ static BufhlLineStatus bufhl_clear_line(BufhlLine *lineinfo, int src_id,
if (src_id < 0) {
kv_size(lineinfo->items) = 0;
} else {
size_t newind = 0;
size_t newidx = 0;
for (size_t i = 0; i < kv_size(lineinfo->items); i++) {
if (kv_A(lineinfo->items, i).src_id != src_id) {
if (i != newind) {
kv_A(lineinfo->items, newind) = kv_A(lineinfo->items, i);
if (i != newidx) {
kv_A(lineinfo->items, newidx) = kv_A(lineinfo->items, i);
}
newind++;
newidx++;
}
}
kv_size(lineinfo->items) = newind;
kv_size(lineinfo->items) = newidx;
}
if (kv_size(lineinfo->items) == 0) {
@@ -5349,7 +5350,7 @@ void bufhl_mark_adjust(buf_T* buf,
/// @param lnum The line number
/// @param[out] info The highligts for the line
/// @return true if there was highlights to display
bool bufhl_start_line(buf_T *buf, linenr_T lnum, bufhl_lineinfo_T *info)
bool bufhl_start_line(buf_T *buf, linenr_T lnum, BufhlLineInfo *info)
{
BufhlLine *lineinfo = bufhl_tree_ref(&buf->b_bufhl_info, lnum, false);
if (!lineinfo) {
@@ -5370,14 +5371,14 @@ bool bufhl_start_line(buf_T *buf, linenr_T lnum, bufhl_lineinfo_T *info)
/// @param info The info returned by bufhl_start_line
/// @param col The column to get the attr for
/// @return The highilight attr to display at the column
int bufhl_get_attr(bufhl_lineinfo_T *info, colnr_T col) {
int bufhl_get_attr(BufhlLineInfo *info, colnr_T col) {
if (col <= info->valid_to) {
return info->current;
}
int attr = 0;
info->valid_to = MAXCOL;
for (size_t i = 0; i < kv_size(info->entries); i++) {
bufhl_hl_item_T entry = kv_A(info->entries, i);
BufhlItem entry = kv_A(info->entries, i);
if (entry.start <= col && col <= entry.stop) {
int entry_attr = syn_id2attr(entry.hl_id);
attr = hl_combine_attr(attr, entry_attr);

View File

@@ -760,7 +760,7 @@ struct file_buffer {
int b_mapped_ctrl_c; // modes where CTRL-C is mapped
bufhl_info_T b_bufhl_info; // buffer stored highlights
BufhlInfo b_bufhl_info; // buffer stored highlights
};
/*

View File

@@ -4,32 +4,31 @@
#include "nvim/pos.h"
#include "nvim/lib/kvec.h"
#include "nvim/lib/kbtree.h"
// bufhl: buffer specific highlighting
struct bufhl_hl_item
{
typedef struct {
int src_id;
int hl_id; // highlight group
colnr_T start; // first column to highlight
colnr_T stop; // last column to highlight
};
typedef struct bufhl_hl_item bufhl_hl_item_T;
} BufhlItem;
typedef kvec_t(struct bufhl_hl_item) bufhl_vec_T;
typedef kvec_t(BufhlItem) BufhlItemVec;
typedef struct {
linenr_T line;
bufhl_vec_T items;
BufhlItemVec items;
} BufhlLine;
#define BUFHLLINE_INIT(l) { l, KV_INITIAL_VALUE }
typedef struct {
bufhl_vec_T entries;
BufhlItemVec entries;
int current;
colnr_T valid_to;
} bufhl_lineinfo_T;
} BufhlLineInfo;
#define BUFHL_CMP(a, b) ((int)(((a)->line - (b)->line)))
KBTREE_INIT(bufhl, BufhlLine *, BUFHL_CMP, 10)
typedef kbtree_t(bufhl) bufhl_info_T;
typedef kbtree_t(bufhl) BufhlInfo;
#endif // NVIM_BUFHL_DEFS_H

View File

@@ -2210,7 +2210,7 @@ win_line (
bool search_attr_from_match = false; // if search_attr is from :match
bool has_bufhl = false; // this buffer has highlight matches
int bufhl_attr = 0; // attributes desired by bufhl
bufhl_lineinfo_T bufhl_info; // bufhl data for this line
BufhlLineInfo bufhl_info; // bufhl data for this line
/* draw_state: items that are drawn in sequence: */
#define WL_START 0 /* nothing done yet */