As Bernhard Walle wrote:
> following idea:
> (http://savannah.nongnu.org/bugs/?func=detailitem&item_id=13607)
I've already sent a followup to that request, and set the status to
"Needs info".
Basically, I don't like the idea of depending on an arbitrary value of
TERM. The next person will come with TERM=dialup, another one with
TERM=thatreallyoldparallelprinterthatcouldnotbackspace, and so on.
If at all, I think it should depend on whether the current terminal
has a "cr" capability. If so, the string obtained from "cr" should be
used instead of a hard-coded \r, otherwise quell_progress could be
automatically set to 1.
My remark about the need to additional link to libtermcap is somewhat
a moot point, as libreadline already requires libtermcap anyway.
Well, looking a bit deeper into the code again, it seems your concerns
(garbage displayed on the terminal during progress update) would
already been dealt with by handling the incapable terminal as a
non-tty progress update, where simply one hash mark is printed each
time, no \r between.
I implemented a prototype for this, but interestingly enough,
TERM=dumb is not dumb enough to get no carriage return, as
[n]curses/termcap implicitly sets the "cr" capability for any
terminal, so you need to setup a termcap or terminfo entry that
explicitly denies that feature by saying "cr#".
--
cheers, J"org .-.-. --... ...-- -.. . DL8DTL
http://www.sax.de/~joerg/ NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)
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 <fcntl.h>
#include <limits.h>
#include <string.h>
+#if HAVE_LIBTERMCAP
+# include <termcap.h>
+#endif
#include <time.h>
#include <unistd.h>
#include <ctype.h>
@@ -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;
_______________________________________________
avrdude-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avrdude-dev