commit - 871bd038071fdaf6129995ef9f56226616b47d25
commit + 444d532558298b49ff0edc7fc0376d71b5fa00b0
blob - d22799a47ef9bd147f72ae35dbe392bcadb72680
blob + 2735938d75ca2d0cb81fd696523643ed004e53ee
--- tog/tog.c
+++ tog/tog.c
return view->nlines == LINES && view->ncols == COLS;
}
+static int
+view_is_hsplit_top(struct tog_view *view)
+{
+ return view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
+ view_is_splitscreen(view->child);
+}
+
static void
view_border(struct tog_view *view)
{
if (view->nlines < 1)
return NULL;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
v = view->child;
mvwaddstr(v->window, v->nlines - 1, 0, "/");
struct tog_view *v = view;
int x, n = 0;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
v = view->child;
else if (view->mode == TOG_VIEW_SPLIT_VERT && view->parent)
v = view->parent;
if (newline)
*newline = '\0';
limit = avail - col;
- if (view->child && view_is_splitscreen(view->child) && limit > 0)
+ if (view->child && !view_is_hsplit_top(view) && limit > 0)
limit--; /* for the border */
err = format_line(&wlogmsg, &logmsg_width, &scrollx, logmsg, view->x,
limit, col, 1);
}
static const struct got_error *
-browse_commit_tree(struct tog_view **new_view, int begin_x,
+browse_commit_tree(struct tog_view **new_view, int begin_y, int begin_x,
struct commit_queue_entry *entry, const char *path,
const char *head_ref_name, struct got_repository *repo)
{
struct tog_tree_view_state *s;
struct tog_view *tree_view;
- tree_view = view_open(0, 0, 0, begin_x, TOG_VIEW_TREE);
+ tree_view = view_open(0, 0, begin_y, begin_x, TOG_VIEW_TREE);
if (tree_view == NULL)
return got_error_from_errno("view_open");
if (!page) {
int eos = view->nlines - 2;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
--eos; /* border consumes the last line */
if (s->selected < MIN(eos, s->commits.ncommits - 1))
++s->selected;
}
eos = nscroll = view->nlines - 1;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
--eos; /* border */
-
switch (ch) {
case 'q':
s->quit = 1;
}
break;
case KEY_ENTER:
- case '\r': {
+ case '\r':
view->count = 0;
if (s->selected_entry == NULL)
break;
if (err)
break;
- if (view->mode == TOG_VIEW_SPLIT_HRZN) { /* safe to split */
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) { /* safe to split */
err = view_init_hsplit(view, begin_y);
if (err)
break;
} else
*new_view = diff_view;
break;
- }
case 't':
view->count = 0;
if (s->selected_entry == NULL)
break;
if (view_is_parent_view(view))
- begin_x = view_split_begin_x(view->begin_x);
- err = browse_commit_tree(&tree_view, begin_x,
+ view_get_split(view, &begin_y, &begin_x);
+ err = browse_commit_tree(&tree_view, begin_y, begin_x,
s->selected_entry, s->in_repo_path, s->head_ref_name,
s->repo);
if (err)
break;
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
+ err = view_init_hsplit(view, begin_y);
+ if (err)
+ break;
+ }
view->focussed = 0;
tree_view->focussed = 1;
+ tree_view->mode = view->mode;
+ tree_view->nlines = view->lines - begin_y;
if (view_is_parent_view(view)) {
err = view_close_child(view);
if (err)
case 'r':
view->count = 0;
if (view_is_parent_view(view))
- begin_x = view_split_begin_x(view->begin_x);
- ref_view = view_open(view->nlines, view->ncols,
- view->begin_y, begin_x, TOG_VIEW_REF);
+ view_get_split(view, &begin_y, &begin_x);
+ ref_view = view_open(0, 0, begin_y, begin_x, TOG_VIEW_REF);
if (ref_view == NULL)
return got_error_from_errno("view_open");
err = open_ref_view(ref_view, s->repo);
view_close(ref_view);
return err;
}
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
+ err = view_init_hsplit(view, begin_y);
+ if (err)
+ break;
+ }
view->focussed = 0;
ref_view->focussed = 1;
+ ref_view->mode = view->mode;
+ ref_view->nlines = view->lines - begin_y;
if (view_is_parent_view(view)) {
err = view_close_child(view);
if (err)
int eos, nscroll, begin_y = 0, begin_x = 0;
eos = nscroll = view->nlines - 2;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
--eos; /* border */
switch (ch) {
view_close(diff_view);
break;
}
- if (view->mode == TOG_VIEW_SPLIT_HRZN) {
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
err = view_init_hsplit(view, begin_y);
if (err)
break;
int limit = view->nlines;
s->ndisplayed = 0;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
--limit; /* border */
werase(view->window);
}
static const struct got_error *
-log_selected_tree_entry(struct tog_view **new_view, int begin_x,
+log_selected_tree_entry(struct tog_view **new_view, int begin_y, int begin_x,
struct tog_tree_view_state *s)
{
struct tog_view *log_view;
*new_view = NULL;
- log_view = view_open(0, 0, 0, begin_x, TOG_VIEW_LOG);
+ log_view = view_open(0, 0, begin_y, begin_x, TOG_VIEW_LOG);
if (log_view == NULL)
return got_error_from_errno("view_open");
struct tog_tree_view_state *s = &view->state.tree;
struct tog_view *log_view, *ref_view;
struct got_tree_entry *te;
- int begin_x = 0, n, nscroll = view->nlines - 3;
+ int begin_y = 0, begin_x = 0, n, nscroll = view->nlines - 3;
switch (ch) {
case 'i':
if (!s->selected_entry)
break;
if (view_is_parent_view(view))
- begin_x = view_split_begin_x(view->begin_x);
- err = log_selected_tree_entry(&log_view, begin_x, s);
+ view_get_split(view, &begin_y, &begin_x);
+ err = log_selected_tree_entry(&log_view, begin_y, begin_x, s);
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
+ err = view_init_hsplit(view, begin_y);
+ if (err)
+ break;
+ }
view->focussed = 0;
log_view->focussed = 1;
+ log_view->mode = view->mode;
+ log_view->nlines = view->lines - begin_y;
if (view_is_parent_view(view)) {
err = view_close_child(view);
if (err)
case 'r':
view->count = 0;
if (view_is_parent_view(view))
- begin_x = view_split_begin_x(view->begin_x);
- ref_view = view_open(view->nlines, view->ncols,
- view->begin_y, begin_x, TOG_VIEW_REF);
+ view_get_split(view, &begin_y, &begin_x);
+ ref_view = view_open(0, 0, begin_y, begin_x, TOG_VIEW_REF);
if (ref_view == NULL)
return got_error_from_errno("view_open");
err = open_ref_view(ref_view, s->repo);
view_close(ref_view);
return err;
}
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
+ err = view_init_hsplit(view, begin_y);
+ if (err)
+ break;
+ }
view->focussed = 0;
ref_view->focussed = 1;
+ ref_view->mode = view->mode;
+ ref_view->nlines = view->lines - begin_y;
if (view_is_parent_view(view)) {
err = view_close_child(view);
if (err)
if (err)
break;
- if (view->mode == TOG_VIEW_SPLIT_HRZN) {
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
err = view_init_hsplit(view, begin_y);
if (err)
break;
werase(view->window);
s->ndisplayed = 0;
- if (view->mode == TOG_VIEW_SPLIT_HRZN && view->child &&
- view_is_splitscreen(view->child))
+ if (view_is_hsplit_top(view))
--limit; /* border */
if (limit == 0)
}
static const struct got_error *
-browse_ref_tree(struct tog_view **new_view, int begin_x,
+browse_ref_tree(struct tog_view **new_view, int begin_y, int begin_x,
struct tog_reflist_entry *re, struct got_repository *repo)
{
const struct got_error *err = NULL;
}
- tree_view = view_open(0, 0, 0, begin_x, TOG_VIEW_TREE);
+ tree_view = view_open(0, 0, begin_y, begin_x, TOG_VIEW_TREE);
if (tree_view == NULL) {
err = got_error_from_errno("view_open");
goto done;
if (err)
break;
- if (view->mode == TOG_VIEW_SPLIT_HRZN) {
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
err = view_init_hsplit(view, begin_y);
if (err)
break;
if (!s->selected_entry)
break;
if (view_is_parent_view(view))
- begin_x = view_split_begin_x(view->begin_x);
- err = browse_ref_tree(&tree_view, begin_x, s->selected_entry,
- s->repo);
+ view_get_split(view, &begin_y, &begin_x);
+ err = browse_ref_tree(&tree_view, begin_y, begin_x,
+ s->selected_entry, s->repo);
if (err || tree_view == NULL)
break;
+ if (view_is_parent_view(view) &&
+ view->mode == TOG_VIEW_SPLIT_HRZN) {
+ err = view_init_hsplit(view, begin_y);
+ if (err)
+ break;
+ }
view->focussed = 0;
tree_view->focussed = 1;
+ tree_view->mode = view->mode;
+ tree_view->nlines = view->lines - begin_y;
if (view_is_parent_view(view)) {
err = view_close_child(view);
if (err)