Index: main.c =================================================================== RCS file: /cvsroot/avrdude/avrdude/main.c,v retrieving revision 1.109 diff -u -u -r1.109 main.c --- main.c 21 Sep 2005 15:02:02 -0000 1.109 +++ main.c 21 Sep 2005 20:23:31 -0000 @@ -37,6 +37,9 @@ #include #include #include +#if HAVE_LIBTERMCAP +# include +#endif #include #include #include @@ -80,6 +83,9 @@ char progbuf[PATH_MAX]; /* temporary buffer of spaces the same length as progname; used for lining up multiline messages */ +#if HAVE_LIBTERMCAP +const char *cap_cr; /* "cr" capability string from termcap */ +#endif PROGRAMMER * pgm = NULL; @@ -302,6 +308,14 @@ last = 0; /* Get ready for next time. */ } +#if HAVE_LIBTERMCAP +/* This is required for tputs() below. */ +static int putc_stderr(int c) +{ + return putc(c, stderr); +} +#endif + static void update_progress_tty (int percent, double etime, char *hdr) { static char hashes[51]; @@ -323,8 +337,14 @@ } if (last == 0) { +#if HAVE_LIBTERMCAP + tputs(cap_cr, 1, putc_stderr); + fprintf(stderr, "%s | %s | %d%% %0.2fs", + header, hashes, percent, etime); +#else fprintf(stderr, "\r%s | %s | %d%% %0.2fs", header, hashes, percent, etime); +#endif } if (percent == 100) { @@ -736,6 +756,9 @@ unsigned char safemode_fuse = 0xff; char * safemode_response; +#if HAVE_LIBTERMCAP + char *term, termcapspace[1024], area[100], *areap; +#endif int fuses_specified = 0; int fuses_updated = 0; #if !defined(WIN32NATIVE) @@ -962,9 +985,15 @@ } +#if HAVE_LIBTERMCAP + if ((term = getenv("TERM")) != NULL && tgetent(termcapspace, term) > 0) { + areap = area; + cap_cr = tgetstr("cr", &areap); + } +#endif if (quell_progress == 0) { - if (isatty (STDERR_FILENO)) + if (isatty (STDERR_FILENO) && cap_cr != NULL) update_progress = update_progress_tty; else { update_progress = update_progress_no_tty;