Package: cdebconf Version: 0.30 Severity: wishlist Tags: patch l�r 2003-02-15 klockan 11.03 skrev Martin Sj�gren: > The typical use of the progress bar API looks like this: > > > PROGRESS START 0 N foo/start > > PROGRESS STEP 1 foo/inc > ... > PROGRESS STEP 1 foo/inc > ... > (et.c.) > > PROGRESS STOP > > > Now, the problem is that the counter is increased before the text is > displayed. Wouldn't it make more sense to do a post-increment than a > pre-increment? I guess that would mean that PROGRESS STOP has to show > the final 100% value before leaving. > > How does that sound?
Here's one (somewhat hackish) way to do it:
diff -u -r1.31 text.c
--- src/modules/frontend/text/text.c 26 Jan 2003 16:51:54 -0000
1.31
+++ src/modules/frontend/text/text.c 15 Feb 2003 10:36:21 -0000
@@ -495,14 +495,14 @@
int width = getwidth();
char out[256];
- ui->progress_cur += step;
-
snprintf(out, sizeof(out), "[%.1f%%] %s",
(double)(ui->progress_cur - ui->progress_min) /
(double)(ui->progress_max - ui->progress_min) * 100.0, info);
if (strlen(out) > width - 7)
out[width - 7] = 0;
+ ui->progress_cur += step;
+
printf("%s\r", out);
fflush(stdout);
}
@@ -510,7 +510,7 @@
static void text_progress_stop(struct frontend *ui)
{
INFO(INFO_DEBUG, "%s\n", __FUNCTION__);
-
+ text_progress_step(ui, 0, "");
printf("\n");
}
signature.asc
Description: Detta =?ISO-8859-1?Q?=E4r?= en digitalt signeradmeddelandedel

