commit - 1d7fe5cdae04f3c0e387ffdbd0f0dabe89871351
commit + f26dddb7dc6c83ab9c933da056e4bd8236bfa0da
blob - c01e8707b2d79efb636d884e8954c2781bd15e6a
blob + b99cf6c29e3495f6ce78ec26329723dbe39a17b5
--- tog/tog.c
+++ tog/tog.c
struct commit_queue_head head;
};
-struct tog_line_color {
- SIMPLEQ_ENTRY(tog_line_color) entry;
+struct tog_color {
+ SIMPLEQ_ENTRY(tog_color) entry;
regex_t regex;
short colorpair;
};
-SIMPLEQ_HEAD(tog_line_colors, tog_line_color);
+SIMPLEQ_HEAD(tog_colors, tog_color);
struct tog_diff_view_state {
struct got_object_id *id1, *id2;
int diff_context;
struct got_repository *repo;
struct got_reflist_head *refs;
- struct tog_line_colors line_colors;
+ struct tog_colors line_colors;
/* passed from log view; may be NULL */
struct tog_view *log_view;
struct got_repository *repo;
struct got_reflist_head *refs;
struct got_tree_entry *matched_entry;
- struct tog_line_colors line_colors;
+ struct tog_colors line_colors;
};
/*
return regexec(regex, line, 1, ®match, 0) == 0;
}
-struct tog_line_color *
-match_line_color(struct tog_line_colors *colors, const char *line)
+struct tog_color *
+match_line_color(struct tog_colors *colors, const char *line)
{
- struct tog_line_color *tc = NULL;
+ struct tog_color *tc = NULL;
SIMPLEQ_FOREACH(tc, colors, entry) {
if (match_line(line, &tc->regex))
static const struct got_error *
draw_file(struct tog_view *view, FILE *f, int *first_displayed_line,
int *last_displayed_line, int *eof, int max_lines, char *header,
- struct tog_line_colors *colors)
+ struct tog_colors *colors)
{
const struct got_error *err;
int nlines = 0, nprinted = 0;
char *line;
- struct tog_line_color *lc;
+ struct tog_color *tc;
size_t len;
wchar_t *wline;
int width;
return err;
}
- lc = match_line_color(colors, line);
- if (lc)
- wattr_on(view->window,
- COLOR_PAIR(lc->colorpair), NULL);
+ tc = match_line_color(colors, line);
+ if (tc)
+ wattr_on(view->window,
+ COLOR_PAIR(tc->colorpair), NULL);
waddwstr(view->window, wline);
- if (lc)
+ if (tc)
wattr_off(view->window,
- COLOR_PAIR(lc->colorpair), NULL);
+ COLOR_PAIR(tc->colorpair), NULL);
if (width <= view->ncols - 1)
waddch(view->window, '\n');
if (++nprinted == 1)
}
static const struct got_error *
-add_line_color(struct tog_line_colors *colors, const char *pattern,
+add_line_color(struct tog_colors *colors, const char *pattern,
int idx, short color)
{
const struct got_error *err = NULL;
- struct tog_line_color *lc;
+ struct tog_color *tc;
int regerr = 0;
init_pair(idx, color, -1);
- lc = calloc(1, sizeof(*lc));
- if (lc == NULL)
+ tc = calloc(1, sizeof(*tc));
+ if (tc == NULL)
return got_error_from_errno("calloc");
- regerr = regcomp(&lc->regex, pattern,
+ regerr = regcomp(&tc->regex, pattern,
REG_EXTENDED | REG_NOSUB | REG_NEWLINE);
if (regerr) {
static char regerr_msg[512];
static char err_msg[512];
- regerror(regerr, &lc->regex, regerr_msg,
+ regerror(regerr, &tc->regex, regerr_msg,
sizeof(regerr_msg));
snprintf(err_msg, sizeof(err_msg), "regcomp: %s",
regerr_msg);
err = got_error_msg(GOT_ERR_REGEX, err_msg);
- free(lc);
+ free(tc);
return err;
}
- lc->colorpair = idx;
- SIMPLEQ_INSERT_HEAD(colors, lc, entry);
+ tc->colorpair = idx;
+ SIMPLEQ_INSERT_HEAD(colors, tc, entry);
return NULL;
}
static void
-free_line_colors(struct tog_line_colors *colors)
+free_line_colors(struct tog_colors *colors)
{
- struct tog_line_color *lc;
+ struct tog_color *tc;
while (!SIMPLEQ_EMPTY(colors)) {
- lc = SIMPLEQ_FIRST(colors);
+ tc = SIMPLEQ_FIRST(colors);
SIMPLEQ_REMOVE_HEAD(colors, entry);
- regfree(&lc->regex);
- free(lc);
+ regfree(&tc->regex);
+ free(tc);
}
}
struct got_tree_entry **selected_entry, int *ndisplayed,
const char *label, int show_ids, const char *parent_path,
const struct got_tree_entries *entries, int selected, int limit,
- int isroot, struct tog_line_colors *colors)
+ int isroot, struct tog_colors *colors)
{
const struct got_error *err = NULL;
struct got_tree_entry *te;
wchar_t *wline;
- struct tog_line_color *lc;
+ struct tog_color *tc;
int width, n;
*ndisplayed = 0;
wstandout(view->window);
*selected_entry = te;
}
- lc = match_line_color(colors, line);
- if (lc)
+ tc = match_line_color(colors, line);
+ if (tc)
wattr_on(view->window,
- COLOR_PAIR(lc->colorpair), NULL);
+ COLOR_PAIR(tc->colorpair), NULL);
waddwstr(view->window, wline);
- if (lc)
+ if (tc)
wattr_off(view->window,
- COLOR_PAIR(lc->colorpair), NULL);
+ COLOR_PAIR(tc->colorpair), NULL);
if (width < view->ncols - 1)
waddch(view->window, '\n');
if (n == selected && view->focussed)