summaryrefslogtreecommitdiff
path: root/gui/sheet.c
diff options
context:
space:
mode:
Diffstat (limited to 'gui/sheet.c')
-rw-r--r--gui/sheet.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/gui/sheet.c b/gui/sheet.c
index 3e62485..dfd0f57 100644
--- a/gui/sheet.c
+++ b/gui/sheet.c
@@ -272,12 +272,32 @@ void do_revision_overlays(struct gui_ctx *ctx)
/* ----- Sheet selection overlays ------------------------------------------ */
+static struct gui_sheet *find_parent_sheet(struct gui_sheet *sheets,
+ const struct gui_sheet *ref)
+{
+ struct gui_sheet *parent;
+ const struct sch_obj *obj;
+
+ for (parent = sheets; parent; parent = parent->next)
+ for (obj = parent->sch->objs; obj; obj = obj->next)
+ if (obj->type == sch_obj_sheet &&
+ obj->u.sheet.sheet == ref->sch)
+ return parent;
+ return NULL;
+}
+
+
static void close_subsheet(void *user)
{
struct gui_sheet *sheet = user;
struct gui_ctx *ctx = sheet->ctx;
+ struct gui_sheet *parent;
- go_to_sheet(ctx, sheet);
+ parent = find_parent_sheet(ctx->new_hist->sheets, sheet);
+ if (parent)
+ go_to_sheet(ctx, parent);
+ else
+ show_index(ctx);
}
@@ -308,21 +328,6 @@ static bool hover_sheet(void *user, bool on, int dx, int dy)
}
-static struct gui_sheet *find_parent_sheet(struct gui_sheet *sheets,
- const struct gui_sheet *ref)
-{
- struct gui_sheet *parent;
- const struct sch_obj *obj;
-
- for (parent = sheets; parent; parent = parent->next)
- for (obj = parent->sch->objs; obj; obj = obj->next)
- if (obj->type == sch_obj_sheet &&
- obj->u.sheet.sheet == ref->sch)
- return parent;
- return NULL;
-}
-
-
static void sheet_selector_recurse(struct gui_ctx *ctx, struct gui_sheet *sheet)
{
struct gui_sheet *parent;