qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Pascal Terjan" <pterjan@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Improve completion in monitor
Date: Sat, 22 Sep 2007 16:36:36 +0200	[thread overview]
Message-ID: <e8ca35370709220736g555d89cu43e2ee6b7e507dfe@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 380 bytes --]

Hello,
When you want to change CDROM, and you have 2 files in the directory called
mandriva-linux-2008.0-free-rc2-CD1.i586.iso and
mandriva-linux-2008.0-free-rc2-CD2.i586.iso, you have to enter
mandriva-linux-2008.0-free-rc2-CD2 by hand and only get completion on
.i586.iso which is not really helpful.

The attached patch gets the common prefix so that you can do man<TAB>2<TAB>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qemu-0.9.0-completion.patch --]
[-- Type: text/x-patch; name="qemu-0.9.0-completion.patch", Size: 1338 bytes --]

Index: readline.c
===================================================================
RCS file: /sources/qemu/qemu/readline.c,v
retrieving revision 1.5
diff -u -r1.5 readline.c
--- readline.c	17 Sep 2007 08:09:45 -0000	1.5
+++ readline.c	22 Sep 2007 13:35:18 -0000
@@ -300,7 +300,7 @@
 
 static void term_completion(void)
 {
-    int len, i, j, max_width, nb_cols;
+    int len, i, j, max_width, nb_cols, max_prefix;
     char *cmdline;
 
     nb_completions = 0;
@@ -327,11 +327,26 @@
     } else {
         term_printf("\n");
         max_width = 0;
+        max_prefix = 0;	
         for(i = 0; i < nb_completions; i++) {
             len = strlen(completions[i]);
+            if (i==0) {
+                max_prefix = len;
+            } else {
+                if (len < max_prefix)
+                    max_prefix = len;
+                for(j=0; j<max_prefix; j++) {
+                    if (completions[i][j] != completions[0][j])
+                        max_prefix = j;
+                }
+            }
             if (len > max_width)
                 max_width = len;
         }
+        if (max_prefix > 0) 
+            for(i = completion_index; i < max_prefix; i++) {
+                term_insert_char(completions[0][i]);
+            }
         max_width += 2;
         if (max_width < 10)
             max_width = 10;

                 reply	other threads:[~2007-09-22 14:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e8ca35370709220736g555d89cu43e2ee6b7e507dfe@mail.gmail.com \
    --to=pterjan@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).