#include "memdebug.h" /* keep this as LAST include */
-#define MAX_BARLENGTH 256
+#define MAX_BARLENGTH 400
+#define MIN_BARLENGTH 20
/* 200 values generated by this perl code:
# define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
#endif
+static void update_width(struct ProgressData *bar)
+{
+ int cols = get_terminal_columns();
+ if(cols > MAX_BARLENGTH)
+ bar->width = MAX_BARLENGTH;
+ else if(cols > MIN_BARLENGTH)
+ bar->width = (int)cols;
+ else
+ bar->width = MIN_BARLENGTH;
+}
+
int tool_progress_cb(void *clientp,
curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow)
if(tvdiff(now, bar->prevtime) < 100L)
/* limit progress-bar updating to 10 Hz */
return 0;
+ update_width(bar);
fly(bar, point != bar->prev);
}
}
/* simply count invokes */
bar->calls++;
+ update_width(bar);
if((total > 0) && (point != bar->prev)) {
char line[MAX_BARLENGTH + 1];
char format[40];
void progressbarinit(struct ProgressData *bar,
struct OperationConfig *config)
{
- unsigned int cols;
memset(bar, 0, sizeof(struct ProgressData));
/* pass the resume from value through to the progress function so it can
if(config->use_resume)
bar->initial_size = config->resume_from;
- cols = get_terminal_columns();
- if(cols > MAX_BARLENGTH)
- bar->width = MAX_BARLENGTH;
- else if(cols > 20)
- bar->width = (int)cols;
+ update_width(bar);
bar->out = tool_stderr;
bar->tick = 150;