Skip to content
Snippets Groups Projects
Commit b24c3dee authored by Yorhel's avatar Yorhel
Browse files

Got rid of SF_SI

It was a totally useless feature, anyway.
parent 2b209ba9
No related branches found
No related tags found
No related merge requests found
...@@ -174,7 +174,7 @@ void browse_draw_item(struct dir *n, int row, off_t max, int ispar) { ...@@ -174,7 +174,7 @@ void browse_draw_item(struct dir *n, int row, off_t max, int ispar) {
&& n->sub == NULL ? 'e' : && n->sub == NULL ? 'e' :
' ' ; ' ' ;
dt = n->flags & FF_DIR ? '/' : ' '; dt = n->flags & FF_DIR ? '/' : ' ';
size = formatsize(stbrowse.flags & BF_AS ? n->asize : n->size, sflags & SF_SI); size = formatsize(stbrowse.flags & BF_AS ? n->asize : n->size);
/* create graph (if necessary) */ /* create graph (if necessary) */
pc = ((float)(stbrowse.flags & BF_AS ? n->asize : n->size) / (float)(stbrowse.flags & BF_AS ? n->parent->asize : n->parent->size)) * 100.0f; pc = ((float)(stbrowse.flags & BF_AS ? n->asize : n->size) / (float)(stbrowse.flags & BF_AS ? n->parent->asize : n->parent->size)) * 100.0f;
...@@ -236,9 +236,9 @@ int browse_draw() { ...@@ -236,9 +236,9 @@ int browse_draw() {
mvhline(winrows-1, 0, ' ', wincols); mvhline(winrows-1, 0, ' ', wincols);
mvprintw(0,0,"%s %s ~ Use the arrow keys to navigate, press ? for help", PACKAGE_NAME, PACKAGE_VERSION); mvprintw(0,0,"%s %s ~ Use the arrow keys to navigate, press ? for help", PACKAGE_NAME, PACKAGE_VERSION);
strcpy(tmp, formatsize(cur->parent->size, sflags & SF_SI)); strcpy(tmp, formatsize(cur->parent->size));
mvprintw(winrows-1, 0, " Total disk usage: %s Apparent size: %s Items: %d", mvprintw(winrows-1, 0, " Total disk usage: %s Apparent size: %s Items: %d",
tmp, formatsize(cur->parent->asize, sflags & SF_SI), cur->parent->items); tmp, formatsize(cur->parent->asize), cur->parent->items);
attroff(A_REVERSE); attroff(A_REVERSE);
mvhline(1, 0, '-', wincols); mvhline(1, 0, '-', wincols);
...@@ -368,10 +368,6 @@ int browse_key(int ch) { ...@@ -368,10 +368,6 @@ int browse_key(int ch) {
else else
stbrowse.flags = (stbrowse.flags & BF_HIDE) + (stbrowse.flags & BF_NDIRF) + BF_SIZE + BF_DESC; stbrowse.flags = (stbrowse.flags & BF_HIDE) + (stbrowse.flags & BF_NDIRF) + BF_SIZE + BF_DESC;
break; break;
case 'p':
hideinfo;
toggle(sflags, SF_SI);
break;
case 'h': case 'h':
hideinfo; hideinfo;
toggle(stbrowse.flags, BF_HIDE); toggle(stbrowse.flags, BF_HIDE);
......
...@@ -325,7 +325,7 @@ void calc_draw_progress() { ...@@ -325,7 +325,7 @@ void calc_draw_progress() {
nccreate(10, 60, stcalc.orig ? "Calculating..." : "Recalculating..."); nccreate(10, 60, stcalc.orig ? "Calculating..." : "Recalculating...");
ncprint(2, 2, "Total items: %-8d size: %s", ncprint(2, 2, "Total items: %-8d size: %s",
stcalc.parent->items, formatsize(stcalc.parent->size, sflags & SF_SI)); stcalc.parent->items, formatsize(stcalc.parent->size));
ncprint(3, 2, "Current dir: %s", cropstr(stcalc.cur, 43)); ncprint(3, 2, "Current dir: %s", cropstr(stcalc.cur, 43));
ncaddstr(8, 43, "Press q to quit"); ncaddstr(8, 43, "Press q to quit");
......
...@@ -59,8 +59,6 @@ ...@@ -59,8 +59,6 @@
#define FF_BSEL 0x40 /* selected */ #define FF_BSEL 0x40 /* selected */
/* Settings Flags (int sflags) */ /* Settings Flags (int sflags) */
#define SF_SMFS 0x01 /* same filesystem */
#define SF_SI 0x02 /* use powers of 1000 instead of 1024 */
#define SF_IGNS 0x04 /* ignore too small terminal sizes */ #define SF_IGNS 0x04 /* ignore too small terminal sizes */
#define SF_NOCFM 0x08 /* don't confirm file deletion */ #define SF_NOCFM 0x08 /* don't confirm file deletion */
#define SF_IGNE 0x10 /* ignore errors when deleting */ #define SF_IGNE 0x10 /* ignore errors when deleting */
......
...@@ -57,22 +57,14 @@ char *cropstr(const char *from, int s) { ...@@ -57,22 +57,14 @@ char *cropstr(const char *from, int s) {
} }
char *formatsize(const off_t from, int si) { char *formatsize(const off_t from) {
float r = from; float r = from;
char c = ' '; char c = ' ';
if(si) { if(r < 1000.0f) { }
if(r < 1000.0f) { } else if(r < 1023e3f) { c = 'k'; r/=1024.0f; }
else if(r < 1000e3f) { c = 'k'; r/=1000.0f; } else if(r < 1023e6f) { c = 'M'; r/=1048576.0f; }
else if(r < 1000e6f) { c = 'M'; r/=1000e3f; } else if(r < 1023e9f) { c = 'G'; r/=1073741824.0f; }
else if(r < 1000e9f) { c = 'G'; r/=1000e6f; } else { c = 'T'; r/=1099511627776.0f; }
else { c = 'T'; r/=1000e9f; }
} else {
if(r < 1000.0f) { }
else if(r < 1023e3f) { c = 'k'; r/=1024.0f; }
else if(r < 1023e6f) { c = 'M'; r/=1048576.0f; }
else if(r < 1023e9f) { c = 'G'; r/=1073741824.0f; }
else { c = 'T'; r/=1099511627776.0f; }
}
sprintf(formatsizedat, "%5.1f%cB", r, c); sprintf(formatsizedat, "%5.1f%cB", r, c);
return formatsizedat; return formatsizedat;
} }
......
...@@ -66,7 +66,7 @@ void ncprint(int, int, char *, ...); ...@@ -66,7 +66,7 @@ void ncprint(int, int, char *, ...);
char *cropstr(const char *, int); char *cropstr(const char *, int);
/* formats size in the form of xxx.xXB */ /* formats size in the form of xxx.xXB */
char *formatsize(const off_t, int); char *formatsize(const off_t);
/* int2string with thousand separators */ /* int2string with thousand separators */
char *fullsize(const off_t); char *fullsize(const off_t);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment