old-graph: Move graph API into the common graph struct
[tig.git] / include / tig / graph.h
blob79c40a450751f32c5d4da77acd74e82ea835e332
1 /* Copyright (c) 2006-2014 Jonas Fonseca <jonas.fonseca@gmail.com>
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_COMMIT_COLOR (-1)
18 #define GRAPH_COLORS 14
20 struct graph;
21 struct graph_symbol;
23 struct graph_canvas {
24 size_t size; /* The width of the graph array. */
25 struct graph_symbol *symbols; /* Symbols for this row. */
28 typedef bool (*graph_symbol_iterator_fn)(void *, const struct graph *graph, const struct graph_symbol *, int color_id, bool);
30 struct graph {
31 void *private;
33 void (*done)(struct graph *graph);
34 void (*done_rendering)(struct graph *graph);
36 bool (*add_commit)(struct graph *graph, struct graph_canvas *canvas,
37 const char *id, const char *parents, bool is_boundary);
38 bool (*add_parent)(struct graph *graph, const char *parent);
39 bool (*render_parents)(struct graph *graph, struct graph_canvas *canvas);
41 void (*foreach_symbol)(const struct graph *graph, const struct graph_canvas *canvas, graph_symbol_iterator_fn fn, void *data);
43 const char *(*symbol_to_ascii)(const struct graph_symbol *symbol);
44 const char *(*symbol_to_utf8)(const struct graph_symbol *symbol);
45 const chtype *(*symbol_to_chtype)(const struct graph_symbol *symbol);
48 struct graph *init_graph(void);
50 #endif
52 /* vim: set ts=8 sw=8 noexpandtab: */