aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-02-18 23:20:57 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-02-18 23:20:57 -0800
commitd7e6159eb855578142b19d4becadadc5c55e32ca (patch)
tree57d18bc7a74ee04f14bbb661e92f4eb0c6f88698
parent2767e33ab782edfab8bf6dcde36c28bca9b76f87 (diff)
Bugfix for cursor position not being remembered correctly.
-rw-r--r--bb.c6
-rw-r--r--bb.h2
2 files changed, 5 insertions, 3 deletions
diff --git a/bb.c b/bb.c
index 4470164..d5cda7a 100644
--- a/bb.c
+++ b/bb.c
@@ -397,6 +397,7 @@ int populate_files(bb_t *bb, const char *path)
{
int samedir = path && strcmp(bb->path, path) == 0;
int old_scroll = bb->scroll;
+ int old_cursor = bb->cursor;
char old_selected[PATH_MAX] = "";
if (samedir && bb->nfiles > 0) strcpy(old_selected, bb->files[bb->cursor]->fullname);
@@ -491,6 +492,7 @@ int populate_files(bb_t *bb, const char *path)
sort_files(bb);
if (samedir) {
set_scroll(bb, old_scroll);
+ bb->cursor = old_cursor > bb->nfiles-1 ? bb->nfiles-1 : old_cursor;
if (old_selected[0]) {
entry_t *e = load_entry(bb, old_selected);
if (e) set_cursor(bb, e->index);
@@ -827,8 +829,8 @@ void render(bb_t *bb)
for (int col = 0; bb->columns[col]; col++) {
fprintf(tty_out, "\033[%d;%dH\033[K", y+1, x+1);
if (col > 0) {
- if (i == bb->cursor) fputs("│", tty_out);
- else fputs("\033[37;2m│\033[22m", tty_out);
+ if (i == bb->cursor) fputs("┃", tty_out);
+ else fputs("\033[37;2m┃\033[22m", tty_out);
fputs(i == bb->cursor ? CURSOR_COLOR : "\033[0m", tty_out);
x += 1;
}
diff --git a/bb.h b/bb.h
index a5e9536..3e6faf6 100644
--- a/bb.h
+++ b/bb.h
@@ -25,7 +25,7 @@
#include "bterm.h"
// Macros:
-#define BB_VERSION "0.21.1"
+#define BB_VERSION "0.21.2"
#ifndef PATH_MAX
#define PATH_MAX 4096