#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;
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 */