Tidying up
This commit is contained in:
parent
170fb41568
commit
3678e7608f
20
bb.c
20
bb.c
@ -186,12 +186,14 @@ static void render(bb_state_t *state)
|
|||||||
entry_t **files = state->files;
|
entry_t **files = state->files;
|
||||||
for (int i = state->scroll; i < state->scroll + height - 3 && i < state->nfiles; i++) {
|
for (int i = state->scroll; i < state->scroll + height - 3 && i < state->nfiles; i++) {
|
||||||
entry_t *entry = files[i];
|
entry_t *entry = files[i];
|
||||||
|
struct stat info = {0};
|
||||||
|
lstat(entry->d_fullname, &info);
|
||||||
|
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = i - state->scroll + 2;
|
int y = i - state->scroll + 2;
|
||||||
term_move(x, y);
|
term_move(x, y);
|
||||||
|
|
||||||
// Selection box:
|
{ // Selection box:
|
||||||
if (IS_SELECTED(entry))
|
if (IS_SELECTED(entry))
|
||||||
writez(termfd, "\e[43m \e[0m");
|
writez(termfd, "\e[43m \e[0m");
|
||||||
else
|
else
|
||||||
@ -205,12 +207,9 @@ static void render(bb_state_t *state)
|
|||||||
writez(termfd, "\e[34m");
|
writez(termfd, "\e[34m");
|
||||||
else if (entry->d_type == DT_LNK)
|
else if (entry->d_type == DT_LNK)
|
||||||
writez(termfd, "\e[33m");
|
writez(termfd, "\e[33m");
|
||||||
|
}
|
||||||
|
|
||||||
struct stat info = {0};
|
{ // Filesize:
|
||||||
lstat(entry->d_fullname, &info);
|
|
||||||
|
|
||||||
{
|
|
||||||
// Filesize:
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
const char* units = "BKMGTPEZY";
|
const char* units = "BKMGTPEZY";
|
||||||
double bytes = (double)info.st_size;
|
double bytes = (double)info.st_size;
|
||||||
@ -223,8 +222,7 @@ static void render(bb_state_t *state)
|
|||||||
writez(termfd, buf);
|
writez(termfd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{ // Date:
|
||||||
// Date:
|
|
||||||
char buf[64];
|
char buf[64];
|
||||||
strftime(buf, sizeof(buf), "%l:%M%p %b %e %Y", localtime(&(info.st_mtime)));
|
strftime(buf, sizeof(buf), "%l:%M%p %b %e %Y", localtime(&(info.st_mtime)));
|
||||||
writez(termfd, buf);
|
writez(termfd, buf);
|
||||||
@ -232,8 +230,7 @@ static void render(bb_state_t *state)
|
|||||||
writez(termfd, " │ ");
|
writez(termfd, " │ ");
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{ // Permissions:
|
||||||
// Permissions:
|
|
||||||
char buf[] = {
|
char buf[] = {
|
||||||
'0' + ((info.st_mode >> 6) & 7),
|
'0' + ((info.st_mode >> 6) & 7),
|
||||||
'0' + ((info.st_mode >> 3) & 7),
|
'0' + ((info.st_mode >> 3) & 7),
|
||||||
@ -243,7 +240,7 @@ static void render(bb_state_t *state)
|
|||||||
writez(termfd, " │ ");
|
writez(termfd, " │ ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name:
|
{ // Name:
|
||||||
write(termfd, entry->d_name, entry->d_namlen);
|
write(termfd, entry->d_name, entry->d_namlen);
|
||||||
if (entry->d_isdir)
|
if (entry->d_isdir)
|
||||||
writez(termfd, "/");
|
writez(termfd, "/");
|
||||||
@ -259,6 +256,7 @@ static void render(bb_state_t *state)
|
|||||||
if (entry->d_isdir)
|
if (entry->d_isdir)
|
||||||
writez(termfd, "/");
|
writez(termfd, "/");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
writez(termfd, " \e[0m"); // Reset color and attributes
|
writez(termfd, " \e[0m"); // Reset color and attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user