diff --git a/docs/NEWS.md b/docs/NEWS.md index a21ce94..14cafb1 100644 --- a/docs/NEWS.md +++ b/docs/NEWS.md @@ -1,6 +1,7 @@ ### UNRELEASED - * *feature:* allow **--format** to include "%nA" more than once, with different "n" valeus (#122) + * *fix:* allow **--format** to include "%nA" more than once, with different "n" valeus (#122) + * *fix:* allow **--format** to include "%p" more than once * *fix:* add _configure_ script fallback for **--remote** check when cross-compiling (#120) * *fix:* allow **extra-display** to be changed by **--remote** (#123) diff --git a/po/cs.po b/po/cs.po index af6dcb9..cdbd0b5 100644 --- a/po/cs.po +++ b/po/cs.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: 2024-10-13 20:43+0000\n" "Last-Translator: mmatous \n" "Language-Team: Czech \n" @@ -415,16 +415,16 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "b/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "B/s" diff --git a/po/de.po b/po/de.po index 7981b06..a89cd6f 100644 --- a/po/de.po +++ b/po/de.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: 2024-10-13 20:43+0000\n" "Last-Translator: fnetX \n" "Language-Team: German \n" @@ -438,16 +438,16 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "b/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "B/s" diff --git a/po/es.po b/po/es.po index 9987ed1..7b646dc 100644 --- a/po/es.po +++ b/po/es.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -407,16 +407,16 @@ msgstr "" msgid "B" msgstr "" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "" diff --git a/po/fr.po b/po/fr.po index 7778b00..e5012ae 100644 --- a/po/fr.po +++ b/po/fr.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: 2024-10-12 11:13+0000\n" "Last-Translator: a-j-wood \n" "Language-Team: French \n" @@ -442,16 +442,16 @@ msgstr "" msgid "B" msgstr "O" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "O/s" diff --git a/po/pl.po b/po/pl.po index 89eecc5..ea521ba 100644 --- a/po/pl.po +++ b/po/pl.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: 2024-10-20 14:07+0000\n" "Last-Translator: coralpink \n" "Language-Team: Polish \n" @@ -433,16 +433,16 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "b/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "B/s" diff --git a/po/pt.po b/po/pt.po index 9763307..86c76c3 100644 --- a/po/pt.po +++ b/po/pt.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -421,16 +421,16 @@ msgstr "" msgid "B" msgstr "" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "B/s" diff --git a/po/ru.po b/po/ru.po index 9ce0957..ede6c02 100644 --- a/po/ru.po +++ b/po/ru.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: 2024-10-22 18:07+0000\n" "Last-Translator: 0ko <0ko@users.noreply.translate.codeberg.org>\n" "Language-Team: Russian \n" @@ -416,16 +416,16 @@ msgstr "бит" msgid "B" msgstr "байт" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "бит/с" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "/с" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "байт/с" diff --git a/po/tr.po b/po/tr.po index 595d8fa..4d00039 100644 --- a/po/tr.po +++ b/po/tr.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: pv 1.8.14\n" "Report-Msgid-Bugs-To: pv@ivarch.com\n" -"POT-Creation-Date: 2024-12-07 19:37+0000\n" +"POT-Creation-Date: 2024-12-07 20:21+0000\n" "PO-Revision-Date: 2024-10-12 23:51+0000\n" "Last-Translator: a-j-wood \n" "Language-Team: Turkish \n" @@ -417,16 +417,16 @@ msgstr "b" msgid "B" msgstr "B" -#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1099 +#: src/pv/display.c:862 src/pv/display.c:877 src/pv/display.c:1115 #: src/pv/loop.c:549 msgid "b/s" msgstr "b/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 msgid "/s" msgstr "/s" -#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1103 +#: src/pv/display.c:866 src/pv/display.c:881 src/pv/display.c:1119 #: src/pv/loop.c:549 msgid "B/s" msgstr "B/s" diff --git a/src/pv/display.c b/src/pv/display.c index eb59cd7..c020452 100644 --- a/src/pv/display.c +++ b/src/pv/display.c @@ -631,7 +631,7 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl bool final) { long eta; - int static_portion_size; + int static_portion_size, dynamic_segment_count; pv_display_component component_type; size_t segment; size_t new_display_string_len; @@ -1039,23 +1039,32 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl /* - * Now go through all the static portions of the format to work - * out how much space will be left for any dynamic portions - * (i.e. the progress bar). + * Now go through all the static portions of the format to work out + * how much space will be left for any dynamic segments (i.e. the + * progress bar), and count how many dynamic segments there are. */ static_portion_size = 0; + dynamic_segment_count = 0; for (segment = 0; segment < display->format_segment_count; segment++) { if (display->format[segment].type == PV_COMPONENT_STRING) { static_portion_size += display->format[segment].str_bytes; - } else if (display->format[segment].type != PV_COMPONENT_PROGRESS) { + debug("segment[%d] type:%d width:%d [%.*s]", segment, display->format[segment].type, + display->format[segment].str_bytes, display->format[segment].str_bytes, + &(format_used[display->format[segment].str_start])); + } else if (display->format[segment].type == PV_COMPONENT_PROGRESS) { + dynamic_segment_count++; + debug("segment[%d] type:%d dynamic", segment, display->format[segment].type); + } else { size_t segment_width = display->format[segment].chosen_size; if (0 == segment_width) segment_width = display->component[display->format[segment].type].bytes; static_portion_size += segment_width; + debug("segment[%d] type:%d width:%d", segment, display->format[segment].type, segment_width); } } debug("static_portion_size: %d", static_portion_size); + debug("dynamic_segment_count: %d", dynamic_segment_count); /* * Assemble the progress bar now we know how big it should be. @@ -1064,7 +1073,7 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl char *component_content; size_t component_buf_size; char after_bar[32]; /* flawfinder: ignore - only populated by pv_snprintf(). */ - int available_width, bar_width, pad_count; + int component_width, bar_area_width, filled_bar_width, pad_count; component_content = display->component[PV_COMPONENT_PROGRESS].content; component_content[0] = '\0'; @@ -1072,6 +1081,13 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl memset(after_bar, 0, sizeof(after_bar)); + component_width = (int) (state->control.width) - static_portion_size; + /* + * Divide the total remaining screen space by the number of dynamic segments. + */ + if (dynamic_segment_count > 1) + component_width /= dynamic_segment_count; + if (state->control.size > 0 || state->control.rate_gauge) { /* * Known size, or rate gauge mode. Show a bar, and @@ -1109,33 +1125,32 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl after_bar_width = strlen(after_bar); /* flawfinder: ignore */ /* flawfinder: always \0-terminated by pv_snprintf() and the earlier memset(). */ - available_width = - (int) (state->control.width) - static_portion_size - (int) (after_bar_width) - 2; + bar_area_width = component_width - (int) (after_bar_width) - 2; - if (available_width < 0) - available_width = 0; + if (bar_area_width < 0) + bar_area_width = 0; - if (available_width > (int) (component_buf_size) - 16) - available_width = (int) (component_buf_size - 16); + if (bar_area_width > (int) (component_buf_size) - 16) + bar_area_width = (int) (component_buf_size - 16); /* The opening of the bar area. */ (void) pv_snprintf(component_content, component_buf_size, "["); /* The bar portion. */ - bar_width = (int) ((available_width * bar_percentage) / 100 - 1); - for (pad_count = 0; pad_count < bar_width; pad_count++) { - if (pad_count < available_width) + filled_bar_width = (int) ((bar_area_width * bar_percentage) / 100 - 1); + for (pad_count = 0; pad_count < filled_bar_width; pad_count++) { + if (pad_count < bar_area_width) (void) pv_strlcat(component_content, "=", component_buf_size); } /* The tip of the bar, if not at 100%. */ - if (pad_count < available_width) { + if (pad_count < bar_area_width) { (void) pv_strlcat(component_content, ">", component_buf_size); pad_count++; } /* The spaces after the bar. */ - for (; pad_count < available_width; pad_count++) { + for (; pad_count < bar_area_width; pad_count++) { (void) pv_strlcat(component_content, " ", component_buf_size); } @@ -1148,15 +1163,15 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl int indicator_position = state->calc.percentage; - available_width = (int) (state->control.width) - static_portion_size - 5; + bar_area_width = component_width - 5; - if (available_width < 0) - available_width = 0; + if (bar_area_width < 0) + bar_area_width = 0; - if (available_width > (int) (component_buf_size) - 16) - available_width = (int) (component_buf_size) - 16; + if (bar_area_width > (int) (component_buf_size) - 16) + bar_area_width = (int) (component_buf_size) - 16; - debug("available_width: %d", available_width); + debug("bar_area_width: %d", bar_area_width); /* * Note that pv_calculate_transfer_rate() sets the @@ -1172,8 +1187,8 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl (void) pv_snprintf(component_content, component_buf_size, "["); /* The spaces before the indicator. */ - for (pad_count = 0; pad_count < (available_width * indicator_position) / 100; pad_count++) { - if (pad_count < available_width) + for (pad_count = 0; pad_count < (bar_area_width * indicator_position) / 100; pad_count++) { + if (pad_count < bar_area_width) (void) pv_strlcat(component_content, " ", component_buf_size); } @@ -1181,7 +1196,7 @@ bool pv_format(pvstate_t state, /*@null@ */ const char *format_supplied, pvdispl (void) pv_strlcat(component_content, "<=>", component_buf_size); /* The spaces after the indicator. */ - for (; pad_count < available_width; pad_count++) { + for (; pad_count < bar_area_width; pad_count++) { (void) pv_strlcat(component_content, " ", component_buf_size); }