cex

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.wimdupont.com/cex.git
Log | Files | Refs | LICENSE

commit d11c2cb224a63cbea6c5f957b2915393dbbc3b9d
parent cf2649cd06e7fb5fd928588dcf566aee11f85b4a
Author: Wim Dupont <wim@wimdupont.com>
Date:   Sat, 13 Jul 2024 22:29:33 +0200

fixes empty dir movement

Diffstat:
Mcex.c | 28++++++----------------------
Mcex.h | 2+-
2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/cex.c b/cex.c @@ -41,7 +41,6 @@ main(int argc, char **argv) } } - editor = getenv("EDITOR"); userinf = *getpwuid(getuid()); @@ -415,7 +414,6 @@ remove_selected(char *sel) return res; } - static void set_win_message(DirWin *dirwin, char *message) { @@ -560,15 +558,7 @@ print_top_title() static void print_bot_title() { - struct stat statbuf; - struct passwd *usr; - struct tm *tm; - struct group *grp; - char pathbuf[PATH_MAX]; - char mods[11]; - char datestr[256]; - char modfill = '-'; - char fileinf[maxx]; + char pathbuf[PATH_MAX], fileinf[maxx]; get_fullpath(pathbuf, &curwin, curwin.highlight); memcpy(fileinf, get_file_info(fileinf, pathbuf), maxx); @@ -646,14 +636,12 @@ get_file_info(char *buf, char *filepath) static void print_content() { - char buf[PATH_MAX]; FILE *fp = NULL; size_t size = childwin.maxx; - char str[size+1]; + char str[size+1], buf[PATH_MAX]; int y = 0, x = 0; werase(childwin.window); - free_dirwin(&childwin); if ((fp = fopen(get_fullpath(buf, &curwin, curwin.highlight), "r")) == NULL) { @@ -674,7 +662,6 @@ print_content() } fclose(fp); - wrefresh(childwin.window); } @@ -851,20 +838,16 @@ change_parent_dir(Direction direction) } parwin.usehighlight = TRUE; - curwin.highlight = 0; - change_dir(get_fullpath(pp, &parwin, parwin.highlight), direction, FALSE); } static void open_child() { - char mime[MIME_MAX]; - char mimedefault[MIME_APP_MAX]; sigset_t set; + char mime[MIME_MAX], mimedefault[MIME_APP_MAX], pathbuf[PATH_MAX]; bool istext; - char pathbuf[PATH_MAX]; if (curwin.message != NULL) return; @@ -970,7 +953,7 @@ move_top(DirWin *dirwin) static void move_bot(DirWin *dirwin) { - dirwin->highlight = dirwin->filecount-1; + dirwin->highlight = MAX(dirwin->filecount-1, 0); } static void @@ -982,7 +965,8 @@ move_page_up(DirWin *dirwin) static void move_page_down(DirWin *dirwin) { - dirwin->highlight = MIN(dirwin->highlight + dirwin->maxy/2, dirwin->filecount-1); + dirwin->highlight = MIN(dirwin->highlight + dirwin->maxy/2, + MAX(dirwin->filecount-1, 0)); } static void diff --git a/cex.h b/cex.h @@ -81,7 +81,7 @@ typedef struct _dir_win { int maxy; int startpr; int highlight; - size_t filecount; + int filecount; bool holdupdate; bool usehighlight; } DirWin;