commit 3f6c66148db9beccfaaa0138fcff4b84cb99ec5a from: Mark Jamsek date: Mon Jan 23 04:04:18 2023 UTC tog: display action report on user toggleable event If the diff algorithm, ignore whitespace-only changes, force ASCII text diff, show committer/author, or reference sort order keymaps are toggled, report action to the bottom left of screen. Based on initial patch by Mikhail. ok + tweaks op@ commit - 388b24d60f37266ab8fbe53238f25ec75935b324 commit + 3f6c66148db9beccfaaa0138fcff4b84cb99ec5a blob - 13d7ed16f0bce469f1ab9d48abd5aeb041b9ec82 blob + 20e53ee697ba1c8890789243f34f8726f9ef496b --- 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 *action; }; static const struct got_error *open_diff_view(struct tog_view *, @@ -1457,6 +1458,32 @@ get_compound_key(struct tog_view *view, int c) view->count = n; return c; +} + +static void +action_report(struct tog_view *view) +{ + struct tog_view *v = view; + + if (view_is_hsplit_top(view)) + v = view->child; + else if (view->mode == TOG_VIEW_SPLIT_VERT && view->parent) + v = view->parent; + + wmove(v->window, v->nlines - 1, 0); + wclrtoeol(v->window); + wprintw(v->window, ":%s", view->action); + wrefresh(v->window); + + /* + * Clear action status report. Only clear in blame view + * once annotating is complete, otherwise it's too fast. + */ + if (view->type == TOG_VIEW_BLAME) { + if (view->state.blame.blame_complete) + view->action = NULL; + } else + view->action = NULL; } static const struct got_error * @@ -1468,6 +1495,9 @@ view_input(struct tog_view **new, int *done, struct to int ch, errcode; *new = NULL; + + if (view->action) + action_report(view); /* Clear "no matches" indicator. */ if (view->search_next_done == TOG_SEARCH_NO_MORE || @@ -1668,10 +1698,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->action = "Patience diff algorithm"; + } else { tog_diff_algo = GOT_DIFF_ALGORITHM_MYERS; + view->action = "Myers diff algorithm"; + } TAILQ_FOREACH(v, views, entry) { if (v->reset) { err = v->reset(v); @@ -3718,6 +3751,8 @@ input_log_view(struct tog_view **new_view, struct tog_ break; case '@': s->use_committer = !s->use_committer; + view->action = s->use_committer ? + "show committer" : "show commit author"; break; case 'G': case '*': @@ -5261,10 +5296,18 @@ input_diff_view(struct tog_view **new_view, struct tog break; case 'a': case 'w': - if (ch == 'a') - s->force_text_diff = !s->force_text_diff; - else if (ch == 'w') + if (ch == 'a') { + s->force_text_diff = !s->force_text_diff; + view->action = s->force_text_diff ? + "force ASCII text enabled" : + "force ASCII text disabled"; + } + else if (ch == 'w') { s->ignore_whitespace = !s->ignore_whitespace; + view->action = s->ignore_whitespace ? + "ignore whitespace enabled" : + "ignore whitespace disabled"; + } err = reset_diff_view(view); break; case 'g': @@ -8233,6 +8276,7 @@ input_ref_view(struct tog_view **new_view, struct tog_ break; case 'o': s->sort_by_date = !s->sort_by_date; + view->action = 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 :