2008-08-24 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Mon, 25 Aug 2008 03:30:06 +0000 (03:30 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 25 Aug 2008 03:30:06 +0000 (03:30 -0000)
* TermInfoDriver.cs (GetKeyFromBuffer): Add support for reporting
Alt-LETTER sequences.   They were ignored previously.

svn path=/trunk/mcs/; revision=111523

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/TermInfoDriver.cs

index 50b13948bfd652e0806632fe499910f328251004..e6ca8958aa760c65f8c64ff08320c8c5cf6075f6 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-24  Miguel de Icaza  <miguel@novell.com>
+
+       * TermInfoDriver.cs (GetKeyFromBuffer): Add support for reporting
+       Alt-LETTER sequences.   They were ignored previously.
+
 2008-08-22  Sebastien Pouliot  <sebastien@ximian.com>
 
        * AppDomainSetup.cs: Remove IAppDomainSetup for SL2. This helps
index 92b43831a05dd94eab8bfb3014535c69df921870..6ffd7e03c610407a2ef7764615a15a3f077a02dc 100644 (file)
@@ -371,7 +371,7 @@ namespace System {
                // Should never get called unless inited
                public void WriteSpecialKey (char c)
                {
-                       WriteSpecialKey (CreateKeyInfoFromInt (c));
+                       WriteSpecialKey (CreateKeyInfoFromInt (c, false));
                }
 
                public bool IsSpecialKey (ConsoleKeyInfo key)
@@ -403,7 +403,7 @@ namespace System {
 
                public bool IsSpecialKey (char c)
                {
-                       return IsSpecialKey (CreateKeyInfoFromInt (c));
+                       return IsSpecialKey (CreateKeyInfoFromInt (c, false));
                }
 
                public ConsoleColor BackgroundColor {
@@ -847,13 +847,12 @@ namespace System {
                        }
                }
 
-               ConsoleKeyInfo CreateKeyInfoFromInt (int n)
+               ConsoleKeyInfo CreateKeyInfoFromInt (int n, bool alt)
                {
                        char c = (char) n;
                        ConsoleKey key = (ConsoleKey)n;
                        bool shift = false;
                        bool ctrl = false;
-                       bool alt = false;
 
                        if (n == 10) {
                                key = ConsoleKey.Enter;
@@ -886,13 +885,20 @@ namespace System {
                        if (!cooked || !rootmap.StartsWith (next)) {
                                readpos++;
                                AdjustBuffer ();
-                               return CreateKeyInfoFromInt (next);
+                               return CreateKeyInfoFromInt (next, false);
                        }
 
                        int used;
                        TermInfoStrings str = rootmap.Match (buffer, readpos, writepos - readpos, out used);
-                       if ((int) str == -1)
-                               return null;
+                       if ((int) str == -1){
+                               // Escape sequences: alt keys are sent as ESC-key
+                               if (buffer [readpos] == 27 && (writepos - readpos) >= 2){
+                                       readpos += 2;
+                                       AdjustBuffer ();
+                                       return CreateKeyInfoFromInt (buffer [readpos+1], true);
+                               } else
+                                       return null;
+                       }
 
                        ConsoleKeyInfo key;
                        if (keymap [str] != null) {
@@ -900,7 +906,7 @@ namespace System {
                        } else {
                                readpos++;
                                AdjustBuffer ();
-                               return CreateKeyInfoFromInt (next);
+                               return CreateKeyInfoFromInt (next, false);
                        }
 
                        readpos += used;