lorid

convert chordpro to pdf
git clone git://git.relim.de/lorid.git
Log | Files | Refs | README | LICENSE

commit 7e1f05491cd3e20a14df5da83468f0a20389bc72
parent e75e94315d50f3f216abbdeb5379dc7f8362a8ae
Author: nibo <nibo@relim.de>
Date:   Mon, 18 Nov 2024 18:16:43 +0100

Rename struct 'Style' to 'ChoStyle'

Diffstat:
Mchordpro.c | 36++++++++++++++++++------------------
Mchordpro.h | 22+++++++++++-----------
Mconfig.c | 2+-
Mconfig.h | 2+-
Mout_pdf.c | 12++++++------
Mout_pdf.h | 2+-
6 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/chordpro.c b/chordpro.c @@ -766,7 +766,7 @@ cho_debug_the_default_style_properties(void) } void -cho_debug_style_print(struct Style *style) +cho_debug_style_print(struct ChoStyle *style) { printf("---- BEGIN STYLE ----\n"); cho_font_print(style->font); @@ -791,7 +791,7 @@ cho_debug_style_print(struct Style *style) #endif /* DEBUG */ static bool -cho_style_property_apply_default(enum SongFragmentType current_ftype, enum StylePropertyType ptype, struct Style *style) +cho_style_property_apply_default(enum SongFragmentType current_ftype, enum StylePropertyType ptype, struct ChoStyle *style) { unsigned int i; for (i = 0; i<LENGTH(default_style_properties); i++) { @@ -836,7 +836,7 @@ cho_style_property_apply_default(enum SongFragmentType current_ftype, enum Style } static void -cho_style_apply_default(enum SongFragmentType current_ftype, struct Style *style) +cho_style_apply_default(enum SongFragmentType current_ftype, struct ChoStyle *style) { if (current_ftype == SF_CHORUS) { if (!cho_style_property_apply_default(SF_CHORUS, SPT_FONT, style)) { @@ -855,10 +855,10 @@ cho_style_apply_default(enum SongFragmentType current_ftype, struct Style *style } } -struct Style * +struct ChoStyle * cho_style_new(void) { - struct Style *style = malloc(sizeof(struct Style)); + struct ChoStyle *style = malloc(sizeof(struct ChoStyle)); style->font = cho_font_new(); style->foreground_color = cho_rgbcolor_new(20, 20, 20); style->background_color = cho_rgbcolor_new(255, 255, 255); @@ -875,10 +875,10 @@ cho_style_new(void) return style; } -struct Style * -cho_style_copy(struct Style *style) +struct ChoStyle * +cho_style_copy(struct ChoStyle *style) { - struct Style *copy = malloc(sizeof(struct Style)); + struct ChoStyle *copy = malloc(sizeof(struct ChoStyle)); copy->font = cho_font_copy(style->font); copy->foreground_color = cho_rgbcolor_copy(style->foreground_color); copy->background_color = cho_rgbcolor_copy(style->background_color); @@ -895,7 +895,7 @@ cho_style_copy(struct Style *style) return copy; } -struct Style * +struct ChoStyle * cho_style_new_from_config(enum SongFragmentType ftype) { struct OutputStyle *style; @@ -927,16 +927,16 @@ cho_style_new_from_config(enum SongFragmentType ftype) } } -struct Style * +struct ChoStyle * cho_style_new_default(void) { - struct Style *style = cho_style_new_from_config(g_current_ftype); + struct ChoStyle *style = cho_style_new_from_config(g_current_ftype); cho_style_apply_default(g_current_ftype, style); return style; } void -cho_style_free(struct Style *style) +cho_style_free(struct ChoStyle *style) { if (!style) { return; @@ -1065,12 +1065,12 @@ cho_style_font_desc_parse(const char *str) return font; } -struct Style * -cho_style_parse(const char *tag_name, struct Attr **attrs, struct Style *inherited_style) +struct ChoStyle * +cho_style_parse(const char *tag_name, struct Attr **attrs, struct ChoStyle *inherited_style) { size_t value_len, last_char; struct RGBColor *rgb_color; - struct Style *style; + struct ChoStyle *style; struct Font *font; if (inherited_style) style = cho_style_copy(inherited_style); @@ -1340,7 +1340,7 @@ cho_style_parse(const char *tag_name, struct Attr **attrs, struct Style *inherit } void -cho_style_print_as_toml(struct Style *style, const char *section) +cho_style_print_as_toml(struct ChoStyle *style, const char *section) { printf("foreground_color = \"%s\"\n", cho_rgbcolor_to_string(style->foreground_color)); printf("background_color = \"%s\"\n", cho_rgbcolor_to_string(style->background_color)); @@ -1498,7 +1498,7 @@ cho_tag_close_last_unclosed(const char *tag_name, struct Tag **tags, int last_in return false; } -static struct Style * +static struct ChoStyle * cho_tag_style_inherit(struct Tag **tags, int prev_index) { int i = prev_index; @@ -3328,7 +3328,7 @@ cho_songs_parse(FILE *fp, const char *chordpro_filepath, struct Config *config) songs[so]->sections[se]->lines[li]->items = malloc(sizeof(struct ChoLineItem *)); songs[so]->sections[se]->lines[li]->items[ly] = cho_line_item_new(); struct Tag **tags = NULL; - struct Style *tag_style; + struct ChoStyle *tag_style; struct StyleProperty sprop; struct ChoChord *tmp_chord; struct ChoSection *chorus; diff --git a/chordpro.h b/chordpro.h @@ -90,7 +90,7 @@ struct RGBColor { uint8_t blue; }; -struct Style { +struct ChoStyle { struct Font *font; struct RGBColor *foreground_color; struct RGBColor *background_color; @@ -113,7 +113,7 @@ struct Attr { struct Tag { char *name; - struct Style *style; + struct ChoStyle *style; struct Attr **attrs; bool is_closed; }; @@ -271,17 +271,17 @@ struct ChoDirective { enum StylePropertyType sprop; enum SongFragmentType ftype; enum BreakType btype; - struct Style *style; + struct ChoStyle *style; }; struct ChoMetadata { char *name; char *value; - struct Style *style; + struct ChoStyle *style; }; struct ChoChord { - struct Style *style; + struct ChoStyle *style; bool is_canonical; char *name; char *root; @@ -291,7 +291,7 @@ struct ChoChord { }; struct ChoText { - struct Style *style; + struct ChoStyle *style; char *text; }; @@ -339,11 +339,11 @@ char *cho_chord_name_generate(struct ChoChord *chord); const char *cho_metadata_get(struct ChoMetadata **metadata, const char *name); -struct Style *cho_style_new(void); -void cho_style_free(struct Style *style); -struct Style *cho_style_copy(struct Style *style); +struct ChoStyle *cho_style_new(void); +void cho_style_free(struct ChoStyle *style); +struct ChoStyle *cho_style_copy(struct ChoStyle *style); struct Font *cho_style_font_desc_parse(const char *str); -void cho_style_print_as_toml(struct Style *style, const char *section); +void cho_style_print_as_toml(struct ChoStyle *style, const char *section); struct RGBColor *cho_color_parse(const char *str); enum LineStyle cho_linestyle_parse(const char *str); @@ -364,7 +364,7 @@ enum FontWeight cho_font_weight_parse(const char *str); const char *cho_font_weight_to_config_string(enum FontWeight weight); void cho_font_print_as_toml(struct Font *font, const char *section); -void cho_debug_style_print(struct Style *style); +void cho_debug_style_print(struct ChoStyle *style); // void cho_debug_songs_print(struct ChoSong **songs); #endif /* _CHORDPRO_H_ */ diff --git a/config.c b/config.c @@ -440,7 +440,7 @@ config_load_font(struct Font *font, toml_table_t *table, const char *key_name) } static bool -config_load_style(struct Style *style, toml_table_t *table, const char *key_name) +config_load_style(struct ChoStyle *style, toml_table_t *table, const char *key_name) { toml_value_t value; struct RGBColor *color; diff --git a/config.h b/config.h @@ -3,7 +3,7 @@ struct OutputStyle { char *name; - struct Style *style; + struct ChoStyle *style; }; enum NamingSystem { diff --git a/out_pdf.c b/out_pdf.c @@ -120,7 +120,7 @@ out_pdf_font_get_all(struct ChoSong **songs, struct Config *config) int li = 0; int ly = 0; int ch = 0; - struct Style *style; + struct ChoStyle *style; while (songs[so] != NULL) { while (songs[so]->sections[se] != NULL) { while (songs[so]->sections[se]->lines[li]) { @@ -310,7 +310,7 @@ out_pdf_font_set(pdfio_stream_t *stream, struct Font *font) } static double -text_width(const char *text, struct Style *style) +text_width(const char *text, struct ChoStyle *style) { char *name = out_pdf_fnt_name_create(style->font); pdfio_obj_t *font_obj = out_pdf_fnt_obj_get_by_name(name); @@ -358,7 +358,7 @@ find_whitespace(const char *str, size_t start) } static int -text_find_fitting(const char *str, struct Style *style, double x) +text_find_fitting(const char *str, struct ChoStyle *style, double x) { size_t len = strlen(str); size_t start = len - 1; @@ -503,7 +503,7 @@ out_pdf_text_show(pdfio_stream_t *stream, struct PDFText *text) } static bool -annot_add(struct PDFContext *ctx, struct Style *style, double width) +annot_add(struct PDFContext *ctx, struct ChoStyle *style, double width) { pdfio_rect_t rect; pdfio_dict_t *annot, *action; @@ -1288,7 +1288,7 @@ static bool pdf_texts_add_text( struct PDFContext *ctx, const char *text, - struct Style *style, + struct ChoStyle *style, enum Alignment align ) { @@ -1460,7 +1460,7 @@ pdf_content_create( ctx.biggest_font_size = 0.0; ctx.prev_added_space = 0.0; char *string; - struct Style *style; + struct ChoStyle *style; if (!calc_space_between_text_above(left_items, left_aboves, img_objs, &ctx.spaces)) { LOG_DEBUG("calc_space_between_text_above failed."); return false; diff --git a/out_pdf.h b/out_pdf.h @@ -47,7 +47,7 @@ struct PDFImage { struct PDFText { char *text; - struct Style *style; + struct ChoStyle *style; double x; double y; };