commit bf66f426c330afe123bee81784abb95d13b079f8
Author: Raniconduh <clagv.randomgames@gmail.com>
Date: Sat Jul 02 21:46:14 2022 +0000
diff --git a/include/io.h b/include/io.h
index dc5a9d0..f83ea9c 100644
--- a/include/io.h
+++ b/include/io.h
@@ -586 +587 @@ void mark_all(void);
void set_color(void);
void print_mode(struct dir_entry_t *);
void padstr(size_t);
+void resize_fbuf(void);
extern bool print_path;
diff --git a/src/io.c b/src/io.c
index 425efa4..8b92099 100644
--- a/src/io.c
+++ b/src/io.c
@@ -136 +137 @@
#if ICONS
#include "type.h"
#endif
+#include "main.h"
#include "opts.h"
#include "dir.h"
#include "io.h"
@@ -3843 +38521 @@ void unmark_all(void) {
dir_entries[i]->marked = false;
n_marked_files = 0;
}
+
+
+void resize_fbuf(void) {
+ if (n_dir_entries <= (unsigned)LINES - 6) {
+ first_f = 0;
+ last_f = n_dir_entries;
+ } else if (LINES <= 6) {
+ if (first_f + 1 < n_dir_entries) last_f = first_f + 1;
+ else last_f = first_f;
+ } else if ((unsigned)LINES - 6 > n_dir_entries) {
+ last_f = n_dir_entries;
+ } else {
+ last_f = first_f + LINES - 6;
+ }
+
+ if (cursor > last_f + 1) cursor = last_f + 1;
+
+}
diff --git a/src/main.c b/src/main.c
index d9272c8..b55af8e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37226 +37212 @@ int main(int argc, char ** argv) {
free_dir_entries();
list_dir(cwd);
- if (cursor > n_dir_entries || last_f >= n_dir_entries) {
- cursor = 1;
- first_f = 0;
- last_f = LAST_F;
- }
+ resize_fbuf();
+
break;
case KEY_RESIZE:
- if (n_dir_entries <= (unsigned)LINES - 6) {
- first_f = 0;
- last_f = n_dir_entries;
- } else if (LINES <= 6) {
- if (first_f + 1 < n_dir_entries) last_f = first_f + 1;
- else last_f = first_f;
- } else if ((unsigned)LINES - 6 > n_dir_entries) {
- last_f = n_dir_entries;
- } else {
- last_f = first_f + LINES - 6;
- }
- if (cursor > last_f + 1) cursor = last_f + 1;
+ resize_fbuf();
erase();
refresh();