aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bb.c11
-rw-r--r--bb.h4
2 files changed, 14 insertions, 1 deletions
diff --git a/bb.c b/bb.c
index d8d3c13..c525913 100644
--- a/bb.c
+++ b/bb.c
@@ -907,6 +907,17 @@ void render(bb_t *bb)
fputs(" \033[K\033[0m", tty_out); // Reset color and attributes
}
+ // Scrollbar:
+ if (bb->nfiles > ONSCREEN) {
+ int height = (ONSCREEN*ONSCREEN + (bb->nfiles-1))/bb->nfiles;
+ int start = 2 + (bb->scroll*ONSCREEN)/bb->nfiles;
+ for (int i = 2; i < 2 + ONSCREEN; i++) {
+ move_cursor(tty_out, winsize.ws_col-1, i);
+ fprintf(tty_out, "%s\033[0m",
+ (i >= start && i < start + height) ? SCROLLBAR_FG : SCROLLBAR_BG);
+ }
+ }
+
move_cursor(tty_out, winsize.ws_col/2, winsize.ws_row - 1);
fputs("\033[0m\033[K", tty_out);
int x = winsize.ws_col;
diff --git a/bb.h b/bb.h
index e133800..0d0fd85 100644
--- a/bb.h
+++ b/bb.h
@@ -25,7 +25,7 @@
#include "bterm.h"
// Macros:
-#define BB_VERSION "0.20.5"
+#define BB_VERSION "0.21.0"
#ifndef PATH_MAX
#define PATH_MAX 4096
@@ -172,6 +172,8 @@ typedef struct proc_s {
#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