Disallow refresh/delete after import + provide visual feedback

It's kinda annoying how you need to confirm the messages. I'd prefer
having some status bar where messages are automatically removed after a
short timeout or something. But that's more work, and for the few
cases where feedback is necessary this'll work fine, too.
This commit is contained in:
Yorhel 2012-09-06 13:16:11 +02:00
parent 267de619ba
commit aad479a19a

View file

@ -31,6 +31,7 @@
static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0; static int graph = 1, show_as = 0, info_show = 0, info_page = 0, info_start = 0;
static char *message = NULL;
@ -202,9 +203,16 @@ void browse_draw() {
selected = i; selected = i;
} }
/* draw message window */
if(message) {
nccreate(6, 60, "Message");
ncaddstr(2, 2, message);
ncaddstr(4, 34, "Press any key to continue");
}
/* draw information window */ /* draw information window */
t = dirlist_get(0); t = dirlist_get(0);
if(info_show && t != dirlist_parent) if(!message && info_show && t != dirlist_parent)
browse_draw_info(t); browse_draw_info(t);
/* move cursor to selected row for accessibility */ /* move cursor to selected row for accessibility */
@ -216,6 +224,12 @@ int browse_key(int ch) {
struct dir *t, *sel; struct dir *t, *sel;
int i, catch = 0; int i, catch = 0;
/* message window overwrites all keys */
if(message) {
message = NULL;
return 0;
}
sel = dirlist_get(0); sel = dirlist_get(0);
/* info window overwrites a few keys */ /* info window overwrites a few keys */
@ -347,6 +361,10 @@ int browse_key(int ch) {
/* and other stuff */ /* and other stuff */
case 'r': case 'r':
if(dir_import_active) {
message = "Directory imported from file, won't refresh.";
break;
}
if(sel != NULL) { if(sel != NULL) {
dir_ui = 2; dir_ui = 2;
dir_mem_init(sel->parent); dir_mem_init(sel->parent);
@ -373,7 +391,13 @@ int browse_key(int ch) {
info_show = 0; info_show = 0;
break; break;
case 'd': case 'd':
if(read_only || sel == NULL || sel == dirlist_parent) if(read_only || dir_import_active) {
message = read_only
? "File deletion disabled in read-only mode."
: "File deletion not available for imported directories.";
break;
}
if(sel == NULL || sel == dirlist_parent)
break; break;
info_show = 0; info_show = 0;
if((t = dirlist_get(1)) == sel) if((t = dirlist_get(1)) == sel)
@ -396,6 +420,7 @@ int browse_key(int ch) {
void browse_init(struct dir *cur) { void browse_init(struct dir *cur) {
pstate = ST_BROWSE; pstate = ST_BROWSE;
message = NULL;
dirlist_open(cur); dirlist_open(cur);
} }