Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit When doing filename autocompletion, append a tra...



details:   https://anonhg.NetBSD.org/src/rev/59d1eeac5a6b
branches:  trunk
changeset: 823376:59d1eeac5a6b
user:      abhinav <abhinav%NetBSD.org@localhost>
date:      Fri Apr 21 05:38:03 2017 +0000

description:
When doing filename autocompletion, append a trailing slash at the end of directory
names. We already do this when there is only one completion option but
in case of of multiple completion options, it wasn't being done.

ok christos@

diffstat:

 lib/libedit/filecomplete.c |  18 ++++++++++++------
 lib/libedit/filecomplete.h |   5 +++--
 lib/libedit/readline.c     |  29 +++++++++++++++--------------
 3 files changed, 30 insertions(+), 22 deletions(-)

diffs (132 lines):

diff -r a807204f4066 -r 59d1eeac5a6b lib/libedit/filecomplete.c
--- a/lib/libedit/filecomplete.c        Thu Apr 20 22:57:30 2017 +0000
+++ b/lib/libedit/filecomplete.c        Fri Apr 21 05:38:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $        */
+/*     $NetBSD: filecomplete.c,v 1.45 2017/04/21 05:38:03 abhinav Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.44 2016/10/31 17:46:32 abhinav Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.45 2017/04/21 05:38:03 abhinav Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -354,10 +354,13 @@
  * 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 @@
                        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 @@
                                 * 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]) {
diff -r a807204f4066 -r 59d1eeac5a6b lib/libedit/filecomplete.h
--- a/lib/libedit/filecomplete.h        Thu Apr 20 22:57:30 2017 +0000
+++ b/lib/libedit/filecomplete.h        Fri Apr 21 05:38:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecomplete.h,v 1.10 2016/04/11 00:50:13 christos Exp $       */
+/*     $NetBSD: filecomplete.h,v 1.11 2017/04/21 05:38:03 abhinav Exp $        */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -37,7 +37,8 @@
     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);
 
diff -r a807204f4066 -r 59d1eeac5a6b lib/libedit/readline.c
--- a/lib/libedit/readline.c    Thu Apr 20 22:57:30 2017 +0000
+++ b/lib/libedit/readline.c    Fri Apr 21 05:38:03 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.140 2017/01/09 03:09:05 christos Exp $  */
+/*     $NetBSD: readline.c,v 1.141 2017/04/21 05:38:03 abhinav Exp $   */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.140 2017/01/09 03:09:05 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.141 2017/04/21 05:38:03 abhinav Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -1812,18 +1812,6 @@
        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 @@
 
 
 /*
+ * 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 */



Home | Main Index | Thread Index | Old Index