qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Improve completion in monitor
@ 2007-09-22 14:36 Pascal Terjan
  0 siblings, 0 replies; only message in thread
From: Pascal Terjan @ 2007-09-22 14:36 UTC (permalink / raw)
  To: qemu-devel

[-- 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-09-22 14:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-22 14:36 [Qemu-devel] [PATCH] Improve completion in monitor Pascal Terjan

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).