2 /* Copyright (c) 2006-2010 Jonas Fonseca <fonseca@diku.dk>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
15 #ifndef TIG_GRAPH_H
16 #define TIG_GRAPH_H
18 #define GRAPH_COLORS 7
20 struct graph_symbol {
21 unsigned int color:8;
22 unsigned int bold:1;
24 unsigned int commit:1;
25 unsigned int branch:1;
27 unsigned int boundary:1;
28 unsigned int initial:1;
29 unsigned int merge:1;
31 unsigned int vbranch:1;
32 unsigned int branched:1;
33 };
35 struct graph_canvas {
36 size_t size; /* The width of the graph array. */
37 struct graph_symbol *symbols; /* Symbols for this row. */
38 };
40 struct graph_column {
41 struct graph_symbol symbol;
42 char id[SIZEOF_REV]; /* Parent SHA1 ID. */
43 };
45 struct graph_row {
46 size_t size;
47 struct graph_column *columns;
48 };
50 struct graph {
51 struct graph_row row;
52 struct graph_row parents;
53 size_t position;
54 size_t expanded;
55 const char *id;
56 struct graph_canvas *canvas;
57 size_t colors[GRAPH_COLORS];
58 bool has_parents;
59 bool is_boundary;
60 };
62 void done_graph(struct graph *graph);
64 bool graph_render_parents(struct graph *graph);
65 bool graph_add_commit(struct graph *graph, struct graph_canvas *canvas,
66 const char *id, const char *parents, bool is_boundary);
67 struct graph_column *graph_add_parent(struct graph *graph, const char *parent);
69 const char *graph_symbol_to_ascii(struct graph_symbol *symbol);
70 const char *graph_symbol_to_utf8(struct graph_symbol *symbol);
71 const chtype *graph_symbol_to_chtype(struct graph_symbol *symbol);
73 #endif