commit fa93a3cfbc2505d467a4c58b1faadc36ed667cea
parent 784cd031f874c73ffa34ff11fadad4b1f2ace308
Author: Quentin Rameau <quinq@fifth.space>
Date: Thu, 22 Jun 2017 22:40:04 +0200
Print fixed-width index
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
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;