2006-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 28 Sep 2006 04:34:38 +0000 (04:34 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 28 Sep 2006 04:34:38 +0000 (04:34 -0000)
* ConsoleDriver.cs:
* TermInfoDriver.cs:
* IConsoleDriver.cs:
* CStreamWriter.cs:
* ConsoleKeyInfo.cs:
* NullConsoleDriver.cs:
* Console.cs:
* CStreamReader.cs:
* WindowsConsoleDriver.cs: initial changes to handle cursor position
and screen buffers.

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

mcs/class/corlib/System/CStreamReader.cs [new file with mode: 0644]
mcs/class/corlib/System/CStreamWriter.cs [new file with mode: 0644]
mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/Console.cs
mcs/class/corlib/System/ConsoleDriver.cs
mcs/class/corlib/System/ConsoleKeyInfo.cs
mcs/class/corlib/System/IConsoleDriver.cs
mcs/class/corlib/System/NullConsoleDriver.cs [new file with mode: 0644]
mcs/class/corlib/System/TermInfoDriver.cs
mcs/class/corlib/System/WindowsConsoleDriver.cs

diff --git a/mcs/class/corlib/System/CStreamReader.cs b/mcs/class/corlib/System/CStreamReader.cs
new file mode 100644 (file)
index 0000000..69ea50c
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// System.CStreamReader
+//
+// Authors:
+//   Dietmar Maurer (dietmar@ximian.com)
+//   Miguel de Icaza (miguel@ximian.com)
+//   Dick Porter (dick@ximian.com)
+//   Sebastien Pouliot  <sebastien@ximian.com>
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+// Copyright (C) 2004-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.Text;
+using System.Runtime.InteropServices;
+
+namespace System.IO {
+       class CStreamReader : StreamReader {
+               public CStreamReader(Stream stream, Encoding encoding)
+                       : base (stream, encoding)
+               {
+               }
+
+               public override int Peek ()
+               {
+                       try {
+                               return base.Peek ();
+                       } catch (IOException) {
+                       }
+
+                       return -1;
+               }
+
+               public override int Read ()
+               {
+                       try {
+                               ConsoleKeyInfo key = Console.ReadKey ();
+                               return key.KeyChar;
+                       } catch (IOException) {
+                       }
+
+                       return(-1);
+               }
+
+               public override int Read ([In, Out] char [] dest_buffer, int index, int count)
+               {
+                       if (dest_buffer == null)
+                               throw new ArgumentNullException ("dest_buffer");
+                       if (index < 0)
+                               throw new ArgumentOutOfRangeException ("index", "< 0");
+                       if (count < 0)
+                               throw new ArgumentOutOfRangeException ("count", "< 0");
+                       // ordered to avoid possible integer overflow
+                       if (index > dest_buffer.Length - count)
+                               throw new ArgumentException ("index + count > dest_buffer.Length");
+
+                       int chars_read = 0;
+                       while (count > 0) {
+                               int c = Read ();
+                               if (c < 0)
+                                       break;
+                               chars_read++;
+                               count--;
+
+                               dest_buffer [index] = (char) c;
+                               //if (CheckEOL (dest_buffer [index++]))
+                               //      return chars_read;
+                       }
+                       return chars_read;
+               }
+
+               public override string ReadLine ()
+               {
+                       try {
+                               return ConsoleDriver.driver.ReadLine ();
+                       } catch (IOException) {
+                       }
+
+                       return null;
+               }
+
+               public override string ReadToEnd ()
+               {
+                       try {
+                               return (base.ReadToEnd ());
+                       } catch (IOException) {
+                       }
+
+                       return null;
+               }
+       }
+}
+#endif
+
diff --git a/mcs/class/corlib/System/CStreamWriter.cs b/mcs/class/corlib/System/CStreamWriter.cs
new file mode 100644 (file)
index 0000000..2417544
--- /dev/null
@@ -0,0 +1,107 @@
+//
+// System.CStreamWriter
+//
+// Authors:
+//   Dietmar Maurer (dietmar@ximian.com)
+//   Paolo Molaro (lupus@ximian.com)
+//   Dick Porter (dick@ximian.com)
+//
+// (c) 2006 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
+// 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;
+using System.Text;
+
+namespace System.IO {
+       class CStreamWriter : StreamWriter {
+               TermInfoDriver driver;
+
+               public CStreamWriter (Stream stream, Encoding encoding)
+                       : base (stream, encoding)
+               {
+                       driver = (TermInfoDriver) ConsoleDriver.driver;
+               }
+
+               public override void Write (char [] buffer, int index, int count)
+               {
+                       if (count <= 0)
+                               return;
+
+                       for (int i = 0; i < count; i++) {
+                               Write (buffer [index + i]);
+                       }
+               }
+
+               public override void Write (char val)
+               {
+                       lock (this) {
+                               try {
+                                       if (driver.NotifyWrite (val))
+                                               InternalWriteChar (val);
+                               } catch (IOException) {
+                               }
+                       }
+               }
+
+               public void WriteKey (ConsoleKeyInfo key)
+               {
+                       lock (this) {
+                               ConsoleKeyInfo copy = new ConsoleKeyInfo (key);
+                               if (driver.NotifyWrite (copy))
+                                       InternalWriteChar (copy.KeyChar);
+                       }
+               }
+
+               public void InternalWriteString (string val)
+               {
+                       try {
+                               base.Write (val);
+                       } catch (IOException) {
+                       }
+               }
+
+               public void InternalWriteChar (char val)
+               {
+                       try {
+                               base.Write (val);
+                       } catch (IOException) {
+                       }
+               }
+
+               public override void Write (char [] val)
+               {
+                       Write (val, 0, val.Length);
+               }
+
+               public override void Write (string val)
+               {
+                       if (val != null)
+                               Write (val.ToCharArray ());
+               }
+       }
+}
+#endif
+
index 6fd1055cd9283ccd2f174ee689145dd94161ddd7..7022fdb1bfbbe6b4705baa01948b789f6af6f493 100644 (file)
@@ -1,3 +1,16 @@
+2006-09-28 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * ConsoleDriver.cs:
+       * TermInfoDriver.cs:
+       * IConsoleDriver.cs:
+       * CStreamWriter.cs:
+       * ConsoleKeyInfo.cs:
+       * NullConsoleDriver.cs:
+       * Console.cs:
+       * CStreamReader.cs:
+       * WindowsConsoleDriver.cs: initial changes to handle cursor position
+       and screen buffers.
+
 2006-09-21  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * ArithmeticException.cs: Modified default message to match MS, to
index bed36804a4877993b9540f602143d248c1b8056d..d1ffae3ffccbf0558256f84179ebdf39616445bc 100644 (file)
@@ -65,7 +65,7 @@ namespace System
                        }
                }
 
-               private static TextWriter stdout;
+               internal static TextWriter stdout;
                private static TextWriter stderr;
                private static TextReader stdin;
 
@@ -104,32 +104,28 @@ namespace System
                                        inputEncoding = outputEncoding = Encoding.Default;
                        }
 
+                       stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
+                       ((StreamWriter)stderr).AutoFlush = true;
+                       stderr = TextWriter.Synchronized (stderr, true);
+
 #if NET_2_0
-/*
                        if (ConsoleDriver.IsConsole) {
-                               CStreamWriter w = new CStreamWriter (OpenStandardError (0), outputEncoding); 
-                               w.AutoFlush = true;
-                               stderr = TextWriter.Synchronized (w, true);
-
-                               w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
+                               StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
                                w.AutoFlush = true;
-                               stdout = TextWriter.Synchronized (w, true);
+                               stdout = w;
+                               stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
+                               ConsoleDriver.Init ();
                        } else {
-                       */
 #endif
-                               stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
-                               ((StreamWriter)stderr).AutoFlush = true;
-                               stderr = TextWriter.Synchronized (stderr, true);
-
                                stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
                                ((StreamWriter)stdout).AutoFlush = true;
                                stdout = TextWriter.Synchronized (stdout, true);
+                               stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
+                               stdin = TextReader.Synchronized (stdin);
 #if NET_2_0
-                       //}
+                       }
 #endif
 
-                       stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
-                       stdin = TextReader.Synchronized (stdin);
                        GC.SuppressFinalize (stdout);
                        GC.SuppressFinalize (stderr);
                        GC.SuppressFinalize (stdin);
@@ -467,7 +463,7 @@ namespace System
 #if NET_2_0
                public static int Read ()
                {
-                       if (ConsoleDriver.IsConsole) {
+                       if ((stdin is CStreamReader) && ConsoleDriver.IsConsole) {
                                return ConsoleDriver.Read ();
                        } else {
                                return stdin.Read ();
@@ -476,7 +472,7 @@ namespace System
 
                public static string ReadLine ()
                {
-                       if (ConsoleDriver.IsConsole) {
+                       if ((stdin is CStreamReader) && ConsoleDriver.IsConsole) {
                                return ConsoleDriver.ReadLine ();
                        } else {
                                return stdin.ReadLine ();
index d2b552d84119aa1d737ebc6fa44052c89e342ca4..af50fb8cfa0e4f81fc38ad5ca7862c4e240c35f5 100644 (file)
@@ -33,13 +33,15 @@ using System.Runtime.CompilerServices;
 
 namespace System {
        class ConsoleDriver {
-               static IConsoleDriver driver;
+               internal static IConsoleDriver driver;
                static bool is_console;
                static bool called_isatty;
 
                static ConsoleDriver ()
                {
-                       if (Environment.IsRunningOnWindows) {
+                       if (!IsConsole) {
+                               driver = new NullConsoleDriver ();
+                       } else if (Environment.IsRunningOnWindows) {
                                driver = new WindowsConsoleDriver ();
                        } else {
                                driver = new TermInfoDriver (Environment.GetEnvironmentVariable ("TERM"));
@@ -180,6 +182,11 @@ namespace System {
                                        targetLeft, targetTop, sourceChar, sourceForeColor, sourceBackColor);
                }
 
+               public static void Init ()
+               {
+                       driver.Init ();
+               }
+
                public static int Read ()
                {
                        return ReadKey (false).KeyChar;
index 8a05b302fd7fe73e40bd14e7609648b2f6b233b9..43311b5d6f67d43d6707ffa1220a2d52f0477310 100644 (file)
@@ -31,6 +31,7 @@
 namespace System {
        [Serializable]
        public struct ConsoleKeyInfo {
+               internal static ConsoleKeyInfo Empty = new ConsoleKeyInfo ('\0', 0, false, false, false);
                ConsoleKey key;
                char keychar;
                ConsoleModifiers modifiers;
index 2c6bde30bfbe812be9ff073757d2a26f4c973b38..a51f11fdee7cb80519dab93fa29171a84bf68d06 100644 (file)
@@ -51,6 +51,7 @@ namespace System {
                int WindowTop { get; set; }
                int WindowWidth { get; set; }
 
+               void Init ();
                void Beep (int frequency, int duration);
                void Clear ();
                void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
diff --git a/mcs/class/corlib/System/NullConsoleDriver.cs b/mcs/class/corlib/System/NullConsoleDriver.cs
new file mode 100644 (file)
index 0000000..49b5e6b
--- /dev/null
@@ -0,0 +1,184 @@
+//
+// System.NullConsoleDriver
+//
+// Author:
+//     Gonzalo Paniagua Javier (gonzalo@ximian.com)
+//
+// (C) 2006 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.Runtime.InteropServices;
+using System.Text;
+namespace System {
+       class NullConsoleDriver : IConsoleDriver {
+               public ConsoleColor BackgroundColor {
+                       get { return ConsoleColor.Black; }
+                       set {
+                       }
+               }
+
+               public int BufferHeight {
+                       get { return 0; }
+                       set {}
+               }
+
+               public int BufferWidth {
+                       get { return 0; }
+                       set {}
+               }
+
+               public bool CapsLock {
+                       get { return false; }
+               }
+
+               public int CursorLeft {
+                       get { return 0; }
+                       set {}
+               }
+
+               public int CursorSize {
+                       get { return 0; }
+                       set { }
+               }
+
+               public int CursorTop {
+                       get { return 0; }
+                       set {}
+               }
+
+               public bool CursorVisible {
+                       get { return false; }
+                       set {}
+               }
+
+               public bool Echo { // not really used on windows
+                       get { return true; }
+                       set {}
+               }
+
+               public ConsoleColor ForegroundColor {
+                       get { return ConsoleColor.Black; }
+                       set {}
+               }
+
+               public bool KeyAvailable {
+                       get { return false; } // FIXME: throw?
+               }
+
+               public bool Initialized {
+                       get { return true; }
+               }
+
+               public int LargestWindowHeight {
+                       get { return 0; }
+               }
+
+               public int LargestWindowWidth {
+                       get { return 0; }
+               }
+
+               public bool NumberLock {
+                       get { return false; }
+               }
+
+               public string Title {
+                       get { return ""; }
+                       set {}
+               }
+
+               public bool TreatControlCAsInput {
+                       get { return false; }
+                       set {}
+               }
+
+               public int WindowHeight {
+                       get { return 0; }
+                       set {}
+               }
+
+               public int WindowLeft {
+                       get { return 0; }
+                       set {}
+               }
+
+               public int WindowTop {
+                       get { return 0; }
+                       set {}
+               }
+
+               public int WindowWidth {
+                       get { return 0; }
+                       set {}
+               }
+
+               public void Beep (int frequency, int duration)
+               {
+               }
+
+               public void Clear ()
+               {
+               }
+
+               public void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
+                                       int targetLeft, int targetTop, Char sourceChar,
+                                       ConsoleColor sourceForeColor, ConsoleColor sourceBackColor)
+               {
+               }
+
+               public void Init ()
+               {
+               }
+
+               public string ReadLine ()
+               {
+                       return null;
+               }
+
+               public ConsoleKeyInfo ReadKey (bool intercept)
+               {
+                       return ConsoleKeyInfo.Empty;
+               }
+
+               public void ResetColor ()
+               {
+               }
+
+               public void SetBufferSize (int width, int height)
+               {
+               }
+
+               public void SetCursorPosition (int left, int top)
+               {
+               }
+
+               public void SetWindowPosition (int left, int top)
+               {
+               }
+
+               public void SetWindowSize (int width, int height)
+               {
+               }
+       }
+}
+#endif
+
index c0c13d474fd0bbc1319087d9e32edee41a9342bb..1be77b5c40a932d4b2ef7c2134a027de40c9d7b1 100644 (file)
@@ -31,6 +31,7 @@
 using System.Collections;
 using System.IO;
 using System.Text;
+using System.Runtime.InteropServices;
 namespace System {
        class TermInfoDriver : IConsoleDriver {
                static string [] locations = { "/etc/terminfo", "/usr/share/terminfo", "/usr/lib/terminfo" };
@@ -46,9 +47,8 @@ namespace System {
                string clear;
                string bell;
                string term;
-               Stream stdout;
                Stream stdin;
-               byte verase;
+               internal byte verase;
                byte vsusp;
                byte intr;
 
@@ -111,7 +111,7 @@ namespace System {
                        if (str == null)
                                return;
 
-                       Console.Write (str);
+                       ((CStreamWriter) Console.stdout).InternalWriteString (str);
                }
 
                public TermInfoDriver ()
@@ -135,15 +135,13 @@ namespace System {
 
                        if (reader == null)
                                reader = new TermInfoReader (term, KnownTerminals.ansi);
-
-                       Init ();
                }
 
                public bool Initialized {
                        get { return inited; }
                }
                
-               void Init ()
+               public void Init ()
                {
                        if (inited)
                                return;
@@ -174,7 +172,6 @@ namespace System {
                        if (!ConsoleDriver.TtySetup (endString, out verase, out vsusp, out intr))
                                throw new IOException ("Error initializing terminal.");
 
-                       stdout = Console.OpenStandardOutput (0);
                        stdin = Console.OpenStandardInput (0);
                        clear = reader.Get (TermInfoStrings.ClearScreen);
                        bell = reader.Get (TermInfoStrings.Bell);
@@ -255,6 +252,284 @@ namespace System {
                        return 0;
                }
 
+               public bool NotifyWrite (ConsoleKeyInfo key)
+               {
+                       if (key.Key >= ConsoleKey.A && key.Key <= ConsoleKey.Z) {
+                               cursorLeft++;
+                               if (cursorLeft >= WindowWidth) {
+                                       cursorTop++;
+                                       cursorLeft = 0;
+                                       if (cursorTop >= WindowHeight) {
+                                               cursorTop--;
+                                       }
+                               }
+                               return true;
+                       }       
+                       switch (key.Key) {
+                       case ConsoleKey.Backspace:
+                               if (cursorLeft > 0) {
+                                       cursorLeft--;
+                                       SetCursorPosition (cursorLeft, cursorTop);
+                                       WriteConsole (" ");
+                                       SetCursorPosition (cursorLeft, cursorTop);
+                               }
+                               return false;
+                       case ConsoleKey.Tab:
+                               break;
+                       case ConsoleKey.Clear:
+                               break;
+                       case ConsoleKey.Enter:
+                               break;
+                       case ConsoleKey.Pause:
+                               break;
+                       case ConsoleKey.Escape:
+                               break;
+                       case ConsoleKey.Spacebar:
+                               break;
+                       case ConsoleKey.PageUp:
+                               break;
+                       case ConsoleKey.PageDown:
+                               break;
+                       case ConsoleKey.End:
+                               break;
+                       case ConsoleKey.Home:
+                               break;
+                       case ConsoleKey.LeftArrow:
+                               break;
+                       case ConsoleKey.UpArrow:
+                               break;
+                       case ConsoleKey.RightArrow:
+                               break;
+                       case ConsoleKey.DownArrow:
+                               break;
+                       case ConsoleKey.Select:
+                               break;
+                       case ConsoleKey.Print:
+                               break;
+                       case ConsoleKey.Execute:
+                               break;
+                       case ConsoleKey.PrintScreen:
+                               break;
+                       case ConsoleKey.Insert:
+                               break;
+                       case ConsoleKey.Delete:
+                               break;
+                       case ConsoleKey.Help:
+                               break;
+                       case ConsoleKey.D0:
+                               break;
+                       case ConsoleKey.D1:
+                               break;
+                       case ConsoleKey.D2:
+                               break;
+                       case ConsoleKey.D3:
+                               break;
+                       case ConsoleKey.D4:
+                               break;
+                       case ConsoleKey.D5:
+                               break;
+                       case ConsoleKey.D6:
+                               break;
+                       case ConsoleKey.D7:
+                               break;
+                       case ConsoleKey.D8:
+                               break;
+                       case ConsoleKey.D9:
+                               break;
+                       case ConsoleKey.LeftWindows:
+                               break;
+                       case ConsoleKey.RightWindows:
+                               break;
+                       case ConsoleKey.Applications:
+                               break;
+                       case ConsoleKey.Sleep:
+                               break;
+                       case ConsoleKey.NumPad0:
+                               break;
+                       case ConsoleKey.NumPad1:
+                               break;
+                       case ConsoleKey.NumPad2:
+                               break;
+                       case ConsoleKey.NumPad3:
+                               break;
+                       case ConsoleKey.NumPad4:
+                               break;
+                       case ConsoleKey.NumPad5:
+                               break;
+                       case ConsoleKey.NumPad6:
+                               break;
+                       case ConsoleKey.NumPad7:
+                               break;
+                       case ConsoleKey.NumPad8:
+                               break;
+                       case ConsoleKey.NumPad9:
+                               break;
+                       case ConsoleKey.Multiply:
+                               break;
+                       case ConsoleKey.Add:
+                               break;
+                       case ConsoleKey.Separator:
+                               break;
+                       case ConsoleKey.Subtract:
+                               break;
+                       case ConsoleKey.Decimal:
+                               break;
+                       case ConsoleKey.Divide:
+                               break;
+                       case ConsoleKey.F1:
+                               break;
+                       case ConsoleKey.F2:
+                               break;
+                       case ConsoleKey.F3:
+                               break;
+                       case ConsoleKey.F4:
+                               break;
+                       case ConsoleKey.F5:
+                               break;
+                       case ConsoleKey.F6:
+                               break;
+                       case ConsoleKey.F7:
+                               break;
+                       case ConsoleKey.F8:
+                               break;
+                       case ConsoleKey.F9:
+                               break;
+                       case ConsoleKey.F10:
+                               break;
+                       case ConsoleKey.F11:
+                               break;
+                       case ConsoleKey.F12:
+                               break;
+                       case ConsoleKey.F13:
+                               break;
+                       case ConsoleKey.F14:
+                               break;
+                       case ConsoleKey.F15:
+                               break;
+                       case ConsoleKey.F16:
+                               break;
+                       case ConsoleKey.F17:
+                               break;
+                       case ConsoleKey.F18:
+                               break;
+                       case ConsoleKey.F19:
+                               break;
+                       case ConsoleKey.F20:
+                               break;
+                       case ConsoleKey.F21:
+                               break;
+                       case ConsoleKey.F22:
+                               break;
+                       case ConsoleKey.F23:
+                               break;
+                       case ConsoleKey.F24:
+                               break;
+                       case ConsoleKey.BrowserBack:
+                               break;
+                       case ConsoleKey.BrowserForward:
+                               break;
+                       case ConsoleKey.BrowserRefresh:
+                               break;
+                       case ConsoleKey.BrowserStop:
+                               break;
+                       case ConsoleKey.BrowserSearch:
+                               break;
+                       case ConsoleKey.BrowserFavorites:
+                               break;
+                       case ConsoleKey.BrowserHome:
+                               break;
+                       case ConsoleKey.VolumeMute:
+                               break;
+                       case ConsoleKey.VolumeDown:
+                               break;
+                       case ConsoleKey.VolumeUp:
+                               break;
+                       case ConsoleKey.MediaNext:
+                               break;
+                       case ConsoleKey.MediaPrevious:
+                               break;
+                       case ConsoleKey.MediaStop:
+                               break;
+                       case ConsoleKey.MediaPlay:
+                               break;
+                       case ConsoleKey.LaunchMail:
+                               break;
+                       case ConsoleKey.LaunchMediaSelect:
+                               break;
+                       case ConsoleKey.LaunchApp1:
+                               break;
+                       case ConsoleKey.LaunchApp2:
+                               break;
+                       case ConsoleKey.Oem1:
+                               break;
+                       case ConsoleKey.OemPlus:
+                               break;
+                       case ConsoleKey.OemComma:
+                               break;
+                       case ConsoleKey.OemMinus:
+                               break;
+                       case ConsoleKey.OemPeriod:
+                               break;
+                       case ConsoleKey.Oem2:
+                               break;
+                       case ConsoleKey.Oem3:
+                               break;
+                       case ConsoleKey.Oem4:
+                               break;
+                       case ConsoleKey.Oem5:
+                               break;
+                       case ConsoleKey.Oem6:
+                               break;
+                       case ConsoleKey.Oem7:
+                               break;
+                       case ConsoleKey.Oem8:
+                               break;
+                       case ConsoleKey.Oem102:
+                               break;
+                       case ConsoleKey.Process:
+                               break;
+                       case ConsoleKey.Packet:
+                               break;
+                       case ConsoleKey.Attention:
+                               break;
+                       case ConsoleKey.CrSel:
+                               break;
+                       case ConsoleKey.ExSel:
+                               break;
+                       case ConsoleKey.EraseEndOfFile:
+                               break;
+                       case ConsoleKey.Play:
+                               break;
+                       case ConsoleKey.Zoom:
+                               break;
+                       case ConsoleKey.NoName:
+                               break;
+                       case ConsoleKey.Pa1:
+                               break;
+                       case ConsoleKey.OemClear:
+                               break;
+                       default:
+                               return true;
+                       }
+                       return true;
+               }
+
+               public bool NotifyWrite (char val)
+               {
+                       if (val == verase) {
+                               string str = reader.Get (TermInfoStrings.EraseChars);
+                               if (str != null) {
+                                       Console.Error.WriteLine ("{0}", TermInfoReader.Escape (str));
+                               } else {
+                                       Console.Error.WriteLine ("FUCK");
+                               }
+                               return false;
+                       } else {
+                               //TODO: compute cursor position
+                               return true;
+                       }
+               }
+
                public ConsoleColor BackgroundColor {
                        get { return bgcolor; }
                        set {
@@ -354,7 +629,6 @@ namespace System {
 
                public int CursorLeft {
                        get {
-                               GetCursorPosition ();
                                return cursorLeft;
                        }
                        set {
@@ -365,7 +639,6 @@ namespace System {
 
                public int CursorTop {
                        get {
-                               GetCursorPosition ();
                                return cursorTop;
                        }
                        set {
@@ -398,7 +671,6 @@ namespace System {
                                        return;
 
                                noEcho = !value;
-                               ConsoleDriver.SetEcho (value);
                        }
                }
 
@@ -637,13 +909,14 @@ namespace System {
                                Echo  = true;
                        StringBuilder builder = new StringBuilder ();
                        bool exit = false;
+                       CStreamWriter writer = (CStreamWriter) Console.stdout;
                        do {
                                ConsoleKeyInfo key = ReadKeyInternal ();
                                char c = key.KeyChar;
                                exit = (c == '\n');
                                if (!exit)
                                        builder.Append (c);
-                               stdout.WriteByte ((byte) c);
+                               writer.WriteKey (key);
                        } while (!exit);
                        if (prevEcho == false)
                                Echo = prevEcho;
index b9592116785b45f20882e45a2639f4dc883b4597..983c91e94649e903852610de00a9fd544b968a2c 100644 (file)
@@ -456,6 +456,10 @@ namespace System {
                                throw new ArgumentException (String.Empty, "Cannot write to the specified coordinates.");
                }
 
+               public void Init ()
+               {
+               }
+
                public string ReadLine ()
                {
                        StringBuilder builder = new StringBuilder ();