Create a commit view history API based on the tree view stack
[tig.git] / graph.h
blob419fd3ae987ac64edbbf826b0f19ecdb8fd0a1ba
1 /* Copyright (c) 2006-2013 Jonas Fonseca <fonseca@diku.dk>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef TIG_GRAPH_H
15 #define TIG_GRAPH_H
17 #define GRAPH_COLORS 7
19 struct graph_symbol {
20 unsigned int color:8;
21 unsigned int bold:1;
23 unsigned int commit:1;
24 unsigned int branch:1;
26 unsigned int boundary:1;
27 unsigned int initial:1;
28 unsigned int merge:1;
30 unsigned int vbranch:1;
31 unsigned int branched:1;
34 struct graph_canvas {
35 size_t size; /* The width of the graph array. */
36 struct graph_symbol *symbols; /* Symbols for this row. */
39 struct graph_column {
40 struct graph_symbol symbol;
41 char id[SIZEOF_REV]; /* Parent SHA1 ID. */
44 struct graph_row {
45 size_t size;
46 struct graph_column *columns;
49 struct graph {
50 struct graph_row row;
51 struct graph_row parents;
52 size_t position;
53 size_t expanded;
54 const char *id;
55 struct graph_canvas *canvas;
56 size_t colors[GRAPH_COLORS];
57 bool has_parents;
58 bool is_boundary;
61 void done_graph(struct graph *graph);
63 bool graph_render_parents(struct graph *graph);
64 bool graph_add_commit(struct graph *graph, struct graph_canvas *canvas,
65 const char *id, const char *parents, bool is_boundary);
66 struct graph_column *graph_add_parent(struct graph *graph, const char *parent);
68 const char *graph_symbol_to_ascii(struct graph_symbol *symbol);
69 const char *graph_symbol_to_utf8(struct graph_symbol *symbol);
70 const chtype *graph_symbol_to_chtype(struct graph_symbol *symbol);
72 #endif
74 /* vim: set ts=8 sw=8 noexpandtab: */