shell: implement draw_progress() as a convenience function
This commit is contained in:
parent
4c2f4eab24
commit
1638f9b0f1
3 changed files with 26 additions and 0 deletions
|
@ -5,5 +5,6 @@ obj-y += source/shell/echo.o
|
|||
obj-y += source/shell/flash.o
|
||||
obj-y += source/shell/ftl.o
|
||||
obj-y += source/shell/mufs.o
|
||||
obj-y += source/shell/progress.o
|
||||
obj-y += source/shell/rtc.o
|
||||
obj-y += source/shell/version.o
|
||||
|
|
22
source/shell/progress.c
Normal file
22
source/shell/progress.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#define TERM_WIDTH 80
|
||||
|
||||
void draw_progress(FILE *fp, unsigned long pos, unsigned long max)
|
||||
{
|
||||
unsigned long head = (TERM_WIDTH - 2) * pos / max;
|
||||
unsigned long i;
|
||||
|
||||
fputc('[', fp);
|
||||
|
||||
for (i = 0; i <= head; ++i)
|
||||
fputc('#', fp);
|
||||
|
||||
for (; i < (TERM_WIDTH - 2); ++i)
|
||||
fputc(' ', fp);
|
||||
|
||||
fputc(']', fp);
|
||||
|
||||
for (i = 0; i < TERM_WIDTH; ++i)
|
||||
fputc('\b', fp);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue