summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0e92d31)
raw | patch | inline | side by side (parent: 0e92d31)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sat, 3 Jun 2006 23:53:32 +0000 (01:53 +0200) | ||
committer | Jonas Fonseca Madsen <fonseca@ask.diku.dk> | |
Sat, 3 Jun 2006 23:53:32 +0000 (01:53 +0200) |
It is toggleable via 'g', on by default, and restricted to max being 19
chars wide. Note, it still only shows just the left tee.
chars wide. Note, it still only shows just the left tee.
manual.txt | patch | blob | history | |
tig.c | patch | blob | history |
diff --git a/manual.txt b/manual.txt
index 4584cc157caae25bedc554e086ab49ad4865fad2..b530f1cc66fa067d765300f8128d1d4f3521b82c 100644 (file)
--- a/manual.txt
+++ b/manual.txt
Show version.
n::
Toggle line numbers on/off.
+g::
+ Toggle revision graph visualization on/off.
':'::
Open prompt. This allows you to specify what git command
to run. Example:
index 9845c4094e975bef9d3d76db81a3f81703f6a2ab..0f77167fbdfa40f55ac8a34dcc813dc5d686554d 100644 (file)
--- a/tig.c
+++ b/tig.c
#define SIZEOF_REF 256 /* Size of symbolic or SHA1 ID. */
#define SIZEOF_CMD 1024 /* Size of command buffer. */
+#define SIZEOF_REVGRAPH 19 /* Size of revision ancestry graphics. */
/* This color name can be used to refer to the default term colors. */
#define COLOR_DEFAULT (-1)
REQ_(SCREEN_RESIZE, "Resize the screen"), \
REQ_(SHOW_VERSION, "Show version information"), \
REQ_(STOP_LOADING, "Stop all loading views"), \
- REQ_(TOGGLE_LINENO, "Toggle line numbers"),
+ REQ_(TOGGLE_LINENO, "Toggle line numbers"), \
+ REQ_(TOGGLE_REV_GRAPH, "Toggle revision graph visualization"),
/* User action requests. */
/* Option and state variables. */
static bool opt_line_number = FALSE;
+static bool opt_rev_graph = TRUE;
static int opt_num_interval = NUMBER_INTERVAL;
static int opt_tab_size = TABSIZE;
static enum request opt_request = REQ_VIEW_MAIN;
}
+/*
+ * Line-oriented content detection.
+ */
+
#define LINE_INFO \
LINE(DIFF_HEADER, "diff --git ", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(DIFF_CHUNK, "@@", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(MAIN_TAG, "", COLOR_MAGENTA, COLOR_DEFAULT, A_BOLD), \
LINE(MAIN_REF, "", COLOR_CYAN, COLOR_DEFAULT, A_BOLD), \
-
-/*
- * Line-oriented content detection.
- */
-
enum line_type {
#define LINE(type, line, fg, bg, attr) \
LINE_##type
redraw_display();
break;
+ case REQ_TOGGLE_REV_GRAPH:
+ opt_rev_graph = !opt_rev_graph;
+ redraw_display();
+ break;
+
case REQ_PROMPT:
/* Always reload^Wrerun commands from the prompt. */
open_view(view, opt_request, OPEN_RELOAD);
*/
struct commit {
- char id[41]; /* SHA1 ID. */
- char title[75]; /* The first line of the commit message. */
- char author[75]; /* The author of the commit. */
- struct tm time; /* Date from the author ident. */
- struct ref **refs; /* Repository references; tags & branch heads. */
+ char id[41]; /* SHA1 ID. */
+ char title[75]; /* First line of the commit message. */
+ char author[75]; /* Author of the commit. */
+ struct tm time; /* Date from the author ident. */
+ struct ref **refs; /* Repository references. */
+ chtype graph[SIZEOF_REVGRAPH]; /* Ancestry chain graphics. */
+ size_t graph_size; /* The width of the graph array. */
};
static bool
if (type != LINE_CURSOR)
wattrset(view->win, A_NORMAL);
- mvwaddch(view->win, lineno, col, ACS_LTEE);
- wmove(view->win, lineno, col + 2);
- col += 2;
+ if (opt_rev_graph && commit->graph_size) {
+ size_t i;
+
+ wmove(view->win, lineno, col);
+ /* Using waddch() instead of waddnstr() ensures that
+ * they'll be rendered correctly for the cursor line. */
+ for (i = 0; i < commit->graph_size; i++)
+ waddch(view->win, commit->graph[i]);
+
+ col += commit->graph_size + 1;
+ }
+
+ wmove(view->win, lineno, col);
if (commit->refs) {
size_t i = 0;
view->line[view->lines++].data = commit;
string_copy(commit->id, line);
commit->refs = get_refs(commit->id);
+ commit->graph[commit->graph_size++] = ACS_LTEE;
break;
case LINE_AUTHOR:
{ 'v', REQ_SHOW_VERSION },
{ 'r', REQ_SCREEN_REDRAW },
{ 'n', REQ_TOGGLE_LINENO },
+ { 'g', REQ_TOGGLE_REV_GRAPH},
{ ':', REQ_PROMPT },
/* wgetch() with nodelay() enabled returns ERR when there's no input. */