commit - 430cd7d8a26300453a7617806e1e4ed1a5e15558
commit + 00ecdc1e9fb94ee869a04bb3789c80f9e0a7c04d
blob - fa83d0bc7b3be73b8676a63cc90e313fbc9e4f03
blob + b1ed2221373b5bdbd53c804a49ae619caa161b74
--- rover.c
+++ rover.c
try_to_sel(const char *target)
{
ESEL = 0;
- while (strcoll(ENAME(ESEL), target) < 0)
+ while ((ESEL+1) < rover.nfiles && strcoll(ENAME(ESEL), target) < 0)
ESEL++;
if (rover.nfiles > HEIGHT) {
SCROLL = ESEL - (HEIGHT >> 1);
}
}
+/* Reload CWD, but try to keep selection. */
+static void
+reload()
+{
+ if (rover.nfiles) {
+ strcpy(INPUT, ENAME(ESEL));
+ cd(1);
+ try_to_sel(INPUT);
+ update_view();
+ }
+ else cd(1);
+}
+
/* Recursively process a source directory using CWD as destination root.
* For each node (i.e. directory), do the following:
* 1. call pre(destination);
else ret = proc(path);
if (!ret) del_mark(&rover.marks, rover.marks.entries[i]);
}
- strcpy(INPUT, ENAME(ESEL));
- cd(1);
- try_to_sel(INPUT);
- update_view();
+ reload();
if (!rover.marks.nentries)
message("Done.", GREEN);
else
ARGS[0] = program;
ARGS[1] = NULL;
spawn();
- cd(1);
+ reload();
}
}
else if (!strcmp(key, RVK_VIEW)) {
}
else if (!strcmp(key, RVK_TG_FILES)) {
FLAGS ^= SHOW_FILES;
- cd(1);
+ reload();
}
else if (!strcmp(key, RVK_TG_DIRS)) {
FLAGS ^= SHOW_DIRS;
- cd(1);
+ reload();
}
else if (!strcmp(key, RVK_TG_HIDDEN)) {
FLAGS ^= SHOW_HIDDEN;
- cd(1);
+ reload();
}
else if (!strcmp(key, RVK_NEW_FILE)) {
int ok = 0;
}
clear_message();
if (strlen(INPUT)) {
- if (ok) { rename(ENAME(ESEL), INPUT); cd(1); }
+ if (ok) {
+ rename(ENAME(ESEL), INPUT);
+ cd(1);
+ try_to_sel(INPUT);
+ update_view();
+ }
else message("File already exists.", RED);
}
}