avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avrdude-dev] optional hash mark progress indicator


From: Theodore A. Roth
Subject: RE: [avrdude-dev] optional hash mark progress indicator
Date: Fri, 25 Jul 2003 14:40:14 -0700 (PDT)


On Sat, 26 Jul 2003, Alex Shepherd wrote:

> > If you are really set on the hash marks, I'd at least like the number
> > of hash marks printed to be a fixed number, like a percentage.  So
> > that part way through, the display might look something like this:
> >
> >   Writing: |###########                              |  29%
> > ETA 22.3 sec
>
> I'm really simply interested in some sort of progress indication that
> doesn't fill up my captured output with hundreds of line feeds. Printing a
> single character . or # every so often is a way to indicate things are
> working. From use I know how many characters will be printed for each
> project and know when it will be done.

I think the best solution would be to use Brian's method (above) if
istty() is true and Alex's method if false. This would work with both
a terminal and for captured output.

In both cases, -q should quell the output.

The easiest way to implement this would be via a pointer to function.
Maybe something like this (kinda psuedo code, haven't looked into
were something like this would go in the real code):

  typedef void (*FP_Progress)(int completed, int total);

  FP_Progess progress = NULL;

  if (quell_progress)
  {
    if (isty())
      progress = progress_tty;
    else
      progress = progress_no_tty;
  }

  void report_progress (int completed, int total)
  {
    if (progress)
      progress (completed, total)
  }

Then whenever you need to report the progress, just call
report_progress().

The no tty version could either print 50 hashes (each being 2%), or a
hash for every n bytes.

If both versions print a hash for each 2%, you get nearly consistent
output in both cases in the end. For example:

  Writing | ########################################  100% Complete

The only difference would be in the interim:

  Writing | ###############

versus

  Writing | ###############                           28% Complete

In my opinion, using carriage returns and special characters to dance
around the screen is not very portable. If you are going to go that
far, might as well use curses.

Ted Roth




reply via email to

[Prev in Thread] Current Thread [Next in Thread]