1
1

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.
Этот коммит содержится в:
Yorhel 2010-07-18 18:58:22 +02:00
родитель d942a0ebc6
Коммит 791612dc4d

Просмотреть файл

@ -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;