// 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;
{
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;
+
+ do {
+ c = buffer [i++];
- if (driver.Initialized){
- lock (this){
- for (int i = 0; i < count; i++) {
- try {
- char val = buffer [index + i];
- if (driver.NotifyWrite (val))
- InternalWriteChar (val);
- } catch (IOException){
+ 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) {
}
- }
- } else {
- try {
- base.Write (buffer, index, count);
- } catch (IOException){
}
}
}
{
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 {
}
}
+ 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);