download ConsoleDriver.cs
Language: C#
Copyright: (C) 2005 Novell, Inc (http://www.novell.com)
LOC: 160
Project Info
mcs
Server: Mono
Type: svn
...cs\mcs\class\corlib\System\
   __ComObject.cs
   _AppDomain.cs
   ...ssViolationException.cs
   Action.cs
   ActivationContext.cs
   Activator.cs
   AppDomain.cs
   AppDomainInitializer.cs
   AppDomainManager.cs
   AppDomainSetup.cs
   ...ainUnloadedException.cs
   ApplicationException.cs
   ApplicationId.cs
   ApplicationIdentity.cs
   ArgIterator.cs
   ArgumentException.cs
   ArgumentNullException.cs
   ...tOutOfRangeException.cs
   ArithmeticException.cs
   Array.cs
   ArraySegment.cs
   ...ypeMismatchException.cs
   AssemblyLoadEventArgs.cs
   ...mblyLoadEventHandler.cs
   AsyncCallback.cs
   Attribute.cs
   AttributeTargets.cs
   AttributeUsageAttribute.cs
   BadImageFormatException.cs
   Base64FormattingOptions.cs
   BitConverter.cs
   Boolean.cs
   Buffer.cs
   Byte.cs
   ...adAppDomainException.cs
   Char.cs
   CharEnumerator.cs
   CLSCompliantAttribute.cs
   Comparison.cs
   Console.cs
   ConsoleCancelEventArgs.cs
   ...leCancelEventHandler.cs
   ConsoleColor.cs
   ConsoleDriver.cs
   ConsoleKey.cs
   ConsoleKeyInfo.cs
   ConsoleModifiers.cs
   ConsoleSpecialKey.cs
   ContextBoundObject.cs
   ContextMarshalException.cs
   ContextStaticAttribute.cs
   Convert.cs
   Converter.cs
   CrossAppDomainDelegate.cs
   DataMisalignedException.cs
   DateTime.cs
   DateTimeKind.cs
   DayOfWeek.cs
   DBNull.cs
   Decimal.cs
   Delegate.cs
   ...eSerializationHolder.cs
   DivideByZeroException.cs
   DllNotFoundException.cs
   ...rInitializationFlags.cs
   Double.cs
   ...eWaitObjectException.cs
   ...intNotFoundException.cs
   Enum.cs
   Environment.cs
   ...onmentVariableTarget.cs
   EventArgs.cs
   EventHandler.cs
   Exception.cs
   ...utionEngineException.cs
   FieldAccessException.cs
   FlagsAttribute.cs
   FormatException.cs
   GC.cs
   Guid.cs
   IAppDomainSetup.cs
   IApplicationDescription.cs
   IAsyncResult.cs
   ICloneable.cs
   IComparable.cs
   IConsoleDriver.cs
   IConvertible.cs
   ICustomFormatter.cs
   IDisposable.cs
   IEquatable.cs
   IFormatProvider.cs
   IFormattable.cs
   IHostContext.cs
   ...xOutOfRangeException.cs
   Int16.cs
   Int32.cs
   Int64.cs
   IntPtr.cs
   INullableValue.cs
   InvalidCastException.cs
   ...idOperationException.cs
   InvalidProgramException.cs
   IServiceProvider.cs
   KnownTerminals.cs
   LoaderOptimization.cs
   ...ptimizationAttribute.cs
   LocalDataStoreSlot.cs
   MarshalByRefObject.cs
   Math.cs
   MemberAccessException.cs
   MethodAccessException.cs
   MidpointRounding.cs
   MissingFieldException.cs
   MissingMemberException.cs
   MissingMethodException.cs
   ModuleHandle.cs
   MonoAsyncCall.cs
   MonoCustomAttrs.cs
   MonoType.cs
   MTAThreadAttribute.cs
   MulticastDelegate.cs
   ...otSupportedException.cs
   NonSerializedAttribute.cs
   NotCancelableException.cs
   ...initeNumberException.cs
   NotImplementedException.cs
   NotSupportedException.cs
   Nullable.cs
   NullReferenceException.cs
   NumberFormatter.cs
   Object.cs
   ObjectDisposedException.cs
   ObsoleteAttribute.cs
   OperatingSystem.cs
   ...ionCanceledException.cs
   OutOfMemoryException.cs
   OverflowException.cs
   ParamArrayAttribute.cs
   PlatformID.cs
   ...otSupportedException.cs
   Predicate.cs
   Random.cs
   RankException.cs
   ResolveEventArgs.cs
   ResolveEventHandler.cs
   RuntimeArgumentHandle.cs
   RuntimeFieldHandle.cs
   RuntimeMethodHandle.cs
   RuntimeTypeHandle.cs
   SByte.cs
   SerializableAttribute.cs
   Single.cs
   StackOverflowException.cs
   STAThreadAttribute.cs
   String.cs
   StringComparer.cs
   StringComparison.cs
   StringSplitOptions.cs
   SystemException.cs
   TermInfoBooleans.cs
   TermInfoDriver.cs
   TermInfoNumbers.cs
   TermInfoReader.cs
   TermInfoStrings.cs
   ThreadStaticAttribute.cs
   TimeoutException.cs
   TimeSpan.cs
   TimeZone.cs
   Type.cs
   TypeCode.cs
   TypedReference.cs
   ...tializationException.cs
   TypeLoadException.cs
   TypeUnloadedException.cs
   UInt16.cs
   UInt32.cs
   UInt64.cs
   UIntPtr.cs
   ...rizedAccessException.cs
   ...edExceptionEventArgs.cs
   ...xceptionEventHandler.cs
   ...ySerializationHolder.cs
   ValueType.cs
   Variant.cs
   Version.cs
   Void.cs
   WeakReference.cs
   WindowsConsoleDriver.cs

//
// 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 ()
		{
			if (Environment.IsRunningOnWindows) {
				driver = new WindowsConsoleDriver ();
			} else {
				driver = new TermInfoDriver (Environment.GetEnvironmentVariable ("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;
			}
		}

		public static int BufferHeight {
			get { return driver.BufferHeight; }
			set { driver.BufferHeight = value; }
		}

		public static int BufferWidth {
			get { return driver.BufferWidth; }
			set { driver.BufferWidth = value; }
		}

		public static bool CapsLock {
			get { return driver.CapsLock; }
		}

		public static int CursorLeft {
			get { return driver.CursorLeft; }
			set { driver.CursorLeft = value; }
		}

		public static int CursorSize {
			get { return driver.CursorSize; }
			set { driver.CursorSize = value; }
		}

		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;
			}
		}

		public static int LargestWindowHeight {
			get { return driver.LargestWindowHeight; }
		}

		public static int LargestWindowWidth {
			get { return driver.LargestWindowWidth; }
		}

		public static bool NumberLock {
			get { return driver.NumberLock; }
		}

		public static string Title {
			get { return driver.Title; }
			set { driver.Title = value; }
		}

		public static bool TreatControlCAsInput {
			get { return driver.TreatControlCAsInput; }
			set { driver.TreatControlCAsInput = value; }
		} 

		public static int WindowHeight {
			get { return driver.WindowHeight; }
			set { driver.WindowHeight = value; }
		}

		public static int WindowLeft {
			get { return driver.WindowLeft; }
			set { driver.WindowLeft = value; }
		}

		public static int WindowTop {
			get { return driver.WindowTop; }
			set { driver.WindowTop = value; }
		}

		public static int WindowWidth {
			get { return driver.WindowWidth; }
			set { driver.WindowWidth = value; }
		}

		public static void Beep (int frequency, int duration)
		{
			driver.Beep (frequency, duration);
		}
		
		public static void Clear ()
		{
			driver.Clear ();
		}

		public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
					int targetLeft, int targetTop)
		{
			MoveBufferArea (sourceLeft, sourceTop, sourceWidth, sourceHeight,
					targetLeft, targetTop, ' ', 0, 0);
		}

		public static void MoveBufferArea (int sourceLeft, int sourceTop, int sourceWidth, int sourceHeight,
					int targetLeft, int targetTop, char sourceChar,
					ConsoleColor sourceForeColor, ConsoleColor sourceBackColor)
		{
			driver.MoveBufferArea (sourceLeft, sourceTop, sourceWidth, sourceHeight,
					targetLeft, targetTop, sourceChar, sourceForeColor, sourceBackColor);
		}

		public static ConsoleKeyInfo ReadKey (bool intercept)
		{
			return driver.ReadKey (intercept);
		}

		public static void ResetColor ()
		{
			driver.ResetColor ();
		}

		public static void SetBufferSize (int width, int height)
		{
			driver.SetBufferSize (width, height);
		}

		public static void SetCursorPosition (int left, int top)
		{
			driver.SetCursorPosition (left, top);
		}

		public static void SetWindowPosition (int left, int top)
		{
			driver.SetWindowPosition (left, top);
		}

		public static void SetWindowSize (int width, int height)
		{
			driver.SetWindowSize (width, 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);

		[MethodImplAttribute(MethodImplOptions.InternalCall)]
		internal static extern bool GetTtySize (IntPtr handle, out int width, out int height);
	}
}
#endif

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us