commit - 72a9cb46de886cdce06a733a113b6ed47be4969b
commit + 9970f7fca9084ec99cb608732155668240b318fe
blob - 93cab5bc651a6c3c3f52c54de341de80c62862ea
blob + 50fefd43b456ae573fe7ef9c214a59c72cb42a9e
--- tog/tog.c
+++ tog/tog.c
int nlines, ncols, begin_y, begin_x;
int lines, cols; /* copies of LINES and COLS */
int focussed;
+ int dying;
struct tog_view *parent;
struct tog_view *child;
const struct got_error *(*show)(struct tog_view *);
const struct got_error *(*input)(struct tog_view **,
- struct tog_view **, struct tog_view**, struct tog_view *, int);
+ struct tog_view **, struct tog_view *, int);
const struct got_error *(*close)(struct tog_view *);
const struct got_error *(*search_start)(struct tog_view *);
struct got_repository *);
static const struct got_error *show_diff_view(struct tog_view *);
static const struct got_error *input_diff_view(struct tog_view **,
- struct tog_view **, struct tog_view **, struct tog_view *, int);
+ struct tog_view **, struct tog_view *, int);
static const struct got_error* close_diff_view(struct tog_view *);
static const struct got_error *search_start_diff_view(struct tog_view *);
static const struct got_error *search_next_diff_view(struct tog_view *);
const char *, const char *, int);
static const struct got_error * show_log_view(struct tog_view *);
static const struct got_error *input_log_view(struct tog_view **,
- struct tog_view **, struct tog_view **, struct tog_view *, int);
+ struct tog_view **, struct tog_view *, int);
static const struct got_error *close_log_view(struct tog_view *);
static const struct got_error *search_start_log_view(struct tog_view *);
static const struct got_error *search_next_log_view(struct tog_view *);
struct got_object_id *, struct got_repository *);
static const struct got_error *show_blame_view(struct tog_view *);
static const struct got_error *input_blame_view(struct tog_view **,
- struct tog_view **, struct tog_view **, struct tog_view *, int);
+ struct tog_view **, struct tog_view *, int);
static const struct got_error *close_blame_view(struct tog_view *);
static const struct got_error *search_start_blame_view(struct tog_view *);
static const struct got_error *search_next_blame_view(struct tog_view *);
struct got_tree_object *, struct got_object_id *, struct got_repository *);
static const struct got_error *show_tree_view(struct tog_view *);
static const struct got_error *input_tree_view(struct tog_view **,
- struct tog_view **, struct tog_view **, struct tog_view *, int);
+ struct tog_view **, struct tog_view *, int);
static const struct got_error *close_tree_view(struct tog_view *);
static const struct got_error *search_start_tree_view(struct tog_view *);
static const struct got_error *search_next_tree_view(struct tog_view *);
struct got_repository *);
static const struct got_error *show_ref_view(struct tog_view *);
static const struct got_error *input_ref_view(struct tog_view **,
- struct tog_view **, struct tog_view **, struct tog_view *, int);
+ struct tog_view **, struct tog_view *, int);
static const struct got_error *close_ref_view(struct tog_view *);
static const struct got_error *search_start_ref_view(struct tog_view *);
static const struct got_error *search_next_ref_view(struct tog_view *);
}
static const struct got_error *
-view_input(struct tog_view **new, struct tog_view **dead,
- struct tog_view **focus, int *done, struct tog_view *view,
- struct tog_view_list_head *views)
+view_input(struct tog_view **new, struct tog_view **focus, int *done,
+ struct tog_view *view, struct tog_view_list_head *views)
{
const struct got_error *err = NULL;
struct tog_view *v;
int ch, errcode;
*new = NULL;
- *dead = NULL;
*focus = NULL;
/* Clear "no matches" indicator. */
err = view_resize(v);
if (err)
return err;
- err = v->input(new, dead, focus, v, KEY_RESIZE);
+ err = v->input(new, focus, v, KEY_RESIZE);
if (err)
return err;
}
}
break;
case 'q':
- err = view->input(new, dead, focus, view, ch);
- *dead = view;
+ err = view->input(new, focus, view, ch);
+ view->dying = 1;
break;
case 'Q':
*done = 1;
err = view_splitscreen(view->child);
if (err)
break;
- err = view->child->input(new, dead, focus,
- view->child, KEY_RESIZE);
+ err = view->child->input(new, focus, view->child,
+ KEY_RESIZE);
} else {
if (view_is_splitscreen(view)) {
*focus = view;
}
if (err)
break;
- err = view->input(new, dead, focus, view,
- KEY_RESIZE);
+ err = view->input(new, focus, view, KEY_RESIZE);
}
break;
case KEY_RESIZE:
if (view->search_start)
view_search_start(view);
else
- err = view->input(new, dead, focus, view, ch);
+ err = view->input(new, focus, view, ch);
break;
case 'N':
case 'n':
view->search_next_done = 0;
view->search_next(view);
} else
- err = view->input(new, dead, focus, view, ch);
+ err = view->input(new, focus, view, ch);
break;
default:
- err = view->input(new, dead, focus, view, ch);
+ err = view->input(new, focus, view, ch);
break;
}
{
const struct got_error *err = NULL;
struct tog_view_list_head views;
- struct tog_view *new_view, *dead_view, *focus_view, *main_view;
+ struct tog_view *new_view, *focus_view, *main_view;
int fast_refresh = 10;
int done = 0, errcode;
if (fast_refresh && fast_refresh-- == 0)
halfdelay(10); /* switch to once per second */
- err = view_input(&new_view, &dead_view, &focus_view, &done,
- view, &views);
+ err = view_input(&new_view, &focus_view, &done, view, &views);
if (err)
break;
- if (dead_view) {
+ if (view->dying) {
struct tog_view *prev = NULL;
- if (view_is_parent_view(dead_view))
- prev = TAILQ_PREV(dead_view,
- tog_view_list_head, entry);
- else if (view->parent != dead_view)
+ if (view_is_parent_view(view))
+ prev = TAILQ_PREV(view, tog_view_list_head,
+ entry);
+ else if (view->parent != view)
prev = view->parent;
- if (dead_view->parent)
- dead_view->parent->child = NULL;
+ if (view->parent)
+ view->parent->child = NULL;
else
- TAILQ_REMOVE(&views, dead_view, entry);
+ TAILQ_REMOVE(&views, view, entry);
- err = view_close(dead_view);
- if (err || (dead_view == main_view && new_view == NULL))
+ err = view_close(view);
+ if (err || (view == main_view && new_view == NULL))
goto done;
- if (view == dead_view) {
- if (focus_view)
- view = focus_view;
- else if (prev)
- view = prev;
- else if (!TAILQ_EMPTY(&views))
- view = TAILQ_LAST(&views,
- tog_view_list_head);
+ if (focus_view)
+ view = focus_view;
+ else if (prev)
+ view = prev;
+ else if (!TAILQ_EMPTY(&views))
+ view = TAILQ_LAST(&views,
+ tog_view_list_head);
+ else
+ view = NULL;
+ if (view) {
+ if (view->child &&
+ view->child->focussed)
+ focus_view = view->child;
else
- view = NULL;
- if (view) {
- if (view->child &&
- view->child->focussed)
- focus_view = view->child;
- else
- focus_view = view;
- }
+ focus_view = view;
}
}
if (new_view) {
if (s->matched_entry) {
int cur = s->selected_entry->idx;
while (cur < s->matched_entry->idx) {
- err = input_log_view(NULL, NULL, NULL, view, KEY_DOWN);
+ err = input_log_view(NULL, NULL, view, KEY_DOWN);
if (err)
return err;
cur++;
}
while (cur > s->matched_entry->idx) {
- err = input_log_view(NULL, NULL, NULL, view, KEY_UP);
+ err = input_log_view(NULL, NULL, view, KEY_UP);
if (err)
return err;
cur--;
}
static const struct got_error *
-input_log_view(struct tog_view **new_view, struct tog_view **dead_view,
- struct tog_view **focus_view, struct tog_view *view, int ch)
+input_log_view(struct tog_view **new_view, struct tog_view **focus_view,
+ struct tog_view *view, int ch)
{
const struct got_error *err = NULL;
struct tog_log_view_state *s = &view->state.log;
view_close(lv);
return err;;
}
- *dead_view = view;
+ view->dying = 1;
*new_view = lv;
break;
case 'B':
view_close(lv);
return err;;
}
- *dead_view = view;
+ view->dying = 1;
*new_view = lv;
break;
case 'r':
}
static const struct got_error *
-input_diff_view(struct tog_view **new_view, struct tog_view **dead_view,
- struct tog_view **focus_view, struct tog_view *view, int ch)
+input_diff_view(struct tog_view **new_view, struct tog_view **focus_view,
+ struct tog_view *view, int ch)
{
const struct got_error *err = NULL;
struct tog_diff_view_state *s = &view->state.diff;
if (entry == NULL)
break;
- err = input_log_view(NULL, NULL, NULL, s->log_view,
- KEY_UP);
+ err = input_log_view(NULL, NULL, s->log_view, KEY_UP);
if (err)
break;
if (err)
break;
}
- err = input_log_view(NULL, NULL, NULL, s->log_view,
- KEY_DOWN);
+ err = input_log_view(NULL, NULL, s->log_view, KEY_DOWN);
if (err)
break;
}
static const struct got_error *
-input_blame_view(struct tog_view **new_view, struct tog_view **dead_view,
- struct tog_view **focus_view, struct tog_view *view, int ch)
+input_blame_view(struct tog_view **new_view, struct tog_view **focus_view,
+ struct tog_view *view, int ch)
{
const struct got_error *err = NULL, *thread_err = NULL;
struct tog_view *diff_view;
}
static const struct got_error *
-input_tree_view(struct tog_view **new_view, struct tog_view **dead_view,
- struct tog_view **focus_view, struct tog_view *view, int ch)
+input_tree_view(struct tog_view **new_view, struct tog_view **focus_view,
+ struct tog_view *view, int ch)
{
const struct got_error *err = NULL;
struct tog_tree_view_state *s = &view->state.tree;
return err;
}
static const struct got_error *
-input_ref_view(struct tog_view **new_view, struct tog_view **dead_view,
- struct tog_view **focus_view, struct tog_view *view, int ch)
+input_ref_view(struct tog_view **new_view, struct tog_view **focus_view,
+ struct tog_view *view, int ch)
{
const struct got_error *err = NULL;
struct tog_ref_view_state *s = &view->state.ref;