From: Jonas Fonseca Date: Sun, 10 Apr 2011 03:18:40 +0000 (-0400) Subject: Refactor draw_refs out from main_draw X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d4d5d590bab0ae4297adcdbfbece1f07d44d4c25;p=tig.git Refactor draw_refs out from main_draw --- diff --git a/tig.c b/tig.c index 047b853..65973d2 100644 --- a/tig.c +++ b/tig.c @@ -1711,6 +1711,43 @@ draw_lineno(struct view *view, unsigned int lineno) return draw_graphic(view, LINE_DEFAULT, &separator, 1, TRUE); } +static bool +draw_refs(struct view *view, struct ref_list *refs) +{ + size_t i; + + if (!opt_show_refs || !refs) + return FALSE; + + for (i = 0; i < refs->size; i++) { + struct ref *ref = refs->refs[i]; + enum line_type type; + + if (ref->head) + type = LINE_MAIN_HEAD; + else if (ref->ltag) + type = LINE_MAIN_LOCAL_TAG; + else if (ref->tag) + type = LINE_MAIN_TAG; + else if (ref->tracked) + type = LINE_MAIN_TRACKED; + else if (ref->remote) + type = LINE_MAIN_REMOTE; + else + type = LINE_MAIN_REF; + + if (draw_text(view, type, "[") || + draw_text(view, type, ref->name) || + draw_text(view, type, "]")) + return TRUE; + + if (draw_text(view, LINE_DEFAULT, " ")) + return TRUE; + } + + return FALSE; +} + static bool draw_view_line(struct view *view, unsigned int lineno) { @@ -5794,35 +5831,8 @@ main_draw(struct view *view, struct line *line, unsigned int lineno) if (opt_rev_graph && draw_graph(view, &commit->graph)) return TRUE; - if (opt_show_refs && commit->refs) { - size_t i; - - for (i = 0; i < commit->refs->size; i++) { - struct ref *ref = commit->refs->refs[i]; - enum line_type type; - - if (ref->head) - type = LINE_MAIN_HEAD; - else if (ref->ltag) - type = LINE_MAIN_LOCAL_TAG; - else if (ref->tag) - type = LINE_MAIN_TAG; - else if (ref->tracked) - type = LINE_MAIN_TRACKED; - else if (ref->remote) - type = LINE_MAIN_REMOTE; - else - type = LINE_MAIN_REF; - - if (draw_text(view, type, "[") || - draw_text(view, type, ref->name) || - draw_text(view, type, "]")) - return TRUE; - - if (draw_text(view, LINE_DEFAULT, " ")) - return TRUE; - } - } + if (draw_refs(view, commit->refs)) + return TRUE; draw_text(view, LINE_DEFAULT, commit->title); return TRUE;