Replace pv_state_set_format() with pv_set_format_options(), which takes a structure rather than a long list of arguments, to make it easier to pass around - and rely on pv_state_name_set() being called first rather than doing it within this function, so it is only doing one job (#67).

This commit is contained in:
Andrew Wood
2026-04-03 20:00:42 +01:00
parent 80358e84f3
commit d7327aaf95
5 changed files with 87 additions and 79 deletions
+1 -11
View File
@@ -209,17 +209,7 @@ struct pvstate_s {
pvdisplay_width_t width; /* screen width */
unsigned int height; /* screen height */
unsigned int extra_displays; /* bitmask of extra display destinations */
struct { /* old-style format options (used by -R) */
size_t lastwritten; /* --last-written (amount) */
bool progress; /* --progress */
bool timer; /* --timer */
bool eta; /* --eta */
bool fineta; /* --fineta */
bool rate; /* --rate */
bool average_rate; /* --average-rate */
bool bytes; /* --bytes */
bool bufpercent; /* --buffer-percent */
} format_option;
pvformatoptions_s format_option; /* old-style format options (used by -R) */
bool force; /* display even if not on terminal */
bool cursor; /* use cursor positioning */
bool numeric; /* numeric output only */
+14 -8
View File
@@ -193,15 +193,21 @@ extern /*@null@*/ /*@only@*/ pvstate_t pv_state_alloc(void);
extern void pv_state_reset(pvstate_t state);
/*
* Set the formatting string, given a set of old-style formatting options.
* Set the format options and use them to build a default formatting string.
* The default string is used if no format string is explicitly set.
*/
extern void pv_state_set_format(pvstate_t state, bool progress,
bool timer, bool eta,
bool fineta, bool rate,
bool average_rate, bool bytes,
bool bufpercent,
size_t lastwritten,
/*@null@*/ const char *name);
typedef struct {
size_t lastwritten; /* --last-written (amount) */
bool progress; /* --progress */
bool timer; /* --timer */
bool eta; /* --eta */
bool fineta; /* --fineta */
bool rate; /* --rate */
bool average_rate; /* --average-rate */
bool bytes; /* --bytes */
bool bufpercent; /* --buffer-percent */
} pvformatoptions_s;
extern void pv_state_set_format_options(pvstate_t, pvformatoptions_s);
/*
* Set the various options.