tweaks: frob a couple of comments, and drop two, for conciseness

master
Benno Schulenberg 2021-11-12 16:28:15 +01:00
parent b76b5b9967
commit 30595dd2bb
1 changed files with 11 additions and 18 deletions

View File

@ -430,7 +430,7 @@ char *browse(char *path)
if (path == NULL || dir == NULL) { if (path == NULL || dir == NULL) {
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno)); statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
/* If we don't have a file list yet, there is nothing to show. */ /* If we don't have a file list, there is nothing to show. */
if (filelist == NULL) { if (filelist == NULL) {
lastmessage = VACUUM; lastmessage = VACUUM;
free(present_name); free(present_name);
@ -486,25 +486,21 @@ char *browse(char *path)
if (kbinput == KEY_MOUSE) { if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y; int mouse_x, mouse_y;
/* We can click on the edit window to select a filename. */ /* When the user clicked in the file list, select a filename. */
if (get_mouseinput(&mouse_y, &mouse_x, TRUE) == 0 && if (get_mouseinput(&mouse_y, &mouse_x, TRUE) == 0 &&
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) { wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
/* longest is the width of each column. There
* are two spaces between each column. */
selected = selected - selected % (editwinrows * width) + selected = selected - selected % (editwinrows * width) +
(mouse_y * width) + (mouse_x / (longest + 2)); (mouse_y * width) + (mouse_x / (longest + 2));
/* If they clicked beyond the end of a row, /* When beyond end-of-row, select the preceding filename. */
* select the last filename in that row. */
if (mouse_x > width * (longest + 2)) if (mouse_x > width * (longest + 2))
selected--; selected--;
/* If we're beyond the list, select the last filename. */ /* When beyond end-of-list, select the last filename. */
if (selected > list_length - 1) if (selected > list_length - 1)
selected = list_length - 1; selected = list_length - 1;
/* If we selected the same filename as last time, fake a /* When a filename is clicked a second time, choose it. */
* press of the Enter key so that the file is read in. */
if (old_selected == selected) if (old_selected == selected)
kbinput = KEY_ENTER; kbinput = KEY_ENTER;
} }
@ -524,16 +520,14 @@ char *browse(char *path)
if (func == full_refresh) { if (func == full_refresh) {
full_refresh(); full_refresh();
#ifndef NANO_TINY #ifndef NANO_TINY
/* Simulate a window resize to force a directory reread. */ /* Simulate a terminal resize to force a directory reread. */
kbinput = KEY_WINCH; kbinput = KEY_WINCH;
#endif #endif
} else if (func == do_help) { } else if (func == do_help) {
do_help(); do_help();
#ifndef NANO_TINY #ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */ /* The terminal dimensions might have changed, so act as if. */
kbinput = KEY_WINCH; kbinput = KEY_WINCH;
#endif
#ifndef NANO_TINY
} else if (func == do_toggle) { } else if (func == do_toggle) {
TOGGLE(NO_HELP); TOGGLE(NO_HELP);
window_init(); window_init();
@ -615,8 +609,8 @@ char *browse(char *path)
#ifdef ENABLE_OPERATINGDIR #ifdef ENABLE_OPERATINGDIR
if (outside_of_confinement(path, FALSE)) { if (outside_of_confinement(path, FALSE)) {
/* TRANSLATORS: This refers to the confining effect of the /* TRANSLATORS: This refers to the confining effect of
* option --operatingdir, not of --restricted. */ * the option --operatingdir, not of --restricted. */
statusline(ALERT, _("Can't go outside of %s"), operating_dir); statusline(ALERT, _("Can't go outside of %s"), operating_dir);
path = mallocstrcpy(path, present_path); path = mallocstrcpy(path, present_path);
continue; continue;
@ -679,7 +673,7 @@ char *browse(char *path)
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) { } else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */ ; /* Gets handled below. */
#endif #endif
} else if (func == do_exit) { } else if (func == do_exit) {
break; break;
@ -687,11 +681,10 @@ char *browse(char *path)
unbound_key(kbinput); unbound_key(kbinput);
#ifndef NANO_TINY #ifndef NANO_TINY
/* If the window resized, refresh the file list. */ /* If the terminal resized (or might have), refresh the file list. */
if (kbinput == KEY_WINCH) { if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */ /* Remember the selected file, to be able to reselect it. */
present_name = copy_of(filelist[selected]); present_name = copy_of(filelist[selected]);
/* Reread the contents of the current directory. */
goto read_directory_contents; goto read_directory_contents;
} }
#endif #endif