Inheritance: StreamWriter
Exemplo n.º 1
0
		public TermInfoDriver (string term)
		{
#if DEBUG
			File.Delete ("console.log");
			logger = new StreamWriter (File.OpenWrite ("console.log"));
#endif
			this.term = term;

			string filename = SearchTerminfo (term);
			if (filename != null)
				reader = new TermInfoReader (term, filename);
			else {
				// fallbacks
				if (term == "xterm") {
					reader = new TermInfoReader (term, KnownTerminals.xterm);
				} else if (term == "linux") {
					reader = new TermInfoReader (term, KnownTerminals.linux);
				}
			}

			if (reader == null)
				reader = new TermInfoReader (term, KnownTerminals.ansi);

			if (!(Console.stdout is CStreamWriter)) {
				// Application set its own stdout, we need a reference to the real stdout
				stdout = new CStreamWriter (Console.OpenStandardOutput (0), Console.OutputEncoding, false);
				((StreamWriter) stdout).AutoFlush = true;
			} else {
				stdout = (CStreamWriter) Console.stdout;
			}
		}
Exemplo n.º 2
0
		static void SetupStreams (Encoding inputEncoding, Encoding outputEncoding)
		{
#if !NET_2_1
			if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
				StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stdout = TextWriter.Synchronized (w, true);

				w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stderr = TextWriter.Synchronized (w, true);
				
				stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
			} else {
#endif
#if MONOTOUCH
				stdout = new NSLogWriter ();
#else
				stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
				((StreamWriter)stdout).AutoFlush = true;
#endif
				stdout = TextWriter.Synchronized (stdout, true);

#if MONOTOUCH
				stderr = new NSLogWriter ();
#else
				stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
				((StreamWriter)stderr).AutoFlush = true;
#endif
				stderr = TextWriter.Synchronized (stderr, true);

				stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
				stdin = TextReader.Synchronized (stdin);
#if !NET_2_1
			}
#endif

#if NET_4_5 && !MOBILE
			console_stderr = stderr;
			console_stdout = stdout;
			console_stdin = stdin;
#endif

#if MONODROID
			if (LogcatTextWriter.IsRunningOnAndroid ()) {
				stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
				stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
			}
#endif  // MONODROID

			GC.SuppressFinalize (stdout);
			GC.SuppressFinalize (stderr);
			GC.SuppressFinalize (stdin);
		}
Exemplo n.º 3
0
		static void SetupStreams (Encoding inputEncoding, Encoding outputEncoding)
		{
#if !NET_2_1
			if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
				StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stdout = TextWriter.Synchronized (w, true);

				w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stderr = TextWriter.Synchronized (w, true);
				
				stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
			} else {
#endif
// FULL_AOT_RUNTIME is used (instead of MONOTOUCH) since we only want this code when running on 
// iOS (simulator or devices) and *not* when running tools (e.g. btouch #12179) that needs to use 
// the mscorlib.dll shipped with Xamarin.iOS
#if FULL_AOT_RUNTIME
				stdout = new NSLogWriter ();
#else
				stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
				((StreamWriter)stdout).AutoFlush = true;
#endif
				stdout = TextWriter.Synchronized (stdout, true);

#if FULL_AOT_RUNTIME
				stderr = new NSLogWriter ();
#else
				stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
				((StreamWriter)stderr).AutoFlush = true;
#endif
				stderr = TextWriter.Synchronized (stderr, true);

				stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
				stdin = TextReader.Synchronized (stdin);
#if !NET_2_1
			}
#endif

#if NET_4_5 && !MOBILE
			console_stderr = stderr;
			console_stdout = stdout;
			console_stdin = stdin;
#endif

#if MONODROID
			if (LogcatTextWriter.IsRunningOnAndroid ()) {
				stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
				stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
			}
#endif  // MONODROID

			GC.SuppressFinalize (stdout);
			GC.SuppressFinalize (stderr);
			GC.SuppressFinalize (stdin);
		}
		static Console ()
		{
#if NET_2_1
			Encoding inputEncoding;
			Encoding outputEncoding;
#endif

			if (Environment.IsRunningOnWindows) {
				//
				// On Windows, follow the Windows tradition
				//
#if NET_2_1
				// should never happen since Moonlight does not run on windows
				inputEncoding = outputEncoding = Encoding.Default;
#else			
				try {
					inputEncoding = Encoding.GetEncoding (WindowsConsole.GetInputCodePage ());
					outputEncoding = Encoding.GetEncoding (WindowsConsole.GetOutputCodePage ());
					// ArgumentException and NotSupportedException can be thrown as well
				} catch {
					// FIXME: I18N assemblies are not available when compiling mcs
					// Use Latin 1 as it is fast and UTF-8 is never used as console code page
					inputEncoding = outputEncoding = Encoding.Default;
				}
#endif
			} else {
				//
				// On Unix systems (128), do not output the
				// UTF-8 ZWNBSP (zero-width non-breaking space).
				//
				int code_page = 0;
				Encoding.InternalCodePage (ref code_page);

				if (code_page != -1 && ((code_page & 0x0fffffff) == 3 // UTF8Encoding.UTF8_CODE_PAGE
					|| ((code_page & 0x10000000) != 0)))
					inputEncoding = outputEncoding = Encoding.UTF8Unmarked;
				else
					inputEncoding = outputEncoding = Encoding.Default;
			}

			stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
			((StreamWriter)stderr).AutoFlush = true;
			stderr = TextWriter.Synchronized (stderr, true);

#if !NET_2_1
			if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
				StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stdout = TextWriter.Synchronized (w, true);
				stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
			} else {
#endif
				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_1
			}
#endif

			GC.SuppressFinalize (stdout);
			GC.SuppressFinalize (stderr);
			GC.SuppressFinalize (stdin);
		}
Exemplo n.º 5
0
		static void SetupStreams (Encoding inputEncoding, Encoding outputEncoding)
		{
#if !NET_2_1
			if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
				StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stdout = TextWriter.Synchronized (w, true);

				w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stderr = TextWriter.Synchronized (w, true);
				
				stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
			} else {
#endif
#if FULL_AOT_RUNTIME
				Type nslogwriter = Type.GetType ("MonoTouch.Foundation.NSLogWriter, monotouch, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
				stdout = (TextWriter) Activator.CreateInstance (nslogwriter);
#else
				stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
				((StreamWriter)stdout).AutoFlush = true;
#endif
				stdout = TextWriter.Synchronized (stdout, true);

#if FULL_AOT_RUNTIME
				stderr = (TextWriter) Activator.CreateInstance (nslogwriter);
#else
				stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
				((StreamWriter)stderr).AutoFlush = true;
#endif
				stderr = TextWriter.Synchronized (stderr, true);

				stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
				stdin = TextReader.Synchronized (stdin);
#if !NET_2_1
			}
#endif

#if NET_4_5 && !MOBILE
			console_stderr = stderr;
			console_stdout = stdout;
			console_stdin = stdin;
#endif

#if MONODROID
			if (LogcatTextWriter.IsRunningOnAndroid ()) {
				stdout = TextWriter.Synchronized (new LogcatTextWriter ("mono-stdout", stdout));
				stderr = TextWriter.Synchronized (new LogcatTextWriter ("mono-stderr", stderr));
			}
#endif  // MONODROID

			GC.SuppressFinalize (stdout);
			GC.SuppressFinalize (stderr);
			GC.SuppressFinalize (stdin);
		}
Exemplo n.º 6
0
		static void SetupStreams (Encoding inputEncoding, Encoding outputEncoding)
		{
			stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
			((StreamWriter)stderr).AutoFlush = true;
			stderr = TextWriter.Synchronized (stderr, true);

#if !NET_2_1
			if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
				StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
				w.AutoFlush = true;
				stdout = TextWriter.Synchronized (w, true);
				stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
			} else {
#endif
				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_1
			}
#endif

#if NET_4_5
			console_stderr = stderr;
			console_stdout = stdout;
			console_stdin = stdin;
#endif

			GC.SuppressFinalize (stdout);
			GC.SuppressFinalize (stderr);
			GC.SuppressFinalize (stdin);
		}