From 258876ef2c4bd65b64121f4499cf1b3b88f1353f Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 4 Aug 2016 08:42:36 -0300 Subject: [PATCH] eeshow/: retrieve title from *.sch; prefer over subsheet name when displaying --- eeshow/gui.c | 6 +++++- eeshow/sch-parse.c | 5 +++++ eeshow/sch.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/eeshow/gui.c b/eeshow/gui.c index 3a915aa..76f2bba 100644 --- a/eeshow/gui.c +++ b/eeshow/gui.c @@ -389,9 +389,13 @@ static void select_subsheet(void *user) for (sheet = ctx->sheets; sheet; sheet = sheet->next) if (sheet->sch == obj->u.sheet.sheet) { + const char *name; + sheet->prev = ctx->curr_sheet; set_sheet(ctx, sheet); - overlay_add(&ctx->overlays, obj->u.sheet.name, + name = sheet->sch->title ? sheet->sch->title : + obj->u.sheet.name; + overlay_add(&ctx->overlays, name, &ctx->aois, NULL, close_subsheet, ctx); return; } diff --git a/eeshow/sch-parse.c b/eeshow/sch-parse.c index be0dd0c..7fbdfdd 100644 --- a/eeshow/sch-parse.c +++ b/eeshow/sch-parse.c @@ -283,6 +283,7 @@ static struct sheet *new_sheet(struct sch_ctx *ctx) struct sheet *sheet; sheet = alloc_type(struct sheet); + sheet->title = NULL; sheet->objs = NULL; sheet->next_obj = &sheet->objs; sheet->next = NULL; @@ -441,6 +442,10 @@ static bool parse_line(const struct file *file, void *user, const char *line) return 0; break; case sch_descr: + if (sscanf(line, "Title \"%m[^\"]\"", &s) == 1) { + ctx->curr_sheet->title = s; + return 1; + } if (sscanf(line, "$EndDescr%n", &n) || !n) return 1; ctx->state = sch_basic; diff --git a/eeshow/sch.h b/eeshow/sch.h index fbb1c0f..ff4f731 100644 --- a/eeshow/sch.h +++ b/eeshow/sch.h @@ -91,6 +91,7 @@ struct sch_obj { }; struct sheet { + const char *title; struct sch_obj *objs; struct sch_obj **next_obj; struct sheet *parent;