public override void Write (char [] buffer, int index, int count)
{
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.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) {
}
}
}
}