tog: at eof in diff view, print (END) like less does
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
diff --git a/tog/tog.c b/tog/tog.c
index 353d457..f4576ea 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -100,6 +100,8 @@ enum tog_view_type {
TOG_VIEW_TREE
};
+#define TOG_EOF_STRING "(END)"
+
struct commit_queue_entry {
TAILQ_ENTRY(commit_queue_entry) entry;
struct got_object_id *id;
@@ -1958,7 +1960,7 @@ parse_next_line(FILE *f, size_t *len)
static const struct got_error *
draw_file(struct tog_view *view, FILE *f, int *first_displayed_line,
int *last_displayed_line, int *eof, int max_lines,
- char * header)
+ char *header)
{
const struct got_error *err;
int nlines = 0, nprinted = 0;
@@ -2019,6 +2021,22 @@ draw_file(struct tog_view *view, FILE *f, int *first_displayed_line,
view_vborder(view);
+ if (*eof) {
+ while (nprinted < view->nlines) {
+ waddch(view->window, '\n');
+ nprinted++;
+ }
+
+ err = format_line(&wline, &width, TOG_EOF_STRING, view->ncols);
+ if (err) {
+ return err;
+ }
+
+ wstandout(view->window);
+ waddwstr(view->window, wline);
+ wstandend(view->window);
+ }
+
return NULL;
}