commit - 7cc84d774f901f489d37cc35dafaa5f4a7be1218
commit + cc3c9aac74c52266b5bfd68dbc942f539e3634c7
blob - e53bce1876ff74de20b16c0e4534243ad7158bbb
blob + 4688ed6d8f3dd0e133723353d0f6b9e6e67a0665
--- tog/tog.c
+++ tog/tog.c
"browse trees in repository" },
};
-static struct tog_view {
+struct tog_view {
WINDOW *window;
PANEL *panel;
-} tog_tree_view;
+};
static const struct got_error *
show_diff_view(struct tog_view *, struct got_object *, struct got_object *,
char *commit_id_str = NULL, *tree_label = NULL;
int nentries, ndisplayed;
struct tog_parent_trees parents;
+ struct tog_view *view = NULL;
TAILQ_INIT(&parents);
goto done;
}
- if (tog_tree_view.window == NULL) {
- tog_tree_view.window = newwin(0, 0, 0, 0);
- if (tog_tree_view.window == NULL)
- return got_error_from_errno();
- keypad(tog_tree_view.window, TRUE);
+ view = open_view();
+ if (view == NULL) {
+ err = got_error_from_errno();
+ goto done;
}
- if (tog_tree_view.panel == NULL) {
- tog_tree_view.panel = new_panel(tog_tree_view.window);
- if (tog_tree_view.panel == NULL)
- return got_error_from_errno();
- } else
- show_panel(tog_tree_view.panel);
+ show_panel(view->panel);
entries = got_object_tree_get_entries(root);
first_displayed_entry = SIMPLEQ_FIRST(&entries->head);
err = draw_tree_entries(&first_displayed_entry,
&last_displayed_entry, &selected_entry, &ndisplayed,
- tog_tree_view.window, tree_label, show_ids,
+ view->window, tree_label, show_ids,
parent_path, entries, selected, LINES, tree == root);
free(parent_path);
if (err)
break;
nodelay(stdscr, FALSE);
- ch = wgetch(tog_tree_view.window);
+ ch = wgetch(view->window);
nodelay(stdscr, TRUE);
switch (ch) {
case 'q':
}
}
done:
+ if (view)
+ close_view(view);
free(tree_label);
free(commit_id_str);
while (!TAILQ_EMPTY(&parents)) {