summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 70ea817)
raw | patch | inline | side by side (parent: 70ea817)
author | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 26 Mar 2008 08:50:19 +0000 (09:50 +0100) | ||
committer | Jonas Fonseca <fonseca@diku.dk> | |
Wed, 26 Mar 2008 08:56:08 +0000 (09:56 +0100) |
Also, improve the positioning of the cursor line after updates to
restore or select something that is "updateable". Adding new files
should now work more intuitively.
restore or select something that is "updateable". Adding new files
should now work more intuitively.
tig.c | patch | blob | history | |
tigrc.5.txt | patch | blob | history |
index a1a6a803cfda4730320b5cb5cb9320ac031646dd..b5e69885af4e44cf3d952420ee1373764320042a 100644 (file)
--- a/tig.c
+++ b/tig.c
LINE(MAIN_REVGRAPH,"", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
LINE(TREE_DIR, "", COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), \
LINE(TREE_FILE, "", COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL), \
+LINE(STAT_HEAD, "", COLOR_YELLOW, COLOR_DEFAULT, 0), \
LINE(STAT_SECTION, "", COLOR_CYAN, COLOR_DEFAULT, 0), \
LINE(STAT_NONE, "", COLOR_DEFAULT, COLOR_DEFAULT, 0), \
LINE(STAT_STAGED, "", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
* might have rearranged things. */
redraw_view(view);
-
} else if (redraw_from >= 0) {
/* If this is an incremental update, redraw the previous line
* since for commits some members could have changed when
} new;
};
+static char status_onbranch[SIZEOF_STR];
static struct status stage_status;
static enum line_type stage_line_type;
view->lines = view->line_alloc = view->line_size = view->lineno = 0;
view->line = NULL;
- if (!realloc_lines(view, view->line_size + 6))
+ if (!realloc_lines(view, view->line_size + 7))
+ return FALSE;
+
+ add_line_data(view, NULL, LINE_STAT_HEAD);
+ if (!*opt_head)
+ string_copy(status_onbranch, "Not currently on any branch");
+ else if (!string_format(status_onbranch, "On branch %s", opt_head))
return FALSE;
if (!string_format(exclude, "%s/info/exclude", opt_git_dir))
return FALSE;
/* If all went well restore the previous line number to stay in
- * the context. */
+ * the context or select a line with something that can be
+ * updated. */
+ if (prev_lineno >= view->lines)
+ prev_lineno = view->lines - 1;
+ while (prev_lineno < view->lines && !view->line[prev_lineno].data)
+ prev_lineno++;
+
+ /* If the above fails, always skip the "On branch" line. */
if (prev_lineno < view->lines)
view->lineno = prev_lineno;
else
- view->lineno = view->lines - 1;
+ view->lineno = 1;
return TRUE;
}
@@ -3948,6 +3962,10 @@ status_draw(struct view *view, struct line *line, unsigned int lineno, bool sele
wchgat(view->win, -1, 0, LINE_CURSOR, NULL);
tilde_attr = -1;
+ } else if (line->type == LINE_STAT_HEAD) {
+ wattrset(view->win, get_line_attr(LINE_STAT_HEAD));
+ wchgat(view->win, -1, 0, LINE_STAT_HEAD, NULL);
+
} else if (!status && line->type != LINE_STAT_NONE) {
wattrset(view->win, get_line_attr(LINE_STAT_SECTION));
wchgat(view->win, -1, 0, LINE_STAT_SECTION, NULL);
@@ -3976,6 +3994,10 @@ status_draw(struct view *view, struct line *line, unsigned int lineno, bool sele
text = " (no files)";
break;
+ case LINE_STAT_HEAD:
+ text = status_onbranch;
+ break;
+
default:
return FALSE;
}
info = "Untracked file %s";
break;
+ case LINE_STAT_HEAD:
+ return REQ_NONE;
+
default:
die("line type %d not handled in switch", line->type);
}
@@ -4114,6 +4139,9 @@ status_update_file(struct view *view, struct status *status, enum line_type type
string_add(cmd, cmdsize, "git update-index -z --add --remove --stdin");
break;
+ case LINE_STAT_HEAD:
+ return TRUE;
+
default:
die("line type %d not handled in switch", type);
}
text = "Press %s to stage %s for addition";
break;
+ case LINE_STAT_HEAD:
case LINE_STAT_NONE:
text = "Nothing to update";
break;
diff --git a/tigrc.5.txt b/tigrc.5.txt
index b6fe7eb3e0e2460d0a93e5102960658b18b50f9b..b7d626d7782dbe79b5cc358cd91525df65fa9d96 100644 (file)
--- a/tigrc.5.txt
+++ b/tigrc.5.txt
Status markup::
-Colors used in the status view.
+Colors used in the status view for coloring the "On branch"-line, sections,
+"no file" lines and the various file status groups.
-*stat-section*, *stat-none*, *stat-staged*, *stat-unstaged*, *stat-untracked*
+*stat-head*, *stat-section*, *stat-none*, *stat-staged*, *stat-unstaged*,
+*stat-untracked*
--