Print fixed-width index - sacc - sacc(omys), simple console gopher client HTML git clone git://bitreich.org/sacc/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/sacc/ DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit fa93a3cfbc2505d467a4c58b1faadc36ed667cea DIR parent 784cd031f874c73ffa34ff11fadad4b1f2ace308 HTML Author: Quentin Rameau <quinq@fifth.space> Date: Thu, 22 Jun 2017 22:40:04 +0200 Print fixed-width index Diffstat: M sacc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- DIR diff --git a/sacc.c b/sacc.c @@ -162,6 +162,7 @@ display(Item *item) { Item **items; size_t i, lines, nitems; + int ndigits; if (item->type > '1') return; @@ -174,9 +175,10 @@ display(Item *item) items = item->dir->items; nitems = item->dir->nitems; lines = item->printoff + termlines(); + ndigits = (nitems < 10) ? 1 : (nitems < 100) ? 2 : 3; for (i = item->printoff; i < nitems && i < lines; ++i) { - printf("[%d]%.4s: %s\n", i+1, + printf("[%*d]%.4s: %s\n", ndigits, i+1, typedisplay(items[i]->type), items[i]->username); } break;