2010-07-09 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / tools / csharp / getline.cs
index d95ecdbbeb25877d86466994cfa899a0dc3bcc36..63ff480118bb61e82f6f46a87196ffe2d361da06 100644 (file)
@@ -22,9 +22,6 @@
 //    Console needs a way of updating its position after things have been written
 //    behind its back (P/Invoke puts for example).
 //    System.Console needs to get the DELETE character, and report accordingly.
-//    Typing before the program start causes the cursor position to be wrong
-//              This is caused by Console not reading all the available data
-//              before sending the report-position sequence and reading it back.
 //
 #if NET_2_0 || NET_1_1
 #define IN_MCS_BUILD
@@ -191,7 +188,7 @@ namespace Mono.Terminal {
                                Handler.Alt ((char) 8, ConsoleKey.Backspace, CmdDeleteBackword),
                                
                                // DEBUG
-                               Handler.Control ('T', CmdDebug),
+                               //Handler.Control ('T', CmdDebug),
 
                                // quote
                                Handler.Control ('Q', delegate { HandleChar (Console.ReadKey (true).KeyChar); })
@@ -769,13 +766,22 @@ namespace Mono.Terminal {
                        ConsoleKeyInfo cki;
 
                        while (!done){
+                               ConsoleModifiers mod;
+                               
                                cki = Console.ReadKey (true);
+                               if (cki.Key == ConsoleKey.Escape){
+                                       cki = Console.ReadKey (true);
 
+                                       mod = ConsoleModifiers.Alt;
+                               } else
+                                       mod = cki.Modifiers;
+                               
                                bool handled = false;
+
                                foreach (Handler handler in handlers){
                                        ConsoleKeyInfo t = handler.CKI;
 
-                                       if (t.Key == cki.Key && t.Modifiers == cki.Modifiers){
+                                       if (t.Key == cki.Key && t.Modifiers == mod){
                                                handled = true;
                                                handler.KeyHandler ();
                                                last_handler = handler.KeyHandler;
@@ -985,7 +991,7 @@ namespace Mono.Terminal {
                        public bool NextAvailable ()
                        {
                                int next = (cursor + 1) % history.Length;
-                               if (count == 0 || next > head)
+                               if (count == 0 || next >= head)
                                        return false;
 
                                return true;