make 'tog diff' show a progress message while generating diffs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
diff --git a/tog/tog.c b/tog/tog.c
index ea459c1..bc37cce 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -486,7 +486,7 @@ view_set_child(struct tog_view *view, struct tog_view *child)
static int
view_is_splitscreen(struct tog_view *view)
{
- return !view_is_parent_view(view) && view->begin_x > 0;
+ return view->begin_x > 0;
}
static void
@@ -2107,6 +2107,15 @@ done:
return err;
}
+static void
+diff_view_indicate_progress(struct tog_view *view)
+{
+ werase(view->window);
+ waddstr(view->window, "diffing...");
+ update_panels();
+ doupdate();
+}
+
static const struct got_error *
open_diff_view(struct tog_view *view, struct got_object_id *id1,
struct got_object_id *id2, struct tog_view *log_view,
@@ -2148,6 +2157,10 @@ open_diff_view(struct tog_view *view, struct got_object_id *id1,
view->state.diff.repo = repo;
view->state.diff.refs = refs;
+ if (log_view && view_is_splitscreen(view))
+ show_log_view(log_view); /* draw vborder */
+ diff_view_indicate_progress(view);
+
err = create_diff(&view->state.diff);
if (err) {
free(view->state.diff.id1);
@@ -2275,12 +2288,14 @@ input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
case '[':
if (s->diff_context > 0) {
s->diff_context--;
+ diff_view_indicate_progress(view);
err = create_diff(s);
}
break;
case ']':
if (s->diff_context < GOT_DIFF_MAX_CONTEXT) {
s->diff_context++;
+ diff_view_indicate_progress(view);
err = create_diff(s);
}
break;
@@ -2306,6 +2321,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
s->first_displayed_line = 1;
s->last_displayed_line = view->nlines;
+ diff_view_indicate_progress(view);
err = create_diff(s);
break;
case '>':
@@ -2345,6 +2361,7 @@ input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
s->first_displayed_line = 1;
s->last_displayed_line = view->nlines;
+ diff_view_indicate_progress(view);
err = create_diff(s);
break;
default: