2005-01-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 31 Jan 2005 19:50:35 +0000 (19:50 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 31 Jan 2005 19:50:35 +0000 (19:50 -0000)
* ConsoleDriver.cs: static class that forwards the Console 2.0 class
calls to the proper driver.
* TermInfoDriver.cs: terminfo based console driver.
* IConsoleDriver.cs: interface implemented by console drivers.

* ConsoleCancelEventArgs.cs:
* ConsoleCancelEventHandler.cs:

* ConsoleModifiers.cs:
* ConsoleSpecialKey.cs:
* ConsoleColor.cs:
* ConsoleKey.cs: new enumerations.

* ConsoleKeyInfo.cs: New file.

* TermInfoReader.cs: reader for terminfo capabilities files.

* TermInfoNumbers.cs:
* TermInfoBooleans.cs:
* TermInfoStrings.cs: enumations for terminfo property names.

* KnownTerminals.cs: byte arrays for selected terminals.

* Console.cs: added more 2.0 methods and implemented some of them.

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

18 files changed:
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Console.cs
mcs/class/corlib/System/ConsoleCancelEventArgs.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleCancelEventHandler.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleColor.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleDriver.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleKey.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleKeyInfo.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleModifiers.cs [new file with mode: 0644]
mcs/class/corlib/System/ConsoleSpecialKey.cs [new file with mode: 0644]
mcs/class/corlib/System/IConsoleDriver.cs [new file with mode: 0644]
mcs/class/corlib/System/KnownTerminals.cs [new file with mode: 0644]
mcs/class/corlib/System/TermInfoBooleans.cs [new file with mode: 0644]
mcs/class/corlib/System/TermInfoDriver.cs [new file with mode: 0644]
mcs/class/corlib/System/TermInfoNumbers.cs [new file with mode: 0644]
mcs/class/corlib/System/TermInfoReader.cs [new file with mode: 0644]
mcs/class/corlib/System/TermInfoStrings.cs [new file with mode: 0644]
mcs/class/corlib/corlib.dll.sources

index 3cd7ef1cbe30e420c1ded9521735391e2ecd5268..2099f7cf6199b554d604a36364ad06daa03709cd 100644 (file)
@@ -1,3 +1,31 @@
+2005-01-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * ConsoleDriver.cs: static class that forwards the Console 2.0 class
+       calls to the proper driver.
+       * TermInfoDriver.cs: terminfo based console driver.
+       * IConsoleDriver.cs: interface implemented by console drivers.
+
+       * ConsoleCancelEventArgs.cs:
+       * ConsoleCancelEventHandler.cs:
+
+       * ConsoleModifiers.cs: 
+       * ConsoleSpecialKey.cs:
+       * ConsoleColor.cs:
+       * ConsoleKey.cs: new enumerations.
+
+       * ConsoleKeyInfo.cs: New file.
+
+       * TermInfoReader.cs: reader for terminfo capabilities files.
+
+       * TermInfoNumbers.cs:
+       * TermInfoBooleans.cs:
+       * TermInfoStrings.cs: enumations for terminfo property names.
+
+       * KnownTerminals.cs: byte arrays for selected terminals.
+
+       * Console.cs: added more 2.0 methods and implemented some of them.
+
+
 2005-01-30  Atsushi Enomoto  <atsushi@ximian.com>
 
        * Int32.cs : (FindSign) IndexOf() is better than creating substring.
index 8f6c38e6034b65e0d4b291ddf58260b3f2253e75..12757071ff7715c8d1af0045ca08a0a80b71deb3 100644 (file)
@@ -2,14 +2,13 @@
 // System.Console.cs
 //
 // Author:
-//   Dietmar Maurer (dietmar@ximian.com)
+//     Dietmar Maurer (dietmar@ximian.com)
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
 //
 // (C) Ximian, Inc.  http://www.ximian.com
+// (C) 2004,2005 Novell, Inc. (http://www.novell.com)
 //
 
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-//
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 // "Software"), to deal in the Software without restriction, including
@@ -399,7 +398,152 @@ namespace System
 
                public static string ReadLine ()
                {
+#if NET_2_0
+                       bool prevEcho;
+                       if (ConsoleDriver.Initialized) {
+                               prevEcho = ConsoleDriver.Echo;
+                               ConsoleDriver.Echo = true;
+                       }
+#endif
                        return stdin.ReadLine ();
+#if NET_2_0
+                       if (ConsoleDriver.Initialized)
+                               ConsoleDriver.Echo = prevEcho;
+#endif
+               }
+
+#if NET_2_0
+               // On windows, for en-US the Default is Windows-1252, while input/output is IBM437
+               // We might want to initialize these fields in the ConsoleDriver instead.
+               static Encoding inputEncoding = Encoding.Default;
+               static Encoding outputEncoding = Encoding.Default;
+
+               public static Encoding InputEncoding {
+                       get { return inputEncoding; }
+                       set { inputEncoding = value; }
+               }
+
+               public static Encoding OutputEncoding {
+                       get { return outputEncoding; }
+                       set { outputEncoding = value; }
+               }
+
+               public static ConsoleColor BackgroundColor {
+                       get { return ConsoleDriver.BackgroundColor; }
+                       set { ConsoleDriver.BackgroundColor = value; }
+               }
+
+               public static int CursorLeft {
+                       get { return ConsoleDriver.CursorLeft; }
+                       set { ConsoleDriver.CursorLeft = value; }
+               }
+
+               public static int CursorTop {
+                       get { return ConsoleDriver.CursorTop; }
+                       set { ConsoleDriver.CursorTop = value; }
+               }
+
+               public static bool CursorVisible {
+                       get { return ConsoleDriver.CursorVisible; }
+                       set { ConsoleDriver.CursorVisible = value; }
+               }
+
+               public static ConsoleColor ForegroundColor {
+                       get { return ConsoleDriver.ForegroundColor; }
+                       set { ConsoleDriver.ForegroundColor = value; }
+               }
+
+               public static bool KeyAvailable {
+                       get { return ConsoleDriver.KeyAvailable; }
+               }
+
+               public static string Title {
+                       get { return ConsoleDriver.Title; }
+                       set { ConsoleDriver.Title = value; }
+               }
+
+               public static bool TreatControlCAsInput {
+                       get { return ConsoleDriver.TreatControlCAsInput; }
+                       set { ConsoleDriver.TreatControlCAsInput = value; }
+               }
+
+               public static void Beep ()
+               {
+                       Beep (1000, 500);
+               }
+
+               public static void Beep (int frequency, int duration)
+               {
+                       if (frequency < 37 || frequency > 32767)
+                               throw new ArgumentOutOfRangeException ("frequency");
+
+                       if (duration <= 0)
+                               throw new ArgumentOutOfRangeException ("duration");
+
+                       ConsoleDriver.Beep (frequency, duration);
+               }
+
+               public static void Clear ()
+               {
+                       ConsoleDriver.Clear ();
+               }
+
+               [MonoTODO]
+               public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+                                               int targetLeft, int targetTop)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+                                               int targetLeft, int targetTop, Char sourceChar,
+                                               ConsoleColor sourceForeColor, ConsoleColor sourceBackColor)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static ConsoleKeyInfo ReadKey ()
+               {
+                       return ReadKey (false);
                }
+
+               public static ConsoleKeyInfo ReadKey (bool intercept)
+               {
+                       return ConsoleDriver.ReadKey (intercept);
+               }
+
+               public static void ResetColor ()
+               {
+                       ConsoleDriver.ResetColor ();
+               }
+
+               [MonoTODO]
+               public static void SetBufferSize (int width, int height)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               public static void SetCursorPosition (int left, int top)
+               {
+                       ConsoleDriver.SetCursorPosition (left, top);
+               }
+
+               [MonoTODO]
+               public static void SetWindowPosition (int left, int top)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               [MonoTODO]
+               public static void SetWindowSize (int width, int height)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               //FIXME
+               //public event ConsoleCancelEventHandler CancelKeyPress;
+#endif
        }
 }
+
diff --git a/mcs/class/corlib/System/ConsoleCancelEventArgs.cs b/mcs/class/corlib/System/ConsoleCancelEventArgs.cs
new file mode 100644 (file)
index 0000000..87b310a
--- /dev/null
@@ -0,0 +1,53 @@
+//
+// System.ConsoleCancelEventArgs
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       public sealed class ConsoleCancelEventArgs : EventArgs {
+               bool cancel;
+               ConsoleSpecialKey specialKey;
+
+               public bool Cancel {
+                       get { return cancel; }
+                       set { cancel = value; }
+               }
+
+               public ConsoleSpecialKey SpecialKey {
+                       get { return specialKey; }
+                       set { specialKey = value; }
+               }
+
+               [Obsolete]
+               public ConsoleSpecialKey SpecialKeys {
+                       get { return specialKey; }
+               }
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleCancelEventHandler.cs b/mcs/class/corlib/System/ConsoleCancelEventHandler.cs
new file mode 100644 (file)
index 0000000..bac56d7
--- /dev/null
@@ -0,0 +1,35 @@
+//
+// System.ConsoleCancelEventHandler
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       public delegate void ConsoleCancelEventHandler (object sender, ConsoleCancelEventArgs e);
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleColor.cs b/mcs/class/corlib/System/ConsoleColor.cs
new file mode 100644 (file)
index 0000000..31749c3
--- /dev/null
@@ -0,0 +1,52 @@
+//
+// System.ConsoleColor
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       public enum ConsoleColor {
+               Black,
+               DarkBlue,
+               DarkGreen,
+               DarkCyan,
+               DarkRed,
+               DarkMagenta,
+               DarkYellow,
+               Gray,
+               DarkGray,
+               Blue,
+               Green,
+               Cyan,
+               Red,
+               Magenta,
+               Yellow,
+               White
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleDriver.cs b/mcs/class/corlib/System/ConsoleDriver.cs
new file mode 100644 (file)
index 0000000..80477f9
--- /dev/null
@@ -0,0 +1,171 @@
+//
+// System.ConsoleDriver
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System.IO;
+using System.Runtime.CompilerServices;
+
+namespace System {
+       class ConsoleDriver {
+               static IConsoleDriver driver;
+
+               static ConsoleDriver ()
+               {
+                       string term = Environment.GetEnvironmentVariable ("TERM");
+                       if (term == null && Environment.IsRunningOnWindows) {
+                       } else {
+                               driver = new TermInfoDriver (term);
+                       }
+               }
+
+               public static bool Echo {
+                       get { return driver.Echo; }
+                       set { driver.Echo = value; }
+               }
+
+               public static bool Initialized {
+                       get { return driver.Initialized; }
+               }
+
+               public static ConsoleColor BackgroundColor {
+                       get { return driver.BackgroundColor; }
+                       set {
+                               if (value < ConsoleColor.Black || value > ConsoleColor.White)
+                                       throw new ArgumentOutOfRangeException ("value", "Not a ConsoleColor value.");
+
+                               driver.BackgroundColor = value;
+                       }
+               }
+
+               //int BufferHeight { get; set; }
+               //int BufferWidth { get; set; }
+               //bool CapsLock { get; }
+
+               public static int CursorLeft {
+                       get { return driver.CursorLeft; }
+                       set { driver.CursorLeft = value; }
+               }
+
+               //int CursorSize { get; set; }
+
+               public static int CursorTop {
+                       get { return driver.CursorTop; }
+                       set { driver.CursorTop = value; }
+               } 
+               
+               public static bool CursorVisible {
+                       get { return driver.CursorVisible; }
+                       set { driver.CursorVisible = value; }
+               }
+
+               public static bool KeyAvailable {
+                       get { return driver.KeyAvailable; }
+               }
+
+               public static ConsoleColor ForegroundColor {
+                       get { return driver.ForegroundColor; }
+                       set {
+                               if (value < ConsoleColor.Black || value > ConsoleColor.White)
+                                       throw new ArgumentOutOfRangeException ("value", "Not a ConsoleColor value.");
+
+                               driver.ForegroundColor = value;
+                       }
+               }
+
+               //int LargestWindowHeight { get; set; }
+               //int LargestWindowWidth { get; set; }
+               //bool NumberLock { get; }
+               public static string Title {
+                       get { return driver.Title; }
+                       set { driver.Title = value; }
+               }
+
+               public static bool TreatControlCAsInput {
+                       get { return driver.TreatControlCAsInput; }
+                       set { driver.TreatControlCAsInput = value; }
+               } 
+               //int WindowHeight { get; set; }
+               //int WindowLeft { get; set; }
+               //int WindowTop { get; set; }
+               //int WindowWidth { get; set; }
+
+               public static void Beep (int frequency, int duration)
+               {
+                       driver.Beep (frequency, duration);
+               }
+               
+               public static void Clear ()
+               {
+                       driver.Clear ();
+               }
+
+               //void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+       //                              int targetLeft, int targetTop);
+       //      void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+       //                              int targetLeft, int targetTop, Char sourceChar,
+                                       //ConsoleColor sourceForeColor, ConsoleColor sourceBackColor);
+
+               public static ConsoleKeyInfo ReadKey (bool intercept)
+               {
+                       return driver.ReadKey (intercept);
+               }
+
+               public static void ResetColor ()
+               {
+                       driver.ResetColor ();
+               }
+
+               //void SetBufferSize (int width, int height);
+
+               public static void SetCursorPosition (int left, int top)
+               {
+                       driver.SetCursorPosition (left, top);
+               }
+
+               //void SetWindowPosition (int left, int top);
+               //void SetWindowSize (int width, int height);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               internal static extern bool Isatty (IntPtr handle);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               internal static extern int InternalKeyAvailable (int ms_timeout);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               internal static extern bool TtySetup (string teardown);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               internal static extern bool SetEcho (bool wantEcho);
+
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               internal static extern bool SetBreak (bool wantBreak);
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleKey.cs b/mcs/class/corlib/System/ConsoleKey.cs
new file mode 100644 (file)
index 0000000..95cdc68
--- /dev/null
@@ -0,0 +1,180 @@
+//
+// System.ConsoleKey
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       public enum ConsoleKey {
+               BackSpace = 8,
+               Tab = 9,
+               Clear = 12,
+               Enter = 13,
+               Pause = 19,
+               Escape = 27,
+               SpaceBar = 32,
+               PageUp = 33,
+               PageDown = 34,
+               End = 35,
+               Home = 36,
+               LeftArrow = 37,
+               UpArrow = 38,
+               RightArrow = 39,
+               DownArrow = 40,
+               Select = 41,
+               Print = 42,
+               Execute = 43,
+               PrintScreen = 44,
+               Insert = 45,
+               Delete = 46,
+               Help = 47,
+               D0 = 48,
+               D1 = 49,
+               D2 = 50,
+               D3 = 51,
+               D4 = 52,
+               D5 = 53,
+               D6 = 54,
+               D7 = 55,
+               D8 = 56,
+               D9 = 57,
+               A = 65,
+               B = 66,
+               C = 67,
+               D = 68,
+               E = 69,
+               F = 70,
+               G = 71,
+               H = 72,
+               I = 73,
+               J = 74,
+               K = 75,
+               L = 76,
+               M = 77,
+               N = 78,
+               O = 79,
+               P = 80,
+               Q = 81,
+               R = 82,
+               S = 83,
+               T = 84,
+               U = 85,
+               V = 86,
+               W = 87,
+               X = 88,
+               Y = 89,
+               Z = 90,
+               LeftWindows = 91,
+               RightWindows = 92,
+               Applications = 93,
+               Sleep = 95,
+               NumPad0 = 96,
+               NumPad1 = 97,
+               NumPad2 = 98,
+               NumPad3 = 99,
+               NumPad4 = 100,
+               NumPad5 = 101,
+               NumPad6 = 102,
+               NumPad7 = 103,
+               NumPad8 = 104,
+               NumPad9 = 105,
+               Multiply = 106,
+               Add = 107,
+               Separator = 108,
+               Subtract = 109,
+               Decimal = 110,
+               Divide = 111,
+               F1 = 112,
+               F2 = 113,
+               F3 = 114,
+               F4 = 115,
+               F5 = 116,
+               F6 = 117,
+               F7 = 118,
+               F8 = 119,
+               F9 = 120,
+               F10 = 121,
+               F11 = 122,
+               F12 = 123,
+               F13 = 124,
+               F14 = 125,
+               F15 = 126,
+               F16 = 127,
+               F17 = 128,
+               F18 = 129,
+               F19 = 130,
+               F20 = 131,
+               F21 = 132,
+               F22 = 133,
+               F23 = 134,
+               F24 = 135,
+               BrowserBack = 166,
+               BrowserForward = 167,
+               BrowserRefresh = 168,
+               BrowserStop = 169,
+               BrowserSearch = 170,
+               BrowserFavorites = 171,
+               BrowserHome = 172,
+               VolumeMute = 173,
+               VolumeDown = 174,
+               VolumeUp = 175,
+               MediaNext = 176,
+               MediaPrevious = 177,
+               MediaStop = 178,
+               MediaPlay = 179,
+               LaunchMail = 180,
+               LaunchMediaSelect = 181,
+               LaunchApp1 = 182,
+               LaunchApp2 = 183,
+               Oem1 = 186,
+               OemPlus = 187,
+               OemComma = 188,
+               OemMinus = 189,
+               OemPeriod = 190,
+               Oem2 = 191,
+               Oem3 = 192,
+               Oem4 = 219,
+               Oem5 = 220,
+               Oem6 = 221,
+               Oem7 = 222,
+               Oem8 = 223,
+               Oem102 = 226,
+               Process = 229,
+               Packet = 231,
+               Attention = 246,
+               CrSel = 247,
+               ExSel = 248,
+               EraseEndOfFile = 249,
+               Play = 250,
+               Zoom = 251,
+               NoName = 252,
+               Pa1 = 253,
+               OemClear = 254,
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleKeyInfo.cs b/mcs/class/corlib/System/ConsoleKeyInfo.cs
new file mode 100644 (file)
index 0000000..aea7609
--- /dev/null
@@ -0,0 +1,60 @@
+//
+// System.ConsoleKeyInfo
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       public struct ConsoleKeyInfo {
+               ConsoleKey key;
+               char keychar;
+               ConsoleModifiers modifiers;
+
+               public ConsoleKeyInfo (char keyChar, ConsoleKey key, bool shift, bool alt, bool control)
+               {
+                       this.key = key;
+                       this.keychar = keyChar;
+                       this.modifiers = (shift) ? ConsoleModifiers.Shift : 0;
+                       this.modifiers |= (alt) ? ConsoleModifiers.Alt : 0;
+                       this.modifiers |= (control) ? ConsoleModifiers.Control : 0;
+               }
+
+               public ConsoleKey Key {
+                       get { return key; }
+               }
+
+               public char KeyChar {
+                       get { return keychar; }
+               }
+
+               public ConsoleModifiers Modifiers {
+                       get { return modifiers; }
+               }
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleModifiers.cs b/mcs/class/corlib/System/ConsoleModifiers.cs
new file mode 100644 (file)
index 0000000..b367ff7
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// System.ConsoleModifiers
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       [Flags]
+       public enum ConsoleModifiers {
+               Alt = 1,
+               Shift = 2,
+               Control = 4
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/ConsoleSpecialKey.cs b/mcs/class/corlib/System/ConsoleSpecialKey.cs
new file mode 100644 (file)
index 0000000..c7b0b6d
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// System.ConsoleSpecialKey
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       public enum ConsoleSpecialKey {
+               ControlC,
+               ControlBreak
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/IConsoleDriver.cs b/mcs/class/corlib/System/IConsoleDriver.cs
new file mode 100644 (file)
index 0000000..a36af91
--- /dev/null
@@ -0,0 +1,71 @@
+//
+// System.IConsoleDriver
+//
+// Author:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc. (http://www.novell.com)
+//
+
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       interface IConsoleDriver {
+               ConsoleColor BackgroundColor { get; set; }
+               //int BufferHeight { get; set; }
+               //int BufferWidth { get; set; }
+               //bool CapsLock { get; }
+               int CursorLeft { get; set; } 
+               //int CursorSize { get; set; } 
+               int CursorTop { get; set; }
+               bool CursorVisible { get; set; }
+               bool Echo { get; set; }  // mono
+               ConsoleColor ForegroundColor { get; set; }
+               bool KeyAvailable { get; }
+               bool Initialized { get; }
+               //int LargestWindowHeight { get; set; }
+               //int LargestWindowWidth { get; set; }
+               //bool NumberLock { get; }
+               string Title { get; set; }
+               bool TreatControlCAsInput { get; set; } 
+               //int WindowHeight { get; set; }
+               //int WindowLeft { get; set; }
+               //int WindowTop { get; set; }
+               //int WindowWidth { get; set; }
+
+               void Beep (int frequency, int duration);
+               void Clear ();
+               //void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+       //                              int targetLeft, int targetTop);
+       //      void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+       //                              int targetLeft, int targetTop, Char sourceChar,
+                                       //ConsoleColor sourceForeColor, ConsoleColor sourceBackColor);
+
+               ConsoleKeyInfo ReadKey (bool intercept);
+               void ResetColor ();
+               //void SetBufferSize (int width, int height);
+               void SetCursorPosition (int left, int top);
+               //void SetWindowPosition (int left, int top);
+               //void SetWindowSize (int width, int height);
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/KnownTerminals.cs b/mcs/class/corlib/System/KnownTerminals.cs
new file mode 100644 (file)
index 0000000..e7bd43f
--- /dev/null
@@ -0,0 +1,282 @@
+//
+// System.KnownTerminals
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       class KnownTerminals {
+               private KnownTerminals ()
+               {
+               }
+
+               public static byte [] linux = {
+                       26,1,20,0,29,0,16,0,125,1,41,3,108,105,110,117,120,124,108,105,110,117,120,32,99,111,110,115,111,
+                       108,101,0,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,255,255,8,0,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,8,0,64,0,18,0,255,255,0,0,
+                       2,0,4,0,21,0,26,0,33,0,37,0,41,0,255,255,52,0,69,0,71,0,75,0,87,0,255,255,89,0,101,0,255,255,105,
+                       0,109,0,121,0,125,0,255,255,255,255,129,0,135,0,140,0,255,255,255,255,145,0,150,0,155,0,255,255,160,
+                       0,165,0,170,0,175,0,184,0,190,0,255,255,255,255,198,0,203,0,209,0,215,0,255,255,255,255,255,255,255,
+                       255,255,255,255,255,233,0,237,0,255,255,241,0,255,255,255,255,255,255,243,0,255,255,248,0,255,255,
+                       255,255,255,255,255,255,252,0,1,1,7,1,12,1,17,1,22,1,27,1,33,1,39,1,45,1,51,1,56,1,255,255,61,1,255,
+                       255,65,1,70,1,75,1,255,255,255,255,255,255,79,1,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,83,1,255,255,86,1,95,1,255,255,
+                       104,1,255,255,113,1,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,122,1,255,255,255,255,255,255,128,1,131,1,142,1,145,1,147,1,150,1,247,1,255,255,250,1,255,
+                       255,255,255,255,255,255,255,255,255,255,255,252,1,255,255,255,255,255,255,255,255,0,2,255,255,65,
+                       2,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,69,2,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,74,2,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,76,2,82,2,88,2,94,2,100,2,106,2,112,2,118,2,124,2,130,2,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,136,2,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,141,2,152,2,157,2,163,2,167,2,176,2,180,2,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,5,3,255,255,255,255,255,255,9,3,19,3,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       29,3,35,3,7,0,13,0,27,91,37,105,37,112,49,37,100,59,37,112,50,37,100,114,0,27,91,51,103,0,27,91,72,
+                       27,91,74,0,27,91,75,0,27,91,74,0,27,91,37,105,37,112,49,37,100,71,0,27,91,37,105,37,112,49,37,100,
+                       59,37,112,50,37,100,72,0,10,0,27,91,72,0,27,91,63,50,53,108,27,91,63,49,99,0,8,0,27,91,63,50,53,104,
+                       27,91,63,48,99,0,27,91,67,0,27,91,65,0,27,91,63,50,53,104,27,91,63,56,99,0,27,91,80,0,27,91,77,0,
+                       27,91,49,49,109,0,27,91,53,109,0,27,91,49,109,0,27,91,50,109,0,27,91,52,104,0,27,91,56,109,0,27,91,
+                       55,109,0,27,91,55,109,0,27,91,52,109,0,27,91,37,112,49,37,100,88,0,27,91,49,48,109,0,27,91,48,59,
+                       49,48,109,0,27,91,52,108,0,27,91,50,55,109,0,27,91,50,52,109,0,27,91,63,53,104,27,91,63,53,108,36,
+                       60,50,48,48,47,62,0,27,91,64,0,27,91,76,0,127,0,27,91,51,126,0,27,91,66,0,27,91,91,65,0,27,91,50,
+                       49,126,0,27,91,91,66,0,27,91,91,67,0,27,91,91,68,0,27,91,91,69,0,27,91,49,55,126,0,27,91,49,56,126,
+                       0,27,91,49,57,126,0,27,91,50,48,126,0,27,91,49,126,0,27,91,50,126,0,27,91,68,0,27,91,54,126,0,27,
+                       91,53,126,0,27,91,67,0,27,91,65,0,13,10,0,27,91,37,112,49,37,100,80,0,27,91,37,112,49,37,100,77,0,
+                       27,91,37,112,49,37,100,64,0,27,91,37,112,49,37,100,76,0,27,99,27,93,82,0,27,56,0,27,91,37,105,37,
+                       112,49,37,100,100,0,27,55,0,10,0,27,77,0,27,91,48,59,49,48,37,63,37,112,49,37,116,59,55,37,59,37,
+                       63,37,112,50,37,116,59,52,37,59,37,63,37,112,51,37,116,59,55,37,59,37,63,37,112,52,37,116,59,53,37,
+                       59,37,63,37,112,53,37,116,59,50,37,59,37,63,37,112,54,37,116,59,49,37,59,37,63,37,112,55,37,116,59,
+                       56,37,59,37,63,37,112,57,37,116,59,49,49,37,59,109,0,27,72,0,9,0,27,91,71,0,43,16,44,17,45,24,46,
+                       25,48,219,96,4,97,177,102,248,103,241,104,176,105,206,106,217,107,191,108,218,109,192,110,197,111,
+                       126,112,196,113,196,114,196,115,95,116,195,117,180,118,193,119,194,120,179,121,243,122,242,123,227,
+                       124,216,125,156,126,254,0,27,91,90,0,27,91,52,126,0,26,0,27,91,50,51,126,0,27,91,50,52,126,0,27,91,
+                       50,53,126,0,27,91,50,54,126,0,27,91,50,56,126,0,27,91,50,57,126,0,27,91,51,49,126,0,27,91,51,50,126,
+                       0,27,91,51,51,126,0,27,91,51,52,126,0,27,91,49,75,0,27,91,37,105,37,100,59,37,100,82,0,27,91,54,110,
+                       0,27,91,63,54,99,0,27,91,99,0,27,91,51,57,59,52,57,109,0,27,93,82,0,27,93,80,37,112,49,37,120,37,
+                       112,50,37,123,50,53,54,125,37,42,37,123,49,48,48,48,125,37,47,37,48,50,120,37,112,51,37,123,50,53,
+                       54,125,37,42,37,123,49,48,48,48,125,37,47,37,48,50,120,37,112,52,37,123,50,53,54,125,37,42,37,123,
+                       49,48,48,48,125,37,47,37,48,50,120,0,27,91,77,0,27,91,51,37,112,49,37,100,109,0,27,91,52,37,112,49,
+                       37,100,109,0,27,91,49,49,109,0,27,91,49,48,109,0
+                       }; // linux
+
+               public static byte [] xterm = {
+                       26,1,28,0,29,0,15,0,157,1,150,4,120,116,101,114,109,124,88,49,49,32,116,101,114,109,105,110,97,108,
+                       32,101,109,117,108,97,116,111,114,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,80,
+                       0,8,0,24,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,8,0,64,
+                       0,0,0,4,0,6,0,8,0,25,0,30,0,38,0,42,0,46,0,255,255,57,0,74,0,76,0,80,0,87,0,255,255,89,0,96,0,255,
+                       255,100,0,255,255,104,0,108,0,255,255,255,255,112,0,114,0,119,0,124,0,255,255,255,255,133,0,138,0,
+                       255,255,143,0,148,0,153,0,158,0,167,0,169,0,174,0,255,255,183,0,188,0,194,0,200,0,255,255,255,255,
+                       255,255,218,0,255,255,255,255,255,255,236,0,255,255,240,0,255,255,255,255,255,255,242,0,255,255,247,
+                       0,255,255,255,255,255,255,255,255,251,0,255,0,5,1,9,1,13,1,17,1,23,1,29,1,35,1,41,1,47,1,51,1,255,
+                       255,56,1,255,255,60,1,65,1,70,1,255,255,255,255,255,255,74,1,78,1,86,1,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,94,1,
+                       103,1,112,1,121,1,255,255,130,1,139,1,148,1,255,255,157,1,255,255,255,255,255,255,166,1,170,1,175,
+                       1,255,255,180,1,183,1,255,255,255,255,201,1,204,1,215,1,218,1,220,1,223,1,45,2,255,255,48,2,255,255,
+                       255,255,255,255,255,255,255,255,255,255,50,2,255,255,255,255,255,255,255,255,54,2,255,255,107,2,255,
+                       255,255,255,111,2,117,2,255,255,255,255,123,2,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,130,2,134,2,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,138,2,255,255,255,255,145,2,255,255,255,255,255,255,255,255,150,2,155,2,162,
+                       2,255,255,255,255,167,2,255,255,174,2,255,255,255,255,255,255,181,2,255,255,255,255,255,255,255,255,
+                       255,255,186,2,192,2,198,2,203,2,208,2,213,2,218,2,226,2,234,2,242,2,250,2,2,3,10,3,18,3,26,3,31,3,
+                       36,3,41,3,46,3,54,3,62,3,70,3,78,3,86,3,94,3,102,3,110,3,115,3,120,3,125,3,130,3,138,3,146,3,154,
+                       3,162,3,170,3,178,3,186,3,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,194,3,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,199,3,210,3,215,3,223,3,227,3,255,255,255,255,255,255,255,
+                       255,236,3,50,4,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,120,4,255,255,255,255,255,255,124,4,134,4,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,144,4,147,4,27,91,90,0,7,0,13,
+                       0,27,91,37,105,37,112,49,37,100,59,37,112,50,37,100,114,0,27,91,51,103,0,27,91,72,27,91,50,74,0,27,
+                       91,75,0,27,91,74,0,27,91,37,105,37,112,49,37,100,71,0,27,91,37,105,37,112,49,37,100,59,37,112,50,
+                       37,100,72,0,10,0,27,91,72,0,27,91,63,50,53,108,0,8,0,27,91,63,50,53,104,0,27,91,67,0,27,91,65,0,27,
+                       91,80,0,27,91,77,0,14,0,27,91,53,109,0,27,91,49,109,0,27,91,63,49,48,52,57,104,0,27,91,52,104,0,27,
+                       91,56,109,0,27,91,55,109,0,27,91,55,109,0,27,91,52,109,0,27,91,37,112,49,37,100,88,0,15,0,27,91,109,
+                       15,0,27,91,63,49,48,52,57,108,0,27,91,52,108,0,27,91,50,55,109,0,27,91,50,52,109,0,27,91,63,53,104,
+                       36,60,49,48,48,47,62,27,91,63,53,108,0,27,91,33,112,27,91,63,51,59,52,108,27,91,52,108,27,62,0,27,
+                       91,76,0,127,0,27,91,51,126,0,27,79,66,0,27,79,80,0,27,91,50,49,126,0,27,79,81,0,27,79,82,0,27,79,
+                       83,0,27,91,49,53,126,0,27,91,49,55,126,0,27,91,49,56,126,0,27,91,49,57,126,0,27,91,50,48,126,0,27,
+                       79,72,0,27,91,50,126,0,27,79,68,0,27,91,54,126,0,27,91,53,126,0,27,79,67,0,27,79,65,0,27,91,63,49,
+                       108,27,62,0,27,91,63,49,104,27,61,0,27,91,37,112,49,37,100,80,0,27,91,37,112,49,37,100,77,0,27,91,
+                       37,112,49,37,100,66,0,27,91,37,112,49,37,100,64,0,27,91,37,112,49,37,100,76,0,27,91,37,112,49,37,
+                       100,68,0,27,91,37,112,49,37,100,67,0,27,91,37,112,49,37,100,65,0,27,91,105,0,27,91,52,105,0,27,91,
+                       53,105,0,27,99,0,27,91,33,112,27,91,63,51,59,52,108,27,91,52,108,27,62,0,27,56,0,27,91,37,105,37,
+                       112,49,37,100,100,0,27,55,0,10,0,27,77,0,27,91,48,37,63,37,112,54,37,116,59,49,37,59,37,63,37,112,
+                       50,37,116,59,52,37,59,37,63,37,112,49,37,112,51,37,124,37,116,59,55,37,59,37,63,37,112,52,37,116,
+                       59,53,37,59,37,63,37,112,55,37,116,59,56,37,59,109,37,63,37,112,57,37,116,14,37,101,15,37,59,0,27,
+                       72,0,9,0,27,79,69,0,96,96,97,97,102,102,103,103,105,105,106,106,107,107,108,108,109,109,110,110,111,
+                       111,112,112,113,113,114,114,115,115,116,116,117,117,118,118,119,119,120,120,121,121,122,122,123,123,
+                       124,124,125,125,126,126,0,27,91,90,0,27,91,63,55,104,0,27,91,63,55,108,0,27,40,66,27,41,48,0,27,79,
+                       70,0,27,79,77,0,27,91,51,59,53,126,0,27,79,53,70,0,27,79,53,72,0,27,91,50,59,53,126,0,27,79,53,68,
+                       0,27,91,54,59,53,126,0,27,91,53,59,53,126,0,27,79,53,67,0,27,91,50,51,126,0,27,91,50,52,126,0,27,
+                       79,50,80,0,27,79,50,81,0,27,79,50,82,0,27,79,50,83,0,27,91,49,53,59,50,126,0,27,91,49,55,59,50,126,
+                       0,27,91,49,56,59,50,126,0,27,91,49,57,59,50,126,0,27,91,50,48,59,50,126,0,27,91,50,49,59,50,126,0,
+                       27,91,50,51,59,50,126,0,27,91,50,52,59,50,126,0,27,79,53,80,0,27,79,53,81,0,27,79,53,82,0,27,79,53,
+                       83,0,27,91,49,53,59,53,126,0,27,91,49,55,59,53,126,0,27,91,49,56,59,53,126,0,27,91,49,57,59,53,126,
+                       0,27,91,50,48,59,53,126,0,27,91,50,49,59,53,126,0,27,91,50,51,59,53,126,0,27,91,50,52,59,53,126,0,
+                       27,79,54,80,0,27,79,54,81,0,27,79,54,82,0,27,79,54,83,0,27,91,49,53,59,54,126,0,27,91,49,55,59,54,
+                       126,0,27,91,49,56,59,54,126,0,27,91,49,57,59,54,126,0,27,91,50,48,59,54,126,0,27,91,50,49,59,54,126,
+                       0,27,91,50,51,59,54,126,0,27,91,50,52,59,54,126,0,27,91,49,75,0,27,91,37,105,37,100,59,37,100,82,
+                       0,27,91,54,110,0,27,91,63,49,59,50,99,0,27,91,99,0,27,91,51,57,59,52,57,109,0,27,91,51,37,63,37,112,
+                       49,37,123,49,125,37,61,37,116,52,37,101,37,112,49,37,123,51,125,37,61,37,116,54,37,101,37,112,49,
+                       37,123,52,125,37,61,37,116,49,37,101,37,112,49,37,123,54,125,37,61,37,116,51,37,101,37,112,49,37,
+                       100,37,59,109,0,27,91,52,37,63,37,112,49,37,123,49,125,37,61,37,116,52,37,101,37,112,49,37,123,51,
+                       125,37,61,37,116,54,37,101,37,112,49,37,123,52,125,37,61,37,116,49,37,101,37,112,49,37,123,54,125,
+                       37,61,37,116,51,37,101,37,112,49,37,100,37,59,109,0,27,91,77,0,27,91,51,37,112,49,37,100,109,0,27,
+                       91,52,37,112,49,37,100,109,0,27,108,0,27,109,0
+                       }; // xterm
+
+               public static byte [] cygwin = {
+                       26,1,33,0,21,0,15,0,125,1,162,2,99,121,103,119,105,110,124,97,110,115,105,32,101,109,117,108,97,116,
+                       105,111,110,32,102,111,114,32,67,121,103,119,105,110,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,1,
+                       255,255,8,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       8,0,64,0,0,0,4,0,6,0,255,255,255,255,8,0,15,0,19,0,23,0,255,255,34,0,51,0,55,0,255,255,59,0,255,255,
+                       255,255,61,0,255,255,65,0,255,255,69,0,73,0,255,255,255,255,77,0,255,255,82,0,87,0,255,255,255,255,
+                       96,0,101,0,255,255,106,0,111,0,116,0,255,255,121,0,127,0,135,0,255,255,148,0,153,0,159,0,255,255,
+                       255,255,165,0,255,255,255,255,255,255,255,255,167,0,171,0,255,255,175,0,255,255,255,255,255,255,177,
+                       0,255,255,182,0,255,255,255,255,255,255,255,255,186,0,191,0,197,0,202,0,207,0,212,0,217,0,223,0,229,
+                       0,235,0,241,0,246,0,255,255,251,0,255,255,255,0,4,1,9,1,255,255,255,255,255,255,13,1,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,17,1,255,255,20,1,29,1,38,1,47,1,255,255,56,1,65,1,74,1,255,255,83,1,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,92,1,255,255,255,255,255,255,98,1,101,1,112,1,115,1,117,1,120,
+                       1,255,255,255,255,206,1,208,1,255,255,255,255,255,255,255,255,255,255,212,1,255,255,255,255,255,255,
+                       255,255,216,1,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,23,2,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,28,2,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,30,2,36,2,42,2,48,2,54,2,60,2,
+                       66,2,72,2,78,2,84,2,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,90,2,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,95,2,106,2,111,2,117,2,121,2,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,130,2,140,2,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,150,2,156,2,27,91,90,0,7,0,13,0,27,91,72,27,91,74,0,27,91,75,0,27,
+                       91,74,0,27,91,37,105,37,112,49,37,100,71,0,27,91,37,105,37,112,49,37,100,59,37,112,50,37,100,72,0,
+                       27,91,66,0,27,91,72,0,8,0,27,91,67,0,27,91,65,0,27,91,80,0,27,91,77,0,27,49,49,109,0,27,91,49,109,
+                       0,27,55,27,91,63,52,55,104,0,27,91,52,104,0,27,91,56,109,0,27,91,55,109,0,27,91,55,109,0,27,91,52,
+                       109,0,27,91,49,48,109,0,27,91,48,59,49,48,109,0,27,91,50,74,27,91,63,52,55,108,27,56,0,27,91,52,108,
+                       0,27,91,50,55,109,0,27,91,50,52,109,0,7,0,27,91,64,0,27,91,76,0,8,0,27,91,51,126,0,27,91,66,0,27,
+                       91,91,65,0,27,91,50,49,126,0,27,91,91,66,0,27,91,91,67,0,27,91,91,68,0,27,91,91,69,0,27,91,49,55,
+                       126,0,27,91,49,56,126,0,27,91,49,57,126,0,27,91,50,48,126,0,27,91,49,126,0,27,91,50,126,0,27,91,68,
+                       0,27,91,54,126,0,27,91,53,126,0,27,91,67,0,27,91,65,0,13,10,0,27,91,37,112,49,37,100,80,0,27,91,37,
+                       112,49,37,100,77,0,27,91,37,112,49,37,100,66,0,27,91,37,112,49,37,100,64,0,27,91,37,112,49,37,100,
+                       76,0,27,91,37,112,49,37,100,68,0,27,91,37,112,49,37,100,67,0,27,91,37,112,49,37,100,65,0,27,99,27,
+                       93,82,0,27,56,0,27,91,37,105,37,112,49,37,100,100,0,27,55,0,10,0,27,77,0,27,91,48,59,49,48,37,63,
+                       37,112,49,37,116,59,55,37,59,37,63,37,112,50,37,116,59,52,37,59,37,63,37,112,51,37,116,59,55,37,59,
+                       37,63,37,112,52,37,116,59,53,37,59,37,63,37,112,54,37,116,59,49,37,59,37,63,37,112,55,37,116,59,56,
+                       37,59,37,63,37,112,57,37,116,59,49,49,37,59,109,0,9,0,27,93,59,0,27,91,71,0,43,16,44,17,45,24,46,
+                       25,48,219,96,4,97,177,102,248,103,241,104,176,106,217,107,191,108,218,109,192,110,197,111,126,112,
+                       196,113,196,114,196,115,95,116,195,117,180,118,193,119,194,120,179,121,243,122,242,123,227,124,216,
+                       125,156,126,254,0,27,91,52,126,0,26,0,27,91,50,51,126,0,27,91,50,52,126,0,27,91,50,53,126,0,27,91,
+                       50,54,126,0,27,91,50,56,126,0,27,91,50,57,126,0,27,91,51,49,126,0,27,91,51,50,126,0,27,91,51,51,126,
+                       0,27,91,51,52,126,0,27,91,49,75,0,27,91,37,105,37,100,59,37,100,82,0,27,91,54,110,0,27,91,63,54,99,
+                       0,27,91,99,0,27,91,51,57,59,52,57,109,0,27,91,51,37,112,49,37,100,109,0,27,91,52,37,112,49,37,100,
+                       109,0,27,91,49,49,109,0,27,91,49,48,109,0
+                       }; // cygwin
+
+               public static byte [] ansi = {
+                       26,1,40,0,23,0,16,0,125,1,68,2,97,110,115,105,124,97,110,115,105,47,112,99,45,116,101,114,109,32,
+                       99,111,109,112,97,116,105,98,108,101,32,119,105,116,104,32,99,111,108,111,114,0,0,1,0,0,0,0,0,0,0,
+                       0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,80,0,8,0,24,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,8,0,64,0,3,0,0,0,4,0,6,0,255,255,8,0,13,0,20,0,24,0,28,0,255,255,39,0,56,
+                       0,60,0,255,255,64,0,255,255,255,255,68,0,255,255,72,0,255,255,76,0,80,0,255,255,255,255,84,0,90,0,
+                       95,0,255,255,255,255,255,255,255,255,100,0,255,255,105,0,110,0,115,0,120,0,129,0,135,0,255,255,255,
+                       255,255,255,143,0,147,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,151,0,255,
+                       255,155,0,255,255,255,255,255,255,255,255,255,255,157,0,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,161,0,165,0,255,255,169,0,255,
+                       255,255,255,255,255,173,0,255,255,255,255,255,255,177,0,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,181,0,255,255,186,0,195,
+                       0,204,0,213,0,222,0,231,0,240,0,249,0,2,1,11,1,255,255,255,255,255,255,255,255,20,1,25,1,30,1,255,
+                       255,255,255,255,255,255,255,255,255,50,1,255,255,61,1,255,255,63,1,149,1,255,255,152,1,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,156,1,255,255,219,1,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,223,1,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,228,1,239,1,244,1,7,2,11,2,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,20,2,30,2,255,255,255,255,255,255,
+                       40,2,44,2,48,2,52,2,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+                       255,255,56,2,62,2,27,91,90,0,7,0,13,0,27,91,50,103,0,27,91,72,27,91,74,0,27,91,75,0,27,91,74,0,27,
+                       91,37,105,37,112,49,37,100,71,0,27,91,37,105,37,112,49,37,100,59,37,112,50,37,100,72,0,27,91,66,0,
+                       27,91,72,0,27,91,68,0,27,91,67,0,27,91,65,0,27,91,80,0,27,91,77,0,27,91,49,49,109,0,27,91,53,109,
+                       0,27,91,49,109,0,27,91,56,109,0,27,91,55,109,0,27,91,55,109,0,27,91,52,109,0,27,91,37,112,49,37,100,
+                       88,0,27,91,49,48,109,0,27,91,48,59,49,48,109,0,27,91,109,0,27,91,109,0,27,91,76,0,8,0,27,91,66,0,
+                       27,91,72,0,27,91,76,0,27,91,68,0,27,91,67,0,27,91,65,0,13,27,91,83,0,27,91,37,112,49,37,100,80,0,
+                       27,91,37,112,49,37,100,77,0,27,91,37,112,49,37,100,66,0,27,91,37,112,49,37,100,64,0,27,91,37,112,
+                       49,37,100,83,0,27,91,37,112,49,37,100,76,0,27,91,37,112,49,37,100,68,0,27,91,37,112,49,37,100,67,
+                       0,27,91,37,112,49,37,100,84,0,27,91,37,112,49,37,100,65,0,27,91,52,105,0,27,91,53,105,0,37,112,49,
+                       37,99,27,91,37,112,50,37,123,49,125,37,45,37,100,98,0,27,91,37,105,37,112,49,37,100,100,0,10,0,27,
+                       91,48,59,49,48,37,63,37,112,49,37,116,59,55,37,59,37,63,37,112,50,37,116,59,52,37,59,37,63,37,112,
+                       51,37,116,59,55,37,59,37,63,37,112,52,37,116,59,53,37,59,37,63,37,112,54,37,116,59,49,37,59,37,63,
+                       37,112,55,37,116,59,56,37,59,37,63,37,112,57,37,116,59,49,49,37,59,109,0,27,72,0,27,91,73,0,43,16,
+                       44,17,45,24,46,25,48,219,96,4,97,177,102,248,103,241,104,176,106,217,107,191,108,218,109,192,110,
+                       197,111,126,112,196,113,196,114,196,115,95,116,195,117,180,118,193,119,194,120,179,121,243,122,242,
+                       123,227,124,216,125,156,126,254,0,27,91,90,0,27,91,49,75,0,27,91,37,105,37,100,59,37,100,82,0,27,
+                       91,54,110,0,27,91,63,37,91,59,48,49,50,51,52,53,54,55,56,57,93,99,0,27,91,99,0,27,91,51,57,59,52,
+                       57,109,0,27,91,51,37,112,49,37,100,109,0,27,91,52,37,112,49,37,100,109,0,27,40,66,0,27,41,66,0,27,
+                       42,66,0,27,43,66,0,27,91,49,49,109,0,27,91,49,48,109,0
+                       }; // ansi
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/TermInfoBooleans.cs b/mcs/class/corlib/System/TermInfoBooleans.cs
new file mode 100644 (file)
index 0000000..97f5604
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// System.TermInfoBooleans
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       enum TermInfoBooleans {
+               AutoLeftMargin,         // 0
+               AutoRightMargin,
+               NoEscCtlc,
+               CeolStandoutGlitch,
+               EatNewlineGlitch,
+               EraseOverstrike,
+               GenericType,
+               HardCopy,
+               HasMetaKey,
+               HasStatusLine,
+               InsertNullGlitch,
+               MemoryAbove,
+               MemoryBelow,
+               MoveInsertMode,
+               MoveStandoutMode,
+               OverStrike,
+               StatusLineEscOk,
+               DestTabsMagicSmso,
+               TildeGlitch,
+               TransparentUnderline,
+               XonXoff,
+               NeedsXonXoff,
+               PrtrSilent,
+               HardCursor,
+               NonRevRmcup,
+               NoPadChar,
+               NonDestScrollRegion,
+               CanChange,
+               BackColorErase,
+               HueLightnessSaturation,
+               ColAddrGlitch,
+               CrCancelsMicroMode,
+               HasPrintWheel,
+               RowAddrGlitch,
+               SemiAutoRightMargin,
+               CpiChangesRes,
+               LpiChangesRes,          // 36
+               Last
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/TermInfoDriver.cs b/mcs/class/corlib/System/TermInfoDriver.cs
new file mode 100644 (file)
index 0000000..0a0f4f2
--- /dev/null
@@ -0,0 +1,423 @@
+//
+// System.ConsoleDriver
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System.IO;
+namespace System {
+       class TermInfoDriver : IConsoleDriver {
+               static string [] locations = { "/etc/terminfo", "/usr/share/terminfo", "/usr/lib/terminfo" };
+
+               TermInfoReader reader;
+               int cursorLeft;
+               int cursorTop;
+               string title = "";
+               string titleFormat = "";
+               bool cursorVisible = true;
+               string csrVisible;
+               string csrInvisible;
+               string clear;
+               string bell;
+               string term;
+               Stream stdout;
+               Stream stdin;
+               int windowWidth;
+               int windowHeight;
+               string enterCA, exitCA;
+               bool controlCAsInput;
+               bool inited;
+               bool noEcho;
+               string origPair;
+               string origColors;
+               string cursorAddress;
+               bool addOneWhenAddressing;
+               int bufferHeight = 200; // FIXME
+               int bufferWidth = 200; // FIXME
+               ConsoleColor fgcolor = ConsoleColor.White;
+               ConsoleColor bgcolor = ConsoleColor.Black;
+               string setafcolor; // TODO: use setforeground/setbackground if available for better
+               string setabcolor; // color mapping.
+               bool noGetPosition;
+
+               static string SearchTerminfo (string term)
+               {
+                       if (term == null || term == "")
+                               return null;
+
+                       // Ignore TERMINFO and TERMINFO_DIRS by now
+                       //string terminfo = Environment.GetEnvironmentVariable ("TERMINFO");
+                       //string terminfoDirs = Environment.GetEnvironmentVariable ("TERMINFO_DIRS");
+
+                       foreach (string dir in locations) {
+                               if (!Directory.Exists (dir))
+                                       continue;
+
+                               string path = Path.Combine (dir, term.Substring (0, 1));
+                               if (!Directory.Exists (dir))
+                                       continue;
+
+                               path = Path.Combine (path, term);
+                               if (!File.Exists (path))
+                                       continue;
+
+                               return path;
+                       }
+
+                       return null;
+               }
+
+               // FIXME: this won't work on windows
+               static void WriteConsole (string str)
+               {
+                       if (str == null)
+                               return;
+
+                       Console.Write (str);
+               }
+
+               public TermInfoDriver ()
+                       : this (Environment.GetEnvironmentVariable ("TERM"))
+               {
+               }
+
+               public TermInfoDriver (string term)
+               {
+                       this.term = term;
+                       if (term == null)
+                               this.term = "ansi";
+
+                       if (term == "xterm") {
+                               reader = new TermInfoReader (term, KnownTerminals.xterm);
+                       } else if (term == "linux") {
+                               reader = new TermInfoReader (term, KnownTerminals.linux);
+                       } else if (term == "cygwin") {
+                               reader = new TermInfoReader (term, KnownTerminals.cygwin);
+                       } else if (term == "ansi") {
+                               reader = new TermInfoReader (term, KnownTerminals.ansi);
+                       } else {
+                               string filename = SearchTerminfo (term);
+                               reader = new TermInfoReader (term, filename);
+                       }
+               }
+
+               public bool Initialized {
+                       get { return inited; }
+               }
+               
+               void Init ()
+               {
+                       if (inited)
+                               return;
+
+                       inited = true;
+                       enterCA = reader.Get (TermInfoStrings.EnterCaMode);
+                       exitCA = reader.Get (TermInfoStrings.ExitCaMode);
+
+                       if (!ConsoleDriver.Isatty (MonoIO.ConsoleOutput) || !ConsoleDriver.Isatty (MonoIO.ConsoleInput))
+                               throw new IOException ("Not a tty.");
+
+                       origPair = reader.Get (TermInfoStrings.OrigPair);
+                       origColors = reader.Get (TermInfoStrings.OrigColors);
+                       setafcolor = MangleParameters (reader.Get (TermInfoStrings.SetAForeground));
+                       setabcolor = MangleParameters (reader.Get (TermInfoStrings.SetABackground));
+                       string resetColors = (origColors == null) ? origPair : origColors;
+                       if (!ConsoleDriver.TtySetup (exitCA + resetColors))
+                               throw new IOException ("Error initializing terminal.");
+
+                       if (enterCA != null && exitCA != null)
+                               WriteConsole (enterCA);
+
+                       stdout = Console.OpenStandardOutput (0);
+                       stdin = Console.OpenStandardInput (0);
+                       clear = reader.Get (TermInfoStrings.ClearScreen);
+                       bell = reader.Get (TermInfoStrings.Bell);
+                       if (clear == null) {
+                               clear = reader.Get (TermInfoStrings.CursorHome);
+                               clear += reader.Get (TermInfoStrings.ClrEos);
+                       }
+
+                       csrVisible = reader.Get (TermInfoStrings.CursorNormal);
+                       if (csrVisible == null)
+                               csrVisible = reader.Get (TermInfoStrings.CursorVisible);
+
+                       csrInvisible = reader.Get (TermInfoStrings.CursorInvisible);
+                       if (term == "cygwin" || term == "linux" || term.StartsWith ("xterm") ||
+                               term == "rxvt" || term == "dtterm") {
+                               titleFormat = "\x1b]0;{0}\x7"; // icon + window title
+                       } else if (term == "iris-ansi") {
+                               titleFormat = "\x1bP1.y{0}\x1b\\"; // not tested
+                       } else if (term == "sun-cmd") {
+                               titleFormat = "\x1b]l{0}\x1b\\"; // not tested
+                       }
+
+                       cursorAddress = reader.Get (TermInfoStrings.CursorAddress);
+                       if (cursorAddress != null) {
+                               string result = cursorAddress.Replace ("%i", "");
+                               addOneWhenAddressing = (cursorAddress != result);
+                               cursorAddress = MangleParameters (cursorAddress);
+                       }
+               }
+
+               static string MangleParameters (string str)
+               {
+                       if (str == null)
+                               return null;
+
+                       str = str.Replace ("{", "{{");
+                       str = str.Replace ("}", "}}");
+                       str = str.Replace ("%p1%d", "{0}");
+                       return str.Replace ("%p2%d", "{1}");
+               }
+
+               static int TranslateColor (ConsoleColor desired)
+               {
+                       switch (desired) {
+                       case ConsoleColor.Black:
+                       case ConsoleColor.DarkGray:
+                               return 0;
+                       case ConsoleColor.DarkBlue:
+                       case ConsoleColor.Blue:
+                               return 4;
+                       case ConsoleColor.DarkGreen:
+                       case ConsoleColor.Green:
+                               return 2;
+                       case ConsoleColor.DarkCyan:
+                       case ConsoleColor.Cyan:
+                               return 6;
+                       case ConsoleColor.DarkRed:
+                       case ConsoleColor.Red:
+                               return 1;
+                       case ConsoleColor.DarkMagenta:
+                       case ConsoleColor.Magenta:
+                               return 5;
+                       case ConsoleColor.DarkYellow:
+                       case ConsoleColor.Yellow:
+                               return 3;
+                       case ConsoleColor.Gray:
+                       case ConsoleColor.White:
+                               return 7;
+                       }
+
+                       return 0;
+               }
+
+               public ConsoleColor BackgroundColor {
+                       get { return bgcolor; }
+                       set {
+                               bgcolor = value;
+                               WriteConsole (String.Format (setabcolor, TranslateColor (value)));
+                       }
+               }
+
+               public ConsoleColor ForegroundColor {
+                       get { return fgcolor; }
+                       set {
+                               fgcolor = value;
+                               WriteConsole (String.Format (setafcolor, TranslateColor (value)));
+                       }
+               }
+
+               void GetCursorPosition ()
+               {
+                       if (noGetPosition)
+                               return;
+
+                       int row = 0, col = 0;
+                       bool prevEcho = Echo;
+                       Echo = false;
+                       try {
+                               WriteConsole ("\x1b[6n");
+                               if (ConsoleDriver.InternalKeyAvailable (1000) <= 0) {
+                                       noGetPosition = true;
+                                       return;
+                               }
+
+                               int b = stdin.ReadByte ();
+                               if (b != '\x1b') {
+                                       // Fix this with the buffer
+                                       return;
+                               }
+
+                               b = stdin.ReadByte ();
+                               if (b != '[') {
+                                       return;
+                               }
+
+                               b = stdin.ReadByte ();
+                               if (b != ';') {
+                                       row = b - '0';
+                                       b = stdin.ReadByte ();
+                                       if (b != ';')
+                                               row = row * 10 + b - '0';
+                               }
+
+                               b = stdin.ReadByte ();
+                               if (b != 'R') {
+                                       col = b - '0';
+                                       b = stdin.ReadByte ();
+                                       if (b != 'R') {
+                                               col = col * 10 + b - '0';
+                                               stdin.ReadByte (); // This should be the 'R'
+                                       }
+                               }
+                       } finally {
+                               Echo = prevEcho;
+                       }
+
+                       cursorLeft = col;
+                       cursorTop = row;
+               }
+
+               public int CursorLeft {
+                       get {
+                               Init ();
+                               GetCursorPosition ();
+                               return cursorLeft;
+                       }
+                       set {
+                               Init ();
+                               SetCursorPosition (value, CursorTop);
+                               cursorLeft = value;
+                       }
+               }
+
+               public int CursorTop {
+                       get {
+                               Init ();
+                               GetCursorPosition ();
+                               return cursorTop;
+                       }
+                       set {
+                               Init ();
+                               SetCursorPosition (CursorLeft, value);
+                               cursorTop = value;
+                       }
+               }
+
+               public bool CursorVisible {
+                       get {
+                               Init ();
+                               return cursorVisible;
+                       }
+                       set {
+                               Init ();
+                               cursorVisible = value;
+                               WriteConsole ((value ? csrVisible : csrInvisible));
+                       }
+               }
+
+               public bool Echo {
+                       get { return !noEcho; }
+                       set {
+                               if (value != noEcho)
+                                       return;
+
+                               noEcho = !value;
+                               ConsoleDriver.SetEcho (value);
+                       }
+               }
+
+               public bool KeyAvailable {
+                       get {
+                               Init ();
+                               return (ConsoleDriver.InternalKeyAvailable (0) > 0);
+                       }
+               }
+
+               public string Title {
+                       get { return title; }
+                       
+                       set {
+                               Init ();
+                               title = value;
+                               WriteConsole (String.Format (titleFormat, value));
+                       }
+               }
+
+               public bool TreatControlCAsInput {
+                       get { return controlCAsInput; }
+                       set {
+                               if (controlCAsInput == value)
+                                       return;
+
+                               Init ();
+                               ConsoleDriver.SetBreak (value);
+                               controlCAsInput = value;
+                       }
+               }
+
+               public void Clear ()
+               {
+                       Init ();
+                       WriteConsole (clear);
+                       cursorTop = 0;
+                       cursorLeft = 0;
+               }
+
+               public void Beep (int frequency, int duration)
+               {
+                       Init ();
+                       WriteConsole (bell);
+               }
+
+               public ConsoleKeyInfo ReadKey (bool intercept)
+               {
+                       Init ();
+                       Echo  = !intercept;
+                       int b = stdin.ReadByte ();
+                       return new ConsoleKeyInfo ((char) b, (ConsoleKey) b, false, false, false);
+               }
+
+               public void ResetColor ()
+               {
+                       Init ();
+                       string str = (origPair != null) ? origPair : origColors;
+                       WriteConsole (str);
+               }
+
+               public void SetCursorPosition (int left, int top)
+               {
+                       if (left < 0 || left >= bufferWidth)
+                               throw new ArgumentOutOfRangeException ("left", "Value must be positive and below the buffer width.");
+
+                       if (top < 0 || top >= bufferHeight)
+                               throw new ArgumentOutOfRangeException ("top", "Value must be positive and below the buffer height.");
+
+                       Init ();
+
+                       // Either CursorAddress or nothing.
+                       // We might want to play with up/down/left/right/home when ca is not available.
+                       int adj = (addOneWhenAddressing) ? 1 : 0;
+                       WriteConsole (String.Format (cursorAddress, left + adj, top + adj));
+                       cursorLeft = left;
+                       cursorTop = top;
+               }
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/TermInfoNumbers.cs b/mcs/class/corlib/System/TermInfoNumbers.cs
new file mode 100644 (file)
index 0000000..3514c8f
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// System.TermInfoNumbers
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       enum TermInfoNumbers {
+               Columns,                // 0
+               InitTabs,
+               Lines,
+               LinesOfMemory,
+               MagicCookieGlitch,
+               PaddingBaudRate,
+               VirtualTerminal,
+               WidthStatusLine,
+               NumLabels,
+               LabelHeight,
+               LabelWidth,
+               MaxAttributes,
+               MaximumWindows,
+               MaxColors,
+               MaxPairs,
+               NoColorVideo,
+               BufferCapacity,
+               DotVertSpacing,
+               DotHorzSpacing,
+               MaxMicroAddress,
+               MaxMicroJump,
+               MicroColSize,
+               MicroLineSize,
+               NumberOfPins,
+               OutputResChar,
+               OutputResLine,
+               OutputResHorzInch,
+               OutputResVertInch,
+               PrintRate,
+               WideCharSize,
+               Buttons,
+               BitImageEntwining,
+               BitImageType,           // 32
+               Last
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/TermInfoReader.cs b/mcs/class/corlib/System/TermInfoReader.cs
new file mode 100644 (file)
index 0000000..e48f504
--- /dev/null
@@ -0,0 +1,183 @@
+//
+// System.TermInfoReader
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+using System.IO;
+using System.Text;
+namespace System {
+       class TermInfoReader {
+               short nameSize;
+               short boolSize;
+               short numSize;
+               short strOffsets;
+               short strSize;
+
+               string [] names; // Last one is the description
+               byte [] buffer;
+               int booleansOffset;
+               string term;
+
+               public TermInfoReader (string term, string filename)
+               {
+                       using (FileStream st = File.OpenRead (filename)) {
+                               long length = st.Length;
+                               if (length > 4096)
+                                       throw new Exception ("File must be smaller than 4K");
+
+                               buffer = new byte [(int) length];
+                               if (st.Read (buffer, 0, buffer.Length) != buffer.Length)
+                                       throw new Exception ("Short read");
+
+                               ReadHeader (buffer, ref booleansOffset);
+                               ReadNames (buffer, ref booleansOffset);
+                       }
+
+               }
+
+               public TermInfoReader (string term, byte [] buffer)
+               {
+                       if (buffer == null)
+                               throw new ArgumentNullException ("buffer");
+
+                       this.buffer = buffer;
+                       ReadHeader (buffer, ref booleansOffset);
+                       ReadNames (buffer, ref booleansOffset);
+               }
+
+               public string Term {
+                       get { return term; }
+               }
+
+               void ReadHeader (byte [] buffer, ref int position)
+               {
+                       short magic = GetInt16 (buffer, position);
+                       position += 2;
+                       if (magic != 282)
+                               throw new Exception (String.Format ("Magic number is wrong: {0}", magic));
+                       
+                       nameSize = GetInt16 (buffer, position);
+                       position += 2;
+                       boolSize = GetInt16 (buffer, position);
+                       position += 2;
+                       numSize = GetInt16 (buffer, position);
+                       position += 2;
+                       strOffsets = GetInt16 (buffer, position);
+                       position += 2;
+                       strSize = GetInt16 (buffer, position);
+                       position += 2;
+               }
+
+               void ReadNames (byte [] buffer, ref int position)
+               {
+                       string prev = GetString (buffer, position);
+                       position += prev.Length + 1;
+                       names = prev.Split ('|');
+               }
+
+               public bool Get (TermInfoBooleans boolean)
+               {
+                       int x = (int) boolean;
+                       if (x < 0 || boolean >= TermInfoBooleans.Last || x >= boolSize)
+                               return false;
+
+                       int offset = booleansOffset;
+                       offset += (int) boolean;
+                       return (buffer [offset] != 0);
+               }
+
+               public int Get (TermInfoNumbers number)
+               {
+                       int x = (int) number;
+                       if (x < 0 || number >= TermInfoNumbers.Last || x > numSize)
+                               return -1;
+
+                       int offset = booleansOffset + boolSize;
+                       if ((offset % 2) == 1)
+                               offset++;
+
+                       offset += ((int) number) * 2;
+                       return GetInt16 (buffer, offset);
+               }
+
+               public string Get (TermInfoStrings tstr)
+               {
+                       int x = (int) tstr;
+                       if (x < 0 || tstr >= TermInfoStrings.Last || x > strOffsets)
+                               return null;
+
+                       int offset = booleansOffset + boolSize;
+                       if ((offset % 2) == 1)
+                               offset++;
+
+                       offset += numSize * 2;
+                       int off2 = GetInt16 (buffer, offset + (int) tstr * 2);
+                       if (off2 == -1)
+                               return null;
+
+                       return GetString (buffer, offset + strOffsets * 2 + off2);
+               }
+
+               short GetInt16 (byte [] buffer, int offset)
+               {
+                       int uno = (int) buffer [offset];
+                       int dos = (int) buffer [offset + 1];
+                       if (uno == 255  && dos == 255)
+                               return -1;
+
+                       return (short) (uno + dos * 256);
+               }
+
+               string GetString (byte [] buffer, int offset)
+               {
+                       int length = 0;
+                       int off = offset;
+                       while (buffer [off++] != 0)
+                               length++;
+
+                       return Encoding.ASCII.GetString (buffer, offset, length);
+               }
+
+               internal static string Escape (string s)
+               {
+                       StringBuilder sb = new StringBuilder ();
+                       for (int i = 0; i < s.Length; i++) {
+                               char current = s [i];
+                               if (Char.IsControl (current)) {
+                                       sb.AppendFormat ("\\x{0:X2}", (int) current);
+                               } else {
+                                       sb.Append (current);
+                               }
+                       }
+
+                       return sb.ToString ();
+               }
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/TermInfoStrings.cs b/mcs/class/corlib/System/TermInfoStrings.cs
new file mode 100644 (file)
index 0000000..09f7f70
--- /dev/null
@@ -0,0 +1,431 @@
+//
+// System.TermInfoStrings
+//
+// Authors:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2005 Novell, Inc (http://www.novell.com)
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+#if NET_2_0
+namespace System {
+       enum TermInfoStrings {
+               BackTab,                // 0
+               Bell,
+               CarriageReturn,
+               ChangeScrollRegion,
+               ClearAllTabs,
+               ClearScreen,
+               ClrEol,
+               ClrEos,
+               ColumnAddress,
+               CommandCharacter,
+               CursorAddress,
+               CursorDown,
+               CursorHome,
+               CursorInvisible,
+               CursorLeft,
+               CursorMemAddress,
+               CursorNormal,
+               CursorRight,
+               CursorToLl,
+               CursorUp,
+               CursorVisible,
+               DeleteCharacter,
+               DeleteLine,
+               DisStatusLine,
+               DownHalfLine,
+               EnterAltCharsetMode,
+               EnterBlinkMode,
+               EnterBoldMode,
+               EnterCaMode,
+               EnterDeleteMode,
+               EnterDimMode,
+               EnterInsertMode,
+               EnterSecureMode,
+               EnterProtectedMode,
+               EnterReverseMode,
+               EnterStandoutMode,
+               EnterUnderlineMode,
+               EraseChars,
+               ExitAltCharsetMode,
+               ExitAttributeMode,
+               ExitCaMode,
+               ExitDeleteMode,
+               ExitInsertMode,
+               ExitStandoutMode,
+               ExitUnderlineMode,
+               FlashScreen,
+               FormFeed,
+               FromStatusLine,
+               Init1string,
+               Init2string,
+               Init3string,
+               InitFile,
+               InsertCharacter,
+               InsertLine,
+               InsertPadding,
+               KeyBackspace,
+               KeyCatab,
+               KeyClear,
+               KeyCtab,
+               KeyDc,
+               KeyDl,
+               KeyDown,
+               KeyEic,
+               KeyEol,
+               KeyEos,
+               KeyF0,
+               KeyF1,
+               KeyF10,
+               KeyF2,
+               KeyF3,
+               KeyF4,
+               KeyF5,
+               KeyF6,
+               KeyF7,
+               KeyF8,
+               KeyF9,
+               KeyHome,
+               KeyIc,
+               KeyIl,
+               KeyLeft,
+               KeyLl,
+               KeyNpage,
+               KeyPpage,
+               KeyRight,
+               KeySf,
+               KeySr,
+               KeyStab,
+               KeyUp,
+               KeypadLocal,
+               KeypadXmit,
+               LabF0,
+               LabF1,
+               LabF10,
+               LabF2,
+               LabF3,
+               LabF4,
+               LabF5,
+               LabF6,
+               LabF7,
+               LabF8,
+               LabF9,
+               MetaOff,
+               MetaOn,
+               Newline,
+               PadChar,
+               ParmDch,
+               ParmDeleteLine,
+               ParmDownCursor,
+               ParmIch,
+               ParmIndex,
+               ParmInsertLine,
+               ParmLeftCursor,
+               ParmRightCursor,
+               ParmRindex,
+               ParmUpCursor,
+               PkeyKey,
+               PkeyLocal,
+               PkeyXmit,
+               PrintScreen,
+               PrtrOff,
+               PrtrOn,
+               RepeatChar,
+               Reset1string,
+               Reset2string,
+               Reset3string,
+               ResetFile,
+               RestoreCursor,
+               RowAddress,
+               SaveCursor,
+               ScrollForward,
+               ScrollReverse,
+               SetAttributes,
+               SetTab,
+               SetWindow,
+               Tab,
+               ToStatusLine,
+               UnderlineChar,
+               UpHalfLine,
+               InitProg,
+               KeyA1,
+               KeyA3,
+               KeyB2,
+               KeyC1,
+               KeyC3,
+               PrtrNon,
+               CharPadding,
+               AcsChars,
+               PlabNorm,
+               KeyBtab,
+               EnterXonMode,
+               ExitXonMode,
+               EnterAmMode,
+               ExitAmMode,
+               XonCharacter,
+               XoffCharacter,
+               EnaAcs,
+               LabelOn,
+               LabelOff,
+               KeyBeg,
+               KeyCancel,
+               KeyClose,
+               KeyCommand,
+               KeyCopy,
+               KeyCreate,
+               KeyEnd,
+               KeyEnter,
+               KeyExit,
+               KeyFind,
+               KeyHelp,
+               KeyMark,
+               KeyMessage,
+               KeyMove,
+               KeyNext,
+               KeyOpen,
+               KeyOptions,
+               KeyPrevious,
+               KeyPrint,
+               KeyRedo,
+               KeyReference,
+               KeyRefresh,
+               KeyReplace,
+               KeyRestart,
+               KeyResume,
+               KeySave,
+               KeySuspend,
+               KeyUndo,
+               KeySbeg,
+               KeyScancel,
+               KeyScommand,
+               KeyScopy,
+               KeyScreate,
+               KeySdc,
+               KeySdl,
+               KeySelect,
+               KeySend,
+               KeySeol,
+               KeySexit,
+               KeySfind,
+               KeyShelp,
+               KeyShome,
+               KeySic,
+               KeySleft,
+               KeySmessage,
+               KeySmove,
+               KeySnext,
+               KeySoptions,
+               KeySprevious,
+               KeySprint,
+               KeySredo,
+               KeySreplace,
+               KeySright,
+               KeySrsume,
+               KeySsave,
+               KeySsuspend,
+               KeySundo,
+               ReqForInput,
+               KeyF11,
+               KeyF12,
+               KeyF13,
+               KeyF14,
+               KeyF15,
+               KeyF16,
+               KeyF17,
+               KeyF18,
+               KeyF19,
+               KeyF20,
+               KeyF21,
+               KeyF22,
+               KeyF23,
+               KeyF24,
+               KeyF25,
+               KeyF26,
+               KeyF27,
+               KeyF28,
+               KeyF29,
+               KeyF30,
+               KeyF31,
+               KeyF32,
+               KeyF33,
+               KeyF34,
+               KeyF35,
+               KeyF36,
+               KeyF37,
+               KeyF38,
+               KeyF39,
+               KeyF40,
+               KeyF41,
+               KeyF42,
+               KeyF43,
+               KeyF44,
+               KeyF45,
+               KeyF46,
+               KeyF47,
+               KeyF48,
+               KeyF49,
+               KeyF50,
+               KeyF51,
+               KeyF52,
+               KeyF53,
+               KeyF54,
+               KeyF55,
+               KeyF56,
+               KeyF57,
+               KeyF58,
+               KeyF59,
+               KeyF60,
+               KeyF61,
+               KeyF62,
+               KeyF63,
+               ClrBol,
+               ClearMargins,
+               SetLeftMargin,
+               SetRightMargin,
+               LabelFormat,
+               SetClock,
+               DisplayClock,
+               RemoveClock,
+               CreateWindow,
+               GotoWindow,
+               Hangup,
+               DialPhone,
+               QuickDial,
+               Tone,
+               Pulse,
+               FlashHook,
+               FixedPause,
+               WaitTone,
+               User0,
+               User1,
+               User2,
+               User3,
+               User4,
+               User5,
+               User6,
+               User7,
+               User8,
+               User9,
+               OrigPair,
+               OrigColors,
+               InitializeColor,
+               InitializePair,
+               SetColorPair,
+               SetForeground,
+               SetBackground,
+               ChangeCharPitch,
+               ChangeLinePitch,
+               ChangeResHorz,
+               ChangeResVert,
+               DefineChar,
+               EnterDoublewideMode,
+               EnterDraftQuality,
+               EnterItalicsMode,
+               EnterLeftwardMode,
+               EnterMicroMode,
+               EnterNearLetterQuality,
+               EnterNormalQuality,
+               EnterShadowMode,
+               EnterSubscriptMode,
+               EnterSuperscriptMode,
+               EnterUpwardMode,
+               ExitDoublewideMode,
+               ExitItalicsMode,
+               ExitLeftwardMode,
+               ExitMicroMode,
+               ExitShadowMode,
+               ExitSubscriptMode,
+               ExitSuperscriptMode,
+               ExitUpwardMode,
+               MicroColumnAddress,
+               MicroDown,
+               MicroLeft,
+               MicroRight,
+               MicroRowAddress,
+               MicroUp,
+               OrderOfPins,
+               ParmDownMicro,
+               ParmLeftMicro,
+               ParmRightMicro,
+               ParmUpMicro,
+               SelectCharSet,
+               SetBottomMargin,
+               SetBottomMarginParm,
+               SetLeftMarginParm,
+               SetRightMarginParm,
+               SetTopMargin,
+               SetTopMarginParm,
+               StartBitImage,
+               StartCharSetDef,
+               StopBitImage,
+               StopCharSetDef,
+               SubscriptCharacters,
+               SuperscriptCharacters,
+               TheseCauseCr,
+               ZeroMotion,
+               CharSetNames,
+               KeyMouse,
+               MouseInfo,
+               ReqMousePos,
+               GetMouse,
+               SetAForeground,
+               SetABackground,
+               PkeyPlab,
+               DeviceType,
+               CodeSetInit,
+               Set0DesSeq,
+               Set1DesSeq,
+               Set2DesSeq,
+               Set3DesSeq,
+               SetLrMargin,
+               SetTbMargin,
+               BitImageRepeat,
+               BitImageNewline,
+               BitImageCarriageReturn,
+               ColorNames,
+               DefineBitImageRegion,
+               EndBitImageRegion,
+               SetColorBand,
+               SetPageLength,
+               DisplayPcChar,
+               EnterPcCharsetMode,
+               ExitPcCharsetMode,
+               EnterScancodeMode,
+               ExitScancodeMode,
+               PcTermOptions,
+               ScancodeEscape,
+               AltScancodeEsc,
+               EnterHorizontalHlMode,
+               EnterLeftHlMode,
+               EnterLowHlMode,
+               EnterRightHlMode,
+               EnterTopHlMode,
+               EnterVerticalHlMode,
+               SetAAttributes,
+               SetPglenInch,           // 393
+               Last
+       }
+}
+#endif
+
index 5deb22eebb27c15f914468272baf6b943e6efecb..718783d70328e0a2a3eaf2fdc13c70716bae7957 100755 (executable)
@@ -86,6 +86,14 @@ System/Char.cs
 System/CharEnumerator.cs
 System/CLSCompliantAttribute.cs
 System/Console.cs
+System/ConsoleCancelEventArgs.cs
+System/ConsoleCancelEventHandler.cs
+System/ConsoleColor.cs
+System/ConsoleDriver.cs
+System/ConsoleKey.cs
+System/ConsoleKeyInfo.cs
+System/ConsoleModifiers.cs
+System/ConsoleSpecialKey.cs
 System/ContextBoundObject.cs
 System/ContextMarshalException.cs
 System/ContextStaticAttribute.cs
@@ -123,6 +131,7 @@ System/IApplicationDescription.cs
 System/IAsyncResult.cs
 System/ICloneable.cs
 System/IComparable.cs
+System/IConsoleDriver.cs
 System/IConvertible.cs
 System/ICustomFormatter.cs
 System/IDisposable.cs
@@ -139,6 +148,7 @@ System/InvalidCastException.cs
 System/InvalidOperationException.cs
 System/InvalidProgramException.cs
 System/IServiceProvider.cs
+System/KnownTerminals.cs
 System/LoaderOptimization.cs
 System/LoaderOptimizationAttribute.cs
 System/LocalDataStoreSlot.cs
@@ -190,6 +200,11 @@ System/StackOverflowException.cs
 System/STAThreadAttribute.cs
 System/String.cs
 System/SystemException.cs
+System/TermInfoBooleans.cs
+System/TermInfoDriver.cs
+System/TermInfoNumbers.cs
+System/TermInfoReader.cs
+System/TermInfoStrings.cs
 System/ThreadStaticAttribute.cs
 System/TimeSpan.cs
 System/TimeZone.cs