static bool blame_read(struct view *view, char *line) { struct blame_state *state = view->private; if (!state->done_reading) return blame_read_file(view, line, state); if (!line) { state->auto_filename_display = blame_detect_filename_display(view); string_format(view->ref, "%s", view->vid); if (view_is_displayed(view)) { update_view_title(view); redraw_view_from(view, 0); } return TRUE; } if (!state->commit) { state->commit = read_blame_commit(view, line, state); string_format(view->ref, "%s %2zd%%", view->vid, view->lines ? state->blamed * 100 / view->lines : 0); } else if (parse_blame_info(state->commit, line)) { if (!state->commit->filename) return FALSE; state->commit = NULL; } return TRUE; }
void redraw_view(struct view *view) { werase(view->win); redraw_view_from(view, 0); }
static void redraw_view(struct view *view) { wclear(view->win); redraw_view_from(view, 0); }
static int update_view(struct view *view) { char buffer[BUFSIZ]; char *line; void **tmp; int redraw_from = -1; unsigned long lines = view->height; char *top = "Binary file"; if (!view->pipe) return TRUE; /* Only redraw if lines are visible. */ if (view->offset + view->height >= view->lines) redraw_from = view->lines - view->offset; tmp = realloc(view->line, sizeof(*view->line) * (view->lines + lines)); if (!tmp) goto alloc_error; view->line = tmp; while ((line = fgets(buffer, sizeof(buffer), view->pipe))) { int linelen; linelen = strlen(line); if (linelen) line[linelen - 1] = 0; if(!strncmp(line, top, strlen(top))) continue; if (!view->read(view, line)) goto alloc_error; if (lines-- == 1) break; } if (redraw_from >= 0) { /* If this is an incremental update, redraw the previous line * since for commits some members could have changed when * loading the main view. */ if (redraw_from > 0) redraw_from--; /* Incrementally draw avoids flickering. */ redraw_view_from(view, redraw_from); } update_title_win(view); if (ferror(view->pipe)) { printw("Failed to read %s", view->cmd); goto end; } else if (feof(view->pipe)) { report("load %d lines", view->lines); goto end; } return TRUE; alloc_error: printw("Allocation failure"); end: end_update(view); return FALSE; }