Download raw body.
tog: status bar prompt about togglable events
Inlined patch adds short timed prompts to status bar about things like switching between diff algorithms, showing white spaces in patches, toggling bin/ascii views for blobs, changing committer and author representations, and switch between date/name sorting for ref view. Originally I wanted it because I needed to see current diff algorithm, but decided to expand the patch to show all togglable events, except for ref view, where, for example, showing IDs speaks for itself by changing the look of the table and doesn't require a prompt. diff /home/misha/work/got commit - 7713cc5e4f5544e81909670d592e89526ed86c9b path + /home/misha/work/got blob - 35282ce50aa4dec0745aa6402cd0b50d87b7416b file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -690,6 +690,7 @@ struct tog_view { #define TOG_SEARCH_HAVE_NONE 3 regex_t regex; regmatch_t regmatch; + const char *prompt; }; static const struct got_error *open_diff_view(struct tog_view *, @@ -1476,6 +1477,16 @@ view_input(struct tog_view **new, int *done, struct to view->count = 0; } + /* + * Clear statusbar prompt, for blame view clear it only when + * annotating is completed, otherwise it's too fast. + */ + if (view->type == TOG_VIEW_BLAME) { + if (view->state.blame.blame_complete) + view->prompt = NULL; + } else + view->prompt = NULL; + if (view->searching && !view->search_next_done) { errcode = pthread_mutex_unlock(&tog_mutex); if (errcode) @@ -1668,10 +1679,13 @@ view_input(struct tog_view **new, int *done, struct to err = view->input(new, view, ch); break; case 'A': - if (tog_diff_algo == GOT_DIFF_ALGORITHM_MYERS) + if (tog_diff_algo == GOT_DIFF_ALGORITHM_MYERS) { tog_diff_algo = GOT_DIFF_ALGORITHM_PATIENCE; - else + view->prompt = "Patience algorithm"; + } else { tog_diff_algo = GOT_DIFF_ALGORITHM_MYERS; + view->prompt = "Myers algorithm"; + } TAILQ_FOREACH(v, views, entry) { if (v->reset) { err = v->reset(v); @@ -2489,10 +2503,11 @@ draw_commits(struct tog_view *view) if (s->limit_view && s->commits->ncommits == 0) limit_str = "no matches found"; - if (asprintf(&ncommits_str, " [%d/%d] %s %s", + if (asprintf(&ncommits_str, " [%d/%d] %s %s %s", entry ? entry->idx + 1 : 0, s->commits->ncommits, search_str ? search_str : (refs_str ? refs_str : ""), - limit_str ? limit_str : "") == -1) { + (limit_str ? limit_str : ""), + (view->prompt ? view->prompt : "")) == -1) { err = got_error_from_errno("asprintf"); goto done; } @@ -3718,6 +3733,7 @@ input_log_view(struct tog_view **new_view, struct tog_ break; case '@': s->use_committer = !s->use_committer; + view->prompt = (s->use_committer ? "Committer" : "Author"); break; case 'G': case '*': @@ -5130,7 +5146,8 @@ show_diff_view(struct tog_view *view) return err; label2 = s->label2 ? s->label2 : id_str2; - if (asprintf(&header, "diff %s %s", label1, label2) == -1) { + if (asprintf(&header, "diff %s %s %s", label1, label2, + (view->prompt ? view->prompt : "")) == -1) { err = got_error_from_errno("asprintf"); free(id_str1); free(id_str2); @@ -5261,10 +5278,17 @@ input_diff_view(struct tog_view **new_view, struct tog break; case 'a': case 'w': - if (ch == 'a') + if (ch == 'a') { s->force_text_diff = !s->force_text_diff; - else if (ch == 'w') + view->prompt = + (s->force_text_diff ? "Text diff" : "Bin diff"); + } + else if (ch == 'w') { s->ignore_whitespace = !s->ignore_whitespace; + view->prompt = + (s->ignore_whitespace ? + "Ignore whitespaces" : "Show whitespaces"); + } err = reset_diff_view(view); break; case 'g': @@ -5621,12 +5645,16 @@ draw_blame(struct tog_view *view) rewind(blame->f); werase(view->window); - if (asprintf(&line, "commit %s", id_str) == -1) { + if (asprintf(&line, "commit %s %s", id_str, + (view->prompt ? view->prompt : "")) == -1) { err = got_error_from_errno("asprintf"); free(id_str); return err; } + if (s->blame_complete) + view->prompt = NULL; + err = format_line(&wline, &width, NULL, line, 0, view->ncols, 0, 0); free(line); line = NULL; @@ -8006,8 +8034,8 @@ show_ref_view(struct tog_view *view) re = s->first_displayed_entry; - if (asprintf(&line, "references [%d/%d]", re->idx + s->selected + 1, - s->nrefs) == -1) + if (asprintf(&line, "references [%d/%d] %s", re->idx + s->selected + 1, + s->nrefs, (view->prompt ? view->prompt : "")) == -1) return got_error_from_errno("asprintf"); err = format_line(&wline, &width, NULL, line, 0, view->ncols, 0, 0); @@ -8233,6 +8261,8 @@ input_ref_view(struct tog_view **new_view, struct tog_ break; case 'o': s->sort_by_date = !s->sort_by_date; + view->prompt = + (s->sort_by_date ? "Sort by date" : "Sort by name"); view->count = 0; err = got_reflist_sort(&tog_refs, s->sort_by_date ? got_ref_cmp_by_commit_timestamp_descending :
tog: status bar prompt about togglable events