mirror of
https://github.com/systemd/systemd.git
synced 2025-01-24 06:04:05 +03:00
progress-bar: Put a space after the prefix
We always want a space there. So let's just put one in the drawing routine, and adjust the call cites to avoid adding a second one.
This commit is contained in:
parent
7571cb42a8
commit
6e1992166f
@ -45,7 +45,7 @@ static const char* arg_format = NULL;
|
||||
static sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
|
||||
static ImageClass arg_image_class = _IMAGE_CLASS_INVALID;
|
||||
|
||||
#define PROGRESS_PREFIX "Total: "
|
||||
#define PROGRESS_PREFIX "Total:"
|
||||
|
||||
static int settle_image_class(void) {
|
||||
|
||||
|
@ -4553,7 +4553,7 @@ static int progress_bytes(uint64_t n_bytes, void *userdata) {
|
||||
|
||||
p->copy_blocks_done += n_bytes;
|
||||
|
||||
if (asprintf(&s, "%s %s %s %s/%s ",
|
||||
if (asprintf(&s, "%s %s %s %s/%s",
|
||||
strna(p->copy_blocks_path),
|
||||
special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
|
||||
strna(p->definition_path),
|
||||
|
@ -469,12 +469,14 @@ void draw_progress_bar(const char *prefix, double percentage) {
|
||||
setvbuf(stderr, buffer, _IOFBF, sizeof(buffer));
|
||||
|
||||
fputc('\r', stderr);
|
||||
if (prefix)
|
||||
if (prefix) {
|
||||
fputs(prefix, stderr);
|
||||
fputc(' ', stderr);
|
||||
}
|
||||
|
||||
if (!terminal_is_dumb()) {
|
||||
size_t cols = columns();
|
||||
size_t prefix_width = utf8_console_width(prefix);
|
||||
size_t prefix_width = utf8_console_width(prefix) + 1 /* space */;
|
||||
size_t length = cols > prefix_width + 6 ? cols - prefix_width - 6 : 0;
|
||||
|
||||
if (length > 5 && percentage >= 0.0 && percentage <= 100.0) {
|
||||
@ -533,8 +535,8 @@ void clear_progress_bar(const char *prefix) {
|
||||
|
||||
if (terminal_is_dumb())
|
||||
fputs(strrepa(" ",
|
||||
prefix ? utf8_console_width(prefix) + 4 :
|
||||
LESS_BY(columns(), 1U)), /* 4: %3.0f%% */
|
||||
prefix ? utf8_console_width(prefix) + 5 : /* %3.0f%% (4 chars) + space */
|
||||
LESS_BY(columns(), 1U)),
|
||||
stderr);
|
||||
else
|
||||
fputs(ANSI_ERASE_TO_END_OF_LINE, stderr);
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "random-util.h"
|
||||
#include "tests.h"
|
||||
|
||||
#define PROGRESS_PREFIX "test: "
|
||||
#define PROGRESS_PREFIX "test:"
|
||||
|
||||
TEST(progress_bar) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user