Last active
April 20, 2017 18:38
-
-
Save abhinav-upadhyay/23417c9201ce6c9b49d4fa2b05e5d1ad to your computer and use it in GitHub Desktop.
We should append a trailing slash at the end of directory names and a space after filenames when doing multi-column file completion. Pass app_func as an argument to fn_display_match_list for compatibility with readline.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: filecomplete.c | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libedit/filecomplete.c,v | |
retrieving revision 1.44 | |
diff -u -p -r1.44 filecomplete.c | |
--- filecomplete.c 31 Oct 2016 17:46:32 -0000 1.44 | |
+++ filecomplete.c 20 Apr 2017 18:24:57 -0000 | |
@@ -354,10 +354,13 @@ _fn_qsort_string_compare(const void *i1, | |
* num, so the strings are matches[1] *through* matches[num-1]. | |
*/ | |
void | |
-fn_display_match_list (EditLine *el, char **matches, size_t num, size_t width) | |
+fn_display_match_list(EditLine * el, char **matches, size_t num, size_t width, | |
+ const char *(*app_func) (const char *)) | |
{ | |
size_t line, lines, col, cols, thisguy; | |
int screenwidth = el->el_terminal.t_size.h; | |
+ if (app_func == NULL) | |
+ app_func = append_char_function; | |
/* Ignore matches[0]. Avoid 1-based array logic below. */ | |
matches++; | |
@@ -385,8 +388,11 @@ fn_display_match_list (EditLine *el, cha | |
thisguy = line + col * lines; | |
if (thisguy >= num) | |
break; | |
- (void)fprintf(el->el_outfile, "%s%-*s", | |
- col == 0 ? "" : " ", (int)width, matches[thisguy]); | |
+ (void)fprintf(el->el_outfile, "%s%s%s", | |
+ col == 0 ? "" : " ", matches[thisguy], | |
+ append_char_function(matches[thisguy])); | |
+ (void)fprintf(el->el_outfile, "%-*s", | |
+ (int) (width - strlen(matches[thisguy])), ""); | |
} | |
(void)fprintf(el->el_outfile, "\n"); | |
} | |
@@ -533,7 +539,7 @@ fn_complete(EditLine *el, | |
* add 1 to matches_num for the call. | |
*/ | |
fn_display_match_list(el, matches, | |
- matches_num+1, maxlen); | |
+ matches_num+1, maxlen, app_func); | |
} | |
retval = CC_REDISPLAY; | |
} else if (matches[0][0]) { | |
Index: filecomplete.h | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libedit/filecomplete.h,v | |
retrieving revision 1.10 | |
diff -u -p -r1.10 filecomplete.h | |
--- filecomplete.h 11 Apr 2016 00:50:13 -0000 1.10 | |
+++ filecomplete.h 20 Apr 2017 18:24:57 -0000 | |
@@ -37,7 +37,8 @@ int fn_complete(EditLine *, | |
const wchar_t *, const wchar_t *, const char *(*)(const char *), size_t, | |
int *, int *, int *, int *); | |
-void fn_display_match_list(EditLine *, char **, size_t, size_t); | |
+void fn_display_match_list(EditLine *, char **, size_t, size_t, | |
+ const char *(*)(const char *)); | |
char *fn_tilde_expand(const char *); | |
char *fn_filename_completion_function(const char *, int); | |
Index: readline.c | |
=================================================================== | |
RCS file: /cvsroot/src/lib/libedit/readline.c,v | |
retrieving revision 1.140 | |
diff -u -p -r1.140 readline.c | |
--- readline.c 9 Jan 2017 03:09:05 -0000 1.140 | |
+++ readline.c 20 Apr 2017 18:24:57 -0000 | |
@@ -1812,18 +1812,6 @@ _el_rl_tstp(EditLine *el __attribute__(( | |
return CC_NORM; | |
} | |
-/* | |
- * Display list of strings in columnar format on readline's output stream. | |
- * 'matches' is list of strings, 'len' is number of strings in 'matches', | |
- * 'max' is maximum length of string in 'matches'. | |
- */ | |
-void | |
-rl_display_match_list(char **matches, int len, int max) | |
-{ | |
- | |
- fn_display_match_list(e, matches, (size_t)len, (size_t)max); | |
-} | |
- | |
static const char * | |
/*ARGSUSED*/ | |
_rl_completion_append_character_function(const char *dummy | |
@@ -1837,6 +1825,19 @@ _rl_completion_append_character_function | |
/* | |
+ * Display list of strings in columnar format on readline's output stream. | |
+ * 'matches' is list of strings, 'len' is number of strings in 'matches', | |
+ * 'max' is maximum length of string in 'matches'. | |
+ */ | |
+void | |
+rl_display_match_list(char **matches, int len, int max) | |
+{ | |
+ | |
+ fn_display_match_list(e, matches, (size_t)len, (size_t)max, | |
+ _rl_completion_append_character_function); | |
+} | |
+ | |
+/* | |
* complete word at current point | |
*/ | |
/* ARGSUSED */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment