sprintf(timecell, "%f [%3d%%]", diff,
done ? 100 : (int)(diff / (TIME_PERIOD / 100.0)));
- /* don't print line separator when in progress */
- scols_table_enable_nolinesep(tb, !done);
+ /* Note that libsmartcols don't print \n for last line
+ * in the table, but if you print a line somewhere in
+ * the midle of the table you need
+ *
+ * scols_table_enable_nolinesep(tb, !done);
+ *
+ * to disable line breaks. In this example it's
+ * unnecessary as we print the latest line only.
+ */
+
/* print the line */
scols_table_print_range(tb, line, NULL);
fflush(scols_table_get_stream(tb));
/* move to the begin of the line */
fputc('\r', scols_table_get_stream(tb));
- }
+ } else
+ fputc('\n', scols_table_get_stream(tb));
} while (!done);
last = now;
struct libscols_line *ln;
assert(tb);
+ DBG(TAB, ul_debugobj(tb, "printing range"));
while (rc == 0 && scols_table_next_line(tb, itr, &ln) == 0) {
if (scols_table_is_tree(tb))
return -EINVAL;
- DBG(TAB, ul_debugobj(tb, "printing range"));
+ DBG(TAB, ul_debugobj(tb, "printing range from API"));
rc = initialize_printing(tb, &buf);
if (rc)