+ 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) {
+ }
+ }