X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2Fcorlib%2FSystem%2FCStreamWriter.cs;h=85436f8be30a8f46802e781b6ad687e44fff7e9a;hb=25981a0d42819c70496ee1a2a0622e0c4e7c6019;hp=24175444e43bd2b8e4b87987f02a405ed20fb49c;hpb=2007998771b1c4d9e762943676d7959daaf74385;p=mono.git diff --git a/mcs/class/corlib/System/CStreamWriter.cs b/mcs/class/corlib/System/CStreamWriter.cs index 24175444e43..85436f8be30 100644 --- a/mcs/class/corlib/System/CStreamWriter.cs +++ b/mcs/class/corlib/System/CStreamWriter.cs @@ -31,7 +31,7 @@ // 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 +#if !NET_2_1 using System; using System.Text; @@ -49,9 +49,52 @@ namespace System.IO { { if (count <= 0) return; + + if (!driver.Initialized) { + try { + base.Write (buffer, index, count); + } catch (IOException) { + } + + return; + } + + lock (this) { + int last = index + count; + int i = index; + int n = 0; + char c; - for (int i = 0; i < count; i++) { - Write (buffer [index + i]); + do { + c = buffer [i++]; + + if (driver.IsSpecialKey (c)) { + // flush what we have + if (n > 0) { + try { + base.Write (buffer, index, n); + } catch (IOException) { + } + + n = 0; + } + + // write the special key + driver.WriteSpecialKey (c); + + index = i; + } else { + n++; + } + } while (i < last); + + if (n > 0) { + // write out the remainder of the buffer + try { + base.Write (buffer, index, n); + } catch (IOException) { + } + } } } @@ -59,22 +102,26 @@ namespace System.IO { { lock (this) { try { - if (driver.NotifyWrite (val)) + if (driver.IsSpecialKey (val)) + driver.WriteSpecialKey (val); + else InternalWriteChar (val); } catch (IOException) { } } } - +/* public void WriteKey (ConsoleKeyInfo key) { lock (this) { ConsoleKeyInfo copy = new ConsoleKeyInfo (key); - if (driver.NotifyWrite (copy)) + if (driver.IsSpecialKey (copy)) + driver.WriteSpecialKey (copy); + else InternalWriteChar (copy.KeyChar); } } - +*/ public void InternalWriteString (string val) { try { @@ -91,6 +138,14 @@ namespace System.IO { } } + public void InternalWriteChars (char [] buffer, int n) + { + try { + base.Write (buffer, 0, n); + } catch (IOException) { + } + } + public override void Write (char [] val) { Write (val, 0, val.Length); @@ -98,8 +153,18 @@ namespace System.IO { public override void Write (string val) { - if (val != null) + if (val == null) + return; + + if (driver.Initialized) Write (val.ToCharArray ()); + else { + try { + base.Write (val); + } catch (IOException){ + + } + } } } }