mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 19:51:53 +02:00
sch2fig/: text can contain newlines (as '\' 'n'), support them
This commit is contained in:
parent
4427d092ef
commit
7caf1fb84a
@ -568,9 +568,26 @@ bool sch_parse(struct sch_ctx *ctx, const char *line)
|
|||||||
break;
|
break;
|
||||||
case sch_text:
|
case sch_text:
|
||||||
ctx->state = sch_basic;
|
ctx->state = sch_basic;
|
||||||
if (ctx->text)
|
if (ctx->text) {
|
||||||
ctx->text(ctx->x, ctx->y, line, ctx->dir, ctx->dim,
|
const char *from;
|
||||||
|
char *to;
|
||||||
|
|
||||||
|
s = alloc_size(strlen(line) + 1);
|
||||||
|
from = line;
|
||||||
|
to = s;
|
||||||
|
while (*from) {
|
||||||
|
if (from[0] != '\\' || from[1] != 'n') {
|
||||||
|
*to++ = *from++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*to++ = '\n';
|
||||||
|
from += 2;
|
||||||
|
}
|
||||||
|
*to = 0;
|
||||||
|
ctx->text(ctx->x, ctx->y, s, ctx->dir, ctx->dim,
|
||||||
ctx->shape);
|
ctx->shape);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
case sch_wire:
|
case sch_wire:
|
||||||
if (sscanf(line, "%d %d %d %d", &x, &y, &ex, &ey) != 4)
|
if (sscanf(line, "%d %d %d %d", &x, &y, &ex, &ey) != 4)
|
||||||
|
@ -72,4 +72,6 @@
|
|||||||
#define PIN_NUM_OFFSET 15 // eeschema has more like 10
|
#define PIN_NUM_OFFSET 15 // eeschema has more like 10
|
||||||
#define HSHEET_FIELD_OFFSET 10
|
#define HSHEET_FIELD_OFFSET 10
|
||||||
|
|
||||||
|
#define NEWLINE_SKIP 1.4 // * text size
|
||||||
|
|
||||||
#endif /* !STYLE_H */
|
#endif /* !STYLE_H */
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "style.h"
|
||||||
#include "fig.h"
|
#include "fig.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
|
|
||||||
@ -93,12 +94,24 @@ static int align(int dim, enum text_align align)
|
|||||||
|
|
||||||
void text_fig(const struct text *txt, int color, unsigned layer)
|
void text_fig(const struct text *txt, int color, unsigned layer)
|
||||||
{
|
{
|
||||||
|
char *buf = stralloc(txt->s);
|
||||||
|
char *tmp = buf;
|
||||||
|
const char *s;
|
||||||
int x = txt->x;
|
int x = txt->x;
|
||||||
int y = txt->y;
|
int y = txt->y;
|
||||||
|
|
||||||
x += rx(0, align(txt->size, txt->vert), txt->rot);
|
x += rx(0, align(txt->size, txt->vert), txt->rot);
|
||||||
y += ry(0, align(txt->size, txt->vert), txt->rot);
|
y += ry(0, align(txt->size, txt->vert), txt->rot);
|
||||||
fig_text(x, y, txt->s, txt->size, txt->hor, txt->rot, color, layer);
|
while (1) {
|
||||||
|
s = strtok(tmp, "\n");
|
||||||
|
if (!s)
|
||||||
|
break;
|
||||||
|
tmp = NULL;
|
||||||
|
fig_text(x, y, s, txt->size, txt->hor, txt->rot, color, layer);
|
||||||
|
x += rx(0, NEWLINE_SKIP * txt->size, txt->rot);
|
||||||
|
y += ry(0, NEWLINE_SKIP * txt->size, txt->rot);
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user