summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-07-18 18:58:22 +0200
committerYorhel <git@yorhel.nl>2010-07-18 18:58:22 +0200
commit791612dc4daa08444668dca6d52c26613cc142a3 (patch)
tree5d48545a7bebdc269200689b4d295f3420a66c5a /src
parentd942a0ebc6766437fbb09e27211d7f75d74e36b8 (diff)
browser.c: Got rid of the 'line' format string
This solution is far cleaner. Thanks to Ben North for pointing me to the *-width-specifier that has apparently been built into the printf-family functions for, well, quite a while, it seems.
Diffstat (limited to 'src')
-rw-r--r--src/browser.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/browser.c b/src/browser.c
index a5a5a8c..f004abe 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -90,7 +90,7 @@ void browse_draw_info(struct dir *dr) {
}
-void browse_draw_item(struct dir *n, int row, char *line) {
+void browse_draw_item(struct dir *n, int row) {
char ct, dt, *size, gr[11];
int i, o;
float pc;
@@ -142,10 +142,10 @@ void browse_draw_item(struct dir *n, int row, char *line) {
/* format and add item to the list */
switch(graph) {
- case 0: mvprintw(row, 0, line, ct, size, dt, cropstr(n->name, wincols-13)); break;
- case 1: mvprintw(row, 0, line, ct, size, gr, dt, cropstr(n->name, wincols-25)); break;
- case 2: mvprintw(row, 0, line, ct, size, pc, dt, cropstr(n->name, wincols-21)); break;
- case 3: mvprintw(row, 0, line, ct, size, pc, gr, dt, cropstr(n->name, wincols-32));
+ case 0: mvprintw(row, 0, "%c %8s %c%-*s", ct, size, dt, wincols-13, cropstr(n->name, wincols-13)); break;
+ case 1: mvprintw(row, 0, "%c %8s [%10s] %c%-*s", ct, size, gr, dt, wincols-25, cropstr(n->name, wincols-25)); break;
+ case 2: mvprintw(row, 0, "%c %8s [%5.1f%%] %c%-*s", ct, size, pc, dt, wincols-21, cropstr(n->name, wincols-21)); break;
+ case 3: mvprintw(row, 0, "%c %8s [%5.1f%% %10s] %c%-*s", ct, size, pc, gr, dt, wincols-32, cropstr(n->name, wincols-32));
}
if(n->flags & FF_BSEL)
@@ -155,7 +155,7 @@ void browse_draw_item(struct dir *n, int row, char *line) {
void browse_draw() {
struct dir *t;
- char fmtsize[9], *tmp, line[35];
+ char fmtsize[9], *tmp;
int selected, i;
erase();
@@ -194,17 +194,9 @@ void browse_draw() {
/* get start position */
t = dirlist_top(0);
- /* create line format */
- switch(graph) {
- case 0: sprintf(line, "%%c %%8s %%c%%-%ds", wincols-13); break;
- case 1: sprintf(line, "%%c %%8s [%%10s] %%c%%-%ds", wincols-25); break;
- case 2: sprintf(line, "%%c %%8s [%%5.1f%%%%] %%c%%-%ds", wincols-21); break;
- case 3: sprintf(line, "%%c %%8s [%%5.1f%%%% %%10s] %%c%%-%ds", wincols-32);
- }
-
/* print the list to the screen */
for(i=0; t && i<winrows-3; t=dirlist_next(t),i++) {
- browse_draw_item(t, 2+i, line);
+ browse_draw_item(t, 2+i);
/* save the selected row number for later */
if(t->flags & FF_BSEL)
selected = i;