Just to show willing. Provide the obvious default, because it seems to
be necessary!
if (setupterm(0, fileno(tty->fp), &err) != OK || err < 1) return (-1);
tty->cap.cr = tigetstr("cr");
if (setupterm(0, fileno(tty->fp), &err) != OK || err < 1) return (-1);
tty->cap.cr = tigetstr("cr");
+ tty->cap.nw = tigetstr("nel");
tty->cap.up = tigetstr("cuu1");
tty->cap.ce = tigetstr("el");
tty->cap.cd = tigetstr("ed");
tty->cap.up = tigetstr("cuu1");
tty->cap.ce = tigetstr("el");
tty->cap.cd = tigetstr("ed");
capcur = tty->capbuf;
tty->cap.cr = tgetstr("cr", &capcur);
capcur = tty->capbuf;
tty->cap.cr = tgetstr("cr", &capcur);
+ tty->cap.nw = tgetstr("nw", &capcur);
tty->cap.up = tgetstr("up", &capcur);
tty->cap.ce = tgetstr("ce", &capcur);
tty->cap.cd = tgetstr("cd", &capcur);
tty->cap.up = tgetstr("up", &capcur);
tty->cap.ce = tgetstr("ce", &capcur);
tty->cap.cd = tgetstr("cd", &capcur);
#undef SETDIM
if (!tty->cap.cr) tty->cap.cr = "\r";
#undef SETDIM
if (!tty->cap.cr) tty->cap.cr = "\r";
+ if (!tty->cap.nw) tty->cap.nw = "\r\n";
if (!tty->cap.up || !tty->cap.ce || !tty->cap.cd)
{ fclose(tty->fp); tty->fp = 0; return (-1); }
if (!tty->cap.af || !tty->cap.ab || !tty->cap.op) tty->cap.op = 0;
if (!tty->cap.up || !tty->cap.ce || !tty->cap.cd)
{ fclose(tty->fp); tty->fp = 0; return (-1); }
if (!tty->cap.af || !tty->cap.ab || !tty->cap.op) tty->cap.op = 0;
int progress_update(struct progress_state *progress)
{
struct progress_render_state render;
int progress_update(struct progress_state *progress)
{
struct progress_render_state render;
+ const struct progress_ttyinfo *tty = &progress->tty;
struct progress_item *item;
unsigned f = 0;
#define f_any 1u
struct progress_item *item;
unsigned f = 0;
#define f_any 1u
clear_progress(progress, &render, 0);
for (item = progress->items; item; item = item->next) {
clear_progress(progress, &render, 0);
for (item = progress->items; item; item = item->next) {
- if (f&f_any) fputs("\r\n", progress->tty.fp);
+ if (f&f_any) put_sequence(tty, tty->cap.nw, 1);
render.leftsz = render.rightsz = 0;
render.leftwd = render.rightwd = 0;
item->render(item, &render); progress->last_lines++; f |= f_any;
render.leftsz = render.rightsz = 0;
render.leftwd = render.rightwd = 0;
item->render(item, &render); progress->last_lines++; f |= f_any;
struct { /* terminal capabilities */
unsigned f; /* various flags */
#define TCF_BCE 1u /* erases to background colour */
struct { /* terminal capabilities */
unsigned f; /* various flags */
#define TCF_BCE 1u /* erases to background colour */
- const char *cr, *up, *ce, *cd; /* cursor motion */
+ const char *cr, *nw, *up, *ce, *cd; /* cursor motion */
const char *mr, *md, *me; /* reverse video, bold */
const char *af, *ab, *op; /* colour */
} cap;
const char *mr, *md, *me; /* reverse video, bold */
const char *af, *ab, *op; /* colour */
} cap;