summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-12 14:34:53 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-12 14:43:29 -0300
commitd2e16c9a002e9349628ee6ee935432b39935e378 (patch)
tree818f6323f54fcb49b02da6fe475ab48b5a491228
parent370b28fe91b9683323d02a66949c3519841a65c6 (diff)
downloadeeshow-d2e16c9a002e9349628ee6ee935432b39935e378.tar.gz
eeshow-d2e16c9a002e9349628ee6ee935432b39935e378.tar.bz2
eeshow-d2e16c9a002e9349628ee6ee935432b39935e378.zip
eeshow/: missing components are no longer fatal
-rw-r--r--delta.c2
-rw-r--r--lib-render.c19
-rw-r--r--sch-parse.c4
-rw-r--r--style.c1
-rw-r--r--style.h5
5 files changed, 28 insertions, 3 deletions
diff --git a/delta.c b/delta.c
index f407019..fe89233 100644
--- a/delta.c
+++ b/delta.c
@@ -114,6 +114,8 @@ static bool comp_eq(const struct comp *a, const struct comp *b)
{
if (a == b)
return 1;
+ if (!(a && b))
+ return 0;
if (strcmp(a->name, b->name))
return 0;
if (a->units != b->units)
diff --git a/lib-render.c b/lib-render.c
index 2e7407e..1bfc463 100644
--- a/lib-render.c
+++ b/lib-render.c
@@ -380,7 +380,8 @@ const struct comp *lib_find(const struct lib *lib, const char *name)
if (!strcmp(alias->name, name))
return comp;
}
- fatal("\"%s\" not found\n", name);
+ error("\"%s\" not found\n", name);
+ return NULL;
}
@@ -390,10 +391,26 @@ bool lib_field_visible(const struct comp *comp, int n)
}
+static void missing_component(const int m[4])
+{
+ int sx = mx(0, 0, m);
+ int sy = my(0, 0, m);
+ int ex = mx(MISSING_WIDTH, MISSING_HEIGHT, m);
+ int ey = my(MISSING_WIDTH, MISSING_HEIGHT, m);
+
+ gfx_rect(sx, sy, ex, ey, COLOR_MISSING_FG, COLOR_MISSING_BG,
+ LAYER_COMP_DWG);
+}
+
+
void lib_render(const struct comp *comp, unsigned unit, const int m[4])
{
const struct lib_obj *obj;
+ if (!comp) {
+ missing_component(m);
+ return;
+ }
if (!unit)
unit = 1;
for (obj = comp->objs; obj; obj = obj->next) {
diff --git a/sch-parse.c b/sch-parse.c
index ac15d8c..7b2e3f5 100644
--- a/sch-parse.c
+++ b/sch-parse.c
@@ -114,12 +114,12 @@ static bool parse_field(struct sch_ctx *ctx, const char *line)
&hor, &vert, &italic, &bold) != 11)
return 0;
- if (flags || !lib_field_visible(comp->comp, n)) {
+ if (flags || (comp->comp && !lib_field_visible(comp->comp, n))) {
free(field);
return 1;
}
- if (n == 0 && comp->comp->units > 1) {
+ if (n == 0 && comp->comp && comp->comp->units > 1) {
int len = strlen(txt->s);
char *s;
diff --git a/style.c b/style.c
index 3f9e472..3e0f21c 100644
--- a/style.c
+++ b/style.c
@@ -31,6 +31,7 @@ uint32_t color_rgb[] = {
[COLOR_RED3] = 0xb00000,
[COLOR_MAGENTA4] = 0x900090,
[COLOR_BROWN2] = 0xc06000,
+ [COLOR_PINK4] = 0xff8080,
/* user-defined colors */
[COLOR_DARK_YELLOW] = 0x848400,
diff --git a/style.h b/style.h
index eaa3b49..cfeba00 100644
--- a/style.h
+++ b/style.h
@@ -34,6 +34,7 @@
#define COLOR_RED3 19
#define COLOR_MAGENTA4 21
#define COLOR_BROWN2 26
+#define COLOR_PINK4 27
#define COLOR_DARK_YELLOW 32 /* user-defined */
#define COLOR_LIGHT_GREY 33 /* user-defined, not used for FIG */
@@ -54,6 +55,8 @@
#define COLOR_FIELD COLOR_CYAN4
#define COLOR_PIN_NAME COLOR_FIELD
#define COLOR_PIN_NUMBER COLOR_RED4
+#define COLOR_MISSING_FG COLOR_RED
+#define COLOR_MISSING_BG COLOR_PINK4
#define FONT_HELVETICA_BOLD 18
@@ -90,6 +93,8 @@
#define NEWLINE_SKIP 1.4 // * text size
+#define MISSING_WIDTH 300 // size of missing things indicator box
+#define MISSING_HEIGHT 300
extern uint32_t color_rgb[];