keep track of view types in tog
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
diff --git a/tog/tog.c b/tog/tog.c
index 3913894..bee3431 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -82,12 +82,20 @@ static struct tog_cmd tog_commands[] = {
"browse trees in repository" },
};
+enum tog_view_type {
+ TOG_VIEW_DIFF,
+ TOG_VIEW_LOG,
+ TOG_VIEW_TREE,
+ TOG_VIEW_BLAME
+};
+
struct tog_view {
WINDOW *window;
PANEL *panel;
int nlines, ncols, begin_y, begin_x;
int lines, cols; /* copies of LINES and COLS */
struct tog_view *parent;
+ enum tog_view_type type;
};
static const struct got_error *
@@ -115,7 +123,7 @@ close_view(struct tog_view *view)
static struct tog_view *
open_view(int nlines, int ncols, int begin_y, int begin_x,
- struct tog_view *parent)
+ struct tog_view *parent, enum tog_view_type type)
{
struct tog_view *view = malloc(sizeof(*view));
@@ -123,6 +131,7 @@ open_view(int nlines, int ncols, int begin_y, int begin_x,
return NULL;
view->parent = parent;
+ view->type = type;
view->lines = LINES;
view->cols = COLS;
view->nlines = nlines ? nlines : LINES - begin_y;
@@ -751,7 +760,7 @@ show_commit(struct tog_view *parent_view, struct commit_queue_entry *entry,
goto done;
}
- view = open_view(0, 0, 0, 0, parent_view);
+ view = open_view(0, 0, 0, 0, parent_view, TOG_VIEW_DIFF);
if (view == NULL) {
err = got_error_from_errno();
goto done;
@@ -780,7 +789,7 @@ browse_commit(struct tog_view *parent_view, struct commit_queue_entry *entry,
if (err)
return err;
- view = open_view(0, 0, 0, 0, parent_view);
+ view = open_view(0, 0, 0, 0, parent_view, TOG_VIEW_TREE);
if (view == NULL) {
err = got_error_from_errno();
goto done;
@@ -1029,7 +1038,7 @@ cmd_log(int argc, char *argv[])
if (error != NULL)
goto done;
- view = open_view(0, 0, 0, 0, NULL);
+ view = open_view(0, 0, 0, 0, NULL, TOG_VIEW_LOG);
if (view == NULL) {
error = got_error_from_errno();
goto done;
@@ -1264,7 +1273,7 @@ cmd_diff(int argc, char *argv[])
if (error)
goto done;
- view = open_view(0, 0, 0, 0, NULL);
+ view = open_view(0, 0, 0, 0, NULL, TOG_VIEW_DIFF);
if (view == NULL) {
error = got_error_from_errno();
goto done;
@@ -1867,7 +1876,8 @@ show_blame_view(struct tog_view *view, const char *path,
break;
if (pobj == NULL && obj == NULL)
break;
- diff_view = open_view(0, 0, 0, 0, view);
+ diff_view = open_view(0, 0, 0, 0, view,
+ TOG_VIEW_DIFF);
if (diff_view == NULL) {
err = got_error_from_errno();
break;
@@ -2012,7 +2022,7 @@ cmd_blame(int argc, char *argv[])
if (error != NULL)
goto done;
- view = open_view(0, 0, 0, 0, NULL);
+ view = open_view(0, 0, 0, 0, NULL, TOG_VIEW_BLAME);
if (view == NULL) {
error = got_error_from_errno();
goto done;
@@ -2254,7 +2264,7 @@ blame_tree_entry(struct tog_view *parent_view, struct got_tree_entry *te,
if (err)
return err;
- view = open_view(0, 0, 0, 0, parent_view);
+ view = open_view(0, 0, 0, 0, parent_view, TOG_VIEW_BLAME);
if (view) {
err = show_blame_view(view, path, commit_id, repo);
close_view(view);
@@ -2345,7 +2355,8 @@ show_tree_view(struct tog_view *view, struct got_tree_object *root,
case 'l':
if (selected_entry) {
struct tog_view *log_view;
- log_view = open_view(0, 0, 0, 0, view);
+ log_view = open_view(0, 0, 0, 0, view,
+ TOG_VIEW_LOG);
if (log_view == NULL) {
err = got_error_from_errno();
goto done;
@@ -2552,7 +2563,7 @@ cmd_tree(int argc, char *argv[])
if (error != NULL)
goto done;
- view = open_view(0, 0, 0, 0, NULL);
+ view = open_view(0, 0, 0, 0, NULL, TOG_VIEW_TREE);
if (view == NULL) {
error = got_error_from_errno();
goto done;