summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 33c4f9e)
raw | patch | inline | side by side (parent: 33c4f9e)
author | Jonas Fonseca <fonseca@diku.dk> | |
Sun, 10 Sep 2006 19:54:39 +0000 (21:54 +0200) | ||
committer | Jonas Fonseca <fonseca@antimatter.localdomain> | |
Sun, 10 Sep 2006 19:54:39 +0000 (21:54 +0200) |
Like the main view, when you after start-up switches to the
tree view.
Also spreads some more asserts to verify guard that no view other than
those being displayed updates their screen.
tree view.
Also spreads some more asserts to verify guard that no view other than
those being displayed updates their screen.
tig.c | patch | blob | history |
index 6518f0d6e7cc8fa67315751af4748ab459274677..8664732e46248ba58d40c63bcc1ba2307fde4fa9 100644 (file)
--- a/tig.c
+++ b/tig.c
#define VIEW(req) (&views[(req) - REQ_OFFSET - 1])
+#define foreach_view(view, i) \
+ for (i = 0; i < ARRAY_SIZE(views) && (view = &views[i]); i++)
+
+#define view_is_displayed(view) \
+ (view == display[0] || view == display[1])
static bool
draw_view_line(struct view *view, unsigned int lineno)
{
+ assert(view_is_displayed(view));
+
if (view->offset + lineno >= view->lines)
return FALSE;
static void
update_view_title(struct view *view)
{
+ assert(view_is_displayed(view));
+
if (view == display[current_view])
wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
else
static void
do_scroll_view(struct view *view, int lines, bool redraw)
{
+ assert(view_is_displayed(view));
+
/* The rendering expects the new offset. */
view->offset += lines;
@@ -1586,6 +1597,8 @@ static void search_view(struct view *view, enum request request, const char *sea
static bool
find_next_line(struct view *view, unsigned long lineno, struct line *line)
{
+ assert(view_is_displayed(view));
+
if (!view->ops->grep(view, line))
return FALSE;
if (view->offset + view->height >= view->lines)
redraw_from = view->lines - view->offset;
+ /* FIXME: This is probably not perfect for backgrounded views. */
if (!realloc_lines(view, view->lines + lines))
goto alloc_error;
}
}
+ if (!view_is_displayed(view))
+ goto check_pipe;
+
if (view == VIEW(REQ_VIEW_TREE)) {
/* Clear the view and redraw everything since the tree sorting
* might have rearranged things. */
* commit reference in view->ref it'll be available here. */
update_view_title(view);
+check_pipe:
if (ferror(view->pipe)) {
report("Failed to read: %s", strerror(errno));
goto end;
struct view *view;
int i, key;
- foreach_displayed_view (view, i)
+ foreach_view (view, i)
update_view(view);
report("%s%.*s", prompt, pos, buf);
int key;
int i;
- foreach_displayed_view (view, i)
+ foreach_view (view, i)
update_view(view);
/* Refresh, accept single keystroke of input */