Commit d9d8eb24 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: straighten out the flow of a loop

No related merge requests found
Showing with 18 additions and 21 deletions
+18 -21
...@@ -72,9 +72,6 @@ char *do_browser(char *path) ...@@ -72,9 +72,6 @@ char *do_browser(char *path)
read_directory_contents: read_directory_contents:
/* We come here when we refresh or select a new directory. */ /* We come here when we refresh or select a new directory. */
/* Start with no key pressed. */
kbinput = ERR;
path = mallocstrassn(path, get_full_path(newpath ? newpath : path)); path = mallocstrassn(path, get_full_path(newpath ? newpath : path));
if (path != NULL && newpath != NULL) if (path != NULL && newpath != NULL)
...@@ -128,30 +125,15 @@ char *do_browser(char *path) ...@@ -128,30 +125,15 @@ char *do_browser(char *path)
bottombars(MBROWSER); bottombars(MBROWSER);
#ifndef NANO_TINY /* Display (or redisplay) the file list if the list itself or
/* If the window resized, also refresh the file list. */ * the selected file has changed. */
if (kbinput == KEY_WINCH) { if (old_selected != selected)
/* Remember the selected file, to be able to reselect it. */
present_name = strdup(filelist[selected]);
/* Reread the contents of the current directory. */
newpath = strdup(present_path);
goto read_directory_contents;
}
#endif
/* Display (or redisplay) the file list if we don't have a key yet,
* or the list has changed, or the selected file has changed. */
if (kbinput == ERR || old_selected != selected)
browser_refresh(); browser_refresh();
old_selected = selected; old_selected = selected;
kbinput = get_kbinput(edit); kbinput = get_kbinput(edit);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH)
continue;
#endif
#ifndef DISABLE_MOUSE #ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) { if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y; int mouse_x, mouse_y;
...@@ -340,8 +322,23 @@ char *do_browser(char *path) ...@@ -340,8 +322,23 @@ char *do_browser(char *path)
} else if (func == do_exit) { } else if (func == do_exit) {
/* Exit from the file browser. */ /* Exit from the file browser. */
break; break;
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
;
#endif
} else } else
unbound_key(kbinput); unbound_key(kbinput);
#ifndef NANO_TINY
/* If the window resized, refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = strdup(filelist[selected]);
/* Reread the contents of the current directory. */
newpath = strdup(present_path);
goto read_directory_contents;
}
#endif
} }
titlebar(NULL); titlebar(NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment