Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit 59587e551c227b6aa370cd299081bb653cf0e5dc Author: rani <clagv.randomgames@gmail.com> Date: Thu Jun 02 21:20:56 2022 +0000 resize no longer guarantees segfault diff --git a/src/main.c b/src/main.c index cda4714..d2e2f68 100644 --- a/src/main.c +++ b/src/main.c @@ -557 +556 @@ int main(int argc, char ** argv) {     curses_init();   - signal(SIGWINCH, sig_handler);   signal(SIGCONT, sig_handler);     list_dir(cwd); @@ -3626 +36124 @@ int main(int argc, char ** argv) {   first_f = 0;   last_f = LAST_F;   } + break; + case KEY_RESIZE: +/* + first_f = 0; + last_f = LAST_F; + cursor = 1; +*/ + 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; + + erase(); + refresh(); +   break;   case CTRL_Z:   terminate_curses(); @@ -41313 +4306 @@ void help(void) {    void sig_handler(int signo) {   switch (signo) { - case SIGWINCH: - endwin(); - refresh(); - - last_f = first_f + LINES - 6; - if (cursor > last_f) cursor = last_f; - break;   case SIGCONT:   curses_init();   break;