commit c860fe8e7d3bf8e81a663424d0be84cc593e589a
parent 364b455f56cc8d45af2ae1374cc91e3b94772e1b
Author: nibo <nibo@relim.de>
Date: Sat, 12 Jul 2025 10:29:37 +0200
Use verbose enum names instead of abbreviations
Diffstat:
| M | src/chord_diagram.c | | | 64 | ++++++++++++++++++++++++++++++++-------------------------------- |
| M | src/chordpro.c | | | 1304 | +++++++++++++++++++++++++++++++++++++------------------------------------------ |
| M | src/chordpro.h | | | 92 | ++++++++++++++++++++++++++++++++++++++++--------------------------------------- |
| M | src/config.c | | | 284 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | src/core.c | | | 40 | ++++++++++++++++++++-------------------- |
| M | src/core.h | | | 214 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | src/out_pdf.c | | | 122 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | src/out_pdf.h | | | 14 | +++++++------- |
8 files changed, 1024 insertions(+), 1110 deletions(-)
diff --git a/src/chord_diagram.c b/src/chord_diagram.c
@@ -557,13 +557,13 @@ chord_diagram_free(struct ChordDiagram *d)
{
free(d->color);
switch (d->type) {
- case CDC_STRING:
+ case CHORD_DIAGRAM_CONTENT_STRING:
string_diagram_free(d->u.sd);
break;
- case CDC_KEYBOARD:
+ case CHORD_DIAGRAM_CONTENT_KEYBOARD:
keyboard_diagram_free(d->u.kd);
break;
- case CDC_CHORD_MAP:
+ case CHORD_DIAGRAM_CONTENT_CHORD_MAP:
chord_map_free(d->u.cm);
break;
default:
@@ -579,10 +579,10 @@ chord_diagram_copy_all_but_name(struct ChordDiagram *diagram)
copy->color = cho_color_copy(diagram->color);
copy->type = diagram->type;
switch (diagram->type) {
- case CDC_STRING:
+ case CHORD_DIAGRAM_CONTENT_STRING:
copy->u.sd = string_diagram_copy_all_but_name(diagram->u.sd);
break;
- case CDC_KEYBOARD:
+ case CHORD_DIAGRAM_CONTENT_KEYBOARD:
copy->u.kd = keyboard_diagram_copy_all_but_name(diagram->u.kd);
break;
default:
@@ -605,54 +605,54 @@ chord_diagram_duplicate(
int d;
for (d = custom_diagrams_len-1; d >= 0; d--) {
switch (custom_diagrams[d]->type) {
- case CDC_STRING:
+ case CHORD_DIAGRAM_CONTENT_STRING:
if (!strcmp(custom_diagrams[d]->u.sd->name, chord_to_copy)) {
- diagram->type = CDC_STRING;
+ diagram->type = CHORD_DIAGRAM_CONTENT_STRING;
diagram->u.sd = string_diagram_copy_all_but_name(custom_diagrams[d]->u.sd);
diagram->u.sd->name = strdup(name);
- return CDC_STRING;
+ return CHORD_DIAGRAM_CONTENT_STRING;
}
break;
- case CDC_KEYBOARD:
+ case CHORD_DIAGRAM_CONTENT_KEYBOARD:
if (!strcmp(custom_diagrams[d]->u.kd->name, chord_to_copy)) {
- diagram->type = CDC_KEYBOARD;
+ diagram->type = CHORD_DIAGRAM_CONTENT_KEYBOARD;
diagram->u.kd = keyboard_diagram_copy_all_but_name(custom_diagrams[d]->u.kd);
diagram->u.kd->name = strdup(name);
- return CDC_KEYBOARD;
+ return CHORD_DIAGRAM_CONTENT_KEYBOARD;
}
break;
- case CDC_CHORD_MAP:
+ case CHORD_DIAGRAM_CONTENT_CHORD_MAP:
if (!strcmp(custom_diagrams[d]->u.cm->name, chord_to_copy)) {
- diagram->type = CDC_CHORD_MAP;
+ diagram->type = CHORD_DIAGRAM_CONTENT_CHORD_MAP;
diagram->u.cm = chord_map_new();
diagram->u.cm->display = strdup(custom_diagrams[d]->u.cm->display);
diagram->u.cm->name = strdup(name);
- return CDC_CHORD_MAP;
+ return CHORD_DIAGRAM_CONTENT_CHORD_MAP;
}
break;
default:
}
}
switch (instrument) {
- case INS_GUITAR: {
+ case INSTRUMENT_GUITAR: {
size_t i;
for (i = 0; i<LENGTH(guitar_diagrams); i++) {
if (!strcmp(guitar_diagrams[i].name, chord_to_copy)) {
- diagram->type = CDC_STRING;
+ diagram->type = CHORD_DIAGRAM_CONTENT_STRING;
diagram->u.sd = string_diagram_copy_all_but_name(&guitar_diagrams[i]);
diagram->u.sd->name = strdup(name);
- return CDC_STRING;
+ return CHORD_DIAGRAM_CONTENT_STRING;
}
}
break;
}
- case INS_KEYBOARD: {
+ case INSTRUMENT_KEYBOARD: {
break;
}
- case INS_MANDOLIN: {
+ case INSTRUMENT_MANDOLIN: {
break;
}
- case INS_UKULELE: {
+ case INSTRUMENT_UKULELE: {
break;
}
}
@@ -688,7 +688,7 @@ debug_chord_diagram_print(struct ChordDiagram *diagram)
printf("color: %s\n", str);
switch (diagram->type) {
- case CDC_STRING:
+ case CHORD_DIAGRAM_CONTENT_STRING:
printf("name: %s\n", diagram->u.sd->name);
printf("base-fret: %d\n", diagram->u.sd->base_fret);
printf("frets: ");
@@ -702,7 +702,7 @@ debug_chord_diagram_print(struct ChordDiagram *diagram)
}
printf("\n");
break;
- case CDC_KEYBOARD:
+ case CHORD_DIAGRAM_CONTENT_KEYBOARD:
printf("name: %s\n", diagram->u.kd->name);
printf("keys: ");
for (i = 0; i<24; i++) {
@@ -710,7 +710,7 @@ debug_chord_diagram_print(struct ChordDiagram *diagram)
}
printf("\n");
break;
- case CDC_CHORD_MAP:
+ case CHORD_DIAGRAM_CONTENT_CHORD_MAP:
printf("name: %s\n", diagram->u.cm->name);
printf("display: %s\n", diagram->u.cm->display);
break;
@@ -735,7 +735,7 @@ chord_diagrams_create(
char **names = NULL;
char *chord_name, *parsed_chord_name, *common_chord_name;
switch (config->output->diagram->instrument) {
- case INS_GUITAR:
+ case INSTRUMENT_GUITAR:
for (c = *chords; *c; c++) {
// cho_debug_chord_print(*c);
parsed_chord_name = (*c)->name;
@@ -747,7 +747,7 @@ chord_diagrams_create(
}
for (cd = custom_diagrams; *cd; cd++) {
if (
- (*cd)->type == CDC_STRING &&
+ (*cd)->type == CHORD_DIAGRAM_CONTENT_STRING &&
string_diagram_fret_count((*cd)->u.sd) == 6 &&
!strcmp(parsed_chord_name, (*cd)->u.sd->name) &&
!strs_has(names, chord_name)
@@ -772,7 +772,7 @@ chord_diagrams_create(
strs_add(&names, chord_name);
diagrams = erealloc(diagrams, (d+1) * sizeof(struct ChordDiagram *));
diagrams[d] = chord_diagram_new();
- diagrams[d]->type = CDC_STRING;
+ diagrams[d]->type = CHORD_DIAGRAM_CONTENT_STRING;
diagrams[d]->u.sd = string_diagram_copy_all_but_name(&guitar_diagrams[i]);
diagrams[d]->u.sd->name = strdup(chord_name);
d++;
@@ -784,11 +784,11 @@ chord_diagrams_create(
free(chord_name);
}
break;
- case INS_KEYBOARD:
+ case INSTRUMENT_KEYBOARD:
break;
- case INS_MANDOLIN:
+ case INSTRUMENT_MANDOLIN:
break;
- case INS_UKULELE:
+ case INSTRUMENT_UKULELE:
break;
default:
util_log(NULL, 0, LOG_ERR, "Invalid Instrument enum value '%d'.", config->output->diagram->instrument);
@@ -810,16 +810,16 @@ chord_diagram_draw(
)
{
switch (diagram->type) {
- case CDC_STRING:
+ case CHORD_DIAGRAM_CONTENT_STRING:
if (!string_diagram_draw(ctx, stream, diagram->u.sd, x, y, width)) {
LOG_DEBUG("draw_string_chord_diagram failed.");
return false;
}
break;
- case CDC_KEYBOARD:
+ case CHORD_DIAGRAM_CONTENT_KEYBOARD:
util_log(NULL, 0, LOG_TODO, "draw_keyboard_chord_diagram()");
break;
- case CDC_CHORD_MAP:
+ case CHORD_DIAGRAM_CONTENT_CHORD_MAP:
util_log(NULL, 0, LOG_TODO, "well");
break;
default:
diff --git a/src/chordpro.c b/src/chordpro.c
@@ -19,7 +19,6 @@ static const char *font_styles[] = { "normal", "oblique", "italic" };
static const char *font_weights[] = { "normal", "bold" };
static const char *line_styles[] = { "single", "double", "none" };
static const char *chord_qualifiers[] = { "m", "", "+", "°" };
-static const char *grid_tokens[] = { "GT_CHORD", "GT_BAR_LINE_SYMBOL", "GT_PLACEHOLDER" };
static const char *section_types[] = { "", "", "chorus", "verse", "bridge", "tab", "grid", "custom" };
extern const struct InstrumentInfo instruments[];
@@ -44,30 +43,30 @@ static const char *state_enums[] = {
struct StyleProperty default_style_properties[] = {
// TODO: footer are missing
- { TT_CHORD, SPT_FONT, { .font_name = NULL } },
- { TT_CHORD, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_CHORD, SPT_COLOR, { .foreground_color = NULL } },
- { TT_CHORUS, SPT_FONT, { .font_name = NULL } },
- { TT_CHORUS, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_CHORUS, SPT_COLOR, { .foreground_color = NULL } },
- { TT_GRID, SPT_FONT, { .font_name = NULL } },
- { TT_GRID, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_GRID, SPT_COLOR, { .foreground_color = NULL } },
- { TT_TAB, SPT_FONT, { .font_name = NULL } },
- { TT_TAB, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_TAB, SPT_COLOR, { .foreground_color = NULL } },
- { TT_TEXT, SPT_FONT, { .font_name = NULL } },
- { TT_TEXT, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_TEXT, SPT_COLOR, { .foreground_color = NULL } },
- { TT_TITLE, SPT_FONT, { .font_name = NULL } },
- { TT_TITLE, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_TITLE, SPT_COLOR, { .foreground_color = NULL } },
- { TT_TOC, SPT_FONT, { .font_name = NULL } },
- { TT_TOC, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_TOC, SPT_COLOR, { .foreground_color = NULL } },
- { TT_LABEL, SPT_FONT, { .font_name = NULL } },
- { TT_LABEL, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
- { TT_LABEL, SPT_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_CHORD, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_CHORD, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_CHORD, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_CHORUS, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_CHORUS, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_CHORUS, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_GRID, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_GRID, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_GRID, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_TAB, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_TAB, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_TAB, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_TEXT, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_TEXT, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_TEXT, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_TITLE, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_TITLE, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_TITLE, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_TOC, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_TOC, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_TOC, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
+ { TEXT_TYPE_LABEL, STYLE_PROPERTY_TYPE_FONT, { .font_name = NULL } },
+ { TEXT_TYPE_LABEL, STYLE_PROPERTY_TYPE_SIZE, { .font_size = EMPTY_DOUBLE } },
+ { TEXT_TYPE_LABEL, STYLE_PROPERTY_TYPE_COLOR, { .foreground_color = NULL } },
};
static const char *chord_extensions_major[] = {
@@ -154,78 +153,78 @@ static bool g_show_info_logs = false;
#ifdef DEBUG
static const char *alignment_enums[] = {
- "A_LEFT",
- "A_CENTER",
- "A_RIGHT"
+ "ALIGNMENT_LEFT",
+ "ALIGNMENT_CENTER",
+ "ALIGNMENT_RIGHT"
};
static const char *anchor_enums[] = {
- "AN_PAPER",
- "AN_PAGE",
- "AN_COLUMN",
- "AN_LINE",
- "AN_FLOAT"
+ "ANCHOR_PAPER",
+ "ANCHOR_PAGE",
+ "ANCHOR_COLUMN",
+ "ANCHOR_LINE",
+ "ANCHOR_FLOAT"
};
static const char *chord_qualifier_enums[] = {
- "CQ_MIN",
- "CQ_MAJ",
- "CQ_AUG",
- "CQ_DIM"
+ "CHORD_QUALIFIER_MIN",
+ "CHORD_QUALIFIER_MAJ",
+ "CHORD_QUALIFIER_AUG",
+ "CHORD_QUALIFIER_DIM"
};
static const char *directive_type_enums[] = {
- "DT_ENVIRONMENT",
- "DT_METADATA",
- "DT_FORMATTING",
- "DT_IMAGE",
- "DT_PREAMBLE",
- "DT_FONT",
- "DT_CHORD",
- "DT_OUTPUT",
- "DT_EXTENSION",
- "DT_CUSTOM"
+ "DIRECTIVE_TYPE_ENVIRONMENT",
+ "DIRECTIVE_TYPE_METADATA",
+ "DIRECTIVE_TYPE_FORMATTING",
+ "DIRECTIVE_TYPE_IMAGE",
+ "DIRECTIVE_TYPE_PREAMBLE",
+ "DIRECTIVE_TYPE_FONT",
+ "DIRECTIVE_TYPE_CHORD",
+ "DIRECTIVE_TYPE_OUTPUT",
+ "DIRECTIVE_TYPE_EXTENSION",
+ "DIRECTIVE_TYPE_CUSTOM"
};
static const char *section_type_enums[] = {
- "ST_UNINITIALIZED",
- "ST_NEWSONG",
- "ST_CHORUS",
- "ST_VERSE",
- "ST_BRIDGE",
- "ST_TAB",
- "ST_GRID",
- "ST_CUSTOM"
+ "SECTION_TYPE_UNINITIALIZED",
+ "SECTION_TYPE_NEWSONG",
+ "SECTION_TYPE_CHORUS",
+ "SECTION_TYPE_VERSE",
+ "SECTION_TYPE_BRIDGE",
+ "SECTION_TYPE_TAB",
+ "SECTION_TYPE_GRID",
+ "SECTION_TYPE_CUSTOM"
};
static const char *position_enums[] = {
- "POS_START",
- "POS_END",
- "POS_NO"
+ "POSITION_START",
+ "POSITION_END",
+ "POSITION_NO"
};
static const char *text_type_enums[] = {
- "TT_CHORD",
- "TT_ANNOT",
- "TT_CHORUS",
- "TT_FOOTER",
- "TT_GRID",
- "TT_TAB",
- "TT_TOC",
- "TT_TOC_TITLE",
- "TT_TEXT",
- "TT_TITLE",
- "TT_SUBTITLE",
- "TT_LABEL",
- "TT_COMMENT",
- "TT_COMMENT_ITALIC",
- "TT_COMMENT_BOX"
+ "TEXT_TYPE_CHORD",
+ "TEXT_TYPE_ANNOT",
+ "TEXT_TYPE_CHORUS",
+ "TEXT_TYPE_FOOTER",
+ "TEXT_TYPE_GRID",
+ "TEXT_TYPE_TAB",
+ "TEXT_TYPE_TOC",
+ "TEXT_TYPE_TOC_TITLE",
+ "TEXT_TYPE_TEXT",
+ "TEXT_TYPE_TITLE",
+ "TEXT_TYPE_SUBTITLE",
+ "TEXT_TYPE_LABEL",
+ "TEXT_TYPE_COMMENT",
+ "TEXT_TYPE_COMMENT_ITALIC",
+ "TEXT_TYPE_COMMENT_BOX"
};
static const char *style_property_type_enums[] = {
- "SPT_FONT",
- "SPT_SIZE",
- "SPT_COLOR"
+ "STYLE_PROPERTY_TYPE_FONT",
+ "STYLE_PROPERTY_TYPE_SIZE",
+ "STYLE_PROPERTY_TYPE_COLOR"
};
void
@@ -554,9 +553,9 @@ cho_font_new(void)
{
struct Font *font = emalloc(sizeof(struct Font));
font->name = NULL;
- font->family = FF_NORMAL;
- font->style = FS_ROMAN;
- font->weight = FW_REGULAR;
+ font->family = FONT_FAMILY_NORMAL;
+ font->style = FONT_STYLE_ROMAN;
+ font->weight = FONT_WEIGHT_REGULAR;
font->size = DEFAULT_FONT_SIZE;
return font;
}
@@ -603,17 +602,17 @@ enum FontFamily
cho_font_family_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, font_families[FF_SANS])) {
- return FF_SANS;
- } else if (!strcmp(str, font_families[FF_SERIF])) {
- return FF_SERIF;
- } else if (!strcmp(str, font_families[FF_MONOSPACE])) {
- return FF_MONOSPACE;
- } else if (!strcmp(str, font_families[FF_NORMAL])) {
- return FF_NORMAL;
+ if (!strcmp(str, font_families[FONT_FAMILY_SANS])) {
+ return FONT_FAMILY_SANS;
+ } else if (!strcmp(str, font_families[FONT_FAMILY_SERIF])) {
+ return FONT_FAMILY_SERIF;
+ } else if (!strcmp(str, font_families[FONT_FAMILY_MONOSPACE])) {
+ return FONT_FAMILY_MONOSPACE;
+ } else if (!strcmp(str, font_families[FONT_FAMILY_NORMAL])) {
+ return FONT_FAMILY_NORMAL;
}
*error = true;
- return FF_SANS; // unused
+ return FONT_FAMILY_SANS; // unused
}
const char *
@@ -626,15 +625,15 @@ enum FontStyle
cho_font_style_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, font_styles[FS_ITALIC])) {
- return FS_ITALIC;
- } else if (!strcmp(str, font_styles[FS_OBLIQUE])) {
- return FS_OBLIQUE;
- } else if (!strcmp(str, font_styles[FS_ROMAN])) {
- return FS_ROMAN;
+ if (!strcmp(str, font_styles[FONT_STYLE_ITALIC])) {
+ return FONT_STYLE_ITALIC;
+ } else if (!strcmp(str, font_styles[FONT_STYLE_OBLIQUE])) {
+ return FONT_STYLE_OBLIQUE;
+ } else if (!strcmp(str, font_styles[FONT_STYLE_ROMAN])) {
+ return FONT_STYLE_ROMAN;
}
*error = true;
- return FS_ITALIC; // unused
+ return FONT_STYLE_ITALIC; // unused
}
const char *
@@ -647,13 +646,13 @@ enum FontWeight
cho_font_weight_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, font_weights[FW_BOLD])) {
- return FW_BOLD;
- } else if (!strcmp(str, font_weights[FW_REGULAR])) {
- return FW_REGULAR;
+ if (!strcmp(str, font_weights[FONT_WEIGHT_BOLD])) {
+ return FONT_WEIGHT_BOLD;
+ } else if (!strcmp(str, font_weights[FONT_WEIGHT_REGULAR])) {
+ return FONT_WEIGHT_REGULAR;
}
*error = true;
- return FW_BOLD; // unused
+ return FONT_WEIGHT_BOLD; // unused
}
const char *
@@ -692,15 +691,15 @@ enum LineStyle
cho_linestyle_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, line_styles[LS_SINGLE])) {
- return LS_SINGLE;
- } else if (!strcmp(str, line_styles[LS_DOUBLE])) {
- return LS_DOUBLE;
- } else if (!strcmp(str, line_styles[LS_NONE])) {
- return LS_NONE;
+ if (!strcmp(str, line_styles[LINE_STYLE_SINGLE])) {
+ return LINE_STYLE_SINGLE;
+ } else if (!strcmp(str, line_styles[LINE_STYLE_DOUBLE])) {
+ return LINE_STYLE_DOUBLE;
+ } else if (!strcmp(str, line_styles[LINE_STYLE_NONE])) {
+ return LINE_STYLE_NONE;
}
*error = true;
- return LS_SINGLE; // unused
+ return LINE_STYLE_SINGLE; // unused
}
const char *
@@ -722,16 +721,16 @@ cho_debug_the_default_style_properties(void)
style_property_type_enums[default_style_properties[i].type]
);
switch (default_style_properties[i].type) {
- case SPT_FONT:
+ case STYLE_PROPERTY_TYPE_FONT:
if (default_style_properties[i].u.font_name)
printf("%s\n", default_style_properties[i].u.font_name);
else
printf("NULL\n");
break;
- case SPT_SIZE:
+ case STYLE_PROPERTY_TYPE_SIZE:
printf("%.1f\n", default_style_properties[i].u.font_size);
break;
- case SPT_COLOR:
+ case STYLE_PROPERTY_TYPE_COLOR:
if (default_style_properties[i].u.foreground_color)
printf("%s\n", cho_rgbcolor_to_string(default_style_properties[i].u.foreground_color));
else
@@ -783,7 +782,7 @@ cho_style_property_apply_default(
default_style_properties[i].type == ptype
) {
switch (ptype) {
- case SPT_FONT:
+ case STYLE_PROPERTY_TYPE_FONT:
if (default_style_properties[i].u.font_name) {
free(style->font->name);
style->font->name = strdup(default_style_properties[i].u.font_name);
@@ -792,7 +791,7 @@ cho_style_property_apply_default(
return false;
}
break;
- case SPT_SIZE:
+ case STYLE_PROPERTY_TYPE_SIZE:
if (default_style_properties[i].u.font_size != EMPTY_DOUBLE) {
style->font->size = default_style_properties[i].u.font_size;
return true;
@@ -800,7 +799,7 @@ cho_style_property_apply_default(
return false;
}
break;
- case SPT_COLOR:
+ case STYLE_PROPERTY_TYPE_COLOR:
if (default_style_properties[i].u.foreground_color) {
free(style->foreground_color);
style->foreground_color = cho_rgbcolor_copy(default_style_properties[i].u.foreground_color);
@@ -821,20 +820,20 @@ cho_style_property_apply_default(
static void
cho_style_apply_default(struct ChoContext *ctx, enum TextType current_ttype, struct ChoStyle *style)
{
- if (current_ttype == TT_CHORUS) {
- if (!cho_style_property_apply_default(ctx, TT_CHORUS, SPT_FONT, style)) {
- cho_style_property_apply_default(ctx, TT_TEXT, SPT_FONT, style);
+ if (current_ttype == TEXT_TYPE_CHORUS) {
+ if (!cho_style_property_apply_default(ctx, TEXT_TYPE_CHORUS, STYLE_PROPERTY_TYPE_FONT, style)) {
+ cho_style_property_apply_default(ctx, TEXT_TYPE_TEXT, STYLE_PROPERTY_TYPE_FONT, style);
}
- if (!cho_style_property_apply_default(ctx, TT_CHORUS, SPT_SIZE, style)) {
- cho_style_property_apply_default(ctx, TT_TEXT, SPT_SIZE, style);
+ if (!cho_style_property_apply_default(ctx, TEXT_TYPE_CHORUS, STYLE_PROPERTY_TYPE_SIZE, style)) {
+ cho_style_property_apply_default(ctx, TEXT_TYPE_TEXT, STYLE_PROPERTY_TYPE_SIZE, style);
}
- if (!cho_style_property_apply_default(ctx, TT_CHORUS, SPT_COLOR, style)) {
- cho_style_property_apply_default(ctx, TT_TEXT, SPT_COLOR, style);
+ if (!cho_style_property_apply_default(ctx, TEXT_TYPE_CHORUS, STYLE_PROPERTY_TYPE_COLOR, style)) {
+ cho_style_property_apply_default(ctx, TEXT_TYPE_TEXT, STYLE_PROPERTY_TYPE_COLOR, style);
}
} else {
- cho_style_property_apply_default(ctx, current_ttype, SPT_FONT, style);
- cho_style_property_apply_default(ctx, current_ttype, SPT_SIZE, style);
- cho_style_property_apply_default(ctx, current_ttype, SPT_COLOR, style);
+ cho_style_property_apply_default(ctx, current_ttype, STYLE_PROPERTY_TYPE_FONT, style);
+ cho_style_property_apply_default(ctx, current_ttype, STYLE_PROPERTY_TYPE_SIZE, style);
+ cho_style_property_apply_default(ctx, current_ttype, STYLE_PROPERTY_TYPE_COLOR, style);
}
}
@@ -845,9 +844,9 @@ cho_style_new(void)
style->font = cho_font_new();
style->foreground_color = cho_rgbcolor_new(20, 20, 20);
style->background_color = cho_rgbcolor_new(255, 255, 255);
- style->underline_style = LS_NONE;
+ style->underline_style = LINE_STYLE_NONE;
style->underline_color = cho_rgbcolor_new(20, 20, 20);
- style->overline_style = LS_NONE;
+ style->overline_style = LINE_STYLE_NONE;
style->overline_color = cho_rgbcolor_new(20, 20, 20);
style->strikethrough = false;
style->strikethrough_color = cho_rgbcolor_new(20, 20, 20);
@@ -1020,48 +1019,48 @@ cho_style_font_desc_parse(const char *str, struct ChoStylePresence *presence)
int stop_at = EMPTY_INT;
for (w = 0; words[w]; w++) {
if (strcasecmp(words[w], "italic") == 0) {
- font->style = FS_ITALIC;
+ font->style = FONT_STYLE_ITALIC;
presence->font.style = true;
if (stop_at == EMPTY_INT) {
stop_at = w;
}
} else if (strcasecmp(words[w], "bold") == 0) {
- font->weight = FW_BOLD;
+ font->weight = FONT_WEIGHT_BOLD;
presence->font.weight = true;
if (stop_at == EMPTY_INT) {
stop_at = w;
}
} else if (strcasecmp(words[w], "oblique") == 0) {
- font->style = FS_OBLIQUE;
+ font->style = FONT_STYLE_OBLIQUE;
presence->font.style = true;
if (stop_at == EMPTY_INT) {
stop_at = w;
}
// TODO: Is that smart?
} else if (strcasecmp(words[w], "regular") == 0) {
- font->weight = FW_REGULAR;
+ font->weight = FONT_WEIGHT_REGULAR;
presence->font.weight = true;
if (stop_at == EMPTY_INT) {
stop_at = w;
}
// TODO: Is that smart?
} else if (strcasecmp(words[w], "normal") == 0) {
- font->style = FS_ROMAN;
+ font->style = FONT_STYLE_ROMAN;
presence->font.style = true;
if (stop_at == EMPTY_INT) {
stop_at = w;
}
/* Commented because the family name sometimes contains 'sans' or 'serif' */
/* } else if (strcasecmp(words[w], "sans") == 0) {
- font->family = FF_SANS;
+ font->family = FONT_FAMILY_SANS;
if (stop_at == EMPTY_INT)
stop_at = w;
} else if (strcasecmp(words[w], "serif") == 0) {
- font->family = FF_SERIF;
+ font->family = FONT_FAMILY_SERIF;
if (stop_at == EMPTY_INT)
stop_at = w; */
} else if (strcasecmp(words[w], "monospace") == 0) {
- font->family = FF_MONOSPACE;
+ font->family = FONT_FAMILY_MONOSPACE;
presence->font.family = true;
if (stop_at == EMPTY_INT) {
stop_at = w;
@@ -1138,16 +1137,16 @@ cho_style_parse(
!strcmp(attrs[a]->name, "face")
) {
if (!strcmp(attrs[a]->value, "normal")) {
- style->font->family = FF_NORMAL;
+ style->font->family = FONT_FAMILY_NORMAL;
presence->font.family = true;
} else if (!strcmp(attrs[a]->value, "sans")) {
- style->font->family = FF_SANS;
+ style->font->family = FONT_FAMILY_SANS;
presence->font.family = true;
} else if (!strcmp(attrs[a]->value, "serif")) {
- style->font->family = FF_SERIF;
+ style->font->family = FONT_FAMILY_SERIF;
presence->font.family = true;
} else if (!strcmp(attrs[a]->value, "monospace")) {
- style->font->family = FF_MONOSPACE;
+ style->font->family = FONT_FAMILY_MONOSPACE;
presence->font.family = true;
} else {
cho_log(ctx, LOG_ERR, "Attribute 'font_family/face' of markup tag '%s' has an invalid value '%s'.", tag_name, attrs[a]->value);
@@ -1217,13 +1216,13 @@ cho_style_parse(
}
} else if (!strcmp(attrs[a]->name, "style")) {
if (!strcmp(attrs[a]->value, "normal")) {
- style->font->style = FS_ROMAN;
+ style->font->style = FONT_STYLE_ROMAN;
presence->font.style = true;
} else if (!strcmp(attrs[a]->value, "oblique")) {
- style->font->style = FS_OBLIQUE;
+ style->font->style = FONT_STYLE_OBLIQUE;
presence->font.style = true;
} else if (!strcmp(attrs[a]->value, "italic")) {
- style->font->style = FS_ITALIC;
+ style->font->style = FONT_STYLE_ITALIC;
presence->font.style = true;
} else {
cho_log(ctx, LOG_ERR, "Attribute 'style' of markup tag '%s' has an invalid value '%s'.", tag_name, attrs[a]->value);
@@ -1231,10 +1230,10 @@ cho_style_parse(
}
} else if (!strcmp(attrs[a]->name, "weight")) {
if (!strcmp(attrs[a]->value, "normal")) {
- style->font->weight = FW_REGULAR;
+ style->font->weight = FONT_WEIGHT_REGULAR;
presence->font.weight = true;
} else if (!strcmp(attrs[a]->value, "bold")) {
- style->font->weight = FW_BOLD;
+ style->font->weight = FONT_WEIGHT_BOLD;
presence->font.weight = true;
} else {
cho_log(ctx, LOG_ERR, "Attribute 'weight' of markup tag '%s' has an invalid value '%s'.", tag_name, attrs[a]->value);
@@ -1264,13 +1263,13 @@ cho_style_parse(
}
} else if (!strcmp(attrs[a]->name, "underline")) {
if (!strcmp(attrs[a]->value, "single")) {
- style->underline_style = LS_SINGLE;
+ style->underline_style = LINE_STYLE_SINGLE;
presence->underline_style = true;
} else if (!strcmp(attrs[a]->value, "double")) {
- style->underline_style = LS_DOUBLE;
+ style->underline_style = LINE_STYLE_DOUBLE;
presence->underline_style = true;
} else if (!strcmp(attrs[a]->value, "none")) {
- style->underline_style = LS_NONE;
+ style->underline_style = LINE_STYLE_NONE;
presence->underline_style = true;
} else {
cho_log(ctx, LOG_ERR, "Attribute 'underline' of markup tag '%s' has an invalid value '%s'.", tag_name, attrs[a]->value);
@@ -1289,13 +1288,13 @@ cho_style_parse(
}
} else if (!strcmp(attrs[a]->name, "overline")) {
if (!strcmp(attrs[a]->value, "single")) {
- style->overline_style = LS_SINGLE;
+ style->overline_style = LINE_STYLE_SINGLE;
presence->overline_style = true;
} else if (!strcmp(attrs[a]->value, "double")) {
- style->overline_style = LS_DOUBLE;
+ style->overline_style = LINE_STYLE_DOUBLE;
presence->overline_style = true;
} else if (!strcmp(attrs[a]->value, "none")) {
- style->overline_style = LS_NONE;
+ style->overline_style = LINE_STYLE_NONE;
presence->overline_style = true;
} else {
cho_log(ctx, LOG_ERR, "Attribute 'overline' of markup tag '%s' has an invalid value '%s'.", tag_name, attrs[a]->value);
@@ -1401,13 +1400,13 @@ cho_style_parse(
}
}
} else if (!strcmp(tag_name, "b")) {
- style->font->weight = FW_BOLD;
+ style->font->weight = FONT_WEIGHT_BOLD;
presence->font.weight = true;
} else if (!strcmp(tag_name, "big")) {
style->font->size *= 0.8;
presence->font.size = true;
} else if (!strcmp(tag_name, "i")) {
- style->font->style = FS_ITALIC;
+ style->font->style = FONT_STYLE_ITALIC;
presence->font.style = true;
} else if (!strcmp(tag_name, "s")) {
style->strikethrough = true;
@@ -1426,10 +1425,10 @@ cho_style_parse(
style->font->size *= 0.8;
presence->font.size = true;
} else if (!strcmp(tag_name, "tt")) {
- style->font->family = FF_MONOSPACE;
+ style->font->family = FONT_FAMILY_MONOSPACE;
presence->font.family = true;
} else if (!strcmp(tag_name, "u")) {
- style->underline_style = LS_SINGLE;
+ style->underline_style = LINE_STYLE_SINGLE;
presence->underline_style = true;
} else {
cho_log(ctx, LOG_ERR, "Markup tag '%s' is invalid.", tag_name);
@@ -1467,7 +1466,7 @@ cho_style_change_default(struct ChoContext *ctx, struct StyleProperty sprop)
default_style_properties[i].type == sprop.type
) {
switch (sprop.type) {
- case SPT_FONT:
+ case STYLE_PROPERTY_TYPE_FONT:
free(default_style_properties[i].u.font_name);
if (sprop.u.font_name) {
default_style_properties[i].u.font_name = strdup(sprop.u.font_name);
@@ -1475,10 +1474,10 @@ cho_style_change_default(struct ChoContext *ctx, struct StyleProperty sprop)
default_style_properties[i].u.font_name = NULL;
}
return true;
- case SPT_SIZE:
+ case STYLE_PROPERTY_TYPE_SIZE:
default_style_properties[i].u.font_size = sprop.u.font_size;
return true;
- case SPT_COLOR:
+ case STYLE_PROPERTY_TYPE_COLOR:
free(default_style_properties[i].u.foreground_color);
if (sprop.u.foreground_color) {
default_style_properties[i].u.foreground_color = cho_rgbcolor_copy(sprop.u.foreground_color);
@@ -1501,14 +1500,14 @@ cho_style_reset_default(struct ChoContext *ctx)
unsigned int i;
for (i = 0; i<LENGTH(default_style_properties); i++) {
switch (default_style_properties[i].type) {
- case SPT_FONT:
+ case STYLE_PROPERTY_TYPE_FONT:
free(default_style_properties[i].u.font_name);
default_style_properties[i].u.font_name = NULL;
return true;
- case SPT_SIZE:
+ case STYLE_PROPERTY_TYPE_SIZE:
default_style_properties[i].u.font_size = EMPTY_DOUBLE;
return true;
- case SPT_COLOR:
+ case STYLE_PROPERTY_TYPE_COLOR:
free(default_style_properties[i].u.foreground_color);
default_style_properties[i].u.foreground_color = NULL;
return true;
@@ -1923,8 +1922,8 @@ cho_metadata_substitution_parse(
o++;
}
- enum MetadataSubstitutionState state = MSS_NAME;
- enum AttrValueSyntax avs = AVS_UNINITIALIZED;
+ enum MetadataSubstitutionState state = METADATA_SUBSTITUTION_STATE_NAME;
+ enum AttrValueSyntax avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
char name[128];
char name_index[8];
char value[4096];
@@ -1953,34 +1952,34 @@ cho_metadata_substitution_parse(
}
switch (state) {
- case MSS_NAME: {
+ case METADATA_SUBSTITUTION_STATE_NAME: {
if (c == '=') {
name[n] = 0;
n = 0;
- state = MSS_VALUE;
+ state = METADATA_SUBSTITUTION_STATE_VALUE;
break;
}
if (c == '.') {
name[n] = 0;
- state = MSS_NAME_OR_INDEX;
+ state = METADATA_SUBSTITUTION_STATE_NAME_OR_INDEX;
break;
}
if (prev_c != '\\' && c == '|') {
name[n] = 0;
n = 0;
- state = MSS_TRUE_TEXT;
+ state = METADATA_SUBSTITUTION_STATE_TRUE_TEXT;
break;
}
name[n] = c;
n++;
break;
}
- case MSS_NAME_OR_INDEX: {
+ case METADATA_SUBSTITUTION_STATE_NAME_OR_INDEX: {
if (c == '-' || isdigit(c)) {
n = 0;
name_index[n] = c;
n++;
- state = MSS_INDEX;
+ state = METADATA_SUBSTITUTION_STATE_INDEX;
break;
} else
if (islower(c)) {
@@ -1988,23 +1987,23 @@ cho_metadata_substitution_parse(
n++;
name[n] = c;
n++;
- state = MSS_NAME;
+ state = METADATA_SUBSTITUTION_STATE_NAME;
break;
}
cho_log(ctx, LOG_ERR, "Invalid character after the dot.");
return NULL;
}
- case MSS_INDEX: {
+ case METADATA_SUBSTITUTION_STATE_INDEX: {
if (c == '=') {
name_index[n] = 0;
n = 0;
- state = MSS_VALUE;
+ state = METADATA_SUBSTITUTION_STATE_VALUE;
break;
}
if (prev_c != '\\' && c == '|') {
name_index[n] = 0;
n = 0;
- state = MSS_TRUE_TEXT;
+ state = METADATA_SUBSTITUTION_STATE_TRUE_TEXT;
break;
}
if (!isdigit(c)) {
@@ -2016,8 +2015,8 @@ cho_metadata_substitution_parse(
n++;
break;
}
- case MSS_VALUE: {
- if (avs == AVS_UNINITIALIZED) {
+ case METADATA_SUBSTITUTION_STATE_VALUE: {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED) {
if (is_whitespace(c)) {
cho_log(ctx, LOG_ERR, "Whitespace character after equals sign is invalid.");
return NULL;
@@ -2027,73 +2026,73 @@ cho_metadata_substitution_parse(
return NULL;
}
if (c == '\'') {
- avs = AVS_APOSTROPHE;
+ avs = ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE;
} else if (c == '"') {
- avs = AVS_QUOTATION_MARK;
+ avs = ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK;
} else {
- avs = AVS_UNQUOTED;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNQUOTED;
value[n] = c;
n++;
}
break;
}
if (prev_c != '\\' && c == '|') {
- if (avs == AVS_APOSTROPHE) {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE) {
cho_log(ctx, LOG_ERR, "Can't find a matching \"\'\".");
return NULL;
}
- if (avs == AVS_QUOTATION_MARK) {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK) {
cho_log(ctx, LOG_ERR, "Can't find a matching '\"'.");
return NULL;
}
- if (avs == AVS_UNQUOTED) {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED) {
value[n] = 0;
n = 0;
- state = MSS_TRUE_TEXT;
+ state = METADATA_SUBSTITUTION_STATE_TRUE_TEXT;
break;
}
- if (avs == AVS_UNINITIALIZED) {
- state = MSS_TRUE_TEXT;
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED) {
+ state = METADATA_SUBSTITUTION_STATE_TRUE_TEXT;
break;
}
break;
}
if (
- (avs == AVS_APOSTROPHE && c == '\'') ||
- (avs == AVS_QUOTATION_MARK && c == '"') ||
- (avs == AVS_UNQUOTED && c == ' ')
+ (avs == ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE && c == '\'') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK && c == '"') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED && c == ' ')
) {
value[n] = 0;
n = 0;
- state = MSS_WAIT_FOR_PIPE;
+ state = METADATA_SUBSTITUTION_STATE_WAIT_FOR_PIPE;
break;
}
value[n] = c;
n++;
break;
}
- case MSS_TRUE_TEXT: {
+ case METADATA_SUBSTITUTION_STATE_TRUE_TEXT: {
if (prev_c != '\\' && c == '|' && nested_level == 0) {
true_text[n] = 0;
n = 0;
- state = MSS_FALSE_TEXT;
+ state = METADATA_SUBSTITUTION_STATE_FALSE_TEXT;
break;
}
true_text[n] = c;
n++;
break;
}
- case MSS_FALSE_TEXT: {
+ case METADATA_SUBSTITUTION_STATE_FALSE_TEXT: {
false_text[n] = c;
n++;
break;
}
- case MSS_WAIT_FOR_PIPE: {
+ case METADATA_SUBSTITUTION_STATE_WAIT_FOR_PIPE: {
if (is_whitespace(c)) {
break;
}
if (c == '|') {
- state = MSS_TRUE_TEXT;
+ state = METADATA_SUBSTITUTION_STATE_TRUE_TEXT;
break;
}
break;
@@ -2102,30 +2101,30 @@ cho_metadata_substitution_parse(
prev_c = c;
}
switch (state) {
- case MSS_NAME:
+ case METADATA_SUBSTITUTION_STATE_NAME:
name[n] = 0;
break;
- case MSS_INDEX:
+ case METADATA_SUBSTITUTION_STATE_INDEX:
name_index[n] = 0;
break;
- case MSS_VALUE:
+ case METADATA_SUBSTITUTION_STATE_VALUE:
switch (avs) {
- case AVS_APOSTROPHE:
+ case ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE:
cho_log(ctx, LOG_ERR, "Can't find a matching \"\'\".");
return NULL;
- case AVS_QUOTATION_MARK:
+ case ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK:
cho_log(ctx, LOG_ERR, "Can't find a matching '\"'.");
return NULL;
- case AVS_UNQUOTED:
+ case ATTRIBUTE_VALUE_SYNTAX_UNQUOTED:
value[n] = 0;
break;
default:
}
break;
- case MSS_TRUE_TEXT:
+ case METADATA_SUBSTITUTION_STATE_TRUE_TEXT:
true_text[n] = 0;
break;
- case MSS_FALSE_TEXT:
+ case METADATA_SUBSTITUTION_STATE_FALSE_TEXT:
false_text[n] = 0;
break;
default:
@@ -2229,11 +2228,11 @@ transposition_calc_chord_root(struct ChoContext *ctx, int index, enum NoteType t
int transpose = *ctx->transpose;
if (transpose == 0) {
switch (type) {
- case NT_NOTE:
+ case NOTE_TYPE_NOTE:
return strdup(ctx->config->output->notes[index]->note);
- case NT_SHARP:
+ case NOTE_TYPE_SHARP:
return strdup(ctx->config->output->notes[index]->sharp);
- case NT_FLAT:
+ case NOTE_TYPE_FLAT:
return strdup(ctx->config->output->notes[index]->flat);
}
}
@@ -2243,7 +2242,7 @@ transposition_calc_chord_root(struct ChoContext *ctx, int index, enum NoteType t
if (transpose > 0) {
for (i = 0; i<transpose; i++) {
switch (note_type) {
- case NT_NOTE:
+ case NOTE_TYPE_NOTE:
switch (new_index) {
case 2:
new_index++;
@@ -2252,22 +2251,22 @@ transposition_calc_chord_root(struct ChoContext *ctx, int index, enum NoteType t
new_index = 0;
break;
default:
- note_type = NT_SHARP;
+ note_type = NOTE_TYPE_SHARP;
}
break;
- case NT_SHARP:
+ case NOTE_TYPE_SHARP:
new_index++;
- note_type = NT_NOTE;
+ note_type = NOTE_TYPE_NOTE;
break;
- case NT_FLAT:
- note_type = NT_NOTE;
+ case NOTE_TYPE_FLAT:
+ note_type = NOTE_TYPE_NOTE;
break;
}
}
} else {
for (i = transpose; i<0; i++) {
switch (note_type) {
- case NT_NOTE:
+ case NOTE_TYPE_NOTE:
switch (new_index) {
case 0:
new_index = 6;
@@ -2276,25 +2275,25 @@ transposition_calc_chord_root(struct ChoContext *ctx, int index, enum NoteType t
new_index--;
break;
default:
- note_type = NT_FLAT;
+ note_type = NOTE_TYPE_FLAT;
}
break;
- case NT_SHARP:
- note_type = NT_NOTE;
+ case NOTE_TYPE_SHARP:
+ note_type = NOTE_TYPE_NOTE;
break;
- case NT_FLAT:
+ case NOTE_TYPE_FLAT:
new_index--;
- note_type = NT_NOTE;
+ note_type = NOTE_TYPE_NOTE;
break;
}
}
}
switch (note_type) {
- case NT_NOTE:
+ case NOTE_TYPE_NOTE:
return strdup(ctx->config->output->notes[new_index]->note);
- case NT_SHARP:
+ case NOTE_TYPE_SHARP:
return strdup(ctx->config->output->notes[new_index]->sharp);
- case NT_FLAT:
+ case NOTE_TYPE_FLAT:
return strdup(ctx->config->output->notes[new_index]->flat);
}
cho_log(ctx, LOG_ERR, "Invalid NoteType '%d'.", note_type);
@@ -2443,7 +2442,7 @@ cho_chord_root_parse(struct ChoContext *ctx, const char *str, struct ChoChord *c
for (i = 0; i<7; i++) {
sharp = ctx->config->parser->notes[i]->sharp;
if (sharp && str_starts_with(str, sharp)) {
- transposed_root = transposition_calc_chord_root(ctx, i, NT_SHARP);
+ transposed_root = transposition_calc_chord_root(ctx, i, NOTE_TYPE_SHARP);
if (!transposed_root) {
LOG_DEBUG("transposition_calc_chord_root failed.");
return 0;
@@ -2453,7 +2452,7 @@ cho_chord_root_parse(struct ChoContext *ctx, const char *str, struct ChoChord *c
}
flat = ctx->config->parser->notes[i]->flat;
if (flat && str_starts_with(str, flat)) {
- transposed_root = transposition_calc_chord_root(ctx, i, NT_FLAT);
+ transposed_root = transposition_calc_chord_root(ctx, i, NOTE_TYPE_FLAT);
if (!transposed_root) {
LOG_DEBUG("transposition_calc_chord_root failed.");
return 0;
@@ -2463,7 +2462,7 @@ cho_chord_root_parse(struct ChoContext *ctx, const char *str, struct ChoChord *c
}
note = ctx->config->parser->notes[i]->note;
if (str_starts_with(str, note)) {
- transposed_root = transposition_calc_chord_root(ctx, i, NT_NOTE);
+ transposed_root = transposition_calc_chord_root(ctx, i, NOTE_TYPE_NOTE);
if (!transposed_root) {
LOG_DEBUG("transposition_calc_chord_root failed.");
return 0;
@@ -2491,35 +2490,35 @@ cho_chord_qualifier_and_extension_parse(const char *str, struct ChoChord *chord)
for (i = 0; chord_extensions_major[i]; i++) {
if (str_starts_with(str, chord_extensions_major[i])) {
chord->ext = strdup(chord_extensions_major[i]);
- chord->qual = CQ_MAJ;
+ chord->qual = CHORD_QUALIFIER_MAJ;
return strlen(chord_extensions_major[i]);
}
}
for (i = 0; chord_extensions_minor[i]; i++) {
if (str_starts_with(str, chord_extensions_minor[i])) {
chord->ext = cho_chord_qualifier_strip(chord_extensions_minor[i]);
- chord->qual = CQ_MIN;
+ chord->qual = CHORD_QUALIFIER_MIN;
return strlen(chord_extensions_minor[i]);
}
}
if (str_starts_with(str, "aug")) {
- chord->qual = CQ_AUG;
+ chord->qual = CHORD_QUALIFIER_AUG;
return 3;
}
if (str_starts_with(str, "+")) {
- chord->qual = CQ_AUG;
+ chord->qual = CHORD_QUALIFIER_AUG;
return 1;
}
if (str_starts_with(str, "dim")) {
- chord->qual = CQ_DIM;
+ chord->qual = CHORD_QUALIFIER_DIM;
return 3;
}
if (str_starts_with(str, "0")) {
- chord->qual = CQ_DIM;
+ chord->qual = CHORD_QUALIFIER_DIM;
return 1;
}
if (str_starts_with(str, "ø")) {
- chord->qual = CQ_DIM;
+ chord->qual = CHORD_QUALIFIER_DIM;
return 1;
}
// TODO: What about 'ø', 'h', 'h7' and 'h9'?
@@ -2571,7 +2570,7 @@ cho_chord_parse(struct ChoContext *ctx, const char *str)
for (i = 0; i<ctx->dia; i++) {
diagram = ctx->songs[ctx->so]->diagrams[i];
if (
- diagram->type == CDC_CHORD_MAP &&
+ diagram->type == CHORD_DIAGRAM_CONTENT_CHORD_MAP &&
!strcmp(str, diagram->u.cm->name)
) {
chord->display = strdup(diagram->u.cm->display);
@@ -2585,7 +2584,7 @@ cho_chord_parse(struct ChoContext *ctx, const char *str)
if (ret == 0) {
return chord;
}
- chord->qual = CQ_MAJ;
+ chord->qual = CHORD_QUALIFIER_MAJ;
bytes_parsed += ret;
if (bytes_parsed == str_len) {
chord->is_canonical = true;
@@ -2735,13 +2734,13 @@ cho_image_new(void)
image->height = NULL;
image->width_scale = NULL;
image->height_scale = NULL;
- image->align = A_CENTER;
+ image->align = ALIGNMENT_CENTER;
image->border = EMPTY_DOUBLE;
image->spread_space = NULL;
image->href = NULL;
image->x = NULL;
image->y = NULL;
- image->anchor = AN_FLOAT;
+ image->anchor = ANCHOR_FLOAT;
image->dx = NULL;
image->dy = NULL;
image->w = NULL;
@@ -2916,7 +2915,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'width' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'width' in image directive. Allowed types are: points, percentage.");
return false;
}
@@ -2928,7 +2927,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'height' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'height' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -2943,7 +2942,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'scale' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'scale' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -2953,7 +2952,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'scale' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'scale' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -2964,7 +2963,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'scale' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'scale' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -2974,13 +2973,13 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
} else
if (!strcmp(name, "align")) {
if (!strcmp(value, "left")) {
- image->align = A_LEFT;
+ image->align = ALIGNMENT_LEFT;
} else
if (!strcmp(value, "right")) {
- image->align = A_RIGHT;
+ image->align = ALIGNMENT_RIGHT;
} else
if (!strcmp(value, "center")) {
- image->align = A_CENTER;
+ image->align = ALIGNMENT_CENTER;
} else {
cho_log(ctx, LOG_ERR, "Invalid value in option 'align' in image directive.");
return false;
@@ -2999,7 +2998,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'spread' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'spread' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -3014,7 +3013,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'x' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'x' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -3026,7 +3025,7 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
cho_log(ctx, LOG_ERR, "Invalid value in option 'y' in image directive.");
return false;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in option 'y' in image directive. Allowed types are: point, percentage.");
return false;
}
@@ -3034,19 +3033,19 @@ cho_image_option_parse(struct ChoContext *ctx, struct ChoImage *image, const cha
} else
if (!strcmp(name, "anchor")) {
if (!strcmp(value, "paper")) {
- image->anchor = AN_PAPER;
+ image->anchor = ANCHOR_PAPER;
} else
if (!strcmp(value, "page")) {
- image->anchor = AN_PAGE;
+ image->anchor = ANCHOR_PAGE;
} else
if (!strcmp(value, "column")) {
- image->anchor = AN_COLUMN;
+ image->anchor = ANCHOR_COLUMN;
} else
if (!strcmp(value, "line")) {
- image->anchor = AN_LINE;
+ image->anchor = ANCHOR_LINE;
} else
if (!strcmp(value, "float")) {
- image->anchor = AN_FLOAT;
+ image->anchor = ANCHOR_FLOAT;
} else {
cho_log(ctx, LOG_ERR, "Invalid value in option 'anchor' in image directive.");
return false;
@@ -3061,8 +3060,8 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
struct ChoImage *image = cho_image_new();
struct ChoImage *asset;
char c;
- enum OptionState state = OS_NAME;
- enum AttrValueSyntax avs = AVS_UNINITIALIZED;
+ enum OptionState state = OPTION_STATE_NAME;
+ enum AttrValueSyntax avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
char name[6+1];
char value[URL_MAX_LEN+1];
int n = 0;
@@ -3074,7 +3073,7 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
for (i = 0; str[i]; i++) {
c = str[i];
switch (state) {
- case OS_NAME:
+ case OPTION_STATE_NAME:
if (is_whitespace(c)) {
if (n == 0) {
break;
@@ -3086,7 +3085,7 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
}
if (c == '=') {
name[n] = 0;
- state = OS_VALUE;
+ state = OPTION_STATE_VALUE;
break;
}
if (n > 5) {
@@ -3096,18 +3095,18 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
name[n] = c;
n++;
break;
- case OS_VALUE:
- if (avs == AVS_UNINITIALIZED) {
+ case OPTION_STATE_VALUE:
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED) {
if (is_whitespace(c)) {
cho_log(ctx, LOG_ERR, "Whitespace character after equals sign in image directive is invalid.");
return NULL;
}
if (c == '\'') {
- avs = AVS_APOSTROPHE;
+ avs = ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE;
} else if (c == '"') {
- avs = AVS_QUOTATION_MARK;
+ avs = ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK;
} else {
- avs = AVS_UNQUOTED;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNQUOTED;
value[v] = c;
v++;
}
@@ -3118,9 +3117,9 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
return NULL;
}
if (
- (avs == AVS_APOSTROPHE && c == '\'') ||
- (avs == AVS_QUOTATION_MARK && c == '"') ||
- (avs == AVS_UNQUOTED && (c == ' ' || c == '\t'))
+ (avs == ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE && c == '\'') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK && c == '"') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED && (c == ' ' || c == '\t'))
) {
value[v] = 0;
if (!cho_image_option_parse(ctx, image, name, value)) {
@@ -3132,8 +3131,8 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
memset(value, 0, v);
n = 0;
v = 0;
- avs = AVS_UNINITIALIZED;
- state = OS_NAME;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
+ state = OPTION_STATE_NAME;
break;
}
value[v] = c;
@@ -3141,7 +3140,7 @@ cho_image_directive_parse(struct ChoContext *ctx, const char *str)
break;
}
}
- if (avs == AVS_UNQUOTED) {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED) {
value[v] = 0;
if (!cho_image_option_parse(ctx, image, name, value)) {
LOG_DEBUG("cho_image_option_parse failed.");
@@ -3192,7 +3191,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'width' in 'img' tag.");
return NULL;
}
- if (size->type == ST_PERCENT) {
+ if (size->type == SIZE_TYPE_PERCENT) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'width' in 'img' tag. Allowed types are: point, em, ex.");
return NULL;
}
@@ -3204,7 +3203,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'height' in 'img' tag.");
return NULL;
}
- if (size->type == ST_PERCENT) {
+ if (size->type == SIZE_TYPE_PERCENT) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'height' in 'img' tag. Allowed types are: point, em, ex.");
return NULL;
}
@@ -3216,7 +3215,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'dx' in 'img' tag.");
return NULL;
}
- if (size->type == ST_PERCENT) {
+ if (size->type == SIZE_TYPE_PERCENT) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'dx' in 'img' tag. Allowed types are: point, em, ex.");
return NULL;
}
@@ -3228,7 +3227,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'dy' in 'img' tag.");
return NULL;
}
- if (size->type == ST_PERCENT) {
+ if (size->type == SIZE_TYPE_PERCENT) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'dy' in 'img' tag. Allowed types are: point, em, ex.");
return NULL;
}
@@ -3243,7 +3242,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'scale' in 'img' tag.");
return NULL;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'scale' in 'img' tag. Allowed types are: point, percent");
return NULL;
}
@@ -3253,7 +3252,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'scale' in 'img' tag.");
return NULL;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'scale' in 'img' tag. Allowed types are: point, percent");
return NULL;
}
@@ -3264,7 +3263,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'scale' in 'img' tag.");
return NULL;
}
- if (size->type == ST_EM || size->type == ST_EX) {
+ if (size->type == SIZE_TYPE_EM || size->type == SIZE_TYPE_EX) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'scale' in 'img' tag. Allowed types are: point, percent");
return NULL;
}
@@ -3274,13 +3273,13 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
} else
if (!strcmp(attrs[a]->name, "align")) {
if (!strcmp(attrs[a]->value, "left")) {
- image->align = A_LEFT;
+ image->align = ALIGNMENT_LEFT;
} else
if (!strcmp(attrs[a]->value, "right")) {
- image->align = A_RIGHT;
+ image->align = ALIGNMENT_RIGHT;
} else
if (!strcmp(attrs[a]->value, "center")) {
- image->align = A_CENTER;
+ image->align = ALIGNMENT_CENTER;
} else {
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'align' in 'img' tag.");
return NULL;
@@ -3303,7 +3302,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'w' in 'img' tag.");
return NULL;
}
- if (size->type != ST_POINT) {
+ if (size->type != SIZE_TYPE_POINT) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'w' in 'img' tag. Allowed type is: point");
return NULL;
}
@@ -3315,7 +3314,7 @@ cho_image_tag_parse(struct ChoContext *ctx, struct Attr **attrs)
cho_log(ctx, LOG_ERR, "Invalid value in attribute 'h' in 'img' tag.");
return NULL;
}
- if (size->type != ST_POINT) {
+ if (size->type != SIZE_TYPE_POINT) {
cho_log(ctx, LOG_ERR, "Invalid type of value in attribute 'h' in 'img' tag. Allowed type is: point");
return NULL;
}
@@ -3379,9 +3378,9 @@ cho_chord_diagram_parse(
)
{
struct ChordDiagram *diagram = chord_diagram_new();
- enum ChordDiagramState state = CDS_NAME;
- enum ChordDiagramContent current_content = CDC_UNINITIALIZED;
- enum ChordDiagramContent future_content = CDC_UNINITIALIZED;
+ enum ChordDiagramState state = CHORD_DIAGRAM_STATE_NAME;
+ enum ChordDiagramContent current_content = CHORD_DIAGRAM_CONTENT_UNINITIALIZED;
+ enum ChordDiagramContent future_content = CHORD_DIAGRAM_CONTENT_UNINITIALIZED;
bool is_maybe_minus_one = false;
char name[20];
char option[10];
@@ -3400,14 +3399,14 @@ cho_chord_diagram_parse(
for (c = str; *c; c++){
// printf("c '%c' state '%d'\n", c, state);
switch (state) {
- case CDS_NAME: {
+ case CHORD_DIAGRAM_STATE_NAME: {
if (is_whitespace(*c)) {
if (i == 0) {
break;
}
name[i] = 0;
i = 0;
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
break;
}
if (i > 18) {
@@ -3418,59 +3417,62 @@ cho_chord_diagram_parse(
i++;
break;
}
- case CDS_OPTION_NAME: {
+ case CHORD_DIAGRAM_STATE_OPTION_NAME: {
if (is_whitespace(*c)) {
if (i == 0) {
break;
}
option[i] = 0;
- future_content = CDC_UNINITIALIZED;
+ future_content = CHORD_DIAGRAM_CONTENT_UNINITIALIZED;
if (!strcmp(option, "base-fret")) {
- state = CDS_BASE_FRET;
- future_content = CDC_STRING;
+ state = CHORD_DIAGRAM_STATE_BASE_FRET;
+ future_content = CHORD_DIAGRAM_CONTENT_STRING;
} else
if (!strcmp(option, "frets")) {
- state = CDS_FRETS;
- future_content = CDC_STRING;
+ state = CHORD_DIAGRAM_STATE_FRETS;
+ future_content = CHORD_DIAGRAM_CONTENT_STRING;
} else
if (!strcmp(option, "fingers")) {
- state = CDS_FINGERS;
- future_content = CDC_STRING;
+ state = CHORD_DIAGRAM_STATE_FINGERS;
+ future_content = CHORD_DIAGRAM_CONTENT_STRING;
} else
if (!strcmp(option, "keys")) {
- state = CDS_KEYS;
- future_content = CDC_KEYBOARD;
+ state = CHORD_DIAGRAM_STATE_KEYS;
+ future_content = CHORD_DIAGRAM_CONTENT_KEYBOARD;
} else
if (!strcmp(option, "diagram")) {
- state = CDS_DIAGRAM;
+ state = CHORD_DIAGRAM_STATE_DIAGRAM;
} else
if (!strcmp(option, "copy")) {
- state = CDS_COPY;
+ state = CHORD_DIAGRAM_STATE_COPY;
} else
if (!strcmp(option, "display")) {
- state = CDS_DISPLAY;
- future_content = CDC_CHORD_MAP;
+ state = CHORD_DIAGRAM_STATE_DISPLAY;
+ future_content = CHORD_DIAGRAM_CONTENT_CHORD_MAP;
} else {
cho_log(ctx, LOG_ERR, "Invalid option '%s' in define directive.", option);
return NULL;
}
memset(option, 0, i);
i = 0;
- if (current_content == CDC_UNINITIALIZED && future_content != CDC_UNINITIALIZED) {
+ if (
+ current_content == CHORD_DIAGRAM_CONTENT_UNINITIALIZED &&
+ future_content != CHORD_DIAGRAM_CONTENT_UNINITIALIZED
+ ) {
current_content = future_content;
switch (future_content) {
- case CDC_STRING:
- diagram->type = CDC_STRING;
+ case CHORD_DIAGRAM_CONTENT_STRING:
+ diagram->type = CHORD_DIAGRAM_CONTENT_STRING;
diagram->u.sd = string_diagram_new();
diagram->u.sd->name = strdup(name);
break;
- case CDC_KEYBOARD:
- diagram->type = CDC_KEYBOARD;
+ case CHORD_DIAGRAM_CONTENT_KEYBOARD:
+ diagram->type = CHORD_DIAGRAM_CONTENT_KEYBOARD;
diagram->u.kd = keyboard_diagram_new();
diagram->u.kd->name = strdup(name);
break;
- case CDC_CHORD_MAP:
- diagram->type = CDC_CHORD_MAP;
+ case CHORD_DIAGRAM_CONTENT_CHORD_MAP:
+ diagram->type = CHORD_DIAGRAM_CONTENT_CHORD_MAP;
diagram->u.cm = chord_map_new();
diagram->u.cm->name = strdup(name);
break;
@@ -3488,7 +3490,7 @@ cho_chord_diagram_parse(
i++;
break;
}
- case CDS_BASE_FRET: {
+ case CHORD_DIAGRAM_STATE_BASE_FRET: {
if (is_whitespace(*c)) {
if (i == 0) {
break;
@@ -3506,7 +3508,7 @@ cho_chord_diagram_parse(
return NULL;
}
diagram->u.sd->base_fret = (int8_t)l;
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
break;
}
if (i > 1) {
@@ -3518,7 +3520,7 @@ cho_chord_diagram_parse(
i++;
break;
}
- case CDS_FRETS: {
+ case CHORD_DIAGRAM_STATE_FRETS: {
number = -2;
if (is_whitespace(*c)) {
break;
@@ -3541,7 +3543,7 @@ cho_chord_diagram_parse(
} else
if (isalpha(*c)) {
f = 0;
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
c--;
break;
}
@@ -3562,13 +3564,13 @@ cho_chord_diagram_parse(
fret_count++;
break;
}
- case CDS_FINGERS: {
+ case CHORD_DIAGRAM_STATE_FINGERS: {
if (is_whitespace(*c)) {
break;
}
if (*c == 'b' || *c == 'f') {
f = 0;
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
c--;
break;
}
@@ -3586,7 +3588,7 @@ cho_chord_diagram_parse(
finger_count++;
break;
}
- case CDS_KEYS: {
+ case CHORD_DIAGRAM_STATE_KEYS: {
if (is_whitespace(*c)) {
if (i == 0) {
break;
@@ -3608,7 +3610,7 @@ cho_chord_diagram_parse(
break;
}
if (isalpha(*c)) {
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
c--;
break;
}
@@ -3621,7 +3623,7 @@ cho_chord_diagram_parse(
i++;
break;
}
- case CDS_DIAGRAM: {
+ case CHORD_DIAGRAM_STATE_DIAGRAM: {
if (is_whitespace(*c)) {
if (i == 0) {
break;
@@ -3641,26 +3643,26 @@ cho_chord_diagram_parse(
return NULL;
}
}
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
break;
}
diagram_value[i] = *c;
i++;
break;
}
- case CDS_COPY: {
+ case CHORD_DIAGRAM_STATE_COPY: {
if (is_whitespace(*c)) {
if (i == 0) {
break;
}
chord_to_copy[i] = 0;
- if (current_content != CDC_UNINITIALIZED) {
+ if (current_content != CHORD_DIAGRAM_CONTENT_UNINITIALIZED) {
cho_log(ctx, LOG_ERR, "The define options 'base-fret', 'frets', 'fingers' and 'keys' are not allowed before the 'copy' option.");
return NULL;
}
enum Instrument ins = ctx->config->output->diagram->instrument;
current_content = chord_diagram_duplicate(diagram, custom_diagrams, custom_diagrams_len, name, chord_to_copy, ins);
- if (current_content == CDC_UNINITIALIZED) {
+ if (current_content == CHORD_DIAGRAM_CONTENT_UNINITIALIZED) {
cho_log(ctx, LOG_ERR, "Can't copy the diagram for the chord '%s'"
"because no previous definition was found and also"
"no predefined chord diagram for the instrument '%s'"
@@ -3668,14 +3670,14 @@ cho_chord_diagram_parse(
return NULL;
}
i = 0;
- state = CDS_OPTION_NAME;
+ state = CHORD_DIAGRAM_STATE_OPTION_NAME;
break;
}
chord_to_copy[i] = *c;
i++;
break;
}
- case CDS_DISPLAY: {
+ case CHORD_DIAGRAM_STATE_DISPLAY: {
if (is_whitespace(*c)) {
display[i] = 0;
i = 0;
@@ -3689,7 +3691,7 @@ cho_chord_diagram_parse(
}
}
switch (state) {
- case CDS_BASE_FRET: {
+ case CHORD_DIAGRAM_STATE_BASE_FRET: {
base_fret[i] = 0;
i = 0;
l = str_to_number(base_fret);
@@ -3705,7 +3707,7 @@ cho_chord_diagram_parse(
diagram->u.sd->base_fret = (int8_t)l;
break;
}
- case CDS_KEYS: {
+ case CHORD_DIAGRAM_STATE_KEYS: {
key[i] = 0;
if (strlen(key) > 0) {
l = str_to_number(key);
@@ -3722,7 +3724,7 @@ cho_chord_diagram_parse(
}
break;
}
- case CDS_DIAGRAM: {
+ case CHORD_DIAGRAM_STATE_DIAGRAM: {
diagram_value[i] = 0;
if (!strcmp(diagram_value, "off")) {
diagram->show = false;
@@ -3740,9 +3742,9 @@ cho_chord_diagram_parse(
}
break;
}
- case CDS_COPY: {
+ case CHORD_DIAGRAM_STATE_COPY: {
chord_to_copy[i] = 0;
- if (current_content != CDC_UNINITIALIZED) {
+ if (current_content != CHORD_DIAGRAM_CONTENT_UNINITIALIZED) {
cho_log(ctx, LOG_ERR, "The define options 'base-fret', 'frets',"
"'fingers' and 'keys' are not allowed before the 'copy'"
"option.");
@@ -3750,7 +3752,7 @@ cho_chord_diagram_parse(
}
enum Instrument ins = ctx->config->output->diagram->instrument;
current_content = chord_diagram_duplicate(diagram, custom_diagrams, custom_diagrams_len, name, chord_to_copy, ins);
- if (current_content == CDC_UNINITIALIZED) {
+ if (current_content == CHORD_DIAGRAM_CONTENT_UNINITIALIZED) {
cho_log(ctx, LOG_ERR, "Can't copy the diagram for the chord '%s' because"
"no previous definition was found and also no predefined"
"chord diagram for the instrument '%s' was found.",
@@ -3759,7 +3761,7 @@ cho_chord_diagram_parse(
}
break;
}
- case CDS_DISPLAY: {
+ case CHORD_DIAGRAM_STATE_DISPLAY: {
display[i] = 0;
diagram->u.cm->display = strdup(display);
break;
@@ -3767,7 +3769,7 @@ cho_chord_diagram_parse(
default:
}
if (
- current_content == CDC_STRING &&
+ current_content == CHORD_DIAGRAM_CONTENT_STRING &&
fret_count > 0 &&
finger_count > 0 &&
fret_count != finger_count
@@ -3775,7 +3777,7 @@ cho_chord_diagram_parse(
cho_log(ctx, LOG_ERR, "The number of frets (%d) and fingers (%d) in the chord diagram must be equal.", fret_count, finger_count);
return NULL;
}
- if (current_content == CDC_UNINITIALIZED) {
+ if (current_content == CHORD_DIAGRAM_CONTENT_UNINITIALIZED) {
cho_log(ctx, LOG_ERR, "The chord diagram is invalid.");
return NULL;
}
@@ -3897,7 +3899,7 @@ cho_line_new(void)
struct ChoLine *line = emalloc(sizeof(struct ChoLine));
line->text_above = NULL;
line->items = NULL;
- line->btype = BT_LINE;
+ line->btype = BREAK_TYPE_LINE;
return line;
}
@@ -3940,7 +3942,7 @@ static struct ChoSection *
cho_section_new(void)
{
struct ChoSection *section = emalloc(sizeof(struct ChoSection));
- section->type = ST_UNINITIALIZED;
+ section->type = SECTION_TYPE_UNINITIALIZED;
section->label = NULL;
section->lines = NULL;
return section;
@@ -4008,7 +4010,7 @@ cho_song_new(struct ChoContext *ctx)
}
song->sections = NULL;
song->diagrams = NULL;
- memset(song->present_text_types, 0, TT_LENGTH);
+ memset(song->present_text_types, 0, TEXT_TYPE_LENGTH);
return song;
}
@@ -4091,7 +4093,7 @@ cho_find_previous_chorus(struct ChoSection **sections, int se)
{
int i;
for (i = se; i>=0; i--) {
- if (sections[i]->type == ST_CHORUS) {
+ if (sections[i]->type == SECTION_TYPE_CHORUS) {
return sections[i];
}
}
@@ -4102,7 +4104,7 @@ static struct ChoDirective *
cho_directive_new(struct ChoContext *ctx)
{
struct ChoDirective *directive = emalloc(sizeof(struct ChoDirective));
- directive->stype = ST_UNINITIALIZED;
+ directive->stype = SECTION_TYPE_UNINITIALIZED;
directive->style = cho_style_new_default(ctx);
return directive;
}
@@ -4125,107 +4127,107 @@ cho_directive_parse(struct ChoContext *ctx, const char *name)
!strcmp(name, "start_of_chorus") ||
!strcmp(name, "soc")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_START;
- directive->stype = ST_CHORUS;
- directive->ttype = TT_CHORUS;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_START;
+ directive->stype = SECTION_TYPE_CHORUS;
+ directive->ttype = TEXT_TYPE_CHORUS;
return directive;
} else if (
!strcmp(name, "end_of_chorus") ||
!strcmp(name, "eoc")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_END;
- directive->stype = ST_CHORUS;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_END;
+ directive->stype = SECTION_TYPE_CHORUS;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (!strcmp(name, "chorus")) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_NO;
- directive->ttype = TT_LABEL;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_NO;
+ directive->ttype = TEXT_TYPE_LABEL;
return directive;
} else if (
!strcmp(name, "start_of_verse") ||
!strcmp(name, "sov")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_START;
- directive->stype = ST_VERSE;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_START;
+ directive->stype = SECTION_TYPE_VERSE;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (
!strcmp(name, "end_of_verse") ||
!strcmp(name, "eov")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_END;
- directive->stype = ST_VERSE;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_END;
+ directive->stype = SECTION_TYPE_VERSE;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (
!strcmp(name, "start_of_bridge") ||
!strcmp(name, "sob")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_START;
- directive->stype = ST_BRIDGE;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_START;
+ directive->stype = SECTION_TYPE_BRIDGE;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (
!strcmp(name, "end_of_bridge") ||
!strcmp(name, "eob")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_END;
- directive->stype = ST_BRIDGE;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_END;
+ directive->stype = SECTION_TYPE_BRIDGE;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (
!strcmp(name, "start_of_tab") ||
!strcmp(name, "sot")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_START;
- directive->stype = ST_TAB;
- directive->ttype = TT_TAB;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_START;
+ directive->stype = SECTION_TYPE_TAB;
+ directive->ttype = TEXT_TYPE_TAB;
return directive;
} else if (
!strcmp(name, "end_of_tab") ||
!strcmp(name, "eot")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_END;
- directive->stype = ST_TAB;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_END;
+ directive->stype = SECTION_TYPE_TAB;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (
!strcmp(name, "start_of_grid") ||
!strcmp(name, "sog")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_START;
- directive->stype = ST_GRID;
- directive->ttype = TT_GRID;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_START;
+ directive->stype = SECTION_TYPE_GRID;
+ directive->ttype = TEXT_TYPE_GRID;
return directive;
} else if (
!strcmp(name, "end_of_grid") ||
!strcmp(name, "eog")
) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_END;
- directive->stype = ST_GRID;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_END;
+ directive->stype = SECTION_TYPE_GRID;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
}
if (
!strcmp(name, "title") ||
!strcmp(name, "t")
) {
- directive->dtype = DT_METADATA;
- directive->meta = MD_TITLE;
+ directive->dtype = DIRECTIVE_TYPE_METADATA;
+ directive->meta = METADATA_DIRECTIVE_TITLE;
cho_style_free(directive->style);
ctx->prev_ttype = ctx->current_ttype;
- ctx->current_ttype = TT_TITLE;
+ ctx->current_ttype = TEXT_TYPE_TITLE;
directive->style = cho_style_new_default(ctx);
ctx->current_ttype = ctx->prev_ttype;
return directive;
@@ -4234,11 +4236,11 @@ cho_directive_parse(struct ChoContext *ctx, const char *name)
!strcmp(name, "subtitle") ||
!strcmp(name, "st")
) {
- directive->dtype = DT_METADATA;
- directive->meta = MD_SUBTITLE;
+ directive->dtype = DIRECTIVE_TYPE_METADATA;
+ directive->meta = METADATA_DIRECTIVE_SUBTITLE;
cho_style_free(directive->style);
ctx->prev_ttype = ctx->current_ttype;
- ctx->current_ttype = TT_SUBTITLE;
+ ctx->current_ttype = TEXT_TYPE_SUBTITLE;
directive->style = cho_style_new_default(ctx);
ctx->current_ttype = ctx->prev_ttype;
return directive;
@@ -4259,8 +4261,8 @@ cho_directive_parse(struct ChoContext *ctx, const char *name)
!strcmp(name, "meta") ||
!strcmp(name, "arranger")
) {
- directive->dtype = DT_METADATA;
- directive->meta = MD_OTHER;
+ directive->dtype = DIRECTIVE_TYPE_METADATA;
+ directive->meta = METADATA_DIRECTIVE_OTHER;
return directive;
}
if (
@@ -4268,194 +4270,194 @@ cho_directive_parse(struct ChoContext *ctx, const char *name)
!strcmp(name, "c") ||
!strcmp(name, "highlight")
) {
- directive->dtype = DT_FORMATTING;
+ directive->dtype = DIRECTIVE_TYPE_FORMATTING;
ctx->prev_ttype = ctx->current_ttype;
- ctx->current_ttype = TT_COMMENT;
+ ctx->current_ttype = TEXT_TYPE_COMMENT;
cho_style_free(directive->style);
directive->style = cho_style_new_default(ctx);
ctx->current_ttype = ctx->prev_ttype;
- directive->ttype = TT_COMMENT;
+ directive->ttype = TEXT_TYPE_COMMENT;
return directive;
} else if (
!strcmp(name, "comment_italic") ||
!strcmp(name, "ci")
) {
- directive->dtype = DT_FORMATTING;
+ directive->dtype = DIRECTIVE_TYPE_FORMATTING;
ctx->prev_ttype = ctx->current_ttype;
- ctx->current_ttype = TT_COMMENT_ITALIC;
+ ctx->current_ttype = TEXT_TYPE_COMMENT_ITALIC;
cho_style_free(directive->style);
directive->style = cho_style_new_default(ctx);
ctx->current_ttype = ctx->prev_ttype;
- directive->ttype = TT_COMMENT_ITALIC;
+ directive->ttype = TEXT_TYPE_COMMENT_ITALIC;
return directive;
} else if (
!strcmp(name, "comment_box") ||
!strcmp(name, "cb")
) {
- directive->dtype = DT_FORMATTING;
+ directive->dtype = DIRECTIVE_TYPE_FORMATTING;
ctx->prev_ttype = ctx->current_ttype;
- ctx->current_ttype = TT_COMMENT_BOX;
+ ctx->current_ttype = TEXT_TYPE_COMMENT_BOX;
cho_style_free(directive->style);
directive->style = cho_style_new_default(ctx);
ctx->current_ttype = ctx->prev_ttype;
- directive->ttype = TT_COMMENT_BOX;
+ directive->ttype = TEXT_TYPE_COMMENT_BOX;
return directive;
}
if (!strcmp(name, "image")) {
- directive->dtype = DT_IMAGE;
+ directive->dtype = DIRECTIVE_TYPE_IMAGE;
return directive;
}
if (
!strcmp(name, "new_song") ||
!strcmp(name, "ns")
) {
- directive->dtype = DT_PREAMBLE;
- directive->stype = ST_NEWSONG;
+ directive->dtype = DIRECTIVE_TYPE_PREAMBLE;
+ directive->stype = SECTION_TYPE_NEWSONG;
return directive;
}
if (
!strcmp(name, "chordfont") ||
!strcmp(name, "cf")
) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_CHORD;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_CHORD;
return directive;
} else if (
!strcmp(name, "chordsize") ||
!strcmp(name, "cs")
) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_CHORD;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_CHORD;
return directive;
} else if (!strcmp(name, "chordcolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_CHORD;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_CHORD;
return directive;
} else if (!strcmp(name, "chorusfont")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_CHORUS;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_CHORUS;
return directive;
} else if (!strcmp(name, "chorussize")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_CHORUS;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_CHORUS;
return directive;
} else if (!strcmp(name, "choruscolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_CHORUS;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_CHORUS;
return directive;
} else if (!strcmp(name, "gridfont")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_GRID;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_GRID;
return directive;
} else if (!strcmp(name, "gridsize")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_GRID;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_GRID;
return directive;
} else if (!strcmp(name, "gridcolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_GRID;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_GRID;
return directive;
} else if (!strcmp(name, "tabfont")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_TAB;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_TAB;
return directive;
} else if (!strcmp(name, "tabsize")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_TAB;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_TAB;
return directive;
} else if (!strcmp(name, "tabcolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_TAB;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_TAB;
return directive;
} else if (
!strcmp(name, "textfont") ||
!strcmp(name, "tf")
) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (
!strcmp(name, "textsize") ||
!strcmp(name, "ts")
) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (!strcmp(name, "textcolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (!strcmp(name, "titlefont")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_TITLE;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_TITLE;
return directive;
} else if (!strcmp(name, "titlesize")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_TITLE;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_TITLE;
return directive;
} else if (!strcmp(name, "titlecolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_TITLE;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_TITLE;
return directive;
} else if (!strcmp(name, "tocfont")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_TOC;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_TOC;
return directive;
} else if (!strcmp(name, "tocsize")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_TOC;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_TOC;
return directive;
} else if (!strcmp(name, "toccolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_TOC;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_TOC;
return directive;
/* } else if (!strcmp(name, "footerfont")) {
} else if (!strcmp(name, "footersize")) {
} else if (!strcmp(name, "footercolour")) { */
} else if (!strcmp(name, "labelfont")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_FONT;
- directive->ttype = TT_LABEL;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_FONT;
+ directive->ttype = TEXT_TYPE_LABEL;
return directive;
} else if (!strcmp(name, "labelsize")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_SIZE;
- directive->ttype = TT_LABEL;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_SIZE;
+ directive->ttype = TEXT_TYPE_LABEL;
return directive;
} else if (!strcmp(name, "labelcolour")) {
- directive->dtype = DT_FONT;
- directive->sprop = SPT_COLOR;
- directive->ttype = TT_LABEL;
+ directive->dtype = DIRECTIVE_TYPE_FONT;
+ directive->sprop = STYLE_PROPERTY_TYPE_COLOR;
+ directive->ttype = TEXT_TYPE_LABEL;
return directive;
}
if (!strcmp(name, "transpose")) {
- directive->dtype = DT_CHORD;
- directive->ctype = TRANSPOSE;
+ directive->dtype = DIRECTIVE_TYPE_CHORD;
+ directive->ctype = CHORD_DIRECTIVE_TRANSPOSE;
return directive;
} else if (!strcmp(name, "define")) {
- directive->dtype = DT_CHORD;
- directive->ctype = DEFINE;
+ directive->dtype = DIRECTIVE_TYPE_CHORD;
+ directive->ctype = CHORD_DIRECTIVE_DEFINE;
return directive;
} /* else if (!strcmp(name, "chord")) {
} */
@@ -4463,136 +4465,46 @@ cho_directive_parse(struct ChoContext *ctx, const char *name)
!strcmp(name, "new_page") ||
!strcmp(name, "np")
) {
- directive->dtype = DT_OUTPUT;
- directive->btype = BT_PAGE;
+ directive->dtype = DIRECTIVE_TYPE_OUTPUT;
+ directive->btype = BREAK_TYPE_PAGE;
return directive;
} else if (
!strcmp(name, "column_break") ||
!strcmp(name, "colb")
) {
- directive->dtype = DT_OUTPUT;
- directive->btype = BT_COLUMN;
+ directive->dtype = DIRECTIVE_TYPE_OUTPUT;
+ directive->btype = BREAK_TYPE_COLUMN;
return directive;
}
if (str_starts_with(name, "start_of_")) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_START;
- directive->stype = ST_CUSTOM;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_START;
+ directive->stype = SECTION_TYPE_CUSTOM;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
} else if (str_starts_with(name, "end_of_")) {
- directive->dtype = DT_ENVIRONMENT;
- directive->position = POS_END;
- directive->stype = ST_CUSTOM;
- directive->ttype = TT_TEXT;
+ directive->dtype = DIRECTIVE_TYPE_ENVIRONMENT;
+ directive->position = POSITION_END;
+ directive->stype = SECTION_TYPE_CUSTOM;
+ directive->ttype = TEXT_TYPE_TEXT;
return directive;
}
if (str_starts_with(name, "x_")) {
- directive->dtype = DT_EXTENSION;
+ directive->dtype = DIRECTIVE_TYPE_EXTENSION;
return directive;
}
- directive->dtype = DT_CUSTOM;
+ directive->dtype = DIRECTIVE_TYPE_CUSTOM;
return directive;
}
-static char *
-cho_directive_label_parse(struct ChoContext *ctx, const char *directive_name, const char *str)
-{
- char *label_name = NULL;
- char c;
- enum OptionState state = OS_NAME;
- enum AttrValueSyntax avs = AVS_UNINITIALIZED;
- char name[5+1];
- char value[URL_MAX_LEN+1];
- int n = 0;
- int v = 0;
- memset(name, 0, sizeof(name));
- memset(value, 0, sizeof(value));
- int i;
- for (i = 0; str[i]; i++) {
- c = str[i];
- switch (state) {
- case OS_NAME:
- if (is_whitespace(c)) {
- if (n == 0) {
- break;
- } else {
- name[n] = 0;
- cho_log(ctx, LOG_ERR, "Option with name '%s' in environment directive '%s' has no value.", name, directive_name);
- return NULL;
- }
- }
- if (c == '=') {
- name[n] = 0;
- if (strcmp(name, "label") != 0) {
- cho_log(ctx, LOG_ERR, "Invalid option name '%s' in environment directive '%s'.", name, directive_name);
- }
- memset(name, 0, n);
- n = 0;
- state = OS_VALUE;
- break;
- }
- if (n > 4) {
- cho_log(ctx, LOG_ERR, "Option name in environment directive '%s' is too long.", directive_name);
- return NULL;
- }
- name[n] = c;
- n++;
- break;
- case OS_VALUE:
- if (avs == AVS_UNINITIALIZED) {
- if (is_whitespace(c)) {
- cho_log(ctx, LOG_ERR, "Whitespace character after equals sign in environment directive '%s' is invalid.", directive_name);
- return NULL;
- }
- if (c == '\'') {
- avs = AVS_APOSTROPHE;
- } else if (c == '"') {
- avs = AVS_QUOTATION_MARK;
- } else {
- avs = AVS_UNQUOTED;
- value[v] = c;
- v++;
- }
- break;
- }
- if (c == '\n') {
- cho_log(ctx, LOG_ERR, "Newline character inside an option value in environment directive '%s' is invalid.", directive_name);
- return NULL;
- }
- if (
- (avs == AVS_APOSTROPHE && c == '\'') ||
- (avs == AVS_QUOTATION_MARK && c == '"') ||
- (avs == AVS_UNQUOTED && (c == ' ' || c == '\t'))
- ) {
- value[v] = 0;
- label_name = strdup(value);
- memset(value, 0, v);
- v = 0;
- avs = AVS_UNINITIALIZED;
- state = OS_NAME;
- break;
- }
- value[v] = c;
- v++;
- break;
- }
- }
- if (avs == AVS_UNQUOTED) {
- value[v] = 0;
- label_name = strdup(value);
- }
- return label_name;
-}
-
static struct Attr **
cho_attrs_parse(struct ChoContext *ctx, const char *str)
{
const char *directive_name = "something";
struct Attr **attrs = NULL;
int a = 0;
- enum OptionState state = OS_NAME;
- enum AttrValueSyntax avs = AVS_UNINITIALIZED;
+ enum OptionState state = OPTION_STATE_NAME;
+ enum AttrValueSyntax avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
char name[5+1];
char value[URL_MAX_LEN+1];
int n = 0;
@@ -4602,7 +4514,7 @@ cho_attrs_parse(struct ChoContext *ctx, const char *str)
const char *c;
for (c = str; *c; c++) {
switch (state) {
- case OS_NAME:
+ case OPTION_STATE_NAME:
if (is_whitespace(*c)) {
if (n == 0) {
break;
@@ -4614,7 +4526,7 @@ cho_attrs_parse(struct ChoContext *ctx, const char *str)
}
if (*c == '=') {
name[n] = 0;
- state = OS_VALUE;
+ state = OPTION_STATE_VALUE;
break;
}
if (n > 4) {
@@ -4624,18 +4536,18 @@ cho_attrs_parse(struct ChoContext *ctx, const char *str)
name[n] = *c;
n++;
break;
- case OS_VALUE:
- if (avs == AVS_UNINITIALIZED) {
+ case OPTION_STATE_VALUE:
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED) {
if (is_whitespace(*c)) {
cho_log(ctx, LOG_ERR, "Whitespace character after equals sign in environment directive '%s' is invalid.", directive_name);
return NULL;
}
if (*c == '\'') {
- avs = AVS_APOSTROPHE;
+ avs = ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE;
} else if (*c == '"') {
- avs = AVS_QUOTATION_MARK;
+ avs = ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK;
} else {
- avs = AVS_UNQUOTED;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNQUOTED;
value[v] = *c;
v++;
}
@@ -4646,9 +4558,9 @@ cho_attrs_parse(struct ChoContext *ctx, const char *str)
return NULL;
}
if (
- (avs == AVS_APOSTROPHE && *c == '\'') ||
- (avs == AVS_QUOTATION_MARK && *c == '"') ||
- (avs == AVS_UNQUOTED && (*c == ' ' || *c == '\t'))
+ (avs == ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE && *c == '\'') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK && *c == '"') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED && (*c == ' ' || *c == '\t'))
) {
value[v] = 0;
attrs = erealloc(attrs, (a+1) * sizeof(struct Attr *));
@@ -4660,8 +4572,8 @@ cho_attrs_parse(struct ChoContext *ctx, const char *str)
n = 0;
memset(value, 0, v);
v = 0;
- avs = AVS_UNINITIALIZED;
- state = OS_NAME;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
+ state = OPTION_STATE_NAME;
break;
}
value[v] = *c;
@@ -4669,7 +4581,7 @@ cho_attrs_parse(struct ChoContext *ctx, const char *str)
break;
}
}
- if (avs == AVS_UNQUOTED) {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED) {
value[v] = 0;
attrs = erealloc(attrs, (a+1) * sizeof(struct Attr *));
attrs[a] = emalloc(sizeof(struct Attr));
@@ -4699,11 +4611,11 @@ static bool
cho_grid_shape_parse_and_set(struct ChoContext *ctx, const char *str)
{
enum {
- BEFORE_FIRST_PLUS,
- AFTER_FIRST_PLUS,
+ BEFORE_FIRSIZE_TYPE_PLUS,
+ AFTER_FIRSIZE_TYPE_PLUS,
AFTER_SECOND_PLUS,
AFTER_X
- } state = BEFORE_FIRST_PLUS;
+ } state = BEFORE_FIRSIZE_TYPE_PLUS;
const char *c;
char tmp[6+1];
int t = 0;
@@ -4712,7 +4624,7 @@ cho_grid_shape_parse_and_set(struct ChoContext *ctx, const char *str)
int i;
for (c = str; *c; c++) {
switch (state) {
- case BEFORE_FIRST_PLUS:
+ case BEFORE_FIRSIZE_TYPE_PLUS:
if (*c == '+') {
tmp[t] = 0;
i = atoi(tmp);
@@ -4723,7 +4635,7 @@ cho_grid_shape_parse_and_set(struct ChoContext *ctx, const char *str)
ctx->grid.left = i;
memset(tmp, 0, t);
t = 0;
- state = AFTER_FIRST_PLUS;
+ state = AFTER_FIRSIZE_TYPE_PLUS;
break;
}
if (*c == 'x') {
@@ -4746,7 +4658,7 @@ cho_grid_shape_parse_and_set(struct ChoContext *ctx, const char *str)
tmp[t] = *c;
t++;
break;
- case AFTER_FIRST_PLUS:
+ case AFTER_FIRSIZE_TYPE_PLUS:
if (*c == '+') {
tmp[t] = 0;
i = atoi(tmp);
@@ -4807,9 +4719,9 @@ cho_grid_shape_parse_and_set(struct ChoContext *ctx, const char *str)
return false;
}
switch (state) {
- case BEFORE_FIRST_PLUS:
+ case BEFORE_FIRSIZE_TYPE_PLUS:
/* fallthrough */
- case AFTER_FIRST_PLUS:
+ case AFTER_FIRSIZE_TYPE_PLUS:
ctx->grid.cells = i;
break;
case AFTER_SECOND_PLUS:
@@ -4830,41 +4742,41 @@ cho_grid_token_parse(struct ChoContext *ctx, const char *token, bool *err)
*err = false;
if (!strcmp(token, ".")) {
- return GT_PLACEHOLDER;
+ return GRID_TOKEN_PLACEHOLDER;
} else
if (!strcmp(token, "/")) {
- return GT_PLACEHOLDER;
+ return GRID_TOKEN_PLACEHOLDER;
} else
if (!strcmp(token, "|")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (!strcmp(token, "||")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (!strcmp(token, "|.")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (!strcmp(token, "|:")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (!strcmp(token, ":|")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (!strcmp(token, ":|:")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (token[0] == '|' && isdigit(token[1])) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if (!strcmp(token, "|2>")) {
- return GT_BAR_LINE_SYMBOL;
+ return GRID_TOKEN_BAR_LINE_SYMBOL;
} else
if ((chord = cho_chord_parse(ctx, token)) && chord->is_canonical) {
cho_chord_free(chord);
- return GT_CHORD;
+ return GRID_TOKEN_CHORD;
}
*err = true;
- return GT_CHORD;
+ return GRID_TOKEN_CHORD;
}
static bool
@@ -4883,8 +4795,8 @@ cho_context_init(
ctx->state_before_tag = STATE_LYRICS;
ctx->state_before_backslash = STATE_LYRICS;
ctx->state_before_metadata_substitution = STATE_LYRICS;
- ctx->current_ttype = TT_TEXT;
- ctx->prev_ttype = TT_TEXT;
+ ctx->current_ttype = TEXT_TYPE_TEXT;
+ ctx->prev_ttype = TEXT_TYPE_TEXT;
ctx->ann = 0;
ctx->at = 0;
ctx->atn = 0;
@@ -4940,7 +4852,7 @@ cho_context_init(
struct ChoSong **
cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *config)
{
- enum AttrValueSyntax avs = AVS_UNINITIALIZED;
+ enum AttrValueSyntax avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
enum GridToken token;
struct Attr **attrs = NULL;
struct ChoStyle *tag_style;
@@ -4976,7 +4888,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
lines = &ctx.songs[ctx.so]->sections[ctx.se]->lines;
(*lines)[ctx.li]->items = emalloc(sizeof(struct ChoLineItem *));
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
- ctx.songs[ctx.so]->present_text_types[TT_TOC] = config->output->toc->show;
+ ctx.songs[ctx.so]->present_text_types[TEXT_TYPE_TOC] = config->output->toc->show;
for (; *str; str++) {
c = *str;
// printf("state: %s, c: %c\n", state_enums[ctx.state], c);
@@ -5042,7 +4954,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
if (ctx.lii == 0) {
if (
!(*lines)[ctx.li]->text_above &&
- (*lines)[ctx.li]->btype == BT_LINE
+ (*lines)[ctx.li]->btype == BREAK_TYPE_LINE
) {
free((*lines)[ctx.li]->items);
free((*lines)[ctx.li]);
@@ -5096,11 +5008,11 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
directive_name, cho_debug_dtype(directive->dtype), cho_debug_the_stype(directive->stype), cho_debug_the_pos(directive->position)
); */
switch (directive->dtype) {
- case DT_ENVIRONMENT: {
+ case DIRECTIVE_TYPE_ENVIRONMENT: {
ctx.current_ttype = directive->ttype;
switch (directive->position) {
- case POS_START: {
- if (directive->stype == ST_CUSTOM) {
+ case POSITION_START: {
+ if (directive->stype == SECTION_TYPE_CUSTOM) {
memset(custom_directive, 0, sizeof(custom_directive));
strcpy(custom_directive, &directive_name[9]);
}
@@ -5121,10 +5033,10 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
ctx.songs[ctx.so]->present_text_types[directive->ttype] = true;
switch (directive->stype) {
- case ST_TAB:
+ case SECTION_TYPE_TAB:
ctx.state = STATE_TAB;
break;
- case ST_GRID:
+ case SECTION_TYPE_GRID:
ctx.state = STATE_GRID;
break;
default:
@@ -5132,14 +5044,14 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case POS_END: {
+ case POSITION_END: {
if (directive->stype == ctx.songs[ctx.so]->sections[ctx.se]->type) {
- if (directive->stype == ST_CUSTOM) {
+ if (directive->stype == SECTION_TYPE_CUSTOM) {
if (strcmp(custom_directive, &directive_name[7]) != 0) {
break;
}
}
- if (directive->stype == ST_GRID) {
+ if (directive->stype == SECTION_TYPE_GRID) {
ctx.grid.bar_line_symbol_count = 0;
ctx.grid.tokens_per_cell = 0;
ctx.grid.expected_tokens_per_cell = 0;
@@ -5170,7 +5082,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case POS_NO: {
+ case POSITION_NO: {
/* INFO: {chorus} */
chorus = cho_find_previous_chorus(ctx.songs[ctx.so]->sections, ctx.se);
if (chorus) {
@@ -5221,7 +5133,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li]->items = erealloc((*lines)[ctx.li]->items, (ctx.lii+1) * sizeof(struct ChoLineItem *));
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
cho_style_free((*lines)[ctx.li]->items[ctx.lii]->u.text->style);
- ctx.current_ttype = TT_LABEL;
+ ctx.current_ttype = TEXT_TYPE_LABEL;
(*lines)[ctx.li]->items[ctx.lii]->u.text->style = cho_style_new_default(&ctx);
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = label;
ctx.te += strlen(label);
@@ -5245,7 +5157,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li]->items = erealloc((*lines)[ctx.li]->items, (ctx.lii+1) * sizeof(struct ChoLineItem *));
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
cho_style_free((*lines)[ctx.li]->items[ctx.lii]->u.text->style);
- ctx.current_ttype = TT_LABEL;
+ ctx.current_ttype = TEXT_TYPE_LABEL;
(*lines)[ctx.li]->items[ctx.lii]->u.text->style = cho_style_new_default(&ctx);
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = label;
ctx.te += strlen(label);
@@ -5258,16 +5170,16 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case DT_METADATA:
+ case DIRECTIVE_TYPE_METADATA:
cho_log(&ctx, LOG_WARN, "Ignoring metadata directive '%s' because it has no value.", directive_name);
break;
- case DT_FORMATTING:
+ case DIRECTIVE_TYPE_FORMATTING:
cho_log(&ctx, LOG_WARN, "Formatting directive '%s' has no value.", directive_name);
break;
- case DT_IMAGE:
+ case DIRECTIVE_TYPE_IMAGE:
cho_log(&ctx, LOG_ERR, "Directive 'image' has no value.");
return NULL;
- case DT_PREAMBLE: {
+ case DIRECTIVE_TYPE_PREAMBLE: {
// INFO: The only preamble directive is 'new_song'
cho_line_item_free((*lines)[ctx.li]->items[ctx.lii]);
free((*lines)[ctx.li]->items);
@@ -5317,17 +5229,17 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
break;
}
- case DT_FONT: {
+ case DIRECTIVE_TYPE_FONT: {
sprop.ttype = directive->ttype;
sprop.type = directive->sprop;
switch (directive->sprop) {
- case SPT_FONT:
+ case STYLE_PROPERTY_TYPE_FONT:
sprop.u.font_name = NULL;
break;
- case SPT_SIZE:
+ case STYLE_PROPERTY_TYPE_SIZE:
sprop.u.font_size = EMPTY_DOUBLE;
break;
- case SPT_COLOR:
+ case STYLE_PROPERTY_TYPE_COLOR:
sprop.u.foreground_color = NULL;
break;
default:
@@ -5340,25 +5252,25 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case DT_CHORD: {
+ case DIRECTIVE_TYPE_CHORD: {
switch (directive->ctype) {
- case TRANSPOSE:
+ case CHORD_DIRECTIVE_TRANSPOSE:
ctx.transpose--;
ctx.th--;
break;
- case DEFINE:
+ case CHORD_DIRECTIVE_DEFINE:
cho_log(&ctx, LOG_WARN, "Ignoring chord directive '%s' because it has no value.", directive_name);
break;
}
break;
}
- case DT_OUTPUT:
+ case DIRECTIVE_TYPE_OUTPUT:
(*lines)[ctx.li]->btype = directive->btype;
break;
- case DT_EXTENSION:
+ case DIRECTIVE_TYPE_EXTENSION:
// INFO: Such a directive should not be logged.
break;
- case DT_CUSTOM:
+ case DIRECTIVE_TYPE_CUSTOM:
cho_log(&ctx, LOG_INFO, "Ignoring custom directive '%s'.", directive_name);
break;
default:
@@ -5405,14 +5317,14 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
directive_name, dtype(directive->dtype), the_stype(directive->stype), pos(directive->position)
); */
switch (directive->dtype) {
- case DT_ENVIRONMENT: {
+ case DIRECTIVE_TYPE_ENVIRONMENT: {
if (strlen(stripped_directive_value) > 0) {
- ctx.songs[ctx.so]->present_text_types[TT_LABEL] = true;
+ ctx.songs[ctx.so]->present_text_types[TEXT_TYPE_LABEL] = true;
}
ctx.current_ttype = directive->ttype;
switch (directive->position) {
- case POS_START: {
- if (directive->stype == ST_CUSTOM) {
+ case POSITION_START: {
+ if (directive->stype == SECTION_TYPE_CUSTOM) {
memset(custom_directive, 0, sizeof(custom_directive));
strcpy(custom_directive, &directive_name[9]);
}
@@ -5433,7 +5345,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
return NULL;
}
label = cho_attrs_get(attrs, "label");
- if (directive->stype == ST_GRID) {
+ if (directive->stype == SECTION_TYPE_GRID) {
shape = cho_attrs_get(attrs, "shape");
if (shape) {
if (!cho_grid_shape_parse_and_set(&ctx, shape)) {
@@ -5443,7 +5355,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
}
} else {
- if (directive->stype == ST_GRID) {
+ if (directive->stype == SECTION_TYPE_GRID) {
int index = str_index_of(stripped_directive_value, ' ');
if (index != -1) {
stripped_directive_value[index] = 0;
@@ -5461,7 +5373,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
ctx.songs[ctx.so]->sections[ctx.se]->label = emalloc(sizeof(struct ChoText));
ctx.songs[ctx.so]->sections[ctx.se]->label->text = strdup(label);
ctx.prev_ttype = ctx.current_ttype;
- ctx.current_ttype = TT_LABEL;
+ ctx.current_ttype = TEXT_TYPE_LABEL;
ctx.songs[ctx.so]->sections[ctx.se]->label->style = cho_style_new_default(&ctx);
ctx.current_ttype = ctx.prev_ttype;
label = NULL;
@@ -5481,11 +5393,11 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
ctx.songs[ctx.so]->present_text_types[directive->ttype] = true;
break;
}
- case POS_END: {
+ case POSITION_END: {
cho_log(&ctx, LOG_ERR, "A directive that closes a section can't have arguments.");
return NULL;
}
- case POS_NO: {
+ case POSITION_NO: {
/* INFO: {chorus: ...} */
label = strdup(stripped_directive_value);
chorus = cho_find_previous_chorus(ctx.songs[ctx.so]->sections, ctx.se);
@@ -5514,7 +5426,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
free(ctx.songs[ctx.so]->sections[ctx.se]->label->text);
ctx.songs[ctx.so]->sections[ctx.se]->label->text = label;
} else {
- ctx.current_ttype = TT_LABEL;
+ ctx.current_ttype = TEXT_TYPE_LABEL;
ctx.songs[ctx.so]->sections[ctx.se]->label = cho_text_new(&ctx);
ctx.songs[ctx.so]->sections[ctx.se]->label->text = label;
}
@@ -5545,7 +5457,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li]->items = erealloc((*lines)[ctx.li]->items, (ctx.lii+1) * sizeof(struct ChoLineItem *));
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
cho_style_free((*lines)[ctx.li]->items[ctx.lii]->u.text->style);
- ctx.current_ttype = TT_LABEL;
+ ctx.current_ttype = TEXT_TYPE_LABEL;
(*lines)[ctx.li]->items[ctx.lii]->u.text->style = cho_style_new_default(&ctx);
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = label;
if (ctx.directive_has_tag) {
@@ -5572,7 +5484,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li]->items = erealloc((*lines)[ctx.li]->items, (ctx.lii+1) * sizeof(struct ChoLineItem *));
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
cho_style_free((*lines)[ctx.li]->items[ctx.lii]->u.text->style);
- ctx.current_ttype = TT_LABEL;
+ ctx.current_ttype = TEXT_TYPE_LABEL;
(*lines)[ctx.li]->items[ctx.lii]->u.text->style = cho_style_new_default(&ctx);
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = label;
if (ctx.directive_has_tag) {
@@ -5588,7 +5500,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case DT_METADATA: {
+ case DIRECTIVE_TYPE_METADATA: {
metadata_value = strdup(stripped_directive_value);
if (strlen(metadata_value) == 0) {
cho_log(&ctx, LOG_WARN, "Ignoring metadata directive '%s' because it has no value.", directive_name);
@@ -5596,25 +5508,25 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
break;
}
switch (directive->meta) {
- case MD_TITLE:
+ case METADATA_DIRECTIVE_TITLE:
ctx.songs[ctx.so]->metadata = erealloc(ctx.songs[ctx.so]->metadata, (ctx.m+1) * sizeof(struct ChoMetadata *));
ctx.songs[ctx.so]->metadata[ctx.m] = cho_metadata_new(&ctx);
ctx.songs[ctx.so]->metadata[ctx.m]->name = strdup("title");
ctx.songs[ctx.so]->metadata[ctx.m]->value = metadata_value;
cho_style_free(ctx.songs[ctx.so]->metadata[ctx.m]->style);
ctx.songs[ctx.so]->metadata[ctx.m]->style = cho_style_copy(directive->style);
- ctx.songs[ctx.so]->present_text_types[TT_TITLE] = true;
+ ctx.songs[ctx.so]->present_text_types[TEXT_TYPE_TITLE] = true;
break;
- case MD_SUBTITLE:
+ case METADATA_DIRECTIVE_SUBTITLE:
ctx.songs[ctx.so]->metadata = erealloc(ctx.songs[ctx.so]->metadata, (ctx.m+1) * sizeof(struct ChoMetadata *));
ctx.songs[ctx.so]->metadata[ctx.m] = cho_metadata_new(&ctx);
ctx.songs[ctx.so]->metadata[ctx.m]->name = strdup("subtitle");
ctx.songs[ctx.so]->metadata[ctx.m]->value = metadata_value;
cho_style_free(ctx.songs[ctx.so]->metadata[ctx.m]->style);
ctx.songs[ctx.so]->metadata[ctx.m]->style = cho_style_copy(directive->style);
- ctx.songs[ctx.so]->present_text_types[TT_SUBTITLE] = true;
+ ctx.songs[ctx.so]->present_text_types[TEXT_TYPE_SUBTITLE] = true;
break;
- case MD_OTHER: {
+ case METADATA_DIRECTIVE_OTHER: {
if (!strcmp(directive_name, "meta")) {
metadata = cho_metadata_split(&ctx, directive_value);
if (!metadata) {
@@ -5639,7 +5551,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
ctx.m++;
break;
}
- case DT_FORMATTING: {
+ case DIRECTIVE_TYPE_FORMATTING: {
if ((*lines)[ctx.li]->items[ctx.lii]->is_text) {
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = erealloc((*lines)[ctx.li]->items[ctx.lii]->u.text->text, (ctx.te+1) * sizeof(char));
(*lines)[ctx.li]->items[ctx.lii]->u.text->text[ctx.te] = 0;
@@ -5664,7 +5576,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
ctx.songs[ctx.so]->present_text_types[directive->ttype] = true;
break;
}
- case DT_IMAGE: {
+ case DIRECTIVE_TYPE_IMAGE: {
if (strchr(directive_value, '=')) {
image = cho_image_directive_parse(&ctx, directive_value);
if (!image) {
@@ -5694,33 +5606,33 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case DT_PREAMBLE:
+ case DIRECTIVE_TYPE_PREAMBLE:
cho_log(&ctx, LOG_ERR, "Preamble directive '%s' can't have a value.", directive_name);
return NULL;
- case DT_FONT: {
+ case DIRECTIVE_TYPE_FONT: {
sprop.ttype = directive->ttype;
char *dir_value = strdup(stripped_directive_value);
switch (directive->sprop) {
- case SPT_FONT:
+ case STYLE_PROPERTY_TYPE_FONT:
sprop.u.font_name = emalloc((strlen(dir_value)+1) * sizeof(char));
strcpy(sprop.u.font_name, dir_value);
- sprop.type = SPT_FONT;
+ sprop.type = STYLE_PROPERTY_TYPE_FONT;
break;
- case SPT_SIZE:
+ case STYLE_PROPERTY_TYPE_SIZE:
sprop.u.font_size = strtod(dir_value, NULL);
if (sprop.u.font_size == 0.0) {
cho_log(&ctx, LOG_ERR, "Font directive '%s' has an invalid value.", directive_name);
return NULL;
}
- sprop.type = SPT_SIZE;
+ sprop.type = STYLE_PROPERTY_TYPE_SIZE;
break;
- case SPT_COLOR:
+ case STYLE_PROPERTY_TYPE_COLOR:
sprop.u.foreground_color = cho_color_parse(dir_value);
if (sprop.u.foreground_color == NULL) {
cho_log(&ctx, LOG_ERR, "Font directive '%s' has an invalid value.", directive_name);
return NULL;
}
- sprop.type = SPT_COLOR;
+ sprop.type = STYLE_PROPERTY_TYPE_COLOR;
break;
default:
cho_log(&ctx, LOG_ERR, "Invalid style property type '%d'.", directive->sprop);
@@ -5730,17 +5642,17 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
LOG_DEBUG("cho_style_change_default failed.");
return NULL;
}
- if (sprop.type == SPT_FONT) {
+ if (sprop.type == STYLE_PROPERTY_TYPE_FONT) {
free(sprop.u.font_name);
- } else if (sprop.type == SPT_COLOR) {
+ } else if (sprop.type == STYLE_PROPERTY_TYPE_COLOR) {
free(sprop.u.foreground_color);
}
free(dir_value);
break;
}
- case DT_CHORD: {
+ case DIRECTIVE_TYPE_CHORD: {
switch (directive->ctype) {
- case TRANSPOSE:
+ case CHORD_DIRECTIVE_TRANSPOSE:
if (!transposition_parse(directive_value, &transpose)) {
LOG_DEBUG("transposition_parse failed.");
cho_log(&ctx, LOG_ERR, "Directive 'transpose' has an invalid value.");
@@ -5751,7 +5663,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
ctx.transpose = &ctx.transpose_history[ctx.th];
ctx.th++;
break;
- case DEFINE:
+ case CHORD_DIRECTIVE_DEFINE:
diagram = cho_chord_diagram_parse(&ctx, directive_value, ctx.songs[ctx.so]->diagrams, ctx.dia);
if (!diagram) {
LOG_DEBUG("cho_chord_diagram_parse failed.");
@@ -5765,13 +5677,13 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- case DT_OUTPUT:
+ case DIRECTIVE_TYPE_OUTPUT:
cho_log(&ctx, LOG_ERR, "Directive '%s' can't have a value.", directive_name);
return NULL;
- case DT_EXTENSION:
+ case DIRECTIVE_TYPE_EXTENSION:
// INFO: Such a directive should not be logged.
break;
- case DT_CUSTOM:
+ case DIRECTIVE_TYPE_CUSTOM:
cho_log(&ctx, LOG_INFO, "Ignoring custom directive '%s'.", directive_name);
break;
default:
@@ -5779,10 +5691,10 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
return NULL;
}
switch (directive->stype) {
- case ST_TAB:
+ case SECTION_TYPE_TAB:
ctx.state = STATE_TAB;
break;
- case ST_GRID:
+ case SECTION_TYPE_GRID:
ctx.state = STATE_GRID;
break;
default:
@@ -5832,7 +5744,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
chord[ctx.ch] = 0;
ctx.ch = 0;
ctx.prev_ttype = ctx.current_ttype;
- ctx.current_ttype = TT_CHORD;
+ ctx.current_ttype = TEXT_TYPE_CHORD;
if (ctx.is_chord_already_initialized) {
ctx.text_above_pos = cho_line_compute_text_above_position(ctx.songs[ctx.so]->sections[ctx.se]->lines[ctx.li], ctx.lii, ctx.te);
(*lines)[ctx.li]->text_above[ctx.lia]->position = ctx.text_above_pos;
@@ -5854,7 +5766,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
cho_log(&ctx, LOG_INFO, "Didn't recognize the chord '%s'.", (*lines)[ctx.li]->text_above[ctx.lia]->u.chord->name);
}
}
- ctx.songs[ctx.so]->present_text_types[TT_CHORD] = true;
+ ctx.songs[ctx.so]->present_text_types[TEXT_TYPE_CHORD] = true;
memset(chord, 0, strlen(chord));
ctx.lia++;
ctx.current_ttype = ctx.prev_ttype;
@@ -5863,7 +5775,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
if (prev_c == '[' && c == '*') {
ctx.prev_ttype = ctx.current_ttype;
- ctx.current_ttype = TT_ANNOT;
+ ctx.current_ttype = TEXT_TYPE_ANNOT;
(*lines)[ctx.li]->text_above = erealloc((*lines)[ctx.li]->text_above, (ctx.lia+1) * sizeof(struct ChoLineItemAbove *));
(*lines)[ctx.li]->text_above[ctx.lia] = emalloc(sizeof(struct ChoLineItemAbove));
(*lines)[ctx.li]->text_above[ctx.lia]->is_chord = false;
@@ -5912,7 +5824,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
if (c == ']') {
(*lines)[ctx.li]->text_above[ctx.lia]->u.annot->text = erealloc((*lines)[ctx.li]->text_above[ctx.lia]->u.annot->text, (ctx.ann+1) * sizeof(char));
(*lines)[ctx.li]->text_above[ctx.lia]->u.annot->text[ctx.ann] = 0;
- ctx.songs[ctx.so]->present_text_types[TT_ANNOT] = true;
+ ctx.songs[ctx.so]->present_text_types[TEXT_TYPE_ANNOT] = true;
ctx.ann = 0;
ctx.lia++;
ctx.current_ttype = ctx.prev_ttype;
@@ -5967,7 +5879,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
(*lines)[ctx.li] = cho_line_new();
(*lines)[ctx.li]->items = emalloc(sizeof(struct ChoLineItem *));
(*lines)[ctx.li]->items[ctx.lii] = cho_line_item_new(&ctx);
- ctx.current_ttype = TT_TEXT;
+ ctx.current_ttype = TEXT_TYPE_TEXT;
ctx.state = STATE_LYRICS;
break;
} else {
@@ -6031,7 +5943,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
if (ctx.lii == 0) {
if (
!(*lines)[ctx.li]->text_above &&
- (*lines)[ctx.li]->btype == BT_LINE
+ (*lines)[ctx.li]->btype == BREAK_TYPE_LINE
) {
free((*lines)[ctx.li]->items);
free((*lines)[ctx.li]);
@@ -6090,7 +6002,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
cho_log(&ctx, LOG_ERR, "Invalid token '%s' in grid section.", grid_token);
return NULL;
}
- if (token == GT_BAR_LINE_SYMBOL) {
+ if (token == GRID_TOKEN_BAR_LINE_SYMBOL) {
ctx.grid.bar_line_symbol_count++;
ctx.grid.bar_line_symbol_in_line_count++;
if (ctx.grid.bar_line_symbol_count == 2) {
@@ -6112,11 +6024,11 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
} else {
ctx.grid.tokens_per_cell++;
}
- if (token == GT_PLACEHOLDER) {
+ if (token == GRID_TOKEN_PLACEHOLDER) {
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = strdup(" ");
} else {
ctx.prev_ttype = ctx.current_ttype;
- ctx.current_ttype = TT_GRID;
+ ctx.current_ttype = TEXT_TYPE_GRID;
cho_style_free((*lines)[ctx.li]->items[ctx.lii]->u.text->style);
(*lines)[ctx.li]->items[ctx.lii]->u.text->style = cho_style_new_default(&ctx);
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = strdup(grid_token);
@@ -6149,7 +6061,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
cho_log(&ctx, LOG_ERR, "Invalid token '%s' in grid section.", grid_token);
return NULL;
}
- if (token == GT_BAR_LINE_SYMBOL) {
+ if (token == GRID_TOKEN_BAR_LINE_SYMBOL) {
ctx.grid.bar_line_symbol_count++;
ctx.grid.bar_line_symbol_in_line_count++;
if (ctx.grid.bar_line_symbol_count == 2) {
@@ -6171,11 +6083,11 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
} else {
ctx.grid.tokens_per_cell++;
}
- if (token == GT_PLACEHOLDER) {
+ if (token == GRID_TOKEN_PLACEHOLDER) {
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = strdup(" ");
} else {
ctx.prev_ttype = ctx.current_ttype;
- ctx.current_ttype = TT_GRID;
+ ctx.current_ttype = TEXT_TYPE_GRID;
cho_style_free((*lines)[ctx.li]->items[ctx.lii]->u.text->style);
(*lines)[ctx.li]->items[ctx.lii]->u.text->style = cho_style_new_default(&ctx);
(*lines)[ctx.li]->items[ctx.lii]->u.text->text = strdup(grid_token);
@@ -6426,7 +6338,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
cho_log(&ctx, LOG_ERR, "Newline character inside an attribute value is invalid.");
return NULL;
}
- if (avs == AVS_UNINITIALIZED) {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED) {
if (is_whitespace(c)) {
cho_log(&ctx, LOG_ERR, "Whitespace character after equals sign is invalid.");
return NULL;
@@ -6436,11 +6348,11 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
return NULL;
}
if (c == '\'') {
- avs = AVS_APOSTROPHE;
+ avs = ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE;
} else if (c == '"') {
- avs = AVS_QUOTATION_MARK;
+ avs = ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK;
} else {
- avs = AVS_UNQUOTED;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNQUOTED;
if (c == '%') {
ctx.state_before_metadata_substitution = STATE_MARKUP_ATTR_VALUE;
ctx.state = STATE_MAYBE_METADATA_SUBSTITUTION;
@@ -6452,7 +6364,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
break;
}
- if (avs == AVS_UNQUOTED && c == '>') {
+ if (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED && c == '>') {
ctx.tags[ctx.ta]->attrs[ctx.at]->value = erealloc(ctx.tags[ctx.ta]->attrs[ctx.at]->value, (ctx.atv+1) * sizeof(char));
ctx.tags[ctx.ta]->attrs[ctx.at]->value[ctx.atv] = 0;
ctx.atv = 0;
@@ -6500,15 +6412,15 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
}
}
ctx.at = 0;
- avs = AVS_UNINITIALIZED;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
memset(tag_start, 0, strlen(tag_start));
ctx.state = ctx.state_before_tag;
break;
}
if (
- (avs == AVS_APOSTROPHE && c == '\'') ||
- (avs == AVS_QUOTATION_MARK && c == '"') ||
- (avs == AVS_UNQUOTED && (c == ' ' || c == '\t'))
+ (avs == ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE && c == '\'') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK && c == '"') ||
+ (avs == ATTRIBUTE_VALUE_SYNTAX_UNQUOTED && (c == ' ' || c == '\t'))
) {
ctx.tags[ctx.ta]->attrs[ctx.at]->value = erealloc(ctx.tags[ctx.ta]->attrs[ctx.at]->value, (ctx.atv+1) * sizeof(char));
ctx.tags[ctx.ta]->attrs[ctx.at]->value[ctx.atv] = 0;
@@ -6516,7 +6428,7 @@ cho_songs_parse(const char *str, const char *chordpro_filepath, struct Config *c
ctx.at++;
ctx.tags[ctx.ta]->attrs = erealloc(ctx.tags[ctx.ta]->attrs, (ctx.at+1) * sizeof(struct Attr *));
ctx.tags[ctx.ta]->attrs[ctx.at] = cho_tag_attr_new();
- avs = AVS_UNINITIALIZED;
+ avs = ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED;
ctx.state = STATE_MARKUP_ATTR_NAME;
break;
}
diff --git a/src/chordpro.h b/src/chordpro.h
@@ -15,72 +15,74 @@
#define CHORD_LEN 15
enum AttrValueSyntax {
- AVS_UNINITIALIZED,
- AVS_QUOTATION_MARK,
- AVS_APOSTROPHE,
- AVS_UNQUOTED
+ ATTRIBUTE_VALUE_SYNTAX_UNINITIALIZED,
+ ATTRIBUTE_VALUE_SYNTAX_QUOTATION_MARK,
+ ATTRIBUTE_VALUE_SYNTAX_APOSTROPHE,
+ ATTRIBUTE_VALUE_SYNTAX_UNQUOTED
};
enum ChordDiagramState {
- CDS_NAME,
- CDS_OPTION_NAME,
- CDS_BASE_FRET,
- CDS_FRETS,
- CDS_FINGERS,
- CDS_KEYS,
- CDS_DIAGRAM,
- CDS_COPY,
- CDS_DISPLAY
+ CHORD_DIAGRAM_STATE_NAME,
+ CHORD_DIAGRAM_STATE_OPTION_NAME,
+ CHORD_DIAGRAM_STATE_BASE_FRET,
+ CHORD_DIAGRAM_STATE_FRETS,
+ CHORD_DIAGRAM_STATE_FINGERS,
+ CHORD_DIAGRAM_STATE_KEYS,
+ CHORD_DIAGRAM_STATE_DIAGRAM,
+ CHORD_DIAGRAM_STATE_COPY,
+ CHORD_DIAGRAM_STATE_DISPLAY
};
enum MetadataSubstitutionState {
- MSS_NAME,
- MSS_NAME_OR_INDEX,
- MSS_INDEX,
- MSS_VALUE,
- MSS_TRUE_TEXT,
- MSS_FALSE_TEXT,
- MSS_WAIT_FOR_PIPE
+ METADATA_SUBSTITUTION_STATE_NAME,
+ METADATA_SUBSTITUTION_STATE_NAME_OR_INDEX,
+ METADATA_SUBSTITUTION_STATE_INDEX,
+ METADATA_SUBSTITUTION_STATE_VALUE,
+ METADATA_SUBSTITUTION_STATE_TRUE_TEXT,
+ METADATA_SUBSTITUTION_STATE_FALSE_TEXT,
+ METADATA_SUBSTITUTION_STATE_WAIT_FOR_PIPE
};
enum ChordDirective {
- TRANSPOSE, DEFINE /* , CHORD */
+ CHORD_DIRECTIVE_TRANSPOSE,
+ CHORD_DIRECTIVE_DEFINE,
+ /* CHORD_DIRECTIVE_CHORD */
};
enum DirectiveType {
- DT_ENVIRONMENT,
- DT_METADATA,
- DT_FORMATTING,
- DT_IMAGE,
- DT_PREAMBLE,
- DT_FONT,
- DT_CHORD,
- DT_OUTPUT,
- DT_EXTENSION,
- DT_CUSTOM
+ DIRECTIVE_TYPE_ENVIRONMENT,
+ DIRECTIVE_TYPE_METADATA,
+ DIRECTIVE_TYPE_FORMATTING,
+ DIRECTIVE_TYPE_IMAGE,
+ DIRECTIVE_TYPE_PREAMBLE,
+ DIRECTIVE_TYPE_FONT,
+ DIRECTIVE_TYPE_CHORD,
+ DIRECTIVE_TYPE_OUTPUT,
+ DIRECTIVE_TYPE_EXTENSION,
+ DIRECTIVE_TYPE_CUSTOM
};
enum GridToken {
- GT_CHORD,
- GT_BAR_LINE_SYMBOL,
- GT_PLACEHOLDER
+ GRID_TOKEN_CHORD,
+ GRID_TOKEN_BAR_LINE_SYMBOL,
+ GRID_TOKEN_PLACEHOLDER
};
enum MetadataDirective {
- MD_TITLE,
- MD_SUBTITLE,
- MD_OTHER
+ METADATA_DIRECTIVE_TITLE,
+ METADATA_DIRECTIVE_SUBTITLE,
+ METADATA_DIRECTIVE_OTHER
};
enum OptionState {
- OS_NAME,
- OS_VALUE
+ OPTION_STATE_NAME,
+ OPTION_STATE_VALUE
};
enum Position {
- POS_START,
- POS_END,
- POS_NO
+ POSITION_START,
+ POSITION_END,
+ POSITION_NO
};
enum State {
@@ -103,9 +105,9 @@ enum State {
};
enum StylePropertyType {
- SPT_FONT,
- SPT_SIZE,
- SPT_COLOR
+ STYLE_PROPERTY_TYPE_FONT,
+ STYLE_PROPERTY_TYPE_SIZE,
+ STYLE_PROPERTY_TYPE_COLOR
};
struct Attr {
diff --git a/src/config.c b/src/config.c
@@ -116,72 +116,72 @@ static enum TextType
config_text_type_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, text_types[TT_CHORD])) {
- return TT_CHORD;
+ if (!strcmp(str, text_types[TEXT_TYPE_CHORD])) {
+ return TEXT_TYPE_CHORD;
} else
- if (!strcmp(str, text_types[TT_ANNOT])) {
- return TT_ANNOT;
+ if (!strcmp(str, text_types[TEXT_TYPE_ANNOT])) {
+ return TEXT_TYPE_ANNOT;
} else
- if (!strcmp(str, text_types[TT_CHORUS])) {
- return TT_CHORUS;
+ if (!strcmp(str, text_types[TEXT_TYPE_CHORUS])) {
+ return TEXT_TYPE_CHORUS;
} else
- if (!strcmp(str, text_types[TT_FOOTER])) {
- return TT_FOOTER;
+ if (!strcmp(str, text_types[TEXT_TYPE_FOOTER])) {
+ return TEXT_TYPE_FOOTER;
} else
- if (!strcmp(str, text_types[TT_GRID])) {
- return TT_GRID;
+ if (!strcmp(str, text_types[TEXT_TYPE_GRID])) {
+ return TEXT_TYPE_GRID;
} else
- if (!strcmp(str, text_types[TT_TAB])) {
- return TT_TAB;
+ if (!strcmp(str, text_types[TEXT_TYPE_TAB])) {
+ return TEXT_TYPE_TAB;
} else
- if (!strcmp(str, text_types[TT_TOC])) {
- return TT_TOC;
+ if (!strcmp(str, text_types[TEXT_TYPE_TOC])) {
+ return TEXT_TYPE_TOC;
} else
- if (!strcmp(str, text_types[TT_TOC_TITLE])) {
- return TT_TOC_TITLE;
+ if (!strcmp(str, text_types[TEXT_TYPE_TOC_TITLE])) {
+ return TEXT_TYPE_TOC_TITLE;
} else
- if (!strcmp(str, text_types[TT_TEXT])) {
- return TT_TEXT;
+ if (!strcmp(str, text_types[TEXT_TYPE_TEXT])) {
+ return TEXT_TYPE_TEXT;
} else
- if (!strcmp(str, text_types[TT_TITLE])) {
- return TT_TITLE;
+ if (!strcmp(str, text_types[TEXT_TYPE_TITLE])) {
+ return TEXT_TYPE_TITLE;
} else
- if (!strcmp(str, text_types[TT_SUBTITLE])) {
- return TT_SUBTITLE;
+ if (!strcmp(str, text_types[TEXT_TYPE_SUBTITLE])) {
+ return TEXT_TYPE_SUBTITLE;
} else
- if (!strcmp(str, text_types[TT_LABEL])) {
- return TT_LABEL;
+ if (!strcmp(str, text_types[TEXT_TYPE_LABEL])) {
+ return TEXT_TYPE_LABEL;
} else
- if (!strcmp(str, text_types[TT_COMMENT])) {
- return TT_COMMENT;
+ if (!strcmp(str, text_types[TEXT_TYPE_COMMENT])) {
+ return TEXT_TYPE_COMMENT;
} else
- if (!strcmp(str, text_types[TT_COMMENT_ITALIC])) {
- return TT_COMMENT_ITALIC;
+ if (!strcmp(str, text_types[TEXT_TYPE_COMMENT_ITALIC])) {
+ return TEXT_TYPE_COMMENT_ITALIC;
} else
- if (!strcmp(str, text_types[TT_COMMENT_BOX])) {
- return TT_COMMENT_BOX;
+ if (!strcmp(str, text_types[TEXT_TYPE_COMMENT_BOX])) {
+ return TEXT_TYPE_COMMENT_BOX;
}
*error = true;
- return TT_CHORD; // unused
+ return TEXT_TYPE_CHORD; // unused
}
static enum NotationSystem
config_notation_system_parse(const char *str)
{
- if (!strcmp(str, notation_systems[NS_COMMON]) || !strcmp(str, "dutch")) {
- return NS_COMMON;
- } else if (!strcmp(str, notation_systems[NS_GERMAN])) {
- return NS_GERMAN;
- } else if (!strcmp(str, notation_systems[NS_SCANDINAVIAN])) {
- return NS_SCANDINAVIAN;
- } else if (!strcmp(str, notation_systems[NS_LATIN])) {
- return NS_LATIN;
- } else if (!strcmp(str, notation_systems[NS_ROMAN])) {
- return NS_ROMAN;
- } else if (!strcmp(str, notation_systems[NS_NASHVILLE])) {
- return NS_NASHVILLE;
+ if (!strcmp(str, notation_systems[NOTATION_SYSTEM_COMMON]) || !strcmp(str, "dutch")) {
+ return NOTATION_SYSTEM_COMMON;
+ } else if (!strcmp(str, notation_systems[NOTATION_SYSTEM_GERMAN])) {
+ return NOTATION_SYSTEM_GERMAN;
+ } else if (!strcmp(str, notation_systems[NOTATION_SYSTEM_SCANDINAVIAN])) {
+ return NOTATION_SYSTEM_SCANDINAVIAN;
+ } else if (!strcmp(str, notation_systems[NOTATION_SYSTEM_LATIN])) {
+ return NOTATION_SYSTEM_LATIN;
+ } else if (!strcmp(str, notation_systems[NOTATION_SYSTEM_ROMAN])) {
+ return NOTATION_SYSTEM_ROMAN;
+ } else if (!strcmp(str, notation_systems[NOTATION_SYSTEM_NASHVILLE])) {
+ return NOTATION_SYSTEM_NASHVILLE;
}
- return NS_CUSTOM;
+ return NOTATION_SYSTEM_CUSTOM;
}
static const char *
@@ -194,20 +194,20 @@ static enum Instrument
config_instrument_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, instruments[INS_GUITAR].name)) {
- return INS_GUITAR;
+ if (!strcmp(str, instruments[INSTRUMENT_GUITAR].name)) {
+ return INSTRUMENT_GUITAR;
} else
- if (!strcmp(str, instruments[INS_KEYBOARD].name)) {
- return INS_KEYBOARD;
+ if (!strcmp(str, instruments[INSTRUMENT_KEYBOARD].name)) {
+ return INSTRUMENT_KEYBOARD;
} else
- if (!strcmp(str, instruments[INS_MANDOLIN].name)) {
- return INS_MANDOLIN;
+ if (!strcmp(str, instruments[INSTRUMENT_MANDOLIN].name)) {
+ return INSTRUMENT_MANDOLIN;
} else
- if (!strcmp(str, instruments[INS_UKULELE].name)) {
- return INS_UKULELE;
+ if (!strcmp(str, instruments[INSTRUMENT_UKULELE].name)) {
+ return INSTRUMENT_UKULELE;
}
*error = true;
- return INS_GUITAR;
+ return INSTRUMENT_GUITAR;
}
static const char *
@@ -265,19 +265,19 @@ config_notes_new_default(enum NotationSystem system)
struct Note **notes_default = emalloc(8 * sizeof(struct Note *));
struct Note *notes;
switch (system) {
- case NS_GERMAN:
+ case NOTATION_SYSTEM_GERMAN:
notes = (struct Note *)¬es_german;
break;
- case NS_SCANDINAVIAN:
+ case NOTATION_SYSTEM_SCANDINAVIAN:
notes = (struct Note *)¬es_scandinavian;
break;
- case NS_LATIN:
+ case NOTATION_SYSTEM_LATIN:
notes = (struct Note *)¬es_latin;
break;
- case NS_ROMAN:
+ case NOTATION_SYSTEM_ROMAN:
notes = (struct Note *)¬es_roman;
break;
- case NS_NASHVILLE:
+ case NOTATION_SYSTEM_NASHVILLE:
notes = (struct Note *)¬es_nashville;
break;
default:
@@ -362,25 +362,25 @@ config_notes_print_as_toml(enum NotationSystem system)
{
struct Note *notes;
switch (system) {
- case NS_COMMON:
+ case NOTATION_SYSTEM_COMMON:
notes = (struct Note *)¬es_common;
break;
- case NS_GERMAN:
+ case NOTATION_SYSTEM_GERMAN:
notes = (struct Note *)¬es_german;
break;
- case NS_SCANDINAVIAN:
+ case NOTATION_SYSTEM_SCANDINAVIAN:
notes = (struct Note *)¬es_scandinavian;
break;
- case NS_LATIN:
+ case NOTATION_SYSTEM_LATIN:
notes = (struct Note *)¬es_latin;
break;
- case NS_ROMAN:
+ case NOTATION_SYSTEM_ROMAN:
notes = (struct Note *)¬es_roman;
break;
- case NS_NASHVILLE:
+ case NOTATION_SYSTEM_NASHVILLE:
notes = (struct Note *)¬es_nashville;
break;
- case NS_CUSTOM:
+ case NOTATION_SYSTEM_CUSTOM:
return;
}
printf("%s = [\n", config_notation_system_to_config_string(system));
@@ -408,17 +408,17 @@ static enum Alignment
config_alignment_parse(const char *str, bool *error)
{
*error = false;
- if (!strcmp(str, alignments[A_LEFT])) {
- return A_LEFT;
+ if (!strcmp(str, alignments[ALIGNMENT_LEFT])) {
+ return ALIGNMENT_LEFT;
} else
- if (!strcmp(str, alignments[A_CENTER])) {
- return A_CENTER;
+ if (!strcmp(str, alignments[ALIGNMENT_CENTER])) {
+ return ALIGNMENT_CENTER;
} else
- if (!strcmp(str, alignments[A_RIGHT])) {
- return A_RIGHT;
+ if (!strcmp(str, alignments[ALIGNMENT_RIGHT])) {
+ return ALIGNMENT_RIGHT;
}
*error = true;
- return A_LEFT; // unused
+ return ALIGNMENT_LEFT; // unused
}
static const char *
@@ -433,12 +433,12 @@ config_print_default(void)
struct Config *config = config_load_default();
printf("metadata_separator = \"%s\"\n\n", config->metadata_separator);
printf("[notation_systems]\n");
- config_notes_print_as_toml(NS_COMMON);
- config_notes_print_as_toml(NS_GERMAN);
- config_notes_print_as_toml(NS_SCANDINAVIAN);
- config_notes_print_as_toml(NS_LATIN);
- config_notes_print_as_toml(NS_ROMAN);
- config_notes_print_as_toml(NS_NASHVILLE);
+ config_notes_print_as_toml(NOTATION_SYSTEM_COMMON);
+ config_notes_print_as_toml(NOTATION_SYSTEM_GERMAN);
+ config_notes_print_as_toml(NOTATION_SYSTEM_SCANDINAVIAN);
+ config_notes_print_as_toml(NOTATION_SYSTEM_LATIN);
+ config_notes_print_as_toml(NOTATION_SYSTEM_ROMAN);
+ config_notes_print_as_toml(NOTATION_SYSTEM_NASHVILLE);
printf("[parser]\n");
printf("[parser.chords]\n");
@@ -462,7 +462,7 @@ config_print_default(void)
printf("title = \"%s\"\n\n", config->output->toc->title);
printf("[output.styles]\n");
int i;
- for (i = 1; i<TT_LENGTH; i++) {
+ for (i = 1; i<TEXT_TYPE_LENGTH; i++) {
printf("[output.styles.%s]\n\n", text_types[i]);
cho_style_print_as_toml(config->output->styles[i], text_types[i]);
}
@@ -793,11 +793,11 @@ lyrics_set_text_style_as_default(
struct ChoStyle *style, *text_style;
struct ChoStylePresence *presence, *text_presence;
enum TextType lyric_types[] = {
- TT_CHORUS, TT_COMMENT,
- TT_COMMENT_ITALIC, TT_COMMENT_BOX
+ TEXT_TYPE_CHORUS, TEXT_TYPE_COMMENT,
+ TEXT_TYPE_COMMENT_ITALIC, TEXT_TYPE_COMMENT_BOX
};
- text_presence = &presences[TT_TEXT];
- text_style = styles[TT_TEXT];
+ text_presence = &presences[TEXT_TYPE_TEXT];
+ text_style = styles[TEXT_TYPE_TEXT];
size_t i;
for (i = 0; i<LENGTH(lyric_types); i++) {
presence = &presences[lyric_types[i]];
@@ -814,73 +814,73 @@ config_load_default(void)
config->parser = emalloc(sizeof(struct ConfigParser));
config->parser->chords = emalloc(sizeof(struct ConfigChords));
- config->parser->chords->notation_system = NS_COMMON;
- config->parser->chords->mode = PM_STRICT;
- config->parser->notes = config_notes_new_default(NS_COMMON);
+ config->parser->chords->notation_system = NOTATION_SYSTEM_COMMON;
+ config->parser->chords->mode = PARSE_MODE_STRICT;
+ config->parser->notes = config_notes_new_default(NOTATION_SYSTEM_COMMON);
config->output = emalloc(sizeof(struct ConfigOutput));
- config->output->notation_system = NS_COMMON;
+ config->output->notation_system = NOTATION_SYSTEM_COMMON;
config->output->start_song_on_new_page = true;
- config->output->notes = config_notes_new_default(NS_COMMON);
+ config->output->notes = config_notes_new_default(NOTATION_SYSTEM_COMMON);
config->output->chorus = emalloc(sizeof(struct ConfigChorus));
config->output->chorus->label = strdup("Chorus");
config->output->chorus->quote = false;
config->output->diagram = emalloc(sizeof(struct ChordDiagram));
config->output->diagram->show = true;
- config->output->diagram->instrument = INS_GUITAR;
+ config->output->diagram->instrument = INSTRUMENT_GUITAR;
config->output->page_no = emalloc(sizeof(struct ConfigPageNo));
config->output->page_no->show = true;
- config->output->page_no->align = A_CENTER;
+ config->output->page_no->align = ALIGNMENT_CENTER;
config->output->toc = emalloc(sizeof(struct ConfigToc));
config->output->toc->show = false;
config->output->toc->title = strdup("Table Of Contents");
- config->output->styles[TT_CHORD] = cho_style_new();
- config->output->styles[TT_CHORD]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_CHORD]->font->weight = FW_BOLD;
- config->output->styles[TT_ANNOT] = cho_style_new();
- config->output->styles[TT_ANNOT]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_ANNOT]->font->style = FS_ITALIC;
- config->output->styles[TT_CHORUS] = cho_style_new();
- config->output->styles[TT_CHORUS]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_FOOTER] = cho_style_new();
- config->output->styles[TT_FOOTER]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_GRID] = cho_style_new();
- config->output->styles[TT_GRID]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_GRID]->font->weight = FW_BOLD;
- config->output->styles[TT_TAB] = cho_style_new();
- config->output->styles[TT_TAB]->font->name = strdup("Courier");
- // config->output->styles[TT_TAB]->font->family = FF_MONOSPACE;
- config->output->styles[TT_TOC] = cho_style_new();
- config->output->styles[TT_TOC]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_TOC]->font->size = 12.0;
- config->output->styles[TT_TOC_TITLE] = cho_style_new();
- config->output->styles[TT_TOC_TITLE]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_TOC_TITLE]->font->weight = FW_BOLD;
- config->output->styles[TT_TOC_TITLE]->font->size = 18.0;
- config->output->styles[TT_TEXT] = cho_style_new();
- config->output->styles[TT_TEXT]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_TITLE] = cho_style_new();
- config->output->styles[TT_TITLE]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_TITLE]->font->weight = FW_BOLD;
- config->output->styles[TT_TITLE]->font->size = 18.0;
- config->output->styles[TT_SUBTITLE] = cho_style_new();
- config->output->styles[TT_SUBTITLE]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_SUBTITLE]->font->size = 12.0;
- config->output->styles[TT_LABEL] = cho_style_new();
- config->output->styles[TT_LABEL]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_LABEL]->font->style = FS_ITALIC;
- config->output->styles[TT_COMMENT] = cho_style_new();
- config->output->styles[TT_COMMENT]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_COMMENT]->background_color->red = 228;
- config->output->styles[TT_COMMENT]->background_color->green = 228;
- config->output->styles[TT_COMMENT]->background_color->blue = 228;
- config->output->styles[TT_COMMENT_ITALIC] = cho_style_new();
- config->output->styles[TT_COMMENT_ITALIC]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_COMMENT_ITALIC]->font->style = FS_ITALIC;
- config->output->styles[TT_COMMENT_BOX] = cho_style_new();
- config->output->styles[TT_COMMENT_BOX]->font->name = strdup(DEFAULT_FONT);
- config->output->styles[TT_COMMENT_BOX]->boxed = true;
+ config->output->styles[TEXT_TYPE_CHORD] = cho_style_new();
+ config->output->styles[TEXT_TYPE_CHORD]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_CHORD]->font->weight = FONT_WEIGHT_BOLD;
+ config->output->styles[TEXT_TYPE_ANNOT] = cho_style_new();
+ config->output->styles[TEXT_TYPE_ANNOT]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_ANNOT]->font->style = FONT_STYLE_ITALIC;
+ config->output->styles[TEXT_TYPE_CHORUS] = cho_style_new();
+ config->output->styles[TEXT_TYPE_CHORUS]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_FOOTER] = cho_style_new();
+ config->output->styles[TEXT_TYPE_FOOTER]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_GRID] = cho_style_new();
+ config->output->styles[TEXT_TYPE_GRID]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_GRID]->font->weight = FONT_WEIGHT_BOLD;
+ config->output->styles[TEXT_TYPE_TAB] = cho_style_new();
+ config->output->styles[TEXT_TYPE_TAB]->font->name = strdup("Courier");
+ // config->output->styles[TEXT_TYPE_TAB]->font->family = FONT_FAMILY_MONOSPACE;
+ config->output->styles[TEXT_TYPE_TOC] = cho_style_new();
+ config->output->styles[TEXT_TYPE_TOC]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_TOC]->font->size = 12.0;
+ config->output->styles[TEXT_TYPE_TOC_TITLE] = cho_style_new();
+ config->output->styles[TEXT_TYPE_TOC_TITLE]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_TOC_TITLE]->font->weight = FONT_WEIGHT_BOLD;
+ config->output->styles[TEXT_TYPE_TOC_TITLE]->font->size = 18.0;
+ config->output->styles[TEXT_TYPE_TEXT] = cho_style_new();
+ config->output->styles[TEXT_TYPE_TEXT]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_TITLE] = cho_style_new();
+ config->output->styles[TEXT_TYPE_TITLE]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_TITLE]->font->weight = FONT_WEIGHT_BOLD;
+ config->output->styles[TEXT_TYPE_TITLE]->font->size = 18.0;
+ config->output->styles[TEXT_TYPE_SUBTITLE] = cho_style_new();
+ config->output->styles[TEXT_TYPE_SUBTITLE]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_SUBTITLE]->font->size = 12.0;
+ config->output->styles[TEXT_TYPE_LABEL] = cho_style_new();
+ config->output->styles[TEXT_TYPE_LABEL]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_LABEL]->font->style = FONT_STYLE_ITALIC;
+ config->output->styles[TEXT_TYPE_COMMENT] = cho_style_new();
+ config->output->styles[TEXT_TYPE_COMMENT]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_COMMENT]->background_color->red = 228;
+ config->output->styles[TEXT_TYPE_COMMENT]->background_color->green = 228;
+ config->output->styles[TEXT_TYPE_COMMENT]->background_color->blue = 228;
+ config->output->styles[TEXT_TYPE_COMMENT_ITALIC] = cho_style_new();
+ config->output->styles[TEXT_TYPE_COMMENT_ITALIC]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_COMMENT_ITALIC]->font->style = FONT_STYLE_ITALIC;
+ config->output->styles[TEXT_TYPE_COMMENT_BOX] = cho_style_new();
+ config->output->styles[TEXT_TYPE_COMMENT_BOX]->font->name = strdup(DEFAULT_FONT);
+ config->output->styles[TEXT_TYPE_COMMENT_BOX]->boxed = true;
return config;
}
@@ -952,7 +952,7 @@ config_load(toml_table_t *toml, const char *filepath)
value = toml_table_string(output, "notation_system");
if (value.ok) {
notation_system = config_notation_system_parse(value.u.s);
- if (notation_system == NS_CUSTOM) {
+ if (notation_system == NOTATION_SYSTEM_CUSTOM) {
notes = toml_table_table(toml, "notation_systems");
if (!notes) {
config_log(&ctx, LOG_ERR, "[output]", "Custom notation system '%s' has no corresponding definition in [notation_systems]");
@@ -1000,7 +1000,7 @@ config_load(toml_table_t *toml, const char *filepath)
const char *key_name;
enum TextType ttype;
struct ChoStyle *style;
- struct ChoStylePresence presences[TT_LENGTH] = {0};
+ struct ChoStylePresence presences[TEXT_TYPE_LENGTH] = {0};
toml_table_t *key;
for (i = 0; i<toml_table_len(styles); i++) {
key_name = toml_table_key(styles, i, &unused);
@@ -1034,7 +1034,7 @@ config_load(toml_table_t *toml, const char *filepath)
value = toml_table_string(chords, "notation_system");
if (value.ok) {
notation_system = config_notation_system_parse(value.u.s);
- if (notation_system == NS_CUSTOM) {
+ if (notation_system == NOTATION_SYSTEM_CUSTOM) {
notes = toml_table_table(toml, "notation_systems");
if (!notes) {
config_log(&ctx, LOG_ERR, "[parser.chords]", "Custom notation system '%s' has no corresponding definition in [notation_systems].", value.u.s);
@@ -1058,9 +1058,9 @@ config_load(toml_table_t *toml, const char *filepath)
value = toml_table_string(chords, "mode");
if (value.ok) {
if (!strcmp(value.u.s, "strict")) {
- config->parser->chords->mode = PM_STRICT;
+ config->parser->chords->mode = PARSE_MODE_STRICT;
} else if (!strcmp(value.u.s, "relaxed")) {
- config->parser->chords->mode = PM_RELAXED;
+ config->parser->chords->mode = PARSE_MODE_RELAXED;
}
free(value.u.s);
}
@@ -1128,7 +1128,7 @@ config_free(struct Config *config)
free(config->output->chorus->label);
free(config->output->chorus);
int i;
- for (i = 0; i<TT_LENGTH; i++) {
+ for (i = 0; i<TEXT_TYPE_LENGTH; i++) {
cho_style_free(config->output->styles[i]);
}
config_notes_free(config->output->notes);
diff --git a/src/core.c b/src/core.c
@@ -361,15 +361,15 @@ file_type(const char *path)
{
struct stat s;
if (stat(path, &s) != 0) {
- return F_ERROR;
+ return FILE_TYPE_ERROR;
}
if (S_ISDIR(s.st_mode)) {
- return F_FOLDER;
+ return FILE_TYPE_FOLDER;
}
if (S_ISREG(s.st_mode)) {
- return F_REG_FILE;
+ return FILE_TYPE_REG_FILE;
}
- return F_OTHER;
+ return FILE_TYPE_OTHER;
}
char *
@@ -525,11 +525,11 @@ static const char *
size_type_to_string(enum SizeType type)
{
switch (type) {
- case ST_PERCENT:
+ case SIZE_TYPE_PERCENT:
return "%";
- case ST_EM:
+ case SIZE_TYPE_EM:
return "em";
- case ST_EX:
+ case SIZE_TYPE_EX:
return "ex";
default:
return "";
@@ -549,20 +549,20 @@ size_create(const char *str)
return NULL;
}
size->d = d;
- size->type = ST_POINT;
+ size->type = SIZE_TYPE_POINT;
if (len > 1 && str[len-1] == '%') {
if (size->d < 1.0 || size->d > 100.0) {
util_log(NULL, 0, LOG_ERR, "invalid percentage.");
return NULL;
}
size->d = d / 100.0;
- size->type = ST_PERCENT;
+ size->type = SIZE_TYPE_PERCENT;
} else
if (len > 2 && str[len-2] == 'e' && str[len-1] == 'm') {
- size->type = ST_EM;
+ size->type = SIZE_TYPE_EM;
} else
if (len > 2 && str[len-2] == 'e' && str[len-1] == 'x') {
- size->type = ST_EX;
+ size->type = SIZE_TYPE_EX;
}
return size;
}
@@ -592,37 +592,37 @@ const char *
is_base_font(struct Font *font)
{
if (!strcmp(font->name, "Courier")) {
- if (font->style == FS_ITALIC && font->weight == FW_BOLD) {
+ if (font->style == FONT_STYLE_ITALIC && font->weight == FONT_WEIGHT_BOLD) {
return "Courier-BoldItalic";
} else
- if (font->style == FS_ITALIC) {
+ if (font->style == FONT_STYLE_ITALIC) {
return "Courier-Italic";
} else
- if (font->weight == FW_BOLD) {
+ if (font->weight == FONT_WEIGHT_BOLD) {
return "Courier-Bold";
}
return "Courier";
} else
if (!strcmp(font->name, "Helvetica")) {
- if (font->style == FS_OBLIQUE && font->weight == FW_BOLD) {
+ if (font->style == FONT_STYLE_OBLIQUE && font->weight == FONT_WEIGHT_BOLD) {
return "Helvetica-BoldOblique";
} else
- if (font->style == FS_OBLIQUE) {
+ if (font->style == FONT_STYLE_OBLIQUE) {
return "Helvetica-Oblique";
} else
- if (font->weight == FW_BOLD) {
+ if (font->weight == FONT_WEIGHT_BOLD) {
return "Helvetica-Bold";
}
return "Helvetica";
} else
if (!strcmp(font->name, "Times")) {
- if (font->style == FS_ITALIC && font->weight == FW_BOLD) {
+ if (font->style == FONT_STYLE_ITALIC && font->weight == FONT_WEIGHT_BOLD) {
return "Times-BoldItalic";
} else
- if (font->style == FS_ITALIC) {
+ if (font->style == FONT_STYLE_ITALIC) {
return "Times-Italic";
} else
- if (font->weight == FW_BOLD) {
+ if (font->weight == FONT_WEIGHT_BOLD) {
return "Times-Bold";
}
return "Times-Roman";
diff --git a/src/core.h b/src/core.h
@@ -18,105 +18,141 @@
#define COLOR_BOLD_BLUE "\033[1;34m"
#define COLOR_RESET "\033[0m"
-enum TextType {
- TT_CHORD,
- TT_ANNOT,
- TT_CHORUS,
- TT_FOOTER,
- TT_GRID,
- TT_TAB,
- TT_TOC,
- TT_TOC_TITLE,
- TT_TEXT,
- TT_TITLE,
- TT_SUBTITLE,
- TT_LABEL,
- TT_COMMENT,
- TT_COMMENT_ITALIC,
- TT_COMMENT_BOX,
- TT_LENGTH
-};
-
enum Alignment {
- A_LEFT,
- A_CENTER,
- A_RIGHT
+ ALIGNMENT_LEFT,
+ ALIGNMENT_CENTER,
+ ALIGNMENT_RIGHT
};
enum Anchor {
- AN_PAPER,
- AN_PAGE,
- AN_COLUMN,
- AN_LINE,
- AN_FLOAT
+ ANCHOR_PAPER,
+ ANCHOR_PAGE,
+ ANCHOR_COLUMN,
+ ANCHOR_LINE,
+ ANCHOR_FLOAT
};
enum BreakType {
- BT_LINE,
- BT_PAGE,
- BT_COLUMN
+ BREAK_TYPE_LINE,
+ BREAK_TYPE_PAGE,
+ BREAK_TYPE_COLUMN
};
enum ChordDiagramContent {
- CDC_UNINITIALIZED,
- CDC_STRING,
- CDC_KEYBOARD,
- CDC_CHORD_MAP
+ CHORD_DIAGRAM_CONTENT_UNINITIALIZED,
+ CHORD_DIAGRAM_CONTENT_STRING,
+ CHORD_DIAGRAM_CONTENT_KEYBOARD,
+ CHORD_DIAGRAM_CONTENT_CHORD_MAP
};
enum ChordQualifier {
- CQ_MIN,
- CQ_MAJ,
- CQ_AUG,
- CQ_DIM
+ CHORD_QUALIFIER_MIN,
+ CHORD_QUALIFIER_MAJ,
+ CHORD_QUALIFIER_AUG,
+ CHORD_QUALIFIER_DIM
};
-enum SectionType {
- ST_UNINITIALIZED,
- ST_NEWSONG,
- ST_CHORUS,
- ST_VERSE,
- ST_BRIDGE,
- ST_TAB,
- ST_GRID,
- ST_CUSTOM
-};
-
-enum SizeType {
- ST_POINT,
- ST_PERCENT,
- ST_EM,
- ST_EX
+enum FileType {
+ FILE_TYPE_ERROR,
+ FILE_TYPE_FOLDER,
+ FILE_TYPE_REG_FILE,
+ FILE_TYPE_OTHER
};
enum FontFamily {
- FF_NORMAL,
- FF_SANS,
- FF_SERIF,
- FF_MONOSPACE
+ FONT_FAMILY_NORMAL,
+ FONT_FAMILY_SANS,
+ FONT_FAMILY_SERIF,
+ FONT_FAMILY_MONOSPACE
};
enum FontStyle {
- FS_ROMAN,
- FS_OBLIQUE,
- FS_ITALIC
+ FONT_STYLE_ROMAN,
+ FONT_STYLE_OBLIQUE,
+ FONT_STYLE_ITALIC
};
enum FontWeight {
- FW_REGULAR,
- FW_BOLD
+ FONT_WEIGHT_REGULAR,
+ FONT_WEIGHT_BOLD
+};
+
+enum Instrument {
+ INSTRUMENT_GUITAR,
+ INSTRUMENT_KEYBOARD,
+ INSTRUMENT_MANDOLIN,
+ INSTRUMENT_UKULELE
};
enum LineStyle {
- LS_SINGLE,
- LS_DOUBLE,
- LS_NONE
+ LINE_STYLE_SINGLE,
+ LINE_STYLE_DOUBLE,
+ LINE_STYLE_NONE
+};
+
+enum LogLevel {
+ LOG_INFO,
+ LOG_WARN,
+ LOG_ERR,
+ LOG_TODO
+};
+
+enum NotationSystem {
+ NOTATION_SYSTEM_COMMON,
+ NOTATION_SYSTEM_GERMAN,
+ NOTATION_SYSTEM_SCANDINAVIAN,
+ NOTATION_SYSTEM_LATIN,
+ NOTATION_SYSTEM_ROMAN,
+ NOTATION_SYSTEM_NASHVILLE,
+ NOTATION_SYSTEM_CUSTOM
};
enum NoteType {
- NT_NOTE,
- NT_SHARP,
- NT_FLAT
+ NOTE_TYPE_NOTE,
+ NOTE_TYPE_SHARP,
+ NOTE_TYPE_FLAT
+};
+
+enum ParseMode {
+ PARSE_MODE_STRICT,
+ PARSE_MODE_RELAXED
+};
+
+enum SectionType {
+ SECTION_TYPE_UNINITIALIZED,
+ SECTION_TYPE_NEWSONG,
+ SECTION_TYPE_CHORUS,
+ SECTION_TYPE_VERSE,
+ SECTION_TYPE_BRIDGE,
+ SECTION_TYPE_TAB,
+ SECTION_TYPE_GRID,
+ SECTION_TYPE_CUSTOM
+};
+
+enum SizeType {
+ SIZE_TYPE_POINT,
+ SIZE_TYPE_PERCENT,
+ SIZE_TYPE_EM,
+ SIZE_TYPE_EX
+};
+
+enum TextType {
+ TEXT_TYPE_CHORD,
+ TEXT_TYPE_ANNOT,
+ TEXT_TYPE_CHORUS,
+ TEXT_TYPE_FOOTER,
+ TEXT_TYPE_GRID,
+ TEXT_TYPE_TAB,
+ TEXT_TYPE_TOC,
+ TEXT_TYPE_TOC_TITLE,
+ TEXT_TYPE_TEXT,
+ TEXT_TYPE_TITLE,
+ TEXT_TYPE_SUBTITLE,
+ TEXT_TYPE_LABEL,
+ TEXT_TYPE_COMMENT,
+ TEXT_TYPE_COMMENT_ITALIC,
+ TEXT_TYPE_COMMENT_BOX,
+ TEXT_TYPE_LENGTH
};
struct FontPresence {
@@ -228,7 +264,7 @@ struct ChoSong {
struct ChoMetadata **metadata;
struct ChoSection **sections;
struct ChordDiagram **diagrams;
- bool present_text_types[TT_LENGTH];
+ bool present_text_types[TEXT_TYPE_LENGTH];
};
struct ChoImage {
@@ -286,28 +322,6 @@ struct ChordDiagram {
} u;
};
-enum NotationSystem {
- NS_COMMON,
- NS_GERMAN,
- NS_SCANDINAVIAN,
- NS_LATIN,
- NS_ROMAN,
- NS_NASHVILLE,
- NS_CUSTOM
-};
-
-enum ParseMode {
- PM_STRICT,
- PM_RELAXED
-};
-
-enum Instrument {
- INS_GUITAR,
- INS_KEYBOARD,
- INS_MANDOLIN,
- INS_UKULELE
-};
-
struct InstrumentInfo {
char *name;
char *description;
@@ -355,7 +369,7 @@ struct ConfigOutput {
struct ConfigChordDiagram *diagram;
struct ConfigPageNo *page_no;
struct ConfigToc *toc;
- struct ChoStyle *styles[TT_LENGTH];
+ struct ChoStyle *styles[TEXT_TYPE_LENGTH];
struct Note **notes;
enum NotationSystem notation_system;
bool start_song_on_new_page;
@@ -367,20 +381,6 @@ struct Config {
struct ConfigParser *parser;
};
-enum LogLevel {
- LOG_INFO,
- LOG_WARN,
- LOG_ERR,
- LOG_TODO
-};
-
-enum FileType {
- F_ERROR,
- F_FOLDER,
- F_REG_FILE,
- F_OTHER
-};
-
void util_log_enable_info_logs(void);
void *emalloc(size_t size);
diff --git a/src/out_pdf.c b/src/out_pdf.c
@@ -163,7 +163,7 @@ fonts_get_all(struct ChoSong **songs, struct Config *config)
bool added;
int i;
for (so = songs; *so; so++) {
- for (i = 0; i < TT_LENGTH; i++) {
+ for (i = 0; i < TEXT_TYPE_LENGTH; i++) {
if ((*so)->present_text_types[i]) {
font = cho_font_copy(config->output->styles[i]->font);
added = fonts_add_if_not_in(&fonts, font);
@@ -251,14 +251,14 @@ fontpath_find(struct Font *font, enum FontType font_type)
FcPatternAdd(pattern, FC_VARIABLE, variable, FcFalse);
FcValue width = { .type = FcTypeInteger, .u.i = FC_WIDTH_NORMAL };
FcPatternAdd(pattern, FC_WIDTH, width, FcFalse);
- /* TODO: Also handle FF_NORMAL, FF_SANS and FF_SERIF, but how? */
- if (font->family == FF_MONOSPACE) {
+ /* TODO: Also handle FONT_FAMILY_NORMAL, FONT_FAMILY_SANS and FONT_FAMILY_SERIF, but how? */
+ if (font->family == FONT_FAMILY_MONOSPACE) {
FcValue spacing = { .type = FcTypeInteger, .u.i = FC_MONO };
FcPatternAdd(pattern, FC_SPACING, spacing, FcFalse);
}
FcValue type;
type.type = FcTypeString;
- if (font_type == FT_OTF) {
+ if (font_type == FONT_TYPE_OTF) {
type.u.s = (FcChar8 *)"CFF";
} else {
type.u.s = (FcChar8 *)"TrueType";
@@ -267,13 +267,13 @@ fontpath_find(struct Font *font, enum FontType font_type)
FcValue style;
style.type = FcTypeInteger;
switch (font->style) {
- case FS_ROMAN:
+ case FONT_STYLE_ROMAN:
style.u.i = FC_SLANT_ROMAN;
break;
- case FS_OBLIQUE:
+ case FONT_STYLE_OBLIQUE:
style.u.i = FC_SLANT_OBLIQUE;
break;
- case FS_ITALIC:
+ case FONT_STYLE_ITALIC:
style.u.i = FC_SLANT_ITALIC;
break;
default:
@@ -284,10 +284,10 @@ fontpath_find(struct Font *font, enum FontType font_type)
FcValue weight;
weight.type = FcTypeInteger;
switch (font->weight) {
- case FW_REGULAR:
+ case FONT_WEIGHT_REGULAR:
weight.u.i = FC_WEIGHT_REGULAR;
break;
- case FW_BOLD:
+ case FONT_WEIGHT_BOLD:
weight.u.i = FC_WEIGHT_BOLD;
break;
default:
@@ -323,9 +323,9 @@ pdf_load_chord_diagram_fonts(struct PDFContext *ctx)
const char *font_name;
struct Font font = {
.name = DEFAULT_FONT,
- .family = FF_NORMAL,
- .style = FS_ROMAN,
- .weight = FW_REGULAR
+ .family = FONT_FAMILY_NORMAL,
+ .style = FONT_STYLE_ROMAN,
+ .weight = FONT_WEIGHT_REGULAR
};
fnt = obj_new();
fnt->name = strdup("chord-diagram-regular-font");
@@ -333,9 +333,9 @@ pdf_load_chord_diagram_fonts(struct PDFContext *ctx)
fnt->value = pdfioFileCreateFontObjFromBase(ctx->pdf_file, font_name);
ctx->diagram_font_is_base_font = true;
} else {
- fontpath = fontpath_find(&font, FT_TTF);
+ fontpath = fontpath_find(&font, FONT_TYPE_TTF);
if (!fontpath) {
- fontpath = fontpath_find(&font, FT_OTF);
+ fontpath = fontpath_find(&font, FONT_TYPE_OTF);
if (!fontpath) {
LOG_DEBUG("fontpath_find failed.");
return false;
@@ -404,7 +404,7 @@ pdf_load_fonts(struct PDFContext *ctx, struct Font **needed_fonts)
}
objs_add_obj(&ctx->fonts, fnt);
} else {
- fontpath = fontpath_find(*f, FT_TTF);
+ fontpath = fontpath_find(*f, FONT_TYPE_TTF);
if (fontpath) {
fnt = obj_new();
fnt->name = fnt_name_create(*f);
@@ -424,7 +424,7 @@ pdf_load_fonts(struct PDFContext *ctx, struct Font **needed_fonts)
objs_add_obj(&ctx->fonts, fnt);
free(fontpath);
} else {
- fontpath = fontpath_find(*f, FT_OTF);
+ fontpath = fontpath_find(*f, FONT_TYPE_OTF);
if (fontpath) {
fnt = obj_new();
fnt->name = fnt_name_create(*f);
@@ -514,11 +514,11 @@ pdf_filepath_create(
if (out) {
type = file_type(out);
switch (type) {
- case F_ERROR:
+ case FILE_TYPE_ERROR:
tmp = filepath_dirname(out);
type = file_type(tmp);
switch (type) {
- case F_FOLDER:
+ case FILE_TYPE_FOLDER:
free(pdf_filepath);
free(pdf_filename);
free(tmp);
@@ -529,18 +529,18 @@ pdf_filepath_create(
return NULL;
}
break;
- case F_REG_FILE:
+ case FILE_TYPE_REG_FILE:
free(pdf_filepath);
free(pdf_filename);
return strdup(out);
- case F_FOLDER:
+ case FILE_TYPE_FOLDER:
tmp = filepath_add_ending_slash_if_missing(out);
tmp = erealloc(tmp, (strlen(tmp)+strlen(pdf_filename)+1) * sizeof(char));
strcat(tmp, pdf_filename);
free(pdf_filename);
free(pdf_filepath);
return tmp;
- case F_OTHER:
+ case FILE_TYPE_OTHER:
util_log(NULL, 0, LOG_ERR, "Invalid argument --output/-o value. It doesn't refer to a folder or regular file.");
return NULL;
default:
@@ -671,19 +671,19 @@ pdf_draw_line(
{
double red, green, blue;
switch (line_location) {
- case LL_UNDER:
+ case LINE_LOCATION_UNDER:
red = text->style->underline_color->red / 255.0;
green = text->style->underline_color->green / 255.0;
blue = text->style->underline_color->blue / 255.0;
y -= 2.0;
break;
- case LL_STRIKETHROUGH:
+ case LINE_LOCATION_STRIKETHROUGH:
red = text->style->strikethrough_color->red / 255.0;
green = text->style->strikethrough_color->green / 255.0;
blue = text->style->strikethrough_color->blue / 255.0;
y += text->style->font->size * 0.3;
break;
- case LL_OVER:
+ case LINE_LOCATION_OVER:
red = text->style->overline_color->red / 255.0;
green = text->style->overline_color->green / 255.0;
blue = text->style->overline_color->blue / 255.0;
@@ -788,20 +788,20 @@ pdf_text_show(struct PDFContext *ctx, pdfio_stream_t *stream, struct PDFText *te
LOG_DEBUG("pdfioContentTextEnd failed.");
return false;
}
- if (text->style->underline_style == LS_SINGLE) {
- pdf_draw_line(stream, text, text->y, text->width, LL_UNDER);
- } else if (text->style->underline_style == LS_DOUBLE) {
- pdf_draw_line(stream, text, text->y, text->width, LL_UNDER);
- pdf_draw_line(stream, text, text->y-1.5, text->width, LL_UNDER);
+ if (text->style->underline_style == LINE_STYLE_SINGLE) {
+ pdf_draw_line(stream, text, text->y, text->width, LINE_LOCATION_UNDER);
+ } else if (text->style->underline_style == LINE_STYLE_DOUBLE) {
+ pdf_draw_line(stream, text, text->y, text->width, LINE_LOCATION_UNDER);
+ pdf_draw_line(stream, text, text->y-1.5, text->width, LINE_LOCATION_UNDER);
}
if (text->style->strikethrough) {
- pdf_draw_line(stream, text, text->y, text->width, LL_STRIKETHROUGH);
+ pdf_draw_line(stream, text, text->y, text->width, LINE_LOCATION_STRIKETHROUGH);
}
- if (text->style->overline_style == LS_SINGLE) {
- pdf_draw_line(stream, text, text->y, text->width, LL_OVER);
- } else if (text->style->overline_style == LS_DOUBLE) {
- pdf_draw_line(stream, text, text->y, text->width, LL_OVER);
- pdf_draw_line(stream, text, text->y+1.5, text->width, LL_OVER);
+ if (text->style->overline_style == LINE_STYLE_SINGLE) {
+ pdf_draw_line(stream, text, text->y, text->width, LINE_LOCATION_OVER);
+ } else if (text->style->overline_style == LINE_STYLE_DOUBLE) {
+ pdf_draw_line(stream, text, text->y, text->width, LINE_LOCATION_OVER);
+ pdf_draw_line(stream, text, text->y+1.5, text->width, LINE_LOCATION_OVER);
}
if (text->style->boxed) {
red = text->style->boxed_color->red / 255.0;
@@ -999,10 +999,10 @@ image_width(struct ChoImage *image, pdfio_obj_t *obj)
double width;
width = pdfioImageGetWidth(obj);
if (image->width) {
- if (image->width->type == ST_POINT) {
+ if (image->width->type == SIZE_TYPE_POINT) {
width = image->width->d;
} else
- if (image->width->type == ST_PERCENT) {
+ if (image->width->type == SIZE_TYPE_PERCENT) {
width = LINE_WIDTH * image->width->d;
}
}
@@ -1019,10 +1019,10 @@ image_height(struct ChoImage *image, pdfio_obj_t *obj)
double height;
height = pdfioImageGetHeight(obj);
if (image->height) {
- if (image->height->type == ST_POINT) {
+ if (image->height->type == SIZE_TYPE_POINT) {
height = image->height->d;
} else
- if (image->height->type == ST_PERCENT) {
+ if (image->height->type == SIZE_TYPE_PERCENT) {
height = LINE_WIDTH * image->height->d;
}
}
@@ -1599,7 +1599,7 @@ text_above_update_positions(struct ChoLineItemAbove **aboves, size_t consumed_ly
static double
calc_x(double width, enum Alignment align)
{
- if (align == A_CENTER) {
+ if (align == ALIGNMENT_CENTER) {
return MARGIN_HORIZONTAL + (LINE_WIDTH - width) / 2;
}
return MARGIN_HORIZONTAL;
@@ -1701,7 +1701,7 @@ numeral_system_western_arabic_to_roman(unsigned int n)
static const char *
numeral_system_number_to_str(enum NumeralSystem system, int n)
{
- if (system == NUS_ROMAN) {
+ if (system == NUMERAL_SYSTEM_ROMAN) {
const char *str = numeral_system_western_arabic_to_roman((unsigned int)n);
if (!str) {
LOG_DEBUG("numeral_system_western_arabic_to_roman failed.");
@@ -1748,13 +1748,13 @@ pdf_page_add_page_no(
(*texts)[c_ctx->text]->y = MARGIN_BOTTOM / 2;
(*texts)[c_ctx->text]->width = width;
switch (ctx->config->output->page_no->align) {
- case A_LEFT:
+ case ALIGNMENT_LEFT:
x = MARGIN_HORIZONTAL / 2;
break;
- case A_CENTER:
+ case ALIGNMENT_CENTER:
x = MARGIN_HORIZONTAL + (LINE_WIDTH - width) / 2;
break;
- case A_RIGHT:
+ case ALIGNMENT_RIGHT:
x = MEDIABOX_WIDTH - MARGIN_HORIZONTAL / 2 - width;
break;
default:
@@ -1900,7 +1900,7 @@ pdf_texts_add_toc_entry(
line_count = 0;
while (width+MARGIN_HORIZONTAL > max_song_title_width) {
if (ctx->t_ctx.y < MARGIN_BOTTOM) {
- if (!pdf_page_close_then_add(ctx, &ctx->t_ctx, NUS_ROMAN)) {
+ if (!pdf_page_close_then_add(ctx, &ctx->t_ctx, NUMERAL_SYSTEM_ROMAN)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
@@ -1935,7 +1935,7 @@ pdf_texts_add_toc_entry(
ctx->t_ctx.text++;
}
if (ctx->t_ctx.y < MARGIN_BOTTOM) {
- if (!pdf_page_close_then_add(ctx, &ctx->t_ctx, NUS_ROMAN)) {
+ if (!pdf_page_close_then_add(ctx, &ctx->t_ctx, NUMERAL_SYSTEM_ROMAN)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
@@ -1990,7 +1990,7 @@ pdf_texts_add_toc_entry(
ctx->t_ctx.y -= 8.0 + style->font->size;
} else {
if (ctx->t_ctx.y < MARGIN_BOTTOM) {
- if (!pdf_page_close_then_add(ctx, &ctx->t_ctx, NUS_ROMAN)) {
+ if (!pdf_page_close_then_add(ctx, &ctx->t_ctx, NUMERAL_SYSTEM_ROMAN)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
@@ -2319,12 +2319,12 @@ pdf_toc_create(
ctx->t_ctx.content->pages[ctx->t_ctx.page] = pdf_page_new(ctx);
texts = &ctx->t_ctx.content->pages[ctx->t_ctx.page]->texts;
if (ctx->config->output->page_no->show) {
- if (!pdf_page_add_page_no(ctx, &ctx->t_ctx, NUS_ROMAN)) {
+ if (!pdf_page_add_page_no(ctx, &ctx->t_ctx, NUMERAL_SYSTEM_ROMAN)) {
LOG_DEBUG("pdf_page_add_page_no failed.");
return false;
}
}
- toc_style = ctx->config->output->styles[TT_TOC];
+ toc_style = ctx->config->output->styles[TEXT_TYPE_TOC];
toc = pdf_body->toc;
max_song_title_width = LINE_WIDTH * 0.85;
toc_page_count = pdf_toc_page_count(ctx, toc, toc_style, max_song_title_width);
@@ -2332,8 +2332,8 @@ pdf_toc_create(
LOG_DEBUG("pdf_toc_page_count failed.");
return false;
}
- title_style = ctx->config->output->styles[TT_TOC_TITLE];
- if (!pdf_texts_add_text(ctx, &ctx->t_ctx, ctx->config->output->toc->title, title_style, A_CENTER, NUS_ROMAN)) {
+ title_style = ctx->config->output->styles[TEXT_TYPE_TOC_TITLE];
+ if (!pdf_texts_add_text(ctx, &ctx->t_ctx, ctx->config->output->toc->title, title_style, ALIGNMENT_CENTER, NUMERAL_SYSTEM_ROMAN)) {
LOG_DEBUG("pdf_texts_add_text(toctitle) failed.");
return false;
}
@@ -2389,7 +2389,7 @@ pdf_body_create(
imgs = &ctx->b_ctx.content->pages[ctx->b_ctx.page]->images;
diagrams = &ctx->b_ctx.content->pages[ctx->b_ctx.page]->diagrams;
if (ctx->config->output->page_no->show) {
- if (!pdf_page_add_page_no(ctx, &ctx->b_ctx, NUS_WESTERN_ARABIC)) {
+ if (!pdf_page_add_page_no(ctx, &ctx->b_ctx, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_page_add_page_no failed.");
return false;
}
@@ -2424,13 +2424,13 @@ pdf_body_create(
ctx->b_ctx.content->toc[ctx->b_ctx.toc_entry]->page_index = ctx->b_ctx.page;
ctx->b_ctx.content->toc[ctx->b_ctx.toc_entry]->page_y = ctx->b_ctx.y;
ctx->b_ctx.toc_entry++;
- if (!pdf_texts_add_text(ctx, &ctx->b_ctx, metadata, metadata_style, A_CENTER, NUS_WESTERN_ARABIC)) {
+ if (!pdf_texts_add_text(ctx, &ctx->b_ctx, metadata, metadata_style, ALIGNMENT_CENTER, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_texts_add_text(title) failed.");
return false;
}
free(metadata);
if (cho_metadata_value(songs[s]->metadata, "subtitle", ctx->config->metadata_separator, &metadata, &metadata_style)) {
- if (!pdf_texts_add_text(ctx, &ctx->b_ctx, metadata, metadata_style, A_CENTER, NUS_WESTERN_ARABIC)) {
+ if (!pdf_texts_add_text(ctx, &ctx->b_ctx, metadata, metadata_style, ALIGNMENT_CENTER, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_texts_add_text(subtitle) failed.");
return false;
}
@@ -2442,7 +2442,7 @@ pdf_body_create(
ctx->b_ctx.y -= 30.0;
for (se = songs[s]->sections; *se; se++) {
if ((*se)->label) {
- if (!pdf_texts_add_text(ctx, &ctx->b_ctx, (*se)->label->text, (*se)->label->style, A_LEFT, NUS_WESTERN_ARABIC)) {
+ if (!pdf_texts_add_text(ctx, &ctx->b_ctx, (*se)->label->text, (*se)->label->style, ALIGNMENT_LEFT, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_texts_add_text(label) failed.");
return false;
}
@@ -2450,7 +2450,7 @@ pdf_body_create(
imgs = &ctx->b_ctx.content->pages[ctx->b_ctx.page]->images;
diagrams = &ctx->b_ctx.content->pages[ctx->b_ctx.page]->diagrams;
}
- if ((*se)->type == ST_GRID) {
+ if ((*se)->type == SECTION_TYPE_GRID) {
double biggest_line_item_width, x, biggest_font_size;
struct ChoLine **li;
struct ChoLineItem **lii;
@@ -2590,7 +2590,7 @@ pdf_body_create(
*texts = erealloc(*texts, (--ctx->b_ctx.text) * sizeof(struct PDFText *));
}
}
- if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUS_WESTERN_ARABIC)) {
+ if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
@@ -2690,7 +2690,7 @@ pdf_body_create(
}
ctx->b_ctx.y -= 8.0 + ctx->b_ctx.biggest_font_size;
if (ctx->b_ctx.y < ctx->b_ctx.margin_bottom) {
- if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUS_WESTERN_ARABIC)) {
+ if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
@@ -2704,8 +2704,8 @@ pdf_body_create(
pos = NULL;
text_above_update_positions(left_aboves, ctx->b_ctx.consumed_lyrics);
}
- if ((*li)->btype == BT_PAGE) {
- if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUS_WESTERN_ARABIC)) {
+ if ((*li)->btype == BREAK_TYPE_PAGE) {
+ if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
@@ -2717,7 +2717,7 @@ pdf_body_create(
ctx->b_ctx.y -= SECTION_GAP_WIDTH;
}
if (start_song_on_new_page) {
- if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUS_WESTERN_ARABIC)) {
+ if (!pdf_page_close_then_add(ctx, &ctx->b_ctx, NUMERAL_SYSTEM_WESTERN_ARABIC)) {
LOG_DEBUG("pdf_page_close_then_add failed.");
return false;
}
diff --git a/src/out_pdf.h b/src/out_pdf.h
@@ -15,19 +15,19 @@
#define TOC_DOTS_GAP_WIDTH 10.0
enum LineLocation {
- LL_OVER,
- LL_STRIKETHROUGH,
- LL_UNDER
+ LINE_LOCATION_OVER,
+ LINE_LOCATION_STRIKETHROUGH,
+ LINE_LOCATION_UNDER
};
enum FontType {
- FT_TTF,
- FT_OTF
+ FONT_TYPE_TTF,
+ FONT_TYPE_OTF
};
enum NumeralSystem {
- NUS_WESTERN_ARABIC,
- NUS_ROMAN
+ NUMERAL_SYSTEM_WESTERN_ARABIC,
+ NUMERAL_SYSTEM_ROMAN
};
struct CharPosition {