files: show possible tab completions near the bottom of the edit window

Especially when it are just a handful of possible completions, it is
much nicer to have them listed close to the prompt bar where the eyes
of the user are.

This fulfills https://savannah.gnu.org/bugs/?58620.
This commit is contained in:
Benno Schulenberg 2020-06-21 10:44:05 +02:00
parent 91ba76e1e0
commit c7356c2d85

View File

@ -2559,8 +2559,9 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
/* If there is more than one possible completion, show a sorted list. */
if (num_matches > 1) {
size_t longest_name = 0, ncols;
int row = 0;
size_t longest_name = 0;
size_t nrows, ncols;
int row;
qsort(matches, num_matches, sizeof(char *), diralphasort);
@ -2578,6 +2579,9 @@ char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *list
/* The columns of names will be separated by two spaces,
* but the last column will have just one space after it. */
ncols = (COLS + 1) / (longest_name + 2);
nrows = (num_matches + ncols - 1) / ncols;
row = (nrows < editwinrows - 1) ? editwinrows - nrows - 1 : 0;
/* Blank the edit window and hide the cursor. */
blank_edit();