aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-04-10 00:12:57 -0700
committerBruce Hill <bruce@bruce-hill.com>2020-04-10 00:12:57 -0700
commit8d1e5f8172b9d2bcbd4ef0c33ea7a9f78cf70e9a (patch)
tree26007c9fc3bfee1b397c75e2d43972dce9374a26
parent5183cbd78f43f97e4e3d1cb5ad36a07fdcee51e0 (diff)
General code cleanup and removed some unnecessary imports.
-rw-r--r--bb.c1
-rw-r--r--bb.h42
-rw-r--r--columns.h22
3 files changed, 30 insertions, 35 deletions
diff --git a/bb.c b/bb.c
index 26cfcb0..5c9c487 100644
--- a/bb.c
+++ b/bb.c
@@ -1304,7 +1304,6 @@ int main(int argc, char *argv[])
init_term();
bb_browse(&bb, full_initial_path);
fputs(T_LEAVE_BBMODE, tty_out);
- cleanup();
if (bb.selected && print_selection) {
for (entry_t *e = bb.selected; e; e = e->selected.next) {
diff --git a/bb.h b/bb.h
index 23682b8..946f323 100644
--- a/bb.h
+++ b/bb.h
@@ -5,7 +5,6 @@
*
* This file contains definitions and customization for `bb`.
*/
-#include <dirent.h>
#include <fcntl.h>
#include <glob.h>
#include <limits.h>
@@ -13,14 +12,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/dir.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
-#include <sys/types.h>
#include <sys/wait.h>
#include <termios.h>
-#include <time.h>
#include <unistd.h>
#include "bterm.h"
@@ -32,11 +28,29 @@
#define PATH_MAX 4096
#endif
-#define BB_TIME_FMT " %T %D "
#define MAX_COLS 12
#define MAX_SORT (2*MAX_COLS)
#define HASH_SIZE 1024
#define HASH_MASK (HASH_SIZE - 1)
+#define MAX_BINDINGS 1024
+
+// Configurable options:
+#define BB_TIME_FMT " %T %D "
+#define SCROLLOFF MIN(5, (winsize.ws_row-4)/2)
+#define SORT_INDICATOR "↓"
+#define RSORT_INDICATOR "↑"
+#define SELECTED_INDICATOR " \033[31;7m \033[0m"
+#define NOT_SELECTED_INDICATOR " "
+// Colors (using ANSI escape sequences):
+#define TITLE_COLOR "\033[37;1m"
+#define NORMAL_COLOR "\033[37m"
+#define CURSOR_COLOR "\033[43;30;1m"
+#define LINK_COLOR "\033[35m"
+#define DIR_COLOR "\033[34m"
+#define EXECUTABLE_COLOR "\033[31m"
+#define SCROLLBAR_FG "\033[48;5;247m "
+#define SCROLLBAR_BG "\033[48;5;239m "
+
#define MAX(a,b) ((a) < (b) ? (b) : (a))
#define MIN(a,b) ((a) > (b) ? (b) : (a))
#define IS_SELECTED(p) (((p)->selected.atme) != NULL)
@@ -156,24 +170,6 @@ typedef struct proc_s {
} running;
} proc_t;
-// Configurable options:
-#define SCROLLOFF MIN(5, (winsize.ws_row-4)/2)
-#define SORT_INDICATOR "↓"
-#define RSORT_INDICATOR "↑"
-#define SELECTED_INDICATOR " \033[31;7m \033[0m"
-#define NOT_SELECTED_INDICATOR " "
-// Colors (using ANSI escape sequences):
-#define TITLE_COLOR "\033[37;1m"
-#define NORMAL_COLOR "\033[37m"
-#define CURSOR_COLOR "\033[43;30;1m"
-#define LINK_COLOR "\033[35m"
-#define DIR_COLOR "\033[34m"
-#define EXECUTABLE_COLOR "\033[31m"
-#define SCROLLBAR_FG "\033[48;5;247m "
-#define SCROLLBAR_BG "\033[48;5;239m "
-
-#define MAX_BINDINGS 1024
-
static binding_t bindings[MAX_BINDINGS];
#include "columns.h"
diff --git a/columns.h b/columns.h
index 90c5105..297a00a 100644
--- a/columns.h
+++ b/columns.h
@@ -66,57 +66,57 @@ static void timeago(char *buf, time_t t)
sprintf(buf, "%d years", (int)delta/YEAR);
}
-void col_mreltime(entry_t *entry, const char *color, char *buf, int width) {
+static void col_mreltime(entry_t *entry, const char *color, char *buf, int width) {
(void)color;
timeago(buf, entry->info.st_mtime);
lpad(buf, width);
}
-void col_areltime(entry_t *entry, const char *color, char *buf, int width) {
+static void col_areltime(entry_t *entry, const char *color, char *buf, int width) {
(void)color;
timeago(buf, entry->info.st_atime);
lpad(buf, width);
}
-void col_creltime(entry_t *entry, const char *color, char *buf, int width) {
+static void col_creltime(entry_t *entry, const char *color, char *buf, int width) {
(void)color;
timeago(buf, entry->info.st_ctime);
lpad(buf, width);
}
-void col_mtime(entry_t *entry, const char *color, char *buf, int width) {
+static void col_mtime(entry_t *entry, const char *color, char *buf, int width) {
(void)color;
strftime(buf, (size_t)width, BB_TIME_FMT, localtime(&(entry->info.st_mtime)));
}
-void col_atime(entry_t *entry, const char *color, char *buf, int width) {
+static void col_atime(entry_t *entry, const char *color, char *buf, int width) {
(void)color;
strftime(buf, (size_t)width, BB_TIME_FMT, localtime(&(entry->info.st_atime)));
}
-void col_ctime(entry_t *entry, const char *color, char *buf, int width) {
+static void col_ctime(entry_t *entry, const char *color, char *buf, int width) {
(void)color;
strftime(buf, (size_t)width, BB_TIME_FMT, localtime(&(entry->info.st_ctime)));
}
-void col_selected(entry_t *entry, const char *color, char *buf, int width) {
+static void col_selected(entry_t *entry, const char *color, char *buf, int width) {
(void)width;
buf = stpcpy(buf, IS_SELECTED(entry) ? SELECTED_INDICATOR : NOT_SELECTED_INDICATOR);
buf = stpcpy(buf, color);
}
-void col_perm(entry_t *entry, const char *color, char *buf, int width) {
+static void col_perm(entry_t *entry, const char *color, char *buf, int width) {
(void)color; (void)width;
sprintf(buf, " %03o", entry->info.st_mode & 0777);
}
-void col_random(entry_t *entry, const char *color, char *buf, int width)
+static void col_random(entry_t *entry, const char *color, char *buf, int width)
{
(void)color;
sprintf(buf, "%*d", width, entry->shufflepos);
}
-void col_size(entry_t *entry, const char *color, char *buf, int width)
+static void col_size(entry_t *entry, const char *color, char *buf, int width)
{
(void)color; (void)width;
int j = 0;
@@ -129,7 +129,7 @@ void col_size(entry_t *entry, const char *color, char *buf, int width)
sprintf(buf, " %6.*f%c ", j > 0 ? 1 : 0, bytes, units[j]);
}
-void col_name(entry_t *entry, const char *color, char *buf, int width)
+static void col_name(entry_t *entry, const char *color, char *buf, int width)
{
(void)width;
if (entry->no_esc) buf = stpcpy(buf, entry->name);