From e4af5b41477c86224abd6afd577daaf75923e7f2 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch
Date: Thu, 1 Nov 2018 18:25:38 +0100
Subject: Remember cursor position in ancestor directories
---
sdn.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 50 insertions(+), 17 deletions(-)
diff --git a/sdn.cpp b/sdn.cpp
index d4ce0d7..76c87e3 100644
--- a/sdn.cpp
+++ b/sdn.cpp
@@ -305,20 +305,6 @@ enum { ALT = 1 << 24, SYM = 1 << 25 }; // Outside the range of Unicode
#define KEY(name) (SYM | KEY_ ## name)
#define CTRL 31 &
-struct entry {
- string filename, target_path;
- struct stat info = {}, target_info = {};
-
- enum { MODES, USER, GROUP, SIZE, MTIME, FILENAME, COLUMNS };
- ncstring cols[COLUMNS];
-
- auto operator< (const entry &other) -> bool {
- auto a = S_ISDIR (info.st_mode);
- auto b = S_ISDIR (other.info.st_mode);
- return (a && !b) || (a == b && filename < other.filename);
- }
-};
-
#define ACTIONS(XX) XX(NONE) XX(CHOOSE) XX(CHOOSE_FULL) XX(HELP) XX(QUIT) \
XX(UP) XX(DOWN) XX(TOP) XX(BOTTOM) XX(PAGE_PREVIOUS) XX(PAGE_NEXT) \
XX(SCROLL_UP) XX(SCROLL_DOWN) XX(GO_START) XX(GO_HOME) \
@@ -383,10 +369,30 @@ struct stringcaseless {
}
};
+struct entry {
+ string filename, target_path;
+ struct stat info = {}, target_info = {};
+
+ enum { MODES, USER, GROUP, SIZE, MTIME, FILENAME, COLUMNS };
+ ncstring cols[COLUMNS];
+
+ auto operator< (const entry &other) -> bool {
+ auto a = S_ISDIR (info.st_mode);
+ auto b = S_ISDIR (other.info.st_mode);
+ return (a && !b) || (a == b && filename < other.filename);
+ }
+};
+
+struct level {
+ int offset, cursor; ///< Scroll offset and cursor position
+ string path, filename; ///< Level path and filename at cursor
+};
+
static struct {
string cwd; ///< Current working directory
string start_dir; ///< Starting directory
vector