Merge pull request #2698 from esdrubal/iosxmlarray
[mono.git] / mcs / tools / csharp / getline.cs
index 068fe5d3178fb09cd40d919051aee03e07d6411e..b60971e0df34eabe9d3954b6843f0f875063b41d 100644 (file)
@@ -462,7 +462,7 @@ namespace Mono.Terminal {
                                        
                                        Console.ForegroundColor = selected ? ConsoleColor.Black : ConsoleColor.Gray;
                                        Console.BackgroundColor = selected ? ConsoleColor.Cyan : ConsoleColor.Blue;
-                                       
+
                                        var item = Prefix + Completions [item_idx];
                                        if (item.Length > Width)
                                                item = item.Substring (0, Width);
@@ -490,7 +490,7 @@ namespace Mono.Terminal {
                        {
                                if (selected_item+1 < Completions.Length){
                                        selected_item++;
-                                       if (selected_item + top_item >= Height)
+                                       if (selected_item - top_item >= Height)
                                                top_item++;
                                        SaveExcursion (DrawSelection);
                                }
@@ -596,6 +596,7 @@ namespace Mono.Terminal {
                                        
                        if (completions.Length == 1){
                                InsertTextAtCursor (completions [0]);
+                               HideCompletions ();
                        } else {
                                int last = -1;
 
@@ -1418,7 +1419,15 @@ namespace Mono.Terminal {
        class Demo {
                static void Main ()
                {
-                       LineEditor le = new LineEditor ("foo");
+                       LineEditor le = new LineEditor ("foo") {
+                               HeuristicsMode = "csharp"
+                       };
+                       le.AutoCompleteEvent += delegate (string a, int pos){
+                               string prefix = "";
+                               var completions = new string [] { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten" };
+                               return new Mono.Terminal.LineEditor.Completion (prefix, completions);
+                       };
+                       
                        string s;
                        
                        while ((s = le.Edit ("shell> ", "")) != null){