sacc

sacc (saccomys): simple gopher client.
Log | Files | Refs | LICENSE

commit a78b697325cbbd8080252d615c1f4414d5668245
parent 11124906aacdbeab120693f2729813e32d5e0149
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu, 22 Jun 2017 22:40:04 +0200

Print fixed-width index

Diffstat:
sacc.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sacc.c b/sacc.c @@ -165,6 +165,7 @@ display(Item *item) { Item **items; size_t i, lines, nitems; + int ndigits; if (item->type > '1') return; @@ -177,9 +178,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;