commit ab27811272099122bc6f0e040af4e2f54c8cb124
parent 0b57e0123cb28e2146b7c4c27e33ed0e4ae6fd65
Author: nibo <nibo@relim.de>
Date: Fri, 17 Jan 2025 19:05:52 +0100
Rename 'SongFragmentType' to 'TextType'
Diffstat:
| M | chordpro.c | | | 282 | ++++++++++++++++++++++++++++++++++++++++---------------------------------------- |
| M | chordpro.h | | | 8 | ++++---- |
| M | config.c | | | 50 | +++++++++++++++++++++++++------------------------- |
| M | out_pdf.c | | | 2 | +- |
4 files changed, 171 insertions(+), 171 deletions(-)
diff --git a/chordpro.c b/chordpro.c
@@ -32,7 +32,8 @@ static const char *state_enums[] = {
"STATE_COMMENT"
};
-struct StyleProperty default_style_properties[21] = {
+struct StyleProperty default_style_properties[] = {
+ // TODO: label and footer are missing
{ SF_CHORD, SPT_FONT, { .font_name = NULL } },
{ SF_CHORD, SPT_SIZE, { .font_size = EMPTY_DOUBLE } },
{ SF_CHORD, SPT_COLOR, { .foreground_color = NULL } },
@@ -136,8 +137,8 @@ static const char *chord_extensions_minor[] = {
};
static bool g_show_info_logs = false;
-static enum SongFragmentType g_current_ftype = SF_TEXT;
-static enum SongFragmentType g_prev_ftype = SF_TEXT;
+static enum TextType g_current_ttype = SF_TEXT;
+static enum TextType g_prev_ttype = SF_TEXT;
static struct Config *g_config = NULL;
static const char *g_chordpro_filepath = NULL;
static int *g_transpose_history = NULL;
@@ -200,7 +201,7 @@ static const char *position_enums[] = {
"POS_END"
};
-static const char *song_fragment_type_enums[] = {
+static const char *text_type_enums[] = {
"SF_EMPTY",
"SF_CHORD",
"SF_ANNOT",
@@ -719,7 +720,7 @@ cho_debug_the_default_style_properties(void)
for (i = 0; i<LENGTH(default_style_properties); i++) {
printf(
"%s %s ",
- song_fragment_type_enums[default_style_properties[i].ftype],
+ text_type_enums[default_style_properties[i].ttype],
style_property_type_enums[default_style_properties[i].type]
);
switch (default_style_properties[i].type) {
@@ -770,12 +771,12 @@ cho_debug_style_print(struct ChoStyle *style)
#endif /* DEBUG */
static bool
-cho_style_property_apply_default(enum SongFragmentType current_ftype, enum StylePropertyType ptype, struct ChoStyle *style)
+cho_style_property_apply_default(enum TextType current_ttype, enum StylePropertyType ptype, struct ChoStyle *style)
{
unsigned int i;
for (i = 0; i<LENGTH(default_style_properties); i++) {
if (
- default_style_properties[i].ftype == current_ftype &&
+ default_style_properties[i].ttype == current_ttype &&
default_style_properties[i].type == ptype
) {
switch (ptype) {
@@ -815,9 +816,9 @@ cho_style_property_apply_default(enum SongFragmentType current_ftype, enum Style
}
static void
-cho_style_apply_default(enum SongFragmentType current_ftype, struct ChoStyle *style)
+cho_style_apply_default(enum TextType current_ttype, struct ChoStyle *style)
{
- if (current_ftype == SF_CHORUS) {
+ if (current_ttype == SF_CHORUS) {
if (!cho_style_property_apply_default(SF_CHORUS, SPT_FONT, style)) {
cho_style_property_apply_default(SF_TEXT, SPT_FONT, style);
}
@@ -828,9 +829,9 @@ cho_style_apply_default(enum SongFragmentType current_ftype, struct ChoStyle *st
cho_style_property_apply_default(SF_TEXT, SPT_COLOR, style);
}
} else {
- cho_style_property_apply_default(current_ftype, SPT_FONT, style);
- cho_style_property_apply_default(current_ftype, SPT_SIZE, style);
- cho_style_property_apply_default(current_ftype, SPT_COLOR, style);
+ cho_style_property_apply_default(current_ttype, SPT_FONT, style);
+ cho_style_property_apply_default(current_ttype, SPT_SIZE, style);
+ cho_style_property_apply_default(current_ttype, SPT_COLOR, style);
}
}
@@ -875,20 +876,20 @@ cho_style_copy(struct ChoStyle *style)
}
static struct ChoStyle *
-cho_style_new_from_config(enum SongFragmentType ftype)
+cho_style_new_from_config(enum TextType ttype)
{
- return cho_style_copy(g_config->output->styles[ftype]);
+ return cho_style_copy(g_config->output->styles[ttype]);
}
static struct ChoStyle *
cho_style_new_default(void)
{
- struct ChoStyle *style = cho_style_new_from_config(g_current_ftype);
+ struct ChoStyle *style = cho_style_new_from_config(g_current_ttype);
if (!style) {
LOG_DEBUG("cho_style_new_from_config failed.");
return NULL;
}
- cho_style_apply_default(g_current_ftype, style);
+ cho_style_apply_default(g_current_ttype, style);
return style;
}
@@ -1320,7 +1321,7 @@ cho_style_change_default(struct StyleProperty sprop)
unsigned int i;
for (i = 0; i<LENGTH(default_style_properties); i++) {
if (
- default_style_properties[i].ftype == sprop.ftype &&
+ default_style_properties[i].ttype == sprop.ttype &&
default_style_properties[i].type == sprop.type
) {
switch (sprop.type) {
@@ -3081,7 +3082,7 @@ cho_song_new(void)
song->metadata = NULL;
song->sections = NULL;
song->diagrams = NULL;
- memset(song->present_fragments, 0, SF_LENGTH);
+ memset(song->present_text_types, 0, SF_LENGTH);
return song;
}
@@ -3179,7 +3180,7 @@ cho_directive_new(void)
directive->stype = ST_EMPTY;
directive->position = POS_EMPTY;
directive->sprop = SPT_EMPTY;
- directive->ftype = SF_EMPTY;
+ directive->ttype = SF_EMPTY;
directive->btype = BT_EMPTY;
directive->meta = -1;
directive->ctype = -1;
@@ -3208,8 +3209,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_START;
directive->stype = ST_CHORUS;
- directive->ftype = SF_CHORUS;
- goto END;
+ directive->ttype = SF_CHORUS;
+ return directive;
} else if (
!strcmp(name, "end_of_chorus") ||
!strcmp(name, "eoc")
@@ -3217,12 +3218,12 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_END;
directive->stype = ST_CHORUS;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (!strcmp(name, "chorus")) {
directive->dtype = DT_ENVIRONMENT;
- directive->ftype = SF_LABEL;
- goto END;
+ directive->ttype = SF_LABEL;
+ return directive;
} else if (
!strcmp(name, "start_of_verse") ||
!strcmp(name, "sov")
@@ -3230,8 +3231,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_START;
directive->stype = ST_VERSE;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (
!strcmp(name, "end_of_verse") ||
!strcmp(name, "eov")
@@ -3239,8 +3240,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_END;
directive->stype = ST_VERSE;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (
!strcmp(name, "start_of_bridge") ||
!strcmp(name, "sob")
@@ -3248,8 +3249,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_START;
directive->stype = ST_BRIDGE;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (
!strcmp(name, "end_of_bridge") ||
!strcmp(name, "eob")
@@ -3257,8 +3258,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_END;
directive->stype = ST_BRIDGE;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (
!strcmp(name, "start_of_tab") ||
!strcmp(name, "sot")
@@ -3266,8 +3267,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_START;
directive->stype = ST_TAB;
- directive->ftype = SF_TAB;
- goto END;
+ directive->ttype = SF_TAB;
+ return directive;
} else if (
!strcmp(name, "end_of_tab") ||
!strcmp(name, "eot")
@@ -3275,8 +3276,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_END;
directive->stype = ST_TAB;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (
!strcmp(name, "start_of_grid") ||
!strcmp(name, "sog")
@@ -3284,8 +3285,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_START;
directive->stype = ST_GRID;
- directive->ftype = SF_GRID;
- goto END;
+ directive->ttype = SF_GRID;
+ return directive;
} else if (
!strcmp(name, "end_of_grid") ||
!strcmp(name, "eog")
@@ -3293,8 +3294,8 @@ cho_directive_parse(const char *name)
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_END;
directive->stype = ST_GRID;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
}
if (
!strcmp(name, "title") ||
@@ -3303,11 +3304,11 @@ cho_directive_parse(const char *name)
directive->dtype = DT_METADATA;
directive->meta = TITLE;
cho_style_free(directive->style);
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_TITLE;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_TITLE;
directive->style = cho_style_new_default();
- g_current_ftype = g_prev_ftype;
- goto END;
+ g_current_ttype = g_prev_ttype;
+ return directive;
} else if (
!strcmp(name, "subtitle") ||
@@ -3316,11 +3317,11 @@ cho_directive_parse(const char *name)
directive->dtype = DT_METADATA;
directive->meta = SUBTITLE;
cho_style_free(directive->style);
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_SUBTITLE;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_SUBTITLE;
directive->style = cho_style_new_default();
- g_current_ftype = g_prev_ftype;
- goto END;
+ g_current_ttype = g_prev_ttype;
+ return directive;
}
if (
!strcmp(name, "sorttitle") ||
@@ -3339,7 +3340,7 @@ cho_directive_parse(const char *name)
!strcmp(name, "arranger")
) {
directive->dtype = DT_METADATA;
- goto END;
+ return directive;
}
if (
!strcmp(name, "comment") ||
@@ -3347,41 +3348,41 @@ cho_directive_parse(const char *name)
!strcmp(name, "highlight")
) {
directive->dtype = DT_FORMATTING;
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_COMMENT;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_COMMENT;
cho_style_free(directive->style);
directive->style = cho_style_new_default();
- g_current_ftype = g_prev_ftype;
- directive->ftype = SF_COMMENT;
- goto END;
+ g_current_ttype = g_prev_ttype;
+ directive->ttype = SF_COMMENT;
+ return directive;
} else if (
!strcmp(name, "comment_italic") ||
!strcmp(name, "ci")
) {
directive->dtype = DT_FORMATTING;
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_COMMENT_ITALIC;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_COMMENT_ITALIC;
cho_style_free(directive->style);
directive->style = cho_style_new_default();
- g_current_ftype = g_prev_ftype;
- directive->ftype = SF_COMMENT_ITALIC;
- goto END;
+ g_current_ttype = g_prev_ttype;
+ directive->ttype = SF_COMMENT_ITALIC;
+ return directive;
} else if (
!strcmp(name, "comment_box") ||
!strcmp(name, "cb")
) {
directive->dtype = DT_FORMATTING;
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_COMMENT_BOX;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_COMMENT_BOX;
cho_style_free(directive->style);
directive->style = cho_style_new_default();
- g_current_ftype = g_prev_ftype;
- directive->ftype = SF_COMMENT_BOX;
- goto END;
+ g_current_ttype = g_prev_ttype;
+ directive->ttype = SF_COMMENT_BOX;
+ return directive;
}
if (!strcmp(name, "image")) {
directive->dtype = DT_IMAGE;
- goto END;
+ return directive;
}
if (
!strcmp(name, "new_song") ||
@@ -3389,7 +3390,7 @@ cho_directive_parse(const char *name)
) {
directive->dtype = DT_PREAMBLE;
directive->stype = ST_NEWSONG;
- goto END;
+ return directive;
}
if (
!strcmp(name, "chordfont") ||
@@ -3397,114 +3398,114 @@ cho_directive_parse(const char *name)
) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_CHORD;
- goto END;
+ directive->ttype = SF_CHORD;
+ return directive;
} else if (
!strcmp(name, "chordsize") ||
!strcmp(name, "cs")
) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_CHORD;
- goto END;
+ directive->ttype = SF_CHORD;
+ return directive;
} else if (!strcmp(name, "chordcolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_CHORD;
- goto END;
+ directive->ttype = SF_CHORD;
+ return directive;
} else if (!strcmp(name, "chorusfont")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_CHORUS;
- goto END;
+ directive->ttype = SF_CHORUS;
+ return directive;
} else if (!strcmp(name, "chorussize")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_CHORUS;
- goto END;
+ directive->ttype = SF_CHORUS;
+ return directive;
} else if (!strcmp(name, "choruscolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_CHORUS;
- goto END;
+ directive->ttype = SF_CHORUS;
+ return directive;
} else if (!strcmp(name, "gridfont")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_GRID;
- goto END;
+ directive->ttype = SF_GRID;
+ return directive;
} else if (!strcmp(name, "gridsize")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_GRID;
- goto END;
+ directive->ttype = SF_GRID;
+ return directive;
} else if (!strcmp(name, "gridcolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_GRID;
- goto END;
+ directive->ttype = SF_GRID;
+ return directive;
} else if (!strcmp(name, "tabfont")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_TAB;
- goto END;
+ directive->ttype = SF_TAB;
+ return directive;
} else if (!strcmp(name, "tabsize")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_TAB;
- goto END;
+ directive->ttype = SF_TAB;
+ return directive;
} else if (!strcmp(name, "tabcolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_TAB;
- goto END;
+ directive->ttype = SF_TAB;
+ return directive;
} else if (
!strcmp(name, "textfont") ||
!strcmp(name, "tf")
) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (
!strcmp(name, "textsize") ||
!strcmp(name, "ts")
) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (!strcmp(name, "textcolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (!strcmp(name, "titlefont")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_TITLE;
- goto END;
+ directive->ttype = SF_TITLE;
+ return directive;
} else if (!strcmp(name, "titlesize")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_TITLE;
- goto END;
+ directive->ttype = SF_TITLE;
+ return directive;
} else if (!strcmp(name, "titlecolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_TITLE;
- goto END;
+ directive->ttype = SF_TITLE;
+ return directive;
} else if (!strcmp(name, "tocfont")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_FONT;
- directive->ftype = SF_TOC;
+ directive->ttype = SF_TOC;
} else if (!strcmp(name, "tocsize")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_SIZE;
- directive->ftype = SF_TOC;
+ directive->ttype = SF_TOC;
} else if (!strcmp(name, "toccolour")) {
directive->dtype = DT_FONT;
directive->sprop = SPT_COLOR;
- directive->ftype = SF_TOC;
+ directive->ttype = SF_TOC;
} /* else if (!strcmp(name, "footerfont")) {
} else if (!strcmp(name, "footersize")) {
} else if (!strcmp(name, "footercolour")) {
@@ -3515,11 +3516,11 @@ cho_directive_parse(const char *name)
if (!strcmp(name, "transpose")) {
directive->dtype = DT_CHORD;
directive->ctype = TRANSPOSE;
- goto END;
+ return directive;
} else if (!strcmp(name, "define")) {
directive->dtype = DT_CHORD;
directive->ctype = DEFINE;
- goto END;
+ return directive;
} /* else if (!strcmp(name, "chord")) {
} */
if (
@@ -3528,30 +3529,29 @@ cho_directive_parse(const char *name)
) {
directive->dtype = DT_OUTPUT;
directive->btype = BT_PAGE;
- goto END;
+ return directive;
} else if (
!strcmp(name, "column_break") ||
!strcmp(name, "colb")
) {
directive->dtype = DT_OUTPUT;
directive->btype = BT_COLUMN;
- goto END;
+ return directive;
}
if (str_starts_with(name, "start_of_")) {
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_START;
directive->stype = ST_CUSTOM;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
} else if (str_starts_with(name, "end_of_")) {
directive->dtype = DT_ENVIRONMENT;
directive->position = POS_END;
directive->stype = ST_CUSTOM;
- directive->ftype = SF_TEXT;
- goto END;
+ directive->ttype = SF_TEXT;
+ return directive;
}
directive->dtype = DT_CUSTOM;
-END:
return directive;
}
@@ -3700,7 +3700,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
lines = &songs[so]->sections[se]->lines;
(*lines)[li]->items = emalloc(sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
- songs[so]->present_fragments[SF_TOC] = config->output->toc->show;
+ songs[so]->present_text_types[SF_TOC] = config->output->toc->show;
struct Tag **tags = NULL;
struct ChoStyle *tag_style;
struct StyleProperty sprop;
@@ -3816,7 +3816,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
); */
switch (directive->dtype) {
case DT_ENVIRONMENT:
- g_current_ftype = directive->ftype;
+ g_current_ttype = directive->ttype;
switch (directive->position) {
case POS_START:
if (directive->stype == ST_CUSTOM) {
@@ -3838,7 +3838,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li] = cho_line_new();
(*lines)[li]->items = emalloc(sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
- songs[so]->present_fragments[directive->ftype] = true;
+ songs[so]->present_text_types[directive->ttype] = true;
break;
case POS_END:
if (directive->stype == songs[so]->sections[se]->type) {
@@ -3914,7 +3914,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li]->items = erealloc((*lines)[li]->items, (ly+1) * sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
cho_style_free((*lines)[li]->items[ly]->u.text->style);
- g_current_ftype = SF_LABEL;
+ g_current_ttype = SF_LABEL;
(*lines)[li]->items[ly]->u.text->style = cho_style_new_default();
(*lines)[li]->items[ly]->u.text->text = label;
te += strlen(label);
@@ -3938,7 +3938,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li]->items = erealloc((*lines)[li]->items, (ly+1) * sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
cho_style_free((*lines)[li]->items[ly]->u.text->style);
- g_current_ftype = SF_LABEL;
+ g_current_ttype = SF_LABEL;
(*lines)[li]->items[ly]->u.text->style = cho_style_new_default();
(*lines)[li]->items[ly]->u.text->text = label;
te += strlen(label);
@@ -3992,7 +3992,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li]->items[ly] = cho_line_item_new();
break;
case DT_FONT:
- sprop.ftype = directive->ftype;
+ sprop.ttype = directive->ttype;
sprop.type = directive->sprop;
switch (directive->sprop) {
case SPT_FONT:
@@ -4072,9 +4072,9 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
switch (directive->dtype) {
case DT_ENVIRONMENT:
if (strlen(stripped_directive_value) > 0) {
- songs[so]->present_fragments[SF_LABEL] = true;
+ songs[so]->present_text_types[SF_LABEL] = true;
}
- g_current_ftype = directive->ftype;
+ g_current_ttype = directive->ttype;
switch (directive->position) {
case POS_START:
if (directive->stype == ST_CUSTOM) {
@@ -4109,7 +4109,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li] = cho_line_new();
(*lines)[li]->items = emalloc(sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
- songs[so]->present_fragments[directive->ftype] = true;
+ songs[so]->present_text_types[directive->ttype] = true;
break;
case POS_END:
if (directive->stype == songs[so]->sections[se]->type) {
@@ -4159,7 +4159,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
songs[so]->sections[se]->label->text = label;
} else {
songs[so]->sections[se]->label = emalloc(sizeof(struct ChoText));
- g_current_ftype = SF_LABEL;
+ g_current_ttype = SF_LABEL;
songs[so]->sections[se]->label->style = cho_style_new_default();
}
se++;
@@ -4185,7 +4185,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li]->items = erealloc((*lines)[li]->items, (ly+1) * sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
cho_style_free((*lines)[li]->items[ly]->u.text->style);
- g_current_ftype = SF_LABEL;
+ g_current_ttype = SF_LABEL;
(*lines)[li]->items[ly]->u.text->style = cho_style_new_default();
(*lines)[li]->items[ly]->u.text->text = label;
te += strlen(label);
@@ -4208,7 +4208,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li]->items = erealloc((*lines)[li]->items, (ly+1) * sizeof(struct ChoLineItem *));
(*lines)[li]->items[ly] = cho_line_item_new();
cho_style_free((*lines)[li]->items[ly]->u.text->style);
- g_current_ftype = SF_LABEL;
+ g_current_ttype = SF_LABEL;
(*lines)[li]->items[ly]->u.text->style = cho_style_new_default();
(*lines)[li]->items[ly]->u.text->text = label;
te += strlen(label);
@@ -4235,7 +4235,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
cho_style_free(songs[so]->metadata[m]->style);
songs[so]->metadata[m]->style = cho_style_copy(directive->style);
m++;
- songs[so]->present_fragments[SF_TITLE] = true;
+ songs[so]->present_text_types[SF_TITLE] = true;
break;
case SUBTITLE:
songs[so]->metadata = erealloc(songs[so]->metadata, (m+1) * sizeof(struct ChoMetadata *));
@@ -4245,7 +4245,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
cho_style_free(songs[so]->metadata[m]->style);
songs[so]->metadata[m]->style = cho_style_copy(directive->style);
m++;
- songs[so]->present_fragments[SF_SUBTITLE] = true;
+ songs[so]->present_text_types[SF_SUBTITLE] = true;
break;
default:
if (!strcmp(directive_name, "meta")) {
@@ -4285,7 +4285,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
(*lines)[li]->items[ly]->u.text->style = cho_style_copy(directive->style);
(*lines)[li]->items[ly]->u.text->text = strdup(stripped_directive_value);
te += strlen(stripped_directive_value);
- songs[so]->present_fragments[directive->ftype] = true;
+ songs[so]->present_text_types[directive->ttype] = true;
break;
case DT_IMAGE:
if (strstr(directive_value, "=")) {
@@ -4320,7 +4320,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
cho_log(LOG_ERR, "Preamble directive '%s' can't have a value.", directive_name);
return NULL;
case DT_FONT:
- sprop.ftype = directive->ftype;
+ sprop.ttype = directive->ttype;
char *dir_value = strdup(stripped_directive_value);
switch (directive->sprop) {
case SPT_FONT:
@@ -4422,8 +4422,8 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
if (buf == ']') {
chord[ch] = 0;
ch = 0;
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_CHORD;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_CHORD;
if (is_chord_already_initialized) {
text_above_pos = cho_line_compute_text_above_position(songs[so]->sections[se]->lines[li], ly, te);
(*lines)[li]->text_above[c]->position = text_above_pos;
@@ -4445,16 +4445,16 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
cho_log(LOG_INFO, "Didn't recognize the chord '%s'.", (*lines)[li]->text_above[c]->u.chord->name);
}
}
- songs[so]->present_fragments[SF_CHORD] = true;
+ songs[so]->present_text_types[SF_CHORD] = true;
memset(chord, 0, strlen(chord));
c++;
- g_current_ftype = g_prev_ftype;
+ g_current_ttype = g_prev_ttype;
state = STATE_LYRICS;
break;
}
if (prev_buf == '[' && buf == '*') {
- g_prev_ftype = g_current_ftype;
- g_current_ftype = SF_ANNOT;
+ g_prev_ttype = g_current_ttype;
+ g_current_ttype = SF_ANNOT;
(*lines)[li]->text_above = erealloc((*lines)[li]->text_above, (c+1) * sizeof(struct ChoLineItemAbove *));
(*lines)[li]->text_above[c] = emalloc(sizeof(struct ChoLineItemAbove));
(*lines)[li]->text_above[c]->is_chord = false;
@@ -4491,10 +4491,10 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
if (buf == ']') {
(*lines)[li]->text_above[c]->u.annot->text = erealloc((*lines)[li]->text_above[c]->u.annot->text, (ann+1) * sizeof(char));
(*lines)[li]->text_above[c]->u.annot->text[ann] = 0;
- songs[so]->present_fragments[SF_ANNOT] = true;
+ songs[so]->present_text_types[SF_ANNOT] = true;
ann = 0;
c++;
- g_current_ftype = g_prev_ftype;
+ g_current_ttype = g_prev_ttype;
state = STATE_LYRICS;
break;
}
@@ -4852,8 +4852,8 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config)
so++;
songs = erealloc(songs, (so+1) * sizeof(struct ChoSong *));
songs[so] = NULL;
- g_current_ftype = SF_TEXT;
- g_prev_ftype = SF_TEXT;
+ g_current_ttype = SF_TEXT;
+ g_prev_ttype = SF_TEXT;
g_config = NULL;
g_chordpro_filepath = NULL;
free(g_transpose_history);
diff --git a/chordpro.h b/chordpro.h
@@ -3,7 +3,7 @@
#ifndef _CHORDPRO_H_
#define _CHORDPRO_H_
-enum SongFragmentType {
+enum TextType {
SF_EMPTY,
SF_CHORD,
SF_ANNOT,
@@ -233,7 +233,7 @@ struct ChoDirective {
enum SectionType stype;
enum Position position;
enum StylePropertyType sprop;
- enum SongFragmentType ftype;
+ enum TextType ttype;
enum BreakType btype;
enum MetadataDirective meta;
enum ChordDirective ctype;
@@ -306,7 +306,7 @@ struct ChoSong {
struct ChoMetadata **metadata;
struct ChoSection **sections;
struct ChordDiagram **diagrams;
- bool present_fragments[SF_LENGTH];
+ bool present_text_types[SF_LENGTH];
};
union StylePropertyValue {
@@ -316,7 +316,7 @@ union StylePropertyValue {
};
struct StyleProperty {
- enum SongFragmentType ftype;
+ enum TextType ttype;
enum StylePropertyType type;
union StylePropertyValue u;
};
diff --git a/config.c b/config.c
@@ -30,7 +30,7 @@ static const char *instruments[] = {
"unknown"
};
-static const char *song_fragment_types[] = {
+static const char *text_types[] = {
"empty", "chord", "annotation", "chorus",
"footer", "grid", "tab", "toc", "text",
"title", "subtitle", "label", "comment",
@@ -119,50 +119,50 @@ static struct Note notes_nashville[] = {
{ .note = "7", .sharp = NULL, .flat = "7b" },
};
-static enum SongFragmentType
-config_song_fragment_type_parse(const char *str)
+static enum TextType
+config_text_type_parse(const char *str)
{
// TODO: can g_valid_styles be replaced by the song fragment types?
- if (!strcmp(str, song_fragment_types[SF_CHORD])) {
+ if (!strcmp(str, text_types[SF_CHORD])) {
return SF_CHORD;
} else
- if (!strcmp(str, song_fragment_types[SF_ANNOT])) {
+ if (!strcmp(str, text_types[SF_ANNOT])) {
return SF_ANNOT;
} else
- if (!strcmp(str, song_fragment_types[SF_CHORUS])) {
+ if (!strcmp(str, text_types[SF_CHORUS])) {
return SF_CHORUS;
} else
- if (!strcmp(str, song_fragment_types[SF_FOOTER])) {
+ if (!strcmp(str, text_types[SF_FOOTER])) {
return SF_FOOTER;
} else
- if (!strcmp(str, song_fragment_types[SF_GRID])) {
+ if (!strcmp(str, text_types[SF_GRID])) {
return SF_GRID;
} else
- if (!strcmp(str, song_fragment_types[SF_TAB])) {
+ if (!strcmp(str, text_types[SF_TAB])) {
return SF_TAB;
} else
- if (!strcmp(str, song_fragment_types[SF_TOC])) {
+ if (!strcmp(str, text_types[SF_TOC])) {
return SF_TOC;
} else
- if (!strcmp(str, song_fragment_types[SF_TEXT])) {
+ if (!strcmp(str, text_types[SF_TEXT])) {
return SF_TEXT;
} else
- if (!strcmp(str, song_fragment_types[SF_TITLE])) {
+ if (!strcmp(str, text_types[SF_TITLE])) {
return SF_TITLE;
} else
- if (!strcmp(str, song_fragment_types[SF_SUBTITLE])) {
+ if (!strcmp(str, text_types[SF_SUBTITLE])) {
return SF_SUBTITLE;
} else
- if (!strcmp(str, song_fragment_types[SF_LABEL])) {
+ if (!strcmp(str, text_types[SF_LABEL])) {
return SF_LABEL;
} else
- if (!strcmp(str, song_fragment_types[SF_COMMENT])) {
+ if (!strcmp(str, text_types[SF_COMMENT])) {
return SF_COMMENT;
} else
- if (!strcmp(str, song_fragment_types[SF_COMMENT_ITALIC])) {
+ if (!strcmp(str, text_types[SF_COMMENT_ITALIC])) {
return SF_COMMENT_ITALIC;
} else
- if (!strcmp(str, song_fragment_types[SF_COMMENT_BOX])) {
+ if (!strcmp(str, text_types[SF_COMMENT_BOX])) {
return SF_COMMENT_BOX;
}
return SF_EMPTY;
@@ -479,8 +479,8 @@ config_print_default(void)
printf("[output.styles]\n");
int i;
for (i = 1; i<SF_LENGTH; i++) {
- printf("[output.styles.%s]\n\n", song_fragment_types[i]);
- cho_style_print_as_toml(config->output->styles[i], song_fragment_types[i]);
+ printf("[output.styles.%s]\n\n", text_types[i]);
+ cho_style_print_as_toml(config->output->styles[i], text_types[i]);
}
printf("[parser]\n");
printf("[parser.chords]\n");
@@ -793,7 +793,7 @@ lyrics_set_text_style_as_default(
{
struct ChoStyle *style, *text_style;
struct ChoStylePresence *presence, *text_presence;
- enum SongFragmentType lyric_types[] = {
+ enum TextType lyric_types[] = {
SF_CHORUS, SF_COMMENT,
SF_COMMENT_ITALIC, SF_COMMENT_BOX
};
@@ -905,18 +905,18 @@ config_load(const char *filepath)
if (styles) {
int i, unused;
const char *key_name;
- enum SongFragmentType ftype;
+ enum TextType ttype;
struct ChoStyle *style;
struct ChoStylePresence presences[SF_LENGTH] = {0};
toml_table_t *key;
for (i = 0; i<toml_table_len(styles); i++) {
key_name = toml_table_key(styles, i, &unused);
- ftype = config_song_fragment_type_parse(key_name);
- if (ftype != SF_EMPTY) {
+ ttype = config_text_type_parse(key_name);
+ if (ttype != SF_EMPTY) {
key = toml_table_table(styles, key_name);
if (key) {
- style = config->output->styles[ftype];
- if (!config_load_style(style, key, key_name, &presences[ftype])) {
+ style = config->output->styles[ttype];
+ if (!config_load_style(style, key, key_name, &presences[ttype])) {
LOG_DEBUG("config_load_style failed.");
return NULL;
}
diff --git a/out_pdf.c b/out_pdf.c
@@ -186,7 +186,7 @@ fonts_get_all(struct ChoSong **songs, struct Config *config)
int i;
for (so = songs; *so; so++) {
for (i = 0; i < SF_LENGTH; i++) {
- if ((*so)->present_fragments[i]) {
+ if ((*so)->present_text_types[i]) {
font = cho_font_copy(config->output->styles[i]->font);
added = fonts_add_if_not_in(&fonts, font);
if (!added) {