commit - 517f9344e0290333237cc80999f5f2e70f909a07
commit + bb90b2d2f774dba4f039e6e30a5e1a6fc84503d8
blob - 3411f2925cbfdc6aeb563df2957e62d1aefcbb3c
blob + 27c3193d32d4c33d8896966474d8853ae5ee5ea1
--- rover.c
+++ rover.c
STATUS[0] = rover.flags & SHOW_FILES ? 'F' : ' ';
STATUS[1] = rover.flags & SHOW_DIRS ? 'D' : ' ';
STATUS[2] = rover.flags & SHOW_HIDDEN ? 'H' : ' ';
- sprintf(STATUS+3, fmt, rover.fsel + 1, rover.nfiles);
+ if (!rover.nfiles)
+ sprintf(STATUS+3, fmt, 0, 0);
+ else
+ sprintf(STATUS+3, fmt, rover.fsel + 1, rover.nfiles);
color_set(RVC_STATUS, NULL);
mvaddstr(LINES - 1, COLS - strlen(STATUS), STATUS);
color_set(DEFAULT, NULL);
if (!strcmp(key, RVK_QUIT))
break;
else if (!strcmp(key, RVK_DOWN)) {
+ if (!rover.nfiles) continue;
if (rover.fsel == rover.nfiles - 1)
rover.scroll = rover.fsel = 0;
- else if (rover.nfiles != 0) {
+ else {
rover.fsel++;
if ((rover.fsel - rover.scroll) == HEIGHT)
rover.scroll++;
update_browser();
}
else if (!strcmp(key, RVK_UP)) {
+ if (!rover.nfiles) continue;
if (rover.fsel == 0) {
rover.fsel = rover.nfiles - 1;
rover.scroll = rover.nfiles - HEIGHT;
if (rover.scroll < 0)
rover.scroll = 0;
}
- else if (rover.nfiles != 0) {
+ else {
rover.fsel--;
if (rover.fsel < rover.scroll)
rover.scroll--;
update_browser();
}
else if (!strcmp(key, RVK_JUMP_DOWN)) {
+ if (!rover.nfiles) continue;
rover.fsel += RV_JUMP;
if (rover.fsel >= rover.nfiles)
rover.fsel = rover.nfiles - 1;
update_browser();
}
else if (!strcmp(key, RVK_JUMP_UP)) {
+ if (!rover.nfiles) continue;
rover.fsel -= RV_JUMP;
if (rover.fsel < 0)
rover.fsel = 0;
update_browser();
}
else if (!strcmp(key, RVK_CD_DOWN)) {
+ if (!rover.nfiles) continue;
if (strchr(rover.fnames[rover.fsel], '/') == NULL)
continue;
strcat(rover.cwd, rover.fnames[rover.fsel]);
}
}
else if (!strcmp(key, RVK_VIEW)) {
+ if (!rover.nfiles) continue;
if (strchr(rover.fnames[rover.fsel], '/') != NULL)
continue;
program = getenv("PAGER");
}
}
else if (!strcmp(key, RVK_EDIT)) {
+ if (!rover.nfiles) continue;
if (strchr(rover.fnames[rover.fsel], '/') != NULL)
continue;
program = getenv("EDITOR");
}
}
else if (!strcmp(key, RVK_SEARCH)) {
+ if (!rover.nfiles) continue;
int ch, length, sel, oldsel, oldscroll;
color_t color;
mvaddstr(LINES - 1, 0, "search:");